Skip to content

Commit

Permalink
fix: sync of icon chain processor (#196)
Browse files Browse the repository at this point in the history
* fix: sync of icon chain processor

* chore: unnecessary log

---------

Co-authored-by: viveksharmapoudel <[email protected]>
  • Loading branch information
izyak and viveksharmapoudel authored Nov 24, 2023
1 parent 6362f0a commit bb0a2e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 9 additions & 2 deletions relayer/chains/icon/icon_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func (icp *IconChainProcessor) SnapshotHeight(height int64) {
func (icp *IconChainProcessor) verifyBlock(ctx context.Context, ibcHeader provider.IBCHeader) error {
header, ok := ibcHeader.(IconIBCHeader)
if !ok {
return fmt.Errorf("Provided Header is not compatible with IBCHeader")
return fmt.Errorf("provided header is not compatible with IBCHeader")
}
if icp.firstTime {
proofContext, err := icp.chainProvider.GetProofContextByHeight(int64(header.MainHeight) - 1)
Expand Down Expand Up @@ -666,6 +666,13 @@ func (icp *IconChainProcessor) handlePathProcessorUpdate(ctx context.Context,
ibcHeaderCache processor.IBCHeaderCache) error {

chainID := icp.chainProvider.ChainId()
latestHeight, _ := icp.chainProvider.QueryLatestHeight(ctx)

inSync := false

if latestHeight != 0 && uint64(latestHeight)-latestHeader.Height() < 3 {
inSync = true
}

for _, pp := range icp.pathProcessors {
clientID := pp.RelevantClientID(chainID)
Expand All @@ -682,7 +689,7 @@ func (icp *IconChainProcessor) handlePathProcessorUpdate(ctx context.Context,
LatestBlock: icp.latestBlock,
LatestHeader: latestHeader,
IBCMessagesCache: messageCache,
InSync: true,
InSync: inSync,
ClientState: clientState,
ConnectionStateCache: icp.connectionStateCache.FilterForClient(clientID),
ChannelStateCache: icp.channelStateCache.FilterForClient(clientID, icp.channelConnections, icp.connectionClients),
Expand Down
4 changes: 2 additions & 2 deletions relayer/chains/icon/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ func (icp *IconProvider) ChannelProof(ctx context.Context, msg provider.ChannelI

func (icp *IconProvider) ValidatePacket(msgTransfer provider.PacketInfo, latestBlock provider.LatestBlock) error {
if msgTransfer.Sequence <= 0 {
return fmt.Errorf("Refuse to relay packet with sequence 0")
return fmt.Errorf("refuse to relay packet with sequence 0")
}
if len(msgTransfer.Data) == 0 {
return fmt.Errorf("Refuse to relay packet with empty data")
return fmt.Errorf("refuse to relay packet with empty data")
}
// This should not be possible, as it violates IBC spec
if msgTransfer.TimeoutHeight.IsZero() {
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/icon/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ func (icp *IconProvider) QueryPacketReceipt(ctx context.Context, height int64, c
return nil, err
}

keyhash := common.Sha3keccak256(common.GetPacketReceiptCommitmentPath(portid, channelid, big.NewInt(height)))
keyhash := common.Sha3keccak256(common.GetPacketReceiptCommitmentKey(portid, channelid, big.NewInt(height)))

proof, err := icp.QueryIconProof(ctx, height, keyhash)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions relayer/chains/wasm/wasm_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,6 @@ func (ccp *WasmChainProcessor) queryCycle(ctx context.Context, persistence *quer
persistence.latestHeight = status.SyncInfo.LatestBlockHeight
// ccp.chainProvider.setCometVersion(ccp.log, status.NodeInfo.Version)

ccp.log.Debug("Queried latest height",
zap.Int64("latest_height", persistence.latestHeight),
)

if ccp.metrics != nil {
ccp.CollectMetrics(ctx, persistence)
}
Expand Down

0 comments on commit bb0a2e4

Please sign in to comment.