-
Notifications
You must be signed in to change notification settings - Fork 476
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
PeerStore Merge Not Preserving Existing Protocols on Update #1789
Comments
Happy to open a PR for this hotfix but I think this is some unintended behaviour for |
Thanks for spotting this issue. I've dug into it a little and it seems the remote peer does not send a signed peer record during identify, this hits this branch and so the sent protocols are never persisted. This is a bug as we should persist the identify information, but replace any addresses with those from the signed peer record if it's present. TBH I thought all libp2p implementations sent signed peer records by now - what is the remote peer type in this test? |
Right. I am testing against I will check with the nwaku team re the same. Judging by
seems like in the interim, we can expect js-libp2p to still work when there is not a Is this something we can expect a fixed release for, soon, as this is currently a blocker for our upgrade to 0.45.4 Thanks for looking into it @achingbrain |
Yes, I'll get a fix out very soon. |
I'm pretty sure this is disabled on most, if not all eth consensus clients (which use a very small/safe subset of libp2p features) |
I was about to open an issue but I believe this covers my issue, I'll add the details here. Please let me know if it's unrelated. I'm observing that Steps to ReproduceRun the Run the import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { circuitRelayTransport } from 'libp2p/circuit-relay'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { yamux } from '@chainsafe/libp2p-yamux'
import { noise } from '@chainsafe/libp2p-noise'
import { identifyService } from 'libp2p/identify'
export async function privateLibp2pNode () {
const node = await createLibp2p({
addresses: {
listen: ['/ip4/0.0.0.0/tcp/0']
},
transports: [
tcp(),
circuitRelayTransport({
discoverRelays: 1,
}),
],
streamMuxers: [yamux(), mplex()],
connectionEncryption: [noise()],
peerDiscovery: [],
services: {
identify: identifyService()
}
})
return node
}
(async () => {
const node = await privateLibp2pNode()
console.log(node.peerId)
node.addEventListener("peer:identify", (event) => {
const identify = event.detail;
console.log('peer:identify', identify.peerId, identify.protocols)
})
node.addEventListener("self:peer:update", (event) => {
console.log('self:peer:update', node.getMultiaddrs())
})
const ma = multiaddr('<addr of the rust-libp2p relay>')
await node.dial(ma)
})() Actual ResultRelayed address is not listed on peer:update
Expected ResultPeer update includes the relayed address on peer:update
|
Good catch @Marcel-G thanks for spotting this. I've merged @achingbrain 's fix #1790 which should be released in |
|
Version: [email protected]
Platform: MacOS
Subsystem: Upgrader/PeerStore
Severity: High
Description:
While testing my code with upgraded [email protected]., I encountered an issue where the protocol array in the peer store was not behaving as expected. While I expect that a new protocol should be appended to the existing list of protocols for a given peer, it appears that instead the new protocol is replacing the old entries.
Here is the test code:
This can be run in an environment through this commit message: waku-org/js-waku@e0f7af3
This test code is throwing an error:
Error: Failed to find known peer that registers protocols: /vac/waku/filter-subscribe/2.0.0-beta1
. It seems that only one protocol is registered at a time according to the output ofconsole.log((await waku.libp2p.peerStore.all()).map((p) => p.protocols));
However, I expect the peer to have multiple protocols registered: Filter, LightPush, and Store.
I found that changing the upstream libp2p code with
upgrader.ts
(https://github.com/libp2p/js-libp2p/blob/41641f1a7656aa654234f6f849b1749786867121/src/upgrader.ts#LL465C11-L467C13) to the following fixed this issue.Steps to reproduce the error:
npm i && npm run build
cd packages/tests && npm run test:node
Note: This is part of a larger migration PR for js-waku from v0.42 to 0.45.4: waku-org/js-waku#1385
cc @achingbrain
Tasks
The text was updated successfully, but these errors were encountered: