mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 23:01:01 +00:00
* Companion PR for Substrate #5375 * fix compilation * Update rpc/Cargo.toml * update substrate Co-authored-by: André Silva <andre.beat@gmail.com> Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
This commit is contained in:
Generated
+149
-128
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,8 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "mas
|
|||||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
txpool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master" }
|
txpool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" }
|
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
+22
-2
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use polkadot_primitives::{Block, AccountId, Nonce, Balance};
|
use polkadot_primitives::{Block, BlockNumber, AccountId, Nonce, Balance, Hash};
|
||||||
use sp_api::ProvideRuntimeApi;
|
use sp_api::ProvideRuntimeApi;
|
||||||
use txpool_api::TransactionPool;
|
use txpool_api::TransactionPool;
|
||||||
use sp_blockchain::HeaderBackend;
|
use sp_blockchain::HeaderBackend;
|
||||||
@@ -29,8 +29,16 @@ use sc_client_api::light::{Fetcher, RemoteBlockchain};
|
|||||||
/// A type representing all RPC extensions.
|
/// A type representing all RPC extensions.
|
||||||
pub type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
|
pub type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
|
||||||
|
|
||||||
|
/// Dependencies for GRANDPA
|
||||||
|
pub struct GrandpaDeps {
|
||||||
|
/// Voting round info.
|
||||||
|
pub shared_voter_state: sc_finality_grandpa::SharedVoterState,
|
||||||
|
/// Authority set info.
|
||||||
|
pub shared_authority_set: sc_finality_grandpa::SharedAuthoritySet<Hash, BlockNumber>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Instantiate all RPC extensions.
|
/// Instantiate all RPC extensions.
|
||||||
pub fn create_full<C, P, UE>(client: Arc<C>, pool: Arc<P>) -> RpcExtension where
|
pub fn create_full<C, P, UE>(client: Arc<C>, pool: Arc<P>, grandpa_deps: GrandpaDeps) -> RpcExtension where
|
||||||
C: ProvideRuntimeApi<Block>,
|
C: ProvideRuntimeApi<Block>,
|
||||||
C: HeaderBackend<Block>,
|
C: HeaderBackend<Block>,
|
||||||
C: Send + Sync + 'static,
|
C: Send + Sync + 'static,
|
||||||
@@ -41,14 +49,26 @@ pub fn create_full<C, P, UE>(client: Arc<C>, pool: Arc<P>) -> RpcExtension where
|
|||||||
{
|
{
|
||||||
use frame_rpc_system::{FullSystem, SystemApi};
|
use frame_rpc_system::{FullSystem, SystemApi};
|
||||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
||||||
|
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
|
||||||
|
|
||||||
let mut io = jsonrpc_core::IoHandler::default();
|
let mut io = jsonrpc_core::IoHandler::default();
|
||||||
|
let GrandpaDeps {
|
||||||
|
shared_voter_state,
|
||||||
|
shared_authority_set,
|
||||||
|
} = grandpa_deps;
|
||||||
|
|
||||||
io.extend_with(
|
io.extend_with(
|
||||||
SystemApi::to_delegate(FullSystem::new(client.clone(), pool))
|
SystemApi::to_delegate(FullSystem::new(client.clone(), pool))
|
||||||
);
|
);
|
||||||
io.extend_with(
|
io.extend_with(
|
||||||
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
|
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
|
||||||
);
|
);
|
||||||
|
io.extend_with(
|
||||||
|
GrandpaApi::to_delegate(GrandpaRpcHandler::new(
|
||||||
|
shared_authority_set,
|
||||||
|
shared_voter_state,
|
||||||
|
))
|
||||||
|
);
|
||||||
io
|
io
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use polkadot_primitives::{parachain, Hash, BlockId, AccountId, Nonce, Balance};
|
|||||||
#[cfg(feature = "full-node")]
|
#[cfg(feature = "full-node")]
|
||||||
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
|
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
|
||||||
use service::{error::Error as ServiceError, ServiceBuilder};
|
use service::{error::Error as ServiceError, ServiceBuilder};
|
||||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState};
|
||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
use log::info;
|
use log::info;
|
||||||
pub use service::{
|
pub use service::{
|
||||||
@@ -151,6 +151,7 @@ macro_rules! new_full_start {
|
|||||||
set_prometheus_registry(&mut $config)?;
|
set_prometheus_registry(&mut $config)?;
|
||||||
|
|
||||||
let mut import_setup = None;
|
let mut import_setup = None;
|
||||||
|
let mut rpc_setup = None;
|
||||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||||
let builder = service::ServiceBuilder::new_full::<
|
let builder = service::ServiceBuilder::new_full::<
|
||||||
Block, $runtime, $executor
|
Block, $runtime, $executor
|
||||||
@@ -203,10 +204,19 @@ macro_rules! new_full_start {
|
|||||||
Ok(import_queue)
|
Ok(import_queue)
|
||||||
})?
|
})?
|
||||||
.with_rpc_extensions(|builder| -> Result<polkadot_rpc::RpcExtension, _> {
|
.with_rpc_extensions(|builder| -> Result<polkadot_rpc::RpcExtension, _> {
|
||||||
Ok(polkadot_rpc::create_full(builder.client().clone(), builder.pool()))
|
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
|
||||||
|
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
|
||||||
|
let shared_authority_set = grandpa_link.shared_authority_set();
|
||||||
|
let shared_voter_state = SharedVoterState::empty();
|
||||||
|
let grandpa_deps = polkadot_rpc::GrandpaDeps {
|
||||||
|
shared_voter_state: shared_voter_state.clone(),
|
||||||
|
shared_authority_set: shared_authority_set.clone(),
|
||||||
|
};
|
||||||
|
rpc_setup = Some((shared_voter_state));
|
||||||
|
Ok(polkadot_rpc::create_full(builder.client().clone(), builder.pool(), grandpa_deps))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
(builder, import_setup, inherent_data_providers)
|
(builder, import_setup, inherent_data_providers, rpc_setup)
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +251,8 @@ macro_rules! new_full {
|
|||||||
let authority_discovery_enabled = $authority_discovery_enabled;
|
let authority_discovery_enabled = $authority_discovery_enabled;
|
||||||
let slot_duration = $slot_duration;
|
let slot_duration = $slot_duration;
|
||||||
|
|
||||||
let (builder, mut import_setup, inherent_data_providers) = new_full_start!($config, $runtime, $dispatch);
|
let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) =
|
||||||
|
new_full_start!($config, $runtime, $dispatch);
|
||||||
|
|
||||||
let backend = builder.backend().clone();
|
let backend = builder.backend().clone();
|
||||||
|
|
||||||
@@ -255,6 +266,9 @@ macro_rules! new_full {
|
|||||||
let (block_import, link_half, babe_link) = import_setup.take()
|
let (block_import, link_half, babe_link) = import_setup.take()
|
||||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||||
|
|
||||||
|
let shared_voter_state = rpc_setup.take()
|
||||||
|
.expect("The SharedVoterState is present for Full Services or setup failed before. qed");
|
||||||
|
|
||||||
let client = service.client();
|
let client = service.client();
|
||||||
let known_oracle = client.clone();
|
let known_oracle = client.clone();
|
||||||
|
|
||||||
@@ -470,6 +484,7 @@ macro_rules! new_full {
|
|||||||
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
|
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
|
||||||
voting_rule,
|
voting_rule,
|
||||||
prometheus_registry: service.prometheus_registry(),
|
prometheus_registry: service.prometheus_registry(),
|
||||||
|
shared_voter_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
service.spawn_essential_task(
|
service.spawn_essential_task(
|
||||||
|
|||||||
Reference in New Issue
Block a user