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

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

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

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

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

@ -31,7 +31,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
alias Explorer.Chain
alias Explorer.Chain.Beacon.Reader, as: BeaconReader
alias Explorer.Chain.{Hash, Transaction}
alias Explorer.Chain.Zkevm.Reader
alias Explorer.Chain.PolygonZkevm.Reader
alias Indexer.Fetcher.FirstTraceOnDemand
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.
It renders the list of L2 transactions bound to the specified batch.
"""
@spec zkevm_batch(Plug.Conn.t(), map()) :: Plug.Conn.t()
def zkevm_batch(conn, %{"batch_number" => batch_number} = _params) do
@spec polygon_zkevm_batch(Plug.Conn.t(), map()) :: Plug.Conn.t()
def polygon_zkevm_batch(conn, %{"batch_number" => batch_number} = _params) do
transactions =
batch_number
|> Reader.batch_transactions(api?: true)

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

@ -24,7 +24,7 @@ defmodule BlockScoutWeb.Mixfile do
],
start_permanent: Mix.env() == :prod,
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

@ -1,13 +1,13 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
defmodule Explorer.Chain.Import.Runner.PolygonZkevm.BatchTransactions do
@moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.BatchTransaction.t/0`.
Bulk imports `t:Explorer.Chain.PolygonZkevm.BatchTransaction.t/0`.
"""
require Ecto.Query
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.BatchTransaction
alias Explorer.Chain.PolygonZkevm.BatchTransaction
alias Explorer.Prometheus.Instrumenter
@behaviour Import.Runner
@ -21,7 +21,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
def ecto_schema_module, do: BatchTransaction
@impl Import.Runner
def option_key, do: :zkevm_batch_transactions
def option_key, do: :polygon_zkevm_batch_transactions
@impl Import.Runner
@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(: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(
fn -> insert(repo, changes_list, insert_options) end,
:block_referencing,
:zkevm_batch_transactions,
:zkevm_batch_transactions
:polygon_zkevm_batch_transactions,
:polygon_zkevm_batch_transactions
)
end)
end
@ -59,7 +59,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
{:ok, [BatchTransaction.t()]}
| {:error, [Changeset.t()]}
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)
{:ok, inserted} =

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

@ -1,6 +1,6 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
defmodule Explorer.Chain.Import.Runner.PolygonZkevm.BridgeOperations do
@moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.Bridge.t/0`.
Bulk imports `t:Explorer.Chain.PolygonZkevm.Bridge.t/0`.
"""
require Ecto.Query
@ -9,7 +9,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.Bridge, as: ZkevmBridge
alias Explorer.Chain.PolygonZkevm.Bridge, as: PolygonZkevmBridge
alias Explorer.Prometheus.Instrumenter
@behaviour Import.Runner
@ -17,13 +17,13 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
# milliseconds
@timeout 60_000
@type imported :: [ZkevmBridge.t()]
@type imported :: [PolygonZkevmBridge.t()]
@impl Import.Runner
def ecto_schema_module, do: ZkevmBridge
def ecto_schema_module, do: PolygonZkevmBridge
@impl Import.Runner
def option_key, do: :zkevm_bridge_operations
def option_key, do: :polygon_zkevm_bridge_operations
@impl Import.Runner
def imported_table_row do
@ -42,12 +42,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
|> Map.put_new(:timeout, @timeout)
|> 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(
fn -> insert(repo, changes_list, insert_options) end,
:block_referencing,
:zkevm_bridge_operations,
:zkevm_bridge_operations
:polygon_zkevm_bridge_operations,
:polygon_zkevm_bridge_operations
)
end)
end
@ -56,12 +56,12 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
def timeout, do: @timeout
@spec insert(Repo.t(), [map()], %{required(:timeout) => timeout(), required(:timestamps) => Import.timestamps()}) ::
{:ok, [ZkevmBridge.t()]}
{:ok, [PolygonZkevmBridge.t()]}
| {:error, [Changeset.t()]}
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)
# 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})
{:ok, inserted} =
@ -70,7 +70,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
ordered_changes_list,
conflict_target: [:type, :index],
on_conflict: on_conflict,
for: ZkevmBridge,
for: PolygonZkevmBridge,
returning: true,
timeout: timeout,
timestamps: timestamps
@ -81,7 +81,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.BridgeOperations do
defp default_on_conflict do
from(
op in ZkevmBridge,
op in PolygonZkevmBridge,
update: [
set: [
# 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 """
Bulk imports `t:Explorer.Chain.Zkevm.LifecycleTransaction.t/0`.
Bulk imports `t:Explorer.Chain.PolygonZkevm.LifecycleTransaction.t/0`.
"""
require Ecto.Query
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.LifecycleTransaction
alias Explorer.Chain.PolygonZkevm.LifecycleTransaction
alias Explorer.Prometheus.Instrumenter
import Ecto.Query, only: [from: 2]
@ -23,7 +23,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do
def ecto_schema_module, do: LifecycleTransaction
@impl Import.Runner
def option_key, do: :zkevm_lifecycle_transactions
def option_key, do: :polygon_zkevm_lifecycle_transactions
@impl Import.Runner
@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(: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(
fn -> insert(repo, changes_list, insert_options) end,
:block_referencing,
:zkevm_lifecycle_transactions,
:zkevm_lifecycle_transactions
:polygon_zkevm_lifecycle_transactions,
:polygon_zkevm_lifecycle_transactions
)
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
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)
{:ok, inserted} =

@ -1,13 +1,13 @@
defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do
defmodule Explorer.Chain.Import.Runner.PolygonZkevm.TransactionBatches do
@moduledoc """
Bulk imports `t:Explorer.Chain.Zkevm.TransactionBatch.t/0`.
Bulk imports `t:Explorer.Chain.PolygonZkevm.TransactionBatch.t/0`.
"""
require Ecto.Query
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.TransactionBatch
alias Explorer.Chain.PolygonZkevm.TransactionBatch
alias Explorer.Prometheus.Instrumenter
import Ecto.Query, only: [from: 2]
@ -23,7 +23,7 @@ defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do
def ecto_schema_module, do: TransactionBatch
@impl Import.Runner
def option_key, do: :zkevm_transaction_batches
def option_key, do: :polygon_zkevm_transaction_batches
@impl Import.Runner
@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(: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(
fn -> insert(repo, changes_list, insert_options) end,
:block_referencing,
:zkevm_transaction_batches,
:zkevm_transaction_batches
:polygon_zkevm_transaction_batches,
:polygon_zkevm_transaction_batches
)
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
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)
{:ok, inserted} =

@ -26,11 +26,11 @@ defmodule Explorer.Chain.Import.Stage.BlockReferencing do
]
@polygon_zkevm_runners [
Runner.Zkevm.LifecycleTransactions,
Runner.Zkevm.TransactionBatches,
Runner.Zkevm.BatchTransactions,
Runner.Zkevm.BridgeL1Tokens,
Runner.Zkevm.BridgeOperations
Runner.PolygonZkevm.LifecycleTransactions,
Runner.PolygonZkevm.TransactionBatches,
Runner.PolygonZkevm.BatchTransactions,
Runner.PolygonZkevm.BridgeL1Tokens,
Runner.PolygonZkevm.BridgeOperations
]
@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."
use Explorer.Schema
alias Explorer.Chain.{Hash, Transaction}
alias Explorer.Chain.Zkevm.TransactionBatch
alias Explorer.Chain.PolygonZkevm.TransactionBatch
@required_attrs ~w(batch_number hash)a
@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(: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."
use Explorer.Schema
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
@ -26,7 +26,7 @@ defmodule Explorer.Chain.Zkevm.Bridge do
}
@primary_key false
schema "zkevm_bridge" do
schema "polygon_zkevm_bridge" do
field(:type, Ecto.Enum, values: [:deposit, :withdrawal], primary_key: true)
field(:index, :integer, primary_key: true)
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."
use Explorer.Schema
@ -16,7 +16,7 @@ defmodule Explorer.Chain.Zkevm.BridgeL1Token do
}
@primary_key {:id, :id, autogenerate: true}
schema "zkevm_bridge_l1_tokens" do
schema "polygon_zkevm_bridge_l1_tokens" do
field(:address, Hash.Address)
field(:decimals, :integer)
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."
use Explorer.Schema
alias Explorer.Chain.Hash
alias Explorer.Chain.Zkevm.TransactionBatch
alias Explorer.Chain.PolygonZkevm.TransactionBatch
@required_attrs ~w(id hash is_verify)a
@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(:hash, Hash.Full, 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."
import Ecto.Query,
@ -12,13 +12,13 @@ defmodule Explorer.Chain.Zkevm.Reader do
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 Indexer.Helper
@doc """
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.
"""
@spec batch(non_neg_integer() | :latest, list()) :: {:ok, map()} | {:error, :not_found}
@ -49,7 +49,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end
@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()
def batches(options \\ []) do
@ -79,7 +79,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end
@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()
def batch_transactions(batch_number, options \\ []) do
@ -90,7 +90,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
@doc """
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 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
@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.
If not found, returns zero block number and nil as the transaction hash.
"""
@ -142,7 +142,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end
@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.
If not found, returns zero block number and nil as the transaction hash.
"""
@ -162,7 +162,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end
@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.
"""
@spec last_verified_batch_number() :: non_neg_integer()
@ -181,7 +181,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end
@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()
def lifecycle_transactions(l1_tx_hashes) do
@ -196,7 +196,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
end
@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()
def next_id do
@ -217,7 +217,7 @@ defmodule Explorer.Chain.Zkevm.Reader do
@doc """
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.
"""
@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."
use Explorer.Schema
alias Explorer.Chain.Hash
alias Explorer.Chain.Zkevm.{BatchTransaction, LifecycleTransaction}
alias Explorer.Chain.PolygonZkevm.{BatchTransaction, LifecycleTransaction}
@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
@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(:timestamp, :utc_datetime_usec)
field(:l2_transactions_count, :integer)

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

@ -2,7 +2,7 @@ defmodule Explorer.Repo.PolygonZkevm.Migrations.AddBridgeTables do
use Ecto.Migration
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(:address, :bytea, null: false)
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)
end
create(unique_index(:zkevm_bridge_l1_tokens, :address))
create(unique_index(:polygon_zkevm_bridge_l1_tokens, :address))
execute(
"CREATE TYPE zkevm_bridge_op_type AS ENUM ('deposit', 'withdrawal')",
"DROP TYPE zkevm_bridge_op_type"
"CREATE TYPE polygon_zkevm_bridge_op_type AS ENUM ('deposit', 'withdrawal')",
"DROP TYPE polygon_zkevm_bridge_op_type"
)
create table(:zkevm_bridge, primary_key: false) do
add(:type, :zkevm_bridge_op_type, null: false, primary_key: true)
create table(:polygon_zkevm_bridge, primary_key: false) do
add(:type, :polygon_zkevm_bridge_op_type, null: false, primary_key: true)
add(:index, :integer, null: false, primary_key: true)
add(:l1_transaction_hash, :bytea, null: true)
add(:l2_transaction_hash, :bytea, null: true)
add(
: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
)
@ -37,6 +37,10 @@ defmodule Explorer.Repo.PolygonZkevm.Migrations.AddBridgeTables do
timestamps(null: false, type: :utc_datetime_usec)
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

@ -16,8 +16,8 @@ defmodule Indexer.Block.Fetcher do
alias Explorer.Chain.Cache.Blocks, as: BlocksCache
alias Explorer.Chain.Cache.{Accounts, BlockNumber, Transactions, Uncles}
alias Indexer.Block.Fetcher.Receipts
alias Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens, as: PolygonZkevmBridgeL1Tokens
alias Indexer.Fetcher.TokenInstance.Realtime, as: TokenInstanceRealtime
alias Indexer.Fetcher.Zkevm.BridgeL1Tokens, as: ZkevmBridgeL1Tokens
alias Indexer.Fetcher.{
Beacon.Blob,
@ -48,7 +48,7 @@ defmodule Indexer.Block.Fetcher do
alias Indexer.Transform.Shibarium.Bridge, as: ShibariumBridge
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()}
@ -160,9 +160,9 @@ defmodule Indexer.Block.Fetcher do
do: ShibariumBridge.parse(blocks, transactions_with_receipts, logs),
else: []
),
zkevm_bridge_operations =
polygon_zkevm_bridge_operations =
if(callback_module == Indexer.Block.Realtime.Fetcher,
do: ZkevmBridge.parse(blocks, logs),
do: PolygonZkevmBridge.parse(blocks, logs),
else: []
),
%FetchedBeneficiaries{params_set: beneficiary_params_set, errors: beneficiaries_errors} =
@ -178,7 +178,7 @@ defmodule Indexer.Block.Fetcher do
transactions: transactions_with_receipts,
transaction_actions: transaction_actions,
withdrawals: withdrawals_params,
zkevm_bridge_operations: zkevm_bridge_operations
polygon_zkevm_bridge_operations: polygon_zkevm_bridge_operations
}),
coin_balances_params_set =
%{
@ -216,7 +216,7 @@ defmodule Indexer.Block.Fetcher do
transactions_with_receipts: transactions_with_receipts,
polygon_edge_withdrawals: polygon_edge_withdrawals,
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
},
{:ok, inserted} <-
@ -249,7 +249,7 @@ defmodule Indexer.Block.Fetcher do
transactions_with_receipts: transactions_with_receipts,
polygon_edge_withdrawals: polygon_edge_withdrawals,
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
}) do
case Application.get_env(:explorer, :chain_type) do
@ -266,7 +266,7 @@ defmodule Indexer.Block.Fetcher do
"polygon_zkevm" ->
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" ->
basic_import_options
@ -439,15 +439,15 @@ defmodule Indexer.Block.Fetcher do
@doc """
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.
"""
@spec async_import_zkevm_bridge_l1_tokens(map()) :: :ok
def async_import_zkevm_bridge_l1_tokens(%{zkevm_bridge_operations: operations}) do
ZkevmBridgeL1Tokens.async_fetch(operations)
@spec async_import_polygon_zkevm_bridge_l1_tokens(map()) :: :ok
def async_import_polygon_zkevm_bridge_l1_tokens(%{polygon_zkevm_bridge_operations: operations}) do
PolygonZkevmBridgeL1Tokens.async_fetch(operations)
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
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_instances: 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
]
@ -37,8 +37,8 @@ defmodule Indexer.Block.Realtime.Fetcher do
alias Indexer.Block.Realtime.TaskSupervisor
alias Indexer.Fetcher.{CoinBalance, CoinBalanceDailyUpdater}
alias Indexer.Fetcher.PolygonEdge.{DepositExecute, Withdrawal}
alias Indexer.Fetcher.PolygonZkevm.BridgeL2, as: PolygonZkevmBridgeL2
alias Indexer.Fetcher.Shibarium.L2, as: ShibariumBridgeL2
alias Indexer.Fetcher.Zkevm.BridgeL2, as: ZkevmBridgeL2
alias Indexer.Prometheus
alias Indexer.Transform.Addresses
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
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)
# 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
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
@ -452,7 +452,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
async_import_uncles(imported)
async_import_replaced_transactions(imported)
async_import_blobs(imported)
async_import_zkevm_bridge_l1_tokens(imported)
async_import_polygon_zkevm_bridge_l1_tokens(imported)
end
defp balances(

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.Bridge do
defmodule Indexer.Fetcher.PolygonZkevm.Bridge do
@moduledoc """
Contains common functions for Indexer.Fetcher.Zkevm.Bridge* modules.
Contains common functions for Indexer.Fetcher.PolygonZkevm.Bridge* modules.
"""
require Logger
@ -20,7 +20,7 @@ defmodule Indexer.Fetcher.Zkevm.Bridge do
alias EthereumJSONRPC.Logs
alias Explorer.Chain
alias Explorer.Chain.Zkevm.Reader
alias Explorer.Chain.PolygonZkevm.Reader
alias Explorer.SmartContract.Reader, as: SmartContractReader
alias Indexer.Helper
alias Indexer.Transform.Addresses
@ -112,20 +112,20 @@ defmodule Indexer.Fetcher.Zkevm.Bridge do
@doc """
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.
"""
@spec import_operations(list()) :: no_return()
def import_operations(operations) do
addresses =
Addresses.extract_addresses(%{
zkevm_bridge_operations: operations
polygon_zkevm_bridge_operations: operations
})
{:ok, _} =
Chain.import(%{
addresses: %{params: addresses, on_conflict: :nothing},
zkevm_bridge_operations: %{params: operations},
polygon_zkevm_bridge_operations: %{params: operations},
timeout: :infinity
})
end
@ -267,11 +267,11 @@ defmodule Indexer.Fetcher.Zkevm.Bridge do
{:ok, inserts} =
Chain.import(%{
zkevm_bridge_l1_tokens: %{params: tokens_to_insert},
polygon_zkevm_bridge_l1_tokens: %{params: tokens_to_insert},
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
# 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 """
Fills zkevm_bridge DB table.
Fills polygon_zkevm_bridge DB table.
"""
use GenServer
@ -11,16 +11,16 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
import Ecto.Query
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]
alias Explorer.Chain.Zkevm.{Bridge, Reader}
alias Explorer.Chain.PolygonZkevm.{Bridge, Reader}
alias Explorer.Repo
alias Indexer.Fetcher.RollupL1ReorgMonitor
alias Indexer.Helper
@eth_get_logs_range_size 1000
@fetcher_name :zkevm_bridge_l1
@fetcher_name :polygon_zkevm_bridge_l1
def child_spec(start_link_arguments) do
spec = %{
@ -100,7 +100,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
{:stop, :normal, %{}}
{: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("safe_block = #{inspect(safe_block)}")
{:stop, :normal, %{}}
@ -114,7 +114,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
{:l1_tx_not_found, true} ->
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, %{}}
@ -203,7 +203,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1 do
if deleted_count > 0 do
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

@ -1,4 +1,4 @@
defmodule Indexer.Fetcher.Zkevm.BridgeL1Tokens do
defmodule Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens do
@moduledoc """
Fetches information about L1 tokens for zkEVM bridge.
"""
@ -10,7 +10,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1Tokens do
alias Explorer.Repo
alias Indexer.{BufferedTask, Helper}
alias Indexer.Fetcher.Zkevm.{Bridge, BridgeL1}
alias Indexer.Fetcher.PolygonZkevm.{Bridge, BridgeL1}
@behaviour BufferedTask
@ -41,7 +41,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL1Tokens do
|> Bridge.token_addresses_to_ids(json_rpc_named_arguments)
|> Enum.each(fn {l1_token_address, l1_token_id} ->
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]
)
end)

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
defmodule Indexer.Fetcher.PolygonZkevm.BridgeL2 do
@moduledoc """
Fills zkevm_bridge DB table.
Fills polygon_zkevm_bridge DB table.
"""
use GenServer
@ -11,15 +11,15 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
import Ecto.Query
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]
alias Explorer.Chain.Zkevm.{Bridge, Reader}
alias Explorer.Chain.PolygonZkevm.{Bridge, Reader}
alias Explorer.Repo
alias Indexer.Helper
@eth_get_logs_range_size 1000
@fetcher_name :zkevm_bridge_l2
@fetcher_name :polygon_zkevm_bridge_l2
def child_spec(start_link_arguments) do
spec = %{
@ -55,7 +55,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
env = Application.get_all_env(:indexer)[__MODULE__]
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)},
{:bridge_contract_address_is_valid, true} <-
{:bridge_contract_address_is_valid, Helper.address_correct?(env[:bridge_contract])},
@ -93,7 +93,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
{:stop, :normal, state}
{: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}
{:error, error_data} ->
@ -105,7 +105,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
{:l2_tx_not_found, true} ->
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}
@ -169,7 +169,7 @@ defmodule Indexer.Fetcher.Zkevm.BridgeL2 do
if deleted_count > 0 do
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

@ -1,6 +1,6 @@
defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
defmodule Indexer.Fetcher.PolygonZkevm.TransactionBatch do
@moduledoc """
Fills zkevm_transaction_batches DB table.
Fills polygon_zkevm_transaction_batches DB table.
"""
use GenServer
@ -12,7 +12,7 @@ defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
alias Explorer.Chain
alias Explorer.Chain.Events.Publisher
alias Explorer.Chain.Zkevm.Reader
alias Explorer.Chain.PolygonZkevm.Reader
alias Indexer.Helper
@zero_hash "0000000000000000000000000000000000000000000000000000000000000000"
@ -34,9 +34,9 @@ defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
@impl GenServer
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]
recheck_interval = config[:recheck_interval]
@ -251,9 +251,9 @@ defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
{:ok, _} =
Chain.import(%{
zkevm_lifecycle_transactions: %{params: l1_txs_to_import},
zkevm_transaction_batches: %{params: batches_to_import},
zkevm_batch_transactions: %{params: l2_txs_to_import},
polygon_zkevm_lifecycle_transactions: %{params: l1_txs_to_import},
polygon_zkevm_transaction_batches: %{params: batches_to_import},
polygon_zkevm_batch_transactions: %{params: l2_txs_to_import},
timeout: :infinity
})

@ -34,8 +34,8 @@ defmodule Indexer.Fetcher.RollupL1ReorgMonitor do
modules_can_use_reorg_monitor = [
Indexer.Fetcher.PolygonEdge.Deposit,
Indexer.Fetcher.PolygonEdge.WithdrawalExit,
Indexer.Fetcher.Shibarium.L1,
Indexer.Fetcher.Zkevm.BridgeL1
Indexer.Fetcher.PolygonZkevm.BridgeL1,
Indexer.Fetcher.Shibarium.L1
]
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,
# 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
# 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)
l1_rpc =

@ -144,12 +144,12 @@ defmodule Indexer.Supervisor do
[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.Zkevm.BridgeL1.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.Zkevm.BridgeL1Tokens.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.Zkevm.BridgeL2.Supervisor, [
configure(Indexer.Fetcher.PolygonZkevm.BridgeL1.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.PolygonZkevm.BridgeL1Tokens.Supervisor, [[memory_monitor: memory_monitor]]),
configure(Indexer.Fetcher.PolygonZkevm.BridgeL2.Supervisor, [
[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]
]),
{Indexer.Fetcher.Beacon.Blob.Supervisor, [[memory_monitor: memory_monitor]]},

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

@ -1,14 +1,14 @@
defmodule Indexer.Transform.Zkevm.Bridge do
defmodule Indexer.Transform.PolygonZkevm.Bridge do
@moduledoc """
Helper functions for transforming data for Polygon zkEVM Bridge operations.
"""
require Logger
import Indexer.Fetcher.Zkevm.Bridge,
import Indexer.Fetcher.PolygonZkevm.Bridge,
only: [filter_bridge_events: 2, prepare_operations: 4]
alias Indexer.Fetcher.Zkevm.{BridgeL1, BridgeL2}
alias Indexer.Fetcher.PolygonZkevm.{BridgeL1, BridgeL2}
alias Indexer.Helper
@doc """
@ -17,7 +17,7 @@ defmodule Indexer.Transform.Zkevm.Bridge do
@spec parse(list(), list()) :: list()
def parse(blocks, logs) do
prev_metadata = Logger.metadata()
Logger.metadata(fetcher: :zkevm_bridge_l2_realtime)
Logger.metadata(fetcher: :polygon_zkevm_bridge_l2_realtime)
items =
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.Zkevm.BridgeL1,
config :indexer, Indexer.Fetcher.PolygonZkevm.BridgeL1,
rpc: System.get_env("INDEXER_POLYGON_ZKEVM_L1_RPC"),
start_block: System.get_env("INDEXER_POLYGON_ZKEVM_L1_BRIDGE_START_BLOCK"),
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_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.Zkevm.BridgeL1Tokens.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.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"),
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),
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:
ConfigHelper.chain_type() == "polygon_zkevm" &&
ConfigHelper.parse_bool_env_var("INDEXER_POLYGON_ZKEVM_BATCHES_ENABLED")

Loading…
Cancel
Save