EOSIO.SG, Singapore based public chain technical BP operation team officially joins HashQuark Open Staking Platform (OSP) Validator Enablement Program.The HashQuark OSP Validator Enablement Program is open to individuals and teams with industry or comm…
Dear all,We are happy to announce that FINDEX, our first incubator project, will operate independently from 1st January 2019.Over the past 6 months, we assisted the team at FINDEX to achieve several development milestones and supported the expansion of…
Update: 21st Nov 2018, 04:00 UTC, a claim from GiggleAll was received.Based on his story, the transaction was performed using the ‘gizdkmjvhege’ testing account on test net and subsequently posted on Github. This happened during the exploit.Therefore, …
Dear EOS Community,This is an official announcement by EOSIO.SG, a Singapore-based BP. Since conception, we have and will always continue to dedicate ourselves to contributing to the EOS ecosystem and are honoured to be part of the BP community.Account…
FINDEX is a community-governing decentralised exchange on EOS mainnet, it doesn’t require users to deposit token into the exchange and can provide a swift & smooth experience similar to centralised exchange. On 24th July 2018, EOSIO.SG attended the…
The main net of EOS has been launched for almost one month, and EOSIO.SG hosted a meetup in the WeWork@Robinson, Singapore on 4th July to discuss the tech and other concerned topics. The event attracted the EOS developers, tech fans and enthusiasts to …
After almost 10 days of hard work by our dedicated developers, we are pleased to announce the launch of our Voting Portal today.Based on our understanding of the voting feature alone with its relevant source code, we built this testing portal to help e…
System Contract Part #2 — Voting Process
In eos network, eosio.system contract enable users to 1) stake tokens, and then vote on producers (or worker proposals), 2) proxy their voting influence to other users, 3) register producers, 4) claim producer rewards, 5) delegate resources (net, cpu & ram) and push other necessary actions to keep blockchain system running.
In this series, we will go through What is the contract, What are included in the contract and How the contract can be used.
Our last post discussed the ‘Block Producer Rewards’, in this article we will talk about voting process.
In this article, we will be discussing detailed flows/steps on Producer Registration, Token Staking, Voting on BP , and Changing/Withdrawing Vote successively.
All codes present are based on commit of 44e7d3e
- Token holders have to stake with their tokens on net and cpu for voting
- On voting, all staked assets will convert to x amount of weighted votes, which can be used to vote up to 30 producers and each selected producer will get x amount of votes repectively
- Refunding process takes up to 3 days to reflect the unstaked tokens in available token balance
- Newer votes possess higher voting weights
Accounts should register themselves as producer first before they can be voted. This process is done by pushing a system_contract::regproduceraction.
- The core logic code below is to insert or replace producers’ configurations (i.e. public key & parameters) into producerinfo table.
*This part of code is under rapid development, we will keep updating it if significant changes are found.
Token holders can only vote after they have staked their tokens on net and cpu. Staking process is done by pushing a system_contract::delegatebwaction. Inside delegatebw action, voter’s tokens are staked and cannot be transferred until refunded.
- If a user has not staked before, insert a record for this account in the table deltable. If a user has staked, add newly amount to the existing amount.
- Set resource limits for stake receiver. Transfer corresponding amount as stake to a public account eosio.
3. Update voter’s staked amount.
- Find the voter from voters table, if not exist, insert a new record of this voter.
- Add newly delegated stake into the voter’s staked attribute.
- Call voteproducer action to update vote results. This means if the push sender has voted before, on new delegatebw action, votes will be updated for last voting producers (or lasting voting proxy).
****Note that user can also delegate net & cpu to other accounts, making resource transfer to be possible. We will talk about user resources in depth in the upcoming blog.***
Vote On Producer / Proxy
Stake holders (token holders who have their tokens staked) can vote for producers (or proxy, who will vote on behalf of push sender), all stakes will convert to weighted x votes and then add up to 30 producers by x votes.
*Leaving proxy arguments to be empty
- Producers to be vote must be given in order;
- Producers to be vote must be registered;
- Producers to be vote must be active.
2. Calculate current vote weight based on the following formula:
*The weight increasing could be treated as a linear growing with time within a short period.
If the voter is a proxy, proxied_vote_weight of the voter will also be updated.
- Reduce last_vote_weight (if ever), and then add current vote weight.
- Create a relation between voting producer and vote weight.
- Deduct last voting weight from voting producers.
- Add each voting producer’s vote weight by the new weight.
2. Record voting results.
- Modify voters table, update vote weight & voting producers (or proxy) respectively.
- Modify producerinfo table, update producer’s votes.
*Leaving producers arguments to be empty
An account marked as a proxy can vote with the weight of other accounts which have selected it as a proxy. Other accounts must refresh their voteproducer to update the proxy’s weight.
- Proxy to be vote must have registered to be a proxy by pushing action system_contract::regproxy.
- Proxy and producers cannot be voted at the same time.
2. Calculate current vote weight, same as above.
3. Update proxy’s vote weight
- Deduct last voting weight from the voting proxy.
- Add each voting proxy’s vote weight by the new amount.
Voters are able to change voted producers (or proxy) by pushing voteproducer actions again, details have been discussed in the previous section.
Votes Withdraw (Unstake)
Voters can withdraw their votes by pushing by pushing system_contract::undelegatebw actions with any amount that is no bigger than the net & cpu been staked & delegated. Undelegated stakes will be available for system_contract::refund after 3 days.
- Decrease refunding amount from voter’s staked column of votertable.
- Update totals_tbl table and update resource limits for the account.
- Create refund request.
- Update refunds table with unstaked amount
- If user undelegate many times within a short period of time, the last undelegating time will be recorded (this time will be used for calculating the available refunding time).
4. Create (or replace) a deferred system_contract::refund transaction & update voting results.
- Push a deferred transaction.
- refund_delay = 3*24*3600, i.e. 3 days.
- Call voteproducer to deduct corresponding votes from voted producers.
- Token owner can only vote after they staked their tokens on net & cpu.
- During voting action, all stakes of the voter will convert into x weighted votes, and every voted producer (up to 30) is going to get equivalent x weighted votes.
- Newer votes count more than older votes, the weight grows approximately linearly.
- Users can undelegate their stakes and have to wait up to 3 days before they can re-allocate this amount of tokens.
In the next article, we are going to talk about some detailed implementation about user resources, including delegate cpu & net, buy & sell ram, new account, producer voting and proxy related stuff.