Separate FIRST_BLOCK and TRACE_FIRST_BLOCK option for blocks import and tracing methods

pull/5014/head
Viktor Baranov 3 years ago
parent 6c291ace22
commit 714670e9c2
  1. 3
      CHANGELOG.md
  2. 2
      apps/block_scout_web/assets/js/lib/smart_contract/common_helpers.js
  3. 12
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
  4. 7
      apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex
  5. 4
      apps/indexer/config/config.exs
  6. 2
      apps/indexer/lib/indexer/empty_blocks_sanitizer.ex
  7. 11
      apps/indexer/lib/indexer/fetcher/coin_balance.ex
  8. 24
      docker/Makefile

@ -23,8 +23,9 @@
- [#4867](https://github.com/blockscout/blockscout/pull/4867) - Fix bug in quering contracts method and improve contracts interactions
### Chore
- [#4983](https://github.com/blockscout/blockscout/pull/4983) - Fix contract verification tests
- [#5014](https://github.com/blockscout/blockscout/pull/5014) - Separate FIRST_BLOCK and TRACE_FIRST_BLOCK option for blocks import and tracing methods
- [#4998](https://github.com/blockscout/blockscout/pull/4998) - API endpoints logger
- [#4983](https://github.com/blockscout/blockscout/pull/4983) - Fix contract verification tests
## 4.0.0-beta

@ -46,7 +46,7 @@ export function prepareMethodArgs ($functionInputs, inputs) {
const sanitizedInputValueElements = inputValueElements.map(elementValue => {
const elementInputType = inputType.split('[')[0]
var sanitizedElementValue = replaceDoubleQuotes(elementValue, elementInputType)
let sanitizedElementValue = replaceDoubleQuotes(elementValue, elementInputType)
sanitizedElementValue = replaceSpaces(sanitizedElementValue, elementInputType)
if (isBoolInputType(elementInputType)) {

@ -219,7 +219,7 @@ defmodule EthereumJSONRPC do
@spec fetch_beneficiaries([block_number], json_rpc_named_arguments) ::
{:ok, FetchedBeneficiaries.t()} | {:error, reason :: term} | :ignore
def fetch_beneficiaries(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do
min_block = first_block_to_fetch()
min_block = trace_first_block_to_fetch()
filtered_block_numbers =
block_numbers
@ -310,7 +310,7 @@ defmodule EthereumJSONRPC do
Fetches internal transactions for entire blocks from variant API.
"""
def fetch_block_internal_transactions(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do
min_block = first_block_to_fetch()
min_block = trace_first_block_to_fetch()
filtered_block_numbers =
block_numbers
@ -488,8 +488,12 @@ defmodule EthereumJSONRPC do
end
end
defp first_block_to_fetch do
string_value = Application.get_env(:indexer, :first_block)
defp trace_first_block_to_fetch do
first_block_to_fetch(:trace_first_block)
end
def first_block_to_fetch(config) do
string_value = Application.get_env(:indexer, config)
case Integer.parse(string_value) do
{integer, ""} -> integer

@ -588,11 +588,14 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
end
defp remove_consensus_of_invalid_blocks(repo, invalid_block_numbers) do
minimal_block = first_block_to_fetch()
if Enum.count(invalid_block_numbers) > 0 do
update_query =
from(
b in Block,
where: b.number in ^invalid_block_numbers and b.consensus,
where: b.number > ^minimal_block,
select: b.hash,
# ShareLocks order already enforced by `acquire_blocks` (see docs: sharelocks.md)
update: [set: [consensus: false]]
@ -619,6 +622,10 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
end
end
def first_block_to_fetch do
EthereumJSONRPC.first_block_to_fetch(:trace_first_block)
end
def update_pending_blocks_status(repo, pending_hashes, invalid_block_hashes) do
valid_block_hashes =
pending_hashes

@ -36,7 +36,9 @@ config :indexer,
# bytes
memory_limit: 1 <<< 30,
first_block: System.get_env("FIRST_BLOCK") || "",
last_block: System.get_env("LAST_BLOCK") || ""
last_block: System.get_env("LAST_BLOCK") || "",
trace_first_block: System.get_env("TRACE_FIRST_BLOCK") || "",
trace_last_block: System.get_env("TRACE_LAST_BLOCK") || ""
config :indexer, Indexer.Fetcher.PendingTransaction.Supervisor,
disabled?: System.get_env("ETHEREUM_JSONRPC_VARIANT") == "besu"

@ -1,7 +1,7 @@
defmodule Indexer.EmptyBlocksSanitizer do
@moduledoc """
Periodically checks empty blocks starting from the head of the chain, detects for which blocks transactions should be refetched
and loose consensus for block in order to refetch transactions.
and lose consensus for block in order to refetch transactions.
"""
use GenServer

@ -79,7 +79,7 @@ defmodule Indexer.Fetcher.CoinBalance do
unique_filtered_entries =
Enum.filter(unique_entries, fn {_hash, block_number} ->
block_number >= first_block_to_index()
block_number >= EthereumJSONRPC.first_block_to_fetch(:trace_first_block)
end)
unique_entry_count = Enum.count(unique_filtered_entries)
@ -106,15 +106,6 @@ defmodule Indexer.Fetcher.CoinBalance do
end
end
defp first_block_to_index do
string_value = Application.get_env(:indexer, :first_block)
case Integer.parse(string_value) do
{integer, ""} -> integer
_ -> 0
end
end
defp entry_to_params({address_hash_bytes, block_number}) when is_integer(block_number) do
{:ok, address_hash} = Hash.Address.cast(address_hash_bytes)
%{block_quantity: integer_to_quantity(block_number), hash_data: to_string(address_hash)}

@ -118,6 +118,12 @@ endif
ifdef LAST_BLOCK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'LAST_BLOCK=$(LAST_BLOCK)'
endif
ifdef TRACE_FIRST_BLOCK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TRACE_FIRST_BLOCK=$(TRACE_FIRST_BLOCK)'
endif
ifdef TRACE_LAST_BLOCK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TRACE_LAST_BLOCK=$(TRACE_LAST_BLOCK)'
endif
ifdef TXS_COUNT_CACHE_PERIOD
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TXS_COUNT_CACHE_PERIOD=$(TXS_COUNT_CACHE_PERIOD)'
endif
@ -329,6 +335,24 @@ endif
ifdef DISPLAY_TOKEN_ICONS
BLOCKSCOUT_CONTAINER_PARAMS += -e 'DISPLAY_TOKEN_ICONS=$(DISPLAY_TOKEN_ICONS)'
endif
ifdef SHOW_TENDERLY_LINK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'SHOW_TENDERLY_LINK=$(SHOW_TENDERLY_LINK)'
endif
ifdef TENDERLY_CHAIN_PATH
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TENDERLY_CHAIN_PATH=$(TENDERLY_CHAIN_PATH)'
endif
ifdef MAX_STRING_LENGTH_WITHOUT_TRIMMING
BLOCKSCOUT_CONTAINER_PARAMS += -e 'MAX_STRING_LENGTH_WITHOUT_TRIMMING=$(MAX_STRING_LENGTH_WITHOUT_TRIMMING)'
endif
ifdef RE_CAPTCHA_SECRET_KEY
BLOCKSCOUT_CONTAINER_PARAMS += -e 'RE_CAPTCHA_SECRET_KEY=$(RE_CAPTCHA_SECRET_KEY)'
endif
ifdef RE_CAPTCHA_CLIENT_KEY
BLOCKSCOUT_CONTAINER_PARAMS += -e 'RE_CAPTCHA_CLIENT_KEY=$(RE_CAPTCHA_CLIENT_KEY)'
endif
ifdef ADDRESS_TOKEN_TRANSFERS_COUNTER_CACHE_PERIOD
BLOCKSCOUT_CONTAINER_PARAMS += -e 'ADDRESS_TOKEN_TRANSFERS_COUNTER_CACHE_PERIOD=$(ADDRESS_TOKEN_TRANSFERS_COUNTER_CACHE_PERIOD)'
endif
HAS_BLOCKSCOUT_IMAGE := $(shell docker images | grep -sw ${DOCKER_IMAGE})
build:

Loading…
Cancel
Save