mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
runtime: remove mmr and beefy from westend runtime (#2916)
* runtime: remove mmr and beefy from westend runtime * runtime: westend: remove pallet_beefy config * node: only start beefy gadget on rococo * node: remove beefy keys from westend chain spec
This commit is contained in:
@@ -35,7 +35,6 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch =
|
||||
pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
@@ -49,7 +48,6 @@ pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "m
|
||||
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
@@ -128,8 +126,6 @@ std = [
|
||||
"pallet-im-online/std",
|
||||
"pallet-indices/std",
|
||||
"pallet-membership/std",
|
||||
"pallet-beefy/std",
|
||||
"pallet-mmr/std",
|
||||
"pallet-mmr-primitives/std",
|
||||
"beefy-primitives/std",
|
||||
"pallet-multisig/std",
|
||||
@@ -179,7 +175,6 @@ runtime-benchmarks = [
|
||||
"pallet-identity/runtime-benchmarks",
|
||||
"pallet-im-online/runtime-benchmarks",
|
||||
"pallet-indices/runtime-benchmarks",
|
||||
"pallet-mmr/runtime-benchmarks",
|
||||
"pallet-multisig/runtime-benchmarks",
|
||||
"pallet-proxy/runtime-benchmarks",
|
||||
"pallet-scheduler/runtime-benchmarks",
|
||||
|
||||
@@ -31,7 +31,6 @@ use primitives::v1::{
|
||||
InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
|
||||
};
|
||||
use runtime_common::{
|
||||
mmr as mmr_common,
|
||||
SlowAdjustingFeeUpdate, CurrencyToVote,
|
||||
impls::ToAuthor,
|
||||
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
|
||||
@@ -43,7 +42,7 @@ use sp_runtime::{
|
||||
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
|
||||
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
|
||||
traits::{
|
||||
Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
|
||||
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
|
||||
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
|
||||
},
|
||||
};
|
||||
@@ -91,7 +90,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("westend"),
|
||||
impl_name: create_runtime_str!("parity-westend"),
|
||||
authoring_version: 2,
|
||||
// NOTE: see https://github.com/paritytech/polkadot/wiki/Westend
|
||||
spec_version: 51,
|
||||
impl_version: 0,
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
@@ -269,18 +267,6 @@ parameter_types! {
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
// TODO [ToDr] Remove while BEEFY runtime upgrade is done.
|
||||
impl_opaque_keys! {
|
||||
pub struct OldSessionKeys {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub grandpa: Grandpa,
|
||||
@@ -289,28 +275,6 @@ impl_opaque_keys! {
|
||||
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
pub beefy: Beefy,
|
||||
}
|
||||
}
|
||||
|
||||
fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys {
|
||||
SessionKeys {
|
||||
grandpa: old.grandpa,
|
||||
babe: old.babe,
|
||||
im_online: old.im_online,
|
||||
para_validator: old.para_validator,
|
||||
para_assignment: old.para_assignment,
|
||||
authority_discovery: old.authority_discovery,
|
||||
beefy: runtime_common::dummy_beefy_id_from_account_id(v),
|
||||
}
|
||||
}
|
||||
|
||||
// When this is removed, should also remove `OldSessionKeys`.
|
||||
pub struct UpgradeSessionKeys;
|
||||
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
|
||||
fn on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
|
||||
Perbill::from_percent(50) * BlockWeights::get().max_block
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,24 +586,6 @@ impl pallet_sudo::Config for Runtime {
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
impl pallet_beefy::Config for Runtime {
|
||||
type AuthorityId = BeefyId;
|
||||
}
|
||||
|
||||
impl pallet_mmr::Config for Runtime {
|
||||
const INDEXING_PREFIX: &'static [u8] = b"mmr";
|
||||
type Hashing = Keccak256;
|
||||
type Hash = <Keccak256 as sp_runtime::traits::Hash>::Output;
|
||||
type OnNewRoot = mmr_common::DepositBeefyDigest<Runtime>;
|
||||
type WeightInfo = ();
|
||||
type LeafData = mmr_common::Pallet<Runtime>;
|
||||
}
|
||||
|
||||
impl mmr_common::Config for Runtime {
|
||||
type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys;
|
||||
type ParachainHeads = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// One storage item; key size 32, value size 8; .
|
||||
pub const ProxyDepositBase: Balance = deposit(1, 8);
|
||||
@@ -798,11 +744,6 @@ construct_runtime! {
|
||||
|
||||
// Election pallet. Only works with staking, but placed here to maintain indices.
|
||||
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24,
|
||||
|
||||
// Bridges support.
|
||||
Mmr: pallet_mmr::{Pallet, Call, Storage} = 28,
|
||||
Beefy: pallet_beefy::{Pallet, Config<T>, Storage} = 29,
|
||||
MmrLeaf: mmr_common::{Pallet, Storage} = 30,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,7 +782,7 @@ pub type Executive = frame_executive::Executive<
|
||||
frame_system::ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllPallets,
|
||||
UpgradeSessionKeys,
|
||||
(),
|
||||
>;
|
||||
/// The payload being signed in transactions.
|
||||
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
|
||||
@@ -976,40 +917,33 @@ sp_api::impl_runtime_apis! {
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
|
||||
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
|
||||
Beefy::validator_set()
|
||||
// dummy implementation due to lack of BEEFY pallet.
|
||||
beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_mmr_primitives::MmrApi<Block, Hash> for Runtime {
|
||||
fn generate_proof(leaf_index: u64)
|
||||
fn generate_proof(_leaf_index: u64)
|
||||
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
|
||||
{
|
||||
Mmr::generate_proof(leaf_index)
|
||||
.map(|(leaf, proof)| (mmr::EncodableOpaqueLeaf::from_leaf(&leaf), proof))
|
||||
// dummy implementation due to lack of MMR pallet.
|
||||
Err(mmr::Error::GenerateProof)
|
||||
}
|
||||
|
||||
fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof<Hash>)
|
||||
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
|
||||
-> Result<(), mmr::Error>
|
||||
{
|
||||
pub type Leaf = <
|
||||
<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider
|
||||
>::LeafData;
|
||||
|
||||
let leaf: Leaf = leaf
|
||||
.into_opaque_leaf()
|
||||
.try_decode()
|
||||
.ok_or(mmr::Error::Verify)?;
|
||||
Mmr::verify_leaf(leaf, proof)
|
||||
// dummy implementation due to lack of MMR pallet.
|
||||
Err(mmr::Error::Verify)
|
||||
}
|
||||
|
||||
fn verify_proof_stateless(
|
||||
root: Hash,
|
||||
leaf: mmr::EncodableOpaqueLeaf,
|
||||
proof: mmr::Proof<Hash>
|
||||
_root: Hash,
|
||||
_leaf: mmr::EncodableOpaqueLeaf,
|
||||
_proof: mmr::Proof<Hash>
|
||||
) -> Result<(), mmr::Error> {
|
||||
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing;
|
||||
let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf());
|
||||
pallet_mmr::verify_leaf_proof::<MmrHashing, _>(root, node, proof)
|
||||
// dummy implementation due to lack of MMR pallet.
|
||||
Err(mmr::Error::Verify)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user