Merge pull request from GHSA-86h5-xcpx-cfqc

* fix slashing hole with test

* release notes + changelog

* word

* date

* updates

---------

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
khanh
2024-02-27 17:28:05 +01:00
committed by GitHub
co-authored by Julien Robert
parent fcfc099953
commit c21c8249c8
5 changed files with 247 additions and 12 deletions
+31
View File
@@ -11,6 +11,8 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
coreheader "cosmossdk.io/core/header"
"cosmossdk.io/depinject"
sdkmath "cosmossdk.io/math"
@@ -107,6 +109,35 @@ func SetupAtGenesis(appConfig depinject.Config, extraOutputs ...interface{}) (*r
return SetupWithConfiguration(appConfig, cfg, extraOutputs...)
}
// NextBlock starts a new block.
func NextBlock(app *runtime.App, ctx sdk.Context, jumpTime time.Duration) (sdk.Context, error) {
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: ctx.BlockHeight(), Time: ctx.BlockTime()})
if err != nil {
return sdk.Context{}, err
}
_, err = app.Commit()
if err != nil {
return sdk.Context{}, err
}
newBlockTime := ctx.BlockTime().Add(jumpTime)
header := ctx.BlockHeader()
header.Time = newBlockTime
header.Height = header.Height + 1
newCtx := app.BaseApp.NewUncachedContext(false, header).WithHeaderInfo(coreheader.Info{
Height: header.Height,
Time: header.Time,
})
if err != nil {
return sdk.Context{}, err
}
return newCtx, err
}
// SetupWithConfiguration initializes a new runtime.App. A Nop logger is set in runtime.App.
// appConfig defines the application configuration (f.e. app_config.go).
// extraOutputs defines the extra outputs to be assigned by the dependency injector (depinject).