On my local machine when I supply a peer ID everything works great. It happily uses it and the node runs. When I move this exact same code (Node) to an EC2 instanceā¦ problems. The first problem I got was this assertion:
AssertionError: Missing peerId. Use Peer.create(cb) to create one
at new PeerInfo (/home/ec2-user/bootstrap-node/node_modules/peer-info/src/index.js:12:5)
Since I am supplying a peer ID I found this error strange and started digging. I finally tracked it down to line 211 in peer-id/src/index.js:
(cb) => crypto.keys.unmarshalPrivateKey(buf, cb)
It seems that the actual error is being squashed (which causes the assertion error above), so I logged the error and now see the following:
Error: Unknown wire type: 7
at skip (/home/ec2-user/bootstrap-node/node_modules/protons/src/compile/decode.js:198:13)
at Object.decode (/home/ec2-user/bootstrap-node/node_modules/protons/src/compile/decode.js:156:18)
at Object.exports.unmarshalPrivateKey.err [as unmarshalPrivateKey] (/home/ec2-user/bootstrap-node/node_modules/peer-id/node_modules/libp2p-crypto/src/keys/index.js:87:34)
at waterfall (/home/ec2-user/bootstrap-node/node_modules/peer-id/src/index.js:255:16)
at nextTask (/home/ec2-user/bootstrap-node/node_modules/async/waterfall.js:16:14)
at exports.default (/home/ec2-user/bootstrap-node/node_modules/async/waterfall.js:26:5)
at Function.exports.createFromJSON (/home/ec2-user/bootstrap-node/node_modules/peer-id/src/index.js:251:5)
at Function.PeerInfo.create (/home/ec2-user/bootstrap-node/node_modules/peer-info/src/index.js:58:12)
at waterfall (/home/ec2-user/bootstrap-node/main.js:130:18)
at nextTask (/home/ec2-user/bootstrap-node/node_modules/async/waterfall.js:16:14)
I figured Iād stop there and ask if anyone knows why this would be happening only when I run on an EC2 host.
In case it helps, here is my bundle setup:
class MyBundle extends libp2p {
constructor (_options) {
const defaults = {
modules: {
transport: [new WebSockets(), new TCP()],
streamMuxer: [Mplex, SPDY],
connEncryption: [SECIO]
}
}
super(defaultsDeep(_options, defaults))
}
}
Thanks!