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

* Fixes

* Removes unused import

* Uses Block and removes BlockNumber/Header from Chain

* Fixes bridges

* Fixes

* Removes unused import

* Fixes build

* Uses correct RelayBlock

* Minor fix

* Fixes glutton-kusama

* Uses correct RelayBlock

* Minor fix

* Fixes benchmark for pallet-bridge-parachains

* Adds appropriate constraints

* Minor fixes

* Removes unused import

* Fixes integrity tests

* Minor fixes

* Updates trait bounds

* Uses custom bound for AsPrimitive

* Fixes trait bounds

* Revert "Fixes trait bounds"

This reverts commit 0b0f42f583f3a616a88afe45fcd06d31e7d9a06f.

* Revert "Uses custom bound for AsPrimitive"

This reverts commit 838e5281adf8b6e9632a2abb9cd550db4ae24126.

* No AsPrimitive trait bound for now

* Removes bounds on Number

* update lockfile for {"substrate", "polkadot"}

* Formatting

* ".git/.scripts/commands/fmt/fmt.sh"

* Minor fix

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
gupnik
2023-07-13 19:00:28 +05:30
committed by GitHub
parent 49145bdd9b
commit 24d6e46ad0
54 changed files with 449 additions and 633 deletions
+8 -8
View File
@@ -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;
}
@@ -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
@@ -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()
}
@@ -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()
}
@@ -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 {
@@ -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>,
},
}
@@ -445,7 +445,7 @@ pub mod pallet {
_,
Blake2_128Concat,
T::AccountId,
Registration<T::BlockNumber, T::Reward>,
Registration<BlockNumberFor<T>, T::Reward>,
OptionQuery,
>;
}
+2 -8
View File
@@ -25,7 +25,6 @@ use bp_relayers::{
use frame_support::{parameter_types, traits::fungible::Mutate, weights::RuntimeDbWeight};
use sp_core::H256;
use sp_runtime::{
testing::Header as SubstrateHeader,
traits::{BlakeTwo256, ConstU32, IdentityLookup},
BuildStorage,
};
@@ -44,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<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Event<T>},
@@ -70,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 = ();