Skip to content

Commit

Permalink
Merge pull request blockscout#8742 from blockscout/mf-merge-rsk-into-…
Browse files Browse the repository at this point in the history
…main

Merge rsk branch into the master branch
  • Loading branch information
vbaranov authored Nov 15, 2023
2 parents d9d7ef9 + f22c4b5 commit abce79e
Show file tree
Hide file tree
Showing 17 changed files with 720 additions and 141 deletions.
73 changes: 58 additions & 15 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,23 @@ on:

env:
MIX_ENV: test
OTP_VERSION: '25.2.1'
ELIXIR_VERSION: '1.14.5'
ACCOUNT_AUTH0_DOMAIN: 'blockscoutcom.us.auth0.com'
OTP_VERSION: "25.2.1"
ELIXIR_VERSION: "1.14.5"
ACCOUNT_AUTH0_DOMAIN: "blockscoutcom.us.auth0.com"

jobs:
matrix-builder:
name: Build matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
env:
matrixStringifiedObject: '{"chain-type": ["ethereum", "polygon_edge", "polygon_zkevm", "rsk", "suave", "stability"]}'

build-and-cache:
name: Build and Cache deps
runs-on: ubuntu-latest
Expand Down Expand Up @@ -142,10 +154,16 @@ jobs:
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
- run: mix format --check-formatted

dialyzer:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-builder.outputs.matrix) }}
name: Dialyzer static analysis
runs-on: ubuntu-latest
needs: build-and-cache
needs:
- build-and-cache
- matrix-builder
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
Expand All @@ -169,18 +187,22 @@ jobs:
id: dialyzer-cache
with:
path: priv/plts
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-dialyzer-mixlockhash_25-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-${{ matrix.chain-type }}-dialyzer-mixlockhash_25-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-dialyzer-"
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-${{ matrix.chain-type }}-dialyzer-"
- name: Conditionally build Dialyzer Cache
if: steps.dialyzer-cache.output.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt
env:
CHAIN_TYPE: ${{ matrix.chain-type }}

- name: Run Dialyzer
run: mix dialyzer --halt-exit-status
env:
CHAIN_TYPE: ${{ matrix.chain-type }}

gettext:
name: Missing translation keys check
Expand Down Expand Up @@ -370,9 +392,14 @@ jobs:
working-directory: apps/block_scout_web/assets

test_nethermind_mox_ethereum_jsonrpc:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-builder.outputs.matrix) }}
name: EthereumJSONRPC Tests
runs-on: ubuntu-latest
needs: build-and-cache
needs:
- build-and-cache
- matrix-builder
services:
postgres:
image: postgres
Expand Down Expand Up @@ -423,10 +450,16 @@ jobs:
PGUSER: postgres
ETHEREUM_JSONRPC_CASE: "EthereumJSONRPC.Case.Nethermind.Mox"
ETHEREUM_JSONRPC_WEB_SOCKET_CASE: "EthereumJSONRPC.WebSocket.Case.Mox"
CHAIN_TYPE: "${{ matrix.chain-type }}"
test_nethermind_mox_explorer:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-builder.outputs.matrix) }}
name: Explorer Tests
runs-on: ubuntu-latest
needs: build-and-cache
needs:
- build-and-cache
- matrix-builder
services:
postgres:
image: postgres
Expand Down Expand Up @@ -488,10 +521,16 @@ jobs:
PGUSER: postgres
ETHEREUM_JSONRPC_CASE: "EthereumJSONRPC.Case.Nethermind.Mox"
ETHEREUM_JSONRPC_WEB_SOCKET_CASE: "EthereumJSONRPC.WebSocket.Case.Mox"
CHAIN_TYPE: "${{ matrix.chain-type }}"
test_nethermind_mox_indexer:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-builder.outputs.matrix) }}
name: Indexer Tests
runs-on: ubuntu-latest
needs: build-and-cache
needs:
- build-and-cache
- matrix-builder
services:
postgres:
image: postgres
Expand Down Expand Up @@ -529,7 +568,6 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
- run: ./bin/install_chrome_headless.sh

- name: mix test --exclude no_nethermind
Expand All @@ -546,15 +584,20 @@ jobs:
PGUSER: postgres
ETHEREUM_JSONRPC_CASE: "EthereumJSONRPC.Case.Nethermind.Mox"
ETHEREUM_JSONRPC_WEB_SOCKET_CASE: "EthereumJSONRPC.WebSocket.Case.Mox"

CHAIN_TYPE: "${{ matrix.chain-type }}"
test_nethermind_mox_block_scout_web:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-builder.outputs.matrix) }}
name: Blockscout Web Tests
runs-on: ubuntu-latest
needs: build-and-cache
needs:
- build-and-cache
- matrix-builder
services:
redis_db:
image: 'redis:alpine'
ports:
image: "redis:alpine"
ports:
- 6379:6379

postgres:
Expand Down Expand Up @@ -593,7 +636,6 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
- name: Restore Explorer NPM Cache
uses: actions/cache@v2
id: explorer-npm-cache
Expand Down Expand Up @@ -638,3 +680,4 @@ jobs:
ACCOUNT_ENABLED: "true"
ACCOUNT_REDIS_URL: "redis://localhost:6379"
SOURCIFY_INTEGRATION_ENABLED: "true"
CHAIN_TYPE: "${{ matrix.chain-type }}"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

- [#8832](https://github.com/blockscout/blockscout/pull/8832) - Log more details in regards 413 error
- [#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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ defmodule BlockScoutWeb.API.V2.BlockView do
"tx_fees" => tx_fees,
"withdrawals_count" => count_withdrawals(block)
}
|> chain_type_fields(block, single_block?)
end

def prepare_rewards(rewards, block, single_block?) do
Expand Down Expand Up @@ -115,4 +116,19 @@ 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 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
6 changes: 3 additions & 3 deletions apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ defmodule EthereumJSONRPC do
@doc """
Fetches blocks by block number list.
"""
@spec fetch_blocks_by_numbers([block_number()], json_rpc_named_arguments) ::
@spec fetch_blocks_by_numbers([block_number()], json_rpc_named_arguments, boolean()) ::
{:ok, Blocks.t()} | {:error, reason :: term}
def fetch_blocks_by_numbers(block_numbers, json_rpc_named_arguments) do
def fetch_blocks_by_numbers(block_numbers, json_rpc_named_arguments, with_transactions? \\ true) do
block_numbers
|> Enum.map(fn number -> %{number: number} end)
|> fetch_blocks_by_params(&Block.ByNumber.request/1, json_rpc_named_arguments)
|> fetch_blocks_by_params(&Block.ByNumber.request(&1, with_transactions?), json_rpc_named_arguments)
end

@doc """
Expand Down
Loading

0 comments on commit abce79e

Please sign in to comment.