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] Avoid remove vote when the account transfer all the neo #3720

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

shargon
Copy link
Member

@shargon shargon commented Feb 6, 2025

Description

Fix #3721

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Not new

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@shargon shargon requested a review from roman-khimov February 6, 2025 15:16
@shargon shargon added the Bug Used to tag confirmed bugs label Feb 6, 2025
@lock9
Copy link
Contributor

lock9 commented Feb 6, 2025

Hi @shargon ,
While I understand this is an issue, you need to consider that the candidate's public key occupies most of the space in every account.
Wouldn't it be possible to 'restore' the vote when the balance changes? Not sure if it's doable (maybe not).

@shargon
Copy link
Member Author

shargon commented Feb 6, 2025

Hi @shargon ,
While I understand this is an issue, you need to consider that the candidate's public key occupies most of the space in every account.
Wouldn't it be possible to 'restore' the vote when the balance changes? Not sure if it's doable (maybe not).

You paid for this storage when you vote

@lock9
Copy link
Contributor

lock9 commented Feb 6, 2025

Yes, but my concern is that this value will stay there forever. I was just wondering if there was a better option since it doesn't make sense to keep the candidate stored while the user has no votes.

@shargon
Copy link
Member Author

shargon commented Feb 6, 2025

Yes, but my concern is that this value will stay there forever. I was just wondering if there was a better option since it doesn't make sense to keep the candidate stored while the user has no votes.

For me it's totally different, i vote you, and when I have balance I earn gas, but when not, i don't earn nothing, imagine change all your receipts if your bank account is zero, what's the sense? Or we duplicate the keys and we store them in different places, or we need this information although without balance. Different things that cause unexpected results during voting. I can vote with 0 balance, but my voting power is zero.

Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

This will clutter our storage with useless entries, I do not agree it's a problem (and we had this behavior for 3+ years), long-term these stale entries are a bigger problem.

@shargon
Copy link
Member Author

shargon commented Feb 7, 2025

This will clutter our storage with useless entries, I do not agree it's a problem (and we had this behavior for 3+ years), long-term these stale entries are a bigger problem.

Is not useless, you vote for it. If a problem appears after 3 years, that's not means that is not a problem... we can separate the values in different keys, I'm sure it will be worst because the duplicate key

@roman-khimov
Copy link
Contributor

Well, let's get some statistics then:

  • how many voting accounts with 0 NEO get any new NEO in future
  • vs how many voting accounts dump their NEO elsewhere and never return

With 6M+ blocks this can be somewhat representative. But I really think that current behavior is fair, no NEO --- no voting, nothing to store. And I expect many accounts to be used temporarily, so they come, get NEO, vote, spend NEO and never return. Maybe this assumption is wrong. But it looks to me that we're trying to solve the problem three people have while adding overhead for the whole network.

@cschuchardt88
Copy link
Member

Bottomline they paid for the storage. It should stay or refund should be issued.

@shargon
Copy link
Member Author

shargon commented Feb 7, 2025

another valid solution is fault if you left 0 neo and vote for something, if you want to transfer it you should vote for null

{
if (engine.IsHardforkEnabled(Hardfork.HF_Echidna))
{
if (state.VoteTo != null) return false;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
if (state.VoteTo != null) return false;
if (state.VoteTo != null)
{
throw new UncatcheableException("You need to vote for null if you want to transfer all your neos");
}

something like this

Copy link
Contributor

Choose a reason for hiding this comment

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

Neat, but then people will complain that "Neo forces us to make two transactions instead of one".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Used to tag confirmed bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vote should be preserved without neo balance
4 participants