-
Notifications
You must be signed in to change notification settings - Fork 2.6k
WIP safe mode and tx pause {continued} #12371
Conversation
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
benchmarking getting call stack exhausted
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
To ensure that the As the OP hoped, the behavior using the apps ui is the same as proxy: you have drop downs on the only selections you can make. The only grip is that you are forced to used correct values here generally in the "call" you supply (like an account and value for a balance transfer) to make the UI and subxt happy. @ggwpez wdyt? Not too bad for the extra safety and less need to lookup the correct string to place into storage for the pallet and the function/call as it was previously? |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/safe-mode-and-transaction-pause-pallets/636/1 |
We could already safe-guard against wrong pallet names by going through all available pallets. This is maybe also possible for calls. I think requiring additional argument data which we will then ignore is not good. PS: A front-end UI could also real all Pallet and Call names from metadata, so we should be good with just strings. |
Agreed that extraneous call data is not ideal. Dumb question: is it possible to specify a type that is inclusive of only the call without values? Perhaps its somewhere in the macro logic to generate the RuntimeCall enum or maybe a way to cheaply impl a type that does this from the fully generated RuntimeCall enum...? Perhaps yes: https://stackoverflow.com/questions/32554285/compare-enums-only-by-variant-not-value |
Not having to create a custom ui just to handle this pallet was my goal in using the Call variants though (in part) although I agree its an option. I want to test behavior of sending a raw encoded call with incorrect call data specified to pause, as at least to me it's unclear if that extrinsic would be rejected. I do think so though, as we need to be able to read the pallet name and call name, and dummy call data set in the pause extrinsics should fail to extract this (i hope). Stingy names can be set without a check and succeed (as it is now) to set an arbitrary, possibly meaningless via typo, filter. Perhaps it is possible to use stringy names that are checked at execution time to be correct? Static at compile time imho is still preferred. |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/safe-mode-and-transaction-pause-pallets/636/4 |
|
||
impl ForceActivateOrigin { | ||
/// The duration of how long the safe-mode will be activated. | ||
pub fn duration(&self) -> u32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will prefer to make it
/// An origin that can enable the safe-mode by force.
pub enum ForceActivateOrigin {
Weak = 5,
Medium = 7,
Strong = 11,
}
so that frontend doesn't need to hardcod those number once more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool - TIL https://doc.rust-lang.org/reference/items/enumerations.html#custom-discriminant-values-for-fieldless-enumerations is a thing
So this example diff works to yield an integer castable item, so BlockNumber works fine.
But you cannot assign the same value for any origin this way as it would conflict:
enum SharedDiscriminantError {
SharedA = 1,
SharedB = 1
}
I think this restriction would be OK, but hope there is a better method to get there... Open to ideas.
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/safe-mode-and-transaction-pause-pallets/636/6 |
Removed Introduced substrate/bin/node/runtime/src/lib.rs Lines 217 to 241 in b95b286
|
ad27654
to
0538ecd
Compare
* Add safe-mode Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Update pallet Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add to kitchensink-runtime Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Spelling Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Rename to tx-pause Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add SafeMode pallet Signed-off-by: Oliver Tale-Yazdi <[email protected]> * fmt Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Automatically disable safe-mode in on_init… Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add permissionless enable+extend Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add repay+slash stake methods Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add docs Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix stakes storage Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Genesis config for safe-mode pallet Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Genesis config for safe-mode pallet Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Rename ExtrinsicName to FunctionName Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Origin variable duration Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Rename FunctionName -> CallName Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Rename and docs Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Pallet safe mode tests (#12148) * Add safe-mode mock runtime * Add safe-mode tests * Add ForceEnable- and ForceExtendOrigin * Start dummy benchmarks Co-authored-by: Oliver Tale-Yazdi <[email protected]> * Tests for `pallet-tx-pause` (#12259) * mock added * tests added * dummy benchmarks started * rename to active/inactive tests broken, in progress * Runtime types, fix tests * WIP safe mode and tx pause {continued} (#12371) * test coverage on safe mode and tx pause * benchmarks & tests * tests passing, use FullNameOf to check tx-pause unfilterables * naming updates Signed-off-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]> * Set block number Signed-off-by: Oliver Tale-Yazdi <[email protected]> * dummy weights generated, safe mode * add repay_reservation call with RepaymentDelay per #10033 feature requirements * make call name optional to allow pausing pallets, handle `Contains` correctly for this throughout, doc comments started * move to full_name notation for all interfaces, last commit introduced 1 more storage read. * refactor is_paused * safe math on safe mode * Make stuff compile Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Compile Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Cleanup & renames Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Cleanup TxPause pallet Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix benches Signed-off-by: Oliver Tale-Yazdi <[email protected]> * fmt Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Refactor to fungibles::* and rename stuf Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Make compile Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix node config Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Typos Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Remove CausalHoldReason Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Refactor benchmarks and runtime configs Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add traits Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Remove old code Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Cleanup safe-mode benches Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Update frame/safe-mode/Cargo.toml Co-authored-by: Liam Aharon <[email protected]> * Update frame/safe-mode/Cargo.toml Co-authored-by: Liam Aharon <[email protected]> * Docs Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Remove getters Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Update Cargo.lock Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Remove phantom Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix test Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Remove phantom Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Apply suggestions from code review Co-authored-by: Liam Aharon <[email protected]> * Use new as Origin benchmarking syntax Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Docs Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix node Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix tx-pause benches Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Renames * Remove duplicate test * Add docs * docs * Apply suggestions from code review Co-authored-by: Liam Aharon <[email protected]> Co-authored-by: Muharem Ismailov <[email protected]> Co-authored-by: Gonçalo Pestana <[email protected]> * Cleanup tests * docs * Cleanup GenesisConfigs * Doc traits * Remove PauseTooLongNames * docs * Use V2 benchmarking Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Use RuntimeHoldReason * Fix kitchensink runtime * Fix CI Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix CI Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Review Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Rename Stake to Deposit Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add docs Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add Notify and test it Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix kitchensink Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Update frame/safe-mode/src/tests.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/safe-mode/src/tests.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/tx_pause.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/tx-pause/src/lib.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/tx-pause/src/lib.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/tx-pause/src/mock.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Simplify code * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Update frame/support/src/traits/safe_mode.rs Co-authored-by: Liam Aharon <[email protected]> * Fixup merge Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Make stuff compile Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Make tx-pause compile again Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix features Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Fix more features Signed-off-by: Oliver Tale-Yazdi <[email protected]> * ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_safe_mode * Update weights Signed-off-by: Oliver Tale-Yazdi <[email protected]> --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: Dan Shields <[email protected]> Co-authored-by: Dan Shields <[email protected]> Co-authored-by: Liam Aharon <[email protected]> Co-authored-by: Muharem Ismailov <[email protected]> Co-authored-by: Gonçalo Pestana <[email protected]> Co-authored-by: command-bot <>
Targets #12092
Changes the tx pause pallet to accept input asThis was decided to be a bad idea, based on feedback.RuntimeCall
s, instead of stringy names.The storage is still stringy names, as it allows for less headache on migration and safetyThe UI can now help you as in the Proxy pallet have dropdown selections for the possible calls, and there should be no possibility of user error, or inserting calls that do not explicitly exist in the runtime. Example:The above likely means we have to over specify calls with "real" values, but all we really want here is the call without dummy data. TBD on behavior and if a fix is possibletests for tx pause and safe mode working as written 🎉
benchmarks configured and dummy files genereated 🎉
naming tweaks for intuitive understanding and common terms between pallets.
Considerations (for abandoned
RuntimeCall
variation on these pallets)One issue with tx pause pallet to accept input as
RuntimeCall
s: on runtime upgrades changing names or removing pallets that are paused will be inaccessible to remove from tx pause storage, as the runtime metadata won't include the matching stringy names from before.Possible solution: a "raw" call in this pallet to insert or drop pauses by stringy names explicitly as a privileged call for the unpause origin. Alternatively, just a note on how to remove a raw storage key if you missed it in a migration (likely not possible from the unpause origin!)
Its more of a corner case IMHO, and a very simple migration would be needed if you wanted to keep a modified call paused. No issue leaving an irrelevant call name in storage either. Not an DOS attachable thing or something likely to case any issue if forgotten
TODO
pause_call
batch. ~ in a folllowup PRmatch
statement ergonomically, so you can specify pallets inclusive of all calls without explicitly naming each?