Grinnode-live / 2020-grin-bug-bash-challenge

Finding bugs in Grin-Wallet & Grin-nodes for a bounty prior to Grin fork v5.
3 stars 1 forks source link

Node starts API and stratum servers too soon #58

Closed bladedoyle closed 3 years ago

bladedoyle commented 3 years ago

The grin node starts API and stratum servers before its ready to handle requests. The result is confusing because the connections are accepted but result in an error, so the node seems broken at that point. For example, the wallet reports this:

$ ./grin-wallet info
Password: 
20201229 10:39:47.871 WARN grin_wallet_libwallet::internal::updater - Not updating outputs as the height of the node's chain is less than the last reported wallet update height.
20201229 10:39:47.871 WARN grin_wallet_libwallet::internal::updater - Please wait for sync on node to complete or fork to resolve and try again.
20201229 10:39:47.943 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20201229 10:39:48.214 ERROR grin_wallet_impls::node_clients::http - Response { result: Some(Object({"Err": String("NotFound")})), error: None, id: Number(1), jsonrpc: Some("2.0") }
20201229 10:39:48.214 ERROR grin_wallet_impls::node_clients::http - Unable to parse response for get_pmmr_indices: JSON decode error: invalid type: null, expected struct OutputListing
Wallet command failed: LibWallet Error: Client Callback Error: Unable to parse response for get_pmmr_indices: JSON decode error: invalid type: null, expected struct OutputListing

Suggested fix: Servers should not start to accept connections before they are ready to service the requests. That is, The node should be ready to build a block template before it begins to accept connections on stratum port. The node should be synced before it starts the api listener - OR - there should be an RPC message reply indicating that its still syncing and the wallet should check that and report a nice message.

bladedoyle commented 3 years ago

Filed this as https://github.com/mimblewimble/grin/issues/3546