Skip to content

Commit 1ac4c04

Browse files
committed
easier debugging with shortened error messages, also blobs doesnt spam reuse of existing blobs in console
1 parent e3fc73d commit 1ac4c04

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

src/ethereum_test_execution/blob_transaction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def versioned_hashes_with_blobs_and_proofs(
2626
)
2727
elif isinstance(blob.proof, list):
2828
versioned_hashes[blob.versioned_hash] = BlobAndProofV2(
29-
blob=blob.data, proofs=blob.proof
29+
blob=blob.data, proofs=blob.cells
3030
)
3131
else:
3232
raise ValueError(
33-
f"Blob with versioned hash {blob.versioned_hash.hex()} requires either kzg_proof "
34-
"or kzg_cell_proofs, but both are None"
33+
f"Blob with versioned hash {blob.versioned_hash.hex()} requires either proof "
34+
"or cells, but both are None"
3535
)
3636

3737
return versioned_hashes

src/ethereum_test_rpc/rpc.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ def __str__(self):
4343
if self.tx is not None:
4444
f"{super().__str__()} Transaction={self.tx.model_dump_json()}"
4545
elif self.tx_rlp is not None:
46-
return f"{super().__str__()} Transaction RLP={self.tx_rlp.hex()}"
46+
tx_rlp_hex = self.tx_rlp.hex()
47+
if len(tx_rlp_hex) > 1000:
48+
tx_rlp_hex = tx_rlp_hex[:50] # if it's very long just print first few chars
49+
return f"{super().__str__()} Transaction RLP={tx_rlp_hex}"
4750
return super().__str__()
4851

4952

@@ -182,7 +185,10 @@ def send_raw_transaction(self, transaction_rlp: Bytes) -> Hash:
182185
assert result_hash is not None
183186
return result_hash
184187
except Exception as e:
185-
raise SendTransactionExceptionError(str(e), tx_rlp=transaction_rlp) from e
188+
shortened_rlp_error_message = str(e) # signal in console that you don't see full rlp
189+
raise SendTransactionExceptionError(
190+
shortened_rlp_error_message, tx_rlp=transaction_rlp
191+
) from e
186192

187193
def send_transaction(self, transaction: Transaction) -> Hash:
188194
"""`eth_sendRawTransaction`: Send a transaction to the client."""

src/ethereum_test_rpc/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ def blob_versioned_hashes(self, versioned_hash_version: int = 1) -> List[Hash]:
150150

151151

152152
class BlobAndProofV1(CamelModel):
153-
"""Represents a blob and single-proof structure."""
153+
"""Represents a blob and single-proof structure (< Osaka)."""
154154

155155
blob: Bytes
156156
proof: Bytes
157157

158158

159159
class BlobAndProofV2(CamelModel):
160-
"""Represents a blob and proof structure."""
160+
"""Represents a blob and cell proof structure (>= Osaka)."""
161161

162162
blob: Bytes
163163
proofs: List[Bytes]

src/ethereum_test_types/blob_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
from ethereum_test_base_types.base_types import Bytes, Hash
1515
from ethereum_test_base_types.pydantic import CamelModel
1616
from ethereum_test_forks import Cancun, Fork, Osaka, Prague
17+
from pytest_plugins.logging import get_logger
1718

1819
CACHED_BLOBS_DIRECTORY: Path = (
1920
Path(platformdirs.user_cache_dir("ethereum-execution-spec-tests")) / "cached_blobs"
2021
)
22+
logger = get_logger(__name__)
2123

2224

2325
def clear_blob_cache(cached_blobs_folder_path: Path):
@@ -220,7 +222,7 @@ def get_cells(fork: Fork, data: Bytes) -> List[Bytes] | None:
220222
# if this blob already exists then load from file
221223
blob_location: Path = Blob.get_filepath(fork, seed)
222224
if blob_location.exists():
223-
print(f"Blob exists already, reading it from file {blob_location}")
225+
logger.debug(f"Blob exists already, reading it from file {blob_location}")
224226
return Blob.from_file(Blob.get_filename(fork, seed))
225227

226228
assert fork.supports_blobs(), f"Provided fork {fork.name()} does not support blobs!"
@@ -289,7 +291,7 @@ def write_to_file(self):
289291

290292
# warn if existing static_blob gets overwritten
291293
if output_location.exists():
292-
print(f"Blob {output_location} already exists. It will be overwritten.")
294+
logger.debug(f"Blob {output_location} already exists. It will be overwritten.")
293295

294296
with open(output_location, "w", encoding="utf-8") as f: # overwrite existing
295297
f.write(json_str)

src/ethereum_test_types/transaction_types.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,7 @@ def get_rlp_fields(self) -> List[str]:
761761
"Neither proofs nor cell_proofs are in rlp_fields. Critical error!"
762762
)
763763

764-
logger.warning(f"Ended up with this rlp field list: {rlp_fields}")
765-
# print("with this")
764+
logger.debug(f"Ended up with this rlp field list: {rlp_fields}")
766765

767766
return rlp_fields
768767

0 commit comments

Comments
 (0)