Move zkevm_* files into a separate folder

pull/7584/head
POA 1 year ago
parent 126c59a30d
commit a82c8bd2a3
  1. 6
      apps/block_scout_web/lib/block_scout_web/chain.ex
  2. 14
      apps/explorer/lib/explorer/chain.ex
  3. 17
      apps/explorer/lib/explorer/chain/import/runner/zkevm/batch_transactions.ex
  4. 19
      apps/explorer/lib/explorer/chain/import/runner/zkevm/lifecycle_transactions.ex
  5. 19
      apps/explorer/lib/explorer/chain/import/runner/zkevm/transaction_batches.ex
  6. 6
      apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex
  7. 6
      apps/explorer/lib/explorer/chain/transaction.ex
  8. 9
      apps/explorer/lib/explorer/chain/zkevm/batch_transaction.ex
  9. 9
      apps/explorer/lib/explorer/chain/zkevm/lifecycle_transaction.ex
  10. 17
      apps/explorer/lib/explorer/chain/zkevm/transaction_batch.ex
  11. 12
      apps/indexer/lib/indexer/fetcher/zkevm/transaction_batch.ex
  12. 7
      apps/indexer/lib/indexer/supervisor.ex

@ -34,10 +34,10 @@ defmodule BlockScoutWeb.Chain do
Transaction,
Transaction.StateChange,
Wei,
Withdrawal,
ZkevmTransactionBatch
Withdrawal
}
alias Explorer.Chain.Zkevm.TransactionBatch
alias Explorer.PagingOptions
defimpl Poison.Encoder, for: Decimal do
@ -535,7 +535,7 @@ defmodule BlockScoutWeb.Chain do
%{"index" => index}
end
defp paging_params(%ZkevmTransactionBatch{number: number}) do
defp paging_params(%TransactionBatch{number: number}) do
%{"number" => number}
end

@ -64,11 +64,11 @@ defmodule Explorer.Chain do
TokenTransfer,
Transaction,
Wei,
Withdrawal,
ZkevmBatchTransaction,
ZkevmTransactionBatch
Withdrawal
}
alias Explorer.Chain.Zkevm.{BatchTransaction, TransactionBatch}
alias Explorer.Chain.Block.{EmissionReward, Reward}
alias Explorer.Chain.Cache.{
@ -6396,7 +6396,7 @@ defmodule Explorer.Chain do
def zkevm_batch(number, options \\ [])
def zkevm_batch(:latest, options) when is_list(options) do
ZkevmTransactionBatch
TransactionBatch
|> order_by(desc: :number)
|> limit(1)
|> select_repo(options).one()
@ -6409,7 +6409,7 @@ defmodule Explorer.Chain do
def zkevm_batch(number, options) when is_list(options) do
necessity_by_association = Keyword.get(options, :necessity_by_association, %{})
ZkevmTransactionBatch
TransactionBatch
|> where(number: ^number)
|> join_associations(necessity_by_association)
|> select_repo(options).one()
@ -6442,7 +6442,7 @@ defmodule Explorer.Chain do
necessity_by_association = Keyword.get(options, :necessity_by_association, %{})
base_query =
from(tb in ZkevmTransactionBatch,
from(tb in TransactionBatch,
order_by: [desc: tb.number]
)
@ -6465,7 +6465,7 @@ defmodule Explorer.Chain do
end
def zkevm_batch_transactions(batch_number, options \\ []) do
query = from(bts in ZkevmBatchTransaction, where: bts.batch_number == ^batch_number)
query = from(bts in BatchTransaction, where: bts.batch_number == ^batch_number)
select_repo(options).all(query)
end

@ -1,12 +1,13 @@
defmodule Explorer.Chain.Import.Runner.ZkevmBatchTransactions do
defmodule Explorer.Chain.Import.Runner.Zkevm.BatchTransactions do
@moduledoc """
Bulk imports `t:Explorer.Chain.ZkevmBatchTransaction.t/0`.
Bulk imports `t:Explorer.Chain.Zkevm.BatchTransaction.t/0`.
"""
require Ecto.Query
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.{Import, ZkevmBatchTransaction}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.BatchTransaction
alias Explorer.Prometheus.Instrumenter
@behaviour Import.Runner
@ -14,10 +15,10 @@ defmodule Explorer.Chain.Import.Runner.ZkevmBatchTransactions do
# milliseconds
@timeout 60_000
@type imported :: [ZkevmBatchTransaction.t()]
@type imported :: [BatchTransaction.t()]
@impl Import.Runner
def ecto_schema_module, do: ZkevmBatchTransaction
def ecto_schema_module, do: BatchTransaction
@impl Import.Runner
def option_key, do: :zkevm_batch_transactions
@ -53,17 +54,17 @@ defmodule Explorer.Chain.Import.Runner.ZkevmBatchTransactions do
def timeout, do: @timeout
@spec insert(Repo.t(), [map()], %{required(:timeout) => timeout(), required(:timestamps) => Import.timestamps()}) ::
{:ok, [ZkevmBatchTransaction.t()]}
{:ok, [BatchTransaction.t()]}
| {:error, [Changeset.t()]}
def insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = _options) when is_list(changes_list) do
# Enforce ZkevmBatchTransaction ShareLocks order (see docs: sharelock.md)
# Enforce Zkevm.BatchTransaction ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, & &1.hash)
{:ok, inserted} =
Import.insert_changes_list(
repo,
ordered_changes_list,
for: ZkevmBatchTransaction,
for: BatchTransaction,
returning: true,
timeout: timeout,
timestamps: timestamps,

@ -1,12 +1,13 @@
defmodule Explorer.Chain.Import.Runner.ZkevmLifecycleTransactions do
defmodule Explorer.Chain.Import.Runner.Zkevm.LifecycleTransactions do
@moduledoc """
Bulk imports `t:Explorer.Chain.ZkevmLifecycleTransaction.t/0`.
Bulk imports `t:Explorer.Chain.Zkevm.LifecycleTransaction.t/0`.
"""
require Ecto.Query
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.{Import, ZkevmLifecycleTransaction}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.LifecycleTransaction
alias Explorer.Prometheus.Instrumenter
import Ecto.Query, only: [from: 2]
@ -16,10 +17,10 @@ defmodule Explorer.Chain.Import.Runner.ZkevmLifecycleTransactions do
# milliseconds
@timeout 60_000
@type imported :: [ZkevmLifecycleTransaction.t()]
@type imported :: [LifecycleTransaction.t()]
@impl Import.Runner
def ecto_schema_module, do: ZkevmLifecycleTransaction
def ecto_schema_module, do: LifecycleTransaction
@impl Import.Runner
def option_key, do: :zkevm_lifecycle_transactions
@ -55,19 +56,19 @@ defmodule Explorer.Chain.Import.Runner.ZkevmLifecycleTransactions do
def timeout, do: @timeout
@spec insert(Repo.t(), [map()], %{required(:timeout) => timeout(), required(:timestamps) => Import.timestamps()}) ::
{:ok, [ZkevmLifecycleTransaction.t()]}
{:ok, [LifecycleTransaction.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 ZkevmLifecycleTransaction ShareLocks order (see docs: sharelock.md)
# Enforce Zkevm.LifecycleTransaction ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, & &1.id)
{:ok, inserted} =
Import.insert_changes_list(
repo,
ordered_changes_list,
for: ZkevmLifecycleTransaction,
for: LifecycleTransaction,
returning: true,
timeout: timeout,
timestamps: timestamps,
@ -80,7 +81,7 @@ defmodule Explorer.Chain.Import.Runner.ZkevmLifecycleTransactions do
defp default_on_conflict do
from(
tx in ZkevmLifecycleTransaction,
tx in LifecycleTransaction,
update: [
set: [
# don't update `id` as it is a primary key

@ -1,12 +1,13 @@
defmodule Explorer.Chain.Import.Runner.ZkevmTransactionBatches do
defmodule Explorer.Chain.Import.Runner.Zkevm.TransactionBatches do
@moduledoc """
Bulk imports `t:Explorer.Chain.ZkevmTransactionBatch.t/0`.
Bulk imports `t:Explorer.Chain.Zkevm.TransactionBatch.t/0`.
"""
require Ecto.Query
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.{Import, ZkevmTransactionBatch}
alias Explorer.Chain.Import
alias Explorer.Chain.Zkevm.TransactionBatch
alias Explorer.Prometheus.Instrumenter
import Ecto.Query, only: [from: 2]
@ -16,10 +17,10 @@ defmodule Explorer.Chain.Import.Runner.ZkevmTransactionBatches do
# milliseconds
@timeout 60_000
@type imported :: [ZkevmTransactionBatch.t()]
@type imported :: [TransactionBatch.t()]
@impl Import.Runner
def ecto_schema_module, do: ZkevmTransactionBatch
def ecto_schema_module, do: TransactionBatch
@impl Import.Runner
def option_key, do: :zkevm_transaction_batches
@ -55,19 +56,19 @@ defmodule Explorer.Chain.Import.Runner.ZkevmTransactionBatches do
def timeout, do: @timeout
@spec insert(Repo.t(), [map()], %{required(:timeout) => timeout(), required(:timestamps) => Import.timestamps()}) ::
{:ok, [ZkevmTransactionBatch.t()]}
{:ok, [TransactionBatch.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 ZkevmTransactionBatch ShareLocks order (see docs: sharelock.md)
# Enforce Zkevm.TransactionBatch ShareLocks order (see docs: sharelock.md)
ordered_changes_list = Enum.sort_by(changes_list, & &1.number)
{:ok, inserted} =
Import.insert_changes_list(
repo,
ordered_changes_list,
for: ZkevmTransactionBatch,
for: TransactionBatch,
returning: true,
timeout: timeout,
timestamps: timestamps,
@ -80,7 +81,7 @@ defmodule Explorer.Chain.Import.Runner.ZkevmTransactionBatches do
defp default_on_conflict do
from(
tb in ZkevmTransactionBatch,
tb in TransactionBatch,
update: [
set: [
# don't update `number` as it is a primary key and used for the conflict target

@ -33,9 +33,9 @@ defmodule Explorer.Chain.Import.Stage.BlockReferencing do
"polygon_zkevm" ->
@default_runners ++
[
Runner.ZkevmLifecycleTransactions,
Runner.ZkevmTransactionBatches,
Runner.ZkevmBatchTransactions
Runner.Zkevm.LifecycleTransactions,
Runner.Zkevm.TransactionBatches,
Runner.Zkevm.BatchTransactions
]
_ -> @default_runners
end

@ -27,11 +27,11 @@ defmodule Explorer.Chain.Transaction do
TokenTransfer,
Transaction,
TransactionAction,
Wei,
ZkevmBatchTransaction
Wei
}
alias Explorer.Chain.Transaction.{Fork, Status}
alias Explorer.Chain.Zkevm.BatchTransaction
alias Explorer.SmartContract.SigProviderInterface
@optional_attrs ~w(max_priority_fee_per_gas max_fee_per_gas block_hash block_number created_contract_address_hash cumulative_gas_used earliest_processing_start
@ -276,7 +276,7 @@ defmodule Explorer.Chain.Transaction do
has_many(:uncles, through: [:forks, :uncle])
has_one(:zkevm_batch_transaction, ZkevmBatchTransaction, foreign_key: :hash)
has_one(:zkevm_batch_transaction, BatchTransaction, foreign_key: :hash)
has_one(:zkevm_batch, through: [:zkevm_batch_transaction, :batch])
has_one(:zkevm_sequence_txn, through: [:zkevm_batch, :sequence_transaction])
has_one(:zkevm_verify_txn, through: [:zkevm_batch, :verify_transaction])

@ -1,22 +1,23 @@
defmodule Explorer.Chain.ZkevmBatchTransaction do
defmodule Explorer.Chain.Zkevm.BatchTransaction do
@moduledoc "Models a list of transactions related to a batch for zkEVM."
use Explorer.Schema
alias Explorer.Chain.{Hash, Transaction, ZkevmTransactionBatch}
alias Explorer.Chain.{Hash, Transaction}
alias Explorer.Chain.Zkevm.TransactionBatch
@required_attrs ~w(batch_number hash)a
@type t :: %__MODULE__{
batch_number: non_neg_integer(),
batch: %Ecto.Association.NotLoaded{} | ZkevmTransactionBatch.t() | nil,
batch: %Ecto.Association.NotLoaded{} | TransactionBatch.t() | nil,
hash: Hash.t(),
l2_transaction: %Ecto.Association.NotLoaded{} | Transaction.t() | nil
}
@primary_key false
schema "zkevm_batch_l2_transactions" do
belongs_to(:batch, ZkevmTransactionBatch, foreign_key: :batch_number, references: :number, type: :integer)
belongs_to(:batch, TransactionBatch, foreign_key: :batch_number, references: :number, type: :integer)
belongs_to(:l2_transaction, Transaction, foreign_key: :hash, primary_key: true, references: :hash, type: Hash.Full)
timestamps()

@ -1,9 +1,10 @@
defmodule Explorer.Chain.ZkevmLifecycleTransaction do
defmodule Explorer.Chain.Zkevm.LifecycleTransaction do
@moduledoc "Models an L1 lifecycle transaction for zkEVM."
use Explorer.Schema
alias Explorer.Chain.{Hash, ZkevmTransactionBatch}
alias Explorer.Chain.Hash
alias Explorer.Chain.Zkevm.TransactionBatch
@required_attrs ~w(id hash is_verify)a
@ -17,8 +18,8 @@ defmodule Explorer.Chain.ZkevmLifecycleTransaction do
field(:hash, Hash.Full)
field(:is_verify, :boolean)
has_many(:sequenced_batches, ZkevmTransactionBatch, foreign_key: :sequence_id)
has_many(:verified_batches, ZkevmTransactionBatch, foreign_key: :verify_id)
has_many(:sequenced_batches, TransactionBatch, foreign_key: :sequence_id)
has_many(:verified_batches, TransactionBatch, foreign_key: :verify_id)
timestamps()
end

@ -1,9 +1,10 @@
defmodule Explorer.Chain.ZkevmTransactionBatch do
defmodule Explorer.Chain.Zkevm.TransactionBatch do
@moduledoc "Models a batch of transactions for zkEVM."
use Explorer.Schema
alias Explorer.Chain.{Hash, ZkevmBatchTransaction, ZkevmLifecycleTransaction}
alias Explorer.Chain.Hash
alias Explorer.Chain.Zkevm.{BatchTransaction, LifecycleTransaction}
@optional_attrs ~w(sequence_id verify_id)a
@ -17,10 +18,10 @@ defmodule Explorer.Chain.ZkevmTransactionBatch do
acc_input_hash: Hash.t(),
state_root: Hash.t(),
sequence_id: non_neg_integer() | nil,
sequence_transaction: %Ecto.Association.NotLoaded{} | ZkevmLifecycleTransaction.t() | nil,
sequence_transaction: %Ecto.Association.NotLoaded{} | LifecycleTransaction.t() | nil,
verify_id: non_neg_integer() | nil,
verify_transaction: %Ecto.Association.NotLoaded{} | ZkevmLifecycleTransaction.t() | nil,
l2_transactions: %Ecto.Association.NotLoaded{} | [ZkevmBatchTransaction.t()]
verify_transaction: %Ecto.Association.NotLoaded{} | LifecycleTransaction.t() | nil,
l2_transactions: %Ecto.Association.NotLoaded{} | [BatchTransaction.t()]
}
@primary_key {:number, :integer, autogenerate: false}
@ -31,15 +32,15 @@ defmodule Explorer.Chain.ZkevmTransactionBatch do
field(:acc_input_hash, Hash.Full)
field(:state_root, Hash.Full)
belongs_to(:sequence_transaction, ZkevmLifecycleTransaction,
belongs_to(:sequence_transaction, LifecycleTransaction,
foreign_key: :sequence_id,
references: :id,
type: :integer
)
belongs_to(:verify_transaction, ZkevmLifecycleTransaction, foreign_key: :verify_id, references: :id, type: :integer)
belongs_to(:verify_transaction, LifecycleTransaction, foreign_key: :verify_id, references: :id, type: :integer)
has_many(:l2_transactions, ZkevmBatchTransaction, foreign_key: :batch_number)
has_many(:l2_transactions, BatchTransaction, foreign_key: :batch_number)
timestamps()
end

@ -1,4 +1,4 @@
defmodule Indexer.Fetcher.ZkevmTransactionBatch do
defmodule Indexer.Fetcher.Zkevm.TransactionBatch do
@moduledoc """
Fills zkevm_transaction_batches DB table.
"""
@ -13,7 +13,7 @@ defmodule Indexer.Fetcher.ZkevmTransactionBatch do
import EthereumJSONRPC, only: [integer_to_quantity: 1, json_rpc: 2, quantity_to_integer: 1]
alias Explorer.{Chain, Repo}
alias Explorer.Chain.{ZkevmLifecycleTransaction, ZkevmTransactionBatch}
alias Explorer.Chain.Zkevm.{LifecycleTransaction, TransactionBatch}
@zero_hash "0000000000000000000000000000000000000000000000000000000000000000"
@ -36,7 +36,7 @@ defmodule Indexer.Fetcher.ZkevmTransactionBatch do
def init(args) do
Logger.metadata(fetcher: :zkevm_transaction_batches)
config = Application.get_all_env(:indexer)[Indexer.Fetcher.ZkevmTransactionBatch]
config = Application.get_all_env(:indexer)[Indexer.Fetcher.Zkevm.TransactionBatch]
chunk_size = config[:chunk_size]
recheck_interval = config[:recheck_interval]
@ -113,7 +113,7 @@ defmodule Indexer.Fetcher.ZkevmTransactionBatch do
defp get_last_verified_batch_number do
query =
from(tb in ZkevmTransactionBatch,
from(tb in TransactionBatch,
select: tb.number,
where: not is_nil(tb.verify_id),
order_by: [desc: tb.number],
@ -127,7 +127,7 @@ defmodule Indexer.Fetcher.ZkevmTransactionBatch do
defp get_next_id do
query =
from(lt in ZkevmLifecycleTransaction,
from(lt in LifecycleTransaction,
select: lt.id,
order_by: [desc: lt.id],
limit: 1
@ -228,7 +228,7 @@ defmodule Indexer.Fetcher.ZkevmTransactionBatch do
query =
from(
lt in ZkevmLifecycleTransaction,
lt in LifecycleTransaction,
select: {lt.hash, lt.id},
where: lt.hash in ^l1_tx_hashes
)

@ -34,10 +34,11 @@ defmodule Indexer.Supervisor do
TokenUpdater,
TransactionAction,
UncleBlock,
Withdrawal,
ZkevmTransactionBatch
Withdrawal
}
alias Indexer.Fetcher.Zkevm.TransactionBatch
alias Indexer.Temporary.{
BlocksTransactionsMismatch,
UncatalogedTokenTransfers,
@ -133,7 +134,7 @@ defmodule Indexer.Supervisor do
{Indexer.Fetcher.PolygonEdge.Withdrawal.Supervisor,
[[memory_monitor: memory_monitor, json_rpc_named_arguments: json_rpc_named_arguments]]},
{Indexer.Fetcher.PolygonEdge.WithdrawalExit.Supervisor, [[memory_monitor: memory_monitor]]},
configure(ZkevmTransactionBatch.Supervisor, [
configure(TransactionBatch.Supervisor, [
[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]
]),

Loading…
Cancel
Save