Skip to content

Commit

Permalink
optim: shallow copy block header in Context (cosmos#19966)
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang authored Apr 10, 2024
1 parent 24d44b6 commit a6f3fbf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a6f3fbf

Please sign in to comment.