Repository navigation
feat: Satin inspector contract, steady-state benches, fail-closed mutation gate, spec draft, no Rex7 - #390
Conversation
…dering Each assumed that a state byte costs about 1,530: a deposit dominating its creator's record history, a hundred fresh slots outweighing the detention cap, a canonical keyless transaction too short for its code. They now derive their bounds from the schedule, and hold at MEGA_SATIN_CPSB=312.5.
…inspector made of its result
The modexp input keeps its 1,024-byte base, so its price is unchanged, and takes a one-byte modulus, which sizes the work: it computes in a moment instead of a second in an unoptimized build. The frame that runs out of its own gas spends it on 32 KiB copies instead of 11-gas rounds. The suite's serial test time drops from 43.9 s to 28.8 s.
Every KZG test loads the trusted setup, and under nextest each test is its own process: at opt-level 3 the load's C code takes about 11% less, 1.45 s to 1.29 s per test.
…Foundry's inspector does
The gate passed when a run left no results, or empty lists: a driver that crashed under bash 3.2, a failed baseline or an interrupted run all read as nothing to test. It now scores outcomes.json only when the baseline succeeded and every mutant has an outcome, and passes a run that tested nothing only on the producer's word: cargo-mutants' empty mutants.json, or the line it prints when --in-diff leaves no mutant, which the driver records. umutate.py writes the same record. The driver refuses a bash older than 5, clears its results before anything can fail, and hands an empty diff to cargo-mutants. The gate's tests run in a new self-test job.
A mutant is tested beside the others the run tests at once, each running the whole suite on the same cores: on CI one that a test catches in seconds alone timed out. The driver re-runs every unsuppressed timeout once with --jobs 1, into recheck/mutants.out, and the gate takes that outcome for it: caught alone is caught, surviving alone is a survivor, and timing out again stays inconclusive.
Every measured block started from a state without the seven predeploys, so it paid their first deployment, which a chain pays once, and ran without any limit. The block benches now start each block from a fresh State over the state the previous block's pre-block changes left, predeploys included, under BlockLimits::default(), and hand the state back so its drop is not measured. The first block after activation keeps its own arm, activation_pre_block.
Where /bin/sh is bash 5 the guard lets it through, and the test ran the driver's full subcommand. It now skips a shell that is bash 5 or newer, and calls the driver with a subcommand it does not have, a scratch output directory and a minimal PATH.
…ad note An outcomes list of anything but objects crashed the gate with a traceback; it is now results that cannot be scored, with the reason. The nothing-to-test report no longer counts unviable mutants a run without outcomes cannot have.
Stock macOS has no nproc, and the driver computed its job count before it cleared the previous run's results, so a run that stopped there left them for the gate to read.
…ice-independent tests
…hat a fork upgrade checks StepGuard forwards only the callbacks revm's instruction loop makes; a forward the loop never reaches would be code nothing tests. A callback the loop gains in a later fork revision would reach no inspector until it is forwarded, so the comment says a fork upgrade checks the loop's callbacks against the guard's list.
…held split The withheld part is in the frame's Gas, and gas detention sets it only at a read, a frame's start or resume, and after an SSTORE. An inspector that overwrites the interpreter's gas, as Foundry's pauseGasMetering does before every instruction, overwrites the split with it until the next of those; the step guard keeps only the crossing record.
The comment's claim, that the callee runs out before its third write completes, holds at every price; at the spec's prices it already runs out on its second write's state gas, which the comment now says.
cargo-mutants rewrites outcomes.json after every outcome, and its total_mutants counts the outcomes recorded so far, so comparing the two passed a run that stopped part way. The gate now requires the end_time the producer sets only when the run finishes, and outcomes naming exactly the mutants mutants.json selects. umutate.py writes its selection before it tests anything and its outcomes, with an end_time, once all are tested.
The driver let a re-check that failed as a run hand its files to the gate, which scored them as a finished run's. It now records the exit in the re-check's results, and the gate refuses results so marked, with the reason. A test drives the real driver with a stand-in cargo-mutants.
An admitted EIP-7702 authority keeps its nonce, delegation, state gas, write record and that record's history through a stop, while the first frame's value and record come back with the frame; a stopped deposit keeps the caller it created, with its mint and state gas.
A transaction-level stop reverts the frames' writes and logs, not what pre-execution applied: admitted EIP-7702 authorizations keep their nonce and delegation writes, their state gas, their records and those records' history, and a deposit keeps its mint and created caller, beside the sender's nonce and fees. Authorities that would cross a limit are still taken back before the first frame.
Claude review status
🛠️ Review did not finish Attempted head This round did not publish: MODEL_NO_OUTPUT: Claude returned no structured review output. Anything listed below is from the last round that did. Workflow run: https://github.com/megaeth-labs/mega-evm/actions/runs/39735991491 |
🧬 Mutation testing — ✅ PASSNothing to test: the mutant list under the run's filters was empty. |
Merging this PR will regress 2 benchmarks2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🧬 Mutation testing — ✅ PASSDiff mutation score: 100.0% (142/142 viable mutants killed)
No new test gaps introduced by this change. 🎉 |
…ngines, byte-price grid (#399) Co-authored-by: mega-putin <mega-putin[bot]@users.noreply.github.com>
Summary
Wave 5 of the Satin engine, on top of the wave-4 pull request (#388, base
cz/feat/satin-w4). Three lanes were merged from their own branches with--no-ff— the inspector contract, hygiene, and the Satin specification draft with the end of Rex7 — and the fixes two independent reviews of the merged branch asked for sit on top as single-concern commits.evm/inspector.rs,AGENTS.mdand the crate README, and pinned by tests. Five gaps a rewriting inspector exposed are closed; Foundry'sdeal,store,pauseGasMetering/resumeGasMeteringandexpectRevertare driven through the engine as Foundry drives them.docs/spec/upgrades/satin.mdstates Satin against Rex6 in 21 sections, with the glossary terms and the spec ladder updated; a transaction-level stop is specified to revert what the frames did and keep what was applied before the first frame.PlainandRecordedsections of the keyless differential record.The inspector contract
Where an inspector runs.
keylessDeploycall, which runs no instruction, and the creation below it.transact_system_callruns one: no callback. A tool that wants to watch a system call usesInspectSystemCallEvm.The admission gate. Block execution checks it wherever an outcome is produced or chosen: the pre-block changes, a transaction's execution, the end of the block, and
commit_transaction_outcome, the checked commit. A declared observer sees the block's transactions, user and system alike; a rewriting inspector is refused before anything runs. alloy-evm'scommit_transactionchecks nothing and needs no check: it cannot fail, runs no code, and commits the outcome the last execution produced under the gate, which no inspector enabled since can reach.What a rewrite does not change.
settle_kept_nothing).expectRevertcompares, is left as it was.What an inspector's writes to gas cannot do.
step_endof a frame's last instruction reaches nobody; a result's gas rewritten incall_endis what the caller merges.StepGuard, which puts back the crossing record such a refusal leaves, so gas detention never stops a frame for an inspector's charge.Gasthe answer was built on. Foundry answers every cheatcode onGas::new(limit), which carries no reservoir, and runs tests at 2^30 gas, above the execution cap, so without this a forge test lost its reservoir at its first cheatcode call and paid it in the receipt.pauseGasMeteringrestores a snapshot before every instruction, and the frame runs on the snapshot's split until detention next holds it.The gaps closed.
Gas::new(limit)handed a caller above the execution cap an empty reservoir.The four parked inspector tests are ported: one kept as it was, three rewritten because block execution now refuses the answering inspector and the stop is a revert.
Hygiene
BlockLimits::default()(production data-size limits and detention's caps), and theStateis dropped outside the measurement. A new arm,block/activation_pre_block, keeps the one-time deploy path measured. On arm64 callgrind the existing arms step once, by the harness and not the engine:block/transfers−2.95%,block/storage_writes−4.16%,block/steady_pre_block−2.99%.outcomes.jsonand nothing else, and fails with the reason on anything it cannot score: no results, a failed or missing baseline, a run that did not finish, a selected mutant without an outcome, an outcome of an unknown kind, unreadable JSON. It reads completion from cargo-mutants 27.1.0's own contract:end_time, which stays null until the run finishes, andmutants.json, the selection written before any mutant is tested, which the outcomes must name exactly. cargo-mutants rewritesoutcomes.jsonafter every outcome and itstotal_mutantscounts the outcomes recorded so far, so comparing the two let a run that stopped part way pass; the gate no longer reads that field.umutate.pykeeps the same contract: its selection on disk before any test, its outcomes with anend_timeonce every one is tested. The gate passes on nothing tested only on cargo-mutants' own word, which the driver records from its output. The driver refuses a bash older than 5 under any shell and clears its results before anything can fail. A mutant that timed out beside others is re-run once, alone, and the gate takes that outcome for it; a re-check that exits abnormally has its exit recorded in its results, and the gate refuses them rather than trusting files that can look like a finished run's. A self-test job runs the gate's tests on every PR.Diff changes no Rust source files, and the driver scopes its diff to the crate's Rust sources with:(glob)crates/mega-evm/src/**/*.rs. The diff used to take every file undersrc/, so a PR that edited only a module guide there failed the gate. The:(glob)magic matters: without it, git's default pathspec would need a second/and leavelib.rs,constants.rsandtypes.rsout; a test holds the pathspec to every tracked.rsfile undersrc/.umutate.py, and the gate's tests run one test in their place that fails with that sentence: a failure rather than a skip, so a job on an old Python cannot pass on nothing tested.MEGA_SATIN_CPSB=312.5, where nine tests failed before.c-kzgandblstare optimized in dev builds ([profile.dev.package]only; release, bench andno_stdbuilds are unchanged).The Satin specification draft
docs/spec/upgrades/satin.md, 798 lines: the Karst base, precompiles, size limits, EIP-8037's two pools, the gas schedule, state gas and SALT pricing, history gas, the history allowance, gas forwarding, resource limits, the revert-class stop, gas detention, volatile-data access control, EIP-7708 transfer logs, native keyless deployment, the Oracle, the live system address, system calls, the protocol's own transactions, block limits and refusals, each with its previous behavior. Every constant, access-type code, keyless rule order and the pre-block order were checked against the code.overview.md,hardfork-spec.md,upgrades/overview.md,SUMMARY.md) lists Satin as the unstable rung; the Rex6 page states that Rex6 is scheduled on both networks.AGENTS.md, which said a block cap never refuses one, now says the same, and two block tests pin it.No Rex7
LEGACY_SPEC_NAMESends atRex6;MegaSpecId::SATINkeeps discriminant 12, after the released legacy crate's 0 through 11.docs/spec/upgrades/rex7.mdis removed and the ladder reads… → Rex6 → Satin, so exactly one spec is unstable again.mega-evme(outside the workspace until it is ported) defaults toRex6and stops listingRex7in its doc strings and pages; the bench baseline rows and the mutation spec-gate ladder end atREX6; the PR template says a PR that changes Satin isspec:unstable.Behaviour notes
inspect_frame_init,inspect_frame_run,frame_end_checked);EvmTr::frame_init,frame_run,frame_return_resultand the handler are untouched. A declared observer rewrites nothing, so the settlement of a frame that kept nothing only carries flags revm's own results already carry, and the journal revert never runs for it.call_end, so a write made there stays. Pinned by a test."Rex7".parse::<MegaSpecId>()now fails withParseMegaSpecError::Unknownrather thanLegacy, andLEGACY_SPEC_NAMESno longer lists it. No signature changes; nothing in the tree matched onLegacyfor that name.umutate.pywrote before this change carry noend_timeand are refused; a new run writes one.block/transfers,block/storage_writesandblock/steady_pre_blockkeep their names and step once on this PR;block/activation_pre_blockstarts its own history.Open items
TracerEip3155writes its summary from the outermost frame'scall_end, before the transaction settles, so it cannot carry the settled ledgers. The proposed shape is a public method that writes the summary aftertransactfrom values — gas used and the state gas, history gas and reservoir left — as optional fields that keep upstream's output byte-identical when absent. Nothing inmega-evmchanges for it; it lands with the fork tagmega-evme's port uses.nproc, which stock macOS lacks; it fails there without leaving stale results.Test plan
cargo fmt --all --check,cargo clippy --workspace --lib --examples --tests --benches --all-features --locked,cargo sort --check --workspace --grouped …,cargo check -p mega-evm --target riscv64imac-unknown-none-elf --no-default-features --locked, Prettier ondocs/**/*.mdand the root*.md,git diff --check: all clean.cargo check --workspace --all-targets --lockedon every commit of the review fixes: no error, no warning.cargo test --workspace --locked: 1,376 passed, 0 failed in debug (mega-evmlib 335, block 122, satin 553, system 321), 34 more than the base's 1,342 measured at55906ab4; 1,362 passed, 0 failed in release, where the debug-only tripwire tests compile out.cargo test -p mega-evm --features satin-price-override,test-utils --locked --no-fail-fastwith the prices unset, atMEGA_SATIN_CPSB=2000 MEGA_SATIN_CPHB=100and atMEGA_SATIN_CPSB=312.5: lib 337 (1 ignored), block 122, satin 553, system 321 passed at each, 0 failed.amsterdam-opcodes-on-osaka, 2 listed); Amsterdam 15,754 executed, 72 skipped, 15,717 passed, 37 deviated (selfdestruct-burns-on-osaka, 37 listed); 0 unattributed and 0 unreproduced in both. Both summaries are identical to the recorded ones.Plain,RecordedandAnsweredsection is byte-identical, and 8Rewrittensections change, each now equal to itsPlainledgers where it used to carry rolled-back state gas or record history. The review fixes leave the whole record byte-identical.tests/: the gate scripts, two tests and documentation. The execution-spec gate, the keyless record and the diff mutation run above were not re-run for them.umutate.pyand the tests stop with the version sentence. Eight of them, the refusals of an unfinished or incomplete record, fail against the previous gate, and the three abnormal re-check cases fail against the previous driver and gate.total_mutants0,end_timenull) and right after the first caught mutant (total_mutants1,end_timenull), the records a crash at either point leaves, now fail with the reason where the previous gate passed both, the second at 100%; the finished run passes, 2/2 killed; the second copy with a forgedend_timeis still refused, one selected mutant having no outcome. A stand-in cargo-mutants drives the real driver: a re-check that exits 70 over a finished record, and one that exits 1 writing nothing, are refused; one that exits 0 is scored. The driver, run end to end on a diff that touches only a module guide undersrc/, passes on cargo-mutants'Diff file is empty; the base driver fails the same diff. On this branch's owndiff HEADit passes on the same line.cargo bench -p mega-evm --bench block --locked -- --test:block/transfers,block/storage_writes,block/steady_pre_blockandblock/activation_pre_blockall succeed.