--- /dev/null +++ b/.maintain/frame-weight-template.hbs @@ -0,0 +1,95 @@ +// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs + +//! Autogenerated weights for {{pallet}} +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} + +// Executed Command: +{{#each args as |arg|~}} +// {{arg}} +{{/each}} + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for {{pallet}}. +pub trait WeightInfo { + {{~#each benchmarks as |benchmark|}} + fn {{benchmark.name~}} + ( + {{~#each benchmark.components as |c| ~}} + {{c.name}}: u32, {{/each~}} + ) -> Weight; + {{~/each}} +} + +/// Weights for {{pallet}} using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + {{~#each benchmarks as |benchmark|}} + {{~#each benchmark.comments as |comment|}} + // {{comment}} + {{~/each}} + fn {{benchmark.name~}} + ( + {{~#each benchmark.components as |c| ~}} + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} + ) -> Weight { + ({{underscore benchmark.base_weight}} as Weight) + {{~#each benchmark.component_weight as |cw|}} + // Standard Error: {{underscore cw.error}} + .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + {{~/each}} + {{~#if (ne benchmark.base_reads "0")}} + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + {{~/if}} + {{~#each benchmark.component_reads as |cr|}} + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + {{~/each}} + {{~#if (ne benchmark.base_writes "0")}} + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + {{~/if}} + {{~#each benchmark.component_writes as |cw|}} + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + {{~/each}} + } + {{~/each}} +} + +// For backwards compatibility and tests +impl WeightInfo for () { + {{~#each benchmarks as |benchmark|}} + {{~#each benchmark.comments as |comment|}} + // {{comment}} + {{~/each}} + fn {{benchmark.name~}} + ( + {{~#each benchmark.components as |c| ~}} + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} + ) -> Weight { + ({{underscore benchmark.base_weight}} as Weight) + {{~#each benchmark.component_weight as |cw|}} + // Standard Error: {{underscore cw.error}} + .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + {{~/each}} + {{~#if (ne benchmark.base_reads "0")}} + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight)) + {{~/if}} + {{~#each benchmark.component_reads as |cr|}} + .saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + {{~/each}} + {{~#if (ne benchmark.base_writes "0")}} + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight)) + {{~/if}} + {{~#each benchmark.component_writes as |cw|}} + .saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + {{~/each}} + } + {{~/each}} +} \ No newline at end of file --- a/Cargo.lock +++ b/Cargo.lock @@ -704,6 +704,117 @@ ] [[package]] +name = "bp-header-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "finality-grandpa", + "frame-support", + "parity-scale-codec", + "serde", + "sp-core", + "sp-finality-grandpa", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-messages" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "bitvec 0.20.4", + "bp-runtime", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "serde", + "sp-std", +] + +[[package]] +name = "bp-polkadot-core" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std", + "sp-version", +] + +[[package]] +name = "bp-rococo" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "bp-messages", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "parity-scale-codec", + "smallvec 1.6.1", + "sp-api", + "sp-runtime", + "sp-std", + "sp-version", +] + +[[package]] +name = "bp-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "frame-support", + "hash-db", + "num-traits", + "parity-scale-codec", + "sp-core", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", +] + +[[package]] +name = "bp-test-utils" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "bp-header-chain", + "ed25519-dalek", + "finality-grandpa", + "parity-scale-codec", + "sp-application-crypto", + "sp-finality-grandpa", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-wococo" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "bp-messages", + "bp-polkadot-core", + "bp-rococo", + "bp-runtime", + "parity-scale-codec", + "sp-api", + "sp-runtime", + "sp-std", +] + +[[package]] name = "bs58" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3779,6 +3890,91 @@ ] [[package]] +name = "kusama-runtime" +version = "0.9.8" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "beefy-primitives", + "bitvec 0.20.4", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "max-encoded-len", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-bounties", + "pallet-collective", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-elections-phragmen", + "pallet-gilt", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-mmr-primitives", + "pallet-multisig", + "pallet-nicks", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-proxy", + "pallet-recovery", + "pallet-scheduler 3.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8)", + "pallet-session", + "pallet-session-benchmarking", + "pallet-society", + "pallet-staking", + "pallet-staking-reward-fn", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "serde", + "serde_derive", + "smallvec 1.6.1", + "sp-api", + "sp-arithmetic", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-core", + "sp-inherents", + "sp-io", + "sp-npos-elections", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder 4.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8)", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] name = "kv-log-macro" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5019,6 +5215,7 @@ "pallet-evm", "pallet-evm-coder-substrate", "pallet-evm-contract-helpers", + "pallet-evm-migration", "pallet-evm-transaction-payment", "pallet-inflation", "pallet-nft", @@ -5321,6 +5518,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "pallet-treasury", @@ -5330,10 +5528,32 @@ ] [[package]] +name = "pallet-bridge-grandpa" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "bp-header-chain", + "bp-runtime", + "bp-test-utils", + "finality-grandpa", + "frame-support", + "frame-system", + "log", + "num-traits", + "parity-scale-codec", + "serde", + "sp-finality-grandpa", + "sp-runtime", + "sp-std", + "sp-trie", +] + +[[package]] name = "pallet-collective" version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "log", @@ -5423,11 +5643,13 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", "parity-scale-codec", + "rand 0.7.3", "sp-arithmetic", "sp-core", "sp-io", @@ -5442,6 +5664,7 @@ version = "4.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "log", @@ -5542,6 +5765,22 @@ ] [[package]] +name = "pallet-evm-migration" +version = "0.1.0" +dependencies = [ + "fp-evm", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-evm", + "parity-scale-codec", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] name = "pallet-evm-transaction-payment" version = "0.1.0" dependencies = [ @@ -5559,6 +5798,20 @@ ] [[package]] +name = "pallet-gilt" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-arithmetic", + "sp-runtime", + "sp-std", +] + +[[package]] name = "pallet-grandpa" version = "3.1.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" @@ -5600,6 +5853,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "log", @@ -5618,6 +5872,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -5717,6 +5972,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -5822,10 +6078,33 @@ ] [[package]] +name = "pallet-offences-benchmarking" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-im-online", + "pallet-offences", + "pallet-session", + "pallet-staking", + "parity-scale-codec", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] name = "pallet-proxy" version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "max-encoded-len", @@ -5850,6 +6129,20 @@ ] [[package]] +name = "pallet-recovery" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" +dependencies = [ + "enumflags2", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] name = "pallet-scheduler" version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" @@ -5903,10 +6196,40 @@ ] [[package]] +name = "pallet-session-benchmarking" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-session", + "pallet-staking", + "rand 0.7.3", + "sp-runtime", + "sp-session", + "sp-std", +] + +[[package]] +name = "pallet-society" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "rand_chacha 0.2.2", + "sp-runtime", + "sp-std", +] + +[[package]] name = "pallet-staking" version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", @@ -5915,6 +6238,7 @@ "pallet-session", "parity-scale-codec", "paste", + "rand_chacha 0.2.2", "serde", "sp-application-crypto", "sp-io", @@ -5936,6 +6260,15 @@ ] [[package]] +name = "pallet-staking-reward-fn" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" +dependencies = [ + "log", + "sp-arithmetic", +] + +[[package]] name = "pallet-sudo" version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" @@ -5971,6 +6304,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "pallet-treasury", @@ -6029,6 +6363,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "impl-trait-for-tuples", @@ -6044,6 +6379,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -6059,6 +6395,7 @@ source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8#74101dc21cfffb4c2d014fcc28edc166d5ca1b16" dependencies = [ "enumflags2", + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -6074,6 +6411,7 @@ "frame-support", "frame-system", "parity-scale-codec", + "serde", "sp-runtime", "sp-std", "xcm", @@ -7149,12 +7487,15 @@ dependencies = [ "beefy-primitives", "bitvec 0.20.4", + "frame-benchmarking", "frame-election-provider-support", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", + "hex-literal", "log", "max-encoded-len", "pallet-authority-discovery", @@ -7175,9 +7516,11 @@ "pallet-multisig", "pallet-nicks", "pallet-offences", + "pallet-offences-benchmarking", "pallet-proxy", "pallet-scheduler 3.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8)", "pallet-session", + "pallet-session-benchmarking", "pallet-staking", "pallet-staking-reward-curve", "pallet-timestamp", @@ -7220,12 +7563,14 @@ dependencies = [ "beefy-primitives", "bitvec 0.20.4", + "frame-benchmarking", "frame-support", "frame-system", "impl-trait-for-tuples", "libsecp256k1 0.3.5", "log", "pallet-authorship", + "pallet-babe", "pallet-balances", "pallet-beefy", "pallet-election-provider-multi-phase", @@ -7263,8 +7608,10 @@ dependencies = [ "bitvec 0.20.4", "derive_more", + "frame-benchmarking", "frame-support", "frame-system", + "libsecp256k1 0.3.5", "log", "pallet-authority-discovery", "pallet-authorship", @@ -7304,6 +7651,7 @@ "frame-system-rpc-runtime-api", "futures 0.3.16", "hex-literal", + "kusama-runtime", "kvdb", "kvdb-rocksdb", "pallet-babe", @@ -7339,6 +7687,7 @@ "polkadot-runtime", "polkadot-runtime-parachains", "polkadot-statement-distribution", + "rococo-runtime", "sc-authority-discovery", "sc-basic-authorship", "sc-block-builder", @@ -7380,6 +7729,7 @@ "substrate-prometheus-endpoint", "thiserror", "tracing", + "westend-runtime", ] [[package]] @@ -8144,6 +8494,73 @@ ] [[package]] +name = "rococo-runtime" +version = "0.9.8" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "beefy-primitives", + "bp-rococo", + "bp-wococo", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "hex-literal", + "log", + "max-encoded-len", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-beefy", + "pallet-bridge-grandpa", + "pallet-collective", + "pallet-grandpa", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-mmr", + "pallet-mmr-primitives", + "pallet-offences", + "pallet-proxy", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "serde", + "serde_derive", + "smallvec 1.6.1", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder 4.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8)", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] name = "rpassword" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -12044,6 +12461,89 @@ ] [[package]] +name = "westend-runtime" +version = "0.9.8" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.8#3a10ee63c0b5703a1c802db3438ab7e01344a8ce" +dependencies = [ + "beefy-primitives", + "bitvec 0.20.4", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "max-encoded-len", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-collective", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-elections-phragmen", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-mmr-primitives", + "pallet-multisig", + "pallet-nicks", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-proxy", + "pallet-recovery", + "pallet-scheduler 3.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8)", + "pallet-session", + "pallet-session-benchmarking", + "pallet-society", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "serde", + "serde_derive", + "smallvec 1.6.1", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-core", + "sp-inherents", + "sp-io", + "sp-npos-elections", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder 4.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.8)", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] name = "which" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +.PHONY: _bench +_bench: + cargo run --release --features runtime-benchmarks -- \ + benchmark --pallet pallet-$(PALLET) \ + --wasm-execution compiled --extrinsic '*' \ + --template .maintain/frame-weight-template.hbs --steps=50 --repeat=20 \ + --output=./pallets/$(PALLET)/src/weights.rs + +.PHONY: bench-evm-migration +bench-evm-migration: + make _bench PALLET=evm-migration + +.PHONY: bench +bench: bench-evm-migration --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -317,4 +317,7 @@ [features] default = [] -runtime-benchmarks = ['nft-runtime/runtime-benchmarks'] +runtime-benchmarks = [ + 'nft-runtime/runtime-benchmarks', + 'polkadot-service/runtime-benchmarks', +] --- /dev/null +++ b/pallets/evm-migration/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "pallet-evm-migration" +version = "0.1.0" +edition = "2018" + +[dependencies] +frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +frame-benchmarking = { default-features = false, version = '3.0.0', optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +sp-runtime = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +sp-std = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +sp-io = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +sp-core = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' } +pallet-evm = { default-features = false, version = "5.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" } +fp-evm = { default-features = false, version = "2.0.0", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" } + +[dependencies.codec] +default-features = false +features = ['derive'] +package = 'parity-scale-codec' +version = '2.0.0' + +[features] +default = ["std", "runtime-benchmarks"] +std = [ + "frame-support/std", + "frame-system/std", + "frame-benchmarking/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "sp-core/std", + "pallet-evm/std", + "fp-evm/std", +] +runtime-benchmarks = ["frame-benchmarking"] --- /dev/null +++ b/pallets/evm-migration/src/benchmarking.rs @@ -0,0 +1,30 @@ +use super::{Call, Config, Pallet}; +use frame_benchmarking::benchmarks; +use frame_system::RawOrigin; +use sp_core::{H160, H256}; +use sp_std::vec::Vec; + +benchmarks! { + begin { + }: _(RawOrigin::Root, H160::default()) + + set_data { + let b in 0..80; + let address = H160::from_low_u64_be(b as u64); + let mut data = Vec::new(); + for i in 0..b { + data.push(( + H256::from_low_u64_be(i as u64), + H256::from_low_u64_be(i as u64), + )); + } + >::begin(RawOrigin::Root.into(), address)?; + }: _(RawOrigin::Root, address, data) + + finish { + let b in 0..80; + let address = H160::from_low_u64_be(b as u64); + let data: Vec = (0..b as u8).collect(); + >::begin(RawOrigin::Root.into(), address)?; + }: _(RawOrigin::Root, address, data) +} --- /dev/null +++ b/pallets/evm-migration/src/lib.rs @@ -0,0 +1,111 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +pub use pallet::*; +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; +pub mod weights; + +#[frame_support::pallet] +pub mod pallet { + use frame_support::{pallet_prelude::*, transactional}; + use frame_system::pallet_prelude::*; + use sp_core::{H160, H256}; + use sp_std::vec::Vec; + use super::weights::WeightInfo; + + #[pallet::config] + pub trait Config: frame_system::Config + pallet_evm::Config { + type WeightInfo: WeightInfo; + } + + type SelfWeightOf = ::WeightInfo; + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(_); + + #[pallet::error] + pub enum Error { + AccountNotEmpty, + AccountIsNotMigrating, + } + + #[pallet::storage] + pub(super) type MigrationPending = + StorageMap; + + #[pallet::call] + impl Pallet { + #[pallet::weight(>::begin())] + pub fn begin(origin: OriginFor, address: H160) -> DispatchResult { + ensure_root(origin)?; + ensure!( + >::is_account_empty(&address) + && !>::get(&address), + >::AccountNotEmpty, + ); + + >::insert(address, true); + Ok(()) + } + + #[pallet::weight(>::set_data(data.len() as u32))] + pub fn set_data( + origin: OriginFor, + address: H160, + data: Vec<(H256, H256)>, + ) -> DispatchResult { + use frame_support::StorageDoubleMap; + ensure_root(origin)?; + ensure!( + >::get(&address), + >::AccountIsNotMigrating, + ); + + for (k, v) in data { + pallet_evm::AccountStorages::insert(&address, k, v); + } + Ok(()) + } + + #[pallet::weight(>::finish(code.len() as u32))] + #[transactional] + pub fn finish(origin: OriginFor, address: H160, code: Vec) -> DispatchResult { + use frame_support::StorageMap; + ensure_root(origin)?; + ensure!( + >::get(&address), + >::AccountIsNotMigrating, + ); + + pallet_evm::AccountCodes::insert(&address, code); + >::remove(address); + Ok(()) + } + } + + pub struct OnMethodCall(PhantomData); + impl pallet_evm::OnMethodCall for OnMethodCall { + fn is_reserved(contract: &H160) -> bool { + >::get(&contract) + } + + fn is_used(_contract: &H160) -> bool { + false + } + + fn call( + _source: &H160, + _arget: &H160, + _gas_left: u64, + _input: &[u8], + _value: sp_core::U256, + ) -> Option { + None + } + + fn get_code(_contract: &H160) -> Option> { + None + } + } +} --- /dev/null +++ b/pallets/evm-migration/src/weights.rs @@ -0,0 +1,80 @@ +// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs + +//! Autogenerated weights for pallet_evm_migration +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2021-08-12, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128 + +// Executed Command: +// target/release/nft +// benchmark +// --pallet +// pallet-evm-migration +// --wasm-execution +// compiled +// --extrinsic +// * +// --template +// .maintain/frame-weight-template.hbs +// --steps=50 +// --repeat=20 +// --output=./pallets/evm-migration/src/weights.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_evm_migration. +pub trait WeightInfo { + fn begin() -> Weight; + fn set_data(b: u32, ) -> Weight; + fn finish(b: u32, ) -> Weight; +} + +/// Weights for pallet_evm_migration using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn begin() -> Weight { + (6_210_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn set_data(b: u32, ) -> Weight { + (2_926_000 as Weight) + // Standard Error: 4_000 + .saturating_add((649_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + } + fn finish(_b: u32, ) -> Weight { + (4_309_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn begin() -> Weight { + (6_210_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn set_data(b: u32, ) -> Weight { + (2_926_000 as Weight) + // Standard Error: 4_000 + .saturating_add((649_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + } + fn finish(_b: u32, ) -> Weight { + (4_309_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } +} \ No newline at end of file --- a/pallets/nft-transaction-payment/src/benchmarking.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![cfg(feature = "runtime-benchmarks")] - -use super::*; - -use sp_std::prelude::*; -use frame_system::RawOrigin; -use frame_benchmarking::{benchmarks}; -use frame_support::traits::OnInitialize; - -benchmarks! { - - // on_initialize { - // let block1: T::BlockNumber = T::BlockNumber::from(1u32); - // let block2: T::BlockNumber = T::BlockNumber::from(2u32); - // Inflation::::on_initialize(block1); // Create Treasury account - // }: { Inflation::::on_initialize(block2); } // Benchmark deposit_into_existing path - -} --- a/pallets/nft-transaction-payment/src/lib.rs +++ b/pallets/nft-transaction-payment/src/lib.rs @@ -11,9 +11,6 @@ #[cfg(feature = "std")] pub use serde::*; -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; - use frame_support::{decl_module, decl_storage}; use sp_std::prelude::*; use up_sponsorship::SponsorshipHandler; --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -23,11 +23,14 @@ 'frame-support/runtime-benchmarks', 'frame-system-benchmarking', 'frame-system/runtime-benchmarks', + 'pallet-evm-migration/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'pallet-nft/runtime-benchmarks', 'pallet-inflation/runtime-benchmarks', + 'pallet-xcm/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', + 'xcm-builder/runtime-benchmarks', ] std = [ 'codec/std', @@ -56,6 +59,7 @@ 'pallet-treasury/std', 'pallet-vesting/std', 'pallet-evm/std', + 'pallet-evm-migration/std', 'pallet-evm-contract-helpers/std', 'pallet-evm-transaction-payment/std', 'pallet-evm-coder-substrate/std', @@ -392,6 +396,7 @@ # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' } pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' } pallet-nft-charge-transaction = { path = '../pallets/nft-charge-transaction', default-features = false, version = '3.0.0' } +pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false } pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false } pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false } pallet-evm-coder-substrate = { default-features = false, path = "../pallets/evm-coder-substrate" } --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -252,6 +252,7 @@ type Currency = Balances; type Event = Event; type OnMethodCall = ( + pallet_evm_migration::OnMethodCall, pallet_nft::NftErcSupport, pallet_evm_contract_helpers::HelpersOnMethodCall, ); @@ -263,6 +264,10 @@ type FindAuthor = EthereumFindAuthor; } +impl pallet_evm_migration::Config for Runtime { + type WeightInfo = pallet_evm_migration::weights::SubstrateWeight; +} + pub struct EthereumFindAuthor(core::marker::PhantomData); impl> FindAuthor for EthereumFindAuthor { fn find_author<'a, I>(digests: I) -> Option @@ -819,6 +824,7 @@ EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150, EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151, EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152, + EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153, } ); @@ -1180,6 +1186,7 @@ let mut batches = Vec::::new(); let params = (&config, &whitelist); + add_benchmark!(params, batches, pallet_evm_migration, EvmMigration); add_benchmark!(params, batches, pallet_nft, Nft); add_benchmark!(params, batches, pallet_inflation, Inflation); --- /dev/null +++ b/tests/src/eth/migration.test.ts @@ -0,0 +1,82 @@ +import { expect } from 'chai'; +import privateKey from '../substrate/privateKey'; +import { submitTransactionAsync } from '../substrate/substrate-api'; +import { createEthAccountWithBalance, GAS_ARGS, itWeb3 } from './util/helpers'; + +describe('EVM Migrations', () => { + itWeb3('Deploy contract saved state', async ({ web3, api }) => { + /* + contract StatefulContract { + uint counter; + mapping (uint => uint) kv; + + function inc() public { + counter = counter + 1; + } + function counterValue() public view returns (uint) { + return counter; + } + + function set(uint key, uint value) public { + kv[key] = value; + } + + function get(uint key) public view returns (uint) { + return kv[key]; + } + } + */ + const ADDRESS = '0x4956bf52ef9ed8789f21bc600e915e0d961079f6'; + const CODE = '0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80631ab06ee514610051578063371303c01461006d5780637bfdec3b146100775780639507d39a14610095575b600080fd5b61006b60048036038101906100669190610160565b6100c5565b005b6100756100e1565b005b61007f6100f8565b60405161008c91906101af565b60405180910390f35b6100af60048036038101906100aa9190610133565b610101565b6040516100bc91906101af565b60405180910390f35b8060016000848152602001908152602001600020819055505050565b60016000546100f091906101ca565b600081905550565b60008054905090565b600060016000838152602001908152602001600020549050919050565b60008135905061012d8161025e565b92915050565b60006020828403121561014957610148610259565b5b60006101578482850161011e565b91505092915050565b6000806040838503121561017757610176610259565b5b60006101858582860161011e565b92505060206101968582860161011e565b9150509250929050565b6101a981610220565b82525050565b60006020820190506101c460008301846101a0565b92915050565b60006101d582610220565b91506101e083610220565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156102155761021461022a565b5b828201905092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b61026781610220565b811461027257600080fd5b5056fea26469706673582212206a02d2fb5c244105ab884961479c1aee3b4c1011e4b5530ab483eb22344a865664736f6c63430008060033'; + const DATA = [ + // counter = 10 + ['0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000000000000000000000000000000000000000000a'], + // kv = {1: 1, 2: 2, 3: 3, 4: 4}, + ['0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f', '0x0000000000000000000000000000000000000000000000000000000000000001'], + ['0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f', '0x0000000000000000000000000000000000000000000000000000000000000002'], + ['0x7dfe757ecd65cbd7922a9c0161e935dd7fdbcc0e999689c7d31633896b1fc60b', '0x0000000000000000000000000000000000000000000000000000000000000003'], + ['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'], + ]; + + const alice = privateKey('//Alice'); + const caller = await createEthAccountWithBalance(api, web3); + + await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS))); + await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.setData(ADDRESS, DATA))); + await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.finish(ADDRESS, CODE))); + + const contract = new web3.eth.Contract([ + { + inputs: [], + name: 'counterValue', + outputs: [{ + internalType: 'uint256', + name: '', + type: 'uint256', + }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ + internalType: 'uint256', + name: 'key', + type: 'uint256', + }], + name: 'get', + outputs: [{ + internalType: 'uint256', + name: '', + type: 'uint256', + }], + stateMutability: 'view', + type: 'function', + }, + ], ADDRESS, { from: caller, ...GAS_ARGS }); + + expect(await contract.methods.counterValue().call()).to.be.equal('10'); + for (let i = 1; i <= 4; i++) { + expect(await contract.methods.get(i).call()).to.be.equal(i.toString()); + } + }); +}); \ No newline at end of file