Skip to content

Commit

Permalink
Merge pull request #8576 from cosmos/am-backport-docs
Browse files Browse the repository at this point in the history
[backport/v0.41.x] Mega Docs cherry-pick PR
  • Loading branch information
Alessio Treglia authored Feb 15, 2021
2 parents 5bd006c + c878615 commit 2c52cb4
Show file tree
Hide file tree
Showing 19 changed files with 298 additions and 315 deletions.
2 changes: 1 addition & 1 deletion docs/building-modules/beginblock-endblock.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The actual implementation of `BeginBlocker` and `EndBlocker` in `./abci.go` are

A specificity of the `EndBlocker` is that it can return validator updates to the underlying consensus engine in the form of an [`[]abci.ValidatorUpdates`](https://tendermint.com/docs/app-dev/abci-spec.html#validatorupdate). This is the preferred way to implement custom validator changes.

It is possible for developers to defined the order of execution between the `BeginBlocker`/`EndBlocker` functions of each of their application's modules via the module's manager `SetOrderBeginBlocker`/`SetOrderEndBlocker` methods. For more on the module manager, click [here](./module-manager.md#manager).
It is possible for developers to define the order of execution between the `BeginBlocker`/`EndBlocker` functions of each of their application's modules via the module's manager `SetOrderBeginBlocker`/`SetOrderEndBlocker` methods. For more on the module manager, click [here](./module-manager.md#manager).

See an example implementation of `BeginBlocker` from the `distr` module:

Expand Down
5 changes: 3 additions & 2 deletions docs/building-modules/module-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Let us go through the methods of `AppModule`:
- `LegacyQuerierHandler(*codec.LegacyAmino)` (deprecated): Returns a [`querier`](./query-services.md#legacy-queriers) given the query `path`, in order to process the `query`.
- `RegisterServices(Configurator)`: Allows a module to register services.
- `BeginBlock(sdk.Context, abci.RequestBeginBlock)`: This method gives module developers the option to implement logic that is automatically triggered at the beginning of each block. Implement empty if no logic needs to be triggered at the beginning of each block for this module.
- `EndBlock(sdk.Context, abci.RequestEndBlock)`: This method gives module developers the option to implement logic that is automatically triggered at the beginning of each block. This is also where the module can inform the underlying consensus engine of validator set changes (e.g. the `staking` module). Implement empty if no logic needs to be triggered at the beginning of each block for this module.
- `EndBlock(sdk.Context, abci.RequestEndBlock)`: This method gives module developers the option to implement logic that is automatically triggered at the end of each block. This is also where the module can inform the underlying consensus engine of validator set changes (e.g. the `staking` module). Implement empty if no logic needs to be triggered at the end of each block for this module.


### Implementing the Application Module Interfaces

Expand Down Expand Up @@ -132,7 +133,7 @@ The module manager is used throughout the application whenever an action on a co
- `SetOrderInitGenesis(moduleNames ...string)`: Sets the order in which the [`InitGenesis`](./genesis.md#initgenesis) function of each module will be called when the application is first started. This function is generally called from the application's main [constructor function](../basics/app-anatomy.md#constructor-function).
- `SetOrderExportGenesis(moduleNames ...string)`: Sets the order in which the [`ExportGenesis`](./genesis.md#exportgenesis) function of each module will be called in case of an export. This function is generally called from the application's main [constructor function](../basics/app-anatomy.md#constructor-function).
- `SetOrderBeginBlockers(moduleNames ...string)`: Sets the order in which the `BeginBlock()` function of each module will be called at the beginning of each block. This function is generally called from the application's main [constructor function](../basics/app-anatomy.md#constructor-function).
- `SetOrderEndBlockers(moduleNames ...string)`: Sets the order in which the `EndBlock()` function of each module will be called at the beginning of each block. This function is generally called from the application's main [constructor function](../basics/app-anatomy.md#constructor-function).
- `SetOrderEndBlockers(moduleNames ...string)`: Sets the order in which the `EndBlock()` function of each module will be called at the end of each block. This function is generally called from the application's main [constructor function](../basics/app-anatomy.md#constructor-function).
- `RegisterInvariants(ir sdk.InvariantRegistry)`: Registers the [invariants](./invariants.md) of each module.
- `RegisterRoutes(router sdk.Router, queryRouter sdk.QueryRouter, legacyQuerierCdc *codec.LegacyAmino)`: Registers legacy [`Msg`](./messages-and-queries.md#messages) and [`querier`](./query-services.md#legacy-queriers) routes.
- `RegisterServices(cfg Configurator)`: Registers all module services.
Expand Down
8 changes: 4 additions & 4 deletions docs/core/grpc_rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Cosmos SDK v0.40 introduced Protobuf as the main [encoding](./encoding) library,

Each module exposes [`Msg` and `Query` Protobuf services](../building-modules/messages-and-queries.md) to define state transitions and state queries. These services are hooked up to gRPC via the following function inside the application:

https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc4/server/types/app.go#L39-L41
<https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/server/types/app.go#L39-L41>

The `grpc.Server` is a concrete gRPC server, which spawns and serves any gRPC requests. This server can be configured inside `$TMHOME/config/app.toml`:

- `grpc.enable = true|false` field defines if the gRPC server should be enabled. Defaults to `true`.
- `grpc.address = {string}` field defines the address (really, the port, since the host should be kept at `0.0.0.0`) the server should bind to. Defaults to `0.0.0.0:9000`.
- `grpc.address = {string}` field defines the address (really, the port, since the host should be kept at `0.0.0.0`) the server should bind to. Defaults to `0.0.0.0:9090`.

::tip
`$TMHOME` is the directory where the node's configuration and databases are stored. By default, it's set to `~/.{app_name}`.
Expand All @@ -45,7 +45,7 @@ In Cosmos SDK v0.40, the node continues to serve a REST server. However, the exi

All routes are configured under the following fields in `$TMHOME/config/app.toml`:

- `api.enable = true|false` field defines if the REST server should be enabled. Defaults to `true`.
- `api.enable = true|false` field defines if the REST server should be enabled. Defaults to `false`.
- `api.address = {string}` field defines the address (really, the port, since the host should be kept at `0.0.0.0`) the server should bind to. Defaults to `tcp://0.0.0.0:1317`.
- some additional API configuration options are defined in `$TMHOME/config/app.toml`, along with comments, please refer to that file directly.

Expand All @@ -55,7 +55,7 @@ If, for various reasons, you cannot use gRPC (for example, you are building a we

[gRPC-gateway](https://grpc-ecosystem.github.io/grpc-gateway/) is a tool to expose gRPC endpoints as REST endpoints. For each RPC endpoint defined in a Protobuf service, the SDK offers a REST equivalent. For instance, querying a balance could be done via the `/cosmos.bank.v1beta1.Query/AllBalances` gRPC endpoint, or alternatively via the gRPC-gateway `"/cosmos/bank/v1beta1/balances/{address}"` REST endpoint: both will return the same result. For each RPC method defined in a Protobuf service, the corresponding REST endpoint is defined as an option:

+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc4/proto/cosmos/bank/v1beta1/query.proto#L19-L22
+++ <https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/proto/cosmos/bank/v1beta1/query.proto#L19-L22>

For application developers, gRPC-gateway REST routes needs to be wired up to the REST server, this is done by calling the `RegisterGRPCGatewayRoutes` function on the ModuleManager.

Expand Down
102 changes: 53 additions & 49 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4738,11 +4738,11 @@ liveness activity.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | |
| `start_height` | [int64](#int64) | | Height at which validator was first a candidate OR was unjailed |
| `index_offset` | [int64](#int64) | | Index which is incremented each time the validator was a bonded in a block and may have signed a precommit or not. This in conjunction with the `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. |
| `jailed_until` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | Timestamp until which the validator is jailed due to liveness downtime. |
| `tombstoned` | [bool](#bool) | | Whether or not a validator has been tombstoned (killed out of validator set). It is set once the validator commits an equivocation or for any other configured misbehiavor. |
| `missed_blocks_counter` | [int64](#int64) | | A counter kept to avoid unnecessary array reads. Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. |
| `start_height` | [int64](#int64) | | height at which validator was first a candidate OR was unjailed |
| `index_offset` | [int64](#int64) | | index offset into signed block bit array |
| `jailed_until` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | timestamp validator cannot be unjailed until |
| `tombstoned` | [bool](#bool) | | whether or not a validator has been tombstoned (killed out of validator set) |
| `missed_blocks_counter` | [int64](#int64) | | missed blocks counter (to avoid scanning the array every time) |



Expand Down Expand Up @@ -5024,8 +5024,8 @@ Commission defines commission parameters for a given validator.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `commission_rates` | [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) | | |
| `update_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `commission_rates` | [CommissionRates](#cosmos.staking.v1beta1.CommissionRates) | | commission_rates defines the initial commission rates to be used for creating a validator. |
| `update_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | update_time is the last time the commission rate was changed. |



Expand All @@ -5041,9 +5041,9 @@ a validator.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `rate` | [string](#string) | | |
| `max_rate` | [string](#string) | | |
| `max_change_rate` | [string](#string) | | |
| `rate` | [string](#string) | | rate is the commission rate charged to delegators, as a fraction. |
| `max_rate` | [string](#string) | | max_rate defines the maximum commission rate which validator can ever charge, as a fraction. |
| `max_change_rate` | [string](#string) | | max_change_rate defines the maximum daily increase of the validator commission, as a fraction. |



Expand Down Expand Up @@ -5128,9 +5128,9 @@ validator.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `delegator_address` | [string](#string) | | |
| `validator_address` | [string](#string) | | |
| `shares` | [string](#string) | | |
| `delegator_address` | [string](#string) | | delegator_address is the bech32-encoded address of the delegator. |
| `validator_address` | [string](#string) | | validator_address is the bech32-encoded address of the validator. |
| `shares` | [string](#string) | | shares define the delegation shares received. |



Expand Down Expand Up @@ -5162,11 +5162,11 @@ Description defines a validator description.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `moniker` | [string](#string) | | |
| `identity` | [string](#string) | | |
| `website` | [string](#string) | | |
| `security_contact` | [string](#string) | | |
| `details` | [string](#string) | | |
| `moniker` | [string](#string) | | moniker defines a human-readable name for the validator. |
| `identity` | [string](#string) | | identity defines an optional identity signature (ex. UPort or Keybase). |
| `website` | [string](#string) | | website defines an optional website link. |
| `security_contact` | [string](#string) | | security_contact defines an optional email for security contact. |
| `details` | [string](#string) | | details define other optional details. |



Expand Down Expand Up @@ -5200,11 +5200,11 @@ Params defines the parameters for the staking module.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `unbonding_time` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
| `max_validators` | [uint32](#uint32) | | |
| `max_entries` | [uint32](#uint32) | | |
| `historical_entries` | [uint32](#uint32) | | |
| `bond_denom` | [string](#string) | | |
| `unbonding_time` | [google.protobuf.Duration](#google.protobuf.Duration) | | unbonding_time is the time duration of unbonding. |
| `max_validators` | [uint32](#uint32) | | max_validators is the maximum number of validators. |
| `max_entries` | [uint32](#uint32) | | max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). |
| `historical_entries` | [uint32](#uint32) | | historical_entries is the number of historical entries to persist. |
| `bond_denom` | [string](#string) | | bond_denom defines the bondable coin denomination. |



Expand Down Expand Up @@ -5237,10 +5237,12 @@ from a particular source validator to a particular destination validator.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `delegator_address` | [string](#string) | | |
| `validator_src_address` | [string](#string) | | |
| `validator_dst_address` | [string](#string) | | |
| `entries` | [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) | repeated | redelegation entries |
| `delegator_address` | [string](#string) | | delegator_address is the bech32-encoded address of the delegator. |
| `validator_src_address` | [string](#string) | | validator_src_address is the validator redelegation source operator address. |
| `validator_dst_address` | [string](#string) | | validator_dst_address is the validator redelegation destination operator address. |
| `entries` | [RedelegationEntry](#cosmos.staking.v1beta1.RedelegationEntry) | repeated | entries are the redelegation entries.

redelegation entries |



Expand All @@ -5255,10 +5257,10 @@ RedelegationEntry defines a redelegation object with relevant metadata.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `creation_height` | [int64](#int64) | | |
| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `initial_balance` | [string](#string) | | |
| `shares_dst` | [string](#string) | | |
| `creation_height` | [int64](#int64) | | creation_height defines the height which the redelegation took place. |
| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | completion_time defines the unix time for redelegation completion. |
| `initial_balance` | [string](#string) | | initial_balance defines the initial balance when redelegation started. |
| `shares_dst` | [string](#string) | | shares_dst is the amount of destination-validator shares created by redelegation. |



Expand Down Expand Up @@ -5310,9 +5312,11 @@ for a single validator in an time-ordered list.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `delegator_address` | [string](#string) | | |
| `validator_address` | [string](#string) | | |
| `entries` | [UnbondingDelegationEntry](#cosmos.staking.v1beta1.UnbondingDelegationEntry) | repeated | unbonding delegation entries |
| `delegator_address` | [string](#string) | | delegator_address is the bech32-encoded address of the delegator. |
| `validator_address` | [string](#string) | | validator_address is the bech32-encoded address of the validator. |
| `entries` | [UnbondingDelegationEntry](#cosmos.staking.v1beta1.UnbondingDelegationEntry) | repeated | entries are the unbonding delegation entries.

unbonding delegation entries |



Expand All @@ -5327,10 +5331,10 @@ UnbondingDelegationEntry defines an unbonding object with relevant metadata.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `creation_height` | [int64](#int64) | | |
| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `initial_balance` | [string](#string) | | |
| `balance` | [string](#string) | | |
| `creation_height` | [int64](#int64) | | creation_height is the height which the unbonding took place. |
| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | completion_time is the unix time for unbonding completion. |
| `initial_balance` | [string](#string) | | initial_balance defines the tokens initially scheduled to receive at completion. |
| `balance` | [string](#string) | | balance defines the tokens to receive at completion. |



Expand Down Expand Up @@ -5367,17 +5371,17 @@ multiplied by exchange rate.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator_address` | [string](#string) | | |
| `consensus_pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | |
| `jailed` | [bool](#bool) | | |
| `status` | [BondStatus](#cosmos.staking.v1beta1.BondStatus) | | |
| `tokens` | [string](#string) | | |
| `delegator_shares` | [string](#string) | | |
| `description` | [Description](#cosmos.staking.v1beta1.Description) | | |
| `unbonding_height` | [int64](#int64) | | |
| `unbonding_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `commission` | [Commission](#cosmos.staking.v1beta1.Commission) | | |
| `min_self_delegation` | [string](#string) | | |
| `operator_address` | [string](#string) | | operator_address defines the address of the validator's operator; bech encoded in JSON. |
| `consensus_pubkey` | [google.protobuf.Any](#google.protobuf.Any) | | consensus_pubkey is the consensus public key of the validator, as a Protobuf Any. |
| `jailed` | [bool](#bool) | | jailed defined whether the validator has been jailed from bonded status or not. |
| `status` | [BondStatus](#cosmos.staking.v1beta1.BondStatus) | | status is the validator status (bonded/unbonding/unbonded). |
| `tokens` | [string](#string) | | tokens define the delegated tokens (incl. self-delegation). |
| `delegator_shares` | [string](#string) | | delegator_shares defines total shares issued to a validator's delegators. |
| `description` | [Description](#cosmos.staking.v1beta1.Description) | | description defines the description terms for the validator. |
| `unbonding_height` | [int64](#int64) | | unbonding_height defines, if unbonding, the height at which this validator has begun unbonding. |
| `unbonding_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. |
| `commission` | [Commission](#cosmos.staking.v1beta1.Commission) | | commission defines the commission parameters. |
| `min_self_delegation` | [string](#string) | | min_self_delegation is the validator's self declared minimum self delegation. |



Expand Down
Loading

0 comments on commit 2c52cb4

Please sign in to comment.