Skip to content

Commit

Permalink
chore: upgrade to 1.14.0 (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter White <petras9789@gmail.com>
Co-authored-by: Daanvdplas <daanvdplas@live.nl>
Co-authored-by: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com>
  • Loading branch information
4 people committed Sep 6, 2024
1 parent e6a66ac commit 7ef0f55
Show file tree
Hide file tree
Showing 23 changed files with 730 additions and 632 deletions.
254 changes: 130 additions & 124 deletions Cargo.toml

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ repository.workspace = true

[dev-dependencies]
codec.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "std", "tracing-log"] }
tracing-subscriber = { workspace = true, features = [
"env-filter",
"fmt",
"std",
"tracing-log",
] }

# Substrate
frame-support.workspace = true
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/src/chains/asset_hub_paseo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub(crate) mod genesis;

use crate::chains::paseo::Paseo;
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain,
Expand Down Expand Up @@ -34,6 +33,6 @@ decl_test_parachains! {
// AssetHubPaseo implementation
impl_accounts_helpers_for_parachain!(AssetHubPaseo);
impl_assert_events_helpers_for_parachain!(AssetHubPaseo);
impl_assets_helpers_for_parachain!(AssetHubPaseo, Paseo);
impl_foreign_assets_helpers_for_parachain!(AssetHubPaseo, Paseo);
impl_assets_helpers_for_parachain!(AssetHubPaseo);
impl_foreign_assets_helpers_for_parachain!(AssetHubPaseo, xcm::v3::Location);
impl_xcm_helpers_for_parachain!(AssetHubPaseo);
14 changes: 7 additions & 7 deletions integration-tests/src/chains/paseo/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use emulated_integration_tests_common::{
accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config,
validators,
accounts, build_genesis_storage, get_from_seed, get_host_config, validators,
};
use paseo_runtime_constants::currency::UNITS as PAS;
use polkadot_primitives::{AssignmentId, Balance, ValidatorId};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, storage::Storage};
use sp_core::storage::Storage;

