Skip to content

Commit 8e5947e

Browse files
souradeep-dasSamWilsn
authored andcommitted
osaka: add specific exceptions on tests
1 parent efd5edb commit 8e5947e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/ethereum/osaka/exceptions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,13 @@ class InitCodeTooLargeError(InvalidTransaction):
113113
"""
114114
The init code of the transaction is too large.
115115
"""
116+
117+
118+
class TransactionGasLimitExceededError(InvalidTransaction):
119+
"""
120+
The transaction has specified a gas limit that is greater than the allowed
121+
maximum.
122+
123+
Note that this is _not_ the exception thrown when bytecode execution runs
124+
out of gas.
125+
"""

src/ethereum/osaka/transactions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
NonceOverflowError,
2020
)
2121

22-
from .exceptions import InitCodeTooLargeError, TransactionTypeError
22+
from .exceptions import (
23+
InitCodeTooLargeError,
24+
TransactionGasLimitExceededError,
25+
TransactionTypeError,
26+
)
2327
from .fork_types import Address, Authorization, VersionedHash
2428

2529
TX_BASE_COST = Uint(21000)
@@ -556,8 +560,10 @@ def validate_transaction(tx: Transaction) -> Tuple[Uint, Uint]:
556560
raise InsufficientTransactionGasError("Insufficient gas")
557561
if U256(tx.nonce) >= U256(U64.MAX_VALUE):
558562
raise NonceOverflowError("Nonce too high")
563+
if tx.to == Bytes0(b"") and len(tx.data) > MAX_INIT_CODE_SIZE:
564+
raise InitCodeTooLargeError("Code size too large")
559565
if tx.gas > TX_MAX_GAS_LIMIT:
560-
raise InvalidTransaction("Gas limit too high")
566+
raise TransactionGasLimitExceededError("Gas limit too high")
561567

562568
return intrinsic_gas, calldata_floor_gas_cost
563569

0 commit comments

Comments
 (0)