test(#248): reject all-zero admin pubkey on initialize - #619
Merged
Conversation
…revoke Add a persistent per-user last-updated marker (DataKey::LastUpdated) that records the ledger timestamp of the most recent successful mint (mint_wrap / mint_wrap_batch) or revoke. Expose it via a new get_last_updated query and cover it with monotonicity tests. The baseline main branch did not compile against Soroban SDK 27 (broken merge ec4e11a plus pre-existing drift), so this change also repairs the crate to green: FSM transitions (Draft/Pending->Expired, Active->Pending for bridging), strict expiry deadline semantics, updated contract-error codes in tests, stake tests now set an explicit ledger timestamp (SDK 27 defaults it to 0), SDK 27 event-buffer reset handling, and clippy/fmt/doc cleanliness (-D warnings).
An all-zero Ed25519 public key has no known private key, so accepting it would silently brick every future mint_wrap call while leaving the contract in an initialized state. Reject it at initialize time with a new InvalidAdminPubKey error and cover the behavior with tests: - zero admin pubkey is rejected (Error(Contract, zintarh#52)) - a rejected zero-key attempt leaves the contract uninitialized so a valid initialize still succeeds
|
@EmannuellaO 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.
Closes #248
Summary
The contract previously accepted any
BytesN<32>as the admin signing key. An all-zero Ed25519 public key has no known corresponding private key, so accepting it would silently brick every futuremint_wrapcall (no valid signature could ever be produced) while leaving the contract in an initialized, degraded state.This PR rejects the all-zero key at
initializetime with a new contract error.Changes
errors.rs: addInvalidAdminPubKey = 52.admin.rs::initialize: panic withInvalidAdminPubKeywhen the provided pubkey is all-zero; document the rationale.test.rs: add tests coveringError(Contract, #52)),initializestill succeeds.Acceptance criteria
Verification
cargo fmt --checkcleancargo clippy --all-targets -- -D warnings0 errorsRUSTDOCFLAGS="-D warnings" cargo doc --no-deps0 errorsRUSTFLAGS="-D warnings" cargo test→ 174 passed / 0 failed / 1 ignored + 1 integration testNote: this branch is stacked on #618 (baseline SDK 27 repair) so CI can compile.