pos 命名空间
conflux-rust
从版本2.0.0开始引入了权益证明(PoS)最终性,以加速区块的最终性并防止51%攻击。 PoS finality将引入一个独立的PoS链用于PoS共识和确认PoW块的最终性。 对应地,PoS也有自己的RPC方法,用于从PoS链中获取数据。
目前,只有conflux-rust的存档节点可以向公众提供PoS RPC服务。 public_rpc_apis
needs to be configured to open RPC.
您可以将pos
组添加到当前RPC方法组中。
public_rpc_apis = "safe,pos"
又或者,你可以将public_rpc_apis
设置为all
以打开所有RPC方法。
public_rpc_apis = "all"
基本概念
epoch
纪元(Epoch)是 PoS 中也使用的概念。 However, different from the epoch in PoW, an epoch in PoS represents the term of a committee, starting from term 1
. 每个纪元的平均时长为半小时
。 每个 epoch 结束后,委员会的一部分成员会被替换。 The rewards for participating in PoS consensus are also given on an epoch basis.
round
A PoS chain will on average perform one round of consensus 30 seconds
(i.e. try to generate a PoS block). 这意味着每个epoch将有60
个回合,每次新的epoch
开始后,回合编号会重新从1
开始计数。
注意: 并不是每个回合都会生成一个块。 there may be network or consensus failures preventing a block from generating.
block.number
区块的block.number是指该区块的高度
,每生成一个新的区块,该值就会加一。
After a PoS block is proposed by a committee member, it will be sent to the network for voting. 当该区块收集到足够的投票时,它被标记为voted
(已投票)。 However, the block has yet been committed. When three consecutive blocks are created, the block corresponding to the first round will be submitted. 然后,它的状态将从voted
更改为committed
。
pivotDecision
pivotDecision is the PoS chain's final decision on a block in the PoW chain. Once a block in the PoW is referenced by the PoS, the PoW block is finalized and there will be no further reversion. PoS链中的区块将包括PivotDecision属性,表明该PoS区块已经对PoW链中的一个区块进行了最终确认。 The pivotDecision is the block number or hash value of a block in the PoW chain.
PoS Address
不同于 PoW 地址的格式,PoS 账户地址是一个 256 位的哈希值,例如:
0x046ca462890f25ed9394ca9f92c979ff48e1738a81822ecab96d83813c1a433c
PoS Model
账户状态
当账户注册参与PoS共识或增加质押投票后,这些投票将首先进入 inQueue
状态,并在13天
后锁定
。 当用户执行解锁命令时,要解锁的票数将首先进入 outQueue
状态。 Then it takes 1 day
to become unlocked
.
availableVotes
:QUANTITY
- 当前账户可用的票数。 等于sum inQueue
+locked
的总和forfeited
:QUANTITY
- the number of votes that are locked and cannot be retrieved if the account is identified as malicious.forceRetired
:QUANTITY
- 票数被取消的区块号inQueue
:Array
of VotesInQueue - the number of votes that are currently waiting to be lockedlocked
:QUANTITY
- the number of votes that are currently lockedoutQueue
:Array
of VotesInQueue - the number of votes that are currently waiting to be unlockedunlocked
:QUANTITY
- the number of users total unlocked votes in history
Decision
The PoS chain's decision on the height of the PoW chain. The block of the PoW that is decided by the PoS chain is the Finalized block.
height
:QUANTITY
- PoW 区块的高度blockHash
:HASH
- PoW 区块的哈希值
VotesInQueue
The information regarding a user's in-queue votes.
endBlockNumber
:QUANTITY
- block number when the state endspower
:QUANTITY
- 当前状态中的投票数
RPCs
pos_getStatus
返回 PoS 链的当前状态。
参数
Empty
返回值
Object
- PoS 状态对象。
epoch
:QUANTITY
- PoS 链的当前纪元编号。latestCommitted
:QUANTITY
- 最新提交区块的编号。 提交的区块不会被回滚latestVoted
:QUANTITY
- The number of the latest successfully voted block, ornull
(if there are no blocks completed voting).pivotDecision
:Decision
- The PoS chain's finalized decision about the latest PoW pivot block.
示例
请求
curl --location --request POST 'http://localhost:12537' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
"method": "pos_getStatus",
"params": []
}'
Result
{
"jsonrpc": "2.0",
"result": {
"epoch": "0x56",
"latestCommitted": "0x140c",
"latestVoted": "0x140e",
"pivotDecision": {
"height": "0x113af0",
"blockHash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
}
},
"id": 1
}
pos_getAccount
获取 PoS 账户信息