22
22
from ethereum .crypto .hash import Hash32 , keccak256
23
23
from ethereum .exceptions import (
24
24
EthereumException ,
25
+ GasUsedExceedsLimitError ,
25
26
InsufficientBalanceError ,
26
27
InvalidBlock ,
27
28
InvalidSenderError ,
@@ -417,7 +418,7 @@ def check_transaction(
417
418
blob_gas_available = MAX_BLOB_GAS_PER_BLOCK - block_output .blob_gas_used
418
419
419
420
if tx .gas > gas_available :
420
- raise InvalidBlock
421
+ raise GasUsedExceedsLimitError ( "gas used exceeds limit" )
421
422
422
423
tx_blob_gas_used = calculate_total_blob_gas (tx )
423
424
if tx_blob_gas_used > blob_gas_available :
@@ -434,7 +435,9 @@ def check_transaction(
434
435
"priority fee greater than max fee"
435
436
)
436
437
if tx .max_fee_per_gas < block_env .base_fee_per_gas :
437
- raise InsufficientMaxFeePerGasError ("insufficient max fee per gas" )
438
+ raise InsufficientMaxFeePerGasError (
439
+ tx .max_fee_per_gas , block_env .base_fee_per_gas
440
+ )
438
441
439
442
priority_fee_per_gas = min (
440
443
tx .max_priority_fee_per_gas ,
@@ -478,11 +481,11 @@ def check_transaction(
478
481
if not any (tx .authorizations ):
479
482
raise EmptyAuthorizationListError ("empty authorization list" )
480
483
481
- if sender_account .nonce != tx .nonce :
482
- if sender_account . nonce > Uint ( tx . nonce ):
483
- raise NonceMismatchError ( " nonce too low" )
484
- else :
485
- raise NonceMismatchError ( "nonce too high" )
484
+ if sender_account .nonce > Uint ( tx .nonce ) :
485
+ raise NonceMismatchError ( " nonce too low" )
486
+ elif sender_account . nonce < Uint ( tx . nonce ):
487
+ raise NonceMismatchError ( "nonce too high" )
488
+
486
489
if Uint (sender_account .balance ) < max_gas_fee + Uint (tx .value ):
487
490
raise InsufficientBalanceError ("insufficient sender balance" )
488
491
if sender_account .code and not is_valid_delegation (sender_account .code ):
0 commit comments