pub(crate) const ED: Balance = paseo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
const ENDOWMENT: u128 = 1_000_000 * PAS;
Expand Down Expand Up @@ -58,12 +57,13 @@ pub(crate) fn genesis() -> Storage {
},
babe: paseo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(paseo_runtime::BABE_GENESIS_EPOCH_CONFIG),
epoch_config: paseo_runtime::BABE_GENESIS_EPOCH_CONFIG,
..Default::default()
},
sudo: paseo_runtime::SudoConfig {
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
},
// TODO: sudo pallet is not configured in polkadot runtime
// sudo: runtime::SudoConfig {
// key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
// },
configuration: paseo_runtime::ConfigurationConfig { config: get_host_config() },
registrar: paseo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/src/chains/paseo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use emulated_integration_tests_common::{

// Paseo declaration
decl_test_relay_chains! {
#[api_version(10)]
#[api_version(11)]
pub struct Paseo {
genesis = genesis::genesis(),
on_init = (),
Expand All @@ -18,7 +18,8 @@ decl_test_relay_chains! {
},
pallets = {
XcmPallet: paseo_runtime::XcmPallet,
Sudo: paseo_runtime::Sudo,
// TODO: sudo pallet is not configured in polkadot runtime
// Sudo: paseo_runtime::Sudo,
Balances: paseo_runtime::Balances,
Hrmp: paseo_runtime::Hrmp,
}
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/src/chains/pop_network/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub(crate) mod genesis;

use crate::chains::paseo::Paseo;
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain,
Expand Down Expand Up @@ -33,5 +32,5 @@ decl_test_parachains! {
// PopNetwork implementation
impl_accounts_helpers_for_parachain!(PopNetwork);
impl_assert_events_helpers_for_parachain!(PopNetwork);
impl_assets_helpers_for_parachain!(PopNetwork, Paseo);
impl_assets_helpers_for_parachain!(PopNetwork);
impl_xcm_helpers_for_parachain!(PopNetwork);
18 changes: 7 additions & 11 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn para_receiver_assertions<Test>(_: Test) {
assert_expected_events!(
PopNetworkPara,
vec![
RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {},
RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => {},
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
Expand All @@ -113,9 +113,7 @@ fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) {
PopNetworkPara,
vec![
// Amount to reserve transfer is transferred to Parachain's Sovereign account
RuntimeEvent::Balances(
pallet_balances::Event::Withdraw { who, amount }
) => {
RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount }) => {
who: *who == t.sender.account_id,
amount: *amount == t.args.amount,
},
Expand All @@ -133,9 +131,7 @@ fn para_to_relay_sender_assertions(t: ParaToRelayTest) {
PopNetworkPara,
vec![
// Amount to reserve transfer is transferred to Parachain's Sovereign account
RuntimeEvent::Balances(
pallet_balances::Event::Withdraw { who, amount }
) => {
RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount }) => {
who: *who == t.sender.account_id,
amount: *amount == t.args.amount,
},
Expand Down Expand Up @@ -297,7 +293,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
test.assert();

let delivery_fees = PaseoRelay::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<PaseoXcmConfig as xcm_executor::Config>::XcmSender,
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
Expand Down Expand Up @@ -353,7 +349,7 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
let receiver_balance_after = test.receiver.balance;

let delivery_fees = PopNetworkPara::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<PopNetworkXcmConfig as xcm_executor::Config>::XcmSender,
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
Expand Down Expand Up @@ -401,7 +397,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
let receiver_balance_after = test.receiver.balance;

let delivery_fees = AssetHubPaseoPara::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<AssetHubPaseoXcmConfig as xcm_executor::Config>::XcmSender,
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
Expand Down Expand Up @@ -467,7 +463,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let receiver_balance_after = test.receiver.balance;

let delivery_fees = PopNetworkPara::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<PopNetworkXcmConfig as xcm_executor::Config>::XcmSender,
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
Expand Down
4 changes: 2 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pop-node"
version = "0.1.0-alpha"
version = "0.2.0-alpha"
authors.workspace = true
description.workspace = true
license = "Unlicense"
Expand Down Expand Up @@ -28,6 +28,7 @@ pop-runtime-common.workspace = true
frame-benchmarking.workspace = true
frame-benchmarking-cli.workspace = true
pallet-transaction-payment-rpc.workspace = true
prometheus-endpoint.workspace = true
sc-basic-authorship.workspace = true
sc-chain-spec.workspace = true
sc-cli.workspace = true
Expand Down Expand Up @@ -57,7 +58,6 @@ sp-session.workspace = true
sp-timestamp.workspace = true
sp-transaction-pool.workspace = true
substrate-frame-rpc-system.workspace = true
substrate-prometheus-endpoint.workspace = true

# Polkadot
polkadot-cli.workspace = true
Expand Down
9 changes: 4 additions & 5 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};

/// Specialized `ChainSpec` for the development parachain runtime.
pub type DevnetChainSpec =
sc_service::GenericChainSpec<pop_runtime_devnet::RuntimeGenesisConfig, Extensions>;
pub type DevnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Specialized `ChainSpec` for the testnet parachain runtime.
pub type TestnetChainSpec =
sc_service::GenericChainSpec<pop_runtime_testnet::RuntimeGenesisConfig, Extensions>;
pub type TestnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
Expand All @@ -31,11 +29,12 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu

/// The extensions for the [`ChainSpec`].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
#[serde(deny_unknown_fields)]
pub struct Extensions {
/// The relay chain of the Parachain.
#[serde(alias = "relayChain", alias = "RelayChain")]
pub relay_chain: String,
/// The id of the Parachain.
#[serde(alias = "paraId", alias = "ParaId")]
pub para_id: u32,
}

Expand Down
5 changes: 0 additions & 5 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ pub enum Subcommand {
#[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Try-runtime has migrated to a standalone
/// [CLI](<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
TryRuntime,

/// Key management CLI utilities
#[command(subcommand)]
Key(sc_cli::KeySubcommand),
Expand Down
64 changes: 25 additions & 39 deletions node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{net::SocketAddr, path::PathBuf};

use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunctions;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::info;
Expand All @@ -9,13 +10,13 @@ use sc_cli::{
NetworkParams, Result, SharedParams, SubstrateCli,
};
use sc_service::config::{BasePath, PrometheusConfig};
use sp_runtime::traits::AccountIdConversion;
use sp_runtime::traits::HashingFor;

use crate::{
chain_spec,
chain_spec::Relay,
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, DevnetRuntimeExecutor, TestnetRuntimeExecutor},
service::new_partial,
};

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -156,7 +157,7 @@ macro_rules! construct_async_run {
match runner.config().chain_spec.runtime() {
Runtime::Devnet => {
runner.async_run(|$config| {
let $components = new_partial::<pop_runtime_devnet::RuntimeApi, DevnetRuntimeExecutor>(
let $components = new_partial::<pop_runtime_devnet::RuntimeApi>(
&$config
)?;
let task_manager = $components.task_manager;
Expand All @@ -165,7 +166,7 @@ macro_rules! construct_async_run {
}
Runtime::Testnet => {
runner.async_run(|$config| {
let $components = new_partial::<pop_runtime_testnet::RuntimeApi, TestnetRuntimeExecutor>(
let $components = new_partial::<pop_runtime_testnet::RuntimeApi>(
&$config
)?;
let task_manager = $components.task_manager;
Expand All @@ -180,15 +181,11 @@ macro_rules! construct_benchmark_partials {
($config:expr, |$partials:ident| $code:expr) => {
match $config.chain_spec.runtime() {
Runtime::Devnet => {
let $partials =
new_partial::<pop_runtime_devnet::RuntimeApi, DevnetRuntimeExecutor>(&$config)?;
let $partials = new_partial::<pop_runtime_devnet::RuntimeApi>(&$config)?;
$code
},
Runtime::Testnet => {
let $partials = new_partial::<
pop_runtime_testnet::RuntimeApi,
TestnetRuntimeExecutor,
>(&$config)?;
let $partials = new_partial::<pop_runtime_testnet::RuntimeApi>(&$config)?;
$code
},
}
Expand Down Expand Up @@ -251,9 +248,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::ExportGenesisHead(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| {
cmd.run(partials.client)
})
construct_benchmark_partials!(config, |partials| cmd.run(partials.client))
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand All @@ -267,25 +262,28 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(cmd)?;
// Switch on the concrete benchmark sub-command-
match cmd {
BenchmarkCmd::Pallet(cmd) =>
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, ()>(config))
runner.sync_run(|config| {
cmd.run_with_spec::<HashingFor<Block>, ReclaimHostFunctions>(Some(
config.chain_spec,
))
})
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
},
}
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| cmd.run(partials.client))
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) =>
return Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks \
BenchmarkCmd::Storage(_) => Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks \
to enable storage benchmarks."
.into(),
)
.into()),
.into(),
)),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| {
Expand All @@ -294,15 +292,15 @@ pub fn run() -> Result<()> {
cmd.run(config, partials.client.clone(), db, storage)
})
}),
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
BenchmarkCmd::Machine(cmd) => {
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))
},
// NOTE: this allows the Client to leniently implement
// new benchmark commands without requiring a companion MR.
#[allow(unreachable_patterns)]
_ => Err("Benchmarking sub-command unsupported".into()),
}
},
Some(Subcommand::TryRuntime) => Err("The `try-runtime` subcommand has been migrated to a standalone CLI (https://github.com/paritytech/try-runtime-cli). It is no longer being maintained here and will be removed entirely some time after January 2024. Please remove this subcommand from your runtime and use the standalone CLI.".into()),
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
None => {
let runner = cli.create_runner(&cli.run.normalize())?;
Expand All @@ -327,28 +325,19 @@ pub fn run() -> Result<()> {

let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(
&id,
);

let tokio_handle = config.tokio_handle.clone();
let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

info!("Parachain Account: {parachain_account}");
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

match config.chain_spec.runtime() {
Runtime::Devnet => {
sp_core::crypto::set_default_ss58_version(
pop_runtime_devnet::SS58Prefix::get().into(),
);
crate::service::start_parachain_node::<
pop_runtime_devnet::RuntimeApi,
DevnetRuntimeExecutor,
>(
crate::service::start_parachain_node::<pop_runtime_devnet::RuntimeApi>(
config,
polkadot_config,
collator_options,
Expand All @@ -363,10 +352,7 @@ pub fn run() -> Result<()> {
sp_core::crypto::set_default_ss58_version(
pop_runtime_testnet::SS58Prefix::get().into(),
);
crate::service::start_parachain_node::<
pop_runtime_testnet::RuntimeApi,
TestnetRuntimeExecutor,
>(
crate::service::start_parachain_node::<pop_runtime_testnet::RuntimeApi>(
config,
polkadot_config,
collator_options,
Expand Down
Loading

0 comments on commit 7ef0f55

Please sign in to comment.