-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BeaconNode <--> ValidatorClient API - Messages #1011
Comments
This is great! For |
another option is that we define the interfaces such that the beacon node returns everything the validator client provides in the request, such that the response is a strict superset of the request. this is kind of the route that (afaiui) graphQL takes, where a server will "fill in the blanks" for a given client. i would argue this is helpful for a few reasons (probably others):
i think this notion of safety is pretty important so i would extend the design principle across every API (and really this stands for any RPC we will define for the whole endeavor) -- the only downside is the additional communication overhead but i don't see it being that major |
Can you put this issue into a PR? It would make it much easier to review and add comments directly to this spec. Great work! |
@ralexstokes I think this is probably better to ask existing teams from eth1.x what would make sense (ethers.js, web3.js,... Etc) I'll forward this off to my tooling group and see if they have Any input. Edit; I realize this isn't beacon chain RPC as I thought... Lol none the less I'll pass it along |
Thanks! I was originally going to do it as a PR, and happy to do so, I'm just not sure of a sensible place for the doc to reside. Open to suggestion! |
Perhaps, you can place it under |
Are we sure we want to be using |
I think the It seems like the committee only needs to be checked once per epoch (and can be looked up one epoch beforehand), whereas the block production assignment must be checked every slot. I'm thinking something that mirrors the two functions here: https://github.com/ethereum/eth2.0-specs/blob/dev/specs/validator/0_beacon-chain-validator.md#validator-assignments |
How about introducing namespacing for methods (similar to eth1)?
|
|
Regarding the actual message format, I'd suggest only little things, like keeping consistent datatypes - so get syncing status would be more useful if it just returned the syncing status, which could include the info that it was not syncing, or simply return null. Returning false or object makes implementation a bit more complicated as you have to check if you get Bool or Object. Also - I am not up to speed on the actual Eth 2.0 stuff but are there cases for PUT as well as POST here? Finally, (referring to the other issue on the actual protocol), I'd suggest a REST-like structure of the messages and roles (eventually one node may serve multiple APIs not just this beacon one): |
@GregTheGreek - I think this was resolved on Gitter. It could also be possible for the |
@wemeetagain - I think our plan is to check both pieces of information every slot, since both the committee and block production could theoretically change at any point due to forks.
We decided to keep the API minimal, and keep functionality in the |
@mpetrunic - This is a fantastic idea. I will introduce namespacing in my next revision of this API proposal. |
@FrankSzendzielarz - This is a good point, I will keep the data types of the return values consistent in my next revision of the proposal. I also agree that HTTP-REST is a better choice than JSON-RPC, which is discussed in more detail in #1012. |
If we roll with REST-HTTP (#1012) we can achieve this with urls (e.g., |
@spble @djrtwo "Do you think it makes sense to submit a PR with a Markdown RFC in specs/validator? Let me know but if you want I can fine tune the swagger and give you the auto generated MD from the swagger codegen. Have a look at the docs folder in the golang zip in #1012 if it suits. (or the attachment here) In fact, @djrtwo if the Swagger http approach works, could do all specs as actual code in a test web first, and auto-gen the MD on the basis of the code. |
I would pull validator endpoints under root |
@mpetrunic I can change that to reflect what is agreed on here. I am not familiar with the actual spec but it strikes me that for at least testnets you will have single implementations running either as Beacon or Validator - in which case I think the above API is the api the Beacon would be offering. If this is the case , I'd say the beacon prefix should remain in place. (but yeah - whatever is appropriate) |
@FrankSzendzielarz Let me give you some example of what I meant: Currently only these methods belong in beacon root : |
@mpetrunic Ah I see. Yes that makes sense. |
@spble During implementation I noticed some "bottlenecks". I think we should add method |
@mpetrunic good point! I have two potentially interesting thoughts around this: Searching for pubkeys in the validator registryLighthouse also found this As a result, we have a map hanging around to do ID'ing validators via pubkey vs. validator indexThere is an argument that we could use the Given that a Of course, I'm keen to hear other's thoughts too. |
Since consensus in #1012 was to use a REST API, I have written up a new proposal using the OpenAPI specification. I have tried to incorporate all the suggestions in this thread, though the identification of validators via pubkey vs index remains an open question; I have left it as pubkey for now. I've opened a PR #1069 which contains the proposed spec, so I will close this issue for now and we can discuss/refine the spec further on the PR. A 'live' version of the API spec can be viewed on SwaggerHub. |
ETH2.0 Beacon Node & Validator Client RPC Proposal
Outline
This issue proposes a minimal communications specification between a beacon node and validator client, targeting phase 0 of the Eth2.0 specification. The protocol is designed to be a simple local communications interface, permitting two separate binaries to communicate.
This specification is intended to describe communication abstractly, without choosing any particular protocol. The protocol used (e.g. gRPC/JSON-RPC) is discussed in a separate issue: #1012.
This issue follows on from a discussion during the Client Architecture session at the Sydney Implementers meeting. This also follow from the Client Architecture Roundtable in Prague.
There is an editable version of this document, here: https://hackmd.io/r7D61hs4RWKm8nz_O2iinQ
Background
The beacon node maintains the state of the beacon chain by communicating with other beacon nodes in the Ethereum Serenity network. Conceptually, it does not maintain keypairs that participate with the beacon chain.
The validator client is conceptually a separate entity which utilises private keys to perform validator related tasks on the beacon chain, which we call validator "duties". This includes the production of beacon blocks and signing of attestations.
Since it is recommended to separate these concerns in the client implementations, it is necessary for us to clearly define the communication between them.
The goal of this specification is to promote interoperability between beacon nodes and validator clients derived from different projects. For example, the validator client from Lighthouse, could communicate with a running instance of the beacon node from Prysm.
This proposal has been adapted from the Lighthouse gRPC protocol specification.
There is also another WIP proposal for a Minimum Validator Interface, which describes additional functions possibly necessary for phase 1 and beyond.
Specification
Entities
The following are the two entities that participate in this protocol:
BeaconNode
:A beacon node instance, run with a
--rpc
flag to enable the RPC interface. Runs stand-alone.ValidatorClient
:A validator client instance, which must connect to at least one instance of
BeaconNode
.Endpoints
This section summarises API endpoints which are published by an instance of
BeaconNode
, for the exclusive use ofValidatorClient
implementations.This proposal is a minimum set of messages necessary to enable effective communication, without any extra features. Anything extra is beyond the scope of this document.
Summary Table
get_client_version
client_version
get_genesis_time
genesis_time
get_syncing_status
syncing_status
get_duties
validator_pubkeys
syncing_status
,current_version
, [ValidatorDuty
]produce_block
slot
,randao_reveal
beacon_block
publish_block
beacon_block
produce_attestation
slot
,shard
indexed_attestation
publish_attestation
indexed_attestation
Status Codes
For each of these endpoints the underlying transport protocol should provide status codes. Assuming this will be based on HTTP, one of the following standard status codes will always be included as part of a response:
200
40X
500
BeaconNode
cannot complete the request due to an internal error.503
BeaconNode
is currently syncing, try again later. A call can be made toget_syncing_status
to in order to find out how much has been synchronised.get_client_version
Requests that the
BeaconNode
identify information about its implementation in a format similar to a HTTP User-Agent field.client_version
BeaconNode
and its current software version.Note: Unlike most other endpoints,
get_client_version
does not return an error503
while theBeaconNode
is syncing, but instead returns status code200
.get_genesis_time
Requests the
genesis_time
parameter from theBeaconNode
, which should be consistent across allBeaconNodes
that follow the same beacon chain.genesis_time
genesis_time
, which is a fairly static configuration option for theBeaconNode
.Note: Unlike most other endpoints,
get_genesis_time
does not return an error503
while theBeaconNode
is syncing, but instead returns status code200
.get_syncing_status
Requests the
BeaconNode
to describe if it's currently syncing or not, and if it is, what block it is up to. This is modelled after the Eth1.0 JSON-RPCeth_syncing
call.syncing
false
ORSyncingStatus
false
if the node is not syncing, or aSyncingStatus
object if it is.Note: Unlike most other endpoints,
get_syncing_status
does not return an error503
while theBeaconNode
is syncing, but instead returns status code200
with theSyncingStatus
object.get_duties
Requests the BeaconNode to provide a set of “duties”, which are actions that should be performed by ValidatorClients. This API call should be polled at every slot, to ensure that any chain reorganisations are catered for, and to ensure that the currently connected
BeaconNode
is properly synchronised.validator_pubkeys
0x
encoded hex string.current_version
current_version
, as described by the currentFork
.validator_duties
ValidatorDuty
]ValidatorDuty
object.produce_block
Requests a
BeaconNode
to produce a valid block, which can then be signed by a ValidatorClient.slot
randao_reveal
beacon_block
BeaconBlock
BeaconBlock
object, but with thesignature
field left blank.publish_block
Instructs the
BeaconNode
to publish a newly signed beacon block to the beacon network, to be included in the beacon chain.beacon_block
BeaconBlock
BeaconBlock
object, as sent from theBeaconNode
originally, but now with thesignature
field completed.produce_attestation
Requests that the
BeaconNode
produce anIndexedAttestation
, with a blanksignature
field, which theValidatorClient
will then sign.slot
shard
indexed_attestation
IndexedAttestation
IndexedAttestation
structure with thesignature
field left blank.publish_attestation
Instructs the
BeaconNode
to publish a newly signedIndexedAttestation
object, to be incorporated into the beacon chain.indexed_attestation
IndexedAttestation
IndexedAttestation
structure, as originally provided by theBeaconNode
, but now with thesignature
field completed.Data Structures
Two new data objects are proposed for the sake of implementation, and several other data objects from the Eth2.0 specs are referenced.
The
bytes
data types are encoded hex strings, with0x
preceeding them.uint64
are decimal encoded integers, andNone
may benull
, which is distinct from0
.ValidatorDuty
SyncingStatus
As described by the Eth1.0 JSON-RPC.:
Fork
As described by Fork in the Eth2.0 specs.
BeaconBlock
As described by BeaconBlock in the Eth2.0 specs.
IndexedAttestation
As described by IndexedAttestation in the Eth2.0 specs.
Optional Extras
Endpoint:
get_fork
Requests the
BeaconNode
to provide which fork version it is currently on.fork
Fork
BeaconNode
is currently following.chain_id
BeaconNode
. Analagous to Eth1.0 JSON-RPCnet_version
.The text was updated successfully, but these errors were encountered: