Skip to content
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

Node API V2 #28

Merged
merged 24 commits into from
Dec 5, 2019
Merged

Node API V2 #28

merged 24 commits into from
Dec 5, 2019

Conversation

quentinlesceller
Copy link
Member

@quentinlesceller quentinlesceller commented Oct 1, 2019

@quentinlesceller quentinlesceller added core Related to core team node dev Related to node dev team labels Oct 1, 2019
@quentinlesceller quentinlesceller changed the title [WIP] Node API V2 Node API V2 Oct 9, 2019
@quentinlesceller quentinlesceller marked this pull request as ready for review October 9, 2019 18:09
@quentinlesceller
Copy link
Member Author

Ready for review.

text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
@0xmichalis
Copy link
Contributor

How do you return errors in the new API? Are they typed or do you only rely on HTTP statuses? Can you add an example?

@quentinlesceller
Copy link
Member Author

quentinlesceller commented Oct 9, 2019

@Kargakis I'll add a few examples of errors you can get!

@quentinlesceller
Copy link
Member Author

@Kargakis added a few examples. But basically it's like the v2/v3 grin-wallet API.

@quentinlesceller quentinlesceller mentioned this pull request Oct 11, 2019
11 tasks
Copy link
Contributor

@lehnberg lehnberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quentinlesceller really nice job on this - I'd gladly shepherd this RFC through the process of getting merged, if okay. Just gave some minor feedback inline.

More generally, as this will be a reference document if merged, it's good to write the RFC in present tense like it has already been approved and merged. And avoid having language like "if accepted" or "proposed" in it, as it will only be live if accepted already, if that makes sense.

See a similar discussion on RFC0005 here.

text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
Copy link
Contributor

@lehnberg lehnberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @quentinlesceller I took another detailed pass on the document, see comments of minor tweaks.

The actual API documentation looks really good to me - reads clear. I only had suggestions to make the RFC be more "future proof" so that it remains up to date and accurate even after it's been merged, and some minor tweaks here and there.

text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved
text/0000-node-api-v2.md Outdated Show resolved Hide resolved

## Authentication

Like the v1 API, the v2 API uses basic auth with the same secret. This token is usually in `grin/main/.api_secret`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this model is too simple, we clearly have more than one API here, at least 2 - data consumer and node management (perhaps also data producer - push_tx), which may require different tokens or more granular auth model.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly we could separate them in 2 or 3 difference endpoints. Do we want to add such complexity though. For such use case someone can just build a middleware on top of it to filter the requests?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically we have 2 APIs here, let's call them Blockchain API and Node API. The former is not node-specific (at least eventually), the later is. There are 2 different use cases and sets of clients. Security-wise exposing node api to internet is very risky. It's not that easy to restrict access to different JSON-RPC calls as for REST API (simple URL filtering is enough).
Token per endpoint model doesn't seem too hard to me, 1-2 lines of code to lookup a config key eg api_token_{endpoint_name}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. However I'm still not sure it's worth the additional complexity here. It's also possible to do filtering with JSON RPC method. Not against but not convinced :)

Copy link
Contributor

@jaspervdm jaspervdm Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this concern, it might be worthwhile to split them. A wallet only needs very few of these endpoints to fully function, so anyone exposing their node publically would prefer to only have those few methods available on the outside (or without api secret token).

text/0000-node-api-v2.md Outdated Show resolved Hide resolved
@lehnberg
Copy link
Contributor

In accordance with our RFC process, as of today this can be considered in Final Comment Period with a disposition to merge.

@lehnberg
Copy link
Contributor

lehnberg commented Dec 2, 2019

@hashmap @jaspervdm do you mind reviewing the recent Owner / Foreign API changes, before I merge the RFC?

@lehnberg lehnberg merged commit dbd30d9 into mimblewimble:master Dec 5, 2019
@lehnberg
Copy link
Contributor

lehnberg commented Dec 5, 2019

🎉 Wohooo! This RFC has now been merged! 🤸‍♀️
Tracking issue: mimblewimble/grin#3158

@quentinlesceller quentinlesceller deleted the nodeapiv2 branch December 5, 2019 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to core team node dev Related to node dev team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants