From 44a7fb188c3be4c8647c4a515b497aeb58819bdb Mon Sep 17 00:00:00 2001 From: Guruprasad Kamath <48196632+gurukamath@users.noreply.github.com> Date: Mon, 3 Feb 2025 08:44:19 +0100 Subject: [PATCH] port #1098 and #1011 to `forks/prague` (#1102) * port #1098 to prague * port #1011 to prague --- .github/workflows/gh-pages.yaml | 5 +++-- src/ethereum/prague/fork.py | 10 +++++++--- src/ethereum/prague/state.py | 6 +++--- src/ethereum/prague/vm/__init__.py | 3 ++- src/ethereum/prague/vm/interpreter.py | 9 +++++---- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yaml index 320f82f7f1..52d972d8cb 100644 --- a/.github/workflows/gh-pages.yaml +++ b/.github/workflows/gh-pages.yaml @@ -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 @@ -46,6 +46,7 @@ jobs: permissions: pages: write id-token: write + actions: read environment: name: github-pages @@ -54,4 +55,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/src/ethereum/prague/fork.py b/src/ethereum/prague/fork.py index f18c28d11d..32fbb8efac 100644 --- a/src/ethereum/prague/fork.py +++ b/src/ethereum/prague/fork.py @@ -20,7 +20,11 @@ from ethereum_types.numeric import U64, U256, Uint from ethereum.crypto.hash import Hash32, keccak256 -from ethereum.exceptions import InvalidBlock, InvalidSenderError +from ethereum.exceptions import ( + EthereumException, + InvalidBlock, + InvalidSenderError, +) from . import vm from .blocks import Block, Header, Log, Receipt, Withdrawal, encode_receipt @@ -453,7 +457,7 @@ def check_transaction( def make_receipt( tx: Transaction, - error: Optional[Exception], + error: Optional[EthereumException], cumulative_gas_used: Uint, logs: Tuple[Log, ...], ) -> Union[Bytes, Receipt]: @@ -925,7 +929,7 @@ def process_general_purpose_requests( def process_transaction( env: vm.Environment, tx: Transaction -) -> Tuple[Uint, Tuple[Log, ...], Optional[Exception]]: +) -> Tuple[Uint, Tuple[Log, ...], Optional[EthereumException]]: """ Execute a transaction against the provided environment. diff --git a/src/ethereum/prague/state.py b/src/ethereum/prague/state.py index eae92ed528..920ee6dd49 100644 --- a/src/ethereum/prague/state.py +++ b/src/ethereum/prague/state.py @@ -17,7 +17,7 @@ `EMPTY_ACCOUNT`. """ from dataclasses import dataclass, field -from typing import Callable, Dict, Iterable, List, Optional, Set, Tuple +from typing import Callable, Dict, List, Optional, Set, Tuple from ethereum_types.bytes import Bytes, Bytes32 from ethereum_types.frozen import modify @@ -719,7 +719,7 @@ def set_transient_storage( def destroy_touched_empty_accounts( - state: State, touched_accounts: Iterable[Address] + state: State, touched_accounts: Set[Address] ) -> None: """ Destroy all touched accounts that are empty. @@ -727,7 +727,7 @@ def destroy_touched_empty_accounts( ---------- state: `State` The current state. - touched_accounts: `Iterable[Address]` + touched_accounts: `Set[Address]` All the accounts that have been touched in the current transaction. """ for address in touched_accounts: diff --git a/src/ethereum/prague/vm/__init__.py b/src/ethereum/prague/vm/__init__.py index e73dba47bd..e2abe20d98 100644 --- a/src/ethereum/prague/vm/__init__.py +++ b/src/ethereum/prague/vm/__init__.py @@ -20,6 +20,7 @@ from ethereum_types.numeric import U64, U256, Uint from ethereum.crypto.hash import Hash32 +from ethereum.exceptions import EthereumException from ..blocks import Log from ..fork_types import Address, Authorization, VersionedHash @@ -95,7 +96,7 @@ class Evm: accounts_to_delete: Set[Address] touched_accounts: Set[Address] return_data: Bytes - error: Optional[Exception] + error: Optional[EthereumException] accessed_addresses: Set[Address] accessed_storage_keys: Set[Tuple[Address, Bytes32]] diff --git a/src/ethereum/prague/vm/interpreter.py b/src/ethereum/prague/vm/interpreter.py index df02758171..d105142452 100644 --- a/src/ethereum/prague/vm/interpreter.py +++ b/src/ethereum/prague/vm/interpreter.py @@ -12,11 +12,12 @@ A straightforward interpreter that executes EVM code. """ from dataclasses import dataclass -from typing import Iterable, Optional, Set, Tuple, Union +from typing import Optional, Set, Tuple from ethereum_types.bytes import Bytes, Bytes0 from ethereum_types.numeric import U256, Uint, ulen +from ethereum.exceptions import EthereumException from ethereum.trace import ( EvmStop, OpEnd, @@ -83,10 +84,10 @@ class MessageCallOutput: gas_left: Uint refund_counter: U256 - logs: Union[Tuple[()], Tuple[Log, ...]] + logs: Tuple[Log, ...] accounts_to_delete: Set[Address] - touched_accounts: Iterable[Address] - error: Optional[Exception] + touched_accounts: Set[Address] + error: Optional[EthereumException] return_data: Bytes