Probe nested + flat SignalService checkpoint layouts (forward-compat)#116
Draft
davidtaikocha wants to merge 5 commits into
Draft
Probe nested + flat SignalService checkpoint layouts (forward-compat)#116davidtaikocha wants to merge 5 commits into
davidtaikocha wants to merge 5 commits into
Conversation
…-version-probe # Conflicts: # crates/pipeline/src/forks/shasta/spec.rs # crates/primitives/src/lib.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
raiko2's Shasta stalled-anchor path reads the parent checkpoint (
blockHash,stateRoot) from the L2 SignalService (checkpoint-store predeploy0x…0005) via a witness storage proof, to pin the anchor when the L1 anchor has stalled. The record lives in a mapping at slot 254.taiko-monoorigin/main): flatmapping(uint48 blockNumber => CheckpointRecord)→ record slotkeccak(blockNumber ‖ 254). ← what raiko2 computes today; correct.taiko-alethia-protocol-v3.0.0): nestedmapping(uint256 VERSION => mapping(uint48 blockNumber => CheckpointRecord))withVERSION = 1→ record slotkeccak(blockNumber ‖ keccak(VERSION ‖ 254)).Once the nested layout ships to L2, raiko2's flat-only derivation would read an unpopulated slot, trip the non-zero guard, and make stalled-anchor proposals unprovable (a liveness halt confined to that edge case). This PR makes the read forward-compatible by probing both layouts, so no L2-side flag-day coordination is needed.
How
One derivation —
shasta_checkpoint_storage_slot_candidates()— returns both candidate(blockHash, stateRoot)slot pairs in precedence order (nested-v1 first, then flat); host and guest both consume it, so their slot math cannot drift:crates/primitives/src/chain_spec.rs—SHASTA_CHECKPOINT_VERSION, flat + nested derivations,…_candidates(), and hardcoded self-contained slot tests.crates/pipeline/src/forks/shasta/spec.rs— preflight requestseth_getProoffor all candidate slots.crates/guest-common/src/lib.rs—verified_parent_shasta_checkpointprobes nested-then-flat.Soundness
This is a correctness/liveness change — not soundness — and it adds no new forgery surface. Every read is MPT-proven against the parent state root (bound to the on-chain parent block hash). The probe is fail-closed: a missing/unresolvable proof → error (propagated via
?, no fallback); only a proven-zeroblockHashadvances to the next candidate; all-absent → error. An attacker controlling the witness can neither forge a value nor forge a slot's absence, and cannot steer which layout is read (the block-number index is itself an MPT-proven, host-cross-checked value). Verified end-to-end by an independent review.Limitations (accepted)
VERSION = 1(the SignalServiceVERSIONis a Solidityconstant, not readable from storage). A futureVERSIONbump needs a one-line constant update; flagged with a loud comment.Testing
cargo clippy -p raiko2-primitives -p raiko2-guest-common -p raiko2-pipeline -- -D warnings— clean.cargo test -p raiko2-primitives -p raiko2-guest-common -p raiko2-pipeline— pass. The sole failure,shasta_backends_return_expected_elves, is the pre-existing missing-SP1-ELF environment issue, unrelated to this change.cargo fmt --allapplied.Non-blocking follow-ups
#[allow(clippy::too_many_arguments)]onread_checkpoint_record(6 args — never trips).Base branch
Targets
main(consistent with the F-1 fix #115). Per the dual-branch convention this likely needs a port tomainnet— leaving that to maintainers.🤖 Generated with Claude Code