Skip to content

Commit

Permalink
Merge PR #1005: Fix legacy race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Nov 15, 2022
1 parent 49e848c commit ed105e3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions relayer/naive-strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,31 +476,33 @@ func RelayPackets(ctx context.Context, log *zap.Logger, src, dst *Chain, sp Rela
return err
}

// set the maximum relay transaction constraints
msgs := &RelayMsgs{
Src: []provider.RelayerMessage{},
Dst: []provider.RelayerMessage{},
MaxTxSize: maxTxSize,
MaxMsgLength: maxMsgLength,
}

eg, egCtx := errgroup.WithContext(ctx)
// add messages for sequences on src
var msgsSrc1, msgsDst1 []provider.RelayerMessage
eg.Go(func() error {
return AddMessagesForSequences(egCtx, sp.Src, src, dst, srch, dsth, &msgs.Src, &msgs.Dst,
return AddMessagesForSequences(egCtx, sp.Src, src, dst, srch, dsth, &msgsSrc1, &msgsDst1,
srcChannel.ChannelId, srcChannel.PortId, srcChannel.Counterparty.ChannelId, srcChannel.Counterparty.PortId, srcChannel.Ordering)
})

var msgsSrc2, msgsDst2 []provider.RelayerMessage
// add messages for sequences on dst
eg.Go(func() error {
return AddMessagesForSequences(egCtx, sp.Dst, dst, src, dsth, srch, &msgs.Dst, &msgs.Src,
return AddMessagesForSequences(egCtx, sp.Dst, dst, src, dsth, srch, &msgsDst2, &msgsSrc2,
srcChannel.Counterparty.ChannelId, srcChannel.Counterparty.PortId, srcChannel.ChannelId, srcChannel.PortId, srcChannel.Ordering)
})

if err = eg.Wait(); err != nil {
return err
}

// set the maximum relay transaction constraints
msgs := &RelayMsgs{
Src: append(msgsSrc1, msgsSrc2...),
Dst: append(msgsDst1, msgsDst2...),
MaxTxSize: maxTxSize,
MaxMsgLength: maxMsgLength,
}

if !msgs.Ready() {
log.Info(
"No packets to relay",
Expand Down

0 comments on commit ed105e3

Please sign in to comment.