Skip to content

Commit 915b1ad

Browse files
souradeep-dasSamWilsn
authored andcommitted
add test cancun exception
1 parent 2be399c commit 915b1ad

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/ethereum/cancun/exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ class TransactionTypeError(InvalidTransaction):
2222
def __init__(self, transaction_type: int):
2323
super().__init__(f"unknown transaction type `{transaction_type}`")
2424
self.transaction_type = transaction_type
25+
26+
27+
class InsufficientMaxFeePerBlobGasError(InvalidTransaction):
28+
"""
29+
The maximum fee per blob gas is insufficient for the transaction.
30+
"""

src/ethereum/cancun/fork.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from . import vm
3030
from .blocks import Block, Header, Log, Receipt, Withdrawal, encode_receipt
3131
from .bloom import logs_bloom
32+
from .exceptions import InsufficientMaxFeePerBlobGasError
3233
from .fork_types import Account, Address, VersionedHash
3334
from .state import (
3435
State,
@@ -420,7 +421,7 @@ def check_transaction(
420421

421422
blob_gas_price = calculate_blob_gas_price(block_env.excess_blob_gas)
422423
if Uint(tx.max_fee_per_blob_gas) < blob_gas_price:
423-
raise InvalidBlock
424+
raise InsufficientMaxFeePerBlobGasError("insufficient max fee per blob gas")
424425

425426
max_gas_fee += Uint(calculate_total_blob_gas(tx)) * Uint(
426427
tx.max_fee_per_blob_gas

src/ethereum/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ class InvalidSignatureError(InvalidTransaction):
4040
Thrown when a transaction has an invalid signature.
4141
"""
4242

43+
4344
class InsufficientBalanceError(InvalidTransaction):
4445
"""
4546
Thrown when a transaction cannot be executed due to insufficient sender funds.
4647
"""
4748

49+
4850
class NonceMismatchError(InvalidTransaction):
4951
"""
5052
Thrown when a transaction's nonce does not match the expected nonce for the sender.
51-
"""
53+
"""

src/ethereum/prague/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, transaction_type: int):
2323
super().__init__(f"unknown transaction type `{transaction_type}`")
2424
self.transaction_type = transaction_type
2525

26+
2627
class TransactionTypeContractCreationError(InvalidTransaction):
2728
"""
2829
Transaction type is not allowed for contract creation.
@@ -37,36 +38,43 @@ def __init__(self, transaction_type: int):
3738
super().__init__(f"transaction type `{transaction_type}` not allowed for contract creation")
3839
self.transaction_type = transaction_type
3940

41+
4042
class BlobGasLimitExceededError(InvalidTransaction):
4143
"""
4244
The blob gas limit for the transaction exceeds the maximum allowed.
4345
"""
4446

47+
4548
class InsufficientMaxFeePerBlobGasError(InvalidTransaction):
4649
"""
4750
The maximum fee per blob gas is insufficient for the transaction.
4851
"""
4952

53+
5054
class InsufficientMaxFeePerGasError(InvalidTransaction):
5155
"""
5256
The maximum fee per gas is insufficient for the transaction.
5357
"""
5458

59+
5560
class InvalidBlobVersionedHashError(InvalidTransaction):
5661
"""
5762
The versioned hash of the blob is invalid.
5863
"""
5964

65+
6066
class NoBlobDataError(InvalidTransaction):
6167
"""
6268
The transaction does not contain any blob data.
6369
"""
6470

71+
6572
class PriorityFeeGreaterThanMaxFeeError(InvalidTransaction):
6673
"""
6774
The priority fee is greater than the maximum fee per gas.
6875
"""
6976

77+
7078
class EmptyAuthorizationListError(InvalidTransaction):
7179
"""
7280
The authorization list in the transaction is empty.

0 commit comments

Comments
 (0)