diff --git a/package.json b/package.json index edfa3ea30..c28e756f4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/build.js b/scripts/build.js index 1d53b62c8..7b0c5cde1 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -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); diff --git a/src/debug/getters.yaml b/src/debug/getters.yaml new file mode 100644 index 000000000..6d28d9f3e --- /dev/null +++ b/src/debug/getters.yaml @@ -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' diff --git a/src/schemas/base-types.yaml b/src/schemas/base-types.yaml index e1c40b5f4..a657f6330 100644 --- a/src/schemas/base-types.yaml +++ b/src/schemas/base-types.yaml @@ -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 diff --git a/src/schemas/block.yaml b/src/schemas/block.yaml index a98ab262d..00f576103 100644 --- a/src/schemas/block.yaml +++ b/src/schemas/block.yaml @@ -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' diff --git a/tests/bad.rlp b/tests/bad.rlp new file mode 100644 index 000000000..a95f76f31 Binary files /dev/null and b/tests/bad.rlp differ diff --git a/tests/debug_getRawBlock/get-block-n.io b/tests/debug_getRawBlock/get-block-n.io new file mode 100644 index 000000000..97c88b208 --- /dev/null +++ b/tests/debug_getRawBlock/get-block-n.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":5,"method":"debug_getRawBlock","params":["0x3"]} +<< {"jsonrpc":"2.0","id":5,"result":"0xf90269f901faa087a74234d5ad70c6ff8e89ffd305fa85048e6cbb4045d66b43a7bf03fe9b6171a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09ba750cfccbb3e45e010229e805d1d854befeb2701745e93f975dbc965f737a5a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000003834c4b408252081e80a00b43d19e6220dd7b4e8018a5046283377354ab021f49cdd082dfe167c86502fe8836a52bdb03334a2d842806be9df869f86702842806be9e82520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a040ce7918eeb045ebf8c8b1887ca139d076bda00fa828a07881d442a72626c42da0156576a68e456e295e4c9cf67cf9f53151f329438916e0f24fc69d6bbb7fbacfc0"} diff --git a/tests/debug_getRawBlock/get-genesis.io b/tests/debug_getRawBlock/get-genesis.io new file mode 100644 index 000000000..1e1e77ddc --- /dev/null +++ b/tests/debug_getRawBlock/get-genesis.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":4,"method":"debug_getRawBlock","params":["0x0"]} +<< {"jsonrpc":"2.0","id":4,"result":"0xf901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0078dc6061b1d8eaa8493384b59c9c65ceb917201221d08b80c4de6770b6ec7e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00c0c0"} diff --git a/tests/debug_getRawBlock/get-invalid-number.io b/tests/debug_getRawBlock/get-invalid-number.io new file mode 100644 index 000000000..3ccc1709a --- /dev/null +++ b/tests/debug_getRawBlock/get-invalid-number.io @@ -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"}} diff --git a/tests/debug_getRawHeader/get-block-n.io b/tests/debug_getRawHeader/get-block-n.io new file mode 100644 index 000000000..08abc4443 --- /dev/null +++ b/tests/debug_getRawHeader/get-block-n.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":2,"method":"debug_getRawHeader","params":["0x3"]} +<< {"jsonrpc":"2.0","id":2,"result":"0xf901faa087a74234d5ad70c6ff8e89ffd305fa85048e6cbb4045d66b43a7bf03fe9b6171a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09ba750cfccbb3e45e010229e805d1d854befeb2701745e93f975dbc965f737a5a0d911c25e97e27898680d242b7780b6faef30995c355a2d5de92e6b9a7212ad3aa0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000003834c4b408252081e80a00b43d19e6220dd7b4e8018a5046283377354ab021f49cdd082dfe167c86502fe8836a52bdb03334a2d842806be9d"} diff --git a/tests/debug_getRawHeader/get-genesis.io b/tests/debug_getRawHeader/get-genesis.io new file mode 100644 index 000000000..e036fe584 --- /dev/null +++ b/tests/debug_getRawHeader/get-genesis.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":1,"method":"debug_getRawHeader","params":["0x0"]} +<< {"jsonrpc":"2.0","id":1,"result":"0xf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0078dc6061b1d8eaa8493384b59c9c65ceb917201221d08b80c4de6770b6ec7e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180834c4b40808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000843b9aca00"} diff --git a/tests/debug_getRawHeader/get-invalid-number.io b/tests/debug_getRawHeader/get-invalid-number.io new file mode 100644 index 000000000..9b5efa078 --- /dev/null +++ b/tests/debug_getRawHeader/get-invalid-number.io @@ -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"}} diff --git a/tests/debug_getRawReceipts/get-block-n.io b/tests/debug_getRawReceipts/get-block-n.io new file mode 100644 index 000000000..e828aa06a --- /dev/null +++ b/tests/debug_getRawReceipts/get-block-n.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":8,"method":"debug_getRawReceipts","params":["0x3"]} +<< {"jsonrpc":"2.0","id":8,"result":["0xf9010801825208b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0"]} diff --git a/tests/debug_getRawReceipts/get-genesis.io b/tests/debug_getRawReceipts/get-genesis.io new file mode 100644 index 000000000..b41282c1b --- /dev/null +++ b/tests/debug_getRawReceipts/get-genesis.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":7,"method":"debug_getRawReceipts","params":["0x0"]} +<< {"jsonrpc":"2.0","id":7,"result":[]} diff --git a/tests/debug_getRawReceipts/get-invalid-number.io b/tests/debug_getRawReceipts/get-invalid-number.io new file mode 100644 index 000000000..a49745db5 --- /dev/null +++ b/tests/debug_getRawReceipts/get-invalid-number.io @@ -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"}} diff --git a/tests/debug_getRawTransaction/get-invalid-hash.io b/tests/debug_getRawTransaction/get-invalid-hash.io new file mode 100644 index 000000000..e2c46e7ca --- /dev/null +++ b/tests/debug_getRawTransaction/get-invalid-hash.io @@ -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"}} diff --git a/tests/debug_getRawTransaction/get-tx.io b/tests/debug_getRawTransaction/get-tx.io new file mode 100644 index 000000000..a5f27d48a --- /dev/null +++ b/tests/debug_getRawTransaction/get-tx.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":10,"method":"debug_getRawTransaction","params":["0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b"]} +<< {"jsonrpc":"2.0","id":10,"result":"0xf8678084342770c182520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a0af5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60a0201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}