mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
* Add new trait to offences * companion for substrate#6069 * update to latest changes * Update Cargo.lock Co-authored-by: André Silva <andre.beat@gmail.com> Co-authored-by: Gav Wood <gavin@parity.io>
This commit is contained in:
Generated
+310
-308
File diff suppressed because it is too large
Load Diff
+14
-3
@@ -25,9 +25,10 @@ use sp_api::ProvideRuntimeApi;
|
||||
use txpool_api::TransactionPool;
|
||||
use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_consensus_babe::BabeApi;
|
||||
use sc_client_api::light::{Fetcher, RemoteBlockchain};
|
||||
use sc_consensus_babe::Epoch;
|
||||
use sp_consensus_babe::BabeApi;
|
||||
use sc_rpc::DenyUnsafe;
|
||||
|
||||
/// A type representing all RPC extensions.
|
||||
pub type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
|
||||
@@ -70,6 +71,8 @@ pub struct FullDeps<C, P, SC> {
|
||||
pub pool: Arc<P>,
|
||||
/// The SelectChain Strategy
|
||||
pub select_chain: SC,
|
||||
/// Whether to deny unsafe calls
|
||||
pub deny_unsafe: DenyUnsafe,
|
||||
/// BABE specific dependencies.
|
||||
pub babe: BabeDeps,
|
||||
/// GRANDPA specific dependencies.
|
||||
@@ -91,13 +94,14 @@ pub fn create_full<C, P, UE, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
|
||||
use frame_rpc_system::{FullSystem, SystemApi};
|
||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
||||
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
|
||||
use sc_consensus_babe_rpc::BabeRPCHandler;
|
||||
use sc_consensus_babe_rpc::BabeRpcHandler;
|
||||
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
let FullDeps {
|
||||
client,
|
||||
pool,
|
||||
select_chain,
|
||||
deny_unsafe,
|
||||
babe,
|
||||
grandpa,
|
||||
} = deps;
|
||||
@@ -119,7 +123,14 @@ pub fn create_full<C, P, UE, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
|
||||
);
|
||||
io.extend_with(
|
||||
sc_consensus_babe_rpc::BabeApi::to_delegate(
|
||||
BabeRPCHandler::new(client, shared_epoch_changes, keystore, babe_config, select_chain)
|
||||
BabeRpcHandler::new(
|
||||
client,
|
||||
shared_epoch_changes,
|
||||
keystore,
|
||||
babe_config,
|
||||
select_chain,
|
||||
deny_unsafe,
|
||||
)
|
||||
)
|
||||
);
|
||||
io.extend_with(
|
||||
|
||||
@@ -1603,7 +1603,7 @@ mod tests {
|
||||
pub struct Test;
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u32 = 250;
|
||||
pub const MaximumBlockWeight: u32 = 4 * 1024 * 1024;
|
||||
pub const MaximumBlockWeight: Weight = 4 * 1024 * 1024;
|
||||
pub const MaximumBlockLength: u32 = 4 * 1024 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
}
|
||||
@@ -1810,10 +1810,15 @@ mod tests {
|
||||
type MaxRetries = MaxRetries;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl offences::Trait for Test {
|
||||
type Event = ();
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -56,6 +56,7 @@ use sp_staking::SessionIndex;
|
||||
use frame_support::{
|
||||
parameter_types, construct_runtime, debug,
|
||||
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
|
||||
weights::Weight,
|
||||
};
|
||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
@@ -476,10 +477,15 @@ impl treasury::Trait for Runtime {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl offences::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
|
||||
@@ -58,6 +58,7 @@ use sp_staking::SessionIndex;
|
||||
use frame_support::{
|
||||
parameter_types, construct_runtime, debug,
|
||||
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
|
||||
weights::Weight,
|
||||
};
|
||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
@@ -482,10 +483,15 @@ impl treasury::Trait for Runtime {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl offences::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
|
||||
@@ -52,6 +52,7 @@ use sp_staking::SessionIndex;
|
||||
use frame_support::{
|
||||
parameter_types, construct_runtime, debug,
|
||||
traits::{KeyOwnerProofSystem, Randomness},
|
||||
weights::Weight,
|
||||
};
|
||||
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use session::historical as session_historical;
|
||||
@@ -422,10 +423,15 @@ impl system::offchain::SigningTypes for Runtime {
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl offences::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -55,6 +55,7 @@ use sp_staking::SessionIndex;
|
||||
use frame_support::{
|
||||
parameter_types, construct_runtime, debug,
|
||||
traits::{KeyOwnerProofSystem, Randomness},
|
||||
weights::Weight,
|
||||
};
|
||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
@@ -331,10 +332,15 @@ parameter_types! {
|
||||
pub const InstantAllowed: bool = true;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
impl offences::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
}
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
|
||||
+32
-17
@@ -26,7 +26,7 @@ use polkadot_primitives::{parachain, Hash, BlockId, AccountId, Nonce, Balance};
|
||||
#[cfg(feature = "full-node")]
|
||||
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
|
||||
use service::{error::Error as ServiceError, ServiceBuilder};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use sc_executor::native_executor_instance;
|
||||
use log::info;
|
||||
pub use service::{
|
||||
@@ -213,30 +213,46 @@ macro_rules! new_full_start {
|
||||
import_setup = Some((block_import, grandpa_link, babe_link));
|
||||
Ok(import_queue)
|
||||
})?
|
||||
.with_rpc_extensions(|builder| -> Result<polkadot_rpc::RpcExtension, _> {
|
||||
let babe_link = import_setup.as_ref().map(|s| &s.2)
|
||||
.expect("BabeLink is present for full services or set up faile; qed.");
|
||||
.with_rpc_extensions_builder(|builder| {
|
||||
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 shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = grandpa::SharedVoterState::empty();
|
||||
|
||||
rpc_setup = Some((shared_voter_state.clone()));
|
||||
|
||||
let babe_link = import_setup.as_ref().map(|s| &s.2)
|
||||
.expect("BabeLink is present for full services or set up faile; qed.");
|
||||
|
||||
let babe_config = babe_link.config().clone();
|
||||
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||
|
||||
let client = builder.client().clone();
|
||||
let pool = builder.pool().clone();
|
||||
let select_chain = builder.select_chain().cloned()
|
||||
.expect("SelectChain is present for full services or set up failed; qed.");
|
||||
let keystore = builder.keystore().clone();
|
||||
|
||||
Ok(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
|
||||
let deps = polkadot_rpc::FullDeps {
|
||||
client: builder.client().clone(),
|
||||
pool: builder.pool(),
|
||||
select_chain: builder.select_chain().cloned()
|
||||
.expect("SelectChain is present for full services or set up failed; qed."),
|
||||
client: client.clone(),
|
||||
pool: pool.clone(),
|
||||
select_chain: select_chain.clone(),
|
||||
deny_unsafe,
|
||||
babe: polkadot_rpc::BabeDeps {
|
||||
keystore: builder.keystore(),
|
||||
babe_config: babe::BabeLink::config(babe_link).clone(),
|
||||
shared_epoch_changes: babe::BabeLink::epoch_changes(babe_link).clone(),
|
||||
babe_config: babe_config.clone(),
|
||||
shared_epoch_changes: shared_epoch_changes.clone(),
|
||||
keystore: keystore.clone(),
|
||||
},
|
||||
grandpa: 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(deps))
|
||||
|
||||
polkadot_rpc::create_full(deps)
|
||||
})
|
||||
})?;
|
||||
|
||||
(builder, import_setup, inherent_data_providers, rpc_setup)
|
||||
@@ -593,8 +609,7 @@ macro_rules! new_light {
|
||||
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
|
||||
Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
|
||||
})?
|
||||
.with_rpc_extensions(|builder|
|
||||
-> Result<polkadot_rpc::RpcExtension, _> {
|
||||
.with_rpc_extensions(|builder| {
|
||||
let fetcher = builder.fetcher()
|
||||
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
|
||||
let remote_blockchain = builder.remote_backend()
|
||||
|
||||
Reference in New Issue
Block a user