Title: feat: apply CEI pattern, guardian pause, M-of-N verifiers, and lint config to accountability_vault#419
Open
Andreschuks101 wants to merge 1 commit into
Open
Conversation
|
@Andreschuks101 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.
Summary
slash_on_miss,claim, andwithdraw— vault status andstakedare zeroed in storage before anytoken::Client::transfercall, ensuring terminal state is committed even if the downstream token call panics.guardianaddress andpausedflag toVault; introduceemergency_pause/emergency_unpausefunctions that blockslash_on_miss,claim, and active-vaultwithdrawwhile paused. Only the guardian set at vault creation may toggle the flag.verifier: AddresswithVerifierSet { verifiers: Vec<Address>, threshold: u32 }.check_innow accumulates per-milestone approvals inDataKey::MilestoneApprovals(index)and flipsMilestone.verifiedonly oncethresholddistinct addresses have approved. Double-approval by the same address returnsError::AlreadyApproved.contracts/rustfmt.tomlwith workspace formatting config; add[workspace.lints.clippy] all = "warn"tocontracts/Cargo.tomland[lints] workspace = truetocontracts/accountability_vault/Cargo.toml; fix the brokenreclaim_after_settlementimplementation (wrong type usage and incorrect field check); suppress pre-existingdead_codelint in test setup struct with#[allow(dead_code)].Changes
contracts/accountability_vault/src/lib.rsVerifierSetcontracttype struct (groupsverifiers+thresholdto stay within Soroban's 10-parameter limit)DataKey::MilestoneApprovals(u32)storage keyErrorvariants:Paused = 18,AlreadyApproved = 19,NoVerifiers = 20,InvalidThreshold = 21,StakedRemaining = 22guardian: Addressandpaused: boolfields toVaultverifier: Addresswithverifiers: Vec<Address>andapproval_threshold: u32inVaultcreate_vault: acceptsverifier_set: VerifierSetandguardian: Address; validates non-empty verifiers and valid thresholdcheck_in: M-of-N approval tracking with double-approval guardextend_deadline: removedverifierparameter; all stored verifiers must co-sign viarequire_authslash_on_miss,claim,withdraw: CEI reorder (state persisted before token transfer) +pausedgateemergency_pauseandemergency_unpausereclaim_after_settlement: load vault from storage, usevault.staked, usetoken::Clientcontracts/accountability_vault/src/test.rssetup/setup_with_oraclehelpers and allcreate_vaultcall sites to useVerifierSetextend_deadlinecalls to two-argument formtest_cei_slash_on_miss_state_is_terminal_before_transfer,test_cei_claim_state_is_terminal_before_transfer,test_cei_slash_cannot_be_triggered_twice,test_cei_claim_cannot_be_triggered_twicetest_pause_blocks_slash_on_miss,test_pause_blocks_claim,test_pause_blocks_withdraw_active,test_unpause_allows_slash_on_miss,test_unpause_allows_claim,test_non_guardian_cannot_pause,test_pause_does_not_block_draft_withdrawtest_multi_verifier_single_approval_insufficient_for_threshold_two,test_multi_verifier_both_approve_verifies_milestone,test_multi_verifier_double_approval_by_same_verifier_fails,test_multi_verifier_threshold_one_of_two_single_approval_sufficient,test_multi_verifier_2of2_full_claim_flowtest_create_vault_invalid_threshold_exceeds_verifiers_fails,test_create_vault_zero_threshold_failscontracts/README.md: documented CEI invariant, guardian role, M-of-N model, updated error table, added lint/format commands.contracts/rustfmt.toml: new file with workspace formatting config.contracts/Cargo.toml: added[workspace.lints.clippy] all = "warn".contracts/accountability_vault/Cargo.toml: added[lints] workspace = true.Test plan
cargo test— 0 failures, 0 warnings)