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

[R4R] fix account may have currency with zero balance #679

Merged
merged 3 commits into from
Oct 30, 2019
Merged

Conversation

unclezoro
Copy link
Collaborator

Description

resolve issue #677

Rationale

Some consideration for the fixing:

  1. Why not change Plus function for Coins.
    May need check every currency value of the coin, may hurt the performance.
  2. Is there any point that call Plus may have such issue?
    Swap, Freeze, Timelock, Send, Mint, Burn , Issue have checked the coins to be positive, this only happend when add an currency which is possiable to be zero, for now only trade will involved.

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • integration tests passed (make integration_test)
  • manual transaction test passed (cli invoke)

Already reviewed by

...

Related issues

#667

@unclezoro unclezoro changed the base branch from master to develop October 23, 2019 08:36
@unclezoro unclezoro requested review from ackratos, darren-liu, rickyyangz, HaoyangLiu and yutianwu and removed request for ackratos and darren-liu October 23, 2019 08:37
Plus(sdk.Coins{sdk.NewCoin(tran.outAsset, tran.unlock-tran.out)}))
accountCoin := account.GetCoins().
Plus(sdk.Coins{sdk.NewCoin(tran.inAsset, tran.in)})
if tran.unlock-tran.out > 0 || !sdk.IsUpgrade(upgrade.FixZeroBalance) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if remain := tran.unlock-tran.out; remain > 0 || !sdk.IsUpgrade... {
     accountCoin = accountCoin.Plus(sdk.Coins{sdk.NewCoin(tran.outAsset, remain)})
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure whether we want clean up historical data at a specific height......

Amazing, this is better in performance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not this:

if tran.unlock>tran.out || !sdk.IsUpgrade... {

@ackratos
Copy link
Contributor

not sure whether we want clean up historical data at a specific height......

@unclezoro
Copy link
Collaborator Author

unclezoro commented Oct 23, 2019

not sure whether we want clean up historical data at a specific height......

emm, this may stop the world for a while, I am not sure either. @yutianwu @HaoyangLiu @darren-liu @rickyyangz any suggest?

@yutianwu
Copy link
Contributor

it seems acceptable if we clean the accounts in prod for there are only 300k accounts in prod. and there are 700k in testnet. we can test how long will it take to clean the accounts.

@rickyyangz
Copy link
Contributor

we need to find out how many accounts that have such case to estimate the cost. I think there should not be too many and then it may be acceptable to handle it in one height.

@unclezoro
Copy link
Collaborator Author

I will sync the prod data and try how many time it takes.

@unclezoro
Copy link
Collaborator Author

unclezoro commented Oct 30, 2019

@rickyyangz @ackratos @HaoyangLiu @yutianwu Please see the test and statistics info in #684. The time may be acceptable, but during writing the algorithm that deletes the coin in coin slice, I really afraid of deleting the wrong coin which may totally ruin our chain. I don't want to take such risk, especially there is no strong requirement for this. Please comment.

@HaoyangLiu
Copy link
Contributor

I prefer just leave them alone. Doing this has no obvious gain but take big risk.

@yutianwu
Copy link
Contributor

ok, just let it go, and record this issue just in case we need to update the accounts.

or we can just airdrop some tokens to addresses affected, lol

@ackratos
Copy link
Contributor

@rickyyangz @ackratos @HaoyangLiu @yutianwu Please see the test and statistics info in #684. The time may be acceptable, but during writing the algorithm that deletes the coin in coin slice, I really afraid of deleting the wrong coin which may totally ruin our chain. I don't want to take such risk, especially there is no strong requirement for this. Please comment.

agree

@unclezoro unclezoro merged commit b516c1a into develop Oct 30, 2019
@unclezoro unclezoro deleted the issue677 branch May 10, 2022 06:14
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
forcodedancing pushed a commit that referenced this pull request May 19, 2022
* hardfork: fix possible zero currency balance

* add change log

* fix review suggest
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.

5 participants