Skip to content

Commit

Permalink
fix: fetch proof from msg height not from latest height (#100)
Browse files Browse the repository at this point in the history
* fix: fetch proof from msg height not from latest height

* chore: archway module handle res nil condition in waitfortxresult

---------

Co-authored-by: izyak <76203436+izyak@users.noreply.github.com>
  • Loading branch information
viveksharmapoudel and izyak authored Jul 4, 2023
1 parent ec02b5f commit 7cc09d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions relayer/chains/archway/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,9 @@ func (ap *ArchwayProvider) waitForTxResult(
return nil, fmt.Errorf("timed out after: %d; %s", waitTimeout, ErrTimeoutAfterWaitingForTxBroadcast)
case <-time.After(time.Millisecond * 100):
res, err := ap.RPCClient.Tx(ctx, txHash, false)
if err == nil && res == nil {
continue
}
if err == nil {
return ap.mkTxResult(res)
}
Expand Down
13 changes: 6 additions & 7 deletions relayer/chains/icon/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ func (icp *IconProvider) NewClientState(
}

func (icp *IconProvider) ConnectionHandshakeProof(ctx context.Context, msgOpenInit provider.ConnectionInfo, height uint64) (provider.ConnectionProof, error) {

clientState, clientStateProof, consensusStateProof, connStateProof, proofHeight, err := icp.GenerateConnHandshakeProof(ctx, int64(height), msgOpenInit.ClientID, msgOpenInit.ConnID)
clientState, clientStateProof, consensusStateProof, connStateProof, proofHeight, err := icp.GenerateConnHandshakeProof(ctx, int64(msgOpenInit.Height), msgOpenInit.ClientID, msgOpenInit.ConnID)
if err != nil {
return provider.ConnectionProof{}, err
}
Expand Down Expand Up @@ -296,7 +295,7 @@ func (icp *IconProvider) ConnectionProof(ctx context.Context, msgOpenAck provide
}

func (icp *IconProvider) ChannelProof(ctx context.Context, msg provider.ChannelInfo, height uint64) (provider.ChannelProof, error) {
channelResult, err := icp.QueryChannel(ctx, int64(height), msg.ChannelID, msg.PortID)
channelResult, err := icp.QueryChannel(ctx, int64(msg.Height), msg.ChannelID, msg.PortID)
if err != nil {
return provider.ChannelProof{}, nil
}
Expand Down Expand Up @@ -338,7 +337,7 @@ func (icp *IconProvider) ValidatePacket(msgTransfer provider.PacketInfo, latestB

func (icp *IconProvider) PacketCommitment(ctx context.Context, msgTransfer provider.PacketInfo, height uint64) (provider.PacketProof, error) {
packetCommitmentResponse, err := icp.QueryPacketCommitment(
ctx, int64(height), msgTransfer.SourceChannel, msgTransfer.SourcePort, msgTransfer.Sequence,
ctx, int64(msgTransfer.Height), msgTransfer.SourceChannel, msgTransfer.SourcePort, msgTransfer.Sequence,
)

if err != nil {
Expand All @@ -351,7 +350,7 @@ func (icp *IconProvider) PacketCommitment(ctx context.Context, msgTransfer provi
}

func (icp *IconProvider) PacketAcknowledgement(ctx context.Context, msgRecvPacket provider.PacketInfo, height uint64) (provider.PacketProof, error) {
packetAckResponse, err := icp.QueryPacketAcknowledgement(ctx, int64(height), msgRecvPacket.SourceChannel, msgRecvPacket.SourcePort, msgRecvPacket.Sequence)
packetAckResponse, err := icp.QueryPacketAcknowledgement(ctx, int64(msgRecvPacket.Height), msgRecvPacket.SourceChannel, msgRecvPacket.SourcePort, msgRecvPacket.Sequence)
if err != nil {
return provider.PacketProof{}, nil
}
Expand All @@ -363,7 +362,7 @@ func (icp *IconProvider) PacketAcknowledgement(ctx context.Context, msgRecvPacke
}

func (icp *IconProvider) PacketReceipt(ctx context.Context, msgTransfer provider.PacketInfo, height uint64) (provider.PacketProof, error) {
packetReceiptResponse, err := icp.QueryPacketReceipt(ctx, int64(height), msgTransfer.SourceChannel, msgTransfer.SourcePort, msgTransfer.Sequence)
packetReceiptResponse, err := icp.QueryPacketReceipt(ctx, int64(msgTransfer.Height), msgTransfer.SourceChannel, msgTransfer.SourcePort, msgTransfer.Sequence)

if err != nil {
return provider.PacketProof{}, nil
Expand All @@ -376,7 +375,7 @@ func (icp *IconProvider) PacketReceipt(ctx context.Context, msgTransfer provider
}

func (icp *IconProvider) NextSeqRecv(ctx context.Context, msgTransfer provider.PacketInfo, height uint64) (provider.PacketProof, error) {
nextSeqRecvResponse, err := icp.QueryNextSeqRecv(ctx, int64(height), msgTransfer.DestChannel, msgTransfer.DestPort)
nextSeqRecvResponse, err := icp.QueryNextSeqRecv(ctx, int64(msgTransfer.Height), msgTransfer.DestChannel, msgTransfer.DestPort)
if err != nil {
return provider.PacketProof{}, nil
}
Expand Down

0 comments on commit 7cc09d5

Please sign in to comment.