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

chore(rln-relay): health check should account for window of roots #2664

Merged
merged 4 commits into from
May 8, 2024

Conversation

rymnc
Copy link
Contributor

@rymnc rymnc commented May 3, 2024

Description

This PR modifies the ready behaviour of rln-relay's onchain mode. If the node is behind the tip of the blockchain by window blocks, it should still be marked as ready IMO.

Changes

  • returns ready if the node is behind the tip of the blockchain by window blocks

Copy link

github-actions bot commented May 3, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2664-rln-v1

Built from 6db6820

Copy link

github-actions bot commented May 3, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2664-rln-v2

Built from 6db6820

@rymnc rymnc requested review from alrevuelta and Ivansete-status and removed request for alrevuelta May 6, 2024 06:19
@rymnc rymnc marked this pull request as ready for review May 6, 2024 06:19
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! Thank! 💯

@@ -855,7 +855,8 @@ method isReady*(g: OnchainGroupManager): Future[bool] {.async.} =
g.retryWrapper(currentBlock, "Failed to get the current block number"):
cast[BlockNumber](await g.ethRpc.get().provider.eth_blockNumber())

if g.latestProcessedBlock < currentBlock:
# the node is still able to process messages if it is behind the latest block by a factor of the valid roots
if uint(g.latestProcessedBlock) < uint(currentBlock) - uint(g.validRoots.len):
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 is safer to add parenthesis:

Suggested change
if uint(g.latestProcessedBlock) < uint(currentBlock) - uint(g.validRoots.len):
if uint(g.latestProcessedBlock) < ( uint(currentBlock) - uint(g.validRoots.len) ):

Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't harm, i would add it as well :)

@@ -855,7 +855,8 @@ method isReady*(g: OnchainGroupManager): Future[bool] {.async.} =
g.retryWrapper(currentBlock, "Failed to get the current block number"):
cast[BlockNumber](await g.ethRpc.get().provider.eth_blockNumber())

if g.latestProcessedBlock < currentBlock:
# the node is still able to process messages if it is behind the latest block by a factor of the valid roots
if uint(g.latestProcessedBlock) < uint(currentBlock) - uint(g.validRoots.len):
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it better widening rather than narrowing? i mean instead of casting everything to unit and operating with that, using the latestProcessedBlock type which has more bits and then "widening" validRoots to do the -?

wondering also if in the first run we can hit currentBlock-g.validRoots.len where currentBlock=0 and since we are using unit that will lead to a huge value, meaning that we are ready when we are not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

currentBlock will never be 0, since that is fetched from the chain (and we can operate under the assumption that it will always be greater than 0). good point about widening vs narrowing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

casted to u256 - 442ca43

@@ -855,7 +855,8 @@ method isReady*(g: OnchainGroupManager): Future[bool] {.async.} =
g.retryWrapper(currentBlock, "Failed to get the current block number"):
cast[BlockNumber](await g.ethRpc.get().provider.eth_blockNumber())

if g.latestProcessedBlock < currentBlock:
# the node is still able to process messages if it is behind the latest block by a factor of the valid roots
if uint(g.latestProcessedBlock) < uint(currentBlock) - uint(g.validRoots.len):
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't harm, i would add it as well :)

@rymnc rymnc requested a review from alrevuelta May 8, 2024 08:19
@rymnc rymnc changed the title test(rln-relay): health check should account for window of roots chore(rln-relay): health check should account for window of roots May 8, 2024
@rymnc rymnc merged commit 6a1af92 into master May 8, 2024
14 of 15 checks passed
@rymnc rymnc deleted the lax-health-check branch May 8, 2024 12:18
Ivansete-status pushed a commit that referenced this pull request May 14, 2024
)

* test(rln-relay): health check should account for window of roots

* fix: some type-fu

* fix: widen the type vs narrowing

* fix: add extra parens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants