Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions eth/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
FrozenSet,
Iterable,
Iterator,
List,
MutableMapping,
NamedTuple,
Optional,
Expand Down Expand Up @@ -51,6 +52,9 @@

T = TypeVar('T')

# A decoded RLP object of unknown interpretation, with a maximum "depth" of 1.
DecodedZeroOrOneLayerRLP = Union[bytes, List[bytes]]


class MiningHeaderAPI(ABC):
"""
Expand Down Expand Up @@ -241,7 +245,7 @@ class ReceiptBuilderAPI(ReceiptDecoderAPI):

@classmethod
@abstractmethod
def deserialize(cls, encoded: bytes) -> 'ReceiptAPI':
def deserialize(cls, encoded: DecodedZeroOrOneLayerRLP) -> 'ReceiptAPI':
"""
Extract a receipt from an encoded RLP object.

Expand All @@ -251,7 +255,7 @@ def deserialize(cls, encoded: bytes) -> 'ReceiptAPI':

@classmethod
@abstractmethod
def serialize(cls, obj: 'ReceiptAPI') -> bytes:
def serialize(cls, obj: 'ReceiptAPI') -> DecodedZeroOrOneLayerRLP:
"""
Encode a receipt to a series of bytes used by RLP.

Expand Down Expand Up @@ -448,7 +452,7 @@ class TransactionBuilderAPI(TransactionDecoderAPI):

@classmethod
@abstractmethod
def deserialize(cls, encoded: bytes) -> 'SignedTransactionAPI':
def deserialize(cls, encoded: DecodedZeroOrOneLayerRLP) -> 'SignedTransactionAPI':
"""
Extract a transaction from an encoded RLP object.

Expand All @@ -458,7 +462,7 @@ def deserialize(cls, encoded: bytes) -> 'SignedTransactionAPI':

