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: mount metadata in wakucanary #2793

Merged
merged 2 commits into from
Jun 14, 2024
Merged

fix: mount metadata in wakucanary #2793

merged 2 commits into from
Jun 14, 2024

Conversation

darshankabariya
Copy link
Contributor

@darshankabariya darshankabariya commented Jun 9, 2024

closes #2720

Add cluster ID and shards in the Wakucanary configuration, and then mount this metadata information to Wakunode.

Copy link

github-actions bot commented Jun 9, 2024

You can find the image built from this PR at

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

Built from 70f3696

Copy link

github-actions bot commented Jun 9, 2024

You can find the image built from this PR at

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

Built from 70f3696

Copy link

This PR may contain changes to configuration options of one of the apps.

If you are introducing a breaking change (i.e. the set of options in latest release would no longer be applicable) make sure the original option is preserved with a deprecation note for 2 following releases before it is actually removed.

Please also make sure the label release-notes is added to make sure any changes to the user interface are properly announced in changelog and release notes.

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

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

Ooh thanks so much! added a small comment :))

Comment on lines 197 to 205
proc mountMetadata*(
node: WakuNode, clusterId: uint32, shards: seq[uint16] = @[]
): Result[void, string] =
if not node.wakuMetadata.isNil():
return err("Waku metadata already mounted, skipping")

let metadata = WakuMetadata.new(clusterId, node.enr, node.topicSubscriptionQueue)

for shard in shards:
metadata.shards.incl(uint32(shard))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this change is not necessary and might be problematic.
The shards are added to metadata in WakuMetadata.newby using the parameter node.enr

If the node used in the Canary is subscribed to the right shards, then they should be in the ENR and added from there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Gabriel !

Then i should try to add this shards information in ENR.

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.

It looks well so far! Good work 🙌
Nevertheless, there are a couple of points to be considered. See my comments:)
Also, kindly revert the change around vendor/nim-bearssl. We shouldn't change that in this PR

--websocket-secure-key-path Secure websocket key path: '/path/to/key.txt' .
--websocket-secure-cert-path Secure websocket Certificate path: '/path/to/cert.txt' .

-c, --cluster-id Cluster ID of the fleet node to check status [Default=1].
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the README.md I think is missing explaining about the shards parameter and give an example on how to use it and why

Comment on lines 204 to 205
for shard in shards:
metadata.shards.incl(uint32(shard))
Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems correct from my PoV but let's ask SP about it:

@SionoiS - Do you think there is a more idiomatic way to achieve that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes? I find it weird to add this to waku_node.nim when this PR is about adapting the Canary to it. I would expect that if this line would be missing, then we would have some bug open about it

Copy link
Collaborator

@Ivansete-status Ivansete-status Jun 12, 2024

Choose a reason for hiding this comment

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

Yes? I find it weird to add this to waku_node.nim when this PR is about adapting the Canary to it. I would expect that if this line would be missing, then we would have some bug open about it

I think that @darshankabariya's suggestion sounds very reasonable and looks more explicit. Also, it seems correct too because we are already passing the clusterId as a parameter in mountMetadata.

Nevertheless, you and SP might have more context than me about that and there might be a more idiomatic way to achieve that, i.e. the way you suggested (which I didn't see while I was adding my first comment .)

Copy link
Contributor

Choose a reason for hiding this comment

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

The less we add to wakunode the better IMO. In this case, you can have WakuMetadata add shard by subscribing to them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @SionoiS, @gabrielmer, and @Ivansete-status. I'll update the implementation to add shard information via ENR.

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

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

Looks amazing! Thanks so much! 🚀

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 for it! 💯
Beautiful changes and great work! Congrats 🥳
I'm just adding a small suggestion to have the code more aligned with the style that we use to have (use valueOr and isOkOr.)

Comment on lines 208 to 213
let relayShards = RelayShards.init(conf.clusterId, conf.shards)
if relayShards.isok():
enrBuilder.withWakuRelaySharding(relayShards.get()).isOkOr:
error "Building ENR with relay sharding failed", error = error
else:
error "Relay shards initialization failed", error = relayShards.error
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a nitpick comment where we use valueOr and, in case of error, we stop the wakucanary execution.

Notice how valueOr is very similar to isOkOr, in concept, but in this case, it allows to return an item.

Suggested change
let relayShards = RelayShards.init(conf.clusterId, conf.shards)
if relayShards.isok():
enrBuilder.withWakuRelaySharding(relayShards.get()).isOkOr:
error "Building ENR with relay sharding failed", error = error
else:
error "Relay shards initialization failed", error = relayShards.error
let relayShards = RelayShards.init(conf.clusterId, conf.shards).valueOr:
error "Relay shards initialization failed", error = error
return 1
enrBuilder.withWakuRelaySharding(relayShards.get()).isOkOr:
error "Building ENR with relay sharding failed", error = error
return 1

Copy link

This PR may contain changes to database schema of one of the drivers.

If you are introducing any changes to the schema, make sure the upgrade from the latest release to this change passes without any errors/issues.

Please make sure the label release-notes is added to make sure upgrade instructions properly highlight this change.

@darshankabariya darshankabariya merged commit 3b27aee into master Jun 14, 2024
13 of 15 checks passed
@darshankabariya darshankabariya deleted the Bug_2720 branch June 14, 2024 12:59
rymnc pushed a commit that referenced this pull request Jun 20, 2024
* chore: integrate cluster id and shards to waku node.
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.

bug: Unable to verify status fleets using WakuCanary
4 participants