Skip to content

ZKsync OS REVM#2

Merged
vladbochok merged 26 commits intomainfrom
vb-initial-version
Dec 9, 2025
Merged

ZKsync OS REVM#2
vladbochok merged 26 commits intomainfrom
vb-initial-version

Conversation

@vladbochok
Copy link
Member

@vladbochok vladbochok commented Oct 21, 2025

ZKsync OS variant of REVM. Most of the code is just imports from REVM and wrappers that implement REVM traits. The big things to review:

  • precompiles — precompiles should behave exactly the same as on ZKsync OS, and if a precompile is present on ZKsync OS, then it must be present in this REVM and vice versa.
  • hooks — same as precompiles. All ZKsync OS hooks should be implemented here as well. Pay attention to:
    • gas. How much used by precompiles in a positive testcase. Out of Gas handling.
    • How the precompile should behave in static mode.
    • What would happen if hook is called in delegatecall.
  • tx_types - all transaction types should behave exactly the same way as on ZKsync OS. For EIP-1559 transactions, this means correctly charging fees and not burning the base fee. For pre-155 txs, don’t check the chain ID. For L1 → L2 transactions (priority and upgrade types), don’t perform validation, and don’t bump the nonce when validating the transaction.
  • ZKsyncHandler - this is the main component. Most of the custom logic is implemented here. It handles transaction validation, refunds, and state change reverts. Pay special attention to gas_used_override and force_failing. I recommend reading the vanilla REVM. Unfortunately, I couldn’t find good documentation for this component.

RomanBrodetski added a commit to matter-labs/zksync-os-server that referenced this pull request Oct 24, 2025
Adding a separate pipeline item for running the revm execution
environment to compare state results. The zksync-revm uses a Database
with access to a custom state handler. All state changes across one
block are accumulated in an in-memory (cache) database, and for each new
block, the data is loaded from the server state handler. This means that
each block comparison is done separately, and if a mismatch happens in
block X, the block X + 1 comparison won’t be affected.

You can find the zksync-revm here:
- matter-labs/zksync-os-revm#2

---------

Co-authored-by: romanbrodetski <rb@matterlabs.dev>
itegulov
itegulov previously approved these changes Dec 8, 2025
Copy link
Contributor

@itegulov itegulov left a comment

Choose a reason for hiding this comment

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

Mostly nits, LGTM otherwise. At the very least I'd add basic GHA workflows and clarify how ZkSpecId is expected to be evolved going forward.

This PR upgrades revm 29.0.0->31.0.2. There have been a few changes in
the interfaces so the code had to be adapted accordingly. No functional
changes expected.
@vladbochok vladbochok merged commit a686621 into main Dec 9, 2025
3 checks passed
@vladbochok vladbochok deleted the vb-initial-version branch December 9, 2025 15:24
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.

2 participants