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: switches to REST for calling nwaku messages/subscription endpoints #1852

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

adklempner
Copy link
Member

Problem

nwaku will be deprecating JSON RPC API. We will no longer be able to use those endpoints in e2e tests and must switch to using the REST API.

Solution

This PR migrates two endpoints used in e2e from RPC to REST: GET /relay/v1/messages/ and POST /relay/v1/subscriptions
Also updates utils for running the Docker image to provide arguments to enable rest and run it on restPort

Notes

@adklempner adklempner requested a review from a team as a code owner February 15, 2024 02:12
@adklempner adklempner force-pushed the feat/messages-subscription-rest branch from dee052c to 6bde07c Compare February 15, 2024 02:14
Copy link

github-actions bot commented Feb 15, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 30.81 KB (0%) 617 ms (0%) 585 ms (-8.43% 🔽) 1.3 s
Waku Simple Light Node 275.6 KB (0%) 5.6 s (0%) 1.6 s (+1.1% 🔺) 7.1 s
ECIES encryption 27.54 KB (0%) 551 ms (0%) 732 ms (+120.97% 🔺) 1.3 s
Symmetric encryption 26.86 KB (0%) 538 ms (0%) 471 ms (+18.06% 🔺) 1.1 s
DNS discovery 92.49 KB (0%) 1.9 s (0%) 890 ms (+14.6% 🔺) 2.8 s
Privacy preserving protocols 135.69 KB (0%) 2.8 s (0%) 794 ms (-25.45% 🔽) 3.6 s
Light protocols 29.26 KB (0%) 586 ms (0%) 372 ms (+35.76% 🔺) 958 ms
History retrieval protocols 27.63 KB (0%) 553 ms (0%) 283 ms (-50.51% 🔽) 835 ms
Deterministic Message Hashing 6 KB (0%) 120 ms (0%) 114 ms (-18.87% 🔽) 234 ms

Copy link
Collaborator

@danisharora099 danisharora099 left a comment

Choose a reason for hiding this comment

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

LGTM

packages/tests/src/lib/service_node.ts Outdated Show resolved Hide resolved
@@ -255,7 +283,7 @@ export class ServiceNode {
]);
}

async messages(
async messagesRpc(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: do we need to update the new function name within any tests?

Copy link
Collaborator

Choose a reason for hiding this comment

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

do we even need to keep it?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

throw error;
}
},
{ retries: 5 }
Copy link
Collaborator

Choose a reason for hiding this comment

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

just wondering why 5 retries?

Copy link
Member Author

Choose a reason for hiding this comment

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

copied from old function. removed and it doesn't break tests

@adklempner adklempner force-pushed the feat/messages-subscription-rest branch 2 times, most recently from 3547160 to 6cd419b Compare February 15, 2024 22:35
This commit modifies functions in ServiceNode to use the REST API
instead of JSON RPC when reading messages for a pubsub topic or
content topic, and when ensuring a nwaku node is subscribed to a
pubsub topic. Also modifies default Docker params to enable the
rest API and provide a port.
@adklempner adklempner force-pushed the feat/messages-subscription-rest branch from 6cd419b to 739f2bc Compare February 15, 2024 22:39
@adklempner adklempner merged commit aabd907 into master Feb 15, 2024
10 checks passed
@adklempner adklempner deleted the feat/messages-subscription-rest branch February 15, 2024 22:58
@@ -109,6 +109,7 @@ export default class Dockerode {
HostConfig: {
AutoRemove: true,
PortBindings: {
[`${restPort}/tcp`]: [{ HostPort: restPort.toString() }],
[`${rpcPort}/tcp`]: [{ HostPort: rpcPort.toString() }],

Choose a reason for hiding this comment

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

unsure how this is used but rpc wont longer exist. eg rpcPort.toString().

@@ -49,6 +50,7 @@ export class ServiceNode {
private websocketPort?: number;
private readonly logPath: string;
private rpcPort?: number;

Choose a reason for hiding this comment

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

remove?

if (err) reject(err);
resolve(ports);
resolve({
rpcPort: ports[0],

Choose a reason for hiding this comment

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

same, remove?

@@ -138,13 +148,15 @@ export class ServiceNode {
Object.assign(
mergedArgs,
{
rest: true,
restPort,
rpcPort,

Choose a reason for hiding this comment

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

same?

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.

4 participants