Skip to content

feat(admin): add emergency upgrade bypass - #846

Open
Hikmaholadele wants to merge 9 commits into
BCPathway:mainfrom
Hikmaholadele:feat/682-emergency-upgrade-bypass
Open

feat(admin): add emergency upgrade bypass#846
Hikmaholadele wants to merge 9 commits into
BCPathway:mainfrom
Hikmaholadele:feat/682-emergency-upgrade-bypass

Conversation

@Hikmaholadele

Copy link
Copy Markdown

Closes #682

Summary

  • Add unanimous-approval emergency upgrade bypass.
  • Preserve the existing timelock-based upgrade flow.
  • Update upgrade E2E tests to use a valid uploaded WASM fixture.
  • Add snapshots covering emergency upgrade behavior.

Closes #682

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Hikmaholadele 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

@p3ris0n

p3ris0n commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@Hikmaholadele please fix CI

Hikmaholadele added a commit to Hikmaholadele/bc-forge that referenced this pull request Aug 27, 2026
Resolve merge conflicts from PR BCPathway#846:
- lib.rs: keep both emergency_execute_upgrade (ours) and register_wasm_hash/
  require_valid_wasm_hash (main) with no code changes to either
- 581 snapshot files: accept main's versions (regenerable fuzz data, upstream is canonical)
- Emergency upgrade test snapshots (6 files) and upgrade_e2e.rs preserved from feature branch

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@p3ris0n

p3ris0n commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@Hikmaholadele please fix CI and resolve conflicts

Hikmaholadele and others added 8 commits August 27, 2026 11:21
Add `withdraw`, which burns wrapped shares and returns a pro-rata share
of the vault's underlying assets (principal + accrued yield):

  tokens_out = shares * total_assets / total_shares

Payouts round down to favor the protocol and revert if they round to
zero. Withdrawals are guarded by the existing reentrancy lock, paused
state, and share-balance checks. Emits a `withdrw` event.

Adds unit tests covering happy paths (partial/full/multi-user
withdrawals, yield compounding, rounding) and error states (zero,
negative, insufficient shares, paused, uninitialized, dust payout),
regenerates stale wrapper snapshots, and exposes `withdraw` on the
TypeScript WrapperClient.

Closes BCPathway#721

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
BCPathway#730)

Adds the require_unlocked modifier to the vault (wrapper) contract. The
guard checks env.ledger().timestamp() against the user's recorded unlock
time and reverts with WrapperError::TokensLocked while the deposit is
still locked, and is wired into withdraw so locked deposits cannot be
exited early.

New admin-gated entry points set_unlock_time/clear_unlock_time record and
remove the per-user deposit lockup, and get_unlock_time exposes the stored
unlock timestamp. Lockup state is stored per-user in persistent storage
under DataKey::UnlockTime(Address). Unit tests cover the happy paths
(withdrawal at and after the unlock time) and error states (locked revert,
per-user isolation, non-admin rejection, uninitialized contract).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…t after main merge

Merging main into the unlocked-modifier branch duplicated the `withdraw`
entry point (main's copy plus the branch's copy with the BCPathway#730
require_unlocked guard) and gave ZeroShares the same discriminant as
TokensLocked, which broke compilation. Keep the lockup-guarded withdraw,
drop the duplicate, and renumber ZeroShares to 12. Also commit the
snapshot files for the share-price, supply, and pauser tests that
arrived with the merge.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Allows the proposer of a multi-sig UpgradeProposal to withdraw it before
execution. The proposal is marked ProposalStatus::Cancelled rather than
deleted, preserving its history. Reverts with ProposalAlreadyExecuted if
already executed, NotProposer if called by anyone other than the original
proposer, and ProposalNotCancellable if already Cancelled or Expired.

Resolves BCPathway#662
Add --estimate option to the upgrade command that uses Soroban
simulateTransaction to calculate gas and estimate total fee cost
without submitting on-chain. Returns base fee, resource fee, and
total fee in stroops.
Adds integration tests exercising the full multi-sig gated WASM upgrade
lifecycle: deploy, register a new WASM hash as a valid upgrade target,
submit a proposal, gather approvals to reach quorum, and drive
execute_upgrade through every governance gate (pool membership, quorum,
mandatory timelock) up to WASM installation. Fills a coverage gap: the
execute_upgrade error paths (QuorumNotMet, TimelockActive, UnauthorizedRole,
ProposalNotFound, ProposalAlreadyExecuted) had no dedicated tests before.

Resolves BCPathway#672
- Add gitignore exception for testdata/*.wasm so the test fixture
  contract.wasm is tracked (previously excluded by *.wasm rule)
- Commit contract.wasm test fixture required by upgrade_e2e.rs tests
- Update Soroban auth snapshots to reflect RoleMask storage layout
  introduced by the main merge

This resolves three CI compilation errors:
1. E0425: emergency_execute_upgrade not found in module super
2. couldn't read contracts/admin/testdata/contract.wasm
3. E0425: emergency_execute_upgrade not found in crate bc_forge_admin

The emergency_execute_upgrade implementation itself was correctly
preserved through the merge; the failures were caused by the missing
WASM fixture and stale auth snapshots.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Hikmaholadele
Hikmaholadele force-pushed the feat/682-emergency-upgrade-bypass branch from 1998250 to 89e0873 Compare August 27, 2026 12:08
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.

[Guards] Emergency bypass for critical security patches

5 participants