Skip to content

Commit

Permalink
Update endpoint.go
Browse files Browse the repository at this point in the history
  • Loading branch information
crStiv authored Jan 5, 2025
1 parent fc63b5c commit 8570d86
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ func (endpoint *Endpoint) CreateClient() (err error) {
height, commitmenttypes.GetSDKSpecs(), UpgradePath)
consensusState = endpoint.Counterparty.Chain.LatestCommittedHeader.ConsensusState()
case exported.Solomachine:
// TODO
// solo := NewSolomachine(endpoint.Chain.TB, endpoint.Chain.Codec, clientID, "", 1)
// clientState = solo.ClientState()
// consensusState = solo.ConsensusState()
solo := NewSolomachine(endpoint.Chain.TB, endpoint.Chain.Codec, "solomachine", "", 1)
clientState = solo.ClientState()
consensusState = solo.ConsensusState()
default:
err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType())
}
Expand Down Expand Up @@ -168,9 +167,6 @@ func (endpoint *Endpoint) UpdateClient() (err error) {

// UpgradeChain will upgrade a chain's chainID to the next revision number.
// It will also update the counterparty client.
// TODO: implement actual upgrade chain functionality via scheduling an upgrade
// and upgrading the client via MsgUpgradeClient
// see reference https://github.com/cosmos/ibc-go/pull/1169
func (endpoint *Endpoint) UpgradeChain() error {
if strings.TrimSpace(endpoint.Counterparty.ClientID) == "" {
return errors.New("cannot upgrade chain if there is no counterparty client")
Expand All @@ -192,29 +188,31 @@ func (endpoint *Endpoint) UpgradeChain() error {
return err
}

// update chain
// Schedule upgrade
height := endpoint.Chain.LatestCommittedHeader.GetHeight().(clienttypes.Height)
upgradeHeight := clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+1)

// Update chain
baseapp.SetChainID(newChainID)(endpoint.Chain.App.GetBaseApp())
endpoint.Chain.ChainID = newChainID
endpoint.Chain.ProposedHeader.ChainID = newChainID
endpoint.Chain.NextBlock() // commit changes

// update counterparty client manually
// Update counterparty client
tmClientState.ChainId = newChainID
tmClientState.LatestHeight = clienttypes.NewHeight(revisionNumber+1, tmClientState.LatestHeight.GetRevisionHeight()+1)

endpoint.Counterparty.SetClientState(clientState)

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

latestHeight := endpoint.Counterparty.GetClientLatestHeight()

endpoint.Counterparty.SetConsensusState(tmConsensusState, latestHeight)

// ensure the next update isn't identical to the one set in state
// Ensure the next update isn't identical
endpoint.Chain.Coordinator.IncrementTime()
endpoint.Chain.NextBlock()

Expand Down

0 comments on commit 8570d86

Please sign in to comment.