diff --git a/CHANGELOG.md b/CHANGELOG.md index 11a0565890..8eb9a5afb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ ### Chore +- [#6952](https://github.com/blockscout/blockscout/pull/6952) - Manage BlockReward fetcher params - [#6929](https://github.com/blockscout/blockscout/pull/6929) - Extend `INDEXER_MEMORY_LIMIT` env parsing - [#6902](https://github.com/blockscout/blockscout/pull/6902) - Increase verification timeout to 120 seconds for microservice verification diff --git a/apps/indexer/lib/indexer/fetcher/block_reward.ex b/apps/indexer/lib/indexer/fetcher/block_reward.ex index c473aa00f0..956117ba93 100644 --- a/apps/indexer/lib/indexer/fetcher/block_reward.ex +++ b/apps/indexer/lib/indexer/fetcher/block_reward.ex @@ -25,13 +25,8 @@ defmodule Indexer.Fetcher.BlockReward do @behaviour BufferedTask - @defaults [ - flush_interval: :timer.seconds(3), - max_batch_size: 10, - max_concurrency: 4, - task_supervisor: Indexer.Fetcher.BlockReward.TaskSupervisor, - metadata: [fetcher: :block_reward] - ] + @default_max_batch_size 10 + @default_max_concurrency 4 @doc """ Asynchronously fetches block rewards for each `t:Explorer.Chain.Explorer.block_number/0`` in `block_numbers`. @@ -57,7 +52,7 @@ defmodule Indexer.Fetcher.BlockReward do end merged_init_options = - @defaults + defaults() |> Keyword.merge(mergeable_init_options) |> Keyword.put(:state, state) @@ -337,4 +332,14 @@ defmodule Indexer.Fetcher.BlockReward do when is_integer(code) and is_binary(message) and is_binary(block_quantity) do ["@", quantity_to_integer(block_quantity), ": (", to_string(code), ") ", message, ?\n] 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, + task_supervisor: Indexer.Fetcher.BlockReward.TaskSupervisor, + metadata: [fetcher: :block_reward] + ] + end end diff --git a/config/runtime.exs b/config/runtime.exs index 52a2c6e7ce..1f60f4bc9b 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -566,6 +566,14 @@ blocks_catchup_fetcher_missing_ranges_batch_size_default_str = "100000" config :indexer, Indexer.Block.Catchup.MissingRangesCollector, missing_ranges_batch_size: blocks_catchup_fetcher_missing_ranges_batch_size +{block_reward_fetcher_batch_size, _} = Integer.parse(System.get_env("INDEXER_BLOCK_REWARD_BATCH_SIZE", "10")) + +{block_reward_fetcher_concurrency, _} = Integer.parse(System.get_env("INDEXER_BLOCK_REWARD_CONCURRENCY", "4")) + +config :indexer, Indexer.Fetcher.BlockReward, + batch_size: block_reward_fetcher_batch_size, + concurrency: block_reward_fetcher_concurrency + {internal_transaction_fetcher_batch_size, _} = Integer.parse(System.get_env("INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE", "10")) diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 9b5cc00c60..f265ff3125 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -86,6 +86,8 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false # INDEXER_CATCHUP_BLOCKS_CONCURRENCY= # INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE= # INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY= +# INDEXER_BLOCK_REWARD_BATCH_SIZE= +# INDEXER_BLOCK_REWARD_CONCURRENCY= # INDEXER_COIN_BALANCES_BATCH_SIZE= # INDEXER_COIN_BALANCES_CONCURRENCY= # INDEXER_RECEIPTS_BATCH_SIZE= diff --git a/docker/Makefile b/docker/Makefile index 9c1ba7123c..d79ed23b76 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -463,6 +463,12 @@ endif ifdef INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY=$(INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY)' endif +ifdef INDEXER_BLOCK_REWARD_BATCH_SIZE + BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_BLOCK_REWARD_BATCH_SIZE=$(INDEXER_BLOCK_REWARD_BATCH_SIZE)' +endif +ifdef INDEXER_BLOCK_REWARD_CONCURRENCY + BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_BLOCK_REWARD_CONCURRENCY=$(INDEXER_BLOCK_REWARD_CONCURRENCY)' +endif ifdef INDEXER_COIN_BALANCES_BATCH_SIZE BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_RECEIPTS_BATCH_SIZE=$(INDEXER_RECEIPTS_BATCH_SIZE)' endif