Skip to content

Commit

Permalink
fix: re-enable yamux (#205)
Browse files Browse the repository at this point in the history
This PR re-enables yamux in E-IPFS. Some historical context:

1. E-IPFS release with yamux made all pods unstable. We reverted adding
yamux in #195 and
created issue ChainSafe/js-libp2p-yamux#23
2. In the meantime this issue was addressed
ChainSafe/js-libp2p-yamux#25

Please note that deploying this needs attention and we should monitor
and perform canary release.

Closes elastic-ipfs/elastic-ipfs#25

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
vasco-santos and Alan Shaw authored Sep 18, 2023
1 parent 4101994 commit 4b1ad05
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@aws-sdk/client-sqs": "3.258.0",
"@aws-sdk/node-http-handler": "3.257.0",
"@chainsafe/libp2p-noise": "11.0.0",
"@chainsafe/libp2p-yamux": "3.0.5",
"@chainsafe/libp2p-yamux": "3.0.7",
"@libp2p/mplex": "7.1.1",
"@libp2p/peer-id": "2.0.1",
"@libp2p/peer-id-factory": "2.0.1",
Expand Down
6 changes: 3 additions & 3 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createLibp2p } from 'libp2p'
import { webSockets } from '@libp2p/websockets'
import { noise } from '@chainsafe/libp2p-noise'
import { mplex } from '@libp2p/mplex'
// import { yamux } from '@chainsafe/libp2p-yamux'
import { yamux } from '@chainsafe/libp2p-yamux'
import LRU from 'lru-cache'

import { noiseCrypto } from './noise-crypto.js'
Expand Down Expand Up @@ -70,8 +70,8 @@ async function startService ({ peerId, port, peerAnnounceAddr, awsClient, connec
maxInboundStreams: connectionConfig.mplex.maxInboundStreams,
maxOutboundStreams: connectionConfig.mplex.maxOutboundStreams,
maxStreamBufferSize: connectionConfig.mplex.maxStreamBufferSize
})
// yamux({ client: false })
}),
yamux({ client: false })
],
connectionManager: {
maxConnections: connectionConfig.p2p.maxConnections,
Expand Down
70 changes: 35 additions & 35 deletions test/bitswap-1.2.0.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,38 +428,38 @@ t.test(
}
)

// t.test(
// `${protocol} - should work with client using yamux muxer only`,
// async t => {
// const { awsClient } = await mockAWS(config)
// const { client, service, connection, receiver } = await setup({ protocol, awsClient, muxers: ['yamux'] })

// const wantList = new WantList(
// [
// new Entry(cid1, 1, false, Entry.WantType.Block, true),
// new Entry(cid2, 1, false, Entry.WantType.Block, true),
// new Entry(cid3, 1, false, Entry.WantType.Block, true),
// new Entry(cid4, 1, false, Entry.WantType.Block, true)
// ],
// false
// )

// const request = new Message(wantList, [], [], 0)
// await connection.send(request.encode(protocol))

// const [response] = await receiveMessages(receiver, protocol)
// await teardown(client, service, connection)

// t.equal(response.blocks.length, 2)
// t.equal(response.blockPresences.length, 2)

// const cid1Blocks = response.blocks.filter(b => Buffer.from(b.data).toString('utf8') === cid1Content)
// t.equal(cid1Blocks.length, 1)

// const cid2Blocks = response.blocks.filter(b => safeGetDAGLinks(b.data)?.[0]?.Name === cid2Link)
// t.equal(cid2Blocks.length, 1)

// t.equal(getPresence(t, response, cid3).type, BlockPresence.Type.DontHave)
// t.equal(getPresence(t, response, cid4).type, BlockPresence.Type.DontHave)
// }
// )
t.test(
`${protocol} - should work with client using yamux muxer only`,
async t => {
const { awsClient } = await mockAWS(config)
const { client, service, connection, receiver } = await setup({ protocol, awsClient, muxers: ['yamux'] })

const wantList = new WantList(
[
new Entry(cid1, 1, false, Entry.WantType.Block, true),
new Entry(cid2, 1, false, Entry.WantType.Block, true),
new Entry(cid3, 1, false, Entry.WantType.Block, true),
new Entry(cid4, 1, false, Entry.WantType.Block, true)
],
false
)

const request = new Message(wantList, [], [], 0)
await connection.send(request.encode(protocol))

const [response] = await receiveMessages(receiver, protocol)
await teardown(client, service, connection)

t.equal(response.blocks.length, 2)
t.equal(response.blockPresences.length, 2)

const cid1Blocks = response.blocks.filter(b => Buffer.from(b.data).toString('utf8') === cid1Content)
t.equal(cid1Blocks.length, 1)

const cid2Blocks = response.blocks.filter(b => safeGetDAGLinks(b.data)?.[0]?.Name === cid2Link)
t.equal(cid2Blocks.length, 1)

t.equal(getPresence(t, response, cid3).type, BlockPresence.Type.DontHave)
t.equal(getPresence(t, response, cid4).type, BlockPresence.Type.DontHave)
}
)

0 comments on commit 4b1ad05

Please sign in to comment.