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

Panic on FLOW remainder in UInt to UFix64 conversion #6856

Open
sisyphusSmiling opened this issue Jan 8, 2025 · 0 comments · May be fixed by #6877
Open

Panic on FLOW remainder in UInt to UFix64 conversion #6856

sisyphusSmiling opened this issue Jan 8, 2025 · 0 comments · May be fixed by #6877
Assignees
Labels
Bug Something isn't working

Comments

@sisyphusSmiling
Copy link
Contributor

sisyphusSmiling commented Jan 8, 2025

What is the severity of this bug?

Should have:

Reproduction steps

Run a transaction attempting to withdraw an amount of FLOW from a COA that exceeds UFix64 precision which will result in the following error:

error: [Error Code: 1300] evm runtime error: withdraw failed! the balance is susceptible to the rounding error

e.g. the result of running this transaction

This seems to be the result of the check in the impl.newInternalEVMTypeWithdrawFunction() method:

ufix, roundedOff, err := types.ConvertBalanceToUFix64(vault.Balance())
if err != nil {
  panic(err)
}
if roundedOff {
  panic(types.ErrWithdrawBalanceRounding)
}

Expected behaviour

I would expect one of two things:
a. Withdraw the withdrawable amount - e.g. 1000000000012345678 to be withdrawn as 1.0 FLOW
b. The error message to read something like “Withdrawal amounts should be not exceed UFix64 precision”

The former behaviour IMHO is preferable as it allows for the amount to be withdrawn, truncating the remainder without loss.

Screenshots

Example transactions attached

Specifications

  • System: N/A
  • Go: N/A

Additional context

N/A

@sisyphusSmiling sisyphusSmiling changed the title Panic on remainder in UInt to UFix64 conversion Panic on FLOW remainder in UInt to UFix64 conversion Jan 8, 2025
@sisyphusSmiling sisyphusSmiling added the Bug Something isn't working label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants