摘要
本文指定了 Cosmos SDK 的 Staking
模块,该模块最早在 2016 年 6 月的《 》中描述。
该模块使基于 Cosmos SDK 的区块链能够支持先进的权益证明(PoS)系统。在该系统中,链的原生 staking 代币的持有者可以成为验证人,并将代币委托给验证人,最终决定系统的有效验证人集合。
该模块用于 Cosmos Hub,这是 Cosmos 网络中的第一个 Hub。
目录
状态
Pool
Pool
用于跟踪绑定和未绑定代币的供应量,单位为债券的面额。
LastTotalPower
LastTotalPower
跟踪上一块结束时记录的绑定代币的总量。所有以 "Last" 为前缀的存储条目必须保持不变,直到 EndBlock
。
LastTotalPower: 0x12 -> ProtocolBuffer(math.Int)
ValidatorUpdates
ValidatorUpdates
包含每个区块结束时返回给 ABCI 的验证人更新。这些值在每个区块中被覆盖。
ValidatorUpdates 0x61 -> []abci.ValidatorUpdate
UnbondingID
UnbondingID
存储最新解除绑定操作的 ID。它用于为解除绑定操作创建唯一的 ID,即每次启动新的解除绑定操作(验证人解除绑定、委托解除绑定、重新委托)时,UnbondingID
会递增。
UnbondingID: 0x37 -> uint64
参数
Staking
模块将其参数存储在状态中,前缀为 0x51,参数可以通过治理或具有权限的地址进行更新。
Params: 0x51 | ProtocolBuffer(Params)
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L310-L333
验证者
验证人可以有三种状态之一:
Unbonded : 验证人不在活动集合中。它们不能签署区块,也不会获得奖励。它们可以接收委托。
Unbonding : 当验证人离开活动集合时,无论是主动选择还是由于被惩罚、监禁或墓碑化,其所有委托将开始解除绑定。所有委托必须等待 UnbondingTime
,然后其代币才会从 BondedPool
转移到其账户中。
:::warning 墓碑化是永久性的,一旦墓碑化,验证人的共识密钥不能在发生墓碑化的链内重新使用。 :::
验证人对象应主要通过 OperatorAddr
存储和访问,OperatorAddr
是验证人运营者的 SDK 地址。每个验证人对象会维护两个附加索引,以满足惩罚和验证人集合更新所需的查找操作。一个第三个特殊索引(LastValidatorPower
)也会维护,但它在每个区块中保持不变,区别于前两个索引,这两个索引在每个区块中反映验证人记录。
Validators : 0x21 | OperatorAddrLen
(1 字节) | OperatorAddr
-> ProtocolBuffer(validator)
ValidatorsByConsAddr : 0x22 | ConsAddrLen
(1 字节) | ConsAddr
-> OperatorAddr
ValidatorsByPower : 0x23 | BigEndian(ConsensusPower)
| OperatorAddrLen
(1 字节) | OperatorAddr
-> OperatorAddr
LastValidatorsPower : 0x11 | OperatorAddrLen
(1 字节) | OperatorAddr
-> ProtocolBuffer(ConsensusPower)
ValidatorsByUnbondingID : 0x38 | UnbondingID
-> 0x21 | OperatorAddrLen
(1 字节) | OperatorAddr
Validators
是主索引 - 它确保每个运营者只能有一个关联的验证人,其中该验证人的公钥可以在未来发生变化。委托者可以引用该验证人不可变的运营者,而不必担心公钥的变化。
ValidatorsByUnbondingID
是附加索引,它通过与当前解除绑定相关的解除绑定 ID 来启用验证人的查找。
ValidatorByConsAddr
是附加索引,它通过惩罚启用查找。当 CometBFT 报告证据时,它提供验证人地址,因此需要这个映射来查找运营者。请注意,ConsAddr
对应于可以从验证人的 ConsPubKey
派生出的地址。
ValidatorsByPower
是附加索引,它提供潜在验证人的排序列表,以快速确定当前的活动集合。这里,ConsensusPower
默认值为 validator.Tokens / 10^6
。请注意,所有 Jailed
为 true
的验证人不会存储在此索引中。
每个验证人的状态存储在一个 Validator
结构体中:
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L82-L138
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L26-L80
代理
委托通过将 DelegatorAddr
(委托者地址)与 ValidatorAddr
结合来标识。委托者在存储中的索引如下:
Delegation : 0x31 | DelegatorAddrLen
(1 字节) | DelegatorAddr
| ValidatorAddrLen
(1 字节) | ValidatorAddr
-> ProtocolBuffer(delegation)
持币者可以将代币委托给验证人;在这种情况下,他们的资金会保存在一个 Delegation
数据结构中。该数据结构由一个委托者拥有,并与一个验证人的股份相关联。交易的发送者是该债券的拥有者。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L198-L216
委托人股份
当一个委托者将代币委托给验证人时,根据动态汇率发放一定数量的委托人股份,汇率的计算方式如下,基于委托给验证人的代币总量和已发放的股份数量:
每个代币的股份 = validator.TotalShares()
/ validator.Tokens()
仅接收的股份数量会存储在 DelegationEntry
中。当委托者进行解除委托时,他们收到的代币数量是基于他们当前持有的股份数量和反向汇率计算的:
每个股份的代币数量 = validator.Tokens()
/ validatorShares()
这些股份仅仅是一个记账机制,并不是一种可替代资产。使用这种机制的原因是简化惩罚相关的记账工作。与其逐个惩罚每个委托项的代币,不如直接惩罚验证人的总绑定代币,从而有效减少每个已发放的委托人股份的价值。
解绑代理
委托中的股份可以解除绑定,但它们必须在一段时间内存在于 UnbondingDelegation
中,如果检测到拜占庭行为,股份可能会被减少。
UnbondingDelegation
在存储中的索引如下:
UnbondingDelegation : 0x32 | DelegatorAddrLen
(1 字节) | DelegatorAddr
| ValidatorAddrLen
(1 字节) | ValidatorAddr
-> ProtocolBuffer(unbondingDelegation)
UnbondingDelegationsFromValidator : 0x33 | ValidatorAddrLen
(1 字节) | ValidatorAddr
| DelegatorAddrLen
(1 字节) | DelegatorAddr
-> nil
UnbondingDelegationByUnbondingId : 0x38 | UnbondingId
-> 0x32 | DelegatorAddrLen
(1 字节) | DelegatorAddr
| ValidatorAddrLen
(1 字节) | ValidatorAddr
UnbondingDelegation
用于查询,查找给定委托者的所有解除委托项。
UnbondingDelegationsFromValidator
用于惩罚,查找与给定验证人关联的所有解除委托项,且这些解除委托项需要被惩罚。
UnbondingDelegationByUnbondingId
是一个附加索引,它通过包含解除委托项的解除绑定 ID 启用解除委托项的查找。
每次启动解除绑定时,都会创建一个 UnbondingDelegation
对象。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L218-L261
重新委托
委托的绑定代币可以立即从源验证人重新委托到另一个验证人(目标验证人)。然而,当这种情况发生时,它们必须在一个 Redelegation
对象中进行跟踪,如果它们的代币贡献了源验证人犯下的拜占庭错误,则其股份可能会被惩罚。
Redelegation
在存储中的索引如下:
Redelegations : 0x34 | DelegatorAddrLen
(1 字节) | DelegatorAddr
| ValidatorAddrLen
(1 字节) | ValidatorSrcAddr
| ValidatorDstAddr
-> ProtocolBuffer(redelegation)
RedelegationsBySrc : 0x35 | ValidatorSrcAddrLen
(1 字节) | ValidatorSrcAddr
| ValidatorDstAddrLen
(1 字节) | ValidatorDstAddr
| DelegatorAddrLen
(1 字节) | DelegatorAddr
-> nil
RedelegationsByDst : 0x36 | ValidatorDstAddrLen
(1 字节) | ValidatorDstAddr
| ValidatorSrcAddrLen
(1 字节) | ValidatorSrcAddr
| DelegatorAddrLen
(1 字节) | DelegatorAddr
-> nil
RedelegationByUnbondingId : 0x38 | UnbondingId
-> 0x34 | DelegatorAddrLen
(1 字节) | DelegatorAddr
| ValidatorAddrLen
(1 字节) | ValidatorSrcAddr
| ValidatorDstAddr
Redelegations 用于查询,查找给定委托者的所有重新委托项。
RedelegationsBySrc 用于基于 ValidatorSrcAddr
进行惩罚。
RedelegationsByDst 用于基于 ValidatorDstAddr
进行惩罚。
这里的第一个映射用于查询,查找给定委托者的所有重新委托项。第二个映射用于基于 ValidatorSrcAddr
进行惩罚,而第三个映射则用于基于 ValidatorDstAddr
进行惩罚。
RedelegationByUnbondingId 是一个附加索引,它通过包含重新委托项的解除绑定 ID 启用重新委托项的查找。
每次发生重新委托时,都会创建一个 Redelegation
对象。为了防止 "重新委托跳跃",当发生以下情况时,不能进行重新委托:
委托者已经有一个未完成的重新委托,目标是某个验证人(我们称之为验证人 X)。
委托者试图创建一个新的重新委托,其中该新重新委托的源验证人是验证人 X。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L263-L308
Queues
所有队列对象都按时间戳排序。队列中使用的时间首先被转换为 UTC,四舍五入到最接近的纳秒,然后进行排序。使用的可排序时间格式是 RFC3339Nano 的轻微修改版,格式化字符串为 "2006-01-02T15:04:05.000000000"。值得注意的是,这种格式:
在所有情况下,存储的时间戳表示队列元素的成熟时间。
UnbondingDelegationQueue
为了跟踪解除委托的进度,维护了一个解除委托队列。
UnbondingDelegation
: 0x41 | 格式化时间 -> []DVPair
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L162-L172
RedelegationQueue
为了跟踪重新委托的进度,维护了一个重新委托队列。
RedelegationQueue
: 0x42 | 格式化时间 -> []DVVTriplet
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L179-L191
ValidatorQueue
为了跟踪解除绑定验证人的进度,维护了一个验证人队列。
ValidatorQueueTime
: 0x43 | 格式化时间 -> []sdk.ValAddress
每个键存储的对象是一个验证人操作员地址数组,通过这些地址可以访问验证人对象。通常,预计每个时间戳只会与一个验证人记录关联,但也有可能在同一位置存在多个验证人在队列中。
HistoricalInfo
HistoricalInfo
对象在每个区块时存储并修剪,以便 staking keeper 保留由 staking 模块参数 HistoricalEntries
定义的最近 n 个历史信息。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L17-L24
在每个 BeginBlock
时,staking keeper 会将当前的 Header 和提交当前区块的验证人保存在一个 HistoricalInfo
对象中。验证人会按地址排序,以确保它们处于确定性的顺序。最旧的 HistoricalEntries
会被修剪,以确保只保留由参数定义的历史条目数量。
状态转移
验证者
验证人可以是 Unbonded、Unbonding 或 Bonded。Unbonded 和 Unbonding 被统称为 Not Bonded。验证人可以在所有状态之间直接转换,但不能从 Bonded 转换到 Unbonded。
Not Bonded 到 Bonded
当验证人在 ValidatorPowerIndex
中的排名超过 LastValidator
时,发生以下转换:
将验证人的 Tokens
从 NotBondedTokens
转移到 BondedPool ModuleAccount
删除 ValidatorByPowerIndex
中的现有记录
将更新后的记录添加到 ValidatorByPowerIndex
如果存在,删除该验证人的任何 ValidatorQueue
记录
Bonded 到 Unbonding
当验证人开始解除绑定过程时,发生以下操作:
将验证人的 Tokens
从 BondedPool
转移到 NotBondedTokens ModuleAccount
删除 ValidatorByPowerIndex
中的现有记录
将更新后的记录添加到 ValidatorByPowerIndex
为该验证人插入一个新的 ValidatorQueue
记录
Unbonding 到 Unbonded
当验证人的 ValidatorQueue
对象从 Bonded 转换到 Unbonded 时,验证人从 Unbonding 状态移动到 Unbonded 状态:
Jail/Unjail
当验证人被监禁时,它实际上被从 CometBFT 集合中移除,这个过程也可以被反转。发生以下操作:
设置 Validator.Jailed
并更新对象
如果被监禁,删除 ValidatorByPowerIndex
中的记录
如果被释放,向 ValidatorByPowerIndex
添加记录
被监禁的验证人不会出现在以下任何存储中:
委托
委托
当发生委托时,验证人和委托对象都会受到影响:
根据委托的代币数和验证人的交换率来确定委托人的份额
将委托的 Amount
从委托人的账户转移到 BondedPool
或 NotBondedPool ModuleAccount
,具体取决于验证人的 Status
是否为 Bonded
删除 ValidatorByPowerIndex
中的现有记录
添加更新后的记录到 ValidatorByPowerIndex
开始解绑
作为 Undelegate 和 Complete Unbonding 状态转换的一部分,可能会调用 Unbond Delegation
:
将解锁的代币添加到一个 UnbondingDelegationEntry
中
如果该委托是验证人的操作员且没有剩余份额,则触发监禁验证人
如果验证人的状态是 Bonded,则将解锁的份额所对应的代币从 BondedPool
转移到 NotBondedPool ModuleAccount
如果验证人处于 Unbonded 状态且没有剩余的委托份额,则删除该验证人
获取唯一的 unbondingId
并将其映射到 UnbondingDelegationEntry
在 UnbondingDelegationByUnbondingId
中
调用 AfterUnbondingInitiated(unbondingId)
钩子
将解锁的委托添加到 UnbondingDelegationQueue
中,完成时间设定为 UnbondingTime
取消 UnbondingDelegation
当取消一个解锁委托时,验证人、委托和 UnbondingDelegationQueue
状态将被更新:
如果取消解锁委托的数量等于 UnbondingDelegation
条目的余额,则从 UnbondingDelegationQueue
中删除该条目
如果取消解锁委托的数量少于 UnbondingDelegation
条目的余额,则 UnbondingDelegation
条目会在 UnbondingDelegationQueue
中更新新余额
完成解绑
对于未立即完成的解除委托,当解锁委托队列元素成熟时,执行以下操作:
从 UnbondingDelegation
对象中移除该条目
将代币从 NotBondedPool ModuleAccount
转移到委托人的账户
开始重新委托
重新委托会影响委托、源验证人和目标验证人:
从源验证人处执行解除委托以获取解锁份额所对应的代币
如果源验证人的状态为 Bonded,且目标验证人不是 Bonded,则将新委托的代币从 BondedPool
转移到 NotBondedPool ModuleAccount
否则,如果源验证人的状态不是 Bonded,且目标验证人是 Bonded,则将新委托的代币从 NotBondedPool
转移到 BondedPool ModuleAccount
记录代币数量并在相关的 Redelegation
中创建一个新条目
从重新委托开始到完成之前,委托人处于 "伪解锁" 状态,并且在重新委托开始之前发生的违规行为仍然可以被罚款
完成重新委托
当重新委托完成时,执行以下操作:
惩罚
验证者惩罚
当验证人被惩罚(Slashed)时,执行以下操作:
计算 total slashAmount
,公式为:slashFactor
(链上参数) * TokensFromConsensusPower
,其中 TokensFromConsensusPower
是违规发生时验证人所绑定的总代币数。
所有在违规发生后才开始解锁或重新委托的 UnbondingDelegation
和 pseudo-unbonding Redelegation
,都会按 slashFactor
乘以 initialBalance
进行惩罚。
从重新委托和解锁委托中被惩罚的总金额会从 total slash amount
中扣除。
剩余的 remaingSlashAmount
会根据验证人的 status
,从 BondedPool
或 NonBondedPool
进行惩罚。这将减少代币的总供应量。
若因需要提交证据的违规行为(例如双重签名)导致惩罚,则惩罚发生在包含证据的区块,而不是违规发生的区块。换句话说,验证人不会被追溯惩罚,只有在违规被发现时才会被惩罚。
解绑委托惩罚
当验证人被惩罚时,所有在违规发生后才开始解锁的 UnbondingDelegation
也会被惩罚:验证人的每个 UnbondingDelegation
条目都会按照 slashFactor
进行惩罚。惩罚金额基于委托的 InitialBalance
计算,并设有上限,以防止出现负余额。已完成(或成熟)的解锁委托不会被惩罚。
重新委托惩罚
当验证人被惩罚时,所有在违规发生后才开始的 Redelegation
也会被惩罚:重新委托按照 slashFactor
进行惩罚。在违规发生之前开始的重新委托不会被惩罚。惩罚金额基于委托的 InitialBalance
计算,并设有上限,以防止出现负余额。已完成的重新委托(即已完成 pseudo-unbonding
的)不会被惩罚。
股份计算方式
在任意时刻,每个验证人拥有一定数量的代币 T
,并发行了一定数量的份额 S
。每个委托人 i
持有 S_i
份额。代币数量 T
由所有委托给验证人的代币总和加上奖励,再减去削减值计算得出。
委托人有权获得与其持有份额比例相对应的底层代币。因此,委托人 i
可获得验证人代币总量中的 T * S_i / S
。
当委托人向验证人委托新的代币时,他们会按照其贡献比例获得相应的份额。例如,当委托人 j
委托 T_j
代币时,他们将获得 S_j = S * T_j / T
份额。此时,总代币数量变为 T + T_j
,总份额变为 S + S_j
。j
的份额比例与其贡献的总代币比例相同,即:(S + S_j) / S = (T + T_j) / T
一个特殊情况是初始委托,即 T = 0
且 S = 0
,此时 T_j / T
未定义。在初始委托情况下,委托人 j
直接获得 S_j = T_j
份额。因此,在没有获得任何奖励且未被削减的情况下,验证人的 T
与 S
相等。
消息
MsgCreateValidator
验证人通过 MsgCreateValidator
消息创建。验证人必须由其操作员进行初始委托后才能创建。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L20-L21
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L50-L73
如果出现以下情况,此消息将执行失败:
初始自委托代币的 denom
并未指定为绑定 denom
佣金参数不合法,包括:
初始 MaxChangeRate
为负数或大于 MaxRate
此消息将在适当的索引位置创建并存储 Validator
对象。此外,使用初始委托代币执行一次自委托 Delegation
。验证人初始状态始终为未绑定 (Unbonded
),但可能在第一个 end-block
时变为绑定 (Bonded
)。
MsgEditValidator
验证人的 Description
和 CommissionRate
可通过 MsgEditValidator
消息进行更新。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L23-L24
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L78-L97
如果出现以下情况,此消息将执行失败:
初始 CommissionRate
为负数或大于 MaxRate
CommissionRate
在过去 24 小时内已被更新
CommissionRate
大于 MaxChangeRate
此消息将存储更新后的 Validator
对象。
MsgDelegate
在此消息中,委托人提供代币,并获得验证人新创建的部分 delegator-shares
,这些份额被分配至 Delegation.Shares
。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L26-L28
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L102-L114
如果出现以下情况,此消息将执行失败:
Amount
代币的 denom
与 params.BondDenom
定义的不同
汇率无效,即验证人没有代币(由于削减)但仍存在未清算的份额
如果为提供的地址尚未存在现有的 Delegation
对象,则该对象将作为此消息的一部分创建;否则,现有的 Delegation
将更新以包括新接收的份额。
委托人按当前汇率接收新铸造的份额。汇率为验证人现有份额的数量除以当前委托的代币数量。
验证人将在 ValidatorByPower
索引中更新,委托将在 Validators
索引中的验证人对象中跟踪。
可以向一个被禁锢的验证人委托,唯一的区别是,直到验证人解除禁锢前,它不会被加入到 power
索引中。
MsgUndelegate
MsgUndelegate
消息允许委托人从验证人处取消委托其代币。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L34-L36
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L140-L152
此消息返回一个响应,包含取消委托的完成时间:
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L154-L158
如果出现以下情况,此消息将执行失败:
已存在的 UnbondingDelegation
达到 params.MaxEntries
定义的最大条目数
Amount
代币的 denom
与 params.BondDenom
定义的不同
当此消息被处理时,将发生以下操作:
验证人的 DelegatorShares
和委托的 Shares
都会减少 SharesAmount
计算份额对应的代币价值,移除该数量的代币从验证人持有的代币中
如果验证人处于以下状态:
Bonded :将移除的代币添加到 UnbondingDelegation
的条目中(如果不存在则创建 UnbondingDelegation
),并设置完成时间为当前时间加上完整的解除绑定周期。更新池份额,减少 BondedTokens
,并增加 NotBondedTokens
,数量为份额的代币价值。
Unbonding :将移除的代币添加到 UnbondingDelegation
的条目中(如果不存在则创建 UnbondingDelegation
),并设置完成时间为与验证人相同的解除绑定时间(UnbondingMinTime
)。
Unbonded :将代币发送到消息中的 DelegatorAddr
。
如果委托中不再有份额,则从存储中移除该委托对象。
在这种情况下,如果该委托是验证人的自委托,则验证人也会被禁锢。
MsgCancelUnbondingDelegation
MsgCancelUnbondingDelegation
消息允许委托人取消解除绑定委托条目,并将代币重新委托回先前的验证人。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L38-L42
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L160-L175
如果出现以下情况,此消息将执行失败:
unbondingDelegation
条目已被处理
取消解除绑定委托的金额大于 unbondingDelegation
条目余额
取消解除绑定委托的区块高度在委托人的 unbondingDelegationQueue
中不存在
当此消息被处理时,将发生以下操作:
如果 unbondingDelegation
条目余额为零:
在这种情况下,unbondingDelegation
条目将从 unbondingDelegationQueue
中移除。
否则,unbondingDelegationQueue
将更新为新的 unbondingDelegation
条目余额和初始余额。
验证人的 DelegatorShares
和委托的 Shares
都将增加消息中的 Amount
。
MsgBeginRedelegate
redelegation
命令允许委托人立即切换验证人。一旦解除绑定期过去,redelegation
将在 EndBlocker
中自动完成。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L30-L32
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L119-L132
此消息返回一个响应,包含重委托的完成时间:
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L133-L138
如果出现以下情况,此消息将执行失败:
源验证人有一个尚未成熟的接收重委托(即重委托可能是转接的)
已存在的 Redelegation
达到 params.MaxEntries
定义的最大条目数
Amount
代币的 denom
与 params.BondDenom
定义的不同
当此消息被处理时,将发生以下操作:
源验证人的 DelegatorShares
和委托的 Shares
都将减少 SharesAmount
计算份额对应的代币价值,移除该数量的代币从源验证人持有的代币中
如果源验证人处于以下状态:
Bonded :将一个条目添加到 Redelegation
中(如果不存在则创建 Redelegation
),并设置完成时间为当前时间加上完整的解除绑定周期。更新池份额,减少 BondedTokens
,并增加 NotBondedTokens
,数量为份额的代币价值(尽管下一步可能会有效地逆转此操作)。
Unbonding :将一个条目添加到 Redelegation
中(如果不存在则创建 Redelegation
),并设置完成时间为与验证人相同的解除绑定时间(UnbondingMinTime
)。
将代币价值委托给目标验证人,可能将代币移回绑定状态。
如果源委托中不再有份额,则从存储中移除该源委托对象。
在这种情况下,如果该委托是验证人的自委托,则验证人也会被禁锢。
MsgUpdateParams
MsgUpdateParams
更新抵押模块的参数。这些参数通过治理提案进行更新,提案的签名者是 gov
模块的账户地址。
Copy https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/staking/v1beta1/tx.proto#L182-L195
如果出现以下情况,消息处理将失败:
签名者不是在抵押管理器中定义的权限(通常是 gov
模块账户)。
Begin-Block
每次 abci begin block
调用时,历史信息将根据 HistoricalEntries
参数进行存储和修剪。
历史信息跟踪
如果 HistoricalEntries
参数为 0,则 BeginBlock
执行时不进行任何操作(no-op)。
否则,最新的历史信息将存储在键 historicalInfoKey|height
下,同时任何早于 height - HistoricalEntries
的条目将被删除。在大多数情况下,这将导致每个区块修剪一个条目。然而,如果 HistoricalEntries
参数被更改为较小的值,则存储中会有多个条目需要被修剪。
End-Block
每次 abci end block
调用时,指定执行更新队列和验证人集变化的操作。
验证人集变化
在此过程中,抵押验证人集在每个区块结束时通过状态转变进行更新。作为此过程的一部分,任何更新过的验证人也会返回给 CometBFT,以便将其纳入 CometBFT 验证人集中,后者负责在共识层验证 CometBFT 消息。操作如下:
新的验证人集通过从 ValidatorsByPower
索引中获取前 params.MaxValidators
数量的验证人来确定。
比较之前的验证人集和新的验证人集:
缺少的验证人开始解除绑定,其代币从 BondedPool
转移到 NotBondedPool
模块账户。
新的验证人立即绑定,其代币从 NotBondedPool
转移到 BondedPool
模块账户。
在所有情况下,任何离开或进入绑定验证人集的验证人,或者余额发生变化但仍保持在绑定验证人集中的验证人,都会收到更新消息,报告他们的新共识权重,并将其传回 CometBFT。
LastTotalPower
和 LastValidatorsPower
保存上一个区块结束时的总权重和验证人权重状态,用于检查在 ValidatorsByPower
中发生的变化以及总新权重,这些变化会在 EndBlock
中进行计算。
队列(Queues)
在抵押过程中,某些状态转变不是即时发生的,而是随着时间的推移(通常是解除绑定期)逐步完成。当这些转变成熟时,必须执行某些操作以完成状态操作。这是通过使用队列来实现的,这些队列会在每个区块结束时进行检查和处理。
解除绑定的验证人
当一个验证人被踢出绑定验证人集(无论是被禁锢还是没有足够的绑定代币)时,它开始解除绑定过程,同时所有与其委托的委托人也开始解除绑定(尽管仍然委托给该验证人)。此时,该验证人被称为“解除绑定的验证人”,在解除绑定期结束后,它将成熟为“非绑定验证人”。
每个区块,验证人队列都会被检查,以查看是否有成熟的解除绑定验证人(即完成时间 <=
当前时间且完成高度 <=
当前区块高度)。此时,任何没有剩余委托的成熟验证人将从状态中删除。对于所有其他仍有剩余委托的成熟解除绑定验证人,validator.Status
将从 types.Unbonding
切换到 types.Unbonded
。
解除绑定操作可以通过外部模块通过 PutUnbondingOnHold(unbondingId)
方法被暂停。因此,处于暂停状态的解除绑定操作(例如解除绑定委托)即使达到成熟状态也无法完成。为了确保一个解除绑定操作在成熟后能够最终完成,每次调用 PutUnbondingOnHold(unbondingId)
都必须对应一个调用 UnbondingCanComplete(unbondingId)
。
解除绑定委托
通过以下过程完成所有成熟的 UnbondingDelegations.Entries
的解除绑定:
从 UnbondingDelegation.Entries
中移除成熟的条目
如果没有剩余条目,则从存储中移除 UnbondingDelegation
对象
重委托
完成 Redelegation
队列中所有成熟的 Redelegation.Entries
的解除绑定,具体过程如下:
从 Redelegation.Entries
中移除成熟的条目
如果没有剩余条目,则从存储中移除 Redelegation
对象
钩子(Hooks)
其他模块可以注册操作,以在抵押过程中发生特定事件时执行。这些事件可以注册为在抵押事件之前或之后执行(根据钩子的名称)。以下钩子可以与抵押模块一起注册:
AfterValidatorCreated(Context, ValAddress) error
BeforeValidatorModified(Context, ValAddress) error
AfterValidatorRemoved(Context, ConsAddress, ValAddress) error
AfterValidatorBonded(Context, ConsAddress, ValAddress) error
AfterValidatorBeginUnbonding(Context, ConsAddress, ValAddress) error
BeforeDelegationCreated(Context, AccAddress, ValAddress) error
BeforeDelegationSharesModified(Context, AccAddress, ValAddress) error
AfterDelegationModified(Context, AccAddress, ValAddress) error
BeforeDelegationRemoved(Context, AccAddress, ValAddress) error
AfterUnbondingInitiated(Context, UnbondingID)
在启动解除绑定操作(验证人解除绑定、解除绑定委托、重委托)时调用
事件
质押模块会发出以下事件:
EndBlocker
{totalRedelegationAmount}
Msg's
MsgCreateValidator
MsgEditValidator
MsgDelegate
MsgUndelegate
MsgCancelUnbondingDelegation
cancel_unbonding_delegation
cancel_unbonding_delegation
cancel_unbonding_delegation
{cancelUnbondingDelegationAmount}
cancel_unbonding_delegation
{unbondingCreationHeight}
MsgBeginRedelegate
参数
质押模块包含以下参数:
客户端
CLI
用户可以使用 CLI 查询和与质押模块进行交互。
Query
查询命令允许用户查询质押状态。
Copy simd query staking --help
delegation
委托命令允许用户查询单个委托人在单个验证人上的委托情况。
使用:
Copy simd query staking delegation [delegator-addr] [validator-addr] [flags]
示例:
Copy simd query staking delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
示例输出:
Copy balance:
amount: "10000000000"
denom: stake
delegation:
delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
shares: "10000000000.000000000000000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
delegations
委托情况命令允许用户查询单个委托人在所有验证人上的委托情况。
使用:
Copy simd query staking delegations [delegator-addr] [flags]
示例:
Copy simd query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
示例输出:
Copy delegation_responses:
- balance:
amount: "10000000000"
denom: stake
delegation:
delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
shares: "10000000000.000000000000000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
- balance:
amount: "10000000000"
denom: stake
delegation:
delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
shares: "10000000000.000000000000000000"
validator_address: cosmosvaloper1x20lytyf6zkcrv5edpkfkn8sz578qg5sqfyqnp
pagination:
next_key: null
total: "0"
delegations-to
delegations-to
命令允许用户查询单个验证人上的委托情况。
使用:
Copy simd query staking delegations-to [validator-addr] [flags]
示例:
Copy simd query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
示例输出:
Copy - balance:
amount: "504000000"
denom: stake
delegation:
delegator_address: cosmos1q2qwwynhv8kh3lu5fkeex4awau9x8fwt45f5cp
shares: "504000000.000000000000000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
- balance:
amount: "78125000000"
denom: uixo
delegation:
delegator_address: cosmos1qvppl3479hw4clahe0kwdlfvf8uvjtcd99m2ca
shares: "78125000000.000000000000000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
pagination:
next_key: null
total: "0"
historical-info
historical-info
命令允许用户查询在给定高度的历史信息。
使用:
Copy simd query staking historical-info [height] [flags]
示例:
Copy simd query staking historical-info 10
示例输出:
Copy header:
app_hash: Lbx8cXpI868wz8sgp4qPYVrlaKjevR5WP/IjUxwp3oo=
chain_id: testnet
consensus_hash: BICRvH3cKD93v7+R1zxE2ljD34qcvIZ0Bdi389qtoi8=
data_hash: 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
evidence_hash: 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
height: "10"
last_block_id:
hash: RFbkpu6pWfSThXxKKl6EZVDnBSm16+U0l0xVjTX08Fk=
part_set_header:
hash: vpIvXD4rxD5GM4MXGz0Sad9I7//iVYLzZsEU4BVgWIU=
total: 1
last_commit_hash: Ne4uXyx4QtNp4Zx89kf9UK7oG9QVbdB6e7ZwZkhy8K0=
last_results_hash: 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
next_validators_hash: nGBgKeWBjoxeKFti00CxHsnULORgKY4LiuQwBuUrhCs=
proposer_address: mMEP2c2IRPLr99LedSRtBg9eONM=
time: "2021-10-01T06:00:49.785790894Z"
validators_hash: nGBgKeWBjoxeKFti00CxHsnULORgKY4LiuQwBuUrhCs=
version:
app: "0"
block: "11"
valset:
- commission:
commission_rates:
max_change_rate: "0.010000000000000000"
max_rate: "0.200000000000000000"
rate: "0.100000000000000000"
update_time: "2021-10-01T05:52:50.380144238Z"
consensus_pubkey:
'@type': /cosmos.crypto.ed25519.PubKey
key: Auxs3865HpB/EfssYOzfqNhEJjzys2Fo6jD5B8tPgC8=
delegator_shares: "10000000.000000000000000000"
description:
details: ""
identity: ""
moniker: myvalidator
security_contact: ""
website: ""
jailed: false
min_self_delegation: "1"
operator_address: cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc
status: BOND_STATUS_BONDED
tokens: "10000000"
unbonding_height: "0"
unbonding_time: "1970-01-01T00:00:00Z"
params
参数命令允许用户查询设置为质押参数的值。
使用:
Copy simd query staking params [flags]
示例:
Copy simd query staking params
示例输出:
Copy bond_denom: stake
historical_entries: 10000
max_entries: 7
max_validators: 50
unbonding_time: 1814400s
pool
pool
命令允许用户查询存储在质押池中的金额值。
使用:
Copy simd q staking pool [flags]
示例:
示例输出:
Copy bonded_tokens: "10000000"
not_bonded_tokens: "0"
redelegation
redelegation
命令允许用户根据委托人以及源验证人和目标验证人的地址查询重委托记录。
使用:
Copy simd query staking redelegation [delegator-addr] [src-validator-addr] [dst-validator-addr] [flags]
示例:
Copy simd query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosmosvaloper1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
示例输出:
Copy pagination: null
redelegation_responses:
- entries:
- balance: "50000000"
redelegation_entry:
completion_time: "2021-10-24T20:33:21.960084845Z"
creation_height: 2.382847e+06
initial_balance: "50000000"
shares_dst: "50000000.000000000000000000"
- balance: "5000000000"
redelegation_entry:
completion_time: "2021-10-25T21:33:54.446846862Z"
creation_height: 2.397271e+06
initial_balance: "5000000000"
shares_dst: "5000000000.000000000000000000"
redelegation:
delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
entries: null
validator_dst_address: cosmosvaloper1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm
validator_src_address: cosmosvaloper1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm
redelegations
redelegations
命令允许用户查询单个委托人的所有重委托记录。
使用:
Copy simd query staking redelegations [delegator-addr] [flags]
示例:
Copy simd query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
示例输出:
Copy pagination:
next_key: null
total: "0"
redelegation_responses:
- entries:
- balance: "50000000"
redelegation_entry:
completion_time: "2021-10-24T20:33:21.960084845Z"
creation_height: 2.382847e+06
initial_balance: "50000000"
shares_dst: "50000000.000000000000000000"
- balance: "5000000000"
redelegation_entry:
completion_time: "2021-10-25T21:33:54.446846862Z"
creation_height: 2.397271e+06
initial_balance: "5000000000"
shares_dst: "5000000000.000000000000000000"
redelegation:
delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
entries: null
validator_dst_address: cosmosvaloper1uccl5ugxrm7vqlzwqr04pjd320d2fz0z3hc6vm
validator_src_address: cosmosvaloper1zppjyal5emta5cquje8ndkpz0rs046m7zqxrpp
- entries:
- balance: "562770000000"
redelegation_entry:
completion_time: "2021-10-25T21:42:07.336911677Z"
creation_height: 2.39735e+06
initial_balance: "562770000000"
shares_dst: "562770000000.000000000000000000"
redelegation:
delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
entries: null
validator_dst_address: cosmosvaloper1uccl5ugxrm7vqlzwqr04pjd320d2fz0z3hc6vm
validator_src_address: cosmosvaloper1zppjyal5emta5cquje8ndkpz0rs046m7zqxrpp
redelegations-from
redelegations-from
命令允许用户查询从一个验证人进行重委托的委托情况。
使用:
Copy simd query staking redelegations-from [validator-addr] [flags]
示例:
Copy simd query staking redelegations-from cosmosvaloper1y4rzzrgl66eyhzt6gse2k7ej3zgwmngeleucjy
示例输出:
Copy pagination:
next_key: null
total: "0"
redelegation_responses:
- entries:
- balance: "50000000"
redelegation_entry:
completion_time: "2021-10-24T20:33:21.960084845Z"
creation_height: 2.382847e+06
initial_balance: "50000000"
shares_dst: "50000000.000000000000000000"
- balance: "5000000000"
redelegation_entry:
completion_time: "2021-10-25T21:33:54.446846862Z"
creation_height: 2.397271e+06
initial_balance: "5000000000"
shares_dst: "5000000000.000000000000000000"
redelegation:
delegator_address: cosmos1pm6e78p4pgn0da365plzl4t56pxy8hwtqp2mph
entries: null
validator_dst_address: cosmosvaloper1uccl5ugxrm7vqlzwqr04pjd320d2fz0z3hc6vm
validator_src_address: cosmosvaloper1y4rzzrgl66eyhzt6gse2k7ej3zgwmngeleucjy
- entries:
- balance: "221000000"
redelegation_entry:
completion_time: "2021-10-05T21:05:45.669420544Z"
creation_height: 2.120693e+06
initial_balance: "221000000"
shares_dst: "221000000.000000000000000000"
redelegation:
delegator_address: cosmos1zqv8qxy2zgn4c58fz8jt8jmhs3d0attcussrf6
entries: null
validator_dst_address: cosmosvaloper10mseqwnwtjaqfrwwp2nyrruwmjp6u5jhah4c3y
validator_src_address: cosmosvaloper1y4rzzrgl66eyhzt6gse2k7ej3zgwmngeleucjy
unbonding-delegation
unbonding-delegation
命令允许用户查询单个委托人在单个验证人上的解除绑定委托情况。
使用:
Copy simd query staking unbonding-delegation [delegator-addr] [validator-addr] [flags]
示例:
Copy simd query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
示例输出:
Copy delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
entries:
- balance: "52000000"
completion_time: "2021-11-02T11:35:55.391594709Z"
creation_height: "55078"
initial_balance: "52000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
unbonding-delegations
unbonding-delegations
命令允许用户查询单个委托人的所有解除绑定委托记录。
使用:
Copy simd query staking unbonding-delegations [delegator-addr] [flags]
示例:
Copy simd query staking unbonding-delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
示例输出:
Copy pagination:
next_key: null
total: "0"
unbonding_responses:
- delegator_address: cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
entries:
- balance: "52000000"
completion_time: "2021-11-02T11:35:55.391594709Z"
creation_height: "55078"
initial_balance: "52000000"
validator_address: cosmosvaloper1t8ehvswxjfn3ejzkjtntcyrqwvmvuknzmvtaaa
unbonding-delegations-from
unbonding-delegations-from
命令允许用户查询从一个验证人解除绑定的委托情况。
使用:
Copy simd query staking unbonding-delegations-from [validator-addr] [flags]
示例:
Copy simd query staking unbonding-delegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
示例输出:
Copy pagination:
next_key: null
total: "0"
unbonding_responses:
- delegator_address: cosmos1qqq9txnw4c77sdvzx0tkedsafl5s3vk7hn53fn
entries:
- balance: "150000000"
completion_time: "2021-11-01T21:41:13.098141574Z"
creation_height: "46823"
initial_balance: "150000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
- delegator_address: cosmos1peteje73eklqau66mr7h7rmewmt2vt99y24f5z
entries:
- balance: "24000000"
completion_time: "2021-10-31T02:57:18.192280361Z"
creation_height: "21516"
initial_balance: "24000000"
validator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
validator
validator
命令允许用户查询单个验证人的详细信息。
使用:
Copy simd query staking validator [validator-addr] [flags]
示例:
Copy simd query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
示例输出:
Copy commission:
commission_rates:
max_change_rate: "0.020000000000000000"
max_rate: "0.200000000000000000"
rate: "0.050000000000000000"
update_time: "2021-10-01T19:24:52.663191049Z"
consensus_pubkey:
'@type': /cosmos.crypto.ed25519.PubKey
key: sIiexdJdYWn27+7iUHQJDnkp63gq/rzUq1Y+fxoGjXc=
delegator_shares: "32948270000.000000000000000000"
description:
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.
identity: 51468B615127273A
moniker: Witval
security_contact: ""
website: ""
jailed: false
min_self_delegation: "1"
operator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
status: BOND_STATUS_BONDED
tokens: "32948270000"
unbonding_height: "0"
unbonding_time: "1970-01-01T00:00:00Z"
validators
validators
命令允许用户查询网络上所有验证人的详细信息。
使用:
Copy simd query staking validators [flags]
示例:
Copy simd query staking validators
示例输出:
Copy pagination:
next_key: FPTi7TKAjN63QqZh+BaXn6gBmD5/
total: "0"
validators:
commission:
commission_rates:
max_change_rate: "0.020000000000000000"
max_rate: "0.200000000000000000"
rate: "0.050000000000000000"
update_time: "2021-10-01T19:24:52.663191049Z"
consensus_pubkey:
'@type': /cosmos.crypto.ed25519.PubKey
key: sIiexdJdYWn27+7iUHQJDnkp63gq/rzUq1Y+fxoGjXc=
delegator_shares: "32948270000.000000000000000000"
description:
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.
identity: 51468B615127273A
moniker: Witval
security_contact: ""
website: ""
jailed: false
min_self_delegation: "1"
operator_address: cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
status: BOND_STATUS_BONDED
tokens: "32948270000"
unbonding_height: "0"
unbonding_time: "1970-01-01T00:00:00Z"
- commission:
commission_rates:
max_change_rate: "0.100000000000000000"
max_rate: "0.200000000000000000"
rate: "0.050000000000000000"
update_time: "2021-10-04T18:02:21.446645619Z"
consensus_pubkey:
'@type': /cosmos.crypto.ed25519.PubKey
key: GDNpuKDmCg9GnhnsiU4fCWktuGUemjNfvpCZiqoRIYA=
delegator_shares: "559343421.000000000000000000"
description:
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!
identity: 812E82D12FEA3493
moniker: Noderunners
security_contact: info@noderunners.biz
website: http://noderunners.biz
jailed: false
min_self_delegation: "1"
operator_address: cosmosvaloper1q5ku90atkhktze83j9xjaks2p7uruag5zp6wt7
status: BOND_STATUS_BONDED
tokens: "559343421"
unbonding_height: "0"
unbonding_time: "1970-01-01T00:00:00Z"
Transactions
tx
命令允许用户与质押模块进行交互。
Copy simd tx staking --help
create-validator
命令 create-validator
允许用户创建一个新的验证人,并为其初始化自我委托。
使用:
Copy simd tx staking create-validator [path/to/validator.json] [flags]
示例:
Copy simd tx staking create-validator /path/to/validator.json \
--chain-id="name_of_chain_id" \
--gas="auto" \
--gas-adjustment="1.2" \
--gas-prices="0.025stake" \
--from=mykey
其中 validator.json
包含:
Copy {
"pubkey": {"@type":"/cosmos.crypto.ed25519.PubKey","key":"BnbwFpeONLqvWqJb3qaUbL5aoIcW3fSuAp9nT3z5f20="},
"amount": "1000000stake",
"moniker": "my-moniker",
"website": "https://myweb.site",
"security": "security-contact@gmail.com",
"details": "description of your validator",
"commission-rate": "0.10",
"commission-max-rate": "0.20",
"commission-max-change-rate": "0.01",
"min-self-delegation": "1"
}
公钥可以通过使用 simd tendermint show-validator
命令获得。
delegate
命令 delegate
允许用户将流动性资产委托给一个验证人。
使用:
Copy simd tx staking delegate [validator-addr] [amount] [flags]
示例:
Copy simd tx staking delegate cosmosvaloper1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm 1000stake --from mykey
edit-validator
命令 edit-validator
允许用户编辑现有的验证人账户。
使用:
Copy simd tx staking edit-validator [flags]
示例:
Copy simd tx staking edit-validator --moniker "new_moniker_name" --website "new_webiste_url" --from mykey
redelegate
命令 redelegate
允许用户将非流动性资产从一个验证人重新委托到另一个验证人。
使用:
Copy simd tx staking redelegate [src-validator-addr] [dst-validator-addr] [amount] [flags]
示例:
Copy simd tx staking redelegate cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj cosmosvaloper1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm 100stake --from mykey
unbond
命令 unbond
允许用户从验证人解除质押份额。
使用:
Copy simd tx staking unbond [validator-addr] [amount] [flags]
示例:
Copy simd tx staking unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from mykey
cancel unbond
命令 cancel-unbond
允许用户取消解除质押的委托条目,并重新委托回原始验证人。
使用:
Copy simd tx staking cancel-unbond [validator-addr] [amount] [creation-height]
示例:
Copy simd tx staking cancel-unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake 123123 --from mykey
gRPC
用户可以使用 gRPC 端点查询质押模块。
Validators
Validators
端点查询所有与指定状态匹配的验证人。
Copy cosmos.staking.v1beta1.Query/Validators
示例:
Copy grpcurl -plaintext localhost:9090 cosmos.staking.v1beta1.Query/Validators
示例输出:
Copy {
"validators": [
{
"operatorAddress": "cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"consensusPubkey": {"@type":"/cosmos.crypto.ed25519.PubKey","key":"Auxs3865HpB/EfssYOzfqNhEJjzys2Fo6jD5B8tPgC8="},
"status": "BOND_STATUS_BONDED",
"tokens": "10000000",
"delegatorShares": "10000000000000000000000000",
"description": {
"moniker": "myvalidator"
},
"unbondingTime": "1970-01-01T00:00:00Z",
"commission": {
"commissionRates": {
"rate": "100000000000000000",
"maxRate": "200000000000000000",
"maxChangeRate": "10000000000000000"
},
"updateTime": "2021-10-01T05:52:50.380144238Z"
},
"minSelfDelegation": "1"
}
],
"pagination": {
"total": "1"
}
}
Validator
Validator
端点查询指定验证人地址的验证人信息。
Copy cosmos.staking.v1beta1.Query/Validator
示例:
Copy grpcurl -plaintext -d '{"validator_addr":"cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc"}' \
localhost:9090 cosmos.staking.v1beta1.Query/Validator
示例输出:
Copy {
"validator": {
"operatorAddress": "cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"consensusPubkey": {"@type":"/cosmos.crypto.ed25519.PubKey","key":"Auxs3865HpB/EfssYOzfqNhEJjzys2Fo6jD5B8tPgC8="},
"status": "BOND_STATUS_BONDED",
"tokens": "10000000",
"delegatorShares": "10000000000000000000000000",
"description": {
"moniker": "myvalidator"
},
"unbondingTime": "1970-01-01T00:00:00Z",
"commission": {
"commissionRates": {
"rate": "100000000000000000",
"maxRate": "200000000000000000",
"maxChangeRate": "10000000000000000"
},
"updateTime": "2021-10-01T05:52:50.380144238Z"
},
"minSelfDelegation": "1"
}
}
ValidatorDelegations
ValidatorDelegations
端点查询指定验证人的委托信息。
Copy cosmos.staking.v1beta1.Query/ValidatorDelegations
示例:
Copy grpcurl -plaintext -d '{"validator_addr":"cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc"}' \
localhost:9090 cosmos.staking.v1beta1.Query/ValidatorDelegations
示例输出:
Copy {
"delegationResponses": [
{
"delegation": {
"delegatorAddress": "cosmos1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgy3ua5t",
"validatorAddress": "cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"shares": "10000000000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "10000000"
}
}
],
"pagination": {
"total": "1"
}
}
ValidatorUnbondingDelegations
ValidatorUnbondingDelegations
端点查询指定验证人的解质押委托信息。
Copy cosmos.staking.v1beta1.Query/ValidatorUnbondingDelegations
示例:
Copy grpcurl -plaintext -d '{"validator_addr":"cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc"}' \
localhost:9090 cosmos.staking.v1beta1.Query/ValidatorUnbondingDelegations
示例输出:
Copy {
"unbonding_responses": [
{
"delegator_address": "cosmos1z3pzzw84d6xn00pw9dy3yapqypfde7vg6965fy",
"validator_address": "cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"entries": [
{
"creation_height": "25325",
"completion_time": "2021-10-31T09:24:36.797320636Z",
"initial_balance": "20000000",
"balance": "20000000"
}
]
},
{
"delegator_address": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77",
"validator_address": "cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"entries": [
{
"creation_height": "13100",
"completion_time": "2021-10-30T12:53:02.272266791Z",
"initial_balance": "1000000",
"balance": "1000000"
}
]
},
],
"pagination": {
"next_key": null,
"total": "8"
}
}
Delegation
Delegation
端点查询指定验证人和委托人对的委托信息。
Copy cosmos.staking.v1beta1.Query/Delegation
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77", validator_addr":"cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc"}' \
localhost:9090 cosmos.staking.v1beta1.Query/Delegation
示例输出:
Copy {
"delegation_response":
{
"delegation":
{
"delegator_address":"cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77",
"validator_address":"cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"shares":"25083119936.000000000000000000"
},
"balance":
{
"denom":"stake",
"amount":"25083119936"
}
}
}
UnbondingDelegation
UnbondingDelegation
端点查询指定验证人和委托人的解质押信息。
Copy cosmos.staking.v1beta1.Query/UnbondingDelegation
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77", validator_addr":"cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc"}' \
localhost:9090 cosmos.staking.v1beta1.Query/UnbondingDelegation
示例输出:
Copy {
"unbond": {
"delegator_address": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77",
"validator_address": "cosmosvaloper1rne8lgs98p0jqe82sgt0qr4rdn4hgvmgp9ggcc",
"entries": [
{
"creation_height": "136984",
"completion_time": "2021-11-08T05:38:47.505593891Z",
"initial_balance": "400000000",
"balance": "400000000"
},
{
"creation_height": "137005",
"completion_time": "2021-11-08T05:40:53.526196312Z",
"initial_balance": "385000000",
"balance": "385000000"
}
]
}
}
DelegatorDelegations
DelegatorDelegations
端点查询指定委托人地址的所有委托信息。
Copy cosmos.staking.v1beta1.Query/DelegatorDelegations
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77"}' \
localhost:9090 cosmos.staking.v1beta1.Query/DelegatorDelegations
示例输出:
Copy {
"delegation_responses": [
{"delegation":{"delegator_address":"cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77","validator_address":"cosmosvaloper1eh5mwu044gd5ntkkc2xgfg8247mgc56fww3vc8","shares":"25083339023.000000000000000000"},"balance":{"denom":"stake","amount":"25083339023"}}
],
"pagination": {
"next_key": null,
"total": "1"
}
}
DelegatorUnbondingDelegations
DelegatorUnbondingDelegations
端点查询指定委托人地址的所有解质押委托信息。
Copy cosmos.staking.v1beta1.Query/DelegatorUnbondingDelegations
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77"}' \
localhost:9090 cosmos.staking.v1beta1.Query/DelegatorUnbondingDelegations
示例输出:
Copy {
"unbonding_responses": [
{
"delegator_address": "cosmos1y8nyfvmqh50p6ldpzljk3yrglppdv3t8phju77",
"validator_address": "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9uxyejze",
"entries": [
{
"creation_height": "136984",
"completion_time": "2021-11-08T05:38:47.505593891Z",
"initial_balance": "400000000",
"balance": "400000000"
},
{
"creation_height": "137005",
"completion_time": "2021-11-08T05:40:53.526196312Z",
"initial_balance": "385000000",
"balance": "385000000"
}
]
}
],
"pagination": {
"next_key": null,
"total": "1"
}
}
Redelegations
Redelegations
端点查询指定地址的重委托信息。
Copy cosmos.staking.v1beta1.Query/Redelegations
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1ld5p7hn43yuh8ht28gm9pfjgj2fctujp2tgwvf", "src_validator_addr" : "cosmosvaloper1j7euyj85fv2jugejrktj540emh9353ltgppc3g", "dst_validator_addr" : "cosmosvaloper1yy3tnegzmkdcm7czzcy3flw5z0zyr9vkkxrfse"}' \
localhost:9090 cosmos.staking.v1beta1.Query/Redelegations
示例输出:
Copy {
"redelegation_responses": [
{
"redelegation": {
"delegator_address": "cosmos1ld5p7hn43yuh8ht28gm9pfjgj2fctujp2tgwvf",
"validator_src_address": "cosmosvaloper1j7euyj85fv2jugejrktj540emh9353ltgppc3g",
"validator_dst_address": "cosmosvaloper1yy3tnegzmkdcm7czzcy3flw5z0zyr9vkkxrfse",
"entries": null
},
"entries": [
{
"redelegation_entry": {
"creation_height": 135932,
"completion_time": "2021-11-08T03:52:55.299147901Z",
"initial_balance": "2900000",
"shares_dst": "2900000.000000000000000000"
},
"balance": "2900000"
}
]
}
],
"pagination": null
}
DelegatorValidators
DelegatorValidators
端点查询指定委托人所有验证人的信息。
Copy cosmos.staking.v1beta1.Query/DelegatorValidators
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1ld5p7hn43yuh8ht28gm9pfjgj2fctujp2tgwvf"}' \
localhost:9090 cosmos.staking.v1beta1.Query/DelegatorValidators
示例输出:
Copy {
"validators": [
{
"operator_address": "cosmosvaloper1eh5mwu044gd5ntkkc2xgfg8247mgc56fww3vc8",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "UPwHWxH1zHJWGOa/m6JB3f5YjHMvPQPkVbDqqi+U7Uw="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "347260647559",
"delegator_shares": "347260647559.000000000000000000",
"description": {
"moniker": "BouBouNode",
"identity": "",
"website": "https://boubounode.com",
"security_contact": "",
"details": "AI-based Validator. #1 AI Validator on Game of Stakes. Fairly priced. Don't trust (humans), verify. Made with BouBou love."
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.061000000000000000",
"max_rate": "0.300000000000000000",
"max_change_rate": "0.150000000000000000"
},
"update_time": "2021-10-01T15:00:00Z"
},
"min_self_delegation": "1"
}
],
"pagination": {
"next_key": null,
"total": "1"
}
}
DelegatorValidator
DelegatorValidator
端点查询指定委托人和验证人对的验证人信息。
Copy cosmos.staking.v1beta1.Query/DelegatorValidator
示例:
Copy grpcurl -plaintext \
-d '{"delegator_addr": "cosmos1eh5mwu044gd5ntkkc2xgfg8247mgc56f3n8rr7", "validator_addr": "cosmosvaloper1eh5mwu044gd5ntkkc2xgfg8247mgc56fww3vc8"}' \
localhost:9090 cosmos.staking.v1beta1.Query/DelegatorValidator
示例输出:
Copy {
"validator": {
"operator_address": "cosmosvaloper1eh5mwu044gd5ntkkc2xgfg8247mgc56fww3vc8",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "UPwHWxH1zHJWGOa/m6JB3f5YjHMvPQPkVbDqqi+U7Uw="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "347262754841",
"delegator_shares": "347262754841.000000000000000000",
"description": {
"moniker": "BouBouNode",
"identity": "",
"website": "https://boubounode.com",
"security_contact": "",
"details": "AI-based Validator. #1 AI Validator on Game of Stakes. Fairly priced. Don't trust (humans), verify. Made with BouBou love."
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.061000000000000000",
"max_rate": "0.300000000000000000",
"max_change_rate": "0.150000000000000000"
},
"update_time": "2021-10-01T15:00:00Z"
},
"min_self_delegation": "1"
}
}
HistoricalInfo
Copy cosmos.staking.v1beta1.Query/HistoricalInfo
示例:
Copy grpcurl -plaintext -d '{"height" : 1}' localhost:9090 cosmos.staking.v1beta1.Query/HistoricalInfo
示例输出:
Copy {
"hist": {
"header": {
"version": {
"block": "11",
"app": "0"
},
"chain_id": "simd-1",
"height": "140142",
"time": "2021-10-11T10:56:29.720079569Z",
"last_block_id": {
"hash": "9gri/4LLJUBFqioQ3NzZIP9/7YHR9QqaM6B2aJNQA7o=",
"part_set_header": {
"total": 1,
"hash": "Hk1+C864uQkl9+I6Zn7IurBZBKUevqlVtU7VqaZl1tc="
}
},
"last_commit_hash": "VxrcS27GtvGruS3I9+AlpT7udxIT1F0OrRklrVFSSKc=",
"data_hash": "80BjOrqNYUOkTnmgWyz9AQ8n7SoEmPVi4QmAe8RbQBY=",
"validators_hash": "95W49n2hw8RWpr1GPTAO5MSPi6w6Wjr3JjjS7AjpBho=",
"next_validators_hash": "95W49n2hw8RWpr1GPTAO5MSPi6w6Wjr3JjjS7AjpBho=",
"consensus_hash": "BICRvH3cKD93v7+R1zxE2ljD34qcvIZ0Bdi389qtoi8=",
"app_hash": "ZZaxnSY3E6Ex5Bvkm+RigYCK82g8SSUL53NymPITeOE=",
"last_results_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
"evidence_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
"proposer_address": "aH6dO428B+ItuoqPq70efFHrSMY="
},
"valset": [
{
"operator_address": "cosmosvaloper196ax4vc0lwpxndu9dyhvca7jhxp70rmcqcnylw",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "/O7BtNW0pafwfvomgR4ZnfldwPXiFfJs9mHg3gwfv5Q="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "1426045203613",
"delegator_shares": "1426045203613.000000000000000000",
"description": {
"moniker": "SG-1",
"identity": "48608633F99D1B60",
"website": "https://sg-1.online",
"security_contact": "",
"details": "SG-1 - your favorite validator on Witval. 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"
}
]
}
}
Pool
Pool
端点查询池的信息。
Copy cosmos.staking.v1beta1.Query/Pool
示例:
Copy grpcurl -plaintext -d localhost:9090 cosmos.staking.v1beta1.Query/Pool
示例输出:
Copy {
"pool": {
"not_bonded_tokens": "369054400189",
"bonded_tokens": "15657192425623"
}
}
Params
Params
端点查询参数信息。
Copy cosmos.staking.v1beta1.Query/Params
示例:
Copy grpcurl -plaintext localhost:9090 cosmos.staking.v1beta1.Query/Params
示例输出:
Copy {
"params": {
"unbondingTime": "1814400s",
"maxValidators": 100,
"maxEntries": 7,
"historicalEntries": 10000,
"bondDenom": "stake"
}
}
REST
用户可以使用 REST 端点查询质押模块。
DelegatorDelegations
DelegtaorDelegations
REST端点查询给定委托人地址的所有委托。
Copy /cosmos/staking/v1beta1/delegations/{delegatorAddr}
示例:
Copy curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/delegations/cosmos1vcs68xf2tnqes5tg0khr0vyevm40ff6zdxatp5" -H "accept: application/json"
示例输出:
Copy {
"delegation_responses": [
{
"delegation": {
"delegator_address": "cosmos1vcs68xf2tnqes5tg0khr0vyevm40ff6zdxatp5",
"validator_address": "cosmosvaloper1quqxfrxkycr0uzt4yk0d57tcq3zk7srm7sm6r8",
"shares": "256250000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "256250000"
}
},
{
"delegation": {
"delegator_address": "cosmos1vcs68xf2tnqes5tg0khr0vyevm40ff6zdxatp5",
"validator_address": "cosmosvaloper194v8uwee2fvs2s8fa5k7j03ktwc87h5ym39jfv",
"shares": "255150000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "255150000"
}
}
],
"pagination": {
"next_key": null,
"total": "2"
}
}
Redelegations
Redelegations
REST端点查询给定地址的重新委托。
Copy /cosmos/staking/v1beta1/delegators/{delegatorAddr}/redelegations
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/delegators/cosmos1thfntksw0d35n2tkr0k8v54fr8wxtxwxl2c56e/redelegations?srcValidatorAddr=cosmosvaloper1lzhlnpahvznwfv4jmay2tgaha5kmz5qx4cuznf&dstValidatorAddr=cosmosvaloper1vq8tw77kp8lvxq9u3c8eeln9zymn68rng8pgt4" \
-H "accept: application/json"
示例输出:
Copy {
"redelegation_responses": [
{
"redelegation": {
"delegator_address": "cosmos1thfntksw0d35n2tkr0k8v54fr8wxtxwxl2c56e",
"validator_src_address": "cosmosvaloper1lzhlnpahvznwfv4jmay2tgaha5kmz5qx4cuznf",
"validator_dst_address": "cosmosvaloper1vq8tw77kp8lvxq9u3c8eeln9zymn68rng8pgt4",
"entries": null
},
"entries": [
{
"redelegation_entry": {
"creation_height": 151523,
"completion_time": "2021-11-09T06:03:25.640682116Z",
"initial_balance": "200000000",
"shares_dst": "200000000.000000000000000000"
},
"balance": "200000000"
}
]
}
],
"pagination": null
}
DelegatorUnbondingDelegations
DelegatorUnbondingDelegations
REST端点查询给定委托人地址的所有未绑定委托。
Copy /cosmos/staking/v1beta1/delegators/{delegatorAddr}/unbonding_delegations
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/delegators/cosmos1nxv42u3lv642q0fuzu2qmrku27zgut3n3z7lll/unbonding_delegations" \
-H "accept: application/json"
示例输出:
Copy {
"unbonding_responses": [
{
"delegator_address": "cosmos1nxv42u3lv642q0fuzu2qmrku27zgut3n3z7lll",
"validator_address": "cosmosvaloper1e7mvqlz50ch6gw4yjfemsc069wfre4qwmw53kq",
"entries": [
{
"creation_height": "2442278",
"completion_time": "2021-10-12T10:59:03.797335857Z",
"initial_balance": "50000000000",
"balance": "50000000000"
}
]
}
],
"pagination": {
"next_key": null,
"total": "1"
}
}
DelegatorValidators
DelegatorValidators
REST端点查询给定委托人地址的所有验证人信息。
Copy /cosmos/staking/v1beta1/delegators/{delegatorAddr}/validators
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/delegators/cosmos1xwazl8ftks4gn00y5x3c47auquc62ssune9ppv/validators" \
-H "accept: application/json"
示例输出:
Copy {
"validators": [
{
"operator_address": "cosmosvaloper1xwazl8ftks4gn00y5x3c47auquc62ssuvynw64",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "5v4n3px3PkfNnKflSgepDnsMQR1hiNXnqOC11Y72/PQ="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "21592843799",
"delegator_shares": "21592843799.000000000000000000",
"description": {
"moniker": "jabbey",
"identity": "",
"website": "https://twitter.com/JoeAbbey",
"security_contact": "",
"details": "just another dad in the cosmos"
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.100000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.100000000000000000"
},
"update_time": "2021-10-09T19:03:54.984821705Z"
},
"min_self_delegation": "1"
}
],
"pagination": {
"next_key": null,
"total": "1"
}
}
DelegatorValidator
DelegatorValidator
REST端点查询给定委托人验证人对的验证人信息。
Copy /cosmos/staking/v1beta1/delegators/{delegatorAddr}/validators/{validatorAddr}
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/delegators/cosmos1xwazl8ftks4gn00y5x3c47auquc62ssune9ppv/validators/cosmosvaloper1xwazl8ftks4gn00y5x3c47auquc62ssuvynw64" \
-H "accept: application/json"
示例输出:
Copy {
"validator": {
"operator_address": "cosmosvaloper1xwazl8ftks4gn00y5x3c47auquc62ssuvynw64",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "5v4n3px3PkfNnKflSgepDnsMQR1hiNXnqOC11Y72/PQ="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "21592843799",
"delegator_shares": "21592843799.000000000000000000",
"description": {
"moniker": "jabbey",
"identity": "",
"website": "https://twitter.com/JoeAbbey",
"security_contact": "",
"details": "just another dad in the cosmos"
},
"unbonding_height": "0",
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.100000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.100000000000000000"
},
"update_time": "2021-10-09T19:03:54.984821705Z"
},
"min_self_delegation": "1"
}
}
HistoricalInfo
HistoricalInfo
REST端点查询给定高度的历史信息。
Copy /cosmos/staking/v1beta1/historical_info/{height}
示例:
Copy curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/historical_info/153332" -H "accept: application/json"
示例输出:
Copy {
"hist": {
"header": {
"version": {
"block": "11",
"app": "0"
},
"chain_id": "cosmos-1",
"height": "153332",
"time": "2021-10-12T09:05:35.062230221Z",
"last_block_id": {
"hash": "NX8HevR5khb7H6NGKva+jVz7cyf0skF1CrcY9A0s+d8=",
"part_set_header": {
"total": 1,
"hash": "zLQ2FiKM5tooL3BInt+VVfgzjlBXfq0Hc8Iux/xrhdg="
}
},
"last_commit_hash": "P6IJrK8vSqU3dGEyRHnAFocoDGja0bn9euLuy09s350=",
"data_hash": "eUd+6acHWrNXYju8Js449RJ99lOYOs16KpqQl4SMrEM=",
"validators_hash": "mB4pravvMsJKgi+g8aYdSeNlt0kPjnRFyvtAQtaxcfw=",
"next_validators_hash": "mB4pravvMsJKgi+g8aYdSeNlt0kPjnRFyvtAQtaxcfw=",
"consensus_hash": "BICRvH3cKD93v7+R1zxE2ljD34qcvIZ0Bdi389qtoi8=",
"app_hash": "fuELArKRK+CptnZ8tu54h6xEleSWenHNmqC84W866fU=",
"last_results_hash": "p/BPexV4LxAzlVcPRvW+lomgXb6Yze8YLIQUo/4Kdgc=",
"evidence_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
"proposer_address": "G0MeY8xQx7ooOsni8KE/3R/Ib3Q="
},
"valset": [
{
"operator_address": "cosmosvaloper196ax4vc0lwpxndu9dyhvca7jhxp70rmcqcnylw",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "/O7BtNW0pafwfvomgR4ZnfldwPXiFfJs9mHg3gwfv5Q="
},
"jailed": false,
"status": "BOND_STATUS_BONDED",
"tokens": "1416521659632",
"delegator_shares": "1416521659632.000000000000000000",
"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
Parameters
REST端点查询质押参数。
Copy /cosmos/staking/v1beta1/params
示例:
Copy curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/params" -H "accept: application/json"
示例输出:
Copy {
"params": {
"unbonding_time": "2419200s",
"max_validators": 100,
"max_entries": 7,
"historical_entries": 10000,
"bond_denom": "stake"
}
}
Pool
Pool
REST端点查询池信息。
Copy /cosmos/staking/v1beta1/pool
示例:
Copy curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/pool" -H "accept: application/json"
示例输出:
Copy {
"pool": {
"not_bonded_tokens": "432805737458",
"bonded_tokens": "15783637712645"
}
}
Validators
Validators
REST端点查询所有匹配给定状态的验证人。
Copy /cosmos/staking/v1beta1/validators
示例:
Copy curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/validators" -H "accept: application/json"
示例输出:
Copy {
"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端点查询给定验证人地址的验证人信息。
Copy /cosmos/staking/v1beta1/validators/{validatorAddr}
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q" \
-H "accept: application/json"
示例输出:
Copy {
"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
ValidatorDelegations
REST端点查询给定验证人的委托信息。
Copy /cosmos/staking/v1beta1/validators/{validatorAddr}/delegations
示例:
Copy curl -X GET "http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q/delegations" -H "accept: application/json"
示例输出:
Copy {
"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
Delegation
REST端点查询给定验证人委托人对的委托信息。
Copy /cosmos/staking/v1beta1/validators/{validatorAddr}/delegations/{delegatorAddr}
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q/delegations/cosmos1n8f5fknsv2yt7a8u6nrx30zqy7lu9jfm0t5lq8" \
-H "accept: application/json"
示例输出:
Copy {
"delegation_response": {
"delegation": {
"delegator_address": "cosmos1n8f5fknsv2yt7a8u6nrx30zqy7lu9jfm0t5lq8",
"validator_address": "cosmosvaloper16msryt3fqlxtvsy8u5ay7wv2p8mglfg9g70e3q",
"shares": "500000000.000000000000000000"
},
"balance": {
"denom": "stake",
"amount": "500000000"
}
}
}
UnbondingDelegation
UnbondingDelegation
REST端点查询给定验证人委托人对的未绑定信息。
Copy /cosmos/staking/v1beta1/validators/{validatorAddr}/delegations/{delegatorAddr}/unbonding_delegation
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu/delegations/cosmos1ze2ye5u5k3qdlexvt2e0nn0508p04094ya0qpm/unbonding_delegation" \
-H "accept: application/json"
示例输出:
Copy {
"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
ValidatorUnbondingDelegations
REST端点查询验证人的未绑定委托。
Copy /cosmos/staking/v1beta1/validators/{validatorAddr}/unbonding_delegations
示例:
Copy curl -X GET \
"http://localhost:1317/cosmos/staking/v1beta1/validators/cosmosvaloper13v4spsah85ps4vtrw07vzea37gq5la5gktlkeu/unbonding_delegations" \
-H "accept: application/json"
示例输出:
Copy {
"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"
}
}