-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat(rln-relay): Keep track of the last processed event for membership changes #1265
Comments
Changed the state of this issue assuming it is in progress. If not, please move it back to the Backlog. |
I remember we agreed that cursor to be an always increasing value that keeps track of the index of the last inserted pk. |
That works too. It would not make a difference between the two. If you prefer it, I can use the index of the last inserted pk |
If there is no specific benefit regarding the per-block cursor, then a global cursor for the index of the last inserted pk is a more flexible solution (e.g., it is agnostic to how group synchronization works, and it would be also easily adaptable to any alternative solutions we want to use for the calculation of window of acceptable roots) |
I'm not completely convinced about replacing the 0/1 cursor with the latest membership Index seen: that works well with registrations, but what about deletions? It seems like we need to store a value for each event we're listening to.. While a 0/1 flag that indicates if a block is fully processed or not is much more natural to me:
Did I miss something? |
@s1fr0, with #1266, the roots will change on a per block basis. Although, I do understand your point for membership deletions. The event emitted on membership deletions looks to have the same structure as registrations - Maybe we could track registrations and deletions separately. |
I think what you say would have made more sense if processing each registration was a particularly expensive operation, hence saving some tree insertions was worth it. However I don't think this is the case and we do not expect many registrations happening in a block (in the edge case of a block having exclusively membership registrations we cannot have more than ~600 in a block - registration costs ~51k Gas, block seems to have a limit of 30M Gas, but this ignores completely block size and other limits). From Zerokit tests, on an old laptop tree insertion takes roughly 900µs, hence 600 additions would take half a second. Furthermore, we cannot download a block partially, so we have to go through its full content anyway. I believe that processing all block's registrations/deletions at once is better: conceptually we only have one root change (and not intermediate ones in case of connection drops) and that's what we meant by allowing a windows of valid roots. Zerokit exposes |
Agreed. Can we then deprecate this feature in favor of #1266 and process blocks atomically? |
@s1fr0 @rymnc
Does that address everyone's concerns? |
Problem
To allow reconnections to the Ethereum node, we need to keep a track of the last event that was processed re: Membership changes. This allows the node to reconnect, and resume the tree sync from the last processed event to avoid inconsistencies in the tree root.
Suggested solution
The suggested solution would involve a cursor which is set back to 0 after each block is processed by the node. We already keep a track of the last block processed, which can then be used to resubscribe to the events starting from that block.
Alternatives considered
We could process blocks atomically.
Additional context
None
Acceptance criteria
The text was updated successfully, but these errors were encountered: