XinFinOrg / XDPoSChain

Customer centric, Hybrid & Interoperable XinFin Network
https://www.xinfin.org
GNU Lesser General Public License v3.0
51 stars 61 forks source link

XDC Network Protocol Upgrade Proposal: Fully Proof-of-Stake (PoS) Network #166

Closed riteshkakkad closed 2 years ago

riteshkakkad commented 2 years ago

Brief Background Early in 2017, XDC Network Founders decided to create a scalable and open-source blockchain infrastructure (a smart contract-based platform) that solved major problems facing networks that relied upon the Proof of Work (PoW) consensus protocol.

Following extensive research and consultations with technology experts, the XDC Network went live on the 1st of June 2019. Immediately after launch, the XDC network helped cut transaction times from a few minutes to two seconds; reduce Gas fees from between $5-$30 to near-zero fees(less than one-millionth of an XDC for most transactions). And, minimize energy consumption by 99%--i.e. XDC mining consumes a mere 0.0000074TWh as compared to 71.12 (TWh) and 20.61 (TWh) needed to mine Bitcoin and Ethereum, respectively.

As well, the XDC network added a KYC layer for its validators, which enabled the identification of masternodes/validators. With this unique feature, the XDC network successfully handled queries from different regulators that had issues with identity and KYC-related compliance requirements.

As of 1st June 2022, the XDC Network completed three years on the Mainnet using XDPoS (XinFin’s Delegated Proof of Stake) consensus protocol.

Since then, there has been an explosion in the usage of the XDC Blockchain Network. A few major growth factors contributing to the surge were: XinFin’s approach to growing the network’s performance and technical specs after collecting opinions from community members; use cases that are based on real-world enterprise, and the network’s proactive approach to solving problems facing the evolving blockchain technology space. And with the XDC network’s smart contract capability and open-source nature, the Network is inherently programmable, and it has become by far the most popular platform for developers to build Decentralized Applications (dApps)

For more insights, here are some recent statistics on the network.

Validator Node or Masternode increased from 3 to 207 (that’s including Backup/Standby nodes). Each validator has to stake 10 Million XDC (i.e. the MIN_STAKE) to become a validator/masternode. On the XDC network,masternode/validators are capped at 5000 Validator Nodes (i.e. the MAX_REGISTERED_VALIDATORS = 5000).

The total value of XDC Coin staked on the network is roughly 2,070,801,888

The total number of blocks created on the XDC network is 47094840.

More than 9500 XRC20 tokens have been deployed.

Following extensive research and deliberations, the XDC team has found out that the XDC Chain is the most suitable chain for implementing various trade finance and retail use cases. Top on the list of retail use cases that can thrive on the XDC chain are projects on: data oracle, storage, NFT marketplaces, ISO 20022 compliant messaging standards, and decentralized exchange (DEX). Many of the real-world DeFi and TradeFinance initiatives have begun to provide real benefits to the XDC community.

As a part of continuous research and development, the XDC team is proposing the next upgrade and seeks opinions from the Public/Community to improve.

Proposal to migrate from Delegated Proof of Stake (DPoS) to a Fully Proof of Stake (PoS) protocol

How does the PoS protocol work?

Under the PoS protocol, a consensus is attained by requiring users to stake a specific amount of their tokens before they can be selected to validate transaction blocks and get rewards for successfully doing so.

To elaborate…

With the PoS protocol, XDC coin owners will validate block transactions based on the amount of XDC the validator/ Masternode stakes. Note: block creators under PoS are called validators. And their role is to check transactions, verify activities, vote on outcomes, and maintain transaction records.

To "buy into" the position of becoming a block creator, validators need only to purchase the sufficient limit of XDC coins or tokens required to become a validator for a PoS blockchain. To the contrary, miners under Proof-of-Work (PoW) protocol have to invest in expensive equipment and incur heavy energy charges to power the mining rigs used to solve complex mathematical equations before they can validate transactions and get rewarded for their work.

What Blockchains are Currently using PoS?

Examples of blockchain networks that currently employ the PoS consensus protocol include XDC Network, Polkadot, Avalanche, and Cardano.

Under the PoS consensus mechanism. The next block validator/block writer on the network is randomly selected, with higher odds being assigned to nodes that have larger stake positions or holders that have staked a higher number of tokens and have held the tokens for a longer period.

Key benefits of Proof-of-Stake include: Reducing the amount of computational work needed to verify blocks and transactions that keep the blockchain system and tokens secure. Slashing transaction costs are incurred when transactions take place. Simplifies the way blocks are verified via the machines of coin owners, thus boosting efficiency. To elaborate, coin owners offer their tokens as a guarantee of the legitimacy of any new transaction they add to the blockchain. These coin owners are called validators.

Currently, what’s XDC’s consensus mechanism?

To become a validator on the XDC network, validators currently need a 10 million XDC stake(i.e. that’s the MIN_STAKE on the network)

Note, other important Masternode parameters on the XDC network:

XDC network’s VALIDATOR_SET_SIZE is currently 108 The EPOCH size is 900 VALIDATOR_REWARD equals: NOS_masternode / TOTAL_REWARD NOS_masternode = 108 AND TOTAL_REWARD = 86400000 XDC + very small Transaction fees REWARDS_TRANSFER: Every next block of epoch WITHDRAWAL_PERIOD: Set of Epoch (1 Epoch == 900 Blocks) for XDC Network.

The system uses verifiable random functions (VRFs) to randomly select 108 candidates. Blocks are validated by more than one validator, and when ⅔ (two-thirds) of the validators verify that the block is accurate (VALIDATOR_SET_SIZE × 2/3), it is finalized and closed. More elaborately, a validator will verify the transactions and add them to a shard block, which requires at least ⅔ (two-thirds) of the 108 validators to attest to. And, once shards are validated and a block created, two-thirds of the validators must agree that the transaction is valid, then the block is closed.

Note: In the event of no proposal and/or a timeout in a round (r − 1), nodes will send a "timeout" message for this round, and the leader of the round (r-1) will gather tH of them into a timeout certificate (TC), so that this round can be dropped from the blockchain.

As well, for each iteration of 900 blocks (called an epoch), a checkpoint block is created. The block---also known as the block signer--- implements the reward under the protocol, which implements reward works. Block signers count the number of signatures sent to the block signer smart contract during the epoch. Rewards are based on the number of signatures linked to a masternode in an epoch.

In the event that a masternode is demoted or intentionally resigns from the masternode, the candidate’s deposits (10 million XDC) are locked for 30 days and can be accessed thereafter.

You may be wondering, what’s the Safety Violation and Forensic monitoring feature (part of the Forensic Monitoring Update) employed by the XDC network?

Well, here’s the monitoring feature in detail…

In the unlikely event that the ratio of Byzantine nodes exceeds ⅓ (one-third), these nodes can collude and create a security violation — either a safety or liveness violation. However, they cannot achieve this without being held accountable and punished, thanks to the protocol’s design

When the adversary corrupts more than ⅓ (one-third) of the master nodes in the BFT committee of an epoch, the adversary can violate the safety and jeopardize the consensus by creating forks - such as two finalized blockchains. However, certain messages need to be signed and sent by the corrupt nodes to successfully jeopardize the consensus mechanism. But, the XDC system can detect the messages, gathering irrefutable evidence of a node or nodes’ misbehavior. Worth noting, messages between nodes are embedded into the blockchain and can be obtained by querying master nodes for forked blockchains. This property of XDPoS 2.0 enables XDC’s safety forensic feature, which can identify as many Byzantine master nodes as possible while obtaining proof from querying as few witnesses as possible.

As well, the process of identifying culpable Byzantine master nodes involves performing appropriate quorum intersections since two quorums of tH ≈ VALIDATOR_SET_SIZE × 2/3 master nodes intersect in at least VALIDATOR_SET_SIZE/3 master nodes. With this approach, the XDC network can identify as many Byzantine master nodes that may have colluded to violate the safety and jeopardize the consensus mechanism by creating forks.

For witnesses, two honest nodes that have access to one of the two conflicting blockchains, respectively, are sufficient as proof. Since non-master nodes also passively monitor the blockchain, they can also serve as witnesses. This implies that as long as there are at least two honest nodes on the XDC network and the adversary wants to create a safety violation for the two nodes, the XDC team can provide evidence of the violation. Once a master node is held culpable by the forensic protocol, the proof is forwarded to XDC Network’s governance committee, initiating appropriate penalty mechanisms.

XDC’s network employs slashing of smart contracts and burning up to 100% of XDC Staked by a validator.

On slashing, the XinFin network employs both off-chain and on-chain slashing mechanisms.

For on-chain slashing, validators that engage in equivocation---the process of signing-off two blocks with the same step---trigger the process. Particularly, when a validator node keys in the wrong KYC details, the contract includes a reportMalicious method. If more than 2/3 of the validators agree on a reportMalicious, an on-chain slashing is executed. This process can burn up to 100% of a validator’s stake.

On the other hand, with off-chain slashing, detection of crafty characters involves a reportBenign functionality. Within a validator's contract is reportBenign, which only validators can call, pass a message, and a block number. Slashing is initiated when more than 2/3 of the Validators agree on the misconduct. Misconduct by validators might include: consistently propagating blocks late and validators being offline for more than 24 hours without notice. Off-chain slashing can be executed on a portion of the stake—say 5%.

