feat: Implement EIP-7708 ETH transfers emit a log#3334
Merged
Conversation
EIP-7708 specifies that all ETH transfers (transactions, CALL, CREATE, SELFDESTRUCT) emit a log, making ETH transfers trackable like ERC-20 tokens. Changes: - Add EIP-7708 constants in revm-primitives (ETH_TRANSFER_LOG_ADDRESS, ETH_TRANSFER_LOG_TOPIC, SELFDESTRUCT_TO_SELF_LOG_TOPIC) - Add eip7708_transfer_log() and eip7708_selfdestruct_to_self_log() helpers to JournalInner for emitting transfer logs - Emit LOG3 Transfer event for non-zero value transfers in: - transfer_loaded() (CALL with value) - create_account_checkpoint() (CREATE with value) - selfdestruct() (SELFDESTRUCT to different address) - Emit LOG2 SelfBalanceLog event for selfdestruct-to-self when balance is burned - Logs only emitted when EIP-7708 is enabled (Amsterdam hardfork) and value > 0 - Add 7 tests covering transfer, selfdestruct, and edge cases
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
Member
Author
|
Pretty safe to merge as logs are behind the fork |
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
Implements EIP-7708: ETH transfers emit a log.
This EIP specifies that all ETH transfers (transactions, CALL, CREATE, SELFDESTRUCT) emit a log, making ETH transfers trackable like ERC-20 tokens. This is particularly useful for smart contract wallets and exchanges that need to track native ETH transfers.
Changes
New constants in
revm-primitives(crates/primitives/src/eip7708.rs):ETH_TRANSFER_LOG_ADDRESS: System address0xfffffffffffffffffffffffffffffffffffffffeETH_TRANSFER_LOG_TOPIC: keccak256("Transfer(address,address,uint256)")SELFDESTRUCT_TO_SELF_LOG_TOPIC: keccak256("SelfBalanceLog(address,uint256)")Journal modifications (
crates/context/src/journal/inner.rs):eip7708_transfer_log()- emits LOG3 for ETH transferseip7708_selfdestruct_to_self_log()- emits LOG2 for selfdestruct-to-selftransfer_loaded(),create_account_checkpoint(), andselfdestruct()Log emission rules:
Tests
Added 7 comprehensive tests in
crates/ee-tests/src/revm_tests.rs:test_eip7708_transfer_log_tx_value- transaction value transfertest_eip7708_no_log_for_zero_value- no log for zero valuetest_eip7708_no_log_before_amsterdam- no log before Amsterdamtest_eip7708_selfdestruct_to_different_address- SELFDESTRUCT transfertest_eip7708_selfdestruct_to_self- selfdestruct-to-self logtest_eip7708_call_with_value- CALL opcode with valuetest_eip7708_create_with_value- CREATE opcode with valueTest plan
cargo checkpasses for all affected crates