Rename Zkevm to PolygonZkevm

pull/9098/head
POA 9 months ago
parent 357a7d1a83
commit d8fd9b2d20
  1. 20
      apps/block_scout_web/lib/block_scout_web/api_router.ex
  2. 2
      apps/block_scout_web/lib/block_scout_web/chain.ex
  3. 6
      apps/block_scout_web/lib/block_scout_web/channels/polygon_zkevm_confirmed_batch_channel.ex
  4. 2
      apps/block_scout_web/lib/block_scout_web/channels/user_socket_v2.ex
  5. 4
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/polygon_zkevm_controller.ex
  6. 6
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex
  7. 4
      apps/block_scout_web/lib/block_scout_web/views/api/v2/polygon_zkevm_view.ex
  8. 2
      apps/block_scout_web/mix.exs
  9. 16
      apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/batch_transactions.ex
  10. 14
      apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_l1_tokens.ex
  11. 26
      apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_operations.ex
  12. 16
      apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/lifecycle_transactions.ex
  13. 16
      apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/transaction_batches.ex
  14. 10
      apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex
  15. 6
      apps/explorer/lib/explorer/chain/polygon_zkevm/batch_transaction.ex
  16. 6
      apps/explorer/lib/explorer/chain/polygon_zkevm/bridge.ex
  17. 4
      apps/explorer/lib/explorer/chain/polygon_zkevm/bridge_l1_token.ex
  18. 6
      apps/explorer/lib/explorer/chain/polygon_zkevm/lifecycle_transaction.ex
  19. 24
      apps/explorer/lib/explorer/chain/polygon_zkevm/reader.ex
  20. 6
      apps/explorer/lib/explorer/chain/polygon_zkevm/transaction_batch.ex
  21. 2
      apps/explorer/lib/explorer/chain/transaction.ex
  22. 20
      apps/explorer/priv/polygon_zkevm/migrations/20231010093238_add_bridge_tables.exs
  23. 26
      apps/indexer/lib/indexer/block/fetcher.ex
  24. 10
      apps/indexer/lib/indexer/block/realtime/fetcher.ex
  25. 16
      apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge.ex
  26. 16
      apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1.ex
  27. 6
      apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1_tokens.ex
  28. 18
      apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l2.ex
  29. 16
      apps/indexer/lib/indexer/fetcher/polygon_zkevm/transaction_batch.ex
  30. 6
      apps/indexer/lib/indexer/fetcher/rollup_l1_reorg_monitor.ex
  31. 8
      apps/indexer/lib/indexer/supervisor.ex
  32. 4
      apps/indexer/lib/indexer/transform/addresses.ex
  33. 8
      apps/indexer/lib/indexer/transform/polygon_zkevm/bridge.ex
  34. 16
      config/runtime.exs

@ -204,7 +204,7 @@ defmodule BlockScoutWeb.ApiRouter do
get("/watchlist", V2.TransactionController, :watchlist_transactions) get("/watchlist", V2.TransactionController, :watchlist_transactions)
if System.get_env("CHAIN_TYPE") == "polygon_zkevm" do if System.get_env("CHAIN_TYPE") == "polygon_zkevm" do
get("/zkevm-batch/:batch_number", V2.TransactionController, :zkevm_batch) get("/zkevm-batch/:batch_number", V2.TransactionController, :polygon_zkevm_batch)
end end
if System.get_env("CHAIN_TYPE") == "suave" do if System.get_env("CHAIN_TYPE") == "suave" do
@ -274,8 +274,8 @@ defmodule BlockScoutWeb.ApiRouter do
get("/indexing-status", V2.MainPageController, :indexing_status) get("/indexing-status", V2.MainPageController, :indexing_status)
if System.get_env("CHAIN_TYPE") == "polygon_zkevm" do if System.get_env("CHAIN_TYPE") == "polygon_zkevm" do
get("/zkevm/batches/confirmed", V2.ZkevmController, :batches_confirmed) get("/zkevm/batches/confirmed", V2.PolygonZkevmController, :batches_confirmed)
get("/zkevm/batches/latest-number", V2.ZkevmController, :batch_latest_number) get("/zkevm/batches/latest-number", V2.PolygonZkevmController, :batch_latest_number)
end end
end end
@ -313,13 +313,13 @@ defmodule BlockScoutWeb.ApiRouter do
scope "/zkevm" do scope "/zkevm" do
if System.get_env("CHAIN_TYPE") == "polygon_zkevm" do if System.get_env("CHAIN_TYPE") == "polygon_zkevm" do
get("/batches", V2.ZkevmController, :batches) get("/batches", V2.PolygonZkevmController, :batches)
get("/batches/count", V2.ZkevmController, :batches_count) get("/batches/count", V2.PolygonZkevmController, :batches_count)
get("/batches/:batch_number", V2.ZkevmController, :batch) get("/batches/:batch_number", V2.PolygonZkevmController, :batch)
get("/deposits", V2.ZkevmController, :deposits) get("/deposits", V2.PolygonZkevmController, :deposits)
get("/deposits/count", V2.ZkevmController, :deposits_count) get("/deposits/count", V2.PolygonZkevmController, :deposits_count)
get("/withdrawals", V2.ZkevmController, :withdrawals) get("/withdrawals", V2.PolygonZkevmController, :withdrawals)
get("/withdrawals/count", V2.ZkevmController, :withdrawals_count) get("/withdrawals/count", V2.PolygonZkevmController, :withdrawals_count)
end end
end end

@ -41,7 +41,7 @@ defmodule BlockScoutWeb.Chain do
Wei Wei
} }
alias Explorer.Chain.Zkevm.TransactionBatch alias Explorer.Chain.PolygonZkevm.TransactionBatch
alias Explorer.PagingOptions alias Explorer.PagingOptions
defimpl Poison.Encoder, for: Decimal do defimpl Poison.Encoder, for: Decimal do

@ -1,10 +1,10 @@
defmodule BlockScoutWeb.ZkevmConfirmedBatchChannel do defmodule BlockScoutWeb.PolygonZkevmConfirmedBatchChannel do
@moduledoc """ @moduledoc """
Establishes pub/sub channel for live updates of zkEVM confirmed batch events. Establishes pub/sub channel for live updates of zkEVM confirmed batch events.
""" """
use BlockScoutWeb, :channel use BlockScoutWeb, :channel
alias BlockScoutWeb.API.V2.ZkevmView alias BlockScoutWeb.API.V2.PolygonZkevmView
intercept(["new_zkevm_confirmed_batch"]) intercept(["new_zkevm_confirmed_batch"])
@ -17,7 +17,7 @@ defmodule BlockScoutWeb.ZkevmConfirmedBatchChannel do
%{batch: batch}, %{batch: batch},
%Phoenix.Socket{handler: BlockScoutWeb.UserSocketV2} = socket %Phoenix.Socket{handler: BlockScoutWeb.UserSocketV2} = socket
) do ) do
rendered_batch = ZkevmView.render("zkevm_batch.json", %{batch: batch, socket: nil}) rendered_batch = PolygonZkevmView.render("zkevm_batch.json", %{batch: batch, socket: nil})
push(socket, "new_zkevm_confirmed_batch", %{ push(socket, "new_zkevm_confirmed_batch", %{
batch: rendered_batch batch: rendered_batch

@ -10,7 +10,7 @@ defmodule BlockScoutWeb.UserSocketV2 do
channel("rewards:*", BlockScoutWeb.RewardChannel) channel("rewards:*", BlockScoutWeb.RewardChannel)
channel("transactions:*", BlockScoutWeb.TransactionChannel) channel("transactions:*", BlockScoutWeb.TransactionChannel)
channel("tokens:*", BlockScoutWeb.TokenChannel) channel("tokens:*", BlockScoutWeb.TokenChannel)
channel("zkevm_batches:*", BlockScoutWeb.ZkevmConfirmedBatchChannel) channel("zkevm_batches:*", BlockScoutWeb.PolygonZkevmConfirmedBatchChannel)
def connect(_params, socket) do def connect(_params, socket) do
{:ok, socket} {:ok, socket}

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.API.V2.ZkevmController do defmodule BlockScoutWeb.API.V2.PolygonZkevmController do
use BlockScoutWeb, :controller use BlockScoutWeb, :controller
import BlockScoutWeb.Chain, import BlockScoutWeb.Chain,
@ -8,7 +8,7 @@ defmodule BlockScoutWeb.API.V2.ZkevmController do
split_list_by_page: 1 split_list_by_page: 1
] ]
alias Explorer.Chain.Zkevm.Reader alias Explorer.Chain.PolygonZkevm.Reader
action_fallback(BlockScoutWeb.API.V2.FallbackController) action_fallback(BlockScoutWeb.API.V2.FallbackController)

@ -31,7 +31,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.Beacon.Reader, as: BeaconReader alias Explorer.Chain.Beacon.Reader, as: BeaconReader
alias Explorer.Chain.{Hash, Transaction} alias Explorer.Chain.{Hash, Transaction}
alias Explorer.Chain.Zkevm.Reader alias Explorer.Chain.PolygonZkevm.Reader
alias Indexer.Fetcher.FirstTraceOnDemand alias Indexer.Fetcher.FirstTraceOnDemand
action_fallback(BlockScoutWeb.API.V2.FallbackController) action_fallback(BlockScoutWeb.API.V2.FallbackController)
@ -155,8 +155,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
Function to handle GET requests to `/api/v2/transactions/zkevm-batch/:batch_number` endpoint. Function to handle GET requests to `/api/v2/transactions/zkevm-batch/:batch_number` endpoint.
It renders the list of L2 transactions bound to the specified batch. It renders the list of L2 transactions bound to the specified batch.
""" """
@spec zkevm_batch(Plug.Conn.t(), map()) :: Plug.Conn.t() @spec polygon_zkevm_batch(Plug.Conn.t(), map()) :: Plug.Conn.t()
def zkevm_batch(conn, %{"batch_number" => batch_number} = _params) do def polygon_zkevm_batch(conn, %{"batch_number" => batch_number} = _params) do
transactions = transactions =
batch_number batch_number
|> Reader.batch_transactions(api?: true) |> Reader.batch_transactions(api?: true)

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.API.V2.ZkevmView do defmodule BlockScoutWeb.API.V2.PolygonZkevmView do
use BlockScoutWeb, :view use BlockScoutWeb, :view
@doc """ @doc """
@ -75,7 +75,7 @@ defmodule BlockScoutWeb.API.V2.ZkevmView do
items: items, items: items,
next_page_params: next_page_params next_page_params: next_page_params
}) do }) do
env = Application.get_all_env(:indexer)[Indexer.Fetcher.Zkevm.BridgeL1] env = Application.get_all_env(:indexer)[Indexer.Fetcher.PolygonZkevm.BridgeL1]
%{ %{
items: items:

@ -24,7 +24,7 @@ defmodule BlockScoutWeb.Mixfile do
], ],
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
version: "6.1.0", version: "6.1.0",
xref: [exclude: [Explorer.Chain.Zkevm.Reader, Explorer.Chain.Beacon.Reader]] xref: [exclude: [Explorer.Chain.PolygonZkevm.Reader, Explorer.Chain.Beacon.Reader]]
] ]
end end

