Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.
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
201 changes: 97 additions & 104 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[workspace]
members = [
"node",
"runtime/stout",
"runtime/trappist",
"primitives/xcm",
"node",
"runtime/stout",
"runtime/trappist",
"primitives/xcm",
]
exclude = [
"contracts",
"xcm-simulator"
"contracts",
"xcm-simulator"
]

[profile.release]
Expand All @@ -32,15 +32,15 @@ license = "Apache License v2"
async-trait = "0.1.57"
clap = { version = "4.0.32" }
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
futures = { version = "0.3.25"}
hex-literal = { version = "0.3.4"}
log = { version = "0.4.17"}
futures = { version = "0.3.25" }
hex-literal = { version = "0.3.4" }
log = { version = "0.4.17" }
serde = { version = "1.0.152" }
scale-info = { version = "2.3.1", default-features = false, features = ["derive"] }
smallvec = "1.9.0"

# Local dependencies
trappist-runtime = { path = "runtime/trappist"}
trappist-runtime = { path = "runtime/trappist" }
stout-runtime = { path = "runtime/stout" }
jsonrpsee = { version = "0.16.2" }

Expand All @@ -57,7 +57,7 @@ pallet-lockdown-mode = { version = "0.1.0", default-features = false, path = "pa

# Substrate std
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37"}
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
Expand All @@ -76,9 +76,10 @@ sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkad
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37"}
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37"}
substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }

# Substrate non-std
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
Expand All @@ -97,6 +98,7 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", bra

# Substrate Runtime
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" }
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" }
Expand Down Expand Up @@ -138,7 +140,7 @@ pallet-utility = { git = "https://github.com/paritytech/substrate", default-feat
pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" }

# Cumulus client dependencies
cumulus-client-cli ={ git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
Expand Down
36 changes: 20 additions & 16 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ path = "src/main.rs"
[dependencies]
async-trait = { workspace = true }
clap = { workspace = true }
parity-scale-codec = { workspace = true }
parity-scale-codec = { workspace = true }
futures = { workspace = true }
hex-literal = { workspace = true }
log = { workspace = true }
Expand All @@ -34,57 +34,61 @@ jsonrpsee = { workspace = true, features = ["server"] }
pallet-dex-rpc = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, features = [ "std" ] }
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true }
sp-runtime = { workspace = true }
sp-io = { workspace = true, features = [ "std" ] }
sp-core = { workspace = true, features = [ "std" ] }
sp-io = { workspace = true, features = ["std"] }
sp-core = { workspace = true, features = ["std"] }
sp-consensus = { workspace = true }
sp-session = { workspace = true, features = [ "std" ] }
sp-session = { workspace = true, features = ["std"] }
sc-consensus = { workspace = true }
sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-executor = { workspace = true }
sc-service = { workspace = true }
sc-telemetry = { workspace = true }
sc-transaction-pool = { workspace = true }
sp-transaction-pool = { workspace = true, features = [ "std" ] }
sp-transaction-pool = { workspace = true, features = ["std"] }
sc-network = { workspace = true }
sc-network-common = { workspace = true }
sc-basic-authorship = { workspace = true }
sp-timestamp = { workspace = true, features = [ "std" ] }
sp-timestamp = { workspace = true, features = ["std"] }
sp-inherents = { workspace = true }
sp-blockchain = { workspace = true }
sp-block-builder = { workspace = true, features = [ "std" ] }
sp-keystore = { workspace = true, features = [ "std" ] }
sp-block-builder = { workspace = true, features = ["std"] }
sp-keyring = { workspace = true }
sp-keystore = { workspace = true, features = ["std"] }
sc-chain-spec = { workspace = true }
sc-rpc = { workspace = true }
sc-tracing = { workspace = true }
sp-offchain = { workspace = true, features = [ "std" ] }
sp-api = { workspace = true, features = [ "std" ] }
sp-consensus-aura = { workspace = true, features = [ "std" ] }
sp-offchain = { workspace = true, features = ["std"] }
sp-api = { workspace = true, features = ["std"] }
sp-consensus-aura = { workspace = true, features = ["std"] }
sc-sysinfo = { workspace = true }
sp-serializer = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }
try-runtime-cli = { workspace = true, optional = true }
sc-transaction-pool-api = { workspace = true }
frame-system = { workspace = true }
frame-rpc-system = { workspace = true }
pallet-asset-tx-payment = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
substrate-state-trie-migration-rpc = { workspace = true }

# Polkadot
polkadot-cli = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-service = { workspace = true }
xcm = { workspace = true, features = [ "std" ] }
xcm = { workspace = true, features = ["std"] }

