|
| 1 | +<pre> |
| 2 | + NEP: TBD |
| 3 | + Title: NeoFS block storage format |
| 4 | + Author: Ekaterina Pavlova < [email protected]> |
| 5 | + Type: Informational |
| 6 | + Status: Draft |
| 7 | + Created: 2025-04-07 |
| 8 | +</pre> |
| 9 | + |
| 10 | +==Abstract== |
| 11 | + |
| 12 | +This proposal outlines the methodology and specifications for storing Neo blockchain blocks within |
| 13 | +the NeoFS container. |
| 14 | + |
| 15 | +==Motivation== |
| 16 | + |
| 17 | +Neo node synchronization via P2P requires all block headers (~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 speeding |
| 20 | +up sync with snapshots or checkpoints. This proposal defines a NeoFS storage schema, building on |
| 21 | +experiments (e.g., nspcc-dev/neo-go#3496) and future enhancements (#1526). |
| 22 | + |
| 23 | +==Specification== |
| 24 | + |
| 25 | +===Block Storage Schema=== |
| 26 | +A single NeoFS container is used to store blocks. Each container |
| 27 | +has network magic attribute (`Magic:56753`). Each block is stored in a binary |
| 28 | +form as a separate object with a unique OID and a set of attributes: |
| 29 | + - block object identifier with block index value (`Block:1`) |
| 30 | + - primary node index (`Primary:0`) |
| 31 | + - block hash in the LE form (`Hash:5412a781caf278c0736556c0e544c7cfdbb6e3c62ae221ef53646be89364566b`) |
| 32 | + - previous block hash in the LE form (`PrevHash:3654a054d82a8178c7dfacecc2c57282e23468a42ee407f14506368afe22d929`) |
| 33 | + - millisecond-precision block creation timestamp (`BlockTime:1627894840919`) |
| 34 | + - second-precision block uploading timestamp (`Timestamp:1627894840`) |
| 35 | + |
| 36 | +These attributes are stored as NeoFS object metadata alongside the binary block data. |
| 37 | +Multibyte data items are always stored in little-endian order, where the low bytes come first. |
| 38 | +Its structure is described further below. |
| 39 | + |
| 40 | +<pre> |
| 41 | +block_binary |
| 42 | +{ |
| 43 | + var-byte header; // Fixed-size header including witnesses |
| 44 | + var-byte txcount; // Transaction count |
| 45 | + var-byte transactions[]; // Array of serialized transactions |
| 46 | +} |
| 47 | +</pre> |
| 48 | + |
| 49 | +== References == |
| 50 | +* [https://github.com/neo-project/neo/issues/3463 Neo Issue#3463] |
| 51 | +* [https://github.com/neo-project/neo/issues/2373 Neo Issue#2373] |
| 52 | +* [https://github.com/neo-project/neo/issues/1526 Neo Issue#1526] |
| 53 | +* [https://github.com/nspcc-dev/neo-go/issues/3496 NeoGo Issue#3496] |
| 54 | +* [https://github.com/nspcc-dev/neofs-api/issues/285 NeoFS API Issue#285] |
| 55 | +
|
| 56 | + |
| 57 | +== Implementation == |
| 58 | +* Go: https://github.com/nspcc-dev/neo-go/blob/61992405983ddfb5547ae3afab75c22186dc966f/cli/util/uploader.go |
0 commit comments