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

Updates Service Provider Guide #826

Merged
merged 17 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions docs/gaia-tutorials/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ gaiad version --long
```bash
name: gaia
server_name: gaiad
version: 2.0.3
commit: 2f6783e298f25ff4e12cb84549777053ab88749a
version: v4.2.1
commit: dbd8a6fb522c571debf958837f9113c56d418f6b
build_tags: netgo,ledger
go: go version go1.12.5 darwin/amd64
go: go version go1.16 darwin/amd64
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as before, we are on go1.15

```

### Build Tags
Expand All @@ -78,13 +78,10 @@ Build tags indicate special features that have been enabled in the binary.
| netgo | Name resolution will use pure Go code |
| ledger | Ledger devices are supported (hardware wallets) |

### Install binary distribution via snap (Linux only)
## Work with a Cosmos SDK Clone

**Do not use snap at this time to install the binaries for production until we have a reproducible binary system.**

## Developer Workflow

To test any changes made in the SDK or Tendermint, a `replace` clause needs to be added to `go.mod` providing the correct import path.
If you want to work with your own modifications of the Cosmos SDK, make a fork and add a `replace` clause to the `go.mod` file.
toschdev marked this conversation as resolved.
Show resolved Hide resolved
The `replace` clause needs to be added to `go.mod` providing the correct import path.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

- Make appropriate changes
- Add `replace github.com/cosmos/cosmos-sdk => /path/to/clone/cosmos-sdk` to `go.mod`
Expand Down
59 changes: 46 additions & 13 deletions docs/gaia-tutorials/join-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ order: 3

# Join the Cosmos Hub Mainnet


## Quickstart

**Get Ready**
Expand Down Expand Up @@ -36,7 +35,6 @@ Note: If your node is unable to connect to any of the seeds listed here, you ca

If you'd like to save those seeds to your settings put them in ~/.gaia/config/config.toml in the p2p section under seeds in the same comma-separated list format.
toschdev marked this conversation as resolved.
Show resolved Hide resolved


## Setting Up a New Node

**You need to [install gaia](./installation.md) before you go further**
Expand Down Expand Up @@ -72,7 +70,7 @@ You can edit the `~/.gaia/config/app.toml` file in order to enable the anti spam
# transaction. A transaction's fees must meet the minimum of any denomination
# specified in this config (e.g. 10uatom).
toschdev marked this conversation as resolved.
Show resolved Hide resolved

minimum-gas-prices = ""
minimum-gas-prices = "0.025uatom"
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest matching what's written as the example's text, e.g., is "10uatom" written as "10utom"? Is 0.025uatom the official recommendation? If there's an official standard, perhaps a link could be helpful.

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, it's actually in the same document a few lines below

End of chapter a note on gas and fees. So I thought let's make it even more clear. Having no input is actually dangerous (because of transaction flood) - so let's add it to the code snipped directly.
https://github.com/cosmos/gaia/blob/main/docs/gaia-tutorials/join-mainnet.md#a-note-on-gas-and-fees

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Speaking about this, we could consider making this default into the bootstrapped app.toml file.

```

Your full node has been initialized!
Expand Down Expand Up @@ -132,13 +130,16 @@ The initial recommended `min-gas-prices` is `0.025uatom`, but you might want to

## Pruning of State

There are three strategies for pruning state, please be aware that this is only for state and not for block storage:
There are four strategies for pruning state, please be aware that this is only for state and not for block storage.
Pruning can be set by either adjusting the `pruning` parameter in the `~/.gaia/config/app.toml` file.
toschdev marked this conversation as resolved.
Show resolved Hide resolved
The following settings are available
toschdev marked this conversation as resolved.
Show resolved Hide resolved

1. `PruneEverything`: This means that all saved states will be pruned other than the current.
2. `PruneNothing`: This means that all state will be saved and nothing will be deleted.
3. `PruneSyncable`: This means that only the state of the last 100 and every 10,000th blocks will be saved.
1. `everything`: This means that all saved states will be pruned other than the current.
2. `nothing`: This means that all state will be saved and nothing will be deleted.
3. `default`: This means that only the state of the last 100 and every 10,000th blocks will be saved.
4. `custom`: Pruning settings can be specified through `pruning-keep-recent`, `pruning-keep-every`, and `pruning-interval`
toschdev marked this conversation as resolved.
Show resolved Hide resolved

By default every node is in `PruneSyncable` mode. If you would like to change your nodes pruning strategy then you must do so when the node is initialized. For example, if you would like to change your node to the `PruneEverything` mode then you can pass the `---pruning everything` flag when you call `gaiad start`.
By default every node is in `default` mode. If you would like to change your nodes pruning strategy then you must do so when the node is initialized. Passing a flag when starting `gaia` will always override settings in the `app.toml` file, if you would like to change your node to the `everything` mode then you can pass the `---pruning everything` flag when you call `gaiad start`.

> Note: When you are pruning state you will not be able to query the heights that are not in your store.

Choose a reason for hiding this comment

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

Suggested change
> Note: When you are pruning state you will not be able to query the heights that are not in your store.
> Note: Querying heights that are not in your store is not supported during state pruning.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that it is possible but only by specifying a node target that has a different pruning strategy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

during state pruning sounds like it is a process that has a short period of time. As we learned, it is a setting that will be used until the database is erased and the whole blockchain starts downloading with a (new or same) set pruning state.


Expand All @@ -158,6 +159,42 @@ gaiad status

View the status of the network with the [Cosmos Explorer](https://cosmos.network/launch).

## Enable the REST API

The REST API can be enabled in the `~/.gaia/config/app.toml` file.
By default the REST API is disabled, find the API part in the `app.toml` file and set `enable` to `true`
toschdev marked this conversation as resolved.
Show resolved Hide resolved

```toml
###############################################################################
### API Configuration ###
###############################################################################
[api]
# Enable defines if the API server should be enabled.
enable = true
# Swagger defines if swagger documentation should automatically be registered.
swagger = false
# Address defines the API server to listen on.
address = "tcp://0.0.0.0:1317"
```

Optionally you can set to activate swagger with setting `swagger` to `true` or change the port of the REST API in the parameter `address`.
After restarting your application, you are able to access the REST API on `YOURNODEIP:1317`.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

## GRPC Configuration

GRPC is enabled by default on port `9090`. You can find the gRPC settings in the `~/.gaia/config/app.toml` file in the gRPC section. Set `enable` to `false` in case you want to disabled the gRPC endpoint, you can change the port with changing the `address` parameter.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

```toml
###############################################################################
### gRPC Configuration ###
###############################################################################
[grpc]
# Enable defines if the gRPC server should be enabled.
enable = true
# Address defines the gRPC server address to bind to.
address = "0.0.0.0:9090"
```

## Export State

Gaia can dump the entire application state to a JSON file, which could be useful for manual analysis and can also be used as the genesis file of a new network.
toschdev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -208,8 +245,4 @@ invariant broken:
```

When submitting a invariant-broken transaction, transaction fee tokens are not
deducted as the blockchain will halt (aka. this is a free transaction).

## Upgrade to Validator Node
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Full Node setup should be providing the setup how to create a Full Node.
Opening REST API, GRPC and remote access are all suggestions that are not for a validator node, which should have different security setups. Therefore upgrading an open Full Node to a Validator Node should not be emphasized in this setup.


You now have an active full node. What's the next step? You can upgrade your full node to become a Cosmos Validator. The top 125 validators have the ability to propose new blocks to the Cosmos Hub. Continue onto [the Validator Setup](../validators/validator-setup.md).
deducted as the blockchain will halt (aka. this is a free transaction).
toschdev marked this conversation as resolved.
Show resolved Hide resolved
169 changes: 97 additions & 72 deletions docs/resources/service-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,103 @@ order: 5

# Service Providers

We define 'service providers' as entities providing services for end-users that involve some form of interaction with a Cosmos-SDK based blockchain (this includes the Cosmos Hub). More specifically, this document will be focused around interactions with tokens.
'Service Providers' are defined as entities providing services for end-users that involve some form of interaction with the Cosmos Hub. More specifically, this document will be focused around interactions with tokens.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

This section does not concern wallet builders that want to provide Light-Client functionalities. Service providers are expected to act as trusted point of contact to the blockchain for their end-users.
This section does not concern wallet builders that want to provide Light-Client functionalities. Service Providers are expected to act as trusted point of contact to the blockchain for their end-users.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

## High-level description of the architecture
## Connection Options

There are three main pieces to consider:
There are four main technologies to consider, connecting to the Cosmos Hub:
toschdev marked this conversation as resolved.
Show resolved Hide resolved

- Full-nodes: To interact with the blockchain.
- Rest Server: This acts as a relayer for HTTP calls.
- Rest API: Define available endpoints for the Rest Server.
- Full Nodes: To interact with the blockchain.
- REST Server: This acts as a relayer for HTTP calls.
- REST API: Define available endpoints for the REST Server.
- GRPC: Connect to the Cosmos Hub via gRPC.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

## Running a Full-Node
toschdev marked this conversation as resolved.
Show resolved Hide resolved

### What is a Full Node?

A Full Node is a network node that syncs up with the state of the blockchain. It provides blockchain data to others by using RESTful APIs, a replica of the database by exposing data with interfaces. A Full Node keeps in syncs with the rest of the blockchain nodes and stores the state on disk. If the full node does not have the queried block on disk the full node can go find the blockchain where the queried data lives.

Choose a reason for hiding this comment

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

Suggested change
A Full Node is a network node that syncs up with the state of the blockchain. It provides blockchain data to others by using RESTful APIs, a replica of the database by exposing data with interfaces. A Full Node keeps in syncs with the rest of the blockchain nodes and stores the state on disk. If the full node does not have the queried block on disk the full node can go find the blockchain where the queried data lives.
A full node is a network node that syncs up with the state of the blockchain. A full node provides blockchain data to other blockchains by using RESTful APIs. A full node is a replica of the database by exposing data with interfaces. A full node keeps in syncs with the rest of the blockchain nodes and stores the state on disk. If the full node does not have the queried block on disk, the full node can go find the blockchain where the queried data lives.

Choose a reason for hiding this comment

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

I am learning! what do we mean by? (is a full node a replica?)

by using RESTful APIs. A full node is a replica of the database by exposing data with interfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to other blockchains is not correct. It providers blockchain data to other nodes using the same blockchain.


### Installation and configuration
toschdev marked this conversation as resolved.
Show resolved Hide resolved

We will describe the steps to run and interact with a full-node for the Cosmos Hub. For other SDK-based blockchain, the process should be similar.
We will describe the steps to run and interact with a Full Node for the Cosmos Hub.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

First, you need to [install the software](../gaia-tutorials/installation.md).

Then, you can start [running a full-node](../gaia-tutorials/join-mainnet.md).
Consider running your own [Cosmos Hub Full Node](../gaia-tutorials/join-mainnet.md).

### Command-Line interface
## Command-Line interface

## Setting Up `gaiad`
The Command-Line Interface (CLI) is the most powerful tool to access the Cosmos Hub and use gaia.
toschdev marked this conversation as resolved.
Show resolved Hide resolved
You need to install the latest version of `gaia` on your machine in order to use the Command-Line Interface.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

::: tip
**Before setting up `gaiad`, make sure you have set up a way to [access the Cosmos Hub network](#accessing-the-cosmos-hub-network)**
:::
Compare your version with the [latest release version](https://github.com/cosmos/gaia/releases)

::: warning
**Please check that you are always using the latest stable release of `gaiad`**
:::
```bash
gaiad version --long
```

`gaiad` is the tool that enables you to interact with the node that runs on the Cosmos Hub network, whether you run it yourself or not. Let us set it up properly.
#### Help

In order to set up `gaiad`, use the following command:
All available CLI commands will be shown if you just execute `gaiad`:
toschdev marked this conversation as resolved.
Show resolved Hide resolved

```bash
gaiad config <flag> <value>
gaiad
```

```bash
Stargate Cosmos Hub App

Usage:
gaiad [command]

Available Commands:


add-genesis-account Add a genesis account to genesis.json
collect-gentxs Collect genesis txs and output a genesis.json file
debug Tool for helping with debugging your application
export Export state to JSON
gentx Generate a genesis tx carrying a self delegation
help Help about any command
init Initialize private validator, p2p, genesis, and application configuration files
keys Manage your application's keys
migrate Migrate genesis to a specified target version
query Querying subcommands
start Run the full node
status Query remote node for status
tendermint Tendermint subcommands
testnet Initialize files for a simapp testnet
tx Transactions subcommands
unsafe-reset-all Resets the blockchain database, removes address book files, and resets data/priv_validator_state.json to the genesis state
validate-genesis validates the genesis file at the default location or at the location passed as an arg
version Print the application binary version information

Flags:
-h, --help help for gaiad
--home string directory for config and data (default "/Users/tobias/.gaia")
--log_format string The logging format (json|plain) (default "plain")
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
--trace print out full stack trace on errors

Use "gaiad [command] --help" for more information about a command.
```

It allows you to set a default value for each given flag.
For each displayed command, you can use the `--help` flag to get further information.

### Remote Access to gaiad

When choosing to remote access a Full Node and gaiad, you need a Full Node running and gaia installed on your local machine.

`gaiad` is the tool that enables you to interact with the node that runs on the Cosmos Hub network, whether you run it yourself or not.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line could be moved earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how far earlier do you have in mind? Beginning of this chapter or even at the start of the whole article?


In order to set up `gaiad` on a local machine and connect to an existing Full Node, use the following command:
toschdev marked this conversation as resolved.
Show resolved Hide resolved

```bash
gaiad config <flag> <value>
```

First, set up the address of the full-node you want to connect to:
toschdev marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -56,25 +110,26 @@ gaiad config node <host>:<port
// example: gaiad config node https://77.87.106.33:26657
```

If you run your own full-node, just use `tcp://localhost:26657` as the address.
If you run your own Full Node locally, use `tcp://localhost:26657` as the address.
toschdev marked this conversation as resolved.
Show resolved Hide resolved

Then, let us set the default value of the `--trust-node` flag:
Set the default value of the `--trust-node` flag:

```bash
gaiad config trust-node false

// Set to true if you run a light-client node, false otherwise
// Set to true if you run a light-client node
toschdev marked this conversation as resolved.
Show resolved Hide resolved
```

Finally, let us set the `chain-id` of the blockchain we want to interact with:
Finally, set the `chain-id` of the blockchain you want to interact with:

```bash
gaiad config chain-id cosmoshub-2
gaiad config chain-id cosmoshub-4
```

Next you will find a few useful CLI commands to interact with the Full-Node.
Next you will learn useful CLI commands to interact with the Full Node.
toschdev marked this conversation as resolved.
Show resolved Hide resolved
You can run these commands as remote control or when you are running it on your local machine.

#### Creating a key-pair
### How to create a key-pair

To generate a new key (default secp256k1 elliptic curve):
toschdev marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -90,13 +145,13 @@ You will be asked to create a password (at least 8 characters) for this key-pair
- `PUBKEY`: Your public key. Useful for validators.
- `MNEMONIC`: 24-words phrase. **Save this mnemonic somewhere safe**. It is used to recover your private key in case you forget the password.

You can see all your available keys by typing:
You can see all available keys by typing:

```bash
gaiad keys list
```

#### Checking your balance
#### Check your balance

After receiving tokens to your address, you can view your account's balance by typing:

Expand All @@ -106,13 +161,13 @@ gaiad query account <YOUR_ADDRESS>

*Note: When you query an account balance with zero tokens, you will get this error: No account with address <YOUR_ADDRESS> was found in the state. This is expected! We're working on improving our error messages.*

#### Sending coins via the CLI
#### Send coins using the CLI
toschdev marked this conversation as resolved.
Show resolved Hide resolved

Here is the command to send coins via the CLI:
toschdev marked this conversation as resolved.
Show resolved Hide resolved

```bash
gaiad tx send <from_key_or_address> <to_address> <amount> \
--chain-id=<name_of_testnet_chain>
--chain-id=<your_chain_id>
```

Parameters:
Expand All @@ -123,48 +178,12 @@ Parameters:

Flags:

- `--chain-id`: This flag allows you to specify the id of the chain. There will be different ids for different testnet chains and main chain.
- `--chain-id`: This flag allows you to specify the id of the chain. There will be different ids for different testnet chains and mainnet chains.

#### Help
## REST API

If you need to do something else, the best command you can run is:

```bash
gaiad
```

It will display all the available commands. For each command, you can use the `--help` flag to get further information.

## Setting up the Rest Server

The Rest Server acts as an intermediary between the front-end and the full-node. You don't need to run the Rest Server on the same machine as the full-node.

To start the Rest server:

```bash
gaiad rest-server --node=<full_node_address:full_node_port>
```

Flags:
- `--trust-node`: A boolean. If `true`, light-client verification is disabled. If `false`, it is enabled. For service providers, this should be set to `true`. By default, it set to `false`.
- `--node`: This is where you indicate the address and the port of your full-node. The format is `<full_node_address:full_node_port>`. If the full-node is on the same machine, the address should be `tcp://localhost:26657`.
- `--laddr`: This flag allows you to specify the address and port for the Rest Server (default `1317`). You will mostly use this flag only to specify the port, in which case just input "localhost" for the address. The format is <rest_server_address:port>.


### Listening for incoming transaction

The recommended way to listen for incoming transaction is to periodically query the blockchain through the following endpoint of the LCD:

[`/bank/balance/{address}`](https://cosmos.network/rpc/#/ICS20/get_bank_balances__address_)

## Rest API

The Rest API documents all the available endpoints that you can use to interact
with your full node. It can be found [here](https://cosmos.network/rpc/).

The API is divided into ICS standards for each category of endpoints. For
example, the [ICS20](https://cosmos.network/rpc/#/ICS20/) describes the API to
interact with tokens.
The [REST API documents](https://cosmos.network/rpc/) list all the available endpoints that you can use to interact
with your Full Node.

To give more flexibility to developers, we have included the ability to
generate unsigned transactions, [sign](https://cosmos.network/rpc/#/ICS20/post_tx_sign)
Expand All @@ -176,6 +195,12 @@ In order to generate an unsigned transaction (example with
[coin transfer](https://cosmos.network/rpc/#/ICS20/post_bank_accounts__address__transfers)),
you need to use the field `generate_only` in the body of `base_req`.

### Listen for incoming transaction
toschdev marked this conversation as resolved.
Show resolved Hide resolved

The recommended way to listen for incoming transaction is to periodically query the blockchain through the following endpoint of the LCD:

[`/cosmos/bank/v1beta1/balances/{address}`](https://cosmos.network/rpc/)

## Cosmos SDK Transaction Signing

Cosmos SDK transaction signing is a fairly simple process.
Expand Down