Skip to content

Commit 3dffdca

Browse files
committed
fixes
1 parent 35ffb69 commit 3dffdca

File tree

5 files changed

+32
-21
lines changed

5 files changed

+32
-21
lines changed

src/ethereum_test_execution/blob_transaction.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import ClassVar, Dict, List
44

55
from ethereum_test_base_types import Hash
6+
from ethereum_test_base_types.base_types import Bytes
67
from ethereum_test_forks import Fork
78
from ethereum_test_rpc import BlobAndProofV1, BlobAndProofV2, EngineRPC, EthRPC
89
from ethereum_test_types import NetworkWrappedTransaction, Transaction
@@ -19,16 +20,17 @@ def versioned_hashes_with_blobs_and_proofs(
1920
"""
2021
versioned_hashes: Dict[Hash, BlobAndProofV1 | BlobAndProofV2] = {}
2122
for blob in tx.blobs:
22-
versioned_hash = blob.versioned_hash()
23-
if blob.kzg_proof is not None:
24-
versioned_hashes[versioned_hash] = BlobAndProofV1(blob=blob.data, proof=blob.kzg_proof)
25-
elif blob.kzg_cell_proofs is not None:
26-
versioned_hashes[versioned_hash] = BlobAndProofV2(
27-
blob=blob.data, proofs=blob.kzg_cell_proofs
23+
if isinstance(blob.proof, Bytes):
24+
versioned_hashes[blob.versioned_hash] = BlobAndProofV1(
25+
blob=blob.data, proof=blob.proof
26+
)
27+
elif isinstance(blob.proof, list):
28+
versioned_hashes[blob.versioned_hash] = BlobAndProofV2(
29+
blob=blob.data, proofs=blob.proof
2830
)
2931
else:
3032
raise ValueError(
31-
f"Blob with versioned hash {versioned_hash.hex()} requires either kzg_proof "
33+
f"Blob with versioned hash {blob.versioned_hash.hex()} requires either kzg_proof "
3234
"or kzg_cell_proofs, but both are None"
3335
)
3436

src/ethereum_test_forks/base_fork.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
"""Abstract base class for Ethereum forks."""
22

33
from abc import ABC, ABCMeta, abstractmethod
4-
from typing import Any, ClassVar, List, Literal, Mapping, Optional, Protocol, Sized, Tuple, Type
4+
from typing import (
5+
Any,
6+
ClassVar,
7+
Dict,
8+
List,
9+
Literal,
10+
Mapping,
11+
Optional,
12+
Protocol,
13+
Sized,
14+
Tuple,
15+
Type,
16+
Union,
17+
)
518

619
from semver import Version
720

@@ -156,7 +169,7 @@ class BaseFork(ABC, metaclass=BaseForkMeta):
156169
_ignore: ClassVar[bool] = False
157170

158171
# make mypy happy
159-
BLOB_CONSTANTS: ClassVar[dict[str, int | Literal["big"]]] = {}
172+
BLOB_CONSTANTS: ClassVar[Dict[str, Union[int, Literal["big"]]]] = {}
160173

161174
@classmethod
162175
def get_blob_constant(cls, name: str) -> int | Literal["big"]:

src/ethereum_test_forks/forks/forks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ def valid_opcodes(
871871
class Cancun(Shanghai):
872872
"""Cancun fork."""
873873

874-
BLOB_CONSTANTS: Dict[str, Union[int, Literal["big"]]] = { # every value is an int or a Literal
874+
BLOB_CONSTANTS = { # every value is an int or a Literal
875875
"FIELD_ELEMENTS_PER_BLOB": 4096,
876876
"BYTES_PER_FIELD_ELEMENT": 32,
877877
"CELL_LENGTH": 2048,
@@ -1076,7 +1076,7 @@ class Prague(Cancun):
10761076
"""Prague fork."""
10771077

10781078
# update some blob constants
1079-
BLOB_CONSTANTS: Dict[str, Union[int, Literal["big"]]] = {
1079+
BLOB_CONSTANTS = {
10801080
**Cancun.BLOB_CONSTANTS, # same base constants as cancun
10811081
"MAX_BLOBS_PER_BLOCK": 9, # but overwrite or add these
10821082
"TARGET_BLOBS_PER_BLOCK": 6,
@@ -1337,7 +1337,7 @@ class Osaka(Prague, solc_name="cancun"):
13371337
"""Osaka fork."""
13381338

13391339
# update some blob constants
1340-
BLOB_CONSTANTS: Dict[str, Union[int, Literal["big"]]] = {
1340+
BLOB_CONSTANTS = {
13411341
**Prague.BLOB_CONSTANTS, # same base constants as prague
13421342
"AMOUNT_CELL_PROOFS": 128,
13431343
}

src/ethereum_test_types/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Common definitions and types."""
22

33
from .account_types import EOA, Alloc
4-
from .blob import Blob
4+
from .blob_types import Blob
55
from .block_types import (
66
Environment,
77
EnvironmentDefaults,
@@ -24,7 +24,6 @@
2424
)
2525
from .transaction_types import (
2626
AuthorizationTuple,
27-
Blob,
2827
NetworkWrappedTransaction,
2928
Transaction,
3029
TransactionDefaults,

src/ethereum_test_types/transaction_types.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,15 @@ def blob_data(self) -> Sequence[Bytes]:
657657
@property
658658
def blob_kzg_commitments(self) -> Sequence[Bytes]:
659659
"""Return a list of kzg commitments."""
660-
return [blob.kzg_commitment for blob in self.blobs]
660+
return [blob.commitment for blob in self.blobs]
661661

662662
@computed_field # type: ignore[prop-decorator]
663663
@property
664-
def blob_kzg_proofs(self) -> Sequence[Bytes]:
664+
def blob_kzg_proofs(self) -> Sequence[Sequence[Bytes]] | Sequence[Bytes]:
665665
"""Return a list of kzg proofs."""
666-
proofs: List[Bytes] = []
666+
proofs: List[List[Bytes]] | List[Bytes] = []
667667
for blob in self.blobs:
668-
if blob.kzg_proof is not None:
669-
proofs.append(blob.kzg_proof)
670-
elif blob.kzg_cell_proofs is not None:
671-
proofs.extend(blob.kzg_cell_proofs)
668+
proofs.append(blob.proof) # type: ignore[arg-type]
672669
return proofs
673670

674671
def get_rlp_fields(self) -> List[str]:

0 commit comments

Comments
 (0)