Skip to content

feat(soroban,stellar): upgrade path management, multi-sig auth, state snapshot, and tx sequencing#687

Open
Macnelson9 wants to merge 1 commit into
StellerCraft:mainfrom
Macnelson9:feat/issues-621-622-623-624-soroban-upgrade-multisig-snapshot-sequencing
Open

feat(soroban,stellar): upgrade path management, multi-sig auth, state snapshot, and tx sequencing#687
Macnelson9 wants to merge 1 commit into
StellerCraft:mainfrom
Macnelson9:feat/issues-621-622-623-624-soroban-upgrade-multisig-snapshot-sequencing

Conversation

@Macnelson9
Copy link
Copy Markdown
Contributor

Summary

Changes

packages/stellar/src/soroban.ts

  • validateUpgradeCompatibility(deployedSchema, newSchema) — pure compatibility check
  • scheduleContractUpgrade(...) — validates then returns a ContractUpgradeRecord
  • rollbackContractUpgrade(record) — cancels a pending upgrade
  • createMultiSigOperation(payload, config) — creates a pending multi-sig op
  • collectSignature(operation, signerPublicKey, config) — accumulates validated signatures
  • executeMultiSigOperation(operation) — marks approved op as executed
  • snapshotContractState(contractId, network, ...) — captures testnet contract storage
  • restoreContractState(contractId, snapshot, network, ...) — reapplies a snapshot on testnet

packages/stellar/src/service.ts

  • isSequenceConflict(error) — detects tx_bad_seq result codes
  • SequenceManager — in-memory sequence cache with getSequence, increment, refresh, clear
  • submitWithSequenceRetry(...) — submits with automatic conflict-resolution retry

Test plan

  • validateUpgradeCompatibility returns compatible for schema superset, incompatible when keys are removed or retyped
  • scheduleContractUpgrade throws on incompatible schemas
  • rollbackContractUpgrade throws on non-pending records
  • createMultiSigOperation enforces threshold bounds
  • collectSignature rejects unauthorized/duplicate signers; transitions to approved at threshold
  • executeMultiSigOperation throws when status is not approved
  • snapshotContractState / restoreContractState throw on non-testnet network values
  • restoreContractState throws when snapshot belongs to a different contract
  • isSequenceConflict matches tx_bad_seq error messages
  • SequenceManager.refresh updates cache from Horizon; increment bumps counter
  • submitWithSequenceRetry retries on conflict and succeeds with refreshed sequence

Closes #621
Closes #622
Closes #623
Closes #624

… snapshot, and tx sequencing

Issue StellerCraft#621 — Contract Upgrade Path Management
- Add `validateUpgradeCompatibility` to check deployed vs new storage key schemas
- Add `scheduleContractUpgrade` that validates compatibility before returning a pending record
- Add `rollbackContractUpgrade` to cancel pending upgrades before on-chain submission
- Reject upgrades that remove or retype existing storage keys to prevent state corruption

Issue StellerCraft#622 — Multi-Signature Authorization for Admin Operations
- Add `createMultiSigOperation` with configurable signer threshold and authorized signer set
- Add `collectSignature` to accumulate validated signatures; auto-approves at threshold
- Add `executeMultiSigOperation` to finalize approved operations
- Reject unauthorized signers, duplicate signatures, and operations below threshold

Issue StellerCraft#623 — Contract State Snapshot and Restore for Testnet Debugging
- Add `snapshotContractState` to serialize contract storage into a versioned portable snapshot
- Add `restoreContractState` to reapply a snapshot to a testnet contract
- Guard both operations to testnet only; throw on any other network value
- Injectable entry fetcher/applier for testability without live RPC

Issue StellerCraft#624 — Stellar Payment Channel Transaction Sequencing with Conflict Resolution
- Add `isSequenceConflict` to detect tx_bad_seq / bad_seq Horizon result codes
- Add `SequenceManager` class with in-memory sequence cache, increment, and Horizon refresh
- Add `submitWithSequenceRetry` that detects conflicts, refreshes the sequence from Horizon, and retries submission with the corrected sequence number

Closes StellerCraft#621
Closes StellerCraft#622
Closes StellerCraft#623
Closes StellerCraft#624
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@Macnelson9 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant