Repository navigation
Fix CRITICAL admin bootstrap & MEDIUM delegation cap - #308
Merged
dultimateade merged 2 commits intoOct 17, 2026
Merged
dultimateade merged 2 commits into
dultimateade merged 2 commits into
Conversation
CRITICAL (markets): Admin bootstrap allowed any caller when admin was unset. Added initialize() entrypoint that atomically stores admin and initialized flag. is_admin_internal() now returns false when no admin is stored (was true). Added pause_markets, unpause_markets, transfer_ownership, add_admin entrypoints all gated by assert_is_admin(). Added get_admin and is_paused read-only entrypoints. Fixed proptest error variant mismatch (AdminCooldownActive vs AdminActionTimelocked). MEDIUM (predictify-hybrid): Created delegation.rs with DelegationManager implementing set_delegate/unset_delegate. Enforces 10% cap on delegated voting power per address (MAX_DELEGATION_BPS=1000 of BPS_DENOMINATOR=10000). Cap checked at delegation time; excess rejected with DelegationCapExceeded. Added DelegationCapExceeded=676 error variant and updated err_stability snapshot (120→121 variants). Tests: 14 auth boundary tests for markets (initialize, pause/unpause, transfer_ownership, add_admin, admin-unset rejection, read-only). 13 unit tests in delegation.rs (basic delegation, cap boundary, multiple delegators, re-delegation, self-delegation rejection, zero stake, unset, cap calc).
|
@jc1788-byte 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
CRITICAL: markets contract admin bootstrap allows any caller
is_admin_internal()returnedtruewhen no admin was stored, allowing any caller to front-run deployment and callpause_markets,transfer_ownership,add_adminon a fresh deployment.initialize(env, admin)entrypoint that atomically storesDataKey::AdminandDataKey::Initialized.is_admin_internal()now returnsfalsewhen admin is unset. All admin entrypoints (pause_markets,unpause_markets,transfer_ownership,add_admin) are gated byassert_is_admin(). Addedget_adminandis_pausedread-only entrypoints.AdminActionTimelocked→AdminCooldownActive) that was failing CI.MEDIUM: predictify-hybrid delegation voting power uncapped
delegation.rsdid not exist;set_delegate/unset_delegateentrypoints were referenced in the event catalog but had no implementation, meaning delegated voting power was uncapped.contracts/predictify-hybrid/src/delegation.rswithDelegationManagerimplementingset_delegate/unset_delegate. Enforces a 10% cap on delegated voting power per address (MAX_DELEGATION_BPS=1000ofBPS_DENOMINATOR=10000). Cap is checked at delegation time; excess rejected withDelegationCapExceeded. AddedDelegationCapExceeded=676error variant and updated the err_stability snapshot (120→121 variants).What was tested
initializesets admin, rejects re-init, requires authpause_markets/unpause_marketsrequire admin, attacker rejectedtransfer_ownershipadmin-only, self-transfer rejectedadd_adminadmin-only, self rejecteddelegation.rscovering basic delegation, cap enforcement at boundary, multiple delegators, re-delegation, self-delegation rejection, zero stake rejection, unset without active delegation, and cap calculationNote
The
predictify-hybridcontract has 23 pre-existing compile errors (missing module files:analytics,audit,governance,versioning, etc., and an unclosed delimiter indisputes.rs). These are unrelated to this PR. The newdelegation.rsmodule produces zero compile errors itself, and themarketscontract builds and tests cleanly.closes #283
closes #270
closes #271
closes #284