optim: shallow copy block header in Context (#19966)

This commit is contained in:
yihuang 2024-04-10 18:09:25 +08:00 committed by GitHub
parent 24d44b6506
commit a6f3fbfbeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -92,6 +92,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding
* (x/auth) [#19651](https://github.com/cosmos/cosmos-sdk/pull/19651) Allow empty public keys in `GetSignBytesAdapter`.
* (x/genutil) [#19735](https://github.com/cosmos/cosmos-sdk/pull/19735) Update genesis api to match new `appmodule.HasGenesis` interface.
* (server) [#19966](https://github.com/cosmos/cosmos-sdk/pull/19966) Return BlockHeader by shallow copy in server Context.
### Bug Fixes

View File

@ -6,7 +6,6 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/gogoproto/proto"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/header"
@ -91,10 +90,9 @@ func (c Context) StreamingManager() storetypes.StreamingManager { return c.strea
func (c Context) CometInfo() comet.Info { return c.cometInfo }
func (c Context) HeaderInfo() header.Info { return c.headerInfo }
// clone the header before returning
// BlockHeader returns the header by value.
func (c Context) BlockHeader() cmtproto.Header {
msg := proto.Clone(&c.header).(*cmtproto.Header)
return *msg
return c.header
}
// HeaderHash returns a copy of the header hash obtained during abci.RequestBeginBlock