Convex-Dev / convex-web

https://convex.world
16 stars 18 forks source link

Error displaying balance upon account creation #231

Open Darkneew opened 2 years ago

Darkneew commented 2 years ago

I made a brand new account using the sandbox built in system to create an account, and here were my two first commands using the account, in transaction mode : Capture d’écran 2022-08-25 002507 We can see that either I gained coins by checking my balance (feels unlikely), either the first displayed balance wasn't my true balance.

helins commented 2 years ago

Do you still have that account? Can you reproduce? 🤔 Unfortunately I can't. How much time elapsed between both transactions?

Screenshot 2022-08-25 at 11 43 12
Darkneew commented 2 years ago

Hello, I had this issue with the account #513. Capture d’écran 2022-08-25 195018 I can also reproduce the bug as seen here. The screenshot shows the integrality of commands I ran.

I am using google chrome if that changes anything. Steps to reproduce :

  1. Open a window with no previous cookie or data (I simply go into guest mode)
  2. Open convex's sandbox
  3. Create a new account with the button that appear where you usually type code
  4. Run balance in transaction mode
  5. Run balance in query mode

:)

Darkneew commented 2 years ago

After some testing, I found out that asking the balance in transaction mode simply make convex forget 2000000 coins. The issue is completely reproducible and works on any account independant of the age of the account of or previous code run.

I guess when running balance in transaction mode, it checks the balance whilst removing coins for juice, which afterwards return to the account.

Also, this issue would give a lot of sense to another issue I found out recently : https://github.com/Convex-Dev/convex/issues/390

In this other issue, I can see when querying my balance that I have enough coins to make a transaction, but when doing the actual transaction, I get an insufficient fund error

helins commented 2 years ago

Indeed I think this is because remaining transaction juice is reimbursed. @mikera Can you confirm?

mikera commented 2 years ago

Yes currently transaction juice is subtracted at start, and reimbursed at end. I'd like to change this so that this doesn't happen (since it is confusing) but it's a bit tricky because we need to stop people spending more juice than they have....

Darkneew commented 2 years ago

Does the substracted juice have an upper limit? If so, you can instead simply substract this amount from the balance, and display a "net balance"