From bfd8e9df8b409a6ff47db98bd8c74d8e6f5b6d20 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Tue, 15 Nov 2022 14:24:14 +0400 Subject: [PATCH] Internal transaction fetcher envs --- CHANGELOG.md | 1 + .../indexer/fetcher/internal_transaction.ex | 25 +++++++++++-------- config/runtime.exs | 10 ++++++++ docker-compose/envs/common-blockscout.env | 2 ++ docker/Makefile | 6 +++++ 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4df9f9607..e5e30b68fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - [#6257](https://github.com/blockscout/blockscout/pull/6257), [#6276](https://github.com/blockscout/blockscout/pull/6276) - DISABLE_TOKEN_INSTANCE_FETCHER env variable - [#6391](https://github.com/blockscout/blockscout/pull/6391), [#6427](https://github.com/blockscout/blockscout/pull/6427) - TokenTransfer token_id -> token_ids migration - [#6443](https://github.com/blockscout/blockscout/pull/6443) - Drop internal transactions order index +- [#6450](https://github.com/blockscout/blockscout/pull/6450) - INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE and INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY env variables ### Fixes diff --git a/apps/indexer/lib/indexer/fetcher/internal_transaction.ex b/apps/indexer/lib/indexer/fetcher/internal_transaction.ex index 681a8cd97c..dba1ed36f8 100644 --- a/apps/indexer/lib/indexer/fetcher/internal_transaction.ex +++ b/apps/indexer/lib/indexer/fetcher/internal_transaction.ex @@ -21,16 +21,8 @@ defmodule Indexer.Fetcher.InternalTransaction do @behaviour BufferedTask - @max_batch_size 10 - @max_concurrency 4 - @defaults [ - flush_interval: :timer.seconds(3), - max_concurrency: @max_concurrency, - max_batch_size: @max_batch_size, - poll: true, - task_supervisor: Indexer.Fetcher.InternalTransaction.TaskSupervisor, - metadata: [fetcher: :internal_transaction] - ] + @default_max_batch_size 10 + @default_max_concurrency 4 @doc """ Asynchronously fetches internal transactions. @@ -68,7 +60,7 @@ defmodule Indexer.Fetcher.InternalTransaction do end merged_init_opts = - @defaults + defaults() |> Keyword.merge(mergeable_init_options) |> Keyword.put(:state, state) @@ -273,4 +265,15 @@ defmodule Indexer.Fetcher.InternalTransaction do end end) end + + defp defaults do + [ + flush_interval: :timer.seconds(3), + max_concurrency: Application.get_env(:indexer, __MODULE__)[:concurrency] || @default_max_concurrency, + max_batch_size: Application.get_env(:indexer, __MODULE__)[:batch_size] || @default_max_batch_size, + poll: true, + task_supervisor: Indexer.Fetcher.InternalTransaction.TaskSupervisor, + metadata: [fetcher: :internal_transaction] + ] + end end diff --git a/config/runtime.exs b/config/runtime.exs index 668524a7fb..50cd63f2b0 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -467,6 +467,16 @@ config :indexer, Indexer.Block.Catchup.Fetcher, batch_size: blocks_catchup_fetcher_batch_size, concurrency: blocks_catchup_fetcher_concurrency +{internal_transaction_fetcher_batch_size, _} = + Integer.parse(System.get_env("INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE", "10")) + +{internal_transaction_fetcher_concurrency, _} = + Integer.parse(System.get_env("INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY", "4")) + +config :indexer, Indexer.Fetcher.InternalTransaction, + batch_size: internal_transaction_fetcher_batch_size, + concurrency: internal_transaction_fetcher_concurrency + Code.require_file("#{config_env()}.exs", "config/runtime") for config <- "../apps/*/config/runtime/#{config_env()}.exs" |> Path.expand(__DIR__) |> Path.wildcard() do diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 6f9a4a8779..cffb1aac85 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -84,6 +84,8 @@ INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER=false INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false # INDEXER_CATCHUP_BLOCKS_BATCH_SIZE= # INDEXER_CATCHUP_BLOCKS_CONCURRENCY= +# INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE= +# INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY= # TOKEN_ID_MIGRATION_FIRST_BLOCK= # TOKEN_ID_MIGRATION_CONCURRENCY= # TOKEN_ID_MIGRATION_BATCH_SIZE= diff --git a/docker/Makefile b/docker/Makefile index e674a0a1d7..8382fdbdbd 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -454,6 +454,12 @@ endif ifdef INDEXER_CATCHUP_BLOCKS_CONCURRENCY BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_CATCHUP_BLOCKS_CONCURRENCY=$(INDEXER_CATCHUP_BLOCKS_CONCURRENCY)' endif +ifdef INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE + BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE=$(INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE)' +endif +ifdef INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY + BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY=$(INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY)' +endif ifdef INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE=$(INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE)' endif