Adding try_state hook for Treasury pallet#1820
Conversation
ggwpez
left a comment
There was a problem hiding this comment.
Looks very clean, thanks!
Should probably try this before merging on Polkadot and Kusama states, so we know that it all works.
|
bot fmt |
|
cargo fmt seems to break markdown lists in comments. I guess I should fix these manually before merging too. |
Yea... lines should wrap at exactly 100 chars - also comments. |
|
bot fmt |
It works on rococo state ( |
liamaharon
left a comment
There was a problem hiding this comment.
looking good, thanks!
|
I have added tests for all As for the tests: I really don't like catching errors based on a string value. An enum would be much cleaner, but I guess there's no other way for now? |
|
Thanks, tests look great 👌
|
* master: (54 commits) Publish `xcm-emulator` crate (#1881) Adding migrations to clean Rococo Gov 1 storage & reserved funds (#1849) Arkworks Elliptic Curve utils overhaul (#1870) Fix typos (#1878) fix: GoAhead signal only set when runtime upgrade is enacted from parachain side (#1176) Refactor staking ledger (#1484) Paired-key Crypto Scheme (#1705) Include polkadot version in artifact path (#1828) add link to rfc-0001 in broker README (#1862) Discard `Executor` (#1855) Macros to use path instead of ident (#1474) Remove clippy clone-double-ref lint noise (#1860) Refactor alliance benchmarks to v2 (#1868) Check executor params coherence (#1774) frame: use derive-impl for beefy and mmr pallets (#1867) sc-consensus-beefy: improve gossip logic (#1852) Adds instance support for composite enums (#1857) Fix links to implementers' guide (#1865) Disabled validators runtime API (#1257) Adding `try_state` hook for `Treasury` pallet (#1820) ...
…ribution * tsv-disabling-backing: (54 commits) Publish `xcm-emulator` crate (#1881) Adding migrations to clean Rococo Gov 1 storage & reserved funds (#1849) Arkworks Elliptic Curve utils overhaul (#1870) Fix typos (#1878) fix: GoAhead signal only set when runtime upgrade is enacted from parachain side (#1176) Refactor staking ledger (#1484) Paired-key Crypto Scheme (#1705) Include polkadot version in artifact path (#1828) add link to rfc-0001 in broker README (#1862) Discard `Executor` (#1855) Macros to use path instead of ident (#1474) Remove clippy clone-double-ref lint noise (#1860) Refactor alliance benchmarks to v2 (#1868) Check executor params coherence (#1774) frame: use derive-impl for beefy and mmr pallets (#1867) sc-consensus-beefy: improve gossip logic (#1852) Adds instance support for composite enums (#1857) Fix links to implementers' guide (#1865) Disabled validators runtime API (#1257) Adding `try_state` hook for `Treasury` pallet (#1820) ...
This PR adds a `try_state` hook for the `Treasury` pallet. Part of paritytech#239.
This PR adds a
try_statehook for theTreasurypallet.Part of #239.
The invariants checked are:
ProposalCountmust beProposals. TheProposalCountstorage value is only increased, but never decreased, whereas individual proposals can be removed from theProposalsstorage map.T::ProposalBondMinimum* Number of proposals with non-zero bondSince the introduction of the dispatchable$\textrm{p.bond} \neq 0 $ .
spend, a bond is no longer required (bond is set to zero in these cases). However, the old way of proposing using a bond is still available and we can filter for these by looking at proposals withT::ProposalBondMaximum* Number of proposals with non-zero bondAnalogous to 2., but only relevant when
T::ProposalBondMaximumis notNone.ProposalIndexcontained inApprovalsshould exist inProposals. Note, that thisautomatically implies
Approvals.count() <= Proposals.count().SpendCountmust beSpends. Follows the same reasoning as invariant 1.Spendswe should havespend.expire_at > spend.valid_from.