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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user