[Core] Implement approve_upgrade function - #815
Merged
p3ris0n merged 2 commits intoAug 27, 2026
Conversation
Adds approve_upgrade, letting an admin-pool member cast a weighted vote on a Pending UpgradeProposal. The proposal transitions to Approved as soon as the tally reaches its snapshotted quorum, mirroring the existing approve_proposal / timelock-snapshot pattern already in this module. Voting is rejected once the proposal is no longer Pending (including past its voting-window expiry), and a voter cannot cast a second vote on the same proposal. Resolves BCPathway#654.
Contributor
|
@Hollujay please resolve conflicts |
…-upgrade-function # Conflicts: # contracts/admin/src/lib.rs
Contributor
Author
|
Conflicts resolved @p3ris0n |
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
Closes #654.
approve_upgrade(env, voter, proposal_id): lets an admin-pool member cast a vote on aPendingUpgradeProposal.1and may vote at most once per proposal (AdminError::DuplicateVoteon a second attempt).quorum, the proposal transitions fromPendingtoApprovedin the same call — mirroring the existingapprove_proposal/ timelock-snapshot pattern already in this module, so quorum is detected at the exact vote that completes it.Pending, including once itsexpires_atvoting window has passed (AdminError::ProposalNotPending).AdminErrorvariants:UpgradeProposalNotFound(12),ProposalNotPending(13),DuplicateVote(14) — spaced pastTimelockActive = 10and [Guards] Addrequire_valid_wasm_hashcheck #657'sInvalidWasmHash = 11to avoid discriminant collisions with that sibling PR.Scope note
submit_upgrade_proposal(#653) hasn't landed yet, so proposals are seeded directly via test-only storage writes in this PR's tests — no public submission API is added here.Test plan
cargo test -p bc-forge-admin— all existing tests pass, plus 7 new tests covering: vote recorded below quorum, quorum reached flips status toApproved, non-pool-member rejected, duplicate vote rejected, nonexistent proposal rejected, voting on an already-Approvedproposal rejected, voting after the window expires rejected.cargo fmt -- --checkclean.cargo clippy --all-targets -- -D warningsclean.