Skip to content

feat!: the Satin execution engine on the revm 40 forks - #386

Open
RealiCZ wants to merge 535 commits into
satinfrom
cz/feat/satin-w2
Open

RealiCZ wants to merge 535 commits into
satinfrom
cz/feat/satin-w2

Conversation

@RealiCZ

@RealiCZ RealiCZ commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Satin is MegaETH's new execution engine: mega-evm 2.0, on the MegaETH forks of revm 40.0.3 and op-revm 20.0.0, running one unstable spec, SATIN. It restates MegaETH's execution rules on Optimism Karst (Ethereum Osaka): EIP-8037 regular and state gas under a 200,000,000 execution cap, state gas scaled by the SALT bucket it lands in, a history-gas ledger for the bytes a transaction appends, data-size, KV-update and state-growth limits whose crossing reverts only the frame that crosses it, gas detention, native keyless deployment, the live system address read by the transaction itself, and the witness a stateless validator re-executes a block from. The legacy engine on main keeps executing every block before Satin activates.

This pull request targets satin and holds the whole engine: #407, #409 and #417 have merged into this branch, and satin is merged into it (which changed no file), so the diff no longer repeats the skeleton (#385) that satin already holds. The stacked pull requests' descriptions carry the detail:

Each linked description covers its series as it was merged, and later series changed parts of it: #404 removed the KV and state-gas limits #387 added, fixed the limits per spec rather than as #399's chain parameters, and replaced #388's latched stop with a stop the caller can catch; the engine no longer deploys the system contracts #387 deployed, and only checks them in the block where Satin activates; #407 restored the KV-update and state-growth limits, counted on Satin's write records and state growth, removed #390's inspector settlement and admission gate in favour of revm's own inspected lifecycle, and replaced #388's instruction wrappers with the fork's hooks. Review against the final tree, the specification and the review guide, not against these descriptions.

How to review

What is still to come

Nothing more in this pull request. #407, #409 and #417 have merged into this branch.

This pull request merges into satin with a squash. After it, the fork pins move to the merged commits of the fork pull requests, and to tags once the line is final; follow-up pull requests on satin simplify the engine further, reading more of its accounting off revm's journal, and take up the performance work.

Out of scope

@RealiCZ RealiCZ added spec:new Introduces a new MegaSpecId variant api:breaking Crate interface change — downstream users must update comp:core Changes to the `mega-evm` core crate dependencies Pull requests that update a dependency file agent Generated by AI agents labels Sep 21, 2026
@github-actions

Copy link
Copy Markdown

🧬 Mutation testing — ✅ PASS

Nothing to test — no mutants were generated on the changed lines.

@codspeed

codspeed Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 15.79%

3 warnings

⚠️ 17 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 15 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 15 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

❌ 15 regressed benchmarks
✅ 10 untouched benchmarks
🆕 35 new benchmarks
⏩ 385 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ deep_calls/satin 392.6 µs 543.1 µs -27.71%
❌ storage_writes/satin 324.4 µs 443 µs -26.76%
❌ ether_transfer/satin 44.9 µs 58.1 µs -22.77%
❌ logs/satin 151.8 µs 191.3 µs -20.62%
❌ empty_transaction/satin 43.7 µs 54.9 µs -20.28%
❌ create_evm_with_inspector 28.6 µs 35.2 µs -18.76%
❌ nested_refund_depth_10 119.5 µs 142.6 µs -16.19%
❌ create_evm 27.4 µs 32.2 µs -14.94%
❌ selfdestruct 88.2 µs 101.6 µs -13.23%
❌ create 86.1 µs 97.9 µs -12.03%
❌ deep_calls/op_revm 357.5 µs 390.7 µs -8.5%
❌ sstore_set 69.7 µs 75.9 µs -8.11%
❌ nested_revert 77.7 µs 84.2 µs -7.67%
❌ ether_transfer/op_revm 41.6 µs 45.1 µs -7.56%
❌ eip7702_delegation 83.1 µs 89.8 µs -7.46%
🆕 storage_writes N/A 2.3 ms N/A
🆕 transfers N/A 2.8 ms N/A
🆕 intercepted_calls/op_revm N/A 557.9 µs N/A
🆕 intercepted_calls/satin N/A 362.2 µs N/A
🆕 salt_new_accounts/crowded N/A 145.6 µs N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cz/feat/satin-w2 (a7205c0) with satin (17fb2b1)

