Skip to content
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

fix(baseapp): populate header info in NewUncachedContext #22557

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions baseapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package baseapp
import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"

coreheader "cosmossdk.io/core/header"
errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -50,7 +51,8 @@ func (app *BaseApp) SimWriteState() {
func (app *BaseApp) NewContextLegacy(isCheckTx bool, header cmtproto.Header) sdk.Context {
if isCheckTx {
return sdk.NewContext(app.checkState.ms, true, app.logger).
WithMinGasPrices(app.minGasPrices).WithBlockHeader(header)
WithMinGasPrices(app.minGasPrices).
WithBlockHeader(header)
}

return sdk.NewContext(app.finalizeBlockState.ms, false, app.logger).WithBlockHeader(header)
Expand All @@ -62,7 +64,12 @@ func (app *BaseApp) NewContext(isCheckTx bool) sdk.Context {
}

func (app *BaseApp) NewUncachedContext(isCheckTx bool, header cmtproto.Header) sdk.Context {
return sdk.NewContext(app.cms, isCheckTx, app.logger).WithBlockHeader(header)
return sdk.NewContext(app.cms, isCheckTx, app.logger).
WithBlockHeader(header).
WithHeaderInfo(coreheader.Info{
Height: header.Height,
Time: header.Time,
})
}

func (app *BaseApp) GetContextForFinalizeBlock(txBytes []byte) sdk.Context {
Expand Down
6 changes: 1 addition & 5 deletions testutil/sims/app_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
cmtjson "github.com/cometbft/cometbft/libs/json"
cmttypes "github.com/cometbft/cometbft/types"

coreheader "cosmossdk.io/core/header"
corestore "cosmossdk.io/core/store"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/depinject"
Expand Down Expand Up @@ -131,10 +130,7 @@ func NextBlock(app *runtime.App, ctx sdk.Context, jumpTime time.Duration) (sdk.C
header.Time = newBlockTime
header.Height++

newCtx := app.BaseApp.NewUncachedContext(false, header).WithHeaderInfo(coreheader.Info{
Height: header.Height,
Time: header.Time,
})
newCtx := app.BaseApp.NewUncachedContext(false, header)

return newCtx, nil
}
Expand Down
Loading