Skip to content

Commit

Permalink
rename lastheader to latestcommittedheader (cosmos#5672)
Browse files Browse the repository at this point in the history
* renamed lastheader to latestcommittedheader

* chore: lint fixes

post github ui merge conflict linting fixes.

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
  • Loading branch information
chandiniv1 and DimitrisJim committed Jan 22, 2024
1 parent 5322823 commit 0ad8ab4
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions modules/core/02-client/types/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (suite *TypesTestSuite) TestPackConsensusState() {
},
{
"tendermint consensus",
suite.chainA.LastHeader.ConsensusState(),
suite.chainA.LatestCommittedHeader.ConsensusState(),
true,
},
{
Expand Down Expand Up @@ -129,7 +129,7 @@ func (suite *TypesTestSuite) TestPackClientMessage() {
},
{
"tendermint header",
suite.chainA.LastHeader,
suite.chainA.LatestCommittedHeader,
true,
},
{
Expand Down
6 changes: 3 additions & 3 deletions modules/core/03-connection/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)
connection = path.EndpointA.GetConnection()
height = suite.chainB.LastHeader.GetHeight()
height = suite.chainB.LatestCommittedHeader.GetHeight()
}, true},
{"client state not found", func() {}, false},
{"consensus state not found", func() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)
connection = path.EndpointA.GetConnection()
height = suite.chainB.LastHeader.GetHeight().Increment()
height = suite.chainB.LatestCommittedHeader.GetHeight().Increment()
}, false},
}

Expand All @@ -154,7 +154,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() {

if tc.expPass {
suite.Require().NoError(err)
suite.Require().EqualValues(uint64(suite.chainB.LastHeader.GetTime().UnixNano()), actualTimestamp)
suite.Require().EqualValues(uint64(suite.chainB.LatestCommittedHeader.GetTime().UnixNano()), actualTimestamp)
} else {
suite.Require().Error(err)
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (suite *AnteTestSuite) createAcknowledgementMessage(isRedundant bool) sdk.M

// createTimeoutMessage creates an Timeout message for a packet sent from chain B to chain A.
func (suite *AnteTestSuite) createTimeoutMessage(isRedundant bool) sdk.Msg {
height := suite.chainA.LastHeader.GetHeight()
height := suite.chainA.LatestCommittedHeader.GetHeight()
timeoutHeight := clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+1)

sequence, err := suite.path.EndpointB.SendPacket(timeoutHeight, 0, ibctesting.MockPacketData)
Expand Down Expand Up @@ -123,7 +123,7 @@ func (suite *AnteTestSuite) createTimeoutMessage(isRedundant bool) sdk.Msg {

// createTimeoutOnCloseMessage creates an TimeoutOnClose message for a packet sent from chain B to chain A.
func (suite *AnteTestSuite) createTimeoutOnCloseMessage(isRedundant bool) sdk.Msg {
height := suite.chainA.LastHeader.GetHeight()
height := suite.chainA.LatestCommittedHeader.GetHeight()
timeoutHeight := clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+1)

sequence, err := suite.path.EndpointB.SendPacket(timeoutHeight, 0, ibctesting.MockPacketData)
Expand Down
6 changes: 3 additions & 3 deletions modules/light-clients/07-tendermint/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (suite *TendermintTestSuite) TestInitialize() {
clientState := ibctm.NewClientState(
path.EndpointB.Chain.ChainID,
tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift,
suite.chainB.LastHeader.GetTrustedHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath,
suite.chainB.LatestCommittedHeader.GetTrustedHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath,
)

store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID)
Expand All @@ -287,11 +287,11 @@ func (suite *TendermintTestSuite) TestInitialize() {
if tc.expPass {
suite.Require().NoError(err, "valid case returned an error")
suite.Require().True(store.Has(host.ClientStateKey()))
suite.Require().True(store.Has(host.ConsensusStateKey(suite.chainB.LastHeader.GetTrustedHeight())))
suite.Require().True(store.Has(host.ConsensusStateKey(suite.chainB.LatestCommittedHeader.GetTrustedHeight())))
} else {
suite.Require().Error(err, "invalid case didn't return an error")
suite.Require().False(store.Has(host.ClientStateKey()))
suite.Require().False(store.Has(host.ConsensusStateKey(suite.chainB.LastHeader.GetTrustedHeight())))
suite.Require().False(store.Has(host.ConsensusStateKey(suite.chainB.LatestCommittedHeader.GetTrustedHeight())))
}
})
}
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/07-tendermint/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
)

func (suite *TendermintTestSuite) TestGetHeight() {
header := suite.chainA.LastHeader
header := suite.chainA.LatestCommittedHeader
suite.Require().NotEqual(uint64(0), header.GetHeight())
}

func (suite *TendermintTestSuite) TestGetTime() {
header := suite.chainA.LastHeader
header := suite.chainA.LatestCommittedHeader
suite.Require().NotEqual(time.Time{}, header.GetTime())
}

Expand All @@ -38,7 +38,7 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() {
header.SignedHeader.Commit.Height = -1
}, false},
{"signed header failed tendermint ValidateBasic", func() {
header = suite.chainA.LastHeader
header = suite.chainA.LatestCommittedHeader
header.SignedHeader.Commit = nil
}, false},
{"trusted height is equal to header height", func() {
Expand All @@ -52,7 +52,7 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() {
}, false},
{"header validator hash does not equal hash of validator set", func() {
// use chainB's randomly generated validator set
header.ValidatorSet = suite.chainB.LastHeader.ValidatorSet
header.ValidatorSet = suite.chainB.LatestCommittedHeader.ValidatorSet
}, false},
}

Expand All @@ -64,7 +64,7 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() {
suite.Run(tc.name, func() {
suite.SetupTest()

header = suite.chainA.LastHeader // must be explicitly changed in malleate
header = suite.chainA.LatestCommittedHeader // must be explicitly changed in malleate

tc.malleate()

Expand Down
20 changes: 10 additions & 10 deletions testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ type SenderAccount struct {
type TestChain struct {
testing.TB

Coordinator *Coordinator
App TestingApp
ChainID string
LastHeader *ibctm.Header // header for last block height committed
ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height
QueryServer types.QueryServer
TxConfig client.TxConfig
Codec codec.Codec
Coordinator *Coordinator
App TestingApp
ChainID string
LatestCommittedHeader *ibctm.Header // header for last block height committed
ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height
QueryServer types.QueryServer
TxConfig client.TxConfig
Codec codec.Codec

Vals *cmttypes.ValidatorSet
NextVals *cmttypes.ValidatorSet
Expand Down Expand Up @@ -306,7 +306,7 @@ func (chain *TestChain) commitBlock(res *abci.ResponseFinalizeBlock) {

// set the last header to the current header
// use nil trusted fields
chain.LastHeader = chain.CurrentTMClientHeader()
chain.LatestCommittedHeader = chain.CurrentTMClientHeader()

// val set changes returned from previous block get applied to the next validators
// of this block. See tendermint spec for details.
Expand Down Expand Up @@ -454,7 +454,7 @@ func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty *TestChain, c
// ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the
// light client on the source chain.
func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty *TestChain, clientID string, trustedHeight clienttypes.Height) (*ibctm.Header, error) {
header := counterparty.LastHeader
header := counterparty.LatestCommittedHeader
// Relayer must query for LatestHeight on client to get TrustedHeight if the trusted height is not set
if trustedHeight.IsZero() {
trustedHeight = chain.GetClientState(clientID).GetLatestHeight().(clienttypes.Height)
Expand Down
10 changes: 5 additions & 5 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func (endpoint *Endpoint) CreateClient() (err error) {
tmConfig, ok := endpoint.ClientConfig.(*TendermintConfig)
require.True(endpoint.Chain.TB, ok)

height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height)
height := endpoint.Counterparty.Chain.LatestCommittedHeader.GetHeight().(clienttypes.Height)
clientState = ibctm.NewClientState(
endpoint.Counterparty.Chain.ChainID, tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift,
height, commitmenttypes.GetSDKSpecs(), UpgradePath)
consensusState = endpoint.Counterparty.Chain.LastHeader.ConsensusState()
consensusState = endpoint.Counterparty.Chain.LatestCommittedHeader.ConsensusState()
case exported.Solomachine:
// TODO
// solo := NewSolomachine(endpoint.Chain.TB, endpoint.Chain.Codec, clientID, "", 1)
Expand Down Expand Up @@ -195,9 +195,9 @@ func (endpoint *Endpoint) UpgradeChain() error {
endpoint.Counterparty.SetClientState(clientState)

tmConsensusState := &ibctm.ConsensusState{
Timestamp: endpoint.Chain.LastHeader.GetTime(),
Root: commitmenttypes.NewMerkleRoot(endpoint.Chain.LastHeader.Header.GetAppHash()),
NextValidatorsHash: endpoint.Chain.LastHeader.Header.NextValidatorsHash,
Timestamp: endpoint.Chain.LatestCommittedHeader.GetTime(),
Root: commitmenttypes.NewMerkleRoot(endpoint.Chain.LatestCommittedHeader.Header.GetAppHash()),
NextValidatorsHash: endpoint.Chain.LatestCommittedHeader.Header.NextValidatorsHash,
}
endpoint.Counterparty.SetConsensusState(tmConsensusState, clientState.GetLatestHeight())

Expand Down
6 changes: 3 additions & 3 deletions testing/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ func (solo *Solomachine) ConnOpenInit(chain *TestChain, clientID string) string
func (solo *Solomachine) ConnOpenAck(chain *TestChain, clientID, connectionID string) {
tryProof := solo.GenerateConnOpenTryProof(clientID, connectionID)

clientState := ibctm.NewClientState(chain.ChainID, DefaultTrustLevel, TrustingPeriod, UnbondingPeriod, MaxClockDrift, chain.LastHeader.GetHeight().(clienttypes.Height), commitmenttypes.GetSDKSpecs(), UpgradePath)
clientState := ibctm.NewClientState(chain.ChainID, DefaultTrustLevel, TrustingPeriod, UnbondingPeriod, MaxClockDrift, chain.LatestCommittedHeader.GetHeight().(clienttypes.Height), commitmenttypes.GetSDKSpecs(), UpgradePath)
clientProof := solo.GenerateClientStateProof(clientState)

consensusState := chain.LastHeader.ConsensusState()
consensusHeight := chain.LastHeader.GetHeight()
consensusState := chain.LatestCommittedHeader.ConsensusState()
consensusHeight := chain.LatestCommittedHeader.GetHeight()
consensusProof := solo.GenerateConsensusStateProof(consensusState, consensusHeight)

msgConnOpenAck := connectiontypes.NewMsgConnectionOpenAck(
Expand Down

0 comments on commit 0ad8ab4

Please sign in to comment.