Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(testing): Implement Solomachine client and chain upgrade functionality in endpoint.go #7823

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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)

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion

Check failure on line 112 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

cannot use endpoint.Chain.TB (variable of type "testing".TB) as *"testing".T value in argument to NewSolomachine: need type assertion
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 @@

// 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 @@
return err
}

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

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

declared and not used: upgradeHeight (typecheck)

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

declared and not used: upgradeHeight) (typecheck)

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / lint

declared and not used: upgradeHeight) (typecheck)

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (00)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (01)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (02)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

declared and not used: upgradeHeight

Check failure on line 193 in testing/endpoint.go

View workflow job for this annotation

GitHub Actions / tests (03)

declared and not used: upgradeHeight

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning test

This definition of upgradeHeight is never used.

// 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
Loading