Skip to content

Pre-Funding Split Ratio Lock #557

Description

@Kingsman-99

Description

Administrative functions may allow split ratios to be modified after invoice creation but before the funding target is reached, enabling a malicious or compromised admin to redirect funds mid-campaign. Once any contributor payment is recorded, the split ratios must be frozen and any subsequent mutation attempt must be rejected with an explicit error.

Technical Context

contracts/split/src/lib.rsupdate_split_ratio() or equivalent admin entry point that currently writes to DataKey::Recipients; contracts/split/src/storage.rs — add a read of DataKey::TotalContributed to determine whether any payment has landed before allowing writes; contracts/split/src/error.rs — add Error::SplitRatioLocked; contracts/split/src/events.rs — emit event::split_ratio_locked(invoice_id, locked_at_ledger) when the first contribution is recorded, signalling the freeze.

Acceptance Criteria

  • Calling update_split_ratio() when TotalContributed > 0 returns Error::SplitRatioLocked without modifying any storage entry
  • Calling update_split_ratio() when TotalContributed == 0 succeeds and writes the new ratios as before
  • The TotalContributed read and the ratio-write guard are performed within the same contract invocation with no observable TOCTOU window
  • A split_ratio_locked event is emitted exactly once — on the first pay() call — and includes the ledger sequence number
  • Tests in contracts/split/src/tests/ratio_lock_tests.rs cover: ratio update before first payment (allowed), after first payment (denied), and after full funding (denied)
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions