Skip to content

Commit 5c8daea

Browse files
committed
extended error categories & code ranges implementation
1 parent 9b06027 commit 5c8daea

File tree

4 files changed

+81
-12
lines changed

4 files changed

+81
-12
lines changed

scripts/build.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ extensionsSpecsFiles.forEach(file => {
9494
extensionSpecs.push(parsed);
9595
});
9696

97+
// Enhance the existing XErrorGroupsJSON extension with conditional validation for different error categories
98+
const enhancedErrorGroupSchema = JSON.parse(fs.readFileSync('src/extensions/schemas/x-error-category-ranges.json', 'utf8'));
99+
XErrorGroupsJSON.schema = enhancedErrorGroupSchema;
100+
97101
extensionSpecs.push(XErrorGroupsJSON);
98102

99103
let extensions = [];
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
x-error-group:
22
ExecutionErrors:
3-
- code: -31800
3+
- code: -31600
44
message: "NONCE_TOO_LOW"
55
data: "Transaction nonce is lower than the sender account's current nonce"
6-
- code: -31801
6+
x-error-category: "EXECUTION_ERRORS"
7+
- code: -31601
78
message: "NONCE_TOO_HIGH"
89
data: "Transaction nonce is higher than the sender account's current nonce"
9-
- code: -31802
10+
x-error-category: "EXECUTION_ERRORS"
11+
- code: -31602
1012
message: "EXECUTION_REVERTED"
1113
data: "Execution is reverted by REVERT Opcode"
12-
- code: -31803
14+
x-error-category: "EXECUTION_ERRORS"
15+
- code: -31603
1316
message: "INVALID_OPCODE"
1417
data: "An invalid opcode was encountered during execution"
15-
- code: -31804
18+
x-error-category: "EXECUTION_ERRORS"
19+
- code: -31604
1620
message: "OUT_OF_COUNTERS"
1721
data: "Not enough step counters to continue the execution"
18-
x-metadata:
19-
severity: "error"
20-
must-implement: true
21-
clients:
22-
- "polygon-cdk":
23-
- message: "Out of counters"
24-
- version: ">=0.5.0"
22+
x-error-category: "EXECUTION_ERRORS"

src/extensions/components/gas-error-groups.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,40 @@ x-error-group:
33
- code: -31800
44
message: "GAS_TOO_LOW"
55
data: "Transaction gas is too low / intrinsic gas too low"
6+
x-error-category: "GAS_ERRORS"
67
- code: -31801
78
message: "OUT_OF_GAS"
89
data: "The transaction ran out of gas"
10+
x-error-category: "GAS_ERRORS"
911
- code: -31802
1012
message: "GAS_PRICE_TOO_LOW"
1113
data: "Gas price too low / gas price below configured minimum gas price"
14+
x-error-category: "GAS_ERRORS"
1215
- code: -31803
1316
message: "BLOCK_GAS_LIMIT_EXCEEDED"
1417
data: "Tx gas limit exceeds max block gas limit / intrinsic gas exceeds gas limit"
18+
x-error-category: "GAS_ERRORS"
1519
- code: -31804
1620
message: "FEE_CAP_EXCEEDED"
1721
data: "Tx fee exceeds cap / max priority fee per gas higher than max fee per gas"
22+
x-error-category: "GAS_ERRORS"
1823
- code: -31805
1924
message: "GAS_OVERFLOW"
2025
data: "Gas overflow error"
26+
x-error-category: "GAS_ERRORS"
2127
- code: -31806
2228
message: "INSUFFICIENT_TRANSACTION_PRICE"
2329
data: "Transaction price must be greater than base fee / max fee per gas less than block base fee"
30+
x-error-category: "GAS_ERRORS"
2431
- code: -31807
2532
message: "INVALID_MAX_PRIORITY_FEE_PER_GAS"
2633
data: "Max priority fee per gas higher than 2^256-1"
34+
x-error-category: "GAS_ERRORS"
2735
- code: -31808
2836
message: "INVALID_MAX_FEE_PER_GAS"
2937
data: "Max fee per gas higher than 2^256-1"
38+
x-error-category: "GAS_ERRORS"
3039
- code: -31809
3140
message: "INSUFFICIENT_FUNDS"
3241
data: "Insufficient funds for gas * price + value"
42+
x-error-category: "GAS_ERRORS"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"type": "array",
3+
"items": {
4+
"oneOf": [
5+
{
6+
"type": "array",
7+
"items": {
8+
"allOf": [
9+
{
10+
"type": "object",
11+
"properties": {
12+
"code": { "type": "integer", "description": "The code of the error." },
13+
"message": { "type": "string", "description": "The message of the error." },
14+
"data": {"description": "The data of the error." },
15+
"x-error-category": { "type": "string"}
16+
},
17+
"required": ["code", "message"]
18+
},
19+
{
20+
"if": {
21+
"properties": {
22+
"x-error-category": { "const": "GAS_ERRORS" }
23+
},
24+
"required": ["x-error-category"]
25+
},
26+
"then": {
27+
"properties": {
28+
"code": { "type": "integer", "minimum": -31999, "maximum": -31800 }
29+
}
30+
}
31+
},
32+
{
33+
"if": {
34+
"properties": {
35+
"x-error-category": { "const": "EXECUTION_ERRORS" }
36+
},
37+
"required": ["x-error-category"]
38+
},
39+
"then": {
40+
"properties": {
41+
"code": { "type": "integer", "minimum": -31799, "maximum": -31600 }
42+
}
43+
}
44+
}
45+
]
46+
}
47+
},
48+
{
49+
"type": "object",
50+
"properties": {
51+
"$ref": { "type": "string" }
52+
},
53+
"required": ["$ref"]
54+
}
55+
]
56+
}
57+
}

0 commit comments

Comments
 (0)