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

fix!: make committing a proposed batch atomic - #4551

Merged
raymondk merged 5 commits into
masterfrom
lwshang/reset-evidence-on-propose
Nov 24, 2026
Merged

raymondk merged 5 commits into
masterfrom
lwshang/reset-evidence-on-propose

Conversation

@lwshang

@lwshang lwshang commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two changes to how the asset canister commits a proposed batch.

1. Commit a proposed batch in a single message. Since #4450, commit_proposed_batch awaits a self-call once it passes 35B instructions, and sets certified_data only after the last operation. If an operation fails after such an await, only the failing message rolls back: the operations applied before it stay live, and the certified tree no longer matches certified_data until the next successful commit. commit_proposed_batch now runs the state machine to completion within one message, so any failure, including running out of instructions, rolls back the whole commit, as before 0.30.2. The cost is that a proposed batch is again bounded by the per-message instruction limit. commit_batch keeps the self-call extension.

This changes ic_certified_assets::commit_proposed_batch from async fn to fn (breaking for direct callers of the crate); the Candid interface is unchanged.

2. Discard computed evidence when a batch's arguments change. propose_commit_batch now clears any evidence previously computed for the batch, and commit_proposed_batch clears it when it takes the proposed arguments, so evidence always describes the arguments the batch currently holds and new arguments need a fresh compute_evidence.

How Has This Been Tested?

  • New unit test evidence_does_not_carry_over_to_reproposed_arguments covers change 2 (fails without it).
  • Change 1 is at the canister entry point and only differs from the previous behaviour once a commit passes 35B instructions, which unit tests can't reach; no automated test covers it.
  • All 111 ic-certified-assets lib tests pass; clippy is clean.
  • src/distributed/assetstorage.wasm.gz rebuilt with ./scripts/update-frontend-canister.sh --release-build.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

🤖 Generated with Claude Code

lwshang and others added 3 commits October 19, 2026 12:01
propose_commit_batch now clears any evidence previously computed for the batch,
and commit_proposed_batch clears it when it takes the proposed arguments. Since
commit_proposed_batch can span several messages, a failure after the first one
leaves the batch in place without its arguments; its evidence must not validate
arguments proposed for it afterwards.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
commit_proposed_batch no longer awaits self-calls to extend its instruction
budget. A failure after an await rolled back only the failing message, leaving
the operations applied before it live and certified_data stale. Committing in
one message makes the commit all-or-nothing again, as it was before 0.30.2, at
the cost of bounding a proposed batch by the per-message instruction limit.
commit_batch keeps the extension.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@lwshang lwshang changed the title fix: discard a batch's computed evidence when its arguments change fix!: make committing a proposed batch atomic Oct 27, 2026
ShellCheck 0.11.0 (now on ubuntu-latest) split unused-function warnings
out of SC2317 into the new SC2329, which flags the unused warn() helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lwshang
lwshang marked this pull request as ready for review November 24, 2026 13:08
@lwshang
lwshang requested a review from a team as a code owner November 24, 2026 13:08
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:08
@zeropath-ai

zeropath-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed 3 of 7 changed files (4 skipped) up to 26a99a7.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► src/canisters/frontend/ic-certified-assets/src/lib.rs
    - Change commit_proposed_batch from async to sync and adjust loop to complete within a single message
► src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs
    - Reset evidence_computation when arguments are changed or commit spans multiple messages
► src/canisters/frontend/ic-certified-assets/src/tests.rs
    - Update tests to reflect new evidence handling and commit workflow
► docs/design/asset-canister-interface.md
    - Added note about single-message commit behavior

Copilot AI 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.

🟡 Changes recommended

The regression test clears evidence before re-proposing, so it cannot detect missing proposal-time invalidation and needs a case that starts with stale computed evidence.

1 open issue
What changed in this PR

This PR restores atomic commits for proposed asset batches, preventing failed commits from leaving partial changes live or certification data inconsistent.

Changes:

  • Run commit_proposed_batch synchronously in one message; commit_batch retains self-call extension.
  • Clear computed evidence when proposed arguments are replaced or taken, with regression coverage.
  • Document the breaking Rust API change and per-message instruction limit.
File Description
src/​canisters/​frontend/​ic-certified-assets/​src/​tests.rs Adds a regression test for stale evidence after re-proposal.
src/​canisters/​frontend/​ic-certified-assets/​src/​state_machine/​mod.rs Clears evidence when proposed arguments change or are taken.
src/​canisters/​frontend/​ic-certified-assets/​src/​lib.rs Makes proposed-batch commits synchronous and single-message.
src/​canisters/​frontend/​ic-certified-assets/​CHANGELOG.md Records the API change and evidence invalidation fix.
docs/​design/​asset-canister-interface.md Documents rollback guarantees and commit size constraints.
CHANGELOG.md Describes user-facing behavior changes and updates the frontend module hash.

Review effort: Balanced

@raymondk
raymondk merged commit 7ff1a90 into master Nov 24, 2026
112 checks passed
@raymondk
raymondk deleted the lwshang/reset-evidence-on-propose branch November 24, 2026 14:35
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.

3 participants