Skip to content

Commit d259200

Browse files
committed
use shibuya runtime + auto manual seal
1 parent be26e1f commit d259200

File tree

11 files changed

+727
-56
lines changed

11 files changed

+727
-56
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "
157157
sc-client-db = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
158158
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
159159
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
160-
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
161160
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
162-
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
163161
sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
164162
sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
165163
sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
@@ -208,7 +206,6 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk"
208206
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
209207
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
210208
pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
211-
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
212209
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
213210
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
214211
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
@@ -272,6 +269,7 @@ cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-
272269
cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
273270
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
274271
cumulus-client-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
272+
cumulus-client-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
275273
cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
276274
cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
277275
cumulus-client-consensus-proposer = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }

bin/collator/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ sc-client-api = { workspace = true }
6262
sc-client-db = { workspace = true }
6363
sc-consensus = { workspace = true }
6464
sc-consensus-aura = { workspace = true }
65-
sc-consensus-babe = { workspace = true }
66-
sc-consensus-grandpa = { workspace = true }
67-
sc-consensus-manual-seal = { workspace = true, optional = true }
65+
sc-consensus-manual-seal = { workspace = true }
6866
sc-executor = { workspace = true }
6967
sc-network = { workspace = true }
7068
sc-network-sync = { workspace = true }
@@ -125,6 +123,7 @@ cumulus-client-consensus-common = { workspace = true }
125123
cumulus-client-consensus-proposer = { workspace = true }
126124
cumulus-client-consensus-relay-chain = { workspace = true }
127125
cumulus-client-network = { workspace = true }
126+
cumulus-client-parachain-inherent = { workspace = true }
128127
cumulus-client-service = { workspace = true }
129128
cumulus-primitives-aura = { workspace = true }
130129
cumulus-primitives-core = { workspace = true, features = ["std"] }
@@ -207,4 +206,3 @@ try-runtime = [
207206
"sp-runtime/try-runtime",
208207
"frame-support/try-runtime",
209208
]
210-
manual-seal = ["sc-consensus-manual-seal"]

bin/collator/src/command.rs

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//! Astar collator CLI handlers.
2020
use crate::{
2121
cli::{Cli, RelayChainCli, Subcommand},
22+
local::{self, development_config},
2223
parachain::{self, chain_spec, service::AdditionalConfig},
2324
};
2425
use cumulus_primitives_core::ParaId;
@@ -36,6 +37,7 @@ use sp_runtime::traits::AccountIdConversion;
3637

