Take into account `CHAIN_TYPE` for RSK

pull/8742/head
Maxim Filonov 1 year ago
parent 940799b5f9
commit 48bc9a16bd
  1. 1
      CHANGELOG.md
  2. 14
      apps/block_scout_web/lib/block_scout_web/views/api/v2/block_view.ex
  3. 111
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex
  4. 11
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/blocks.ex
  5. 14
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs
  6. 1
      apps/explorer/config/config.exs
  7. 46
      apps/explorer/lib/explorer/chain/block.ex
  8. 0
      apps/explorer/priv/rsk/migrations/20230724094744_add_rootstock_fields_to_blocks.exs
  9. 2
      apps/indexer/test/indexer/fetcher/rootstock_data_test.exs
  10. 3
      config/config_helper.exs
  11. 24
      config/runtime.exs

@ -21,6 +21,7 @@
### Chore
- [#8802](https://github.com/blockscout/blockscout/pull/8802) - Enable API v2 by default
- [#8742](https://github.com/blockscout/blockscout/pull/8742) - Merge rsk branch into the master branch
- [#8728](https://github.com/blockscout/blockscout/pull/8728) - Remove repos_list (default value for ecto repos) from Explorer.ReleaseTasks
<details>

@ -61,7 +61,7 @@ defmodule BlockScoutWeb.API.V2.BlockView do
"tx_fees" => tx_fees,
"withdrawals_count" => count_withdrawals(block)
}
|> add_rootstock_fields(block, single_block?)
|> chain_type_fields(block, single_block?)
end
def prepare_rewards(rewards, block, single_block?) do
@ -117,14 +117,18 @@ defmodule BlockScoutWeb.API.V2.BlockView do
def count_withdrawals(%Block{withdrawals: withdrawals}) when is_list(withdrawals), do: Enum.count(withdrawals)
def count_withdrawals(_), do: nil
defp add_rootstock_fields(prepared_block, _block, false), do: prepared_block
defp add_rootstock_fields(prepared_block, block, true) do
prepared_block
defp chain_type_fields(result, block, single_block?) do
case single_block? && Application.get_env(:explorer, :chain_type) do
"rsk" ->
result
|> Map.put("minimum_gas_price", block.minimum_gas_price)
|> Map.put("bitcoin_merged_mining_header", block.bitcoin_merged_mining_header)
|> Map.put("bitcoin_merged_mining_coinbase_transaction", block.bitcoin_merged_mining_coinbase_transaction)
|> Map.put("bitcoin_merged_mining_merkle_proof", block.bitcoin_merged_mining_merkle_proof)
|> Map.put("hash_for_merged_mining", block.hash_for_merged_mining)
_ ->
result
end
end
end

@ -8,8 +8,23 @@ defmodule EthereumJSONRPC.Block do
alias EthereumJSONRPC.{Transactions, Uncles, Withdrawals}
if Application.compile_env(:explorer, :chain_type) == "rsk" do
@rootstock_fields quote(
do: [
bitcoin_merged_mining_header: EthereumJSONRPC.data(),
bitcoin_merged_mining_coinbase_transaction: EthereumJSONRPC.data(),
bitcoin_merged_mining_merkle_proof: EthereumJSONRPC.data(),
hash_for_merged_mining: EthereumJSONRPC.data(),
minimum_gas_price: non_neg_integer()
]
)
else
@rootstock_fields quote(do: [])
end
@type elixir :: %{String.t() => non_neg_integer | DateTime.t() | String.t() | nil}
@type params :: %{
unquote_splicing(@rootstock_fields),
difficulty: pos_integer(),
extra_data: EthereumJSONRPC.hash(),
gas_limit: non_neg_integer(),
@ -30,12 +45,7 @@ defmodule EthereumJSONRPC.Block do
transactions_root: EthereumJSONRPC.hash(),
uncles: [EthereumJSONRPC.hash()],
base_fee_per_gas: non_neg_integer(),
withdrawals_root: EthereumJSONRPC.hash(),
minimum_gas_price: non_neg_integer(),
bitcoin_merged_mining_header: EthereumJSONRPC.data(),
bitcoin_merged_mining_coinbase_transaction: EthereumJSONRPC.data(),
bitcoin_merged_mining_merkle_proof: EthereumJSONRPC.data(),
hash_for_merged_mining: EthereumJSONRPC.data()
withdrawals_root: EthereumJSONRPC.hash()
}
@typedoc """
@ -74,12 +84,16 @@ defmodule EthereumJSONRPC.Block do
`t:EthereumJSONRPC.hash/0`.
* `"baseFeePerGas"` - `t:EthereumJSONRPC.quantity/0` of wei to denote amount of fee burned per unit gas used. Introduced in [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md)
* `"withdrawalsRoot"` - `t:EthereumJSONRPC.hash/0` of the root of the withdrawals.
#{if Application.compile_env(:explorer, :chain_type) == "rsk" do
"""
* `"minimumGasPrice"` - `t:EthereumJSONRPC.quantity/0` of the minimum gas price for this block.
* `"bitcoinMergedMiningHeader"` - `t:EthereumJSONRPC.data/0` of the Bitcoin merged mining header.
* `"bitcoinMergedMiningCoinbaseTransaction"` - `t:EthereumJSONRPC.data/0` of the Bitcoin merged mining coinbase transaction.
* `"bitcoinMergedMiningMerkleProof"` - `t:EthereumJSONRPC.data/0` of the Bitcoin merged mining merkle proof.
* `"hashForMergedMining"` - `t:EthereumJSONRPC.data/0` of the hash for merged mining.
"""
end}
"""
@type t :: %{String.t() => EthereumJSONRPC.data() | EthereumJSONRPC.hash() | EthereumJSONRPC.quantity() | nil}
def from_response(%{id: id, result: nil}, id_to_params) when is_map(id_to_params) do
@ -129,13 +143,18 @@ defmodule EthereumJSONRPC.Block do
...> "timestamp" => Timex.parse!("2017-12-15T21:03:30Z", "{ISO:Extended:Z}"),
...> "totalDifficulty" => 340282366920938463463374607431465668165,
...> "transactions" => [],
...> "transactionsRoot" => "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
...> "uncles" => [],
...> "transactionsRoot" => "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",\
#{if Application.compile_env(:explorer, :chain_type) == "rsk" do
"""
...> "minimumGasPrice" => 345786,
...> "bitcoinMergedMiningHeader" => "0x00006d20ffd048280094a6ea0851d854036aacaa25ee0f23f0040200000000000000000078d2638fe0b4477c54601e6449051afba8228e0a88ff06b0c91f091fd34d5da57487c76402610517372c2fe9",
...> "bitcoinMergedMiningCoinbaseTransaction" => "0x00000000000000805bf0dc9203da49a3b4e3ec913806e43102cc07db991272dc8b7018da57eb5abe59a32d070000ffffffff03449a4d26000000001976a914536ffa992491508dca0354e52f32a3a7a679a53a88ac00000000000000002b6a2952534b424c4f434b3ad2508d21d28c8f89d495923c0758ec3f64bd6755b4ec416f5601312600542a400000000000000000266a24aa21a9ed4ae42ea6dca2687aaed665714bf58b055c4e11f2fb038605930d630b49ad7b9d00000000",
...> "bitcoinMergedMiningMerkleProof" => "0x8e5a4ba74eb4eb2f9ad4cabc2913aeed380a5becf7cd4d513341617efb798002bd83a783c31c66a8a8f6cc56c071c2d471cb610e3dc13054b9d216021d8c7e9112f622564449ebedcedf7d4ccb6fe0ffac861b7ed1446c310813cdf712e1e6add28b1fe1c0ae5e916194ba4f285a9340aba41e91bf847bf31acf37a9623a04a2348a37ab9faa5908122db45596bbc03e9c3644b0d4589471c4ff30fc139f3ba50506e9136fa0df799b487494de3e2b3dec937338f1a2e18da057c1f60590a9723672a4355b9914b1d01af9f582d9e856f6e1744be00f268b0b01d559329f7e0685aa63ffeb7c28486d7462292021d1345cddbf7c920ca34bb7aa4c6cdbe068806e35d0db662e7fcda03cb4d779594638c62a1fdd7ec98d1fb6d240d853958abe57561d9b9d0465cf8b9d6ee3c58b0d8b07d6c4c5d8f348e43fe3c06011b6a0008db4e0b16c77ececc3981f9008201cea5939869d648e59a09bd2094b1196ff61126bffb626153deed2563e1745436247c94a85d2947756b606d67633781c99d7",
...> "hashForMergedMining" => "0xd2508d21d28c8f89d495923c0758ec3f64bd6755b4ec416f5601312600542a40",
...> "hashForMergedMining" => "0xd2508d21d28c8f89d495923c0758ec3f64bd6755b4ec416f5601312600542a40",\
"""
end}
...> "uncles" => []
...> }
...> )
%{
@ -157,13 +176,18 @@ defmodule EthereumJSONRPC.Block do
timestamp: Timex.parse!("2017-12-15T21:03:30Z", "{ISO:Extended:Z}"),
total_difficulty: 340282366920938463463374607431465668165,
transactions_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: [],
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: [],\
#{if Application.compile_env(:explorer, :chain_type) == "rsk" do
"""
bitcoin_merged_mining_coinbase_transaction: "0x00000000000000805bf0dc9203da49a3b4e3ec913806e43102cc07db991272dc8b7018da57eb5abe59a32d070000ffffffff03449a4d26000000001976a914536ffa992491508dca0354e52f32a3a7a679a53a88ac00000000000000002b6a2952534b424c4f434b3ad2508d21d28c8f89d495923c0758ec3f64bd6755b4ec416f5601312600542a400000000000000000266a24aa21a9ed4ae42ea6dca2687aaed665714bf58b055c4e11f2fb038605930d630b49ad7b9d00000000",
bitcoin_merged_mining_header: "0x00006d20ffd048280094a6ea0851d854036aacaa25ee0f23f0040200000000000000000078d2638fe0b4477c54601e6449051afba8228e0a88ff06b0c91f091fd34d5da57487c76402610517372c2fe9",
bitcoin_merged_mining_merkle_proof: "0x8e5a4ba74eb4eb2f9ad4cabc2913aeed380a5becf7cd4d513341617efb798002bd83a783c31c66a8a8f6cc56c071c2d471cb610e3dc13054b9d216021d8c7e9112f622564449ebedcedf7d4ccb6fe0ffac861b7ed1446c310813cdf712e1e6add28b1fe1c0ae5e916194ba4f285a9340aba41e91bf847bf31acf37a9623a04a2348a37ab9faa5908122db45596bbc03e9c3644b0d4589471c4ff30fc139f3ba50506e9136fa0df799b487494de3e2b3dec937338f1a2e18da057c1f60590a9723672a4355b9914b1d01af9f582d9e856f6e1744be00f268b0b01d559329f7e0685aa63ffeb7c28486d7462292021d1345cddbf7c920ca34bb7aa4c6cdbe068806e35d0db662e7fcda03cb4d779594638c62a1fdd7ec98d1fb6d240d853958abe57561d9b9d0465cf8b9d6ee3c58b0d8b07d6c4c5d8f348e43fe3c06011b6a0008db4e0b16c77ececc3981f9008201cea5939869d648e59a09bd2094b1196ff61126bffb626153deed2563e1745436247c94a85d2947756b606d67633781c99d7",
hash_for_merged_mining: "0xd2508d21d28c8f89d495923c0758ec3f64bd6755b4ec416f5601312600542a40",
minimum_gas_price: 345786
minimum_gas_price: 345786,\
"""
end}
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
[Geth] `elixir` can be converted to params
@ -211,18 +235,28 @@ defmodule EthereumJSONRPC.Block do
timestamp: Timex.parse!("2015-07-30T15:32:07Z", "{ISO:Extended:Z}"),
total_difficulty: 1039309006117,
transactions_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: [],
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: [],\
#{if Application.compile_env(:explorer, :chain_type) == "rsk" do
"""
bitcoin_merged_mining_coinbase_transaction: nil,
bitcoin_merged_mining_header: nil,
bitcoin_merged_mining_merkle_proof: nil,
hash_for_merged_mining: nil,
minimum_gas_price: nil
minimum_gas_price: nil,\
"""
end}
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
"""
@spec elixir_to_params(elixir) :: params
def elixir_to_params(
def elixir_to_params(elixir) do
elixir
|> do_elixir_to_params()
|> chain_type_fields(elixir)
end
defp do_elixir_to_params(
%{
"difficulty" => difficulty,
"extraData" => extra_data,
@ -266,16 +300,11 @@ defmodule EthereumJSONRPC.Block do
uncles: uncles,
base_fee_per_gas: base_fee_per_gas,
withdrawals_root:
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
minimum_gas_price: Map.get(elixir, "minimumGasPrice"),
bitcoin_merged_mining_header: Map.get(elixir, "bitcoinMergedMiningHeader"),
bitcoin_merged_mining_coinbase_transaction: Map.get(elixir, "bitcoinMergedMiningCoinbaseTransaction"),
bitcoin_merged_mining_merkle_proof: Map.get(elixir, "bitcoinMergedMiningMerkleProof"),
hash_for_merged_mining: Map.get(elixir, "hashForMergedMining")
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
}
end
def elixir_to_params(
defp do_elixir_to_params(
%{
"difficulty" => difficulty,
"extraData" => extra_data,
@ -317,16 +346,11 @@ defmodule EthereumJSONRPC.Block do
uncles: uncles,
base_fee_per_gas: base_fee_per_gas,
withdrawals_root:
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
minimum_gas_price: Map.get(elixir, "minimumGasPrice"),
bitcoin_merged_mining_header: Map.get(elixir, "bitcoinMergedMiningHeader"),
bitcoin_merged_mining_coinbase_transaction: Map.get(elixir, "bitcoinMergedMiningCoinbaseTransaction"),
bitcoin_merged_mining_merkle_proof: Map.get(elixir, "bitcoinMergedMiningMerkleProof"),
hash_for_merged_mining: Map.get(elixir, "hashForMergedMining")
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
}
end
def elixir_to_params(
defp do_elixir_to_params(
%{
"difficulty" => difficulty,
"extraData" => extra_data,
@ -368,17 +392,12 @@ defmodule EthereumJSONRPC.Block do
transactions_root: transactions_root,
uncles: uncles,
withdrawals_root:
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
minimum_gas_price: Map.get(elixir, "minimumGasPrice"),
bitcoin_merged_mining_header: Map.get(elixir, "bitcoinMergedMiningHeader"),
bitcoin_merged_mining_coinbase_transaction: Map.get(elixir, "bitcoinMergedMiningCoinbaseTransaction"),
bitcoin_merged_mining_merkle_proof: Map.get(elixir, "bitcoinMergedMiningMerkleProof"),
hash_for_merged_mining: Map.get(elixir, "hashForMergedMining")
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
}
end
# Geth: a response from eth_getblockbyhash for uncle blocks is without `totalDifficulty` param
def elixir_to_params(
defp do_elixir_to_params(
%{
"difficulty" => difficulty,
"extraData" => extra_data,
@ -418,13 +437,25 @@ defmodule EthereumJSONRPC.Block do
transactions_root: transactions_root,
uncles: uncles,
withdrawals_root:
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
Map.get(elixir, "withdrawalsRoot", "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
}
end
defp chain_type_fields(params, elixir) do
case Application.get_env(:explorer, :chain_type) do
"rsk" ->
params
|> Map.merge(%{
minimum_gas_price: Map.get(elixir, "minimumGasPrice"),
bitcoin_merged_mining_header: Map.get(elixir, "bitcoinMergedMiningHeader"),
bitcoin_merged_mining_coinbase_transaction: Map.get(elixir, "bitcoinMergedMiningCoinbaseTransaction"),
bitcoin_merged_mining_merkle_proof: Map.get(elixir, "bitcoinMergedMiningMerkleProof"),
hash_for_merged_mining: Map.get(elixir, "hashForMergedMining")
}
})
_ ->
params
end
end
@doc """

@ -116,13 +116,18 @@ defmodule EthereumJSONRPC.Blocks do
timestamp: Timex.parse!("1970-01-01T00:00:00Z", "{ISO:Extended:Z}"),
total_difficulty: 131072,
transactions_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: ["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273311"],
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: ["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273311"],\
#{if Application.compile_env(:explorer, :chain_type) == "rsk" do
"""
bitcoin_merged_mining_coinbase_transaction: nil,
bitcoin_merged_mining_header: nil,
bitcoin_merged_mining_merkle_proof: nil,
hash_for_merged_mining: nil,
minimum_gas_price: nil
minimum_gas_price: nil,\
"""
end}
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
]

@ -32,7 +32,8 @@ defmodule EthereumJSONRPC.BlockTest do
"uncles" => []
})
assert result == %{
assert result ==
%{
difficulty: 17_561_410_778,
extra_data: "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32",
gas_limit: 5000,
@ -53,13 +54,22 @@ defmodule EthereumJSONRPC.BlockTest do
total_difficulty: nil,
transactions_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: [],
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
withdrawals_root: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
|> (&if(Application.get_env(:explorer, :chain_type) == "rsk",
do:
Map.merge(
&1,
%{
bitcoin_merged_mining_coinbase_transaction: nil,
bitcoin_merged_mining_header: nil,
bitcoin_merged_mining_merkle_proof: nil,
hash_for_merged_mining: nil,
minimum_gas_price: nil
}
),
else: &1
)).()
end
end

@ -11,6 +11,7 @@ import Config
# General application configuration
config :explorer,
chain_type: ConfigHelper.chain_type(),
ecto_repos: ConfigHelper.repos(),
token_functions_reader_max_retries: 3,
# for not fully indexed blockchains

@ -10,7 +10,15 @@ defmodule Explorer.Chain.Block do
alias Explorer.Chain.{Address, Block, Gas, Hash, PendingBlockOperation, Transaction, Wei, Withdrawal}
alias Explorer.Chain.Block.{Reward, SecondDegreeRelation}
@optional_attrs ~w(size refetch_needed total_difficulty difficulty base_fee_per_gas minimum_gas_price bitcoin_merged_mining_header bitcoin_merged_mining_coinbase_transaction bitcoin_merged_mining_merkle_proof hash_for_merged_mining)a
@optional_attrs ~w(size refetch_needed total_difficulty difficulty base_fee_per_gas)a
|> (&(case Application.compile_env(:explorer, :chain_type) == "rsk" do
"rsk" ->
&1 ++
~w(minimum_gas_price bitcoin_merged_mining_header bitcoin_merged_mining_coinbase_transaction bitcoin_merged_mining_merkle_proof hash_for_merged_mining)a
_ ->
&1
end)).()
@required_attrs ~w(consensus gas_limit gas_used hash miner_hash nonce number parent_hash timestamp)a
@ -26,6 +34,20 @@ defmodule Explorer.Chain.Block do
"""
@type block_number :: non_neg_integer()
if Application.compile_env(:explorer, :chain_type) == "rsk" do
@rootstock_fields quote(
do: [
bitcoin_merged_mining_header: binary(),
bitcoin_merged_mining_coinbase_transaction: binary(),
bitcoin_merged_mining_merkle_proof: binary(),
hash_for_merged_mining: binary(),
minimum_gas_price: Decimal.t()
]
)
else
@rootstock_fields quote(do: [])
end
@typedoc """
* `consensus`
* `true` - this is a block on the longest consensus agreed upon chain.
@ -47,8 +69,18 @@ defmodule Explorer.Chain.Block do
* `total_difficulty` - the total `difficulty` of the chain until this block.
* `transactions` - the `t:Explorer.Chain.Transaction.t/0` in this block.
* `base_fee_per_gas` - Minimum fee required per unit of gas. Fee adjusts based on network congestion.
#{if Application.compile_env(:explorer, :chain_type) == "rsk" do
"""
* `bitcoin_merged_mining_header` - Bitcoin merged mining header on Rootstock chains.
* `bitcoin_merged_mining_coinbase_transaction` - Bitcoin merged mining coinbase transaction on Rootstock chains.
* `bitcoin_merged_mining_merkle_proof` - Bitcoin merged mining merkle proof on Rootstock chains.
* `hash_for_merged_mining` - Hash for merged mining on Rootstock chains.
* `minimum_gas_price` - Minimum block gas price on Rootstock chains.
"""
end}
"""
@type t :: %__MODULE__{
unquote_splicing(@rootstock_fields),
consensus: boolean(),
difficulty: difficulty(),
gas_limit: Gas.t(),
@ -65,12 +97,7 @@ defmodule Explorer.Chain.Block do
transactions: %Ecto.Association.NotLoaded{} | [Transaction.t()],
refetch_needed: boolean(),
base_fee_per_gas: Wei.t(),
is_empty: boolean(),
minimum_gas_price: Decimal.t(),
bitcoin_merged_mining_header: binary(),
bitcoin_merged_mining_coinbase_transaction: binary(),
bitcoin_merged_mining_merkle_proof: binary(),
hash_for_merged_mining: binary()
is_empty: boolean()
}
@primary_key {:hash, Hash.Full, autogenerate: false}
@ -87,11 +114,14 @@ defmodule Explorer.Chain.Block do
field(:refetch_needed, :boolean)
field(:base_fee_per_gas, Wei)
field(:is_empty, :boolean)
field(:minimum_gas_price, :decimal)
if Application.compile_env(:explorer, :chain_type) == "rsk" do
field(:bitcoin_merged_mining_header, :binary)
field(:bitcoin_merged_mining_coinbase_transaction, :binary)
field(:bitcoin_merged_mining_merkle_proof, :binary)
field(:hash_for_merged_mining, :binary)
field(:minimum_gas_price, :decimal)
end
timestamps()

@ -10,6 +10,7 @@ defmodule Indexer.Fetcher.RootstockDataTest do
setup :verify_on_exit!
setup :set_mox_global
if Application.compile_env(:explorer, :chain_type) == "rsk" do
test "do not start when all old blocks are fetched", %{json_rpc_named_arguments: json_rpc_named_arguments} do
RootstockData.Supervisor.Case.start_supervised!(json_rpc_named_arguments: json_rpc_named_arguments)
@ -131,4 +132,5 @@ defmodule Indexer.Fetcher.RootstockDataTest do
# Terminates the process so it finishes all Ecto processes.
GenServer.stop(pid)
end
end
end

@ -179,4 +179,7 @@ defmodule ConfigHelper do
rescue
err -> raise "Invalid JSON in environment variable #{env_var}: #{inspect(err)}"
end
@spec chain_type() :: String.t()
def chain_type, do: System.get_env("CHAIN_TYPE") || "ethereum"
end

@ -4,8 +4,6 @@ import Config
|> Path.join()
|> Code.eval_file()
chain_type = System.get_env("CHAIN_TYPE") || "ethereum"
######################
### BlockScout Web ###
######################
@ -162,7 +160,7 @@ config :ethereum_jsonrpc, EthereumJSONRPC.HTTP,
config :ethereum_jsonrpc, EthereumJSONRPC.Geth,
debug_trace_transaction_timeout: System.get_env("ETHEREUM_JSONRPC_DEBUG_TRACE_TRANSACTION_TIMEOUT", "5s"),
tracer:
if(chain_type == "polygon_edge",
if(ConfigHelper.chain_type() == "polygon_edge",
do: "polygon_edge",
else: System.get_env("INDEXER_INTERNAL_TRANSACTIONS_TRACER_TYPE", "call_tracer")
)
@ -185,7 +183,6 @@ checksum_function = System.get_env("CHECKSUM_FUNCTION")
exchange_rates_coin = System.get_env("EXCHANGE_RATES_COIN")
config :explorer,
chain_type: chain_type,
coin: System.get_env("COIN") || exchange_rates_coin || "ETH",
coin_name: System.get_env("COIN_NAME") || exchange_rates_coin || "ETH",
allowed_solidity_evm_versions:
@ -590,15 +587,19 @@ config :indexer, Indexer.Fetcher.Withdrawal.Supervisor,
config :indexer, Indexer.Fetcher.Withdrawal, first_block: System.get_env("WITHDRAWALS_FIRST_BLOCK")
config :indexer, Indexer.Fetcher.PolygonEdge.Supervisor, disabled?: !(chain_type == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.Supervisor, disabled?: !(ConfigHelper.chain_type() == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.Deposit.Supervisor, disabled?: !(chain_type == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.Deposit.Supervisor,
disabled?: !(ConfigHelper.chain_type() == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.DepositExecute.Supervisor, disabled?: !(chain_type == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.DepositExecute.Supervisor,
disabled?: !(ConfigHelper.chain_type() == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.Withdrawal.Supervisor, disabled?: !(chain_type == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.Withdrawal.Supervisor,
disabled?: !(ConfigHelper.chain_type() == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.WithdrawalExit.Supervisor, disabled?: !(chain_type == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge.WithdrawalExit.Supervisor,
disabled?: !(ConfigHelper.chain_type() == "polygon_edge")
config :indexer, Indexer.Fetcher.PolygonEdge,
polygon_edge_l1_rpc: System.get_env("INDEXER_POLYGON_EDGE_L1_RPC"),
@ -630,8 +631,9 @@ config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch.Supervisor,
System.get_env("CHAIN_TYPE", "ethereum") == "polygon_zkevm" &&
ConfigHelper.parse_bool_env_var("INDEXER_ZKEVM_BATCHES_ENABLED")
config :indexer, Indexer.Fetcher.RootstockData.Supervisor,
disabled?: ConfigHelper.parse_bool_env_var("INDEXER_DISABLE_ROOTSTOCK_DATA_FETCHER")
config :indexer, Indexer.Fetcher.RootstockData.Supervisor,
disabled?:
ConfigHelper.chain_type() != "rsk" || ConfigHelper.parse_bool_env_var("INDEXER_DISABLE_ROOTSTOCK_DATA_FETCHER")
config :indexer, Indexer.Fetcher.RootstockData,
interval: ConfigHelper.parse_time_env_var("INDEXER_ROOTSTOCK_DATA_FETCHER_INTERVAL", "3s"),

Loading…
Cancel
Save