# Cumulus
cumulus-client-cli ={ workspace = true }
cumulus-client-cli = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-relay-chain = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-client-network = { workspace = true }
cumulus-primitives-core = { workspace = true, features = [ "std" ] }
cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }

Expand All @@ -105,7 +109,7 @@ polkadot-cli = { workspace = true }
[features]
default = []
runtime-benchmarks = [
"trappist-runtime/runtime-benchmarks",
"trappist-runtime/runtime-benchmarks",
"stout-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks"
]
Expand Down
176 changes: 176 additions & 0 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
use std::{sync::Arc, time::Duration};

use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider;
use parity_scale_codec::Encode;
use sc_client_api::BlockBackend;
use sp_core::Pair;
use sp_inherents::{InherentData, InherentDataProvider};
use sp_keyring::Sr25519Keyring;
use sp_runtime::{generic, OpaqueExtrinsic, SaturatedConversion};

use crate::service::ParachainClient;

/// Generates `System::Remark` extrinsics for the benchmarks.
///
/// Note: Should only be used for benchmarking.
pub struct RemarkBuilder<RuntimeApi> {
client: Arc<ParachainClient<RuntimeApi>>,
}

impl<RuntimeApi> RemarkBuilder<RuntimeApi> {
/// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<ParachainClient<RuntimeApi>>) -> Self {
Self { client }
}
}

impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder<trappist_runtime::RuntimeApi> {
fn pallet(&self) -> &str {
"system"
}

fn extrinsic(&self) -> &str {
"remark"
}

fn build(&self, nonce: u32) -> Result<OpaqueExtrinsic, &'static str> {
use trappist_runtime as runtime;

let call: runtime::RuntimeCall = runtime::SystemCall::remark { remark: vec![] }.into();
let period = runtime::BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let best_block = self.client.chain_info().best_number;
let tip = 0;
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(generic::Era::mortal(
period,
best_block.saturated_into(),
)),
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_asset_tx_payment::ChargeAssetTxPayment::<runtime::Runtime>::from(tip, None),
);

let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists");
let best_hash = self.client.chain_info().best_hash;
let payload = runtime::SignedPayload::from_raw(
call.clone(),
extra.clone(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
genesis_hash,
best_hash,
(),
(),
(),
),
);

let sender = Sr25519Keyring::Bob.pair();
let signature = payload.using_encoded(|x| sender.sign(x));
let extrinsic = runtime::UncheckedExtrinsic::new_signed(
call,
sp_runtime::AccountId32::from(sender.public()).into(),
runtime::Signature::Sr25519(signature),
extra,
);

Ok(extrinsic.into())
}
}

impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder<stout_runtime::RuntimeApi> {
fn pallet(&self) -> &str {
"system"
}

fn extrinsic(&self) -> &str {
"remark"
}

fn build(&self, nonce: u32) -> Result<OpaqueExtrinsic, &'static str> {
use stout_runtime as runtime;

let call: runtime::RuntimeCall = runtime::SystemCall::remark { remark: vec![] }.into();
let period = runtime::BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let best_block = self.client.chain_info().best_number;
let tip = 0;
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(generic::Era::mortal(
period,
best_block.saturated_into(),
)),
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_asset_tx_payment::ChargeAssetTxPayment::<runtime::Runtime>::from(tip, None),
);

let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists");
let best_hash = self.client.chain_info().best_hash;
let payload = runtime::SignedPayload::from_raw(
call.clone(),
extra.clone(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
genesis_hash,
best_hash,
(),
(),
(),
),
);

let sender = Sr25519Keyring::Bob.pair();
let signature = payload.using_encoded(|x| sender.sign(x));
let extrinsic = runtime::UncheckedExtrinsic::new_signed(
call,
sp_runtime::AccountId32::from(sender.public()).into(),
runtime::Signature::Sr25519(signature),
extra,
);

Ok(extrinsic.into())
}
}

/// Generates inherent data for the `benchmark overhead` command.
pub fn inherent_benchmark_data() -> sc_cli::Result<InherentData> {
let mut inherent_data = InherentData::new();

let timestamp = sp_timestamp::InherentDataProvider::new(Duration::ZERO.into());
futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data))
.map_err(|e| format!("creating inherent data: {e:?}"))?;

let parachain_inherent = MockValidationDataInherentDataProvider {
current_para_block: 1,
relay_offset: 0,
relay_blocks_per_para_block: 1,
para_blocks_per_relay_epoch: 0,
relay_randomness_config: (),
xcm_config: Default::default(),
raw_downward_messages: Default::default(),
raw_horizontal_messages: Default::default(),
};

futures::executor::block_on(parachain_inherent.provide_inherent_data(&mut inherent_data))
.map_err(|e| format!("creating inherent data: {e:?}"))?;

Ok(inherent_data)
}
Loading