difftreelog
fix benchmark rmrk-core with opal-runtime
in: master
10 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8558,11 +8558,14 @@
"fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
+ "frame-benchmarking",
"frame-executive",
"frame-support",
"frame-system",
+ "frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
+ "hex-literal",
"log",
"orml-vesting",
"pallet-aura",
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@
.PHONY: _bench
_bench:
- cargo run --release --features runtime-benchmarks,unique-runtime -- \
+ cargo run --release --features runtime-benchmarks,$(RUNTIME) -- \
benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \
--wasm-execution compiled --extrinsic '*' \
--template .maintain/frame-weight-template.hbs --steps=50 --repeat=80 --heap-pages=4096 \
node/cli/Cargo.tomldiffbeforeafterboth--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -323,7 +323,9 @@
[features]
default = []
runtime-benchmarks = [
- 'unique-runtime/runtime-benchmarks',
+ 'unique-runtime?/runtime-benchmarks',
+ 'quartz-runtime?/runtime-benchmarks',
+ 'opal-runtime/runtime-benchmarks',
'polkadot-service/runtime-benchmarks',
]
try-runtime = []
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -26,13 +26,13 @@
use unique_runtime_common::types::*;
#[cfg(feature = "unique-runtime")]
-use unique_runtime as default_runtime;
+pub use unique_runtime as default_runtime;
#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
-use quartz_runtime as default_runtime;
+pub use quartz_runtime as default_runtime;
#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
-use opal_runtime as default_runtime;
+pub use opal_runtime as default_runtime;
/// The `ChainSpec` parameterized for the unique runtime.
#[cfg(feature = "unique-runtime")]
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -33,7 +33,7 @@
// limitations under the License.
use crate::{
- chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
+ chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification, default_runtime},
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, start_node, start_dev_node},
};
@@ -44,7 +44,7 @@
#[cfg(feature = "quartz-runtime")]
use crate::service::QuartzRuntimeExecutor;
-use crate::service::OpalRuntimeExecutor;
+use crate::service::{OpalRuntimeExecutor, DefaultRuntimeExecutor};
use codec::Encode;
use cumulus_primitives_core::ParaId;
@@ -372,7 +372,6 @@
Ok(())
}
- #[cfg(feature = "unique-runtime")]
Some(Subcommand::Benchmark(cmd)) => {
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
let runner = cli.create_runner(cmd)?;
@@ -380,7 +379,7 @@
match cmd {
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
- runner.sync_run(|config| cmd.run::<Block, UniqueRuntimeExecutor>(config))
+ runner.sync_run(|config| cmd.run::<Block, DefaultRuntimeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
@@ -389,16 +388,16 @@
}
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial::<
- unique_runtime::RuntimeApi,
- UniqueRuntimeExecutor,
+ default_runtime::RuntimeApi,
+ DefaultRuntimeExecutor,
_,
>(&config, crate::service::parachain_build_import_queue)?;
cmd.run(partials.client)
}),
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial::<
- unique_runtime::RuntimeApi,
- UniqueRuntimeExecutor,
+ default_runtime::RuntimeApi,
+ DefaultRuntimeExecutor,
_,
>(&config, crate::service::parachain_build_import_queue)?;
let db = partials.backend.expose_db();
@@ -411,10 +410,6 @@
}
BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()),
}
- }
- #[cfg(not(feature = "unique-runtime"))]
- Some(Subcommand::Benchmark(..)) => {
- Err("benchmarking is only available with unique runtime enabled".into())
}
Some(Subcommand::TryRuntime(cmd)) => {
if cfg!(feature = "try-runtime") {
node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -77,13 +77,21 @@
#[cfg(feature = "quartz-runtime")]
/// Quartz native executor instance.
-
pub struct QuartzRuntimeExecutor;
/// Opal native executor instance.
pub struct OpalRuntimeExecutor;
#[cfg(feature = "unique-runtime")]
+pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;
+
+#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
+pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;
+
+#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
+pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;
+
+#[cfg(feature = "unique-runtime")]
impl NativeExecutionDispatch for UniqueRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
pallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/benchmarking.rs
+++ b/pallets/proxy-rmrk-core/src/benchmarking.rs
@@ -220,7 +220,6 @@
let b in 0..100;
let caller: T::AccountId = account("caller", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
create_max_collection::<T>(&caller)?;
let collection_id = 0;
@@ -381,7 +380,6 @@
add_basic_resource {
let caller: T::AccountId = account("caller", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
create_max_collection::<T>(&caller)?;
let collection_id = 0;
@@ -398,7 +396,6 @@
add_composable_resource {
let caller: T::AccountId = account("caller", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
create_max_collection::<T>(&caller)?;
let collection_id = 0;
@@ -415,7 +412,6 @@
add_slot_resource {
let caller: T::AccountId = account("caller", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
create_max_collection::<T>(&caller)?;
let collection_id = 0;
@@ -432,7 +428,6 @@
remove_resource {
let caller: T::AccountId = account("caller", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
create_max_collection::<T>(&caller)?;
let collection_id = 0;
@@ -448,7 +443,7 @@
resource
)?;
- let resource_id = 1;
+ let resource_id = 0;
}: _(
RawOrigin::Signed(caller),
collection_id,
@@ -460,8 +455,6 @@
let caller: T::AccountId = account("caller", 0, SEED);
let admin: T::AccountId = account("admin", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&admin, T::CollectionCreationPrice::get());
-
create_max_collection::<T>(&admin)?;
let collection_id = 0;
@@ -486,7 +479,7 @@
resource
)?;
- let resource_id = 1;
+ let resource_id = 0;
}: _(
RawOrigin::Signed(caller),
collection_id,
@@ -498,8 +491,6 @@
let caller: T::AccountId = account("caller", 0, SEED);
let admin: T::AccountId = account("admin", 0, SEED);
- <T as pallet_common::Config>::Currency::deposit_creating(&admin, T::CollectionCreationPrice::get());
-
create_max_collection::<T>(&admin)?;
let collection_id = 0;
@@ -515,7 +506,7 @@
resource
)?;
- let resource_id = 1;
+ let resource_id = 0;
let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::AccountId(caller.clone());
pallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/weights.rs
+++ b/pallets/proxy-rmrk-core/src/weights.rs
@@ -3,7 +3,7 @@
//! Autogenerated weights for pallet_proxy_rmrk_core
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2022-06-16, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
@@ -19,7 +19,7 @@
// --template
// .maintain/frame-weight-template.hbs
// --steps=50
-// --repeat=200
+// --repeat=80
// --heap-pages=4096
// --output=./pallets/proxy-rmrk-core/src/weights.rs
@@ -64,7 +64,7 @@
// Storage: Common CollectionById (r:0 w:1)
// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
fn create_collection() -> Weight {
- (41_277_000 as Weight)
+ (41_768_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
@@ -77,7 +77,7 @@
// Storage: Nonfungible TokensBurnt (r:0 w:1)
// Storage: Common AdminAmount (r:0 w:1)
fn destroy_collection() -> Weight {
- (43_371_000 as Weight)
+ (43_402_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
@@ -85,7 +85,7 @@
// Storage: Common CollectionById (r:1 w:1)
// Storage: Common CollectionProperties (r:1 w:0)
fn change_collection_issuer() -> Weight {
- (21_891_000 as Weight)
+ (21_711_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -95,7 +95,7 @@
// Storage: Nonfungible TokensMinted (r:1 w:0)
// Storage: Nonfungible TokensBurnt (r:1 w:0)
fn lock_collection() -> Weight {
- (23_144_000 as Weight)
+ (23_204_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -107,18 +107,15 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:2 w:2)
fn mint_nft(b: u32, ) -> Weight {
- (68_329_000 as Weight)
- // Standard Error: 3_000
- .saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))
- .saturating_add(T::DbWeight::get().reads(12 as Weight))
+ (44_655_000 as Weight)
+ // Standard Error: 2_000
+ .saturating_add((10_953_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
- .saturating_add(T::DbWeight::get().writes(12 as Weight))
- .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
@@ -132,8 +129,8 @@
// Storage: Nonfungible TokenProperties (r:0 w:1)
fn burn_nft(b: u32, ) -> Weight {
(0 as Weight)
- // Standard Error: 959_000
- .saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))
+ // Standard Error: 3_677_000
+ .saturating_add((357_082_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
@@ -149,7 +146,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn send() -> Weight {
- (71_405_000 as Weight)
+ (73_968_000 as Weight)
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
@@ -163,22 +160,22 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn accept_nft() -> Weight {
- (79_159_000 as Weight)
+ (81_954_000 as Weight)
.saturating_add(T::DbWeight::get().reads(15 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:5)
// Storage: Nonfungible TokenProperties (r:1 w:5)
- // Storage: Nonfungible TokenData (r:5 w:5)
// Storage: Nonfungible TokenChildren (r:9 w:4)
// Storage: Nonfungible TokensBurnt (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:5 w:5)
// Storage: Nonfungible Allowance (r:5 w:0)
// Storage: Nonfungible Owned (r:0 w:5)
fn reject_nft() -> Weight {
- (238_179_000 as Weight)
+ (250_041_000 as Weight)
.saturating_add(T::DbWeight::get().reads(29 as Weight))
.saturating_add(T::DbWeight::get().writes(25 as Weight))
}
@@ -188,7 +185,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_property() -> Weight {
- (47_770_000 as Weight)
+ (48_631_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -198,100 +195,72 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_priority() -> Weight {
- (46_679_000 as Weight)
+ (47_830_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:1 w:1)
- // Storage: Common CollectionById (r:1 w:1)
- // Storage: Nonfungible TokenData (r:5 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:2)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Nonfungible TokensMinted (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn add_basic_resource() -> Weight {
- (100_770_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(16 as Weight))
- .saturating_add(T::DbWeight::get().writes(12 as Weight))
+ (54_773_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(10 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:1 w:1)
- // Storage: Common CollectionById (r:1 w:1)
- // Storage: Nonfungible TokenData (r:5 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:2)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Nonfungible TokensMinted (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn add_composable_resource() -> Weight {
- (101_791_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(16 as Weight))
- .saturating_add(T::DbWeight::get().writes(12 as Weight))
+ (55_214_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(10 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:1 w:1)
- // Storage: Common CollectionById (r:1 w:1)
- // Storage: Nonfungible TokenData (r:5 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:2)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Nonfungible TokensMinted (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn add_slot_resource() -> Weight {
- (101_610_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(16 as Weight))
- .saturating_add(T::DbWeight::get().writes(12 as Weight))
+ (54_863_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(10 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:2 w:0)
- // Storage: Common CollectionById (r:2 w:0)
- // Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenData (r:6 w:1)
- // Storage: Nonfungible TokenChildren (r:1 w:0)
- // Storage: Nonfungible TokensBurnt (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Allowance (r:1 w:0)
- // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:5 w:0)
fn remove_resource() -> Weight {
- (80_571_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(16 as Weight))
- .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ (46_848_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(9 as Weight))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
- // Storage: Nonfungible TokenProperties (r:2 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn accept_resource() -> Weight {
- (54_733_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(10 as Weight))
+ (45_635_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:2 w:0)
- // Storage: Common CollectionById (r:2 w:0)
- // Storage: Nonfungible TokenData (r:6 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:1)
- // Storage: Nonfungible TokenChildren (r:1 w:0)
- // Storage: Nonfungible TokensBurnt (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Allowance (r:1 w:0)
- // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn accept_resource_removal() -> Weight {
- (84_138_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(17 as Weight))
- .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ (45_535_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(9 as Weight))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
@@ -306,7 +275,7 @@
// Storage: Common CollectionById (r:0 w:1)
// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
fn create_collection() -> Weight {
- (41_277_000 as Weight)
+ (41_768_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
@@ -319,7 +288,7 @@
// Storage: Nonfungible TokensBurnt (r:0 w:1)
// Storage: Common AdminAmount (r:0 w:1)
fn destroy_collection() -> Weight {
- (43_371_000 as Weight)
+ (43_402_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
@@ -327,7 +296,7 @@
// Storage: Common CollectionById (r:1 w:1)
// Storage: Common CollectionProperties (r:1 w:0)
fn change_collection_issuer() -> Weight {
- (21_891_000 as Weight)
+ (21_711_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -337,7 +306,7 @@
// Storage: Nonfungible TokensMinted (r:1 w:0)
// Storage: Nonfungible TokensBurnt (r:1 w:0)
fn lock_collection() -> Weight {
- (23_144_000 as Weight)
+ (23_204_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -349,18 +318,15 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:2 w:2)
fn mint_nft(b: u32, ) -> Weight {
- (68_329_000 as Weight)
- // Standard Error: 3_000
- .saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))
- .saturating_add(RocksDbWeight::get().reads(12 as Weight))
+ (44_655_000 as Weight)
+ // Standard Error: 2_000
+ .saturating_add((10_953_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
- .saturating_add(RocksDbWeight::get().writes(12 as Weight))
- .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(RocksDbWeight::get().writes(5 as Weight))
+ .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
@@ -374,8 +340,8 @@
// Storage: Nonfungible TokenProperties (r:0 w:1)
fn burn_nft(b: u32, ) -> Weight {
(0 as Weight)
- // Standard Error: 959_000
- .saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))
+ // Standard Error: 3_677_000
+ .saturating_add((357_082_000 as Weight).saturating_mul(b as Weight))
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
@@ -391,7 +357,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn send() -> Weight {
- (71_405_000 as Weight)
+ (73_968_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
@@ -405,22 +371,22 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn accept_nft() -> Weight {
- (79_159_000 as Weight)
+ (81_954_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(15 as Weight))
.saturating_add(RocksDbWeight::get().writes(7 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:5)
// Storage: Nonfungible TokenProperties (r:1 w:5)
- // Storage: Nonfungible TokenData (r:5 w:5)
// Storage: Nonfungible TokenChildren (r:9 w:4)
// Storage: Nonfungible TokensBurnt (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:5 w:5)
// Storage: Nonfungible Allowance (r:5 w:0)
// Storage: Nonfungible Owned (r:0 w:5)
fn reject_nft() -> Weight {
- (238_179_000 as Weight)
+ (250_041_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(29 as Weight))
.saturating_add(RocksDbWeight::get().writes(25 as Weight))
}
@@ -430,7 +396,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_property() -> Weight {
- (47_770_000 as Weight)
+ (48_631_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -440,99 +406,71 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_priority() -> Weight {
- (46_679_000 as Weight)
+ (47_830_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:1 w:1)
- // Storage: Common CollectionById (r:1 w:1)
- // Storage: Nonfungible TokenData (r:5 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:2)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Nonfungible TokensMinted (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn add_basic_resource() -> Weight {
- (100_770_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(16 as Weight))
- .saturating_add(RocksDbWeight::get().writes(12 as Weight))
+ (54_773_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(10 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:1 w:1)
- // Storage: Common CollectionById (r:1 w:1)
- // Storage: Nonfungible TokenData (r:5 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:2)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Nonfungible TokensMinted (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn add_composable_resource() -> Weight {
- (101_791_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(16 as Weight))
- .saturating_add(RocksDbWeight::get().writes(12 as Weight))
+ (55_214_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(10 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:1 w:1)
- // Storage: Common CollectionById (r:1 w:1)
- // Storage: Nonfungible TokenData (r:5 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:2)
- // Storage: Common CreatedCollectionCount (r:1 w:1)
- // Storage: Common DestroyedCollectionCount (r:1 w:0)
- // Storage: System Account (r:2 w:2)
- // Storage: Nonfungible TokensMinted (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Common CollectionPropertyPermissions (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn add_slot_resource() -> Weight {
- (101_610_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(16 as Weight))
- .saturating_add(RocksDbWeight::get().writes(12 as Weight))
+ (54_863_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(10 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:2 w:0)
- // Storage: Common CollectionById (r:2 w:0)
- // Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenData (r:6 w:1)
- // Storage: Nonfungible TokenChildren (r:1 w:0)
- // Storage: Nonfungible TokensBurnt (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Allowance (r:1 w:0)
- // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenData (r:5 w:0)
fn remove_resource() -> Weight {
- (80_571_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(16 as Weight))
- .saturating_add(RocksDbWeight::get().writes(5 as Weight))
+ (46_848_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(9 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
- // Storage: Nonfungible TokenProperties (r:2 w:1)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn accept_resource() -> Weight {
- (54_733_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(10 as Weight))
+ (45_635_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
- // Storage: Common CollectionProperties (r:2 w:0)
- // Storage: Common CollectionById (r:2 w:0)
- // Storage: Nonfungible TokenData (r:6 w:1)
- // Storage: Nonfungible TokenProperties (r:2 w:1)
- // Storage: Nonfungible TokenChildren (r:1 w:0)
- // Storage: Nonfungible TokensBurnt (r:1 w:1)
- // Storage: Nonfungible AccountBalance (r:1 w:1)
- // Storage: Nonfungible Allowance (r:1 w:0)
- // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Common CollectionProperties (r:1 w:0)
+ // Storage: Common CollectionById (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:5 w:0)
+ // Storage: Nonfungible TokenSysProperties (r:1 w:1)
fn accept_resource_removal() -> Weight {
- (84_138_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(17 as Weight))
- .saturating_add(RocksDbWeight::get().writes(5 as Weight))
+ (45_535_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(9 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
}
runtime/common/src/runtime_apis.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#[macro_export]18macro_rules! impl_common_runtime_apis {19 (20 $(21 #![custom_apis]2223 $($custom_apis:tt)+24 )?25 ) => {26 impl_runtime_apis! {27 $($($custom_apis)+)?2829 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {30 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {31 dispatch_unique_runtime!(collection.account_tokens(account))32 }33 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {34 dispatch_unique_runtime!(collection.collection_tokens())35 }36 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {37 dispatch_unique_runtime!(collection.token_exists(token))38 }3940 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {41 dispatch_unique_runtime!(collection.token_owner(token))42 }43 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {44 let budget = up_data_structs::budget::Value::new(10);4546 Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))47 }48 fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {49 Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))50 }51 fn collection_properties(52 collection: CollectionId,53 keys: Option<Vec<Vec<u8>>>54 ) -> Result<Vec<Property>, DispatchError> {55 let keys = keys.map(56 |keys| Common::bytes_keys_to_property_keys(keys)57 ).transpose()?;5859 Common::filter_collection_properties(collection, keys)60 }6162 fn token_properties(63 collection: CollectionId,64 token_id: TokenId,65 keys: Option<Vec<Vec<u8>>>66 ) -> Result<Vec<Property>, DispatchError> {67 let keys = keys.map(68 |keys| Common::bytes_keys_to_property_keys(keys)69 ).transpose()?;7071 dispatch_unique_runtime!(collection.token_properties(token_id, keys))72 }7374 fn property_permissions(75 collection: CollectionId,76 keys: Option<Vec<Vec<u8>>>77 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {78 let keys = keys.map(79 |keys| Common::bytes_keys_to_property_keys(keys)80 ).transpose()?;8182 Common::filter_property_permissions(collection, keys)83 }8485 fn token_data(86 collection: CollectionId,87 token_id: TokenId,88 keys: Option<Vec<Vec<u8>>>89 ) -> Result<TokenData<CrossAccountId>, DispatchError> {90 let token_data = TokenData {91 properties: Self::token_properties(collection, token_id, keys)?,92 owner: Self::token_owner(collection, token_id)?93 };9495 Ok(token_data)96 }9798 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {99 dispatch_unique_runtime!(collection.total_supply())100 }101 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {102 dispatch_unique_runtime!(collection.account_balance(account))103 }104 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {105 dispatch_unique_runtime!(collection.balance(account, token))106 }107 fn allowance(108 collection: CollectionId,109 sender: CrossAccountId,110 spender: CrossAccountId,111 token: TokenId,112 ) -> Result<u128, DispatchError> {113 dispatch_unique_runtime!(collection.allowance(sender, spender, token))114 }115116 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {117 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))118 }119 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {120 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))121 }122 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {123 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))124 }125 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {126 dispatch_unique_runtime!(collection.last_token_id())127 }128 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {129 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))130 }131 fn collection_stats() -> Result<CollectionStats, DispatchError> {132 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())133 }134 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {135 Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as136 $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(137 collection,138 account,139 token))140 }141142 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {143 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))144 }145 }146147 impl sp_api::Core<Block> for Runtime {148 fn version() -> RuntimeVersion {149 VERSION150 }151152 fn execute_block(block: Block) {153 Executive::execute_block(block)154 }155156 fn initialize_block(header: &<Block as BlockT>::Header) {157 Executive::initialize_block(header)158 }159 }160161 impl sp_api::Metadata<Block> for Runtime {162 fn metadata() -> OpaqueMetadata {163 OpaqueMetadata::new(Runtime::metadata().into())164 }165 }166167 impl sp_block_builder::BlockBuilder<Block> for Runtime {168 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {169 Executive::apply_extrinsic(extrinsic)170 }171172 fn finalize_block() -> <Block as BlockT>::Header {173 Executive::finalize_block()174 }175176 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {177 data.create_extrinsics()178 }179180 fn check_inherents(181 block: Block,182 data: sp_inherents::InherentData,183 ) -> sp_inherents::CheckInherentsResult {184 data.check_extrinsics(&block)185 }186187 // fn random_seed() -> <Block as BlockT>::Hash {188 // RandomnessCollectiveFlip::random_seed().0189 // }190 }191192 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {193 fn validate_transaction(194 source: TransactionSource,195 tx: <Block as BlockT>::Extrinsic,196 hash: <Block as BlockT>::Hash,197 ) -> TransactionValidity {198 Executive::validate_transaction(source, tx, hash)199 }200 }201202 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {203 fn offchain_worker(header: &<Block as BlockT>::Header) {204 Executive::offchain_worker(header)205 }206 }207208 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {209 fn chain_id() -> u64 {210 <Runtime as pallet_evm::Config>::ChainId::get()211 }212213 fn account_basic(address: H160) -> EVMAccount {214 let (account, _) = EVM::account_basic(&address);215 account216 }217218 fn gas_price() -> U256 {219 let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();220 price221 }222223 fn account_code_at(address: H160) -> Vec<u8> {224 EVM::account_codes(address)225 }226227 fn author() -> H160 {228 <pallet_evm::Pallet<Runtime>>::find_author()229 }230231 fn storage_at(address: H160, index: U256) -> H256 {232 let mut tmp = [0u8; 32];233 index.to_big_endian(&mut tmp);234 EVM::account_storages(address, H256::from_slice(&tmp[..]))235 }236237 #[allow(clippy::redundant_closure)]238 fn call(239 from: H160,240 to: H160,241 data: Vec<u8>,242 value: U256,243 gas_limit: U256,244 max_fee_per_gas: Option<U256>,245 max_priority_fee_per_gas: Option<U256>,246 nonce: Option<U256>,247 estimate: bool,248 access_list: Option<Vec<(H160, Vec<H256>)>>,249 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {250 let config = if estimate {251 let mut config = <Runtime as pallet_evm::Config>::config().clone();252 config.estimate = true;253 Some(config)254 } else {255 None256 };257258 let is_transactional = false;259 <Runtime as pallet_evm::Config>::Runner::call(260 CrossAccountId::from_eth(from),261 to,262 data,263 value,264 gas_limit.low_u64(),265 max_fee_per_gas,266 max_priority_fee_per_gas,267 nonce,268 access_list.unwrap_or_default(),269 is_transactional,270 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),271 ).map_err(|err| err.error.into())272 }273274 #[allow(clippy::redundant_closure)]275 fn create(276 from: H160,277 data: Vec<u8>,278 value: U256,279 gas_limit: U256,280 max_fee_per_gas: Option<U256>,281 max_priority_fee_per_gas: Option<U256>,282 nonce: Option<U256>,283 estimate: bool,284 access_list: Option<Vec<(H160, Vec<H256>)>>,285 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {286 let config = if estimate {287 let mut config = <Runtime as pallet_evm::Config>::config().clone();288 config.estimate = true;289 Some(config)290 } else {291 None292 };293294 let is_transactional = false;295 <Runtime as pallet_evm::Config>::Runner::create(296 CrossAccountId::from_eth(from),297 data,298 value,299 gas_limit.low_u64(),300 max_fee_per_gas,301 max_priority_fee_per_gas,302 nonce,303 access_list.unwrap_or_default(),304 is_transactional,305 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),306 ).map_err(|err| err.error.into())307 }308309 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {310 Ethereum::current_transaction_statuses()311 }312313 fn current_block() -> Option<pallet_ethereum::Block> {314 Ethereum::current_block()315 }316317 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {318 Ethereum::current_receipts()319 }320321 fn current_all() -> (322 Option<pallet_ethereum::Block>,323 Option<Vec<pallet_ethereum::Receipt>>,324 Option<Vec<TransactionStatus>>325 ) {326 (327 Ethereum::current_block(),328 Ethereum::current_receipts(),329 Ethereum::current_transaction_statuses()330 )331 }332333 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {334 xts.into_iter().filter_map(|xt| match xt.0.function {335 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),336 _ => None337 }).collect()338 }339340 fn elasticity() -> Option<Permill> {341 None342 }343 }344345 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {346 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {347 UncheckedExtrinsic::new_unsigned(348 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),349 )350 }351 }352353 impl sp_session::SessionKeys<Block> for Runtime {354 fn decode_session_keys(355 encoded: Vec<u8>,356 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {357 SessionKeys::decode_into_raw_public_keys(&encoded)358 }359360 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {361 SessionKeys::generate(seed)362 }363 }364365 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {366 fn slot_duration() -> sp_consensus_aura::SlotDuration {367 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())368 }369370 fn authorities() -> Vec<AuraId> {371 Aura::authorities().to_vec()372 }373 }374375 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {376 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {377 ParachainSystem::collect_collation_info(header)378 }379 }380381 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {382 fn account_nonce(account: AccountId) -> Index {383 System::account_nonce(account)384 }385 }386387 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {388 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {389 TransactionPayment::query_info(uxt, len)390 }391 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {392 TransactionPayment::query_fee_details(uxt, len)393 }394 }395396 /*397 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>398 for Runtime399 {400 fn call(401 origin: AccountId,402 dest: AccountId,403 value: Balance,404 gas_limit: u64,405 input_data: Vec<u8>,406 ) -> pallet_contracts_primitives::ContractExecResult {407 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)408 }409410 fn instantiate(411 origin: AccountId,412 endowment: Balance,413 gas_limit: u64,414 code: pallet_contracts_primitives::Code<Hash>,415 data: Vec<u8>,416 salt: Vec<u8>,417 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>418 {419 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)420 }421422 fn get_storage(423 address: AccountId,424 key: [u8; 32],425 ) -> pallet_contracts_primitives::GetStorageResult {426 Contracts::get_storage(address, key)427 }428429 fn rent_projection(430 address: AccountId,431 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {432 Contracts::rent_projection(address)433 }434 }435 */436437 #[cfg(feature = "runtime-benchmarks")]438 impl frame_benchmarking::Benchmark<Block> for Runtime {439 fn benchmark_metadata(extra: bool) -> (440 Vec<frame_benchmarking::BenchmarkList>,441 Vec<frame_support::traits::StorageInfo>,442 ) {443 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};444 use frame_support::traits::StorageInfoTrait;445446 let mut list = Vec::<BenchmarkList>::new();447448 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);449 list_benchmark!(list, extra, pallet_common, Common);450 list_benchmark!(list, extra, pallet_unique, Unique);451 list_benchmark!(list, extra, pallet_structure, Structure);452 list_benchmark!(list, extra, pallet_inflation, Inflation);453 list_benchmark!(list, extra, pallet_fungible, Fungible);454 list_benchmark!(list, extra, pallet_refungible, Refungible);455 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);456 list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);457 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);458459 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();460461 return (list, storage_info)462 }463464 fn dispatch_benchmark(465 config: frame_benchmarking::BenchmarkConfig466 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {467 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};468469 let allowlist: Vec<TrackedStorageKey> = vec![470 // Total Issuance471 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),472473 // Block Number474 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),475 // Execution Phase476 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),477 // Event Count478 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),479 // System Events480 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),481482 // Evm CurrentLogs483 hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),484485 // Transactional depth486 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),487 ];488489 let mut batches = Vec::<BenchmarkBatch>::new();490 let params = (&config, &allowlist);491492 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);493 add_benchmark!(params, batches, pallet_common, Common);494 add_benchmark!(params, batches, pallet_unique, Unique);495 add_benchmark!(params, batches, pallet_structure, Structure);496 add_benchmark!(params, batches, pallet_inflation, Inflation);497 add_benchmark!(params, batches, pallet_fungible, Fungible);498 add_benchmark!(params, batches, pallet_refungible, Refungible);499 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);500 add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);501 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);502503 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }504 Ok(batches)505 }506 }507508 #[cfg(feature = "try-runtime")]509 impl frame_try_runtime::TryRuntime<Block> for Runtime {510 fn on_runtime_upgrade() -> (Weight, Weight) {511 log::info!("try-runtime::on_runtime_upgrade unique-chain.");512 let weight = Executive::try_runtime_upgrade().unwrap();513 (weight, RuntimeBlockWeights::get().max_block)514 }515516 fn execute_block_no_check(block: Block) -> Weight {517 Executive::execute_block_no_check(block)518 }519 }520 }521 }522}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#[macro_export]18macro_rules! impl_common_runtime_apis {19 (20 $(21 #![custom_apis]2223 $($custom_apis:tt)+24 )?25 ) => {26 impl_runtime_apis! {27 $($($custom_apis)+)?2829 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {30 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {31 dispatch_unique_runtime!(collection.account_tokens(account))32 }33 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {34 dispatch_unique_runtime!(collection.collection_tokens())35 }36 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {37 dispatch_unique_runtime!(collection.token_exists(token))38 }3940 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {41 dispatch_unique_runtime!(collection.token_owner(token))42 }43 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {44 let budget = up_data_structs::budget::Value::new(10);4546 Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))47 }48 fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {49 Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))50 }51 fn collection_properties(52 collection: CollectionId,53 keys: Option<Vec<Vec<u8>>>54 ) -> Result<Vec<Property>, DispatchError> {55 let keys = keys.map(56 |keys| Common::bytes_keys_to_property_keys(keys)57 ).transpose()?;5859 Common::filter_collection_properties(collection, keys)60 }6162 fn token_properties(63 collection: CollectionId,64 token_id: TokenId,65 keys: Option<Vec<Vec<u8>>>66 ) -> Result<Vec<Property>, DispatchError> {67 let keys = keys.map(68 |keys| Common::bytes_keys_to_property_keys(keys)69 ).transpose()?;7071 dispatch_unique_runtime!(collection.token_properties(token_id, keys))72 }7374 fn property_permissions(75 collection: CollectionId,76 keys: Option<Vec<Vec<u8>>>77 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {78 let keys = keys.map(79 |keys| Common::bytes_keys_to_property_keys(keys)80 ).transpose()?;8182 Common::filter_property_permissions(collection, keys)83 }8485 fn token_data(86 collection: CollectionId,87 token_id: TokenId,88 keys: Option<Vec<Vec<u8>>>89 ) -> Result<TokenData<CrossAccountId>, DispatchError> {90 let token_data = TokenData {91 properties: Self::token_properties(collection, token_id, keys)?,92 owner: Self::token_owner(collection, token_id)?93 };9495 Ok(token_data)96 }9798 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {99 dispatch_unique_runtime!(collection.total_supply())100 }101 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {102 dispatch_unique_runtime!(collection.account_balance(account))103 }104 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {105 dispatch_unique_runtime!(collection.balance(account, token))106 }107 fn allowance(108 collection: CollectionId,109 sender: CrossAccountId,110 spender: CrossAccountId,111 token: TokenId,112 ) -> Result<u128, DispatchError> {113 dispatch_unique_runtime!(collection.allowance(sender, spender, token))114 }115116 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {117 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))118 }119 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {120 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))121 }122 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {123 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))124 }125 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {126 dispatch_unique_runtime!(collection.last_token_id())127 }128 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {129 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))130 }131 fn collection_stats() -> Result<CollectionStats, DispatchError> {132 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())133 }134 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {135 Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as136 $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(137 collection,138 account,139 token))140 }141142 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {143 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))144 }145 }146147 impl sp_api::Core<Block> for Runtime {148 fn version() -> RuntimeVersion {149 VERSION150 }151152 fn execute_block(block: Block) {153 Executive::execute_block(block)154 }155156 fn initialize_block(header: &<Block as BlockT>::Header) {157 Executive::initialize_block(header)158 }159 }160161 impl sp_api::Metadata<Block> for Runtime {162 fn metadata() -> OpaqueMetadata {163 OpaqueMetadata::new(Runtime::metadata().into())164 }165 }166167 impl sp_block_builder::BlockBuilder<Block> for Runtime {168 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {169 Executive::apply_extrinsic(extrinsic)170 }171172 fn finalize_block() -> <Block as BlockT>::Header {173 Executive::finalize_block()174 }175176 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {177 data.create_extrinsics()178 }179180 fn check_inherents(181 block: Block,182 data: sp_inherents::InherentData,183 ) -> sp_inherents::CheckInherentsResult {184 data.check_extrinsics(&block)185 }186187 // fn random_seed() -> <Block as BlockT>::Hash {188 // RandomnessCollectiveFlip::random_seed().0189 // }190 }191192 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {193 fn validate_transaction(194 source: TransactionSource,195 tx: <Block as BlockT>::Extrinsic,196 hash: <Block as BlockT>::Hash,197 ) -> TransactionValidity {198 Executive::validate_transaction(source, tx, hash)199 }200 }201202 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {203 fn offchain_worker(header: &<Block as BlockT>::Header) {204 Executive::offchain_worker(header)205 }206 }207208 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {209 fn chain_id() -> u64 {210 <Runtime as pallet_evm::Config>::ChainId::get()211 }212213 fn account_basic(address: H160) -> EVMAccount {214 let (account, _) = EVM::account_basic(&address);215 account216 }217218 fn gas_price() -> U256 {219 let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();220 price221 }222223 fn account_code_at(address: H160) -> Vec<u8> {224 EVM::account_codes(address)225 }226227 fn author() -> H160 {228 <pallet_evm::Pallet<Runtime>>::find_author()229 }230231 fn storage_at(address: H160, index: U256) -> H256 {232 let mut tmp = [0u8; 32];233 index.to_big_endian(&mut tmp);234 EVM::account_storages(address, H256::from_slice(&tmp[..]))235 }236237 #[allow(clippy::redundant_closure)]238 fn call(239 from: H160,240 to: H160,241 data: Vec<u8>,242 value: U256,243 gas_limit: U256,244 max_fee_per_gas: Option<U256>,245 max_priority_fee_per_gas: Option<U256>,246 nonce: Option<U256>,247 estimate: bool,248 access_list: Option<Vec<(H160, Vec<H256>)>>,249 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {250 let config = if estimate {251 let mut config = <Runtime as pallet_evm::Config>::config().clone();252 config.estimate = true;253 Some(config)254 } else {255 None256 };257258 let is_transactional = false;259 <Runtime as pallet_evm::Config>::Runner::call(260 CrossAccountId::from_eth(from),261 to,262 data,263 value,264 gas_limit.low_u64(),265 max_fee_per_gas,266 max_priority_fee_per_gas,267 nonce,268 access_list.unwrap_or_default(),269 is_transactional,270 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),271 ).map_err(|err| err.error.into())272 }273274 #[allow(clippy::redundant_closure)]275 fn create(276 from: H160,277 data: Vec<u8>,278 value: U256,279 gas_limit: U256,280 max_fee_per_gas: Option<U256>,281 max_priority_fee_per_gas: Option<U256>,282 nonce: Option<U256>,283 estimate: bool,284 access_list: Option<Vec<(H160, Vec<H256>)>>,285 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {286 let config = if estimate {287 let mut config = <Runtime as pallet_evm::Config>::config().clone();288 config.estimate = true;289 Some(config)290 } else {291 None292 };293294 let is_transactional = false;295 <Runtime as pallet_evm::Config>::Runner::create(296 CrossAccountId::from_eth(from),297 data,298 value,299 gas_limit.low_u64(),300 max_fee_per_gas,301 max_priority_fee_per_gas,302 nonce,303 access_list.unwrap_or_default(),304 is_transactional,305 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),306 ).map_err(|err| err.error.into())307 }308309 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {310 Ethereum::current_transaction_statuses()311 }312313 fn current_block() -> Option<pallet_ethereum::Block> {314 Ethereum::current_block()315 }316317 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {318 Ethereum::current_receipts()319 }320321 fn current_all() -> (322 Option<pallet_ethereum::Block>,323 Option<Vec<pallet_ethereum::Receipt>>,324 Option<Vec<TransactionStatus>>325 ) {326 (327 Ethereum::current_block(),328 Ethereum::current_receipts(),329 Ethereum::current_transaction_statuses()330 )331 }332333 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {334 xts.into_iter().filter_map(|xt| match xt.0.function {335 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),336 _ => None337 }).collect()338 }339340 fn elasticity() -> Option<Permill> {341 None342 }343 }344345 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {346 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {347 UncheckedExtrinsic::new_unsigned(348 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),349 )350 }351 }352353 impl sp_session::SessionKeys<Block> for Runtime {354 fn decode_session_keys(355 encoded: Vec<u8>,356 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {357 SessionKeys::decode_into_raw_public_keys(&encoded)358 }359360 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {361 SessionKeys::generate(seed)362 }363 }364365 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {366 fn slot_duration() -> sp_consensus_aura::SlotDuration {367 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())368 }369370 fn authorities() -> Vec<AuraId> {371 Aura::authorities().to_vec()372 }373 }374375 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {376 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {377 ParachainSystem::collect_collation_info(header)378 }379 }380381 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {382 fn account_nonce(account: AccountId) -> Index {383 System::account_nonce(account)384 }385 }386387 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {388 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {389 TransactionPayment::query_info(uxt, len)390 }391 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {392 TransactionPayment::query_fee_details(uxt, len)393 }394 }395396 /*397 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>398 for Runtime399 {400 fn call(401 origin: AccountId,402 dest: AccountId,403 value: Balance,404 gas_limit: u64,405 input_data: Vec<u8>,406 ) -> pallet_contracts_primitives::ContractExecResult {407 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)408 }409410 fn instantiate(411 origin: AccountId,412 endowment: Balance,413 gas_limit: u64,414 code: pallet_contracts_primitives::Code<Hash>,415 data: Vec<u8>,416 salt: Vec<u8>,417 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>418 {419 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)420 }421422 fn get_storage(423 address: AccountId,424 key: [u8; 32],425 ) -> pallet_contracts_primitives::GetStorageResult {426 Contracts::get_storage(address, key)427 }428429 fn rent_projection(430 address: AccountId,431 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {432 Contracts::rent_projection(address)433 }434 }435 */436437 #[cfg(feature = "runtime-benchmarks")]438 impl frame_benchmarking::Benchmark<Block> for Runtime {439 fn benchmark_metadata(extra: bool) -> (440 Vec<frame_benchmarking::BenchmarkList>,441 Vec<frame_support::traits::StorageInfo>,442 ) {443 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};444 use frame_support::traits::StorageInfoTrait;445446 let mut list = Vec::<BenchmarkList>::new();447448 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);449 list_benchmark!(list, extra, pallet_common, Common);450 list_benchmark!(list, extra, pallet_unique, Unique);451 list_benchmark!(list, extra, pallet_structure, Structure);452 list_benchmark!(list, extra, pallet_inflation, Inflation);453 list_benchmark!(list, extra, pallet_fungible, Fungible);454 list_benchmark!(list, extra, pallet_refungible, Refungible);455 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);456 list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);457458 #[cfg(not(feature = "unique-runtime"))]459 list_benchmark!(list, extra, pallet_proxy_rmrk_core, RmrkCore);460461 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);462463 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();464465 return (list, storage_info)466 }467468 fn dispatch_benchmark(469 config: frame_benchmarking::BenchmarkConfig470 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {471 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};472473 let allowlist: Vec<TrackedStorageKey> = vec![474 // Total Issuance475 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),476477 // Block Number478 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),479 // Execution Phase480 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),481 // Event Count482 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),483 // System Events484 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),485486 // Evm CurrentLogs487 hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),488489 // Transactional depth490 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),491 ];492493 let mut batches = Vec::<BenchmarkBatch>::new();494 let params = (&config, &allowlist);495496 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);497 add_benchmark!(params, batches, pallet_common, Common);498 add_benchmark!(params, batches, pallet_unique, Unique);499 add_benchmark!(params, batches, pallet_structure, Structure);500 add_benchmark!(params, batches, pallet_inflation, Inflation);501 add_benchmark!(params, batches, pallet_fungible, Fungible);502 add_benchmark!(params, batches, pallet_refungible, Refungible);503 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);504 add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);505506 #[cfg(not(feature = "unique-runtime"))]507 add_benchmark!(params, batches, pallet_proxy_rmrk_core, RmrkCore);508509 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);510511 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }512 Ok(batches)513 }514 }515516 #[cfg(feature = "try-runtime")]517 impl frame_try_runtime::TryRuntime<Block> for Runtime {518 fn on_runtime_upgrade() -> (Weight, Weight) {519 log::info!("try-runtime::on_runtime_upgrade unique-chain.");520 let weight = Executive::try_runtime_upgrade().unwrap();521 (weight, RuntimeBlockWeights::get().max_block)522 }523524 fn execute_block_no_check(block: Block) -> Weight {525 Executive::execute_block_no_check(block)526 }527 }528 }529 }530}runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -16,7 +16,7 @@
targets = ['x86_64-unknown-linux-gnu']
[features]
-default = ['std']
+default = ['std', 'unique-runtime']
runtime-benchmarks = [
'hex-literal',
'frame-benchmarking',
@@ -119,6 +119,7 @@
"orml-vesting/std",
]
limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
+unique-runtime = []
################################################################################
# Substrate Dependencies