@ -1,13 +1,13 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do defmodule Explorer.Chain.Import.Runner.PolygonZkevm.BatchTransactions do
@moduledoc """ @moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.BatchTransaction.t/0`. Bulk imports `t:Explorer.Chain.PolygonZkevm.BatchTransaction.t/0`.
""" """
require Ecto.Query require Ecto.Query
alias Ecto.{Changeset, Multi, Repo} alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.BatchTransaction alias Explorer.Chain.PolygonZkevm.BatchTransaction
alias Explorer.Prometheus.Instrumenter alias Explorer.Prometheus.Instrumenter
@behaviour Import.Runner @behaviour Import.Runner
@ -21,7 +21,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
def ecto_schema_module, do: BatchTransaction def ecto_schema_module, do: BatchTransaction
@impl Import.Runner @impl Import.Runner
def option_key, do: :zkevm_batch_transactions def option_key, do: :polygon_zkevm_batch_transactions
@impl Import.Runner @impl Import.Runner
@spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()} @spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()}
@ -42,12 +42,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
|> Map.put_new(:timeout, @timeout) |> Map.put_new(:timeout, @timeout)
|> Map.put(:timestamps, timestamps) |> Map.put(:timestamps, timestamps)
Multi.run(multi, :insert_zkevm_batch_transactions, fn repo, _ -> Multi.run(multi, :insert_polygon_zkevm_batch_transactions, fn repo, _ ->
Instrumenter.block_import_stage_runner( Instrumenter.block_import_stage_runner(
fn -> insert(repo, changes_list, insert_options) end, fn -> insert(repo, changes_list, insert_options) end,
:block_referencing, :block_referencing,
:zkevm_batch_transactions, :polygon_zkevm_batch_transactions,
:zkevm_batch_transactions :polygon_zkevm_batch_transactions
) )
end) end)
end end
@ -59,7 +59,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
{:ok, [BatchTransaction.t()]} {:ok, [BatchTransaction.t()]}
| {:error, [Changeset.t()]} | {:error, [Changeset.t()]}
def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = _options) when is_list(changes_list) do def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = _options) when is_list(changes_list) do
# Enforce Zkevm.BatchTransaction ShareLocks order (see docs: sharelock.md) # Enforce PolygonZkevm.BatchTransaction ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, & &1.hash) ordered_changes_list = Enum.sort_by(changes_list, & &1.hash)
{:ok, inserted} = {:ok, inserted} =

@ -1,6 +1,6 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeL1Tokens do defmodule Explorer.Chain.Import.Runner.PolygonZkevm.BridgeL1Tokens do
@moduledoc """ @moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.BridgeL1Token.t/0`. Bulk imports `t:Explorer.Chain.PolygonZkevm.BridgeL1Token.t/0`.
""" """
require Ecto.Query require Ecto.Query
@ -9,7 +9,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeL1Tokens do
alias Ecto.{Changeset, Multi, Repo} alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.BridgeL1Token alias Explorer.Chain.PolygonZkevm.BridgeL1Token
alias Explorer.Prometheus.Instrumenter alias Explorer.Prometheus.Instrumenter
@behaviour Import.Runner @behaviour Import.Runner
@ -23,7 +23,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeL1Tokens do
def ecto_schema_module, do: BridgeL1Token def ecto_schema_module, do: BridgeL1Token
@impl Import.Runner @impl Import.Runner
def option_key, do: :zkevm_bridge_l1_tokens def option_key, do: :polygon_zkevm_bridge_l1_tokens
@impl Import.Runner @impl Import.Runner
def imported_table_row do def imported_table_row do
@ -42,12 +42,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeL1Tokens do
|> Map.put_new(:timeout, @timeout) |> Map.put_new(:timeout, @timeout)
|> Map.put(:timestamps, timestamps) |> Map.put(:timestamps, timestamps)
Multi.run(multi, :insert_zkevm_bridge_l1_tokens, fn repo, _ -> Multi.run(multi, :insert_polygon_zkevm_bridge_l1_tokens, fn repo, _ ->
Instrumenter.block_import_stage_runner( Instrumenter.block_import_stage_runner(
fn -> insert(repo, changes_list, insert_options) end, fn -> insert(repo, changes_list, insert_options) end,
:block_referencing, :block_referencing,
:zkevm_bridge_l1_tokens, :polygon_zkevm_bridge_l1_tokens,
:zkevm_bridge_l1_tokens :polygon_zkevm_bridge_l1_tokens
) )
end) end)
end end

@ -1,6 +1,6 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do defmodule Explorer.Chain.Import.Runner.PolygonZkevm.BridgeOperations do
@moduledoc """ @moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.Bridge.t/0`. Bulk imports `t:Explorer.Chain.PolygonZkevm.Bridge.t/0`.
""" """
require Ecto.Query require Ecto.Query
@ -9,7 +9,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
alias Ecto.{Changeset, Multi, Repo} alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.Bridge, as: ZkevmBridge alias Explorer.Chain.PolygonZkevm.Bridge, as: PolygonZkevmBridge
alias Explorer.Prometheus.Instrumenter alias Explorer.Prometheus.Instrumenter
@behaviour Import.Runner @behaviour Import.Runner
@ -17,13 +17,13 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
# milliseconds # milliseconds
@timeout 60_000 @timeout 60_000
@type imported :: [ZkevmBridge.t()] @type imported :: [PolygonZkevmBridge.t()]
@impl Import.Runner @impl Import.Runner
def ecto_schema_module, do: ZkevmBridge def ecto_schema_module, do: PolygonZkevmBridge
@impl Import.Runner @impl Import.Runner
def option_key, do: :zkevm_bridge_operations def option_key, do: :polygon_zkevm_bridge_operations
@impl Import.Runner @impl Import.Runner
def imported_table_row do def imported_table_row do
@ -42,12 +42,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
|> Map.put_new(:timeout, @timeout) |> Map.put_new(:timeout, @timeout)
|> Map.put(:timestamps, timestamps) |> Map.put(:timestamps, timestamps)
Multi.run(multi, :insert_zkevm_bridge_operations, fn repo, _ -> Multi.run(multi, :insert_polygon_zkevm_bridge_operations, fn repo, _ ->
Instrumenter.block_import_stage_runner( Instrumenter.block_import_stage_runner(
fn -> insert(repo, changes_list, insert_options) end, fn -> insert(repo, changes_list, insert_options) end,
:block_referencing, :block_referencing,
:zkevm_bridge_operations, :polygon_zkevm_bridge_operations,
:zkevm_bridge_operations :polygon_zkevm_bridge_operations
) )
end) end)
end end
@ -56,12 +56,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
def timeout, do: @timeout def timeout, do: @timeout
@spec insert(Repo.t(), [map()], %{required(:timeout) => timeout(), required(:timestamps) => Import.timestamps()}) :: @spec insert(Repo.t(), [map()], %{required(:timeout) => timeout(), required(:timestamps) => Import.timestamps()}) ::
{:ok, [ZkevmBridge.t()]} {:ok, [PolygonZkevmBridge.t()]}
| {:error, [Changeset.t()]} | {:error, [Changeset.t()]}
def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do
on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0) on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0)
# Enforce ZkevmBridge ShareLocks order (see docs: sharelock.md) # Enforce PolygonZkevmBridge ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, &{&1.type, &1.index}) ordered_changes_list = Enum.sort_by(changes_list, &{&1.type, &1.index})
{:ok, inserted} = {:ok, inserted} =
@ -70,7 +70,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
ordered_changes_list, ordered_changes_list,
conflict_target: [:type, :index], conflict_target: [:type, :index],
on_conflict: on_conflict, on_conflict: on_conflict,
for: ZkevmBridge, for: PolygonZkevmBridge,
returning: true, returning: true,
timeout: timeout, timeout: timeout,
timestamps: timestamps timestamps: timestamps
@ -81,7 +81,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
defp default_on_conflict do defp default_on_conflict do
from( from(
op in ZkevmBridge, op in PolygonZkevmBridge,
update: [ update: [
set: [ set: [
# Don't update `type` as it is part of the composite primary key and used for the conflict target # Don't update `type` as it is part of the composite primary key and used for the conflict target

@ -1,13 +1,13 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do defmodule Explorer.Chain.Import.Runner.PolygonZkevm.LifecycleTransactions do
@moduledoc """ @moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.LifecycleTransaction.t/0`. Bulk imports `t:Explorer.Chain.PolygonZkevm.LifecycleTransaction.t/0`.
""" """
require Ecto.Query require Ecto.Query
alias Ecto.{Changeset, Multi, Repo} alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.LifecycleTransaction alias Explorer.Chain.PolygonZkevm.LifecycleTransaction
alias Explorer.Prometheus.Instrumenter alias Explorer.Prometheus.Instrumenter
import Ecto.Query, only: [from: 2] import Ecto.Query, only: [from: 2]
@ -23,7 +23,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do
def ecto_schema_module, do: LifecycleTransaction def ecto_schema_module, do: LifecycleTransaction
@impl Import.Runner @impl Import.Runner
def option_key, do: :zkevm_lifecycle_transactions def option_key, do: :polygon_zkevm_lifecycle_transactions
@impl Import.Runner @impl Import.Runner
@spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()} @spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()}
@ -44,12 +44,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do
|> Map.put_new(:timeout, @timeout) |> Map.put_new(:timeout, @timeout)
|> Map.put(:timestamps, timestamps) |> Map.put(:timestamps, timestamps)
Multi.run(multi, :insert_zkevm_lifecycle_transactions, fn repo, _ -> Multi.run(multi, :insert_polygon_zkevm_lifecycle_transactions, fn repo, _ ->
Instrumenter.block_import_stage_runner( Instrumenter.block_import_stage_runner(
fn -> insert(repo, changes_list, insert_options) end, fn -> insert(repo, changes_list, insert_options) end,
:block_referencing, :block_referencing,
:zkevm_lifecycle_transactions, :polygon_zkevm_lifecycle_transactions,
:zkevm_lifecycle_transactions :polygon_zkevm_lifecycle_transactions
) )
end) end)
end end
@ -63,7 +63,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do
def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do
on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0) on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0)
# Enforce Zkevm.LifecycleTransaction ShareLocks order (see docs: sharelock.md) # Enforce PolygonZkevm.LifecycleTransaction ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, & &1.id) ordered_changes_list = Enum.sort_by(changes_list, & &1.id)
{:ok, inserted} = {:ok, inserted} =

@ -1,13 +1,13 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do defmodule Explorer.Chain.Import.Runner.PolygonZkevm.TransactionBatches do
@moduledoc """ @moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.TransactionBatch.t/0`. Bulk imports `t:Explorer.Chain.PolygonZkevm.TransactionBatch.t/0`.
""" """
require Ecto.Query require Ecto.Query
alias Ecto.{Changeset, Multi, Repo} alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.TransactionBatch alias Explorer.Chain.PolygonZkevm.TransactionBatch
alias Explorer.Prometheus.Instrumenter alias Explorer.Prometheus.Instrumenter
import Ecto.Query, only: [from: 2] import Ecto.Query, only: [from: 2]
@ -23,7 +23,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do
def ecto_schema_module, do: TransactionBatch def ecto_schema_module, do: TransactionBatch
@impl Import.Runner @impl Import.Runner
def option_key, do: :zkevm_transaction_batches def option_key, do: :polygon_zkevm_transaction_batches
@impl Import.Runner @impl Import.Runner
@spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()} @spec imported_table_row() :: %{:value_description => binary(), :value_type => binary()}
@ -44,12 +44,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do
|> Map.put_new(:timeout, @timeout) |> Map.put_new(:timeout, @timeout)
|> Map.put(:timestamps, timestamps) |> Map.put(:timestamps, timestamps)
Multi.run(multi, :insert_zkevm_transaction_batches, fn repo, _ -> Multi.run(multi, :insert_polygon_zkevm_transaction_batches, fn repo, _ ->
Instrumenter.block_import_stage_runner( Instrumenter.block_import_stage_runner(
fn -> insert(repo, changes_list, insert_options) end, fn -> insert(repo, changes_list, insert_options) end,
:block_referencing, :block_referencing,
:zkevm_transaction_batches, :polygon_zkevm_transaction_batches,
:zkevm_transaction_batches :polygon_zkevm_transaction_batches
) )
end) end)
end end
@ -63,7 +63,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do
def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do
on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0) on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0)
# Enforce Zkevm.TransactionBatch ShareLocks order (see docs: sharelock.md) # Enforce PolygonZkevm.TransactionBatch ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, & &1.number) ordered_changes_list = Enum.sort_by(changes_list, & &1.number)
{:ok, inserted} = {:ok, inserted} =

@ -26,11 +26,11 @@ defmodule Explorer.Chain.Import.Stage.BlockReferencing do
] ]
@polygon_zkevm_runners [ @polygon_zkevm_runners [
Runner.Zkevm.LifecycleTransactions, Runner.PolygonZkevm.LifecycleTransactions,
Runner.Zkevm.TransactionBatches, Runner.PolygonZkevm.TransactionBatches,
Runner.Zkevm.BatchTransactions, Runner.PolygonZkevm.BatchTransactions,
Runner.Zkevm.BridgeL1Tokens, Runner.PolygonZkevm.BridgeL1Tokens,
Runner.Zkevm.BridgeOperations Runner.PolygonZkevm.BridgeOperations
] ]
@shibarium_runners [ @shibarium_runners [

@ -1,15 +1,15 @@
defmodule Explorer.Chain.Zkevm.BatchTransaction do defmodule Explorer.Chain.PolygonZkevm.BatchTransaction do
@moduledoc "Models a list of transactions related to a batch for zkEVM." @moduledoc "Models a list of transactions related to a batch for zkEVM."
use Explorer.Schema use Explorer.Schema
alias Explorer.Chain.{Hash, Transaction} alias Explorer.Chain.{Hash, Transaction}
alias Explorer.Chain.Zkevm.TransactionBatch alias Explorer.Chain.PolygonZkevm.TransactionBatch
@required_attrs ~w(batch_number hash)a @required_attrs ~w(batch_number hash)a
@primary_key false @primary_key false
typed_schema "zkevm_batch_l2_transactions" do typed_schema "polygon_zkevm_batch_l2_transactions" do
belongs_to(:batch, TransactionBatch, foreign_key: :batch_number, references: :number, type: :integer, null: false) belongs_to(:batch, TransactionBatch, foreign_key: :batch_number, references: :number, type: :integer, null: false)
belongs_to(:l2_transaction, Transaction, belongs_to(:l2_transaction, Transaction,

@ -1,10 +1,10 @@
defmodule Explorer.Chain.Zkevm.Bridge do defmodule Explorer.Chain.PolygonZkevm.Bridge do
@moduledoc "Models a bridge operation for Polygon zkEVM." @moduledoc "Models a bridge operation for Polygon zkEVM."
use Explorer.Schema use Explorer.Schema
alias Explorer.Chain.{Block, Hash, Token} alias Explorer.Chain.{Block, Hash, Token}
alias Explorer.Chain.Zkevm.BridgeL1Token alias Explorer.Chain.PolygonZkevm.BridgeL1Token
@optional_attrs ~w(l1_transaction_hash l2_transaction_hash l1_token_id l2_token_address block_number block_timestamp)a @optional_attrs ~w(l1_transaction_hash l2_transaction_hash l1_token_id l2_token_address block_number block_timestamp)a
@ -26,7 +26,7 @@ defmodule Explorer.Chain.Zkevm.Bridge do
} }
@primary_key false @primary_key false
schema "zkevm_bridge" do schema "polygon_zkevm_bridge" do
field(:type, Ecto.Enum, values: [:deposit, :withdrawal], primary_key: true) field(:type, Ecto.Enum, values: [:deposit, :withdrawal], primary_key: true)
field(:index, :integer, primary_key: true) field(:index, :integer, primary_key: true)
field(:l1_transaction_hash, Hash.Full) field(:l1_transaction_hash, Hash.Full)

@ -1,4 +1,4 @@
defmodule Explorer.Chain.Zkevm.BridgeL1Token do defmodule Explorer.Chain.PolygonZkevm.BridgeL1Token do
@moduledoc "Models a bridge token on L1 for Polygon zkEVM." @moduledoc "Models a bridge token on L1 for Polygon zkEVM."
use Explorer.Schema use Explorer.Schema
@ -16,7 +16,7 @@ defmodule Explorer.Chain.Zkevm.BridgeL1Token do
} }
@primary_key {:id, :id, autogenerate: true} @primary_key {:id, :id, autogenerate: true}
schema "zkevm_bridge_l1_tokens" do schema "polygon_zkevm_bridge_l1_tokens" do
field(:address, Hash.Address) field(:address, Hash.Address)
field(:decimals, :integer) field(:decimals, :integer)
field(:symbol, :string) field(:symbol, :string)

@ -1,15 +1,15 @@
defmodule Explorer.Chain.Zkevm.LifecycleTransaction do defmodule Explorer.Chain.PolygonZkevm.LifecycleTransaction do
@moduledoc "Models an L1 lifecycle transaction for zkEVM." @moduledoc "Models an L1 lifecycle transaction for zkEVM."
use Explorer.Schema use Explorer.Schema
alias Explorer.Chain.Hash alias Explorer.Chain.Hash
alias Explorer.Chain.Zkevm.TransactionBatch alias Explorer.Chain.PolygonZkevm.TransactionBatch
@required_attrs ~w(id hash is_verify)a @required_attrs ~w(id hash is_verify)a
@primary_key false @primary_key false
typed_schema "zkevm_lifecycle_l1_transactions" do typed_schema "polygon_zkevm_lifecycle_l1_transactions" do
field(:id, :integer, primary_key: true, null: false) field(:id, :integer, primary_key: true, null: false)
field(:hash, Hash.Full, null: false) field(:hash, Hash.Full, null: false)
field(:is_verify, :boolean, null: false) field(:is_verify, :boolean, null: false)

@ -1,4 +1,4 @@
defmodule Explorer.Chain.Zkevm.Reader do defmodule Explorer.Chain.PolygonZkevm.Reader do
@moduledoc "Contains read functions for zkevm modules." @moduledoc "Contains read functions for zkevm modules."
import Ecto.Query, import Ecto.Query,
@ -12,13 +12,13 @@ defmodule Explorer.Chain.Zkevm.Reader do
import Explorer.Chain, only: [select_repo: 1] import Explorer.Chain, only: [select_repo: 1]
alias Explorer.Chain.Zkevm.{BatchTransaction, Bridge, BridgeL1Token, LifecycleTransaction, TransactionBatch} alias Explorer.Chain.PolygonZkevm.{BatchTransaction, Bridge, BridgeL1Token, LifecycleTransaction, TransactionBatch}
alias Explorer.{Chain, PagingOptions, Repo} alias Explorer.{Chain, PagingOptions, Repo}
alias Indexer.Helper alias Indexer.Helper
@doc """ @doc """
Reads a batch by its number from database. Reads a batch by its number from database.
If the number is :latest, gets the latest batch from `zkevm_transaction_batches` table. If the number is :latest, gets the latest batch from `polygon_zkevm_transaction_batches` table.
Returns {:error, :not_found} in case the batch is not found. Returns {:error, :not_found} in case the batch is not found.
""" """
@spec batch(non_neg_integer() | :latest, list()) :: {:ok, map()} | {:error, :not_found} @spec batch(non_neg_integer() | :latest, list()) :: {:ok, map()} | {:error, :not_found}
@ -49,7 +49,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Reads a list of batches from `zkevm_transaction_batches` table. Reads a list of batches from `polygon_zkevm_transaction_batches` table.
""" """
@spec batches(list()) :: list() @spec batches(list()) :: list()
def batches(options \\ []) do def batches(options \\ []) do
@ -79,7 +79,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Reads a list of L2 transaction hashes from `zkevm_batch_l2_transactions` table. Reads a list of L2 transaction hashes from `polygon_zkevm_batch_l2_transactions` table.
""" """
@spec batch_transactions(non_neg_integer(), list()) :: list() @spec batch_transactions(non_neg_integer(), list()) :: list()
def batch_transactions(batch_number, options \\ []) do def batch_transactions(batch_number, options \\ []) do
@ -90,7 +90,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
@doc """ @doc """
Tries to read L1 token data (address, symbol, decimals) for the given addresses Tries to read L1 token data (address, symbol, decimals) for the given addresses
from the database. If the data for an address is not found in Explorer.Chain.Zkevm.BridgeL1Token, from the database. If the data for an address is not found in Explorer.Chain.PolygonZkevm.BridgeL1Token,
the address is returned in the list inside the tuple (the second item of the tuple). the address is returned in the list inside the tuple (the second item of the tuple).
The first item of the returned tuple contains `L1 token address -> L1 token data` map. The first item of the returned tuple contains `L1 token address -> L1 token data` map.
""" """
@ -122,7 +122,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Gets last known L1 item (deposit) from zkevm_bridge table. Gets last known L1 item (deposit) from polygon_zkevm_bridge table.
Returns block number and L1 transaction hash bound to that deposit. Returns block number and L1 transaction hash bound to that deposit.
If not found, returns zero block number and nil as the transaction hash. If not found, returns zero block number and nil as the transaction hash.
""" """
@ -142,7 +142,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Gets last known L2 item (withdrawal) from zkevm_bridge table. Gets last known L2 item (withdrawal) from polygon_zkevm_bridge table.
Returns block number and L2 transaction hash bound to that withdrawal. Returns block number and L2 transaction hash bound to that withdrawal.
If not found, returns zero block number and nil as the transaction hash. If not found, returns zero block number and nil as the transaction hash.
""" """
@ -162,7 +162,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Gets the number of the latest batch with defined verify_id from `zkevm_transaction_batches` table. Gets the number of the latest batch with defined verify_id from `polygon_zkevm_transaction_batches` table.
Returns 0 if not found. Returns 0 if not found.
""" """
@spec last_verified_batch_number() :: non_neg_integer() @spec last_verified_batch_number() :: non_neg_integer()
@ -181,7 +181,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Reads a list of L1 transactions by their hashes from `zkevm_lifecycle_l1_transactions` table. Reads a list of L1 transactions by their hashes from `polygon_zkevm_lifecycle_l1_transactions` table.
""" """
@spec lifecycle_transactions(list()) :: list() @spec lifecycle_transactions(list()) :: list()
def lifecycle_transactions(l1_tx_hashes) do def lifecycle_transactions(l1_tx_hashes) do
@ -196,7 +196,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end end
@doc """ @doc """
Determines ID of the future lifecycle transaction by reading `zkevm_lifecycle_l1_transactions` table. Determines ID of the future lifecycle transaction by reading `polygon_zkevm_lifecycle_l1_transactions` table.
""" """
@spec next_id() :: non_neg_integer() @spec next_id() :: non_neg_integer()
def next_id do def next_id do
@ -217,7 +217,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
@doc """ @doc """
Builds `L1 token address -> L1 token id` map for the given token addresses. Builds `L1 token address -> L1 token id` map for the given token addresses.
The info is taken from Explorer.Chain.Zkevm.BridgeL1Token. The info is taken from Explorer.Chain.PolygonZkevm.BridgeL1Token.
If an address is not in the table, it won't be in the resulting map. If an address is not in the table, it won't be in the resulting map.
""" """
@spec token_addresses_to_ids_from_db(list()) :: map() @spec token_addresses_to_ids_from_db(list()) :: map()

@ -1,17 +1,17 @@
defmodule Explorer.Chain.Zkevm.TransactionBatch do defmodule Explorer.Chain.PolygonZkevm.TransactionBatch do
@moduledoc "Models a batch of transactions for zkEVM." @moduledoc "Models a batch of transactions for zkEVM."
use Explorer.Schema use Explorer.Schema
alias Explorer.Chain.Hash alias Explorer.Chain.Hash
alias Explorer.Chain.Zkevm.{BatchTransaction, LifecycleTransaction} alias Explorer.Chain.PolygonZkevm.{BatchTransaction, LifecycleTransaction}
@optional_attrs ~w(sequence_id verify_id)a @optional_attrs ~w(sequence_id verify_id)a
@required_attrs ~w(number timestamp l2_transactions_count global_exit_root acc_input_hash state_root)a @required_attrs ~w(number timestamp l2_transactions_count global_exit_root acc_input_hash state_root)a
@primary_key false @primary_key false
typed_schema "zkevm_transaction_batches" do typed_schema "polygon_zkevm_transaction_batches" do
field(:number, :integer, primary_key: true, null: false) field(:number, :integer, primary_key: true, null: false)
field(:timestamp, :utc_datetime_usec) field(:timestamp, :utc_datetime_usec)
field(:l2_transactions_count, :integer) field(:l2_transactions_count, :integer)

@ -14,8 +14,8 @@ defmodule Explorer.Chain.Transaction.Schema do
Wei Wei
} }
alias Explorer.Chain.PolygonZkevm.BatchTransaction
alias Explorer.Chain.Transaction.{Fork, Status} alias Explorer.Chain.Transaction.{Fork, Status}
alias Explorer.Chain.Zkevm.BatchTransaction
@chain_type_fields (case Application.compile_env(:explorer, :chain_type) do @chain_type_fields (case Application.compile_env(:explorer, :chain_type) do
"ethereum" -> "ethereum" ->

@ -2,7 +2,7 @@ defmodule Explorer.Repo.PolygonZkevm.Migrations.AddBridgeTables do
use Ecto.Migration use Ecto.Migration
def change do def change do
create table(:zkevm_bridge_l1_tokens, primary_key: false) do create table(:polygon_zkevm_bridge_l1_tokens, primary_key: false) do
add(:id, :identity, primary_key: true, start_value: 0, increment: 1) add(:id, :identity, primary_key: true, start_value: 0, increment: 1)
add(:address, :bytea, null: false) add(:address, :bytea, null: false)
add(:decimals, :smallint, null: true, default: nil) add(:decimals, :smallint, null: true, default: nil)
@ -10,22 +10,22 @@ defmodule Explorer.Repo.PolygonZkevm.Migrations.AddBridgeTables do
timestamps(null: false, type: :utc_datetime_usec) timestamps(null: false, type: :utc_datetime_usec)
end end
create(unique_index(:zkevm_bridge_l1_tokens, :address)) create(unique_index(:polygon_zkevm_bridge_l1_tokens, :address))
execute( execute(
"CREATE TYPE zkevm_bridge_op_type AS ENUM ('deposit', 'withdrawal')", "CREATE TYPE polygon_zkevm_bridge_op_type AS ENUM ('deposit', 'withdrawal')",
"DROP TYPE zkevm_bridge_op_type" "DROP TYPE polygon_zkevm_bridge_op_type"
) )
create table(:zkevm_bridge, primary_key: false) do create table(:polygon_zkevm_bridge, primary_key: false) do
add(:type, :zkevm_bridge_op_type, null: false, primary_key: true) add(:type, :polygon_zkevm_bridge_op_type, null: false, primary_key: true)
add(:index, :integer, null: false, primary_key: true) add(:index, :integer, null: false, primary_key: true)
add(:l1_transaction_hash, :bytea, null: true) add(:l1_transaction_hash, :bytea, null: true)
add(:l2_transaction_hash, :bytea, null: true) add(:l2_transaction_hash, :bytea, null: true)
add( add(
:l1_token_id, :l1_token_id,
references(:zkevm_bridge_l1_tokens, on_delete: :restrict, on_update: :update_all, type: :identity), references(:polygon_zkevm_bridge_l1_tokens, on_delete: :restrict, on_update: :update_all, type: :identity),
null: true null: true
) )
@ -37,6 +37,10 @@ defmodule Explorer.Repo.PolygonZkevm.Migrations.AddBridgeTables do
timestamps(null: false, type: :utc_datetime_usec) timestamps(null: false, type: :utc_datetime_usec)
end end
create(index(:zkevm_bridge, :l1_token_address)) create(index(:polygon_zkevm_bridge, :l1_token_address))
rename(table(:zkevm_lifecycle_l1_transactions), to: table(:polygon_zkevm_lifecycle_l1_transactions))
rename(table(:zkevm_transaction_batches), to: table(:polygon_zkevm_transaction_batches))
rename(table(:zkevm_batch_l2_transactions), to: table(:polygon_zkevm_batch_l2_transactions))
end end
end end

@ -16,8 +16,8 @@ defmodule Indexer.Block.Fetcher do
alias Explorer.Chain.Cache.Blocks, as: BlocksCache alias Explorer.Chain.Cache.Blocks, as: BlocksCache
alias Explorer.Chain.Cache.{Accounts, BlockNumber, Transactions, Uncles} alias Explorer.Chain.Cache.{Accounts, BlockNumber, Transactions, Uncles}
alias Indexer.Block.Fetcher.Receipts alias Indexer.Block.Fetcher.Receipts
alias Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens, as: PolygonZkevmBridgeL1Tokens
alias Indexer.Fetcher.TokenInstance.Realtime, as: TokenInstanceRealtime alias Indexer.Fetcher.TokenInstance.Realtime, as: TokenInstanceRealtime
alias Indexer.Fetcher.Zkevm.BridgeL1Tokens, as: ZkevmBridgeL1Tokens
alias Indexer.Fetcher.{ alias Indexer.Fetcher.{
Beacon.Blob, Beacon.Blob,
@ -48,7 +48,7 @@ defmodule Indexer.Block.Fetcher do
alias Indexer.Transform.Shibarium.Bridge, as: ShibariumBridge alias Indexer.Transform.Shibarium.Bridge, as: ShibariumBridge
alias Indexer.Transform.Blocks, as: TransformBlocks alias Indexer.Transform.Blocks, as: TransformBlocks
alias Indexer.Transform.Zkevm.Bridge, as: ZkevmBridge alias Indexer.Transform.PolygonZkevm.Bridge, as: PolygonZkevmBridge
@type address_hash_to_fetched_balance_block_number :: %{String.t() => Block.block_number()} @type address_hash_to_fetched_balance_block_number :: %{String.t() => Block.block_number()}
@ -160,9 +160,9 @@ defmodule Indexer.Block.Fetcher do
do: ShibariumBridge.parse(blocks, transactions_with_receipts, logs), do: ShibariumBridge.parse(blocks, transactions_with_receipts, logs),
else: [] else: []
), ),
zkevm_bridge_operations = polygon_zkevm_bridge_operations =
if(callback_module == Indexer.Block.Realtime.Fetcher, if(callback_module == Indexer.Block.Realtime.Fetcher,
do: ZkevmBridge.parse(blocks, logs), do: PolygonZkevmBridge.parse(blocks, logs),
else: [] else: []
), ),
%FetchedBeneficiaries{params_set: beneficiary_params_set, errors: beneficiaries_errors} = %FetchedBeneficiaries{params_set: beneficiary_params_set, errors: beneficiaries_errors} =
@ -178,7 +178,7 @@ defmodule Indexer.Block.Fetcher do
transactions: transactions_with_receipts, transactions: transactions_with_receipts,
transaction_actions: transaction_actions, transaction_actions: transaction_actions,
withdrawals: withdrawals_params, withdrawals: withdrawals_params,
zkevm_bridge_operations: zkevm_bridge_operations polygon_zkevm_bridge_operations: polygon_zkevm_bridge_operations
}), }),
coin_balances_params_set = coin_balances_params_set =
%{ %{
@ -216,7 +216,7 @@ defmodule Indexer.Block.Fetcher do
transactions_with_receipts: transactions_with_receipts, transactions_with_receipts: transactions_with_receipts,
polygon_edge_withdrawals: polygon_edge_withdrawals, polygon_edge_withdrawals: polygon_edge_withdrawals,
polygon_edge_deposit_executes: polygon_edge_deposit_executes, polygon_edge_deposit_executes: polygon_edge_deposit_executes,
zkevm_bridge_operations: zkevm_bridge_operations, polygon_zkevm_bridge_operations: polygon_zkevm_bridge_operations,
shibarium_bridge_operations: shibarium_bridge_operations shibarium_bridge_operations: shibarium_bridge_operations
}, },
{:ok, inserted} <- {:ok, inserted} <-
@ -249,7 +249,7 @@ defmodule Indexer.Block.Fetcher do
transactions_with_receipts: transactions_with_receipts, transactions_with_receipts: transactions_with_receipts,
polygon_edge_withdrawals: polygon_edge_withdrawals, polygon_edge_withdrawals: polygon_edge_withdrawals,
polygon_edge_deposit_executes: polygon_edge_deposit_executes, polygon_edge_deposit_executes: polygon_edge_deposit_executes,
zkevm_bridge_operations: zkevm_bridge_operations, polygon_zkevm_bridge_operations: polygon_zkevm_bridge_operations,
shibarium_bridge_operations: shibarium_bridge_operations shibarium_bridge_operations: shibarium_bridge_operations
}) do }) do
case Application.get_env(:explorer, :chain_type) do case Application.get_env(:explorer, :chain_type) do
@ -266,7 +266,7 @@ defmodule Indexer.Block.Fetcher do
"polygon_zkevm" -> "polygon_zkevm" ->
basic_import_options basic_import_options
|> Map.put_new(:zkevm_bridge_operations, %{params: zkevm_bridge_operations}) |> Map.put_new(:polygon_zkevm_bridge_operations, %{params: polygon_zkevm_bridge_operations})
"shibarium" -> "shibarium" ->
basic_import_options basic_import_options
@ -439,15 +439,15 @@ defmodule Indexer.Block.Fetcher do
@doc """ @doc """
Fills a buffer of L1 token addresses to handle it asynchronously in Fills a buffer of L1 token addresses to handle it asynchronously in
the Indexer.Fetcher.Zkevm.BridgeL1Tokens module. The addresses are the Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens module. The addresses are
taken from the `operations` list. taken from the `operations` list.
""" """
@spec async_import_zkevm_bridge_l1_tokens(map()) :: :ok @spec async_import_polygon_zkevm_bridge_l1_tokens(map()) :: :ok
def async_import_zkevm_bridge_l1_tokens(%{zkevm_bridge_operations: operations}) do def async_import_polygon_zkevm_bridge_l1_tokens(%{polygon_zkevm_bridge_operations: operations}) do
ZkevmBridgeL1Tokens.async_fetch(operations) PolygonZkevmBridgeL1Tokens.async_fetch(operations)
end end
def async_import_zkevm_bridge_l1_tokens(_), do: :ok def async_import_polygon_zkevm_bridge_l1_tokens(_), do: :ok
defp block_reward_errors_to_block_numbers(block_reward_errors) when is_list(block_reward_errors) do defp block_reward_errors_to_block_numbers(block_reward_errors) when is_list(block_reward_errors) do
Enum.map(block_reward_errors, &block_reward_error_to_block_number/1) Enum.map(block_reward_errors, &block_reward_error_to_block_number/1)

@ -22,7 +22,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
async_import_token_balances: 1, async_import_token_balances: 1,
async_import_token_instances: 1, async_import_token_instances: 1,
async_import_uncles: 1, async_import_uncles: 1,
async_import_zkevm_bridge_l1_tokens: 1, async_import_polygon_zkevm_bridge_l1_tokens: 1,
fetch_and_import_range: 2 fetch_and_import_range: 2
] ]
@ -37,8 +37,8 @@ defmodule Indexer.Block.Realtime.Fetcher do
alias Indexer.Block.Realtime.TaskSupervisor alias Indexer.Block.Realtime.TaskSupervisor
alias Indexer.Fetcher.{CoinBalance, CoinBalanceDailyUpdater} alias Indexer.Fetcher.{CoinBalance, CoinBalanceDailyUpdater}
alias Indexer.Fetcher.PolygonEdge.{DepositExecute, Withdrawal} alias Indexer.Fetcher.PolygonEdge.{DepositExecute, Withdrawal}
alias Indexer.Fetcher.PolygonZkevm.BridgeL2, as: PolygonZkevmBridgeL2
alias Indexer.Fetcher.Shibarium.L2, as: ShibariumBridgeL2 alias Indexer.Fetcher.Shibarium.L2, as: ShibariumBridgeL2
alias Indexer.Fetcher.Zkevm.BridgeL2, as: ZkevmBridgeL2
alias Indexer.Prometheus alias Indexer.Prometheus
alias Indexer.Transform.Addresses alias Indexer.Transform.Addresses
alias Timex.Duration alias Timex.Duration
@ -294,7 +294,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
# we need to remove all rows from `shibarium_bridge` table previously written starting from reorg block number # we need to remove all rows from `shibarium_bridge` table previously written starting from reorg block number
remove_shibarium_assets_by_number(block_number_to_fetch) remove_shibarium_assets_by_number(block_number_to_fetch)
# we need to remove all rows from `zkevm_bridge` table previously written starting from reorg block number # we need to remove all rows from `polygon_zkevm_bridge` table previously written starting from reorg block number
remove_polygon_zkevm_assets_by_number(block_number_to_fetch) remove_polygon_zkevm_assets_by_number(block_number_to_fetch)
# give previous fetch attempt (for same block number) a chance to finish # give previous fetch attempt (for same block number) a chance to finish
@ -318,7 +318,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
defp remove_polygon_zkevm_assets_by_number(block_number_to_fetch) do defp remove_polygon_zkevm_assets_by_number(block_number_to_fetch) do
if Application.get_env(:explorer, :chain_type) == "polygon_zkevm" do if Application.get_env(:explorer, :chain_type) == "polygon_zkevm" do
ZkevmBridgeL2.reorg_handle(block_number_to_fetch) PolygonZkevmBridgeL2.reorg_handle(block_number_to_fetch)
end end
end end
@ -452,7 +452,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
async_import_uncles(imported) async_import_uncles(imported)
async_import_replaced_transactions(imported) async_import_replaced_transactions(imported)
async_import_blobs(imported) async_import_blobs(imported)
async_import_zkevm_bridge_l1_tokens(imported) async_import_polygon_zkevm_bridge_l1_tokens(imported)
end end
defp balances( defp balances(

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.Bridge do defmodule Indexer.Fetcher.PolygonZkevm.Bridge do
@moduledoc """ @moduledoc """
Contains common functions for Indexer.Fetcher.Zkevm.Bridge* modules. Contains common functions for Indexer.Fetcher.PolygonZkevm.Bridge* modules.
""" """
require Logger require Logger
@ -20,7 +20,7 @@ defmodule Indexer.Fetcher.Zkevm.Bridge do
alias EthereumJSONRPC.Logs alias EthereumJSONRPC.Logs
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.Zkevm.Reader alias Explorer.Chain.PolygonZkevm.Reader
alias Explorer.SmartContract.Reader, as: SmartContractReader alias Explorer.SmartContract.Reader, as: SmartContractReader
alias Indexer.Helper alias Indexer.Helper
alias Indexer.Transform.Addresses alias Indexer.Transform.Addresses
@ -112,20 +112,20 @@ defmodule Indexer.Fetcher.Zkevm.Bridge do
@doc """ @doc """
Imports the given zkEVM bridge operations into database. Imports the given zkEVM bridge operations into database.
Used by Indexer.Fetcher.Zkevm.BridgeL1 and Indexer.Fetcher.Zkevm.BridgeL2 fetchers. Used by Indexer.Fetcher.PolygonZkevm.BridgeL1 and Indexer.Fetcher.PolygonZkevm.BridgeL2 fetchers.
Doesn't return anything. Doesn't return anything.
""" """
@spec import_operations(list()) :: no_return() @spec import_operations(list()) :: no_return()
def import_operations(operations) do def import_operations(operations) do
addresses = addresses =
Addresses.extract_addresses(%{ Addresses.extract_addresses(%{
zkevm_bridge_operations: operations polygon_zkevm_bridge_operations: operations
}) })
{:ok, _} = {:ok, _} =
Chain.import(%{ Chain.import(%{
addresses: %{params: addresses, on_conflict: :nothing}, addresses: %{params: addresses, on_conflict: :nothing},
zkevm_bridge_operations: %{params: operations}, polygon_zkevm_bridge_operations: %{params: operations},
timeout: :infinity timeout: :infinity
}) })
end end
@ -267,11 +267,11 @@ defmodule Indexer.Fetcher.Zkevm.Bridge do
{:ok, inserts} = {:ok, inserts} =
Chain.import(%{ Chain.import(%{
zkevm_bridge_l1_tokens: %{params: tokens_to_insert}, polygon_zkevm_bridge_l1_tokens: %{params: tokens_to_insert},
timeout: :infinity timeout: :infinity
}) })
tokens_inserted = Map.get(inserts, :insert_zkevm_bridge_l1_tokens, []) tokens_inserted = Map.get(inserts, :insert_polygon_zkevm_bridge_l1_tokens, [])
# we need to query not inserted tokens from DB separately as they # we need to query not inserted tokens from DB separately as they
# could be inserted by another module at the same time (a race condition). # could be inserted by another module at the same time (a race condition).

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.BridgeL1 do defmodule Indexer.Fetcher.PolygonZkevm.BridgeL1 do
@moduledoc """ @moduledoc """
Fills zkevm_bridge DB table. Fills polygon_zkevm_bridge DB table.
""" """
use GenServer use GenServer
@ -11,16 +11,16 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
import Ecto.Query import Ecto.Query
import Explorer.Helper, only: [parse_integer: 1] import Explorer.Helper, only: [parse_integer: 1]
import Indexer.Fetcher.Zkevm.Bridge, import Indexer.Fetcher.PolygonZkevm.Bridge,
only: [get_logs_all: 3, import_operations: 1, prepare_operations: 3] only: [get_logs_all: 3, import_operations: 1, prepare_operations: 3]
alias Explorer.Chain.Zkevm.{Bridge, Reader} alias Explorer.Chain.PolygonZkevm.{Bridge, Reader}
alias Explorer.Repo alias Explorer.Repo
alias Indexer.Fetcher.RollupL1ReorgMonitor alias Indexer.Fetcher.RollupL1ReorgMonitor
alias Indexer.Helper alias Indexer.Helper
@eth_get_logs_range_size 1000 @eth_get_logs_range_size 1000
@fetcher_name :zkevm_bridge_l1 @fetcher_name :polygon_zkevm_bridge_l1
def child_spec(start_link_arguments) do def child_spec(start_link_arguments) do
spec = %{ spec = %{
@ -100,7 +100,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
{:stop, :normal, %{}} {:stop, :normal, %{}}
{:start_block_valid, false, last_l1_block_number, safe_block} -> {:start_block_valid, false, last_l1_block_number, safe_block} ->
Logger.error("Invalid L1 Start Block value. Please, check the value and zkevm_bridge table.") Logger.error("Invalid L1 Start Block value. Please, check the value and polygon_zkevm_bridge table.")
Logger.error("last_l1_block_number = #{inspect(last_l1_block_number)}") Logger.error("last_l1_block_number = #{inspect(last_l1_block_number)}")
Logger.error("safe_block = #{inspect(safe_block)}") Logger.error("safe_block = #{inspect(safe_block)}")
{:stop, :normal, %{}} {:stop, :normal, %{}}
@ -114,7 +114,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
{:l1_tx_not_found, true} -> {:l1_tx_not_found, true} ->
Logger.error( Logger.error(
"Cannot find last L1 transaction from RPC by its hash. Probably, there was a reorg on L1 chain. Please, check zkevm_bridge table." "Cannot find last L1 transaction from RPC by its hash. Probably, there was a reorg on L1 chain. Please, check polygon_zkevm_bridge table."
) )
{:stop, :normal, %{}} {:stop, :normal, %{}}
@ -203,7 +203,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
if deleted_count > 0 do if deleted_count > 0 do
Logger.warning( Logger.warning(
"As L1 reorg was detected, some deposits with block_number >= #{reorg_block} were removed from zkevm_bridge table. Number of removed rows: #{deleted_count}." "As L1 reorg was detected, some deposits with block_number >= #{reorg_block} were removed from polygon_zkevm_bridge table. Number of removed rows: #{deleted_count}."
) )
end end
end end

@ -1,4 +1,4 @@
defmodule Indexer.Fetcher.Zkevm.BridgeL1Tokens do defmodule Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens do
@moduledoc """ @moduledoc """
Fetches information about L1 tokens for zkEVM bridge. Fetches information about L1 tokens for zkEVM bridge.
""" """
@ -10,7 +10,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1Tokens do
alias Explorer.Repo alias Explorer.Repo
alias Indexer.{BufferedTask, Helper} alias Indexer.{BufferedTask, Helper}
alias Indexer.Fetcher.Zkevm.{Bridge, BridgeL1} alias Indexer.Fetcher.PolygonZkevm.{Bridge, BridgeL1}
@behaviour BufferedTask @behaviour BufferedTask
@ -41,7 +41,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1Tokens do
|> Bridge.token_addresses_to_ids(json_rpc_named_arguments) |> Bridge.token_addresses_to_ids(json_rpc_named_arguments)
|> Enum.each(fn {l1_token_address, l1_token_id} -> |> Enum.each(fn {l1_token_address, l1_token_id} ->
Repo.update_all( Repo.update_all(
from(b in Explorer.Chain.Zkevm.Bridge, where: b.l1_token_address == ^l1_token_address), from(b in Explorer.Chain.PolygonZkevm.Bridge, where: b.l1_token_address == ^l1_token_address),
set: [l1_token_id: l1_token_id, l1_token_address: nil] set: [l1_token_id: l1_token_id, l1_token_address: nil]
) )
end) end)

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.BridgeL2 do defmodule Indexer.Fetcher.PolygonZkevm.BridgeL2 do
@moduledoc """ @moduledoc """
Fills zkevm_bridge DB table. Fills polygon_zkevm_bridge DB table.
""" """
use GenServer use GenServer
@ -11,15 +11,15 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
import Ecto.Query import Ecto.Query
import Explorer.Helper, only: [parse_integer: 1] import Explorer.Helper, only: [parse_integer: 1]
import Indexer.Fetcher.Zkevm.Bridge, import Indexer.Fetcher.PolygonZkevm.Bridge,
only: [get_logs_all: 3, import_operations: 1, prepare_operations: 3] only: [get_logs_all: 3, import_operations: 1, prepare_operations: 3]
alias Explorer.Chain.Zkevm.{Bridge, Reader} alias Explorer.Chain.PolygonZkevm.{Bridge, Reader}
alias Explorer.Repo alias Explorer.Repo
alias Indexer.Helper alias Indexer.Helper
@eth_get_logs_range_size 1000 @eth_get_logs_range_size 1000
@fetcher_name :zkevm_bridge_l2 @fetcher_name :polygon_zkevm_bridge_l2
def child_spec(start_link_arguments) do def child_spec(start_link_arguments) do
spec = %{ spec = %{
@ -55,7 +55,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
env = Application.get_all_env(:indexer)[__MODULE__] env = Application.get_all_env(:indexer)[__MODULE__]
with {:start_block_undefined, false} <- {:start_block_undefined, is_nil(env[:start_block])}, with {:start_block_undefined, false} <- {:start_block_undefined, is_nil(env[:start_block])},
rpc_l1 = Application.get_all_env(:indexer)[Indexer.Fetcher.Zkevm.BridgeL1][:rpc], rpc_l1 = Application.get_all_env(:indexer)[Indexer.Fetcher.PolygonZkevm.BridgeL1][:rpc],
{:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(rpc_l1)}, {:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(rpc_l1)},
{:bridge_contract_address_is_valid, true} <- {:bridge_contract_address_is_valid, true} <-
{:bridge_contract_address_is_valid, Helper.address_correct?(env[:bridge_contract])}, {:bridge_contract_address_is_valid, Helper.address_correct?(env[:bridge_contract])},
@ -93,7 +93,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
{:stop, :normal, state} {:stop, :normal, state}
{:start_block_valid, false} -> {:start_block_valid, false} ->
Logger.error("Invalid L2 Start Block value. Please, check the value and zkevm_bridge table.") Logger.error("Invalid L2 Start Block value. Please, check the value and polygon_zkevm_bridge table.")
{:stop, :normal, state} {:stop, :normal, state}
{:error, error_data} -> {:error, error_data} ->
@ -105,7 +105,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
{:l2_tx_not_found, true} -> {:l2_tx_not_found, true} ->
Logger.error( Logger.error(
"Cannot find last L2 transaction from RPC by its hash. Probably, there was a reorg on L2 chain. Please, check zkevm_bridge table." "Cannot find last L2 transaction from RPC by its hash. Probably, there was a reorg on L2 chain. Please, check polygon_zkevm_bridge table."
) )
{:stop, :normal, state} {:stop, :normal, state}
@ -169,7 +169,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
if deleted_count > 0 do if deleted_count > 0 do
Logger.warning( Logger.warning(
"As L2 reorg was detected, some withdrawals with block_number >= #{reorg_block} were removed from zkevm_bridge table. Number of removed rows: #{deleted_count}." "As L2 reorg was detected, some withdrawals with block_number >= #{reorg_block} were removed from polygon_zkevm_bridge table. Number of removed rows: #{deleted_count}."
) )
end end
end end

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.TransactionBatch do defmodule Indexer.Fetcher.PolygonZkevm.TransactionBatch do
@moduledoc """ @moduledoc """
Fills zkevm_transaction_batches DB table. Fills polygon_zkevm_transaction_batches DB table.
""" """
use GenServer use GenServer
@ -12,7 +12,7 @@ defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.Events.Publisher alias Explorer.Chain.Events.Publisher
alias Explorer.Chain.Zkevm.Reader alias Explorer.Chain.PolygonZkevm.Reader
alias Indexer.Helper alias Indexer.Helper
@zero_hash "0000000000000000000000000000000000000000000000000000000000000000" @zero_hash "0000000000000000000000000000000000000000000000000000000000000000"
@ -34,9 +34,9 @@ defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
@impl GenServer @impl GenServer
def init(args) do def init(args) do
Logger.metadata(fetcher: :zkevm_transaction_batches) Logger.metadata(fetcher: :polygon_zkevm_transaction_batches)
config = Application.get_all_env(:indexer)[Indexer.Fetcher.Zkevm.TransactionBatch] config = Application.get_all_env(:indexer)[Indexer.Fetcher.PolygonZkevm.TransactionBatch]
chunk_size = config[:chunk_size] chunk_size = config[:chunk_size]
recheck_interval = config[:recheck_interval] recheck_interval = config[:recheck_interval]
@ -251,9 +251,9 @@ defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
{:ok, _} = {:ok, _} =
Chain.import(%{ Chain.import(%{
zkevm_lifecycle_transactions: %{params: l1_txs_to_import}, polygon_zkevm_lifecycle_transactions: %{params: l1_txs_to_import},
zkevm_transaction_batches: %{params: batches_to_import}, polygon_zkevm_transaction_batches: %{params: batches_to_import},
zkevm_batch_transactions: %{params: l2_txs_to_import}, polygon_zkevm_batch_transactions: %{params: l2_txs_to_import},
timeout: :infinity timeout: :infinity
}) })

@ -34,8 +34,8 @@ defmodule Indexer.Fetcher.RollupL1ReorgMonitor do
modules_can_use_reorg_monitor = [ modules_can_use_reorg_monitor = [
Indexer.Fetcher.PolygonEdge.Deposit, Indexer.Fetcher.PolygonEdge.Deposit,
Indexer.Fetcher.PolygonEdge.WithdrawalExit, Indexer.Fetcher.PolygonEdge.WithdrawalExit,
Indexer.Fetcher.Shibarium.L1, Indexer.Fetcher.PolygonZkevm.BridgeL1,
Indexer.Fetcher.Zkevm.BridgeL1 Indexer.Fetcher.Shibarium.L1
] ]
modules_using_reorg_monitor = modules_using_reorg_monitor =
@ -52,7 +52,7 @@ defmodule Indexer.Fetcher.RollupL1ReorgMonitor do
# As there cannot be different modules for different rollups at the same time, # As there cannot be different modules for different rollups at the same time,
# it's correct to only get the first item of the list. # it's correct to only get the first item of the list.
# For example, Indexer.Fetcher.PolygonEdge.Deposit and Indexer.Fetcher.PolygonEdge.WithdrawalExit can be in the list # For example, Indexer.Fetcher.PolygonEdge.Deposit and Indexer.Fetcher.PolygonEdge.WithdrawalExit can be in the list
# because they are for the same rollup, but Indexer.Fetcher.Shibarium.L1 and Indexer.Fetcher.Zkevm.BridgeL1 cannot (as they are for different rollups). # because they are for the same rollup, but Indexer.Fetcher.Shibarium.L1 and Indexer.Fetcher.PolygonZkevm.BridgeL1 cannot (as they are for different rollups).
module_using_reorg_monitor = Enum.at(modules_using_reorg_monitor, 0) module_using_reorg_monitor = Enum.at(modules_using_reorg_monitor, 0)
l1_rpc = l1_rpc =

@ -144,12 +144,12 @@ defmodule Indexer.Supervisor do
[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]
]), ]),
configure(Indexer.Fetcher.Shibarium.L1.Supervisor, [[memory_monitor: memory_monitor]]), configure(Indexer.Fetcher.Shibarium.L1.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.Zkevm.BridgeL1.Supervisor, [[memory_monitor: memory_monitor]]), configure(Indexer.Fetcher.PolygonZkevm.BridgeL1.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.Zkevm.BridgeL1Tokens.Supervisor, [[memory_monitor: memory_monitor]]), configure(Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.Zkevm.BridgeL2.Supervisor, [ configure(Indexer.Fetcher.PolygonZkevm.BridgeL2.Supervisor, [
[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]
]), ]),
configure(Indexer.Fetcher.Zkevm.TransactionBatch.Supervisor, [ configure(Indexer.Fetcher.PolygonZkevm.TransactionBatch.Supervisor, [
[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]
]), ]),
{Indexer.Fetcher.Beacon.Blob.Supervisor, [[memory_monitor: memory_monitor]]}, {Indexer.Fetcher.Beacon.Blob.Supervisor, [[memory_monitor: memory_monitor]]},

@ -149,7 +149,7 @@ defmodule Indexer.Transform.Addresses do
%{from: :address_hash, to: :hash} %{from: :address_hash, to: :hash}
] ]
], ],
zkevm_bridge_operations: [ polygon_zkevm_bridge_operations: [
[ [
%{from: :l2_token_address, to: :hash} %{from: :l2_token_address, to: :hash}
] ]
@ -461,7 +461,7 @@ defmodule Indexer.Transform.Addresses do
required(:block_number) => non_neg_integer() required(:block_number) => non_neg_integer()
} }
], ],
optional(:zkevm_bridge_operations) => [ optional(:polygon_zkevm_bridge_operations) => [
%{ %{
optional(:l2_token_address) => String.t() optional(:l2_token_address) => String.t()
} }

@ -1,14 +1,14 @@
defmodule Indexer.Transform.Zkevm.Bridge do defmodule Indexer.Transform.PolygonZkevm.Bridge do
@moduledoc """ @moduledoc """
Helper functions for transforming data for Polygon zkEVM Bridge operations. Helper functions for transforming data for Polygon zkEVM Bridge operations.
""" """
require Logger require Logger
import Indexer.Fetcher.Zkevm.Bridge, import Indexer.Fetcher.PolygonZkevm.Bridge,
only: [filter_bridge_events: 2, prepare_operations: 4] only: [filter_bridge_events: 2, prepare_operations: 4]
alias Indexer.Fetcher.Zkevm.{BridgeL1, BridgeL2} alias Indexer.Fetcher.PolygonZkevm.{BridgeL1, BridgeL2}
alias Indexer.Helper alias Indexer.Helper
@doc """ @doc """
@ -17,7 +17,7 @@ defmodule Indexer.Transform.Zkevm.Bridge do
@spec parse(list(), list()) :: list() @spec parse(list(), list()) :: list()
def parse(blocks, logs) do def parse(blocks, logs) do
prev_metadata = Logger.metadata() prev_metadata = Logger.metadata()
Logger.metadata(fetcher: :zkevm_bridge_l2_realtime) Logger.metadata(fetcher: :polygon_zkevm_bridge_l2_realtime)
items = items =
with false <- is_nil(Application.get_env(:indexer, BridgeL2)[:start_block]), with false <- is_nil(Application.get_env(:indexer, BridgeL2)[:start_block]),

@ -725,27 +725,29 @@ config :indexer, Indexer.Fetcher.Shibarium.L1.Supervisor, enabled: ConfigHelper.
config :indexer, Indexer.Fetcher.Shibarium.L2.Supervisor, enabled: ConfigHelper.chain_type() == "shibarium" config :indexer, Indexer.Fetcher.Shibarium.L2.Supervisor, enabled: ConfigHelper.chain_type() == "shibarium"
config :indexer, Indexer.Fetcher.Zkevm.BridgeL1, config :indexer, Indexer.Fetcher.PolygonZkevm.BridgeL1,
rpc: System.get_env("INDEXER_POLYGON_ZKEVM_L1_RPC"), rpc: System.get_env("INDEXER_POLYGON_ZKEVM_L1_RPC"),
start_block: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_START_BLOCK"), start_block: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_START_BLOCK"),
bridge_contract: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_CONTRACT"), bridge_contract: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_CONTRACT"),
native_symbol: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_NATIVE_SYMBOL", "ETH"), native_symbol: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_NATIVE_SYMBOL", "ETH"),
native_decimals: ConfigHelper.parse_integer_env_var("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_NATIVE_DECIMALS", 18) native_decimals: ConfigHelper.parse_integer_env_var("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_NATIVE_DECIMALS", 18)
config :indexer, Indexer.Fetcher.Zkevm.BridgeL1.Supervisor, enabled: ConfigHelper.chain_type() == "polygon_zkevm" config :indexer, Indexer.Fetcher.PolygonZkevm.BridgeL1.Supervisor, enabled: ConfigHelper.chain_type() == "polygon_zkevm"
config :indexer, Indexer.Fetcher.Zkevm.BridgeL1Tokens.Supervisor, enabled: ConfigHelper.chain_type() == "polygon_zkevm"
config :indexer, Indexer.Fetcher.Zkevm.BridgeL2, config :indexer, Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens.Supervisor,
enabled: ConfigHelper.chain_type() == "polygon_zkevm"
config :indexer, Indexer.Fetcher.PolygonZkevm.BridgeL2,
start_block: System.get_env("INDEXER_POLYGON_ZKEVM_L2_BRIDGE_START_BLOCK"), start_block: System.get_env("INDEXER_POLYGON_ZKEVM_L2_BRIDGE_START_BLOCK"),
bridge_contract: System.get_env("INDEXER_POLYGON_ZKEVM_L2_BRIDGE_CONTRACT") bridge_contract: System.get_env("INDEXER_POLYGON_ZKEVM_L2_BRIDGE_CONTRACT")
config :indexer, Indexer.Fetcher.Zkevm.BridgeL2.Supervisor, enabled: ConfigHelper.chain_type() == "polygon_zkevm" config :indexer, Indexer.Fetcher.PolygonZkevm.BridgeL2.Supervisor, enabled: ConfigHelper.chain_type() == "polygon_zkevm"
config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch, config :indexer, Indexer.Fetcher.PolygonZkevm.TransactionBatch,
chunk_size: ConfigHelper.parse_integer_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_CHUNK_SIZE", 20), chunk_size: ConfigHelper.parse_integer_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_CHUNK_SIZE", 20),
recheck_interval: ConfigHelper.parse_integer_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_RECHECK_INTERVAL", 60) recheck_interval: ConfigHelper.parse_integer_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_RECHECK_INTERVAL", 60)
config :indexer, Indexer.Fetcher.Zkevm.TransactionBatch.Supervisor, config :indexer, Indexer.Fetcher.PolygonZkevm.TransactionBatch.Supervisor,
enabled: enabled:
ConfigHelper.chain_type() == "polygon_zkevm" && ConfigHelper.chain_type() == "polygon_zkevm" &&
ConfigHelper.parse_bool_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_ENABLED") ConfigHelper.parse_bool_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_ENABLED")

Loading…
Cancel
Save