Skip to content

Commit

Permalink
fix benchmark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Dec 22, 2023
1 parent 2df89f9 commit 478d962
Show file tree
Hide file tree
Showing 22 changed files with 82 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:

- name: check runtime no-std
run: |
cargo +nightly check -p gargantuan-runtime --no-default-features --target=wasm32-unknown-unknown --locked
cargo +nightly check -p gargantua-runtime --no-default-features --target=wasm32-unknown-unknown --locked
cargo +nightly check -p messier-runtime --no-default-features --target=wasm32-unknown-unknown --locked
fmt:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
resolver = "2"
members = [
# runtime
"parachain/runtimes/gargantuan",
"parachain/runtimes/gargantua",
"parachain/runtimes/messier",

# node
Expand Down
2 changes: 1 addition & 1 deletion client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::types::{
ismp_host::PostRequestEventFilter,
runtime::api::{
ismp::Event as Ev,
runtime_types::{frame_system::EventRecord, gargantuan_runtime::RuntimeEvent},
runtime_types::{frame_system::EventRecord, gargantua_runtime::RuntimeEvent},
},
};
use anyhow::anyhow;
Expand Down
78 changes: 39 additions & 39 deletions client/src/types/runtime.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions parachain/chainspec/gargantua.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Hyperbridge (Gargantua)",
"id": "gargantuan",
"id": "gargantua",
"chainType": "Live",
"bootNodes": [
"/ip4/34.78.130.110/tcp/30333/p2p/12D3KooWMRRsnAgJ1hjxCj3uJXPkauHqhP2BbbP4M5XF8xVJpeLX"
],
"telemetryEndpoints": null,
"protocolId": "gargantuan",
"protocolId": "gargantua",
"properties": {
"ss58Format": 42,
"tokenDecimals": 12,
Expand Down
10 changes: 3 additions & 7 deletions parachain/modules/ismp/pallet/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ pub mod benchmarks {

let msg =
RequestMessage { requests: vec![post.clone()], proof: Proof { height, proof: vec![] } };
let caller = whitelisted_caller();

#[extrinsic_call]
handle(RawOrigin::Signed(caller), vec![Message::Request(msg)]);
handle(RawOrigin::None, vec![Message::Request(msg)]);

let commitment = hash_request::<Host<T>>(&Request::Post(post));
assert!(RequestReceipts::<T>::get(commitment).is_some());
Expand Down Expand Up @@ -155,10 +154,8 @@ pub mod benchmarks {
proof: Proof { height, proof: vec![] },
};

let caller = whitelisted_caller();

#[extrinsic_call]
handle(RawOrigin::Signed(caller), vec![Message::Response(msg)]);
handle(RawOrigin::None, vec![Message::Response(msg)]);

assert!(ResponseReceipts::<T>::get(request_commitment).is_some());
}
Expand Down Expand Up @@ -190,10 +187,9 @@ pub mod benchmarks {
requests: vec![request],
timeout_proof: Proof { height, proof: vec![] },
};
let caller = whitelisted_caller();

#[extrinsic_call]
handle(RawOrigin::Signed(caller), vec![Message::Timeout(msg)]);
handle(RawOrigin::None, vec![Message::Timeout(msg)]);

assert!(RequestCommitments::<T>::get(commitment).is_none());
}
Expand Down
10 changes: 5 additions & 5 deletions parachain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ futures = "0.3.28"
serde_json = "1.0.108"

# local
gargantuan-runtime = { path = "../runtimes/gargantuan" }
gargantua-runtime = { path = "../runtimes/gargantua" }
messier-runtime = { path = "../runtimes/messier" }
ismp-rpc = { path = "../modules/ismp/rpc" }
ismp-runtime-api = { path = "../modules/ismp/runtime-api" }
Expand Down Expand Up @@ -91,12 +91,12 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-s
default = []
runtime-benchmarks = [
"try-runtime-cli/try-runtime",
"gargantuan-runtime/runtime-benchmarks",
"gargantua-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
]
try-runtime = [
"try-runtime-cli/try-runtime",
"gargantuan-runtime/try-runtime"
"gargantua-runtime/try-runtime"
]
sepolia = ["gargantuan-runtime/sepolia", "messier-runtime/sepolia"]
mainnet = ["gargantuan-runtime/mainnet", "messier-runtime/mainnet"]
sepolia = ["gargantua-runtime/sepolia", "messier-runtime/sepolia"]
mainnet = ["gargantua-runtime/mainnet", "messier-runtime/mainnet"]
69 changes: 8 additions & 61 deletions parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.

use cumulus_primitives_core::ParaId;
use gargantuan_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use gargantua_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
Expand All @@ -23,7 +23,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec =
sc_service::GenericChainSpec<gargantuan_runtime::RuntimeGenesisConfig, Extensions>;
sc_service::GenericChainSpec<gargantua_runtime::RuntimeGenesisConfig, Extensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = staging_xcm::prelude::XCM_VERSION;
Expand Down Expand Up @@ -72,26 +72,26 @@ where
/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn session_keys(keys: AuraId) -> gargantuan_runtime::SessionKeys {
gargantuan_runtime::SessionKeys { aura: keys }
pub fn session_keys(keys: AuraId) -> gargantua_runtime::SessionKeys {
gargantua_runtime::SessionKeys { aura: keys }
}

pub fn gargantuan_development_config(id: u32) -> ChainSpec {
pub fn gargantua_development_config(id: u32) -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "DEV".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());

ChainSpec::builder(
gargantuan_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
gargantua_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
para_id: id,
},
)
.with_name("Development")
.with_name("hyperbridge-dev")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis(
Expand Down Expand Up @@ -141,7 +141,7 @@ pub fn messier_development_config(id: u32) -> ChainSpec {
para_id: id,
},
)
.with_name("Development")
.with_name("hyperbridge-dev")
.with_id("messier")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis(
Expand Down Expand Up @@ -176,59 +176,6 @@ pub fn messier_development_config(id: u32) -> ChainSpec {
.build()
}

pub fn local_testnet_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "HYPER".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());

#[allow(deprecated)]
ChainSpec::builder(
gargantuan_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
para_id: 2000,
},
)
.with_name("Local Testnet")
.with_id("local_testnet")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(testnet_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob"),
),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
2000.into(),
))
.with_protocol_id("template-local")
.with_properties(properties)
.build()
}

fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
Expand Down
25 changes: 12 additions & 13 deletions parachain/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::str::FromStr;

use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use gargantuan_runtime::Block;
use gargantua_runtime::Block;
use log::info;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
Expand All @@ -35,20 +35,19 @@ use crate::{

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
name if name.starts_with("gargantuan-") => {
name if name.starts_with("gargantua-") => {
let id = name.split('-').last().expect("dev chainspec should have chain id");
let id = u32::from_str(id).expect("can't parse Id into u32");
Box::new(chain_spec::gargantuan_development_config(id))
Box::new(chain_spec::gargantua_development_config(id))
},
name if name.starts_with("messier-") => {
let id = name.split('-').last().expect("dev chainspec should have chain id");
let id = u32::from_str(id).expect("can't parse Id into u32");
Box::new(chain_spec::messier_development_config(id))
},
"gargantua" | "gargantuan" => Box::new(chain_spec::ChainSpec::from_json_bytes(
name if name.contains("gargantua") => Box::new(chain_spec::ChainSpec::from_json_bytes(
include_bytes!("../../chainspec/gargantua.json").to_vec(),
)?),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
Expand Down Expand Up @@ -129,9 +128,9 @@ macro_rules! construct_async_run {
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
let runner = $cli.create_runner($cmd)?;
match runner.config().chain_spec.id() {
chain if chain.contains("gargantuan") || chain.contains("dev") => {
chain if chain.contains("gargantua") || chain.contains("dev") => {
runner.async_run(|$config| {
let $components = new_partial::<gargantuan_runtime::RuntimeApi, GargantuanExecutor>(&$config)?;
let $components = new_partial::<gargantua_runtime::RuntimeApi, GargantuanExecutor>(&$config)?;
Ok::<_, sc_cli::Error>(( { $( $code )* }, $components.task_manager))
})
}
Expand Down Expand Up @@ -202,9 +201,9 @@ pub fn run() -> Result<()> {
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| match config.chain_spec.id() {
chain if chain.contains("gargantuan") || chain.contains("dev") => {
chain if chain.contains("gargantua") || chain.contains("dev") => {
let components =
new_partial::<gargantuan_runtime::RuntimeApi, GargantuanExecutor>(&config)?;
new_partial::<gargantua_runtime::RuntimeApi, GargantuanExecutor>(&config)?;
cmd.run(&*config.chain_spec, &*components.client)
},
chain if chain.contains("messier") => {
Expand Down Expand Up @@ -236,9 +235,9 @@ pub fn run() -> Result<()> {
},
BenchmarkCmd::Block(cmd) =>
runner.sync_run(|config| match config.chain_spec.id() {
chain if chain.contains("gargantuan") || chain.contains("dev") => {
chain if chain.contains("gargantua") || chain.contains("dev") => {
let components = new_partial::<
gargantuan_runtime::RuntimeApi,
gargantua_runtime::RuntimeApi,
GargantuanExecutor,
>(&config)?;
cmd.run(components.client)
Expand All @@ -263,9 +262,9 @@ pub fn run() -> Result<()> {
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) =>
runner.sync_run(|config| match config.chain_spec.id() {
chain if chain.contains("gargantuan") || chain.contains("dev") => {
chain if chain.contains("gargantua") || chain.contains("dev") => {
let components = new_partial::<
gargantuan_runtime::RuntimeApi,
gargantua_runtime::RuntimeApi,
GargantuanExecutor,
>(&config)?;
let db = components.backend.expose_db();
Expand Down
2 changes: 1 addition & 1 deletion parachain/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::sync::Arc;

use gargantuan_runtime::{opaque::Block, AccountId, Balance, Index as Nonce};
use gargantua_runtime::{opaque::Block, AccountId, Balance, Index as Nonce};

use crate::runtime_api::opaque;
use sc_client_api::{AuxStore, BlockBackend, ProofProvider};
Expand Down
8 changes: 4 additions & 4 deletions parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ impl sc_executor::NativeExecutionDispatch for GargantuanExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
gargantuan_runtime::api::dispatch(method, data)
gargantua_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
gargantuan_runtime::native_version()
gargantua_runtime::native_version()
}
}

Expand Down Expand Up @@ -505,8 +505,8 @@ pub async fn start_parachain_node(
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<TaskManager> {
match parachain_config.chain_spec.id() {
chain if chain.contains("gargantuan") =>
start_node_impl::<gargantuan_runtime::RuntimeApi, GargantuanExecutor>(
chain if chain.contains("gargantua") =>
start_node_impl::<gargantua_runtime::RuntimeApi, GargantuanExecutor>(
parachain_config,
polkadot_config,
collator_options,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "gargantuan-runtime"
name = "gargantua-runtime"
version = "0.1.0"
authors = ["Polytope Labs <hello@polytope.technology>"]
description = "Parachain runtime implementation of the hyperbridge protocol"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("gargantuan"),
impl_name: create_runtime_str!("gargantuan"),
spec_name: create_runtime_str!("gargantua"),
impl_name: create_runtime_str!("gargantua"),
authoring_version: 1,
spec_version: 111,
impl_version: 0,
Expand Down
File renamed without changes.

0 comments on commit 478d962

Please sign in to comment.