Skip to content

Commit

Permalink
Update polkadot v0.9.36 (#878)
Browse files Browse the repository at this point in the history
* Fix payments on-idle (#868)

* fix payments on-idle

* update comment

* Switch to Rust-1.66 (#869)

* feat: derive MEL for Value enum (#867)

* feat: impl MEL for Value enum

* fmt: fix

* feat:Make the XcmTransfer trait support transfer_multiasset_with_fee (#870)

* update bencher deps (#872)

* add BenchmarkError::Weightless (#873)

* add BenchmarkError::Weightless

* Update benchmarking/src/lib.rs

Co-authored-by: zjb0807 <zjb0807@qq.com>

Co-authored-by: zjb0807 <zjb0807@qq.com>

* Update jsonrpsee 0.16.2 (#876)

* Update jsonrpsee 0.16.2

* fix clippy

* fix clippy

Co-authored-by: William Freudenberger <w.freude@icloud.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Ermal Kaleci <ermalkaleci@gmail.com>
Co-authored-by: Andrew Plaza <aplaza@liquidthink.net>
  • Loading branch information
5 people authored Jan 17, 2023
1 parent 4f5a3f3 commit db0381f
Show file tree
Hide file tree
Showing 33 changed files with 201 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Generate code coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
- name: Install cargo-unleash
run: cargo install cargo-unleash --git https://github.com/xlc/cargo-unleash.git # https://github.com/paritytech/cargo-unleash/pull/38
- name: Prepare
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-08-05
toolchain: nightly-2022-10-30
components: rustfmt
target: wasm32-unknown-unknown
- name: Install Wasm toolchain
Expand Down
5 changes: 5 additions & 0 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ members = [
"auction",
"authority",
"bencher",
"bencher/test",
"benchmarking",
"currencies",
"gradually-update",
"oracle",
"oracle/rpc",
"oracle/rpc/runtime-api",
"tokens",
"tokens/rpc",
"tokens/rpc/runtime-api",
"traits",
"utilities",
"vesting",
Expand All @@ -26,6 +29,8 @@ members = [
"payments"
]

exclude = ["bencher/test"]

resolver = "2"

[profile.dev]
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ dev-check: Cargo.toml check

dev-check-tests: Cargo.toml
cargo check --tests --all
cargo check --tests --features=bench --package=orml-weight-meter --package=orml-bencher-test

dev-test: Cargo.toml
cargo test --all --features runtime-benchmarks
cargo test --all --features=runtime-benchmarks
cargo test --features=bench --package=orml-weight-meter --package=orml-bencher-test

# run benchmarks via Acala node
benchmark-all:
Expand Down
2 changes: 1 addition & 1 deletion asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl<T: Config> Pallet<T> {
fn do_insert_location(asset_id: T::AssetId, location: VersionedMultiLocation) -> DispatchResult {
// if the metadata contains a location, set the LocationToAssetId
let location: MultiLocation = location.try_into().map_err(|()| Error::<T>::BadVersion)?;
LocationToAssetId::<T>::try_mutate(&location, |maybe_asset_id| {
LocationToAssetId::<T>::try_mutate(location, |maybe_asset_id| {
ensure!(maybe_asset_id.is_none(), Error::<T>::ConflictingLocation);
*maybe_asset_id = Some(asset_id);
Ok(())
Expand Down
18 changes: 9 additions & 9 deletions auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ pub mod module {
#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
fn on_initialize(now: T::BlockNumber) -> Weight {
T::WeightInfo::on_finalize(AuctionEndTime::<T>::iter_prefix(&now).count() as u32)
T::WeightInfo::on_finalize(AuctionEndTime::<T>::iter_prefix(now).count() as u32)
}

fn on_finalize(now: T::BlockNumber) {
for (auction_id, _) in AuctionEndTime::<T>::drain_prefix(&now) {
if let Some(auction) = Auctions::<T>::take(&auction_id) {
for (auction_id, _) in AuctionEndTime::<T>::drain_prefix(now) {
if let Some(auction) = Auctions::<T>::take(auction_id) {
T::Handler::on_auction_ended(auction_id, auction.bid);
}
}
Expand Down Expand Up @@ -151,10 +151,10 @@ pub mod module {
match bid_result.auction_end_change {
Change::NewValue(new_end) => {
if let Some(old_end_block) = auction.end {
AuctionEndTime::<T>::remove(&old_end_block, id);
AuctionEndTime::<T>::remove(old_end_block, id);
}
if let Some(new_end_block) = new_end {
AuctionEndTime::<T>::insert(&new_end_block, id, ());
AuctionEndTime::<T>::insert(new_end_block, id, ());
}
auction.end = new_end;
}
Expand Down Expand Up @@ -189,10 +189,10 @@ impl<T: Config> Auction<T::AccountId, T::BlockNumber> for Pallet<T> {
) -> DispatchResult {
let auction = Auctions::<T>::get(id).ok_or(Error::<T>::AuctionNotExist)?;
if let Some(old_end) = auction.end {
AuctionEndTime::<T>::remove(&old_end, id);
AuctionEndTime::<T>::remove(old_end, id);
}
if let Some(new_end) = info.end {
AuctionEndTime::<T>::insert(&new_end, id, ());
AuctionEndTime::<T>::insert(new_end, id, ());
}
Auctions::<T>::insert(id, info);
Ok(())
Expand All @@ -211,14 +211,14 @@ impl<T: Config> Auction<T::AccountId, T::BlockNumber> for Pallet<T> {
})?;
Auctions::<T>::insert(auction_id, auction);
if let Some(end_block) = end {
AuctionEndTime::<T>::insert(&end_block, auction_id, ());
AuctionEndTime::<T>::insert(end_block, auction_id, ());
}

Ok(auction_id)
}

fn remove_auction(id: Self::AuctionId) {
if let Some(auction) = Auctions::<T>::take(&id) {
if let Some(auction) = Auctions::<T>::take(id) {
if let Some(end_block) = auction.end {
AuctionEndTime::<T>::remove(end_block, id);
}
Expand Down
10 changes: 5 additions & 5 deletions bencher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ edition = "2021"
[dependencies]
paste = "1.0.7"
build-helper = { version = "0.1.1", optional = true }
cargo_metadata = { version = "0.14.1", optional = true }
cargo_metadata = { version = "0.15.2", optional = true }
tempfile = { version = "3.2.0", optional = true }
toml = { version = "0.5.8", optional = true }
walkdir = { version = "2.3.1", optional = true }
ansi_term = { version = "0.12.1", optional = true }
wasm-gc-api = { version = "0.1.11", optional = true }
rand = {version = "0.8.3", optional = true }
linregress = { version = "0.4.4", optional = true }
parking_lot = { version = "0.12.0", optional = true }
linregress = { version = "0.5.0", optional = true }
parking_lot = { version = "0.12.1", optional = true }
thiserror = { version = "1.0", optional = true }
serde = { version = "1.0.136", optional = true, features = ['derive'] }
serde_json = {version = "1.0.68", optional = true }
Expand All @@ -35,7 +35,7 @@ sc-executor = { git = "https://github.com/paritytech/substrate", default-feature
sc-executor-common = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.36" }
sc-client-db = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["rocksdb"], optional = true , branch = "polkadot-v0.9.36" }
sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.36" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
sp-storage = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.36" }

Expand Down Expand Up @@ -67,7 +67,7 @@ std = [
"sc-executor-common",
"sc-client-db",
"sp-maybe-compressed-blob",
"frame-benchmarking/std",
"frame-support/std",
"sp-externalities/std",
"sp-storage/std",
]
Expand Down
8 changes: 2 additions & 6 deletions bencher/src/bench_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ use super::{
bench_ext::BenchExt,
tracker::{BenchTracker, BenchTrackerExt},
};
use frame_benchmarking::frame_support::sp_runtime::traits::Block;
use frame_support::sp_runtime::traits::Block;
use sc_executor::{WasmExecutionMethod, WasmExecutor, WasmtimeInstantiationStrategy};
use sc_executor_common::runtime_blob::RuntimeBlob;
use sp_externalities::Extensions;
use sp_state_machine::{Ext, OverlayedChanges, StorageTransactionCache};
use sp_std::sync::Arc;

type ComposeHostFunctions = (
sp_io::SubstrateHostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
super::bench::HostFunctions,
);
type ComposeHostFunctions = (sp_io::SubstrateHostFunctions, super::bench::HostFunctions);

/// Run benches
pub fn run<B: Block>(wasm_code: Vec<u8>) -> std::result::Result<Vec<u8>, sc_executor_common::error::Error> {
Expand Down
10 changes: 5 additions & 5 deletions bencher/src/bencher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl Bencher {
pub fn before_run(&self) {
#[cfg(not(feature = "std"))]
{
frame_benchmarking::benchmarking::commit_db();
frame_benchmarking::benchmarking::wipe_db();
crate::bench::commit_db();
crate::bench::wipe_db();
}
}

Expand All @@ -56,8 +56,8 @@ impl Bencher {
{
#[cfg(not(feature = "std"))]
{
frame_benchmarking::benchmarking::commit_db();
frame_benchmarking::benchmarking::reset_read_write_count();
crate::bench::commit_db();
crate::bench::reset_read_write_count();
crate::bench::start_timer();
}

Expand All @@ -68,7 +68,7 @@ impl Bencher {
let elapsed = crate::bench::end_timer().saturating_sub(crate::bench::redundant_time());
self.current.elapses.push(elapsed);

frame_benchmarking::benchmarking::commit_db();
crate::bench::commit_db();

// changed keys
self.current.keys = crate::bench::read_written_keys();
Expand Down
12 changes: 4 additions & 8 deletions bencher/src/build_wasm/prerequisites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ fn get_rustup_nightly(selected: Option<String>) -> Option<CargoCommand> {
let version = match selected {
Some(selected) => selected,
None => {
let output = Command::new("rustup")
.args(&["toolchain", "list"])
.output()
.ok()?
.stdout;
let output = Command::new("rustup").args(["toolchain", "list"]).output().ok()?.stdout;
let lines = output.as_slice().lines();

let mut latest_nightly = None;
Expand Down Expand Up @@ -194,7 +190,7 @@ fn create_check_toolchain_project(project_dir: &Path) {
let manifest_path = project_dir.join("Cargo.toml");

write_file_if_changed(
&manifest_path,
manifest_path,
r#"
[package]
name = "wasm-test"
Expand Down Expand Up @@ -260,7 +256,7 @@ fn check_wasm_toolchain_installed(cargo_command: CargoCommand) -> Result<CargoCo
let manifest_path = temp.path().join("Cargo.toml").display().to_string();

let mut build_cmd = cargo_command.command();
build_cmd.args(&[
build_cmd.args([
"build",
"--target=wasm32-unknown-unknown",
"--manifest-path",
Expand All @@ -272,7 +268,7 @@ fn check_wasm_toolchain_installed(cargo_command: CargoCommand) -> Result<CargoCo
}

let mut run_cmd = cargo_command.command();
run_cmd.args(&["run", "--manifest-path", &manifest_path]);
run_cmd.args(["run", "--manifest-path", &manifest_path]);

build_cmd.output().map_err(|_| err_msg.clone()).and_then(|s| {
if s.status.success() {
Expand Down
2 changes: 1 addition & 1 deletion bencher/src/build_wasm/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ fn build_project(project: &Path, default_rustflags: &str, cargo_cmd: CargoComman
);

build_cmd
.args(&["rustc", "--target=wasm32-unknown-unknown"])
.args(["rustc", "--target=wasm32-unknown-unknown"])
.arg(format!("--manifest-path={}", manifest_path.display()))
.env("RUSTFLAGS", rustflags)
// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock (cargo locks a target dir exclusive).
Expand Down
11 changes: 5 additions & 6 deletions bencher/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
BenchResult,
};
use codec::Decode;
use frame_benchmarking::frame_support::traits::StorageInfo;
use frame_support::traits::StorageInfo;
use linregress::{FormulaRegressionBuilder, RegressionDataBuilder};
use serde::{Deserialize, Serialize};
use sp_core::hexdisplay::HexDisplay;
Expand Down Expand Up @@ -66,14 +66,13 @@ pub fn handle(output: Vec<u8>, storage_infos: Vec<StorageInfo>) {

comments.sort();

let intercepted_value = model.parameters()[0] as u64;

println!(
"{} {:<40} {:>20} storage: {:<20}",
green_bold("Bench"),
cyan(&name),
green_bold(&format!(
"{:?}",
Duration::from_nanos(model.parameters.intercept_value as u64)
)),
green_bold(&format!("{:?}", Duration::from_nanos(intercepted_value))),
green_bold(&format!(
"[r: {}, w: {}]",
&total_reads.to_string(),
Expand All @@ -83,7 +82,7 @@ pub fn handle(output: Vec<u8>, storage_infos: Vec<StorageInfo>) {

BenchData {
name,
weight: model.parameters.intercept_value as u64 * 1_000,
weight: intercepted_value * 1_000,
reads: total_reads,
writes: total_writes,
comments,
Expand Down
2 changes: 1 addition & 1 deletion bencher/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

#[doc(hidden)]
pub extern crate frame_benchmarking;
pub extern crate frame_support;
#[doc(hidden)]
pub extern crate paste;
#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion bencher/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ macro_rules! run_benches {
) => {
#[cfg(all(feature = "std", feature = "bench"))]
pub fn main() -> std::io::Result<()> {
use $crate::frame_benchmarking::frame_support::traits::StorageInfoTrait;
use $crate::frame_support::traits::StorageInfoTrait;
let wasm = $crate::build_wasm::build()?;
let storage_info = $all_pallets_with_system::storage_info();
match $crate::bench_runner::run::<$block>(wasm) {
Expand Down
12 changes: 12 additions & 0 deletions bencher/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ pub trait Bench {
println!("{}", msg);
}

fn commit_db(&mut self) {
self.commit()
}

fn wipe_db(&mut self) {
self.wipe()
}

fn reset_read_write_count(&mut self) {
self.reset_read_write_count()
}

fn start_timer(&mut self) {
let tracker = &***self
.extension::<BenchTrackerExt>()
Expand Down
7 changes: 2 additions & 5 deletions bencher/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ std = [
"serde",
"scale-info/std",
"codec/std",
"orml-bencher/std",
"frame-support/std",
"frame-system/std",
"sp-runtime/std",
"sp-std/std",
"sp-core/std",
"sp-std/std",
"orml-bencher/std",
"orml-weight-meter/std",
]
bench = [
"orml-bencher/bench",
"orml-weight-meter/bench",
"frame-support/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
8 changes: 1 addition & 7 deletions bencher/test/src/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,4 @@ fn whitelist(b: &mut Bencher) {
});
}

benches!(
whitelist,
set_value,
set_foo,
remove_all_bar,
remove_all_bar_with_limit
);
benches!(whitelist, set_value, set_foo, remove_all_bar, remove_all_bar_with_limit);
Loading

0 comments on commit db0381f

Please sign in to comment.