You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
QIP-25
Layer: Blockchain Protocol
Title: Offline Staking
Author: Jackson Belove jb395official@gmail.com
Comments-Summary: Proposing block and transaction protocol modifications to provide
offline staking which will allow address delegation through a smart contract to an
online node which can stake the UTXOs for that address, for a fee.
Comments-URI: https://github.com/qtumproject/qips/issues/25
Status: Draft
Created: 2020-04-01
License: GPLv3
Abstract
This QIP describes a blockchain protocol change and smart contract implementation that allows the delegation of offline addresses to online nodes providing staking services.
From launch, Qtum has allowed Proof of Stake consensus (“staking”) only from online nodes that secure and operate the blockchain. This protocol change will allow addresses from offline wallets to securely delegate their UTXOs (Unspent Transaction Outputs) to an online node which will operate Proof of Stake consensus for the UTXOs of that offline address. Delegation of the address will be accomplished through a smart contract. New blockchain header and transaction protocols will provide a way to validate the delegation and support a real-time fee payment to the online node. The Qtum Core node and light clients will provide an easy way to assign and unassign the delegation through a smart contract call. The delegation will be non-custodial (the offline address owner will retain control of private keys) and the delegated UTXOs will not be locked in any way.
Motivation
One of the most popular Qtum community requests has been for offline staking. From launch, Qtum Mainnet required online staking using a Qtum Core wallet full node. These staking wallets sync the entire Qtum blockchain and must run online 24/7 to operate and secure the network and qualify to be block publishers.
QTUM holders that did not want to run a full node, or had security concerns, could not participate in staking.
A secondary concern for community members was the resources and power to run a full node for staking. Best security practice is to stake from a dedicated machine that is not used for email and surfing the web, because of malware risk. This was a resource issue, especially for small holders who were considering the power cost for running a computer 24/7.
Although not difficult to run a Qtum full node 24/7 this does take dedicated resources, either on-premise or in the cloud, and does take some continuing operations and maintenance for node upgrades, hard forks, operating system upgrades, etc.
Definitions
''Offline Staking'' the ability to stake UTXOs (coins) from an offline wallet address by delegating that address to an online Super Staker node.
''Solo Staker'' a traditional online full node Qtum Core staking wallet staking its UTXOs.
''Staking Services'' is the service provided by a node which accepts delegated addresses, and stakes the coins for those addresses, for a fee.
''StakingServiceFee'' the fee in percent 0 – 100 for staking services. Set by each delegator, the fee they agree to pay.
''Super Staker'' a Qtum Core wallet node running in a mode to provide staking services for delegated addresses.
Specification
Offline Staking
The high-level design goals for offline staking are:
Non-custodial staking solution, the user retains exclusive control of their private keys.
UTXOs for delegated address are not locked and can be sent or solo staked at any time.
Delegated UTXOs follow the pattern of 500 blocks maturity staking period.
Users can set the fee they will pay for the staking services provider, who may accept that fee.
Coinstake protocol modification to provide instant payout of block rewards with split for fee payment.
Staking services providers must be online and commit a stake to obviate the “nothing at stake” problem.
Develop multiple client solutions with easy to use delegation/undelegation assignment.
Since offline staking will delegate the UTXO set of an address to be staked by another online node, "estimated time" to a block reward will work as currently (with variance). Delegated staking is not pool staking.
Coinstake Vouts
The coinstake is the 2nd transaction in every block which stakes UTXOs and pays the block reward composed of 1) newly-minted QTUM for the subsidy (currently 4.0 QTUM) and 2) any transaction fees and Gas for the block.
For offline staking the block reward is paid:
100% – StakingServicesFee to the address delegated
StakingServicesFee to the Super Staker address
For offline staking the coinstake transaction protocol shall be modified as shown in the following example where Alice has delegated her offline address to Bob, who is providing staking services. The column "Changed?" indicates a change from the current protocol.
Vout
Changed?
Description
0
No
Empty output
1
Yes
Pays block reward to Alice
2
Yes
Pays fee for block reward to Bob
To give a numerical example, suppose there was an offline staking user Alice paying a 20% fee delegated to the staking services provider Bob, and there was an offline staking user Carol paying a 15% fee to staking services provider David, and that there were 0.1 QTUM in transaction fees and Gas for each of their block rewards. The total block reward for each block would be 4.1 QTUM. For this scenario the coinstake Vouts would be:
Alice's block reward:
Vout
Value
Description
1
3.280
Pay 80% to Alice
2
0.820
Pay 20% (StakingServicesFee) to Bob
Carol's block reward:
Vout
Value
Description
1
3.485
Pay 85% to Carol
2
0.615
Pay 15% (StakingServicesFee) to David
Notes:
The coinstake transaction pays no fees for itself.
If the fee is set to 0 or 100 (percent) there would be a single output for 3 (a zero Vout would not be sent).
These examples for illustration purposes only. Qtum Mutualized Proof of Stake currently spreads these block reward payments over 509 blocks.
New RPC Commands
Remote Procedure Calls (RPC) are issued to a running Super Staker node. These commands may be issued via RPC calls, the Qtum-Qt GUI wallet console, or for the qtumd daemon server wallet via the qtum-cli command-line interface application. New commands shall be added to Qtum Core to manage offline staking as follows.
Command
Description
setdelegateforaddress
create an OP_SENDER transaction to call addDelegation() function of the contract
removedelegationforaddress
create an OP_SENDER transaction to call removeDelegation() function of the contract
getdelegationsforstaker
should return the delegation info for and address (using callcontract then formatting the output)
getdelegationinfoforaddress
should return the delegation info for and address (using callcontract then formatting the output)
splitutxosforaddress
Used to split UTXOs, with one argument which is the split size. This will replace sendmanywithdupes which can be very long.
New Command-Line Parameters
Command-line parameters are read by the Super Staker when it launches. These commands are listed on the command line, for example, launching the qtumd daemon server wallet:
./qtumd -parameter1 -parameter2=nn -parameter3=nn
The following command line parameters will be added:
Command
Description
-delegationsaddress
The delegations smart contract address
-offlinestakingheight
The block height to active offline staking
-stakingminfee
The minimum fee the Super Staker will accept in percent, e.g,, 15
-stakingminutxovalue
The minimum size of delegated UTXOs that will be staked, e.g., 50
-superstaking
Operate Qtum Core as a Super Staker
Node Operation – Super Staker
The Super Staker will be a Qtum Core wallet (full node) configured to stake delegated address UTXOs. The configuration and new commands will provide the following operation:
Get a list of delegated addresses using a new command getdelegationsforstaker.
Get a list of delegated UTXOs for the address using a new command getaddressutxos.
Sort the list of UTXOs and select according to new commands for minimum value stakingminutxovalue and minimum staking fee stakingminfee.
Run Qtum Proof of Stake algorithm to identify kernel solutions and publish blocks.
When a kernel solution is found, validate the current delegation assignment and produce a block with the coinstake fee payment as described above for Alice and Bob.
Publish the block and commit a UTXO stake owned by the Super Staker.
Client Operation - Wallets
Clients are wallets operated to make the delegation assignment. The clients must provide an easy intuitive way to delegate their UTXO address to a Super Staker providing staking services.
As an example, (final design TBD) the Offline Staking page could look something like this:
)
Client offline staking delegation capability will require smart contract calls, which the Qtum wallets currently have as a general capability. Initially this simplified offline staking capability will be provided using the Qtum Core wallet, followed by the Qtum Web Wallet and Qtum Android mobile wallet. 3rd party wallets may also provide this capability if they integrate smart contract call functionality.
Note that the Qtum Web Wallet provides an option to “Restore from Ledger” and when updated to offer the simplified Offline Staking page will allow offline staking delegation from Ledger hardware wallet addresses.
Delegations Smart Contract
A smart contract will be used to manage delegation assignments, with the main role to add/update delegation information, remove a delegation, and get the delegation for a specific address.
The smart contract will maintain a table of delegation information:
<user address to be delegated>
<super staker address to be delegated to>
delegation fee the user agrees to pay>
<delegation block height>
Continuing the example above, the delegation table would show
User Address
Super Staker Address
Fee
Block Height
Q_Alice_Address
Q_Bob_Address
20
600,000
Q_Carol_Address
Q_David_Address
15
601,000
Compatibility
Because offline staking requires block and transaction protocol changes, the node and clients will not be backward compatible and will require a hard fork for implementation. It would be possible to run a separate test network in advance of deployment of the new nodes and clients, where they should follow the pattern of the Qtum Core v0.18.1 hard fork, i.e., activation on Testnet followed by activation on Mainnet.
Nongoals
The launch version of offline staking shall be a minimum viable product with a focus on security and simplicity. As offline staking gains maturity, and based on further community requests, additional functionality can be added in later updates.
The following features are nongoals, and will not be provided in the initial release.
Delegation from multisignature addresses.
Delegation of SegWit addresses (p2sh-segwit or bech32). Only legacy addresses (beginning with a “Q”) will be supported.
Staking of UTXOs owned by the staking services node.
Recombination of small UTXOs by the staking services node.
Recombination of small UTXOs for the delegated address. This must be done manually.
Acknowledgments
The author would like to thank the Qtum development team for their design and review of Qtum offline staking, and especially Neil Mahi for the original design.
Abstract
This QIP describes a blockchain protocol change and smart contract implementation that allows the delegation of offline addresses to online nodes providing staking services.
From launch, Qtum has allowed Proof of Stake consensus (“staking”) only from online nodes that secure and operate the blockchain. This protocol change will allow addresses from offline wallets to securely delegate their UTXOs (Unspent Transaction Outputs) to an online node which will operate Proof of Stake consensus for the UTXOs of that offline address. Delegation of the address will be accomplished through a smart contract. New blockchain header and transaction protocols will provide a way to validate the delegation and support a real-time fee payment to the online node. The Qtum Core node and light clients will provide an easy way to assign and unassign the delegation through a smart contract call. The delegation will be non-custodial (the offline address owner will retain control of private keys) and the delegated UTXOs will not be locked in any way.
Motivation
One of the most popular Qtum community requests has been for offline staking. From launch, Qtum Mainnet required online staking using a Qtum Core wallet full node. These staking wallets sync the entire Qtum blockchain and must run online 24/7 to operate and secure the network and qualify to be block publishers.
QTUM holders that did not want to run a full node, or had security concerns, could not participate in staking.
A secondary concern for community members was the resources and power to run a full node for staking. Best security practice is to stake from a dedicated machine that is not used for email and surfing the web, because of malware risk. This was a resource issue, especially for small holders who were considering the power cost for running a computer 24/7.
Although not difficult to run a Qtum full node 24/7 this does take dedicated resources, either on-premise or in the cloud, and does take some continuing operations and maintenance for node upgrades, hard forks, operating system upgrades, etc.
Definitions
''Offline Staking'' the ability to stake UTXOs (coins) from an offline wallet address by delegating that address to an online Super Staker node.
''Solo Staker'' a traditional online full node Qtum Core staking wallet staking its UTXOs.
''Staking Services'' is the service provided by a node which accepts delegated addresses, and stakes the coins for those addresses, for a fee.
''StakingServiceFee'' the fee in percent 0 – 100 for staking services. Set by each delegator, the fee they agree to pay.
''Super Staker'' a Qtum Core wallet node running in a mode to provide staking services for delegated addresses.
Specification
Offline Staking
The high-level design goals for offline staking are:
Since offline staking will delegate the UTXO set of an address to be staked by another online node, "estimated time" to a block reward will work as currently (with variance). Delegated staking is not pool staking.
Coinstake Vouts
The coinstake is the 2nd transaction in every block which stakes UTXOs and pays the block reward composed of 1) newly-minted QTUM for the subsidy (currently 4.0 QTUM) and 2) any transaction fees and Gas for the block.
For offline staking the block reward is paid:
100% – StakingServicesFee
to the address delegatedStakingServicesFee
to the Super Staker addressFor offline staking the coinstake transaction protocol shall be modified as shown in the following example where Alice has delegated her offline address to Bob, who is providing staking services. The column "Changed?" indicates a change from the current protocol.
To give a numerical example, suppose there was an offline staking user Alice paying a 20% fee delegated to the staking services provider Bob, and there was an offline staking user Carol paying a 15% fee to staking services provider David, and that there were 0.1 QTUM in transaction fees and Gas for each of their block rewards. The total block reward for each block would be 4.1 QTUM. For this scenario the coinstake Vouts would be:
Alice's block reward:
Carol's block reward:
Notes:
The coinstake transaction pays no fees for itself.
If the fee is set to 0 or 100 (percent) there would be a single output for 3 (a zero Vout would not be sent).
These examples for illustration purposes only. Qtum Mutualized Proof of Stake currently spreads these block reward payments over 509 blocks.
New RPC Commands
Remote Procedure Calls (RPC) are issued to a running Super Staker node. These commands may be issued via RPC calls, the Qtum-Qt GUI wallet console, or for the qtumd daemon server wallet via the qtum-cli command-line interface application. New commands shall be added to Qtum Core to manage offline staking as follows.
setdelegateforaddress
addDelegation()
function of the contractremovedelegationforaddress
OP_SENDER
transaction to callremoveDelegation()
function of the contractgetdelegationsforstaker
getdelegationinfoforaddress
splitutxosforaddress
New Command-Line Parameters
Command-line parameters are read by the Super Staker when it launches. These commands are listed on the command line, for example, launching the qtumd daemon server wallet:
./qtumd -parameter1 -parameter2=nn -parameter3=nn
The following command line parameters will be added:
-delegationsaddress
-offlinestakingheight
-stakingminfee
-stakingminutxovalue
-superstaking
Node Operation – Super Staker
The Super Staker will be a Qtum Core wallet (full node) configured to stake delegated address UTXOs. The configuration and new commands will provide the following operation:
Get a list of delegated addresses using a new command
getdelegationsforstaker
.Get a list of delegated UTXOs for the address using a new command
getaddressutxos
.Sort the list of UTXOs and select according to new commands for minimum value
stakingminutxovalue
and minimum staking feestakingminfee
.Run Qtum Proof of Stake algorithm to identify kernel solutions and publish blocks.
When a kernel solution is found, validate the current delegation assignment and produce a block with the coinstake fee payment as described above for Alice and Bob.
Publish the block and commit a UTXO stake owned by the Super Staker.
Client Operation - Wallets
Clients are wallets operated to make the delegation assignment. The clients must provide an easy intuitive way to delegate their UTXO address to a Super Staker providing staking services.
As an example, (final design TBD) the Offline Staking page could look something like this:
Client offline staking delegation capability will require smart contract calls, which the Qtum wallets currently have as a general capability. Initially this simplified offline staking capability will be provided using the Qtum Core wallet, followed by the Qtum Web Wallet and Qtum Android mobile wallet. 3rd party wallets may also provide this capability if they integrate smart contract call functionality.
Note that the Qtum Web Wallet provides an option to “Restore from Ledger” and when updated to offer the simplified Offline Staking page will allow offline staking delegation from Ledger hardware wallet addresses.
Delegations Smart Contract
A smart contract will be used to manage delegation assignments, with the main role to add/update delegation information, remove a delegation, and get the delegation for a specific address.
The smart contract will maintain a table of delegation information:
<user address to be delegated>
<super staker address to be delegated to>
delegation fee the user agrees to pay>
<delegation block height>
Continuing the example above, the delegation table would show
Compatibility
Because offline staking requires block and transaction protocol changes, the node and clients will not be backward compatible and will require a hard fork for implementation. It would be possible to run a separate test network in advance of deployment of the new nodes and clients, where they should follow the pattern of the Qtum Core v0.18.1 hard fork, i.e., activation on Testnet followed by activation on Mainnet.
Nongoals
The launch version of offline staking shall be a minimum viable product with a focus on security and simplicity. As offline staking gains maturity, and based on further community requests, additional functionality can be added in later updates.
The following features are nongoals, and will not be provided in the initial release.
Acknowledgments
The author would like to thank the Qtum development team for their design and review of Qtum offline staking, and especially Neil Mahi for the original design.
References
Copyright
Qtum and this QIP are licensed under GNU General Public License v3.
The text was updated successfully, but these errors were encountered: