Repository navigation
Description
Migrated from SergioDemianLerner/rustock#347 (pull request by @SDL-A1, 2026-11-07).
Merged: yes. The commits are already in this repository's history.
Original: SergioDemianLerner/rustock#347
Seven fixes found and written by rsk-clients-lab (patogallaiovlabs), reviewed and reconciled onto current main. Their work is excellent — every issue names the rskj class and test that proves the behaviour, and every fix ports those tests.
Two of the nine issues they filed were already fixed here by #340 (the RSKIP252 miner cap and the eth_gasPrice fee-market gate — their campaign is where the "138 blocks" figure in that commit came from). The other seven are below.
What landed
| issue | risk | |
|---|---|---|
| 1 | Miner fills blocks by declared gas limits, not gas used | consensus (adds an import rule) |
| 2 | RSKIP179, the Bitcoin↔RSK timestamp link, is not enforced | consensus |
| 3 | Future-timestamp bound and minimum gas limit differ from rskj | acceptance |
| 4 | One invalid pending transaction stops every template; miner mines while syncing | operational |
| 5 | Pool admits what rskj's TxPendingValidator refuses |
relay/selection |
| 6 | Six behaviours of rskj's MinerServerImpl |
operational |
| 7 | rskj test parity table for the consensus packages | docs |
Consensus changes were checked against the chain, not reasoned about
A consensus rule that is stricter than the chain it must accept is a fork. Both new rules were run over this node's real mainnet history:
The gas-fit rule (a transaction's declared limit must fit in the block limit minus gas used): 3,000 consecutive recent blocks and 4,000 blocks sampled across 2,000,000 — 16,727 transactions, 0 would be rejected. The closest case is the one that matters: mainnet #7,575,268 carries a transaction declaring 6,800,000 on a 6,800,000 limit with nothing used before it — exactly 100.00%. The rule admits it because the comparison is <=. A < would reject a real mainnet block.
RSKIP179: a new permanent guard, rskip179_accepts_every_sampled_mainnet_block, runs the rule over 670 real headers — sampled every 20,000 blocks and one at a time for 200 blocks around iris300, where an off-by-one in the activation would show. All pass, and the largest timestamp gap the chain actually runs is 220 s against the 300 s bound.
The 3,000,000 gas floor (up from 5,000) is stricter, so: the lowest gas limit in this node's entire history is 5,000,000, at block #315, found by walking blocks 0–5,000 one at a time then sampling to the head. Nothing mainnet contains falls below the new floor.
One security fix on top of their work
Their sync gate kept the highest peer height ever seen (fetch_max) rather than the current one. Peer-announced heights are unauthenticated, so one peer claiming 2^60 once would leave the gate shut for the life of the process and the node would never mine again — a remote off-switch for mining, reachable by a single message. Almost certainly a convenience to avoid a race rather than anything intended. The gate now reads the current best peer, which is what rskj's sync service exposes; the height comparison also saturates rather than wrapping.
Security review
The whole 8,491-line branch was screened before anything was taken, and the 3,731-line landing diff again after. No unsafe, no transmute, no network calls, no process spawns, no environment reads, no file writes, and no key handling in any production path — every hit on those patterns is test fixtures. Zero dependency changes: nothing added to Cargo.toml or Cargo.lock.
The one bypass in the set, is_free_tx (which skips the balance and intrinsic-gas checks for federator Bridge calls), was traced to its activation rather than taken on trust: it requires !has_are_bridge_txs_paid, true from height 370,000 on mainnet, 114,000 on testnet and 0 on regtest and every custom chain, so it is unreachable for any transaction the pool sees today on any network. Faithful to rskj, and dead code — not a hole.
What was deliberately not taken
Their branch is 33 commits on an old base, 26 of them their lab harness: --import-blocks, --export-blocks, --mine-timed, --breakdown-log, --account-slots, --allow-chain-overrides, the Dockerfile, mined header version/ummRoot, regtest config. Those are their benchmarking infrastructure, not fixes, and several leaked into the fix commits' diffs through shared context. Dropped: ChainConfig::set_rskj_hardfork, BreakdownSink/CommitOutcome/cumulative_difficulty, two --breakdown-log timing laps, four harness-only tests, the harness flag tests, and an orphaned edges binding that would have changed mined block hashes.
Where their work overlapped #340, ours is kept. Their eth_gasPrice fallback reproduces rskj's floating-point multiply-and-truncate where ours uses the exact ratio 11/10; checked rather than assumed — the two agree on every minimum below 2^53, including all 2,061,855 values under 2e8 compared one by one, and part company only where a minimum gas price would be 1 RBTC per gas. Ours is kept and the boundary is now documented next to it. Their 587 → 645 case, the number from the campaign that found this, is pinned as a test.
Two findings reported, not fixed
probe_and_partitionre-recovers senders the pool already knew, andunwrap_or_default()would silently attribute an unrecoverable signature to the zero address. Not exploitable — the pool validates signatures on admission — but wasteful and a wart.- The comment claiming sublist gas limits are "enforced separately" on import overstates it: the partitioner is the miner's, and there is no import-side sublist validator. Not a regression (it was never enforced), but the gas-fit rule therefore does not cover RSKIP-144 blocks.
Testing
2,585 tests pass (up from 2,529 — 56 new), clippy clean, and all four mainnet replay tests against this node's own store: 427 block-rule blocks, 12,400 uncle-bearing blocks, 300 fork-detection blocks, 670 RSKIP179 headers.
🤖 Generated with Claude Code
Activity