Skip to content

Commit ab3a59c

Browse files
committed
tests passing except for third one, too much gas (nethermind) or too many blobs (7vs9, geth)
1 parent bc43bc5 commit ab3a59c

File tree

9 files changed

+46
-103
lines changed

9 files changed

+46
-103
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Users can select any of the artifacts depending on their testing needs for their
6666
- ✨ Added automatic checklist generation for every EIP inside of the `tests` folder. The checklist is appended to each EIP in the documentation in the "Test Case Reference" section ([#1679](https://github.com/ethereum/execution-spec-tests/pull/1679), [#1718](https://github.com/ethereum/execution-spec-tests/pull/1718)).
6767
- 🔀 Add macOS hive development mode workaround to the docs [#1786](https://github.com/ethereum/execution-spec-tests/pull/1786).
6868
- 🔀 Refactor and clean up of exceptions including EOF exceptions within client specific mappers [#1803](https://github.com/ethereum/execution-spec-tests/pull/1803).
69+
- ✨ Improved RLP logging in rpc.py. Errors shown in console are shortened and full RLP data is logged to file if an exception occurs ([#1614](https://github.com/ethereum/execution-spec-tests/pull/1614)).
6970

7071
### 🧪 Test Cases
7172

pytest-execute-hive.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ addopts =
1515
-p pytest_plugins.execute.rpc.hive
1616
-p pytest_plugins.execute.execute
1717
-p pytest_plugins.shared.execute_fill
18+
-p pytest_plugins.logging.logging
1819
-p pytest_plugins.forks.forks
1920
-p pytest_plugins.pytest_hive.pytest_hive
2021
-p pytest_plugins.help.help

pytest-execute.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ addopts =
1515
-p pytest_plugins.solc.solc
1616
-p pytest_plugins.execute.execute
1717
-p pytest_plugins.shared.execute_fill
18+
-p pytest_plugins.logging.logging
1819
-p pytest_plugins.execute.rpc.remote_seed_sender
1920
-p pytest_plugins.execute.rpc.remote
2021
-p pytest_plugins.forks.forks

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ addopts =
1616
-p pytest_plugins.filler.static_filler
1717
-p pytest_plugins.filler.ported_tests
1818
-p pytest_plugins.shared.execute_fill
19+
-p pytest_plugins.logging.logging
1920
-p pytest_plugins.forks.forks
2021
-p pytest_plugins.eels_resolver
2122
-p pytest_plugins.help.help

src/ethereum_test_base_types/conversions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
from re import sub
44
from typing import Any, List, Optional, SupportsBytes, TypeAlias
55

6+
from pytest_plugins.logging import get_logger
7+
68
BytesConvertible: TypeAlias = str | bytes | SupportsBytes | List[int]
79
FixedSizeBytesConvertible: TypeAlias = str | bytes | SupportsBytes | List[int] | int
810
NumberConvertible: TypeAlias = str | bytes | SupportsBytes | int
911

10-
from pytest_plugins.logging import get_logger
1112

1213
logger = get_logger(__name__)
1314

src/ethereum_test_execution/blob_transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def versioned_hashes_with_blobs_and_proofs(
3131
)
3232
else:
3333
raise ValueError(
34-
f"Blob with versioned hash {blob.versioned_hash.hex()} requires either proof "
35-
"or cells, but both are None"
34+
f"Blob with versioned hash {blob.versioned_hash.hex()} requires a proof "
35+
"that is not None"
3636
)
3737

3838
return versioned_hashes

src/ethereum_test_rpc/rpc.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def post_request(self, method: str, *params: Any, extra_headers: Dict | None = N
136136
payload_json = json.dumps(payload) # pydantic.json
137137
payload_size_bytes = len(payload_json.encode("utf-8"))
138138
payload_size_mb = payload_size_bytes / (1024 * 1024)
139-
logger.info(
139+
logger.debug(
140140
f"I am about to send a POST request of approximated size: {payload_size_mb:.2f} MB "
141141
f"({payload_size_bytes} bytes)"
142142
)
@@ -231,12 +231,11 @@ def send_raw_transaction(self, transaction_rlp: Bytes) -> Hash:
231231
tx_rlp_hex = transaction_rlp.hex()
232232
result_hash = Hash(self.post_request("sendRawTransaction", f"{tx_rlp_hex}"))
233233
assert result_hash is not None, "result_hash seems to be None, critical error!"
234-
# debug: also log successful rpc calls
235-
print(
236-
SendTransactionExceptionError(
237-
str("no error"), tx_rlp=transaction_rlp, shorten_errors=True, log_rlp_data=True
238-
)
239-
) # print triggers __str__ which triggers logging
234+
235+
# if you wrap SendTransactionExceptionError in print() it will get logged to file
236+
SendTransactionExceptionError(
237+
str("no error"), tx_rlp=transaction_rlp, shorten_errors=True, log_rlp_data=False
238+
)
240239

241240
return result_hash
242241
except Exception as e:
@@ -253,12 +252,10 @@ def send_transaction(self, transaction: Transaction) -> Hash:
253252
assert result_hash == transaction.hash
254253
assert result_hash is not None
255254

256-
# debug: also log successful rpc calls
257-
print(
258-
SendTransactionExceptionError(
259-
str("no error"), tx_rlp=transaction_rlp, shorten_errors=True, log_rlp_data=True
260-
)
261-
) # print triggers __str__ which triggers logging
255+
# if you wrap SendTransactionExceptionError in print() it will get logged to file
256+
SendTransactionExceptionError(
257+
str("no error"), tx_rlp=transaction_rlp, shorten_errors=True, log_rlp_data=False
258+
)
262259

263260
return transaction.hash
264261
except Exception as e:

src/ethereum_test_types/transaction_types.py

Lines changed: 10 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,6 @@ def get_rlp_prefix(self) -> bytes:
599599
Return the transaction type as bytes to be appended at the beginning of the
600600
serialized transaction if type is not 0.
601601
"""
602-
# if self.ty == 3: # dont add 0x03 to the rlp
603-
# return b""
604602
if self.ty > 0:
605603
return bytes([self.ty])
606604
return b""
@@ -695,65 +693,20 @@ def proofs(self) -> Sequence[Bytes] | None:
695693

696694
return proofs
697695

698-
# original cell proofs with length 4098
699-
# error: InvalidBlobDataSize: Blob data fields are of incorrect size.
700-
# -> i think its cuz each cell_proof has length 4098, but for some reason it wants length 98 (but ofc if we just shorten it it will expect a different proof)
701696
@computed_field # type: ignore[prop-decorator]
702697
@property
703-
def cell_proofs(self) -> Sequence[Sequence[Bytes]] | Sequence[Bytes] | None:
698+
def cell_proofs(self) -> Sequence[Bytes] | None:
704699
"""Return a list of cells (returns None < Osaka)."""
705700
if self.wrapper_version is None:
706701
return None
707702

708-
cells: list[list[Bytes]] = []
703+
cells: list[Bytes] = []
709704
for blob in self.blob_objects:
710705
assert isinstance(blob.proof, list)
711-
cells.append(blob.proof)
712-
713-
# if you remove below you instead get error: Invalid RLP. (which means getting what we have to work NWT that hold many blobs will be even more work) # noqa: E501
714-
if len(cells) == 1:
715-
return cells[0]
706+
cells.extend(blob.proof)
716707

717708
return cells
718709

719-
# shortened cell proofs of length 98 ( 48*2 + len(0x00) + len(0x03) )
720-
# unlocks new error: proofs dont match cells
721-
# @computed_field # type: ignore[prop-decorator]
722-
# @property
723-
# def cell_proofs(self) -> Sequence[Bytes] | None:
724-
# """Return a list of cells (returns None < Osaka)."""
725-
# if self.wrapper_version is None:
726-
# return None
727-
728-
# cells: list[Bytes] = []
729-
# for blob in self.blob_objects:
730-
# assert isinstance(blob.cells, list)
731-
# # code below gives: InvalidBlobDataSize: Blob data fields are of incorrect size:
732-
# # cells.extend(
733-
# # Bytes(cell)
734-
# # for cell in blob.cells # Bytes(cell[:48])
735-
# # ) # extend unpacks the elements instead of adding it as list
736-
737-
# # code below gives: InvalidBlobProof: Proofs do not match the blobs.
738-
# cells.extend(
739-
# Bytes(cell[:48]) for cell in blob.cells
740-
# ) # extend unpacks the elements instead of adding it as list
741-
742-
# return cells
743-
744-
# just trying to match the 'before.txt' even more closely
745-
# # unlocks new error: proofs dont match cells
746-
# @computed_field # type: ignore[prop-decorator]
747-
# @property
748-
# def cell_proofs(self) -> Sequence[Bytes] | None:
749-
# """Return a list of cells (returns None < Osaka)."""
750-
# if self.wrapper_version is None:
751-
# return None
752-
753-
# cells: list[Bytes] = [self.commitments[0]] * 128
754-
755-
# return cells
756-
757710
def get_rlp_fields(self) -> List[str]:
758711
"""
759712
Return an ordered list of field names to be included in RLP serialization.
@@ -777,7 +730,7 @@ def get_rlp_fields(self) -> List[str]:
777730
if self.cell_proofs is not None:
778731
rlp_cell_proofs = ["cell_proofs"]
779732

780-
# GETH FUSAKA_DEVNET_0 EXPECTS:
733+
# Geth expects:
781734
# type blobTxWithBlobs struct {
782735
# BlobTx *BlobTx
783736
# Blobs []kzg4844.Blob
@@ -796,12 +749,12 @@ def get_rlp_fields(self) -> List[str]:
796749
rlp_fields: List[
797750
str
798751
] = [ # structure explained in https://eips.ethereum.org/EIPS/eip-7594#Networking
799-
"tx", # tx_payload_body, in geth: BlobTx, https://github.com/ethereum/go-ethereum/blob/e17f97a8242c55b6fba66317d3720b9728a12f78/core/types/tx_blob.go#L122
800-
*wrapper, # wrapper_version, which is always 1 for osaka (was non-existing before), in geth: Version # noqa: E501
801-
"blobs", # Blob.data, in geth: Blobs
802-
"commitments", # in geth: Commitments
803-
*rlp_proofs, # only included < osaka, in geth: Proofs
804-
*rlp_cell_proofs, # only included >=osaka, in geth this does not exist(always uses Proofs)
752+
"tx", # tx_payload_body
753+
*wrapper, # wrapper_version, which is always 1 for osaka (was non-existing before)
754+
"blobs", # Blob.data
755+
"commitments",
756+
*rlp_proofs,
757+
*rlp_cell_proofs,
805758
]
806759

807760
assert ("proofs" in rlp_fields) or ("cell_proofs" in rlp_fields), (
@@ -812,21 +765,11 @@ def get_rlp_fields(self) -> List[str]:
812765

813766
return rlp_fields
814767

815-
# GETH PROBLEM:
816-
# osaka without wrapper: too few elements for types.blobTxWithBlobs
817-
# osaka with wrapper: it tries to deserialize into blobTxWithBlobs instead of versionedBlobTxWithBlobs, so it complains about unexpectedly seeing wrapper instead of blob data # noqa: E501
818-
819-
# NETHERMIND PROBLEM:
820-
# osaka without wrapper: code=-32602, message=Specified argument was out of the range of valid values.
821-
# osaka with wrapper: code=-32602, message=Specified argument was out of the range of valid values
822-
823768
def get_rlp_prefix(self) -> bytes:
824769
"""
825770
Return the transaction type as bytes to be appended at the beginning of the
826771
serialized transaction if type is not 0.
827772
"""
828-
# if self.tx.ty == 3: # don't add 0x03 to the rlp
829-
# return b""
830773
if self.tx.ty > 0:
831774
return bytes([self.tx.ty])
832775
return b""

tests/osaka/eip7594_peerdas/test_get_blobs.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def txs( # noqa: D103
197197
blob_objects=tx_blobs,
198198
)
199199
txs.append(network_wrapped_tx)
200-
break # TODO: remove this
201200
return txs
202201

203202

@@ -209,7 +208,7 @@ def generate_full_blob_tests(
209208
parametrized for each different fork.
210209
"""
211210
max_blobs = fork.max_blobs_per_block()
212-
logger.info(f"MAX_BLOBS value for fork {fork}: {max_blobs}")
211+
logger.debug(f"MAX_BLOBS value for fork {fork}: {max_blobs}")
213212

214213
return [
215214
pytest.param(
@@ -220,24 +219,23 @@ def generate_full_blob_tests(
220219
],
221220
id="single_blob_transaction",
222221
),
223-
# pytest.param(
224-
# [ # Txs
225-
# [ # Blobs per transaction
226-
# Blob.from_fork(fork) for _ in range(max_blobs)
227-
# ]
228-
# ],
229-
# id="max_blobs_transaction",
230-
# ),
231-
# pytest.param(
232-
# [ # Txs
233-
# [ # Blobs per transaction
234-
# Blob.from_fork(fork),
235-
# ]
236-
# for _ in range(max_blobs)
237-
# ],
238-
# id="single_blob_max_txs",
239-
# ),
240-
# TODO: uncomment above
222+
pytest.param(
223+
[ # Txs
224+
[ # Blobs per transaction
225+
Blob.from_fork(fork) for _ in range(max_blobs)
226+
]
227+
],
228+
id="max_blobs_transaction",
229+
),
230+
pytest.param(
231+
[ # Txs
232+
[ # Blobs per transaction
233+
Blob.from_fork(fork),
234+
]
235+
for _ in range(max_blobs)
236+
],
237+
id="single_blob_max_txs",
238+
),
241239
]
242240

243241

0 commit comments

Comments
 (0)