From ce1e354860869dbb2b27dd7ca81fe328c6fe4c1e Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Sat, 26 Oct 2024 12:40:31 -0500 Subject: [PATCH] fix: mistaken blob receipt --- src/ape_ethereum/ecosystem.py | 5 +++-- tests/functional/test_ecosystem.py | 33 ++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 6adcc13cbe..82636f65fa 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -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 @@ -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 diff --git a/tests/functional/test_ecosystem.py b/tests/functional/test_ecosystem.py index f55df43e5c..981afecd80 100644 --- a/tests/functional/test_ecosystem.py +++ b/tests/functional/test_ecosystem.py @@ -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):