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

add-sequener-timeout-on-empty-tx-pool #1032

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@ var (
Usage: "This is a maximum time that a batch verification could take. Including retries. This could be interpreted as maximum that that the sequencer can run without executor. Setting it to 0s will mean infinite timeout. Defaults to 30min",
Value: "30m",
}
SequencerTimeoutOnEmptyTxPool = cli.StringFlag{
Name: "zkevm.sequencer-timeout-on-empty-tx-pool",
Usage: "Timeout before requesting txs from the txpool if none were found before. Defaults to 250ms",
Value: "250ms",
}
SequencerHaltOnBatchNumber = cli.Uint64Flag{
Name: "zkevm.sequencer-halt-on-batch-number",
Usage: "Halt the sequencer on this batch number",
Expand Down
1 change: 1 addition & 0 deletions eth/ethconfig/config_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Zk struct {
SequencerBlockSealTime time.Duration
SequencerBatchSealTime time.Duration
SequencerBatchVerificationTimeout time.Duration
SequencerTimeoutOnEmptyTxPool time.Duration
SequencerHaltOnBatchNumber uint64
ExecutorUrls []string
ExecutorStrictMode bool
Expand Down
1 change: 1 addition & 0 deletions turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ var DefaultFlags = []cli.Flag{
&utils.SequencerBlockSealTime,
&utils.SequencerBatchSealTime,
&utils.SequencerBatchVerificationTimeout,
&utils.SequencerTimeoutOnEmptyTxPool,
&utils.SequencerHaltOnBatchNumber,
&utils.ExecutorUrls,
&utils.ExecutorStrictMode,
Expand Down
7 changes: 7 additions & 0 deletions turbo/cli/flags_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func ApplyFlagsForZkConfig(ctx *cli.Context, cfg *ethconfig.Config) {
panic(fmt.Sprintf("could not parse sequencer batch seal time timeout value %s", sequencerBatchSealTimeVal))
}

sequencerTimeoutOnEmptyTxPoolVal := ctx.String(utils.SequencerTimeoutOnEmptyTxPool.Name)
sequencerTimeoutOnEmptyTxPool, err := time.ParseDuration(sequencerTimeoutOnEmptyTxPoolVal)
if err != nil {
panic(fmt.Sprintf("could not parse sequencer batch seal time timeout value %s", sequencerBatchSealTimeVal))
}

effectiveGasPriceForEthTransferVal := ctx.Float64(utils.EffectiveGasPriceForEthTransfer.Name)
effectiveGasPriceForErc20TransferVal := ctx.Float64(utils.EffectiveGasPriceForErc20Transfer.Name)
effectiveGasPriceForContractInvocationVal := ctx.Float64(utils.EffectiveGasPriceForContractInvocation.Name)
Expand Down Expand Up @@ -133,6 +139,7 @@ func ApplyFlagsForZkConfig(ctx *cli.Context, cfg *ethconfig.Config) {
SequencerBlockSealTime: sequencerBlockSealTime,
SequencerBatchSealTime: sequencerBatchSealTime,
SequencerBatchVerificationTimeout: sequencerBatchVerificationTimeout,
SequencerTimeoutOnEmptyTxPool: sequencerTimeoutOnEmptyTxPool,
SequencerHaltOnBatchNumber: ctx.Uint64(utils.SequencerHaltOnBatchNumber.Name),
ExecutorUrls: strings.Split(strings.ReplaceAll(ctx.String(utils.ExecutorUrls.Name), " ", ""), ","),
ExecutorStrictMode: ctx.Bool(utils.ExecutorStrictMode.Name),
Expand Down
4 changes: 2 additions & 2 deletions zk/stages/stage_sequence_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func SpawnSequencingStage(
return err
}
if len(batchState.blockState.transactionsForInclusion) == 0 {
time.Sleep(250 * time.Millisecond)
time.Sleep(batchContext.cfg.zk.SequencerTimeoutOnEmptyTxPool)
} else {
log.Trace(fmt.Sprintf("[%s] Yielded transactions from the pool", logPrefix), "txCount", len(batchState.blockState.transactionsForInclusion))
}
Expand Down Expand Up @@ -298,7 +298,7 @@ func SpawnSequencingStage(
if batchState.isL1Recovery() {
// just go into the normal loop waiting for new transactions to signal that the recovery
// has finished as far as it can go
if batchState.isThereAnyTransactionsToRecover() {
if !batchState.isThereAnyTransactionsToRecover() {
log.Info(fmt.Sprintf("[%s] L1 recovery no more transactions to recover", logPrefix))
}

Expand Down
Loading