Commit 1bdd8e63 authored by Conner Fromknecht's avatar Conner Fromknecht Committed by Matthew Slipper

feat: add SAFE_ABORT_NONCE_TOO_LOW_COUNT flag

parent bcbde5f3
...@@ -111,6 +111,7 @@ func Main(gitVersion string) func(ctx *cli.Context) error { ...@@ -111,6 +111,7 @@ func Main(gitVersion string) func(ctx *cli.Context) error {
ResubmissionTimeout: cfg.ResubmissionTimeout, ResubmissionTimeout: cfg.ResubmissionTimeout,
ReceiptQueryInterval: time.Second, ReceiptQueryInterval: time.Second,
NumConfirmations: cfg.NumConfirmations, NumConfirmations: cfg.NumConfirmations,
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
} }
var services []*bsscore.Service var services []*bsscore.Service
......
...@@ -89,6 +89,11 @@ type Config struct { ...@@ -89,6 +89,11 @@ type Config struct {
// appending new batches. // appending new batches.
NumConfirmations uint64 NumConfirmations uint64
// SafeAbortNonceTooLowCount is the number of ErrNonceTooLowObservations
// required to give up on a tx at a particular nonce without receiving
// confirmation.
SafeAbortNonceTooLowCount uint64
// ResubmissionTimeout is time we will wait before resubmitting a // ResubmissionTimeout is time we will wait before resubmitting a
// transaction. // transaction.
ResubmissionTimeout time.Duration ResubmissionTimeout time.Duration
...@@ -188,6 +193,7 @@ func NewConfig(ctx *cli.Context) (Config, error) { ...@@ -188,6 +193,7 @@ func NewConfig(ctx *cli.Context) (Config, error) {
MaxBatchSubmissionTime: ctx.GlobalDuration(flags.MaxBatchSubmissionTimeFlag.Name), MaxBatchSubmissionTime: ctx.GlobalDuration(flags.MaxBatchSubmissionTimeFlag.Name),
PollInterval: ctx.GlobalDuration(flags.PollIntervalFlag.Name), PollInterval: ctx.GlobalDuration(flags.PollIntervalFlag.Name),
NumConfirmations: ctx.GlobalUint64(flags.NumConfirmationsFlag.Name), NumConfirmations: ctx.GlobalUint64(flags.NumConfirmationsFlag.Name),
SafeAbortNonceTooLowCount: ctx.GlobalUint64(flags.SafeAbortNonceTooLowCountFlag.Name),
ResubmissionTimeout: ctx.GlobalDuration(flags.ResubmissionTimeoutFlag.Name), ResubmissionTimeout: ctx.GlobalDuration(flags.ResubmissionTimeoutFlag.Name),
FinalityConfirmations: ctx.GlobalUint64(flags.FinalityConfirmationsFlag.Name), FinalityConfirmations: ctx.GlobalUint64(flags.FinalityConfirmationsFlag.Name),
RunTxBatchSubmitter: ctx.GlobalBool(flags.RunTxBatchSubmitterFlag.Name), RunTxBatchSubmitter: ctx.GlobalBool(flags.RunTxBatchSubmitterFlag.Name),
......
...@@ -80,6 +80,14 @@ var ( ...@@ -80,6 +80,14 @@ var (
Required: true, Required: true,
EnvVar: prefixEnvVar("NUM_CONFIRMATIONS"), EnvVar: prefixEnvVar("NUM_CONFIRMATIONS"),
} }
SafeAbortNonceTooLowCountFlag = cli.Uint64Flag{
Name: "safe-abort-nonce-too-low-count",
Usage: "Number of ErrNonceTooLow observations required to " +
"give up on a tx at a particular nonce without receiving " +
"confirmation",
Required: true,
EnvVar: prefixEnvVar("SAFE_ABORT_NONCE_TOO_LOW_COUNT"),
}
ResubmissionTimeoutFlag = cli.DurationFlag{ ResubmissionTimeoutFlag = cli.DurationFlag{
Name: "resubmission-timeout", Name: "resubmission-timeout",
Usage: "Duration we will wait before resubmitting a " + Usage: "Duration we will wait before resubmitting a " +
...@@ -221,6 +229,7 @@ var requiredFlags = []cli.Flag{ ...@@ -221,6 +229,7 @@ var requiredFlags = []cli.Flag{
MaxBatchSubmissionTimeFlag, MaxBatchSubmissionTimeFlag,
PollIntervalFlag, PollIntervalFlag,
NumConfirmationsFlag, NumConfirmationsFlag,
SafeAbortNonceTooLowCountFlag,
ResubmissionTimeoutFlag, ResubmissionTimeoutFlag,
FinalityConfirmationsFlag, FinalityConfirmationsFlag,
RunTxBatchSubmitterFlag, RunTxBatchSubmitterFlag,
......
...@@ -207,6 +207,7 @@ func newClearPendingTxHarnessWithNumConfs( ...@@ -207,6 +207,7 @@ func newClearPendingTxHarnessWithNumConfs(
ResubmissionTimeout: time.Second, ResubmissionTimeout: time.Second,
ReceiptQueryInterval: 50 * time.Millisecond, ReceiptQueryInterval: 50 * time.Millisecond,
NumConfirmations: numConfirmations, NumConfirmations: numConfirmations,
SafeAbortNonceTooLowCount: 3,
}, l1Client) }, l1Client)
return &clearPendingTxHarness{ return &clearPendingTxHarness{
......
...@@ -38,6 +38,11 @@ type Config struct { ...@@ -38,6 +38,11 @@ type Config struct {
// NumConfirmations specifies how many blocks are need to consider a // NumConfirmations specifies how many blocks are need to consider a
// transaction confirmed. // transaction confirmed.
NumConfirmations uint64 NumConfirmations uint64
// SafeAbortNonceTooLowCount specifies how many ErrNonceTooLow observations
// are required to give up on a tx at a particular nonce without receiving
// confirmation.
SafeAbortNonceTooLowCount uint64
} }
// TxManager is an interface that allows callers to reliably publish txs, // TxManager is an interface that allows callers to reliably publish txs,
...@@ -120,7 +125,7 @@ func (m *SimpleTxManager) Send( ...@@ -120,7 +125,7 @@ func (m *SimpleTxManager) Send(
ctxc, cancel := context.WithCancel(ctx) ctxc, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
sendState := NewSendState(3) sendState := NewSendState(m.cfg.SafeAbortNonceTooLowCount)
// Create a closure that will block on passed sendTx function in the // Create a closure that will block on passed sendTx function in the
// background, returning the first successfully mined receipt back to // background, returning the first successfully mined receipt back to
......
...@@ -48,6 +48,7 @@ func configWithNumConfs(numConfirmations uint64) txmgr.Config { ...@@ -48,6 +48,7 @@ func configWithNumConfs(numConfirmations uint64) txmgr.Config {
ResubmissionTimeout: time.Second, ResubmissionTimeout: time.Second,
ReceiptQueryInterval: 50 * time.Millisecond, ReceiptQueryInterval: 50 * time.Millisecond,
NumConfirmations: numConfirmations, NumConfirmations: numConfirmations,
SafeAbortNonceTooLowCount: 3,
} }
} }
......
...@@ -8,6 +8,7 @@ BATCH_SUBMITTER_MAX_L1_TX_SIZE=90000 ...@@ -8,6 +8,7 @@ BATCH_SUBMITTER_MAX_L1_TX_SIZE=90000
BATCH_SUBMITTER_MAX_BATCH_SUBMISSION_TIME=0 BATCH_SUBMITTER_MAX_BATCH_SUBMISSION_TIME=0
BATCH_SUBMITTER_POLL_INTERVAL=500ms BATCH_SUBMITTER_POLL_INTERVAL=500ms
BATCH_SUBMITTER_NUM_CONFIRMATIONS=1 BATCH_SUBMITTER_NUM_CONFIRMATIONS=1
BATCH_SUBMITTER_SAFE_ABORT_NONCE_TOO_LOW_COUNT=3
BATCH_SUBMITTER_RESUBMISSION_TIMEOUT=1s BATCH_SUBMITTER_RESUBMISSION_TIMEOUT=1s
BATCH_SUBMITTER_FINALITY_CONFIRMATIONS=0 BATCH_SUBMITTER_FINALITY_CONFIRMATIONS=0
BATCH_SUBMITTER_RUN_TX_BATCH_SUBMITTER=true BATCH_SUBMITTER_RUN_TX_BATCH_SUBMITTER=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment