mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 02:21:14 +00:00
Meter block import results via prometheus (#6025)
This commit is contained in:
committed by
GitHub
parent
302c543b49
commit
efc4849f1a
@@ -35,6 +35,7 @@ sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" }
|
||||
sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" }
|
||||
sp-timestamp = { version = "2.0.0-dev", path = "../../../primitives/timestamp" }
|
||||
sc-telemetry = { version = "2.0.0-dev", path = "../../telemetry" }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.8.0-dev"}
|
||||
|
||||
[dev-dependencies]
|
||||
sp-keyring = { version = "2.0.0-dev", path = "../../../primitives/keyring" }
|
||||
|
||||
@@ -38,6 +38,7 @@ use std::{
|
||||
use futures::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use log::{debug, info, trace};
|
||||
use prometheus_endpoint::Registry;
|
||||
|
||||
use codec::{Encode, Decode, Codec};
|
||||
|
||||
@@ -816,6 +817,7 @@ pub fn import_queue<B, I, C, P, S>(
|
||||
client: Arc<C>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: &S,
|
||||
registry: Option<&Registry>,
|
||||
) -> Result<AuraImportQueue<B, sp_api::TransactionFor<C, B>>, sp_consensus::Error> where
|
||||
B: BlockT,
|
||||
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
|
||||
@@ -842,6 +844,7 @@ pub fn import_queue<B, I, C, P, S>(
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
spawner,
|
||||
registry,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ sc-consensus-uncles = { version = "0.8.0-dev", path = "../uncles" }
|
||||
sc-consensus-slots = { version = "0.8.0-dev", path = "../slots" }
|
||||
sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" }
|
||||
fork-tree = { version = "2.0.0-dev", path = "../../../utils/fork-tree" }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.8.0-dev"}
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
parking_lot = "0.10.0"
|
||||
|
||||
@@ -109,6 +109,7 @@ use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
|
||||
use futures::prelude::*;
|
||||
use log::{debug, info, log, trace, warn};
|
||||
use prometheus_endpoint::Registry;
|
||||
use sc_consensus_slots::{
|
||||
SlotWorker, SlotInfo, SlotCompatible, StorageChanges, CheckedHeader, check_equivocation,
|
||||
};
|
||||
@@ -1291,6 +1292,7 @@ pub fn import_queue<Block: BlockT, Client, Inner>(
|
||||
client: Arc<Client>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
||||
registry: Option<&Registry>,
|
||||
) -> ClientResult<BabeImportQueue<Block, sp_api::TransactionFor<Client, Block>>> where
|
||||
Inner: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<Client, Block>>
|
||||
+ Send + Sync + 'static,
|
||||
@@ -1314,6 +1316,7 @@ pub fn import_queue<Block: BlockT, Client, Inner>(
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
spawner,
|
||||
registry,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -22,19 +22,20 @@ parking_lot = "0.10.0"
|
||||
serde = { version = "1.0", features=["derive"] }
|
||||
assert_matches = "1.3.0"
|
||||
|
||||
sc-client-api = { path = "../../../client/api" , version = "2.0.0-dev"}
|
||||
sc-transaction-pool = { path = "../../transaction-pool" , version = "2.0.0-dev"}
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" , version = "2.0.0-dev"}
|
||||
sp-consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" , version = "0.8.0-dev"}
|
||||
sp-inherents = { path = "../../../primitives/inherents" , version = "2.0.0-dev"}
|
||||
sp-runtime = { path = "../../../primitives/runtime" , version = "2.0.0-dev"}
|
||||
sp-core = { path = "../../../primitives/core" , version = "2.0.0-dev"}
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool" , version = "2.0.0-dev"}
|
||||
sc-client-api = { path = "../../../client/api", version = "2.0.0-dev" }
|
||||
sc-transaction-pool = { path = "../../transaction-pool", version = "2.0.0-dev" }
|
||||
sp-blockchain = { path = "../../../primitives/blockchain", version = "2.0.0-dev" }
|
||||
sp-consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common", version = "0.8.0-dev" }
|
||||
sp-inherents = { path = "../../../primitives/inherents", version = "2.0.0-dev" }
|
||||
sp-runtime = { path = "../../../primitives/runtime", version = "2.0.0-dev" }
|
||||
sp-core = { path = "../../../primitives/core", version = "2.0.0-dev" }
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool", version = "2.0.0-dev" }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.8.0-dev" }
|
||||
|
||||
[dev-dependencies]
|
||||
sc-basic-authorship = { path = "../../basic-authorship" , version = "0.8.0-dev"}
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" , version = "2.0.0-dev"}
|
||||
substrate-test-runtime-transaction-pool = { path = "../../../test-utils/runtime/transaction-pool" , version = "2.0.0-dev"}
|
||||
sc-basic-authorship = { path = "../../basic-authorship", version = "0.8.0-dev" }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client", version = "2.0.0-dev" }
|
||||
substrate-test-runtime-transaction-pool = { path = "../../../test-utils/runtime/transaction-pool", version = "2.0.0-dev" }
|
||||
tokio = { version = "0.2", features = ["rt-core", "macros"] }
|
||||
env_logger = "0.7.0"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
@@ -29,6 +29,7 @@ use sp_runtime::{traits::Block as BlockT, Justification};
|
||||
use sc_client_api::backend::{Backend as ClientBackend, Finalizer};
|
||||
use sc_transaction_pool::txpool;
|
||||
use std::{sync::Arc, marker::PhantomData};
|
||||
use prometheus_endpoint::Registry;
|
||||
|
||||
mod error;
|
||||
mod finalize_block;
|
||||
@@ -69,6 +70,7 @@ impl<B: BlockT> Verifier<B> for ManualSealVerifier {
|
||||
pub fn import_queue<Block, Transaction>(
|
||||
block_import: BoxBlockImport<Block, Transaction>,
|
||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
||||
registry: Option<&Registry>,
|
||||
) -> BasicQueue<Block, Transaction>
|
||||
where
|
||||
Block: BlockT,
|
||||
@@ -80,6 +82,7 @@ pub fn import_queue<Block, Transaction>(
|
||||
None,
|
||||
None,
|
||||
spawner,
|
||||
registry,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,3 +26,4 @@ log = "0.4.8"
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
sp-timestamp = { version = "2.0.0-dev", path = "../../../primitives/timestamp" }
|
||||
derive_more = "0.99.2"
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.8.0-dev"}
|
||||
|
||||
@@ -54,6 +54,7 @@ use sp_consensus::import_queue::{
|
||||
BoxBlockImport, BasicQueue, Verifier, BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
use prometheus_endpoint::Registry;
|
||||
use sc_client_api;
|
||||
use log::*;
|
||||
use sp_timestamp::{InherentError as TIError, TimestampInherentData};
|
||||
@@ -465,6 +466,7 @@ pub fn import_queue<B, Transaction, Algorithm>(
|
||||
algorithm: Algorithm,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
||||
registry: Option<&Registry>,
|
||||
) -> Result<
|
||||
PowImportQueue<B, Transaction>,
|
||||
sp_consensus::Error
|
||||
@@ -483,6 +485,7 @@ pub fn import_queue<B, Transaction, Algorithm>(
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
spawner,
|
||||
registry,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ fn build_test_full_node(config: config::NetworkConfiguration)
|
||||
None,
|
||||
None,
|
||||
&sp_core::testing::SpawnBlockingExecutor::new(),
|
||||
None,
|
||||
));
|
||||
|
||||
let worker = NetworkWorker::new(config::Params {
|
||||
|
||||
@@ -93,6 +93,7 @@ fn async_import_queue_drops() {
|
||||
None,
|
||||
None,
|
||||
&executor,
|
||||
None,
|
||||
);
|
||||
drop(queue);
|
||||
}
|
||||
|
||||
@@ -613,6 +613,7 @@ pub trait TestNetFactory: Sized {
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
&sp_core::testing::SpawnBlockingExecutor::new(),
|
||||
None,
|
||||
));
|
||||
|
||||
let listen_addr = build_multiaddr![Memory(rand::random::<u64>())];
|
||||
@@ -691,6 +692,7 @@ pub trait TestNetFactory: Sized {
|
||||
justification_import,
|
||||
finality_proof_import,
|
||||
&sp_core::testing::SpawnBlockingExecutor::new(),
|
||||
None,
|
||||
));
|
||||
|
||||
let listen_addr = build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
@@ -485,7 +485,7 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
|
||||
/// Defines which import queue to use.
|
||||
pub fn with_import_queue<UImpQu>(
|
||||
self,
|
||||
builder: impl FnOnce(&Configuration, Arc<TCl>, Option<TSc>, Arc<TExPool>, &SpawnTaskHandle)
|
||||
builder: impl FnOnce(&Configuration, Arc<TCl>, Option<TSc>, Arc<TExPool>, &SpawnTaskHandle, Option<&Registry>)
|
||||
-> Result<UImpQu, Error>
|
||||
) -> Result<ServiceBuilder<TBl, TRtApi, TCl, TFchr, TSc, UImpQu, TFprb, TFpp,
|
||||
TExPool, TRpc, Backend>, Error>
|
||||
@@ -496,6 +496,7 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
|
||||
self.select_chain.clone(),
|
||||
self.transaction_pool.clone(),
|
||||
&self.task_manager.spawn_handle(),
|
||||
self.config.prometheus_config.as_ref().map(|config| &config.registry),
|
||||
)?;
|
||||
|
||||
Ok(ServiceBuilder {
|
||||
@@ -586,6 +587,7 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
|
||||
Option<TSc>,
|
||||
Arc<TExPool>,
|
||||
&SpawnTaskHandle,
|
||||
Option<&Registry>,
|
||||
) -> Result<(UImpQu, Option<UFprb>), Error>
|
||||
) -> Result<ServiceBuilder<TBl, TRtApi, TCl, TFchr, TSc, UImpQu, UFprb, TFpp,
|
||||
TExPool, TRpc, Backend>, Error>
|
||||
@@ -598,6 +600,7 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
|
||||
self.select_chain.clone(),
|
||||
self.transaction_pool.clone(),
|
||||
&self.task_manager.spawn_handle(),
|
||||
self.config.prometheus_config.as_ref().map(|config| &config.registry),
|
||||
)?;
|
||||
|
||||
Ok(ServiceBuilder {
|
||||
@@ -630,12 +633,13 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
|
||||
Option<TSc>,
|
||||
Arc<TExPool>,
|
||||
&SpawnTaskHandle,
|
||||
Option<&Registry>,
|
||||
) -> Result<(UImpQu, UFprb), Error>
|
||||
) -> Result<ServiceBuilder<TBl, TRtApi, TCl, TFchr, TSc, UImpQu, UFprb, TFpp,
|
||||
TExPool, TRpc, Backend>, Error>
|
||||
where TSc: Clone, TFchr: Clone {
|
||||
self.with_import_queue_and_opt_fprb(|cfg, cl, b, f, sc, tx, tb|
|
||||
builder(cfg, cl, b, f, sc, tx, tb)
|
||||
self.with_import_queue_and_opt_fprb(|cfg, cl, b, f, sc, tx, tb, pr|
|
||||
builder(cfg, cl, b, f, sc, tx, tb, pr)
|
||||
.map(|(q, f)| (q, Some(f)))
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user