-
Notifications
You must be signed in to change notification settings - Fork 812
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
Adds Neutrino Client #1163
base: master
Are you sure you want to change the base?
Adds Neutrino Client #1163
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1163 +/- ##
==========================================
+ Coverage 70.26% 70.75% +0.49%
==========================================
Files 174 175 +1
Lines 27367 27833 +466
==========================================
+ Hits 19229 19693 +464
- Misses 8138 8140 +2
☔ View full report in Codecov by Sentry. |
@@ -50,6 +50,8 @@ class Indexer extends EventEmitter { | |||
this.blocks = this.options.blocks; | |||
this.chain = this.options.chain; | |||
|
|||
this.neutrino = this.options.neutrino; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably just live in FilterIndexer and leave the base class alone
if (this.neutrino) { | ||
if (!this.batch) | ||
this.start(); | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing this here, I think what we may need to do is in FilterIndexer.indexBlock()
just check if neutrino, return false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I implement it this way, the logStatus at line 458 in indexer.js gives an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also, the indexBlock is expected to return a value. Return false gives out an error
@@ -1001,7 +1008,7 @@ class ChainDB { | |||
*/ | |||
|
|||
async getRawBlock(block) { | |||
if (this.options.spv) | |||
if (this.options.spv && !this.options.neutrino) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm what's wrong with this line? We can't get raw blocks in neutrino mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need this in order to check if a requested block by wallet already exists in the database or not, in order to skip fetching it if it exists.
@@ -1478,7 +1493,7 @@ class ChainDB { | |||
async saveBlock(entry, block, view) { | |||
const hash = block.hash(); | |||
|
|||
if (this.options.spv) | |||
if (this.options.spv && !this.neutrinoSave) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question here - SPV mode does just fine without calling saveBlock()
Neutrino should be the same. Don't we save ChainEntry (headers) outside this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we get a pruned block on request by wallet, without the neutrinoSave flag, the chain skips saving the block.
@@ -73,58 +72,6 @@ describe('P2P', function () { | |||
await node2.close(); | |||
}); | |||
|
|||
describe('BIP157', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that this change triggered a bunch of code coverage warnings, will have to investigate further.
059de6e
to
7d2635c
Compare
a8bb572
to
934bdcc
Compare
feat<sync>: completed HeadersSync, CFHeaderSync, CFilterSync
1dc89dc
to
bffb60a
Compare
bffb60a
to
8e0bec0
Compare
This pr implements neutrino client mode. This has the commit history cleaned for better reviewing.
Added Neutrino node which will communicate with the network.
Added
sendGetCFilters
- Gets compact filters from peer.sendGetCFHeaders
- Gets Compact filter headers from peer.sendGetCFCheckpt
- Gets Filters using checkpointsAdded
saveFilter
andsaveFilterHeader
methods infilterIndexer
. While saving filterHeader I am keeping the filter field empty.Added
NeutrinoState
which helps to keep track of thefilterHeaderHeight
and thefilterHeight
Added
headersFull
, which indicates that we can start fetching filter headerscfheaders
event, which indicates that we can start fetching filters.cfilter
event, which sends the filter to the wallet and marks beginning of filter matching for the particular filter.Added
checkFilter
: Checks the filter against all address hashes in the wallet db. Address hashes are first converted to output scripts and that is then matched against the filter.Added
getBlockFromNode
andgetBlockPeer
: These methods help the client to download a particular block when any filter matches on the wallet side.Added RPC methods:
getfiltercount
: Gets the filter height in NeutrinoStategetfilterheadercount
: Gets the filter header height in NeutrinoStategetblockfilterheader
: Retrieves filter header for a particular block