Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize debug namespace #247

Merged
merged 10 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"main": "index.js",
"type": "module",
"scripts": {
"build": "npm run clean && npm run build:spec && npm run generate-clients",
"build": "npm run build:spec",
"build:spec": "node scripts/build.js",
"build:docs": "cd build/docs/gatsby && npm install --legacy-peer-deps && gatsby build --prefix-paths",
"build:docs": "mkdir -p build && npm run generate-clients && cd build/docs/gatsby && npm install --legacy-peer-deps && gatsby build --prefix-paths",
"lint": "node scripts/build.js && node scripts/validate.js && node scripts/graphql-validate.js",
"clean": "rm -rf build && mkdir -p build",
"generate-clients": "open-rpc-generator generate -c open-rpc-generator-config.json",
Expand Down
12 changes: 12 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ methodFiles.forEach(file => {
];
});

methodsBase = "src/debug/";
methodFiles = fs.readdirSync(methodsBase);
methodFiles.forEach(file => {
console.log(file);
let raw = fs.readFileSync(methodsBase + file);
let parsed = yaml.load(raw);
methods = [
...methods,
...parsed,
];
});

let schemas = {};
let schemasBase = "src/schemas/"
let schemaFiles = fs.readdirSync(schemasBase);
Expand Down
57 changes: 57 additions & 0 deletions src/debug/getters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
- name: debug_getRawHeader
summary: Returns an RLP-encoded header.
params:
- name: Block
required: true
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
result:
name: Header RLP
schema:
$ref: '#/components/schemas/bytes'
- name: debug_getRawBlock
summary: Returns an RLP-encoded block.
params:
- name: Block
required: true
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
result:
name: Block RLP
schema:
$ref: '#/components/schemas/bytes'
- name: debug_getRawTransaction
summary: Returns an array of EIP-2718 binary-encoded transactions.
params:
- name: Transaction hash
required: true
schema:
$ref: '#/components/schemas/hash32'
result:
name: EIP-2718 binary-encoded transaction
schema:
$ref: '#/components/schemas/bytes'
- name: debug_getRawReceipts
summary: Returns an array of EIP-2718 binary-encoded receipts.
params:
- name: Block
required: true
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
result:
name: Receipts
schema:
title: Receipt array
type: array
items:
$ref: '#/components/schemas/bytes'
- name: debug_getBadBlocks
summary: Returns an array of recent bad blocks that the client has seen on the network.
params: []
result:
name: Blocks
schema:
title: Bad block array
type: array
items:
$ref: '#/components/schemas/BadBlock'
2 changes: 1 addition & 1 deletion src/schemas/base-types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ uint:
uint64:
title: hex encoded unsigned integer
type: string
pattern: ^0x([1-9a-f][0-9a-f]{0,31})|0$
pattern: ^0x([1-9a-f][0-9a-f]{0,15})|0$
uint256:
title: hex encoded unsigned integer
type: string
Expand Down
17 changes: 17 additions & 0 deletions src/schemas/block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,20 @@ BlockNumberOrTag:
$ref: '#/components/schemas/uint'
- title: Block tag
$ref: '#/components/schemas/BlockTag'
BadBlock:
title: Bad block
type: object
required:
- block
- hash
- rlp
properties:
block:
title: Block
$ref: '#/components/schemas/bytes'
hash:
title: Hash
$ref: '#/components/schemas/hash32'
rlp:
title: RLP
$ref: '#/components/schemas/bytes'
Binary file added tests/bad.rlp
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/debug_getRawBlock/get-block-n.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":5,"method":"debug_getRawBlock","params":["0x3"]}
<< {"jsonrpc":"2.0","id":5,"result":"0xf90269f901faa087a74234d5ad70c6ff8e89ffd305fa85048e6cbb4045d66b43a7bf03fe9b6171a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09ba750cfccbb3e45e010229e805d1d854befeb2701745e93f975dbc965f737a5a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000003834c4b408252081e80a00b43d19e6220dd7b4e8018a5046283377354ab021f49cdd082dfe167c86502fe8836a52bdb03334a2d842806be9df869f86702842806be9e82520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a040ce7918eeb045ebf8c8b1887ca139d076bda00fa828a07881d442a72626c42da0156576a68e456e295e4c9cf67cf9f53151f329438916e0f24fc69d6bbb7fbacfc0"}
2 changes: 2 additions & 0 deletions tests/debug_getRawBlock/get-genesis.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":4,"method":"debug_getRawBlock","params":["0x0"]}
<< {"jsonrpc":"2.0","id":4,"result":"0xf901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0078dc6061b1d8eaa8493384b59c9c65ceb917201221d08b80c4de6770b6ec7e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00c0c0"}
2 changes: 2 additions & 0 deletions tests/debug_getRawBlock/get-invalid-number.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":6,"method":"debug_getRawBlock","params":["2"]}
<< {"jsonrpc":"2.0","id":6,"error":{"code":-32602,"message":"invalid argument 0: hex string without 0x prefix"}}
2 changes: 2 additions & 0 deletions tests/debug_getRawHeader/get-block-n.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":2,"method":"debug_getRawHeader","params":["0x3"]}
<< {"jsonrpc":"2.0","id":2,"result":"0xf901faa087a74234d5ad70c6ff8e89ffd305fa85048e6cbb4045d66b43a7bf03fe9b6171a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09ba750cfccbb3e45e010229e805d1d854befeb2701745e93f975dbc965f737a5a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000003834c4b408252081e80a00b43d19e6220dd7b4e8018a5046283377354ab021f49cdd082dfe167c86502fe8836a52bdb03334a2d842806be9d"}
2 changes: 2 additions & 0 deletions tests/debug_getRawHeader/get-genesis.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":1,"method":"debug_getRawHeader","params":["0x0"]}
<< {"jsonrpc":"2.0","id":1,"result":"0xf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0078dc6061b1d8eaa8493384b59c9c65ceb917201221d08b80c4de6770b6ec7e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00"}
2 changes: 2 additions & 0 deletions tests/debug_getRawHeader/get-invalid-number.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":3,"method":"debug_getRawHeader","params":["2"]}
<< {"jsonrpc":"2.0","id":3,"error":{"code":-32602,"message":"invalid argument 0: hex string without 0x prefix"}}
2 changes: 2 additions & 0 deletions tests/debug_getRawReceipts/get-block-n.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":8,"method":"debug_getRawReceipts","params":["0x3"]}
<< {"jsonrpc":"2.0","id":8,"result":["0xf9010801825208b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0"]}
2 changes: 2 additions & 0 deletions tests/debug_getRawReceipts/get-genesis.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":7,"method":"debug_getRawReceipts","params":["0x0"]}
<< {"jsonrpc":"2.0","id":7,"result":[]}
2 changes: 2 additions & 0 deletions tests/debug_getRawReceipts/get-invalid-number.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":9,"method":"debug_getRawReceipts","params":["2"]}
<< {"jsonrpc":"2.0","id":9,"error":{"code":-32602,"message":"invalid argument 0: hex string without 0x prefix"}}
2 changes: 2 additions & 0 deletions tests/debug_getRawTransaction/get-invalid-hash.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":11,"method":"debug_getRawTransaction","params":["1000000000000000000000000000000000000000000000000000000000000001"]}
<< {"jsonrpc":"2.0","id":11,"error":{"code":-32602,"message":"invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type common.Hash"}}
2 changes: 2 additions & 0 deletions tests/debug_getRawTransaction/get-tx.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":10,"method":"debug_getRawTransaction","params":["0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b"]}
<< {"jsonrpc":"2.0","id":10,"result":"0xf8678084342770c182520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a0af5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60a0201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}