Skip to content

Copy rsk-clients-lab's benchmarking harness: sixteen flags for rskj-comparable runs #348

Closed

Description

@SDL-A1

Migrated from SergioDemianLerner/rustock#348 (pull request by @SDL-A1, 2026-11-07).
Merged: yes. The commits are already in this repository's history.
Original: SergioDemianLerner/rustock#348

rsk-clients-lab's benchmarking harness, copied from patogallaiovlabs' fork as written and reconciled onto current main. Ten commits, 3,773 lines, sixteen new flags.

This is the tooling behind the findings in #347: it is what let the lab mine a sample with rskj, replay it into both clients on the same state under the same load, and compare per-block timings. With it we can run those comparisons ourselves rather than depending on their lab.

The flags

Running the chain an rskj regtest node runs — so both clients can be fed identical blocks:

flag
--genesis <FILE> start from an rskj genesis JSON instead of the built-in one
--skip-pow-validation accept headers without checking merged-mining PoW (rskj miner.server.skipPowValidation)
--hardfork name=height schedule an rskj network upgrade; repeatable
--consensus-rule name=height override one RSKIP's height (-1 = never); currently rskip97
--min-gas-limit / --max-gas-limit override the header gas-limit bounds
--allow-chain-overrides take the above on a copy of mainnet or testnet

Moving chains between clients: --export-blocks (with --export-from / --export-to) writes the canonical chain in rskj's ExportBlocks format, gzipped when the name ends .gz; --import-blocks (with --import-flush-every) reads one back on top of the best block and exits non-zero at the first block that fails a check.

Measuring: --breakdown-log writes one timing line per block connected as best, in the shape of rskj's block connect breakdown best: debug line — for imported blocks and for blocks this node mines. Off by default, and then no clock is read at all. Plus a trieSaveMs lap timing the trie-store write inside execute.

Mining on a schedule: --mine-timed <MEDIAN> is rskj's miner.client.timedMine — a block after each exponentially distributed delay, floored at 100 ms and scaled by difficulty drift, mining whether or not the pool holds anything. --flush-every sets best blocks between trie flushes.

Pool: --account-slots (rskj transaction.accountSlots, default 16) bounds how many transactions one sender may queue past its nonce.

Also a Dockerfile for rustock-cli on Ubuntu 22.04, amd64 and arm64.

Deliberately not taken

The two commits that make mined headers carry the activated version and ummRoot. They change the headers this node produces — and therefore mined block hashes — so they are consensus-visible rather than harness, and belong in their own review with mainnet validation.

Security review

The --allow-chain-overrides gate holds. With no override flag set it returns the config untouched, so a default node never reaches this path. On chain id 30 or 31 every override is refused without the opt-in, and --genesis is refused even with it — a genesis file would make it another chain. Accepting overrides on a real chain logs a warning. The dangerous combination is reachable only by deliberately passing both --allow-chain-overrides and --skip-pow-validation.

--import-blocks does not bypass validation. Header verifier, then validate_block, then process_block — validate, execute, check, then store, in rskj's internalTryToConnect order, so nothing is written for a block that fails. The same gauntlet follow mode runs.

No unsafe, no network calls, no environment reads, no key handling. The std::process::Command uses are crates/cli/tests/import_blocks.rs spawning the binary under test through CARGO_BIN_EXE; those four tests do a real rskj-fixture round trip and are the end-to-end proof the importer works.

Dependencies — the one thing worth a close look

Unlike the fixes in #347, which added none, this adds three:

crate where why
flate2 crates/cli gzip for .gz ExportBlocks files
serde_json crates/core parsing the rskj genesis JSON
rand crates/execution exponential delays in --mine-timed

rand was already a workspace dependency, so flate2 is the only genuinely new crate in the lockfile, pulling in adler2, miniz_oxide, simd-adler32 and zlib-rs. cargo-deny on this PR is the check to read — five advisories have blocked PRs this week.

Minor: rand now appears in crates/execution, a consensus crate, though its only use is mining/timed.rs, the timed-mining client.

Three repairs during the port

Testing

2,626 tests pass (up from 2,585 — 41 new), clippy clean. All sixteen flags verified present in --help.

🤖 Generated with Claude Code

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions