Add INDEXER_TX_ACTIONS_ENABLE env variable

pull/6582/head
POA 2 years ago
parent 0dc8cffaa3
commit be99681177
  1. 2
      apps/indexer/lib/indexer/supervisor.ex
  2. 62
      apps/indexer/lib/indexer/transform/transaction_actions.ex
  3. 3
      config/runtime.exs
  4. 1
      docker-compose/envs/common-blockscout.env
  5. 3
      docker/Makefile

@ -121,7 +121,7 @@ defmodule Indexer.Supervisor do
[ [
[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]
]}, ]},
{TransactionAction.Supervisor, [[memory_monitor: memory_monitor]]}, configure(TransactionAction.Supervisor, [[memory_monitor: memory_monitor]]),
{ContractCode.Supervisor, {ContractCode.Supervisor,
[[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]},
{TokenBalance.Supervisor, {TokenBalance.Supervisor,

@ -99,38 +99,42 @@ defmodule Indexer.Transform.TransactionActions do
Returns a list of transaction actions given a list of logs. Returns a list of transaction actions given a list of logs.
""" """
def parse(logs, protocols_to_rewrite \\ []) do def parse(logs, protocols_to_rewrite \\ []) do
actions = [] if Application.get_env(:indexer, Indexer.Fetcher.TransactionAction.Supervisor)[:enabled] do
actions = []
chain_id = NetVersion.get_version()
logs
|> logs_group_by_txs()
|> clear_actions(protocols_to_rewrite)
# create tokens cache if not exists
if :ets.whereis(:tx_actions_tokens_data_cache) == :undefined do
:ets.new(:tx_actions_tokens_data_cache, [
:set,
:named_table,
:public,
read_concurrency: true,
write_concurrency: true
])
end
chain_id = NetVersion.get_version() # handle uniswap v3
tx_actions =
if Enum.member?([@mainnet, @goerli, @optimism, @polygon], chain_id) and
(Enum.empty?(protocols_to_rewrite) or Enum.member?(protocols_to_rewrite, "uniswap_v3")) do
logs
|> uniswap_filter_logs()
|> logs_group_by_txs()
|> uniswap(actions, chain_id)
else
actions
end
logs %{transaction_actions: tx_actions}
|> logs_group_by_txs() else
|> clear_actions(protocols_to_rewrite) %{transaction_actions: []}
# create tokens cache if not exists
if :ets.whereis(:tx_actions_tokens_data_cache) == :undefined do
:ets.new(:tx_actions_tokens_data_cache, [
:set,
:named_table,
:public,
read_concurrency: true,
write_concurrency: true
])
end end
# handle uniswap v3
tx_actions =
if Enum.member?([@mainnet, @goerli, @optimism, @polygon], chain_id) and
(Enum.empty?(protocols_to_rewrite) or Enum.member?(protocols_to_rewrite, "uniswap_v3")) do
logs
|> uniswap_filter_logs()
|> logs_group_by_txs()
|> uniswap(actions, chain_id)
else
actions
end
%{transaction_actions: tx_actions}
end end
defp uniswap(logs_grouped, actions, chain_id) do defp uniswap(logs_grouped, actions, chain_id) do

@ -432,6 +432,9 @@ config :indexer,
trace_last_block: System.get_env("TRACE_LAST_BLOCK") || "", trace_last_block: System.get_env("TRACE_LAST_BLOCK") || "",
fetch_rewards_way: System.get_env("FETCH_REWARDS_WAY", "trace_block") fetch_rewards_way: System.get_env("FETCH_REWARDS_WAY", "trace_block")
config :indexer, Indexer.Fetcher.TransactionAction.Supervisor,
enabled: System.get_env("INDEXER_TX_ACTIONS_ENABLE", "false") == "true"
config :indexer, Indexer.Fetcher.TransactionAction, config :indexer, Indexer.Fetcher.TransactionAction,
reindex_first_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK"), reindex_first_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK"),
reindex_last_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK"), reindex_last_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK"),

@ -90,6 +90,7 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false
# INDEXER_COIN_BALANCES_CONCURRENCY= # INDEXER_COIN_BALANCES_CONCURRENCY=
# INDEXER_RECEIPTS_BATCH_SIZE= # INDEXER_RECEIPTS_BATCH_SIZE=
# INDEXER_RECEIPTS_CONCURRENCY= # INDEXER_RECEIPTS_CONCURRENCY=
# INDEXER_TX_ACTIONS_ENABLE=
# INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE= # INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE=
# INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK= # INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK=
# INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK= # INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK=

@ -487,6 +487,9 @@ endif
ifdef TOKEN_ID_MIGRATION_BATCH_SIZE ifdef TOKEN_ID_MIGRATION_BATCH_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TOKEN_ID_MIGRATION_BATCH_SIZE=$(TOKEN_ID_MIGRATION_BATCH_SIZE)' BLOCKSCOUT_CONTAINER_PARAMS += -e 'TOKEN_ID_MIGRATION_BATCH_SIZE=$(TOKEN_ID_MIGRATION_BATCH_SIZE)'
endif endif
ifdef INDEXER_TX_ACTIONS_ENABLE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_ENABLE=$(INDEXER_TX_ACTIONS_ENABLE)'
endif
ifdef INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE ifdef INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE=$(INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE)' BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE=$(INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE)'
endif endif

Loading…
Cancel
Save