Repository navigation
Conversation
…n the node can't be reached A shader call waits for the wallet to sync with a node, so with no node it never started and blocked every call queued behind it. When a connection attempt fails and no node is connected, the calls that can't progress without the node now fail with "No connection to the node: <reason>".
|
Note: #2139 fixes the same issue and was opened a few minutes earlier. The two take different approaches, so here's the difference to help choose:
Either fixes the reported case. This one also covers a node lost mid-call and avoids false errors during startup. |
|
Tested this against master and against my #2139, which fixes the same issue differently. Setup:
|
Fixes #1695.
The bug
ShadersManagerstarts a shader only once the wallet is in sync with a node (DoInSyncedWallet). With no node, that never happens. The call sits there forever, and so does every shader call queued behind it. A running shader that waits for a node response (vars, logs, ...) is stuck the same way after the node goes away.Reproduced on master with
wallet-apiandbvm/Shaders/vault/app.wasm, read-only calls (create_tx: false):action=viewaction=create_contractviewThe fix
The calls fail exactly when there's nothing left to wait for, with no arbitrary timeout:
IShadersManager::AbortCallsWaitingForNode(error)fails the current call, if it waits for the wallet sync or for a node response, and all the calls queued behind it. A shader waiting for a peer message (Comm_Wait) is left alone, since it has its own timeout. Cancelling uses what's already there: the start event thatDoInSyncedWalletholds only weakly, andManagerStd::Reset(), which drops the pending requests of a running shader.WalletApiServersubscribes toNodeNetworkand calls it when a connection attempt fails while no node is connected. A live connection that drops is reported before it's uncounted, so a short drop doesn't fail anything. Only a failed reconnect does.ShadersManager, but its behaviour is unchanged: it never calls the new method.The client now gets an error:
{"error":{"code":-32019,"data":"No connection to the node: connection refused","message":"Contract call failed"},"id":2,"jsonrpc":"2.0"}Tests
wallet/unittests/shaders_manager_test(wallet_core only, no network). The wallet has a node endpoint that is never connected. A call waiting for the sync and a call queued behind it both get the error, the manager is usable afterwards, and aborting with nothing in progress is a no-op. Making the method a no-op makes the test fail.wallet-apiagainst a mainnet node through a local TCP proxy:wallet_test,wallet_api_test,wallet_db_test,slatepack_testpass.