Open in CodSpeed

Footnotes

  1. 385 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@claude

claude Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Label check: spec:new looks incorrect on this PR.

spec:new is described as "Introduces a new MegaSpecId variant." The SATIN variant is defined in crates/mega-evm/src/evm/spec.rs, which already exists on this PR's base branch (cz/feat/satin-t2-skeleton) and is untouched by this diff — this PR only adds mechanisms (gas table, block executor, SALT pricing, system contract interceptors) on top of the existing single-spec skeleton, per its own summary ("Wave 2 of the Satin engine... on top of the pull request that laid the Satin skeleton"). Per AGENTS.md, SATIN is "the unstable spec under active development," so spec:unstable ("Changes to the unstable spec") is the label that matches, not spec:new.

The other labels (api:breaking, comp:core, dependencies, agent) all check out against the diff and the PR summary.

@claude

claude Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Label check

The spec:new label looks incorrect. Per AGENTS.md, MegaSpecId has a single rung, SATIN, and this PR builds on top of the base branch (cz/feat/satin-t2-skeleton) that already introduced it — the diff here only uses MegaSpecId::SATIN / MegaHardfork::Satin (e.g. in evm/mod.rs, block/hardfork.rs, block/chain.rs); it doesn't add a new MegaSpecId variant. spec:new ("Introduces a new MegaSpecId variant") doesn't apply here.

Since this PR makes extensive changes to the Satin engine itself (gas schedule, block executor, SALT pricing, system contract interceptors), spec:unstable ("Changes to the unstable spec") is the label that fits instead.

Other labels look right: api:breaking (the PR body documents the Precompiles/Database bound changes as breaking), comp:core (all changes are in crates/mega-evm), and dependencies (the revm fork pin bump in Cargo.toml/Cargo.lock).

@claude

claude Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Label check

Current labels: spec:new, api:breaking, comp:core, dependencies, agent.

  • spec:new ("Introduces a new MegaSpecId variant") looks incorrect here. This PR builds out mechanisms (gas table, block executor, SALT pricing, system contract interceptors) for the existing SATIN rung — crates/mega-evm/src/evm/spec.rs, where MegaSpecId is defined, isn't touched by this diff, and the PR description never mentions adding a new variant. Per AGENTS.md, Satin is "the unstable spec under active development... its behavior may change until it is sealed," which matches spec:unstable ("Changes to the unstable spec") rather than spec:new. Suggest swapping spec:new → spec:unstable.
  • api:breaking, comp:core, and dependencies (Cargo.lock/Cargo.toml revm fork bump) all look correctly applied.

@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.35476% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.0%. Comparing base (a8f8c7c) to head (a7205c0).
⚠️ Report is 1 commits behind head on satin.

Files with missing lines Patch % Lines
crates/mega-evm/src/block/l1_block_info.rs 95.8% 0 Missing and 13 partials ⚠️
crates/mega-evm/src/system/sequencer_registry.rs 97.7% 4 Missing and 3 partials ⚠️
crates/mega-evm/src/evm/execution.rs 94.6% 4 Missing and 2 partials ⚠️
crates/mega-evm/src/evm/instructions.rs 98.0% 1 Missing and 3 partials ⚠️
crates/mega-evm/src/evm/host.rs 96.4% 0 Missing and 1 partial ⚠️
crates/mega-evm/src/system/keyless/dispatch.rs 99.0% 0 Missing and 1 partial ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@claude

claude Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Label check:

api:breaking, comp:core, dependencies, and agent all look correct given the public-surface changes (Precompiles associated types, DB bound narrowing), the core-crate scope, the revm fork re-pin in Cargo.toml/Cargo.lock, and the AI-authored provenance.

@claude

claude Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Label check

Current labels: spec:unstable, api:breaking, comp:core, dependencies, agent.

The previous spec:new → spec:unstable swap has been made — that's correct now, since this PR only changes the behavior of the existing, still-unstable SATIN spec (gas table, block executor, SALT pricing, system contract interceptors) rather than adding a new MegaSpecId variant.

