Skip to content

fix: handle resubmission replay for canisters without ExpiredTransaction#123

Closed
lpahlavi wants to merge 2 commits intomainfrom
lpahlavi/migrate-resubmission-queue
Closed

fix: handle resubmission replay for canisters without ExpiredTransaction#123
lpahlavi wants to merge 2 commits intomainfrom
lpahlavi/migrate-resubmission-queue

Conversation

@lpahlavi
Copy link
Copy Markdown
Contributor

@lpahlavi lpahlavi commented Apr 10, 2026

Summary

Canisters deployed before ExpiredTransaction was introduced (#122) have event logs where ResubmittedTransaction events have no preceding ExpiredTransaction. The updated state machine (#122) requires the transaction to be in transactions_to_resubmit before it can be resubmitted, so replaying such logs would panic.

The fix is a fallback in process_transaction_resubmitted: if the old signature is in submitted_transactions rather than transactions_to_resubmit (i.e. no preceding ExpiredTransaction in the log), process_transaction_expired is called inline first. This makes every replay of old event logs correct, with no separate migration step or post-replay scan needed.

To be removed after the staging migration is complete.

🤖 Generated with Claude Code

@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from 6278d71 to 0ad0215 Compare April 10, 2026 16:09
@lpahlavi lpahlavi changed the title feat: add migrate_resubmission_queue endpoint for staging migration feat: migrate resubmission queue during post_upgrade Apr 10, 2026
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-queue branch from 99c4f76 to 0b635f9 Compare April 10, 2026 16:24
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from 0ad0215 to bfc8681 Compare April 10, 2026 16:24
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-queue branch from 0b635f9 to a7040bf Compare April 10, 2026 18:32
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from bfc8681 to 3a69214 Compare April 10, 2026 18:34
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-queue branch from a7040bf to 7d47203 Compare April 10, 2026 18:39
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from 3a69214 to ef2dc10 Compare April 10, 2026 18:39
Base automatically changed from lpahlavi/resubmission-queue to main April 13, 2026 10:23
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from ef2dc10 to 0945f05 Compare April 14, 2026 14:27
Copilot AI review requested due to automatic review settings April 14, 2026 14:27
@lpahlavi lpahlavi changed the base branch from main to lpahlavi/single-round-timers April 14, 2026 14:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an upgrade-time migration intended to backfill missing ExpiredTransaction events for older staging deployments so that the resubmission queue logic remains correct after replaying the event log.

Changes:

  • Introduces migrate_resubmission_queue() to scan the audit log and append synthetic ExpiredTransaction events.
  • Adds a compatibility fallback in State::process_transaction_resubmitted for logs that predate ExpiredTransaction.
  • Hooks the migration into post_upgrade, and adds a storage helper to record an event with an explicit timestamp.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
minter/src/storage/mod.rs Adds record_event_at to append events with an explicit timestamp.
minter/src/state/mod.rs Adds backward-compat logic when replaying old ResubmittedTransaction events.
minter/src/migrate.rs New migration that scans the event log and appends synthetic ExpiredTransaction events.
minter/src/lifecycle.rs Calls the migration during post_upgrade and logs the count.
minter/src/lib.rs Registers the new migrate module.
minter/cksol_minter.did Trailing whitespace/newline adjustment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/migrate.rs Outdated
Comment thread minter/src/migrate.rs Outdated
Comment thread minter/src/storage/mod.rs Outdated
Comment thread minter/src/lifecycle.rs Outdated
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from 0945f05 to cfa0d73 Compare April 14, 2026 15:07
Base automatically changed from lpahlavi/single-round-timers to main April 14, 2026 17:00
Copilot AI review requested due to automatic review settings April 15, 2026 06:21
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from cfa0d73 to 4748e32 Compare April 15, 2026 06:21
Canisters deployed before ExpiredTransaction was introduced (#122) have
event logs where ResubmittedTransaction events have no preceding
ExpiredTransaction. The updated state machine requires the transaction
to be in transactions_to_resubmit before it can be resubmitted, so
replaying such logs would panic.

The fix is a fallback in process_transaction_resubmitted: if the old
signature is in submitted_transactions rather than transactions_to_resubmit,
process_transaction_expired is called inline first. This makes every
replay of old event logs correct.

To be removed after the staging migration is complete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lpahlavi lpahlavi force-pushed the lpahlavi/migrate-resubmission-queue branch from 4748e32 to a99910a Compare April 15, 2026 06:21
@lpahlavi lpahlavi changed the title feat: migrate resubmission queue during post_upgrade fix: handle resubmission replay for canisters without ExpiredTransaction Apr 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread minter/src/state/mod.rs
Comment thread minter/src/state/mod.rs
@lpahlavi lpahlavi changed the title fix: handle resubmission replay for canisters without ExpiredTransaction fix: handle resubmission replay for canisters without ExpiredTransaction Apr 15, 2026
@lpahlavi lpahlavi closed this Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants