Skip to content

rpc/jsonrpc: keep system address in executionWitness when a tx opcode touches it#21565

Merged
awskii merged 1 commit into
mainfrom
awskii/witness-system-address-touch
Jun 2, 2026
Merged

rpc/jsonrpc: keep system address in executionWitness when a tx opcode touches it#21565
awskii merged 1 commit into
mainfrom
awskii/witness-system-address-touch

Conversation

@awskii

@awskii awskii commented Jun 1, 2026

Copy link
Copy Markdown
Member

debug_executionWitness dropped the system address (0xff..fe) from the witness unless it had a state change — the rationale being it's only ever the msg.sender of begin/end-block system calls. But a user transaction can access it via an account-accessing opcode (BALANCE/EXTCODESIZE/EXTCODEHASH/EXTCODECOPY/CALL/STATICCALL); per EIP-7928 that's an account-only entry the witness must carry. Such a read usually hits the state-object cache (the account was loaded during the system call), so the RecordingState reader never sees it.

Fix: detect the access via the per-transaction access set (ibs.AccessedAddresses()) and keep the system address when a user tx touched it.

Verified against the EEST zkevm witness suite: bal_account_touch_system_address (all 6 opcode variants: balance/call/extcodesize/extcodehash/extcodecopy/staticcall) goes green, full for_amsterdam corpus shows no regressions. The zkevm suite lives on #21487 until merged, so its CI coverage of this fixture arrives once that lands. make lint clean.

… touches it

debug_executionWitness dropped the system address (0xff..fe) unless it had a
state change, on the rationale that it is only ever the msg.sender of begin/
end-block system calls. But a user transaction can access it via an account-
accessing opcode (BALANCE/EXTCODE*/CALL/STATICCALL); per EIP-7928 that is an
account-only entry that must appear in the witness. Such a read often hits the
state-object cache (the account was loaded during the system call), so the
recorder never sees it.

Detect the access via the per-transaction access set (ibs.AccessedAddresses())
and keep the system address when a user tx touched it.
@awskii awskii requested review from lupin012 and yperbasis as code owners June 1, 2026 21:15
@awskii awskii added the RPC label Jun 1, 2026
@awskii awskii added this to the 3.5.0 milestone Jun 1, 2026
@awskii awskii enabled auto-merge June 1, 2026 22:47
@yperbasis yperbasis requested a review from Copilot June 2, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a gap in debug_executionWitness where the system address (0xff…fe) could be dropped from the witness even when a user transaction accessed it via an account-accessing opcode (e.g. BALANCE, EXTCODE*, CALL), by leveraging the per-transaction address access set to detect such touches even when the state-object cache prevents the RecordingState reader from observing the read.

Changes:

  • Add RecordingState.systemAddrTouchedInTx to remember if any user tx accessed the system address via an opcode.
  • After each ApplyMessage, inspect ibs.AccessedAddresses() and mark the system address as touched when present.
  • Adjust collectAccessedState to retain the system address even without state change when systemAddrTouchedInTx is set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +613 to +618
// A user tx that accesses the system address via an opcode keeps it in the
// witness; the per-tx access set captures this even on state-cache hits.
if acc := ibs.AccessedAddresses(); acc != nil {
if _, ok := acc[params.SystemAddress]; ok {
recordingState.MarkSystemAddrTouchedInTx()
}
@awskii awskii added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit c7e9497 Jun 2, 2026
91 checks passed
@awskii awskii deleted the awskii/witness-system-address-touch branch June 2, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants