[F-2026-17745] Derived transactions share a constant txIndex value#18
Merged
Merged
Conversation
…nintended state persistence
…ived EVM execution
…or derived transaction lookups
…ounter for derived EVM executions
…d uniqueness test (F-2026-17745)
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.
Description
[F-2026-17745] Derived transactions share a constant txIndex value
Issue
Every derived EVM execution in
DerivedEVMCallWithDataemitted a hardcoded compile-time constantDerivedTxIndex = 9999as its transaction index attribute, regardless of its actual position in the block's EVM message sequence.File:
x/vm/keeper/call_evm.goFile:
x/vm/types/events.goHow standard Eth txs handle indexing
The keeper maintains a transient (per-block, in-memory) counter
TxIndexTransient. For each standardMsgEthereumTx:msg_server.goreads the current counter viaGetTxIndexTransientstate_transition.goincrements the counter viaSetTxIndexTransientDerived txs never read or incremented this counter. They emitted 9999 and left the counter untouched.
Impact
In a block containing multiple derived transactions or a mix of standard and derived messages:
Three consequences:
eth_getTransactionByBlockNumberAndIndexfails — multiple derived txs share the same index; the endpoint cannot distinguish or resolve them individually.AttributeKeyTxIndex(block explorers, the KV indexer, tracing tools) sees duplicate 9999 values and cannot order, deduplicate, or resolve derived txs correctly.Solution
Wire derived transactions into the same
TxIndexTransientcounter that standard Eth txs use.In
DerivedEVMCallWithData, within theif commitblock:txConfigis already constructed viak.TxConfig(ctx, tx.Hash())which readsGetTxIndexTransientfor itsTxIndexfield — sotxConfig.TxIndexalready holds the correct sequential value.txConfig.TxIndexinstead of the hardcodedtypes.DerivedTxIndex.SetTxIndexTransient(ctx, txConfig.TxIndex+1)to advance the counter.The counter increment is placed inside
if commitbut outsideif !res.Failed()— failed derived txs still consume an index slot, matching Ethereum's behavior where even reverted transactions occupy a position in the block.Behavior after fix
Sequential, unique, globally ordered — reflecting actual execution order within the block.
DerivedTxType = 99is retained as a marker to identify derived txs even when they carry a real sequential index.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranch