|
| 1 | +# Contributors Guide |
| 2 | + |
| 3 | +This guide will explain for new and experienced contributors alike how to |
| 4 | +propose changes to Ethereum JSON-RPC API. |
| 5 | + |
| 6 | +## Introduction |
| 7 | + |
| 8 | +The Ethereum JSON-RPC API is the canonical interface between users and the |
| 9 | +Ethereum network. Each execution layer client implements the API as defined by |
| 10 | +the spec. |
| 11 | + |
| 12 | +As the main source of chain information, anything that is not provided over via |
| 13 | +API will not be easily accessible to users. |
| 14 | + |
| 15 | +## Guiding Principles |
| 16 | + |
| 17 | +When considering a change to the API, it's important to keep a few guiding |
| 18 | +principles in mind. |
| 19 | + |
| 20 | +### Necessity |
| 21 | + |
| 22 | +The most common path to a newly standardized method is necessity. As the |
| 23 | +protocol changes over time, new types of data become available. EIP-2930 |
| 24 | +necessitated the introduction of `eth_accessList` and EIP-1559 neccesitated |
| 25 | +`eth_feeHistory`. |
| 26 | + |
| 27 | +Therefore, a good question to ask before making a new API proposal is whether |
| 28 | +or not the method is strictly neccessary. Sometimes the answer is yes even |
| 29 | +without a protocol change. For example, `eth_getProof` has been possible since |
| 30 | +the inital version of Ethereum -- yet, it was only standardized in recent years |
| 31 | +as demand for the functionality grew. Before `eth_getProof`, there was no |
| 32 | +interface for getting intermediary trie nodes over the API. This is a great |
| 33 | +example of a method that became more neccessary over time. |
| 34 | + |
| 35 | +Sometimes efficiency is the basis of necessity. If certain patterns of requests |
| 36 | +becomes popular, it can be adventageous to enshrine the behavior into the API. |
| 37 | + |
| 38 | +### Implementation Complexity |
| 39 | + |
| 40 | +How a method is implemented should be carefully considered before proposing a |
| 41 | +change to the API. Although each client is able to validate the Ethereum chain, |
| 42 | +there can be a huge variance in actual design decisions. |
| 43 | + |
| 44 | +As an example, a proposal for a method such as `eth_totalSupply` seems |
| 45 | +reasonable. This is a quanity that users are often interested in and it would |
| 46 | +nice to have it available. However, tracking the total supply is tricky. There |
| 47 | +are several avenues where ether can enter and leave supply. This method would |
| 48 | +need to either i) compute the value on demand or ii) store value for each block |
| 49 | +height. |
| 50 | + |
| 51 | +Option i) is out, because it would involve executing each block starting with |
| 52 | +genesis. Option ii) is viable, but it starts enforcing certain requirements on |
| 53 | +clients beyond being able to simply validate the chain. Now during block |
| 54 | +ingestion, each client needs to store in their database the supply for that |
| 55 | +height. The chain reorg logic also needs to consider this new data. It is not |
| 56 | +trivial. |
| 57 | + |
| 58 | +### Backwards Compatibility |
| 59 | + |
| 60 | +There is currently no accepted path to making backwards incompatible changes to |
| 61 | +the API. This means that proposals which change syntax or semantics of existing |
| 62 | +methods are unlikely to be accepted. A more viable approach is to propose a new |
| 63 | +method be created. |
| 64 | + |
| 65 | +## Standardization |
| 66 | + |
| 67 | +There is not a formal process for standardization of API changes. However, the |
| 68 | +outline below should given proposal authors and champions a rough process to |
| 69 | +follow. |
| 70 | + |
| 71 | +### Idea |
| 72 | + |
| 73 | +An often overlooked aspect on the standardization journey is the idea phase. |
| 74 | +This is an important period of time, because some focused effort at this point |
| 75 | +in time can save time and make the rest of the process much smoother. |
| 76 | + |
| 77 | +During the idea phase, it is recommended to contemplate the proposal idea in |
| 78 | +the context of the guiding principles above. It's also good to get feedback on |
| 79 | +the idea in the open. Just one or two rough acknowledgements from client |
| 80 | +developers that an idea makes sense and is worth pursing can avoid wasting a |
| 81 | +lot of time formalizing a proposal that has little change of being accepted. |
| 82 | + |
| 83 | +### Proposal |
| 84 | + |
| 85 | +The formal proposal stage is where the bulk of time will be spent. A formal |
| 86 | +proposal is a PR to this repository ([ethereum/execution-apis][exec-apis]). A |
| 87 | +good proposal will have the following: |
| 88 | + |
| 89 | +* a modification to the specification implementing the proposal |
| 90 | +* test cases for proposal ([guide][test-gen]) |
| 91 | +* motivation for the change |
| 92 | +* links to acknowledgements that proposal idea is sound |
| 93 | +* clear rationale for non-obvious design decisions |
| 94 | + |
| 95 | +### Acquiring Support |
| 96 | + |
| 97 | +Once a formal proposal has been created, formal support of clients can be |
| 98 | +acquired. This has historically been done via the AllCoreDevs call. It is |
| 99 | +recommended to post a request on the AllCoreDevs agenda (usually in |
| 100 | +[ethereum/pm][pm]) to discuss the proposal, at which point formal support can |
| 101 | +be ascertained. |
| 102 | + |
| 103 | +Often times, support will be conditional certain changes. This means that |
| 104 | +proposals will cycle between formal proposal work and earning support from |
| 105 | +clients. This should be expected and not discourage authors. |
| 106 | + |
| 107 | +### Accepting the Change |
| 108 | + |
| 109 | +After client teams acknowledge and accept the change, it is usually on them to |
| 110 | +implement the method in their client. Due to the lack of versioning of the API, |
| 111 | +it is preferable that clients release the method roughly at the same time so |
| 112 | +that there is not much time where some clients support a certain methods and |
| 113 | +others don't. |
| 114 | + |
| 115 | + |
| 116 | +[exec-apis]: https://github.com/ethereum/execution-apis |
| 117 | +[pm]: https://github.com/ethereum/pm |
| 118 | +[test-gen]: ../tests/README.md |
0 commit comments