Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Fix compile
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Lau <xavier@inv.cafe>
  • Loading branch information
AurevoirXavier committed Oct 24, 2023
1 parent aa56364 commit c78f731
Show file tree
Hide file tree
Showing 8 changed files with 691 additions and 684 deletions.
1,293 changes: 667 additions & 626 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 11 additions & 19 deletions modules/fee-market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ use s2s::RewardItem;
use types::{Order, Relayer, SlashReport};
// paritytech
use bp_messages::{LaneId, MessageNonce};
#[cfg(feature = "std")]
use frame_support::traits::GenesisBuild;
use frame_support::{
ensure,
pallet_prelude::*,
traits::{Currency, Get, LockIdentifier, LockableCurrency, WithdrawReasons},
PalletId,
DefaultNoBound, PalletId,
};
use frame_system::{ensure_signed, pallet_prelude::*, RawOrigin};
use sp_runtime::{
Expand Down Expand Up @@ -80,7 +78,7 @@ pub mod pallet {
type CollateralPerOrder: Get<BalanceOf<Self, I>>;
/// The slot times set
#[pallet::constant]
type Slot: Get<Self::BlockNumber>;
type Slot: Get<BlockNumberFor<Self>>;

/// Reward parameters
#[pallet::constant]
Expand All @@ -95,7 +93,7 @@ pub mod pallet {
type AssignedRelayerSlashRatio: Get<Permill>;
type Slasher: Slasher<Self, I>;

type Currency: LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
type Currency: LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>>;
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
type WeightInfo: WeightInfo;
Expand All @@ -117,15 +115,15 @@ pub mod pallet {
/// Update market assigned relayers numbers. \[new_assigned_relayers_number\]
UpdateAssignedRelayersNumber(u32),
/// Slash report
FeeMarketSlash(SlashReport<T::AccountId, T::BlockNumber, BalanceOf<T, I>>),
FeeMarketSlash(SlashReport<T::AccountId, BlockNumberFor<T>, BalanceOf<T, I>>),
/// Create new order. \[lane_id, message_nonce, order_fee, assigned_relayers,
/// out_of_slots_time\]
OrderCreated(
LaneId,
MessageNonce,
BalanceOf<T, I>,
Vec<T::AccountId>,
Option<T::BlockNumber>,
Option<BlockNumberFor<T>>,
),
/// Reward distribute of the order. \[lane_id, message_nonce, rewards\]
OrderReward(LaneId, MessageNonce, RewardItem<T::AccountId, BalanceOf<T, I>>),
Expand Down Expand Up @@ -181,7 +179,7 @@ pub mod pallet {
_,
Blake2_128Concat,
(LaneId, MessageNonce),
Order<T::AccountId, T::BlockNumber, BalanceOf<T, I>>,
Order<T::AccountId, BlockNumberFor<T>, BalanceOf<T, I>>,
OptionQuery,
>;

Expand All @@ -200,20 +198,14 @@ pub mod pallet {
}

#[pallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
// Initialization relayers data.[AccoundId, Collateral, Quota]
pub relayers: Vec<(T::AccountId, BalanceOf<T, I>, Option<BalanceOf<T, I>>)>,
}

#[cfg(feature = "std")]
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
fn default() -> Self {
Self { relayers: vec![] }
}
}

#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
self.relayers.iter().cloned().for_each(|(id, collateral, quota)| {
let _ = Pallet::<T, I>::enroll_and_lock_collateral(
Expand Down Expand Up @@ -504,7 +496,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
pub(crate) fn update_relayer_after_slash(
who: &T::AccountId,
new_collateral: BalanceOf<T, I>,
report: SlashReport<T::AccountId, T::BlockNumber, BalanceOf<T, I>>,
report: SlashReport<T::AccountId, BlockNumberFor<T>, BalanceOf<T, I>>,
) {
let _ = Self::update_market(
|| {
Expand Down Expand Up @@ -591,13 +583,13 @@ pub trait Slasher<T: Config<I>, I: 'static> {
/// Calculate the concrete slash amount
fn calc_amount(
collateral_per_order: BalanceOf<T, I>,
timeout: T::BlockNumber,
timeout: BlockNumberFor<T>,
) -> BalanceOf<T, I>;
}

/// No penalties, more for testing purposes.
impl<T: Config<I>, I: 'static> Slasher<T, I> for () {
fn calc_amount(_: BalanceOf<T, I>, _: T::BlockNumber) -> BalanceOf<T, I> {
fn calc_amount(_: BalanceOf<T, I>, _: BlockNumberFor<T>) -> BalanceOf<T, I> {
BalanceOf::<T, I>::zero()
}
}
2 changes: 1 addition & 1 deletion modules/fee-market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ pub struct TestSlasher;
impl<T: Config<I>, I: 'static> Slasher<T, I> for TestSlasher {
fn calc_amount(
collateral_per_order: BalanceOf<T, I>,
timeout: T::BlockNumber,
timeout: BlockNumberFor<T>,
) -> BalanceOf<T, I> {
let slash_each_block = 2;
let slash_value = UniqueSaturatedInto::<u128>::unique_saturated_into(timeout)
Expand Down
2 changes: 1 addition & 1 deletion modules/fee-market/src/s2s/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ where
/// order. The slash part will be transferred to fund_account first, and then distributed to various
/// relayers.
pub(crate) fn slash_assigned_relayer<T: Config<I>, I: 'static>(
order: &Order<T::AccountId, T::BlockNumber, BalanceOf<T, I>>,
order: &Order<T::AccountId, BlockNumberFor<T>, BalanceOf<T, I>>,
who: &T::AccountId,
fund_account: &T::AccountId,
amount: BalanceOf<T, I>,
Expand Down
14 changes: 4 additions & 10 deletions modules/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use bp_runtime::{
};
use storage_types::StoredAuthoritySet;
// substrate
use frame_support::{ensure, fail, log};
use frame_support::{ensure, fail, log, DefaultNoBound};
use frame_system::ensure_signed;
use sp_consensus_grandpa::{ConsensusLog, GRANDPA_ENGINE_ID};
use sp_runtime::traits::{Header as HeaderT, Zero};
Expand Down Expand Up @@ -134,7 +134,7 @@ pub mod pallet {

#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight {
fn on_initialize(_n: BlockNumberFor<T>) -> frame_support::weights::Weight {
<RequestCount<T, I>>::mutate(|count| *count = count.saturating_sub(1));

T::DbWeight::get().reads_writes(1, 1)
Expand Down Expand Up @@ -348,22 +348,16 @@ pub mod pallet {
StorageValue<_, BasicOperatingMode, ValueQuery>;

#[pallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
/// Optional module owner account.
pub owner: Option<T::AccountId>,
/// Optional module initialization data.
pub init_data: Option<super::InitializationData<BridgedHeader<T, I>>>,
}

#[cfg(feature = "std")]
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
fn default() -> Self {
Self { owner: None, init_data: None }
}
}

#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
if let Some(ref owner) = self.owner {
<PalletOwner<T, I>>::put(owner);
Expand Down
16 changes: 3 additions & 13 deletions modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ use bp_messages::{
};
use bp_runtime::{BasicOperatingMode, ChainId, OwnedBridgeModule, Size};
// substrate
use frame_support::{dispatch::PostDispatchInfo, ensure, fail, log, traits::Get};
use frame_support::{dispatch::PostDispatchInfo, ensure, fail, log, traits::Get, DefaultNoBound};
use sp_core::H256;
use sp_runtime::traits::Convert;
use sp_std::{cell::RefCell, marker::PhantomData, prelude::*};
Expand Down Expand Up @@ -682,6 +682,7 @@ pub mod pallet {
StorageMap<_, Blake2_128Concat, MessageKey, StoredMessageData<T, I>>;

#[pallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
/// Initial pallet operating mode.
pub operating_mode: MessagesOperatingMode,
Expand All @@ -691,19 +692,8 @@ pub mod pallet {
pub phantom: sp_std::marker::PhantomData<I>,
}

#[cfg(feature = "std")]
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
fn default() -> Self {
Self {
operating_mode: Default::default(),
owner: Default::default(),
phantom: Default::default(),
}
}
}

#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
PalletOperatingMode::<T, I>::put(self.operating_mode);
if let Some(ref owner) = self.owner {
Expand Down
16 changes: 3 additions & 13 deletions modules/parachains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo};
use bp_polkadot_core::parachains::{ParaHash, ParaHasher, ParaHead, ParaHeadsProof, ParaId};
use bp_runtime::StorageProofError;
// substrate
use frame_support::{dispatch::PostDispatchInfo, traits::Contains};
use frame_support::{dispatch::PostDispatchInfo, traits::Contains, DefaultNoBound};
use sp_runtime::traits::Header as HeaderT;
use sp_std::prelude::*;

Expand Down Expand Up @@ -591,6 +591,7 @@ pub mod pallet {
}

#[pallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
/// Initial pallet operating mode.
pub operating_mode: BasicOperatingMode,
Expand All @@ -600,19 +601,8 @@ pub mod pallet {
pub phantom: sp_std::marker::PhantomData<I>,
}

#[cfg(feature = "std")]
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
fn default() -> Self {
Self {
operating_mode: Default::default(),
owner: Default::default(),
phantom: Default::default(),
}
}
}

#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
PalletOperatingMode::<T, I>::put(self.operating_mode);
if let Some(ref owner) = self.owner {
Expand Down
2 changes: 1 addition & 1 deletion runtime-common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ pub mod target {
impl<DecodedCall> FromBridgedChainEncodedMessageCall<DecodedCall> {
/// Create encoded call.
pub fn new(encoded_call: Vec<u8>) -> Self {
FromBridgedChainEncodedMessageCall { encoded_call, _marker: PhantomData::default() }
FromBridgedChainEncodedMessageCall { encoded_call, _marker: PhantomData }
}
}

Expand Down

0 comments on commit c78f731

Please sign in to comment.