-
Notifications
You must be signed in to change notification settings - Fork 378
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
Faster sync #6563
Faster sync #6563
Conversation
The selective event filtering introduced in raiden-network/raiden#6563 changed the API, which make this commit necessary.
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.
LGTM, just a typo and a question left.
raiden/blockchain/filters.py
Outdated
|
||
def union(self, other: "RaidenContractFilter") -> "RaidenContractFilter": | ||
""" Return a new RaidenContractFilter with all elements from both input filters """ | ||
# We must not have to different non-None secret registries. Choose the non-None one. |
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 must not have to different non-None secret registries. Choose the non-None one. | |
# We must not have two different non-None secret registries. Choose the non-None one. |
@@ -318,21 +318,6 @@ def token_network_address(self) -> TokenNetworkAddress: | |||
# FIXME: remove on next breaking release |
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.
Do we still need this comment?
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 (ContractReceiveRouteClosed) shouldn't be removed if the released is supposed to be backwards-compatible.
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.
right, but it is removed in this PR isn't it?
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.
That's my point. Depending on what the goals are, this should eventually stay.
Instead of requesting all events for the relevant contracts, we filter much more selectively by including the right topics.
Apparently, it is faster to include a topic, event when you want to filter for all events of a contract.
If we don't have a channel, we are not interested in any secrets registered online. Thus we can skip the slow event log queries until we open our first channel.
For each block range, we make multiple requests with different filters. Before this commit, only the last request duration has been used to adjust the batch size. But the point of the adjustment is to prevent any request from running into a timeout, so adjusting based on the maximal duration of all requests is a better way to achieve this.
After working with this a bit, the defaultdict seemed to make things less clear than a using a normal dict with `get` and `setdefault`.
The selective event filtering introduced in raiden-network/raiden#6563 changed the API, which make this commit necessary.
The selective event filtering introduced in raiden-network/raiden#6563 changed the API, which make this commit necessary.
The selective event filtering introduced in raiden-network/raiden#6563 changed the API, which make this commit necessary.
Improve event syncing speed by filtering more selectively. This brings down the initial sync on mainnet for a fresh node to 30s (parity, infura) to 2mins (geth).
Before
Fetch all events for the relevant contracts and filter in the Raiden client
After
TokenNetworkCreated
events from TN registryChannelOpened
events that include the node as participantChannelClosed
,ChannelSettled
,ChannelNewDeposit
andChannelWithdraw
eventsSecretRevealed
events from the SecretRegistry once the node starts to participate in a channelCloses #6497
The SP integration test must fail until raiden-network/scenario-player#635 is merged, which has to be based on this PR. To break the cycle, I will force merge this when all tests but the SP integration are green.
Potential future optimizations if we need more speed: