Skip to content

feat(settlement): add checkpoint entrypoint for bounded storage growth#589

Open
GBOYEE wants to merge 28 commits into
CalloraOrg:mainfrom
GBOYEE:task/checkpoint
Open

feat(settlement): add checkpoint entrypoint for bounded storage growth#589
GBOYEE wants to merge 28 commits into
CalloraOrg:mainfrom
GBOYEE:task/checkpoint

Conversation

@GBOYEE

@GBOYEE GBOYEE commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Adds a checkpoint() admin entrypoint to the settlement contract that snapshots the global pool balance and developer index into a timestamped checkpoint record, enabling bounded storage growth via future archival/pruning logic.

Changes

  • StorageKey::Checkpoint — persistent storage for the latest snapshot
  • StorageKey::CheckpointCounter — instance counter for monotonic checkpoint IDs
  • Checkpoint struct — checkpoint_id, total_pool_balance, developer_count, ledger_timestamp, timestamp
  • checkpoint(env, caller) — admin-only entrypoint that creates a snapshot
  • current_checkpoint(env) — read-only getter
  • CheckpointEvent — emitted on each checkpoint creation
  • Tests: returns none before init, creates snapshot with correct values, increments checkpoint_id

Testing

  • checkpoint_before_init_returns_none
  • checkpoint_creates_snapshot
  • checkpoint_increments_id

Closes #567

root added 28 commits June 28, 2026 17:23
Adds:
- StorageKey::Checkpoint and CheckpointCounter for snapshot storage
- Checkpoint struct (checkpoint_id, total_pool_balance, developer_count, timestamps)
- checkpoint() admin entrypoint that snapshots global pool + developer index
- current_checkpoint() read-only getter
- CheckpointEvent emitted on each checkpoint
- Tests: before_init, creates_snapshot, increments_id

Closes CalloraOrg#567
Pre-existing test compilation errors:
- get_revenue_pool() called with extra args (lines 1405, 2614)
- get_settlement() called with extra args (line 2937)
- function with missing parameter name (line 3783)

These prevented entire workspace from compiling.
…ation

Removes:
- Second #[contractimpl] block (lines 1753-1846) with duplicate broadcast()
- Duplicate get_max_deduct() at line 1320

These caused 'name defined multiple times' compilation errors across the workspace.
- Remove duplicate get_storage_ttl from settlement
- Remove broken address/token/last_address code block
- Add missing type defs and StorageKey variants
- Remove duplicate #[contractimpl] in vault
- Fix migrate.rs and cargo fmt violations
…MetaKey

- Add developer: Address::generate(&env) to all 39 DeductItem blocks in test.rs
- Replace u16::MAX with u32::MAX (Soroban v22 compatibility)
- Fix StorageKey::Meta → MetaKey in lib.rs

Unblocks all 4 Callora PRs (vault compilation was failing CI)
…feature

- Restore lib.rs, test.rs and test modules from b3d2e5f (last working state
  before PR CalloraOrg#579 broke the build with -X theirs merge that removed module
  declarations for admin, errors, timelock, types, limits)
- Add Checkpoint struct and StorageKey::Checkpoint/CheckpointCounter variants
- Add checkpoint() admin entrypoint and current_checkpoint() getter
- SettlementError now re-exported from errors module (full enum with all variants)

Fixes: \CalloraOrg#567
- Replace inline type definitions with proper mod declarations
- Add missing mod declarations: admin, errors, limits, pagination, timelock, types
- Add pub use re-exports for SettlementError, PendingDeveloperMigration, types
- Remove duplicate get_storage_ttl functions (incompatible with SDK v22)
- Fix event structs: add token field to PaymentReceivedEvent and BalanceCreditedEvent
- Fix get_ttl() calls (not available in SDK v22)
- Fix SettlementError::OverDraft variant in errors.rs
- Fix test files: add missing token arg to receive_payment and cursor calls
- Fix test_invariant.rs: &(*env).clone() borrow issue
- Add DeveloperClaimWindow variant to StorageKey enum
- Fix all single-arg DeveloperBalance() calls to include token address
- Fix pagination::get_page() call to include usdc_token parameter
- Fix broadcast function String type mismatch (soroban_sdk::String)
- Reorder usdc_address declaration in withdraw_developer_balance
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.

Add settlement.checkpoint entrypoint

1 participant