Skip to content

fix(stellarkraal): prevent same-ledger loan ID collisions - #162

Merged
teslims2 merged 1 commit into
Stellar-kraal:mainfrom
safal207:fix/94-open-loan-id-collision
Sep 1, 2026
Merged

teslims2 merged 1 commit into
Stellar-kraal:mainfrom
safal207:fix/94-open-loan-id-collision

Conversation

@safal207

Copy link
Copy Markdown

Summary

  • add a checked contract-instance nonce to the open_loan ID seed so a same-asset reopen in the same ledger does not reuse the settled loan's storage key
  • keep the public open_loan ABI unchanged and return ArithmeticError if the nonce cannot advance
  • add an open β†’ full repayment β†’ reopen regression without ledger advancement, asserting distinct IDs and preservation of the original closed loan record
  • update the affected Soroban snapshots

Validation

Negative control on base cca5f033318f43cb9b18060d161873d75df58381: failed as expected because both opens produced 183e3685794406772e06e088efceb884f8c4a88ea55d54d5fbb398d5429e7938.

Scoped checks on this change:

  • focused same-ledger reopen regression β€” PASS
  • stellarkraal tests β€” PASS (18 unit, 6 lifecycle, 0 doc tests)
  • cargo fmt -p stellarkraal -- --check β€” PASS
  • cargo clippy --locked -p stellarkraal --all-targets -- -D warnings β€” PASS
  • cargo clippy --locked -p stellarkraal --lib -- -D warnings -D clippy::arithmetic_side_effects β€” PASS
  • stellarkraal release WASM build β€” PASS

Repository-wide status

The scoped package checks above pass. Repository-wide gates remain blocked on current main by unrelated, pre-existing issues: the nested [workspace] in contracts/carbon_credit/fuzz, duplicate TTL constants in carbon_marketplace after a validation-only workspace bypass, and existing carbon_marketplace formatting drift. This PR does not modify those paths.

Fixes #94

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.

[Smart Contract] Harden open_loan ID Generation Against Same-Ledger Collisions in stellarkraal

2 participants