Skip to content

Commit

Permalink
Merge pull request #49 from aurora-is-near/sync-15-07-24
Browse files Browse the repository at this point in the history
Sync with origin
  • Loading branch information
spilin authored Aug 7, 2024
2 parents d5e433b + bf3a9a7 commit 7fa3edb
Show file tree
Hide file tree
Showing 118 changed files with 4,740 additions and 1,643 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup-repo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runs:
- name: Find builder
if: ${{ inputs.docker-remote-multi-platform }}
shell: bash
run: echo "BUILDER_IP=$(./.github/scripts/select-builder.sh ${{ inputs.docker-arm-host }} ubuntu ~/.ssh/id_rsa)" >> $GITHUB_ENV
run: echo "BUILDER_IP=$(./.github/scripts/select-builder.sh ${{ inputs.docker-arm-host }} root ~/.ssh/id_rsa)" >> $GITHUB_ENV
- name: Set up SSH
if: ${{ inputs.docker-remote-multi-platform }}
uses: MrSquaare/ssh-setup-action@523473d91581ccbf89565e12b40faba93f2708bd # v1.1.0
Expand All @@ -68,7 +68,7 @@ runs:
with:
platforms: linux/amd64
append: |
- endpoint: ssh://ubuntu@${{ env.BUILDER_IP }}
- endpoint: ssh://root@${{ env.BUILDER_IP }}
platforms: linux/arm64/v8
- name: Log in to Docker Hub
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-docker-image-for-eth-sepolia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
linux/amd64
linux/arm64/v8
build-args: |
CHAIN_TYPE=ethereum
CACHE_EXCHANGE_RATES_PERIOD=
API_V1_READ_METHODS_DISABLED=false
DISABLE_WEBAPP=false
Expand All @@ -46,6 +45,7 @@ jobs:
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=ethereum
- name: Build and push Docker image (indexer)
uses: docker/build-push-action@v5
Expand All @@ -59,7 +59,6 @@ jobs:
linux/amd64
linux/arm64/v8
build-args: |
CHAIN_TYPE=ethereum
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_WEBAPP=true
DISABLE_API=true
Expand All @@ -68,6 +67,7 @@ jobs:
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=ethereum
- name: Build and push Docker image (API)
uses: docker/build-push-action@v5
Expand All @@ -81,12 +81,12 @@ jobs:
linux/amd64
linux/arm64/v8
build-args: |
CHAIN_TYPE=ethereum
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_WEBAPP=true
DISABLE_INDEXER=true
CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED=
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=ethereum
4 changes: 2 additions & 2 deletions .github/workflows/publish-docker-image-for-eth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
linux/amd64
linux/arm64/v8
build-args: |
CHAIN_TYPE=ethereum
CACHE_EXCHANGE_RATES_PERIOD=
API_V1_READ_METHODS_DISABLED=false
DISABLE_WEBAPP=false
Expand All @@ -45,4 +44,5 @@ jobs:
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=ethereum
46 changes: 45 additions & 1 deletion .github/workflows/publish-docker-image-for-optimism.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
docker-arm-host: ${{ secrets.ARM_RUNNER_HOSTNAME }}
docker-arm-host-key: ${{ secrets.ARM_RUNNER_KEY }}

- name: Build and push Docker image
- name: Build and push Docker image (indexer + API)
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -45,4 +45,48 @@ jobs:
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=optimism
- name: Build and push Docker image (indexer)
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: true
tags: blockscout/blockscout-${{ env.DOCKER_CHAIN_NAME }}:${{ env.RELEASE_VERSION }}-postrelease-${{ env.SHORT_SHA }}-indexer
labels: ${{ steps.setup.outputs.docker-labels }}
platforms: |
linux/amd64
linux/arm64/v8
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_WEBAPP=true
DISABLE_API=true
CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED=
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=optimism
- name: Build and push Docker image (API)
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: true
tags: blockscout/blockscout-${{ env.DOCKER_CHAIN_NAME }}:${{ env.RELEASE_VERSION }}-postrelease-${{ env.SHORT_SHA }}-api
labels: ${{ steps.setup.outputs.docker-labels }}
platforms: |
linux/amd64
linux/arm64/v8
build-args: |
CACHE_EXCHANGE_RATES_PERIOD=
DISABLE_WEBAPP=true
DISABLE_INDEXER=true
CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED=
ADMIN_PANEL_ENABLED=false
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta.+commit.${{ env.SHORT_SHA }}
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
CHAIN_TYPE=optimism
1 change: 1 addition & 0 deletions apps/block_scout_web/config/runtime/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Config

alias EthereumJSONRPC.Variant

config :ethereum_jsonrpc, EthereumJSONRPC.Utility.EndpointAvailabilityChecker, enabled: false
config :explorer, Explorer.ExchangeRates, enabled: false, store: :none

config :ueberauth, Ueberauth.Strategy.Auth0.OAuth,
Expand Down
7 changes: 7 additions & 0 deletions apps/block_scout_web/lib/block_scout_web/chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ defmodule BlockScoutWeb.Chain do
}

alias Explorer.Chain.Optimism.Deposit, as: OptimismDeposit
alias Explorer.Chain.Optimism.FrameSequence, as: OptimismFrameSequence
alias Explorer.Chain.Optimism.OutputRoot, as: OptimismOutputRoot

alias Explorer.Chain.PolygonZkevm.TransactionBatch
Expand Down Expand Up @@ -435,6 +436,7 @@ defmodule BlockScoutWeb.Chain do

# clause for pagination of entities:
# - Account's entities
# - Optimism frame sequences
# - Polygon Edge Deposits
# - Polygon Edge Withdrawals
# - Arbitrum cross chain messages
Expand All @@ -450,6 +452,7 @@ defmodule BlockScoutWeb.Chain do

# clause for pagination of entities:
# - Account's entities
# - Optimism frame sequences
# - Polygon Edge Deposits
# - Polygon Edge Withdrawals
# - Arbitrum cross chain messages
Expand Down Expand Up @@ -621,6 +624,10 @@ defmodule BlockScoutWeb.Chain do
paging_params(token)
end

defp paging_params(%OptimismFrameSequence{id: id}) do
%{"id" => id}
end

defp paging_params(%TagAddress{id: id}) do
%{"id" => id}
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule BlockScoutWeb.ArbitrumChannel do
@moduledoc """
Establishes pub/sub channel for live updates of Arbitrum related events.
"""
use BlockScoutWeb, :channel

def join("arbitrum:new_batch", _params, socket) do
{:ok, %{}, socket}
end

def join("arbitrum:new_messages_to_rollup_amount", _params, socket) do
{:ok, %{}, socket}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ defmodule BlockScoutWeb.UserSocketV2 do
channel("token_instances:*", BlockScoutWeb.TokenInstanceChannel)
channel("zkevm_batches:*", BlockScoutWeb.PolygonZkevmConfirmedBatchChannel)

case Application.compile_env(:explorer, :chain_type) do
:arbitrum -> channel("arbitrum:*", BlockScoutWeb.ArbitrumChannel)
_ -> nil
end

def connect(_params, socket) do
{:ok, socket}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ defmodule BlockScoutWeb.API.V2.ArbitrumController do
only: [
next_page_params: 4,
paging_options: 1,
split_list_by_page: 1
split_list_by_page: 1,
parse_block_hash_or_number_param: 1
]

import Explorer.Chain.Arbitrum.DaMultiPurposeRecord.Helper, only: [calculate_celestia_data_key: 2]

alias Explorer.PagingOptions
alias Explorer.Chain.Arbitrum.{L1Batch, Message, Reader}

action_fallback(BlockScoutWeb.API.V2.FallbackController)

@batch_necessity_by_association %{:commitment_transaction => :optional}
@batch_necessity_by_association %{:commitment_transaction => :required}

@doc """
Function to handle GET requests to `/api/v2/arbitrum/messages/:direction` endpoint.
Expand Down Expand Up @@ -76,6 +79,39 @@ defmodule BlockScoutWeb.API.V2.ArbitrumController do
end
end

@doc """
Function to handle GET requests to `/api/v2/arbitrum/batches/da/:data_hash` or
`/api/v2/arbitrum/batches/da/:tx_commitment/:height` endpoints.
"""
@spec batch_by_data_availability_info(Plug.Conn.t(), map()) :: Plug.Conn.t()
def batch_by_data_availability_info(conn, %{"data_hash" => data_hash} = _params) do
# In case of AnyTrust, `data_key` is the hash of the data itself
case Reader.get_da_record_by_data_key(data_hash, api?: true) do
{:ok, {batch_number, _}} ->
batch(conn, %{"batch_number" => batch_number})

{:error, :not_found} = res ->
res
end
end

def batch_by_data_availability_info(conn, %{"tx_commitment" => tx_commitment, "height" => height} = _params) do
# In case of Celestia, `data_key` is the hash of the height and the commitment hash
with {:ok, :hash, tx_commitment_hash} <- parse_block_hash_or_number_param(tx_commitment),
key <- calculate_celestia_data_key(height, tx_commitment_hash) do
case Reader.get_da_record_by_data_key(key, api?: true) do
{:ok, {batch_number, _}} ->
batch(conn, %{"batch_number" => batch_number})

{:error, :not_found} = res ->
res
end
else
res ->
res
end
end

@doc """
Function to handle GET requests to `/api/v2/arbitrum/batches/count` endpoint.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ defmodule BlockScoutWeb.API.V2.BlockController do
[transactions: :beacon_blob_transaction] => :optional
}

:optimism ->
@chain_type_transaction_necessity_by_association %{}
@chain_type_block_necessity_by_association %{
:op_frame_sequence => :optional
}

:zksync ->
@chain_type_transaction_necessity_by_association %{}
@chain_type_block_necessity_by_association %{
Expand Down
Loading

0 comments on commit 7fa3edb

Please sign in to comment.