Skip to content

fix: harden Satin developer tool inputs and diagnostics - #412

Draft
RealiCZ wants to merge 14 commits into
cz/feat/satin-w10from
cz/fix/satin-devtool-audit
Draft

RealiCZ wants to merge 14 commits into
cz/feat/satin-w10from
cz/fix/satin-devtool-audit

Conversation

@RealiCZ

@RealiCZ RealiCZ commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fail explicitly on oversized or non-regular fixture inputs and on inconsistent replay context, and keep configured RPC endpoints and server error text out of developer-tool diagnostics.

  • Bound fixture discovery and reads without truncating the corpus, and check account and total storage-slot counts before materializing state or hashing it.
    State-test files are capped at 64 MiB; blockchain bundles at 256 MiB because the pinned official fixtures reach about 160 MiB.
  • Discovery fails on non-regular *.json inputs (FIFOs, sockets, devices, directories) and on symlinked directories, given as a root or found below one, instead of hanging, traversing a directory twice or dropping it.
    Symlinks to regular *.json files are read.
    Fixture files are opened non-blocking on Unix and their type is checked on the open descriptor.
  • Remove obsolete slow-test filename exemptions for the supported Osaka and Amsterdam forks.
    Reject oversized blob-gas fields and type 3/4 creation transactions through the existing expected-exception handling.
  • Show only the configured endpoint's origin in diagnostics, keep it separate from cache identity, and filter terminal controls when log-file creation fails.
    JSON-RPC error responses from the server are reported by their error code and a local diagnostic; the server's message and data are never printed.
    Alloy's HTTP and retry implementation is kept, and retry classification still sees the original error.
  • Satin transaction replay validates the fetched parent's number and hash against the child, refuses pending and genesis transactions, reads pre-state at the verified parent hash (EIP-1898, requireCanonical: true), and serves BLOCKHASH ancestors by walking parentHash from the verified parent, failing on a broken link.

The tests extend the existing runner, input, provider, replay and CLI suites; no historical slow fixtures are added.

Behaviour changes for users

  • Satin --rpc.replay-file captures recorded before this change miss on state and ancestor reads, because those requests are now keyed by block hash; re-capture them.
  • RPC error messages no longer include the server's text.
  • A fixture tree that contains a symlinked directory now fails discovery with an explicit error.

Validation

  • Branch merged with the Satin base cz/feat/satin-w10 at 5e3f30ad (no rebase).
  • cargo test --workspace --locked: 1,954 passed, 4 ignored.
  • Full workspace clippy with all features, format, cargo-sort, and documentation Prettier, markdownlint and offline link checks passed.
  • Pinned state fixtures: Osaka 19,465 executed / 52 skipped; Amsterdam 15,754 executed / 72 skipped; both deviation gates passed.
  • Pinned blockchain fixtures: 18,713 executed, all six skip-class counts unchanged, 20,232 blocks checked against Ethereum; deviation gate passed.
  • Witness replay over every Osaka and Amsterdam fixture file, in equivalence and Satin mode: 0 failed.
  • Retry regression covers HTTP 503, a bare JSON-RPC 429 body and a missing-id error, with actual request counts checked.
    CLI diagnostics exercise both stderr and a log file with dependency tracing enabled.

Scope and known residuals

  • Successful RPC payloads are unchanged; errors raised later while decoding their typed contents can still contain the returned data.
  • An offline replay envelope that someone edits by hand to contain a JSON-RPC error response is returned as recorded (the capture writer never stores error responses).
  • Ancestor headers are checked by their advertised hash and number; a hand-edited recording that keeps those but changes a header's parentHash is not detected.
  • The Unix O_NONBLOCK value is selected per target; MIPS r6 and illumos are not mapped and fall back to the pathname check (neither is a supported build target).
  • The witness CI harness (crates/mega-state-test/tests/witness.rs) still reads fixtures with its own unbounded reader.
  • currentExcessBlobGas = u64::MAX passes the width check and overflows in revm's blob-fee calculation.
  • Other review residuals (whole-file skip names, harness-added accounts at the state-size boundary, terminal escaping of some tracing fields) are tracked on the audit Issues.

API

mega-state-test's runner::find_json_files now returns io::Result<Vec<PathBuf>>, and runner::find_json_files_in_paths discovers several input paths under one file budget, refusing an empty input directory; callers must propagate discovery failures.
The in-tree CLI and witness callers are updated with it.
Input readers and limits remain private.

Audit coverage

This PR addresses the maintained Satin tooling paths for these findings.
The fixture byte bound also covers #164's authorization-list input through the runner's file entry point.

mega-audits#147 is closed as accepted risk and is not claimed as fixed by this PR.
mega-audits#115 is addressed by the existing Satin baseline design, not by this PR.

This PR targets a Satin feature branch.
The audit Issues remain open until an eligible default-branch integration PR can be registered in their fix_prs metadata.

@mega-maxwell

mega-maxwell Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude review status

Living comment — rewritten in place. The review workflow keeps this single comment up to date instead of posting a new one each round, so it always describes the latest reviewed commit and the earlier text is intentionally gone. No reply is needed here; reply to a finding in its own review thread, and answer an open question in a reply on this PR. The next review round reconciles your answer.

🛠️ Review did not finish

Attempted head c1ff65b0 · updated 2026-11-19T16:55:09+00:00

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/44571389622

@RealiCZ RealiCZ added spec:unchanged No change to any `mega-evm`'s behavior comp:mega-evme Changes to the `mega-evme` tool comp:misc Changes to the miscellaneous part of this repo comp:doc Changes in the documentation api:breaking Crate interface change — downstream users must update labels Oct 27, 2026
@github-actions

Copy link
Copy Markdown

🧬 Mutation testing — ✅ PASS

Nothing to test: cargo-mutants said: INFO Diff file is empty.

@codspeed

codspeed Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 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

✅ 57 untouched benchmarks
⏩ 389 skipped benchmarks1


Comparing cz/fix/satin-devtool-audit (c1ff65b) with cz/feat/satin-w10 (5e3f30a)

Open in CodSpeed

Footnotes

  1. 389 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. ↩

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

api:breaking Crate interface change — downstream users must update comp:doc Changes in the documentation comp:mega-evme Changes to the `mega-evme` tool comp:misc Changes to the miscellaneous part of this repo spec:unchanged No change to any `mega-evm`'s behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant