bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 64쪽
000",
"description": {
"moniker": "SG-1",
"identity": "48608633F99D1B60",
"website": "https://sg-1.online",
"security_contact": "",
"details": "SG-1 - your favorite validator on cosmos. We offer 100% Soft Slash protection."
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.037500000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.030000000000000000"
},
"update_time": "2021-10-01T15:00:00Z"
},
"min_self_delegation": "1"
},
{
"operator_address": "cosmosvaloper1t8ehvswxjfn3ejzkjtntcyrqwvmvuknzmvtaaa",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "uExZyjNLtr2+FFIhNDAMcQ8+yTrqE7ygYTsI7khkA5Y="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "1348298958808",
"delegator_shares": "1348298958808.000000000000000000",
"description": {
"moniker": "Cosmostation",
"identity": "AE4C403A6E7AA1AC",
"website": "https://www.cosmostation.io",
"security_contact": "admin@stamper.network",
"details": "Cosmostation validator node. Delegate your tokens and Start Earning Staking Rewards"
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.050000000000000000",
"max_rate": "1.000000000000000000",
"max_change_rate": "0.200000000000000000"
},
"update_time": "2021-10-01T15:06:38.821314287Z"
},
"min_self_delegation": "1"
}
]
}
}
```
#### Parameters
The `Parameters` REST endpoint queries the staking parameters.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/params
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/params" -H "accept: application/json"
```
Example Output:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"params": {
"unbonding_time": "2419200s",
"max_validators": 100,
"max_entries": 7,
"historical_entries": 10000,
"bond_denom": "stake"
}
}
```
#### Pool
The `Pool` REST endpoint queries the pool information.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/pool
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/pool" -H "accept: application/json"
```
Example Output:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"pool": {
"not_bonded_tokens": "432805737458",
"bonded_tokens": "15783637712645"
}
}
```
#### Validators
The `Validators` REST endpoint queries all validators that match the given status.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/validators
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/validators" -H "accept: application/json"
```
Example Output:
```bash expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"validators": [
{
"operator_address": "cosmosvaloper1q3jsx9dpfhtyqqgetwpe5tmk8f0ms5qywje8tw",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "N7BPyek2aKuNZ0N/8YsrqSDhGZmgVaYUBuddY8pwKaE="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "383301887799",
"delegator_shares": "383301887799.000000000000000000",
"description": {
"moniker": "SmartNodes",
"identity": "D372724899D1EDC8",
"website": "https://smartnodes.co",
"security_contact": "",
"details": "Earn Rewards with Crypto Staking & Node Deployment"
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.050000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.100000000000000000"
},
"update_time": "2021-10-01T15:51:31.596618510Z"
},
"min_self_delegation": "1"
},
{
"operator_address": "cosmosvaloper1q5ku90atkhktze83j9xjaks2p7uruag5zp6wt7",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "GDNpuKDmCg9GnhnsiU4fCWktuGUemjNfvpCZiqoRIYA="
},
"jailed": false,
"status": "BOND_STATUS_UNBONDING",
"tokens": "1017819654",
"delegator_shares": "1017819654.000000000000000000",
"description": {
"moniker": "Noderunners",
"identity": "812E82D12FEA3493",
"website": "http://noderunners.biz",
"security_contact": "info@noderunners.biz",
"details": "Noderunners is a professional validator in POS networks. We have a huge node running experience, reliable soft and hardware. Our commissions are always low, our support to delegators is always full. Stake with us and start receiving your cosmos rewards now!"
},
"unbonding_height": "147302",
"unbonding_time": "2021-11-08T22:58:53.718662452Z",
"commission": {
"commission_rates": {
"rate": "0.050000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.100000000000000000"
},
"update_time": "2021-10-04T18:02:21.446645619Z"
},
"min_self_delegation": "1"
}
],
"pagination": {
"next_key": "FONDBFkE4tEEf7yxWWKOD49jC2NK",
"total": "2"
}
}
```
#### Validator
The `Validator` REST endpoint queries validator information for given validator address.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/validators/{validatorAddr}
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q" \
-H "accept: application/json"
```
Example Output:
```bash expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"validator": {
"operator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "sIiexdJdYWn27+7iUHQJDnkp63gq/rzUq1Y+fxoGjXc="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "33027900000",
"delegator_shares": "33027900000.000000000000000000",
"description": {
"moniker": "Witval",
"identity": "51468B615127273A",
"website": "",
"security_contact": "",
"details": "Witval is the validator arm from Vitwit. Vitwit is into software consulting and services business since 2015. We are working closely with Cosmos ecosystem since 2018. We are also building tools for the ecosystem, Aneka is our explorer for the cosmos ecosystem."
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.050000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.020000000000000000"
},
"update_time": "2021-10-01T19:24:52.663191049Z"
},
"min_self_delegation": "1"
}
}
```
#### ValidatorDelegations
The `ValidatorDelegations` REST endpoint queries delegate information for given validator.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/validators/{validatorAddr}/delegations
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q/delegations" -H "accept: application/json"
```
Example Output:
```bash expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"delegation_responses": [
{
"delegation": {
"delegator_address": "cosmos190g5j8aszqhvtg7cprmev8xcxs6csra7xnk3n3",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "31000000000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "31000000000"
}
},
{
"delegation": {
"delegator_address": "cosmos1ddle9tczl87gsvmeva3c48nenyng4n56qwq4ee",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "628470000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "628470000"
}
},
{
"delegation": {
"delegator_address": "cosmos10fdvkczl76m040smd33lh9xn9j0cf26kk4s2nw",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "838120000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "838120000"
}
},
{
"delegation": {
"delegator_address": "cosmos1n8f5fknsv2yt7a8u6nrx30zqy7lu9jfm0t5lq8",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "500000000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "500000000"
}
},
{
"delegation": {
"delegator_address": "cosmos16msryt3fqlxtvsy8u5ay7wv2p8mglfg9hrek2e",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "61310000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "61310000"
}
}
],
"pagination": {
"next_key": null,
"total": "5"
}
}
```
#### Delegation
The `Delegation` REST endpoint queries delegate information for given validator delegator pair.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/validators/{validatorAddr}/delegations/{delegatorAddr}
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q/delegations/cosmos1n8f5fknsv2yt7a8u6nrx30zqy7lu9jfm0t5lq8" \
-H "accept: application/json"
```
Example Output:
```bash expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"delegation_response": {
"delegation": {
"delegator_address": "cosmos1n8f5fknsv2yt7a8u6nrx30zqy7lu9jfm0t5lq8",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "500000000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "500000000"
}
}
}
```
#### UnbondingDelegation
The `UnbondingDelegation` REST endpoint queries unbonding information for given validator delegator pair.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/validators/{validatorAddr}/delegations/{delegatorAddr}/unbonding_delegation
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu/delegations/cosmos1ze2ye5u5k3qdlexvt2e0nn0508p04094ya0qpm/unbonding_delegation" \
-H "accept: application/json"
```
Example Output:
```bash expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"unbond": {
"delegator_address": "cosmos1ze2ye5u5k3qdlexvt2e0nn0508p04094ya0qpm",
"validator_address": "cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu",
"entries": [
{
"creation_height": "153687",
"completion_time": "2021-11-09T09:41:18.352401903Z",
"initial_balance": "525111",
"balance": "525111"
}
]
}
}
```
#### ValidatorUnbondingDelegations
The `ValidatorUnbondingDelegations` REST endpoint queries unbonding delegations of a validator.
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
/cosmos/staking/v1beta1/validators/{validatorAddr}/unbonding_delegations
```
Example:
```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu/unbonding_delegations" \
-H "accept: application/json"
```
Example Output:
```bash expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"unbonding_responses": [
{
"delegator_address": "cosmos1q9snn84jfrd9ge8t46kdcggpe58dua82vnj7uy",
"validator_address": "cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu",
"entries": [
{
"creation_height": "90998",
"completion_time": "2021-11-05T00:14:37.005841058Z",
"initial_balance": "24000000",
"balance": "24000000"
}
]
},
{
"delegator_address": "cosmos1qf36e6wmq9h4twhdvs6pyq9qcaeu7ye0s3dqq2",
"validator_address": "cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu",
"entries": [
{
"creation_height": "47478",
"completion_time": "2021-11-01T22:47:26.714116854Z",
"initial_balance": "8000000",
"balance": "8000000"
}
]
}
],
"pagination": {
"next_key": null,
"total": "2"
}
}
```
# x/upgrade
Source: https://docs.cosmos.network/sdk/latest/modules/upgrade/README
## Abstract
`x/upgrade` is an implementation of a Cosmos SDK module that facilitates smoothly
upgrading a live Cosmos chain to a new (breaking) software version. It accomplishes this by
providing a `PreBlocker` hook that prevents the blockchain state machine from
proceeding once a pre-defined upgrade block height has been reached.
The module does not prescribe anything regarding how governance decides to do an
upgrade, but just the mechanism for coordinating the upgrade safely. Without software
support for upgrades, upgrading a live chain is risky because all of the validators
need to pause their state machines at exactly the same point in the process. If
this is not done correctly, there can be state inconsistencies which are hard to
recover from.
* [Concepts](#concepts)
* [State](#state)
* [Events](#events)
* [Client](#client)
* [CLI](#cli)
* [REST](#rest)
* [gRPC](#grpc)
* [Resources](#resources)
## Concepts
### Plan
The `x/upgrade` module defines a `Plan` type in which a live upgrade is scheduled
to occur. A `Plan` can be scheduled at a specific block height.
A `Plan` is created once a (frozen) release candidate along with an appropriate upgrade
`Handler` (see below) is agreed upon, where the `Name` of a `Plan` corresponds to a
specific `Handler`. Typically, a `Plan` is created through a governance proposal
process, where if voted upon and passed, will be scheduled. The `Info` of a `Plan`
may contain various metadata about the upgrade, typically application specific
upgrade info to be included on-chain such as a git commit that validators could
automatically upgrade to.
```go theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
type Plan struct {
Name string
Height int64
Info string
}
```
#### Sidecar Process
If an operator running the application binary also runs a sidecar process to assist
in the automatic download and upgrade of a binary, the `Info` allows this process to
be seamless. This tool is [Cosmovisor](https://github.com/cosmos/cosmos-sdk/tree/release/v0.55.x/tools/cosmovisor#readme).
### Handler
The `x/upgrade` module facilitates upgrading from major version X to major version Y. To
accomplish this, node operators must first upgrade their current binary to a new
binary that has a corresponding `Handler` for the new version Y. It is assumed that
this version has fully been tested and approved by the community at large. This
`Handler` defines what state migrations need to occur before the new binary Y
can successfully run the chain. Naturally, this `Handler` is application specific
and not defined on a per-module basis. Registering a `Handler` is done via
`Keeper#SetUpgradeHandler` in the application.
```go theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
type UpgradeHandler func(Context, Plan, VersionMap) (VersionMap, error)
```
During each `EndBlock` execution, the `x/upgrade` module checks if there exists a
`Plan` that should execute (is scheduled at that height). If so, the corresponding
`Handler` is executed. If the `Plan` is expected to execute but no `Handler` is registered
or if the binary was upgraded too early, the node will gracefully panic and exit.
### StoreLoader
The `x/upgrade` module also facilitates store migrations as part of the upgrade. The
`StoreLoader` sets the migrations that need to occur before the new binary can
successfully run the chain. This `StoreLoader` is also application specific and
not defined on a per-module basis. Registering this `StoreLoader` is done via
`app#SetStoreLoader` in the application.
```go theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
func UpgradeStoreLoader (upgradeHeight int64, storeUpgrades *store.StoreUpgrades)
baseapp.StoreLoader
```
If there's a planned upgrade and the upgrade height is reached, the old binary writes `Plan` to the disk before panicking.
This information is critical to ensure the `StoreUpgrades` happens smoothly at the correct height and
expected upgrade. It eliminates the chances for the new binary to execute `StoreUpgrades` multiple
times every time on restart. Also, if there are multiple upgrades planned on the same height, the `Name`
will ensure these `StoreUpgrades` take place only in the planned upgrade handler.
### Proposal
Typically, a `Plan` is proposed and submitted through governance via a proposal
containing a `MsgSoftwareUpgrade` message.
This proposal prescribes to the standard governance process. If the proposal passes,
the `Plan`, which targets a specific `Handler`, is persisted and scheduled. The
upgrade can be delayed or hastened by updating the `Plan.Height` in a new proposal.
```protobuf theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
// Reference: https://github.com/cosmos/cosmos-sdk/blob/release/v0.55.x/proto/cosmos/upgrade/v1beta1/tx.proto#L28-L39
```
#### Cancelling Upgrade Proposals
Upgrade proposals can be cancelled. There exists a gov-enabled `MsgCancelUpgrade`
message type, which can be embedded in a proposal, voted on and, if passed, will
remove the scheduled upgrade `Plan`.
Of course this requires that the upgrade was known to be a bad idea well before the
upgrade itself, to allow time for a vote.
```protobuf theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
// Reference: https://github.com/cosmos/cosmos-sdk/blob/release/v0.55.x/proto/cosmos/upgrade/v1beta1/tx.proto#L46-L54
```
If such a possibility is desired, the upgrade height is to be
`2 * (VotingPeriod + DepositPeriod) + (SafetyDelta)` from the beginning of the
upgrade proposal. The `SafetyDelta` is the time available from the success of an
upgrade proposal and the realization it was a bad idea (due to external social consensus).
A `MsgCancelUpgrade` proposal can also be made while the original
`MsgSoftwareUpgrade` proposal is still being voted upon, as long as the `VotingPeriod`
ends after the `MsgSoftwareUpgrade` proposal.
## State
The internal state of the `x/upgrade` module is relatively minimal and simple. The
state contains the currently active upgrade `Plan` (if one exists) by key
`0x0` and if a `Plan` is marked as "done" by key `0x1`. The state
contains the consensus versions of all app modules in the application. The versions
are stored as big endian `uint64`, and can be accessed with prefix `0x2` appended
by the corresponding module name of type `string`. The state maintains a
`Protocol Version` which can be accessed by key `0x3`.
* Plan: `0x0 -> Plan`
* Done: `0x1 | byte(plan name) -> BigEndian(Block Height)`
* ConsensusVersion: `0x2 | byte(module name) -> BigEndian(Module Consensus Version)`
* ProtocolVersion: `0x3 -> BigEndian(Protocol Version)`
The `x/upgrade` module contains no genesis state.
## Events
The `x/upgrade` does not emit any events by itself. Any and all proposal related
events are emitte프로젝트로 돌아가기