Add INDEXER_ZKEVM_BATCHES_CHUNK_SIZE env variable

pull/7584/head
POA 1 year ago
parent bc411f545d
commit 841fd7be70
  1. 13
      apps/indexer/lib/indexer/fetcher/zkevm_txn_batch.ex
  2. 3
      config/runtime.exs
  3. 1
      docker-compose/envs/common-blockscout.env

@ -15,7 +15,6 @@ defmodule Indexer.Fetcher.ZkevmTxnBatch do
alias Explorer.{Chain, Repo} alias Explorer.{Chain, Repo}
alias Explorer.Chain.{ZkevmLifecycleTxn, ZkevmTxnBatch} alias Explorer.Chain.{ZkevmLifecycleTxn, ZkevmTxnBatch}
@batch_range_size 20
@recheck_latest_batch_interval 60 @recheck_latest_batch_interval 60
@zero_hash "0000000000000000000000000000000000000000000000000000000000000000" @zero_hash "0000000000000000000000000000000000000000000000000000000000000000"
@ -39,10 +38,13 @@ defmodule Indexer.Fetcher.ZkevmTxnBatch do
Logger.metadata(fetcher: :zkevm_txn_batches) Logger.metadata(fetcher: :zkevm_txn_batches)
# Logger.configure(truncate: :infinity) # Logger.configure(truncate: :infinity)
chunk_size = Application.get_all_env(:indexer)[Indexer.Fetcher.ZkevmTxnBatch][:chunk_size]
Process.send(self(), :continue, []) Process.send(self(), :continue, [])
{:ok, {:ok,
%{ %{
chunk_size: chunk_size,
json_rpc_named_arguments: args[:json_rpc_named_arguments], json_rpc_named_arguments: args[:json_rpc_named_arguments],
prev_latest_batch_number: 0, prev_latest_batch_number: 0,
prev_virtual_batch_number: 0, prev_virtual_batch_number: 0,
@ -54,6 +56,7 @@ defmodule Indexer.Fetcher.ZkevmTxnBatch do
def handle_info( def handle_info(
:continue, :continue,
%{ %{
chunk_size: chunk_size,
json_rpc_named_arguments: json_rpc_named_arguments, json_rpc_named_arguments: json_rpc_named_arguments,
prev_latest_batch_number: prev_latest_batch_number, prev_latest_batch_number: prev_latest_batch_number,
prev_virtual_batch_number: prev_virtual_batch_number, prev_virtual_batch_number: prev_virtual_batch_number,
@ -95,7 +98,9 @@ defmodule Indexer.Fetcher.ZkevmTxnBatch do
Logger.info(log_message <> "Handling the batch range #{start_batch_number}..#{end_batch_number}.") Logger.info(log_message <> "Handling the batch range #{start_batch_number}..#{end_batch_number}.")
{handle_duration, _} = {handle_duration, _} =
:timer.tc(fn -> handle_batch_range(start_batch_number, end_batch_number, json_rpc_named_arguments) end) :timer.tc(fn ->
handle_batch_range(start_batch_number, end_batch_number, json_rpc_named_arguments, chunk_size)
end)
{ {
%{ %{
@ -151,9 +156,9 @@ defmodule Indexer.Fetcher.ZkevmTxnBatch do
last_id + 1 last_id + 1
end end
defp handle_batch_range(start_batch_number, end_batch_number, json_rpc_named_arguments) do defp handle_batch_range(start_batch_number, end_batch_number, json_rpc_named_arguments, chunk_size) do
start_batch_number..end_batch_number start_batch_number..end_batch_number
|> Enum.chunk_every(@batch_range_size) |> Enum.chunk_every(chunk_size)
|> Enum.each(fn chunk -> |> Enum.each(fn chunk ->
chunk_start = List.first(chunk) chunk_start = List.first(chunk)
chunk_end = List.last(chunk) chunk_end = List.last(chunk)

@ -613,6 +613,9 @@ config :indexer, Indexer.Fetcher.PolygonEdge.WithdrawalExit,
start_block_l1: System.get_env("INDEXER_POLYGON_EDGE_L1_WITHDRAWALS_START_BLOCK"), start_block_l1: System.get_env("INDEXER_POLYGON_EDGE_L1_WITHDRAWALS_START_BLOCK"),
exit_helper: System.get_env("INDEXER_POLYGON_EDGE_L1_EXIT_HELPER_CONTRACT") exit_helper: System.get_env("INDEXER_POLYGON_EDGE_L1_EXIT_HELPER_CONTRACT")
config :indexer, Indexer.Fetcher.ZkevmTxnBatch,
chunk_size: ConfigHelper.parse_integer_env_var("INDEXER_ZKEVM_BATCHES_CHUNK_SIZE", 20)
config :indexer, Indexer.Fetcher.ZkevmTxnBatch.Supervisor, config :indexer, Indexer.Fetcher.ZkevmTxnBatch.Supervisor,
enabled: ConfigHelper.parse_bool_env_var("INDEXER_ZKEVM_BATCHES_ENABLED") enabled: ConfigHelper.parse_bool_env_var("INDEXER_ZKEVM_BATCHES_ENABLED")

@ -142,6 +142,7 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false
# INDEXER_POLYGON_EDGE_L2_DEPOSITS_START_BLOCK= # INDEXER_POLYGON_EDGE_L2_DEPOSITS_START_BLOCK=
# INDEXER_POLYGON_EDGE_ETH_GET_LOGS_RANGE_SIZE= # INDEXER_POLYGON_EDGE_ETH_GET_LOGS_RANGE_SIZE=
# INDEXER_ZKEVM_BATCHES_ENABLED= # INDEXER_ZKEVM_BATCHES_ENABLED=
# INDEXER_ZKEVM_BATCHES_CHUNK_SIZE=
# INDEXER_REALTIME_FETCHER_MAX_GAP= # INDEXER_REALTIME_FETCHER_MAX_GAP=
# INDEXER_FETCHER_INIT_QUERY_LIMIT= # INDEXER_FETCHER_INIT_QUERY_LIMIT=
# INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT= # INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT=

Loading…
Cancel
Save