feat: track EXTCODEHASH, EXTCODESIZE, EXTCODECOPY in UsedStateEVMInspector#913
Open
0xMars42 wants to merge 1 commit intoflashbots:developfrom
Open
feat: track EXTCODEHASH, EXTCODESIZE, EXTCODECOPY in UsedStateEVMInspector#9130xMars42 wants to merge 1 commit intoflashbots:developfrom
0xMars42 wants to merge 1 commit intoflashbots:developfrom
Conversation
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.
Summary
Closes #58
Tracks
EXTCODEHASH,EXTCODESIZE, andEXTCODECOPYopcodes inUsedStateEVMInspector, completing the coverage of state-reading opcodes started in #161.Without this, the parallel builder cannot detect conflicts between a transaction that reads a contract's code (e.g.
isContract()check viaEXTCODESIZE) and another that creates or destroys a contract at the same address (viaCREATE2/SELFDESTRUCT). These transactions could be placed in separate conflict groups and executed in the wrong order.Changes
evm_inspector.rsAddedread_code_addresses: HashSet<Address>toUsedStateTrace. The three opcodes are intercepted instep()by reading the target address fromstack[0]before execution, same pattern asBALANCE.groups.rsAddedcode_readstoGroupDataandgroup_code_readsindex toConflictFinder. Two new conflict checks:MevTest.solAddedtestReadCode(address)which executesextcodehashandextcodesizein inline assembly.Notes
read_slot_valuesandread_balances, code reads from reverted transactions are still recorded. This may produce false-positive conflicts (grouping transactions that don't actually conflict), but never false negatives. Safe by design.HashSet::insertper EXTCODE* opcode occurrence. Thestep()callback was already instrumented this adds a match arm, not a new callback.Known limitations
EXTCODECOPYshares the same interception logic as the other two (address atstack[0]) but has no dedicated Solidity test function. The three opcodes are handled in a single match arm.EXTCODEHASH(from0x00tokeccak256("")). Detecting this conflict would require crossingbalance_writeswithcode_reads, which adds complexity for a very rare edge case. Left as a future improvement.Tests
test_read_code: verifiesread_code_addressesis populated when callingtestReadCodeon both a contract (MevTest) and an empty address (Dummy)two_code_reads_no_conflict: two code reads on the same address don't conflictcode_read_and_creation_conflict: EXTCODEHASH + CREATE on same address = conflictcode_read_and_destruction_conflict: EXTCODEHASH + SELFDESTRUCT on same address = conflictcreation_then_code_read_conflict: CREATE first, then EXTCODEHASH = conflict (reverse direction)destruction_then_code_read_conflict: SELFDESTRUCT first, then EXTCODEHASH = conflict (reverse direction)I have completed the following steps:
make lintmake test