-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for adding try_state
hook to all pallets.
#239
Comments
I want to take this up. Can you please assign this to me ? |
This is a tracking issue, you can go ahead and work on any item, no need to assign 👍 |
@kianenigma The idea of the So removing duplicate tests after |
There are actually two advantages that |
Hello @ggwpez could I list out pallets I think won't require Hoping this might speed things up for other contributors :) |
Yes sure @Doordashcon. Marked them together with the nicks pallet. |
I will start working on the try-state for the referenda pallet if no one else picked that already. |
This issue has been mentioned on Polkadot Forum. There might be relevant details there: |
aura implemented here: paritytech/substrate#14363 |
Part of #239. Invariant 1. The number of entries in `Tips` should be equal to `Reasons`. 2. If `OpenTip.finders_fee` is true, then `OpenTip.deposit` should be greater than zero. 3. Reasons exists for each Tip[`OpenTip.reason`], implying equal length of storage. polkadot address: 12zsKEDVcHpKEWb99iFt3xrTCQQXZMu477nJQsTBBrof5k2h --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Part of: #239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This PR adds a `try_state` hook for the `Treasury` pallet. Part of paritytech#239.
Part of paritytech#239. Invariant 1. The number of entries in `Tips` should be equal to `Reasons`. 2. If `OpenTip.finders_fee` is true, then `OpenTip.deposit` should be greater than zero. 3. Reasons exists for each Tip[`OpenTip.reason`], implying equal length of storage. polkadot address: 12zsKEDVcHpKEWb99iFt3xrTCQQXZMu477nJQsTBBrof5k2h --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Part of: paritytech#239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Part of: #239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW
Part of: #239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW
Part of: paritytech#239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW
Part of: #239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
Part of: paritytech#239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
Part of: paritytech#239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
Recovery implemented here #5290 |
is the |
All pallets with non-trivial logic are. |
I like the idea of being able to call the try-state logic from unit tests. However, it looks like there is a lot of code duplication when implementing this for all the pallets. Why not have a |
Can you give an example of what |
Part of: paritytech#239 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
This hook was added in paritytech/substrate#10174. The idea is as follows:
(source)
In other words, the goal is to focus on invariants that must always be held in a pallet. A naive, yet important example of this is that in
pallet-balances
, iterating over all users should yield the correct total issuance.If in doubt, see a number of other pallets that already have this hook to get further inspiration.
Implementations should provide a clear and concise documentation as to why the given invariant must always hold.
Next, we want all pallets to call their
try_state
after each test. This can easily be achieved with a helper function like:polkadot-sdk/substrate/frame/nomination-pools/src/mock.rs
Lines 401 to 407 in 53f615d
Implementing this hook will allow these checks to be called in
try-runtime-cli
, and other testing tools that compile a runtime withfeature = try-runtime
.Note that for those who want to tackle a particular pallet, you must for sure deeply understand a pallet in order to correctly identify its list of invariants. Moreover, you might do your future generation a favor by documenting the invariants as good as you can.
TLDR Checklist
#[pallet::storage]
types, but sometimes also in#[pallet::config]
trait.#[cfg(any(feature = "try-runtime"), test)]
, and no storage must be altered.try_state
after each test, as per the example above.Pallet list
try-state
hook to pallet aura substrate#14363try_state
hook in elections and EPM pallets substrate#13979try_state
hook in elections and EPM pallets substrate#13979indices
pallet #1789TryState
hook forMessageQueue
substrate#13115try_state
hook(tips & vesting) substrate#13515try_state
hook forTreasury
pallet #1820try_state
hook(tips & vesting) substrate#13515The text was updated successfully, but these errors were encountered: