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

DHT peerInfoMapper cause crashes #2874

Open
winprn opened this issue Dec 5, 2024 · 2 comments
Open

DHT peerInfoMapper cause crashes #2874

winprn opened this issue Dec 5, 2024 · 2 comments
Labels
kind/stale need/author-input Needs input from the original author

Comments

@winprn
Copy link

winprn commented Dec 5, 2024

  • Version:
"@libp2p/autonat": "^2.0.6",
"@libp2p/bootstrap": "^11.0.6",
"@libp2p/circuit-relay-v2": "^2.1.2",
"@libp2p/crypto": "^5.0.5",
"@libp2p/dcutr": "^2.0.6",
"@libp2p/devtools-metrics": "^1.1.5",
"@libp2p/identify": "^3.0.6",
"@libp2p/kad-dht": "14.0.0",
"@libp2p/mdns": "^11.0.8",
"@libp2p/peer-id": "^5.0.4",
"@libp2p/pubsub-peer-discovery": "^11.0.0",
"@libp2p/webrtc": "^5.0.9",
"@libp2p/websockets": "^9.0.7",
"@libp2p/webtransport": "^5.0.9",
  • Platform:
  • Chrome latest
  • 6.1.0-26-amd64 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 (2024-09-30) x86_64 GNU/Linux
  • Subsystem:
  • KadDHT

Severity:

Description:

In my setup, I have one public bootstrap node and other browser nodes connect to it.
When they connects, sometimes the peerMapper got call continuously. And if that node is disconnected, the whole wss is down, no further node can connect to the bootstrap:
image

This is my DHT config:

dht: kadDHT({
  protocol: "/topology/dht/1.0.0",
  kBucketSize: this._config?.bootstrap ? 40 : 20,
  clientMode: false,
  peerInfoMapper: (peerInfo) => {
	  log.info("::start::peerInfoMapper", peerInfo);
	  return peerInfo;
  },
  allowQueryWithZeroPeers: false,
}),

Steps to reproduce the error:

const _node_services = {
	autonat: autoNAT(),
	dcutr: dcutr(),
	identify: identify(),
	pubsub: gossipsub(),
	dht: kadDHT({
		protocol: "/topology/dht/1.0.0",
		kBucketSize: this._config?.bootstrap ? 40 : 20,
		clientMode: false,
		peerInfoMapper: (peerInfo) => {
			log.info("::start::peerInfoMapper", peerInfo);
			return peerInfo;
		},
		allowQueryWithZeroPeers: false,
	}),
};

const _bootstrap_node_services = {
	..._node_services,
	relay: circuitRelayServer(),
};

this._node = await createLibp2p({
	privateKey,
	addresses: {
		listen: this._config?.addresses ? this._config.addresses : ["/webrtc"],
	},
	connectionEncrypters: [noise()],
	connectionGater: {
		denyDialMultiaddr: () => {
			return false;
		},
	},
	peerDiscovery: [], // put the bootstrap address here
	services: this._config?.bootstrap
		? _bootstrap_node_services
		: _node_services,
	streamMuxers: [yamux()],
	transports: [
		circuitRelayTransport({
			discoverRelays: 2,
			reservationConcurrency: 1,
		}),
		webRTC(),
		webRTCDirect(),
		webSockets({
			filter: filters.all,
		}),
		webTransport(),
	],
});

Please note that this error is not consistent. Sometimes when I refresh the browser everything works fine.

@winprn winprn added the need/triage Needs initial labeling and prioritization label Dec 5, 2024
@winprn winprn changed the title DHT peerMapper cause crashes DHT peerInfoMapper cause crashes Dec 5, 2024
@achingbrain
Copy link
Member

It's normal for the peer mapper to be called multiple times, as it will be applied to DHT peers as they are encountered.

I can't see the crash you are talking about - is there a stack trace available? Are you able to share a full example that I can run?

@achingbrain achingbrain added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Dec 11, 2024
Copy link
Contributor

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/stale need/author-input Needs input from the original author
Projects
None yet
Development

No branches or pull requests

2 participants