|
|
|
@ -311,7 +311,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
from( |
|
|
|
|
t in Transaction, |
|
|
|
|
where: t.block_hash in ^pending_block_hashes, |
|
|
|
|
select: map(t, [:hash, :block_hash, :block_number, :cumulative_gas_used]), |
|
|
|
|
select: map(t, [:hash, :block_hash, :block_number, :cumulative_gas_used, :status]), |
|
|
|
|
# Enforce Transaction ShareLocks order (see docs: sharelocks.md) |
|
|
|
|
order_by: [asc: t.hash], |
|
|
|
|
lock: "FOR NO KEY UPDATE" |
|
|
|
@ -514,6 +514,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
timeout, |
|
|
|
|
timestamps, |
|
|
|
|
first_trace, |
|
|
|
|
transaction_from_db, |
|
|
|
|
transaction_receipt_from_node |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -525,7 +526,8 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
transaction_hashes_iterator, |
|
|
|
|
timeout, |
|
|
|
|
timestamps, |
|
|
|
|
first_trace |
|
|
|
|
first_trace, |
|
|
|
|
transaction_from_db |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
true -> |
|
|
|
@ -539,6 +541,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
timeout, |
|
|
|
|
timestamps, |
|
|
|
|
first_trace, |
|
|
|
|
transaction_from_db, |
|
|
|
|
transaction_receipt_from_node |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
@ -579,6 +582,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# credo:disable-for-next-line |
|
|
|
|
defp update_transactions_inner( |
|
|
|
|
repo, |
|
|
|
|
valid_internal_transactions, |
|
|
|
@ -587,6 +591,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
timeout, |
|
|
|
|
timestamps, |
|
|
|
|
first_trace, |
|
|
|
|
transaction_from_db, |
|
|
|
|
transaction_receipt_from_node \\ nil |
|
|
|
|
) do |
|
|
|
|
valid_internal_transactions_count = Enum.count(valid_internal_transactions) |
|
|
|
@ -595,6 +600,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
set = |
|
|
|
|
generate_transaction_set_to_update( |
|
|
|
|
first_trace, |
|
|
|
|
transaction_from_db, |
|
|
|
|
transaction_receipt_from_node, |
|
|
|
|
timestamps, |
|
|
|
|
txs_with_error_in_internal_txs |
|
|
|
@ -628,19 +634,20 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
|
|
|
|
|
def generate_transaction_set_to_update( |
|
|
|
|
first_trace, |
|
|
|
|
transaction_from_db, |
|
|
|
|
transaction_receipt_from_node, |
|
|
|
|
timestamps, |
|
|
|
|
txs_with_error_in_internal_txs |
|
|
|
|
) do |
|
|
|
|
default_set = [ |
|
|
|
|
created_contract_address_hash: first_trace.created_contract_address_hash, |
|
|
|
|
error: first_trace.error, |
|
|
|
|
status: first_trace.status, |
|
|
|
|
updated_at: timestamps.updated_at |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
set = |
|
|
|
|
default_set |
|
|
|
|
|> put_status_in_update_set(first_trace, transaction_from_db) |
|
|
|
|
|> put_error_in_update_set(first_trace, transaction_from_db, transaction_receipt_from_node) |
|
|
|
|
|> Keyword.put_new(:block_hash, first_trace.block_hash) |
|
|
|
|
|> Keyword.put_new(:block_number, first_trace.block_number) |
|
|
|
|
|> Keyword.put_new(:index, transaction_receipt_from_node && transaction_receipt_from_node.transaction_index) |
|
|
|
@ -665,6 +672,24 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |
|
|
|
|
filtered_set |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp put_status_in_update_set(update_set, first_trace, %{status: nil}), |
|
|
|
|
do: Keyword.put_new(update_set, :status, first_trace.status) |
|
|
|
|
|
|
|
|
|
defp put_status_in_update_set(update_set, _first_trace, _transaction_from_db), do: update_set |
|
|
|
|
|
|
|
|
|
defp put_error_in_update_set(update_set, first_trace, _transaction_from_db, %{status: :error}), |
|
|
|
|
do: Keyword.put_new(update_set, :error, first_trace.error) |
|
|
|
|
|
|
|
|
|
defp put_error_in_update_set(update_set, first_trace, %{status: :error}, _transaction_receipt_from_node), |
|
|
|
|
do: Keyword.put_new(update_set, :error, first_trace.error) |
|
|
|
|
|
|
|
|
|
defp put_error_in_update_set(update_set, first_trace, _transaction_from_db, _transaction_receipt_from_node) do |
|
|
|
|
case update_set[:status] do |
|
|
|
|
:error -> Keyword.put_new(update_set, :error, first_trace.error) |
|
|
|
|
_ -> update_set |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp remove_consensus_of_invalid_blocks(repo, invalid_block_numbers) do |
|
|
|
|
minimal_block = EthereumJSONRPC.first_block_to_fetch(:trace_first_block) |
|
|
|
|
|
|
|
|
|