Repository navigation
Checkpoint count bound to published CIDs with an on-chain Merkle root - #68
Open
MarouaBoud wants to merge 7 commits into
Open
MarouaBoud wants to merge 7 commits into
MarouaBoud wants to merge 7 commits into
Conversation
Co-Authored-By: Lagartha <ionanova22@gmail.com>
…ted cost detectFailure records heartbeat-timeout or deadline-expiry evidence; reportFailure records agent-attested evidence; reportCost feeds B = (escrow - costAccrued) / escrow into both routers. Checkpoint count no longer sets the failure class. Co-Authored-By: Lagartha <ionanova22@gmail.com>
…detection Co-Authored-By: Lagartha <ionanova22@gmail.com>
…hain root commitCheckpointBatch takes the batch's CIDs; the count is their number and the Merkle root is computed from them, so the count that weights settlement cannot exceed what was committed (H-5). Co-Authored-By: Lagartha <ionanova22@gmail.com>
Co-Authored-By: Lagartha <ionanova22@gmail.com>
An internal Merkle node's sorted children form the same 64-byte preimage as a (cid, index) leaf, so without an index bound an internal node could verify as a checkpoint. The index must now be below the batch size. Co-Authored-By: Lagartha <ionanova22@gmail.com>
…uring recovery Co-Authored-By: Lagartha <ionanova22@gmail.com>
This was referenced Sep 29, 2026
This branch has not been deployed
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.
Builds on #67; the diff reduces to the commits below once #67 is merged.
What changed
commitCheckpointBatch(bytes32 taskId, bytes32[] cids, bytes32 schemaHash)replaces the(count, merkleRoot, latestCID)form. The batch size iscids.length(1–1,000), the last CID becomeslatestCheckpointCID, and the batch's Merkle root is computed on-chain: leafi=keccak256(abi.encodePacked(cids[i], i)), pairs hashed with OpenZeppelin's commutative keccak256, an odd last node promoted. The checkpoint count that weights settlement therefore equals the number of CIDs published (H-5). The contract commits to the CIDs; it does not verify the content they reference.verifyCheckpointrejectsleafIndex >= batchSize. A leaf and an internal node are both keccak256 of 64 bytes, so an internal node's sorted children could otherwise be presented as(cid, leafIndex)and verify as a checkpoint;test_InternalNodeAsLeaf_NotProvablereproduces this against the previous code.CairnCoreUpgradeable. Existing tests updated to the new signature; tests asserting caller-supplied roots now compare against an independently written reference root.Verification
forge test: 458 passing, includingCheckpointBinding.t.sol(count bounds, root parity fuzzed over 1–64 CIDs against a reference implementation, every leaf provable for sizes 2/5/8/13, unpublished CIDs and out-of-range indices not provable).CairnCore95.79%.GasBenchmark.t.sol, execution only): 160,587 for 1 CID, 174,035 for 10, 228,381 for 50, 1,633,412 for 1,000 — about 1.4k gas per checkpoint over a ~159k base (previously ~158.5k independent of count). Calldata adds 512 gas per CID plus Base's L1 data fee.