Skip to content

Commit

Permalink
fix: issue where used SharedBlobReceipt instead of Receipt (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Dec 18, 2024
1 parent 376b366 commit 0a0814a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
27 changes: 6 additions & 21 deletions src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,29 +589,14 @@ def decode_receipt(self, data: dict) -> "ReceiptAPI":
}

receipt_cls: type[Receipt]
if any(
x in data
for x in (
"blobGasPrice",
"blobGasUsed",
"blobVersionedHashes",
"maxFeePerBlobGas",
"blob_gas_price",
"blob_gas_used",
)
):
blob_gas_price = data.get("blob_gas_price", data.get("blobGasPrice"))
if data.get("type") == 3:
receipt_cls = SharedBlobReceipt
blob_gas_price = data.get("blob_gas_price")
if blob_gas_price is None:
# Not actually a blob-receipt? Some providers may give you
# empty values here when meaning the other types of receipts.
receipt_cls = Receipt
blob_gas_price = data.get("blobGasPrice")

else:
receipt_cls = SharedBlobReceipt
receipt_kwargs["blobGasPrice"] = blob_gas_price
receipt_kwargs["blobGasUsed"] = (
data.get("blob_gas_used", data.get("blobGasUsed")) or 0
)
receipt_kwargs["blobGasPrice"] = blob_gas_price
receipt_kwargs["blobGasUsed"] = data.get("blob_gas_used", data.get("blobGasUsed")) or 0

else:
receipt_cls = Receipt
Expand Down
6 changes: 6 additions & 0 deletions tests/functional/test_ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ def test_decode_receipt_shared_blob(ethereum, blob_gas_used, blob_gas_key):
# when None, should also default to 0.
assert actual.blob_gas_used == 0

# Show type=3 is required.
data["type"] = 2
actual = ethereum.decode_receipt(data)
assert not isinstance(actual, SharedBlobReceipt)
assert isinstance(actual, Receipt)


def test_decode_receipt_misleading_blob_receipt(ethereum):
"""
Expand Down

0 comments on commit 0a0814a

Please sign in to comment.