-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
8ba4249
to
d0a3d59
Compare
1548348
to
01f58e1
Compare
chore: adding default readme feat: reworking as a transport feat: getting peers communicating over relay (wip) feat: address in swarm [wip] feat: adding onion dial feat: adding onion dialing and tests feat: make circuit a full fledged transport refactor: split transport dialer and circuit logic test: adding dial tests feat: adding passive/active dialing test test: adding relay tests fix: several isues feat: consolidate and cleanup dialing feat: handle listenning circuit addresses correctly feat: make utils a factory feat: adding StreamHandler to aid with pull-stream read/write refactor: clean up and refactor relay and listener tests: adding more relay and listener tests tests: moving long multiaddr to a fixture feat: adding _writeErr to handle returning errors in relay.js fix: cleanup, moving setup code outside of dialer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to make my review as comments as I was the one creating this PR.
@dryajov lot's of good work here! I see some deadcode and I feel it can get a good cleanup. What do you think?
README.md
Outdated
@@ -1 +1,38 @@ | |||
# js-libp2p-circuit | |||
# <topic> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Topic?
README.md
Outdated
|
||
## License | ||
|
||
[MIT](LICENSE) © 2016 Protocol Labs Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole README needs to be done.
LICENSE
Outdated
@@ -0,0 +1,21 @@ | |||
MIT License | |||
|
|||
Copyright (c) 2017 libp2p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protocol Labs Inc
package.json
Outdated
"rules": { | ||
"strict": "off" | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't monkey patch our codestyle, we want to use the same for every single module in the same way.
package.json
Outdated
"pull-stream": "^3.5.0", | ||
"safe-buffer": "^5.0.1", | ||
"setimmediate": "^1.0.5" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deps need to be updated
src/circuit/onion-dialer.js
Outdated
'use strict' | ||
|
||
require('setimmediate') | ||
require('safe-buffer') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above (safe-buffer)
src/circuit/onion-dialer.js
Outdated
} | ||
} | ||
|
||
module.exports = OnionDialer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this OnionDialer feature? First time reading about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the term was brought up either by @lgierth or @whyrusleeping during one of our IRC convos and it describes one of two dialing modes, onion
and telescope
.
- Onion refers to the client dialing all the relays in a multihop address
- Telescope would dial the first hop and and send the reminder of the multihop address as the destination address to that relay for further dialing, effectively having each
hop
in the multihop address dial the next hop in the chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's accurate. We should add these two modes to the spec as well, and make sure they're reasonably good names. I can see how onion might not be the best names (although it's accurate).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like onion 😄, but I can see how its not the most descriptive name. Maybe something that implies that the client is the one dialing all the relays - Client
and Telescope
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- +1 adding to the spec
- +1 for picking a better name than onion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we settled on a name, should we vote? 🚀
} | ||
|
||
return listener | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file still used? Relay is not a transport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circuit currently relies on the transport interface to plug in with swarm, hence the Dialer/Listener parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #9 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diasdavid I think this has been resolved as part of our previous discussions?
src/index.js
Outdated
Dialer: require('./dialer'), | ||
multicodec: require('./multicodec'), | ||
tag: 'Circuit' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there should be here a file for
- Dialer - what you currently have
- Hop - the handler for the protocol
/libp2p/relay/hop
- Stop - the handler for the protocol
/libp2p/relay/stop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reasons as above - circuit pretends to be a transport to allow pluging in with swarm/libp2p hence the weird similarities with other transport implementations.
src/index.js
Outdated
Relay: require('./circuit/relay'), | ||
Dialer: require('./dialer'), | ||
multicodec: require('./multicodec'), | ||
tag: 'Circuit' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this tag used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since circuit pretends to be a transport, its used by swarm/libp2p when loading all transports. It's essentially used as a transport key.
src/index.js
Outdated
Dialer: require('./dialer'), | ||
multicodec: require('./multicodec'), | ||
tag: 'Circuit' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The listener never gets exported though //cc @dryajov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats the same pattern the other transports use, the listener then gets instantiated with createListener
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you show me where you are using that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is handled by the swarm using the standard transport init flow - https://github.com/libp2p/js-libp2p-swarm/blob/master/src/transport.js#L82.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, when I mean that circuit implements the transport interface I mean that it literally implements this interface - https://github.com/libp2p/interface-transport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think that transport-interface
is possibly a misnomer, perhaps we can rename it to something like connection handler/supplier, once you break away from the assumption that it's a transport any possible impedance mismatches start going away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diasdavid re failing tests for transport interface. Those are on my list to fix, but I believe that when I looked at them initially it required some adjustments to make it work with circuit. I'll take another look and come back with my findings, in any case it should work, because circuit is not doing anything different from the rest of the transport at the interface level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re .getAddr
right now the only thing that circuit does a little different from other transports is that during instantiation it will check if there is /p2p-circuit/<maddr>
address provided and if there isn't it will add a default /p2p-circuit
, the reason for doing this is to enable circuit dialing/listening by default without having to repeat /p2p-circuit
in the swarm config over and over. I think this is OK to do, since /p2p-circuit
is a perfectly valid circuit address that means that this peer is reachable over any circuit.
Also, one more thing about .getAddr
- we do have a clear use case for it since circuit does listen
on specific /p2p-circuit
addresses. This IMO, satisfies the interface intent of returning the list of available addresses the transport is listening on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely share @diasdavid initial reaction to doing it this way (using interface-transport
) . The weird feeling was the hardest thing for me to overcome and drove me to try different approaches but every time realizing that I've just reinvented the wheel again and other transports are already doing exactly the same thing, which is why I stuck with interface-transport
.
The good thing is that the actual circuit logic is not tied to interface-transport
in any way, and could even be exposed as a stand alone module, we could have libp2p-circuit
and libp2p-circuit-transport
, but not sure if doing that makes any sense, since there would be no way of consuming it in swarm/libp2p without also pulling in the transport part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's stick with it. I just have one request. This needs to be all documented! :D
Do you mean documenting the decision behind using transport interface? If that's the case, what's the best place for that, not sure if the spec is appropriate since it's still a low level implementation detail. |
@dryajov It has to be clear that is how relay attaches in swarm, a diagram in the repo README and some comments in the code should do fine. |
Ah, makes sense. I'll add that. |
@diasdavid @lgierth @dignifiedquire I've added some initial documentation to the readme and a diagram. Please let me know what you think about it - I'm not sure if it communicates the intent correctly, so feedback is appreciated :) |
@diasdavid @lgierth @dignifiedquire what do you guys need from me to get this moving? Anything i'm missing? Anything that needs to be done before you continue with the review? |
As discussed in IRC. Let's finalize the spec first. |
I've added a comment here, proposing a timeboxed decision, libp2p/specs#18. |
@diasdavid I've removed onion dialing since we're not supporting multihop for this iteration, this also removed the dependency on modifying swarm, this has reduced the number of outstanding PRs drastically and should make it a lot easier to review and accept. |
Thank you for pushing the updates on this PR, @dryajov. I'll review it as soon as possible. As a side request, please do not use |
@daviddias upps didn't know that! Thanks, looking forward for the review! |
closed in favor of #14 |
dependent PRs:
feat: adding relay (#181) js-libp2p-switch#201test: adding circuit tests [wip] ipfs-inactive/js-libp2p-ipfs-nodejs#105feat: skip p2p-circuit addresses js-libp2p-tcp#80feat: skip p2p-circuit addresses js-libp2p-websockets#61Relevant issues:
CAN_HOP
message Type to circuit-relay to allow passive relay discovery specs#27Tasks:
Implement telescope dialing of chained relay addresses(we can do with onion dialing for now?)/libp2p/circuit/relay/1.0.0/stop
/libp2p/circuit/relay/1.0.0/hop
peer-id
andpeer-info
published to npmTests:
Dialer
Listener
Circuit relay
/libp2p/circuit/relay/1.0.0/hop
and forward connections to dst