Chia-Network / chia-blockchain-gui

Chia blockchain GUI in electron/react
https://chia.net
Apache License 2.0
332 stars 246 forks source link

[BUG] Wallet GUI crashes after multiple offer submissions #2455

Closed janit closed 1 day ago

janit commented 3 weeks ago

What happened?

Playing around with some cats on Dexie lead me to this situation:

image

This happened when I posted multiple offers one after another. The GUI keeps crashing on this error after restarting the app, but after a while the the issue goes away. My guess is this is a problem with the wallet not handling an error from the backend correctly.

See logs below.

Version

2.4.3

What platform are you using?

macOS

What ui mode are you using?

GUI

Relevant log output or stacktrace

Invalid value for 1: null

URL
#/dashboard/wallets/1

Stacktrace
at webpack://@chia-network/gui/src/util/createOfferForIdsToOfferBuilderData.ts:19:12 numericValue.isNaN
at webpack://@chia-network/gui/src/util/createOfferForIdsToOfferBuilderData.ts:15:38 lookupByWalletId
at webpack://@chia-network/gui/src/components/walletConnect/WalletConnectCreateOfferPreview.tsx:29:47 useMemo(
at webpack://node_modules/react-dom/cjs/react-dom.production.min.js:184:188 useLayoutEffect
at webpack://node_modules/react/cjs/react.production.min.js:25:207 useInsertionEffect
at webpack://@chia-network/gui/src/components/walletConnect/WalletConnectCreateOfferPreview.tsx:24:57 WalletConnectCreateOfferPreview
at webpack://node_modules/react-dom/cjs/react-dom.production.min.js:167:136 Xh
at webpack://node_modules/react-dom/cjs/react-dom.production.min.js:290:336 Wk
at webpack://node_modules/react-dom/cjs/react-dom.production.min.js:280:388 uj

—8<————————8<————————8<—————

.chia/mainnet/log/debug.log:

2024-08-21T21:45:58.234 wallet chia.wallet.wallet         : WARNING  TransactionRecord SpendBundle ID: b'xxx' not in mempool. (peer, included, error) list: []
2024-08-21T22:00:10.216 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': 'xxx'}
2024-08-22T05:04:15.492 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': 'xxx'}
2024-08-22T05:04:15.501 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': 'xxx'}
2024-08-22T06:26:11.464 wallet chia.wallet.cat_wallet.cat_wallet: WARNING  Can't select amount higher than our spendable balance.  Amount: 1000000000, spendable: 0
2024-08-22T06:26:11.466 wallet chia.wallet.trade_manager  : ERROR    Error creating trade offer
Traceback (most recent call last):
  File "chia/wallet/trade_manager.py", line 558, in _create_offer_for_ids
  File "chia/wallet/cat_wallet/cat_wallet.py", line 868, in get_coins_to_offer
  File "chia/wallet/cat_wallet/cat_wallet.py", line 530, in select_coins
  File "chia/wallet/coin_selection.py", line 30, in select_coins
ValueError: Can't select amount higher than our spendable balance.  Amount: 1000000000, spendable: 0
2024-08-22T06:26:11.468 wallet chia.rpc.rpc_server        : WARNING  Error while handling message: Traceback (most recent call last):
  File "chia/rpc/rpc_server.py", line 340, in safe_handle
  File "chia/rpc/rpc_server.py", line 331, in ws_api
  File "chia/rpc/util.py", line 160, in rpc_endpoint
  File "chia/rpc/wallet_rpc_api.py", line 1874, in create_offer_for_ids
  File "chia/wallet/trade_manager.py", line 451, in create_offer_for_ids
Exception: Error creating offer: Can't select amount higher than our spendable balance.  Amount: 1000000000, spendable: 0

2024-08-22T06:26:19.535 wallet chia.wallet.cat_wallet.cat_wallet: WARNING  Can't select amount higher than our spendable balance.  Amount: 1000000000, spendable: 0
2024-08-22T06:26:19.535 wallet chia.wallet.trade_manager  : ERROR    Error creating trade offer
Traceback (most recent call last):
  File "chia/wallet/trade_manager.py", line 558, in _create_offer_for_ids
  File "chia/wallet/cat_wallet/cat_wallet.py", line 868, in get_coins_to_offer
  File "chia/wallet/cat_wallet/cat_wallet.py", line 530, in select_coins
  File "chia/wallet/coin_selection.py", line 30, in select_coins
ValueError: Can't select amount higher than our spendable balance.  Amount: 1000000000, spendable: 0
2024-08-22T06:26:19.536 wallet chia.rpc.rpc_server        : WARNING  Error while handling message: Traceback (most recent call last):
  File "chia/rpc/rpc_server.py", line 340, in safe_handle
  File "chia/rpc/rpc_server.py", line 331, in ws_api
  File "chia/rpc/util.py", line 160, in rpc_endpoint
  File "chia/rpc/wallet_rpc_api.py", line 1874, in create_offer_for_ids
  File "chia/wallet/trade_manager.py", line 451, in create_offer_for_ids
Exception: Error creating offer: Can't select amount higher than our spendable balance.  Amount: 1000000000, spendable: 0
wjblanke commented 2 weeks ago

Is there anything displayed additionally in the developer tools console? Izumi can u take a look at this, maybe there is a global or something shared between multiple submissions.

janit commented 2 weeks ago

I haven’t had this issue repeated, so I don’t have access to the dev tools logs output.

I’ll add them to this ticket if/when the bug surfaces again.

ChiaMineJP commented 1 week ago

I'm investigating the code to reproduce this issue. If you find more hints, please let me know.

ChiaMineJP commented 3 days ago

I tried to reproduce this issue by intentionally rasing an exception in create_offer_for_ids RPC API. I activated wallet connect with the Dexie for testnet11 and repeated to create offers on Dexie but the GUI didn't crash at this time.

I'm suspecting that actually GUI crashed with successful create_offer_for_ids RPC API without an exception but the response contains unexpected offer data. (e.g. an offer with a null amount offer item) Still continuing investigation.

image

image

ChiaMineJP commented 3 days ago

Finally, I managed to reproduce this issue. This issue happens when you forget to input amount like below

image

ChiaMineJP commented 3 days ago

Fixed this issue by https://github.com/Chia-Network/chia-blockchain-gui/pull/2476

janit commented 3 days ago

Awesome, never occurred to that my offers may have been invalid. Thank you @ChiaMineJP 💪

wjblanke commented 2 days ago

Thanks guys!