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

SPV, RPC, Rescan fixes #469

Merged
merged 11 commits into from
Jul 5, 2022
Merged

SPV, RPC, Rescan fixes #469

merged 11 commits into from
Jul 5, 2022

Conversation

rithvikvibhu
Copy link
Collaborator

@rithvikvibhu rithvikvibhu commented Feb 11, 2022

SPV, RPC and rescan fixes. Redid commits to make review easier.

node: set spv boolean correctly

ui: hide generatenewblocks if spv

node: remove getAuctionInfo

  • Get Auction Info is a wallet call, but was part of node service, removed it

node: common api url constant

  • A single constant for URL for handshake api (remote node used in SPV mode) - easier to replace during dev

exchange: disable in spv mode

  • Related to Shakedex will not work in SPV mode #480
  • Disables Exchange page in SPV with a message. Keeping the issue open until shakedex is updated to use Bob's node service including remote api calls

rpc: allow http for private IP addresses

  • From Discord, a user wanted to use Bob over RPC to a node on a local network.
  • Instead of allowlisting just localhost, it now checks and allows HTTP for private IP ranges too (hostnames still require HTTPS, even those that resolve to private IP addresses).
  • Uses binet (added to package.json, but hsd itself requires it so doesn't add anything)

rpc: splash screen switch to internal node on error

  • closes Add the rig options on the loading screen (Working on it) #515
  • If Bob is set to use a remote RPC node, and the node is not reachable, Bob errors on splash screen
  • If the node cannot be started (say the IP address is released, or domain is not under user's control), then the only way to get Bob working again was to clear all Bob settings by deleting the db directory.
  • Now, if it's an RPC connection failure, the splash screen has a button to switch to internal node

node: throttle refreshNodeInfo

  • refreshNodeInfo is a slightly expensive call (getInfo and getFees) and was being called for every new block, which is very fast in SPV mode
  • It is now throttled.

wallet: replace rescan hooks with block connect events

  • Before requesting blocks, a node asks for peer's mempool (but only in regtest!)
  • We know that sendGetBlocks doesn't really request anything, so nothing happens after that (2)...
  • BUT, because of (1), the node expects a mempool inv response - which it won't get because mempool is empty - and after 30 secs, kills the connection.
  • With only set to a single peer, it connects to the same peer again and now makes getBlocks for "the first time" and gets the new blocks.
    To a Bob user, it'll look like a rescan took >35 seconds.

Now, rescans work everywhere and show proper status (next commit below):

Settings -> Rescan Auction Rescan
Full node
SPV node
RPC - Full node

wallet: correct resync progress in spv

  • resyncing progress in sidebar and topbar now use resync height added in previous commit

pkg: update to hsd v4.0.1


Overall, SPV seems more stable now, and syncs from scratch in 25 minutes.

TODO:

@pinheadmz
Copy link
Contributor

👍 looks good so far.

@rithvikvibhu rithvikvibhu changed the title SPV fixes SPV, RPC, Rescan fixes Mar 25, 2022
@pinheadmz
Copy link
Contributor

@rithvikvibhu re: 7af427a

I think we can make this a lot simpler by adding a feature to hsd: handshake-org/hsd#621

If wallet and node both emit "new chain height" events, we will always know their sync status and we can drop the unhook hack and forget about "wallet rescan" events entirely. This should work for SPV fine as well.

this.node.wdb.client.unhook('block rescan');

@rithvikvibhu
Copy link
Collaborator Author

@pinheadmz using hsd fork (handshake-org/hsd#707) and yeah it made things simpler!

SPV importname is still a problem though.

@rithvikvibhu rithvikvibhu added dependent Depends on another issue or PR to be resolved first needs translation PR updates locale strings and have not yet been translated labels Mar 27, 2022
@rithvikvibhu rithvikvibhu marked this pull request as ready for review June 29, 2022 17:30
@rithvikvibhu
Copy link
Collaborator Author

Rebased, updated to hsd v4.0.1 and it's SO satisfying to watch the auction rescan in SPV!
The blue progress bar of the bidding period goes back to 0 and increments smoothly.

@rithvikvibhu rithvikvibhu merged commit 1185fbe into kyokan:master Jul 5, 2022
@rithvikvibhu rithvikvibhu deleted the spv-fixes branch July 5, 2022 14:02
@rithvikvibhu rithvikvibhu removed the needs translation PR updates locale strings and have not yet been translated label Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependent Depends on another issue or PR to be resolved first
Projects
None yet
2 participants