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

bug: createLightNode() Function in @waku/sdk v0.0.26: Content/PubSub Topics Requirement #2082

Closed
ryanshahine opened this issue Jul 23, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ryanshahine
Copy link

Description

I am encountering an issue with the createLightNode() function while using @waku/sdk version 0.0.26. It appears that the contentTopics option must be specified during the node's initiation. Without this, both queryWithOrderedCallback() and subscribe() fail to function as expected.

Observed Behavior:

When I omit the contentTopics option, the queryWithOrderedCallback() and subscribe() methods do not return any results.

Example Code:

const ContentTopic = '/portrait_test/1/updates-79/proto';
const PubsubTopic = '/waku/2/rs/1/4';

const wakuNode = await createLightNode({
  pubsubTopics: [PubsubTopic],
  contentTopics: [ContentTopic], // Removing or commenting this line results in no response from queryWithOrderedCallback or subscribe.
  defaultBootstrap: true,
});

await wakuNode.start();
await waitForRemotePeer(wakuNode, [Protocols.Store]);

const decoder = createDecoder(ContentTopic, PubsubTopic);

const callback = (msg) => {
  console.log('Message received:', msg);
};

const { error, subscription } = await wakuNode.filter.createSubscription({
  contentTopics: [ContentTopic],
  pubsubTopics: [PubsubTopic],
});

if (error) {
  console.error('Subscription error:', error);
  return;
}


await subscription.subscribe([decoder], callback);
console.log('Subscribed to content topic');

const queryResult = await wakuNode.store.queryWithOrderedCallback([decoder], callback);
console.log('queryWithOrderedCallback result:', queryResult);

No specific error messages are thrown; the callbacks simply do not execute.

Discussion:

I consulted with @weboko over tg:

Hi, there were some updates and per some feedback we changed API so that it fails if too many network configurations were passed. 

Now you need to select if you want to pass content topics(all those you going to use during lifetime of the node), pub sub topics or shard information manually. 

In case you specify pub sub topic then you need to configure all your decoder/encoders with it so that they are aware of what network is in use (otherwise it defaults to autosharding and will be computed based on content topic that was passed into decoder/encoder). 

Second issue

When I attempt to initiate a light node without a pub sub topic (see convo above), I receive the following error:

Error: Pubsub topic /waku/2/rs/1/4 has not been configured on this instance. Configured topics are: /waku/2/default-waku/proto. Please update your configuration by passing in the topic during Waku node instantiation.

It seems like when the pubsubTopics option is omitted in createLightNode() the default value clashes with the expected value.

@weboko confirmed this might be a bug and requested it be reported for further investigation.

SDK:

@waku/sdk version 0.0.26

@ryanshahine ryanshahine changed the title createLightNode() Function in @waku/sdk v0.0.26: Content/PubSub Topics Requirement Bug bug: createLightNode() Function in @waku/sdk v0.0.26: Content/PubSub Topics Requirement Jul 23, 2024
@weboko weboko self-assigned this Jul 23, 2024
@weboko weboko added the bug Something isn't working label Jul 24, 2024
@weboko
Copy link
Collaborator

weboko commented Jul 24, 2024

Released next version with the fix, can be unstable before I complete PR fully but with the example and works fine.

Please, try out these packages:

Successfully published packages/interfaces with version 0.0.26-1887f4f.0.
Successfully published packages/relay with version 0.0.14-1887f4f.0.
Successfully published packages/message-encryption with version 0.0.29-1887f4f.0.
Successfully published packages/utils with version 0.0.19-1887f4f.0.
Successfully published packages/enr with version 0.0.25-1887f4f.0.
Successfully published packages/discovery with version 0.0.4-1887f4f.0.
Successfully published packages/sdk with version 0.0.27-1887f4f.0.
Successfully published packages/core with version 0.0.31-1887f4f.0.

Code that I worked with:

import { createLightNode, waitForRemotePeer, Protocols, createDecoder, DefaultShardInfo } from "@waku/sdk";

const ContentTopic = '/portrait_test/1/updates-79/proto';
const PubsubTopic = '/waku/2/rs/1/4';

async function run() {
  const wakuNode = await createLightNode({
    shardInfo: DefaultShardInfo,
    defaultBootstrap: true,
  });

  await wakuNode.start();
  await waitForRemotePeer(wakuNode, [Protocols.Store]);

  const decoder = createDecoder(ContentTopic, PubsubTopic);

  const callback = (msg) => {
    console.log('Message received:', msg);
  };

  const { error, subscription } = await wakuNode.filter.createSubscription({
    contentTopics: [ContentTopic],
    pubsubTopics: [PubsubTopic],
  });

  if (error) {
    console.error('Subscription error:', error);
    return;
  }

  await subscription.subscribe([decoder], callback);
  console.log('Subscribed to content topic');

  const queryResult = await wakuNode.store.queryWithOrderedCallback([decoder], callback);
  console.log('queryWithOrderedCallback result:', queryResult);
}

run();

@weboko
Copy link
Collaborator

weboko commented Jul 25, 2024

Resolved with #2085

@weboko weboko closed this as completed Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants