Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Filter out failed transactions before classification #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions mev_inspect/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ async def create_from_block_number(
_find_or_fetch_base_fee_per_gas(w3, block_number, trace_db_session),
)

# filter out failed transactions
failed_transactions = set(
receipt.transaction_hash for receipt in receipts if receipt.status == 0
)
receipts = [
receipt
for receipt in receipts
if receipt.transaction_hash not in failed_transactions
]
traces = [
trace for trace in traces if trace.transaction_hash not in failed_transactions
]

miner_address = _get_miner_address_from_traces(traces)

return Block(
Expand Down
2 changes: 2 additions & 0 deletions mev_inspect/schemas/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class Receipt(CamelModel):
effective_gas_price: int
cumulative_gas_used: int
to: Optional[str]
status: int

@validator(
"block_number",
"transaction_index",
"gas_used",
"effective_gas_price",
"cumulative_gas_used",
"status",
pre=True,
)
def maybe_hex_to_int(v):
Expand Down
3 changes: 3 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def load_test_block(block_number: int) -> Block:

with open(block_path, "r") as block_file:
block_json = json.load(block_file)
for item in block_json["receipts"]:
if "status" not in item:
item["status"] = "0x1"
return Block(
**{
**defaults,
Expand Down