Remove Block RLP hooks - #304
Merged
Merged
Conversation
StephenButtolph
commented
Aug 6, 2026
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates block/body RLP encoding to route extras through Body hooks (removing the block-specific proxy), and adds a fast path to combine RLP-encoded header/body into block bytes.
Changes:
- Replace
BlockRLPProxy-based block encoding/decoding withBodyhook-driven field assembly. - Introduce
BlockBytes(headerBytes, bodyBytes)fast-path and add fuzz/bench coverage for equivalence/performance. - Update tests and temporary extras to use
Bodyhooks and payload access patterns.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| core/types/tempextras.libevm_test.go | Updates temporary extras test to set/get body extras via extras.Body and BodyRLPFieldsForEncoding. |
| core/types/rlp_payload.libevm.go | Adds (*Block).extraOrNil() helper to avoid allocating extras when unregistered. |
| core/types/block.libevm_test.go | Adds body-extra roundtrip test plus fuzz/bench coverage for the new BlockBytes constructor. |
| core/types/block.libevm.go | Reworks block RLP encoding/decoding to use Body hook fields; adds BlockBytes. |
| core/types/block.go | Replaces extblock.hooks with extblock.extra and wires encode/decode through extraOrNil(). |
| core/types/backwards_compat.libevm_test.go | Removes now-obsolete BlockRLP* hook methods from compat extras test type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ARR4N
reviewed
Aug 7, 2026
StephenButtolph
commented
Aug 7, 2026
ARR4N
reviewed
Aug 10, 2026
ARR4N
reviewed
Aug 10, 2026
ARR4N
reviewed
Aug 10, 2026
ARR4N
approved these changes
Aug 10, 2026
ARR4N
left a comment
Collaborator
There was a problem hiding this comment.
No need for me to re-review after suggestions.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why this should be merged
While I do think it's nice to reduce the number of required hooks to implement. The primary point of this PR is introducing an efficient
types.BlockBytesfunction that efficiently combines header bytes and body bytes into block bytes.Technically, this
BlockBytesfunction doesn't need to live in libevm (I could implement it in SAE) - but I think that it makes sense to solidify the hook implementations against a concrete requirement.benchstat: referenceBlockBytes (reencode.txt) vs BlockBytes (blockbytes.txt)
Block reencoding showed up as a significant performance bottleneck while serving blocks. Reencoding currently happens when calling
rawdb.ReadBlock. By implementing this change the GetAncestors optimization observes:benchstat: GetAncestors optimization in avalanchego before & after this change
How this works
While the goal of this PR was adding
BlockBytes- most of the effort fell to removingBlockRLPFieldsForEncodingandBlockRLPFieldPointersForDecoding.These functions needed to be removed because they allowed a hook provider to break the
Header+Body=Blockassumption. There was nothing stopping someone from re-ordering body fields when they were serialized just as a body vs when they were serialized as part of a block.This PR re-uses
BodyRLPFieldsForEncodingandBodyRLPFieldPointersForDecodingso that we are guaranteed that the body bytes follow the same order as the block bytes.How this was tested
BlockBytes