@classmethod
@abstractmethod
def serialize(cls, obj: 'SignedTransactionAPI') -> bytes:
def serialize(cls, obj: 'SignedTransactionAPI') -> DecodedZeroOrOneLayerRLP:
"""
Encode a transaction to a series of bytes used by RLP.

Expand Down
3 changes: 3 additions & 0 deletions eth/chains/goerli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from eth_utils import decode_hex

from .constants import (
BERLIN_GOERLI_BLOCK,
ISTANBUL_GOERLI_BLOCK,
PETERSBURG_GOERLI_BLOCK,
)
Expand All @@ -9,13 +10,15 @@

from eth.rlp.headers import BlockHeader
from eth.vm.forks import (
BerlinVM,
IstanbulVM,
PetersburgVM,
)

GOERLI_VM_CONFIGURATION = (
(PETERSBURG_GOERLI_BLOCK, PetersburgVM),
(ISTANBUL_GOERLI_BLOCK, IstanbulVM),
(BERLIN_GOERLI_BLOCK, BerlinVM),
)


Expand Down
2 changes: 2 additions & 0 deletions eth/chains/goerli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
# Istanbul
#
ISTANBUL_GOERLI_BLOCK = BlockNumber(1561651)

BERLIN_GOERLI_BLOCK = BlockNumber(4460644)
5 changes: 4 additions & 1 deletion eth/chains/ropsten/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from eth_utils import decode_hex

from .constants import (
BERLIN_ROPSTEN_BLOCK,
BYZANTIUM_ROPSTEN_BLOCK,
CONSTANTINOPLE_ROPSTEN_BLOCK,
ISTANBUL_ROPSTEN_BLOCK,
Expand All @@ -18,6 +19,7 @@
from eth.chains.base import Chain
from eth.rlp.headers import BlockHeader
from eth.vm.forks import (
BerlinVM,
ByzantiumVM,
ConstantinopleVM,
IstanbulVM,
Expand All @@ -36,7 +38,8 @@
(CONSTANTINOPLE_ROPSTEN_BLOCK, ConstantinopleVM),
(PETERSBURG_ROPSTEN_BLOCK, PetersburgVM),
(ISTANBUL_ROPSTEN_BLOCK, IstanbulVM),
(MUIR_GLACIER_ROPSTEN_BLOCK, MuirGlacierVM)
(MUIR_GLACIER_ROPSTEN_BLOCK, MuirGlacierVM),
(BERLIN_ROPSTEN_BLOCK, BerlinVM),
)


Expand Down
1 change: 1 addition & 0 deletions eth/chains/ropsten/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@
# Muir Glacier Block
#
MUIR_GLACIER_ROPSTEN_BLOCK = BlockNumber(7117117)
BERLIN_ROPSTEN_BLOCK = BlockNumber(9812189)
9 changes: 5 additions & 4 deletions eth/vm/forks/berlin/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)

from eth.abc import (
DecodedZeroOrOneLayerRLP,
LogAPI,
ReceiptAPI,
ReceiptBuilderAPI,
Expand Down Expand Up @@ -76,13 +77,13 @@ def get_payload_codec(cls, type_id: int) -> Type[ReceiptDecoderAPI]:
raise ValidationError(f"Cannot build typed receipt with {hex(type_id)} >= 0x80")

@classmethod
def deserialize(cls, encoded_unchecked: bytes) -> ReceiptAPI:
def deserialize(cls, encoded_unchecked: DecodedZeroOrOneLayerRLP) -> ReceiptAPI:
# binary checks a few basics, like the length of the bytes
encoded = cls.rlp_type.deserialize(encoded_unchecked)
return cls.decode(encoded)

@classmethod
def serialize(cls, obj: 'TypedReceipt') -> bytes:
def serialize(cls, obj: 'TypedReceipt') -> DecodedZeroOrOneLayerRLP:
encoded = obj.encode()
return cls.rlp_type.serialize(encoded)

Expand Down Expand Up @@ -136,12 +137,12 @@ def decode(cls, encoded: bytes) -> ReceiptAPI:
return rlp.decode(encoded, sedes=cls.legacy_sedes)

@classmethod
def deserialize(cls, encoded: bytes) -> ReceiptAPI:
def deserialize(cls, encoded: DecodedZeroOrOneLayerRLP) -> ReceiptAPI:
if isinstance(encoded, bytes):
return TypedReceipt.deserialize(encoded)
else:
return cls.legacy_sedes.deserialize(encoded)

@classmethod
def serialize(cls, obj: ReceiptAPI) -> bytes:
def serialize(cls, obj: ReceiptAPI) -> DecodedZeroOrOneLayerRLP:
return cls.legacy_sedes.serialize(obj)
9 changes: 5 additions & 4 deletions eth/vm/forks/berlin/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
)

from eth.abc import (
DecodedZeroOrOneLayerRLP,
ReceiptAPI,
SignedTransactionAPI,
TransactionBuilderAPI,
Expand Down Expand Up @@ -254,12 +255,12 @@ def decode(cls, encoded: bytes) -> SignedTransactionAPI:
return cls(type_id, inner_transaction)

@classmethod
def serialize(cls, obj: 'TypedTransaction') -> bytes:
def serialize(cls, obj: 'TypedTransaction') -> DecodedZeroOrOneLayerRLP:
encoded = obj.encode()
return cls.rlp_type.serialize(encoded)

@classmethod
def deserialize(cls, encoded_unchecked: bytes) -> SignedTransactionAPI:
def deserialize(cls, encoded_unchecked: DecodedZeroOrOneLayerRLP) -> SignedTransactionAPI:
# binary checks a few basics, like the length of the bytes
encoded = cls.rlp_type.deserialize(encoded_unchecked)
return cls.decode(encoded)
Expand Down Expand Up @@ -374,14 +375,14 @@ def decode(cls, encoded: bytes) -> SignedTransactionAPI:
return rlp.decode(encoded, sedes=cls.legacy_signed)

@classmethod
def deserialize(cls, encoded: bytes) -> SignedTransactionAPI:
def deserialize(cls, encoded: DecodedZeroOrOneLayerRLP) -> SignedTransactionAPI:
if isinstance(encoded, bytes):
return TypedTransaction.deserialize(encoded)
else:
return cls.legacy_signed.deserialize(encoded)

@classmethod
def serialize(cls, obj: SignedTransactionAPI) -> bytes:
def serialize(cls, obj: SignedTransactionAPI) -> DecodedZeroOrOneLayerRLP:
if isinstance(obj, TypedTransaction):
return TypedTransaction.serialize(obj)
else:
Expand Down
3 changes: 3 additions & 0 deletions newsfragments/1993.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add Berlin block numbers for Goerli and Ropsten. Correct the type signature for
TransactionBuilderAPI and ReceiptBuilderAPI, because it can take a list of bytes for the legacy
types.