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: add function to validate autoshard content topic #1711

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

adklempner
Copy link
Member

@adklempner adklempner commented Nov 8, 2023

Problem

There is currently no function for validating content topics used for autosharding

Solution

This PR adds a function to sharding utils which validates that a string is a valid content topic in the context of autosharding

Notes

Copy link

github-actions bot commented Nov 8, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 83.85 KB (+0.01% 🔺) 1.7 s (+0.01% 🔺) 684 ms (+0.22% 🔺) 2.4 s
Waku Simple Light Node 264.4 KB (+0.06% 🔺) 5.3 s (+0.06% 🔺) 1.7 s (+45.91% 🔺) 7 s
ECIES encryption 79.46 KB (0%) 1.6 s (0%) 651 ms (-22.12% 🔽) 2.3 s
Symmetric encryption 79.46 KB (0%) 1.6 s (0%) 1.2 s (+34.59% 🔺) 2.8 s
DNS discovery 111.23 KB (0%) 2.3 s (0%) 950 ms (-6.14% 🔽) 3.2 s
Privacy preserving protocols 131.77 KB (0%) 2.7 s (0%) 956 ms (+26% 🔺) 3.6 s
Light protocols 81.61 KB (0%) 1.7 s (0%) 478 ms (-8.93% 🔽) 2.2 s
History retrieval protocols 80.53 KB (0%) 1.7 s (0%) 584 ms (+9.04% 🔺) 2.2 s
Deterministic Message Hashing 5.65 KB (0%) 113 ms (0%) 196 ms (-8.38% 🔽) 309 ms

@adklempner adklempner marked this pull request as ready for review November 8, 2023 04:44
@adklempner adklempner requested a review from a team as a code owner November 8, 2023 04:44
@@ -0,0 +1,88 @@
import { expect } from "chai";
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can keep this test in packages/tests similarly how other utils are done there.
https://github.com/waku-org/js-waku/blob/master/packages/tests/tests/utils.spec.ts

Copy link
Member Author

@adklempner adklempner Nov 9, 2023

Choose a reason for hiding this comment

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

@weboko I tired this but now it takes a lot longer to run the unit tests for this function. IMO it shouldn't share a test file that needs docker running in order to not fail.

Plus the tests in that package feel more like integration tests, whereas here we have straightforward unit tests.

* Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/
* @param contentTopic String to validate
*/
export function validateContentTopic(contentTopic: string): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: when the method throws an error on failed check, then I believe the ensure prefix is more commonly used.

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed to ensureValidContentTopic

@adklempner adklempner force-pushed the adklempner/validate-content-topics branch 2 times, most recently from 497c0ef to 0ff58e0 Compare November 16, 2023 06:09
@adklempner adklempner force-pushed the adklempner/validate-content-topics branch from 0ff58e0 to 1bc1eb5 Compare November 16, 2023 06:28
@adklempner adklempner merged commit 5e9c981 into master Nov 16, 2023
10 of 11 checks passed
@adklempner adklempner deleted the adklempner/validate-content-topics branch November 16, 2023 06:43
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.

3 participants