feat: add ExpiredTransaction event and resubmission queue#122
Merged
Conversation
This was referenced Apr 10, 2026
ExpiredTransaction event and resubmission queue
b427300 to
99c4f76
Compare
99c4f76 to
0b635f9
Compare
Snapshot the current slot before calling getSignatureStatuses so that a transaction which finalizes between the slot snapshot and the status check is seen as finalized (not missing), preventing it from being incorrectly marked as expired. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0b635f9 to
a7040bf
Compare
Introduces EventType::ExpiredTransaction fired when a submitted transaction's blockhash expires without being finalized. Adds a transactions_to_resubmit BTreeSet to state so that expired transactions are queued for resubmission and survived across upgrades. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a7040bf to
7d47203
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- In `process_transaction_resubmitted`: assert old_signature was in the queue (mirrors the insert assertion in `process_transaction_expired`) - In `process_transaction_succeeded/failed`: replace the defensive remove with an assertion that the signature is NOT queued — a transaction being finalized must still be in `submitted_transactions`, which means it was never fully resubmitted, so it cannot be in the resubmission queue at the same time Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
THLO
reviewed
Apr 13, 2026
| state.process_transaction_failed(signature); | ||
| } | ||
| EventType::ExpiredTransaction { signature } => { | ||
| state.process_transaction_expired(*signature); |
Contributor
There was a problem hiding this comment.
Why is the signature dereferenced here (unlike for other process_transaction functions)?
Contributor
Author
There was a problem hiding this comment.
Good point. I changed process_transaction_expired to take a &Signature for consistency with other similar methods.
THLO
approved these changes
Apr 13, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lpahlavi
added a commit
that referenced
this pull request
Apr 15, 2026
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>
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.
Summary
ExpiredTransactionevent type (CBOR tagn(10)) that records when a submitted transaction has an expired blockhash and a null on-chain status — meaning it will never be executed and must be resubmittedtransactions_to_resubmit: BTreeSet<Signature>state field, populated byExpiredTransactionevents and cleared on resubmission/finalization — survives canister upgrades since it is rebuilt by replaying the event logThis PR is the prerequisite for #120, which splits
monitor_submitted_transactionsinto two independent timers:finalize_transactionsemitsExpiredTransactionevents, andresubmit_transactionsdrains the queue.Stack
🤖 Generated with Claude Code