Skip to content

Commit 98b76ee

Browse files
BrechtpdSamWilsn
authored andcommitted
Implement EIP-7814
1 parent 5a49b2f commit 98b76ee

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/ethereum/osaka/fork.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ def process_transaction(
921921
blob_versioned_hashes=blob_versioned_hashes,
922922
authorizations=authorizations,
923923
index_in_block=index,
924+
transactions_root=root(block_output.transactions_trie),
924925
tx_hash=get_transaction_hash(encode_transaction(tx)),
925926
traces=[],
926927
)

src/ethereum/osaka/vm/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class TransactionEnvironment:
107107
blob_versioned_hashes: Tuple[VersionedHash, ...]
108108
authorizations: Tuple[Authorization, ...]
109109
index_in_block: Optional[Uint]
110+
transactions_root: Hash32
110111
tx_hash: Optional[Hash32]
111112
traces: List[dict]
112113

src/ethereum/osaka/vm/instructions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class Ops(enum.Enum):
100100
BASEFEE = 0x48
101101
BLOBHASH = 0x49
102102
BLOBBASEFEE = 0x4A
103+
TXROOT = 0x4B
103104

104105
# Control Flow Ops
105106
STOP = 0x00
@@ -252,6 +253,7 @@ class Ops(enum.Enum):
252253
Ops.PREVRANDAO: block_instructions.prev_randao,
253254
Ops.GASLIMIT: block_instructions.gas_limit,
254255
Ops.CHAINID: block_instructions.chain_id,
256+
Ops.TXROOT: block_instructions.tx_root,
255257
Ops.MLOAD: memory_instructions.mload,
256258
Ops.MSTORE: memory_instructions.mstore,
257259
Ops.MSTORE8: memory_instructions.mstore8,

src/ethereum/osaka/vm/instructions/block.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,32 @@ def chain_id(evm: Evm) -> None:
253253

254254
# PROGRAM COUNTER
255255
evm.pc += Uint(1)
256+
257+
258+
def tx_root(evm: Evm) -> None:
259+
"""
260+
Push the incremental transactions root of this block onto the stack.
261+
262+
Parameters
263+
----------
264+
evm :
265+
The current EVM frame.
266+
267+
Raises
268+
------
269+
:py:class:`~ethereum.osaka.vm.exceptions.StackOverflowError`
270+
If `len(stack)` is equal to `1024`.
271+
:py:class:`~ethereum.osaka.vm.exceptions.OutOfGasError`
272+
If `evm.gas_left` is less than `2`.
273+
"""
274+
# STACK
275+
pass
276+
277+
# GAS
278+
charge_gas(evm, GAS_BASE)
279+
280+
# OPERATION
281+
push(evm.stack, U256.from_be_bytes(evm.message.tx_env.transactions_root))
282+
283+
# PROGRAM COUNTER
284+
evm.pc += Uint(1)

0 commit comments

Comments
 (0)