decred / dcrdex

The Decred Decentralized Exchange (DEX), powered by atomic-swaps.
Other
187 stars 95 forks source link

loadbot/doge: Extremely high available balance returned. #1672

Closed JoeGruffins closed 1 year ago

JoeGruffins commented 2 years ago

Running loadbot at https://github.com/decred/dcrdex/pull/1656/commits/a2ad03d399015fc35e80a9ccc7fb66cc1de6292b on the dcr_doge market.

This started happening without resolve until I reset the doge harness. May be a problem with the harness or loadbot. Still, max balance is almost a max uint64 which doesn't make sense to come directly from the rpc wallet.

The error:

2022-06-20 17:13:45.200 [DBG] MANTLE:CMPD:PINGPONG:0: Balance note received for doge (minFunds = 351.19999960, maxFunds = 702.39999920): {"available":18446072150050518966,"immature":375000791124839,"locked":11338989826907810,"stamp":"2022-06-20T17:13:45.200108148+09:00","orderlocked":13169999985,"contractlocked":0}
2022-06-20 17:13:45.200 [DBG] MANTLE:CMPD:PINGPONG:0: Sending 184460720973.70520020 back to doge alpha node
2022-06-20 17:13:45.276 [TRC] CORE:CMPD:STACKER:0[doge]: feeRateWithFallback using caller's suggestion for fee rate, 4072. Local estimate unavailable
2022-06-20 17:13:45.294 [ERR] CORE:CMPD:STACKER:0[doge]: Withdraw error - address = 'mtRoaKRFrHFEEBKW4UnHBfyoRzDJNFfqp5', amount = -6721343.7903241: SendToAddress error: rawrequest (sendtoaddress) error: -3: Amount out of range
2022-06-20 17:13:45.296 [ERR] CORE:CMPD:STACKER:0: notify: |ERROR| (withdraw) Withdraw error - Error encountered during doge withdraw: SendToAddress error: rawrequest (sendtoaddress) error: -3: Amount out of range

The log: doge2.txt

chappjc commented 2 years ago

max balance is almost a max uint64 which doesn't make sense to come directly from the rpc

This screams underflow. The available is not directly from RPC, but the result of a formula:

https://github.com/decred/dcrdex/blob/96fda4727223ef197cde0e4ec74b1c83e144c21b/client/asset/btc/btc.go#L1184

Not the first time we've hit this issue. In a nutshell, locked is higher than actual balance. Why? Probably because of a race between GetWalletInfo and lockedSats.

chappjc commented 2 years ago

Also very likely resolved by https://github.com/decred/dcrdex/pull/1677 because loadbot was using alpha wallet for all traders with DOGE.

chappjc commented 2 years ago

The DOGE and ZEC issue (singular wallets) with loadbot is fixed now, but we can leave this opened because ideally there would be some way to make sure the getwalletinfo and listlockunspent results are atomic, or at least catch when locked is larger than otherwise available balance to prevent an underflow.

Another thing I noted, which I don't think is an issue, is that dogecoind has no error for repeated lock or unlocks of the same UTXO, while other coin daemons seem to error.