Skip to content

Document EIP-7708 ETH transfer logs and add helpers to identify them - #309

Merged
alisinabh merged 4 commits into
mainfrom
feat/glamsterdam-readiness
Nov 16, 2026
Merged

alisinabh merged 4 commits into
mainfrom
feat/glamsterdam-readiness

Conversation

@alisinabh

Copy link
Copy Markdown
Member

Prepares the library for the Glamsterdam network upgrade (live on Sepolia since 2026-10-06; no mainnet date yet).

Changes

  • Add Ethers.Event.system_address/0 and Ethers.Event.eth_transfer_log?/1 to identify EIP-7708 ETH transfer logs. These logs are emitted by SYSTEM_ADDRESS (0xfffffffffffffffffffffffffffffffffffffffe) with the ERC-20 Transfer(address,address,uint256) topics and data, so Transfer filters decode them as token transfers. The predicate checks both the emitter and topics[0], case-insensitively. Ethers.get_logs/2 behaviour is unchanged (no automatic filtering).
  • Warn about these logs on Ethers.get_logs/2, Ethers.EventFilter, Ethers.CombinedEventFilter, Ethers.Event, the README, and in the generated docs of any event filter with the Transfer(address,address,uint256) signature (user contracts and the built-in ERC20/ERC777/ERC721).
  • Unit tests decode a hand-made EIP-7708 RPC log with Ethers.Event.decode/2 and Ethers.CombinedEventFilter.decode_logs/2 (it decodes as Transfer, and the predicate separates it from a token transfer).

Also under EIP-7708, the transaction-level transfer log comes "before any other logs created by EVM execution". Value-bearing transactions to contracts will therefore see their event log_index values shift by one.

EIP status

The included EIPs (7708, 2780, 7976, 7981, 7954, 8037) are in Last Call, not Final. The meta EIP-7773 is in Review. EIP-8037 notes that some values "are not yet final", so the constants below should be re-checked once the EIPs are Final and mainnet is scheduled.

Where the EIP text differs from the issue:

  • EIP-2780 decomposes the flat 21,000 rather than removing it. A value transfer to an existing EOA "remains at the legacy 21,000". Other cases: self-transfer 12,000; zero-value transfer 15,000; transfer creating an account 21,000 + 183,600 state gas; contract creation 24,000 + 183,600 state gas.
  • Under EIP-2780 the EIP-7976 calldata floor (64 gas/byte) sits on the decomposed base instead of 21,000.
  • EIP-7981 quotes access-list costs of 2400/1900, but EIP-8038 raises them to 2,900/2,000.
  • EIP-7773's activation table still lists Hoodi (2026-10-26), while Foundry's hardfork library (alloy-hardforks) treats the Hoodi activation as cancelled.

Audit

Gas repricing (EIP-2780, 7976, 7981, 8037, 8038). The library hardcodes no intrinsic gas. The only 21_000 in lib is a Transaction.new/1 doctest example. Gas auto-fill is eth_estimateGas × margin, and nodes must apply the new rules in their estimates. I audited tests and docs for hardcoded gas values:

Location Hits the node? Result
test/ethers/state_override_test.exs:209 {:ok, 21_000} (1 ETH to an existing EOA) yes Holds: 12,000 + 3,000 + 6,000 = 21,000
test/ethers_test.exs:900 gas_used > 21_000 (createAccessList with an SSTORE) yes Holds: the calldata floor alone is 15,000 + 100 × 64 = 21,400
state_override_test.exs:203 override_gas > base_gas yes Relative comparison, holds
gas: 10_000 / 23_170 signing tests, gas: 100 :no_to_address tests no broadcast Harmless
Encode/decode/validation fixtures (0x5208, 21_000, ...), fee-estimation fake RPC, doc examples (transaction.ex, ethers.ex:878, guides/upgrading.md:227) no Harmless

No test changes are needed, and no live test sends with a hardcoded gas limit.

The default 10% gas margin remains adequate:

  • Plain transfers estimate exactly.
  • The margin covers small same-path drift. It never covered state flips (a storage slot or account going between zero and non-zero), and Glamsterdam enlarges those: a new slot costs 97,920 state gas + 10,000, a new account 183,600.

EIP-7954 (contract size). Nothing in the library enforces the old 24 KiB / 48 KiB limits.

Testing against Glamsterdam

anvil 1.9.0 (the CI version) supports Amsterdam as an opt-in --hardfork amsterdam; the default stays pre-Amsterdam. Verified from the Foundry v1.9.0 source:

  • The anvil config turns on the EIP-8037 and EIP-2780 gas rules for Amsterdam and later.
  • anvil's integration tests start Amsterdam nodes.
  • The bundled revm (43.0.3) emits EIP-7708 logs and implements EIP-7976, 7981, 8038, 7954 and 7928.

Not verified: running anvil 1.9.0 itself, the amsterdam CLI string at runtime, and this suite on an Amsterdam node.

Proposed follow-up (not part of this PR): add a hardfork matrix to the non-blocking canary workflow .github/workflows/latest-tools.yml, and move it to required CI once mainnet is scheduled:

    strategy:
      fail-fast: false
      matrix:
        hardfork: [default, amsterdam]
    # ...
      - name: Start Anvil (Background)
        run: anvil ${{ matrix.hardfork != 'default' && format('--hardfork {0}', matrix.hardfork) || '' }} &

Refs #291

🤖 Generated with Claude Code

https://claude.ai/code/session_012hqvX8DbbP3mgXy5hVEDc6

alisinabh and others added 3 commits November 15, 2026 18:13
Under EIP-7708 (Glamsterdam) every non-zero ETH transfer emits a
Transfer(address,address,uint256) log from SYSTEM_ADDRESS
(0xff...fe), which ERC-20 Transfer filters decode as a token transfer.

Ethers.Event.system_address/0 returns that emitter and
Ethers.Event.eth_transfer_log?/1 tells such events apart (emitter and
Transfer topic, case-insensitive). get_logs/2 is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012hqvX8DbbP3mgXy5hVEDc6
Without an address, a Transfer(address,address,uint256) filter (ERC-20,
ERC-777, or a combined filter including it) also returns native ETH
transfers on networks with EIP-7708 active. Warn about it on
Ethers.get_logs/2, Ethers.EventFilter, Ethers.CombinedEventFilter, the
README and in the generated docs of event filters with that signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012hqvX8DbbP3mgXy5hVEDc6
Decoded events carry an EIP-55 checksummed `address` since #312, so
system_address/0 returns the checksummed form too and compares equal to
the `address` of an ETH transfer log. eth_transfer_log?/1 still compares
case-insensitively.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012hqvX8DbbP3mgXy5hVEDc6
@alisinabh
alisinabh force-pushed the feat/glamsterdam-readiness branch from 619cc04 to ff6adf7 Compare November 16, 2026 01:05
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012hqvX8DbbP3mgXy5hVEDc6
@alisinabh
alisinabh merged commit fcb5f48 into main Nov 16, 2026
5 checks passed
@alisinabh
alisinabh deleted the feat/glamsterdam-readiness branch November 16, 2026 06:08
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