pos 命名空间
conflux-rust
从版本2.0.0开始引入了权益证明(PoS)最终性,以加速区块的最终性并防止51%攻击。 PoS finality将引入一个独立的PoS链用于PoS共识和确认PoW块的最终性。 对应地,PoS也有自己的RPC方法,用于从PoS链中获取数据。
Currently, only the archive nodes of conflux-rust can provide PoS RPC service to the public. public_rpc_apis
needs to be configured to open RPC.
You can add the pos
group to the current RPC method group.
public_rpc_apis = "safe,pos"
Or just set public_rpc_apis
to all
to open all RPC methods.
public_rpc_apis = "all"
Basic Concepts
epoch
The concept of epoch is also used in PoS. However, different from the epoch in PoW, an epoch in PoS represents the term of a committee, starting from term 1
. Each epoch is equivalent to half hour
on average. After each epoch, a part of the members of the committee are replaced. 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). This means that each epoch will have 60
rounds, and with each new epoch
, the round will start from 1
again.
Note: Not every round will generate a block. there may be network or consensus failures preventing a block from generating.
block.number
The block.number is the height
of the block, and is added by one for each new block generated.
After a PoS block is proposed by a committee member, it will be sent to the network for voting. When the block collects enough votes, it is labeled as voted
. However, the block has yet been committed. When three consecutive blocks are created, the block corresponding to the first round will be submitted. Then its state will change from voted
to 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. Blocks in the PoS chain will include PivotDecision attributes, indicating that this PoS block has finalized a block in the PoW chain. The pivotDecision is the block number or hash value of a block in the PoW chain.
PoS Address
Unlike the format of the PoW address, the PoS account address is a 256-bit hash value, e.g:
0x046ca462890f25ed9394ca9f92c979ff48e1738a81822ecab96d83813c1a433c
PoS Model
AccountStatus
After an account registers to participate in PoS consensus, or adds staking to votes, the votes will first go into the inQueue
state and then become locked
after 13 days
. When the user makes an unlock command, the votes to be unlocked will first go into the outQueue
state. Then it takes 1 day
to become unlocked
.
availableVotes
:QUANTITY
- the number of votes currently available for the account. Equals tosum inQueue
+locked
forfeited
:QUANTITY
- the number of votes that are locked and cannot be retrieved if the account is identified as malicious.forceRetired
: [QUANTITY
] - the block number when the votes was retiredinQueue
: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
- the height of the PoW blockblockHash
:HASH
- the hash value of the PoW block
VotesInQueue
The information regarding a user's in-queue votes.
endBlockNumber
:QUANTITY
- block number when the state endspower
:QUANTITY
- number of votes in the current status
RPCs
pos_getStatus
Returns the current status of the PoS chain.
参数
Empty
返回值
Object
- PoS status object.
epoch
:QUANTITY
- The current epoch number of the PoS chain.latestCommitted
:QUANTITY
- The number of the latest committed block. Committed blocks will not be revertedlatestVoted
: [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.
示例
Request
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
Get the PoS account information
参数
ADDRESS
: 32 Bytes - PoS account address- [
QUANTITY
]: block number, optional for querying the status of the account at a certain block height
params: [
"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"0x100"
]
返回值
Object
- the account object, or null
(if the account corresponding to the address does not exist)
address
:ADDRESS
- the account addressblockNumber
:QUANTITY
- the block number corresponding to the statusstatus
:OBJECT
- the user's current status, see Account Status for more information
示例
Request
curl --location --request POST 'http://localhost:12537' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
"method": "pos_getAccount",
"params": ["0x046ca462890f25ed9394ca9f92c979ff48e1738a81822ecab96d83813c1a433c"]
}'
Response
{
"jsonrpc": "2.0",
"result": {
"address": "0x046ca462890f25ed9394ca9f92c979ff48e1738a81822ecab96d83813c1a433c",
"blockNumber": "0x14a7",
"status": {
"availableVotes": "0x513",
"forfeited": "0x0",
"forceRetired": null,
"inQueue": [],
"locked": "0x513",
"outQueue": [],
"unlocked": "0x0"
}
},
"id": 1
}
pos_getCommittee
Get the current PoS committee information in default. It is also able to get the committee information for a block in history by specifying the blockNumber.
参数
- [
QUANTITY
]: block number, optional for querying the committee information at a certain block height
返回值
currentCommittee
:OBJECT
- current committee members, see CurrentCommittee for more informationelections
:Array
- nodes who are running for election
CurrentCommittee
Current committee information
epochNumber
:QUANTITY
- epoch number of the committee termnodes
:Array
of CommitteNode - list of committee membersquorumVotingPower
:QUANTITY
- the minimum number of votes needed to reach consensustotalVotingPower
:QUANTITY
- the total number of votes of the current committee members
CommitteNode
Committee member information
address
:ADDRESS
- account addressvotingPower
:QUANTITY
- number of votes
Election
isFinalized
:BOOLEAN
- whether the election is finalized or notstartBlockNumber
:QUANTITY
- the starting block numbertopElectingNodes
:Array
of CommitteNode - the top ranked 50 nodes after election