r²PoS is a Relay-friendly, unbiasedly Randomized Proof of Stake consensus, developed for side-chain with 2-way relay with another smart-contract platform.
Relay data from one blockchain to another is expensive, mostly because the protocol of each involving blockchain does not actively support it. Relaying chain data and lightclient both require a protocol for the client to easily verify any data contained in the blockchain with only a small part of the chain data. A relay contract is also a light-client with even more limited resource.
BTCRelay contract is abandoned due to low activity. Relaying a single transaction requires all previous block headers from the last relayed one. PeaceRelay is not practical because it's costing too much gas to verify an Ethash in the Ethereum contract platform itself.
Major blockchains have no support for trustless SPV/Lightclient protocol with optimal data and computation. That is, proving a transaction finality in an arbitrary block require relaying much less data than block headers.
Related works:
Proof of Stake relies on the running state of the chain, which is not available in fast and light synchronization. The r²PoS protocol is designed for securing header-chain verification without the chain state. There is no epoch nor checkpoint, the validator queue is constantly changed over each block, so the consensus depends on no single point of vulnerability nor performance bottleneck.
To participate in the validator queue, one must have enough amount governance token, which stays in the chain state. The required stake is verified by the governance contract, which also only available to full-state nodes. For secure stateless header-chain verification, each validator application need confirmations to active. The stake requirement is verified by validators, which are full-state nodes. After more than half of the queue confirm the application, it's fully verified. Then the state-less clients can trust that application, having access to no chain state at all.
To keep the validator queue healthy with the ever-changing validators set, if a validator hasn't publish any block in blocks, it will be leaked out of the active queue. To join the queue again, token holder must re-apply the validator in the governance contract.
Given a header chain is verified up to block , the set of authorized validators for the block can be determined by:
Where is the validator of block ; and are the validator joining and leaving application set of block .
That is:
Sealing Queue can be deterministically reconstructed at any point in the header-chain, where the last headers are verified. Reconstruction does not require any checkpoint, nor scanning more than blocks.
A block in r²PoS is finalized after confirmations, the chain can progress with just more than active validators.
To increase the rate of unique confirmation for anchor chain protocol, the last block validators are the recent signers and cannot publish the next block; hence the chain can only progress with more than active validators.
The order and priority of the active validator queue is shufled using the VDF calculation output as random seed. Input of the next VDF is the hash of the block containing the last VDF output. (See Unbiasable Randomness)
The VDF output can be included in any block to be available to the network as soon as possible. The block with the valid VDF output is prioritized by the protocol, allow it to override any other non-VDF block.
There's no explicit incentive to calculate and publish the VDF output. But as one of the most valuable attributes of VDF, it requires only a single honest participant to secure the whole network, i.e. the randomization works even with only one validator running the VDF calculation.
This setup prevents any kind of stake grinding or biasing. The only weakness is that it's not realtime. As for every random seed, there's a small time window that a specific sequence of validators is known to authorize the upcoming blocks. What is not known is the order of the next sequence after a new random seed available.
r²PoS is designed for trustless and efficient light client verification, allow relaying data from arbitrary block with data complexity, where is the number of validator applications up to block .
Cross-link is a block that contains consensus metadata necessary to verify the blocks followed. Every block is cryptographically linked to a cross-link, and each cross-link is linked to the last cross-link. A cross-link block is created when there's an active change in the validator queue, e.g. validator join or leave.
This chain of cross-link blocks allows the light-client to skip all the blocks that has no affect to the consensus.
In the example diagram above, the cross-link chain only contains block number 6, 8 and 11. All other blocks in between have no effect on the consensus and can be ignored by light-clients.
Anchor is the cryptographic link between cross-link blocks that share the super-majority common validators. Anchor chain allows any block can be relayed, or verified by light client with much less data than headers.
With conflicted messages are assumed to be provable slashing condition, PoS requires of unique confirmations for block finality. Blocks anchoring to the same anchor share the common validator set of . To verify the finality of a block using the continuity anchor, only a set of active validator can be missing or left out. So we have:
So the set of header confirmations must be relayed with:
Picking and is a matter of trading off between the consensus and relay protocol liveness. If we pick (super majority), then we have:
That means, the blocks with the same anchor must share more than common validators (a.k.a. majority continuity), and relaying a block requires confirmations from the anchored validator set.
Let and is the validator set of block and . The majority continuity between the two blocks is preserved when . This allows the validity and finality of block can be verified with any confirmations from the validator set.
Whenever the majority continuity is broken, a new anchor must be created, and the following blocks must anchor to this new anchor.
In the diagram above, block 8 and 11 shares the majority common validators with block 6, so they are anchored to block 6. Block 13 breaks the continuity, even if it's not a cross-link block, it will be turned into one and linked to the new anchor - block 11.
The anchor chain grows at most 1 block for each validator application (i.e. join or leave). There's no probability in (this version of) PoS, so logarithmic growing rate like PoPOW is not possible. Realistically, from the past data of PoS chains, the anchor chain size is often less than 1 over a millions of block headers. This is extremely optimal for PoS chain with quick block time and less frequent change of validators.
The header chain can be optimized for lightclient and relay, using multiple layers hashing. The first hashing layer must reveal only data for the consensus, just enough to verify the header chain and nothing else. All other block content will be hashed in the second layer.
That reduces the data size for each header from 573 bytes + 5 scalars to 129 bytes + 5 scalars. Without 5 scalars, that is about 77% data size saved for each block header.
The ContentHash is only verified when the block content is needed.
Another approach to optimize the data size and calculation for header confirmations is to provide a layer 2 relay signature service. This service only works for relaying the latest part of the chain, which luckily, is most of the relay cases.
Active validators can serve this service by signing the past block on request and providing the signature to the relayer. After collecting signatures, relayer can submit them to the relay contract to prove finality of a block header, without bother with the header destructuring and chaining confirmations.
Ignoring 5 scalars, this methods save up to 88.6% of the data size for each block confirmations.
Theashold signature can be utilized for block finality, when such signature scheme is supported in major foreign chains.
(In Progress)
A object is identified by its hash and can be either:
A has one of the following states:
The (new) genesis block is hardcoded into the contract as the first finalized .
A is the ordered list of validator addresses, recorded in the header extra. The of a is relayed and verified only if the is finalized.
As the consensus, only cross-linked and anchored block has the queue digest to be verified. A can only be linked or anchored, if it's finalized.
A can be verified with its anchor or linked block, when its validator is in the respective .
Note that, a verified alone is not a reliable data source, but a sequence of consecutive s with enough threshold of unique authorized validators is collectively used for finalize relayed data.
A can be finalized with its anchor or linked block.
Anchor finalization requires:
Link finalization requires:
In case of the anchor and cross-link majority continuity is broken, there's a fail-back method to finalize a by consequently apply each validator applications by relaying governance contraction interaction txs and their signatures. (TODO)
With forward support for off-chain signature service, a can be finalized only with bare signatures provided by the validator in the . (TODO)
Cross link hash is recorded in every header's (exclusive field for Ethash), which is the hash of the block that this header is linked to.
Anchor is recorded in the header's Extra, and only for the cross-link header.
0xFF
0xF0
0xF1
0x01
0x02
The queue validators is sorted alphabetically.