Skip to content

Commit

Permalink
Merge pull request #64 from lightclient/various-fixes
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
lightclient authored Aug 26, 2021
2 parents 80980e0 + 2bbab30 commit 6b09d9f
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 17 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/spellcheck.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules/
openrpc.json
data.json
schema.json
*.dic
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 swappable modules.
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 currently three 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 third 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/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions scripts/debug.sh
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions spellcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
matrix:
- 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
8 changes: 4 additions & 4 deletions src/methods/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
}
},
{
"name": "Full transactions",
"name": "Hydrated transactions",
"required": true,
"schema": {
"title": "fullTx",
"title": "hydrated",
"type": "boolean"
}
}
Expand All @@ -38,10 +38,10 @@
}
},
{
"name": "Full transactions",
"name": "Hydrated transactions",
"required": true,
"schema": {
"title": "fullTx",
"title": "hydrated",
"type": "boolean"
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/methods/mining.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": "array",
"items": [
{
"title": "PoW hash",
"title": "Proof-of-work hash",
"$ref": "#/components/schemas/bytes32"
},
{
Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/schemas/base-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -12,12 +12,12 @@
"byte": {
"title": "hex encoded byte",
"type": "string",
"pattern": "^0x([a-fA-F0-9]?){1,2}$"
"pattern": "^0x([0-9,a-f,A-F]?){1,2}$"
},
"bytes": {
"title": "hex encoded bytes",
"type": "string",
"pattern": "^0x[0-9a-f]+$"
"pattern": "^0x[0-9a-f]*$"
},
"bytes32": {
"title": "32 hex encoded bytes",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"miner",
"stateRoot",
"transactionsRoot",
"receiptRoot",
"bloom",
"receiptsRoot",
"logsBloom",
"totalDifficulty",
"number",
"gasLimit",
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"AccessList": {
"title": "Access list",
"type": "object",
"type": "array",
"items": {
"$ref": "#/components/schemas/AccessListEntry"
}
Expand Down
24 changes: 24 additions & 0 deletions wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apis
bytecode
eip
enum
eth
ethereum
json
npm
ommers
openrpc
params
pre
pyspelling
rlp
rpc
schemas
secp
sha
uint
url
validator
wei
yaml
yParity

0 comments on commit 6b09d9f

Please sign in to comment.