From 50849372a52dffb6079f2712f5ae36082a8b2df5 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 19 Nov 2024 16:40:17 +0100 Subject: [PATCH] fix(baseapp): populate header info in `NewUncachedContext` --- baseapp/test_helpers.go | 11 +++++++++-- testutil/sims/app_helpers.go | 6 +----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/baseapp/test_helpers.go b/baseapp/test_helpers.go index 7cae8e541b7..cffc2589f08 100644 --- a/baseapp/test_helpers.go +++ b/baseapp/test_helpers.go @@ -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" @@ -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) @@ -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 { diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index ab41ed6f755..e19da3de00e 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -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" @@ -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 }