Skip to content

Commit

Permalink
Ensure we send the correct polkadot node version to telemetry (#1307)
Browse files Browse the repository at this point in the history
This is basically a hack, but with the current way we initialize the node this is the easiest
solution to ensure we send the correct version etc.
  • Loading branch information
bkchr authored May 30, 2022
1 parent 154ea86 commit 6f416ee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions client/relay-chain-inprocess-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ parking_lot = "0.12.0"
tracing = "0.1.34"

# Substrate
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand All @@ -27,6 +28,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master" }

Expand Down
8 changes: 7 additions & 1 deletion client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use polkadot_client::{ClientHandle, ExecuteWithClient, FullBackend};
use polkadot_service::{
AuxStore, BabeApi, CollatorPair, Configuration, Handle, NewFull, Role, TaskManager,
};
use sc_cli::SubstrateCli;
use sc_client_api::{
blockchain::BlockStatus, Backend, BlockchainEvents, HeaderBackend, ImportNotifications,
StorageProof, UsageProvider,
Expand Down Expand Up @@ -359,12 +360,17 @@ fn build_polkadot_full_node(

/// Builds a relay chain interface by constructing a full relay chain node
pub fn build_inprocess_relay_chain(
polkadot_config: Configuration,
mut polkadot_config: Configuration,
parachain_config: &Configuration,
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
task_manager: &mut TaskManager,
hwbench: Option<sc_sysinfo::HwBench>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
// This is essentially a hack, but we want to ensure that we send the correct node version
// to the telemetry.
polkadot_config.impl_version = polkadot_cli::Cli::impl_version();
polkadot_config.impl_name = polkadot_cli::Cli::impl_name();

let (full_node, collator_key) = build_polkadot_full_node(
polkadot_config,
parachain_config,
Expand Down
3 changes: 1 addition & 2 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ pub fn run() -> Result<()> {
let parachain_account =
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account_truncating(&id);

let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
let state_version = Cli::native_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
3 changes: 1 addition & 2 deletions polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,7 @@ pub fn run() -> Result<()> {
let parachain_account =
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account_truncating(&id);

let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();

let block: crate::service::Block =
generate_genesis_block(&config.chain_spec, state_version)
Expand Down

0 comments on commit 6f416ee

Please sign in to comment.