From e60d2865040d8869fd0303c3c7c8f07fb90d7dda Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Tue, 9 Jan 2024 17:20:57 +0800 Subject: [PATCH 1/7] Feat: Avail service port is customize. --- node/src/avail_task.rs | 5 +++-- node/src/cli.rs | 3 +++ node/src/service.rs | 8 +++++--- primitives/avail/Cargo.toml | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/node/src/avail_task.rs b/node/src/avail_task.rs index 853f1f4..32d4eb5 100644 --- a/node/src/avail_task.rs +++ b/node/src/avail_task.rs @@ -109,6 +109,7 @@ pub fn spawn_avail_task( client: Arc, task_manager: &TaskManager, avail_record: Arc>, + avail_rpc_port: Option, ) -> Result<(), Box> where B: BlockT, @@ -126,15 +127,15 @@ where { task_manager.spawn_essential_handle().spawn("spawn_query_block", "magport", { async move { + let avail_url = format!("ws://127.0.0.1:{}", avail_rpc_port.unwrap_or(9945)); let avail_client = - avail_subxt::build_client("ws://127.0.0.1:9945", false).await.unwrap(); + avail_subxt::build_client(&avail_url, false).await.unwrap(); let mut notification_st = client.import_notification_stream(); while let Some(notification) = notification_st.next().await { if notification.origin != BlockOrigin::Own { continue; } let block_number: u32 = (*notification.header.number()).into(); - // Query if block_number % 5 == 0 { // Sync From Pallet diff --git a/node/src/cli.rs b/node/src/cli.rs index c3e65de..eb8190d 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -21,6 +21,9 @@ pub struct Cli { #[allow(missing_docs)] #[clap(flatten)] pub storage_monitor: sc_storage_monitor::StorageMonitorParams, + + /// Avail PRC Port Number, default is 9945. + pub avail_rpc_port: Option, } #[derive(Debug, clap::Subcommand)] diff --git a/node/src/service.rs b/node/src/service.rs index 7f6e9e7..318e4c5 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -60,8 +60,9 @@ type FullGrandpaBlockImport = /// Builds a new service for a full client. pub fn new_full(config: Configuration, cli: Cli) -> Result { let database_source = config.database.clone(); - let task_manager = new_full_base(config, cli.no_hardware_benchmarks, |_, _| ()) - .map(|NewFullBase { task_manager, .. }| task_manager)?; + let task_manager = + new_full_base(config, cli.no_hardware_benchmarks, |_, _| (), cli.avail_rpc_port) + .map(|NewFullBase { task_manager, .. }| task_manager)?; sc_storage_monitor::StorageMonitorService::try_spawn( cli.storage_monitor, @@ -97,6 +98,7 @@ pub fn new_full_base( &sc_consensus_babe::BabeBlockImport, &sc_consensus_babe::BabeLink, ), + avail_rpc_port: Option, ) -> Result { let hwbench = (!disable_hardware_benchmarks) .then_some(config.database.path().map(|database_path| { @@ -332,7 +334,7 @@ pub fn new_full_base( } // let _ = spawn_query_block_task(client.clone(), &task_manager, avail_record.clone()); // let _ = spawn_submit_block_task(client.clone(), &task_manager, avail_record.clone()); - let _ = spawn_avail_task(client.clone(), &task_manager, avail_record.clone()); + let _ = spawn_avail_task(client.clone(), &task_manager, avail_record.clone(), avail_rpc_port); network_starter.start_network(); Ok(NewFullBase { task_manager, diff --git a/primitives/avail/Cargo.toml b/primitives/avail/Cargo.toml index 8c1050b..5d83f64 100644 --- a/primitives/avail/Cargo.toml +++ b/primitives/avail/Cargo.toml @@ -6,11 +6,11 @@ license = "Unlicense" version = "0.0.1" [dependencies] -codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"], default-features = false } sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", default-features = false } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } +sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", default-features = false } +sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", default-features = false } sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", default-features = false } async-trait = { version = "0.1.57", optional = true } scale-info = { version = "2.1.1", default-features = false } From fd03ffd051b2ffc1c1cd1de0d272d33456e38863 Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Tue, 9 Jan 2024 18:09:30 +0800 Subject: [PATCH 2/7] Fix: Magport startup error --- node/src/avail_task.rs | 29 ++++++++++++++++++++++------- node/src/cli.rs | 3 ++- node/src/service.rs | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/node/src/avail_task.rs b/node/src/avail_task.rs index 32d4eb5..ea9f914 100644 --- a/node/src/avail_task.rs +++ b/node/src/avail_task.rs @@ -109,7 +109,7 @@ pub fn spawn_avail_task( client: Arc, task_manager: &TaskManager, avail_record: Arc>, - avail_rpc_port: Option, + avail_rpc_port: u16, ) -> Result<(), Box> where B: BlockT, @@ -127,14 +127,29 @@ where { task_manager.spawn_essential_handle().spawn("spawn_query_block", "magport", { async move { - let avail_url = format!("ws://127.0.0.1:{}", avail_rpc_port.unwrap_or(9945)); - let avail_client = - avail_subxt::build_client(&avail_url, false).await.unwrap(); + let avail_url = format!("ws://127.0.0.1:{}", avail_rpc_port); + log::info!("================ TASK | avail_url: {:?} ================", avail_url); + let avail_client = Arc::new(Mutex::new(None::>)); let mut notification_st = client.import_notification_stream(); while let Some(notification) = notification_st.next().await { if notification.origin != BlockOrigin::Own { continue; } + // If inner of avail_client is None, try to connect avail + if avail_client.lock().await.is_none() { + let avail_client_inner = avail_subxt::build_client(&avail_url, false).await; + if let Ok(avail_client_inner) = avail_client_inner { + *avail_client.lock().await = Some(avail_client_inner); + log::info!("================ TASK | avail service connected ================"); + } else { + log::info!("================ TASK | avail service not connected ================"); + continue; + } + } + // Get Avail Client + let guard = avail_client.lock().await; + let avail_client_ref = guard.as_ref().unwrap(); + let block_number: u32 = (*notification.header.number()).into(); // Query if block_number % 5 == 0 { @@ -168,7 +183,7 @@ where }; if last_submit_block_confirm != last_submit_block { - let avail_latest_finalized_height = get_avail_latest_finalized_height(&avail_client).await.unwrap(); + let avail_latest_finalized_height = get_avail_latest_finalized_height(avail_client_ref).await.unwrap(); log::info!( "================ QUERY TASK | Avail Block Query Range: {:?} to {:?} ================", last_avail_scan_block_confirm, @@ -185,7 +200,7 @@ where log::info!("================ QUERY TASK | search avail block:{:?} ================", block_number); for block_number_solo in last_submit_block_confirm + 1..=last_submit_block { if let Ok(find_result) = query_block_exist( - &avail_client, + avail_client_ref, client.clone(), block_number, block_number_solo, @@ -268,7 +283,7 @@ where let extrinsic_params = AvailExtrinsicParams::new_with_app_id(AppId(0u32)); let signer = signer_from_seed("//Alice").unwrap(); - match avail_client + match avail_client_ref .tx() .sign_and_submit(&data_transfer, &signer, extrinsic_params) .await diff --git a/node/src/cli.rs b/node/src/cli.rs index eb8190d..7650613 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -23,7 +23,8 @@ pub struct Cli { pub storage_monitor: sc_storage_monitor::StorageMonitorParams, /// Avail PRC Port Number, default is 9945. - pub avail_rpc_port: Option, + #[arg(long, default_value = "9945")] + pub avail_rpc_port: u16, } #[derive(Debug, clap::Subcommand)] diff --git a/node/src/service.rs b/node/src/service.rs index 318e4c5..5837314 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -98,7 +98,7 @@ pub fn new_full_base( &sc_consensus_babe::BabeBlockImport, &sc_consensus_babe::BabeLink, ), - avail_rpc_port: Option, + avail_rpc_port: u16, ) -> Result { let hwbench = (!disable_hardware_benchmarks) .then_some(config.database.path().map(|database_path| { From 0f1a82aee94c46c09062821d56358a386b37c6ff Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Tue, 9 Jan 2024 18:10:05 +0800 Subject: [PATCH 3/7] Fix: Magport startup error --- node/src/avail_task.rs | 2 +- node/src/command.rs | 10 ++++------ runtime/src/lib.rs | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/node/src/avail_task.rs b/node/src/avail_task.rs index ea9f914..141942c 100644 --- a/node/src/avail_task.rs +++ b/node/src/avail_task.rs @@ -149,7 +149,7 @@ where // Get Avail Client let guard = avail_client.lock().await; let avail_client_ref = guard.as_ref().unwrap(); - + let block_number: u32 = (*notification.header.number()).into(); // Query if block_number % 5 == 0 { diff --git a/node/src/command.rs b/node/src/command.rs index 31a2d1e..caa79e1 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -46,9 +46,8 @@ impl SubstrateCli for Cli { "dev" => Box::new(chain_spec::development_config()?), "" | "local" => Box::new(chain_spec::local_testnet_config()?), "staging" => Box::new(chain_spec::staging_network_config()), - path => { - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) - }, + path => + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), }) } } @@ -171,9 +170,8 @@ pub fn run() -> sc_cli::Result<()> { cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) }, - BenchmarkCmd::Machine(cmd) => { - cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()) - }, + BenchmarkCmd::Machine(cmd) => + cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), } }) }, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 274e836..20f3efa 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -369,8 +369,8 @@ impl Get> for OffchainRandomBalancing { max => { let seed = sp_io::offchain::random_seed(); let random = ::decode(&mut TrailingZeroInput::new(&seed)) - .expect("input is padded with zeroes; qed") - % max.saturating_add(1); + .expect("input is padded with zeroes; qed") % + max.saturating_add(1); random as usize }, }; From 7dd61677f1893ba71cfd6051d9889550a3fce801 Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Tue, 9 Jan 2024 18:18:08 +0800 Subject: [PATCH 4/7] Feat: Customize Avail service port. --- node/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/cli.rs b/node/src/cli.rs index 7650613..d9e8f7f 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -22,7 +22,7 @@ pub struct Cli { #[clap(flatten)] pub storage_monitor: sc_storage_monitor::StorageMonitorParams, - /// Avail PRC Port Number, default is 9945. + /// Avail RPC Port Number, default is 9945. #[arg(long, default_value = "9945")] pub avail_rpc_port: u16, } From 9eec546db7f03632a10dcd2edc2e9a5d4fa8d775 Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Tue, 9 Jan 2024 18:22:02 +0800 Subject: [PATCH 5/7] Format code. --- node/src/command.rs | 10 ++++++---- runtime/src/lib.rs | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index caa79e1..31a2d1e 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -46,8 +46,9 @@ impl SubstrateCli for Cli { "dev" => Box::new(chain_spec::development_config()?), "" | "local" => Box::new(chain_spec::local_testnet_config()?), "staging" => Box::new(chain_spec::staging_network_config()), - path => - Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), + path => { + Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?) + }, }) } } @@ -170,8 +171,9 @@ pub fn run() -> sc_cli::Result<()> { cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) }, - BenchmarkCmd::Machine(cmd) => - cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), + BenchmarkCmd::Machine(cmd) => { + cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()) + }, } }) }, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 20f3efa..274e836 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -369,8 +369,8 @@ impl Get> for OffchainRandomBalancing { max => { let seed = sp_io::offchain::random_seed(); let random = ::decode(&mut TrailingZeroInput::new(&seed)) - .expect("input is padded with zeroes; qed") % - max.saturating_add(1); + .expect("input is padded with zeroes; qed") + % max.saturating_add(1); random as usize }, }; From a026afd4d67a892c5f972aaa470653d68f294425 Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Wed, 10 Jan 2024 16:23:30 +0800 Subject: [PATCH 6/7] Feat: Modify node name. --- Cargo.lock | 246 +++++++++++++++++++-------------------- Cargo.toml | 2 +- node/Cargo.toml | 13 +-- node/src/avail_task.rs | 2 +- node/src/benchmarking.rs | 2 +- node/src/chain_spec.rs | 4 +- node/src/command.rs | 4 +- node/src/service.rs | 8 +- runtime/Cargo.toml | 2 +- 9 files changed, 139 insertions(+), 144 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 243704a..78c60b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3941,6 +3941,129 @@ dependencies = [ "syn 2.0.42", ] +[[package]] +name = "magport-node" +version = "4.0.0-dev" +dependencies = [ + "anyhow", + "avail-subxt", + "clap 4.4.11", + "frame-benchmarking", + "frame-benchmarking-cli", + "frame-system", + "futures", + "futures-timer", + "hex-literal", + "jsonrpsee", + "log", + "magport-node-runtime", + "node-primitives 2.0.0", + "pallet-im-online", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc", + "parity-scale-codec", + "primitives-avail", + "rand 0.8.5", + "sc-basic-authorship", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-babe-rpc", + "sc-consensus-epochs", + "sc-consensus-grandpa", + "sc-consensus-grandpa-rpc", + "sc-consensus-slots", + "sc-executor", + "sc-network", + "sc-network-common", + "sc-network-sync", + "sc-offchain", + "sc-rpc", + "sc-rpc-api", + "sc-rpc-spec-v2", + "sc-service", + "sc-storage-monitor", + "sc-sysinfo", + "sc-telemetry", + "sc-transaction-pool", + "sc-transaction-pool-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-inherents", + "sp-io 23.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-keyring", + "sp-keystore 0.27.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-statement-store", + "sp-timestamp", + "sp-transaction-storage-proof", + "substrate-build-script-utils", + "substrate-frame-rpc-system", + "subxt", + "try-runtime-cli", +] + +[[package]] +name = "magport-node-runtime" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "log", + "node-primitives 2.0.0", + "pallet-authorship", + "pallet-avail", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-election-provider-multi-phase", + "pallet-grandpa", + "pallet-im-online", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-template", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "parity-scale-codec", + "primitives-avail", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-inherents", + "sp-io 23.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-npos-elections", + "sp-offchain", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-session", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", +] + [[package]] name = "maplit" version = "1.0.2" @@ -4312,129 +4435,6 @@ dependencies = [ "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", ] -[[package]] -name = "node-template" -version = "4.0.0-dev" -dependencies = [ - "anyhow", - "avail-subxt", - "clap 4.4.11", - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-system", - "futures", - "futures-timer", - "hex-literal", - "jsonrpsee", - "log", - "node-primitives 2.0.0", - "node-template-runtime", - "pallet-im-online", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc", - "parity-scale-codec", - "primitives-avail", - "rand 0.8.5", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-babe-rpc", - "sc-consensus-epochs", - "sc-consensus-grandpa", - "sc-consensus-grandpa-rpc", - "sc-consensus-slots", - "sc-executor", - "sc-network", - "sc-network-common", - "sc-network-sync", - "sc-offchain", - "sc-rpc", - "sc-rpc-api", - "sc-rpc-spec-v2", - "sc-service", - "sc-storage-monitor", - "sc-sysinfo", - "sc-telemetry", - "sc-transaction-pool", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core 21.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-inherents", - "sp-io 23.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-keyring", - "sp-keystore 0.27.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-statement-store", - "sp-timestamp", - "sp-transaction-storage-proof", - "substrate-build-script-utils", - "substrate-frame-rpc-system", - "subxt", - "try-runtime-cli", -] - -[[package]] -name = "node-template-runtime" -version = "4.0.0-dev" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "log", - "node-primitives 2.0.0", - "pallet-authorship", - "pallet-avail", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-election-provider-multi-phase", - "pallet-grandpa", - "pallet-im-online", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-template", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-utility", - "parity-scale-codec", - "primitives-avail", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core 21.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-inherents", - "sp-io 23.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-npos-elections", - "sp-offchain", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-session", - "sp-staking", - "sp-std 8.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0)", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", -] - [[package]] name = "nodrop" version = "0.1.14" diff --git a/Cargo.toml b/Cargo.toml index ace1ab2..1d6494e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" panic = "unwind" [workspace.package] -authors = ["Magport/Substrate-Rollup team"] +authors = ["Substrate DevHub ", "Magport/Substrate-Rollup team"] edition = "2021" license = "Apache License 2.0" repository = "https://github.com/Magport/Substrate-Rollup" diff --git a/node/Cargo.toml b/node/Cargo.toml index 65e7102..f14689e 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "node-template" +name = "magport-node" version = "4.0.0-dev" description = "A fresh FRAME-based Substrate node, ready for hacking." -authors = ["Substrate DevHub "] +authors.workspace = true homepage = "https://substrate.io/" edition = "2021" license = "MIT-0" @@ -13,9 +13,6 @@ build = "build.rs" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] -[[bin]] -name = "node-template" - [dependencies] clap = { version = "4.4.2", features = ["derive"] } futures = { version = "0.3.21", features = ["thread-pool"] } @@ -78,7 +75,7 @@ frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/parityte frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } # Local Dependencies -node-template-runtime = { version = "4.0.0-dev", path = "../runtime" } +magport-node-runtime = { version = "4.0.0-dev", path = "../runtime" } node-primitives = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", default-features = false } primitives-avail = { path = "../primitives/avail"} # CLI-specific dependencies @@ -97,13 +94,13 @@ substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/pa default = [] # Dependencies that are only required if runtime benchmarking should be build. runtime-benchmarks = [ - "node-template-runtime/runtime-benchmarks", + "magport-node-runtime/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", ] # Enable features that allow the runtime to be tried and debugged. Name might be subject to change # in the near future. try-runtime = [ - "node-template-runtime/try-runtime", + "magport-node-runtime/try-runtime", "try-runtime-cli/try-runtime", ] diff --git a/node/src/avail_task.rs b/node/src/avail_task.rs index 141942c..28b6b3f 100644 --- a/node/src/avail_task.rs +++ b/node/src/avail_task.rs @@ -65,7 +65,7 @@ where Call::DataAvailability(da_call) => match da_call { DaCall::submit_data { data } => { // log::info!("=======get:{:?}", data); - let _rollup_block = node_template_runtime::Block::decode(&mut &data.0[..]); + let _rollup_block = magport_node_runtime::Block::decode(&mut &data.0[..]); // log::info!("=======get block:{:?}", rollup_block); let rollup_block_hash = client.block_hash(block_number_solo.into()); let mut find_flag = false; diff --git a/node/src/benchmarking.rs b/node/src/benchmarking.rs index 6e29ad1..c2e88ba 100644 --- a/node/src/benchmarking.rs +++ b/node/src/benchmarking.rs @@ -4,7 +4,7 @@ use crate::service::FullClient; -use node_template_runtime as runtime; +use magport_node_runtime as runtime; use runtime::{AccountId, Balance, BalancesCall, SystemCall}; use sc_cli::Result; use sc_client_api::BlockBackend; diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index d81e6c1..697197e 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,6 +1,6 @@ use hex_literal::hex; use node_primitives::*; -use node_template_runtime::{ +use magport_node_runtime::{ constants::currency::*, AccountId, BabeConfig, BalancesConfig, ImOnlineConfig, MaxNominations, RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig, WASM_BINARY, @@ -296,7 +296,7 @@ fn testnet_genesis( balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), }, babe: BabeConfig { - epoch_config: Some(node_template_runtime::BABE_GENESIS_EPOCH_CONFIG), + epoch_config: Some(magport_node_runtime::BABE_GENESIS_EPOCH_CONFIG), ..Default::default() }, grandpa: Default::default(), diff --git a/node/src/command.rs b/node/src/command.rs index 31a2d1e..a23eb8d 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -5,14 +5,14 @@ use crate::{ service, }; use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; -use node_template_runtime::{Block, EXISTENTIAL_DEPOSIT}; +use magport_node_runtime::{Block, EXISTENTIAL_DEPOSIT}; use sc_cli::SubstrateCli; use sc_service::PartialComponents; use sp_keyring::Sr25519Keyring; #[cfg(feature = "try-runtime")] use { - node_template_runtime::constants::time::SLOT_DURATION, + magport_node_runtime::constants::time::SLOT_DURATION, try_runtime_cli::block_building_info::substrate_info, }; diff --git a/node/src/service.rs b/node/src/service.rs index 5837314..8c4f6a5 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use node_primitives::Block; -use node_template_runtime::RuntimeApi; +use magport_node_runtime::RuntimeApi; use crate::{ avail_task::spawn_avail_task, @@ -39,11 +39,11 @@ impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { type ExtendHostFunctions = (); fn dispatch(method: &str, data: &[u8]) -> Option> { - node_template_runtime::api::dispatch(method, data) + magport_node_runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - node_template_runtime::native_version() + magport_node_runtime::native_version() } } @@ -332,8 +332,6 @@ pub fn new_full_base( sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?, ); } - // let _ = spawn_query_block_task(client.clone(), &task_manager, avail_record.clone()); - // let _ = spawn_submit_block_task(client.clone(), &task_manager, avail_record.clone()); let _ = spawn_avail_task(client.clone(), &task_manager, avail_record.clone(), avail_rpc_port); network_starter.start_network(); Ok(NewFullBase { diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0908a61..666424a 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "node-template-runtime" +name = "magport-node-runtime" version = "4.0.0-dev" description = "A fresh FRAME-based Substrate node, ready for hacking." authors = ["Substrate DevHub "] From cb07ddb957e2714b2fc5cd3b84024924fe86e50a Mon Sep 17 00:00:00 2001 From: luckychacha <358140284@qq.com> Date: Wed, 10 Jan 2024 16:24:02 +0800 Subject: [PATCH 7/7] Feat: Modify node name. --- node/src/chain_spec.rs | 2 +- node/src/service.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 697197e..3e67cbd 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,10 +1,10 @@ use hex_literal::hex; -use node_primitives::*; use magport_node_runtime::{ constants::currency::*, AccountId, BabeConfig, BalancesConfig, ImOnlineConfig, MaxNominations, RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig, WASM_BINARY, }; +use node_primitives::*; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use sc_chain_spec::Properties; use sc_service::ChainType; diff --git a/node/src/service.rs b/node/src/service.rs index 8c4f6a5..e4eeb5e 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -18,8 +18,8 @@ use std::sync::Arc; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; -use node_primitives::Block; use magport_node_runtime::RuntimeApi; +use node_primitives::Block; use crate::{ avail_task::spawn_avail_task,