Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Dec 25, 2024
1 parent 6cac042 commit cf85cbc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 37 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ substrate-build-script-utils = { workspace = true }
array-bytes = { workspace = true }
async-trait = { version = "0.1" }
clap = { version = "4.4", features = ["derive"] }
color-print = { version = "0.3" }
futures = { version = "0.3" }
jsonrpsee = { version = "0.23", features = ["server"] }
log = { workspace = true }
Expand Down
44 changes: 33 additions & 11 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

/// The version of the node.
///
/// This is the version that is used for versioning this node binary.
/// By default the `minor` version is bumped in every release. `Major` or `patch` releases are only
/// expected in very rare cases.
///
/// The worker binaries associated to the node binary should ensure that they are using the same
/// version as the main node that started them.
pub const NODE_VERSION: &str = "6.8.1";

/// Sub-commands supported by the collator.
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
Expand Down Expand Up @@ -71,7 +61,8 @@ pub enum Subcommand {
#[command(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
subcommand_negates_reqs = true,
after_help = examples(Self::executable_name())
)]
pub struct Cli {
#[command(subcommand)]
Expand Down Expand Up @@ -113,6 +104,17 @@ pub struct RelayChainCli {
pub base_path: Option<std::path::PathBuf>,
}
impl RelayChainCli {
fn polkadot_cmd() -> Command {
let help_template = color_print::cformat!(
"The arguments that are passed to the relay chain node. \n\
\n\
<bold><underline>RELAY_CHAIN_ARGS:</></> \n\
{{options}}",
);

polkadot_cli::RunCmd::command().no_binary_name(true).help_template(help_template)
}

/// Parse the relay chain CLI parameters using the para chain `Configuration`.
pub fn new<'a>(
para_config: &sc_service::Configuration,
Expand Down Expand Up @@ -258,3 +260,23 @@ pub struct EthRpcConfig {
pub frontier_sql_backend_thread_count: u32,
pub frontier_sql_backend_cache_size: u64,
}

fn examples(executable_name: String) -> String {
color_print::cformat!(
r#"<bold><underline>Examples:</></>
<bold>{0} --chain para.json --sync warp -- --chain relay.json --sync warp</>
Launch a warp-syncing full node of a given para's chain-spec, and a given relay's chain-spec.
<green><italic>The above approach is the most flexible, and the most forward-compatible way to spawn an omni-node.</></>
<bold>{0} --chain darwinia --sync warp -- --chain polkadot --sync warp</>
Launch a warp-syncing full node of the <italic>Darwinia</> parachain on the <italic>Polkadot</> Relay Chain.
<bold>{0} --chain crab --sync warp --relay-chain-rpc-url ws://rpc.example.com -- --chain kusama</>
Launch a warp-syncing full node of the <italic>Crab</> parachain on the <italic>Kusama</> Relay Chain.
Uses <italic>ws://rpc.example.com</> as remote relay chain node.
"#,
executable_name,
)
}
43 changes: 17 additions & 26 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ use sp_runtime::traits::AccountIdConversion;

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Darwinia".into()
Self::executable_name()
}

fn impl_version() -> String {
let commit_hash = env!("SUBSTRATE_CLI_COMMIT_HASH");

format!("{NODE_VERSION}-{commit_hash}")
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
}

fn description() -> String {
format!(
"Darwinia\n\nThe command-line arguments provided first will be \
passed to the parachain node, while the arguments provided after -- will be passed \
to the relay chain node.\n\n\
{} <parachain-args> -- <relay-chain-args>",
"The command-line arguments provided first will be passed to the parachain node, \n\
and the arguments provided after -- will be passed to the relay chain node. \n\
\n\
Example: \n\
\n\
{} [parachain-args] -- [relay-chain-args]",
Self::executable_name()
)
}
Expand All @@ -77,33 +77,27 @@ impl SubstrateCli for Cli {

impl SubstrateCli for RelayChainCli {
fn impl_name() -> String {
"Darwinia".into()
Cli::impl_name()
}

fn impl_version() -> String {
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
Cli::impl_version()
}

fn description() -> String {
format!(
"Darwinia\n\nThe command-line arguments provided first will be \
passed to the parachain node, while the arguments provided after -- will be passed \
to the relay chain node.\n\n\
{} <parachain-args> -- <relay-chain-args>",
Self::executable_name()
)
Cli::description()
}

fn author() -> String {
env!("CARGO_PKG_AUTHORS").into()
Cli::author()
}

fn support_url() -> String {
"https://github.com/darwinia-network/darwinia/issues/new".into()
Cli::support_url()
}

fn copyright_start_year() -> i32 {
2018
Cli::copyright_start_year()
}

fn load_spec(&self, id: &str) -> StdResult<Box<dyn ChainSpecT>, String> {
Expand Down Expand Up @@ -490,12 +484,9 @@ pub fn run() -> Result<()> {
let storage_monitor = cli.storage_monitor;
let eth_rpc_config = cli.eth_args.build_eth_rpc_config();

log::info!("Parachain id: {id:?}");
log::info!("Parachain Account: {parachain_account}");
log::info!(
"Is collating: {}",
if config.role.is_authority() { "yes" } else { "no" }
);
log::info!("🪪 Parachain id: {:?}", id);
log::info!("🧾 Parachain Account: {}", parachain_account);
log::info!("✍️ Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

if chain_spec.is_dev() {
#[cfg(feature = "crab-runtime")]
Expand Down

0 comments on commit cf85cbc

Please sign in to comment.