Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

WIP safe mode and tx pause {continued} #12371

Merged
merged 28 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d076c92
progress on true call UI types
nuke-web3 Sep 27, 2022
1f2a727
mid rework progress on tx pause
nuke-web3 Sep 27, 2022
bf9c803
stck on overflow evaluating the requirement `pallet::Call<mock::Test>…
nuke-web3 Sep 27, 2022
427d48b
tests pass, kitchen sink needs proper impl for origins
nuke-web3 Sep 28, 2022
a8f06db
fmt
nuke-web3 Sep 28, 2022
04a4711
UnfilterableCalls uniform naming
nuke-web3 Sep 28, 2022
55b38bb
Fix safe-mode benchmarks
ggwpez Sep 28, 2022
7aad890
Fix safe-mode benchmarks
ggwpez Sep 28, 2022
354a251
fix build errors, except origin issue
nuke-web3 Sep 29, 2022
80ede09
update to use named parameter syntax for Events
nuke-web3 Sep 29, 2022
cd50d92
building
nuke-web3 Sep 30, 2022
ed6c25f
building except wasm runtime
nuke-web3 Sep 30, 2022
36ee207
benchmarking::bench_force_activate' has overflowed its stack
nuke-web3 Oct 3, 2022
1b6b2b8
??? enum shit
nuke-web3 Oct 3, 2022
d7c7130
benchmark tests passing
nuke-web3 Oct 3, 2022
ac9020d
named reserve impl, tests pass
nuke-web3 Oct 3, 2022
5d78e1d
test coverage safe mode
nuke-web3 Oct 3, 2022
f2f9435
weights.rs for safe mode and tx pause dummy files configured
nuke-web3 Oct 3, 2022
917961b
Fix benchmarks overflow
ggwpez Oct 4, 2022
f1daf3c
names, more comments safe-mode
nuke-web3 Oct 7, 2022
6bfff58
move back to stringy function inputs, with check on validity
nuke-web3 Oct 8, 2022
cc490ae
safe-mode fmt
nuke-web3 Oct 10, 2022
73225ce
broken?
nuke-web3 Oct 10, 2022
b95b286
tests passing, use FullNameOf to check tx-pause unfilterables
nuke-web3 Oct 11, 2022
bbe4ee5
add proxy and utility pallets to mock tx pause
nuke-web3 Oct 11, 2022
163ea73
safe-mode and utility and proxy in mock and tests
nuke-web3 Oct 11, 2022
adb3ab8
tests for proxy and utility for safe mode
nuke-web3 Oct 11, 2022
0538ecd
tests for proxy and utility for tx-pause, fmt
nuke-web3 Oct 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
building except wasm runtime
  • Loading branch information
nuke-web3 committed Sep 30, 2022
commit ed6c25fe9bc705ec545843333d1378bc57628f86
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ pub fn testnet_genesis(
min_join_bond: 1 * DOLLARS,
..Default::default()
},
safe_mode: Default::default(),
tx_pause: Default::default(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path =
sp-version = { version = "5.0.0", default-features = false, path = "../../../primitives/version" }
sp-io = { version = "6.0.0", default-features = false, path = "../../../primitives/io" }
sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/sandbox" }
sp-keyring = { version = "6.0.0", default-features = false, path = "../../../primitives/keyring" }

# frame dependencies
frame-executive = { version = "4.0.0-dev", default-features = false, path = "../../../frame/executive" }
Expand Down Expand Up @@ -205,6 +206,7 @@ std = [
"sp-io/std",
"pallet-child-bounties/std",
"pallet-alliance/std",
"sp-keyring/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
45 changes: 15 additions & 30 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;
use sp_keyring::AccountKeyring;

#[cfg(any(feature = "std", test))]
pub use frame_system::Call as SystemCall;
Expand Down Expand Up @@ -208,8 +209,9 @@ pub struct UnfilterableCalls;
impl Contains<RuntimeCall> for UnfilterableCalls {
fn contains(call: &RuntimeCall) -> bool {
match call {
RuntimeCall::System(_) | RuntimeCall::SafeMode(_) | RuntimeCall::TxPause() => true,
RuntimeCall::System(_) | RuntimeCall::SafeMode(_) | RuntimeCall::TxPause(_) => true,
RuntimeCall::Balances(_) => false,
_ => false,
}
}
}
Expand Down Expand Up @@ -250,11 +252,11 @@ impl ForceActivateOrigin {
}

/// Account id of the origin.
pub const fn acc(&self) -> u32 {
pub fn acc(&self) -> AccountId {
match self {
Self::Weak => 100,
Self::Medium => 101,
Self::Strong => 102,
Self::Weak => sp_keyring::AccountKeyring::Alice.into(),
Self::Medium => sp_keyring::AccountKeyring::Bob.into(),
Self::Strong => sp_keyring::AccountKeyring::Charlie.into(),
}
}

Expand All @@ -275,11 +277,11 @@ impl ForceExtendOrigin {
}

/// Account id of the origin.
pub const fn acc(&self) -> u32 {
pub fn acc(&self) -> AccountId {
match self {
Self::Weak => 200,
Self::Medium => 201,
Self::Strong => 202,
Self::Weak => sp_keyring::AccountKeyring::Alice.into(),
Self::Medium => sp_keyring::AccountKeyring::Bob.into(),
Self::Strong => sp_keyring::AccountKeyring::Charlie.into(),
}
}

Expand All @@ -289,7 +291,7 @@ impl ForceExtendOrigin {
}
}

impl<O: Into<Result<RawOrigin<u32>, O>> + From<RawOrigin<u32>> + std::fmt::Debug> EnsureOrigin<O>
impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>> + std::fmt::Debug> EnsureOrigin<O>
for ForceActivateOrigin
{
type Success = u32;
Expand All @@ -307,7 +309,7 @@ impl<O: Into<Result<RawOrigin<u32>, O>> + From<RawOrigin<u32>> + std::fmt::Debug
}
}

impl<O: Into<Result<RawOrigin<u32>, O>> + From<RawOrigin<u32>> + std::fmt::Debug> EnsureOrigin<O>
impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>> + std::fmt::Debug> EnsureOrigin<O>
for ForceExtendOrigin
{
type Success = u32;
Expand All @@ -325,29 +327,12 @@ impl<O: Into<Result<RawOrigin<u32>, O>> + From<RawOrigin<u32>> + std::fmt::Debug
}
}

// Required impl to use some <Configured Origin>::get()
impl SortedMembers<u32> for DeactivateOrigin {
fn sorted_members() -> Vec<u32> {
vec![Self::get()]
}
#[cfg(feature = "runtime-benchmarks")]
fn add(_m: &u32) {}
}
impl SortedMembers<u32> for RepayOrigin {
fn sorted_members() -> Vec<u32> {
vec![Self::get()]
}
#[cfg(feature = "runtime-benchmarks")]
fn add(_m: &u32) {}
}

parameter_types! {
pub const ActivateDuration: u32 = 3;
pub const ExtendDuration: u32 = 30;
pub const ActivateStakeAmount: Balance = 10 * DOLLARS; //TODO This needs to be something sensible for the implications of enablement!
pub const ExtendStakeAmount: Balance = 10 * DOLLARS; //TODO This needs to be something sensible for the implications of enablement!
pub const DeactivateOrigin: u32 = 3;
pub const RepayOrigin: u32 = 4;
}

impl pallet_safe_mode::Config for Runtime {
Expand All @@ -360,8 +345,8 @@ impl pallet_safe_mode::Config for Runtime {
type ExtendStakeAmount = ExtendStakeAmount;
type ForceActivateOrigin = ForceActivateOrigin;
type ForceExtendOrigin = ForceExtendOrigin;
type ForceDeactivateOrigin = EnsureSignedBy<DeactivateOrigin, Self::AccountId>;
type RepayOrigin = EnsureSignedBy<RepayOrigin, Self::AccountId>;
type ForceDeactivateOrigin = EnsureRoot<Self::AccountId>;
type RepayOrigin = EnsureRoot<Self::AccountId>;
type WeightInfo = pallet_safe_mode::weights::SubstrateWeight<Runtime>;
}

Expand Down