Skip to content

Commit

Permalink
runtimes compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Aug 19, 2024
1 parent 73a732f commit e99544a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 53 deletions.
39 changes: 18 additions & 21 deletions runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ use cfg_primitives::{
},
LPGatewayQueueMessageNonce, LPGatewaySessionId, Millis, Seconds,
};
use cfg_traits::{
investments::OrderManager, Permissions as PermissionsT, PoolUpdateGuard, PreConditions,
};
use cfg_traits::{investments::OrderManager, time::UnixTimeSecs, PoolUpdateGuard};
use cfg_types::{
domain_address::DomainAddress,
fee_keys::{Fee, FeeKey},
Expand Down Expand Up @@ -60,7 +58,7 @@ use frame_support::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, Contains, EitherOf, EitherOfDiverse,
EqualPrivilegeOnly, Get, InstanceFilter, LinearStoragePrice, LockIdentifier, OnFinalize,
PalletInfoAccess, TransformOrigin, UnixTime, WithdrawReasons,
PalletInfoAccess, TransformOrigin, WithdrawReasons,
},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
Expand Down Expand Up @@ -361,7 +359,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
}

parameter_types! {
pub const MinimumPeriod: Millis = SLOT_DURATION / 2;
pub MinimumPeriod: Millis = SLOT_DURATION / 2;
}

