Skip to content

docs(treasury): audit signer-list scaling cost against the existing max-signers cap - #521

Merged
misrasamuelisiguzor-oss merged 2 commits into
WHEELBACK:mainfrom
jessiE-bliz445:docs/multisig-signer-list-scaling-audit
Aug 31, 2026
Merged

docs(treasury): audit signer-list scaling cost against the existing max-signers cap#521
misrasamuelisiguzor-oss merged 2 commits into
WHEELBACK:mainfrom
jessiE-bliz445:docs/multisig-signer-list-scaling-audit

Conversation

@jessiE-bliz445

Copy link
Copy Markdown
Contributor

Closes #474.

Summary

Measures the actual per-call instruction cost of set_signer and remove_signer at varying signer-list sizes and documents findings in docs/treasury-quorum-review.md.

Audit findings

No MAX_SIGNERS cap exists. Issue #21 added MAX_BATCH_SIZE=50 (a per-batch-call cap), not a signer-count cap.

Both operations are O(n) in the current SignerList length. Measured instruction costs at 101 signers (new signer_list_scaling_test.rs):

Operation Instructions at 101 signers
set_signer (add) 1,100,746
set_signer (weight=0) 1,102,691
remove_signer 1,100,746

Scaling ~10,000 instructions/signer. Soroban limit is 100M — not an immediate concern at realistic deployment scale. Two low-priority follow-ups suggested in the doc.

Pre-existing compile errors fixed

  • compliance/src/lib.rs: missing DataKey::LastBulkAllow/LastBulkBlock variants
  • treasury/src/deposits.rs: DataKey::Balance arity fix + missing enforce_withdrawal_limit
  • treasury/src/disputes.rs: missing Ok(()) on resolve_dispute; stray Ok(()) in resolve_dispute_split
  • crates/multisig/src/lib.rs: TreasuryError discriminants — WithdrawalLimitExceeded=34, InvalidSplitRatio=35, ForceCancelNotAllowed=36, WorkflowNotRegisteredSigner=37
  • settlement-workflow/src/lib.rs: duplicate DataKey enum merged
  • settlement-workflow/Cargo.toml: missing multisig dependency
  • treasury/tests/multisig_quorum_property_test.rs: bad prop_assert_eq! format string
  • treasury/tests/multisig_version_lock_test.rs: exhaustive match updated for new variants

…ax-signers cap

Closes WHEELBACK#474.

## What this PR does

Measures the actual per-call instruction cost of set_signer and remove_signer
at varying signer-list sizes and documents findings in docs/treasury-quorum-review.md.

### Audit findings (new section in treasury-quorum-review.md)

- No MAX_SIGNERS cap exists anywhere in the codebase. Issue WHEELBACK#21 added
  MAX_BATCH_SIZE=50 (a per-batch-call cap), not a signer-count cap.
- Both operations are O(n) in the current SignerList length:
  set_signer (add): O(n) contains() scan + O(n) serialisation
  set_signer (zero): O(n) scan + O(n) full rewrite + O(n) serialise
  remove_signer: O(n) read + O(n) full rewrite + O(n) serialise
- Measured instruction costs at 101 signers (from signer_list_scaling_test.rs):
  set_signer (add):    1,100,746 instructions
  set_signer (zero):   1,102,691 instructions
  remove_signer:       1,100,746 instructions
- Linear scaling ~10,000 instructions/signer. Soroban limit is 100M.
  At this rate, ~9,800 signers would be needed to approach budget. Not
  an immediate concern at any realistic deployment scale.
- The cap absence is documented; two low-priority follow-ups suggested
  (add MAX_SIGNERS constant, add per-call budget assertion to the test).

### New test

contracts/treasury/tests/signer_list_scaling_test.rs measures set_signer
and remove_signer instruction costs at list sizes [1,6,11,21,51,101] using
env.cost_estimate().resources(). All 5 tests pass.

### Pre-existing compile errors fixed

The workspace had several compile errors on main that blocked cargo test --all.
Fixed as part of this PR to satisfy the issue's test-pass requirement:

- contracts/compliance/src/lib.rs: add DataKey::LastBulkAllow/LastBulkBlock
  variants referenced by bulk_allow_addresses/bulk_block_addresses but missing
  from the enum.
- contracts/treasury/src/deposits.rs: fix DataKey::Balance(from) missing second
  token_contract arg; add missing enforce_withdrawal_limit function.
- contracts/treasury/src/disputes.rs: add missing Ok(()) tail to resolve_dispute;
  remove stray Ok(()) from resolve_dispute_split (void return).
- crates/multisig/src/lib.rs: fix TreasuryError discriminants — move
  WorkflowNotRegisteredSigner to 37, add WithdrawalLimitExceeded=34,
  InvalidSplitRatio=35, ForceCancelNotAllowed=36.
- contracts/settlement-workflow/src/lib.rs: merge duplicate DataKey enum
  definitions into one.
- contracts/settlement-workflow/Cargo.toml: add missing multisig dependency.
- contracts/treasury/tests/multisig_quorum_property_test.rs: fix named-arg
  format string in prop_assert_eq! macro.
- contracts/treasury/tests/multisig_version_lock_test.rs: update exhaustive
  match and discriminant assertions for the three new TreasuryError variants.
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@jessiE-bliz445 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

@misrasamuelisiguzor-oss
misrasamuelisiguzor-oss merged commit fbfcbd1 into WHEELBACK:main Aug 31, 2026
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.

Audit whether crates/multisig's Vec<Address>-based signer list scales acceptably as signer count grows

2 participants