Skip to content

Comments

feat: Implement EIP-7708 ETH transfers emit a log#3334

Merged
rakita merged 3 commits intomainfrom
transfer-log
Jan 20, 2026
Merged

feat: Implement EIP-7708 ETH transfers emit a log#3334
rakita merged 3 commits intomainfrom
transfer-log

Conversation

@rakita
Copy link
Member

@rakita rakita commented Jan 20, 2026

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 address 0xfffffffffffffffffffffffffffffffffffffffe
    • ETH_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):

    • Added eip7708_transfer_log() - emits LOG3 for ETH transfers
    • Added eip7708_selfdestruct_to_self_log() - emits LOG2 for selfdestruct-to-self
    • Integrated log emission in transfer_loaded(), create_account_checkpoint(), and selfdestruct()
  • Log emission rules:

    • Only emitted when Amsterdam hardfork is enabled
    • Only emitted for non-zero value transfers
    • Transfer log (LOG3) for CALL/CREATE/SELFDESTRUCT to different address
    • SelfBalanceLog (LOG2) for SELFDESTRUCT to self when balance is burned

Tests

Added 7 comprehensive tests in crates/ee-tests/src/revm_tests.rs:

  • test_eip7708_transfer_log_tx_value - transaction value transfer
  • test_eip7708_no_log_for_zero_value - no log for zero value
  • test_eip7708_no_log_before_amsterdam - no log before Amsterdam
  • test_eip7708_selfdestruct_to_different_address - SELFDESTRUCT transfer
  • test_eip7708_selfdestruct_to_self - selfdestruct-to-self log
  • test_eip7708_call_with_value - CALL opcode with value
  • test_eip7708_create_with_value - CREATE opcode with value

Test plan

  • All 7 new EIP-7708 tests pass
  • All existing ee-tests pass (38 total)
  • Clippy passes with no new warnings
  • cargo check passes for all affected crates

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-hq
Copy link

codspeed-hq bot commented Jan 20, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing transfer-log (1936b4f) with main (63ad58e)

Summary

✅ 173 untouched benchmarks

@rakita
Copy link
Member Author

rakita commented Jan 20, 2026

Pretty safe to merge as logs are behind the fork

@rakita rakita merged commit 76c4a8e into main Jan 20, 2026
30 checks passed
@github-actions github-actions bot mentioned this pull request Jan 20, 2026
@rakita rakita deleted the transfer-log branch February 16, 2026 10:10
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