Skip to content

Transition types #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0a00660
prague initial commit
gurukamath Jan 21, 2025
50c17ac
changes for prague
gurukamath Apr 23, 2024
d35af35
Implement EIP-7702
gurukamath Jan 23, 2025
877f1a5
Implement EIP-2537
gurukamath Jan 23, 2025
f14f9c8
Implement EIP-6110
gurukamath Jan 23, 2025
247fd14
Implement EIP-7002
gurukamath Jan 23, 2025
89d6faf
Implement EIP-7251
gurukamath Jan 23, 2025
b2177e7
Implement EIP-2935
gurukamath Jan 23, 2025
457cb21
Implement EIP-7623
gurukamath Jan 23, 2025
9a5437a
Implement EIP-7691
gurukamath Jan 23, 2025
8892006
run tests
gurukamath Jan 23, 2025
d55ada1
catch invalid signatures
gurukamath Jan 23, 2025
c1d262e
add state test flag
gurukamath Jan 23, 2025
5a32df1
run only prague tests
gurukamath Jan 23, 2025
0c56b70
re-factor validate_transaction
gurukamath Jan 24, 2025
b151dfe
change type of branch node subnodes (#1066) (#1095)
SamWilsn Jan 27, 2025
aa0daf9
update storage trie type (#1070 #1071)
SamWilsn Jan 25, 2025
ad81be4
Merge pull request #1096 from SamWilsn/update-trie-type
gurukamath Jan 29, 2025
33d50c9
update EXTCODE* behavior in 7702 (#1094)
gurukamath Jan 30, 2025
fa33d82
Update EIP-2935, EIP-7002, EIP-7251 system contract addresses (#1100)
marioevz Jan 30, 2025
ef644ed
port #1098 and #1011 to `forks/prague` (#1102)
gurukamath Feb 3, 2025
ad4d15b
run [email protected] tests
gurukamath Feb 5, 2025
a25a8ab
Merge pull request #1110 from gurukamath/run-prague-devnet1.0.0-tests
petertdavies Feb 5, 2025
8b6b2e0
Merge pull request #1111 from ethereum/devnets/prague/6
petertdavies Feb 6, 2025
2c86028
Backport changes from prague (#1113)
gurukamath Feb 11, 2025
8d6093a
Prepare to release
SamWilsn Feb 11, 2025
f739293
fix: check y_parity value (#1107)
SamWilsn Feb 12, 2025
a818bd2
Remove unused file
SamWilsn Feb 13, 2025
891a888
Merge pull request #1120 from SamWilsn/prague-y-parity
petertdavies Feb 13, 2025
6023917
Bump ethash to 1.1.0
SamWilsn Feb 13, 2025
dc76275
Merge remote-tracking branch 'upstream/forks/prague' into prague-rele…
SamWilsn Feb 13, 2025
51f2d6a
Refactor Environment (#1131)
gurukamath Mar 5, 2025
6813313
Force forks to deal with blocks from previous forks
SamWilsn Nov 17, 2024
30a309d
force forks to deal with old headers
SamWilsn Nov 19, 2024
78156d7
More strict bounds on ommer types
SamWilsn Nov 20, 2024
700b411
Bump to mypy 1.15.0
SamWilsn Feb 12, 2025
77e4efd
Switch tox static to pypy3
SamWilsn Mar 5, 2025
77e91da
fixup
SamWilsn Mar 5, 2025
e845300
Split parent_header from validate_header
SamWilsn Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Upload Pages Artifact
id: artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: .tox/docs

Expand All @@ -46,6 +46,7 @@ jobs:
permissions:
pages: write
id-token: write
actions: read

environment:
name: github-pages
Expand All @@ -54,4 +55,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:

- name: Run Tox (CPython)
if: "${{ !startsWith(matrix.py, 'pypy') }}"
run: tox -e static,optimized,py3
run: tox -e optimized,py3

- name: Run Tox (PyPy)
if: "${{ startsWith(matrix.py, 'pypy') }}"
run: tox -e pypy3
run: tox -e static,pypy3
env:
PYPY_GC_MAX: "10G"

Expand Down
26 changes: 19 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ethereum
description = Ethereum specification, provided as a Python package for tooling and testing
name = ethereum-execution
description = Ethereum execution layer specification, provided as a Python package for tooling and testing
long_description = file: README.md
long_description_content_type = text/markdown
version = attr: ethereum.__version__
Expand All @@ -9,6 +9,12 @@ license_files =
LICENSE.md
classifiers =
License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Programming Language :: Python :: 3
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: PyPy
Programming Language :: Python :: Implementation :: CPython
Intended Audience :: Developers
Natural Language :: English

[options]
packages =
Expand Down Expand Up @@ -104,6 +110,12 @@ packages =
ethereum/cancun/vm
ethereum/cancun/vm/instructions
ethereum/cancun/vm/precompiled_contracts
ethereum/prague
ethereum/prague/utils
ethereum/prague/vm
ethereum/prague/vm/instructions
ethereum/prague/vm/precompiled_contracts
ethereum/prague/vm/precompiled_contracts/bls12_381


package_dir =
Expand All @@ -113,10 +125,10 @@ python_requires = >=3.10
install_requires =
pycryptodome>=3,<4
coincurve>=20,<21
typing_extensions>=4
py_ecc @ git+https://github.com/petertdavies/py_ecc.git@127184f4c57b1812da959586d0fe8f43bb1a2389
typing_extensions>=4.2
py-ecc>=8.0.0b2,<9
ethereum-types>=0.2.1,<0.3
ethereum-rlp>=0.1.1,<0.2
ethereum-rlp>=0.1.2,<0.2

[options.package_data]
ethereum =
Expand Down Expand Up @@ -163,7 +175,7 @@ test =
lint =
types-setuptools>=68.1.0.1,<69
isort==5.13.2
mypy==1.14.1
mypy==1.15.0
black==23.12.0
flake8==6.1.0
flake8-bugbear==23.12.2
Expand All @@ -179,7 +191,7 @@ doc =

optimized =
rust-pyspec-glue>=0.0.9,<0.1.0
ethash @ git+https://github.com/chfast/ethash.git@e08bd0fadb8785f7ccf1e2fb07b75f54fe47f92e
ethash>=1.1.0,<2

[flake8]
dictionaries=en_US,python,technical
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""
import sys

__version__ = "0.1.0"
__version__ = "1.17.0rc6.dev1"

#
# Ensure we can reach 1024 frames of recursion
Expand Down
99 changes: 96 additions & 3 deletions src/ethereum/arrow_glacier/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@
chain.
"""
from dataclasses import dataclass
from typing import Tuple, Union
from typing import Annotated, Optional, Tuple, Union

from ethereum_rlp import rlp
from ethereum_types.bytes import Bytes, Bytes8, Bytes32
from ethereum_types.frozen import slotted_freezable
from ethereum_types.numeric import U256, Uint
from typing_extensions import TypeAlias

from ethereum.exceptions import InvalidBlock
from ethereum.london import blocks as previous_blocks

from ..crypto.hash import Hash32
from .fork_types import Address, Bloom, Root
from .transactions import LegacyTransaction
from .transactions import (
AccessListTransaction,
FeeMarketTransaction,
LegacyTransaction,
Transaction,
)


@slotted_freezable
Expand Down Expand Up @@ -45,6 +55,49 @@ class Header:
base_fee_per_gas: Uint


AnyHeader: TypeAlias = Union[previous_blocks.AnyHeader, Header]
"""
Represents all headers that may have appeared in the blockchain before or in
the current fork.
"""


def decode_header(raw_header: rlp.Simple) -> AnyHeader:
"""
Convert `raw_header` from raw sequences and bytes to a structured block
header.

Checks `raw_header` against this fork's `FORK_CRITERIA`, and if it belongs
to this fork, decodes it accordingly. If not, this function forwards to the
preceding fork where the process is repeated.
"""
from . import FORK_CRITERIA

# First, ensure that `raw_header` is not `bytes` (and is therefore a
# sequence.)
if isinstance(raw_header, bytes):
raise InvalidBlock("header is bytes, expected sequence")

# Next, extract the block number and timestamp (which are always at index 8
# and 11 respectively.)
raw_number = raw_header[8]
if not isinstance(raw_number, bytes):
raise InvalidBlock("header number is sequence, expected bytes")
number = Uint.from_be_bytes(raw_number)

raw_timestamp = raw_header[11]
if not isinstance(raw_timestamp, bytes):
raise InvalidBlock("header timestamp is sequence, expected bytes")
timestamp = U256.from_be_bytes(raw_timestamp)

# Finally, check if this header belongs to this fork.
if FORK_CRITERIA.check(number, timestamp):
return rlp.deserialize_to(Header, raw_header)

# If it doesn't, forward to the preceding fork.
return previous_blocks.decode_header(raw_header)


@slotted_freezable
@dataclass
class Block:
Expand All @@ -54,7 +107,14 @@ class Block:

header: Header
transactions: Tuple[Union[Bytes, LegacyTransaction], ...]
ommers: Tuple[Header, ...]
ommers: Tuple[Annotated[AnyHeader, rlp.With(decode_header)], ...]


AnyBlock: TypeAlias = Union[previous_blocks.AnyBlock, Block]
"""
Represents all blocks that may have appeared in the blockchain before or in the
current fork.
"""


@slotted_freezable
Expand All @@ -80,3 +140,36 @@ class Receipt:
cumulative_gas_used: Uint
bloom: Bloom
logs: Tuple[Log, ...]


def encode_receipt(tx: Transaction, receipt: Receipt) -> Union[Bytes, Receipt]:
"""
Encodes a receipt.
"""
if isinstance(tx, AccessListTransaction):
return b"\x01" + rlp.encode(receipt)
elif isinstance(tx, FeeMarketTransaction):
return b"\x02" + rlp.encode(receipt)
else:
return receipt


def decode_receipt(receipt: Union[Bytes, Receipt]) -> Receipt:
"""
Decodes a receipt.
"""
if isinstance(receipt, Bytes):
assert receipt[0] in (1, 2)
return rlp.decode_to(Receipt, receipt[1:])
else:
return receipt


def header_base_fee_per_gas(header: AnyHeader) -> Optional[Uint]:
"""
Returns the `base_fee_per_gas` of the given header, or `None` for headers
without that field.
"""
if isinstance(header, Header):
return header.base_fee_per_gas
return previous_blocks.header_base_fee_per_gas(header)
Loading