From 2b47327569855630758160f09f92ef3099df3e20 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:02:26 +0100 Subject: [PATCH] fix: Set headerInfo in context on setState (backport #19338) (#19342) Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Facundo --- CHANGELOG.md | 1 + baseapp/baseapp.go | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ffaf942c5..d3f574fc3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (baseapp) [#19338](https://github.com/cosmos/cosmos-sdk/pull/19338) Set HeaderInfo in context when calling `setState`. * (abci): [#19200](https://github.com/cosmos/cosmos-sdk/pull/19200) Ensure that sdk side ve math matches cometbft * [#19106](https://github.com/cosmos/cosmos-sdk/pull/19106) Allow empty public keys when setting signatures. Public keys aren't needed for every transaction. * (baseapp) [#19198](https://github.com/cosmos/cosmos-sdk/pull/19198) Remove usage of pointers in logs in all OE goroutines. diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index d651fc8c07..e7c3b5744d 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -16,6 +16,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" @@ -468,11 +469,19 @@ 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, header, false, app.logger).WithStreamingManager(app.streamingManager), + ms: ms, + ctx: sdk.NewContext(ms, h, false, app.logger). + WithStreamingManager(app.streamingManager). + WithHeaderInfo(headerInfo), } switch mode {