Skip to content

Commit

Permalink
wip: address todos and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoAlexandre committed Nov 1, 2023
1 parent c489940 commit 49e880d
Show file tree
Hide file tree
Showing 31 changed files with 52 additions and 64 deletions.
5 changes: 4 additions & 1 deletion libs/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ pub mod types {

/// Common constants for all runtimes
pub mod constants {
use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
use sp_runtime::Perbill;

Expand Down Expand Up @@ -269,6 +268,10 @@ pub mod constants {

/// The safe XCM version of pallet-xcm, same as on relay chain
pub const SAFE_XCM_VERSION: u32 = xcm::opaque::v2::VERSION;

pub const MAX_POV_SIZE: u64 = cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64;
/// Block storage limit in bytes. Set to 40 KB.
pub const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;
}

/// Listing of parachains we integrate with.
Expand Down
2 changes: 1 addition & 1 deletion pallets/anchors/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
1 change: 1 addition & 0 deletions pallets/block-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl pallet_restricted_tokens::Config for Test {
type PreFungiblesMutate = cfg_traits::Always;
type PreFungiblesMutateHold = cfg_traits::Always;
type PreFungiblesTransfer = cfg_traits::Always;
type PreFungiblesUnbalanced = cfg_traits::Always;
type PreReservableCurrency = cfg_traits::Always;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
Expand Down
4 changes: 1 addition & 3 deletions pallets/bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ pub(crate) const RELAYER_A: u64 = 0x2;
pub(crate) const RELAYER_B: u64 = 0x3;
pub(crate) const RELAYER_C: u64 = 0x4;
pub(crate) const ENDOWED_BALANCE: Balance = 10000 * CFG;
//todo(nuno): if we AllowDeath in Fees::withdraw_fee, we don't need to add the
// ED here
pub(crate) const RELAYER_B_INITIAL_BALANCE: Balance =
NATIVE_TOKEN_TRANSFER_FEE + ExistentialDeposit::get();
pub(crate) const TEST_RELAYER_VOTE_THRESHOLD: u32 = 2;
Expand Down Expand Up @@ -139,7 +137,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/collator-allowlist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/crowdloan-claim/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/crowdloan-reward/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
8 changes: 2 additions & 6 deletions pallets/ethereum-transaction/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::str::FromStr;

use cfg_primitives::{BLOCK_STORAGE_LIMIT, MAX_POV_SIZE};
use fp_evm::{FeeCalculator, Precompile, PrecompileResult};
use frame_support::{parameter_types, traits::FindAuthor, weights::Weight};
use pallet_ethereum::{IntermediateStateRoot, PostLogContent};
Expand Down Expand Up @@ -78,7 +79,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down Expand Up @@ -162,10 +163,6 @@ impl PrecompileSet for MockPrecompileSet {
}
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::max_value();
pub WeightPerGas: Weight = Weight::from_parts(20_000, 0);
Expand Down Expand Up @@ -204,7 +201,6 @@ impl pallet_evm::Config for Runtime {

parameter_types! {
pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes;
//todo(nuno): revisit this
pub const ExtraDataLength: u32 = 30;
}

Expand Down
1 change: 0 additions & 1 deletion pallets/fees/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ impl<T: Config> Pallet<T> {
from,
balance,
WithdrawReasons::FEE,
// todo(nuno): discuss whether we can make this AllowDeath instead
ExistenceRequirement::KeepAlive,
)
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/fees/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/investments/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl pallet_balances::Config for MockRuntime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/keystore/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
6 changes: 1 addition & 5 deletions pallets/liquidity-pools-gateway/routers/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::str::FromStr;

use cfg_mocks::{pallet_mock_liquidity_pools, pallet_mock_routers, MessageMock, RouterMock};
use cfg_primitives::{BLOCK_STORAGE_LIMIT, MAX_POV_SIZE};
use cfg_traits::TryConvert;
use cfg_types::domain_address::DomainAddress;
use codec::{Decode, Encode};
Expand Down Expand Up @@ -233,10 +234,6 @@ impl PrecompileSet for MockPrecompileSet {
}
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::max_value();
pub WeightPerGas: Weight = Weight::from_parts(20_000, 0);
Expand Down Expand Up @@ -275,7 +272,6 @@ impl pallet_evm::Config for Runtime {

parameter_types! {
pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes;
//todo(nuno): revisit this
pub const ExtraDataLength: u32 = 30;
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/liquidity-pools-gateway/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/loans/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
6 changes: 3 additions & 3 deletions pallets/migration/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame_support::{
parameter_types,
scale_info::TypeInfo,
sp_runtime::traits::ConvertInto,
traits::{Contains, InstanceFilter, WithdrawReasons},
traits::{ConstU32, Contains, InstanceFilter, WithdrawReasons},
};
use sp_core::{RuntimeDebug, H256};
use sp_runtime::{
Expand Down Expand Up @@ -124,7 +124,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down Expand Up @@ -175,7 +175,7 @@ impl frame_system::Config for Runtime {
type Header = sp_runtime::generic::Header<BlockNumber, BlakeTwo256>;
type Index = Index;
type Lookup = IdentityLookup<Self::AccountId>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/nft-sales/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/nft/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
3 changes: 2 additions & 1 deletion pallets/order-book/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
Expand Down Expand Up @@ -183,6 +183,7 @@ impl pallet_restricted_tokens::Config for Runtime {
type PreFungiblesMutate = cfg_traits::Always;
type PreFungiblesMutateHold = cfg_traits::Always;
type PreFungiblesTransfer = cfg_traits::Always;
type PreFungiblesUnbalanced = cfg_traits::Always;
type PreReservableCurrency = cfg_traits::Always;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/pool-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down
4 changes: 1 addition & 3 deletions pallets/pool-system/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,7 @@ impl<T: Config> InvestmentAccountant<T::AccountId> for Pallet<T> {
) -> Result<(), Self::Error> {
let _details = Pool::<T>::get(id.of_pool()).ok_or(Error::<T>::NoSuchPool)?;

T::Tokens::mint_into(id.into(), buyer, amount).map(|_| ()) // todo(nuno):
// propagate this api
// change upstream
T::Tokens::mint_into(id.into(), buyer, amount).map(|_| ())
}

fn withdraw(
Expand Down
3 changes: 2 additions & 1 deletion pallets/pool-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = ();
Expand Down Expand Up @@ -216,6 +216,7 @@ impl pallet_restricted_tokens::Config for Runtime {
type PreFungiblesMutate = cfg_traits::Always;
type PreFungiblesMutateHold = cfg_traits::Always;
type PreFungiblesTransfer = cfg_traits::Always;
type PreFungiblesUnbalanced = cfg_traits::Always;
type PreReservableCurrency = cfg_traits::Always;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/restricted-tokens/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ConstU32<50>;
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
Expand Down
2 changes: 1 addition & 1 deletion pallets/transfer-allowlist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = ();
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
Expand Down
10 changes: 4 additions & 6 deletions runtime/altair/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use cfg_primitives::{EnsureRootOr, HalfOfCouncil, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
use cfg_primitives::{
EnsureRootOr, HalfOfCouncil, BLOCK_STORAGE_LIMIT, MAXIMUM_BLOCK_WEIGHT, MAX_POV_SIZE,
NORMAL_DISPATCH_RATIO,
};
use frame_support::{parameter_types, traits::FindAuthor, weights::Weight, ConsensusEngineId};
use pallet_ethereum::PostLogContent;
use pallet_evm::{EnsureAddressRoot, EnsureAddressTruncated};
Expand Down Expand Up @@ -41,10 +44,6 @@ impl<F: FindAuthor<u32>> FindAuthor<H160> for FindAuthorTruncated<F> {
}
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS);
pub PrecompilesValue: Altair<Runtime> = Altair::<_>::new();
Expand Down Expand Up @@ -97,7 +96,6 @@ impl pallet_base_fee::Config for Runtime {

parameter_types! {
pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes;
//todo(nuno): revisit this
pub const ExtraDataLength: u32 = 30;
}

Expand Down
5 changes: 2 additions & 3 deletions runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,9 @@ impl pallet_balances::Config for Runtime {
/// The minimum amount required to keep an account open.
type ExistentialDeposit = ExistentialDeposit;
type FreezeIdentifier = ();
//todo(nuno)
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
Expand Down Expand Up @@ -678,7 +677,7 @@ parameter_types! {
pub const DesiredRunnersUp: u32 = 9;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
// todo(nuno)
pub const MaxVotesPerVoter: u32 = 5;
pub const MaxVotesPerVoter: u32 = 20;
}

// Make sure that there are no more than `MAX_MEMBERS` members elected via
Expand Down
9 changes: 4 additions & 5 deletions runtime/centrifuge/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use cfg_primitives::{TwoThirdOfCouncil, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
use cfg_primitives::{
TwoThirdOfCouncil, BLOCK_STORAGE_LIMIT, MAXIMUM_BLOCK_WEIGHT, MAX_POV_SIZE,
NORMAL_DISPATCH_RATIO,
};
use frame_support::{parameter_types, traits::FindAuthor, weights::Weight, ConsensusEngineId};
use pallet_ethereum::PostLogContent;
use pallet_evm::{EnsureAddressRoot, EnsureAddressTruncated};
Expand Down Expand Up @@ -42,10 +45,6 @@ impl<F: FindAuthor<u32>> FindAuthor<H160> for FindAuthorTruncated<F> {
}
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS);
pub PrecompilesValue: CentrifugePrecompiles<crate::Runtime> = CentrifugePrecompiles::<_>::new();
Expand Down
2 changes: 1 addition & 1 deletion runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl pallet_balances::Config for Runtime {
//todo(nuno)
type HoldIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxHolds = frame_support::traits::ConstU32<1>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
Expand Down
Loading

0 comments on commit 49e880d

Please sign in to comment.