-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify RuntimeChange
to support easily new additions
#1637
Conversation
|
||
/// A change done in the runtime, shared between pallets | ||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] | ||
pub enum RuntimeChange<T: Changeable, Options: Clone = ()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key. If none option is passed (RuntimeChange<T>
), the behaviour is the expected one. If FastDelay
option is passed (RuntimeChange<T, FastDelay>
) the behaviour is hacked to be faster. But both are the same generic type and implementations for them are shared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it! Great idea, really, really nice!
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] | ||
pub struct FastDelay; | ||
|
||
impl<T: Changeable> From<RuntimeChange<T, FastDelay>> for PoolChangeProposal { | ||
fn from(runtime_change: RuntimeChange<T, FastDelay>) -> Self { | ||
let new_requirements = runtime_change | ||
.requirement_list() | ||
.into_iter() | ||
.map(|req| match req { | ||
Requirement::DelayTime(_) => Requirement::DelayTime(60), // 1 min | ||
req => req, | ||
}); | ||
|
||
PoolChangeProposal::new(new_requirements) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats great!
@wischli for reference for pool fees, this is how it looks now the addition of a new runtime change variant: https://github.com/centrifuge/centrifuge-chain/pull/1629/files#diff-617c568adf46d885f9ea8e1a77de91c3e9987002c2bdc0e03a084ddb69a7d65a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a ton for this incredible change! The boilerplate setup difference is ridiculous now: A few lines and that's it. Awesome work @lemunozm 🎉
* chore: init blank pool fees pallet * chore: apply workspace #1609 to pool-fees dummy * fix: docker-compose * feat: add changeguard pool fees support * wip: prepare payment logic * refactor: use reserve instead of nav * chore: add extrinsics * feat: prep + pay disbursements * refactor: Apply fees ChangeGuard to #1637 * feat: add pool fees to all runtimes * feat: add fees pool registration * fix: existing pool unit tests * fix: existing integration tests * docs: add pool fee types * wip: init fees unit tests * tests: extrinsics wip * chore: add events * tests: add pool fees unit tests * fix: support retroactive disbursements * refactor: add epoch transition hook * refactor: add pool fee prefix to types * refactor: remove redundand trait bounds * wip: pool system integration tests * refactor: move portfolio valuation from loans to cfg-types * chore: add pool fee account id * wip: pool fee nav * wip: fix uts * wip: fix apply review by @lemunozm * fix: issues after rebase * tests: add saturated_proration * refactor: simplify pool fee amounts * chore: aum + fix fees UTs * chore: apply AUM to pool-system * fix: remove AUM coupling in PoolFees * fix: transfer on close, unit tests * fix: use total nav * fix: taplo * fix: fee calc on nav closing * feat: impl TimeAsSecs for timestamp mock * fix: test on_closing instead of update_active_fees * fix: clippy * tests: fix + add missing pool fees * refactor: make update fees result instead of void * tests: add insufficient resource in p-system * bench: add pool fees, apply to system + registry * fix: tests * refactor: explicitly use Seconds in FeeAmountProration impl * docs: add PoolFeeAmount and NAV update * refactor: update NAV, total assets after review from @mustermeiszer * fix: clippy * refactor: Add PoolFeePayable * fix: clippy * fix: correct epoch execution with fees (#1695) * fix: correct epoch execution with fees * refactor: use new nav syntax * tests: fix auto epoch closing * feat: epoch execution migration * chore: add epoch migration to altair --------- Co-authored-by: William Freudenberger <[email protected]> --------- Co-authored-by: Guillermo Perez <[email protected]> Co-authored-by: Frederik Gartenmeister <[email protected]>
* chore: init blank pool fees pallet * chore: apply workspace #1609 to pool-fees dummy * fix: docker-compose * feat: add changeguard pool fees support * wip: prepare payment logic * refactor: use reserve instead of nav * chore: add extrinsics * feat: prep + pay disbursements * refactor: Apply fees ChangeGuard to #1637 * feat: add pool fees to all runtimes * feat: add fees pool registration * fix: existing pool unit tests * fix: existing integration tests * docs: add pool fee types * wip: init fees unit tests * tests: extrinsics wip * chore: add events * tests: add pool fees unit tests * fix: support retroactive disbursements * refactor: add epoch transition hook * refactor: add pool fee prefix to types * refactor: remove redundand trait bounds * wip: pool system integration tests * refactor: move portfolio valuation from loans to cfg-types * chore: add pool fee account id * wip: pool fee nav * wip: fix uts * wip: fix apply review by @lemunozm * fix: issues after rebase * tests: add saturated_proration * refactor: simplify pool fee amounts * chore: aum + fix fees UTs * chore: apply AUM to pool-system * fix: remove AUM coupling in PoolFees * fix: transfer on close, unit tests * fix: use total nav * fix: taplo * fix: fee calc on nav closing * feat: impl TimeAsSecs for timestamp mock * fix: test on_closing instead of update_active_fees * fix: clippy * tests: fix + add missing pool fees * refactor: make update fees result instead of void * tests: add insufficient resource in p-system * bench: add pool fees, apply to system + registry * fix: tests * refactor: explicitly use Seconds in FeeAmountProration impl * docs: add PoolFeeAmount and NAV update * refactor: update NAV, total assets after review from @mustermeiszer * fix: clippy * refactor: Add PoolFeePayable * fix: clippy * fix: correct epoch execution with fees (#1695) * fix: correct epoch execution with fees * refactor: use new nav syntax * tests: fix auto epoch closing * feat: epoch execution migration * chore: add epoch migration to altair --------- Co-authored-by: William Freudenberger <[email protected]> --------- Co-authored-by: Guillermo Perez <[email protected]> Co-authored-by: Frederik Gartenmeister <[email protected]>
Description
Currently, adding a new change to
RuntimeChange
implies a lot of boilerplate. WithFrom/TryInto
methods and duplicate the work forfast::RuntimeChange
version. This PR tries to ease the process.From/TryInto
methodsfast::RuntimeChange
type has benn removed, and nowRuntimeChange
allows itself to be parameterized with anOptions
type that gives it a specific behavior, i.e. a fast version ofRuntimeChange
.changes
module.Required by: