-
Notifications
You must be signed in to change notification settings - Fork 9
Add eraE file format #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lightclient
wants to merge
13
commits into
eth-clients:main
Choose a base branch
from
lightclient:add-erae-spec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b18391f
add eraE file format
lightclient a528162
fix link
lightclient a4c5203
update readme
lightclient 71748fd
change types to avoid clashing, use little endian notation
lightclient 6887fc2
add type definitions
lightclient 621a312
erae: use CompressedSlipReceipts consistently
lightclient adb2c95
erae: fixup byte repr
lightclient 4ea75b9
erae: define proof-type correctly
lightclient b85f1a2
erae: fix link typo
lightclient ec98c2b
erae: fix typo
lightclient 6eca09e
add erae types to readme, fix typo
lightclient 8667a3c
add slim receipts to list of potentially optional components
lightclient 8b0e864
rename eraE to ere
lightclient File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||
| # EraE files | ||||||
|
|
||||||
| EraE files are themselves e2store files. For more information on this format, | ||||||
| see https://github.com/status-im/nimbus-eth2/blob/stable/docs/e2store.md. | ||||||
|
|
||||||
| The format is designed to be compatible for both pre-merge execution layer data | ||||||
| and post-merge. It is intended to be a companion to the Era format. | ||||||
|
|
||||||
| ## Specification | ||||||
|
|
||||||
| The format can be summarized with the following expression: | ||||||
|
|
||||||
| eraE := Version | CompressedHeader+ | CompressedBody+ | CompressedSlimReceipts+ | Proofs+ | TotalDifficulty* | other-entries* | Accumulator? | BlockIndex | ||||||
|
|
||||||
| Each basic element is its own e2store entry: | ||||||
|
|
||||||
| Version = { type: [0x65, 0x32], data: nil } | ||||||
| CompressedHeader = { type: [0x03, 0x00], data: snappyFramed(rlp(header)) } | ||||||
| CompressedBody = { type: [0x04, 0x00], data: snappyFramed(rlp(body)) } | ||||||
| CompressedSlimReceipts = { type: [0x0a, 0x00], data: snappyFramed(rlp([tx-type, post-state-or-status, cumulative-gas, logs])) } | ||||||
| TotalDifficulty = { type: [0x06, 0x00], data: uint256(header.total_difficulty) } | ||||||
| Proof = { type: [0x0b, 0x00], data: snappyFramed(rlp([proof-type, ssz(BlockProofHistoricalHashesAccumulator) | ssz(BlockProofHistoricalRoots) | ssz(BlockProofHistoricalSummariesCapella) | ssz(BlockProofHistoricalSummariesDeneb)]))} | ||||||
| AccumulatorRoot = { type: [0x07, 0x00], data: hash_tree_root(List(HeaderRecord, 8192)) } | ||||||
| Index = { type: [0x66, 0x32], data: index } | ||||||
|
|
||||||
| A few notes on individual elements: | ||||||
|
|
||||||
| - `CompressedSlimReceipts` is optional and a different format than the consensus EIP-2718 format to optimize internal use in clients. | ||||||
| - `Proof` is a *highly recommended* component that provides the coresponding proof for each `CompressedHeader` in the file corresponding to the Portal Network proofs specification[^1]. It's possible to have multiple proof types in the same file at fork boundaries. | ||||||
| - `TotalDifficulty` is optional and little-endian encoded. | ||||||
| - `AccumulatorRoot` is optional and only defined for epochs with pre-merge data. | ||||||
| - `HeaderRecord` is defined in the Portal Network specification[^2]. | ||||||
| - `other-entries` is a placeholder for other potential objects to be added to EraE. | ||||||
|
|
||||||
| `BlockIndex` stores relative offsets to the components of each block entry. This allows `O(1)` access to all components of a block. The format is: | ||||||
|
|
||||||
| block-index := starting-number | indexes | indexes | indexes ... | component-count | count | ||||||
|
|
||||||
| Where `indexes` represents the index of each block component: | ||||||
|
|
||||||
| indexes := header-index | body-index | receipts-index | difficulty-index? | proof-index? | ||||||
|
|
||||||
| The value `component-count` is the number of indexes stored by `indexes`. It should be in the range of 3-5, depending on whether `TotalyDifficulty` and `Proofs` are present | ||||||
|
lightclient marked this conversation as resolved.
Outdated
lightclient marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo:
Suggested change
|
||||||
|
|
||||||
| All values in the block index are little-endian `uint64`. | ||||||
|
|
||||||
| `starting-number` is the first block number in the archive. Every index is a defined relative to index's location in the file. The total number of block entries in the file is recorded in count. | ||||||
|
|
||||||
| Due to the accumulator size limit of 8192, the maximum number of blocks in an Era batch is also 8192. This is also the value of `SLOTS_PER_HISTORICAL_ROOT`[^3] on the Beacon chain, so it is nice to align on the value. | ||||||
|
|
||||||
| ### Merge transition | ||||||
|
|
||||||
| There are some small differences between pre-merge and post-merge `eraE` files: | ||||||
| - `TotalDifficulty` should only be encoded for `eraE` files pre-merge. For the epoch where the merge occurs, fill all remaining post-merge blocks with the final total difficulty of the chain. | ||||||
| - `AccumulatorRoot` should only be encoded for `eraE` files pre-merge. For the epoch where the merge occurs, compute the root for an incomplete epoch where only pre-merge blocks are recorded in the accumulator. | ||||||
|
|
||||||
| ### Proof type | ||||||
|
|
||||||
| The `proof-type` value maps to an associated proof object. It's used to disambiguate the raw SSZ data inside RLP objects. | ||||||
|
|
||||||
| | Type | Proof object | | ||||||
| |---|---| | ||||||
| | 0 | BlockProofHistoricalHashesAccumulator | | ||||||
| | 1 | BlockProofHistoricalRoots | | ||||||
| | 2 | BlockProofHistoricalSummariesCapella | | ||||||
| | 3 | BlockProofHistoricalSummariesDeneb | | ||||||
|
|
||||||
| [^1]: https://github.com/ethereum/portal-network-specs/blob/master/legacy/history/history-network.md#block-header | ||||||
| [^2]: https://github.com/ethereum/portal-network-specs/blob/master/legacy/hisotry/history-network.md#the-historical-hashes-accumulator | ||||||
|
lightclient marked this conversation as resolved.
Outdated
|
||||||
| [^3]: https://github.com/ethereum/consensus-specs/blob/44ae6e661d9beac383f4a1f33be74259bae93c85/presets/mainnet/phase0.yaml#L42 | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # CompressedSlimReceipts | ||
|
|
||
| ``` | ||
| type: [0x0a, 0x00] | ||
| data: snappyFramed(rlp(receipts)) | ||
| ``` | ||
|
|
||
| `CompressedSlimReceipts` entries contain snappy compressed rlp execution receipts, without bloom filters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Proof | ||
|
|
||
| ``` | ||
| type: [0x0b, 0x00] | ||
| data: snappyFramed(rlp([proof-type, ssz(BlockProofHistoricalHashesAccumulator) | ssz(BlockProofHistoricalRoots) | ssz(BlockProofHistoricalSummaries)])) | ||
| ``` | ||
|
|
||
| `Proof` entries contain a compressed RLP object with a proof type indicator and | ||
| specific proof format that can attest to the validity of the EraE file. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.