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

refactor(network): Default configuration constants for DiscoveryLayerNode #3000

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juslesan
Copy link
Contributor

@juslesan juslesan commented Jan 30, 2025

Summary

Added constants for default configuration of the DiscoveryLayerNode.

Future Improvements

Add default configuration configs to the ControlLayerNode and DhtNode

@github-actions github-actions bot added the network Related to Network Package label Jan 30, 2025
@juslesan juslesan requested review from harbu and teogeb January 30, 2025 15:30
@juslesan juslesan marked this pull request as ready for review January 30, 2025 15:31
import { DhtAddress, PeerDescriptor, RingContacts, ServiceID } from '@streamr/dht'
import { StreamPartID } from '@streamr/utils'

export const DEFAULT_DISCOVERY_LAYER_KBUCKET_SIZE = 4
Copy link
Contributor

@teogeb teogeb Jan 30, 2025

Choose a reason for hiding this comment

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

https://github.com/streamr-dev/network/blob/main/developer-docs/index.md#naming-counts

Suggested change
export const DEFAULT_DISCOVERY_LAYER_KBUCKET_SIZE = 4
export const DEFAULT_DISCOVERY_LAYER_KBUCKET_NODE_COUNT = 4

Could be part of a separate PR (in that case, add a bullet point to the "Future improvements" section)

At some point we refactored PeerManager so that it at least partially hides the KBucket terminology, and uses higher level concepts instead (e.g. neighbors, nearby contacts, connections). Does this config option control any of those higher level concepts, or should we keep this name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used specifically to control the sizes of the k-buckets that the neighbors are placed in. So it's specifically used to tweak the behaviour of kademlia's k-buckets. Simply calling it neighbor-something might be a bit challenging because of that.


export const DEFAULT_DISCOVERY_LAYER_KBUCKET_SIZE = 4
export const DEFAULT_DISCOVERY_LAYER_JOIN_TIMEOUT = 20000
export const DEFAULT_DISCOVERY_LAYER_NEIGHBOR_PING_LIMIT = 16
Copy link
Contributor

Choose a reason for hiding this comment

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

What this limits? E.g. the count of neighbors to ping, or interval of pings, or timeout of ping responses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It limits pings if the number of neighbors is above it. Maybe it could be called ie DEFAULT_DISCOVERY_LAYER_NEIGHBOR_COUNT_PING_LIMIT?

@juslesan juslesan requested a review from teogeb January 31, 2025 13:28
juslesan added a commit that referenced this pull request Mar 4, 2025
## Summary

Added constants for default configurations for Layer2 classes. 

## Changes

- Random node view count is now configured with the nodeViewSize config
option

## Future improvements

- Do the same for the discovery layer #3000 
- Remove remaining magic numbers around ControlLayerNode configuration
(Could also clean up on the DHT side).
- Could maybe pass some of the defaults from a higher layer (for example
the sdk). This will require some thought as some of the configs could be
wanted on a per stream partition basis and others for all streams.
- Rename all fields with `listSize` to ie `listNodeCount `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
network Related to Network Package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants