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
Changes from all 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
537 changes: 268 additions & 269 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions bridges/bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
@@ -38,15 +38,15 @@ macro_rules! assert_chain_types(
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
// configuration is used), or something has broke existing configuration (meaning that all bridged chains
// and relays will stop functioning)
use frame_system::Config as SystemConfig;
use frame_system::{Config as SystemConfig, pallet_prelude::*};
use static_assertions::assert_type_eq_all;

assert_type_eq_all!(<$r as SystemConfig>::Index, bp_runtime::IndexOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::BlockNumber, bp_runtime::BlockNumberOf<$this>);
assert_type_eq_all!(BlockNumberFor<$r>, bp_runtime::BlockNumberOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::Hash, bp_runtime::HashOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::Hashing, bp_runtime::HasherOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::AccountId, bp_runtime::AccountIdOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::Header, bp_runtime::HeaderOf<$this>);
assert_type_eq_all!(HeaderFor<$r>, bp_runtime::HeaderOf<$this>);
}
}
);
27 changes: 9 additions & 18 deletions bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
@@ -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`.
pub type ThisChainBlock = frame_system::mocking::MockBlock<TestRuntime>;
/// Unchecked extrinsic of `ThisChain`.
pub type ThisChainUncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;
// Block of `ThisChain`.
pub type ThisChainBlock = frame_system::mocking::MockBlockU32<TestRuntime>;

/// Account identifier at the `BridgedChain`.
pub type BridgedChainAccountId = u128;
@@ -83,6 +79,8 @@ 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::MockBlockU32<TestRuntime>;

/// Rewards payment procedure.
pub type TestPaymentProcedure = PayRewardFromAccount<Balances, ThisChainAccountId>;
@@ -108,10 +106,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<T>, Storage, Event<T>},
Utility: pallet_utility,
@@ -150,12 +145,11 @@ impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type RuntimeCall = RuntimeCall;
type BlockNumber = ThisChainBlockNumber;
type Hash = ThisChainHash;
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 = ();
@@ -318,10 +312,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;
@@ -358,10 +351,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;
@@ -384,10 +376,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;
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/src/parachains_benchmarking.rs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ where
+ pallet_bridge_grandpa::Config<R::BridgesGrandpaPalletInstance>,
PI: 'static,
<R as pallet_bridge_grandpa::Config<R::BridgesGrandpaPalletInstance>>::BridgedChain:
bp_runtime::Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash>,
bp_runtime::Chain<Block = pallet_bridge_parachains::RelayBlock, Hash = RelayBlockHash>,
{
let parachain_head = ParaHead(vec![0u8; parachain_head_size as usize]);

9 changes: 7 additions & 2 deletions bridges/bin/runtime-common/src/refund_relayer_extension.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ use crate::messages_call_ext::{
};
use bp_messages::{LaneId, MessageNonce};
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
use bp_runtime::{Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider};
use bp_runtime::{Chain, Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider};
use codec::{Decode, Encode};
use frame_support::{
dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo},
@@ -47,7 +47,10 @@ use pallet_transaction_payment::{Config as TransactionPaymentConfig, OnChargeTra
use pallet_utility::{Call as UtilityCall, Config as UtilityConfig, Pallet as UtilityPallet};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{DispatchInfoOf, Get, PostDispatchInfoOf, SignedExtension, Zero},
traits::{
Block as BlockT, DispatchInfoOf, Get, Header as HeaderT, PostDispatchInfoOf,
SignedExtension, Zero,
},
transaction_validity::{
TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransactionBuilder,
},
@@ -278,6 +281,7 @@ where
+ GrandpaCallSubType<Runtime, Runtime::BridgesGrandpaPalletInstance>
+ ParachainsCallSubType<Runtime, Para::Instance>
+ MessagesCallSubType<Runtime, Msgs::Instance>,
<<<Runtime as BoundedBridgeGrandpaConfig<Runtime::BridgesGrandpaPalletInstance>>::BridgedRelayChain as Chain>::Block as BlockT>::Header: HeaderT<Number = RelayBlockNumber>
{
fn expand_call<'a>(&self, call: &'a CallOf<Runtime>) -> Vec<&'a CallOf<Runtime>> {
match call.is_sub_type() {
@@ -525,6 +529,7 @@ where
+ GrandpaCallSubType<Runtime, Runtime::BridgesGrandpaPalletInstance>
+ ParachainsCallSubType<Runtime, Para::Instance>
+ MessagesCallSubType<Runtime, Msgs::Instance>,
<<<Runtime as BoundedBridgeGrandpaConfig<Runtime::BridgesGrandpaPalletInstance>>::BridgedRelayChain as Chain>::Block as BlockT>::Header: HeaderT<Number = RelayBlockNumber>
{
const IDENTIFIER: &'static str = Id::STR;
type AccountId = Runtime::AccountId;
6 changes: 4 additions & 2 deletions bridges/modules/grandpa/src/call_ext.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ use bp_header_chain::{justification::GrandpaJustification, ChainWithGrandpa};
use bp_runtime::BlockNumberOf;
use codec::Encode;
use frame_support::{dispatch::CallableCallFor, traits::IsSubType, weights::Weight, RuntimeDebug};
use frame_system::pallet_prelude::HeaderFor;
use sp_runtime::{
traits::{Header, Zero},
transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction},
@@ -178,8 +179,9 @@ pub(crate) fn submit_finality_proof_info_from_args<T: Config<I>, I: 'static>(

/// Returns maximal expected size of `submit_finality_proof` call arguments.
fn max_expected_call_size<T: Config<I>, I: 'static>(required_precommits: u32) -> u32 {
let max_expected_justification_size =
GrandpaJustification::max_reasonable_size::<T::BridgedChain>(required_precommits);
let max_expected_justification_size = GrandpaJustification::<HeaderFor<T>>::max_reasonable_size::<
T::BridgedChain,
>(required_precommits);

// call arguments are header and justification
T::BridgedChain::MAX_HEADER_SIZE.saturating_add(max_expected_justification_size)
14 changes: 4 additions & 10 deletions bridges/modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ use frame_support::{
};
use sp_core::sr25519::Signature;
use sp_runtime::{
testing::{Header, H256},
testing::H256,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
@@ -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<T>, Storage, Event<T>},
Grandpa: grandpa::{Pallet, Call, Event<T>},
@@ -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 = ();
@@ -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;
4 changes: 2 additions & 2 deletions bridges/modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
@@ -188,9 +188,9 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I>
where
u32: TryFrom<<T as frame_system::Config>::BlockNumber>,
u32: TryFrom<BlockNumberFor<T>>,
{
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)) {
10 changes: 2 additions & 8 deletions bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ use frame_support::{
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{
testing::Header as SubstrateHeader,
traits::{BlakeTwo256, ConstU32, IdentityLookup},
BuildStorage, Perbill,
};
@@ -71,15 +70,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<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Event<T>},
@@ -100,12 +95,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 = ();
2 changes: 1 addition & 1 deletion bridges/modules/parachains/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ benchmarks_instance_pallet! {
where
<T as pallet_bridge_grandpa::Config<T::BridgesGrandpaPalletInstance>>::BridgedChain:
bp_runtime::Chain<
BlockNumber = RelayBlockNumber,
Block = crate::RelayBlock,
Hash = RelayBlockHash,
Hasher = RelayBlockHasher,
>,
15 changes: 7 additions & 8 deletions bridges/modules/parachains/src/lib.rs
Original file line number Diff line number Diff line change
@@ -63,6 +63,8 @@ pub type RelayBlockHash = bp_polkadot_core::Hash;
pub type RelayBlockNumber = bp_polkadot_core::BlockNumber;
/// Hasher of the bridged relay chain.
pub type RelayBlockHasher = bp_polkadot_core::Hasher;
/// Block type of the bridged relay chain.
pub type RelayBlock = bp_polkadot_core::Block;

/// Artifacts of the parachains head update.
struct UpdateParachainHeadArtifacts {
@@ -137,18 +139,15 @@ pub mod pallet {
pub trait BoundedBridgeGrandpaConfig<I: 'static>:
pallet_bridge_grandpa::Config<I, BridgedChain = Self::BridgedRelayChain>
{
type BridgedRelayChain: Chain<
BlockNumber = RelayBlockNumber,
Hash = RelayBlockHash,
Hasher = RelayBlockHasher,
>;
type BridgedRelayChain: Chain<Hash = RelayBlockHash, Hasher = RelayBlockHasher>;
}

impl<T, I: 'static> BoundedBridgeGrandpaConfig<I> for T
where
T: pallet_bridge_grandpa::Config<I>,
T::BridgedChain:
Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>,
T::BridgedChain: Chain<Hash = RelayBlockHash, Hasher = RelayBlockHasher>,
<<T::BridgedChain as Chain>::Block as sp_runtime::traits::Block>::Header:
sp_runtime::traits::Header<Number = RelayBlockNumber>,
{
type BridgedRelayChain = T::BridgedChain;
}
@@ -323,7 +322,7 @@ pub mod pallet {
>::get(relay_block_hash)
.ok_or(Error::<T, I>::UnknownRelayChainBlock)?;
ensure!(
relay_block.number == relay_block_number,
relay_block.number == relay_block_number.into(),
Error::<T, I>::InvalidRelayChainBlockNumber,
);

Loading