Skip to content
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

[WIP] Prague initial commit #2187

Open
wants to merge 1 commit into
base: prague
Choose a base branch
from
Open
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
50 changes: 50 additions & 0 deletions eth/vm/forks/prague/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import (
Type,
)

from eth._utils.db import (
get_block_header_by_hash,
)
from eth.abc import (
BlockAPI,
BlockHeaderAPI,
StateAPI,
TransactionFieldsAPI,
)
from eth.rlp.blocks import (
BaseBlock,
)
from eth.vm.forks.cancun import (
CancunVM,
)
from eth.vm.state import (
BaseState,
)
from eth_utils import (
ValidationError,
to_int,
)

from .blocks import (
PragueBlock,
)
from .headers import (
create_prague_header_from_parent,
)
from .state import (
PragueState,
)


class PragueVM(CancunVM):
# fork name
fork = "prague"

# classes
block_class: Type[BaseBlock] = PragueBlock
_state_class: Type[BaseState] = PragueState

# methods
create_header_from_parent = staticmethod( # type: ignore
create_prague_header_from_parent()
)
39 changes: 39 additions & 0 deletions eth/vm/forks/prague/blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import (
Type,
)

from rlp.sedes import (
CountableList,
)

from eth.abc import (
ReceiptBuilderAPI,
TransactionBuilderAPI,
)
from eth.rlp.headers import (
BlockHeader,
)
from eth.vm.forks.cancun.block import (
CancunBlock,
)

from ..shanghai.withdrawals import (
Withdrawal,
)
from .receipts import (
PragueReceiptBuilder,
)
from .transactions import (
PragueTransactionBuilder,
)


class PragueBlock(CancunBlock):
transaction_builder: Type[TransactionBuilderAPI] = PragueTransactionBuilder
receipt_builder: Type[ReceiptBuilderAPI] = PragueReceiptBuilder
fields = [
("header", BlockHeader),
("transactions", CountableList(transaction_builder)),
("uncles", CountableList(None, max_length=0)),
("withdrawals", CountableList(Withdrawal)),
]
14 changes: 14 additions & 0 deletions eth/vm/forks/prague/computation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from eth.vm.forks.cancun.computation import (
CancunComputation,
)
from eth.vm.forks.prague.opcodes import (
PRAGUE_OPCODES,
)


class PragueComputation(CancunComputation):
"""
A class for all execution computations in the ``Prague`` hard fork
"""

opcodes = PRAGUE_OPCODES
Empty file.
26 changes: 26 additions & 0 deletions eth/vm/forks/prague/headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import (
Any,
Dict,
Optional,
)

from toolz import (
curry,
)

from eth.abc import (
BlockHeaderAPI,
)
from eth.rlp.headers import (
BlockHeader,
)


@curry
def create_prague_header_from_parent(
parent_header: Optional[BlockHeaderAPI],
**header_params: Any,
) -> BlockHeaderAPI:
all_fields: Dict[Any, Any] = {}

return BlockHeader(**all_fields)
Empty file added eth/vm/forks/prague/logic.py
Empty file.
25 changes: 25 additions & 0 deletions eth/vm/forks/prague/opcodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import copy
from typing import (
Dict,
)

from eth_utils.toolz import (
merge,
)

from eth.abc import (
OpcodeAPI,
)
from eth.vm.forks.cancun.opcodes import (
CANCUN_OPCODES,
)

UPDATED_OPCODES: Dict[int, OpcodeAPI] = {}

NEW_OPCODES: Dict[int, OpcodeAPI] = {}

PRAGUE_OPCODES: Dict[int, OpcodeAPI] = merge(
copy.deepcopy(CANCUN_OPCODES),
UPDATED_OPCODES,
NEW_OPCODES,
)
7 changes: 7 additions & 0 deletions eth/vm/forks/prague/receipts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from eth.vm.forks.cancun.receipts import (
CancunReceiptBuilder,
)


class PragueReceiptBuilder(CancunReceiptBuilder):
pass
14 changes: 14 additions & 0 deletions eth/vm/forks/prague/state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from eth.vm.forks.cancun import (
CancunState,
)
from eth.vm.forks.cancun.state import (
CancunTransactionExecutor,
)


class PragueTransactionExecutor(CancunTransactionExecutor):
pass


class PragueState(CancunState):
pass
47 changes: 47 additions & 0 deletions eth/vm/forks/prague/transactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from abc import (
ABC,
)
from typing import (
Type,
)

import rlp

from eth.abc import (
SignedTransactionAPI,
)
from eth.rlp.transactions import (
SignedTransactionMethods,
)
from eth.vm.forks.berlin.transactions import (
TypedTransaction,
)
from eth.vm.forks.cancun.transactions import (
CancunLegacyTransaction,
CancunTransactionBuilder,
CancunUnsignedLegacyTransaction,
)


class PragueLegacyTransaction(CancunLegacyTransaction, ABC):
pass


class PragueUnsignedLegacyTransaction(CancunUnsignedLegacyTransaction):
pass


class SetCodeTransaction(
rlp.Serializable, SignedTransactionMethods, SignedTransactionAPI
):
pass


class PragueTypedTransaction(TypedTransaction):
pass


class PragueTransactionBuilder(CancunTransactionBuilder):
legacy_signed = PragueLegacyTransaction
legacy_unsigned = PragueUnsignedLegacyTransaction
typed_transaction: Type[TypedTransaction] = PragueTypedTransaction