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

Add ability for MPW to run explorer-less #427

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JSKitty
Copy link
Member

@JSKitty JSKitty commented Oct 14, 2024

Abstract

This PR allows the majority of MPW data, aside from heavily indexed (Pubkey/XPub) data, to be acquired from Node RPCs.

This was initially as a fix for MPW being completely unloadable when Explorers are down, due to being unable to fetch chain data, MPW can't even pass the "Loading" screen - however after getting in to the rabbit hole, this PR is able to replace the reliance on Explorers almost entirely and allow full access to MPW despite total explorer outage, relying instead on the internal TXDB, internal mempool, and public RPC data.

This PR adds the ability to use all MPW functions aside from Transparent Sync - Shield can be fully utilised as normal.

RPC Layer Suggestions

This PR proposes the following RPCs be enabled on all RPC Servers supported by MPW:
getblockcount, getblockhash, getblock, getbestblockhash, getrawtransaction, sendrawtransaction

It would however be more efficient to develop a custom RPC layer API like getblockbyheight, it would just be getblockhash passed through getblock, halving the requests MPW needs to make for blockchain sync-via-RPC.

TODOs

  • Add general endpoint fallbacks (getBlockCount, getBestBlockHash, getBlock, getRawTx, etc).
  • Allow Shield synchronisation via Nodes.
  • Allow a "complete" usable wallet state without Explorers based on TXDB + internal mempool. (Activity, Sending).
  • Figure out how to gracefully handle the state in which Shield is synced and ready, but Transparent is not.

Testing

To test this PR, it's suggested to attempt these user flows, or variations of these:

  • Test that MPW loads and opens as expected, without explorers.
  • Test that Shield continues to sync, transact and confirm, without explorers.
  • Test that Shield is capable of syncing from scratch, without explorers.
  • Test transactions, without explorers.

If any errors are found, the PR works unexpectedly, or you have viable suggestions to improve the UX or functionality of the PR, let me know!


@JSKitty JSKitty added the Enhancement New feature or request label Oct 14, 2024
@JSKitty JSKitty self-assigned this Oct 14, 2024
Copy link

netlify bot commented Oct 14, 2024

Deploy Preview for cheery-moxie-4f1121 ready!

Name Link
🔨 Latest commit b7c526b
🔍 Latest deploy log https://app.netlify.com/sites/cheery-moxie-4f1121/deploys/670e787ad04dbe00084762d7
😎 Deploy Preview https://deploy-preview-427--cheery-moxie-4f1121.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JSKitty JSKitty marked this pull request as ready for review October 15, 2024 14:13
Copy link
Member

@panleone panleone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. Overall my idea is that we should make sure to have working explorers instead of making the code more ugly/complicated just to use RPC nodes as fallback.

For example: ok the explorers are not working and I can get the blockCount from the RPC node, but then getLatestTxs is going to fail anyways because it can only be done by an explorer, so what's the point?

const newTx = await r.json();
newTxs.push(newTx);
} else {
newTxs.push(tx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very good, we should consider removing the explorer based getBlock

await cNet.getLatestTxs(this);
fSynced = true;
} catch {
// If all Explorers are down, we'll just rely on the local TXDB and display a warning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more serious: getLatestTxs failed, wallet is almost unusable, balance is wrong and any attempt to create a tx will likely fail.

Copy link
Member Author

@JSKitty JSKitty Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shield is fully usable and transactable, as well as Masternode controller and Governance. Meanwhile current MPW will not even open/load if explorers are down (which they are down far too frequently).

return backend.bestBlockHash;
return backend.bestBlockHash;
} catch {
// Use Nodes as a fallback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using nodes as a fallback for light RPC calls like getBestBlockHash , sendTransaction and getBlockCount: the code is more ugly and imo we should just make sure to have working explorers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo we would need at least 2x (4) explorers to consider it a stable network, or we start relying more on Nodes instead, it is the only compromise to get MPW more stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants