Skip to content

Commit

Permalink
Updated Oasis API Server to work with Oasis v20.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vvoluom committed Jun 19, 2020
1 parent d69fa64 commit 6e70d72
Show file tree
Hide file tree
Showing 23 changed files with 1,025 additions and 304 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<img src="./docs/OASIS.png" alt="design" />

The Oasis API Server is a wrap-around of the [Oasis Protocol Golang API](https://github.com/oasislabs/oasis-core). This makes it easier to use the protocol's API with any programming language in order to query data from the Oasis nodes. This server is also able to query data from the Oasis nodes' exposed Prometheus endpoint.
The Oasis API Server is a wrap-around of the [Oasis Protocol Golang API](https://github.com/oasisprotocol/oasis-core). This makes it easier to use the protocol's API with any programming language in order to query data from the Oasis nodes. This server is also able to query data from the Oasis nodes' exposed Prometheus endpoint.

The API Server was specifically built as a way for PANIC to be able to retrieve data from the Oasis nodes that it will be monitoring. Apart from retrieving data from the protocol's API, this server can retrieve data from the exposed Prometheus endpoint.

Expand Down
30 changes: 30 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 1.0.3
Released on 19th June 2020

### Added

#### Staking

* GetLastBlockFees Handler at /api/staking/lastblockfees
* GetAddressFromPublicKey Handler at /api/staking/publickeytoaddress

#### Consensus:

* GetStatus Handler at /api/consensus/status
* GetGenesisDocument Handler at /api/consensus/genesisdocument

#### Registry:

* GetNodeStatus Handler at /api/registry/nodestatus
* GetRegistryEvents Handler at /api/registry/events

### Updated

#### Staking

* GetAccounts at /api/staking/accounts has been changed to GetAddresses at /api/staking/addresses
* GetAccountInfo at /api/staking/accountinfo has been changed to GetAccount at /api/staking/account, and "ownerKey" query parameter has been changed to "address"
* GetDelegations "ownerKey" query parameter has been changed to "address"
* GetDebondingDelegations "ownerKey" query parameter has been changed to "address"


## 1.0.2

Released on May 2020
Expand Down
34 changes: 20 additions & 14 deletions docs/DESIGN_AND_FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ The API Server works as follows:
- By communicating through this port, the API Server receives the endpoints specified in the `Complete List of Endpoints` section below, and requests information from the nodes it is connected to accordingly.
- Once a request is received for an endpoint the server will read the query which should contain the name of the node that will be queried, it then attempts to establish a connection to the node and request data from it. This data is then foramtted into JSON and returned.
- The server interacts with the protocol API through these clients :
1. [Consensus Client](https://godoc.org/github.com/oasislabs/oasis-core/go/consensus/api#ClientBackend)
2. [Registry Backend](https://godoc.org/github.com/oasislabs/oasis-core/go/registry/api#Backend)
3. [Staking Backend](https://godoc.org/github.com/oasislabs/oasis-core/go/staking/api#Backend)
4. [Scheduler Backend](https://godoc.org/github.com/oasislabs/oasis-core/go/scheduler/api#Backend)
5. [NodeController](https://godoc.org/github.com/oasislabs/oasis-core/go/control/api#NodeController)
6. [Sentry](https://godoc.org/github.com/oasislabs/oasis-core/go/sentry/api#Backend)
1. [Consensus Client](https://godoc.org/github.com/oasisprotocol/oasis-core/go/consensus/api#ClientBackend)
2. [Registry Backend](https://godoc.org/github.com/oasisprotocol/oasis-core/go/registry/api#Backend)
3. [Staking Backend](https://godoc.org/github.com/oasisprotocol/oasis-core/go/staking/api#Backend)
4. [Scheduler Backend](https://godoc.org/github.com/oasisprotocol/oasis-core/go/scheduler/api#Backend)
5. [NodeController](https://godoc.org/github.com/oasisprotocol/oasis-core/go/control/api#NodeController)
6. [Sentry](https://godoc.org/github.com/oasisprotocol/oasis-core/go/sentry/api#Backend)

## Complete List of Endpoints
| API Endpoint | Required Inputs | Optional Inputs | Output |
|----------------------------------|---------------------------------|-----------------|---------------------------|
| API Endpoint | Required Inputs | Optional Inputs | Output |
|--------------------------------------|---------------------------------|-----------------|---------------------------|
| /api/ping | none | none | Pong |
| /api/getconnectionslist | none | none | List of Connections |
| /api/consensus/genesis | Node Name | Height | Consensus Genesis State |
| /api/consensus/epoch | Node Name | Height | Epoch |
| /api/consensus/genesis | Node Name | Height | Consensus Genesis State |
| /api/consensus/genesisdocument | Node Name | | Original Genesis Document |
| /api/consensus/epoch | Node Name | Height | Epoch |
| /api/consensus/status | Node Name | | Node Status |
| /api/consensus/block | Node Name | Height | Block Object |
| /api/consensus/blockheader | Node Name | Height | Block Header Object |
| /api/consensus/blocklastcommit | Node Name | Height | Block Last Commit Object |
Expand All @@ -50,16 +52,20 @@ The API Server works as follows:
| /api/registry/genesis | Node Name | Height | Genesis State of Registry |
| /api/registry/entity | Node Name, Entity Public Key | Height | Entity |
| /api/registry/node | Node Name, Node Public Key | Height | Node |
| /api/registry/nodestatus | Node Name, Node Public Key | Height | Node Status |
| /api/registry/events | Node Name | Height | Registry Events |
| /api/registry/runtime | Node Name, Runtime Namespace | Height | Runtime |
| /api/staking/totalsupply | Node Name | Height | Total Supply |
| /api/staking/commonpool | Node Name | Height | Common Pool |
| /api/staking/lastblockfees | Node Name | Height | Last Block Fees |
| /api/staking/genesis | Node Name | Height | Staking Genesis State |
| /api/staking/threshold | Node Name, kind | Height | Threshold |
| /api/staking/accounts | Node Name | Height | List of accounts |
| /api/staking/accountinfo | Node Name, Account Public Key | Height | Account information |
| /api/staking/delegations | Node Name, Account Public Key | Height | Delegations |
| /api/staking/debondingdelegations | Node Name, Account Public Key | Height | DebondingDelegations |
| /api/staking/addresses | Node Name | Height | List of accounts |
| /api/staking/account | Node Name, Account Address | Height | Account information |
| /api/staking/delegations | Node Name, Account Address | Height | Delegations |
| /api/staking/debondingdelegations | Node Name, Account Address | Height | DebondingDelegations |
| /api/staking/events | Node Name | Height | List of Events |
| /api/staking/publickeytoaddress | Public Key | | Staking Address |
| /api/nodecontroller/synced | Node Name | None | Synchronized State |
| /api/scheduler/validators | Node Name | Height | List of Validators |
| /api/scheduler/committees | Node Name, Namespace | Height | Committees |
Expand Down
13 changes: 10 additions & 3 deletions docs/INSTALL_AND_RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ git clone https://github.com/SimplyVC/oasis_api_server
Then run the following commands to build the image:
```bash
cd oasis_api_server
docker build -t simplyvc/oasis_api_server:1.0.2 .
docker build -t simplyvc/oasis_api_server:1.0.3 .
```


##### Downloading the Pre-Built Docker Image from DockerHub

The pre-built Docker image can simply be downloaded by running the following command:
```bash
docker pull simplyvc/oasis_api_server:1.0.2
docker pull simplyvc/oasis_api_server:1.0.3
```

#### Config Files Directory and Permissions
Expand All @@ -175,7 +175,7 @@ docker run --network="host" -p 127.0.0.1:8686:8686 \
--mount type=bind,source=<CONFIG_DIR>,target=/app/config/ \
--mount type=bind,source=<INTERNAL_SOCK_DIR>,target=<PATH_IN_NODE_CONFIG> \
--mount type=bind,source=<INTERNAL_TLS_DIR>,target=<PATH_IN_SENTRY_CONFIG> \
-d simplyvc/oasis_api_server:1.0.2
-d simplyvc/oasis_api_server:1.0.3
```

Note: The port after `-p` and before the `:` can be used to route a port from the machine to the internal port of the Docker. If changing this, any program which refers to the API Docker container must refer to this port.\
Expand All @@ -193,5 +193,12 @@ If you wish to check the API's connection to a node, you can run the following f
curl -X GET http://localhost:3000/api/pingnode?name=<NODE>
```

**Note**

Using curl with multiple queries requires the entire url to be inside double quotation marks as seen in the example below:

```bash
curl -X GET "http://localhost:3000/api/registry/nodes?name=<NODE>&height=300"
```
---
[Back to API front page](../README.md)
2 changes: 1 addition & 1 deletion setup/setup_user_config_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def reset_section(section: str, cp: ConfigParser) -> None:
def setup_api_server(cp: ConfigParser) -> None:
print('==== API Server')
print('The API server makes the retrieval of Oasis nodes data possible. '
'Apart from the API server, Node Exporter is also using to query '
'Apart from the API server, Node Exporter is also used to query '
'system data. During this setup process you will configure both.')

already_set_up = is_already_set_up(cp, 'api_server')
Expand Down
35 changes: 18 additions & 17 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/SimplyVC/oasis_api_server/src
go 1.13

replace (
github.com/tendermint/tendermint => github.com/oasislabs/tendermint v0.33.4-oasis1
golang.org/x/crypto/curve25519 => github.com/oasislabs/ed25519/extra/x25519 v0.0.0-20191022155220-a426dcc8ad5f
golang.org/x/crypto/ed25519 => github.com/oasislabs/ed25519 v0.0.0-20191109133925-b197a691e30d
github.com/tendermint/tendermint => github.com/oasisprotocol/tendermint v0.33.4-oasis2
golang.org/x/crypto/curve25519 => github.com/oasisprotocol/ed25519/extra/x25519 v0.0.0-20200528083105-55566edd6df0
golang.org/x/crypto/ed25519 => github.com/oasisprotocol/ed25519 v0.0.0-20200528083105-55566edd6df0
)

require (
github.com/blevesearch/bleve v0.8.0
github.com/blevesearch/bleve v1.0.9
github.com/cenkalti/backoff/v4 v4.0.0
github.com/claudetech/ini v0.0.0-20140910072410-73e6100d9d51
github.com/dgraph-io/badger/v2 v2.0.3
Expand All @@ -22,14 +22,15 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
github.com/hpcloud/tail v1.0.0
github.com/kainlite/grpc-ping v0.0.0-20190623201649-d8f897f70424
github.com/libp2p/go-libp2p v0.1.1
github.com/libp2p/go-libp2p-core v0.0.3
github.com/libp2p/go-libp2p v0.9.1
github.com/libp2p/go-libp2p-core v0.5.6
github.com/mackerelio/go-osstat v0.1.0
github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-net v0.0.1
github.com/oasislabs/deoxysii v0.0.0-20190807103041-6159f99c2236
github.com/oasislabs/ed25519 v0.0.0-20191122104632-9d9ffc15f526
github.com/oasislabs/oasis-core/go v0.0.0-20200514075234-edb8515cb538
github.com/multiformats/go-multiaddr v0.2.2
github.com/multiformats/go-multiaddr-net v0.1.5
github.com/oasisprotocol/deoxysii v0.0.0-20200527154044-851aec403956
github.com/oasisprotocol/ed25519 v0.0.0-20200528083105-55566edd6df0
github.com/oasisprotocol/oasis-core v0.0.0-20200616160851-aa117564d654 // indirect
github.com/oasisprotocol/oasis-core/go v0.0.0-20200618144736-02a945839e9b
github.com/opentracing/opentracing-go v1.1.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1
Expand All @@ -40,18 +41,18 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.5.1
github.com/tendermint/go-amino v0.15.0 // indirect
github.com/tendermint/iavl v0.12.2
github.com/tendermint/tendermint v0.32.8
github.com/tendermint/tendermint v0.33.4
github.com/tendermint/tm-db v0.5.1
github.com/thepudds/fzgo v0.2.2
github.com/uber/jaeger-client-go v2.16.0+incompatible
github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc
github.com/whyrusleeping/go-logging v0.0.1
github.com/whyrusleeping/go-notifier v0.0.0-20170827234753-097c5d47330f // indirect
github.com/zenazn/goji v0.9.0
github.com/zondax/ledger-oasis-go v0.3.0
gitlab.com/yawning/dynlib.git v0.0.0-20190911075527-1e6ab3739fd8
golang.org/x/crypto v0.0.0-20200406173513-056763e48d71
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
gitlab.com/yawning/dynlib.git v0.0.0-20200603163025-35fe007b0761
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7
google.golang.org/genproto v0.0.0-20200313141609-30c55424f95d
google.golang.org/grpc v1.29.1
)
Loading

0 comments on commit 6e70d72

Please sign in to comment.