Remaining issue:

  • comp:doc and comp:misc look missing. This PR makes substantial non-core changes: root AGENTS.md (+59/-18), crates/mega-evm/README.md (+47/-3), crates/mega-evm/src/external/AGENTS.md (+6/-1), a new crates/mega-evm/src/system/AGENTS.md (+42), and crates/mega-evm/tests/_pending/README.md (+98/-51) — all doc content, matching comp:doc ("Changes in the documentation"). It also touches .github/workflows/benchmark.yml and root REVIEW.md, the same kind of repo-infra files that earned comp:misc ("Changes to the miscellaneous part of this repo") on PR feat!: restart mega-evm as the Satin skeleton on the revm 40 forks #385, the base "Satin skeleton" PR this one builds on and the closest precedent for this line of work.

api:breaking, comp:core, dependencies, and agent all look correct given the public-surface changes, the core-crate scope, the revm/op-revm fork re-pin in Cargo.toml/Cargo.lock, and the AI-authored provenance.

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🧬 Mutation testing — ✅ PASS

Diff mutation score: 100.0% (885/885 viable mutants killed)

  • caught: 885
  • survived (real gaps): 0
  • timed out (inconclusive): 0
  • suppressed (equivalent/dead-code): 9
  • unviable: 818 · timeout total: 1
  • re-checked: none of the 1 that timed out (no re-check results)
  • run against Mega EEST: none of the 8 the tests missed (no Mega EEST results)

No new test gaps introduced by this change. 🎉

@RealiCZ RealiCZ added spec:unstable Changes to the unstable spec (currently REX5) and removed spec:new Introduces a new MegaSpecId variant labels Sep 27, 2026
@RealiCZ
RealiCZ added this pull request to stack #403 October 12, 2026 12:39
@RealiCZ
RealiCZ removed this pull request from stack #403 October 21, 2026 06:32
@RealiCZ
RealiCZ added this pull request to stack #408 October 22, 2026 06:45
@RealiCZ
RealiCZ marked this pull request as ready for review October 22, 2026 06:46
Base automatically changed from cz/feat/satin-t2-skeleton to satin October 22, 2026 06:47
@RealiCZ
RealiCZ removed this pull request from stack #408 October 22, 2026 06:47
@RealiCZ
RealiCZ changed the base branch from satin to cz/feat/satin-review-base October 22, 2026 07:12
RealiCZ added a commit that referenced this pull request Oct 22, 2026
…hanges

The stack merged down into #386, and the skeleton (#385) merged into
`satin` first, so the guide now names #386 as the pull request under
review and `a8f8c7c9..<head>` as the range that still holds the
skeleton.

- A table of the engine's modules says which are stable and which #407
  still changes, derived from the diff of `cz/feat/satin-w9` against
  this branch and the work still to land in it; it replaces the old
  "What follows" section.
- The fork bullet keeps this branch's tag pins and names the fork pull
  requests that review the commit pins #407 moves to.
- Module headings, three checks and the decided items #407 revisits
  say so.
