Skip to content

fix: remove dead writes before panic in accept_intent - #335

Merged
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
Keengfk:fix/accept-intent-dead-writes
Sep 3, 2026
Merged

fix: remove dead writes before panic in accept_intent#335
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
Keengfk:fix/accept-intent-dead-writes

Conversation

@Keengfk

@Keengfk Keengfk commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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:

  • The call returns Error::IntentExpired (existing behavior unchanged)
  • get_intent still returns state: Open — no partial write committed
  • intent.solver is still None — no partial write committed

This makes the expected observable behavior explicit and guards against the
dead-write pattern being reintroduced accidentally.

docs/111-expire-intent-event-coverage.md

  • Status line updated to note the dead writes were cleaned up
  • §2 updated to past tense — the dead writes have been removed, not just
    identified
  • New §6 "Code Cleanup (dead write removal)" added, documenting what was
    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

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)
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@james2177
james2177 merged commit 371945a into stellar-vortex-protocol:main Sep 3, 2026
2 of 13 checks passed
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.

[High] Fix the dead state-write in accept_intent's expiry branch

2 participants