Skip to content

kona: defer invalid span-batch tx types to the typed decoder#21850

Open
sebastianst wants to merge 2 commits into
codex/pr-21795-prefix-preservationfrom
seb/kona-defer-invalid-tx-types
Open

kona: defer invalid span-batch tx types to the typed decoder#21850
sebastianst wants to merge 2 commits into
codex/pr-21795-prefix-preservationfrom
seb/kona-defer-invalid-tx-types

Conversation

@sebastianst

@sebastianst sebastianst commented Jul 16, 2026

Copy link
Copy Markdown
Member

Stacks on #21808 (base = codex/pr-21795-prefix-preservation). Two commits.

1. Defer invalid tx types to the typed decoder

Resolves the one inconsistency left in #21808: a leading 0x00 was preserved and deferred to the typed decoder, while Deposit (0x7E) was still rejected inline in read_tx_data.

This defers Deposit too. Now every representable type that isn't a valid span-batch envelope — Legacy (0x00) and Deposit — is kept and rejected in one place, SpanBatchTransactionData::decode/decode_typed, downstream in full_txs, mirroring op-node's ReadTxDatadecodeTyped deferral. The only remaining inline rejection is for a byte that maps to no OpTxType at all (0x03, 0x7F, …), which can't be represented in the returned type — a type-forced boundary, not a special case.

One-line production change (drop Ok(OpTxType::Deposit) from the reader's reject arm). Kept the OpTxType return rather than switching to a raw u8: fully deferring unknown bytes too would have required the u8 return + a Vec<u8> tx_types field, adding churn across decode_tx_data/add_txs for no consensus gain (unknown bytes are dropped either way). Adds a deferred-Deposit and an inline-rejected unknown-byte test, and corrects the EIP2718_MAX_TX_TYPE wording about which high bytes fail where.

2. Move read_tx_data into the batch module

read_tx_data was in the general utils module but is span-batch-specific — it size-bounds against MAX_SPAN_BATCH_ELEMENTS, returns SpanBatchError, and has a single caller in decode_tx_data. Relocate it (with its EIP2718_MAX_TX_TYPE const and tests) into batch/transactions.rs, make it private, and drop the crate re-export (no cross-crate users). Adds a doc comment describing its narrow responsibility (split element → optional type prefix + RLP payload, RLP-structure validation only) and noting it does not yet discard invalid tx types — those are rejected downstream by the typed decoder in full_txs. No behavior change.


Consensus-equivalence verified for #1: for any first byte 0x00..=0xFF, kona and op-node accept/reject the same and drop the same batches; legacy_tx_count/protected_bits sizing is unchanged. kona-protocol suite green (231); fmt, clippy, and cargo doc -D warnings all clean.

Draft — for review.

🤖 Generated by Claude Opus 4.8 (1M context)

sebastianst and others added 2 commits July 16, 2026 15:30
Builds on the prefix-preservation fix. read_tx_data no longer rejects Deposit
(0x7E) inline: like a leading 0x00, a physically-present Deposit prefix is kept
and rejected once by the typed decoder (SpanBatchTransactionData::decode)
downstream, matching op-node's ReadTxData -> decodeTyped deferral. Only a byte
that maps to no OpTxType at all is still rejected at the reader, since it cannot
be represented in the returned type.

This removes the inconsistency where a leading 0x00 was preserved-and-deferred
while Deposit was rejected inline; both are now handled the same way. Adds tests
for the deferred Deposit and the inline-rejected unknown bytes, and corrects the
EIP2718_MAX_TX_TYPE doc/test wording about which high bytes fail where.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
read_tx_data is span-batch-specific — it size-bounds against
MAX_SPAN_BATCH_ELEMENTS and returns SpanBatchError — with a single caller in
decode_tx_data, so it doesn't belong in the general utils module. Relocate it
(with its EIP2718_MAX_TX_TYPE const and tests) into batch/transactions.rs, make
it private, and drop the crate re-export.

Add a doc comment describing its narrow responsibility — split an element into
its optional type prefix and RLP payload, validating only RLP structure — and
noting it does not yet discard invalid transaction types, which are rejected
downstream by the typed decoder in full_txs.

No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sebastianst
sebastianst marked this pull request as ready for review July 17, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant