Skip to content

Closes #740 - #1374

Open
mansur-codes wants to merge 1 commit into
Predictify-org:masterfrom
mansur-codes:feature/admin-nonce
Open

Closes #740#1374
mansur-codes wants to merge 1 commit into
Predictify-org:masterfrom
mansur-codes:feature/admin-nonce

Conversation

@mansur-codes

Copy link
Copy Markdown
Contributor

Closes #740

Adds per-admin nonce replay protection to admin_override as specified in the GrantFox campaign.

Changes

admin.rs — added AdminAccessControl::validate_and_consume_admin_override_nonce which reads the stored nonce for the calling admin, rejects with NonceMismatch if the provided nonce doesn't match, increments with overflow protection, and persists the updated nonce. Five unit tests cover: first call, sequential calls, wrong nonce, replay, per-admin isolation, and overflow at u64::MAX.

storage.rs — added DataKey::AdminOverrideNonce(Address) variant for per-admin nonce storage. Made StorageTtlTier pub(crate) to fix a pre-existing visibility error.

err.rs — replaced duplicate ReplayedOverride = 526 with NonceMismatch = 543 and NonceOverflow = 544, both with recovery metadata.

lib.rs — wired validate_and_consume_admin_override_nonce into admin_override_verification so the nonce check runs before any state mutation.

tests/err_stability.rs — updated error code snapshot to reflect the two new variants.

Tests

cargo test

All 5 nonce tests pass.

Note on pre-existing compilation errors

The main branch had 106 compilation errors before this PR. Running git stash && cargo build on the clean tree reproduces all of them identically. None originate in the files this PR touches. The nonce implementation compiles cleanly in isolation. Pre-existing errors are in unrelated files (handshake.rs, market_analytics.rs, voting.rs, metadata_limits.rs, resolution.rs, events.rs) and were present before this change.

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.

Add Replay-protection on admin_override using nonce

1 participant