Skip to content

Commit bf44b35

Browse files
proposal: NeoFS block storage format
Signed-off-by: Ekaterina Pavlova <[email protected]>
1 parent f329e87 commit bf44b35

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

neofs-blocks.mediawiki

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<pre>
2+
NEP: TBD
3+
Title: NeoFS block storage format
4+
Author: Ekaterina Pavlova <[email protected]>
5+
Type: Standard
6+
Status: Draft
7+
Created: 2025-04-07
8+
</pre>
9+
10+
==Abstract==
11+
12+
This proposal outlines the specification for storing Neo blockchain blocks within
13+
the NeoFS container.
14+
15+
==Motivation==
16+
17+
Neo node synchronization via P2P requires all headers and blocks (~700 bytes each, over 1 GB per year with
18+
15-second blocks) to remain available, limiting scalability as chains grow. Storing blocks in NeoFS
19+
provides a distributed alternative, reducing local storage, enabling on-demand fetches and allowing to drop
20+
blocks and headers from storage for most nodes.
21+
22+
==Specification==
23+
24+
===Block Storage Schema===
25+
A single NeoFS container is used to store blocks per network. Each container includes a fixed metadata
26+
attribute named Magic whose value is the network’s magic number in decimal representation. Each block object
27+
is serialized following standard Neo block serialization rules and stored as a separate NeoFS object with a
28+
unique OID with the following fixed metadata attributes:
29+
30+
{| class="wikitable"
31+
! Attribute name !! Attribute value
32+
|-
33+
| Block || String representation of the block index in base 10.
34+
|-
35+
| Hash || Hexadecimal string of the block’s hash.
36+
|-
37+
| PrevHash || Hexadecimal string of the previous block’s hash.
38+
|-
39+
| BlockTime || Millisecond-precision timestamp when the block was created.
40+
|-
41+
| Timestamp || Second-precision timestamp when the block was uploaded.
42+
|}
43+
44+
These attributes are stored as NeoFS object metadata; the list of attributes MAY be extended.
45+
Multibyte data items are always stored in little-endian order, where the least significant
46+
bytes come first. The object consists of block serialized following the standard Neo block
47+
serialization format. The object MAY include additional data after the block.
48+
49+
An example of a block object is as follows:
50+
<pre>
51+
ID: Fu7yQzspvLJwSGJNK64xeeyMdWXtU5B5b1es6KSxUag1
52+
CID: 3RCdP3ZubyKyo8qFeo7EJPryidTZaGCMdUjqFJaaEKBV
53+
Owner: NVvY1FF67XJ2GTVhy9FqiZGC4jEQtvjmHt
54+
CreatedAt: 28202
55+
Size: 697
56+
HomoHash: 45c98e627910d9b915d58368493789ce49ca194626f16ea5bf6b57bb2cce462921a1d3faf682d252a804b0555ca48905286222ee9209b3ff1ce4677a082ffd4d
57+
Checksum: fa6cedddfec3a61157c4a12e25f81e85c0f92aac70317d6df7fe193f983b4917
58+
Type: REGULAR
59+
Attributes:
60+
Block=1
61+
Primary=0
62+
Hash=5f3fbb43d1e516fe07771e2e873ebc9e2810662401acf603a775aace486220bd
63+
PrevHash=1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15
64+
BlockTime=1627894840919
65+
Timestamp=1734362616 (2024-12-16 18:23:36 +0300 MSK)
66+
ID signature:
67+
public key: 02a4920745d86db224c179c936606dc0e4620edad13d568ef036da279352e45f2b
68+
signature: 0443ff20d15952759b5101a7d223d70eb992260fd9ad5aecb404a97448b2ea54bd1ad783b12ccddba0097dd6608b55ccac9215c5715f9589ec6a555542ead6dc00
69+
[Block Binary Data]
70+
</pre>
71+
72+
===Synchronization Algorithm===
73+
Blocks stored in NeoFS and those synchronized via P2P both use the standard Neo block
74+
serialization format, ensuring compatibility across different synchronization methods.
75+
The NeoFS container serves as verified storage for downloading blocks. Blocks should be
76+
searched one by one directly by block attribute.
77+
78+
Downloaded blocks are inserted into the blockchain using the same logic as in the
79+
P2P synchronization protocol.
80+
81+
==Rationale==
82+
Storing each block as a self-contained NeoFS object moves historical data off full nodes
83+
while preserving byte-exact compatibility with the P2P format. Standard metadata makes
84+
blocks easily discoverable without custom indices, and NeoFS gives durability and fast
85+
parallel fetches. The scheme is already validated in NeoGo experiments (e.g., nspcc-dev/neo-go#3496).
86+
87+
== References ==
88+
* [https://github.com/neo-project/neo/issues/3463 Using NeoFS to store blocks and snapshots]
89+
* [https://github.com/neo-project/neo/issues/2373 P2P state exchange]
90+
* [https://github.com/neo-project/neo/issues/1526 StateRoot in block header]
91+
* [https://github.com/nspcc-dev/neo-go/issues/3496 Implement NeoFS block fetcher]
92+
93+
== Implementation ==
94+
* Go: https://github.com/nspcc-dev/neo-go/blob/61992405983ddfb5547ae3afab75c22186dc966f/cli/util/uploader.go
95+
* Go: https://github.com/nspcc-dev/neo-go/blob/a10fa2f0fdcb453363ba84d04d27bb2353de4156/pkg/services/blockfetcher/blockfetcher.go

0 commit comments

Comments
 (0)