docs(treasury): audit signer-list scaling cost against the existing max-signers cap - #521
Merged
misrasamuelisiguzor-oss merged 2 commits intoAug 31, 2026
Conversation
…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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #474.
Summary
Measures the actual per-call instruction cost of
set_signerandremove_signerat varying signer-list sizes and documents findings indocs/treasury-quorum-review.md.Audit findings
No
MAX_SIGNERScap exists. Issue #21 addedMAX_BATCH_SIZE=50(a per-batch-call cap), not a signer-count cap.Both operations are O(n) in the current
SignerListlength. Measured instruction costs at 101 signers (newsigner_list_scaling_test.rs):set_signer(add)set_signer(weight=0)remove_signerScaling ~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: missingDataKey::LastBulkAllow/LastBulkBlockvariantstreasury/src/deposits.rs:DataKey::Balancearity fix + missingenforce_withdrawal_limittreasury/src/disputes.rs: missingOk(())onresolve_dispute; strayOk(())inresolve_dispute_splitcrates/multisig/src/lib.rs:TreasuryErrordiscriminants —WithdrawalLimitExceeded=34,InvalidSplitRatio=35,ForceCancelNotAllowed=36,WorkflowNotRegisteredSigner=37settlement-workflow/src/lib.rs: duplicateDataKeyenum mergedsettlement-workflow/Cargo.toml: missingmultisigdependencytreasury/tests/multisig_quorum_property_test.rs: badprop_assert_eq!format stringtreasury/tests/multisig_version_lock_test.rs: exhaustive match updated for new variants