Skip to content

Conversation

@txhsl
Copy link
Contributor

@txhsl txhsl commented Apr 19, 2024

Close #165. Need update before merge.

receivedVotes[candidateTo] += amount;
votedTo[msg.sender] = candidateTo;
voterGasPerVote[msg.sender] = candidateGasPerVote[candidateTo];
voteHeight[msg.sender] = block.number;
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest not to change the height so that if voter changes the vote target, then it still receives the reward for the rest of the epoch. Exactly like if candidate performs the second vote for the same address.

Copy link
Member

Choose a reason for hiding this comment

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

But it's a subject of discussion.

Copy link
Contributor Author

@txhsl txhsl Apr 24, 2024

Choose a reason for hiding this comment

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

There is a case that a voter first vote to candidate A whose shareRate is low (e.g. 1), then change to another candidate B whose shareRate is high (e.g. 1000) after epoch change. That could happen if A is not select as a CN, so the voter leaves because there is no reward. This seems reasonable.

But if the voter change back to A before the next epoch change. There will be a fact that the voter puts its effective votes to A, but shares rewards from B. Is that what the candidate B expects to see?

I suggest that we delay this change till the future, e.g. when we reduce the epoch length.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, your second example is reasonable, we probably need to think about this case a bit more.

I suggest that we delay this change till the future

Could you create an issue for that?

Copy link
Member

Choose a reason for hiding this comment

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

Ref. #222.

@txhsl txhsl changed the title systemcontract: add changeVote method systemcontract: add transferVote method Apr 30, 2024
@AnnaShaleva AnnaShaleva self-requested a review May 1, 2024 08:38
AnnaShaleva
AnnaShaleva previously approved these changes May 29, 2024
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

With additional issue (#182 (comment)) this PR LGTM.

Luckily, governanceABI does not include method offsets and compatibility between the current Testnet is preserved. But we need to schedule system contracts updates on Testnet after v0.1.2 is released.

@AnnaShaleva
Copy link
Member

@chenquanyu, @roman-khimov, @nicolegys, ready for review and testing.

@AnnaShaleva AnnaShaleva dismissed their stale review May 29, 2024 16:45

Need to squash the commits into logical blocks.

@AnnaShaleva
Copy link
Member

@txhsl, please, squash the commits into a single one.

txhsl and others added 4 commits May 30, 2024 11:05
* index some event parameters

* update solidity compiler version

* systemcontract: governance unit tests (#210)

* update gitignore

* init hardhat project

* first ut

* systemcontract: add candidate management ut and getter check (#211)

* systemcontract: use customized error library (#209)

* systemcontract: use customized error library

* update existing ut

* systemcontract: add policy unit tests (#214)

* systemcontract: add ut about reward distribution and fix several ut (#215)

* systemcontract: optimize gas cost (#195)

* systemcontract: optimize gas cost

---------

Co-authored-by: belane <[email protected]>
@txhsl txhsl merged commit baffe25 into bane-main May 30, 2024
@txhsl txhsl deleted the governance-change-vote branch May 30, 2024 03:27
@AnnaShaleva
Copy link
Member

@txhsl, please, don't merge the unstructured changes into master. We'll end up in a git history mess in a few months.

@txhsl
Copy link
Contributor Author

txhsl commented May 30, 2024

Roger then, we only have #184, #216 and #217 left to merge to get a tag version for system contract after audit. I'm managing it.

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.

Allow changing vote target in Governance contract

4 participants