Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: packet retention not clear #116

Merged
merged 11 commits into from
Jul 27, 2023
2 changes: 1 addition & 1 deletion relayer/chains/icon/icon_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,22 @@
return err
}

func (icp *IconChainProcessor) StartFromHeight(ctx context.Context) int {
cfg := icp.Provider().ProviderConfig().(*IconProviderConfig)
if cfg.StartHeight != 0 {
return int(cfg.StartHeight)
}
snapshotHeight, err := rlycommon.LoadSnapshotHeight(icp.Provider().ChainId())
if err != nil {
icp.log.Warn("Failed to load height from snapshot", zap.Error(err))
} else {
icp.log.Info("Obtained start height from config", zap.Int("height", snapshotHeight))
}
return snapshotHeight

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L157-L168

Added lines #L157 - L168 were not covered by tests
}

func (icp *IconChainProcessor) initializeConnectionState(ctx context.Context) error {
// TODO: review

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L172

Added line #L172 was not covered by tests
ctx, cancel := context.WithTimeout(ctx, queryTimeout)
defer cancel()

Expand Down Expand Up @@ -264,19 +264,19 @@
}

var err error
// processedheight := int64(icp.chainProvider.lastBTPBlockHeight)
// if processedheight == 0 {
processedheight := int64(icp.StartFromHeight(ctx))
if processedheight <= 0 {

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L267-L270

Added lines #L267 - L270 were not covered by tests
processedheight, err = icp.chainProvider.QueryLatestHeight(ctx)
if err != nil {
fmt.Println("Error fetching latest block")

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L273

Added line #L273 was not covered by tests
return err
}
}
// }

icp.log.Debug("Start to query from height", zap.Int64("height", processedheight))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L279

Added line #L279 was not covered by tests
// subscribe to monitor block
ctxMonitorBlock, cancelMonitorBlock := context.WithCancel(ctx)
reconnect()
Expand All @@ -286,7 +286,7 @@
icp.firstTime = true

blockReq := &types.BlockRequest{
Height: types.NewHexInt(int64(icp.chainProvider.PCfg.StartHeight)),

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L289

Added line #L289 was not covered by tests
EventFilters: GetMonitorEventFilters(icp.chainProvider.PCfg.IbcHandlerAddress),
}

Expand All @@ -313,7 +313,7 @@
}, func(conn *websocket.Conn) {
}, func(conn *websocket.Conn, err error) {})
if err != nil {
icp.SnapshotHeight(int(processedheight) - 5)

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L316

Added line #L316 was not covered by tests
if errors.Is(err, context.Canceled) {
return
}
Expand All @@ -325,15 +325,15 @@
}(ctxMonitorBlock, cancelMonitorBlock)
case br := <-btpBlockRespCh:
for ; br != nil; processedheight++ {
// verify BTP Block
err := icp.verifyBlock(ctx, br.Header)
if err != nil {
reconnect()
icp.log.Warn("failed to Verify BTP Block",
zap.Int64("got", br.Height),
zap.Error(err),
)
break

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L328-L336

Added lines #L328 - L336 were not covered by tests
}

icp.latestBlock = provider.LatestBlock{
Expand All @@ -351,7 +351,7 @@
icp.log.Info("Queried Latest height: ",
zap.String("chain id ", icp.chainProvider.ChainId()),
zap.Int64("height", br.Height))
err = icp.handlePathProcessorUpdate(ctx, br.Header, ibcMessageCache, ibcHeaderCache)
err = icp.handlePathProcessorUpdate(ctx, br.Header, ibcMessageCache, ibcHeaderCache.Clone())

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L354

Added line #L354 was not covered by tests
if err != nil {
reconnect()
icp.log.Warn("Reconnect: error occured during handle block response ",
Expand All @@ -359,12 +359,12 @@
)
break
}
time.Sleep(10 * time.Millisecond)

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L362

Added line #L362 was not covered by tests
icp.firstTime = false
if br = nil; len(btpBlockRespCh) > 0 {
br = <-btpBlockRespCh
}
icp.SnapshotHeight(int(icp.latestBlock.Height) - 5)

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L367

Added line #L367 was not covered by tests
}
// remove unprocessed blockResponses
for len(btpBlockRespCh) > 0 {
Expand Down Expand Up @@ -455,78 +455,78 @@
}
}

