Skip to content

Commit 830fcd8

Browse files
authored
Standardize debug namespace (#247)
* add debug namespace * fix typo * capitalize rlp * make receipts plural * remove set head * clarify receipt encoding * add raw prefix * add tests for debug methods * add debug_getRawTransaction * add bad block for tests
1 parent 263c1c2 commit 830fcd8

File tree

17 files changed

+111
-3
lines changed

17 files changed

+111
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"main": "index.js",
66
"type": "module",
77
"scripts": {
8-
"build": "npm run clean && npm run build:spec && npm run generate-clients",
8+
"build": "npm run build:spec",
99
"build:spec": "node scripts/build.js",
10-
"build:docs": "cd build/docs/gatsby && npm install --legacy-peer-deps && gatsby build --prefix-paths",
10+
"build:docs": "mkdir -p build && npm run generate-clients && cd build/docs/gatsby && npm install --legacy-peer-deps && gatsby build --prefix-paths",
1111
"lint": "node scripts/build.js && node scripts/validate.js && node scripts/graphql-validate.js",
1212
"clean": "rm -rf build && mkdir -p build",
1313
"generate-clients": "open-rpc-generator generate -c open-rpc-generator-config.json",

scripts/build.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ methodFiles.forEach(file => {
1818
];
1919
});
2020

21+
methodsBase = "src/debug/";
22+
methodFiles = fs.readdirSync(methodsBase);
23+
methodFiles.forEach(file => {
24+
console.log(file);
25+
let raw = fs.readFileSync(methodsBase + file);
26+
let parsed = yaml.load(raw);
27+
methods = [
28+
...methods,
29+
...parsed,
30+
];
31+
});
32+
2133
let schemas = {};
2234
let schemasBase = "src/schemas/"
2335
let schemaFiles = fs.readdirSync(schemasBase);

src/debug/getters.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
- name: debug_getRawHeader
2+
summary: Returns an RLP-encoded header.
3+
params:
4+
- name: Block
5+
required: true
6+
schema:
7+
$ref: '#/components/schemas/BlockNumberOrTag'
8+
result:
9+
name: Header RLP
10+
schema:
11+
$ref: '#/components/schemas/bytes'
12+
- name: debug_getRawBlock
13+
summary: Returns an RLP-encoded block.
14+
params:
15+
- name: Block
16+
required: true
17+
schema:
18+
$ref: '#/components/schemas/BlockNumberOrTag'
19+
result:
20+
name: Block RLP
21+
schema:
22+
$ref: '#/components/schemas/bytes'
23+
- name: debug_getRawTransaction
24+
summary: Returns an array of EIP-2718 binary-encoded transactions.
25+
params:
26+
- name: Transaction hash
27+
required: true
28+
schema:
29+
$ref: '#/components/schemas/hash32'
30+
result:
31+
name: EIP-2718 binary-encoded transaction
32+
schema:
33+
$ref: '#/components/schemas/bytes'
34+
- name: debug_getRawReceipts
35+
summary: Returns an array of EIP-2718 binary-encoded receipts.
36+
params:
37+
- name: Block
38+
required: true
39+
schema:
40+
$ref: '#/components/schemas/BlockNumberOrTag'
41+
result:
42+
name: Receipts
43+
schema:
44+
title: Receipt array
45+
type: array
46+
items:
47+
$ref: '#/components/schemas/bytes'
48+
- name: debug_getBadBlocks
49+
summary: Returns an array of recent bad blocks that the client has seen on the network.
50+
params: []
51+
result:
52+
name: Blocks
53+
schema:
54+
title: Bad block array
55+
type: array
56+
items:
57+
$ref: '#/components/schemas/BadBlock'

src/schemas/base-types.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ uint:
3838
uint64:
3939
title: hex encoded unsigned integer
4040
type: string
41-
pattern: ^0x([1-9a-f][0-9a-f]{0,31})|0$
41+
pattern: ^0x([1-9a-f][0-9a-f]{0,15})|0$
4242
uint256:
4343
title: hex encoded unsigned integer
4444
type: string

src/schemas/block.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,20 @@ BlockNumberOrTag:
106106
$ref: '#/components/schemas/uint'
107107
- title: Block tag
108108
$ref: '#/components/schemas/BlockTag'
109+
BadBlock:
110+
title: Bad block
111+
type: object
112+
required:
113+
- block
114+
- hash
115+
- rlp
116+
properties:
117+
block:
118+
title: Block
119+
$ref: '#/components/schemas/bytes'
120+
hash:
121+
title: Hash
122+
$ref: '#/components/schemas/hash32'
123+
rlp:
124+
title: RLP
125+
$ref: '#/components/schemas/bytes'

tests/bad.rlp

620 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>> {"jsonrpc":"2.0","id":5,"method":"debug_getRawBlock","params":["0x3"]}
2+
<< {"jsonrpc":"2.0","id":5,"result":"0xf90269f901faa087a74234d5ad70c6ff8e89ffd305fa85048e6cbb4045d66b43a7bf03fe9b6171a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09ba750cfccbb3e45e010229e805d1d854befeb2701745e93f975dbc965f737a5a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000003834c4b408252081e80a00b43d19e6220dd7b4e8018a5046283377354ab021f49cdd082dfe167c86502fe8836a52bdb03334a2d842806be9df869f86702842806be9e82520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a040ce7918eeb045ebf8c8b1887ca139d076bda00fa828a07881d442a72626c42da0156576a68e456e295e4c9cf67cf9f53151f329438916e0f24fc69d6bbb7fbacfc0"}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>> {"jsonrpc":"2.0","id":4,"method":"debug_getRawBlock","params":["0x0"]}
2+
<< {"jsonrpc":"2.0","id":4,"result":"0xf901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0078dc6061b1d8eaa8493384b59c9c65ceb917201221d08b80c4de6770b6ec7e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00c0c0"}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>> {"jsonrpc":"2.0","id":6,"method":"debug_getRawBlock","params":["2"]}
2+
<< {"jsonrpc":"2.0","id":6,"error":{"code":-32602,"message":"invalid argument 0: hex string without 0x prefix"}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>> {"jsonrpc":"2.0","id":2,"method":"debug_getRawHeader","params":["0x3"]}
2+
<< {"jsonrpc":"2.0","id":2,"result":"0xf901faa087a74234d5ad70c6ff8e89ffd305fa85048e6cbb4045d66b43a7bf03fe9b6171a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09ba750cfccbb3e45e010229e805d1d854befeb2701745e93f975dbc965f737a5a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000003834c4b408252081e80a00b43d19e6220dd7b4e8018a5046283377354ab021f49cdd082dfe167c86502fe8836a52bdb03334a2d842806be9d"}

0 commit comments

Comments
 (0)