From b34d00d423fe8744d960a8f3c00ea53c61296ef6 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Wed, 25 Aug 2021 22:35:22 +0200 Subject: [PATCH 01/10] allow empty bytes response --- src/schemas/base-types.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schemas/base-types.json b/src/schemas/base-types.json index 89275b847..652a414e5 100644 --- a/src/schemas/base-types.json +++ b/src/schemas/base-types.json @@ -17,7 +17,7 @@ "bytes": { "title": "hex encoded bytes", "type": "string", - "pattern": "^0x[0-9a-f]+$" + "pattern": "^0x[0-9a-f]*$" }, "bytes32": { "title": "32 hex encoded bytes", From e042ff584189e3529a0c5cdde72d99a31d32c707 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Wed, 25 Aug 2021 22:36:23 +0200 Subject: [PATCH 02/10] access list should be array type --- src/schemas/transaction.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schemas/transaction.json b/src/schemas/transaction.json index 7180feed0..922cb2417 100644 --- a/src/schemas/transaction.json +++ b/src/schemas/transaction.json @@ -16,7 +16,7 @@ }, "AccessList": { "title": "Access list", - "type": "object", + "type": "array", "items": { "$ref": "#/components/schemas/AccessListEntry" } From 58c9a9cc2a9cbfeedbd74d08690cf07c200adf50 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Wed, 25 Aug 2021 23:21:23 +0200 Subject: [PATCH 03/10] fix typos in block required fields --- src/schemas/block.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schemas/block.json b/src/schemas/block.json index 3a316a183..eee1716a6 100644 --- a/src/schemas/block.json +++ b/src/schemas/block.json @@ -8,8 +8,8 @@ "miner", "stateRoot", "transactionsRoot", - "receiptRoot", - "bloom", + "receiptsRoot", + "logsBloom", "totalDifficulty", "number", "gasLimit", From 41ddae9446f9d657353af2b80777700d352ff355 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 01:52:38 +0200 Subject: [PATCH 04/10] stricter definition of uint to not allow leading 0s --- src/schemas/base-types.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schemas/base-types.json b/src/schemas/base-types.json index 652a414e5..08139edca 100644 --- a/src/schemas/base-types.json +++ b/src/schemas/base-types.json @@ -37,7 +37,7 @@ "uint": { "title": "hex encoded unsigned integer", "type": "string", - "pattern": "^0x[0-9a-f]+$" + "pattern": "^0x[1-9a-f]+[0-9a-f]*$" }, "uint256": { "title": "hex encoded unsigned integer", From 78efdddcbeb189a76ee278f379898c6a27e8d7a0 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 03:07:05 +0200 Subject: [PATCH 05/10] add spellcheck to ci --- .github/workflows/spellcheck.yaml | 11 +++++++++++ .gitignore | 1 + spellcheck.yaml | 15 +++++++++++++++ src/methods/block.json | 8 ++++---- src/methods/mining.json | 4 ++-- src/schemas/base-types.json | 2 +- wordlist.txt | 14 ++++++++++++++ 7 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/spellcheck.yaml create mode 100644 spellcheck.yaml create mode 100644 wordlist.txt diff --git a/.github/workflows/spellcheck.yaml b/.github/workflows/spellcheck.yaml new file mode 100644 index 000000000..79fde0c48 --- /dev/null +++ b/.github/workflows/spellcheck.yaml @@ -0,0 +1,11 @@ +name: Spellcheck +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + name: Spellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: rojopolis/spellcheck-github-actions@0.16.0 + name: Spellcheck diff --git a/.gitignore b/.gitignore index 5668b82a0..846ea2b84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ openrpc.json +*.dic diff --git a/spellcheck.yaml b/spellcheck.yaml new file mode 100644 index 000000000..92e7e5ed6 --- /dev/null +++ b/spellcheck.yaml @@ -0,0 +1,15 @@ +matrix: +- name: json + sources: + - 'src/**/*.json' + aspell: + lang: en + d: en_US + run-together: true + run-together-min: 2 + run-together-limit: 256 + dictionary: + wordlists: + - wordlist.txt + encoding: utf-8 + pipeline: null diff --git a/src/methods/block.json b/src/methods/block.json index 58e1e903b..3e71c4aba 100644 --- a/src/methods/block.json +++ b/src/methods/block.json @@ -11,10 +11,10 @@ } }, { - "name": "Full transactions", + "name": "Hydrated transactions", "required": true, "schema": { - "title": "fullTx", + "title": "hydrated", "type": "boolean" } } @@ -38,10 +38,10 @@ } }, { - "name": "Full transactions", + "name": "Hydrated transactions", "required": true, "schema": { - "title": "fullTx", + "title": "hydrated", "type": "boolean" } } diff --git a/src/methods/mining.json b/src/methods/mining.json index 33314a8d4..a3f976ffd 100644 --- a/src/methods/mining.json +++ b/src/methods/mining.json @@ -33,7 +33,7 @@ "type": "array", "items": [ { - "title": "PoW hash", + "title": "Proof-of-work hash", "$ref": "#/components/schemas/bytes32" }, { @@ -53,7 +53,7 @@ "summary": "Used for submitting a proof-of-work solution.", "params": [ { - "name": "PoW hash", + "name": "Proof-of-work hash", "required": true, "schema": { "$ref": "#/components/schemas/bytes32" diff --git a/src/schemas/base-types.json b/src/schemas/base-types.json index 08139edca..59ea5c17b 100644 --- a/src/schemas/base-types.json +++ b/src/schemas/base-types.json @@ -12,7 +12,7 @@ "byte": { "title": "hex encoded byte", "type": "string", - "pattern": "^0x([a-fA-F0-9]?){1,2}$" + "pattern": "^0x([a-f,A-F,0-9]?){1,2}$" }, "bytes": { "title": "hex encoded bytes", diff --git a/wordlist.txt b/wordlist.txt new file mode 100644 index 000000000..380c98e20 --- /dev/null +++ b/wordlist.txt @@ -0,0 +1,14 @@ +bytecode +eip +enum +eth +ommers +params +pre +rlp +schemas +secp +sha +uint +wei +yParity From 1da828e5aba0c4a91e752cab23edb0ba6c07dfb2 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 03:11:43 +0200 Subject: [PATCH 06/10] add schema validation script --- .gitignore | 2 ++ scripts/debug.sh | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100755 scripts/debug.sh diff --git a/.gitignore b/.gitignore index 846ea2b84..641885e56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules/ openrpc.json +data.json +schema.json *.dic diff --git a/scripts/debug.sh b/scripts/debug.sh new file mode 100755 index 000000000..7e4d76b6d --- /dev/null +++ b/scripts/debug.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -o xtrace +curl -s http://localhost:8545 -H 'Content-Type: application/json' -d '{"method":"'$1'","id":1,"jsonrpc":"2.0", "params":['$2']}' | jq '.["result"]' > data.json 2>&1 +cat openrpc.json | jq '.["methods"][] | select(.name == "'$1'") | .["result"]["schema"]' > schema.json +ajv validate -s schema.json -d data.json +# rm schema.json data.json From e76c3d296430725e3679ddf5bb9b86f177da1be6 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 03:14:11 +0200 Subject: [PATCH 07/10] accept mixed case addresses --- src/schemas/base-types.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schemas/base-types.json b/src/schemas/base-types.json index 59ea5c17b..72c199bed 100644 --- a/src/schemas/base-types.json +++ b/src/schemas/base-types.json @@ -2,7 +2,7 @@ "address": { "title": "hex encoded address", "type": "string", - "pattern": "^0x[0-9a-f]{40}$" + "pattern": "^0x[0-9,a-f,A-F]{40}$" }, "addresses": { "title": "hex encoded address", @@ -12,7 +12,7 @@ "byte": { "title": "hex encoded byte", "type": "string", - "pattern": "^0x([a-f,A-F,0-9]?){1,2}$" + "pattern": "^0x([0-9,a-f,A-F]?){1,2}$" }, "bytes": { "title": "hex encoded bytes", From 751d889a678a49cfa1c6096efb7abb2b708e2594 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 03:38:25 +0200 Subject: [PATCH 08/10] spell check readme --- README.md | 2 +- spellcheck.yaml | 46 ++++++++++++++++++++++++++++++++-------------- wordlist.txt | 6 ++++++ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 78198ecf3..f1ceb8066 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The Ethereum JSON-RPC is a collection of methods that all clients implement. This interface allows downstream tooling and infrastructure to treat different -Ethereum clients as swappable modules. +Ethereum clients as modules that can be swapped at will. ## Contributing diff --git a/spellcheck.yaml b/spellcheck.yaml index 92e7e5ed6..09960d31e 100644 --- a/spellcheck.yaml +++ b/spellcheck.yaml @@ -1,15 +1,33 @@ matrix: -- name: json - sources: - - 'src/**/*.json' - aspell: - lang: en - d: en_US - run-together: true - run-together-min: 2 - run-together-limit: 256 - dictionary: - wordlists: - - wordlist.txt - encoding: utf-8 - pipeline: null + - name: markdown + sources: + - '**/*.md|!node_modules/**' + aspell: + lang: en + d: en_US + ignore-case: true + dictionary: + wordlists: + - wordlist.txt + encoding: utf-8 + pipeline: + - pyspelling.filters.markdown: + - pyspelling.filters.html: + comments: false + ignores: + - code + - pre + - name: json schemas + sources: + - 'src/**/*.json' + aspell: + lang: en + d: en_US + run-together: true + run-together-min: 2 + run-together-limit: 256 + dictionary: + wordlists: + - wordlist.txt + encoding: utf-8 + pipeline: null diff --git a/wordlist.txt b/wordlist.txt index 380c98e20..d7ae09d6f 100644 --- a/wordlist.txt +++ b/wordlist.txt @@ -1,14 +1,20 @@ +apis bytecode eip enum eth +ethereum +json ommers +openrpc params pre rlp +rpc schemas secp sha uint +url wei yParity From e26ecd127cf926248c156d47a099b3c83adfbb62 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 04:03:59 +0200 Subject: [PATCH 09/10] update readme with contribution info --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- wordlist.txt | 4 ++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1ceb8066..81e828931 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,60 @@ # Ethereum JSON-RPC Specification -[View the spec](https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/ethereum/eth1.0-apis/assembled-spec/openrpc.json&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:input]=false&uiSchema[appBar][ui:examplesDropdown]=false) +[View the spec][playground] The Ethereum JSON-RPC is a collection of methods that all clients implement. This interface allows downstream tooling and infrastructure to treat different Ethereum clients as modules that can be swapped at will. +## Building + +The specification is split into multiple files to improve readability. It +can be compiled the spec into a single document as follows: + +```console +$ npm install +$ npm run build +Build successful. +``` + +This will output the file `openrpc.json` in the root of the project. This file +will have all schema `#ref`s resolved. + ## Contributing -The specification is written in [OpenRPC](https://open-rpc.org/). +The specification is written in [OpenRPC][openrpc]. Refer to the +OpenRPC specification and the JSON schema specification to get started. + +### Testing + +There are three main tools for testing contributions. The main two that run as +GitHub actions are an [OpenRPC validator][validator] and a +[spellchecker][spellchecker]: + +```console +$ npm install +$ npm run lint +OpenRPC spec validated successfully. + +$ pip install pyspelling +$ pyspelling -c spellcheck.yaml +Spelling check passed :) +``` + +The other tool can validate a live JSON-RPC provider hosted at +`http://localhost:8545` against the specification: + +```console +$ ./scripts/debug.sh eth_getBlockByNumber \"0xc7d772\",false +data.json valid +``` + +## License + +This repository is licensed under [CC0](LICENSE). + + +[playground]: https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/ethereum/eth1.0-apis/assembled-spec/openrpc.json&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:input]=false&uiSchema[appBar][ui:examplesDropdown]=false +[openrpc]: https://open-rpc.org +[validator]: https://open-rpc.github.io/schema-utils-js/globals.html#validateopenrpcdocument +[spellchecker]: https://facelessuser.github.io/pyspelling/ diff --git a/package.json b/package.json index 4f718cecc..5591bcf21 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "build": "node scripts/build.js", - "lint": "node scripts/validate.js" + "lint": "node scripts/build.js && node scripts/validate.js" }, "repository": { "type": "git", diff --git a/wordlist.txt b/wordlist.txt index d7ae09d6f..4e4e27574 100644 --- a/wordlist.txt +++ b/wordlist.txt @@ -5,10 +5,12 @@ enum eth ethereum json +npm ommers openrpc params pre +pyspelling rlp rpc schemas @@ -16,5 +18,7 @@ secp sha uint url +validator wei +yaml yParity From 2bbab3044d08b31c276e79a597e08047b9cc4dc8 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Thu, 26 Aug 2021 04:06:02 +0200 Subject: [PATCH 10/10] improve wording --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81e828931..5d0e59272 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ OpenRPC specification and the JSON schema specification to get started. ### Testing -There are three main tools for testing contributions. The main two that run as -GitHub actions are an [OpenRPC validator][validator] and a +There are currently three tools for testing contributions. The main two that +run as GitHub actions are an [OpenRPC validator][validator] and a [spellchecker][spellchecker]: ```console @@ -41,7 +41,7 @@ $ pyspelling -c spellcheck.yaml Spelling check passed :) ``` -The other tool can validate a live JSON-RPC provider hosted at +The third tool can validate a live JSON-RPC provider hosted at `http://localhost:8545` against the specification: ```console