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

suix_getBalance and suix_GetAllBalances can return invalid balances #21230

Open
aaronTufts opened this issue Feb 14, 2025 · 2 comments
Open

suix_getBalance and suix_GetAllBalances can return invalid balances #21230

aaronTufts opened this issue Feb 14, 2025 · 2 comments
Assignees
Labels

Comments

@aaronTufts
Copy link

aaronTufts commented Feb 14, 2025

I believe this is (at least in part) due to #21229

Example

when you call getAllCoins for this address "0x5c39c34610d99a8139b0b82863969c0862dd400d679f96d97f10227915bbc27c" it returns SUI coins that add up to 1630363926 MIST .

curl https://fullnode.mainnet.sui.io/ \
-X POST \
-H 'Content-Type: application/json' \
-d '{ 
        "jsonrpc":"2.0", 
        "method":"suix_getAllCoins",
        "params":[
            "0x5c39c34610d99a8139b0b82863969c0862dd400d679f96d97f10227915bbc27c"
        ],
        "id":1
    }' | json_pp

If you loop through the coins and call getObject on them all, you find three that don't exist anymore:

{
  code: 'notExists',
  object_id: '0x93d550e5201ab108a0660358d5a31f3d3c5ab96a1564aa5f96ffc3a4544264d3'
}
{
  code: 'notExists',
  object_id: '0x1411272b278d3c19f6c73dadf1d21b070d3b94e029db6a97b18ae09111f93b33'
}
{
  code: 'notExists',
  object_id: '0x691e1a300ae3a4c05df2d52a93c87136f1c1f2a19958ca3ff75f65fce5215b9c'
}

and if you only add up the coins that exist, the total is 1375697499 MIST. "hasNextPage" : false, so we are able to see all the account's coins. I say this because of the bug that prevents paginating when the cursor is a now-deleted coin, which this PR is supposed to fix (likely in the next Testnet version to roll out) - see #21229

However, SuiVision shows a total of 1.63 Sui, and includes the deleted coins in the list of the address's coins. And if you call getAllBalances for the address:

curl https://fullnode.mainnet.sui.io/ \
-X POST \
-H 'Content-Type: application/json' \
-d '{
        "jsonrpc":"2.0",
        "method":"suix_getAllBalances",
        "params":[
            "0x5c39c34610d99a8139b0b82863969c0862dd400d679f96d97f10227915bbc27c"
        ],
        "id":1
    }' | json_pp

You also get a SUI balance of 1.63 SUI, meaning the deleted coins don't appear to be filtered out of the total:

      {
         "coinObjectCount" : 19,
         "coinType" : "0x2::sui::SUI",
         "lockedBalance" : {},
         "totalBalance" : "1630363926"
      },
Copy link
Contributor

Thank you for opening this issue, a team member will review it shortly. Until then, please do not interact with any users that claim to be from Sui support and do not click on any links!

@aaronTufts
Copy link
Author

aaronTufts commented Feb 14, 2025

In this example I did not find any balance issues with non-SUI coins, but of course that's not proof that the issue is limited to SUI. Please let us know if you find more info about the scope: how far back in time, frequency of occurrence, affected coin types, etc.

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

No branches or pull requests

4 participants