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

fix(synchroniser): Store most recent globals hash in the synchroniser, rather than fetching from the latest block #1539

Merged
merged 13 commits into from
Aug 14, 2023

Conversation

Maddiaa0
Copy link
Member

@Maddiaa0 Maddiaa0 commented Aug 11, 2023

fixes: #1537

Stores the most recent global variables hash within the synchroniser rather than fetching it from the most recent block. This created a race condition where the globals hash requested from the block was ahead of the tree roots requested from the node.

As the tree roots were being requested from the node the synchroniser was also behind.

@Maddiaa0 Maddiaa0 changed the title feat(synchroniser): Store most recent globals hash in the synchroniser, rather than fetching from the latest block fix(synchroniser): Store most recent globals hash in the synchroniser, rather than fetching from the latest block Aug 11, 2023
@Maddiaa0 Maddiaa0 marked this pull request as ready for review August 11, 2023 20:20
@Maddiaa0 Maddiaa0 requested review from dbanks12 and LHerskind August 11, 2023 20:20
return Promise.resolve();
}

// TODO / Reviewers note: shall i remove the tree roots and globals hash entirely and just have this? Its all the sim needs.
Copy link
Member Author

Choose a reason for hiding this comment

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

drawing attention to this comment!

Copy link
Contributor

Choose a reason for hiding this comment

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

Both setters and getters? If we are not using the functions standalone in any cases anymore I think it would be fine to remove it. I don't see many cases where you would only want the globalVariablesHash neither, so think the overhead over getting the tree roots directly is fine.

@ludamad
Copy link
Collaborator

ludamad commented Aug 11, 2023

Is it feasible to make a test that tracks this if it regresses?

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Main thing is naming consistency, constant used in the naming sometimes but not every time.

*
* @returns A Promise that resolves to a ConstantHistoricBlockData object.
*/
getConstantHistoricBlockData(): Promise<ConstantHistoricBlockData> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you not just use db.getHistoricBlockData directly here instead of reimplementing? Also, the naming is not fully consistent if including constant or not.

Copy link
Member Author

@Maddiaa0 Maddiaa0 Aug 11, 2023

Choose a reason for hiding this comment

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

correct this is clutter from before i implemented db.

@@ -47,16 +34,11 @@ export async function deployAndInitializeNonNativeL2TokenContracts(
rollupRegistryAddress: EthAddress,
initialBalance = 0n,
owner = AztecAddress.ZERO,
underlyingERC20Address?: EthAddress
underlyingERC20Address?: EthAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

Were formatting not run here before or skipped now? Seems like quite a few formatting changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Were formatting not run here before or skipped now? Seems like quite a few formatting changes.

Ah looks like formatting isnt enforced for it, but i ran the formatter for the whole repo. Ill probably turn the formatter on in another pr

@Maddiaa0
Copy link
Member Author

Is it feasible to make a test that tracks this if it regresses?

I dont think it is without creating a test that has sufficiently many blocks that the node sync starts to drag behind the rest of the test. However if any one has other ideas ill take it on

@Maddiaa0
Copy link
Member Author

Main thing is naming consistency, constant used in the naming sometimes but not every time.

Probably going to drop the constant from it, its within the constants object in circuits, its implied that it is constant

@Maddiaa0 Maddiaa0 requested a review from LHerskind August 11, 2023 22:22
@ludamad
Copy link
Collaborator

ludamad commented Aug 11, 2023

I dont think it is without creating a test that has sufficiently many blocks that the node sync starts to drag behind the rest of the test. However if any one has other ideas ill take it on

Sounds like a fuzzing sort of task + therefore out of scope. Something that kicks off nightly and runs for some time X (increasing period of time as we add features) would be cool though. Made #1545

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

LGTM

@Maddiaa0 Maddiaa0 merged commit 1dd6225 into master Aug 14, 2023
@Maddiaa0 Maddiaa0 deleted the md/race branch August 14, 2023 11:45
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.

feat: store recent public data tree / globals hash of most recent block in rpc server
3 participants