RealiCZ added a commit that referenced this pull request Oct 22, 2026
RealiCZ added a commit that referenced this pull request Oct 22, 2026
Brings the review guide's update for #386. The guide's four conflicting
passages keep this branch's facts (the forks pinned by rev, block execution
admitting any inspector); the rest of the update merges as is and is
refreshed for this branch's code when it merges into cz/feat/satin-w2.
@RealiCZ RealiCZ changed the title feat!: the Satin gas table, block executor, SALT pricing and system contract interceptors feat!: the Satin execution engine on the revm 40 forks Oct 22, 2026
Comment thread crates/mega-evm/src/evm/execution.rs Outdated
let share = shares.get(pool);
let mut allowed = caps.get(pool);
let spent = caller.pool_spent(pool);
if spent < 0 {

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.

The cargo-mutants gate is red on 2ec47583: it reported 22 MISSED mutants and was then cancelled after 5h31m (run 39900935987). The PR calls this gate fail-closed, so it needs a decision before merge.

This line is one of the survivors: spent < 0 → spent <= 0 is caught by no test. Others in new code that look like real test gaps:

  • simulate_authorization_list: execution.rs:1421 (&&→||), :1434 (||→&&), :1437 (+=→*=)
  • AdditionalLimit::authorization_list_may_cross: limit.rs:410, :412 (-→+), :413 (>→>=, twice)
  • Counted::plus dropping transfer_log: limit.rs:208
  • MegaEvm::cfg_env / chain_id: evm/mod.rs:489, :493
  • Accounts::destroyed_parts: record.rs:312 (delete !)

Some of the rest look equivalent: the >→>= and <→<= survivors on the saturating u64/i128 clamps in first_frame_pools (limit.rs:456–464) and positive (limit.rs:846).

Not a code defect, but each of these needs one of three things: a test, a suppression with a reason, or a fix to the gate's runtime so it finishes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in the commits folded in from #417 (ec0983f, 4115da6).
Rerun at the top of the stack, the 22 survivors resolve to 10 killed by new or extended tests, 6 equivalent and 6 removed by later commits (the list-size prefilter in authorization_list_may_cross, the positive-rise guard in check, and the failed-draw cleanup in apply).
The spent < 0 site here is killed by test_only_a_callers_negative_net_holds_its_childs_share_to_its_budget.
The six equivalents are suppressed with their proofs: += → *= on the simulated nonce, four boundaries of the clamp and the cap in first_frame_pools where both branches give the same value, and > → >= in positive.
A scored rerun of all 22 has no unsuppressed miss.
The runtime is addressed too: the pull-request gate now runs the diff in four parallel shards and scores them in one cargo-mutants gate job (0a72ada and follow-ups).

Comment thread Cargo.toml Outdated
[patch.crates-io]
# megaeth fork of revm (revm 40.0.3 + the revm 43 gas core + the megaeth hooks).
# All twelve crates move together, otherwise the build resolves a second copy of revm.
revm = { git = "https://github.com/megaeth-labs/revm", rev = "fd230a3427d1b96c88e0b581bab8a7763c8ec298" }

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.

Optional: the description says the forks are pinned at "the heads under review in megaeth-labs/revm#76 … and megaeth-labs/op-revm#8". Both PRs have moved on since: revm#76 is now at 2b71cb61, not fd230a34, and op-revm#8 is at 8c0db939, not 2ecb7dce. The pinned commits are still ancestors of those branches, so nothing is orphaned. Could you either update the description or re-pin, so reviewers know which fork code this engine was tested against?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the description.
With #409 and #417 folded in, this branch pins the current heads, revm 2b71cb61 (megaeth-labs/revm#76) and op-revm 8c0db939 (megaeth-labs/op-revm#8); the description also names fd230a34 / 2ecb7dce, the pins this pull request was tested on before the fold, both ancestors of those heads.

/// Whether `log` is the EIP-7708 transfer log revm journals for a value movement: a log from the
/// system address `0xff…fe` carrying ERC-20's `Transfer` event.
pub(crate) fn is_transfer_log(log: &Log) -> bool {
log.address == ETH_TRANSFER_LOG_ADDRESS && log.topics().first() == Some(&ETH_TRANSFER_LOG_TOPIC)

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.

Optional: no test kills the mutant && → || here. The unit test's "a contract's log" case has no topics, so it returns false either way. Only revm, or a node's own precompile, can journal a log between the start's mark and the count, so this is harmless today. Still, one assertion would pin the rule: a log from a contract address carrying ETH_TRANSFER_LOG_TOPIC is not a transfer log. For example, in test_a_starts_records_are_read_off_what_revm_did:

journal.log(Log::new_unchecked(OTHER, vec![ETH_TRANSFER_LOG_TOPIC], Bytes::new()));

with the same (RecordDelta::NONE, Counted::NONE) expectation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in ec0983f, folded in from #417: test_a_starts_records_are_read_off_what_revm_did now journals a contract log carrying the transfer topic and expects no transfer log.
It fails with && → || and passes with the predicate as written.

@RealiCZ

RealiCZ commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

#409 and #417 are now folded into this pull request, and it targets satin; the description lists what each brought. On the review's points: (2), the mutation gate, is answered in the commits folded in from #417.
The 22 survivors resolve to 10 killed, 6 equivalent (suppressed with their proofs) and 6 removed by later commits; a scored rerun has no unsuppressed miss.
The pull-request gate now runs in four parallel shards.
On the folded diff against satin (1,712 mutants) it catches all 885 viable mutants, with no survivor, and its shards took 28 to 68 minutes.
One more mutant, += → *= on the loop index in first_frame_pools, never terminates, so a test can only time out on it; a7205c0 accepts it in mutants/suppressions.toml as non-terminating.
(1) and (3) are resolved by the fold: the base is satin, and the head is the code that ships.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Generated by AI agents api:breaking Crate interface change — downstream users must update comp:core Changes to the `mega-evm` core crate comp:doc Changes in the documentation comp:misc Changes to the miscellaneous part of this repo dependencies Pull requests that update a dependency file spec:unstable Changes to the unstable spec (currently REX5)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants