Skip to content

Commit 96c1404

Browse files
committed
feat: build works execpt tracing
1 parent 0452862 commit 96c1404

File tree

26 files changed

+301
-245
lines changed

26 files changed

+301
-245
lines changed

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ fp-ethereum = { git = "https://github.com/AstarNetwork/frontier", branch = "polk
206206
# (native)
207207
fc-consensus = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }
208208
fc-db = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }
209+
fc-api = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }
209210
fc-mapping-sync = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }
210-
fc-rpc = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", features = ["rpc-binary-search-estimate"] }
211+
fc-rpc = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", features = ["rpc-binary-search-estimate", "txpool"] }
211212
fc-rpc-core = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }
212213
fp-consensus = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }
213214
fp-storage = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" }

bin/collator/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fp-rpc = { workspace = true, features = ["std"] }
7676
pallet-ethereum = { workspace = true, features = ["std"] }
7777
pallet-evm = { workspace = true, features = ["std"] }
7878

79+
fc-api = { workspace = true }
7980
fc-consensus = { workspace = true }
8081
fc-db = { workspace = true }
8182
fc-mapping-sync = { workspace = true }
@@ -105,20 +106,19 @@ substrate-frame-rpc-system = { workspace = true }
105106
sc-cli = { workspace = true, optional = true }
106107

107108
# cumulus dependencies
108-
cumulus-primitives-core = { workspace = true, features = ["std"] }
109-
110109
cumulus-client-cli = { workspace = true }
111110
cumulus-client-consensus-aura = { workspace = true }
112111
cumulus-client-consensus-common = { workspace = true }
113112
cumulus-client-consensus-relay-chain = { workspace = true }
114113
cumulus-client-network = { workspace = true }
115114
cumulus-client-service = { workspace = true }
115+
cumulus-primitives-core = { workspace = true, features = ["std"] }
116116
cumulus-primitives-parachain-inherent = { workspace = true }
117117
cumulus-relay-chain-inprocess-interface = { workspace = true }
118118
cumulus-relay-chain-interface = { workspace = true }
119119
cumulus-relay-chain-minimal-node = { workspace = true }
120120
cumulus-relay-chain-rpc-interface = { workspace = true }
121-
cumulus-test-relay-sproof-builder = { workspace = true, optional = true }
121+
cumulus-test-relay-sproof-builder = { workspace = true }
122122

123123
# polkadot dependencies
124124
polkadot-cli = { workspace = true, optional = true }
@@ -157,10 +157,10 @@ runtime-benchmarks = [
157157
"local-runtime/runtime-benchmarks",
158158
"shibuya-runtime/runtime-benchmarks",
159159
"shiden-runtime/runtime-benchmarks",
160+
"astar-runtime/runtime-benchmarks",
160161
"polkadot-cli/runtime-benchmarks",
161162
"polkadot-runtime-common/std",
162163
"sp-keyring",
163-
"cumulus-test-relay-sproof-builder",
164164
"polkadot-runtime-common",
165165
"astar-primitives/runtime-benchmarks",
166166
]

bin/collator/src/command.rs

+45-95
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use sp_runtime::traits::AccountIdConversion;
4343
use sp_runtime::traits::Block as BlockT;
4444
use std::net::SocketAddr;
4545

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

4949
trait IdentifyChain {
@@ -147,8 +147,10 @@ impl SubstrateCli for Cli {
147147
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
148148
load_spec(id)
149149
}
150+
}
150151

151-
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
152+
impl Cli {
153+
fn runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
152154
if chain_spec.is_dev() {
153155
&local_runtime::VERSION
154156
} else if chain_spec.is_astar() {
@@ -202,10 +204,6 @@ impl SubstrateCli for RelayChainCli {
202204
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
203205
}
204206
}
205-
206-
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
207-
polkadot_cli::Cli::native_runtime_version(chain_spec)
208-
}
209207
}
210208

211209
/// Parse command line arguments into service configuration.
@@ -459,12 +457,36 @@ pub fn run() -> Result<()> {
459457
}
460458
Some(Subcommand::ExportGenesisState(cmd)) => {
461459
let runner = cli.create_runner(cmd)?;
460+
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
462461

463-
runner.sync_run(|_config| {
464-
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
465-
let state_version = Cli::native_runtime_version(&spec).state_version();
466-
cmd.run::<Block>(&*spec, state_version)
467-
})
462+
if runner.config().chain_spec.is_astar() {
463+
runner.sync_run(|config| {
464+
let PartialComponents { client, .. } =
465+
parachain::new_partial::<astar::RuntimeApi, astar::Executor, _>(
466+
&config,
467+
parachain::build_import_queue,
468+
)?;
469+
cmd.run::<Block>(&*spec, &*client)
470+
})
471+
} else if runner.config().chain_spec.is_shiden() {
472+
runner.sync_run(|config| {
473+
let PartialComponents { client, .. } =
474+
parachain::new_partial::<shiden::RuntimeApi, shiden::Executor, _>(
475+
&config,
476+
parachain::build_import_queue,
477+
)?;
478+
cmd.run::<Block>(&*spec, &*client)
479+
})
480+
} else {
481+
runner.sync_run(|config| {
482+
let PartialComponents { client, .. } =
483+
parachain::new_partial::<shibuya::RuntimeApi, shibuya::Executor, _>(
484+
&config,
485+
parachain::build_import_queue,
486+
)?;
487+
cmd.run::<Block>(&*spec, &*client)
488+
})
489+
}
468490
}
469491
Some(Subcommand::ExportGenesisWasm(cmd)) => {
470492
let runner = cli.create_runner(cmd)?;
@@ -478,7 +500,7 @@ pub fn run() -> Result<()> {
478500
Some(Subcommand::Sign(cmd)) => cmd.run(),
479501
Some(Subcommand::Verify(cmd)) => cmd.run(),
480502
Some(Subcommand::Vanity(cmd)) => cmd.run(),
481-
#[cfg(feature = "frame-benchmarking-cli")]
503+
#[cfg(feature = "runtime-benchmarks")]
482504
Some(Subcommand::Benchmark(cmd)) => {
483505
use crate::benchmarking::*;
484506
use sp_keyring::Sr25519Keyring;
@@ -490,18 +512,18 @@ pub fn run() -> Result<()> {
490512
BenchmarkCmd::Pallet(cmd) => {
491513
if chain_spec.is_astar() {
492514
runner.sync_run(|config| {
493-
cmd.run::<astar_runtime::Block, astar::Executor>(config)
515+
cmd.run::<astar_runtime::Block, parachain::HostFunctions>(config)
494516
})
495517
} else if chain_spec.is_shiden() {
496518
runner.sync_run(|config| {
497-
cmd.run::<shiden_runtime::Block, shiden::Executor>(config)
519+
cmd.run::<shiden_runtime::Block, parachain::HostFunctions>(config)
498520
})
499521
} else if chain_spec.is_shibuya() {
500522
runner.sync_run(|config| {
501-
cmd.run::<shibuya_runtime::Block, shibuya::Executor>(config)
523+
cmd.run::<shibuya_runtime::Block, parachain::HostFunctions>(config)
502524
})
503525
} else {
504-
runner.sync_run(|config| cmd.run::<Block, local::Executor>(config))
526+
runner.sync_run(|config| cmd.run::<Block, local::HostFunctions>(config))
505527
}
506528
}
507529
BenchmarkCmd::Block(cmd) => {
@@ -763,84 +785,12 @@ pub fn run() -> Result<()> {
763785
}
764786
}
765787
}
766-
#[cfg(feature = "try-runtime")]
767-
Some(Subcommand::TryRuntime(cmd)) => {
768-
let runner = cli.create_runner(cmd)?;
769-
let chain_spec = &runner.config().chain_spec;
770-
771-
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
772-
type HostFunctionsOf<E> = ExtendedHostFunctions<
773-
sp_io::SubstrateHostFunctions,
774-
<E as NativeExecutionDispatch>::ExtendHostFunctions,
775-
>;
776-
777-
if chain_spec.is_shiden() {
778-
runner.async_run(|config| {
779-
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
780-
let info_provider =
781-
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
782-
let task_manager =
783-
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
784-
.map_err(|e| {
785-
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
786-
})?;
787-
Ok((
788-
cmd.run::<shiden_runtime::Block, HostFunctionsOf<shiden::Executor>, _>(
789-
Some(info_provider),
790-
),
791-
task_manager,
792-
))
793-
})
794-
} else if chain_spec.is_shibuya() {
795-
runner.async_run(|config| {
796-
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
797-
let info_provider =
798-
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
799-
let task_manager =
800-
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
801-
.map_err(|e| {
802-
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
803-
})?;
804-
Ok((
805-
cmd.run::<shibuya_runtime::Block, HostFunctionsOf<shibuya::Executor>, _>(
806-
Some(info_provider),
807-
),
808-
task_manager,
809-
))
810-
})
811-
} else if chain_spec.is_astar() {
812-
runner.async_run(|config| {
813-
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
814-
let info_provider =
815-
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
816-
let task_manager =
817-
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
818-
.map_err(|e| {
819-
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
820-
})?;
821-
Ok((
822-
cmd.run::<astar_runtime::Block, HostFunctionsOf<astar::Executor>, _>(Some(
823-
info_provider,
824-
)),
825-
task_manager,
826-
))
827-
})
828-
} else {
829-
runner.async_run(|config| {
830-
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
831-
let info_provider =
832-
try_runtime_cli::block_building_info::timestamp_with_aura_info(6000);
833-
let task_manager =
834-
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
835-
.map_err(|e| {
836-
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
837-
})?;
838-
Ok((
839-
cmd.run::<Block, HostFunctionsOf<local::Executor>, _>(Some(info_provider)),
840-
task_manager,
841-
))
842-
})
843-
}
788+
Some(Subcommand::TryRuntime(_)) => {
789+
Err("The `try-runtime` subcommand has been migrated to a \
790+
standalone CLI (https://github.com/paritytech/try-runtime-cli). It is no longer \
791+
being maintained here and will be removed entirely some time after January 2024. \
792+
Please remove this subcommand from your runtime and use the standalone CLI."
793+
.into())
844794
}
845795
None => {
846796
let runner = cli.create_runner(&cli.run.normalize())?;
@@ -885,7 +835,7 @@ pub fn run() -> Result<()> {
885835
let parachain_account =
886836
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&para_id);
887837

888-
let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
838+
let state_version = Cli::runtime_version(&config.chain_spec).state_version();
889839
let block: Block = generate_genesis_block(&*config.chain_spec, state_version)
890840
.map_err(|e| format!("{:?}", e))?;
891841
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

bin/collator/src/local/chain_spec.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
2121
use local_runtime::{
2222
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BlockRewardConfig,
23-
CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GenesisConfig, GrandpaConfig,
24-
GrandpaId, InflationConfig, InflationParameters, Precompiles, RewardDistributionConfig,
25-
Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TierThreshold, TreasuryConfig,
26-
VestingConfig, AST,
23+
CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GrandpaConfig, GrandpaId,
24+
InflationConfig, InflationParameters, Precompiles, RewardDistributionConfig,
25+
RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
26+
TierThreshold, TreasuryConfig, VestingConfig, AST,
2727
};
2828
use sc_service::ChainType;
2929
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
@@ -35,7 +35,7 @@ use sp_runtime::{
3535
type AccountPublic = <Signature as Verify>::Signer;
3636

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

4040
/// Helper function to generate a crypto pair from seed
4141
fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
@@ -99,15 +99,16 @@ fn testnet_genesis(
9999
initial_authorities: Vec<(AuraId, GrandpaId)>,
100100
root_key: AccountId,
101101
endowed_accounts: Vec<AccountId>,
102-
) -> GenesisConfig {
102+
) -> RuntimeGenesisConfig {
103103
// This is supposed the be the simplest bytecode to revert without returning any data.
104104
// We will pre-deploy it under all of our precompiles to ensure they can be called from
105105
// within contracts.
106106
// (PUSH1 0x00 PUSH1 0x00 REVERT)
107107
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];
108-
GenesisConfig {
108+
RuntimeGenesisConfig {
109109
system: SystemConfig {
110110
code: wasm_binary_unwrap().to_vec(),
111+
..Default::default()
111112
},
112113
balances: BalancesConfig {
113114
balances: endowed_accounts
@@ -126,6 +127,7 @@ fn testnet_genesis(
126127
adjustable_percent: Perbill::from_percent(25),
127128
ideal_dapps_staking_tvl: Perbill::from_percent(40),
128129
},
130+
..Default::default()
129131
},
130132
vesting: VestingConfig { vesting: vec![] },
131133
aura: AuraConfig {
@@ -136,6 +138,7 @@ fn testnet_genesis(
136138
.iter()
137139
.map(|x| (x.1.clone(), 1))
138140
.collect(),
141+
..Default::default()
139142
},
140143
evm: EVMConfig {
141144
// We need _some_ code inserted at the precompile address so that
@@ -153,6 +156,7 @@ fn testnet_genesis(
153156
)
154157
})
155158
.collect(),
159+
..Default::default()
156160
},
157161
ethereum: Default::default(),
158162
sudo: SudoConfig {
@@ -207,9 +211,11 @@ fn testnet_genesis(
207211
TierThreshold::FixedTvlAmount { amount: 10 * AST },
208212
],
209213
slots_per_tier: vec![10, 20, 30, 40],
214+
..Default::default()
210215
},
211216
inflation: InflationConfig {
212217
params: InflationParameters::default(),
218+
..Default::default()
213219
},
214220
}
215221
}

bin/collator/src/local/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ mod service;
2525
mod chain_spec;
2626

2727
pub use chain_spec::*;
28-
pub use service::{new_partial, start_node, Executor, RuntimeApi};
28+
pub use service::{new_partial, start_node, Executor, RuntimeApi, HostFunctions};

0 commit comments

Comments
 (0)