Skip to content

[Core] Implement approve_upgrade function - #815

Merged
p3ris0n merged 2 commits into
BCPathway:mainfrom
Hollujay:feature/654-approve-upgrade-function
Aug 27, 2026
Merged

[Core] Implement approve_upgrade function#815
p3ris0n merged 2 commits into
BCPathway:mainfrom
Hollujay:feature/654-approve-upgrade-function

Conversation

@Hollujay

@Hollujay Hollujay commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #654.

  • Adds approve_upgrade(env, voter, proposal_id): lets an admin-pool member cast a vote on a Pending UpgradeProposal.
  • Each voter carries weight 1 and may vote at most once per proposal (AdminError::DuplicateVote on a second attempt).
  • Once the weighted tally of votes reaches the proposal's snapshotted quorum, the proposal transitions from Pending to Approved in the same call — mirroring the existing approve_proposal / timelock-snapshot pattern already in this module, so quorum is detected at the exact vote that completes it.
  • Voting is rejected when the proposal isn't currently Pending, including once its expires_at voting window has passed (AdminError::ProposalNotPending).
  • New AdminError variants: UpgradeProposalNotFound (12), ProposalNotPending (13), DuplicateVote (14) — spaced past TimelockActive = 10 and [Guards] Add require_valid_wasm_hash check #657's InvalidWasmHash = 11 to 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 to Approved, non-pool-member rejected, duplicate vote rejected, nonexistent proposal rejected, voting on an already-Approved proposal rejected, voting after the window expires rejected.
  • cargo fmt -- --check clean.
  • cargo clippy --all-targets -- -D warnings clean.

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.
@p3ris0n

p3ris0n commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@Hollujay please resolve conflicts

…-upgrade-function

# Conflicts:
#	contracts/admin/src/lib.rs
@Hollujay

Copy link
Copy Markdown
Contributor Author

Conflicts resolved @p3ris0n

@p3ris0n
p3ris0n merged commit 9f6d3e2 into BCPathway:main Aug 27, 2026
3 checks passed
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.

[Core] Implement approve_upgrade function

3 participants