Skip to content

Commit

Permalink
Weight meter (#450)
Browse files Browse the repository at this point in the history
* Use MultiLocation as xtokens transfer dest type. (#396)

* Use MultiLocation as xtokens transfer dest type.

* Make clippy happy.

* Use xcm-handler to execute XCM locally (#401)

* Use cumulus xcm-handler to execute XCM locally.

* Add docstring for xtokens config.

* Replace XcmError::Undefined usage. (#402)

* Replace XcmError::Undefined usage.

* make clippy happy

* Bump and unify serde versions. (#403)

* xtokens and xcm-support documentations (#404)

* Add xtokens module docstring.

* Add xtokens readme.

* Add documentations for xcm-support.

* Add xtokens and xcm-support entries in main readme.

* Add unit tests for xcm-support. (#405)

* Added Minterest to the list of users. (#406)

* update step guide link

* Handle unknown assets in TransactAsset impl (#409)

* Handle unknown assets in TransactAsset impl.

* More documentations.

* Clean code.

* Renaming.

* Should try to deposit known asset first.

* Return error if no UnknownAsset impl.

* Make clippy happy.

* Fix description and repo link. (#410)

* Unknown tokens pallet (#411)

* Impl unknown tokens pallet.

* Fix workspace pallet path.

* Make clippy happy.

* Clippy, be happy.

* Unit tests.

* Remove nonces from oracle pallet. (#413)

* refactor rewards (#412)

* Bump rococo v1 dependencies (#418)

* Fix mocks.

* Replace deprecated.

* Update orml-unknown-tokens unit tests. (#421)

* add build-script-utils from Substrate (#422)

* Update README.md (#420)

* Update README.md

* Update README.md

* Bump impl-trait-for-tuples to 0.2.1 (#424)

* update Cargo.toml (#429)

* add Handler (#431)

* remove disable-tokens-by-owner (#434)

* Cross-chain transfer rework (#432)

* Reserve chain trait.

* Rework cross-chain transfer.

* Remove relay chain balance convert.

* Add 'Parse' trait.

* Change transfer_multiasset fn signature.

* Add transfer dispatchable call.

* Update doc.

* Use xcm-simulator to mock network.

* Send relay chain asset to sibling unit test.

* Move location traits into orml-traits.

* Add MultiNativeAsset filter for is reserve check.

* More unit tests.

* Failing edge case unit tests.

* Handle zero amount asset case.

* Fix mocks.

* Renaming.

* Update currency adapter to work with new xtokens impl (#436)

* Xcm support implementations rework.

* Update xtokens mock.

* Use CurrencyId convert. (#437)

* Use CurrencyId convert.

* Apply review suggestions.

* Update xtokens docs. (#438)

* Update xtokens docs.

* Fix typo.

* Update imbalances impl.

* Don't deposit failure event in orml-unknown-tokens. (#440)

* Don't deposit failure event in orml-unknown-tokens.

* Patch substrate/polkadot/cumulus.

* Fix patch.

* Update README.md (#441)

Include Zeitgeist into "Projects using ORML" section

* Add PoV size in benchmarking. (#442)

* Bump cumulus ref in cargo patch. (#443)

* fix missing features (#444)

* fix missing features

* test with benchmarks

* update auction weight (#445)

* Bump dependencies. (#448)

* Updated Cargo.dev.toml

Co-authored-by: Shaun Wang <[email protected]>
Co-authored-by: dzianis.ramanouski <[email protected]>
Co-authored-by: Bette <[email protected]>
Co-authored-by: wangjj9219 <[email protected]>
Co-authored-by: Xiliang Chen <[email protected]>
Co-authored-by: transxask <[email protected]>
Co-authored-by: Aaro Perämaa <[email protected]>
Co-authored-by: Harald Heckmann <[email protected]>
  • Loading branch information
9 people committed Apr 15, 2021
1 parent 3116627 commit e1c2321
Show file tree
Hide file tree
Showing 60 changed files with 2,107 additions and 688 deletions.
87 changes: 68 additions & 19 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ members = [
"currencies",
"gradually-update",
"oracle",
"oracle/rpc",
"oracle/rpc/runtime-api",
"tokens",
"traits",
"utilities",
Expand All @@ -16,26 +18,73 @@ members = [
"nft",
"xtokens",
"xcm-support",
"unknown-tokens",
"build-script-utils",
"weight-meter",
]
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
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ The Open Runtime Module Library (ORML) is a community maintained collection of S
- Provides scheduled balance locking mechanism, in a *graded vesting* way.
- [orml-gradually-update](./gradually-update)
- Provides way to adjust numeric parameter gradually over a period of time.
- [orml-xtokens](./xtokens)
- Provides way to do cross-chain assets transfer.
- [Step-by-Step guide](https://github.com/open-web3-stack/open-runtime-module-library/wiki/xtokens) to make XCM cross-chain fungible asset transfer available on your parachain
- [orml-xcm-support](./xcm-support)
- Provides traits, types, and implementations to support XCM integration.

## Example

Expand All @@ -48,7 +53,7 @@ ORML use `Cargo.dev.toml` to avoid workspace conflicts with project cargo config
- change the command to `make dev-check` etc which does the copy. (For the full list of `make` commands, check `Makefile`)

# Web3 Foundation Grant Project
ORML is part of the bigger `Open-Web3-Stack` initiative, that is currently under a General Grant from Web3 Foundation. See Application details [here](https://github.com/open-web3-stack/General-Grants-Program/blob/master/grants/speculative/open_web3_stack.md). The 1st milestone has been delivered.
ORML is part of the bigger `Open-Web3-Stack` initiative, that is currently under a General Grant from Web3 Foundation. See Application details [here](https://github.com/open-web3-stack/General-Grants-Program/blob/master/grants/speculative/open_web3_stack.md). The 1st milestone has been delivered.

# Projects using ORML
- [If you intend or are using ORML, please add your project here](https://github.com/open-web3-stack/open-runtime-module-library/edit/master/README.md)
Expand All @@ -61,6 +66,10 @@ _In alphabetical order_
- [ChainX](https://github.com/chainx-org/ChainX)
- [HydraDX](https://github.com/galacticcouncil/hack.HydraDX-node)
- [Laminar Chain](https://github.com/laminar-protocol/laminar-chain)
- [Listen](https://github.com/listenofficial)
- [Minterest](https://github.com/minterest-finance/minterest-chain-node)
- [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)

2 changes: 1 addition & 1 deletion auction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Acala Developers"]
edition = "2018"

[dependencies]
serde = { version = "1.0.111", optional = true }
serde = { version = "1.0.124", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false }
Expand Down
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
4 changes: 1 addition & 3 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 Expand Up @@ -131,7 +129,7 @@ pub mod module {
Auctions::<T>::try_mutate_exists(id, |auction| -> DispatchResult {
let mut auction = auction.as_mut().ok_or(Error::<T>::AuctionNotExist)?;

let block_number = <frame_system::Module<T>>::block_number();
let block_number = <frame_system::Pallet<T>>::block_number();

// make sure auction is started
ensure!(block_number >= auction.start, Error::<T>::AuctionNotStarted);
Expand Down
5 changes: 3 additions & 2 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 Expand Up @@ -86,8 +87,8 @@ construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Storage, Config, Event<T>},
AuctionModule: auction::{Module, Storage, Call, Event<T>},
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
AuctionModule: auction::{Pallet, Storage, Call, Event<T>},
}
);

Expand Down
4 changes: 3 additions & 1 deletion authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Acala Developers"]
edition = "2018"

[dependencies]
serde = { version = "1.0.111", optional = true }
serde = { version = "1.0.124", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false }
Expand Down Expand Up @@ -38,4 +38,6 @@ std = [
"orml-traits/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
6 changes: 3 additions & 3 deletions authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub mod module {
*id = id.checked_add(1).ok_or(Error::<T>::Overflow)?;
Ok(current_id)
})?;
let now = frame_system::Module::<T>::block_number();
let now = frame_system::Pallet::<T>::block_number();
let delay = match when {
DispatchTime::At(x) => x.checked_sub(&now).ok_or(Error::<T>::Overflow)?,
DispatchTime::After(x) => x,
Expand Down Expand Up @@ -283,7 +283,7 @@ pub mod module {
task_id: ScheduleTaskIndex,
when: DispatchTime<T::BlockNumber>,
) -> DispatchResultWithPostInfo {
let now = frame_system::Module::<T>::block_number();
let now = frame_system::Pallet::<T>::block_number();
let new_delay = match when {
DispatchTime::At(x) => x.checked_sub(&now).ok_or(Error::<T>::Overflow)?,
DispatchTime::After(x) => x,
Expand Down Expand Up @@ -317,7 +317,7 @@ pub mod module {
)
.map_err(|_| Error::<T>::FailedToDelay)?;

let now = frame_system::Module::<T>::block_number();
let now = frame_system::Pallet::<T>::block_number();
let dispatch_at = now.saturating_add(additional_delay);

Self::deposit_event(Event::Delayed(initial_origin, task_id, dispatch_at));
Expand Down
7 changes: 4 additions & 3 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 Expand Up @@ -162,9 +163,9 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Config, Event<T>},
Authority: authority::{Module, Call, Origin<T>, Event<T>},
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Event<T>},
Authority: authority::{Pallet, Call, Origin<T>, Event<T>},
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down
2 changes: 1 addition & 1 deletion benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Laminar Developers <[email protected]>"]
edition = "2018"

[dependencies]
serde = { version = "1.0.111", optional = true }
serde = { version = "1.0.124", optional = true }
paste = "0.1.16"
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false }
Expand Down
20 changes: 15 additions & 5 deletions benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ macro_rules! impl_benchmark {
>::instance(&selected_benchmark, c, verify)?;

// Set the block number to at least 1 so events are deposited.
if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) {
frame_system::Module::<$runtime>::set_block_number(1u32.into());
if $crate::Zero::is_zero(&frame_system::Pallet::<$runtime>::block_number()) {
frame_system::Pallet::<$runtime>::set_block_number(1u32.into());
}

// Commit the externalities to the database, flushing the DB cache.
Expand All @@ -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 Expand Up @@ -990,8 +1000,8 @@ macro_rules! impl_benchmark_test {
>::instance(&selected_benchmark, &c, true)?;

// Set the block number to at least 1 so events are deposited.
if $crate::Zero::is_zero(&frame_system::Module::<$runtime>::block_number()) {
frame_system::Module::<$runtime>::set_block_number(1u32.into());
if $crate::Zero::is_zero(&frame_system::Pallet::<$runtime>::block_number()) {
frame_system::Pallet::<$runtime>::set_block_number(1u32.into());
}

// Run execution + verification
Expand Down
5 changes: 3 additions & 2 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 All @@ -97,8 +98,8 @@ construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Storage, Config, Event<T>},
Pallet: test::{Module, Call, Storage, Config},
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
Pallet: test::{Pallet, Call, Storage, Config},

}
);
Expand Down
Loading

0 comments on commit e1c2321

Please sign in to comment.