diff --git a/CHANGELOG.md b/CHANGELOG.md index d6e4ae3401..822a064f5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features ### Fixes +- [#3121](https://github.com/poanetwork/blockscout/pull/3121) - Geth: handle response from eth_getblockbyhash JSON RPC method without totalDifficulty (uncle blocks) - [#3073](https://github.com/poanetwork/blockscout/issues/3073) - Fix performance of Inventory tab loading for ERC-721 tokens - [#3114](https://github.com/poanetwork/blockscout/pull/3114) - Fix performance of "Blocks validated" page - [#3112](https://github.com/poanetwork/blockscout/pull/3112) - Fix verification of contracts, compiled with nightly builds of solc compiler diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex index de83b3601e..20e7db22c8 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex @@ -235,6 +235,49 @@ defmodule EthereumJSONRPC.Block do } end + # Geth: a response from eth_getblockbyhash for uncle blocks is without `totalDifficulty` param + def elixir_to_params( + %{ + "difficulty" => difficulty, + "extraData" => extra_data, + "gasLimit" => gas_limit, + "gasUsed" => gas_used, + "hash" => hash, + "logsBloom" => logs_bloom, + "miner" => miner_hash, + "number" => number, + "parentHash" => parent_hash, + "receiptsRoot" => receipts_root, + "sha3Uncles" => sha3_uncles, + "size" => size, + "stateRoot" => state_root, + "timestamp" => timestamp, + "transactionsRoot" => transactions_root, + "uncles" => uncles + } = elixir + ) do + %{ + difficulty: difficulty, + extra_data: extra_data, + gas_limit: gas_limit, + gas_used: gas_used, + hash: hash, + logs_bloom: logs_bloom, + miner_hash: miner_hash, + mix_hash: Map.get(elixir, "mixHash", "0x0"), + nonce: Map.get(elixir, "nonce", 0), + number: number, + parent_hash: parent_hash, + receipts_root: receipts_root, + sha3_uncles: sha3_uncles, + size: size, + state_root: state_root, + timestamp: timestamp, + transactions_root: transactions_root, + uncles: uncles + } + end + @doc """ Get `t:EthereumJSONRPC.Transactions.elixir/0` from `t:elixir/0`