func (icp *IconChainProcessor) SnapshotHeight(height int) {

blockInterval := icp.Provider().ProviderConfig().GetBlockInterval()
snapshotThreshold := rlycommon.ONE_HOUR / int(blockInterval)

retryAfter := icp.Provider().ProviderConfig().GetFirstRetryBlockAfter()
snapshotHeight := height - int(retryAfter)

if snapshotHeight%snapshotThreshold == 0 {
err := rlycommon.SnapshotHeight(icp.Provider().ChainId(), height)
if err != nil {
icp.log.Warn("Failed saving height snapshot for height", zap.Int("height", height))
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L458-L470

Added lines #L458 - L470 were not covered by tests
}
}

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")
}
if icp.firstTime {
proofContext, err := icp.chainProvider.GetProofContextByHeight(int64(header.MainHeight) - 1)
if err != nil {
return err
}
icp.verifier = &Verifier{
nextProofContext: proofContext,
verifiedHeight: int64(header.MainHeight) - 1,
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L474-L487

Added lines #L474 - L487 were not covered by tests
}

if !ibcHeader.IsCompleteBlock() {
icp.verifier.nextProofContext = header.Validators
icp.verifier.verifiedHeight = int64(header.Height())
return nil
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L490-L494

Added lines #L490 - L494 were not covered by tests

// prevNetworkSectionHash would be nil for first block
if icp.verifier.prevNetworkSectionHash != nil &&
!bytes.Equal(icp.verifier.prevNetworkSectionHash, header.Header.PrevNetworkSectionHash) {
return fmt.Errorf("failed to match prevNetworkSectionHash")
}

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#L497-L500

Added lines #L497 - L500 were not covered by tests

sigs, err := icp.chainProvider.GetBTPProof(int64(header.MainHeight))
if err != nil {
return err
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L502-L505

Added lines #L502 - L505 were not covered by tests

decision := types.NewNetworkTypeSectionDecision(
getSrcNetworkId(icp.chainProvider.PCfg.ICONNetworkID),
icp.chainProvider.PCfg.BTPNetworkTypeID,
int64(header.MainHeight),
header.Header.Round,
types.NetworkTypeSection{
NextProofContextHash: header.Header.NextProofContextHash,
NetworkSectionsRoot: GetNetworkSectionRoot(header.Header),
})

valid, err := VerifyBtpProof(decision, sigs, icp.verifier.nextProofContext)
if err != nil {
return err
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L507-L520

Added lines #L507 - L520 were not covered by tests

if !valid {
return fmt.Errorf("failed to Verify block")
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L522-L524

Added lines #L522 - L524 were not covered by tests

icp.verifier.nextProofContext = header.Validators
icp.verifier.verifiedHeight = int64(header.Height())
icp.verifier.prevNetworkSectionHash = types.NewNetworkSection(header.Header).Hash()
return nil

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L526-L529

Added lines #L526 - L529 were not covered by tests
}

func (icp *IconChainProcessor) handleBTPBlockRequest(
Expand Down Expand Up @@ -662,7 +662,7 @@
ClientState: clientState,
ConnectionStateCache: icp.connectionStateCache.FilterForClient(clientID),
ChannelStateCache: icp.channelStateCache.FilterForClient(clientID, icp.channelConnections, icp.connectionClients),
IBCHeaderCache: ibcHeaderCache.Clone(),

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L665

Added line #L665 was not covered by tests
IsGenesis: icp.firstTime,
})
}
Expand All @@ -673,9 +673,9 @@
// clientState will return the most recent client state if client messages
// have already been observed for the clientID, otherwise it will query for it.
func (icp *IconChainProcessor) clientState(ctx context.Context, clientID string) (provider.ClientState, error) {
if state, ok := icp.latestClientState[clientID]; ok {
return state, nil
}

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L676-L678

Added lines #L676 - L678 were not covered by tests
cs, err := icp.chainProvider.QueryClientStateWithoutProof(ctx, int64(icp.latestBlock.Height), clientID)
if err != nil {
return provider.ClientState{}, err
Expand Down
9 changes: 4 additions & 5 deletions relayer/chains/icon/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
var _ provider.QueryProvider = &IconProvider{}

const (
epoch = 24 * 3600 * 1000
clientNameString = "07-tendermint-"
epoch = 24 * 3600 * 1000
)

type CallParamOption func(*types.CallParam)
Expand Down Expand Up @@ -82,12 +81,12 @@

// required for cosmos only
func (icp *IconProvider) QueryTx(ctx context.Context, hashHex string) (*provider.RelayerTxResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L84

Added line #L84 was not covered by tests
}

// required for cosmos only
func (icp *IconProvider) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*provider.RelayerTxResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L89

Added line #L89 was not covered by tests
}

func (icp *IconProvider) QueryLatestHeight(ctx context.Context) (int64, error) {
Expand Down Expand Up @@ -126,11 +125,11 @@
}

func (icp *IconProvider) QuerySendPacket(ctx context.Context, srcChanID, srcPortID string, sequence uint64) (provider.PacketInfo, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L128

Added line #L128 was not covered by tests
}

func (icp *IconProvider) QueryRecvPacket(ctx context.Context, dstChanID, dstPortID string, sequence uint64) (provider.PacketInfo, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L132

Added line #L132 was not covered by tests
}

func (icp *IconProvider) QueryBalance(ctx context.Context, keyName string) (sdk.Coins, error) {
Expand All @@ -144,17 +143,17 @@

// implementing is not required
func (icp *IconProvider) QueryBalanceWithAddress(ctx context.Context, addr string) (sdk.Coins, error) {
param := types.AddressParam{
Address: types.Address(addr),
}
balance, err := icp.client.GetBalance(&param)
if err != nil {
return nil, err
}
return sdk.Coins{sdk.Coin{
Denom: "ICX",
Amount: math.NewInt(balance.Int64()),
}}, nil

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L146-L156

Added lines #L146 - L156 were not covered by tests
}

func (icp *IconProvider) QueryUnbondingPeriod(context.Context) (time.Duration, error) {
Expand Down Expand Up @@ -293,15 +292,15 @@
}

func (icp *IconProvider) QueryUpgradedClient(ctx context.Context, height int64) (*clienttypes.QueryClientStateResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L295

Added line #L295 was not covered by tests
}

func (icp *IconProvider) QueryUpgradedConsState(ctx context.Context, height int64) (*clienttypes.QueryConsensusStateResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L299

Added line #L299 was not covered by tests
}

func (icp *IconProvider) QueryConsensusState(ctx context.Context, height int64) (ibcexported.ConsensusState, int64, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L303

Added line #L303 was not covered by tests
}

// query all the clients of the chain
Expand All @@ -318,7 +317,7 @@

identifiedClientStates := make(clienttypes.IdentifiedClientStates, 0)
for i := 0; i <= int(seq)-1; i++ {
clientIdentifier := fmt.Sprintf("%s%d", clientNameString, i)
clientIdentifier := common.GetIdentifier(common.TendermintLightClient, i)

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L320

Added line #L320 was not covered by tests
callParams := icp.prepareCallParams(MethodGetClientState, map[string]interface{}{
"clientId": clientIdentifier,
})
Expand Down Expand Up @@ -407,7 +406,7 @@
}

for i := 0; i <= int(nextSeq)-1; i++ {
connectionId := fmt.Sprintf("connection-%d", i)
connectionId := common.GetIdentifier(common.ConnectionKey, i)

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L409

Added line #L409 was not covered by tests
var conn_string_ types.HexBytes
err := icp.client.Call(icp.prepareCallParams(MethodGetConnection, map[string]interface{}{
"connectionId": connectionId,
Expand All @@ -424,7 +423,7 @@
continue
}
// Only return open conenctions
if conn.State == conntypes.OPEN {

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L426

Added line #L426 was not covered by tests
identifiedConn := conntypes.IdentifiedConnection{
Id: connectionId,
ClientId: conn.ClientId,
Expand Down Expand Up @@ -476,7 +475,7 @@
}

func (icp *IconProvider) QueryConnectionsUsingClient(ctx context.Context, height int64, clientid string) (*conntypes.QueryConnectionsResponse, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L478

Added line #L478 was not covered by tests
}
func (icp *IconProvider) GenerateConnHandshakeProof(ctx context.Context, height int64, clientId, connId string) (ibcexported.ClientState,
[]byte, []byte, []byte,
Expand Down Expand Up @@ -571,7 +570,7 @@
)

func (icp *IconProvider) QueryChannelClient(ctx context.Context, height int64, channelid, portid string) (*clienttypes.IdentifiedClientState, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L573

Added line #L573 was not covered by tests
}

// is not needed currently for the operation
Expand Down Expand Up @@ -609,7 +608,7 @@

for i := 0; i <= int(nextSeq)-1; i++ {
for _, portId := range allPorts {
channelId := fmt.Sprintf("channel-%d", i)
channelId := common.GetIdentifier(common.ChannelKey, i)

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L611

Added line #L611 was not covered by tests
var _channel types.HexBytes
err := icp.client.Call(icp.prepareCallParams(MethodGetChannel, map[string]interface{}{
"channelId": channelId,
Expand All @@ -634,7 +633,7 @@
}

// check if the channel is open
if channel.State == chantypes.OPEN {

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L636

Added line #L636 was not covered by tests
identifiedChannel := chantypes.IdentifiedChannel{
State: channel.State,
Ordering: channel.Ordering,
Expand All @@ -654,19 +653,19 @@

// required to flush packets
func (icp *IconProvider) QueryPacketCommitments(ctx context.Context, height uint64, channelid, portid string) (commitments *chantypes.QueryPacketCommitmentsResponse, err error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L656

Added line #L656 was not covered by tests
}

func (icp *IconProvider) QueryPacketAcknowledgements(ctx context.Context, height uint64, channelid, portid string) (acknowledgements []*chantypes.PacketState, err error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L660

Added line #L660 was not covered by tests
}

func (icp *IconProvider) QueryUnreceivedPackets(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L664

Added line #L664 was not covered by tests
}

func (icp *IconProvider) QueryUnreceivedAcknowledgements(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L668

Added line #L668 was not covered by tests
}

func (icp *IconProvider) QueryNextSeqRecv(ctx context.Context, height int64, channelid, portid string) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error) {
Expand Down Expand Up @@ -791,12 +790,12 @@
// ics 20 - transfer
// not required for icon
func (icp *IconProvider) QueryDenomTrace(ctx context.Context, denom string) (*transfertypes.DenomTrace, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L793

Added line #L793 was not covered by tests
}

// not required for icon
func (icp *IconProvider) QueryDenomTraces(ctx context.Context, offset, limit uint64, height int64) ([]transfertypes.DenomTrace, error) {
panic(fmt.Sprintf("%s%s", icp.ChainName(), NOT_IMPLEMENTED))

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

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/query.go#L798

Added line #L798 was not covered by tests
}

func (icp *IconProvider) QueryIconProof(ctx context.Context, height int64, keyHash []byte) ([]byte, error) {
Expand Down
11 changes: 6 additions & 5 deletions relayer/chains/icon/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)

func (icp *IconProvider) MsgCreateClient(clientState ibcexported.ClientState, consensusState ibcexported.ConsensusState) (provider.RelayerMessage, error) {

Check warning on line 37 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L37

Added line #L37 was not covered by tests
clientStateBytes, err := proto.Marshal(clientState)
if err != nil {
return nil, err
Expand Down Expand Up @@ -500,26 +500,26 @@
return nil, err
}

var currentValidatorList types.ValidatorList
// subtract 1 because it is a current validator not last validator
info, err := icp.client.GetNetworkTypeInfo(int64(latestIconHeader.Header.MainHeight-1), icp.PCfg.BTPNetworkTypeID)
if err != nil {
return nil, err
}

Check warning on line 508 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L503-L508

Added lines #L503 - L508 were not covered by tests

_, err = Base64ToData(string(info.NextProofContext), &currentValidatorList)

Check warning on line 510 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L510

Added line #L510 was not covered by tests
if err != nil {
return nil, err
}

var nextValidators types.ValidatorList
// subtract 1 because it is a current validator not last validator
next_info, err := icp.client.GetNetworkTypeInfo(int64(latestIconHeader.Header.MainHeight), icp.PCfg.BTPNetworkTypeID)
if err != nil {
return nil, err
}

Check warning on line 520 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L515-L520

Added lines #L515 - L520 were not covered by tests

_, err = Base64ToData(string(next_info.NextProofContext), &nextValidators)

Check warning on line 522 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L522

Added line #L522 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -535,11 +535,11 @@
PrevNetworkSectionHash: latestIconHeader.Header.PrevNetworkSectionHash,
MessageCount: latestIconHeader.Header.MessageCount,
MessageRoot: latestIconHeader.Header.MessageRoot,
NextValidators: nextValidators.Validators,

Check warning on line 538 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L538

Added line #L538 was not covered by tests
},
Signatures: btp_proof,
TrustedHeight: trustedHeight.RevisionHeight,
CurrentValidators: currentValidatorList.Validators,

Check warning on line 542 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L540-L542

Added lines #L540 - L542 were not covered by tests
}

return signedHeader, nil
Expand Down Expand Up @@ -738,7 +738,7 @@
// If update fails, the subsequent txn will fail, result of update not being fetched concurrently
switch m.Method {
case MethodUpdateClient:
icp.WaitForTxResult(asyncCtx, txhash, m.Method, defaultBroadcastWaitTimeout, asyncCallback)
return icp.WaitForTxResult(asyncCtx, txhash, m.Method, defaultBroadcastWaitTimeout, asyncCallback)

Check warning on line 741 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L741

Added line #L741 was not covered by tests
default:
go icp.WaitForTxResult(asyncCtx, txhash, m.Method, defaultBroadcastWaitTimeout, asyncCallback)
}
Expand All @@ -753,20 +753,20 @@
method string,
timeout time.Duration,
callback func(*provider.RelayerTxResponse, error),
) {
) error {
txhash := types.NewHexBytes(txHash)
_, txRes, err := icp.client.WaitForResults(asyncCtx, &types.TransactionHashParam{Hash: txhash})
if err != nil {
icp.log.Error("Failed to get txn result", zap.String("txHash", string(txhash)), zap.String("method", method), zap.Error(err))
if callback != nil {
callback(nil, err)
}
return
return err

Check warning on line 764 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L764

Added line #L764 was not covered by tests
}

height, err := txRes.BlockHeight.Value()
if err != nil {
return
return err

Check warning on line 769 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L769

Added line #L769 was not covered by tests
}

var eventLogs []provider.RelayerEvent
Expand All @@ -787,7 +787,7 @@
callback(nil, err)
}
icp.LogFailedTx(method, txRes, err)
return
return err

Check warning on line 790 in relayer/chains/icon/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/tx.go#L790

Added line #L790 was not covered by tests

}

Expand All @@ -803,6 +803,7 @@
}
// log successful txn
icp.LogSuccessTx(method, txRes)
return nil
}

func (icp *IconProvider) LogSuccessTx(method string, result *types.TransactionResult) {
Expand Down
6 changes: 3 additions & 3 deletions relayer/chains/wasm/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
NOT_IMPLEMENTED = " :: Not implemented for WASM"
)

func (ap *WasmProvider) QueryTx(ctx context.Context, hashHex string) (*provider.RelayerTxResponse, error) {

Check warning on line 42 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L42

Added line #L42 was not covered by tests
hash, err := hex.DecodeString(hashHex)
if err != nil {
return nil, err
Expand All @@ -61,7 +61,7 @@
}, nil

}
func (ap *WasmProvider) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*provider.RelayerTxResponse, error) {

Check warning on line 64 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L64

Added line #L64 was not covered by tests
if len(events) == 0 {
return nil, errors.New("must declare at least one event to search")
}
Expand Down Expand Up @@ -115,7 +115,7 @@
return events
}

func (ap *WasmProvider) QueryLatestHeight(ctx context.Context) (int64, error) {

Check warning on line 118 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L118

Added line #L118 was not covered by tests

stat, err := ap.RPCClient.Status(ctx)
if err != nil {
Expand All @@ -127,7 +127,7 @@
}

// QueryIBCHeader returns the IBC compatible block header at a specific height.
func (ap *WasmProvider) QueryIBCHeader(ctx context.Context, h int64) (provider.IBCHeader, error) {

Check warning on line 130 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L130

Added line #L130 was not covered by tests
if h == 0 {
return nil, fmt.Errorf("No header at height 0")
}
Expand All @@ -136,31 +136,31 @@
return nil, err
}

return NewWasmIBCHeaderFromLightBlock(lightBlock), nil

Check warning on line 139 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L139

Added line #L139 was not covered by tests
}

func (ap *WasmProvider) QueryLightBlock(ctx context.Context, h int64) (provider.IBCHeader, *tmtypes.LightBlock, error) {
if h == 0 {
return nil, nil, fmt.Errorf("No header at height 0")
}
lightBlock, err := ap.LightProvider.LightBlock(ctx, h)
if err != nil {
return nil, nil, err
}

Check warning on line 149 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L142-L149

Added lines #L142 - L149 were not covered by tests

return NewWasmIBCHeaderFromLightBlock(lightBlock), lightBlock, nil

Check warning on line 151 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L151

Added line #L151 was not covered by tests
}

// query packet info for sequence
func (ap *WasmProvider) QuerySendPacket(ctx context.Context, srcChanID, srcPortID string, sequence uint64) (provider.PacketInfo, error) {
return provider.PacketInfo{}, fmt.Errorf("Not implemented for Wasm")

Check warning on line 156 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L155-L156

Added lines #L155 - L156 were not covered by tests
}
func (ap *WasmProvider) QueryRecvPacket(ctx context.Context, dstChanID, dstPortID string, sequence uint64) (provider.PacketInfo, error) {
return provider.PacketInfo{}, fmt.Errorf("Not implemented for Wasm")

Check warning on line 159 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L158-L159

Added lines #L158 - L159 were not covered by tests
}

// bank
func (ap *WasmProvider) QueryBalance(ctx context.Context, keyName string) (sdk.Coins, error) {

Check warning on line 163 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L163

Added line #L163 was not covered by tests
addr, err := ap.ShowAddress(keyName)
if err != nil {
return nil, err
Expand All @@ -169,7 +169,7 @@
return ap.QueryBalanceWithAddress(ctx, addr)
}

func (ap *WasmProvider) QueryBalanceWithAddress(ctx context.Context, address string) (sdk.Coins, error) {

Check warning on line 172 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L172

Added line #L172 was not covered by tests
qc := bankTypes.NewQueryClient(ap)
p := DefaultPageRequest()
coins := sdk.Coins{}
Expand Down Expand Up @@ -205,13 +205,13 @@
}

// staking
func (ap *WasmProvider) QueryUnbondingPeriod(context.Context) (time.Duration, error) {
// move to provider, panic

Check warning on line 209 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L208-L209

Added lines #L208 - L209 were not covered by tests
return 0, nil
}

// ics 02 - client
func (ap *WasmProvider) QueryClientState(ctx context.Context, height int64, clientid string) (ibcexported.ClientState, error) {

Check warning on line 214 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L214

Added line #L214 was not covered by tests
clientStateRes, err := ap.QueryClientStateResponse(ctx, height, clientid)
if err != nil {
return nil, err
Expand All @@ -225,7 +225,7 @@
}

// TODO: Check revision number
func (ap *WasmProvider) QueryClientStateResponse(ctx context.Context, height int64, srcClientId string) (*clienttypes.QueryClientStateResponse, error) {

Check warning on line 228 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L228

Added line #L228 was not covered by tests

clS, err := ap.QueryClientStateContract(ctx, srcClientId)
if err != nil {
Expand All @@ -237,7 +237,7 @@
}

storageKey := getStorageKeyFromPath(common.GetClientStateCommitmentKey(srcClientId))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 240 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L240

Added line #L240 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -249,7 +249,7 @@
}, nil
}

func (ap *WasmProvider) QueryClientStateContract(ctx context.Context, clientId string) (*icon.ClientState, error) {

Check warning on line 252 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L252

Added line #L252 was not covered by tests
clientStateParam, err := types.NewClientState(clientId).Bytes()
if err != nil {
return nil, err
Expand All @@ -275,7 +275,7 @@
return iconClientState, nil
}

func (ap *WasmProvider) QueryConnectionContract(ctx context.Context, connId string) (*conntypes.ConnectionEnd, error) {

Check warning on line 278 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L278

Added line #L278 was not covered by tests
connStateParam, err := types.NewConnection(connId).Bytes()
if err != nil {
return nil, err
Expand All @@ -294,7 +294,7 @@
return &connS, nil
}

func (ap *WasmProvider) QueryChannelContract(ctx context.Context, portId, channelId string) (*chantypes.Channel, error) {

Check warning on line 297 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L297

Added line #L297 was not covered by tests
channelStateParam, err := types.NewChannel(portId, channelId).Bytes()
if err != nil {
return nil, err
Expand All @@ -312,7 +312,7 @@
return &channelS, nil
}

func (ap *WasmProvider) QueryClientConsensusState(ctx context.Context, chainHeight int64, clientid string, clientHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error) {

Check warning on line 315 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L315

Added line #L315 was not covered by tests
consensusStateParam, err := types.NewConsensusState(clientid, uint64(chainHeight)).Bytes()
consensusState, err := ap.QueryIBCHandlerContractProcessed(ctx, consensusStateParam)
if err != nil {
Expand All @@ -332,7 +332,7 @@
return clienttypes.NewQueryConsensusStateResponse(anyConsensusState, nil, clienttypes.NewHeight(0, uint64(chainHeight))), nil
}

func (ap *WasmProvider) QueryIBCHandlerContract(ctx context.Context, param wasmtypes.RawContractMessage) (*wasmtypes.QuerySmartContractStateResponse, error) {

Check warning on line 335 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L335

Added line #L335 was not covered by tests

return ap.QueryClient.SmartContractState(ctx, &wasmtypes.QuerySmartContractStateRequest{
Address: ap.PCfg.IbcHandlerAddress,
Expand All @@ -340,7 +340,7 @@
})
}

func (ap *WasmProvider) QueryIBCHandlerContractProcessed(ctx context.Context, param wasmtypes.RawContractMessage) ([]byte, error) {

Check warning on line 343 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L343

Added line #L343 was not covered by tests
res, err := ap.QueryIBCHandlerContract(ctx, param)
if err != nil {
return nil, err
Expand All @@ -348,15 +348,15 @@
return ProcessContractResponse(res)
}

func (ap *WasmProvider) QueryUpgradedClient(ctx context.Context, height int64) (*clienttypes.QueryClientStateResponse, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 352 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L351-L352

Added lines #L351 - L352 were not covered by tests
}

func (ap *WasmProvider) QueryUpgradedConsState(ctx context.Context, height int64) (*clienttypes.QueryConsensusStateResponse, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 356 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L355-L356

Added lines #L355 - L356 were not covered by tests
}

func (ap *WasmProvider) QueryConsensusState(ctx context.Context, height int64) (ibcexported.ConsensusState, int64, error) {

Check warning on line 359 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L359

Added line #L359 was not covered by tests

commit, err := ap.RPCClient.Commit(ctx, &height)
if err != nil {
Expand All @@ -381,7 +381,7 @@
return state, height, nil
}

func (ap *WasmProvider) getAllPorts(ctx context.Context) ([]string, error) {

Check warning on line 384 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L384

Added line #L384 was not covered by tests
param, err := types.NewGetAllPorts().Bytes()
if err != nil {
return make([]string, 0), err
Expand All @@ -399,7 +399,7 @@
return ports, nil
}

func (ap *WasmProvider) getNextSequence(ctx context.Context, methodName string) (int, error) {

Check warning on line 402 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L402

Added line #L402 was not covered by tests
switch methodName {
case MethodGetNextClientSequence:
param, err := types.NewNextClientSequence().Bytes()
Expand Down Expand Up @@ -441,7 +441,7 @@
}
}

func (ap *WasmProvider) QueryClients(ctx context.Context) (clienttypes.IdentifiedClientStates, error) {

Check warning on line 444 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L444

Added line #L444 was not covered by tests

seq, err := ap.getNextSequence(ctx, MethodGetNextClientSequence)
if err != nil {
Expand All @@ -454,7 +454,7 @@

identifiedClientStates := make(clienttypes.IdentifiedClientStates, 0)
for i := 0; i <= int(seq)-1; i++ {
clientIdentifier := fmt.Sprintf("%s-%d", ClientPrefix, i)
clientIdentifier := common.GetIdentifier(common.IconLightClient, i)

Check warning on line 457 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L457

Added line #L457 was not covered by tests
clientState, err := ap.QueryClientStateContract(ctx, clientIdentifier)
if err != nil {
return nil, err
Expand All @@ -466,7 +466,7 @@
}

// ics 03 - connection
func (ap *WasmProvider) QueryConnection(ctx context.Context, height int64, connectionid string) (*conntypes.QueryConnectionResponse, error) {

Check warning on line 469 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L469

Added line #L469 was not covered by tests
connectionStateParams, err := types.NewConnection(connectionid).Bytes()
if err != nil {
return nil, err
Expand All @@ -484,12 +484,12 @@
}

storageKey := getStorageKeyFromPath(common.GetConnectionCommitmentKey(connectionid))
connProof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 487 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L487

Added line #L487 was not covered by tests

return conntypes.NewQueryConnectionResponse(conn, connProof, clienttypes.NewHeight(0, uint64(height))), nil
}

func (ap *WasmProvider) QueryWasmProof(ctx context.Context, storageKey []byte, height int64) ([]byte, error) {

Check warning on line 492 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L492

Added line #L492 was not covered by tests
ibcAddr, err := sdk.AccAddressFromBech32(ap.PCfg.IbcHandlerAddress)
if err != nil {
return nil, err
Expand Down Expand Up @@ -533,7 +533,7 @@

}

func (ap *WasmProvider) QueryConnections(ctx context.Context) (conns []*conntypes.IdentifiedConnection, err error) {

Check warning on line 536 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L536

Added line #L536 was not covered by tests

seq, err := ap.getNextSequence(ctx, MethodGetNextConnectionSequence)
if err != nil {
Expand All @@ -545,14 +545,14 @@
}

for i := 0; i <= int(seq)-1; i++ {
connectionId := fmt.Sprintf("%s-%d", ConnectionPrefix, i)
connectionId := common.GetIdentifier(common.ConnectionKey, i)

Check warning on line 548 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L548

Added line #L548 was not covered by tests
conn, err := ap.QueryConnectionContract(ctx, connectionId)
if err != nil {
continue
}

// Only return open conenctions
if conn.State == conntypes.OPEN {

Check warning on line 555 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L555

Added line #L555 was not covered by tests
identifiedConn := conntypes.IdentifiedConnection{
Id: connectionId,
ClientId: conn.ClientId,
Expand All @@ -568,8 +568,8 @@
return conns, nil
}

func (ap *WasmProvider) QueryConnectionsUsingClient(ctx context.Context, height int64, clientid string) (*conntypes.QueryConnectionsResponse, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 572 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L571-L572

Added lines #L571 - L572 were not covered by tests
}

func (ap *WasmProvider) GenerateConnHandshakeProof(ctx context.Context, height int64, clientId, connId string) (clientState ibcexported.ClientState,
Expand All @@ -588,14 +588,14 @@
}

connStorageKey := getStorageKeyFromPath(common.GetConnectionCommitmentKey(connId))
proofConnBytes, err := ap.QueryWasmProof(ctx, connStorageKey, height)

Check warning on line 591 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L591

Added line #L591 was not covered by tests
if err != nil {
return nil, nil, nil, nil, nil, err

}

consStorageKey := getStorageKeyFromPath(common.GetConsensusStateCommitmentKey(clientId, big.NewInt(0), big.NewInt(height)))
proofConsensusBytes, err := ap.QueryWasmProof(ctx, consStorageKey, height)

Check warning on line 598 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L598

Added line #L598 was not covered by tests
if err != nil {
return nil, nil, nil, nil, nil, err
}
Expand All @@ -603,7 +603,7 @@
}

// ics 04 - channel
func (ap *WasmProvider) QueryChannel(ctx context.Context, height int64, channelid, portid string) (chanRes *chantypes.QueryChannelResponse, err error) {

Check warning on line 606 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L606

Added line #L606 was not covered by tests
channelParams, err := types.NewChannel(portid, channelid).Bytes()
if err != nil {
return nil, err
Expand All @@ -624,16 +624,16 @@
}

storageKey := getStorageKeyFromPath(common.GetChannelCommitmentKey(portid, channelid))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 627 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L627

Added line #L627 was not covered by tests

return chantypes.NewQueryChannelResponse(channelS, proof, clienttypes.NewHeight(0, uint64(height))), nil
}

func (ap *WasmProvider) QueryChannelClient(ctx context.Context, height int64, channelid, portid string) (*clienttypes.IdentifiedClientState, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 633 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L632-L633

Added lines #L632 - L633 were not covered by tests
}

func (ap *WasmProvider) QueryConnectionChannels(ctx context.Context, height int64, connectionid string) ([]*chantypes.IdentifiedChannel, error) {

Check warning on line 636 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L636

Added line #L636 was not covered by tests
allChannel, err := ap.QueryChannels(ctx)
if err != nil {
return nil, fmt.Errorf("error querying Channels %v", err)
Expand All @@ -647,7 +647,7 @@
return identifiedChannels, nil
}

func (ap *WasmProvider) QueryChannels(ctx context.Context) ([]*chantypes.IdentifiedChannel, error) {

Check warning on line 650 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L650

Added line #L650 was not covered by tests
nextSeq, err := ap.getNextSequence(ctx, MethodGetNextChannelSequence)
if err != nil {
return nil, err
Expand All @@ -664,14 +664,14 @@

for i := 0; i <= int(nextSeq)-1; i++ {
for _, portId := range allPorts {
channelId := fmt.Sprintf("%s-%d", ChannelPrefix, i)
channelId := common.GetIdentifier(common.ChannelKey, i)

Check warning on line 667 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L667

Added line #L667 was not covered by tests
channel, err := ap.QueryChannelContract(ctx, portId, channelId)
if err != nil {
continue
}

// check if the channel is open
if channel.State == chantypes.OPEN {

Check warning on line 674 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L674

Added line #L674 was not covered by tests
identifiedChannel := chantypes.IdentifiedChannel{
State: channel.State,
Ordering: channel.Ordering,
Expand All @@ -689,23 +689,23 @@
return channels, nil
}

func (ap *WasmProvider) QueryPacketCommitments(ctx context.Context, height uint64, channelid, portid string) (commitments *chantypes.QueryPacketCommitmentsResponse, err error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 693 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L692-L693

Added lines #L692 - L693 were not covered by tests
}

func (ap *WasmProvider) QueryPacketAcknowledgements(ctx context.Context, height uint64, channelid, portid string) (acknowledgements []*chantypes.PacketState, err error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 697 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L696-L697

Added lines #L696 - L697 were not covered by tests
}

func (ap *WasmProvider) QueryUnreceivedPackets(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 701 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L700-L701

Added lines #L700 - L701 were not covered by tests
}

func (ap *WasmProvider) QueryUnreceivedAcknowledgements(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 705 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L704-L705

Added lines #L704 - L705 were not covered by tests
}

func (ap *WasmProvider) QueryNextSeqRecv(ctx context.Context, height int64, channelid, portid string) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error) {

Check warning on line 708 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L708

Added line #L708 was not covered by tests
nextSeqRecvParams, err := types.NewNextSequenceReceive(portid, channelid).Bytes()
if err != nil {
return nil, err
Expand All @@ -715,7 +715,7 @@
return nil, err
}

proof, err := ap.QueryWasmProof(ctx, common.MustHexStrToBytes(STORAGEKEY__NextSequenceReceive), height)

Check warning on line 718 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L718

Added line #L718 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -727,7 +727,7 @@
}, nil
}

func (ap *WasmProvider) QueryPacketCommitment(ctx context.Context, height int64, channelid, portid string, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error) {

Check warning on line 730 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L730

Added line #L730 was not covered by tests
pktCommitmentParams, err := types.NewPacketCommitment(portid, channelid, seq).Bytes()
if err != nil {
return nil, err
Expand All @@ -737,7 +737,7 @@
return nil, err
}
storageKey := getStorageKeyFromPath(common.GetPacketCommitmentKey(portid, channelid, big.NewInt(int64(seq))))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 740 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L740

Added line #L740 was not covered by tests

if err != nil {
return nil, err
Expand All @@ -750,7 +750,7 @@

}

func (ap *WasmProvider) QueryPacketAcknowledgement(ctx context.Context, height int64, channelid, portid string, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error) {

Check warning on line 753 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L753

Added line #L753 was not covered by tests
pktAcknowledgementParams, err := types.NewPacketAcknowledgementCommitment(portid, channelid, seq).Bytes()
if err != nil {
return nil, err
Expand All @@ -760,7 +760,7 @@
return nil, err
}
storageKey := getStorageKeyFromPath(common.GetPacketAcknowledgementCommitmentKey(portid, channelid, big.NewInt(int64(seq))))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 763 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L763

Added line #L763 was not covered by tests

return &chantypes.QueryPacketAcknowledgementResponse{
Acknowledgement: pktAcknowledgement.Data.Bytes(),
Expand All @@ -769,11 +769,11 @@
}, nil
}

func (ap *WasmProvider) QueryPacketReceipt(ctx context.Context, height int64, channelid, portid string, seq uint64) (recRes *chantypes.QueryPacketReceiptResponse, err error) {

Check warning on line 772 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L772

Added line #L772 was not covered by tests

// getting proof from commitment map in contract
storageKey := getStorageKeyFromPath(common.GetPacketReceiptCommitmentKey(portid, channelid, big.NewInt(int64(seq))))
proof, err := ap.QueryWasmProof(ctx, storageKey, height)

Check warning on line 776 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L776

Added line #L776 was not covered by tests
if err != nil {
return nil, err
}
Expand All @@ -795,7 +795,7 @@
}, nil
}

func (ap *WasmProvider) GetCommitmentPrefixFromContract(ctx context.Context) ([]byte, error) {

Check warning on line 798 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L798

Added line #L798 was not covered by tests

pktCommitmentParams, err := types.NewCommitmentPrefix().Bytes()
if err != nil {
Expand All @@ -806,38 +806,38 @@
}

// ics 20 - transfer
func (ap *WasmProvider) QueryDenomTrace(ctx context.Context, denom string) (*transfertypes.DenomTrace, error) {
transfers, err := transfertypes.NewQueryClient(ap).DenomTrace(ctx,
&transfertypes.QueryDenomTraceRequest{
Hash: denom,
})
if err != nil {
return nil, err
}
return transfers.DenomTrace, nil

Check warning on line 817 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L809-L817

Added lines #L809 - L817 were not covered by tests
}
func (ap *WasmProvider) QueryDenomTraces(ctx context.Context, offset, limit uint64, height int64) ([]transfertypes.DenomTrace, error) {
qc := transfertypes.NewQueryClient(ap)
p := DefaultPageRequest()
transfers := []transfertypes.DenomTrace{}
for {
res, err := qc.DenomTraces(ctx,
&transfertypes.QueryDenomTracesRequest{
Pagination: p,
})

if err != nil || res == nil {
return nil, err
}

Check warning on line 831 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L819-L831

Added lines #L819 - L831 were not covered by tests

transfers = append(transfers, res.DenomTraces...)
next := res.GetPagination().GetNextKey()
if len(next) == 0 {
break

Check warning on line 836 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L833-L836

Added lines #L833 - L836 were not covered by tests
}

time.Sleep(PaginationDelay)
p.Key = next

Check warning on line 840 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L839-L840

Added lines #L839 - L840 were not covered by tests
}
return transfers, nil

Check warning on line 842 in relayer/chains/wasm/query.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/query.go#L842

Added line #L842 was not covered by tests
}
12 changes: 5 additions & 7 deletions relayer/chains/wasm/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
defaultDelayPeriod = uint64(0)
)

func (ap *WasmProvider) TxFactory() tx.Factory {

Check warning on line 66 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L66

Added line #L66 was not covered by tests
return tx.Factory{}.
WithAccountRetriever(ap).
WithChainID(ap.PCfg.ChainID).
Expand All @@ -71,12 +71,12 @@
WithGasAdjustment(ap.PCfg.GasAdjustment).
WithGasPrices(ap.PCfg.GasPrices).
WithKeybase(ap.Keybase).
WithSignMode(ap.PCfg.SignMode()).
WithSimulateAndExecute(true)

Check warning on line 75 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L74-L75

Added lines #L74 - L75 were not covered by tests
}

// PrepareFactory mutates the tx factory with the appropriate account number, sequence number, and min gas settings.
func (ap *WasmProvider) PrepareFactory(txf tx.Factory) (tx.Factory, error) {

Check warning on line 79 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L79

Added line #L79 was not covered by tests
var (
err error
from sdk.AccAddress
Expand Down Expand Up @@ -138,7 +138,7 @@
return txf, nil
}

func (pc *WasmProviderConfig) SignMode() signing.SignMode {

Check warning on line 141 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L141

Added line #L141 was not covered by tests
signMode := signing.SignMode_SIGN_MODE_UNSPECIFIED
switch pc.SignModeStr {
case "direct":
Expand All @@ -149,7 +149,7 @@
return signMode
}

func (ap *WasmProvider) NewClientState(dstChainID string, dstIBCHeader provider.IBCHeader, dstTrustingPeriod, dstUbdPeriod time.Duration, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool) (ibcexported.ClientState, error) {

Check warning on line 152 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L152

Added line #L152 was not covered by tests

return &itm.ClientState{
ChainId: dstChainID,
Expand All @@ -163,7 +163,7 @@
}, nil
}

func (ap *WasmProvider) MsgCreateClient(clientState ibcexported.ClientState, consensusState ibcexported.ConsensusState) (provider.RelayerMessage, error) {

Check warning on line 166 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L166

Added line #L166 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -188,15 +188,15 @@
return ap.NewWasmContractMessage(MethodCreateClient, params)
}

func (ap *WasmProvider) MsgUpgradeClient(srcClientId string, consRes *clienttypes.QueryConsensusStateResponse, clientRes *clienttypes.QueryClientStateResponse) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 192 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L191-L192

Added lines #L191 - L192 were not covered by tests
}

func (ap *WasmProvider) MsgSubmitMisbehaviour(clientID string, misbehaviour ibcexported.ClientMessage) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 196 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L195-L196

Added lines #L195 - L196 were not covered by tests
}

func (ap *WasmProvider) ValidatePacket(msgTransfer provider.PacketInfo, latest provider.LatestBlock) error {

Check warning on line 199 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L199

Added line #L199 was not covered by tests

if msgTransfer.Sequence == 0 {
return errors.New("refusing to relay packet with sequence: 0")
Expand Down Expand Up @@ -226,7 +226,7 @@
return nil
}

func (ap *WasmProvider) PacketCommitment(ctx context.Context, msgTransfer provider.PacketInfo, height uint64) (provider.PacketProof, error) {

Check warning on line 229 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L229

Added line #L229 was not covered by tests
packetCommitmentResponse, err := ap.QueryPacketCommitment(
ctx, int64(height), msgTransfer.SourceChannel, msgTransfer.SourcePort, msgTransfer.Sequence,
)
Expand All @@ -240,7 +240,7 @@
}, nil
}

func (ap *WasmProvider) PacketAcknowledgement(ctx context.Context, msgRecvPacket provider.PacketInfo, height uint64) (provider.PacketProof, error) {

Check warning on line 243 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L243

Added line #L243 was not covered by tests
packetAckResponse, err := ap.QueryPacketAcknowledgement(ctx, int64(height), msgRecvPacket.SourceChannel, msgRecvPacket.SourcePort, msgRecvPacket.Sequence)
if err != nil {
return provider.PacketProof{}, nil
Expand All @@ -251,7 +251,7 @@
}, nil
}

func (ap *WasmProvider) PacketReceipt(ctx context.Context, msgTransfer provider.PacketInfo, height uint64) (provider.PacketProof, error) {

Check warning on line 254 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L254

Added line #L254 was not covered by tests

packetReceiptResponse, err := ap.QueryPacketReceipt(ctx, int64(height), msgTransfer.SourceChannel, msgTransfer.SourcePort, msgTransfer.Sequence)

Expand All @@ -264,7 +264,7 @@
}, nil
}

func (ap *WasmProvider) NextSeqRecv(ctx context.Context, msgTransfer provider.PacketInfo, height uint64) (provider.PacketProof, error) {

Check warning on line 267 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L267

Added line #L267 was not covered by tests
nextSeqRecvResponse, err := ap.QueryNextSeqRecv(ctx, int64(height), msgTransfer.DestChannel, msgTransfer.DestPort)
if err != nil {
return provider.PacketProof{}, nil
Expand All @@ -275,12 +275,12 @@
}, nil
}

func (ap *WasmProvider) MsgTransfer(dstAddr string, amount sdk.Coin, info provider.PacketInfo) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))
return nil, fmt.Errorf("Not implemented for Wasm")

Check warning on line 280 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L278-L280

Added lines #L278 - L280 were not covered by tests
}

func (ap *WasmProvider) MsgRecvPacket(msgTransfer provider.PacketInfo, proof provider.PacketProof) (provider.RelayerMessage, error) {

Check warning on line 283 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L283

Added line #L283 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -296,7 +296,7 @@
return ap.NewWasmContractMessage(MethodRecvPacket, params)
}

func (ap *WasmProvider) MsgAcknowledgement(msgRecvPacket provider.PacketInfo, proof provider.PacketProof) (provider.RelayerMessage, error) {

Check warning on line 299 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L299

Added line #L299 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -313,7 +313,7 @@

}

func (ap *WasmProvider) MsgTimeout(msgTransfer provider.PacketInfo, proof provider.PacketProof) (provider.RelayerMessage, error) {

Check warning on line 316 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L316

Added line #L316 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -330,18 +330,16 @@
return ap.NewWasmContractMessage(MethodTimeoutPacket, params)
}

func (ap *WasmProvider) MsgTimeoutRequest(msgTransfer provider.PacketInfo, proof provider.PacketProof) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 334 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L333-L334

Added lines #L333 - L334 were not covered by tests
return nil, fmt.Errorf("MsgTimeoutRequest Not implemented for Wasm module")
}

// panic
func (ap *WasmProvider) MsgTimeoutOnClose(msgTransfer provider.PacketInfo, proofUnreceived provider.PacketProof) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 339 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L338-L339

Added lines #L338 - L339 were not covered by tests
return nil, nil
}

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

Check warning on line 342 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L342

Added line #L342 was not covered by tests
clientState, clientStateProof, consensusStateProof, connStateProof, proofHeight, err := ap.GenerateConnHandshakeProof(ctx, int64(height), msgOpenInit.ClientID, msgOpenInit.ConnID)
if err != nil {
return provider.ConnectionProof{}, err
Expand All @@ -356,7 +354,7 @@
}, nil
}

func (ap *WasmProvider) ConnectionProof(ctx context.Context, msgOpenAck provider.ConnectionInfo, height uint64) (provider.ConnectionProof, error) {

Check warning on line 357 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L357

Added line #L357 was not covered by tests
connState, err := ap.QueryConnection(ctx, int64(height), msgOpenAck.ConnID)
if err != nil {
return provider.ConnectionProof{}, err
Expand All @@ -367,7 +365,7 @@
}, nil
}

func (ap *WasmProvider) MsgConnectionOpenInit(info provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error) {

Check warning on line 368 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L368

Added line #L368 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -388,7 +386,7 @@

}

func (ap *WasmProvider) MsgConnectionOpenTry(msgOpenInit provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error) {

Check warning on line 389 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L389

Added line #L389 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand Down Expand Up @@ -423,7 +421,7 @@

}

func (ap *WasmProvider) MsgConnectionOpenAck(msgOpenTry provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error) {

Check warning on line 424 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L424

Added line #L424 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand Down Expand Up @@ -453,7 +451,7 @@
return ap.NewWasmContractMessage(MethodConnectionOpenAck, params)
}

func (ap *WasmProvider) MsgConnectionOpenConfirm(msgOpenAck provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error) {

Check warning on line 454 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L454

Added line #L454 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -467,7 +465,7 @@
return ap.NewWasmContractMessage(MethodConnectionOpenConfirm, params)
}

func (ap *WasmProvider) ChannelProof(ctx context.Context, msg provider.ChannelInfo, height uint64) (provider.ChannelProof, error) {

Check warning on line 468 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L468

Added line #L468 was not covered by tests
channelResult, err := ap.QueryChannel(ctx, int64(height), msg.ChannelID, msg.PortID)
if err != nil {
return provider.ChannelProof{}, nil
Expand All @@ -483,7 +481,7 @@
}, nil
}

func (ap *WasmProvider) MsgChannelOpenInit(info provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error) {

Check warning on line 484 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L484

Added line #L484 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -505,7 +503,7 @@
return ap.NewWasmContractMessage(MethodChannelOpenInit, params)
}

func (ap *WasmProvider) MsgChannelOpenTry(msgOpenInit provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error) {

Check warning on line 506 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L506

Added line #L506 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand Down Expand Up @@ -535,7 +533,7 @@
return ap.NewWasmContractMessage(MethodChannelOpenTry, params)
}

func (ap *WasmProvider) MsgChannelOpenAck(msgOpenTry provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error) {

Check warning on line 536 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L536

Added line #L536 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -553,7 +551,7 @@
return ap.NewWasmContractMessage(MethodChannelOpenAck, params)
}

func (ap *WasmProvider) MsgChannelOpenConfirm(msgOpenAck provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error) {

Check warning on line 554 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L554

Added line #L554 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -569,7 +567,7 @@
return ap.NewWasmContractMessage(MethodChannelOpenConfirm, params)
}

func (ap *WasmProvider) MsgChannelCloseInit(info provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error) {

Check warning on line 570 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L570

Added line #L570 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -584,7 +582,7 @@
return ap.NewWasmContractMessage(MethodChannelCloseInit, params)
}

func (ap *WasmProvider) MsgChannelCloseConfirm(msgCloseInit provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error) {

Check warning on line 585 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L585

Added line #L585 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -601,26 +599,26 @@
return ap.NewWasmContractMessage(MethodChannelCloseConfirm, params)
}

func (ap *WasmProvider) MsgUpdateClientHeader(latestHeader provider.IBCHeader, trustedHeight clienttypes.Height, trustedHeader provider.IBCHeader) (ibcexported.ClientMessage, error) {
trustedWasmHeader, ok := trustedHeader.(WasmIBCHeader)

Check warning on line 603 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L602-L603

Added lines #L602 - L603 were not covered by tests
if !ok {
return nil, fmt.Errorf("unsupported IBC trusted header type, expected: TendermintIBCHeader, actual: %T", trustedHeader)
}

latestWasmHeader, ok := latestHeader.(WasmIBCHeader)

Check warning on line 608 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L608

Added line #L608 was not covered by tests
if !ok {
return nil, fmt.Errorf("unsupported IBC header type, expected: TendermintIBCHeader, actual: %T", latestHeader)
}

return &itm.TmHeader{
SignedHeader: latestWasmHeader.SignedHeader,
ValidatorSet: latestWasmHeader.ValidatorSet,
TrustedValidators: trustedWasmHeader.ValidatorSet,

Check warning on line 616 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L614-L616

Added lines #L614 - L616 were not covered by tests
TrustedHeight: int64(trustedHeight.RevisionHeight),
}, nil
}

func (ap *WasmProvider) MsgUpdateClient(clientID string, dstHeader ibcexported.ClientMessage) (provider.RelayerMessage, error) {

Check warning on line 621 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L621

Added line #L621 was not covered by tests
signer, err := ap.Address()
if err != nil {
return nil, err
Expand All @@ -640,27 +638,27 @@

}

func (ap *WasmProvider) QueryICQWithProof(ctx context.Context, msgType string, request []byte, height uint64) (provider.ICQProof, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 642 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L641-L642

Added lines #L641 - L642 were not covered by tests
}

func (ap *WasmProvider) MsgSubmitQueryResponse(chainID string, queryID provider.ClientICQQueryID, proof provider.ICQProof) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 646 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L645-L646

Added lines #L645 - L646 were not covered by tests
}

func (ap *WasmProvider) RelayPacketFromSequence(ctx context.Context, src provider.ChainProvider, srch, dsth, seq uint64, srcChanID, srcPortID string, order chantypes.Order) (provider.RelayerMessage, provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 650 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L649-L650

Added lines #L649 - L650 were not covered by tests
}

func (ap *WasmProvider) AcknowledgementFromSequence(ctx context.Context, dst provider.ChainProvider, dsth, seq uint64, dstChanID, dstPortID, srcChanID, srcPortID string) (provider.RelayerMessage, error) {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 654 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L653-L654

Added lines #L653 - L654 were not covered by tests
}

func (ap *WasmProvider) SendMessage(ctx context.Context, msg provider.RelayerMessage, memo string) (*provider.RelayerTxResponse, bool, error) {

Check warning on line 657 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L657

Added line #L657 was not covered by tests
return ap.SendMessages(ctx, []provider.RelayerMessage{msg}, memo)
}

func (ap *WasmProvider) SendMessages(ctx context.Context, msgs []provider.RelayerMessage, memo string) (*provider.RelayerTxResponse, bool, error) {

Check warning on line 661 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L661

Added line #L661 was not covered by tests
var (
rlyResp *provider.RelayerTxResponse
callbackErr error
Expand All @@ -668,12 +666,12 @@
)

callback := func(rtr *provider.RelayerTxResponse, err error) {
callbackErr = err

if err != nil {
wg.Done()
return
}

Check warning on line 674 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L669-L674

Added lines #L669 - L674 were not covered by tests

for i, e := range rtr.Events {
if startsWithWasm(e.EventType) {
Expand Down Expand Up @@ -732,36 +730,36 @@

for _, msg := range msgs {
if msg == nil {
ap.log.Debug("One of the message of is nil ")

Check warning on line 733 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L733

Added line #L733 was not covered by tests
continue
}

wasmMsg, ok := msg.(*WasmContractMessage)

Check warning on line 737 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L737

Added line #L737 was not covered by tests
if !ok {
return fmt.Errorf("Wasm Message is not valid %s", wasmMsg.Type())

Check warning on line 739 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L739

Added line #L739 was not covered by tests
}

txBytes, sequence, err := ap.buildMessages(cliCtx, factory, wasmMsg.Msg)

Check warning on line 742 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L742

Added line #L742 was not covered by tests
if err != nil {
return err
}

if msg.Type() == MethodUpdateClient {
if err := ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, true); err != nil {
if strings.Contains(err.Error(), sdkerrors.ErrWrongSequence.Error()) {
ap.handleAccountSequenceMismatchError(err)
}
return fmt.Errorf("Wasm: failed during updateClient %v", err)

Check warning on line 752 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L748-L752

Added lines #L748 - L752 were not covered by tests
}
ap.updateNextAccountSequence(sequence + 1)

Check warning on line 754 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L754

Added line #L754 was not covered by tests
continue
}
if err := ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, false); err != nil {
if strings.Contains(err.Error(), sdkerrors.ErrWrongSequence.Error()) {
ap.handleAccountSequenceMismatchError(err)
}

Check warning on line 760 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L757-L760

Added lines #L757 - L760 were not covered by tests
}
ap.updateNextAccountSequence(sequence + 1)

Check warning on line 762 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L762

Added line #L762 was not covered by tests
}

//uncomment for saving msg
Expand All @@ -771,7 +769,7 @@

}

func (ap *WasmProvider) LogFailedTx(res *provider.RelayerTxResponse, err error, msgs []provider.RelayerMessage) {

Check warning on line 772 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L772

Added line #L772 was not covered by tests

fields := []zapcore.Field{zap.String("chain_id", ap.ChainId())}
// if res != nil {
Expand All @@ -784,7 +782,7 @@
// Make a copy since we may continue to the warning
errorFields := append(fields, zap.Error(err))
ap.log.Error(
"Failed sending wasm transaction",

Check warning on line 785 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L785

Added line #L785 was not covered by tests
errorFields...,
)

Expand All @@ -805,7 +803,7 @@
}

// LogSuccessTx take the transaction and the messages to create it and logs the appropriate data
func (ap *WasmProvider) LogSuccessTx(res *sdk.TxResponse, msgs []provider.RelayerMessage) {

Check warning on line 806 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L806

Added line #L806 was not covered by tests
// Include the chain_id
fields := []zapcore.Field{zap.String("chain_id", ap.ChainId())}

Expand Down Expand Up @@ -869,7 +867,7 @@

}

func (ap *WasmProvider) sdkError(codespace string, code uint32) error {

Check warning on line 870 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L870

Added line #L870 was not covered by tests
// ABCIError will return an error other than "unknown" if syncRes.Code is a registered error in syncRes.Codespace
// This catches all of the sdk errors https://github.com/cosmos/cosmos-sdk/blob/f10f5e5974d2ecbf9efc05bc0bfe1c99fdeed4b6/types/errors/errors.go
err := errors.Unwrap(sdkerrors.ABCIError(codespace, code, "error broadcasting transaction"))
Expand All @@ -879,7 +877,7 @@
return nil
}

func (ap *WasmProvider) buildMessages(clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) ([]byte, uint64, error) {

Check warning on line 880 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L880

Added line #L880 was not covered by tests
for _, msg := range msgs {
if err := msg.ValidateBasic(); err != nil {
return nil, 0, err
Expand Down Expand Up @@ -1013,8 +1011,7 @@
)

if shouldWait {
ap.waitForTx(asyncCtx, hexTx, msgs, asyncTimeout, asyncCallback)
return nil
return ap.waitForTx(asyncCtx, hexTx, msgs, asyncTimeout, asyncCallback)

Check warning on line 1014 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1014

Added line #L1014 was not covered by tests
}
go ap.waitForTx(asyncCtx, hexTx, msgs, asyncTimeout, asyncCallback)
return nil
Expand All @@ -1034,7 +1031,7 @@
asyncTimeout time.Duration, // timeout for waiting for block inclusion
asyncCallback func(*provider.RelayerTxResponse, error), // callback for success/fail of the wait for block inclusion
) error {
panic(fmt.Sprintf("%s%s", ap.ChainName(), NOT_IMPLEMENTED))

Check warning on line 1034 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1034

Added line #L1034 was not covered by tests
}

func (ap *WasmProvider) waitForTx(
Expand All @@ -1043,14 +1040,14 @@
msgs []provider.RelayerMessage, // used for logging only
waitTimeout time.Duration,
callback func(*provider.RelayerTxResponse, error),
) {
) error {

Check warning on line 1043 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1043

Added line #L1043 was not covered by tests
res, err := ap.waitForTxResult(ctx, txHash, waitTimeout)
if err != nil {
ap.log.Error("Failed to wait for block inclusion", zap.Error(err))
if callback != nil {
callback(nil, err)
}
return
return err

Check warning on line 1050 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1050

Added line #L1050 was not covered by tests
}

rlyResp := &provider.RelayerTxResponse{
Expand All @@ -1076,13 +1073,14 @@
callback(nil, err)
}
ap.LogFailedTx(rlyResp, nil, msgs)
return
return err

Check warning on line 1076 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1076

Added line #L1076 was not covered by tests
}

if callback != nil {
callback(rlyResp, nil)
}
ap.LogSuccessTx(res, msgs)
return nil

Check warning on line 1083 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1083

Added line #L1083 was not covered by tests
}

func (ap *WasmProvider) waitForTxResult(
Expand Down Expand Up @@ -1131,7 +1129,7 @@
AsAny() *codectypes.Any
}

func (ap *WasmProvider) mkTxResult(resTx *coretypes.ResultTx) (*sdk.TxResponse, error) {

Check warning on line 1132 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1132

Added line #L1132 was not covered by tests
txbz, err := ap.Cdc.TxConfig.TxDecoder()(resTx.Tx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1234,7 +1232,7 @@
}

// QueryABCI performs an ABCI query and returns the appropriate response and error sdk error code.
func (cc *WasmProvider) QueryABCI(ctx context.Context, req abci.RequestQuery) (abci.ResponseQuery, error) {

Check warning on line 1235 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1235

Added line #L1235 was not covered by tests
opts := rpcclient.ABCIQueryOptions{
Height: req.Height,
Prove: req.Prove,
Expand All @@ -1256,23 +1254,23 @@
return result.Response, nil
}

func (cc *WasmProvider) handleAccountSequenceMismatchError(err error) {

clientCtx := cc.ClientContext()
fmt.Println("client context is ", clientCtx.GetFromAddress())

_, seq, err := cc.ClientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, clientCtx.GetFromAddress())

// sequences := numRegex.FindAllString(err.Error(), -1)
// if len(sequences) != 2 {
// return
// }
// nextSeq, err := strconv.ParseUint(sequences[0], 10, 64)
if err != nil {
return
}

Check warning on line 1271 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1257-L1271

Added lines #L1257 - L1271 were not covered by tests

cc.nextAccountSeq = seq

Check warning on line 1273 in relayer/chains/wasm/tx.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/tx.go#L1273

Added line #L1273 was not covered by tests
}

func sdkErrorToGRPCError(resp abci.ResponseQuery) error {
Expand Down
6 changes: 6 additions & 0 deletions relayer/chains/wasm/wasm_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
Header *types.LightBlock
}

func NewWasmChainProcessor(log *zap.Logger, provider *WasmProvider, metrics *processor.PrometheusMetrics) *WasmChainProcessor {
return &WasmChainProcessor{

Check warning on line 68 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L67-L68

Added lines #L67 - L68 were not covered by tests
log: log.With(zap.String("chain_name", provider.ChainName()), zap.String("chain_id", provider.ChainId())),
chainProvider: provider,
latestClientState: make(latestClientState),
Expand All @@ -92,7 +92,7 @@
// 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 *WasmChainProcessor) {

Check warning on line 95 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L95

Added line #L95 was not covered by tests
existingClientInfo, ok := l[clientInfo.clientID]
var trustingPeriod time.Duration
if ok {
Expand Down Expand Up @@ -122,19 +122,19 @@
}

// Provider returns the ChainProvider, which provides the methods for querying, assembling IBC messages, and sending transactions.
func (ccp *WasmChainProcessor) Provider() provider.ChainProvider {

Check warning on line 125 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L125

Added line #L125 was not covered by tests
return ccp.chainProvider
}

// Set the PathProcessors that this ChainProcessor should publish relevant IBC events to.
// ChainProcessors need reference to their PathProcessors and vice-versa, handled by EventProcessorBuilder.Build().
func (ccp *WasmChainProcessor) SetPathProcessors(pathProcessors processor.PathProcessors) {

Check warning on line 131 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L131

Added line #L131 was not covered by tests
ccp.pathProcessors = pathProcessors
}

// latestHeightWithRetry will query for the latest height, retrying in case of failure.
// It will delay by latestHeightQueryRetryDelay between attempts, up to latestHeightQueryRetries.
func (ccp *WasmChainProcessor) latestHeightWithRetry(ctx context.Context) (latestHeight int64, err error) {

Check warning on line 137 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L137

Added line #L137 was not covered by tests
return latestHeight, retry.Do(func() error {
latestHeightQueryCtx, cancelLatestHeightQueryCtx := context.WithTimeout(ctx, queryTimeout)
defer cancelLatestHeightQueryCtx()
Expand All @@ -153,7 +153,7 @@

// nodeStatusWithRetry will query for the latest node status, retrying in case of failure.
// It will delay by latestHeightQueryRetryDelay between attempts, up to latestHeightQueryRetries.
func (ccp *WasmChainProcessor) nodeStatusWithRetry(ctx context.Context) (status *ctypes.ResultStatus, err error) {

Check warning on line 156 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L156

Added line #L156 was not covered by tests
return status, retry.Do(func() error {
latestHeightQueryCtx, cancelLatestHeightQueryCtx := context.WithTimeout(ctx, queryTimeout)
defer cancelLatestHeightQueryCtx()
Expand All @@ -172,7 +172,7 @@

// clientState will return the most recent client state if client messages
// have already been observed for the clientID, otherwise it will query for it.
func (ccp *WasmChainProcessor) clientState(ctx context.Context, clientID string) (provider.ClientState, error) {

Check warning on line 175 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L175

Added line #L175 was not covered by tests
if state, ok := ccp.latestClientState[clientID]; ok && state.TrustingPeriod > 0 {
return state, nil
}
Expand All @@ -198,24 +198,24 @@
balanceUpdateWaitDuration time.Duration
}

func (ccp *WasmChainProcessor) StartFromHeight(ctx context.Context) int {
cfg := ccp.Provider().ProviderConfig().(*WasmProviderConfig)
if cfg.StartHeight != 0 {
return int(cfg.StartHeight)
}
snapshotHeight, err := common.LoadSnapshotHeight(ccp.Provider().ChainId())
if err != nil {
ccp.log.Warn("Failed to load height from snapshot", zap.Error(err))
} else {
ccp.log.Info("Obtained start height from config", zap.Int("height", snapshotHeight))
}
return snapshotHeight

Check warning on line 212 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L201-L212

Added lines #L201 - L212 were not covered by tests
}

// Run starts the query loop for the chain which will gather applicable ibc messages and push events out to the relevant PathProcessors.
// The initialBlockHistory parameter determines how many historical blocks should be fetched and processed before continuing with current blocks.
// ChainProcessors should obey the context and return upon context cancellation.
func (ccp *WasmChainProcessor) Run(ctx context.Context, initialBlockHistory uint64) error {

Check warning on line 218 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L218

Added line #L218 was not covered by tests
// this will be used for persistence across query cycle loop executions
persistence := queryCyclePersistence{
minQueryLoopDuration: defaultMinQueryLoopDuration,
Expand All @@ -242,30 +242,30 @@
}

// this will make initial QueryLoop iteration look back initialBlockHistory blocks in history
latestQueriedBlock := ccp.StartFromHeight(ctx)

Check warning on line 245 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L245

Added line #L245 was not covered by tests
if latestQueriedBlock < 0 {
latestQueriedBlock = int(persistence.latestHeight - int64(initialBlockHistory))
if latestQueriedBlock < 0 {
latestQueriedBlock = 0
}

Check warning on line 250 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L247-L250

Added lines #L247 - L250 were not covered by tests
}

persistence.latestQueriedBlock = int64(latestQueriedBlock)

ccp.log.Info("Start to query from height ", zap.Int("height", latestQueriedBlock))

_, lightBlock, err := ccp.chainProvider.QueryLightBlock(ctx, persistence.latestQueriedBlock)
if err != nil {
ccp.log.Error("Failed to get ibcHeader",
zap.Int64("height", persistence.latestQueriedBlock),
zap.Any("error", err),
)
return err

Check warning on line 263 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L253-L263

Added lines #L253 - L263 were not covered by tests
}

ccp.verifier = &Verifier{
Header: lightBlock,
}

Check warning on line 268 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L266-L268

Added lines #L266 - L268 were not covered by tests

var eg errgroup.Group
eg.Go(func() error {
Expand All @@ -278,7 +278,7 @@
return err
}

ccp.log.Debug("Entering Wasm main query loop")

Check warning on line 281 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L281

Added line #L281 was not covered by tests

ticker := time.NewTicker(persistence.minQueryLoopDuration)
defer ticker.Stop()
Expand All @@ -297,7 +297,7 @@
}

// initializeConnectionState will bootstrap the connectionStateCache with the open connection state.
func (ccp *WasmChainProcessor) initializeConnectionState(ctx context.Context) error {

Check warning on line 300 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L300

Added line #L300 was not covered by tests
ctx, cancel := context.WithTimeout(ctx, queryTimeout)
defer cancel()
connections, err := ccp.chainProvider.QueryConnections(ctx)
Expand All @@ -317,7 +317,7 @@
}

// initializeChannelState will bootstrap the channelStateCache with the open channel state.
func (ccp *WasmChainProcessor) initializeChannelState(ctx context.Context) error {

Check warning on line 320 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L320

Added line #L320 was not covered by tests
ctx, cancel := context.WithTimeout(ctx, queryTimeout)
defer cancel()
channels, err := ccp.chainProvider.QueryChannels(ctx)
Expand All @@ -340,14 +340,20 @@
CounterpartyChannelID: ch.Counterparty.ChannelId,
CounterpartyPortID: ch.Counterparty.PortId,
}] = ch.State == chantypes.OPEN
ccp.log.Info("Found channel",
zap.String("channelID", ch.ChannelId),
zap.String("Port id ", ch.PortId))
zap.String("Counterparty Channel Id ", ch.Counterparty.ChannelId)
zap.String("Counterparty Port Id", ch.Counterparty.PortId)

Check warning on line 347 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L343-L347

Added lines #L343 - L347 were not covered by tests

}
return nil
}

func (ccp *WasmChainProcessor) queryCycle(ctx context.Context, persistence *queryCyclePersistence) error {

Check warning on line 353 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L353

Added line #L353 was not covered by tests
status, err := ccp.nodeStatusWithRetry(ctx)
if err != nil {
// don't want to cause WasmChainProcessor to quit here, can retry again next cycle.

Check warning on line 356 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L356

Added line #L356 was not covered by tests
ccp.log.Error(
"Failed to query node status after max attempts",
zap.Uint("attempts", latestHeightQueryRetries),
Expand All @@ -359,7 +365,7 @@
persistence.latestHeight = status.SyncInfo.LatestBlockHeight
// ccp.chainProvider.setCometVersion(ccp.log, status.NodeInfo.Version)

ccp.log.Info("Queried latest height",

Check warning on line 368 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L368

Added line #L368 was not covered by tests
zap.Int64("latest_height", persistence.latestHeight),
)

Expand Down Expand Up @@ -390,14 +396,14 @@

newLatestQueriedBlock := persistence.latestQueriedBlock
chainID := ccp.chainProvider.ChainId()
var latestHeader provider.IBCHeader

ccp.SnapshotHeight(int(persistence.latestHeight))

Check warning on line 401 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L399-L401

Added lines #L399 - L401 were not covered by tests

for i := persistence.latestQueriedBlock + 1; i <= persistence.latestHeight; i++ {
var eg errgroup.Group
var blockRes *ctypes.ResultBlockResults
var lightBlock *types.LightBlock

Check warning on line 406 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L406

Added line #L406 was not covered by tests
i := i
eg.Go(func() (err error) {
queryCtx, cancelQueryCtx := context.WithTimeout(ctx, blockResultsQueryTimeout)
Expand All @@ -409,7 +415,7 @@
eg.Go(func() (err error) {
queryCtx, cancelQueryCtx := context.WithTimeout(ctx, queryTimeout)
defer cancelQueryCtx()
latestHeader, lightBlock, err = ccp.chainProvider.QueryLightBlock(queryCtx, i)

Check warning on line 418 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L418

Added line #L418 was not covered by tests
return err
})

Expand All @@ -418,13 +424,13 @@
break
}

if err := ccp.Verify(ctx, lightBlock); err != nil {
ccp.log.Error("failed to Verify Wasm Header", zap.Int64("Height", blockRes.Height))
return err
}

Check warning on line 430 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L427-L430

Added lines #L427 - L430 were not covered by tests

ccp.log.Debug("Verified block ",
zap.Int64("height", lightBlock.Header.Height))

Check warning on line 433 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L432-L433

Added lines #L432 - L433 were not covered by tests

heightUint64 := uint64(i)

Expand Down Expand Up @@ -495,23 +501,23 @@
return nil
}

func (ccp *WasmChainProcessor) SnapshotHeight(height int) {

blockInterval := ccp.Provider().ProviderConfig().GetBlockInterval()
snapshotThreshold := common.ONE_HOUR / int(blockInterval)

retryAfter := ccp.Provider().ProviderConfig().GetFirstRetryBlockAfter()
snapshotHeight := height - int(retryAfter)

if snapshotHeight%snapshotThreshold == 0 {
err := common.SnapshotHeight(ccp.Provider().ChainId(), height)
if err != nil {
ccp.log.Warn("Failed saving height snapshot for height", zap.Int("height", height))
}

Check warning on line 516 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L504-L516

Added lines #L504 - L516 were not covered by tests
}
}

func (ccp *WasmChainProcessor) CollectMetrics(ctx context.Context, persistence *queryCyclePersistence) {

Check warning on line 520 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L520

Added line #L520 was not covered by tests
ccp.CurrentBlockHeight(ctx, persistence)

// Wait a while before updating the balance
Expand All @@ -521,47 +527,47 @@
}
}

func (ccp *WasmChainProcessor) CurrentBlockHeight(ctx context.Context, persistence *queryCyclePersistence) {

Check warning on line 530 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L530

Added line #L530 was not covered by tests
ccp.metrics.SetLatestHeight(ccp.chainProvider.ChainId(), persistence.latestHeight)
}

func (ccp *WasmChainProcessor) Verify(ctx context.Context, untrusted *types.LightBlock) error {

if untrusted.Height != ccp.verifier.Header.Height+1 {
return errors.New("headers must be adjacent in height")
}

Check warning on line 538 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L534-L538

Added lines #L534 - L538 were not covered by tests

if err := verifyNewHeaderAndVals(untrusted.SignedHeader,
untrusted.ValidatorSet,
ccp.verifier.Header.SignedHeader,
time.Now(), 0); err != nil {
return fmt.Errorf("Failed to verify Header: %v", err)
}

Check warning on line 545 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L540-L545

Added lines #L540 - L545 were not covered by tests

if !bytes.Equal(untrusted.Header.ValidatorsHash, ccp.verifier.Header.NextValidatorsHash) {
err := fmt.Errorf("expected old header next validators (%X) to match those from new header (%X)",
ccp.verifier.Header.NextValidatorsHash,
untrusted.Header.ValidatorsHash,
)
return err
}

Check warning on line 553 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L547-L553

Added lines #L547 - L553 were not covered by tests

if !bytes.Equal(untrusted.Header.LastBlockID.Hash.Bytes(), ccp.verifier.Header.Commit.BlockID.Hash.Bytes()) {
err := fmt.Errorf("expected LastBlockId Hash (%X) of current header to match those from trusted Header BlockID hash (%X)",
ccp.verifier.Header.NextValidatorsHash,
untrusted.Header.ValidatorsHash,
)
return err
}

Check warning on line 561 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L555-L561

Added lines #L555 - L561 were not covered by tests

// Ensure that +2/3 of new validators signed correctly.
if err := untrusted.ValidatorSet.VerifyCommitLight(ccp.verifier.Header.ChainID, untrusted.Commit.BlockID,
untrusted.Header.Height, untrusted.Commit); err != nil {
return fmt.Errorf("invalid header: %v", err)
}

Check warning on line 567 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L564-L567

Added lines #L564 - L567 were not covered by tests

ccp.verifier.Header = untrusted
return nil

Check warning on line 570 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L569-L570

Added lines #L569 - L570 were not covered by tests

}

Expand All @@ -570,40 +576,40 @@
untrustedVals *types.ValidatorSet,
trustedHeader *types.SignedHeader,
now time.Time,
maxClockDrift time.Duration) error {

if err := untrustedHeader.ValidateBasic(trustedHeader.ChainID); err != nil {
return fmt.Errorf("untrustedHeader.ValidateBasic failed: %w", err)
}

Check warning on line 583 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L579-L583

Added lines #L579 - L583 were not covered by tests

if untrustedHeader.Height <= trustedHeader.Height {
return fmt.Errorf("expected new header height %d to be greater than one of old header %d",
untrustedHeader.Height,
trustedHeader.Height)
}

Check warning on line 589 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L585-L589

Added lines #L585 - L589 were not covered by tests

if !untrustedHeader.Time.After(trustedHeader.Time) {
return fmt.Errorf("expected new header time %v to be after old header time %v",
untrustedHeader.Time,
trustedHeader.Time)
}

Check warning on line 595 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L591-L595

Added lines #L591 - L595 were not covered by tests

if !untrustedHeader.Time.Before(now.Add(maxClockDrift)) {
return fmt.Errorf("new header has a time from the future %v (now: %v; max clock drift: %v)",
untrustedHeader.Time,
now,
maxClockDrift)
}

Check warning on line 602 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L597-L602

Added lines #L597 - L602 were not covered by tests

if !bytes.Equal(untrustedHeader.ValidatorsHash, untrustedVals.Hash()) {
return fmt.Errorf("expected new header validators (%X) to match those that were supplied (%X) at height %d",
untrustedHeader.ValidatorsHash,
untrustedVals.Hash(),
untrustedHeader.Height,
)
}

Check warning on line 610 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L604-L610

Added lines #L604 - L610 were not covered by tests

return nil

Check warning on line 612 in relayer/chains/wasm/wasm_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/wasm/wasm_chain_processor.go#L612

Added line #L612 was not covered by tests
}

// func (ccp *WasmChainProcessor) CurrentRelayerBalance(ctx context.Context) {
Expand Down
7 changes: 5 additions & 2 deletions relayer/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ var (
EventTimeoutRequest = "TimeoutRequest(bytes)"
IconModule = "icon"
WasmModule = "wasm"
TendermintLightClient = "tendermint"
ArchwayModule = "archway"
TendermintLightClient = "07-tendermint"
IconLightClient = "iconclient"
ConnectionKey = "connection"
ChannelKey = "channel"
ONE_HOUR = 60 * 60 * 1000
NanosecondRatio = 1000_000
NanosecondRatio = 1000_000
)
7 changes: 7 additions & 0 deletions relayer/common/identifier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package common

import "fmt"

func GetIdentifier(name string, i int) string {
return fmt.Sprintf("%s-%d", name, i)
}
1 change: 0 additions & 1 deletion relayer/processor/message_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
src, dst *pathEndRuntime,
) error {

fmt.Println("inside process Messages")
// 2/3 rule enough_time_pass && context change in case of BTPBlock
needsClientUpdate, err := mp.shouldUpdateClientNow(ctx, src, dst)
if err != nil {
Expand All @@ -105,18 +104,18 @@
// Otherwise, it will be attempted if either 2/3 of the trusting period
// or the configured client update threshold duration has passed.
func (mp *messageProcessor) shouldUpdateClientNow(ctx context.Context, src, dst *pathEndRuntime) (bool, error) {
var err error

Check warning on line 107 in relayer/processor/message_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/message_processor.go#L107

Added line #L107 was not covered by tests
// handle if dst is IconLightClient
if ClientIsIcon(dst.clientState) {
header, found := nextIconIBCHeader(src.ibcHeaderCache.Clone(), dst.lastClientUpdateHeight)
if !found {
header, err = src.chainProvider.QueryIBCHeader(ctx, int64(src.latestBlock.Height))
if err != nil {
return false, err
}
if !header.IsCompleteBlock() {
return false, nil
}

Check warning on line 118 in relayer/processor/message_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/message_processor.go#L112-L118

Added lines #L112 - L118 were not covered by tests
}
if header.ShouldUpdateWithZeroMessage() {
return true, nil
Expand Down
10 changes: 9 additions & 1 deletion relayer/processor/path_end_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@
// this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet.
return false
}
if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.ProviderConfig().GetFirstRetryBlockAfter() {
return false
}

Check warning on line 497 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L495-L497

Added lines #L495 - L497 were not covered by tests
} else {
if blocksSinceLastProcessed < blocksToRetryAssemblyAfter {
// this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet.
Expand Down Expand Up @@ -532,18 +532,26 @@
case chantypes.EventTypeRecvPacket:
toDelete[eventType] = []uint64{sequence}
toDeleteCounterparty[chantypes.EventTypeSendPacket] = []uint64{sequence}
case chantypes.EventTypeWriteAck:
toDelete[eventType] = []uint64{sequence}
case common.EventTimeoutRequest:
toDelete[eventType] = []uint64{sequence}
toDeleteCounterparty[chantypes.EventTypeSendPacket] = []uint64{sequence}

Check warning on line 539 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L535-L539

Added lines #L535 - L539 were not covered by tests
case chantypes.EventTypeAcknowledgePacket, chantypes.EventTypeTimeoutPacket, chantypes.EventTypeTimeoutPacketOnClose:
toDelete[eventType] = []uint64{sequence}
toDeleteCounterparty[chantypes.EventTypeRecvPacket] = []uint64{sequence}
toDeleteCounterparty[chantypes.EventTypeWriteAck] = []uint64{sequence}
toDelete[chantypes.EventTypeAcknowledgePacket] = []uint64{sequence}

Check warning on line 544 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L543-L544

Added lines #L543 - L544 were not covered by tests
toDelete[chantypes.EventTypeSendPacket] = []uint64{sequence}
toDeleteCounterparty[common.EventTimeoutRequest] = []uint64{sequence}

Check warning on line 546 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L546

Added line #L546 was not covered by tests
}
// delete in progress send for this specific message
pathEnd.packetProcessing[k].deleteMessages(map[string][]uint64{
eventType: {sequence},
})
// delete all packet flow retention history for this sequence
pathEnd.messageCache.PacketFlow[k].DeleteMessages(toDelete)
counterparty.messageCache.PacketFlow[k].DeleteMessages(toDeleteCounterparty)
counterparty.messageCache.PacketFlow[k.Counterparty()].DeleteMessages(toDeleteCounterparty)

Check warning on line 554 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L554

Added line #L554 was not covered by tests
}

// shouldSendConnectionMessage determines if the connection handshake message should be sent now.
Expand Down Expand Up @@ -580,9 +588,9 @@
// this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet.
return false
}
if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.ProviderConfig().GetFirstRetryBlockAfter() {
return false
}

Check warning on line 593 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L591-L593

Added lines #L591 - L593 were not covered by tests
} else {
if blocksSinceLastProcessed < blocksToRetryAssemblyAfter {
// this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet.
Expand Down Expand Up @@ -660,9 +668,9 @@
// this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet.
return false
}
if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.ProviderConfig().GetFirstRetryBlockAfter() {
return false
}

Check warning on line 673 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L671-L673

Added lines #L671 - L673 were not covered by tests
} else {
if blocksSinceLastProcessed < blocksToRetryAssemblyAfter {
// this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet.
Expand Down
36 changes: 2 additions & 34 deletions relayer/processor/path_processor_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,9 @@
for seq, info := range pathEndPacketFlowMessages.DstMsgRecvPacket {
deletePreInitIfMatches(info)
toDeleteSrc[chantypes.EventTypeSendPacket] = append(toDeleteSrc[chantypes.EventTypeSendPacket], seq)
toDeleteDst[chantypes.EventTypeRecvPacket] = append(toDeleteDst[chantypes.EventTypeRecvPacket], seq)

Check warning on line 213 in relayer/processor/path_processor_internal.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_processor_internal.go#L212-L213

Added lines #L212 - L213 were not covered by tests
}
// if len(info.Ack) == 0 {
// // have recv_packet but not write_acknowledgement yet. skip for now.
// continue
// }
// // msg is received by dst chain, but no ack yet. Need to relay ack from dst to src!
// ackMsg := packetIBCMessage{
// eventType: chantypes.EventTypeAcknowledgePacket,
// info: info,
// }
// msgs = append(msgs, ackMsg)
// }

processRemovals()

Expand All @@ -234,7 +225,6 @@

for seq, msgTimeoutRequest := range pathEndPacketFlowMessages.DstMsgRequestTimeout {
toDeleteSrc[chantypes.EventTypeSendPacket] = append(toDeleteSrc[chantypes.EventTypeSendPacket], seq)
toDeleteDst[common.EventTimeoutRequest] = append(toDeleteDst[common.EventTimeoutRequest], seq)
timeoutMsg := packetIBCMessage{
eventType: chantypes.EventTypeTimeoutPacket,
info: msgTimeoutRequest,
Expand Down Expand Up @@ -1000,28 +990,6 @@
pathEnd2ProcessRes := make([]pathEndPacketFlowResponse, len(channelPairs))

for i, pair := range channelPairs {
// Append acks into recv packet info if present
// pathEnd1DstMsgRecvPacket :=
// for seq, ackInfo := range pp.pathEnd2.messageCache.PacketFlow[pair.pathEnd2ChannelKey][chantypes.EventTypeWriteAck] {
// if recvPacketInfo, ok := pathEnd1DstMsgRecvPacket[seq]; ok {
// recvPacketInfo.Ack = ackInfo.Ack
// pathEnd1DstMsgRecvPacket[seq] = recvPacketInfo
// continue
// }
// pathEnd1DstMsgRecvPacket[seq] = ackInfo

// }

// pathEnd2DstMsgRecvPacket := pp.pathEnd1.messageCache.PacketFlow[pair.pathEnd1ChannelKey][chantypes.EventTypeRecvPacket]
// for seq, ackInfo := range pp.pathEnd1.messageCache.PacketFlow[pair.pathEnd1ChannelKey][chantypes.EventTypeWriteAck] {
// if recvPacketInfo, ok := pathEnd2DstMsgRecvPacket[seq]; ok {
// recvPacketInfo.Ack = ackInfo.Ack
// pathEnd2DstMsgRecvPacket[seq] = recvPacketInfo
// continue
// }

// pathEnd2DstMsgRecvPacket[seq] = ackInfo
// }

pathEnd1PacketFlowMessages := pathEndPacketFlowMessages{
Src: pp.pathEnd1,
Expand Down
4 changes: 2 additions & 2 deletions relayer/processor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,9 @@
// PacketInfoChannelKey returns the applicable ChannelKey for the chain based on the eventType.
func PacketInfoChannelKey(eventType string, info provider.PacketInfo) (ChannelKey, error) {
switch eventType {
case chantypes.EventTypeRecvPacket, chantypes.EventTypeWriteAck:
case chantypes.EventTypeRecvPacket, chantypes.EventTypeWriteAck, common.EventTimeoutRequest:

Check warning on line 568 in relayer/processor/types.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/types.go#L568

Added line #L568 was not covered by tests
return packetInfoChannelKey(info).Counterparty(), nil
case chantypes.EventTypeSendPacket, chantypes.EventTypeAcknowledgePacket, chantypes.EventTypeTimeoutPacket, chantypes.EventTypeTimeoutPacketOnClose, common.EventTimeoutRequest:
case chantypes.EventTypeSendPacket, chantypes.EventTypeAcknowledgePacket, chantypes.EventTypeTimeoutPacket, chantypes.EventTypeTimeoutPacketOnClose:

Check warning on line 570 in relayer/processor/types.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/types.go#L570

Added line #L570 was not covered by tests
return packetInfoChannelKey(info), nil
}
return ChannelKey{}, fmt.Errorf("eventType not expected for packetIBCMessage channelKey: %s", eventType)
Expand Down
Loading