Skip to content

Commit

Permalink
added datastream block timeout flag (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Staykov authored Jun 18, 2024
1 parent 8930a6f commit 91f0f69
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
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: "The timeout for the executor request",
Value: 60 * time.Second,
}
DatastreamNewBlockTimeout = cli.DurationFlag{
Name: "zkevm.datastream-new-block-timeout",
Usage: "The timeout for the executor request",
Value: 500 * time.Millisecond,
}
ExecutorMaxConcurrentRequests = cli.IntFlag{
Name: "zkevm.executor-max-concurrent-requests",
Usage: "The maximum number of concurrent requests to the executor",
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 @@ -35,6 +35,7 @@ type Zk struct {
ExecutorUrls []string
ExecutorStrictMode bool
ExecutorRequestTimeout time.Duration
DatastreamNewBlockTimeout time.Duration
ExecutorMaxConcurrentRequests int
AllowFreeTransactions bool
AllowPreEIP155Transactions 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 @@ -194,6 +194,7 @@ var DefaultFlags = []cli.Flag{
&utils.ExecutorUrls,
&utils.ExecutorStrictMode,
&utils.ExecutorRequestTimeout,
&utils.DatastreamNewBlockTimeout,
&utils.ExecutorMaxConcurrentRequests,
&utils.AllowFreeTransactions,
&utils.AllowPreEIP155Transactions,
Expand Down
1 change: 1 addition & 0 deletions turbo/cli/flags_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func ApplyFlagsForZkConfig(ctx *cli.Context, cfg *ethconfig.Config) {
ExecutorUrls: strings.Split(ctx.String(utils.ExecutorUrls.Name), ","),
ExecutorStrictMode: ctx.Bool(utils.ExecutorStrictMode.Name),
ExecutorRequestTimeout: ctx.Duration(utils.ExecutorRequestTimeout.Name),
DatastreamNewBlockTimeout: ctx.Duration(utils.DatastreamNewBlockTimeout.Name),
ExecutorMaxConcurrentRequests: ctx.Int(utils.ExecutorMaxConcurrentRequests.Name),
AllowFreeTransactions: ctx.Bool(utils.AllowFreeTransactions.Name),
AllowPreEIP155Transactions: ctx.Bool(utils.AllowPreEIP155Transactions.Name),
Expand Down
3 changes: 1 addition & 2 deletions zk/stages/stage_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const (
forkId7BlockGasLimit = 18446744073709551615 // 0xffffffffffffffff
forkId8BlockGasLimit = 1125899906842624 // 0x4000000000000
HIGHEST_KNOWN_FORK = 9
newBlockTimeout = 500
)

type ErigonDb interface {
Expand Down Expand Up @@ -384,7 +383,7 @@ LOOP:
// stop the current iteration of the stage
lastWrittenTs := lastWrittenTimeAtomic.Load()
timePassedAfterlastBlock := time.Since(time.Unix(0, lastWrittenTs))
if streamingAtomic.Load() && timePassedAfterlastBlock.Milliseconds() > newBlockTimeout {
if streamingAtomic.Load() && timePassedAfterlastBlock > cfg.zkCfg.DatastreamNewBlockTimeout {
log.Info(fmt.Sprintf("[%s] No new blocks in %d miliseconds. Ending the stage.", logPrefix, timePassedAfterlastBlock.Milliseconds()), "lastBlockHeight", lastBlockHeight)
endLoop = true
}
Expand Down

0 comments on commit 91f0f69

Please sign in to comment.