Skip to content

Commit 14a7429

Browse files
feat(clis/exceptions): Exception Mapper Updates from Static Tests (#1493)
* feat(clis): Exceptions from static tests pt1 * fix: more mapper exceptions * fix(clis/ethereumjs): tox * added two ergion mappings as requested by som * fix: erigon exceptions move * fix(clis/erigon): Add invalid gas used exception * feat(exceptions): Add Invalid-Gas-Used-Above-Limit * feat(clis/all): Add exception messages --------- Co-authored-by: Felix H <[email protected]>
1 parent 2cc73e3 commit 14a7429

File tree

7 files changed

+43
-4
lines changed

7 files changed

+43
-4
lines changed

src/ethereum_clis/clis/besu.py

+6
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,17 @@ class BesuExceptionMapper(ExceptionMapper):
213213
"""Translate between EEST exceptions and error strings returned by Besu."""
214214

215215
mapping_substring: ClassVar[Dict[ExceptionBase, str]] = {
216+
TransactionException.NONCE_IS_MAX: "invalid Nonce must be less than",
216217
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS: (
217218
"transaction invalid tx max fee per blob gas less than block blob gas fee"
218219
),
220+
TransactionException.GASLIMIT_PRICE_PRODUCT_OVERFLOW: (
221+
"invalid Upfront gas cost cannot exceed 2^256 Wei"
222+
),
219223
TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS: (
220224
"transaction invalid gasPrice is less than the current BaseFee"
221225
),
226+
TransactionException.GAS_ALLOWANCE_EXCEEDED: "provided gas insufficient",
222227
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS: (
223228
"transaction invalid max priority fee per gas cannot be greater than max fee per gas"
224229
),
@@ -259,6 +264,7 @@ class BesuExceptionMapper(ExceptionMapper):
259264
BlockException.INCORRECT_BLOB_GAS_USED: (
260265
"Payload BlobGasUsed does not match calculated BlobGasUsed"
261266
),
267+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: "Header validation failed (FULL)",
262268
# TODO EVMONE needs to differentiate when the section is missing in the header or body
263269
EOFException.MISSING_STOP_OPCODE: "err: no_terminating_instruction",
264270
EOFException.MISSING_CODE_HEADER: "err: code_section_missing",

src/ethereum_clis/clis/erigon.py

+6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ class ErigonExceptionMapper(ExceptionMapper):
1212
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS: (
1313
"insufficient funds for gas * price + value"
1414
),
15+
TransactionException.NONCE_IS_MAX: "nonce has max value",
1516
TransactionException.INTRINSIC_GAS_TOO_LOW: "intrinsic gas too low",
1617
TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS: "fee cap less than block base fee",
1718
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS: "tip higher than fee cap",
1819
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS: "max fee per blob gas too low",
1920
TransactionException.NONCE_MISMATCH_TOO_LOW: "nonce too low",
21+
TransactionException.GAS_ALLOWANCE_EXCEEDED: "gas limit reached",
2022
TransactionException.TYPE_3_TX_PRE_FORK: "blob txn is not supported by signer",
2123
TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH: (
2224
"invalid blob versioned hash, must start with VERSIONED_HASH_VERSION_KZG"
@@ -33,10 +35,14 @@ class ErigonExceptionMapper(ExceptionMapper):
3335
TransactionException.TYPE_4_TX_CONTRACT_CREATION: "wrong size for To: 0",
3436
TransactionException.TYPE_4_TX_PRE_FORK: "setCode tx is not supported by signer",
3537
TransactionException.INVALID_DEPOSIT_EVENT_LAYOUT: "could not parse requests logs",
38+
BlockException.SYSTEM_CONTRACT_EMPTY: "Syscall failure: Empty Code at",
39+
BlockException.SYSTEM_CONTRACT_CALL_FAILED: "Unprecedented Syscall failure",
3640
BlockException.INVALID_REQUESTS: "invalid requests root hash in header",
3741
BlockException.INVALID_BLOCK_HASH: "invalid block hash",
3842
}
3943
mapping_regex = {
4044
BlockException.INCORRECT_BLOB_GAS_USED: r"blobGasUsed by execution: \d+, in header: \d+",
4145
BlockException.INCORRECT_EXCESS_BLOB_GAS: r"invalid excessBlobGas: have \d+, want \d+",
46+
BlockException.INVALID_GAS_USED: r"gas used by execution: \w+, in header: \w+",
47+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: r"invalid gasUsed: have \d+, gasLimit \d+",
4248
}

src/ethereum_clis/clis/ethereumjs.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ class EthereumJSExceptionMapper(ExceptionMapper):
5555
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS: (
5656
"Invalid 4844 transactions: undefined"
5757
),
58-
TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS: (
59-
"tx unable to pay base fee (EIP-1559 tx)"
58+
TransactionException.GASLIMIT_PRICE_PRODUCT_OVERFLOW: (
59+
"gas limit * gasPrice cannot exceed MAX_INTEGER"
6060
),
61+
TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS: "tx unable to pay base fee",
62+
TransactionException.NONCE_IS_MAX: "nonce cannot equal or exceed",
6163
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS: (
6264
"maxFeePerGas cannot be less than maxPriorityFeePerGas"
6365
),
@@ -85,7 +87,10 @@ class EthereumJSExceptionMapper(ExceptionMapper):
8587
"sender doesn't have enough funds to send tx"
8688
),
8789
TransactionException.NONCE_MISMATCH_TOO_LOW: "the tx doesn't have the correct nonce",
88-
TransactionException.INVALID_DEPOSIT_EVENT_LAYOUT: "Error verifying block while running",
90+
TransactionException.INVALID_DEPOSIT_EVENT_LAYOUT: (
91+
"Error verifying block while running: error: number exceeds 53 bits"
92+
),
93+
TransactionException.GAS_ALLOWANCE_EXCEEDED: "tx has a higher gas limit than the block",
8994
BlockException.INCORRECT_EXCESS_BLOB_GAS: "Invalid 4844 transactions",
9095
BlockException.INVALID_RECEIPTS_ROOT: "invalid receipttrie",
9196
# TODO EVMONE needs to differentiate when the section is missing in the header or body
@@ -147,4 +152,7 @@ class EthereumJSExceptionMapper(ExceptionMapper):
147152
r"Invalid blockHash, expected: 0x[0-9a-f]+, received: 0x[0-9a-f]+"
148153
),
149154
BlockException.INVALID_REQUESTS: r"Unknown request identifier|invalid requestshash",
155+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: (
156+
r"Invalid block: too much gas used. Used: \d+, gas limit: \d+"
157+
),
150158
}

