fix: remove dead writes before panic in accept_intent - #335
Merged
james2177 merged 2 commits intoSep 3, 2026
Merged
Conversation
Soroban discards all storage mutations from a panicking invocation, so the .set() and bump_intent_ttl() calls immediately before panic_with_error!(Error::IntentExpired) in accept_intent's expiry branch were dead writes that never committed. - Remove the dead .set()/bump_intent_ttl() calls - Replace with a comment explaining why no write is possible here - Add regression test accept_expired_intent_state_unchanged confirming the intent state remains Open (not Expired) after a failed accept, and that solver remains None - Update docs/111-expire-intent-event-coverage.md: status line, §2 past-tense reference, and new §6 documenting the cleanup Closes stellar-vortex-protocol#111 (dead write cleanup)
|
@Keengfk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
In accept_intent's expiry-check branch, two calls —
env.storage().persistent().set(...) and Self::bump_intent_ttl(...) — were made
immediately before panic_with_error!(&env, Error::IntentExpired). Because
Soroban discards all storage mutations from a panicking invocation, these
writes never committed. They were dead code that wasted CPU cycles staging a
write that would always be thrown away, and misled future maintainers into
believing the intent's state was being persisted before the panic.
What changed
intent_settlement/src/lib.rs
Removed the dead .set() and bump_intent_ttl() calls from accept_intent's expiry
branch. Replaced them with an inline comment explaining that no write is
possible at this call site — any mutation staged before a panic_with_error! is
discarded by the Soroban runtime — and that the durable Open → Expired
transition belongs exclusively to expire_intent.
intent_settlement/src/test.rs
Added accept_expired_intent_state_unchanged regression test. After a failed
accept_intent call on a past-deadline intent it asserts:
This makes the expected observable behavior explicit and guards against the
dead-write pattern being reintroduced accidentally.
docs/111-expire-intent-event-coverage.md
identified
removed and referencing the regression test
Testing
The existing accept_expired_intent_fails test is unaffected — the IntentExpired
panic behavior is unchanged. The new accept_expired_intent_state_unchanged
test adds the state-invariant assertion that was previously missing.
Out of scope
expire_intent itself is unchanged. It remains the sole function that durably
writes state: Expired to storage.
closes #279