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

improv: local bootstrap node set up w/ example #200

Merged
merged 17 commits into from
Oct 23, 2024

Conversation

elielnfinic
Copy link
Contributor

Overview

This PR enhances the Developer Experience (DX) for the local environment. It streamlines the process of running a topology bootstrap on a local device or network, making it easier to connect peers efficiently.

Currently, the changes are applied to the chat example, but if approved, I can extend this implementation to the other examples as well.

Summary of Changes

Here are the edited files :

  • examples/chat/package.json
  • examples/chat/src/index.ts
  • packages/network/src/node.ts
  • packages/node/configs/node.json
  • README.md

Here are the created files :

  • examples/chat/src/vite-env.d.ts
  • packages/node/configs/local-bootstrap.json

Feel free to let me know if there are any adjustments or suggestions. Once approved, I can proceed with applying the same improvements to the other examples.

@elielnfinic elielnfinic marked this pull request as ready for review October 17, 2024 23:59
README.md Outdated Show resolved Hide resolved
Comment on lines 67 to 86
const bootstrap_nodes_list = this._config?.bootstrap_peers
? this._config.bootstrap_peers
: [
"/dns4/relay.droak.sh/tcp/443/wss/p2p/Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP",
];

const _pubsubPeerDiscovery = pubsubPeerDiscovery({
interval: 10_000,
topics: ["topology::discovery"],
});

const peer_discovery = bootstrap_nodes_list.length
? [
_pubsubPeerDiscovery,
bootstrap({
list: bootstrap_nodes_list,
}),
]
: [_pubsubPeerDiscovery];

Copy link
Member

Choose a reason for hiding this comment

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

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you disconnect WiFi and the relay.droak.sh is still in the list of bootstrap_peers, when the relay is run it produces an issue.

Copy link
Member

Choose a reason for hiding this comment

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

what do you mean? this change is restructuring code, is not changing logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When there is no bootstrap node list, I shouldn't have the bootstrap({list : []}) property.
If it is in the object, I am getting the following error :

@topology-foundation/[email protected] cli /Users/monordi/apps/topology/ts-topology/packages/node
> tsx ./src/run.ts "relay" "--config" "configs/local-bootstrap.json"

/Users/monordi/apps/topology/ts-topology/node_modules/.pnpm/@[email protected]/node_modules/@libp2p/bootstrap/src/index.ts:98
      throw new Error('Bootstrap requires a list of peer addresses')
            ^


Error: Bootstrap requires a list of peer addresses```

That's why I created the condition to check if I have bootstrap nodes in my config. If not, pass the `peer-discovery` not having the bootstrap property.

packages/network/src/node.ts Show resolved Hide resolved
packages/node/configs/node.json Outdated Show resolved Hide resolved
examples/chat/src/vite-env.d.ts Outdated Show resolved Hide resolved
examples/chat/package.json Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@d-roak d-roak changed the title Local set up DX improvement improv: local bootstrap node set up w/ example Oct 23, 2024
Copy link
Member

@d-roak d-roak left a comment

Choose a reason for hiding this comment

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

lgtm

@d-roak d-roak merged commit 742ea7f into topology-foundation:main Oct 23, 2024
5 checks passed
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.

2 participants