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 660c6b7
Show file tree
Hide file tree
Showing 19 changed files with 774 additions and 777 deletions.
1,293 changes: 667 additions & 626 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ finality-grandpa = { version = "0.16", default-features = false }
hash-db = { version = "0.16", default-features = false }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "2.9", default-features = false, features = ["derive"] }
serde = { version = "1.0" }
serde = { version = "1.0", default-features = false }
trie-db = { version = "0.27", default-features = false }

# darwinia
Expand All @@ -32,7 +32,7 @@ pallet-bridge-parachains = { path = "modules/parachains", default-features = fal
pallet-fee-market = { path = "modules/fee-market", default-features = false }

# frontier
fp-account = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0", default-features = false }
fp-account = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.0.0", default-features = false, features = ["serde"] }

# substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false }
Expand Down
23 changes: 8 additions & 15 deletions modules/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,18 +490,16 @@ mod tests {
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
transaction_validity::{InvalidTransaction, TransactionValidityError},
Perbill,
BuildStorage, Perbill,
};

type Block = MockBlock<TestRuntime>;

type AccountId = u64;
type BridgeMessageId = [u8; 4];

type Block = MockBlock<TestRuntime>;
type UncheckedExtrinsic = MockUncheckedExtrinsic<TestRuntime>;

const SOURCE_CHAIN_ID: ChainId = *b"srce";
const TARGET_CHAIN_ID: ChainId = *b"trgt";

Expand Down Expand Up @@ -536,13 +534,9 @@ mod tests {
}

frame_support::construct_runtime! {
pub enum TestRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
pub enum TestRuntime {
RootTesting: pallet_root_testing,
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Dispatch: call_dispatch::{Pallet, Call, Event<T>},
}
}
Expand All @@ -560,17 +554,16 @@ mod tests {
type AccountData = ();
type AccountId = AccountId;
type BaseCallFilter = frame_support::traits::Everything;
type Block = Block;
type BlockHashCount = BlockHashCount;
type BlockLength = ();
type BlockNumber = u64;
type BlockWeights = ();
type DbWeight = ();
type Hash = H256;
type Hashing = BlakeTwo256;
type Header = Header;
type Index = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type Nonce = u64;
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ();
Expand Down Expand Up @@ -635,7 +628,7 @@ mod tests {
}

fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default().build_storage::<TestRuntime>().unwrap();
let t = <frame_system::GenesisConfig<TestRuntime>>::default().build_storage().unwrap();
sp_io::TestExternalities::new(t)
}

Expand Down
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 @@ -199,21 +197,15 @@ pub mod pallet {
3
}

#[derive(DefaultNoBound)]
#[pallet::genesis_config]
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()
}
}
24 changes: 9 additions & 15 deletions modules/fee-market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ use frame_system::mocking::*;
use pallet_bridge_messages::outbound_lane;
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, UniqueSaturatedInto},
FixedU128, Permill,
BuildStorage, FixedU128, Permill,
};
// --- darwinia-network ---
use crate::{
Expand All @@ -61,7 +60,7 @@ use crate::{
};

type Block = MockBlock<Test>;
type UncheckedExtrinsic = MockUncheckedExtrinsic<Test>;

pub(crate) type Balance = u64;
pub(crate) type AccountId = u64;

Expand All @@ -72,17 +71,16 @@ impl frame_system::Config for Test {
type AccountData = pallet_balances::AccountData<Balance>;
type AccountId = AccountId;
type BaseCallFilter = Everything;
type Block = Block;
type BlockHashCount = ();
type BlockLength = ();
type BlockNumber = u64;
type BlockWeights = ();
type DbWeight = DbWeight;
type Hash = H256;
type Hashing = BlakeTwo256;
type Header = Header;
type Index = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type MaxConsumers = ConstU32<16>;
type Nonce = u64;
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ();
Expand All @@ -104,13 +102,13 @@ impl pallet_balances::Config for Test {
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ();
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = ();
type WeightInfo = ();
}

Expand Down Expand Up @@ -468,7 +466,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 All @@ -495,12 +493,8 @@ impl Config for Test {
}

frame_support::construct_runtime! {
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
pub enum Test {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
FeeMarket: pallet_fee_market::{Pallet, Call, Storage, Event<T>},
Expand Down Expand Up @@ -531,7 +525,7 @@ impl ExtBuilder {
}

pub(crate) fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = <frame_system::GenesisConfig<Test>>::default().build_storage().unwrap();

pallet_balances::GenesisConfig::<Test> { balances: self.balances }
.assimilate_storage(&mut t)
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 @@ -347,6 +347,7 @@ pub mod pallet {
pub type PalletOperatingMode<T: Config<I>, I: 'static = ()> =
StorageValue<_, BasicOperatingMode, ValueQuery>;

#[derive(DefaultNoBound)]
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
/// Optional module owner account.
Expand All @@ -355,15 +356,8 @@ pub mod pallet {
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
Loading

0 comments on commit 660c6b7

Please sign in to comment.