Add NFTs to Statemine (#456)

* Add NFTs to Statemine

* Update NFT deposits

* add_benchmark

* add feature flag

* std feature too

* add weights

* add `transfer_ownership` to `NonTransfer` blacklist

* fix merge

* add `approve_transfer` to `NonTransfer` blacklist

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2021-06-02 09:00:18 +02:00
committed by GitHub
parent b60d1e36d2
commit fccdc2da9a
6 changed files with 547 additions and 289 deletions
+319 -285
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
@@ -45,6 +45,7 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
node-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -91,6 +92,7 @@ runtime-benchmarks = [
'pallet-balances/runtime-benchmarks',
'pallet-multisig/runtime-benchmarks',
'pallet-proxy/runtime-benchmarks',
'pallet-uniques/runtime-benchmarks',
'pallet-utility/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
@@ -127,6 +129,7 @@ std = [
"pallet-timestamp/std",
"pallet-transaction-payment/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-uniques/std",
"pallet-utility/std",
"parachain-info/std",
"cumulus-pallet-aura-ext/std",
@@ -150,7 +150,8 @@ pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(c: &Call) -> bool {
!matches!(c,
Call::Assets(pallet_assets::Call::create(..))
Call::Assets(pallet_assets::Call::create(..)) |
Call::Uniques(pallet_uniques::Call::create(..))
)
}
}
@@ -269,6 +270,33 @@ impl pallet_assets::Config for Runtime {
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
}
parameter_types! {
pub const ClassDeposit: Balance = UNITS; // 1 UNIT deposit to create asset class
pub const InstanceDeposit: Balance = UNITS / 100; // 1/100 UNIT deposit to create asset instance
pub const KeyLimit: u32 = 32; // Max 32 bytes per key
pub const ValueLimit: u32 = 64; // Max 64 bytes per value
pub const UniquesMetadataDepositBase: Balance = deposit(1, 129);
pub const AttributeDepositBase: Balance = deposit(1, 0);
pub const DepositPerByte: Balance = deposit(0, 1);
}
impl pallet_uniques::Config for Runtime {
type Event = Event;
type ClassId = u32;
type InstanceId = u32;
type Currency = Balances;
type ForceOrigin = AssetsForceOrigin;
type ClassDeposit = ClassDeposit;
type InstanceDeposit = InstanceDeposit;
type MetadataDepositBase = UniquesMetadataDepositBase;
type AttributeDepositBase = AttributeDepositBase;
type DepositPerByte = DepositPerByte;
type StringLimit = StringLimit;
type KeyLimit = KeyLimit;
type ValueLimit = ValueLimit;
type WeightInfo = weights::pallet_uniques::WeightInfo<Runtime>;
}
parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
@@ -339,7 +367,10 @@ impl InstanceFilter<Call> for ProxyType {
Call::Assets(pallet_assets::Call::force_transfer(..)) |
Call::Assets(pallet_assets::Call::transfer_ownership(..)) |
Call::Assets(pallet_assets::Call::approve_transfer(..)) |
Call::Assets(pallet_assets::Call::transfer_approved(..))
Call::Assets(pallet_assets::Call::transfer_approved(..)) |
Call::Uniques(pallet_uniques::Call::transfer(..)) |
Call::Uniques(pallet_uniques::Call::transfer_ownership(..)) |
Call::Uniques(pallet_uniques::Call::approve_transfer(..))
),
ProxyType::CancelProxy => matches!(c,
Call::Proxy(pallet_proxy::Call::reject_announcement(..)) |
@@ -347,7 +378,7 @@ impl InstanceFilter<Call> for ProxyType {
Call::Multisig(..)
),
ProxyType::Assets => {
matches!(c, Call::Assets(..) | Call::Utility(..) | Call::Multisig(..))
matches!(c, Call::Assets(..) | Call::Utility(..) | Call::Multisig(..) | Call::Uniques(..))
}
ProxyType::AssetOwner => matches!(c,
Call::Assets(pallet_assets::Call::create(..)) |
@@ -356,6 +387,16 @@ impl InstanceFilter<Call> for ProxyType {
Call::Assets(pallet_assets::Call::set_team(..)) |
Call::Assets(pallet_assets::Call::set_metadata(..)) |
Call::Assets(pallet_assets::Call::clear_metadata(..)) |
Call::Uniques(pallet_uniques::Call::create(..)) |
Call::Uniques(pallet_uniques::Call::destroy(..)) |
Call::Uniques(pallet_uniques::Call::transfer_ownership(..)) |
Call::Uniques(pallet_uniques::Call::set_team(..)) |
Call::Uniques(pallet_uniques::Call::set_metadata(..)) |
Call::Uniques(pallet_uniques::Call::set_attribute(..)) |
Call::Uniques(pallet_uniques::Call::set_class_metadata(..)) |
Call::Uniques(pallet_uniques::Call::clear_metadata(..)) |
Call::Uniques(pallet_uniques::Call::clear_attribute(..)) |
Call::Uniques(pallet_uniques::Call::clear_class_metadata(..)) |
Call::Utility(..) |
Call::Multisig(..)
),
@@ -366,6 +407,12 @@ impl InstanceFilter<Call> for ProxyType {
Call::Assets(pallet_assets::Call::thaw(..)) |
Call::Assets(pallet_assets::Call::freeze_asset(..)) |
Call::Assets(pallet_assets::Call::thaw_asset(..)) |
Call::Uniques(pallet_uniques::Call::mint(..)) |
Call::Uniques(pallet_uniques::Call::burn(..)) |
Call::Uniques(pallet_uniques::Call::freeze(..)) |
Call::Uniques(pallet_uniques::Call::thaw(..)) |
Call::Uniques(pallet_uniques::Call::freeze_class(..)) |
Call::Uniques(pallet_uniques::Call::thaw_class(..)) |
Call::Utility(..) |
Call::Multisig(..)
),
@@ -651,6 +698,7 @@ construct_runtime!(
// The main stage. To include pallet-assets-freezer and pallet-uniques.
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 50,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
}
);
@@ -822,6 +870,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_multisig, Multisig);
add_benchmark!(params, batches, pallet_proxy, Proxy);
add_benchmark!(params, batches, pallet_uniques, Uniques);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
@@ -4,4 +4,5 @@ pub mod pallet_multisig;
pub mod pallet_collator_selection;
pub mod pallet_proxy;
pub mod pallet_timestamp;
pub mod pallet_uniques;
pub mod pallet_utility;
@@ -0,0 +1,171 @@
// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for pallet_uniques
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-06-02, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128
// Executed Command:
// ./target/release/polkadot-collator
// benchmark
// --chain=statemine-dev
// --steps=50
// --repeat=20
// --pallet=pallet_uniques
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./polkadot-parachains/statemine-runtime/src/weights/
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;
/// Weight functions for pallet_uniques.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
fn create() -> Weight {
(42_199_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn force_create() -> Weight {
(21_030_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn destroy(n: u32, m: u32, a: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 14_000
.saturating_add((16_814_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 14_000
.saturating_add((1_026_000 as Weight).saturating_mul(m as Weight))
// Standard Error: 14_000
.saturating_add((952_000 as Weight).saturating_mul(a as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(m as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight)))
}
fn mint() -> Weight {
(57_236_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn burn() -> Weight {
(58_129_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn transfer() -> Weight {
(42_980_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn redeposit(i: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 11_000
.saturating_add((26_921_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn freeze() -> Weight {
(30_427_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn thaw() -> Weight {
(29_789_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn freeze_class() -> Weight {
(21_380_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn thaw_class() -> Weight {
(21_430_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn transfer_ownership() -> Weight {
(49_331_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn set_team() -> Weight {
(22_305_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn force_asset_status() -> Weight {
(21_965_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_attribute() -> Weight {
(70_386_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn clear_attribute() -> Weight {
(63_932_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn set_metadata() -> Weight {
(53_647_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn clear_metadata() -> Weight {
(52_353_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn set_class_metadata() -> Weight {
(51_900_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn clear_class_metadata() -> Weight {
(46_929_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn approve_transfer() -> Weight {
(32_693_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn cancel_approval() -> Weight {
(32_418_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}