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(rln-relay): sync from deployed block number #1955

Merged
merged 3 commits into from
Aug 29, 2023

Conversation

rymnc
Copy link
Contributor

@rymnc rymnc commented Aug 26, 2023

Description

Syncs from the deployed block number to prevent excess network calls

Changes

  • removed decay factor, static chunk size of 2000
  • handles eth rpc reconnection
  • syncs from deployment block of the storage contract

Issue

closes #1942

@rymnc rymnc self-assigned this Aug 26, 2023
@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1955

@rymnc rymnc marked this pull request as ready for review August 26, 2023 07:28
Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

lgtm! Thanks for this, a great improvement that will i) reduce rln tree sync time by a lot and ii) avoid choking eth nodes by requesting less blocks at once (something quite important when using your own non infura node)

left some comments, nothing critical but relevant imho.

@alrevuelta
Copy link
Contributor

🚀 thanks!

Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

couple of comments, one might be important?

else:
let deployedBlockNumber = g.rlnContractDeployedBlockNumber.get()
let deployedBlockNumber = g.rlnContractDeployedBlockNumber
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, but not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 110a8a8

@@ -76,11 +76,11 @@ template initializedGuard(g: OnchainGroupManager): untyped =


proc setMetadata*(g: OnchainGroupManager): RlnRelayResult[void] =
if g.latestProcessedBlock.isNone():
if g.latestProcessedBlock == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

mmm do we still need to error here? guess 0 could be an ok value? eg at startup?

Copy link
Contributor Author

@rymnc rymnc Aug 28, 2023

Choose a reason for hiding this comment

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

there shouldn't be a reason to save the metadata if the latest block number is 0, hence there were 2 options here, either a noop or an error, went for the latter
addressed in b78072c

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! thanks!

@@ -39,6 +39,7 @@ contract(RlnStorage):
proc MEMBERSHIP_DEPOSIT(): Uint256 {.pure.}
proc members(idCommitment: Uint256): Uint256 {.view.}
proc idCommitmentIndex(): Uint256 {.view.}
proc deployedBlockNumber(): Uint256 {.view.}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks nice indeed! However, I wonder if we could add comments above each of these procs to elaborate more about their purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will address in a follow up pr :)

info "reconnecting with the Ethereum client, and restarting group sync", fromBlock = fromBlock
try:
let newEthRpc = waitFor newWeb3(g.ethClientUrl)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if makes sense to perform some retrial mechanism?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi! #1958 tracks handling delays, this piece of code does handle the reconnections!

@rymnc rymnc merged commit bd3be21 into master Aug 29, 2023
13 checks passed
@rymnc rymnc deleted the use-deployed-block-number branch August 29, 2023 07:42
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.

bug + chore: Unhandled exception + fix reducing blockChunkSize
3 participants