Skip to content

Commit

Permalink
chore: Update after review
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikthebird committed Jan 20, 2025
1 parent bd3b37b commit 5219196
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
5 changes: 0 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper"
solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint"
"github.com/spf13/cast"

Expand Down Expand Up @@ -701,9 +700,6 @@ func NewWasmApp(
tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
clientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)

smLightClientModule := solomachine.NewLightClientModule(appCodec, storeProvider)
clientKeeper.AddRoute(solomachine.ModuleName, &smLightClientModule)

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down Expand Up @@ -744,7 +740,6 @@ func NewWasmApp(
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
ibctm.NewAppModule(tmLightClientModule),
solomachine.NewAppModule(smLightClientModule),
// sdk
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
)
Expand Down
22 changes: 11 additions & 11 deletions tests/ibctesting/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory,
return NewTestChainWithValSet(t, coord, appFactory, chainID, valSet, signersByAddress, opts...)
}

// Add this helper method
func GetLatestHeight(clientState exported.ClientState) clienttypes.Height {
tmClientState, ok := clientState.(*ibctm.ClientState)
if !ok {
panic("invalid client state type")
}
return tmClientState.LatestHeight
}

// NewTestChainWithValSet initializes a new TestChain instance with the given validator set
// and signer array. It also initializes 10 Sender accounts with a balance of 10000000000000000000 coins of
// bond denom to use for tests.
Expand Down Expand Up @@ -306,7 +315,7 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl
func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height) {
clientState := chain.GetClientState(clientID)

consensusHeight := chain.GetLatestHeight(clientState)
consensusHeight := GetLatestHeight(clientState)
consensusKey := host.FullConsensusStateKey(clientID, consensusHeight)
proofConsensus, _ := chain.QueryProof(consensusKey)

Expand Down Expand Up @@ -427,15 +436,6 @@ func (chain *TestChain) CaptureIBCEvents(r *abci.ExecTxResult) {
}
}

// Add this helper method to TestChain
func (chain *TestChain) GetLatestHeight(clientState exported.ClientState) clienttypes.Height {
tmClientState, ok := clientState.(*ibctm.ClientState)
if !ok {
panic("invalid client state type")
}
return tmClientState.LatestHeight
}

// GetClientState retrieves the client state for the provided clientID. The client is
// expected to exist otherwise testing will fail.
func (chain *TestChain) GetClientState(clientID string) exported.ClientState {
Expand Down Expand Up @@ -503,7 +503,7 @@ func (chain *TestChain) ConstructUpdateCMTClientHeaderWithTrustedHeight(counterp
header := counterparty.LastHeader
// Relayer must query for LatestHeight on client to get TrustedHeight if the trusted height is not set
if trustedHeight.IsZero() {
trustedHeight = chain.GetLatestHeight(chain.GetClientState(clientID))
trustedHeight = GetLatestHeight(chain.GetClientState(clientID))
}
var (
cmtTrustedVals *cmttypes.ValidatorSet
Expand Down
8 changes: 3 additions & 5 deletions tests/ibctesting/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height) {
clientState := endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID)

// query proof on the counterparty using the latest height of the IBC client
return endpoint.QueryProofAtHeight(key, endpoint.Counterparty.Chain.GetLatestHeight(clientState).GetRevisionHeight())
return endpoint.QueryProofAtHeight(key, GetLatestHeight(clientState).GetRevisionHeight())
}

// QueryProofAtHeight queries proof associated with this endpoint using the proof height
Expand Down Expand Up @@ -197,7 +197,7 @@ func (endpoint *Endpoint) UpgradeChain() error {
Root: commitmenttypes.NewMerkleRoot(endpoint.Chain.LastHeader.Header.GetAppHash()),
NextValidatorsHash: endpoint.Chain.LastHeader.Header.NextValidatorsHash,
}
endpoint.Counterparty.SetConsensusState(consensusState, endpoint.Chain.GetLatestHeight(clientState))
endpoint.Counterparty.SetConsensusState(consensusState, GetLatestHeight(clientState))

// ensure the next update isn't identical to the one set in state
endpoint.Chain.Coordinator.IncrementTime()
Expand Down Expand Up @@ -301,7 +301,7 @@ func (endpoint *Endpoint) QueryConnectionHandshakeProof() (
clientKey := host.FullClientStateKey(endpoint.Counterparty.ClientID)
proofClient, proofHeight = endpoint.Counterparty.QueryProof(clientKey)

consensusHeight = endpoint.Chain.GetLatestHeight(clientState)
consensusHeight = GetLatestHeight(clientState)

// query proof for the consensus state on the counterparty
consensusKey := host.FullConsensusStateKey(endpoint.Counterparty.ClientID, consensusHeight)
Expand Down Expand Up @@ -423,8 +423,6 @@ func (endpoint *Endpoint) ChanCloseConfirm() error {
channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
proof, proofHeight := endpoint.Counterparty.QueryProof(channelKey)

// counterpartyUpgradeSequence uint64,

msg := channeltypes.NewMsgChannelCloseConfirm(
endpoint.ChannelConfig.PortID, endpoint.ChannelID,
proof, proofHeight,
Expand Down

0 comments on commit 5219196

Please sign in to comment.