Submitting Your Vote as Validator
Once you have either 100k PI ready to stake for an individual node, or have registered as a Validator Candidate and 100k PI delegated, you are ready to submit your vote as a validator.
You can submit your vote in the second phase of each Epoch, from 75% to 85% of the Epoch.
Phase
Block Number
What you can do
0% ~ 75%
start_block ~ vote_start_block - 1
apply candidates and delegate
75% ~ 85%
vote_start_block ~ vote_end_block
vote
85% ~ 95%
reveal_start_block ~ reveal_end_block
reveal vote
95% ~ 100%
reveal_end_block + 1 ~ end_block
check next epoch’s info
There are three phases to submitting your vote. Getting your variables, generating the vote hash, then sending the vote hash as a transaction.
Preparing Your Variables
In order to submit your Vote, you will need your address, BLS public key, and the amount you are staking (by yourself or with delegations) with your node.
BLS Public Key
Suppose you have a BLS key file, priv_validator.json
, that looks like this:
The consensus_pub_key
is what you will need. From the example above:
Staking Value
You will also need the amount you are staking. This part is a bit more tricky as we need to convert your balance or total balance (balance + delegated balance) into p-wei and then convert it from decimal to hex. There are many ways to do this, but for this guide, we will try to simplify it.
For this purpose, we will use the RPC to query for your full balance. To do this, we will use:
eth_getFullBalance
Returns the overall balance of the account of a given address.
Parameters
from
: address, 20 Bytes - address to check for balance.blockNumber
: QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending"fullDetail
: Boolean - If true it returns the full detail of proxied/reward object under this address
Returns
balance
: QUANTITY - integer of the current balance in p-wei.total_delegateBalance
: QUANTITY - total delegate balance in p-wei to other addresstotal_depositBalance
: QUANTITY - deposit balance in p-wei for Validator Staketotal_depositProxiedBalance
: QUANTITY - total deposit proxied balance in p-wei for Validator Staketotal_pendingRefundBalance
: QUANTITY - total pending refund balance in p-wei which will be return to delegate at the end of Current Epochtotal_proxiedBalance
: QUANTITY - total proxied balance in p-wei delegate from other addresstotal_rewardBalance
: QUANTITY - total pending reward balance in p-wei of this addressproxied_detail
: Object - detail record of each address's proxied data, including proxied balance, deposit proxied balance and pending refund balancereward_detail
: Object - detail record of this address's reward data, including how much balance in p-wei will be given at the end of each epoch
Example
Where your_address
is the node address that you are registering. You will also notice that at the end of the call, the curl response is piped " |
" into jq
which makes the output much more readable.
This will output something like the below:
If you are a self staked node without delegations, the value you will use for your vote is the total_delegateBalance
, which is just the balance within the wallet:
If you are a Candidate node with delegations, the value you will use for your vote is the total_depositProxiedBalance
, which is the balance within the wallet + the sum of the delegations:
If you convert these values from hex to decimal, you will find that it agrees with the numbers in PIScan, multiplied by 1000000000000000000. For more on FullBalance, see here.
Generating Vote Hash
To generate the vote hash, you will use the Javascript Console. Navigate into the pchain
directory.
And attach to the console:
Once you are in the console, we will set all the variables for the getVoteHash
function:
Where each value is the value associated with your node address (without 0x prefix), BLS public key, and amount from above. The salt
is just a random string that is used to make the output hash safe from others being able to determine the votes and those that submitted them. Each one will return undefined
.
Please note each of these values will be needed when you reveal your vote in order for it to be a successful vote.
Running the web3.getVoteHash()
function with those variables as input will generate the vote hash.
Take note of this as it will be needed in the next step. You can then exit the console with exit
.
Sending Vote Hash Transaction
Now that you have your vote hash, you are ready to send it with the RPC, with the tdm_voteNextEpoch
function:
Where address
is the node address you are registering and vote_hash
is the hash you just generated. Using the example above:
If successful, this will return a transaction hash that can be checked in PIScan for success.
The next step will be to reveal the vote at the 85% - 95% period of the epoch.
Last updated