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

LCD and API Specification / Documentation #1617

Merged
merged 2 commits into from
Jul 19, 2018
Merged

Conversation

adrianbrink
Copy link
Contributor

Supercedes #1314 . All past discussion happened on that branch.

This branch squashes all commits into a single commit without force-pushing over public branches.

Copy link
Member

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Just some initial review. Still going through it. Don't think it belongs in the spec folder. We can merge and mark it as a WIP and move it to the docs - will keep reviewing from there


url: /broadcast_tx_sync

Functionality: Submit a signed transaction and wait for it to be committed.
Copy link
Member

Choose a reason for hiding this comment

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

doesn't wait for it to be committed. that's broadcast_tx_commit. Should we have all three endpoints here? We certainly shouldn't use the same terms to refer to different things ...


Functionality: Submit a signed transaction and wait for it to be committed.

Parameters:
Copy link
Member

Choose a reason for hiding this comment

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

these dont seem to be rendering properly in https://github.com/cosmos/cosmos-sdk/blob/adrian/lcd_spec_final/docs/spec/light/api.md#broadcast_tx_sync---post

This is the case for all these params tables ..

"code":200,
"error": "",
"result": {
"address":BD607C37147656A507A5A521AA9446EB72B2C907
Copy link
Member

Choose a reason for hiding this comment

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

I think the address is missing quotes

"code":200,
"error": "",
"result": {
"seed":crime carpet recycle erase simple prepare moral dentist fee cause pitch trigger when velvet animal abandon
Copy link
Member

Choose a reason for hiding this comment

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

missing quotes ?

"code":200,
"error": "",
"result": {
"atom": 1000,
Copy link
Member

Choose a reason for hiding this comment

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

Amino v0.10 follows proto3 where integers are quoted as strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this apply to all integers? Will the error codes change as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should stick with integers here though, since it seems to be the standard for json. This API doesn't necessarily have to comply with amino encoding.

"code":200,
"error": "",
"result": {
"transaction": "TODO:<JSON sign bytes for the transaction>"
Copy link
Member

Choose a reason for hiding this comment

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

TODO


![deposit](https://github.com/irisnet/cosmos-sdk/raw/bianjie/lcd_spec/docs/spec/lcd/pics/create-account.png)

First you need to get a new seed phrase :[get-seed](https://github.com/irisnet/cosmos-sdk/blob/bianjie/lcd_spec/docs/spec/lcd/api.md#keysseed---get)
Copy link
Member

Choose a reason for hiding this comment

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

these links dont seem to be working

@@ -0,0 +1,203 @@
# Load Balancing Module

The LCD will be an important bridge between service providers and cosmos blockchain network. Suppose
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this section. I don't think we want to build a load balancer in to the LCD.

More likely we need to work on streaming events out of Tendermint and into something like Postgres and load-balancing the access to postgres.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it could be useful that a single light-client distributes its requests over many full-nodes. That's what this section is mostly describing. I am not sure whether we want Gaia Light to include postgres (or some other database) as a dependency.

@@ -0,0 +1,55 @@
# Overview
Copy link
Member

Choose a reason for hiding this comment

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

isnt this just a copy of what's already in the readme?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the overview.md

Error messages my change and should be only used for display purposes. Error messages should not be
used for determining the error type.

## ICS0 - TendermintAPI - not yet implemented
Copy link
Member

Choose a reason for hiding this comment

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

Do we want other endpoints to be part of this ? /status, /net_info, etc. ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, eventually we'll add those in as well.

@ebuchman ebuchman changed the base branch from develop to master July 11, 2018 00:29
* Move from specs to docs folder
* Attempt to fix markdown links
* Address general comments from the PR
* Remove overview.md due to duplication with readme.md
@codecov
Copy link

codecov bot commented Jul 11, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@e984b73). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master    #1617   +/-   ##
=========================================
  Coverage          ?   63.71%           
=========================================
  Files             ?      122           
  Lines             ?     6774           
  Branches          ?        0           
=========================================
  Hits              ?     4316           
  Misses            ?     2211           
  Partials          ?      247

@ebuchman ebuchman changed the base branch from master to develop July 16, 2018 15:53
Copy link
Member

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Really great start. I think we should move it to lite though to be consistent with Tendermint

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Agreed on switching from light to lite.

Left several comments, nothing that needs to block this PR unless you want to make changes, but I don't think we should consider this API finalized yet (mostly because of HD keys).

}
```

### /broadcast_tx_commit - POST
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need either simulation options for these endpoints or a separate simulation endpoint, see #1246 (not yet implemented).

Doesn't need to block this PR.

@@ -0,0 +1,203 @@
# Load Balancing Module - WIP
Copy link
Contributor

Choose a reason for hiding this comment

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

While we can include this, I'm not convinced client-side load balancing is all that useful.

It doesn't protect servers from malicious or misconfigured clients, and can't ever balance that effectively since it has no information about what requests other clients are making to the same full nodes. I think implementing a way for full nodes to provide a single endpoint (fullnode.myvalidator.com) which balances to multiple Tendermint/SDK instances, fronted by a cache layer (don't need to write this, e.g. Varnish) will be more likely to work.

Copy link
Contributor

Choose a reason for hiding this comment

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

What we probably do want is client-side retry logic - switch to a different full node if one is down.

| Storage resource|Huge|Little|Full node will save all blocks and ABCI states. LCD just saves validator sets and some checkpoints|
| Power consume|Huge|Little|Full nodes have to be deployed on machines which have high performance and will be running all the time. So power consume will be huge. LCD can be deployed on the same machines as users' applications, or on independent machines but with poor performance. Besides, LCD can be shutdown anytime when necessary. So LCD only consume very little power, even mobile devices can meet the power requirement|
| Provide APIs|All cosmos APIs|Modular APIs|Full node supports all cosmos APIs. LCD provides modular APIs according to users' configuration|
| Secuity level| High|High|Full node will verify all transactions and blocks by itself. LCD can't do this, but it can query any data from other full nodes and verify the data independently. So both full node and LCD don't need to trust any third nodes, they all can achieve high security|
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth mentioning weak subjectivity here. I would rate LCD security "Medium" personally (but note that it's way, way higher than e.g. Metamask).

}
```

### /keys/recover - POST
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to reflect HD derivation?

| Parameter | Type | Default | Required | Description |
| --------- | ------ | ------- | -------- | ---------------- |
| name | string | null | true | name of key |
| password | string | null | true | password of key |
Copy link
Contributor

Choose a reason for hiding this comment

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

Should add a way to specify an algorithm (ed25519/secp256k1).

}
```

## ICS1 - KeyAPI
Copy link
Contributor

Choose a reason for hiding this comment

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

This API needs to be refactored quite a bit for HD keys, which we probably want to encourage use of (do we want to support anything other than HD keys?)

Also, we support using the Ledger through the LCD API if you want to include that.

"code":200,
"error":"",
"result": {
"atom":1000,
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't how Amino serializes numbers now, they're strings instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we want the API to return numbers, we need to check that we won't lose precision.

| chain-id | string | null | true | chain id of the full node to connect |
| node | URL | "tcp://localhost:46657" | true | address of the full node to connect |
| laddr | URL | "tcp://localhost:1317" | true | address to run the rest server on |
| trust-node | bool | "false" | true | Whether this LCD is connected to a trusted full node |
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this flag do? Enable/disable proof verification?


![validator-set-change](pics/validatorSetChange.png)

### Trust propagation
Copy link
Contributor

Choose a reason for hiding this comment

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

Discuss bisection update algorithm here? Also related to slashing for Byzantine signatures even by unbonded validators (informal discussion with @sunnya97 and @jaekwon, not sure if it was written up anywhere).

Copy link
Contributor

Choose a reason for hiding this comment

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

Or that could go in a separate "Gaia lite formal spec" document.

@ebuchman
Copy link
Member

Merged - follow up in #1758

Thanks for the review @cwgoes - noted we should follow up on it from #1758

@ValarDragon ValarDragon deleted the adrian/lcd_spec_final branch September 23, 2018 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants