Eos's super-node election and super-node voting are all around accounts. The voting function of eosio.system is integrated into the command of cleos system, and you can easily use the command line tool to operate.
Voting is divided into two roles: voting account and candidate node account. If they want to vote/be elected, they need to take the following steps:
Next, I will show you the specific steps:
1. Mortgaged EOS for cpu and net, and only mortgaged EOS can be used for voting.
The delegatebw command can specify which account has EOS and which account will use the mortgaged resources.
2. This account is registered as a super node candidate account so that other accounts can vote for it.
To register the candidate account of the super node, you need to provide the public key, which will be used for signature verification after being elected as the super node.
3. Vote for the super node candidate account.
It can be seen that voter2 has successfully voted for bp 1.
Let's take a look at the detailed explanation of the voteproducer command. Cleos system voteproducer prods is a command sent directly to super nodes, which can specify voting accounts and send them to multiple super node candidate accounts at one time. Account names need to be sorted alphabetically from small to large, with a maximum of 30 accounts.
When the voting account wants to cancel voting, it only needs to redeem the pledged EOS, and the redemption period is 3 days.
Next, I will show you the steps of redemption:
1. To cancel the mortgage, you can use the cleos system undelegatebw command, which is similar to the delegatebw command.
My private chain changed the redemption period to 3 minutes, and you can see the undelegatebw command, which called the refund method internally, and redeemed the EOS pledged in the account after 33 minutes. I'll talk about the specific source code details later.
The source code of delegatebw/undelegatebw essentially uses the method of changebw.
Changebw will do the following:
The system will judge whether the operation is delegatebw or undelegatebw, and whether the account is delegatebw. The transfer parameter is true, which means that the account from the receiver is different, EOS resources are mortgaged to the receiver, and EOS ownership is transferred together.
For the update of the refund form, there are different operations according to different situations:
The undelegatebw method mentioned above, when EOS needs to be redeemed, will trigger the defer transaction that will take effect three days later, and this transaction will trigger the refund method to redeem EOS.
The method will determine whether the request _ time+ refund _delay in the refund table is less than the current time, and the redemption operation can only be performed if it is less than the current time. Request_time The time to update the refund form of undelegatebw.
The source code of the voting operation essentially uses the update_votes method.
This account can be registered as a super node candidate account or a proxy account proxy. The proxy account can centralize the voting rights of ordinary accounts instead of ordinary accounts.
Before voting, a series of pre-checks should be conducted, such as:
In order to encourage users to vote carefully, EOS introduced the concept of voting weight. The voting weight will decay with the passage of time, and when the user triggers the voting operation again, the voting weight will be updated with the new weight. Therefore, users need to re-vote for their favorite super nodes regularly to ensure that their voting effectiveness will not be attenuated.
This paper introduces the operation and source code of eos voting and resource pledge, and then introduces the related functions and source code realization of eosio.system domain name auction, so please pay attention!