3738
trait IdentifyChain {
3839
fn is_astar(&self) -> bool;
40+
fn is_dev(&self) -> bool;
3941
fn is_shiden(&self) -> bool;
4042
fn is_shibuya(&self) -> bool;
4143
}
@@ -44,6 +46,9 @@ impl IdentifyChain for dyn sc_service::ChainSpec {
4446
fn is_astar(&self) -> bool {
4547
self.id().starts_with("astar")
4648
}
49+
fn is_dev(&self) -> bool {
50+
self.id().starts_with("dev")
51+
}
4752
fn is_shiden(&self) -> bool {
4853
self.id().starts_with("shiden")
4954
}
@@ -56,6 +61,9 @@ impl<T: sc_service::ChainSpec + 'static> IdentifyChain for T {
5661
fn is_astar(&self) -> bool {
5762
<dyn sc_service::ChainSpec>::is_astar(self)
5863
}
64+
fn is_dev(&self) -> bool {
65+
<dyn sc_service::ChainSpec>::is_dev(self)
66+
}
5967
fn is_shiden(&self) -> bool {
6068
<dyn sc_service::ChainSpec>::is_shiden(self)
6169
}
@@ -66,6 +74,7 @@ impl<T: sc_service::ChainSpec + 'static> IdentifyChain for T {
6674

6775
fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
6876
Ok(match id {
77+
"dev" => Box::new(development_config()),
6978
"astar-dev" => Box::new(chain_spec::astar::get_chain_spec()),
7079
"shibuya-dev" => Box::new(chain_spec::shibuya::get_chain_spec()),
7180
"shiden-dev" => Box::new(chain_spec::shiden::get_chain_spec()),
@@ -243,16 +252,29 @@ pub fn run() -> Result<()> {
243252
}
244253
Some(Subcommand::Revert(cmd)) => {
245254
let runner = cli.create_runner(cmd)?;
255+
let chain_spec = &runner.config().chain_spec;
246256
let rpc_config = cli.eth_api_options.new_rpc_config();
247-
runner.async_run(|config| {
248-
let PartialComponents {
249-
client,
250-
task_manager,
251-
backend,
252-
..
253-
} = parachain::new_partial(&config, &rpc_config)?;
254-
Ok((cmd.run(client, backend, None), task_manager))
255-
})
257+
if chain_spec.is_dev() {
258+
runner.async_run(|config| {
259+
let PartialComponents {
260+
client,
261+
task_manager,
262+
backend,
263+
..
264+
} = local::new_partial(&config, &rpc_config)?;
265+
Ok((cmd.run(client, backend, None), task_manager))
266+
})
267+
} else {
268+
runner.async_run(|config| {
269+
let PartialComponents {
270+
client,
271+
task_manager,
272+
backend,
273+
..
274+
} = parachain::new_partial(&config, &rpc_config)?;
275+
Ok((cmd.run(client, backend, None), task_manager))
276+
})
277+
}
256278
}
257279
Some(Subcommand::ExportGenesisState(cmd)) => {
258280
let runner = cli.create_runner(cmd)?;
@@ -305,23 +327,45 @@ pub fn run() -> Result<()> {
305327
)
306328
})
307329
} else {
308-
Err(format!(
309-
"Unknown chain '{}' for benchmarking. Use --chain astar, shiden, shibuya, astar-dev, shiden-dev, or shibuya-dev",
310-
chain_spec.id()
311-
).into())
330+
runner.sync_run(|config| {
331+
cmd.run_with_spec::<HashingFor<shibuya_runtime::Block>, local::HostFunctions>(
332+
Some(config.chain_spec),
333+
)
334+
})
335+
}
336+
}
337+
BenchmarkCmd::Block(cmd) => {
338+
if chain_spec.is_dev() {
339+
runner.sync_run(|config| {
340+
let params = local::new_partial(&config, &rpc_config)?;
341+
cmd.run(params.client)
342+
})
343+
} else {
344+
runner.sync_run(|config| {
345+
let params = parachain::new_partial(&config, &rpc_config)?;
346+
cmd.run(params.client)
347+
})
348+
}
349+
}
350+
BenchmarkCmd::Storage(cmd) => {
351+
if chain_spec.is_dev() {
352+
runner.sync_run(|config| {
353+
let params = local::new_partial(&config, &rpc_config)?;
354+
let db = params.backend.expose_db();
355+
let storage = params.backend.expose_storage();
356+
357+
cmd.run(config, params.client, db, storage, None)
358+
})
359+
} else {
360+
runner.sync_run(|config| {
361+
let params = parachain::new_partial(&config, &rpc_config)?;
362+
let db = params.backend.expose_db();
363+
let storage = params.backend.expose_storage();
364+
365+
cmd.run(config, params.client, db, storage, None)
366+
})
312367
}
313368
}
314-
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
315-
let params = parachain::new_partial(&config, &rpc_config)?;
316-
cmd.run(params.client)
317-
}),
318-
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
319-
let params = parachain::new_partial(&config, &rpc_config)?;
320-
let db = params.backend.expose_db();
321-
let storage = params.backend.expose_storage();
322-
323-
cmd.run(config, params.client, db, storage, None)
324-
}),
325369
BenchmarkCmd::Overhead(_) => {
326370
todo!("Overhead benchmarking is not supported. Use 'frame-omni-bencher' tool instead.");
327371
}
@@ -340,6 +384,14 @@ pub fn run() -> Result<()> {
340384
let evm_tracing_config = cli.eth_api_options.new_rpc_config();
341385

342386
runner.run_node_until_exit(|config| async move {
387+
if config.chain_spec.is_dev() {
388+
return local::start_node::<sc_network::NetworkWorker<_, _>>(
389+
config,
390+
evm_tracing_config,
391+
)
392+
.map_err(Into::into);
393+
}
394+
343395
let polkadot_cli = RelayChainCli::new(
344396
&config,
345397
[RelayChainCli::executable_name()]

bin/collator/src/evm_tracing_types.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,12 @@ pub struct FrontierConfig {
9898
#[derive(Debug, Parser)]
9999
pub struct EthApiOptions {
100100
/// Enable EVM tracing module on a non-authority node.
101-
#[cfg_attr(
102-
not(feature = "manual-seal"),
103-
clap(
104-
long,
105-
conflicts_with = "collator",
106-
conflicts_with = "validator",
107-
value_delimiter = ','
108-
)
101+
#[clap(
102+
long,
103+
conflicts_with = "collator",
104+
conflicts_with = "validator",
105+
value_delimiter = ','
109106
)]
110-
#[cfg_attr(feature = "manual-seal", clap(long))]
111107
pub ethapi: Vec<EthApi>,
112108

113109
/// Number of concurrent tracing tasks. Meant to be shared by both "debug" and "trace" modules.

bin/collator/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#![warn(missing_docs)]
2222
#![warn(unused_extern_crates)]
2323

24+
/// Development node support.
25+
pub mod local;
2426
/// Parachain node support.
2527
pub mod parachain;
2628

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// This file is part of Astar.
2+
3+
// Copyright (C) Stake Technologies Pte.Ltd.
4+
// SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
// Astar is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU General Public License as published by
8+
// the Free Software Foundation, either version 3 of the License, or
9+
// (at your option) any later version.
10+
11+
// Astar is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
16+
// You should have received a copy of the GNU General Public License
17+
// along with Astar. If not, see <http://www.gnu.org/licenses/>.
18+
19+
use sc_service::ChainType;
20+
use shibuya_runtime::wasm_binary_unwrap;
21+
22+
/// Specialized `ChainSpec` for local network.
23+
pub type ChainSpec = sc_service::GenericChainSpec;
24+
25+
/// Development config.
26+
pub fn development_config() -> ChainSpec {
27+
let mut properties = serde_json::map::Map::new();
28+
properties.insert("tokenSymbol".into(), "LOC".into());
29+
properties.insert("tokenDecimals".into(), 18.into());
30+
31+
ChainSpec::builder(wasm_binary_unwrap(), None)
32+
.with_name("Development")
33+
.with_id("dev")
34+
.with_chain_type(ChainType::Development)
35+
.with_properties(properties)
36+
.with_genesis_config_preset_name("development")
37+
.build()
38+
}
39+
40+
#[cfg(test)]
41+
pub(crate) mod tests {
42+
use super::*;
43+
use sp_runtime::BuildStorage;
44+
45+
#[test]
46+
fn test_create_development_chain_spec() {
47+
development_config().build_storage().unwrap();
48+
}
49+
}

bin/collator/src/local/mod.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This file is part of Astar.
2+
3+
// Copyright (C) Stake Technologies Pte.Ltd.
4+
// SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
// Astar is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU General Public License as published by
8+
// the Free Software Foundation, either version 3 of the License, or
9+
// (at your option) any later version.
10+
11+
// Astar is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
16+
// You should have received a copy of the GNU General Public License
17+
// along with Astar. If not, see <http://www.gnu.org/licenses/>.
18+
19+
//! Support for local development node.
20+
21+
/// Local development service.
22+
mod service;
23+
24+
/// Development chain specs.
25+
mod chain_spec;
26+
27+
pub use crate::parachain::fake_runtime_api::RuntimeApi;
28+
pub use chain_spec::*;
29+
pub use service::{new_partial, start_node, HostFunctions};

0 commit comments

Comments
 (0)