Skip to content

Commit

Permalink
Backport from polkadot staging 3 (#2700)
Browse files Browse the repository at this point in the history
* Remove Woococo related stuff (#2692)

* Remove Woococo related stuff

* More removes

* Compilation

* Added equvocation for Ro/We

* We need chain-westend primitives

* Porting changes from polkadot-sdk to polkadot-staging - before update subtree with removed wococo stuff (#2696)

* Porting changes from `polkadot-sdk` to `polkadot-staging`

* Bump polkadot-sdk to #ae1bdcfb91a26c5f65c5ca534aa8a04523ca2277

* Cargo.lock

* DefaultConfig

* DefaultConfig for `frame_system::Config`

* Revert back

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
  • Loading branch information
svyatonik and bkontur authored Nov 14, 2023
1 parent c868a5e commit 54eb4cd
Show file tree
Hide file tree
Showing 50 changed files with 524 additions and 1,807 deletions.
678 changes: 433 additions & 245 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ members = [
"primitives/beefy",
"primitives/chain-asset-hub-rococo",
"primitives/chain-asset-hub-westend",
"primitives/chain-asset-hub-wococo",
"primitives/chain-bridge-hub-cumulus",
"primitives/chain-bridge-hub-kusama",
"primitives/chain-bridge-hub-polkadot",
"primitives/chain-bridge-hub-rococo",
"primitives/chain-bridge-hub-westend",
"primitives/chain-bridge-hub-wococo",
"primitives/chain-kusama",
"primitives/chain-polkadot",
"primitives/chain-polkadot-bulletin",
"primitives/chain-rococo",
"primitives/chain-westend",
"primitives/chain-wococo",
"primitives/header-chain",
"primitives/messages",
"primitives/parachains",
Expand All @@ -45,14 +42,12 @@ members = [
"relays/client-bridge-hub-polkadot",
"relays/client-bridge-hub-rococo",
"relays/client-bridge-hub-westend",
"relays/client-bridge-hub-wococo",
"relays/client-kusama",
"relays/client-polkadot",
"relays/client-polkadot-bulletin",
"relays/client-rococo",
"relays/client-substrate",
"relays/client-westend",
"relays/client-wococo",
"relays/equivocation",
"relays/finality",
"relays/lib-substrate-relay",
Expand Down
35 changes: 4 additions & 31 deletions modules/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ use crate::{
use bp_beefy::{BeefyValidatorSignatureOf, ChainWithBeefy, Commitment, MmrDataOrHash};
use bp_runtime::{BasicOperatingMode, Chain, ChainId};
use codec::Encode;
use frame_support::{construct_runtime, parameter_types, traits::ConstU64, weights::Weight};
use frame_support::{construct_runtime, derive_impl, weights::Weight};
use sp_core::{sr25519::Signature, Pair};
use sp_runtime::{
testing::{Header, H256},
traits::{BlakeTwo256, Hash, IdentityLookup},
Perbill, StateVersion,
traits::{BlakeTwo256, Hash},
StateVersion,
};

pub use sp_consensus_beefy::ecdsa_crypto::{AuthorityId as BeefyId, Pair as BeefyPair};
Expand Down Expand Up @@ -67,36 +67,9 @@ construct_runtime! {
}
}

parameter_types! {
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Block = Block;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = TestAccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = ();
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

impl beefy::Config for TestRuntime {
Expand Down
41 changes: 3 additions & 38 deletions modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@
use bp_header_chain::ChainWithGrandpa;
use bp_runtime::{Chain, ChainId};
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU32, ConstU64, Hooks},
weights::Weight,
construct_runtime, derive_impl, parameter_types, traits::Hooks, weights::Weight,
};
use sp_core::sr25519::Signature;
use sp_runtime::{
testing::H256,
traits::{BlakeTwo256, IdentityLookup},
Perbill, StateVersion,
};
use sp_runtime::StateVersion;

pub type AccountId = u64;
pub type TestHeader = sp_runtime::testing::Header;
Expand All @@ -49,43 +43,14 @@ construct_runtime! {
}
}

parameter_types! {
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

parameter_types! {
pub const MaxFreeMandatoryHeadersPerBlock: u32 = 2;
pub const HeadersToKeep: u32 = 5;
pub const SessionLength: u64 = 5;
pub const NumValidators: u32 = 5;
}

impl grandpa::Config for TestRuntime {
Expand Down
2 changes: 0 additions & 2 deletions modules/messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ bp-runtime = { path = "../../primitives/runtime", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true }
Expand All @@ -49,7 +48,6 @@ std = [
"log/std",
"num-traits/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-trie/std",
Expand Down
54 changes: 8 additions & 46 deletions modules/messages/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ use bp_runtime::{
};
use codec::{Decode, Encode};
use frame_support::{
parameter_types,
traits::ConstU64,
derive_impl,
weights::{constants::RocksDbWeight, Weight},
};
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{
testing::Header as SubstrateHeader,
traits::{BlakeTwo256, ConstU32, IdentityLookup},
BuildStorage, Perbill, StateVersion,
testing::{Header as SubstrateHeader, H256},
traits::{BlakeTwo256, ConstU32},
BuildStorage, StateVersion,
};
use std::{collections::VecDeque, ops::RangeInclusive};

Expand Down Expand Up @@ -161,55 +159,19 @@ frame_support::construct_runtime! {
}
}

parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}

pub type DbWeight = RocksDbWeight;

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
type DbWeight = DbWeight;
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)]
impl pallet_balances::Config for TestRuntime {
type MaxLocks = ();
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = frame_system::Pallet<TestRuntime>;
type WeightInfo = ();
type MaxReserves = ();
type ReserveIdentifier = ();
type RuntimeHoldReason = RuntimeHoldReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type ReserveIdentifier = [u8; 8];
type AccountStore = System;
}

impl pallet_bridge_grandpa::Config for TestRuntime {
Expand Down
41 changes: 6 additions & 35 deletions modules/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
use bp_header_chain::ChainWithGrandpa;
use bp_polkadot_core::parachains::ParaId;
use bp_runtime::{Chain, ChainId, Parachain};
use frame_support::{construct_runtime, parameter_types, traits::ConstU32, weights::Weight};
use frame_support::{
construct_runtime, derive_impl, parameter_types, traits::ConstU32, weights::Weight,
};
use sp_runtime::{
testing::H256,
traits::{BlakeTwo256, Header as HeaderT, IdentityLookup},
MultiSignature, Perbill, StateVersion,
traits::{BlakeTwo256, Header as HeaderT},
MultiSignature, StateVersion,
};

use crate as pallet_bridge_parachains;

pub type AccountId = u64;
pub type TestNumber = u64;

pub type RelayBlockHeader =
sp_runtime::generic::Header<crate::RelayBlockNumber, crate::RelayBlockHasher>;
Expand Down Expand Up @@ -168,42 +169,12 @@ construct_runtime! {
}
}

parameter_types! {
pub const BlockHashCount: TestNumber = 250;
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Block = Block;
type Hash = H256;
type Hashing = RegularParachainHasher;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

parameter_types! {
pub const SessionLength: u64 = 5;
pub const NumValidators: u32 = 5;
pub const HeadersToKeep: u32 = 5;
}

Expand Down
1 change: 0 additions & 1 deletion modules/relayers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-test-utils = { path = "../../primitives/test-utils" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }

[features]
Expand Down
42 changes: 7 additions & 35 deletions modules/relayers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ use bp_relayers::{
use bp_runtime::{messages::MessageDispatchResult, Chain, ChainId, Parachain};
use codec::Encode;
use frame_support::{
parameter_types,
derive_impl, parameter_types,
traits::fungible::Mutate,
weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight},
};
use pallet_transaction_payment::Multiplier;
use sp_core::{ConstU64, ConstU8, H256};
use sp_runtime::{
traits::{BlakeTwo256, ConstU32, IdentityLookup},
testing::H256,
traits::{BlakeTwo256, ConstU32, ConstU64, ConstU8},
transaction_validity::TransactionPriority,
BuildStorage, FixedPointNumber, Perquintill, StateVersion,
};
Expand Down Expand Up @@ -202,30 +202,12 @@ parameter_types! {
pub PriorityBoostForActiveLaneRelayer: TransactionPriority = 1;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Block = ThisChainBlock;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = ThisChainAccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = frame_support::traits::ConstU32<250>;
type Version = ();
type PalletInfo = PalletInfo;
type BlockHashCount = ConstU32<256>;
type AccountData = pallet_balances::AccountData<ThisChainBalance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type BaseCallFilter = frame_support::traits::Everything;
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
type DbWeight = DbWeight;
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

impl pallet_utility::Config for TestRuntime {
Expand All @@ -235,20 +217,10 @@ impl pallet_utility::Config for TestRuntime {
type WeightInfo = ();
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)]
impl pallet_balances::Config for TestRuntime {
type MaxLocks = ();
type Balance = ThisChainBalance;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Pallet<TestRuntime>;
type WeightInfo = ();
type MaxReserves = ConstU32<1>;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type AccountStore = System;
}

impl pallet_transaction_payment::Config for TestRuntime {
Expand Down
Loading

0 comments on commit 54eb4cd

Please sign in to comment.