Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Moves Block to frame_system instead of construct_runtime and removes Header and BlockNumber #2790

Merged
merged 33 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e8039f9
Fixes
gupnik Jun 27, 2023
7feb684
Removes unused import
gupnik Jun 28, 2023
8d79fc4
Uses Block and removes BlockNumber/Header from Chain
gupnik Jun 28, 2023
9d0ae3c
Fixes bridges
gupnik Jun 28, 2023
7c3078a
Fixes
gupnik Jun 28, 2023
49d5cdf
Removes unused import
gupnik Jun 28, 2023
acc6d51
Fixes build
gupnik Jun 28, 2023
acde948
Uses correct RelayBlock
gupnik Jun 28, 2023
2a281d6
Minor fix
gupnik Jun 28, 2023
1a27d2f
Fixes glutton-kusama
gupnik Jun 28, 2023
e36976f
Uses correct RelayBlock
gupnik Jun 28, 2023
0b817d5
Minor fix
gupnik Jun 28, 2023
6269914
Merge branch 'master' of github.com:paritytech/cumulus into gupnik/cr…
gupnik Jun 28, 2023
a05bbba
Fixes benchmark for pallet-bridge-parachains
gupnik Jun 29, 2023
1f89fa7
Adds appropriate constraints
gupnik Jun 29, 2023
d15fff0
Minor fixes
gupnik Jun 29, 2023
895c8fe
Removes unused import
gupnik Jun 29, 2023
0173ae2
Fixes integrity tests
gupnik Jun 29, 2023
5fcfab5
Minor fixes
gupnik Jun 29, 2023
bae8a0c
Updates trait bounds
gupnik Jul 11, 2023
9596411
Merge branch 'master' of github.com:paritytech/cumulus into gupnik/cr…
gupnik Jul 11, 2023
838e528
Uses custom bound for AsPrimitive
gupnik Jul 11, 2023
0b0f42f
Fixes trait bounds
gupnik Jul 11, 2023
c933bc2
Revert "Fixes trait bounds"
gupnik Jul 11, 2023
6c38e45
Revert "Uses custom bound for AsPrimitive"
gupnik Jul 11, 2023
c1b16ff
No AsPrimitive trait bound for now
gupnik Jul 11, 2023
f1facb6
Removes bounds on Number
gupnik Jul 12, 2023
8862191
Merge branch 'master' of github.com:paritytech/cumulus into gupnik/cr…
gupnik Jul 12, 2023
5d89f5f
Merge branch 'master' of github.com:paritytech/cumulus into gupnik/cr…
gupnik Jul 13, 2023
033de71
update lockfile for {"substrate", "polkadot"}
Jul 13, 2023
68ff02a
Formatting
gupnik Jul 13, 2023
d61bac6
".git/.scripts/commands/fmt/fmt.sh"
Jul 13, 2023
58f509a
Minor fix
gupnik Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ pub type ThisChainHasher = BlakeTwo256;
pub type ThisChainRuntimeCall = RuntimeCall;
/// Runtime call origin at `ThisChain`.
pub type ThisChainCallOrigin = RuntimeOrigin;
/// Header of `ThisChain`.
pub type ThisChainHeader = sp_runtime::generic::Header<ThisChainBlockNumber, ThisChainHasher>;
/// Block of `ThisChain`.
// Block of `ThisChain`.
pub type ThisChainBlock = frame_system::mocking::MockBlock<TestRuntime>;
/// Unchecked extrinsic of `ThisChain`.
pub type ThisChainUncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;

/// Account identifier at the `BridgedChain`.
pub type BridgedChainAccountId = u128;
Expand All @@ -80,9 +76,8 @@ pub type BridgedChainBlockNumber = u32;
pub type BridgedChainHash = H256;
/// Hasher at the `BridgedChain`.
pub type BridgedChainHasher = BlakeTwo256;
/// Header of the `BridgedChain`.
pub type BridgedChainHeader =
sp_runtime::generic::Header<BridgedChainBlockNumber, BridgedChainHasher>;
/// Block of the `BridgedChain`.
pub type BridgedChainBlock = frame_system::mocking::MockBlock<TestRuntime>;

/// Rewards payment procedure.
pub type TestPaymentProcedure = PayRewardFromAccount<Balances, ThisChainAccountId>;
Expand All @@ -108,10 +103,7 @@ pub const BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT: usize = 2048;
pub const BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE: u32 = 1024;

frame_support::construct_runtime! {
pub enum TestRuntime where
Block = ThisChainBlock,
NodeBlock = ThisChainBlock,
UncheckedExtrinsic = ThisChainUncheckedExtrinsic,
pub enum TestRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Utility: pallet_utility,
Expand Down Expand Up @@ -155,7 +147,7 @@ impl frame_system::Config for TestRuntime {
type Hashing = ThisChainHasher;
type AccountId = ThisChainAccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = ThisChainHeader;
type Block = ThisChainBlock;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU32<250>;
type Version = ();
Expand Down Expand Up @@ -318,10 +310,9 @@ impl From<BridgedChainOrigin>
pub struct ThisUnderlyingChain;

impl Chain for ThisUnderlyingChain {
type BlockNumber = ThisChainBlockNumber;
type Block = ThisChainBlock;
type Hash = ThisChainHash;
type Hasher = ThisChainHasher;
type Header = ThisChainHeader;
type AccountId = ThisChainAccountId;
type Balance = ThisChainBalance;
type Index = u32;
Expand Down Expand Up @@ -358,10 +349,9 @@ pub struct BridgedUnderlyingParachain;
pub struct BridgedChainCall;

impl Chain for BridgedUnderlyingChain {
type BlockNumber = BridgedChainBlockNumber;
type Block = BridgedChainBlock;
type Hash = BridgedChainHash;
type Hasher = BridgedChainHasher;
type Header = BridgedChainHeader;
type AccountId = BridgedChainAccountId;
type Balance = BridgedChainBalance;
type Index = u32;
Expand All @@ -384,10 +374,9 @@ impl ChainWithGrandpa for BridgedUnderlyingChain {
}

impl Chain for BridgedUnderlyingParachain {
type BlockNumber = BridgedChainBlockNumber;
type Block = BridgedChainBlock;
type Hash = BridgedChainHash;
type Hasher = BridgedChainHasher;
type Header = BridgedChainHeader;
type AccountId = BridgedChainAccountId;
type Balance = BridgedChainBalance;
type Index = u32;
Expand Down
12 changes: 3 additions & 9 deletions bridges/modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ pub type TestHeader = crate::BridgedHeader<TestRuntime, ()>;
pub type TestNumber = crate::BridgedBlockNumber<TestRuntime, ()>;

type Block = frame_system::mocking::MockBlock<TestRuntime>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;

pub const MAX_BRIDGED_AUTHORITIES: u32 = 5;

use crate as grandpa;

construct_runtime! {
pub enum TestRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum TestRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Grandpa: grandpa::{Pallet, Call, Event<T>},
Expand All @@ -63,12 +59,11 @@ impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type RuntimeCall = RuntimeCall;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
Expand Down Expand Up @@ -105,10 +100,9 @@ impl grandpa::Config for TestRuntime {
pub struct TestBridgedChain;

impl Chain for TestBridgedChain {
type BlockNumber = <TestRuntime as frame_system::Config>::BlockNumber;
type Block = Block;
type Hash = <TestRuntime as frame_system::Config>::Hash;
type Hasher = <TestRuntime as frame_system::Config>::Hashing;
type Header = <TestRuntime as frame_system::Config>::Header;

type AccountId = AccountId;
type Balance = u64;
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub mod pallet {
where
u32: TryFrom<<T as frame_system::Config>::BlockNumber>,
{
fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight {
fn on_idle(_block: BlockNumberFor<T>, remaining_weight: Weight) -> Weight {
// we'll need at least to read outbound lane state, kill a message and update lane state
let db_weight = T::DbWeight::get();
if !remaining_weight.all_gte(db_weight.reads_writes(1, 2)) {
Expand Down
9 changes: 2 additions & 7 deletions bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,11 @@ pub type TestRelayer = u64;
pub type TestDispatchLevelResult = ();

type Block = frame_system::mocking::MockBlock<TestRuntime>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;

use crate as pallet_bridge_messages;

frame_support::construct_runtime! {
pub enum TestRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum TestRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Event<T>},
Expand All @@ -100,12 +96,11 @@ impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type RuntimeCall = RuntimeCall;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = SubstrateHeader;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
Expand Down
26 changes: 9 additions & 17 deletions bridges/modules/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub type RelayBlockHeader =
sp_runtime::generic::Header<crate::RelayBlockNumber, crate::RelayBlockHasher>;

type Block = frame_system::mocking::MockBlock<TestRuntime>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;

pub const PARAS_PALLET_NAME: &str = "Paras";
pub const UNTRACKED_PARACHAIN_ID: u32 = 10;
Expand All @@ -49,10 +48,9 @@ pub type BigParachainHeader = sp_runtime::generic::Header<u128, BlakeTwo256>;
pub struct Parachain1;

impl Chain for Parachain1 {
type BlockNumber = u64;
type Block = Block;
type Hash = H256;
type Hasher = RegularParachainHasher;
type Header = RegularParachainHeader;
type AccountId = u64;
type Balance = u64;
type Index = u64;
Expand All @@ -73,10 +71,9 @@ impl Parachain for Parachain1 {
pub struct Parachain2;

impl Chain for Parachain2 {
type BlockNumber = u64;
type Block = Block;
type Hash = H256;
type Hasher = RegularParachainHasher;
type Header = RegularParachainHeader;
type AccountId = u64;
type Balance = u64;
type Index = u64;
Expand All @@ -97,10 +94,9 @@ impl Parachain for Parachain2 {
pub struct Parachain3;

impl Chain for Parachain3 {
type BlockNumber = u64;
type Block = Block;
type Hash = H256;
type Hasher = RegularParachainHasher;
type Header = RegularParachainHeader;
type AccountId = u64;
type Balance = u64;
type Index = u64;
Expand All @@ -121,11 +117,12 @@ impl Parachain for Parachain3 {
// this parachain is using u128 as block number and stored head data size exceeds limit
pub struct BigParachain;

type BigBlock = frame_system::mocking::MockBlockU128<TestRuntime>;

impl Chain for BigParachain {
type BlockNumber = u128;
type Block = BigBlock;
type Hash = H256;
type Hasher = RegularParachainHasher;
type Header = BigParachainHeader;
type AccountId = u64;
type Balance = u64;
type Index = u64;
Expand All @@ -144,10 +141,7 @@ impl Parachain for BigParachain {
}

construct_runtime! {
pub enum TestRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum TestRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Grandpa1: pallet_bridge_grandpa::<Instance1>::{Pallet, Event<T>},
Expand All @@ -172,7 +166,7 @@ impl frame_system::Config for TestRuntime {
type Hashing = RegularParachainHasher;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
Expand Down Expand Up @@ -266,7 +260,6 @@ impl Chain for TestBridgedChain {
type BlockNumber = crate::RelayBlockNumber;
type Hash = crate::RelayBlockHash;
type Hasher = crate::RelayBlockHasher;
type Header = RelayBlockHeader;

type AccountId = AccountId;
type Balance = u32;
Expand Down Expand Up @@ -294,10 +287,9 @@ impl ChainWithGrandpa for TestBridgedChain {
pub struct OtherBridgedChain;

impl Chain for OtherBridgedChain {
type BlockNumber = u64;
type Block = Block;
type Hash = crate::RelayBlockHash;
type Hasher = crate::RelayBlockHasher;
type Header = sp_runtime::generic::Header<u64, crate::RelayBlockHasher>;

type AccountId = AccountId;
type Balance = u32;
Expand Down
16 changes: 8 additions & 8 deletions bridges/modules/relayers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub mod pallet {
/// Pay rewards scheme.
type PaymentProcedure: PaymentProcedure<Self::AccountId, Self::Reward>;
/// Stake and slash scheme.
type StakeAndSlash: StakeAndSlash<Self::AccountId, Self::BlockNumber, Self::Reward>;
type StakeAndSlash: StakeAndSlash<Self::AccountId, BlockNumberFor<Self>, Self::Reward>;
/// Pallet call weights.
type WeightInfo: WeightInfoExt;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ pub mod pallet {
/// Registration allows relayer to get priority boost for its message delivery transactions.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::register())]
pub fn register(origin: OriginFor<T>, valid_till: T::BlockNumber) -> DispatchResult {
pub fn register(origin: OriginFor<T>, valid_till: BlockNumberFor<T>) -> DispatchResult {
let relayer = ensure_signed(origin)?;

// valid till must be larger than the current block number and the lease must be larger
Expand Down Expand Up @@ -330,10 +330,10 @@ pub mod pallet {
}

/// Return required registration lease.
pub(crate) fn required_registration_lease() -> T::BlockNumber {
pub(crate) fn required_registration_lease() -> BlockNumberFor<T> {
<T::StakeAndSlash as StakeAndSlash<
T::AccountId,
T::BlockNumber,
BlockNumberFor<T>,
T::Reward,
>>::RequiredRegistrationLease::get()
}
Expand All @@ -342,7 +342,7 @@ pub mod pallet {
pub(crate) fn required_stake() -> T::Reward {
<T::StakeAndSlash as StakeAndSlash<
T::AccountId,
T::BlockNumber,
BlockNumberFor<T>,
T::Reward,
>>::RequiredStake::get()
}
Expand Down Expand Up @@ -383,7 +383,7 @@ pub mod pallet {
/// Relayer account that has been registered.
relayer: T::AccountId,
/// Relayer registration.
registration: Registration<T::BlockNumber, T::Reward>,
registration: Registration<BlockNumberFor<T>, T::Reward>,
},
/// Relayer has been `deregistered`.
Deregistered {
Expand All @@ -395,7 +395,7 @@ pub mod pallet {
/// Relayer account that has been `deregistered`.
relayer: T::AccountId,
/// Registration that was removed.
registration: Registration<T::BlockNumber, T::Reward>,
registration: Registration<BlockNumberFor<T>, T::Reward>,
},
}

Expand Down Expand Up @@ -445,7 +445,7 @@ pub mod pallet {
_,
Blake2_128Concat,
T::AccountId,
Registration<T::BlockNumber, T::Reward>,
Registration<BlockNumberFor<T>, T::Reward>,
OptionQuery,
>;
}
Expand Down
9 changes: 2 additions & 7 deletions bridges/modules/relayers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ pub type TestStakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed<
>;

type Block = frame_system::mocking::MockBlock<TestRuntime>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;

frame_support::construct_runtime! {
pub enum TestRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum TestRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Event<T>},
Expand All @@ -69,12 +65,11 @@ impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type RuntimeCall = RuntimeCall;
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = SubstrateHeader;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = frame_support::traits::ConstU64<250>;
type Version = ();
Expand Down
4 changes: 1 addition & 3 deletions bridges/primitives/chain-bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ use sp_std::prelude::*;
pub struct BridgeHubKusama;

impl Chain for BridgeHubKusama {
type BlockNumber = BlockNumber;
type Hash = Hash;
type Hasher = Hasher;
type Header = Header;

type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
Expand Down
4 changes: 1 addition & 3 deletions bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ use sp_std::prelude::*;
pub struct BridgeHubPolkadot;

impl Chain for BridgeHubPolkadot {
type BlockNumber = BlockNumber;
type Hash = Hash;
type Hasher = Hasher;
type Header = Header;

type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
Expand Down
Loading