new pallet: whitelist pallet (#10159)

* pallet whitelist

* refactor a bit

* fmt

* address audit

* improve tests

* return Ok + refund

* add test for dispatching failing

* add dispatch_whitelisted_call_with_preimage

* fmt

* better name

* Consume all data on decode

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add error docs

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Remove phantom data

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Use rust 2021

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update crate features

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Make compile

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_whitelist --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/whitelist/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Bump Preimage max size

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_whitelist --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/whitelist/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Fmt

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: Parity Bot <admin@parity.io>
This commit is contained in:
Guillaume Thiolliere
2022-03-01 14:31:51 +01:00
committed by GitHub
parent 5ae3ed3b95
commit e71c7b259d
13 changed files with 873 additions and 3 deletions
+3
View File
@@ -100,6 +100,7 @@ pallet-asset-tx-payment = { version = "4.0.0-dev", default-features = false, pat
pallet-transaction-storage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/transaction-storage" }
pallet-uniques = { version = "4.0.0-dev", default-features = false, path = "../../../frame/uniques" }
pallet-vesting = { version = "4.0.0-dev", default-features = false, path = "../../../frame/vesting" }
pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = "../../../frame/whitelist" }
[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
@@ -220,6 +221,7 @@ runtime-benchmarks = [
"pallet-utility/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pallet-whitelist/runtime-benchmarks",
"frame-system-benchmarking",
"hex-literal",
]
@@ -267,6 +269,7 @@ try-runtime = [
"pallet-uniques/try-runtime",
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"pallet-whitelist/try-runtime",
]
# Make contract callable functions marked as __unstable__ available. Do not enable
# on live chains as those are subject to change.
+11
View File
@@ -1357,6 +1357,15 @@ impl pallet_transaction_storage::Config for Runtime {
type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight<Runtime>;
}
impl pallet_whitelist::Config for Runtime {
type Event = Event;
type Call = Call;
type WhitelistOrigin = EnsureRoot<AccountId>;
type DispatchWhitelistedOrigin = EnsureRoot<AccountId>;
type PreimageProvider = Preimage;
type WeightInfo = pallet_whitelist::weights::SubstrateWeight<Runtime>;
}
construct_runtime!(
pub enum Runtime where
Block = Block,
@@ -1411,6 +1420,7 @@ construct_runtime!(
ChildBounties: pallet_child_bounties,
Referenda: pallet_referenda,
ConvictionVoting: pallet_conviction_voting,
Whitelist: pallet_whitelist,
}
);
@@ -1509,6 +1519,7 @@ mod benches {
[pallet_uniques, Uniques]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_whitelist, Whitelist]
);
}