Skip to content

Commit

Permalink
fix: sync of icon chain processor
Browse files Browse the repository at this point in the history
  • Loading branch information
izyak committed Nov 23, 2023
1 parent a166816 commit 2cc9f1e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 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")

Check warning on line 500 in relayer/chains/icon/icon_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L500

Added line #L500 was not covered by tests
}
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
}

Check warning on line 675 in relayer/chains/icon/icon_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L669-L675

Added lines #L669 - L675 were not covered by tests

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,

Check warning on line 692 in relayer/chains/icon/icon_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L692

Added line #L692 was not covered by tests
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")

Check warning on line 291 in relayer/chains/icon/provider.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/provider.go#L291

Added line #L291 was not covered by tests
}
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")

Check warning on line 294 in relayer/chains/icon/provider.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/provider.go#L294

Added line #L294 was not covered by tests
}
// 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)))

Check warning on line 781 in relayer/chains/icon/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L781

Added line #L781 was not covered by tests

proof, err := icp.QueryIconProof(ctx, height, keyhash)
if err != nil {
Expand Down

0 comments on commit 2cc9f1e

Please sign in to comment.