Skip to content
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

Fix incentive for committee #1884

Merged
merged 11 commits into from
Sep 6, 2020
8 changes: 8 additions & 0 deletions src/neo/SmartContract/Native/Tokens/NeoToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ protected override void OnPersist(ApplicationEngine engine)
var pubkey = committee.OrderBy(p => p).ElementAt(index);
var account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash();
GAS.Mint(engine, account, gasPerBlock * CommitteeRewardRatio / 100);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set nextValidators before process the transactions and reward the committee after process these transactions, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should wait for #1907 and reward every epoch (28 blocks)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why #1907 is needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, but ig #1907 it's merged, we can reward them every 28 blocks.

if (engine.Snapshot.PersistingBlock.Index == 1)
{
// Genesis block reward

pubkey = committee.OrderBy(p => p).ElementAt(0);
account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash();
GAS.Mint(engine, account, gasPerBlock * CommitteeRewardRatio / 100);
}

// Set next validators

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public void Check_BalanceOf()
public void Check_CommitteeBonus()
{
var snapshot = Blockchain.Singleton.GetSnapshot();
snapshot.PersistingBlock = new Block { Index = 0 };
snapshot.PersistingBlock = new Block { Index = 1 };

using (ScriptBuilder sb = new ScriptBuilder())
{
Expand All @@ -406,7 +406,8 @@ public void Check_CommitteeBonus()

var committee = Blockchain.StandbyCommittee.OrderBy(p => p).ToArray();
NativeContract.GAS.BalanceOf(snapshot, Contract.CreateSignatureContract(committee[0]).ScriptHash.ToArray()).Should().Be(25000000);
NativeContract.GAS.BalanceOf(snapshot, Contract.CreateSignatureContract(committee[1]).ScriptHash.ToArray()).Should().Be(0);
NativeContract.GAS.BalanceOf(snapshot, Contract.CreateSignatureContract(committee[1]).ScriptHash.ToArray()).Should().Be(25000000);
NativeContract.GAS.BalanceOf(snapshot, Contract.CreateSignatureContract(committee[2]).ScriptHash.ToArray()).Should().Be(0);
}
}

Expand Down