src/ethereum_clis/clis/geth.py

+3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ class GethExceptionMapper(ExceptionMapper):
2929

3030
mapping_substring: ClassVar[Dict[ExceptionBase, str]] = {
3131
TransactionException.SENDER_NOT_EOA: "sender not an eoa",
32+
TransactionException.GAS_ALLOWANCE_EXCEEDED: "gas limit reached",
3233
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS: (
3334
"insufficient funds for gas * price + value"
3435
),
36+
TransactionException.NONCE_IS_MAX: "nonce has max value",
3537
TransactionException.TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED: (
3638
"would exceed maximum allowance"
3739
),
@@ -122,6 +124,7 @@ class GethExceptionMapper(ExceptionMapper):
122124
BlockException.BLOB_GAS_USED_ABOVE_LIMIT: (
123125
r"blob gas used \d+ exceeds maximum allowance \d+"
124126
),
127+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: r"invalid gasUsed: have \d+, gasLimit \d+",
125128
}
126129

127130

src/ethereum_clis/clis/nethermind.py

+5
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ class NethermindExceptionMapper(ExceptionMapper):
328328
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS: (
329329
"InvalidMaxPriorityFeePerGas: Cannot be higher than maxFeePerGas"
330330
),
331+
TransactionException.GAS_ALLOWANCE_EXCEEDED: "Block gas limit exceeded",
332+
TransactionException.NONCE_IS_MAX: "nonce overflow",
331333
TransactionException.INITCODE_SIZE_EXCEEDED: "max initcode size exceeded",
332334
TransactionException.NONCE_MISMATCH_TOO_LOW: "wrong transaction nonce",
333335
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS: (
@@ -354,6 +356,9 @@ class NethermindExceptionMapper(ExceptionMapper):
354356
"HeaderBlobGasMismatch: Blob gas in header does not match calculated"
355357
),
356358
BlockException.INVALID_REQUESTS: "InvalidRequestsHash: Requests hash mismatch in block",
359+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: (
360+
"ExceededGasLimit: Gas used exceeds gas limit."
361+
),
357362
}
358363
mapping_regex = {
359364
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS: (

src/ethereum_clis/clis/reth.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class RethExceptionMapper(ExceptionMapper):
1919
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS: (
2020
"priority fee is greater than max fee"
2121
),
22+
TransactionException.GASLIMIT_PRICE_PRODUCT_OVERFLOW: "overflow",
2223
TransactionException.TYPE_3_TX_CONTRACT_CREATION: "unexpected length",
2324
TransactionException.TYPE_3_TX_WITH_FULL_BLOBS: "unexpected list",
2425
TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH: "blob version not supported",
@@ -47,11 +48,17 @@ class RethExceptionMapper(ExceptionMapper):
4748
TransactionException.TYPE_3_TX_ZERO_BLOBS: (
4849
r"blob transactions present in pre-cancun payload|empty blobs"
4950
),
50-
BlockException.SYSTEM_CONTRACT_CALL_FAILED: (r"failed to apply .* requests contract call"),
51+
TransactionException.GAS_ALLOWANCE_EXCEEDED: (
52+
r"transaction gas limit \w+ is more than blocks available gas \w+"
53+
),
54+
BlockException.SYSTEM_CONTRACT_CALL_FAILED: r"failed to apply .* requests contract call",
5155
BlockException.INCORRECT_BLOB_GAS_USED: (
5256
r"blob gas used mismatch|blob gas used \d+ is not a multiple of blob gas per blob"
5357
),
5458
BlockException.INCORRECT_EXCESS_BLOB_GAS: (
5559
r"excess blob gas \d+ is not a multiple of blob gas per blob|invalid excess blob gas"
5660
),
61+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: (
62+
r"block used gas \(\d+\) is greater than gas limit \(\d+\)"
63+
),
5764
}

src/ethereum_test_exceptions/exceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ class BlockException(ExceptionBase):
495495
"""
496496
Block header's actual gas used does not match the provided header's value
497497
"""
498+
INVALID_GAS_USED_ABOVE_LIMIT = auto()
499+
"""
500+
Block header's gas used value is above the gas limit field's value.
501+
"""
498502
INVALID_WITHDRAWALS_ROOT = auto()
499503
"""
500504
Block header's withdrawals root does not match calculated withdrawals root.

0 commit comments

Comments
 (0)