Skip to content

Commit 855f656

Browse files
committed
retry submission forever for valid messages
1 parent 772b76c commit 855f656

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

op-acceptance-tests/tests/interop/loadtest/helpers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func (n *nonceCounter) Next() uint64 {
2121
return nonce
2222
}
2323

24-
func retryForever(g txplan.ReceiptGetter) txplan.Option {
24+
func retryInclusionForever(g txplan.ReceiptGetter) txplan.Option {
2525
return txplan.WithRetryInclusion(g, math.MaxInt, retry.Exponential())
2626
}
27+
28+
func retrySubmissionForever(s txplan.TransactionSubmitter) txplan.Option {
29+
return txplan.WithRetrySubmission(s, math.MaxInt, retry.Exponential())
30+
}

op-acceptance-tests/tests/interop/loadtest/initiator.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ func (lin *LargeMsgInitiator) Initiate(t devtest.T) []types.Message {
8787
}
8888

8989
func buildAndSendInitTx(t devtest.T, eoa *dsl.EOA, el *dsl.L2ELNode, initCall txintent.Call, opts ...txplan.Option) []types.Message {
90-
initMsgsTx := txintent.NewIntent[txintent.Call, *txintent.InteropOutput](eoa.Plan(), retryForever(el.Escape().EthClient()), txplan.Combine(opts...))
90+
initMsgsTx := txintent.NewIntent[txintent.Call, *txintent.InteropOutput](
91+
eoa.Plan(),
92+
retrySubmissionForever(el.Escape().EthClient()),
93+
retryInclusionForever(el.Escape().EthClient()),
94+
txplan.Combine(opts...),
95+
)
9196
initMsgsTx.Content.Set(initCall)
9297
_, err := initMsgsTx.PlannedTx.Success.Eval(t.Ctx())
9398
t.Require().NoError(err)

op-acceptance-tests/tests/interop/loadtest/relayer.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ func NewValidRelayer(funder *dsl.Funder, el *dsl.L2ELNode, supervisor *dsl.Super
4040
}
4141

4242
func (e *ValidRelayer) Relay(t devtest.T, msgs []types.Message) {
43-
tx := buildRelayTx(e.eoa, e.el, msgs, retryForever(e.el.Escape().EthClient()), txplan.WithStaticNonce(e.counter.Next()))
43+
tx := buildRelayTx(
44+
e.eoa,
45+
e.el,
46+
msgs,
47+
retrySubmissionForever(e.el.Escape().EthClient()),
48+
retryInclusionForever(e.el.Escape().EthClient()),
49+
txplan.WithStaticNonce(e.counter.Next()),
50+
)
4451
receipt, err := tx.Included.Eval(t.Ctx())
4552
t.Require().NoError(err)
4653
_, err = tx.Success.Eval(t.Ctx())

op-service/txplan/txplan.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ func WithTransactionSubmitter(cl TransactionSubmitter) Option {
225225
}
226226
}
227227

228+
func WithRetrySubmission(cl TransactionSubmitter, maxAttempts int, strategy retry.Strategy) Option {
229+
return func(tx *PlannedTx) {
230+
tx.Submitted.DependOn(&tx.Signed)
231+
tx.Submitted.Fn(func(ctx context.Context) (struct{}, error) {
232+
return struct{}{}, retry.Do0(ctx, maxAttempts, strategy, func() error {
233+
return cl.SendTransaction(ctx, tx.Signed.Value())
234+
})
235+
})
236+
}
237+
}
238+
228239
type ReceiptGetter interface {
229240
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
230241
}

0 commit comments

Comments
 (0)