Skip to content

Commit

Permalink
fix: mistaken blob receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Oct 26, 2024
1 parent c064b47 commit ce1e354
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ def decode_receipt(self, data: dict) -> ReceiptAPI:
"blob_gas_used",
)
):

blob_gas_price = data.get("blob_gas_price", data.get("blobGasPrice"))
if blob_gas_price is None:
# Not actually a blob-receipt? Some providers may give you
Expand All @@ -608,7 +607,9 @@ def decode_receipt(self, data: dict) -> ReceiptAPI:
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["blobGasUsed"] = (
data.get("blob_gas_used", data.get("blobGasUsed")) or 0
)

else:
receipt_cls = Receipt
Expand Down
33 changes: 29 additions & 4 deletions tests/functional/test_ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,37 @@ def test_decode_receipt_shared_blob(ethereum, blob_gas_used, blob_gas_key):
assert actual.blob_gas_used == 0


def test_decode_receipt_blob_gas_price_none():
def test_decode_receipt_misleading_blob_receipt(ethereum):
"""
Tests a strange situation where the blob-related keys are in the
data but a required key is None. In this case, the provider is returning
empty data for these values and we should use the regular receipt.
Tests a strange situation (noticed on Tenderly nodes) where _some_
of the keys indicate blob-related fields, set to ``0``, and others
are missing, because it's not actually a blob receipt. In this case,
don't use the blob-receipt class.
"""
data = {
"type": 2,
"status": 1,
"cumulativeGasUsed": 10565720,
"logsBloom": HexBytes(
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" # noqa: E501
),
"logs": [],
"transactionHash": HexBytes(
"0x62fc9991bc7fb0c76bc83faaa8d1c17fc5efb050542e58ac358932f80aa7a087"
),
"from": "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326",
"to": "0xeBec795c9c8bBD61FFc14A6662944748F299cAcf",
"contractAddress": None,
"gasUsed": 21055,
"effectiveGasPrice": 7267406643,
"blockHash": HexBytes("0xa47fc133f829183b751488c1146f1085451bcccd247db42066dc6c89eaf5ebac"),
"blockNumber": 21051245,
"transactionIndex": 130,
"blobGasUsed": 0,
}
actual = ethereum.decode_receipt(data)
assert not isinstance(actual, SharedBlobReceipt)
assert isinstance(actual, Receipt)


def test_default_transaction_type_not_connected_used_default_network(project, ethereum, networks):
Expand Down

0 comments on commit ce1e354

Please sign in to comment.