Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 64 additions & 19 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,67 @@ members = [
]
resolver = "2"

[patch.crates-io]
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
pallet-treasury = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" }
[patch.'https://github.com/paritytech/substrate']
frame-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
frame-support = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
frame-system = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-balances = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-elections-phragmen = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-scheduler = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-treasury = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-authorship = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-vesting = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-timestamp = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-session = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-staking = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-offences = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
pallet-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-api = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-application-crypto = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-arithmetic = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-core = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-inherents = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-io = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-runtime = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-runtime-interface = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-std = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-trie = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-version = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-externalities = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-state-machine = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-wasm-interface = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-keystore = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-staking = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-storage = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-panic-handler = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-npos-elections = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-npos-elections-compact = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-debug-derive = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-allocator = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sc-executor-common = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sc-executor-wasmi = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sc-executor = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sc-client-api = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-tasks = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-authorship = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-consensus = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-timestamp = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-session = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-blockchain = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }
sp-transaction-pool = { git = "https://github.com/paritytech//substrate", rev = "816ed3d4e77a2463c86e69ec5a26fc307ef452b9" }

[patch.'https://github.com/paritytech/cumulus']
cumulus-primitives-core = { git = "https://github.com/paritytech//cumulus", rev = "3db8a38cfad53c4fe742ca68d7b425b88c61813d" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech//cumulus", rev = "3db8a38cfad53c4fe742ca68d7b425b88c61813d" }
parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "3db8a38cfad53c4fe742ca68d7b425b88c61813d" }
cumulus-pallet-xcm-handler = { git = "https://github.com/paritytech//cumulus", rev = "3db8a38cfad53c4fe742ca68d7b425b88c61813d" }

[patch.'https://github.com/paritytech/polkadot']
xcm = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
xcm-executor = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
xcm-builder = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
polkadot-core-primitives = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
polkadot-parachain = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
polkadot-primitives = { git = "https://github.com/paritytech//polkadot", rev = "8adff378fe35c850d5155732ae32260bcb5feb9b" }
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ check-tests: githooks

test: githooks
./scripts/run.sh test
cargo test --manifest-path nft/Cargo.toml -p orml-nft --features disable-tokens-by-owner

