Skip to content

Commit

Permalink
fix: add missing msg type when parse from event (#1196)
Browse files Browse the repository at this point in the history
* add missing EventTypeChannelClosed

* add missing EventTypeUpgradeChain EventTypeUpgradeClientProposal

* add change doc

* mark channel closed

* revert client types change

* reuse with messageInfo

* reuse with utils

* fix build

* Apply suggestions from code review

* fix resolve
  • Loading branch information
mmsqe committed Oct 17, 2023
1 parent cb4708b commit cc75c04
Show file tree
Hide file tree
Showing 11 changed files with 556 additions and 1,000 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [\#1178](https://github.com/cosmos/relayer/pull/1178) Add max-gas-amount parameter in chain configs.
* [\#1180](https://github.com/cosmos/relayer/pull/1180) Update SDK from v0.47.0 to v0.47.2.
* [\#1205](https://github.com/cosmos/relayer/pull/1205) Update ibc-go to v7.0.1.
* [\#1196](https://github.com/cosmos/relayer/pull/1196) Add missing `EventTypeChannelClosed` when parse from event.
* [\#1179](https://github.com/cosmos/relayer/pull/1179) Add extension-options parameter in chain configs and update SDK to v0.47.3.
* [\#1208](https://github.com/cosmos/relayer/pull/1208) Replace gogo/protobuf to cosmos/gogoproto.
* [\#1221](https://github.com/cosmos/relayer/pull/1221) Update cometbft to v0.37.2 and ibc-go to v7.2.0.
Expand Down
15 changes: 8 additions & 7 deletions relayer/chains/cosmos/cosmos_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/cosmos/relayer/v2/relayer/provider"

ctypes "github.com/cometbft/cometbft/rpc/core/types"
"github.com/cosmos/relayer/v2/relayer/chains"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
)
Expand Down Expand Up @@ -89,22 +90,22 @@ const (
// latestClientState is a map of clientID to the latest clientInfo for that client.
type latestClientState map[string]provider.ClientState

func (l latestClientState) update(ctx context.Context, clientInfo clientInfo, ccp *CosmosChainProcessor) {
existingClientInfo, ok := l[clientInfo.clientID]
func (l latestClientState) update(ctx context.Context, clientInfo chains.ClientInfo, ccp *CosmosChainProcessor) {
existingClientInfo, ok := l[clientInfo.ClientID]
var trustingPeriod time.Duration
if ok {
if clientInfo.consensusHeight.LT(existingClientInfo.ConsensusHeight) {
if clientInfo.ConsensusHeight.LT(existingClientInfo.ConsensusHeight) {
// height is less than latest, so no-op
return
}
trustingPeriod = existingClientInfo.TrustingPeriod
}
if trustingPeriod == 0 {
cs, err := ccp.chainProvider.queryTMClientState(ctx, 0, clientInfo.clientID)
cs, err := ccp.chainProvider.queryTMClientState(ctx, 0, clientInfo.ClientID)
if err != nil {
ccp.log.Error(
"Failed to query client state to get trusting period",
zap.String("client_id", clientInfo.clientID),
zap.String("client_id", clientInfo.ClientID),
zap.Error(err),
)
return
Expand All @@ -114,7 +115,7 @@ func (l latestClientState) update(ctx context.Context, clientInfo clientInfo, cc
clientState := clientInfo.ClientState(trustingPeriod)

// update latest if no existing state or provided consensus height is newer
l[clientInfo.clientID] = clientState
l[clientInfo.ClientID] = clientState
}

// Provider returns the ChainProvider, which provides the methods for querying, assembling IBC messages, and sending transactions.
Expand Down Expand Up @@ -467,7 +468,7 @@ func (ccp *CosmosChainProcessor) queryCycle(ctx context.Context, persistence *qu
// tx was not successful
continue
}
messages := ibcMessagesFromEvents(ccp.log, tx.Events, chainID, heightUint64, base64Encoded)
messages := chains.IbcMessagesFromEvents(ccp.log, tx.Events, chainID, heightUint64, base64Encoded)

for _, m := range messages {
ccp.handleMessage(ctx, m, ibcMessagesCache)
Expand Down
Loading

0 comments on commit cc75c04

Please sign in to comment.