Description
In contracts/treasury/src/lib.rs, there is a storage-tier mismatch between where fee_bps is written and where set_fee_bps reads the old value:
initialize writes to instance storage:
env.storage().instance().set(&DataKey::FeeBps, &fee_bps);
set_fee_bps reads old value from persistent storage:
let old_bps: u32 = env
.storage()
.persistent() // ← wrong tier
.get(&DataKey::FeeBps)
.unwrap_or(50); // ← will always be 50 (default) on first update
Because the tiers are separate namespaces in Soroban, the old_bps read will always miss the value written by initialize and fall back to 50. The fee_rate_updated event will then always report the incorrect old fee, breaking any off-chain monitoring or audit tools that rely on the event log to reconstruct fee history.
Additionally, set_fee_bps writes the updated value back to persistent() while get_fee_bps (if it follows the same pattern as other getters) reads from instance(), causing further divergence.
Fix
Standardize to one storage tier throughout. The simplest fix is to use instance() everywhere for FeeBps (consistent with initialize), or document a deliberate migration to persistent().
Acceptance Criteria
Complexity: Low (75 points)
Description
In
contracts/treasury/src/lib.rs, there is a storage-tier mismatch between wherefee_bpsis written and whereset_fee_bpsreads the old value:initializewrites to instance storage:set_fee_bpsreads old value from persistent storage:Because the tiers are separate namespaces in Soroban, the
old_bpsread will always miss the value written byinitializeand fall back to50. Thefee_rate_updatedevent will then always report the incorrect old fee, breaking any off-chain monitoring or audit tools that rely on the event log to reconstruct fee history.Additionally,
set_fee_bpswrites the updated value back topersistent()whileget_fee_bps(if it follows the same pattern as other getters) reads frominstance(), causing further divergence.Fix
Standardize to one storage tier throughout. The simplest fix is to use
instance()everywhere forFeeBps(consistent withinitialize), or document a deliberate migration topersistent().Acceptance Criteria
initialize,set_fee_bps, and any fee getter all use the same storage tier forFeeBps.fee_rate_updatedevent correctly reports the old fee value.Complexity: Low (75 points)