refactor(staking): change historicalinfo to contain minimal set of data (#17655)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Marko
2023-09-19 10:59:04 +00:00
committed by GitHub
co-authored by Aleksandr Bezobchuk
parent 4ef0130bcd
commit c05ff14a97
15 changed files with 2556 additions and 1444 deletions
@@ -4,6 +4,7 @@
* 26 November 2019: Start of first version
* 2 December 2019: Final draft of first version
* 7 September 2023: Reduce HistoricalInfo type
## Context
@@ -16,10 +17,11 @@ The application MUST store the most recent `n` headers in a persistent store. At
The application MUST store this information by storing new headers immediately when handling `abci.RequestBeginBlock`:
```go
func BeginBlock(ctx sdk.Context, keeper HistoricalHeaderKeeper, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
func BeginBlock(ctx sdk.Context, keeper HistoricalHeaderKeeper) error {
info := HistoricalInfo{
Header: ctx.BlockHeader(),
ValSet: keeper.StakingKeeper.GetAllValidators(ctx), // note that this must be stored in a canonical order
apphash: ctx.HeaderInfo().AppHash,
Time: ctx.HeaderInfo().Time,
NextValidatorsHash: ctx.CometInfo().NextValidatorsHash,
}
keeper.SetHistoricalInfo(ctx, ctx.BlockHeight(), info)
n := keeper.GetParamRecentHeadersToStore()