-
Notifications
You must be signed in to change notification settings - Fork 87
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
Proposal for block header lookup via block number in the history network #334
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ The chain history network is a [Kademlia](https://pdos.csail.mit.edu/~petar/pape | |
|
||
Execution chain history data consists of historical block headers, block bodies (transactions, ommers and withdrawals) and block receipts. | ||
|
||
In addition, the chain history network provides individual epoch records for the full range of pre-merge blocks mined before the transition to proof of stake. | ||
In addition, the chain history network provides block number to historical block header lookups | ||
|
||
### Data | ||
|
||
|
@@ -20,19 +20,16 @@ In addition, the chain history network provides individual epoch records for the | |
- Ommers | ||
- Withdrawals | ||
- Receipts | ||
- Header epoch records (pre-merge only) | ||
|
||
#### Retrieval | ||
|
||
The network supports the following mechanisms for data retrieval: | ||
|
||
- Block header by block header hash | ||
- Block header by block number | ||
- Block body by block header hash | ||
- Block receipts by block header hash | ||
- Header epoch record by epoch record hash | ||
|
||
> The presence of the pre-merge header records provides an indirect way to lookup blocks by their number, but is restricted to pre-merge blocks. Retrieval of blocks by their number for post-merge blocks is not intrinsically supported within this network. | ||
> | ||
> This sub-protocol does **not** support retrieval of transactions by hash, only the full set of transactions for a given block. See the "Canonical Transaction Index" sub-protocol of the Portal Network for more information on how the portal network implements lookup of transactions by their individual hashes. | ||
|
||
## Specification | ||
|
@@ -168,23 +165,40 @@ BlockHeaderWithProof = Container( | |
) | ||
``` | ||
|
||
> **_Note:_** The `BlockHeaderProof` allows to provide headers without a proof (`None`). | ||
For pre-merge headers, clients SHOULD NOT accept headers without a proof | ||
as there is the `HistoricalHashesAccumulatorProof` solution available. | ||
For post-merge headers, there is currently no proof solution and clients MAY | ||
accept headers without a proof. | ||
|
||
##### Block Header by Hash | ||
|
||
```python | ||
# Content and content key | ||
|
||
block_header_key = Container(block_hash: Bytes32) | ||
selector = 0x00 | ||
|
||
block_header_with_proof = BlockHeaderWithProof(header: rlp.encode(header)), proof: proof) | ||
block_header_with_proof = BlockHeaderWithProof(header: rlp.encode(header), proof: proof) | ||
|
||
content = SSZ.serialize(block_header_with_proof) | ||
content_key = selector + SSZ.serialize(block_header_key) | ||
``` | ||
|
||
> **_Note:_** The `BlockHeaderProof` allows to provide headers without a proof (`None`). | ||
For pre-merge headers, clients SHOULD NOT accept headers without a proof | ||
as there is the `HistoricalHashesAccumulatorProof` solution available. | ||
For post-merge headers, there is currently no proof solution and clients MAY | ||
accept headers without a proof. | ||
##### Block Header by Number | ||
|
||
|
||
```python | ||
# Content and content key | ||
|
||
block_number_key = Container(block_number: uint64) | ||
selector = 0x04 | ||
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. What's the reasoning not to reuse the 0x03 value of Epoch Records? Avoiding some clashing of older versions that still decode this differently and it being more clear when something sends the old 0x03 data? 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.
Initially
I am fine reusing it, I wasn't sure if that was ok, I will update it now 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. I'm not sure myself / have no strong preference. With no reuse the transition period can be somewhat more clean in terms of error logs, and there are enough numbers available. 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. I'm inclined towards re-using rather than leaving a gap. Not a strong feeling. |
||
|
||
block_header_with_proof = BlockHeaderWithProof(header: rlp.encode(header), proof: proof) | ||
|
||
content = SSZ.serialize(block_header_with_proof) | ||
content_key = selector + SSZ.serialize(block_number_key) | ||
``` | ||
|
||
#### Block Body | ||
|
||
|
@@ -261,17 +275,6 @@ content_key = selector + SSZ.serialize(receipt_key) | |
|
||
Note: The type-specific receipts encoding might be different for future receipt types, but this content encoding is agnostic to the underlying receipt encodings. | ||
|
||
#### Epoch Record | ||
|
||
```python | ||
epoch_record_key = Container(epoch_hash: Bytes32) | ||
selector = 0x03 | ||
epoch_hash = hash_tree_root(epoch_record) | ||
|
||
content = SSZ.serialize(epoch_record) | ||
content_key = selector + SSZ.serialize(epoch_record_key) | ||
``` | ||
|
||
### Algorithms | ||
|
||
#### The "Historical Hashes Accumulator" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick period at end of sentence