Why is the PoS Update important? Having worked with the delegated proof of stake (DPOS) protocol, the XDC team seeks to unlock significant benefits associated with the PoS protocol. These benefits are as follows:

Integrating the Game theory Element:

Game theory is a fundamental mechanism underlying blockchain technology. And, in PoS blockchains, validators and nominators make decisions rationally, trying to maximize their utilities under the stipulated set of rules, and other participants’ decisions and strategies.

For validators in PoS blockchains, key strategies include making decisions on their stake’s size, whether to run a single node or multiple nodes, etc. Nominators on the other hand have to make decisions like how much and which token to stake, which validators to nominate, etc. Payout to validators and nominators depends on each participant’s strategies and the rules guiding how validators are selected and how rewards are distributed.

That’s a classic example of game theory in blockchain.

So, how will the game theory element work with the XDC network?

Upon upgrading to PoS, all Validators/Master nodes on the XDC network will compete with each other to mine the next block and get the reward, therein. As well, to become validators, each masternode has to stake more XDC, and this step increases loyalty towards the network. This Game theory algorithm will help to increase competition, loyalty, and help to improve the network’s health, and boost decentralization. At the same time, slashing (using a function called reportMalicious) can lead to the burning of 100% of a validator’s XDC stake in case of malicious behaviors.

Noting that validators seek to maximize gains by making rational decisions and with the reward and penalty mechanism in place, malicious acts are highly unlikely. Thus, the game theory element introduced by the PoS upgrade will help improve the decentralized network.

Give Masternode holders the freedom to make decisions

With the upgrade to PoS, XDCs’ masternode holders will have the freedom to decide the staking value of XDC. To illustrate, a masternode holder receiving an annual reward of 800000 XDC for the minimum stake size may decide to stake more, exceeding the 10 million XDC mark as the network won't cap the limit at 10million XDC. This feature will help to improve the network's ability to adjust to changes in Demand or Supply of masternodes in various market situations.

And, will the upgrade change the rewards/stake?

Well, the current annual XDC reward of 86400000 XDC for 108 masternodes remains unchanged. However, with the PoS upgrade, masternode holders will have the freedom to stake more tokens to increase their chances of participating in the block validation process.

Optimize Performance

Upgrading to PoS will help improve the effectiveness of the network’s Byzantine Fault Tolerance (BFT) mechanism since validators will make decisions that greatly improve their stake. Noting that selecting a validator depends on their stake and the randomness is selection, adopting PoS will help improve performance since selected validators can immediately confirm a transaction if they agree about a bloc’s transactions. As well, due to the randomness in selecting validators, any node can participate in block validation and can share the rewards therein. With lack of a variance in which nodes earn rewards, all masternodes in the PoS network feel motivated to participate actively in the validation process, avoiding network glitches cause by delays by validators.

On the other hand, upgrading to PoS and leveraging the BFT will help optimize XDC network’s smart contract functionality, improving its scalability. To elaborate, BFT mechanisms guarantee speed and consistency, since validators have to agree before a block is generated. This will ensure faster and consistent settlement finality, further reducing transaction settlement times and loads on the network. With reduced loads, the XDC network will cut energy consumption further, hence improve its scalability.

Increase the number of Masternodes /Validators

Currently, the stable network has 108 Masternode/Validators. With the upgrade, the network’s team proposes to increase the numbers to 150 Masternodes. However, this upgrade requires a hard fork the XDC network will require all validators to participate in the upgrade.

So, why doesn't the network propose more than 150 masternodes?

Well, XDPoS Network started with 18 masternode/validators and increased the number to 108 after various tests on performance, network stability, and scalability of real-time transactions. Thus, the XDC’s team is proposing to cap masternode numbers at 150 since they will be adequate for the network’s performance, stability, and scalability.

Bottom-Line The XDC network values feedback and opinions from XDC community members and Masternode Holders. And, it will be great to get your views on the proposal to migrate from a Delegated Proof of Stake (DPoS) blockchain to a fully Proof of Stake (PoS) blockchain. Another proposal is to update the total masternode from 108 to 130-150 masternode.

Following, the community and masternode holder’s feedback, the XDC community will decide on an appropriate update/upgrade plan. We also welcome other feedback and comments on our developer's forum to keep the XDC network more decentralized and to get more use case adoption.

XDC Network tools and documents for reference : https://xinfin.org/xdc-chain-network-tools-and-documents

Github Links: XinFin Github , XDC Foundation Github Register on XDC.Dev for documented instructions and to discuss with developers on any issues.

MDW8484 commented 2 years ago

Will KYC requirements for new masternodes remain the same?

riteshkakkad commented 2 years ago

Will KYC requirements for new masternodes remain the same?

yes. KYC will reamin same for the masternode.