Repository navigation
Chain layer - #27
Merged
Merged
Chain layer#27
Conversation
A span cannot be a struct field, so the decoder holds only positions and reads the input from a `MemSpan` effect. `list` is a projection: when the list cursor's last use passes, a failure in it, or an item left unread, fails the parent.
`Config.blob_schedule` holds a fork's target and maximum blobs and its blob base fee update fraction, in place of `max_blobs_per_block`. The driver's wire format still carries the maximum.
`decode_transaction` takes a transaction as a block carries it and gives its `TxRequest`, with the sender recovered, and its hash. A gas limit past 64 bits is malformed, where the specification reads it and rejects it as over the cap.
A header with only one of Amsterdam's two fields still decodes, telling them apart by shape, so validation can say which is missing or unexpected.
The trie hashes nodes in place: it reads a node back with `since` and replaces it with its hash after `truncate`. `raw` puts an item already encoded, such as a transaction from a block; `words` puts a logs bloom.
`Trie` takes an ordered list's items, keyed by their index's RLP, and `state_root` the world's accounts and slots under their keccak256 keys. The root sorts the leaves and hashes sorted ranges recursively, without storing a trie: one leaf is a leaf node, a prefix all the keys share an extension, and otherwise the next nibble splits the range into a branch.
The driver takes each test's fork schedule, chain ID, pre-state, genesis and block RLP, checks the genesis state root and imports through Chain. The tool checks each block's validity and that fevm's reason is one the fixture's expectException names, then lastblockhash and postState. Every network fevm supports runs by default; results.json counts them in by_network.
EELS from Amsterdam checks the chain ID first, then the transaction's own fields (nonce limit, initcode size, gas cap, priority fee, blobs, creation, authorizations) and its intrinsic gas before the block's gas. fevm used Osaka's order for both forks, so a legacy transaction with a wrong chain ID and too little gas was named intrinsic_gas, failing test_legacy_chain_id_over_64_bits[case_largest_64_bit_chain_id]. Rules::FIELDS_FIRST places each rule at its fork's position.
import decodes and validates the block and restores or advances the chain; execute runs it; mismatch compares its output and roots with the header. Lines wrap at 120 columns.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Adds a chain layer over
Block: blocks are imported from their RLP, as a client does.ingots/rlp(fevm_rlp): theEncodermoved out offevm, and a strict decoder. The decoder reads its input from aMemSpaneffect, andlist()is a projection, so a sub-list that failed or has items left fails its parent.ingots/chain(fevm_chain):decode_transaction: types 0 to 4, with the sender recovered and the transaction hash.Header: decoding, validation against the parent (base fee, excess blob gas with EIP-7918, gas limit bounds, the post-merge fields, the fields each fork has), and the block'sBlockEnv.Schedule: forks by activation timestamp.Config.blob_schedule(target, max, update fraction) replacesmax_blobs_per_block.Triefor the transactions, receipts and withdrawals roots,state_root(world), andencode_receipt.Chain::importfollowsexecute_block: EIP-7934's size limit, header validation, execution throughBlock, then gas used, the four roots, logs bloom, blob gas used, requests hash and access list hash against the header. It givesValid,Invalidwith the first rule broken, orFailedfor a host failure. One head, no side branches.Chain: nothing decoded comes from the fixture, and every block is judged. The tool checks that a rejection's reason is one the fixture names, andlastblockhash. CI also runs the BPO1, BPO2 and fork-transition fixture sets.Notes for review:
verdictchecked Amsterdam transactions in Osaka's order, so a transaction breaking two rules could get the wrong validity code. Each fork now checks in its own order (Rules::FIELDS_FIRST).decode_transactionaccepts it, which makes block bodies malleable.