From 7d763c0cbc395fb605bc9bdefa602209af120fba Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop <105209995+Qwerty5Uiop@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:32:33 +0400 Subject: [PATCH] chore: Reverse internal transactions fetching order (#10912) * chore: Reverse internal transactions fetching order * Add env var for internal transactions fetching order --- apps/explorer/lib/explorer/chain.ex | 4 +++- config/runtime.exs | 4 +++- docker-compose/envs/common-blockscout.env | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 216d42c700..346b2dd4fa 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1899,12 +1899,14 @@ defmodule Explorer.Chain do when accumulator: term() def stream_blocks_with_unfetched_internal_transactions(initial, reducer, limited? \\ false) when is_function(reducer, 2) do + direction = Application.get_env(:indexer, :internal_transactions_fetch_order) + query = from( po in PendingBlockOperation, where: not is_nil(po.block_number), select: po.block_number, - order_by: [desc: po.block_number] + order_by: [{^direction, po.block_number}] ) query diff --git a/config/runtime.exs b/config/runtime.exs index 3bf15bdd5f..e0be451262 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -681,7 +681,9 @@ config :indexer, ConfigHelper.parse_integer_env_var("INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 100_000), coin_balances_fetcher_init_limit: ConfigHelper.parse_integer_env_var("INDEXER_COIN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 2000), - graceful_shutdown_period: ConfigHelper.parse_time_env_var("INDEXER_GRACEFUL_SHUTDOWN_PERIOD", "5m") + graceful_shutdown_period: ConfigHelper.parse_time_env_var("INDEXER_GRACEFUL_SHUTDOWN_PERIOD", "5m"), + internal_transactions_fetch_order: + ConfigHelper.parse_catalog_value("INDEXER_INTERNAL_TRANSACTIONS_FETCH_ORDER", ["asc", "desc"], true, "asc") config :indexer, :ipfs, gateway_url: System.get_env("IPFS_GATEWAY_URL", "https://ipfs.io/ipfs"), diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 7c82e9e21c..dec8df0744 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -279,6 +279,7 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false # INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT= # INDEXER_COIN_BALANCES_FETCHER_INIT_QUERY_LIMIT= # INDEXER_GRACEFUL_SHUTDOWN_PERIOD= +# INDEXER_INTERNAL_TRANSACTIONS_FETCH_ORDER= # WITHDRAWALS_FIRST_BLOCK= # INDEXER_OPTIMISM_L1_RPC= # INDEXER_OPTIMISM_L1_SYSTEM_CONFIG_CONTRACT=