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
The
types.Header
fields of bothcoreth
andsubnet-evm
have been modified such that their RLP encodings (i.e. block hashes) aren't compatible with vanillageth
nor each other. Supporting bothcoreth
andsubnet-evm
(let alone backwards compatibility) via "passive" modification of RLP (i.e. by modifying fields) is proving to be extremely difficult, if not impossible. This PR is the first step towards an active, and therefore controlled, approach.How this works
The (R)ecursive element of RLP allows it to be readily parsed into a tree, which is introduced as the
rlp.ParseTree([]byte) ItemNode
function. The only node types are the so-called "items" of byte arrays (also called "strings"), positive integers, and lists of other items. The parser is implemented inrlp/tree.libevm.go
, which should be reviewed first.The intent is that
libevm
-style extra payloads will have RLP hooks that manipulate trees after encoding (to add their own items and remove unused ones) and before decoding (to invert the encoding changes). A follow-up PR will add re-encoding of trees.How this was tested
Tree parsing is run against all existing RLP-encoding tests merely to ensure no errors. A more comprehensive set of fuzz tests builds trees and concrete values n parallel, ensuring that the former is recoverable via
rlp.ParseTree(rlp.EncodeToBytes([concrete values]))
. I originally tried to build trees directly from the upstream test inputs but there were so many edge cases that the test logic was no longer reliable.A fuzzed
types.Header
is also parsed, resulting in an RLP "list". As this is the first step in sensitive changes to header encoding, a change-detector test is introduced to lock in backwards compatibility even though no changes are made yet.