|
| 1 | +# Execution API Specification |
| 2 | + |
| 3 | +## JSON-RPC |
| 4 | + |
| 5 | +[View the spec][playground] |
| 6 | + |
| 7 | +The Ethereum JSON-RPC is a standard collection of methods that all execution |
| 8 | +clients implement. It is the canonical interface between users and the network. |
| 9 | +This interface allows downstream tooling and infrastructure to treat different |
| 10 | +Ethereum clients as modules that can be swapped at will. |
| 11 | + |
| 12 | +### Contributing |
| 13 | + |
| 14 | +Please see the [contributors guide][contributors-guide] |
| 15 | +for general information about the process of standardizing new API methods and |
| 16 | +making changes to existing ones. Information on test generation can be found |
| 17 | +in [test-gen][test-gen] |
| 18 | + |
| 19 | +The specification itself is written in [OpenRPC][openrpc]. Refer to the OpenRPC |
| 20 | +specification and the JSON schema [specification][json-schema] to get started. |
| 21 | + |
| 22 | +### Building |
| 23 | + |
| 24 | +The specification is split into multiple files to improve readability. The |
| 25 | +spec can be compiled into a single document as follows: |
| 26 | + |
| 27 | +```console |
| 28 | +$ npm install |
| 29 | +$ npm run build |
| 30 | +Build successful. |
| 31 | +``` |
| 32 | + |
| 33 | +This will output the file `openrpc.json` in the root of the project. This file |
| 34 | +will have all schema `#ref`s resolved. |
| 35 | + |
| 36 | +#### Testing |
| 37 | + |
| 38 | +There are several mechanisms for testing specification contributions and client |
| 39 | +conformance. |
| 40 | + |
| 41 | +First is the [OpenRPC validator][validator]. It performs some basic syntactic |
| 42 | +checks on the generated specification. |
| 43 | + |
| 44 | +```console |
| 45 | +$ npm install |
| 46 | +$ npm run lint |
| 47 | +OpenRPC spec validated successfully. |
| 48 | +``` |
| 49 | + |
| 50 | +Next is `speccheck`. This tool validates the test cases in the `tests` |
| 51 | +directory against the specification. |
| 52 | + |
| 53 | +```console |
| 54 | +$ go install github.com/lightclient/rpctestgen/cmd/speccheck@latest |
| 55 | +$ speccheck -v |
| 56 | +all passing. |
| 57 | +``` |
| 58 | + |
| 59 | +If you get an error that says: `speccheck: command not found`, |
| 60 | + make sure that the go binary is in your $PATH: |
| 61 | + |
| 62 | +```console |
| 63 | +$ export PATH=$HOME/go/bin:$PATH |
| 64 | +``` |
| 65 | + |
| 66 | +The spell checker ensures the specification is free of spelling errors. |
| 67 | + |
| 68 | +```console |
| 69 | +$ pip install pyspelling |
| 70 | +$ pyspelling -c spellcheck.yaml |
| 71 | +Spelling check passed :) |
| 72 | +``` |
| 73 | + |
| 74 | +pyspelling is a wrapper around either [Aspell](http://aspell.net/) or |
| 75 | +[Hunspell](https://hunspell.github.io/). You'll need to install |
| 76 | +one of those before running `pyspelling`. |
| 77 | + |
| 78 | +Finally, the test cases in the `tests/` directory may be run against individual |
| 79 | +execution client using the [`hive`] simulator [`rpc-compat`][rpc-compat]. |
| 80 | +Please see the documentation in the aforementioned repositories for more |
| 81 | +information. |
| 82 | + |
| 83 | +## GraphQL |
| 84 | + |
| 85 | +[View the spec][graphql-schema] |
| 86 | + |
| 87 | +[EIP-1767][eip-1767] proposed a GraphQL schema for interacting with Ethereum clients. Since then Besu and Geth have implemented the interface. This repo contains a live specification to integrate changes to the protocol as well as other improvements into the GraphQL schema. |
| 88 | + |
| 89 | +### Generation |
| 90 | + |
| 91 | +The schema in this repo is generated by issuing a meta GraphQL query against a live node. This can be done as follows: |
| 92 | + |
| 93 | +```console |
| 94 | +$ npm run graphql:schema |
| 95 | +``` |
| 96 | + |
| 97 | +### Testing |
| 98 | + |
| 99 | +A script is included in the source code which reads and validates the given schema to be a valid one. It is recommended to perform this check after modifying the schema by: |
| 100 | + |
| 101 | +```console |
| 102 | +$ npm run graphql:validate |
| 103 | +``` |
| 104 | + |
| 105 | +## License |
| 106 | + |
| 107 | +This repository is licensed under [CC0](LICENSE). |
| 108 | + |
| 109 | + |
| 110 | +[playground]: https://ethereum.github.io/execution-apis/docs/reference/json-rpc-api |
| 111 | +[openrpc]: https://open-rpc.org |
| 112 | +[validator]: https://open-rpc.github.io/schema-utils-js/functions/validateOpenRPCDocument.html |
| 113 | +[graphql-schema]: http://graphql-schema.ethdevops.io/?url=https://raw.githubusercontent.com/ethereum/execution-apis/main/graphql.json |
| 114 | +[eip-1767]: https://eips.ethereum.org/EIPS/eip-1767 |
| 115 | +[contributors-guide]: docs/reference/contributors-guide.md |
| 116 | +[json-schema]: https://json-schema.org |
| 117 | +[hive]: https://github.com/ethereum/hive |
| 118 | +[rpc-compat]: https://github.com/ethereum/hive/tree/master/simulators/ethereum/rpc-compat |
| 119 | +[test-gen]: docs/reference/tests.md |
0 commit comments