From d8fd9b2d20bf2a6813ca94223b12ebea9d11ca73 Mon Sep 17 00:00:00 2001 From: POA <33550681+poa@users.noreply.github.com> Date: Wed, 14 Feb 2024 13:51:14 +0300 Subject: [PATCH] Rename Zkevm to PolygonZkevm --- .../lib/block_scout_web/api_router.ex | 20 +++++++------- .../lib/block_scout_web/chain.ex | 2 +- ... polygon_zkevm_confirmed_batch_channel.ex} | 6 ++--- .../channels/user_socket_v2.ex | 2 +- ...troller.ex => polygon_zkevm_controller.ex} | 4 +-- .../api/v2/transaction_controller.ex | 6 ++--- .../{zkevm_view.ex => polygon_zkevm_view.ex} | 4 +-- apps/block_scout_web/mix.exs | 2 +- .../batch_transactions.ex | 16 ++++++------ .../bridge_l1_tokens.ex | 14 +++++----- .../bridge_operations.ex | 26 +++++++++---------- .../lifecycle_transactions.ex | 16 ++++++------ .../transaction_batches.ex | 16 ++++++------ .../chain/import/stage/block_referencing.ex | 10 +++---- .../batch_transaction.ex | 6 ++--- .../chain/{zkevm => polygon_zkevm}/bridge.ex | 6 ++--- .../bridge_l1_token.ex | 4 +-- .../lifecycle_transaction.ex | 6 ++--- .../chain/{zkevm => polygon_zkevm}/reader.ex | 24 ++++++++--------- .../transaction_batch.ex | 6 ++--- .../lib/explorer/chain/transaction.ex | 2 +- .../20231010093238_add_bridge_tables.exs | 20 ++++++++------ apps/indexer/lib/indexer/block/fetcher.ex | 26 +++++++++---------- .../lib/indexer/block/realtime/fetcher.ex | 10 +++---- .../{zkevm => polygon_zkevm}/bridge.ex | 16 ++++++------ .../{zkevm => polygon_zkevm}/bridge_l1.ex | 16 ++++++------ .../bridge_l1_tokens.ex | 6 ++--- .../{zkevm => polygon_zkevm}/bridge_l2.ex | 18 ++++++------- .../transaction_batch.ex | 16 ++++++------ .../fetcher/rollup_l1_reorg_monitor.ex | 6 ++--- apps/indexer/lib/indexer/supervisor.ex | 8 +++--- .../lib/indexer/transform/addresses.ex | 4 +-- .../{zkevm => polygon_zkevm}/bridge.ex | 8 +++--- config/runtime.exs | 16 +++++++----- 34 files changed, 187 insertions(+), 181 deletions(-) rename apps/block_scout_web/lib/block_scout_web/channels/{zkevm_confirmed_batch_channel.ex => polygon_zkevm_confirmed_batch_channel.ex} (73%) rename apps/block_scout_web/lib/block_scout_web/controllers/api/v2/{zkevm_controller.ex => polygon_zkevm_controller.ex} (97%) rename apps/block_scout_web/lib/block_scout_web/views/api/v2/{zkevm_view.ex => polygon_zkevm_view.ex} (97%) rename apps/explorer/lib/explorer/chain/import/runner/{zkevm => polygon_zkevm}/batch_transactions.ex (79%) rename apps/explorer/lib/explorer/chain/import/runner/{zkevm => polygon_zkevm}/bridge_l1_tokens.ex (86%) rename apps/explorer/lib/explorer/chain/import/runner/{zkevm => polygon_zkevm}/bridge_operations.ex (83%) rename apps/explorer/lib/explorer/chain/import/runner/{zkevm => polygon_zkevm}/lifecycle_transactions.ex (83%) rename apps/explorer/lib/explorer/chain/import/runner/{zkevm => polygon_zkevm}/transaction_batches.ex (86%) rename apps/explorer/lib/explorer/chain/{zkevm => polygon_zkevm}/batch_transaction.ex (84%) rename apps/explorer/lib/explorer/chain/{zkevm => polygon_zkevm}/bridge.ex (93%) rename apps/explorer/lib/explorer/chain/{zkevm => polygon_zkevm}/bridge_l1_token.ex (89%) rename apps/explorer/lib/explorer/chain/{zkevm => polygon_zkevm}/lifecycle_transaction.ex (82%) rename apps/explorer/lib/explorer/chain/{zkevm => polygon_zkevm}/reader.ex (90%) rename apps/explorer/lib/explorer/chain/{zkevm => polygon_zkevm}/transaction_batch.ex (87%) rename apps/indexer/lib/indexer/fetcher/{zkevm => polygon_zkevm}/bridge.ex (96%) rename apps/indexer/lib/indexer/fetcher/{zkevm => polygon_zkevm}/bridge_l1.ex (93%) rename apps/indexer/lib/indexer/fetcher/{zkevm => polygon_zkevm}/bridge_l1_tokens.ex (90%) rename apps/indexer/lib/indexer/fetcher/{zkevm => polygon_zkevm}/bridge_l2.ex (91%) rename apps/indexer/lib/indexer/fetcher/{zkevm => polygon_zkevm}/transaction_batch.ex (95%) rename apps/indexer/lib/indexer/transform/{zkevm => polygon_zkevm}/bridge.ex (91%) diff --git a/apps/block_scout_web/lib/block_scout_web/api_router.ex b/apps/block_scout_web/lib/block_scout_web/api_router.ex index 1116688a64..467793c43c 100644 --- a/apps/block_scout_web/lib/block_scout_web/api_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/api_router.ex @@ -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 diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index 2ca9300676..5dff1d691b 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -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 diff --git a/apps/block_scout_web/lib/block_scout_web/channels/zkevm_confirmed_batch_channel.ex b/apps/block_scout_web/lib/block_scout_web/channels/polygon_zkevm_confirmed_batch_channel.ex similarity index 73% rename from apps/block_scout_web/lib/block_scout_web/channels/zkevm_confirmed_batch_channel.ex rename to apps/block_scout_web/lib/block_scout_web/channels/polygon_zkevm_confirmed_batch_channel.ex index 9007f11764..0b80fb5358 100644 --- a/apps/block_scout_web/lib/block_scout_web/channels/zkevm_confirmed_batch_channel.ex +++ b/apps/block_scout_web/lib/block_scout_web/channels/polygon_zkevm_confirmed_batch_channel.ex @@ -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 diff --git a/apps/block_scout_web/lib/block_scout_web/channels/user_socket_v2.ex b/apps/block_scout_web/lib/block_scout_web/channels/user_socket_v2.ex index 159993433e..ec3e5460ec 100644 --- a/apps/block_scout_web/lib/block_scout_web/channels/user_socket_v2.ex +++ b/apps/block_scout_web/lib/block_scout_web/channels/user_socket_v2.ex @@ -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} diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/polygon_zkevm_controller.ex similarity index 97% rename from apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex rename to apps/block_scout_web/lib/block_scout_web/controllers/api/v2/polygon_zkevm_controller.ex index 961933de88..e01b9a7caf 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/zkevm_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/polygon_zkevm_controller.ex @@ -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) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex index 8b19b18011..a850ed2c42 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex @@ -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) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/polygon_zkevm_view.ex similarity index 97% rename from apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex rename to apps/block_scout_web/lib/block_scout_web/views/api/v2/polygon_zkevm_view.ex index e46af83bbc..1f99d6e574 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/zkevm_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/polygon_zkevm_view.ex @@ -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: diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs index 1f8961202c..5f364a4b16 100644 --- a/apps/block_scout_web/mix.exs +++ b/apps/block_scout_web/mix.exs @@ -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 diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/batch_transactions.ex similarity index 79% rename from apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex rename to apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/batch_transactions.ex index 2df1223945..c330da10e6 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/batch_transactions.ex @@ -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} = diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/bridge_l1_tokens.ex b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_l1_tokens.ex similarity index 86% rename from apps/explorer/lib/explorer/chain/import/runner/zkevm/bridge_l1_tokens.ex rename to apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_l1_tokens.ex index 5cb7e5624b..03ed1bd578 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/bridge_l1_tokens.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_l1_tokens.ex @@ -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 diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/bridge_operations.ex b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_operations.ex similarity index 83% rename from apps/explorer/lib/explorer/chain/import/runner/zkevm/bridge_operations.ex rename to apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_operations.ex index c7aaef5cb0..6cd724fe70 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/bridge_operations.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/bridge_operations.ex @@ -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 diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/lifecycle_transactions.ex similarity index 83% rename from apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex rename to apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/lifecycle_transactions.ex index 7a5e4c1327..3b12c4cd19 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/lifecycle_transactions.ex @@ -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} = diff --git a/apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/transaction_batches.ex similarity index 86% rename from apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex rename to apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/transaction_batches.ex index db9f2771ea..e2b8930b18 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/polygon_zkevm/transaction_batches.ex @@ -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} = diff --git a/apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex b/apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex index 4baec4a082..f85e48a64f 100644 --- a/apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex +++ b/apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex @@ -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 [ diff --git a/apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex b/apps/explorer/lib/explorer/chain/polygon_zkevm/batch_transaction.ex similarity index 84% rename from apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex rename to apps/explorer/lib/explorer/chain/polygon_zkevm/batch_transaction.ex index c60c7ab07b..18d8a775a1 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex +++ b/apps/explorer/lib/explorer/chain/polygon_zkevm/batch_transaction.ex @@ -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, diff --git a/apps/explorer/lib/explorer/chain/zkevm/bridge.ex b/apps/explorer/lib/explorer/chain/polygon_zkevm/bridge.ex similarity index 93% rename from apps/explorer/lib/explorer/chain/zkevm/bridge.ex rename to apps/explorer/lib/explorer/chain/polygon_zkevm/bridge.ex index 7a725275cb..c0623f8fbf 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/bridge.ex +++ b/apps/explorer/lib/explorer/chain/polygon_zkevm/bridge.ex @@ -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) diff --git a/apps/explorer/lib/explorer/chain/zkevm/bridge_l1_token.ex b/apps/explorer/lib/explorer/chain/polygon_zkevm/bridge_l1_token.ex similarity index 89% rename from apps/explorer/lib/explorer/chain/zkevm/bridge_l1_token.ex rename to apps/explorer/lib/explorer/chain/polygon_zkevm/bridge_l1_token.ex index d54951eb3f..c3187c28ea 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/bridge_l1_token.ex +++ b/apps/explorer/lib/explorer/chain/polygon_zkevm/bridge_l1_token.ex @@ -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) diff --git a/apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex b/apps/explorer/lib/explorer/chain/polygon_zkevm/lifecycle_transaction.ex similarity index 82% rename from apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex rename to apps/explorer/lib/explorer/chain/polygon_zkevm/lifecycle_transaction.ex index 4e238dba96..504cdce416 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex +++ b/apps/explorer/lib/explorer/chain/polygon_zkevm/lifecycle_transaction.ex @@ -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) diff --git a/apps/explorer/lib/explorer/chain/zkevm/reader.ex b/apps/explorer/lib/explorer/chain/polygon_zkevm/reader.ex similarity index 90% rename from apps/explorer/lib/explorer/chain/zkevm/reader.ex rename to apps/explorer/lib/explorer/chain/polygon_zkevm/reader.ex index 6118ca4820..60a8d2b8ed 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/reader.ex +++ b/apps/explorer/lib/explorer/chain/polygon_zkevm/reader.ex @@ -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() diff --git a/apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex b/apps/explorer/lib/explorer/chain/polygon_zkevm/transaction_batch.ex similarity index 87% rename from apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex rename to apps/explorer/lib/explorer/chain/polygon_zkevm/transaction_batch.ex index 34c2bdbbab..b602ff0922 100644 --- a/apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex +++ b/apps/explorer/lib/explorer/chain/polygon_zkevm/transaction_batch.ex @@ -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) diff --git a/apps/explorer/lib/explorer/chain/transaction.ex b/apps/explorer/lib/explorer/chain/transaction.ex index d5341e33b4..752b7e56d7 100644 --- a/apps/explorer/lib/explorer/chain/transaction.ex +++ b/apps/explorer/lib/explorer/chain/transaction.ex @@ -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" -> diff --git a/apps/explorer/priv/polygon_zkevm/migrations/20231010093238_add_bridge_tables.exs b/apps/explorer/priv/polygon_zkevm/migrations/20231010093238_add_bridge_tables.exs index 1eca46f86d..805acd4d6a 100644 --- a/apps/explorer/priv/polygon_zkevm/migrations/20231010093238_add_bridge_tables.exs +++ b/apps/explorer/priv/polygon_zkevm/migrations/20231010093238_add_bridge_tables.exs @@ -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 diff --git a/apps/indexer/lib/indexer/block/fetcher.ex b/apps/indexer/lib/indexer/block/fetcher.ex index 65caef9a4d..e85531e04e 100644 --- a/apps/indexer/lib/indexer/block/fetcher.ex +++ b/apps/indexer/lib/indexer/block/fetcher.ex @@ -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) diff --git a/apps/indexer/lib/indexer/block/realtime/fetcher.ex b/apps/indexer/lib/indexer/block/realtime/fetcher.ex index 13a44e75bb..cb49b55d90 100644 --- a/apps/indexer/lib/indexer/block/realtime/fetcher.ex +++ b/apps/indexer/lib/indexer/block/realtime/fetcher.ex @@ -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( diff --git a/apps/indexer/lib/indexer/fetcher/zkevm/bridge.ex b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge.ex similarity index 96% rename from apps/indexer/lib/indexer/fetcher/zkevm/bridge.ex rename to apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge.ex index fdf3425823..b38807a5d5 100644 --- a/apps/indexer/lib/indexer/fetcher/zkevm/bridge.ex +++ b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge.ex @@ -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). diff --git a/apps/indexer/lib/indexer/fetcher/zkevm/bridge_l1.ex b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1.ex similarity index 93% rename from apps/indexer/lib/indexer/fetcher/zkevm/bridge_l1.ex rename to apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1.ex index c0411c0dcd..cd7fe24344 100644 --- a/apps/indexer/lib/indexer/fetcher/zkevm/bridge_l1.ex +++ b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1.ex @@ -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 diff --git a/apps/indexer/lib/indexer/fetcher/zkevm/bridge_l1_tokens.ex b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1_tokens.ex similarity index 90% rename from apps/indexer/lib/indexer/fetcher/zkevm/bridge_l1_tokens.ex rename to apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1_tokens.ex index 59e6f98908..034298174f 100644 --- a/apps/indexer/lib/indexer/fetcher/zkevm/bridge_l1_tokens.ex +++ b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l1_tokens.ex @@ -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) diff --git a/apps/indexer/lib/indexer/fetcher/zkevm/bridge_l2.ex b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l2.ex similarity index 91% rename from apps/indexer/lib/indexer/fetcher/zkevm/bridge_l2.ex rename to apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l2.ex index c469602be1..f8d7695cd9 100644 --- a/apps/indexer/lib/indexer/fetcher/zkevm/bridge_l2.ex +++ b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/bridge_l2.ex @@ -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 diff --git a/apps/indexer/lib/indexer/fetcher/zkevm/transaction_batch.ex b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/transaction_batch.ex similarity index 95% rename from apps/indexer/lib/indexer/fetcher/zkevm/transaction_batch.ex rename to apps/indexer/lib/indexer/fetcher/polygon_zkevm/transaction_batch.ex index 40115826da..278682628f 100644 --- a/apps/indexer/lib/indexer/fetcher/zkevm/transaction_batch.ex +++ b/apps/indexer/lib/indexer/fetcher/polygon_zkevm/transaction_batch.ex @@ -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 }) diff --git a/apps/indexer/lib/indexer/fetcher/rollup_l1_reorg_monitor.ex b/apps/indexer/lib/indexer/fetcher/rollup_l1_reorg_monitor.ex index 6499ccab1e..b9a5e8e4ec 100644 --- a/apps/indexer/lib/indexer/fetcher/rollup_l1_reorg_monitor.ex +++ b/apps/indexer/lib/indexer/fetcher/rollup_l1_reorg_monitor.ex @@ -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 = diff --git a/apps/indexer/lib/indexer/supervisor.ex b/apps/indexer/lib/indexer/supervisor.ex index d8f32eed81..0c338fdecc 100644 --- a/apps/indexer/lib/indexer/supervisor.ex +++ b/apps/indexer/lib/indexer/supervisor.ex @@ -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]]}, diff --git a/apps/indexer/lib/indexer/transform/addresses.ex b/apps/indexer/lib/indexer/transform/addresses.ex index aae8fbbb8d..543352d123 100644 --- a/apps/indexer/lib/indexer/transform/addresses.ex +++ b/apps/indexer/lib/indexer/transform/addresses.ex @@ -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() } diff --git a/apps/indexer/lib/indexer/transform/zkevm/bridge.ex b/apps/indexer/lib/indexer/transform/polygon_zkevm/bridge.ex similarity index 91% rename from apps/indexer/lib/indexer/transform/zkevm/bridge.ex rename to apps/indexer/lib/indexer/transform/polygon_zkevm/bridge.ex index 2d23fcb2e0..441e6950d1 100644 --- a/apps/indexer/lib/indexer/transform/zkevm/bridge.ex +++ b/apps/indexer/lib/indexer/transform/polygon_zkevm/bridge.ex @@ -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]), diff --git a/config/runtime.exs b/config/runtime.exs index 78b5e3f782..89271ad44e 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -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")