You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From a review of crates/core/src/ledger/inflation.rs:
We should be able to have a standard PDController which takes standard parameters and outputs the control input.
This PD controller should be wrapped by a small function for proof-of-stake which needs to calculate the locked ratio before running the controller.
We should double-check that we're using checked arithmetic (with the various numeric types and possible operator overloading, it's not clear to me).
We do not need to store the locked ratio in storage; we can simply recalculate it when needed (we do need to store the old locked ratio, just as we need to store the old target amount, but this should be done by the PD controller with no knowledge of proof-of-stake specific semantics).
This file should be renamed to pd-controller or something more indicative, a PD controller alone has nothing to do with inflation. It should also be moved to a standalone crate instead of being in core.
The text was updated successfully, but these errors were encountered:
Here's how I think this could be done: there are seven common input parameters between the PoS and Shielded controllers:
locked_tokens
total_native_tokens
max_reward_rate
last_inflation_amount
p_gain_nom
d_gain_nom
epochs_per_year
Then there are two different values between them that can be generalized as a target value metric_tar and a previous value metric_last. For PoS, this is a token ratio, and for MASP, this is a token amount.
We can have a struct PDController that is initialized with nine values - the seven above and metric_tar and metric_last. The inflation I is simply max[0, min(I_max, I_last + C)].
The computation of C is not super nicely generalized though - I think it would require two inputs to do something like PDController::compute_control(coefficient, metric_cur).
We do not need to store the locked ratio in storage; we can simply recalculate it when needed (we do need to store the old locked ratio, just as we need to store the old target amount, but this should be done by the PD controller with no knowledge of proof-of-stake specific semantics).
We are already doing this - only the last locked ratio and last inflation amounts are stored.
From a review of
crates/core/src/ledger/inflation.rs
:PDController
which takes standard parameters and outputs the control input.pd-controller
or something more indicative, a PD controller alone has nothing to do with inflation. It should also be moved to a standalone crate instead of being incore
.The text was updated successfully, but these errors were encountered: