-
Notifications
You must be signed in to change notification settings - Fork 296
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
multi: Fast relay checked tip blocks. #1443
Conversation
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.
Working as intended. Tested by adding some instrumentation and using a serial network layout:
https://gist.github.com/matheusd/c2d4e13cb2c68121680955e777c5057d
// Typically, a caller would want to use this notification to relay the | ||
// block to the rest of the network without needing to wait for the more | ||
// time consuming full connection to take place. | ||
NTNewTipBlockChecked NotificationType = iota |
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.
why can't this be added to the end, to leave the other constants the same values?
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.
I prefer to have them defined in the order they are invoked.
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.
But it's a breaking change
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.
Nevermind, these constants should only be referred to by their name, not literals, and afaik they are not serialized anywhere.
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.
Correct. They are not serialized anywhere.
This adds a new function to peers which allows an inventory vector to be queued for immediate send versus the standard trickling batched inventory queue method while still respecting the functionality which filters attempts to notify peers about inventory that they are already known to have.
This modifies the infrastructure for the server inventory relay to allow the caller to specify the inventory should be announced immediately versus using the typical trickle mechanism. It also updates all callers in the repository and changes the relay of accepted blocks use the new ability.
This adds a new notification type to blockchain which allows the caller to be notified when a block that intents to extend the main chain has passed all sanity and contextual checks such as having valid proof of work, valid merkle and stake roots, and only containing allowed votes and revocations. The intention is to allow faster relay of new tip blocks throughout the network by providing a means to relay it before the more expensive connection code takes place even though it may ultimately fail to connect. This is acceptable because blocks that pass all of the aforementioned checks and then fail to connect are quite rare since it takes a significant amount of work to create a block which satisfies the proof of work requirement as well as all other checks up to that point.
This makes use of the newly exposed notification from blockchain when a block that intends to extend the main chain has passed all sanity and contextual checks to relay the block the rest of the network at that point rather than needing to wait for the more expensive connection code to complete.
38ba952
to
fefb892
Compare
This PR consists of several commits which ultimately immediately relays blocks that intend to extend the main chain to the rest of the network directly after they have passed all sanity and contextual checks rather than waiting for the more expensive connection code to complete.
This is acceptable because blocks that pass all of the aforementioned checks and then fail to connect are quite rare since it takes a significant amount of work to create a block which satisfies the proof of work requirement as well as all other checks up to that point.
The first commit adds a new function to
peer
namedQueueInventoryImmediate
which allows an inventory vector to be queued for immediate send versus the standard trickling batched inventory queue method while still respecting the functionality which filters attempts to notify peers about inventory that they are already known to have.The second commit modifies the infrastructure for
server
inventory relay to allow the caller to specify the inventory should be announced immediately versus using the typical trickle mechanism, updates all callers in the repository accordingly, and changes the relay of accepted blocks use the new ability.The third commit adds a new notification type to
blockchain
namedNTNewTipBlockChecked
which allows the caller to be notified when a block that intents to extend the main chain has passed all sanity and contextual checks such as having valid proof of work, valid merkle and stake roots, and only containing allowed votes and revocations.Finally, the fourth commit makes use of the newly exposed notification from
blockchain
to relay the block the rest of the network at that point rather as previously described.