Skip to content

Commit

Permalink
feat: update to polkadot v1.1.0 release (#1182)
Browse files Browse the repository at this point in the history
* feat: update all deps to polkadot v1.1.0

* feat(assets-erc20): update imports for `frame_support`

* feat(xc-asset-config): update imports for `frame_support`

* feat(primitives): replace xcm `Convert` with `sp_runtime`'s `MaybeEquivalence`

* feat: update all pallets for polkadot v1.1.0

* feat: update chain extensions

* feat: update all precompiles

* wip: local runtime

* feat: update shibuya runtmie

* feat: fix local runtime

* feat: fix holds

* feat: update astar and shiden runtime

* feat: fix all tests

* feat: build works execpt tracing

* feat: evm tracing build works

* feat: bump spec versions

* feat: streamline genesis state export

* fix: max hold in local runtime

* fix: aura issue in eth pending api

* feat: review comments

* feat: copy `AllowTopLevelPaidExecutionFrom` barrier into primititves

* fix: build error

* fix: make taplo happy

* fix: review comments

* fix: add contract migration back into shiden

* feat: remove `BlockNumberFor` clauses

* fix: format

* fix: make clippy happy

* feat: update `CodeHashLockupDepositPercent` value
  • Loading branch information
ashutoshvarma authored Mar 2, 2024
1 parent 27b45e9 commit d742022
Show file tree
Hide file tree
Showing 115 changed files with 3,597 additions and 2,607 deletions.
3,536 changes: 2,277 additions & 1,259 deletions Cargo.lock

Large diffs are not rendered by default.

293 changes: 145 additions & 148 deletions Cargo.toml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fp-rpc = { workspace = true, features = ["std"] }
pallet-ethereum = { workspace = true, features = ["std"] }
pallet-evm = { workspace = true, features = ["std"] }

fc-api = { workspace = true }
fc-consensus = { workspace = true }
fc-db = { workspace = true }
fc-mapping-sync = { workspace = true }
Expand Down Expand Up @@ -105,20 +106,19 @@ substrate-frame-rpc-system = { workspace = true }
sc-cli = { workspace = true, optional = true }

# cumulus dependencies
cumulus-primitives-core = { workspace = true, features = ["std"] }

cumulus-client-cli = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-relay-chain = { workspace = true }
cumulus-client-network = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-inprocess-interface = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
cumulus-relay-chain-minimal-node = { workspace = true }
cumulus-relay-chain-rpc-interface = { workspace = true }
cumulus-test-relay-sproof-builder = { workspace = true, optional = true }
cumulus-test-relay-sproof-builder = { workspace = true }

# polkadot dependencies
polkadot-cli = { workspace = true, optional = true }
Expand Down Expand Up @@ -157,10 +157,10 @@ runtime-benchmarks = [
"local-runtime/runtime-benchmarks",
"shibuya-runtime/runtime-benchmarks",
"shiden-runtime/runtime-benchmarks",
"astar-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-runtime-common/std",
"sp-keyring",
"cumulus-test-relay-sproof-builder",
"polkadot-runtime-common",
"astar-primitives/runtime-benchmarks",
]
Expand Down
4 changes: 2 additions & 2 deletions bin/collator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ pub enum Subcommand {
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Try some command against runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),
/// No moved to separte cli and just a placeholder command here
TryRuntime,
}

#[derive(Debug)]
Expand Down
129 changes: 31 additions & 98 deletions bin/collator/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ use sc_service::{
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::AccountIdConversion;
use sp_runtime::traits::Block as BlockT;
use std::net::SocketAddr;
use std::{io::Write, net::SocketAddr};

#[cfg(feature = "frame-benchmarking-cli")]
#[cfg(feature = "runtime-benchmarks")]
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};

trait IdentifyChain {
Expand Down Expand Up @@ -147,8 +147,10 @@ impl SubstrateCli for Cli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id)
}
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
impl Cli {
fn runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
if chain_spec.is_dev() {
&local_runtime::VERSION
} else if chain_spec.is_astar() {
Expand Down Expand Up @@ -202,10 +204,6 @@ impl SubstrateCli for RelayChainCli {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
}
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
polkadot_cli::Cli::native_runtime_version(chain_spec)
}
}

/// Parse command line arguments into service configuration.
Expand Down Expand Up @@ -458,13 +456,22 @@ pub fn run() -> Result<()> {
}
}
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::runtime_version(&spec).state_version();

runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::native_runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, state_version)
})
let block: Block = generate_genesis_block(&*spec, state_version)?;
let raw_header = block.header().encode();
let output_buf = if cmd.raw {
raw_header
} else {
format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()
};
if let Some(output) = &cmd.output {
std::fs::write(output, output_buf)?;
} else {
std::io::stdout().write_all(&output_buf)?;
}
Ok(())
}
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
Expand All @@ -478,7 +485,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::Sign(cmd)) => cmd.run(),
Some(Subcommand::Verify(cmd)) => cmd.run(),
Some(Subcommand::Vanity(cmd)) => cmd.run(),
#[cfg(feature = "frame-benchmarking-cli")]
#[cfg(feature = "runtime-benchmarks")]
Some(Subcommand::Benchmark(cmd)) => {
use crate::benchmarking::*;
use sp_keyring::Sr25519Keyring;
Expand All @@ -490,18 +497,18 @@ pub fn run() -> Result<()> {
BenchmarkCmd::Pallet(cmd) => {
if chain_spec.is_astar() {
runner.sync_run(|config| {
cmd.run::<astar_runtime::Block, astar::Executor>(config)
cmd.run::<astar_runtime::Block, parachain::HostFunctions>(config)
})
} else if chain_spec.is_shiden() {
runner.sync_run(|config| {
cmd.run::<shiden_runtime::Block, shiden::Executor>(config)
cmd.run::<shiden_runtime::Block, parachain::HostFunctions>(config)
})
} else if chain_spec.is_shibuya() {
runner.sync_run(|config| {
cmd.run::<shibuya_runtime::Block, shibuya::Executor>(config)
cmd.run::<shibuya_runtime::Block, parachain::HostFunctions>(config)
})
} else {
runner.sync_run(|config| cmd.run::<Block, local::Executor>(config))
runner.sync_run(|config| cmd.run::<Block, local::HostFunctions>(config))
}
}
BenchmarkCmd::Block(cmd) => {
Expand Down Expand Up @@ -763,85 +770,11 @@ pub fn run() -> Result<()> {
}
}
}
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;

use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
type HostFunctionsOf<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::ExtendHostFunctions,
>;

if chain_spec.is_shiden() {
runner.async_run(|config| {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let info_provider =
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| {
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
})?;
Ok((
cmd.run::<shiden_runtime::Block, HostFunctionsOf<shiden::Executor>, _>(
Some(info_provider),
),
task_manager,
))
})
} else if chain_spec.is_shibuya() {
runner.async_run(|config| {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let info_provider =
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| {
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
})?;
Ok((
cmd.run::<shibuya_runtime::Block, HostFunctionsOf<shibuya::Executor>, _>(
Some(info_provider),
),
task_manager,
))
})
} else if chain_spec.is_astar() {
runner.async_run(|config| {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let info_provider =
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| {
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
})?;
Ok((
cmd.run::<astar_runtime::Block, HostFunctionsOf<astar::Executor>, _>(Some(
info_provider,
)),
task_manager,
))
})
} else {
runner.async_run(|config| {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let info_provider =
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| {
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
})?;
Ok((
cmd.run::<Block, HostFunctionsOf<local::Executor>, _>(Some(info_provider)),
task_manager,
))
})
}
}
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()),
None => {
let runner = cli.create_runner(&cli.run.normalize())?;
let collator_options = cli.run.collator_options();
Expand Down Expand Up @@ -885,7 +818,7 @@ pub fn run() -> Result<()> {
let parachain_account =
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&para_id);

let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
let state_version = Cli::runtime_version(&config.chain_spec).state_version();
let block: Block = generate_genesis_block(&*config.chain_spec, state_version)
.map_err(|e| format!("{:?}", e))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
Expand Down
20 changes: 13 additions & 7 deletions bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
use local_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BlockRewardConfig,
CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GenesisConfig, GrandpaConfig,
GrandpaId, InflationConfig, InflationParameters, Precompiles, RewardDistributionConfig,
Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TierThreshold, TreasuryConfig,
VestingConfig, AST,
CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GrandpaConfig, GrandpaId,
InflationConfig, InflationParameters, Precompiles, RewardDistributionConfig,
RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
TierThreshold, TreasuryConfig, VestingConfig, AST,
};
use sc_service::ChainType;
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
Expand All @@ -35,7 +35,7 @@ use sp_runtime::{
type AccountPublic = <Signature as Verify>::Signer;

/// Specialized `ChainSpec` for Shiden Network.
pub type ChainSpec = sc_service::GenericChainSpec<local_runtime::GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<local_runtime::RuntimeGenesisConfig>;

/// Helper function to generate a crypto pair from seed
fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -99,15 +99,16 @@ fn testnet_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
) -> GenesisConfig {
) -> RuntimeGenesisConfig {
// This is supposed the be the simplest bytecode to revert without returning any data.
// We will pre-deploy it under all of our precompiles to ensure they can be called from
// within contracts.
// (PUSH1 0x00 PUSH1 0x00 REVERT)
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];
GenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
..Default::default()
},
balances: BalancesConfig {
balances: endowed_accounts
Expand All @@ -126,6 +127,7 @@ fn testnet_genesis(
adjustable_percent: Perbill::from_percent(25),
ideal_dapps_staking_tvl: Perbill::from_percent(40),
},
..Default::default()
},
vesting: VestingConfig { vesting: vec![] },
aura: AuraConfig {
Expand All @@ -136,6 +138,7 @@ fn testnet_genesis(
.iter()
.map(|x| (x.1.clone(), 1))
.collect(),
..Default::default()
},
evm: EVMConfig {
// We need _some_ code inserted at the precompile address so that
Expand All @@ -153,6 +156,7 @@ fn testnet_genesis(
)
})
.collect(),
..Default::default()
},
ethereum: Default::default(),
sudo: SudoConfig {
Expand Down Expand Up @@ -207,9 +211,11 @@ fn testnet_genesis(
TierThreshold::FixedTvlAmount { amount: 10 * AST },
],
slots_per_tier: vec![10, 20, 30, 40],
..Default::default()
},
inflation: InflationConfig {
params: InflationParameters::default(),
..Default::default()
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion bin/collator/src/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ mod service;
mod chain_spec;

pub use chain_spec::*;
pub use service::{new_partial, start_node, Executor, RuntimeApi};
pub use service::{new_partial, start_node, Executor, HostFunctions, RuntimeApi};
Loading

0 comments on commit d742022

Please sign in to comment.