Skip to content
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
12 changes: 7 additions & 5 deletions src/ethereum/osaka/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,6 @@ def process_transaction(
index:
Index of the transaction in the block.
"""
trie_set(
block_output.transactions_trie,
rlp.encode(index),
encode_transaction(tx),
)

intrinsic_gas, calldata_floor_gas_cost = validate_transaction(tx)

Expand Down Expand Up @@ -921,6 +916,7 @@ def process_transaction(
blob_versioned_hashes=blob_versioned_hashes,
authorizations=authorizations,
index_in_block=index,
transactions_root=root(block_output.transactions_trie),
tx_hash=get_transaction_hash(encode_transaction(tx)),
traces=[],
)
Expand Down Expand Up @@ -988,6 +984,12 @@ def process_transaction(
receipt,
)

trie_set(
block_output.transactions_trie,
rlp.encode(index),
encode_transaction(tx),
)

block_output.block_logs += tx_output.logs


Expand Down
1 change: 1 addition & 0 deletions src/ethereum/osaka/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class TransactionEnvironment:
blob_versioned_hashes: Tuple[VersionedHash, ...]
authorizations: Tuple[Authorization, ...]
index_in_block: Optional[Uint]
transactions_root: Hash32
tx_hash: Optional[Hash32]
traces: List[dict]

Expand Down
2 changes: 2 additions & 0 deletions src/ethereum/osaka/vm/instructions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Ops(enum.Enum):
BASEFEE = 0x48
BLOBHASH = 0x49
BLOBBASEFEE = 0x4A
TXROOT = 0x4B

# Control Flow Ops
STOP = 0x00
Expand Down Expand Up @@ -252,6 +253,7 @@ class Ops(enum.Enum):
Ops.PREVRANDAO: block_instructions.prev_randao,
Ops.GASLIMIT: block_instructions.gas_limit,
Ops.CHAINID: block_instructions.chain_id,
Ops.TXROOT: block_instructions.tx_root,
Ops.MLOAD: memory_instructions.mload,
Ops.MSTORE: memory_instructions.mstore,
Ops.MSTORE8: memory_instructions.mstore8,
Expand Down
29 changes: 29 additions & 0 deletions src/ethereum/osaka/vm/instructions/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,32 @@ def chain_id(evm: Evm) -> None:

# PROGRAM COUNTER
evm.pc += Uint(1)


def tx_root(evm: Evm) -> None:
"""
Push the incremental transactions root of this block onto the stack.

Parameters
----------
evm :
The current EVM frame.

Raises
------
:py:class:`~ethereum.osaka.vm.exceptions.StackOverflowError`
If `len(stack)` is equal to `1024`.
:py:class:`~ethereum.osaka.vm.exceptions.OutOfGasError`
If `evm.gas_left` is less than `2`.
"""
# STACK
pass

# GAS
charge_gas(evm, GAS_BASE)

# OPERATION
push(evm.stack, U256.from_be_bytes(evm.message.tx_env.transactions_root))

# PROGRAM COUNTER
evm.pc += Uint(1)