Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.

fix: bind stalled anchor checkpoint to parent state - #699

Merged
smtmfft merged 5 commits into
hotfix/hotfix-based-on-1.16.1from
fix/shasta-stalled-parent-checkpoint-hotfix
Jun 27, 2026
Merged

fix: bind stalled anchor checkpoint to parent state#699
smtmfft merged 5 commits into
hotfix/hotfix-based-on-1.16.1from
fix/shasta-stalled-parent-checkpoint-hotfix

Conversation

@smtmfft

@smtmfft smtmfft commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bind Shasta stalled-anchor bypass to the parent L2 SignalService checkpoint stored in parent state.
  • Preflight explicitly loads the parent checkpoint blockHash/stateRoot storage slots so the guest witness contains them.
  • Add regression coverage for accepting matching parent checkpoints and rejecting forged checkpoint calldata.

Complexity / Review Notes

  • Main guest logic is in lib/src/protocol_instance.rs: derive SignalService predeploy address from Anchor predeploy address, compute _checkpoints[blockNumber] slots, read parent storage trie, compare with decoded anchor tx calldata.
  • Host/preflight change is limited to batch Shasta stalled-anchor path with empty l1_ancestor_headers; it touches only the first block parent state because stalled anchors do not update the checkpoint.
  • .env local mrenclave changes are intentionally not included.

Test Plan

  • cargo test -p raiko-lib
  • cargo check -p raiko-core
  • git diff --check -- core/src/preflight/mod.rs lib/src/protocol_instance.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaf61b07de

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +528 to +532
let mut encoded = Vec::with_capacity(64);
encoded.extend_from_slice(&U256::from(block_number).to_be_bytes::<32>());
encoded
.extend_from_slice(&U256::from(SHASTA_SIGNAL_SERVICE_CHECKPOINTS_SLOT).to_be_bytes::<32>());
let block_hash_slot = U256::from_be_bytes::<32>(keccak(&encoded));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include the checkpoint VERSION mapping in slot hashing

For stalled Shasta batches with empty l1_ancestor_headers, this helper is used to load and verify the parent checkpoint, but the SignalService stores checkpoints as _checkpoints[VERSION][blockNumber], not as a flat mapping at slot 254. Hashing only blockNumber with slot 254 points at the wrong storage slots, so preflight proves empty/wrong values and read_parent_shasta_checkpoint rejects otherwise valid stalled-anchor batches before falling back to linkage verification with no headers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not apply to the checkpoint we read here.

This code is reading the L2 checkpoint storage from the L2 SignalService/anchor predeploy path, not the L1 SignalService v3.0.0 received-signal/checkpoint namespace. The L2 checkpoint storage used here is the flat mapping(uint48 => CheckpointRecord) at slot 254, so the slot is keccak256(abi.encode(blockNumber, uint256(254))), with +1 for stateRoot.

I also verified this against the current devnet L2 predeploy 0x1670010000000000000000000000000000000005: getCheckpoint(25454) returns the same blockHash/stateRoot as direct storage reads at the flat slot and slot + 1. Calling VERSION() on that L2 address reverts, which is consistent with this being the L2 checkpoint layout, not the L1 versioned SignalService layout. Adding VERSION here would read the wrong slots for this path.

@smtmfft
smtmfft merged commit abb64aa into hotfix/hotfix-based-on-1.16.1 Jun 27, 2026
11 of 12 checks passed
@smtmfft
smtmfft deleted the fix/shasta-stalled-parent-checkpoint-hotfix branch June 27, 2026 08:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants