From ef3b9016020b45e5ccfcd2c605fa9a31550ea2ad Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Thu, 13 Oct 2022 23:14:33 -0500 Subject: [PATCH] DISABLE_TOKEN_INSTANCE_FETCHER env --- apps/indexer/lib/indexer/supervisor.ex | 113 +++++++++++----------- config/runtime.exs | 3 + docker-compose/envs/common-blockscout.env | 1 + docker/Makefile | 3 + 4 files changed, 64 insertions(+), 56 deletions(-) diff --git a/apps/indexer/lib/indexer/supervisor.ex b/apps/indexer/lib/indexer/supervisor.ex index 50770c23d1..3d3e9bf43c 100644 --- a/apps/indexer/lib/indexer/supervisor.ex +++ b/apps/indexer/lib/indexer/supervisor.ex @@ -92,66 +92,67 @@ defmodule Indexer.Supervisor do realtime_subscribe_named_arguments = realtime_overrides[:subscribe_named_arguments] || subscribe_named_arguments - realtime_fetcher = - if Application.get_env(:indexer, Realtime.Supervisor)[:enabled] do - [ - {Realtime.Supervisor, - [ - %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, - [name: Realtime.Supervisor] - ]} - ] - else - [] - end - - basic_fetchers = [ - # Root fetchers - {Catchup.Supervisor, - [ - %{block_fetcher: block_fetcher, block_interval: block_interval, memory_monitor: memory_monitor}, - [name: Catchup.Supervisor] - ]}, - - # Async catchup fetchers - {UncleBlock.Supervisor, [[block_fetcher: block_fetcher, memory_monitor: memory_monitor]]}, - {BlockReward.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {InternalTransaction.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {CoinBalance.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {Token.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {TokenInstance.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {ContractCode.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {TokenBalance.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {TokenUpdater.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {ReplacedTransaction.Supervisor, [[memory_monitor: memory_monitor]]}, - - # Out-of-band fetchers - {CoinBalanceOnDemand.Supervisor, [json_rpc_named_arguments]}, - {EmptyBlocksSanitizer.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, - {TokenTotalSupplyOnDemand.Supervisor, [json_rpc_named_arguments]}, - {PendingTransactionsSanitizer, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, - - # Temporary workers - {UncatalogedTokenTransfers.Supervisor, [[]]}, - {UnclesWithoutIndex.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {BlocksTransactionsMismatch.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {PendingOpsCleaner, [[], []]} - ] - - all_fetchers = + basic_fetchers = [ - {PendingTransaction.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]} - ] ++ - realtime_fetcher ++ - basic_fetchers + # Root fetchers + {PendingTransaction.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, + configure(Realtime.Supervisor, [ + %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, + [name: Realtime.Supervisor] + ]), + {Catchup.Supervisor, + [ + %{block_fetcher: block_fetcher, block_interval: block_interval, memory_monitor: memory_monitor}, + [name: Catchup.Supervisor] + ]}, + + # Async catchup fetchers + {UncleBlock.Supervisor, [[block_fetcher: block_fetcher, memory_monitor: memory_monitor]]}, + {BlockReward.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {InternalTransaction.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {CoinBalance.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {Token.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + configure(TokenInstance.Supervisor, [ + [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] + ]), + {ContractCode.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {TokenBalance.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {TokenUpdater.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {ReplacedTransaction.Supervisor, [[memory_monitor: memory_monitor]]}, + + # Out-of-band fetchers + {CoinBalanceOnDemand.Supervisor, [json_rpc_named_arguments]}, + {EmptyBlocksSanitizer.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, + {TokenTotalSupplyOnDemand.Supervisor, [json_rpc_named_arguments]}, + {PendingTransactionsSanitizer, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, + + # Temporary workers + {UncatalogedTokenTransfers.Supervisor, [[]]}, + {UnclesWithoutIndex.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {BlocksTransactionsMismatch.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {PendingOpsCleaner, [[], []]} + ] + |> List.flatten() Supervisor.init( - all_fetchers, + basic_fetchers, strategy: :one_for_one ) end + + defp configure(process, opts \\ []) do + if Application.get_env(:indexer, process)[:enabled] do + [{process, opts}] + else + [] + end + end end diff --git a/config/runtime.exs b/config/runtime.exs index 5b7209626f..35e9810710 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -438,6 +438,9 @@ config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") config :indexer, Indexer.Block.Realtime.Supervisor, enabled: System.get_env("DISABLE_REALTIME_INDEXER") != "true" +config :indexer, Indexer.Fetcher.TokenInstance.Supervisor, + enabled: System.get_env("DISABLE_TOKEN_INSTANCE_FETCHER") != "true" + blocks_catchup_fetcher_batch_size_default_str = "10" blocks_catchup_fetcher_concurrency_default_str = "10" diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 27f6506682..b89d6b4f77 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -79,6 +79,7 @@ DISABLE_READ_API=false DISABLE_WRITE_API=false DISABLE_INDEXER=false DISABLE_REALTIME_INDEXER=false +DISABLE_TOKEN_INSTANCE_FETCHER=false INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER=false INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false # INDEXER_CATCHUP_BLOCKS_BATCH_SIZE= diff --git a/docker/Makefile b/docker/Makefile index 4b4ad8f521..c4bc76bd8b 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -181,6 +181,9 @@ endif ifdef DISABLE_REALTIME_INDEXER BLOCKSCOUT_CONTAINER_PARAMS += -e 'DISABLE_REALTIME_INDEXER=$(DISABLE_REALTIME_INDEXER)' endif +ifdef DISABLE_TOKEN_INSTANCE_FETCHER + BLOCKSCOUT_CONTAINER_PARAMS += -e 'DISABLE_TOKEN_INSTANCE_FETCHER=$(DISABLE_TOKEN_INSTANCE_FETCHER)' +endif ifdef WEBAPP_URL BLOCKSCOUT_CONTAINER_PARAMS += -e 'WEBAPP_URL=$(WEBAPP_URL)' endif