-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Implement SFNodeBloom. #499
Conversation
@@ -18,7 +18,7 @@ import ( | |||
const MaxUserAgentLen = 2000 | |||
|
|||
// DefaultUserAgent for wire in the stack | |||
const DefaultUserAgent = "/btcwire:0.2.1/" | |||
const DefaultUserAgent = "/btcwire:0.2.2/" |
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 be 0.3.0
. Typically it's <major>.<minor>.<patch>
and this is adding a new flag and bumping the protocol version, so it's more than a patch.
Commit message has |
--dropaddrindex= Deletes the address-based transaction index from the | ||
database on start up, and the exits. | ||
-V, --version Display version information and exit | ||
-C, --configfile= Path to configuration file (/home/dhill/.btcd/btcd.conf) |
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.
The defaults should be removed here. Notice it wasn't there previously.
Also |
SFNodeBloom is a new service flag that a node is required to use to indicate that it supports bloom filtering. This includes a protocol version bump to 70011 and a wire version bump to 0.3.0. btcd: The SFNodeBloom flag is set by default. A new configuration option --nopeerbloomfilters has been added to to disable bloom filtering. Any node advertising a version greater than or equal to 70011 that attempts to use bloom filtering will be disconnected if bloom filtering is disabled. This mimics Bitcoin Core commit afb0ccaf9c9e4e8fac7db3564c4e19c9218c6b03
Nice work. Everything looks good to me now. OK |
ok |
* Rebase btcsuite#499 * Fix tests by removing hardcoded useragent, protocol version
* Rebase btcsuite#499 * Fix tests by removing hardcoded useragent, protocol version Moved flag fields from stats to Peer Address review items: * Remove defer in simple case * Start err text with lower case * Fixed data race in TestOutboundPeer * Declare isValidBIP0111 before use Remove addrMgr in example_test.go Address review items: * Use services flag 0 in example * Remove defer in Add/Remove listeners * Remove todo for alerts Refactor to replace add/remove listeners with funcs Use bytes.Buffer writer in log tests. This prevents undesired log output to stdout while running the tests. Move a couple of funcs for consistent ordering. Use 0 for services in tests since not full nodes. peer: generate and use unique nonce at package level. This changes the logic around the nonce to make it handled by the package rather than the caller. This makes sense because the real access pattern is not the same as what the tests need to do and it simplifies the logic for the caller. In particular, all peers that are created by this package, whether they are inbound or outbound need to have the same "factory" nonce under any realistic scenario outside of tests. This is because the entire point of the nonce is to be used to detect self connections. This change also means the example had to be changed because it wasn't really representative of the proper way a caller will interact with this package due to requiring different nonces. As a result, the example was simplified to only showcase an outbound peer. Don't log or send reject message due to disconnect. Remove trace logs that aren't particularly helpful. Allow the peer.Config.NewestBlock function to be nil. lookupFunc not used in example_test.go - move it Finish TODO to switch queueWg to queueQuit chan. Remove duplicate negotiate print. peer: Unique nonce per peer. Rather than only generating a single nonce at init time, generate a unique nonce for each pushed version message and keep track of them in a limited and concurrent safe most-recently-used nonce map so the self connection detection still works. Remove unused mruinvmap bits from btcd main dir. Access to fields in trace stmt need mutex. Move comment about peer addr inside function. Callers don't need to know about this. Don't convert fields in state snapshot in peer. The caller might want to do things with this information and pre-formatting it for the RPC server would prevent that. Instead, return the fields using their native types in the snapshot and then convert them in the RPC server as needed. Explicitly comment concurrent safe funcs. Also use a style consistent with the rest of the code base. Add some more details in a few comments. Make peer.Config.Listeners concrete instead of pointer. This removes the need for checking against nil everywhere and still allows is not to be specified since the zero value will contain all nil pointers for the callbacks. Rename listeners and remove On{Read,Write}. Bring back OnRead/OnWrite with better comments. Use new listener names in example. Update server for new listeners Fix build issues with go vet Take chain params in config instead of net + regtest flag. Set to testnet by default if not specified. Make copy of peer config so caller can't modify after. Use global request map to avoid duplicate getdata Address review items: * Re-order peer entry in docs * Move PingTime in assignment * Cleanup peer tests Restore TestPeerConnection Added peer listener tests Reuse peer config Restore done peers Make the Config.ProtocolVersion comments more explicit. Consistent case in trace statement. Improve comments on peer.Config fields. Also reorder them to more naturally group their function. Add handler for MsgMerkleBlock. Various cleanup. - Improve and correct some comments - Correct a log print - Add log print for disconnect due to not receiving initial version msg - Code consistency with spacing and comments
This commit introduces package peer which contains peer related features extracted from peer.go. It allows registration of custom message listeners to implement full nodes, SPV nodes, etc. Basic handshake including protocol negotiation is included by default. Refactor to integrate package peer This commit integrates the new package peer. It involves extending the basic peer provided by the package to work with the blockmanager and server to act as a full node. Address review items: * Rebase btcsuite#499 * Fix tests by removing hardcoded useragent, protocol version Moved flag fields from stats to Peer Address review items: * Remove defer in simple case * Start err text with lower case * Fixed data race in TestOutboundPeer * Declare isValidBIP0111 before use Remove addrMgr in example_test.go Address review items: * Use services flag 0 in example * Remove defer in Add/Remove listeners * Remove todo for alerts Refactor to replace add/remove listeners with funcs Use bytes.Buffer writer in log tests. This prevents undesired log output to stdout while running the tests. Move a couple of funcs for consistent ordering. Use 0 for services in tests since not full nodes. peer: generate and use unique nonce at package level. This changes the logic around the nonce to make it handled by the package rather than the caller. This makes sense because the real access pattern is not the same as what the tests need to do and it simplifies the logic for the caller. In particular, all peers that are created by this package, whether they are inbound or outbound need to have the same "factory" nonce under any realistic scenario outside of tests. This is because the entire point of the nonce is to be used to detect self connections. This change also means the example had to be changed because it wasn't really representative of the proper way a caller will interact with this package due to requiring different nonces. As a result, the example was simplified to only showcase an outbound peer. Don't log or send reject message due to disconnect. Remove trace logs that aren't particularly helpful. Allow the peer.Config.NewestBlock function to be nil. lookupFunc not used in example_test.go - move it Finish TODO to switch queueWg to queueQuit chan. Remove duplicate negotiate print. peer: Unique nonce per peer. Rather than only generating a single nonce at init time, generate a unique nonce for each pushed version message and keep track of them in a limited and concurrent safe most-recently-used nonce map so the self connection detection still works. Remove unused mruinvmap bits from btcd main dir. Access to fields in trace stmt need mutex. Move comment about peer addr inside function. Callers don't need to know about this. Don't convert fields in state snapshot in peer. The caller might want to do things with this information and pre-formatting it for the RPC server would prevent that. Instead, return the fields using their native types in the snapshot and then convert them in the RPC server as needed. Explicitly comment concurrent safe funcs. Also use a style consistent with the rest of the code base. Add some more details in a few comments. Make peer.Config.Listeners concrete instead of pointer. This removes the need for checking against nil everywhere and still allows is not to be specified since the zero value will contain all nil pointers for the callbacks. Rename listeners and remove On{Read,Write}. Bring back OnRead/OnWrite with better comments. Use new listener names in example. Update server for new listeners Fix build issues with go vet Take chain params in config instead of net + regtest flag. Set to testnet by default if not specified. Make copy of peer config so caller can't modify after. Use global request map to avoid duplicate getdata Address review items: * Re-order peer entry in docs * Move PingTime in assignment * Cleanup peer tests Restore TestPeerConnection Added peer listener tests Reuse peer config Restore done peers Make the Config.ProtocolVersion comments more explicit. Consistent case in trace statement. Improve comments on peer.Config fields. Also reorder them to more naturally group their function. Add handler for MsgMerkleBlock. Various cleanup. - Improve and correct some comments - Correct a log print - Add log print for disconnect due to not receiving initial version msg - Code consistency with spacing and comments
This commit introduces package peer which contains peer related features extracted from peer.go. It allows registration of custom message listeners to implement full nodes, SPV nodes, etc. Basic handshake including protocol negotiation is included by default. Refactor to integrate package peer This commit integrates the new package peer. It involves extending the basic peer provided by the package to work with the blockmanager and server to act as a full node. Address review items: * Rebase btcsuite#499 * Fix tests by removing hardcoded useragent, protocol version Moved flag fields from stats to Peer Address review items: * Remove defer in simple case * Start err text with lower case * Fixed data race in TestOutboundPeer * Declare isValidBIP0111 before use Remove addrMgr in example_test.go Address review items: * Use services flag 0 in example * Remove defer in Add/Remove listeners * Remove todo for alerts Refactor to replace add/remove listeners with funcs Use bytes.Buffer writer in log tests. This prevents undesired log output to stdout while running the tests. Move a couple of funcs for consistent ordering. Use 0 for services in tests since not full nodes. peer: generate and use unique nonce at package level. This changes the logic around the nonce to make it handled by the package rather than the caller. This makes sense because the real access pattern is not the same as what the tests need to do and it simplifies the logic for the caller. In particular, all peers that are created by this package, whether they are inbound or outbound need to have the same "factory" nonce under any realistic scenario outside of tests. This is because the entire point of the nonce is to be used to detect self connections. This change also means the example had to be changed because it wasn't really representative of the proper way a caller will interact with this package due to requiring different nonces. As a result, the example was simplified to only showcase an outbound peer. Don't log or send reject message due to disconnect. Remove trace logs that aren't particularly helpful. Allow the peer.Config.NewestBlock function to be nil. lookupFunc not used in example_test.go - move it Finish TODO to switch queueWg to queueQuit chan. Remove duplicate negotiate print. peer: Unique nonce per peer. Rather than only generating a single nonce at init time, generate a unique nonce for each pushed version message and keep track of them in a limited and concurrent safe most-recently-used nonce map so the self connection detection still works. Remove unused mruinvmap bits from btcd main dir. Access to fields in trace stmt need mutex. Move comment about peer addr inside function. Callers don't need to know about this. Don't convert fields in state snapshot in peer. The caller might want to do things with this information and pre-formatting it for the RPC server would prevent that. Instead, return the fields using their native types in the snapshot and then convert them in the RPC server as needed. Explicitly comment concurrent safe funcs. Also use a style consistent with the rest of the code base. Add some more details in a few comments. Make peer.Config.Listeners concrete instead of pointer. This removes the need for checking against nil everywhere and still allows is not to be specified since the zero value will contain all nil pointers for the callbacks. Rename listeners and remove On{Read,Write}. Bring back OnRead/OnWrite with better comments. Use new listener names in example. Update server for new listeners Fix build issues with go vet Take chain params in config instead of net + regtest flag. Set to testnet by default if not specified. Make copy of peer config so caller can't modify after. Use global request map to avoid duplicate getdata Address review items: * Re-order peer entry in docs * Move PingTime in assignment * Cleanup peer tests Restore TestPeerConnection Added peer listener tests Reuse peer config Restore done peers Make the Config.ProtocolVersion comments more explicit. Consistent case in trace statement. Improve comments on peer.Config fields. Also reorder them to more naturally group their function. Add handler for MsgMerkleBlock. Various cleanup. - Improve and correct some comments - Correct a log print - Add log print for disconnect due to not receiving initial version msg - Code consistency with spacing and comments
* Rebase btcsuite#499 * Fix tests by removing hardcoded useragent, protocol version Moved flag fields from stats to Peer Address review items: * Remove defer in simple case * Start err text with lower case * Fixed data race in TestOutboundPeer * Declare isValidBIP0111 before use Remove addrMgr in example_test.go Address review items: * Use services flag 0 in example * Remove defer in Add/Remove listeners * Remove todo for alerts Refactor to replace add/remove listeners with funcs Use bytes.Buffer writer in log tests. This prevents undesired log output to stdout while running the tests. Move a couple of funcs for consistent ordering. Use 0 for services in tests since not full nodes. peer: generate and use unique nonce at package level. This changes the logic around the nonce to make it handled by the package rather than the caller. This makes sense because the real access pattern is not the same as what the tests need to do and it simplifies the logic for the caller. In particular, all peers that are created by this package, whether they are inbound or outbound need to have the same "factory" nonce under any realistic scenario outside of tests. This is because the entire point of the nonce is to be used to detect self connections. This change also means the example had to be changed because it wasn't really representative of the proper way a caller will interact with this package due to requiring different nonces. As a result, the example was simplified to only showcase an outbound peer. Don't log or send reject message due to disconnect. Remove trace logs that aren't particularly helpful. Allow the peer.Config.NewestBlock function to be nil. lookupFunc not used in example_test.go - move it Finish TODO to switch queueWg to queueQuit chan. Remove duplicate negotiate print. peer: Unique nonce per peer. Rather than only generating a single nonce at init time, generate a unique nonce for each pushed version message and keep track of them in a limited and concurrent safe most-recently-used nonce map so the self connection detection still works. Remove unused mruinvmap bits from btcd main dir. Access to fields in trace stmt need mutex. Move comment about peer addr inside function. Callers don't need to know about this. Don't convert fields in state snapshot in peer. The caller might want to do things with this information and pre-formatting it for the RPC server would prevent that. Instead, return the fields using their native types in the snapshot and then convert them in the RPC server as needed. Explicitly comment concurrent safe funcs. Also use a style consistent with the rest of the code base. Add some more details in a few comments. Make peer.Config.Listeners concrete instead of pointer. This removes the need for checking against nil everywhere and still allows is not to be specified since the zero value will contain all nil pointers for the callbacks. Rename listeners and remove On{Read,Write}. Bring back OnRead/OnWrite with better comments. Use new listener names in example. Update server for new listeners Fix build issues with go vet Take chain params in config instead of net + regtest flag. Set to testnet by default if not specified. Make copy of peer config so caller can't modify after. Use global request map to avoid duplicate getdata Address review items: * Re-order peer entry in docs * Move PingTime in assignment * Cleanup peer tests Restore TestPeerConnection Added peer listener tests Reuse peer config Restore done peers Make the Config.ProtocolVersion comments more explicit. Consistent case in trace statement. Improve comments on peer.Config fields. Also reorder them to more naturally group their function. Add handler for MsgMerkleBlock. Various cleanup. - Improve and correct some comments - Correct a log print - Add log print for disconnect due to not receiving initial version msg - Code consistency with spacing and comments Remove outdated docs
SFNodeBloom is a new service flag that a node is required to use to indicate that it supports bloom filtering. This includes a protocol version bump to 70011 and a wire version bump to 0.3.0.
btcd:
The SFNodeBloom flag is set by default. A new configuration option
--nopeerbloomfilters
has been added to to disable bloom filtering.Any node advertising a version greater than or equal to 70011 that attempts to use bloom filtering will be disconnected if bloom filtering is disabled.
This mimics Bitcoin Core commit afb0ccaf9c9e4e8fac7db3564c4e19c9218c6b03