Skip to content

Commit 2d2e8d9

Browse files
souradeep-dasSamWilsn
authored andcommitted
add exception for arrow_glacier
1 parent 6309cde commit 2d2e8d9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ethereum/arrow_glacier/fork.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
2424
from ethereum.exceptions import (
2525
EthereumException,
26+
GasUsedExceedsLimitError,
27+
InsufficientBalanceError,
2628
InvalidBlock,
2729
InvalidSenderError,
30+
NonceMismatchError,
2831
)
2932

3033
from . import vm
@@ -445,7 +448,7 @@ def check_transaction(
445448
"""
446449
gas_available = block_env.block_gas_limit - block_output.block_gas_used
447450
if tx.gas > gas_available:
448-
raise InvalidBlock
451+
raise GasUsedExceedsLimitError("gas used exceeds limit")
449452
sender_address = recover_sender(block_env.chain_id, tx)
450453
sender_account = get_account(block_env.state, sender_address)
451454

@@ -467,10 +470,12 @@ def check_transaction(
467470
effective_gas_price = tx.gas_price
468471
max_gas_fee = tx.gas * tx.gas_price
469472

470-
if sender_account.nonce != tx.nonce:
471-
raise InvalidBlock
473+
if sender_account.nonce > Uint(tx.nonce):
474+
raise NonceMismatchError("nonce too low")
475+
elif sender_account.nonce < Uint(tx.nonce):
476+
raise NonceMismatchError("nonce too high")
472477
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
473-
raise InvalidBlock
478+
raise InsufficientBalanceError("insufficient sender balance")
474479
if sender_account.code:
475480
raise InvalidSenderError("not EOA")
476481

0 commit comments

Comments
 (0)