Repository navigation
fix: audit scope counts, redeploy guide, and pause guards (#487, #488, #491, #492) - #658
Merged
Conversation
…Official#487, ChainLearnOfficial#488, ChainLearnOfficial#491, ChainLearnOfficial#492) - Update SECURITY.md audit scope line counts to reflect all contract source files - Document deployment file backup/removal requirement for Option C in upgrade-guide.md - Add test coverage verifying enroll_checked is blocked during emergency pause - Allow revoke_delegation during pause while keeping delegate_progress blocked
|
@Joeloo1 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! 🚀 |
…ificantly-understated
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
This PR addresses and resolves four distinct issues across documentation, operational upgrade procedures, and contract security/pause behavior:
enroll_checked(Closes enroll_checked is pub and bypasses require_not_paused, allowing enrollment during emergency pause #491)revoke_delegationDuring Emergency Pause (Closes revoke_delegation is blocked during pause, preventing learners from revoking malicious delegates #492)Detailed Changes
1. Update Audit Scope in
SECURITY.md(Closes #487)SECURITY.mdsignificantly understated the line counts (roughly half of actual values) and omitted several contract source files (such asevents.rsincredential-nftandprogress-tracker).learn-token(lib.rs,storage.rs,events.rs): ~5,230 lines (actual: 5,227)credential-nft(lib.rs,mint.rs,verify.rs,metadata.rs,xcall.rs,events.rs): ~2,660 lines (actual: 2,663)progress-tracker(lib.rs,types.rs,rewards.rs,events.rs): ~5,050 lines (actual: 5,049)shared(constants.rs,lib.rs): ~100 lines (actual: 96)2. Document Deployment File Backup/Removal for Option C (Closes #488)
docs/upgrade-guide.md, Option C (and Nuclear Redeployment) instructed running./scripts/deploy.sh <network>. However,scripts/deploy.shcontains an intentional safety guard (lines 62–66) that aborts ifdeployments-<network>.jsonalready exists, causing operators to hit an unexpected error without guidance during time-sensitive recovery.deploy.shguard and its safety rationale.mv deployments-testnet.json deployments-testnet.backup.$(date +%s).json) or remove the deployment file before re-runningdeploy.sh.3. Ensure
enroll_checkedRespects Contract Pause State (Closes #491)enroll_checkedis a public entrypoint onprogress-tracker. Direct callers bypassingenrollmust not be able to mutate contract state when the contract is paused.Self::require_not_paused(&env)executes at the very beginning ofenroll_checkedincontracts/progress-tracker/src/lib.rs.test_enroll_checked_panics_when_paused(#[should_panic(expected = "contract is paused")]) incontracts/progress-tracker/src/lib.rs.tests/integration/emergency_pause_flow.rsverifying thattry_enroll_checkedreverts during pause and succeeds upon unpause.4. Allow
revoke_delegationDuring Emergency Pause (Closes #492)revoke_delegationpreviously calledSelf::require_not_paused(&env). When a contract is emergency-paused (e.g. if a delegate is compromised), learners were unable to revoke their delegation to prevent malicious actions once unpaused. Safety-reducing operations should be frozen, but safety-enhancing/risk-reducing operations (revoking access) should remain accessible.Self::require_not_paused(&env)fromrevoke_delegationincontracts/progress-tracker/src/lib.rs.Self::require_not_paused(&env)indelegate_progressso new delegations remain blocked during pause.test_revoke_delegation_succeeds_when_pausedincontracts/progress-tracker/src/lib.rsand intests/unit/progress_tests.rs.test_delegate_progress_panics_when_pausedincontracts/progress-tracker/src/lib.rsverifyingdelegate_progressremains strictly blocked during pause.Verification & Testing
cargo check --workspace --all-targetspassed cleanly with 0 errors.cargo test -p progress-tracker test_enroll_checked_panics_when_paused-> PASSEDcargo test -p progress-tracker test_delegate_progress_panics_when_paused-> PASSEDcargo test -p progress-tracker test_revoke_delegation_succeeds_when_paused-> PASSEDcargo test --test progress_tests(107 tests) -> ALL 107 PASSEDcargo test --test emergency_pause_flow(4 tests) -> ALL 4 PASSED