fix(market): guard execute_fee_rate_change with require_initialized - #649
Open
Akeem813 wants to merge 1 commit into
Open
fix(market): guard execute_fee_rate_change with require_initialized#649Akeem813 wants to merge 1 commit into
Akeem813 wants to merge 1 commit into
Conversation
execute_fee_rate_change was the only state-mutating contract entry point that did not call validation::require_initialized before operating on persistent storage. Every other mutating function (set_fee_rate, set_fee_cap, set_treasury, cancel_market, update_position, etc.) begins with require_initialized so that callers on an uninitialized contract receive ContractError::NotInitialized rather than silently reading or writing orphaned storage entries. Without the guard a caller could, in theory, write FeeRateBps storage via execute_fee_rate_change before the contract admin is set — producing a partially-configured contract state that is hard to reason about and inconsistent with the initialization invariant documented throughout the codebase. The timelock check itself (timestamp < effective_at → TimelockNotElapsed) is already correct and unchanged; this commit adds the missing initialization gate as the very first check in the function. Fixes: Vatix-Protocol#496
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.
Problem
execute_fee_rate_changewas the only state-mutating contract entry point that did not callvalidation::require_initializedbefore operating on persistent storage.Every other mutating function (
set_fee_rate,set_fee_cap,set_treasury,cancel_market,update_position, etc.) begins withrequire_initializedso callers on an uninitialized contract receiveContractError::NotInitializedrather than silently reading or writing orphaned storage entries.Without the guard a caller could write
FeeRateBpsstorage viaexecute_fee_rate_changebefore the contract admin is set — producing a partially-configured contract state inconsistent with the initialization invariant documented throughout the codebase.What Changed
execute_fee_rate_changenow opens with:This is the same guard used by every other mutating function. The existing timelock check (
timestamp < effective_at → TimelockNotElapsed) is unchanged.Files Changed
contracts/market/src/lib.rs— addrequire_initializedas the first check inexecute_fee_rate_changeAcceptance Criteria
effective_at) fails withTimelockNotElapsed— existing check, unchangedNotInitialized— new guardeffective_aton initialized contract) updatesFeeRateBps— existing behavior, unchanged