impl pallet_timestamp::Config for Runtime {
Expand Down Expand Up @@ -1117,7 +1115,7 @@ parameter_types! {

// How much time should lapse before a tranche investor can be removed
#[derive(Debug, Eq, PartialEq, scale_info::TypeInfo, Clone)]
pub const MinDelay: Seconds = 7 * SECONDS_PER_DAY;
pub const MinDelay: Seconds = SECONDS_PER_WEEK;

#[derive(Debug, Eq, PartialEq, scale_info::TypeInfo, Clone)]
pub const MaxRolesPerPool: u32 = 10_000;
Expand Down Expand Up @@ -1308,7 +1306,7 @@ parameter_types! {
#[derive(scale_info::TypeInfo)]
pub const MaxGroups: u32 = 20;
pub const LiquidityRewardsPalletId: PalletId = cfg_types::ids::LIQUIDITY_REWARDS_PALLET_ID;
pub const InitialEpochDuration: Millis = SECONDS_PER_MINUTE * 1000; // 1 min in milliseconds
pub InitialEpochDuration: Millis = SECONDS_PER_MINUTE.into_millis();
}

impl pallet_rewards::mechanism::gap::Config for Runtime {
Expand Down Expand Up @@ -1407,7 +1405,6 @@ impl pallet_loans::Config for Runtime {
type LoanId = LoanId;
type MaxActiveLoansPerPool = MaxActiveLoansPerPool;
type MaxWriteOffPolicySize = MaxWriteOffPolicySize;
type Moment = Millis;
type NonFungible = Uniques;
type PerThing = Perquintill;
type Permissions = Permissions;
Expand Down Expand Up @@ -1460,10 +1457,10 @@ parameter_types! {
/// The index with which this pallet is instantiated in this runtime.
pub PoolPalletIndex: u8 = <PoolSystem as PalletInfoAccess>::index() as u8;

pub const MinUpdateDelay: u64 = if cfg!(feature = "runtime-benchmarks") {
0
pub MinUpdateDelay: Seconds = if cfg!(feature = "runtime-benchmarks") {
Seconds::new(0)
} else {
2 * SECONDS_PER_DAY
SECONDS_PER_DAY * 2
};

pub const ChallengeTime: BlockNumber = if cfg!(feature = "runtime-benchmarks") {
Expand All @@ -1474,22 +1471,22 @@ parameter_types! {
};

// Defaults for pool parameters
pub const DefaultMinEpochTime: u64 = 23 * SECONDS_PER_HOUR + 50 * SECONDS_PER_MINUTE; // Just under a day
pub const DefaultMaxNAVAge: u64 = 0;
pub DefaultMinEpochTime: Seconds = SECONDS_PER_DAY - 10; // Just under a day
pub const DefaultMaxNAVAge: Seconds = Seconds::new(0);

// Runtime-defined constraints for pool parameters
pub const MinEpochTimeLowerBound: u64 = if cfg!(feature = "runtime-benchmarks") {
pub const MinEpochTimeLowerBound: Seconds = if cfg!(feature = "runtime-benchmarks") {
// Allow short epoch time in benchmarks
1
Seconds::new(1)
} else {
1 * SECONDS_PER_HOUR // 1 hour
SECONDS_PER_HOUR
};
pub const MinEpochTimeUpperBound: u64 = 30 * SECONDS_PER_DAY; // 1 month
pub const MaxNAVAgeUpperBound: u64 = if cfg!(feature = "runtime-benchmarks") {
pub const MinEpochTimeUpperBound: Seconds = SECONDS_PER_MONTH;
pub const MaxNAVAgeUpperBound: Seconds = if cfg!(feature = "runtime-benchmarks") {
// Allow an aged NAV in benchmarks
SECONDS_PER_HOUR
} else {
0
Seconds::new(0)
};

// Pool metadata limit
Expand Down Expand Up @@ -2307,7 +2304,7 @@ impl_runtime_apis! {

impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration().inner)
}

fn authorities() -> Vec<AuraId> {
Expand Down Expand Up @@ -2373,7 +2370,7 @@ impl_runtime_apis! {
}

fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Quantity>>{
let now = <Timestamp as UnixTime>::now().as_secs();
let now = Timestamp::now_secs();
let mut pool = PoolSystem::pool(pool_id)?;
pool
.tranches
Expand Down
48 changes: 24 additions & 24 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use cfg_primitives::{
LPGatewayQueueMessageNonce, LPGatewaySessionId, Millis, Seconds,
};
use cfg_traits::{
investments::OrderManager, Permissions as PermissionsT, PoolUpdateGuard, PreConditions,
investments::OrderManager, time::UnixTimeSecs, Permissions as PermissionsT, PoolUpdateGuard,
PreConditions,
};
use cfg_types::{
domain_address::DomainAddress,
Expand Down Expand Up @@ -61,7 +62,7 @@ use frame_support::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, Contains, EitherOfDiverse,
EqualPrivilegeOnly, Get, InstanceFilter, LinearStoragePrice, LockIdentifier, OnFinalize,
PalletInfoAccess, TransformOrigin, UnixTime, WithdrawReasons,
PalletInfoAccess, TransformOrigin, WithdrawReasons,
},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
Expand Down Expand Up @@ -465,7 +466,7 @@ impl orml_asset_registry::module::Config for Runtime {
}

parameter_types! {
pub const MinimumPeriod: Millis = SLOT_DURATION / 2;
pub MinimumPeriod: Millis = SLOT_DURATION / 2;
}
impl pallet_timestamp::Config for Runtime {
type MinimumPeriod = MinimumPeriod;
Expand Down Expand Up @@ -1306,7 +1307,7 @@ parameter_types! {
#[derive(scale_info::TypeInfo)]
pub const MaxGroups: u32 = 20;
pub const LiquidityRewardsPalletId: PalletId = cfg_types::ids::LIQUIDITY_REWARDS_PALLET_ID;
pub const InitialEpochDuration: Millis = SECONDS_PER_MINUTE * 1000; // 1 min in milliseconds
pub InitialEpochDuration: Millis = SECONDS_PER_MINUTE.into_millis();
}

impl pallet_rewards::mechanism::gap::Config for Runtime {
Expand Down Expand Up @@ -1351,10 +1352,10 @@ parameter_types! {
/// The index with which this pallet is instantiated in this runtime.
pub PoolPalletIndex: u8 = <PoolSystem as PalletInfoAccess>::index() as u8;

pub const MinUpdateDelay: u64 = if cfg!(feature = "runtime-benchmarks") {
0 // Disable update delay in benchmarks
pub const MinUpdateDelay: Seconds = if cfg!(feature = "runtime-benchmarks") {
Seconds::new(0) // Disable update delay in benchmarks
} else {
7 * SECONDS_PER_DAY // 7 days notice
SECONDS_PER_WEEK
};

pub const ChallengeTime: BlockNumber = if cfg!(feature = "runtime-benchmarks") {
Expand All @@ -1364,29 +1365,29 @@ parameter_types! {
};

// Defaults for pool parameters
pub const DefaultMinEpochTime: u64 = if cfg!(feature = "runtime-benchmarks") {
0 // Allow short epoch time in benchmarks and multiple close in one block
pub DefaultMinEpochTime: Seconds = if cfg!(feature = "runtime-benchmarks") {
Seconds::new(0) // Allow short epoch time in benchmarks and multiple close in one block
} else {
23 * SECONDS_PER_HOUR + 50 * SECONDS_PER_MINUTE // 23h and 50 minutes
SECONDS_PER_DAY - 10
};

pub const DefaultMaxNAVAge: u64 = if cfg!(feature = "runtime-benchmarks") {
1 * SECONDS_PER_HOUR // 1 hour
pub const DefaultMaxNAVAge: Seconds = if cfg!(feature = "runtime-benchmarks") {
SECONDS_PER_HOUR
} else {
0 // forcing update_nav + close epoch in same block
Seconds::new(0) // forcing update_nav + close epoch in same block
};

// Runtime-defined constraints for pool parameters
pub const MinEpochTimeLowerBound: u64 = if cfg!(feature = "runtime-benchmarks") {
0 // Allow short epoch time in benchmarks and multiple close in one block
pub const MinEpochTimeLowerBound: Seconds = if cfg!(feature = "runtime-benchmarks") {
Seconds::new(0) // Allow short epoch time in benchmarks and multiple close in one block
} else {
1 * SECONDS_PER_HOUR // 1 hour
SECONDS_PER_HOUR
};
pub const MinEpochTimeUpperBound: u64 = 30 * SECONDS_PER_DAY; // 1 month
pub const MaxNAVAgeUpperBound: u64 = if cfg!(feature = "runtime-benchmarks") {
1 * SECONDS_PER_HOUR // Allow an aged NAV in benchmarks
pub const MinEpochTimeUpperBound: Seconds = SECONDS_PER_MONTH;
pub const MaxNAVAgeUpperBound: Seconds = if cfg!(feature = "runtime-benchmarks") {
SECONDS_PER_HOUR // Allow an aged NAV in benchmarks
} else {
0
Seconds::new(0)
};

// Pool metadata limit
Expand Down Expand Up @@ -1537,7 +1538,7 @@ parameter_types! {

// How much time should lapse before a tranche investor can be removed
#[derive(Debug, Eq, PartialEq, scale_info::TypeInfo, Clone)]
pub const MinDelay: Seconds = 7 * SECONDS_PER_DAY;
pub const MinDelay: Seconds = SECONDS_PER_WEEK;

#[derive(Debug, Eq, PartialEq, scale_info::TypeInfo, Clone)]
pub const MaxRolesPerPool: u32 = 10_000;
Expand Down Expand Up @@ -1701,7 +1702,6 @@ impl pallet_loans::Config for Runtime {
type LoanId = LoanId;
type MaxActiveLoansPerPool = MaxActiveLoansPerPool;
type MaxWriteOffPolicySize = MaxWriteOffPolicySize;
type Moment = Millis;
type NonFungible = Uniques;
type PerThing = Perquintill;
type Permissions = Permissions;
Expand Down Expand Up @@ -2244,7 +2244,7 @@ impl_runtime_apis! {

impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration().inner)
}

fn authorities() -> Vec<AuraId> {
Expand Down Expand Up @@ -2310,7 +2310,7 @@ impl_runtime_apis! {
}

fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Quantity>>{
let now = <Timestamp as UnixTime>::now().as_secs();
let now = Timestamp::now_secs();
let mut pool = PoolSystem::pool(pool_id)?;
pool
.tranches
Expand Down
16 changes: 8 additions & 8 deletions runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,12 +1104,12 @@ parameter_types! {
/// The index with which this pallet is instantiated in this runtime.
pub PoolPalletIndex: u8 = <PoolSystem as PalletInfoAccess>::index() as u8;

pub const MinUpdateDelay: u64 = if cfg!(feature = "runtime-benchmarks") {
pub const MinUpdateDelay: Seconds = if cfg!(feature = "runtime-benchmarks") {
// Disable update delay in benchmarks
0
Seconds::new(0)
} else {
// Same as Lower bound for epochs.
1
Seconds::new(1)
};

pub const ChallengeTime: BlockNumber = if cfg!(feature = "runtime-benchmarks") {
Expand All @@ -1120,13 +1120,13 @@ parameter_types! {
};

// Defaults for pool parameters
pub const DefaultMinEpochTime: u64 = 0; // No minimum epoch time
pub const DefaultMaxNAVAge: Seconds = SECONDS_PER_MINUTE; // 1 minute
pub const DefaultMinEpochTime: Seconds = Seconds::new(0); // No minimum epoch time
pub const DefaultMaxNAVAge: Seconds = SECONDS_PER_MINUTE;

// Runtime-defined constraints for pool parameters
pub const MinEpochTimeLowerBound: u64 = 0; // Allow closing an epoch in the same block as the creation of a pool and also multiple per block if wanted
pub const MinEpochTimeUpperBound: Seconds = SECONDS_PER_MONTH; // 1 month
pub const MaxNAVAgeUpperBound: Seconds = SECONDS_PER_HOUR; // 1 hour
pub const MinEpochTimeLowerBound: Seconds = Seconds::new(0); // Allow closing an epoch in the same block as the creation of a pool and also multiple per block if wanted
pub const MinEpochTimeUpperBound: Seconds = SECONDS_PER_MONTH;
pub const MaxNAVAgeUpperBound: Seconds = SECONDS_PER_HOUR;

// Pool metadata limit
#[derive(scale_info::TypeInfo, Eq, PartialEq, Debug, Clone, Copy )]
Expand Down

0 comments on commit e99544a

Please sign in to comment.