Skip to content
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: new NoteProcessor works through all blocks #1404

Merged
merged 8 commits into from
Aug 4, 2023

Conversation

benesjan
Copy link
Contributor

@benesjan benesjan commented Aug 3, 2023

  1. Fixes Process notes from older blocks when adding a new account to the RPC server #1392
  2. Fixes bug in FunctionL2Logs.random
  3. Used INITIAL_L2_BLOCK_NUM constant in more places

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@benesjan benesjan marked this pull request as draft August 3, 2023 13:51
@benesjan benesjan force-pushed the janb/note-processor-catch-up branch from f831bb2 to ba176c4 Compare August 4, 2023 07:09
@benesjan benesjan force-pushed the janb/note-processor-catch-up branch from b3b439e to dea49f3 Compare August 4, 2023 08:14
@benesjan benesjan marked this pull request as ready for review August 4, 2023 08:16
Copy link
Collaborator

@PhilWindle PhilWindle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable

@benesjan benesjan merged commit c8e7d53 into master Aug 4, 2023
@benesjan benesjan deleted the janb/note-processor-catch-up branch August 4, 2023 09:38
Comment on lines +234 to +240
if (this.synchedToBlock === 0) {
// The main sync thread was never started before and for this reason the synchroniser does not have to catch up
this.noteProcessors.push(noteProcessor);
} else {
// The main sync thread was started before and for this reason the synchroniser has to catch up
this.noteProcessorsToCatchUp.push(noteProcessor);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benesjan sorry for going back to a merged PR, but I think you may have a race condition here: if a noteProcessor is added on the first run of work during await this.updateBlockInfoInBlockTxs(blockContexts), which happens after the note processors are notified but before updating synchedToBlock, then it will be pushed to noteProcessors but will never get the notes from the first iteration.

If the above is correct, maybe you can solve it with a flag isStarted that you set as soon as start is called, and check that instead of synchedToBlock?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @spalladino is right. Perhaps a clean solution is to always add the note processor to noteProcessorsToCatchUp and have workNoteProcessorCatchUp transfer it to noteProcessors in all scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spalladino great catch! Will address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Process notes from older blocks when adding a new account to the RPC server
3 participants