feat: Add admin action audit events for upgrade - #325
Merged
Conversation
- Implement upgrade() function with admin authorization - Emit event containing requested WASM hash before upgrade - Add tests for upgrade event emission and authorization - Document event schema for operators
|
@Gentleslyl2006 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
upgrade(); add unit tests and include the event schema for operators.Motivation
upgrade()is a privileged admin operation. Emitting a pre-upgrade audit event improves observability and allows operators/monitors to detect and validate proactive upgrade intentions before WASM is swapped.Changes
upgrade(e: Env, new_wasm_hash: BytesN<32>)which:upgradeevent with the requested WASM hash prior to performing the upgrade,upgrade()on the public contract interface.test_upgrade_emits_event— verifies theupgradeevent is emitted and contains the requested hash.test_upgrade_requires_admin_auth— verifies admin authorization is required.test_upgrade_before_init_fails— verifies upgrade before initialization fails.Event schema (for operators)
upgradeupgrade)BytesN<32>— the requested WASM hash (sha256 of uploaded WASM blob)Example event shape (semantic):
upgrade]<wasm_hash: BytesN<32>>Operators can watch for
upgradeevents and validate that:Testing
cargo test --libcargo test --lib test_upgrade_emits_event test_upgrade_requires_admin_auth test_upgrade_before_init_failsNotes & Compatibility
upgradeexposed from the contract).Checklist
upgradeevent schema (optional — I can add this in a follow-up commit)Suggested commit message
feat(security): emit audit event for admin
upgradeand add testsCloses #270