-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add incentive for voter #1848
Add incentive for voter #1848
Conversation
I'll add more ut later. |
when sync with the latest block index=160,with pre-configured with four committee members.
corresponding to the committee member account:
the consensus wallet asset as below:
Result |
var pubkey = committee[engine.Snapshot.PersistingBlock.Index % ProtocolSettings.Default.CommitteeMembersCount]; | ||
var account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash(); | ||
GAS.Mint(engine, account, gasPerBlock * CommitteeRewardRatio / 100); | ||
|
||
// Record the cumulative reward of the voters of each committee | ||
|
||
var voterRewardPerCommittee = gasPerBlock * VoterRewardRatio / 100 / (ProtocolSettings.Default.CommitteeMembersCount + ProtocolSettings.Default.ValidatorsCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validators are included inside the Committee, they will be rewarded twice as committee and as validator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, as dictated in the description:
The voters who voted for a consensus node are assigned 2/28 of this part according to the voting weight, and the voters who voted for a committee member (non-consensus node) are assigned 1/28 of this part according to the voting weight. (Implemented by this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is mainly used to ensure that the validators' votes are concentrated and not too scattered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but we've got rounding error even here:
> 500000000.0*85/100/(21+7)
=> 15178571.42857143
Then it only gets worse with votes/neo amount.
That's right. @cloud8little |
@erikzhang @Tommo-L will the genesis block(index=0) generate gas? if yes, will it also be used to reward the committees/neo holders? #1845 (comment) Currently, the genesis block will only reward neo holders but not committee. I think it's okay. What do you think? And this is why Finally four committee members reward totally 10gas * 4 = 40 gas, while there is total 161 blocks, which should be 161 blocks * 5 gas/block * 5% = 40.25 gas, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tommo-L did you tested this lines ?
https://coveralls.io/builds/34525125/source?filename=src%2Fneo%2FSmartContract%2FNative%2FTokens%2FNeoToken.cs#L113
I am not sure if it could throw a Collection was modified
exception when the entry was added in the same execution.
neo/src/neo/IO/Caching/DataCache.cs
Lines 121 to 122 in 7d3a4a2
dictionary.Remove(key); | |
changeSet.Remove(key); |
It'll not happen. As |
Co-authored-by: Erik Zhang <erik@neo.org>
Merge? |
Was changed in neo-project/neo#1848. Affects storage dumps.
Was changed in neo-project/neo#1848. Affects storage dumps.
Was changed in neo-project/neo#1848. Affects storage dumps.
* add reward key * incentive for voter * optimize * optimize * optimize * fix CalculateBonus and add ut * format * Item2 -> Votes * Move fields * Fix GetCommitteeVotes() * specify variable name * Remove double ToArray * fix ut * remove * fix * fix * remove useless code * optimize * fix * format * Add using to dispose enumerators * Update NeoToken.cs * Update NeoToken.cs * fix * fix CalculateBonus * Usng asending order * Update NeoToken.cs * fix * optimize findrange * format * optimize * Update NeoToken.cs * fix * format * Use GetCommitteeFromCache * Ensure registered * fix PostPersist * Update NeoToken.cs * cache committee votes * cache committee * Update src/neo/Ledger/StorageItem.cs Co-authored-by: Erik Zhang <erik@neo.org> * fix PostPersist * fix ShouldRefreshCommittee & optimize PostPersist * add CommitteeEpoch * fix CalculateBonus * fix PostPersist * optimize CalculateBonus * optimize PostPersist * Update NeoToken.cs * add comments for trigger github action * Allow standby can be voted * optimize * rename local variable * Optimize Unregister Candidate * Revert * add ut * fix ut * format * Conflicts * Update src/neo/SmartContract/Native/Tokens/NeoToken.cs Co-authored-by: Erik Zhang <erik@neo.org> Co-authored-by: Tommo-L <luchuan@neo.org> Co-authored-by: Erik Zhang <erik@neo.org> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Shargon <shargon@gmail.com>
* add reward key * incentive for voter * optimize * optimize * optimize * fix CalculateBonus and add ut * format * Item2 -> Votes * Move fields * Fix GetCommitteeVotes() * specify variable name * Remove double ToArray * fix ut * remove * fix * fix * remove useless code * optimize * fix * format * Add using to dispose enumerators * Update NeoToken.cs * Update NeoToken.cs * fix * fix CalculateBonus * Usng asending order * Update NeoToken.cs * fix * optimize findrange * format * optimize * Update NeoToken.cs * fix * format * Use GetCommitteeFromCache * Ensure registered * fix PostPersist * Update NeoToken.cs * cache committee votes * cache committee * Update src/neo/Ledger/StorageItem.cs Co-authored-by: Erik Zhang <erik@neo.org> * fix PostPersist * fix ShouldRefreshCommittee & optimize PostPersist * add CommitteeEpoch * fix CalculateBonus * fix PostPersist * optimize CalculateBonus * optimize PostPersist * Update NeoToken.cs * add comments for trigger github action * Allow standby can be voted * optimize * rename local variable * Optimize Unregister Candidate * Revert * add ut * fix ut * format * Conflicts * Update src/neo/SmartContract/Native/Tokens/NeoToken.cs Co-authored-by: Erik Zhang <erik@neo.org> Co-authored-by: Tommo-L <luchuan@neo.org> Co-authored-by: Erik Zhang <erik@neo.org> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Shargon <shargon@gmail.com>
The additional GAS allocation is as follows: