From d353f11b9898952f19ee20d93feed569c7da0ee7 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Sat, 3 Feb 2024 15:48:58 +0100 Subject: [PATCH] fix: Set headerInfo in context on setState (#19338) --- CHANGELOG.md | 1 + baseapp/baseapp.go | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2356b9146675..ee3037aed524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Bug Fixes +* (baseapp) [#19338](https://github.com/cosmos/cosmos-sdk/pull/19338) Set HeaderInfo in context when calling `setState`. * (x/staking) [#19226](https://github.com/cosmos/cosmos-sdk/pull/19226) Ensure `GetLastValidators` in `x/staking` does not return an error when `MaxValidators` exceeds total number of bonded validators. * (baseapp) [#19198](https://github.com/cosmos/cosmos-sdk/pull/19198) Remove usage of pointers in logs in all OE goroutines. * (baseapp) [#19177](https://github.com/cosmos/cosmos-sdk/pull/19177) Fix baseapp DefaultProposalHandler same-sender non-sequential sequence diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 052d23ececdd..7f7ef4ac5279 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -17,6 +17,7 @@ import ( "golang.org/x/exp/maps" protov2 "google.golang.org/protobuf/proto" + "cosmossdk.io/core/header" errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "cosmossdk.io/store" @@ -479,11 +480,20 @@ func (app *BaseApp) IsSealed() bool { return app.sealed } // setState sets the BaseApp's state for the corresponding mode with a branched // multi-store (i.e. a CacheMultiStore) and a new Context with the same // multi-store branch, and provided header. -func (app *BaseApp) setState(mode execMode, header cmtproto.Header) { +func (app *BaseApp) setState(mode execMode, h cmtproto.Header) { ms := app.cms.CacheMultiStore() + headerInfo := header.Info{ + Height: h.Height, + Time: h.Time, + ChainID: h.ChainID, + AppHash: h.AppHash, + } baseState := &state{ - ms: ms, - ctx: sdk.NewContext(ms, false, app.logger).WithStreamingManager(app.streamingManager).WithBlockHeader(header), + ms: ms, + ctx: sdk.NewContext(ms, false, app.logger). + WithStreamingManager(app.streamingManager). + WithBlockHeader(h). + WithHeaderInfo(headerInfo), } switch mode {