GITHOOKS_SRC = $(wildcard githooks/*)
GITHOOKS_DEST = $(patsubst githooks/%, $(GITHOOK)/%, $(GITHOOKS_SRC))
Expand Down Expand Up @@ -47,5 +46,4 @@ dev-check-tests: Cargo.toml
cargo check --tests --all

dev-test: Cargo.toml
cargo test --all
cargo test --manifest-path nft/Cargo.toml -p orml-nft --features disable-tokens-by-owner
cargo test --all --features runtime-benchmarks
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ _In alphabetical order_
- [Plasm Network](https://github.com/PlasmNetwork)
- [Setheum Network](https://github.com/Setheum-Labs/Setheum)
- [Valiu Liquidity Network](https://github.com/valibre-org/vln-node)
- [Zeitgeist](https://github.com/zeitgeistpm/zeitgeist)

10 changes: 0 additions & 10 deletions auction/src/default_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ impl crate::WeightInfo for () {
.saturating_add(DbWeight::get().reads(12 as Weight))
.saturating_add(DbWeight::get().writes(12 as Weight))
}
fn bid_surplus_auction() -> Weight {
(257_830_000 as Weight)
.saturating_add(DbWeight::get().reads(6 as Weight))
.saturating_add(DbWeight::get().writes(5 as Weight))
}
fn bid_debit_auction() -> Weight {
(287_271_000 as Weight)
.saturating_add(DbWeight::get().reads(7 as Weight))
.saturating_add(DbWeight::get().writes(8 as Weight))
}
fn on_finalize(c: u32) -> Weight {
(50_992_000 as Weight)
.saturating_add((171_653_000 as Weight).saturating_mul(c as Weight))
Expand Down
2 changes: 0 additions & 2 deletions auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ pub mod module {

pub trait WeightInfo {
fn bid_collateral_auction() -> Weight;
fn bid_surplus_auction() -> Weight;
fn bid_debit_auction() -> Weight;
fn on_finalize(c: u32) -> Weight;
}

Expand Down
1 change: 1 addition & 0 deletions auction/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

pub struct Handler;
Expand Down
2 changes: 2 additions & 0 deletions authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ std = [
"orml-traits/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions authority/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

parameter_types! {
Expand Down
12 changes: 11 additions & 1 deletion benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,21 @@ macro_rules! impl_benchmark {
"Start Benchmark: {:?}", c
);

let start_pov = $crate::benchmarking::proof_size();
let start_extrinsic = $crate::benchmarking::current_time();

closure_to_benchmark()?;

let finish_extrinsic = $crate::benchmarking::current_time();
let elapsed_extrinsic = finish_extrinsic - start_extrinsic;
let end_pov = $crate::benchmarking::proof_size();

// Calculate the diff caused by the benchmark.
let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic);
let diff_pov = match (start_pov, end_pov) {
(Some(start), Some(end)) => end.saturating_sub(start),
_ => Default::default(),
};

// Commit the changes to get proper write count
$crate::benchmarking::commit_db();
frame_support::log::trace!(
Expand All @@ -896,6 +905,7 @@ macro_rules! impl_benchmark {
repeat_reads: read_write_count.1,
writes: read_write_count.2,
repeat_writes: read_write_count.3,
proof_size: diff_pov,
});
}

Expand Down
1 change: 1 addition & 0 deletions benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl frame_system::Config for Test {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

impl tests::test::Config for Test {
Expand Down
7 changes: 4 additions & 3 deletions currencies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#![cfg(test)]

use super::*;
use frame_support::{construct_runtime, parameter_types};
use frame_support::{construct_runtime, parameter_types, PalletId};
use orml_traits::parameter_type_with_key;
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{AccountIdConversion, IdentityLookup},
AccountId32, ModuleId,
AccountId32,
};

use crate as currencies;
Expand Down Expand Up @@ -42,6 +42,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

type CurrencyId = u32;
Expand All @@ -68,7 +69,7 @@ parameter_type_with_key! {
}

parameter_types! {
pub DustAccount: AccountId = ModuleId(*b"orml/dst").into_account();
pub DustAccount: AccountId = PalletId(*b"orml/dst").into_account();
}

impl orml_tokens::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions gradually-update/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

parameter_types! {
Expand Down
1 change: 0 additions & 1 deletion nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ std = [
"frame-support/std",
"frame-system/std",
]
disable-tokens-by-owner = []
16 changes: 2 additions & 14 deletions nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ pub mod module {
StorageDoubleMap<_, Twox64Concat, T::ClassId, Twox64Concat, T::TokenId, TokenInfoOf<T>>;

/// Token existence check by owner and class ID.
// TODO: pallet macro doesn't support conditional compiling. Always having `TokensByOwner` storage doesn't hurt but
// it could be removed once conditional compiling supported.
// #[cfg(not(feature = "disable-tokens-by-owner"))]
#[pallet::storage]
#[pallet::getter(fn tokens_by_owner)]
pub type TokensByOwner<T: Config> =
Expand Down Expand Up @@ -216,11 +213,8 @@ impl<T: Config> Pallet<T> {

info.owner = to.clone();

#[cfg(not(feature = "disable-tokens-by-owner"))]
{
TokensByOwner::<T>::remove(from, token);
TokensByOwner::<T>::insert(to, token, ());
}
TokensByOwner::<T>::remove(from, token);
TokensByOwner::<T>::insert(to, token, ());

Ok(())
})
Expand Down Expand Up @@ -252,7 +246,6 @@ impl<T: Config> Pallet<T> {
data,
};
Tokens::<T>::insert(class_id, token_id, token_info);
#[cfg(not(feature = "disable-tokens-by-owner"))]
TokensByOwner::<T>::insert(owner, (class_id, token_id), ());

Ok(token_id)
Expand All @@ -274,7 +267,6 @@ impl<T: Config> Pallet<T> {
Ok(())
})?;

#[cfg(not(feature = "disable-tokens-by-owner"))]
TokensByOwner::<T>::remove(owner, token);

Ok(())
Expand All @@ -295,10 +287,6 @@ impl<T: Config> Pallet<T> {
}

pub fn is_owner(account: &T::AccountId, token: (T::ClassId, T::TokenId)) -> bool {
#[cfg(feature = "disable-tokens-by-owner")]
return Tokens::<T>::get(token.0, token.1).map_or(false, |token| token.owner == *account);

#[cfg(not(feature = "disable-tokens-by-owner"))]
TokensByOwner::<T>::contains_key(account, token)
}
}
1 change: 1 addition & 0 deletions nft/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

impl Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions oracle/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl frame_system::Config for Test {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

thread_local! {
Expand Down
1 change: 1 addition & 0 deletions rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
}

thread_local! {
Expand Down
4 changes: 4 additions & 0 deletions tokens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ std = [
"frame-system/std",
"orml-traits/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
Loading