Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

runtime: Refactor staking reward curve to be cached & dynamic #6469

@gavofyork

Description

@gavofyork

Staking reward curve is currently a static PiecewiseLinear, calculated once and only once in the block.

Instead, it should be a static, lazily cached value, not built unless needed, and re-built
in the case that input parameters have changed. The ideal_stake should be determined by the amount of parachain slots being bid on: this should be around (75 - 25.min(slots / 4))%.

We should probably introduce a new trait Curve, which declares the calculate_for_fraction_times_denominator function. PiecewiseLinear can impl this and staking pallet can require RewardCurve to impl it. We might get away with a simple RefCell to manage the cache and ensure that it can be updated as needed. Either way, we must ensure that the pieces are not recalculated on repeated calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions