fix: Sanitize replaced transactions migration (#10784)

np-fix-forever-pending-verification
Qwerty5Uiop 2 months ago committed by GitHub
parent fae80f7501
commit 23b994dbc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      apps/explorer/config/config.exs
  2. 1
      apps/explorer/config/runtime/test.exs
  3. 3
      apps/explorer/lib/explorer/application.ex
  4. 46
      apps/explorer/lib/explorer/migrator/sanitize_replaced_transactions.ex

@ -129,6 +129,7 @@ config :explorer, Explorer.Migrator.TransactionBlockConsensus, enabled: true
config :explorer, Explorer.Migrator.TokenTransferBlockConsensus, enabled: true
config :explorer, Explorer.Migrator.RestoreOmittedWETHTransfers, enabled: true
config :explorer, Explorer.Migrator.SanitizeMissingTokenBalances, enabled: true
config :explorer, Explorer.Migrator.SanitizeReplacedTransactions, enabled: true
config :explorer, Explorer.Chain.Fetcher.CheckBytecodeMatchingOnDemand, enabled: true

@ -50,6 +50,7 @@ config :explorer, Explorer.Migrator.TokenTransferBlockConsensus, enabled: false
config :explorer, Explorer.Migrator.ShrinkInternalTransactions, enabled: false
config :explorer, Explorer.Migrator.RestoreOmittedWETHTransfers, enabled: false
config :explorer, Explorer.Migrator.SanitizeMissingTokenBalances, enabled: false
config :explorer, Explorer.Migrator.SanitizeReplacedTransactions, enabled: false
config :explorer,
realtime_events_sender: Explorer.Chain.Events.SimpleSender

@ -146,7 +146,8 @@ defmodule Explorer.Application do
configure_mode_dependent_process(Explorer.Migrator.ShrinkInternalTransactions, :indexer),
configure_chain_type_dependent_process(Explorer.Chain.Cache.BlackfortValidatorsCounters, :blackfort),
configure_chain_type_dependent_process(Explorer.Chain.Cache.StabilityValidatorsCounters, :stability),
configure_mode_dependent_process(Explorer.Migrator.SanitizeMissingTokenBalances, :indexer)
configure_mode_dependent_process(Explorer.Migrator.SanitizeMissingTokenBalances, :indexer),
configure_mode_dependent_process(Explorer.Migrator.SanitizeReplacedTransactions, :indexer)
]
|> List.flatten()

@ -0,0 +1,46 @@
defmodule Explorer.Migrator.SanitizeReplacedTransactions do
@moduledoc """
Cleans the transactions that are related to non-consensus blocks.
"""
use Explorer.Migrator.FillingMigration
import Ecto.Query
alias Explorer.Chain.Transaction
alias Explorer.Migrator.FillingMigration
alias Explorer.Repo
@migration_name "sanitize_replaced_transactions"
@impl FillingMigration
def migration_name, do: @migration_name
@impl FillingMigration
def last_unprocessed_identifiers(state) do
limit = batch_size() * concurrency()
ids =
unprocessed_data_query()
|> select([t], t.hash)
|> limit(^limit)
|> Repo.all(timeout: :infinity)
{ids, state}
end
@impl FillingMigration
def unprocessed_data_query do
from(t in Transaction, where: t.block_consensus == false)
end
@impl FillingMigration
def update_batch(transaction_hashes) do
query = from(t in Transaction, where: t.hash in ^transaction_hashes)
Repo.delete_all(query, timeout: :infinity)
end
@impl FillingMigration
def update_cache, do: :ok
end
Loading…
Cancel
Save