Skip to content

Commit

Permalink
Merge branch 'master' into shawntabrizi-binary-trie2
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored Sep 19, 2024
2 parents 39e78d7 + c8d5e5a commit aabaf76
Show file tree
Hide file tree
Showing 44 changed files with 623 additions and 211 deletions.
6 changes: 4 additions & 2 deletions .gitlab/pipeline/zombienet/parachain-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
RUST_LOG: "info,zombienet_orchestrator=debug"
FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: 1
RUN_IN_CONTAINER: "1"
RUNNER_SCRIPT_TIMEOUT: 15m
RUNNER_AFTER_SCRIPT_TIMEOUT: 5m
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: always
Expand All @@ -25,9 +27,9 @@
- ./zombienet-logs
after_script:
- mkdir -p ./zombienet-logs
- cp /tmp/zombie*/logs/* ./zombienet-logs/
- cp /tmp/zombie*/*/*.log ./zombienet-logs/
retry: 2
timeout: 15m
timeout: 20m
tags:
- linux-docker

Expand Down
68 changes: 36 additions & 32 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ snowbridge-router-primitives = { path = "bridges/snowbridge/primitives/router",
snowbridge-runtime-common = { path = "bridges/snowbridge/runtime/runtime-common", default-features = false }
snowbridge-runtime-test-common = { path = "bridges/snowbridge/runtime/test-common", default-features = false }
snowbridge-system-runtime-api = { path = "bridges/snowbridge/pallets/system/runtime-api", default-features = false }
soketto = { version = "0.7.1" }
soketto = { version = "0.8.0" }
solochain-template-runtime = { path = "templates/solochain/runtime" }
sp-api = { path = "substrate/primitives/api", default-features = false }
sp-api-proc-macro = { path = "substrate/primitives/api/proc-macro", default-features = false }
Expand Down
11 changes: 7 additions & 4 deletions cumulus/client/relay-chain-minimal-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,20 @@ async fn build_interface(
client: RelayChainRpcClient,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
let collator_pair = CollatorPair::generate().0;
let blockchain_rpc_client = Arc::new(BlockChainRpcClient::new(client.clone()));
let collator_node = match polkadot_config.network.network_backend {
sc_network::config::NetworkBackendType::Libp2p =>
new_minimal_relay_chain::<RelayBlock, sc_network::NetworkWorker<RelayBlock, RelayHash>>(
polkadot_config,
collator_pair.clone(),
Arc::new(BlockChainRpcClient::new(client.clone())),
blockchain_rpc_client,
)
.await?,
sc_network::config::NetworkBackendType::Litep2p =>
new_minimal_relay_chain::<RelayBlock, sc_network::Litep2pNetworkBackend>(
polkadot_config,
collator_pair.clone(),
Arc::new(BlockChainRpcClient::new(client.clone())),
blockchain_rpc_client,
)
.await?,
};
Expand All @@ -120,17 +121,19 @@ async fn build_interface(
}

pub async fn build_minimal_relay_chain_node_with_rpc(
polkadot_config: Configuration,
relay_chain_config: Configuration,
parachain_prometheus_registry: Option<&Registry>,
task_manager: &mut TaskManager,
relay_chain_url: Vec<Url>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
let client = cumulus_relay_chain_rpc_interface::create_client_and_start_worker(
relay_chain_url,
task_manager,
parachain_prometheus_registry,
)
.await?;

build_interface(polkadot_config, task_manager, client).await
build_interface(relay_chain_config, task_manager, client).await
}

pub async fn build_minimal_relay_chain_node_light_client(
Expand Down
2 changes: 2 additions & 0 deletions cumulus/client/relay-chain-rpc-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sp-version = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
sc-rpc-api = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
prometheus-endpoint = { workspace = true, default-features = true }

tokio = { features = ["sync"], workspace = true, default-features = true }
tokio-util = { features = ["compat"], workspace = true }
Expand All @@ -49,3 +50,4 @@ either = { workspace = true, default-features = true }
thiserror = { workspace = true }
rand = { workspace = true, default-features = true }
pin-project = { workspace = true }
prometheus = { workspace = true }
6 changes: 4 additions & 2 deletions cumulus/client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use cumulus_primitives_core::relay_chain::BlockId;
pub use url::Url;

mod light_client_worker;
mod metrics;
mod reconnecting_ws_client;
mod rpc_client;
mod tokio_platform;
Expand Down Expand Up @@ -87,12 +88,13 @@ impl RelayChainInterface for RelayChainRpcInterface {
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
let hash = match block_id {
BlockId::Hash(hash) => hash,
BlockId::Number(num) =>
BlockId::Number(num) => {
if let Some(hash) = self.rpc_client.chain_get_block_hash(Some(num)).await? {
hash
} else {
return Ok(None)
},
}
},
};
let header = self.rpc_client.chain_get_header(Some(hash)).await?;

Expand Down
49 changes: 49 additions & 0 deletions cumulus/client/relay-chain-rpc-interface/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use prometheus::{Error as PrometheusError, HistogramTimer, Registry};
use prometheus_endpoint::{HistogramOpts, HistogramVec, Opts};

/// Gathers metrics about the blockchain RPC client.
#[derive(Clone)]
pub(crate) struct RelaychainRpcMetrics {
rpc_request: HistogramVec,
}

impl RelaychainRpcMetrics {
pub(crate) fn register(registry: &Registry) -> Result<Self, PrometheusError> {
Ok(Self {
rpc_request: prometheus_endpoint::register(
HistogramVec::new(
HistogramOpts {
common_opts: Opts::new(
"relay_chain_rpc_interface",
"Tracks stats about cumulus relay chain RPC interface",
),
buckets: prometheus::exponential_buckets(0.001, 4.0, 9)
.expect("function parameters are constant and always valid; qed"),
},
&["method"],
)?,
registry,
)?,
})
}

pub(crate) fn start_request_timer(&self, method: &str) -> HistogramTimer {
self.rpc_request.with_label_values(&[method]).start_timer()
}
}
Loading

0 comments on commit aabaf76

Please sign in to comment.