Skip to content

Commit

Permalink
add EraInflationProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusrodri committed Nov 29, 2024
1 parent 04fcb2e commit cab04d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pallets/external-validators-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ pub mod pallet {
#[pallet::constant]
type DisputeStatementPoints: Get<u32>;

/// Provider to know how may tokens were inflated (added) in a specific era.
type EraInflationProvider: Get<u128>;

/// Provider to retrieve the current block timestamp.
type TimestampProvider: Get<u64>;

Expand Down Expand Up @@ -223,8 +226,7 @@ pub mod pallet {
timestamp: T::TimestampProvider::get(),
era_index,
total_points: utils.total_points,
// TODO: manage this in a proper way.
tokens_inflated: 0u128,
tokens_inflated: T::EraInflationProvider::get(),
rewards_merkle_root: utils.rewards_merkle_root,
};

Expand Down
8 changes: 8 additions & 0 deletions pallets/external-validators-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,19 @@ impl Get<u64> for TimestampProvider {
}
}

pub struct EraInflationProvider;
impl Get<u128> for EraInflationProvider {
fn get() -> u128 {
0u128
}
}

impl pallet_external_validators_rewards::Config for Test {
type EraIndexProvider = Mock;
type HistoryDepth = ConstU32<10>;
type BackingPoints = ConstU32<20>;
type DisputeStatementPoints = ConstU32<20>;
type EraInflationProvider = EraInflationProvider;
type TimestampProvider = TimestampProvider;
type Hashing = Keccak256;
type ValidateMessage = ();
Expand Down
10 changes: 10 additions & 0 deletions solo-chains/runtime/dancelight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,11 +1350,21 @@ impl Get<u64> for TimestampProvider {
}
}

// TODO: add a proper way to retrieve the inflated tokens.
// Will likely be through InflationRewards.
pub struct EraInflationProvider;
impl Get<u128> for EraInflationProvider {
fn get() -> u128 {
0u128
}
}

impl pallet_external_validators_rewards::Config for Runtime {
type EraIndexProvider = ExternalValidators;
type HistoryDepth = ConstU32<64>;
type BackingPoints = ConstU32<20>;
type DisputeStatementPoints = ConstU32<20>;
type EraInflationProvider = EraInflationProvider;
type TimestampProvider = TimestampProvider;
type Hashing = Keccak256;
type ValidateMessage = tp_bridge::MessageValidator<Runtime>;
Expand Down

0 comments on commit cab04d8

Please sign in to comment.