-
Notifications
You must be signed in to change notification settings - Fork 174
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
Basic Beacon API #3
Conversation
As mentioned by @terencechain in #2, Prysm have been doing lots of work on the API too. This is great and I've been using it as a reference for this. After chatting on Discord, I thought it might be useful if I listed points where this PR differs from the Prysm docs. That way we can see if I've made some errors in my decision making (likely). I reference mainly api.prylabs.net instead of ethereumapis because the former is in HTTP-style and the latter is more gRPC focused. Get blocks/states by epochI think it's ambiguous as to whether or not querying by I don't think this query is strictly necessary and that the typing in our API would be clearer without it. Can't get multiple blocks/statesTrying to keep this PR small. There's a bit of complexity in getting multiple blocks (e.g., handling skip slots, insufficient history, etc). If it's a must have immediately, I'd propose we do that in a separate PR following this one.
|
Also, #1 is still open so we could decide that this markdown format is a bad idea. |
Get blocks/states by epoch Filed that note here: https://github.com/prysmaticlabs/ethereumapis/issues/23 Can't get multiple blocks/states If you are looking for a long lasting API, I urge you to reconsider. What is the use case where users would only want one block/state, aside from debugging? We removed state fetches from our data API as it was going to be far too expensive to serve on average. Maybe the methods you are suggesting are under a /eth/v1aplha1 prefix The decision for this was largely influenced by the idea what github.com/prysmaticlabs/ethereumapis could be a large collection of any API that applied in the ethereum ecosystem. Layer 2 solutions, public dApps, anything with an API. So, we prefix with the general domain In the context of this repository where it is only Ethereum 2.0 APIs, it isn't necessary. chainhead method replaced by head I don't see how this is better to make multiple requests for the head information. I suppose if you only wanted a subset of the payload then you could use GraphQL or some response filter. |
Thanks for the response!
I'm totally happy to make a new PR straight after this that describes that. Are your urging me to include it in this PR?
Cool. Do you think we should version the
Yeah, I'm down to add more info to |
Great work @paulhauner! I'm going through, implementing this API for Artemis right now. For the "/beacon/head" path, do you think it's necessary to return beacon state root? IMO, since beacon blocks already include the state root, that might be a bit redundant. Also, the Store uses beacon block roots to index the corresponding state in time. |
I'm keen to get some basics merged here. Where do things stand @paulhauner. Any thing to update/modify before an initial merge? |
To add to my previous comment, in the "/beacon/state" path, would it not be better to index the beacon state using a beacon block root hash tree root, since that how we index beacon state's in the Store object? |
@paulhauner is it worth adding |
Thank you! I agree that it's not maximally minimal (lol) to return the beacon state root, however it is convenient for users. @prestonvanloon touched upon this in the "chainhead method replaced by head" part of his comment. I ended up capitulating to Preston's idea that including things like
I assume the I think it may be confusing to users if we index My gut feeling is that keying
I could be wrong, but I think you're suggesting to permit querying for items via If so, I remember chatting to @prestonvanloon about this. I noted that when querying by
I think the main thing to consider is #1. Since @mpetrunic is pushing forward with the Swagger API, perhaps this markdown version is just duplicate effort? If we do want to go ahead with this, I think all I need to do is add more info to the |
@paulhauner thanks for the reply.
Actually, I was suggesting adding epoch to the response. Agreed that it would be confusing to query by epoch, but there is some value to knowing the epoch of the response bc slots_per_epoch is different for minimal and main net configs |
Do we wanna follow more restful endpoints like:
|
Oh yeah I'm with you now. We had this problem on Lighthouse, we had to expose a I think my preference would be to define the EDIT (accidental submission):
I don't have strong feelings on this. My understanding was that query parameters are more common in the wild, but I'm not an active "web developer" so I could be wrong. I also like query params because it's easy to reason about them as a hashmap and it makes routing a tiny bit easier. Like I said though, no strong feelings on the topic. |
I am in favor of conformance with validator API and using RESTful endpoints like @mpetrunic mentioned. This is very common practice in the web. Usually, query string contains optional parameters of the request while parameter in the path makes it obligatory which is straightforward when resources are requested by their identifiers. |
Merging to get the base in. We can work from here. |
What
Adds a markdown document describing a basic beacon API that provides block, state, head and network information.
Why
In the short term, clients need to interoperate and it would be helpful if they implemented standard, human-readable APIs so we don't need to go scrounging through logs to find simple things. Also, so people can build tools that can assess our interoperability foo.
In the long term, it'd be great if clients standardize upon API functionality to help make a unified developer ecosystem. Maybe this document can be the basis for this standardization effort.
Details
What this is:
curl
-able examples.What this is not:
Use cases
Using this API, we can perform these tasks:
$ curl /network/enr
and copy-paste it into a--bootnodes
CLI flag on another node.$ curl /network/peer_id
to get the node's libp2p PeerId.$ curl /network/peers
to see if a node is peered with some other node (comparing peer ids)./beacon/block?slot=42
and comparing the returnedroot
fields./beacon/head
to learn the state root at the head of the chain, then use/beacon/state
to read the finalized checkpoints.Additionally, I hope this API can be used during network testing/analysis with tools that detect network connectivity (connected peers, etc) and canonical chain info (head, blocks at slots, etc).
Notes