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

Conversation

Tommo-L
Copy link
Contributor

@Tommo-L Tommo-L commented Aug 28, 2020

No description provided.

@erikzhang
Copy link
Member

if (block.Index > 0)

Remove this if?

@Tommo-L
Copy link
Contributor Author

Tommo-L commented Aug 28, 2020

No, native contracts have not yet been deployed.

@erikzhang
Copy link
Member

What about move the incentive logic to PostPersist()?

using ApplicationEngine engine = ApplicationEngine.Create(TriggerType.System, null, snapshot);
engine.LoadScript(postPersistScript);
if (engine.Execute() != VMState.HALT) throw new InvalidOperationException();
ApplicationExecuted application_executed = new ApplicationExecuted(engine);
Context.System.EventStream.Publish(application_executed);
all_application_executed.Add(application_executed);

We can remove the if condition.

@Tommo-L
Copy link
Contributor Author

Tommo-L commented Aug 28, 2020

I think it's ok. I'll move it.

@Tommo-L
Copy link
Contributor Author

Tommo-L commented Aug 28, 2020

Waiting for #1738, I still need one or two days for testing it.

shargon
shargon previously approved these changes Aug 31, 2020
Copy link
Member

@erikzhang erikzhang left a comment

Choose a reason for hiding this comment

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

Waiting for #1738

@erikzhang
Copy link
Member

@Tommo-L #1738 has been merged.

@erikzhang
Copy link
Member

@Tommo-L Please fix the UTs.

@Tommo-L
Copy link
Contributor Author

Tommo-L commented Sep 3, 2020

Ok, I'll fix them.

// Distribute GAS for committee

int index = (int)(engine.Snapshot.PersistingBlock.Index % (uint)ProtocolSettings.Default.CommitteeMembersCount);
var gasPerBlock = GetGasPerBlock(engine.Snapshot);
var committee = GetCommitteeMembers(engine.Snapshot).ToArray();
var pubkey = committee.OrderBy(p => p).ElementAt(index);
var pubkey = GetCommittee(engine.Snapshot)[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.

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

we can optimize it later #1884 (comment) after #1907

@shargon shargon merged commit 4066a4f into neo-project:master Sep 6, 2020
ShawnYun pushed a commit to ShawnYun/neo that referenced this pull request Jan 8, 2021
* fix incentive for committee

* fix

* Update Blockchain.cs

* Update NeoToken.cs

* fix ut

Co-authored-by: Tommo-L <luchuan@neo.org>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Erik Zhang <erik@neo.org>
cloud8little pushed a commit to cloud8little/neo that referenced this pull request Jan 24, 2021
* fix incentive for committee

* fix

* Update Blockchain.cs

* Update NeoToken.cs

* fix ut

Co-authored-by: Tommo-L <luchuan@neo.org>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Erik Zhang <erik@neo.org>
ixje added a commit to CityOfZion/neo-mamba that referenced this pull request Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants