mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31: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 txpool_api::TransactionPool;
|
||||||
use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
|
use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
|
||||||
use sp_consensus::SelectChain;
|
use sp_consensus::SelectChain;
|
||||||
|
use sp_consensus_babe::BabeApi;
|
||||||
use sc_client_api::light::{Fetcher, RemoteBlockchain};
|
use sc_client_api::light::{Fetcher, RemoteBlockchain};
|
||||||
use sc_consensus_babe::Epoch;
|
use sc_consensus_babe::Epoch;
|
||||||
use sp_consensus_babe::BabeApi;
|
use sc_rpc::DenyUnsafe;
|
||||||
|
|
||||||
/// 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>;
|
||||||
@@ -70,6 +71,8 @@ pub struct FullDeps<C, P, SC> {
|
|||||||
pub pool: Arc<P>,
|
pub pool: Arc<P>,
|
||||||
/// The SelectChain Strategy
|
/// The SelectChain Strategy
|
||||||
pub select_chain: SC,
|
pub select_chain: SC,
|
||||||
|
/// Whether to deny unsafe calls
|
||||||
|
pub deny_unsafe: DenyUnsafe,
|
||||||
/// BABE specific dependencies.
|
/// BABE specific dependencies.
|
||||||
pub babe: BabeDeps,
|
pub babe: BabeDeps,
|
||||||
/// GRANDPA specific dependencies.
|
/// 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 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};
|
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 mut io = jsonrpc_core::IoHandler::default();
|
||||||
let FullDeps {
|
let FullDeps {
|
||||||
client,
|
client,
|
||||||
pool,
|
pool,
|
||||||
select_chain,
|
select_chain,
|
||||||
|
deny_unsafe,
|
||||||
babe,
|
babe,
|
||||||
grandpa,
|
grandpa,
|
||||||
} = deps;
|
} = deps;
|
||||||
@@ -119,7 +123,14 @@ pub fn create_full<C, P, UE, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
|
|||||||
);
|
);
|
||||||
io.extend_with(
|
io.extend_with(
|
||||||
sc_consensus_babe_rpc::BabeApi::to_delegate(
|
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(
|
io.extend_with(
|
||||||
|
|||||||
@@ -1603,7 +1603,7 @@ mod tests {
|
|||||||
pub struct Test;
|
pub struct Test;
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u32 = 250;
|
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 MaximumBlockLength: u32 = 4 * 1024 * 1024;
|
||||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||||
}
|
}
|
||||||
@@ -1810,10 +1810,15 @@ mod tests {
|
|||||||
type MaxRetries = MaxRetries;
|
type MaxRetries = MaxRetries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||||
|
}
|
||||||
|
|
||||||
impl offences::Trait for Test {
|
impl offences::Trait for Test {
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||||
type OnOffenceHandler = Staking;
|
type OnOffenceHandler = Staking;
|
||||||
|
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ use sp_staking::SessionIndex;
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
parameter_types, construct_runtime, debug,
|
parameter_types, construct_runtime, debug,
|
||||||
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
|
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
|
||||||
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||||
@@ -476,10 +477,15 @@ impl treasury::Trait for Runtime {
|
|||||||
type ModuleId = TreasuryModuleId;
|
type ModuleId = TreasuryModuleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||||
|
}
|
||||||
|
|
||||||
impl offences::Trait for Runtime {
|
impl offences::Trait for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||||
type OnOffenceHandler = Staking;
|
type OnOffenceHandler = Staking;
|
||||||
|
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl authority_discovery::Trait for Runtime {}
|
impl authority_discovery::Trait for Runtime {}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ use sp_staking::SessionIndex;
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
parameter_types, construct_runtime, debug,
|
parameter_types, construct_runtime, debug,
|
||||||
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
|
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
|
||||||
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||||
@@ -482,10 +483,15 @@ impl treasury::Trait for Runtime {
|
|||||||
type ModuleId = TreasuryModuleId;
|
type ModuleId = TreasuryModuleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||||
|
}
|
||||||
|
|
||||||
impl offences::Trait for Runtime {
|
impl offences::Trait for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||||
type OnOffenceHandler = Staking;
|
type OnOffenceHandler = Staking;
|
||||||
|
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl authority_discovery::Trait for Runtime {}
|
impl authority_discovery::Trait for Runtime {}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ use sp_staking::SessionIndex;
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
parameter_types, construct_runtime, debug,
|
parameter_types, construct_runtime, debug,
|
||||||
traits::{KeyOwnerProofSystem, Randomness},
|
traits::{KeyOwnerProofSystem, Randomness},
|
||||||
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||||
use session::historical as session_historical;
|
use session::historical as session_historical;
|
||||||
@@ -422,10 +423,15 @@ impl system::offchain::SigningTypes for Runtime {
|
|||||||
type Signature = Signature;
|
type Signature = Signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||||
|
}
|
||||||
|
|
||||||
impl offences::Trait for Runtime {
|
impl offences::Trait for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||||
type OnOffenceHandler = Staking;
|
type OnOffenceHandler = Staking;
|
||||||
|
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ use sp_staking::SessionIndex;
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
parameter_types, construct_runtime, debug,
|
parameter_types, construct_runtime, debug,
|
||||||
traits::{KeyOwnerProofSystem, Randomness},
|
traits::{KeyOwnerProofSystem, Randomness},
|
||||||
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use im_online::sr25519::AuthorityId as ImOnlineId;
|
use im_online::sr25519::AuthorityId as ImOnlineId;
|
||||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||||
@@ -331,10 +332,15 @@ parameter_types! {
|
|||||||
pub const InstantAllowed: bool = true;
|
pub const InstantAllowed: bool = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
|
||||||
|
}
|
||||||
|
|
||||||
impl offences::Trait for Runtime {
|
impl offences::Trait for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||||
type OnOffenceHandler = Staking;
|
type OnOffenceHandler = Staking;
|
||||||
|
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl authority_discovery::Trait for Runtime {}
|
impl authority_discovery::Trait for Runtime {}
|
||||||
|
|||||||
+40
-25
@@ -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, SharedVoterState};
|
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
use log::info;
|
use log::info;
|
||||||
pub use service::{
|
pub use service::{
|
||||||
@@ -213,30 +213,46 @@ macro_rules! new_full_start {
|
|||||||
import_setup = Some((block_import, grandpa_link, babe_link));
|
import_setup = Some((block_import, grandpa_link, babe_link));
|
||||||
Ok(import_queue)
|
Ok(import_queue)
|
||||||
})?
|
})?
|
||||||
.with_rpc_extensions(|builder| -> Result<polkadot_rpc::RpcExtension, _> {
|
.with_rpc_extensions_builder(|builder| {
|
||||||
let babe_link = import_setup.as_ref().map(|s| &s.2)
|
|
||||||
.expect("BabeLink is present for full services or set up faile; qed.");
|
|
||||||
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
|
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
|
||||||
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
|
.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 deps = polkadot_rpc::FullDeps {
|
let shared_voter_state = grandpa::SharedVoterState::empty();
|
||||||
client: builder.client().clone(),
|
|
||||||
pool: builder.pool(),
|
rpc_setup = Some((shared_voter_state.clone()));
|
||||||
select_chain: builder.select_chain().cloned()
|
|
||||||
.expect("SelectChain is present for full services or set up failed; qed."),
|
let babe_link = import_setup.as_ref().map(|s| &s.2)
|
||||||
babe: polkadot_rpc::BabeDeps {
|
.expect("BabeLink is present for full services or set up faile; qed.");
|
||||||
keystore: builder.keystore(),
|
|
||||||
babe_config: babe::BabeLink::config(babe_link).clone(),
|
let babe_config = babe_link.config().clone();
|
||||||
shared_epoch_changes: babe::BabeLink::epoch_changes(babe_link).clone(),
|
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||||
},
|
|
||||||
grandpa: polkadot_rpc::GrandpaDeps {
|
let client = builder.client().clone();
|
||||||
shared_voter_state: shared_voter_state.clone(),
|
let pool = builder.pool().clone();
|
||||||
shared_authority_set: shared_authority_set.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();
|
||||||
rpc_setup = Some((shared_voter_state));
|
|
||||||
Ok(polkadot_rpc::create_full(deps))
|
Ok(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
|
||||||
|
let deps = polkadot_rpc::FullDeps {
|
||||||
|
client: client.clone(),
|
||||||
|
pool: pool.clone(),
|
||||||
|
select_chain: select_chain.clone(),
|
||||||
|
deny_unsafe,
|
||||||
|
babe: polkadot_rpc::BabeDeps {
|
||||||
|
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(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
polkadot_rpc::create_full(deps)
|
||||||
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
(builder, import_setup, inherent_data_providers, rpc_setup)
|
(builder, import_setup, inherent_data_providers, rpc_setup)
|
||||||
@@ -593,8 +609,7 @@ macro_rules! new_light {
|
|||||||
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
|
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
|
||||||
Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
|
Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
|
||||||
})?
|
})?
|
||||||
.with_rpc_extensions(|builder|
|
.with_rpc_extensions(|builder| {
|
||||||
-> Result<polkadot_rpc::RpcExtension, _> {
|
|
||||||
let fetcher = builder.fetcher()
|
let fetcher = builder.fetcher()
|
||||||
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
|
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
|
||||||
let remote_blockchain = builder.remote_backend()
|
let remote_blockchain = builder.remote_backend()
|
||||||
|
|||||||
Reference in New Issue
Block a user