Repository navigation
fix: Treasury Pallet - Review #431 - #434
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea13f5c268
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[pallet::storage] | ||
| #[pallet::getter(fn treasury_portion)] | ||
| pub type TreasuryPortion<T: Config> = StorageValue<_, u8, ValueQuery>; | ||
| pub type TreasuryPortion<T: Config> = StorageValue<_, Permill, OptionQuery>; |
There was a problem hiding this comment.
Add storage migration for TreasuryPortion type change
TreasuryPortion was changed from StorageValue<_, u8, ValueQuery> to StorageValue<_, Permill, OptionQuery> without a corresponding runtime migration, so upgraded chains will still have old u8-encoded bytes under the same key. After upgrade, portion() now calls expect(...), and pallets/mining-rewards::on_finalize reads this every block, so a decode mismatch can trap block execution immediately after runtime upgrade. Please add an on_runtime_upgrade migration (or equivalent translation) before switching the storage encoding/query type.
Useful? React with 👍 / 👎.
| /// Placeholder for tests/chain-spec defaults. Production must set treasury_account | ||
| /// explicitly. | ||
| fn default() -> Self { | ||
| Self { treasury_account: [0u8; 32].into(), treasury_portion: 50 } | ||
| Self { treasury_account: [1u8; 32].into(), treasury_portion: Permill::from_percent(50) } |
There was a problem hiding this comment.
I think the safest approach here would be to make missing treasury config fail fast during genesis instead of silently misconfiguring the chain with a magic nonzero treasury address. So that would mean either reverting back to the zero address or updating the type to Option<AccountId>,
|
Here's my review of PR #434: Treasury Pallet - Review #431. OverviewThis PR changes Issues
|
#431