Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

feat/v0.1.0 #9

Closed
wants to merge 20 commits into from
Closed

feat/v0.1.0 #9

wants to merge 20 commits into from

Conversation

daviddias
Copy link
Member

@daviddias daviddias commented Mar 27, 2017

dependent PRs:


Relevant issues:


Tasks:

  • Implement the circuit transport
    • Integrated circuit transport in swarm
    • enable swarm dialing over circuit transport
    • proper error handling
    • Implement dialing
      • Implement dialing on relay
      • Implement dialing over a specific relay
      • Implement onion dialing on chained relay addresses
      • Implement telescope dialing of chained relay addresses (we can do with onion dialing for now?)
    • Implement listening - /libp2p/circuit/relay/1.0.0/stop
      • Implement listening on specific circuit addresses
      • Announce circuit addresses over identify
      • check for src address lenght
  • Implement the circuit-relay
    • listen for connections relay requests - /libp2p/circuit/relay/1.0.0/hop
    • dial the requested destination
    • implement active dialing
    • implement passive dialing
    • implement proper error handling
      • check for dst address length
  • make a full fledged transport
  • move tests to proper place
    • add more test coverage
  • integrate with libp2p
    • figure out the best place to plug circuit-relay
  • add relay config section to ipfs
  • add relay tests to js-ipfs
  • latest master for peer-id and peer-info published to npm

Tests:

  • Dialer

    • should dial over relay if no common transport exists
    • should dial over specific relay
      • should dial over specific peer routed relay
      • should dial over specific relay on the provided transport
      • should dial over chained relay address
  • Listener

    • Should receive relayed connections
  • Circuit relay

    • Should listen on /libp2p/circuit/relay/1.0.0/hop and forward connections to dst

@dryajov dryajov requested a review from dignifiedquire April 2, 2017 01:33
@dryajov dryajov self-assigned this Apr 2, 2017
@dryajov dryajov removed the request for review from dignifiedquire April 2, 2017 02:07
@dryajov dryajov force-pushed the feat/v0.1.0 branch 2 times, most recently from 8ba4249 to d0a3d59 Compare April 8, 2017 17:51
@dryajov dryajov force-pushed the feat/v0.1.0 branch 4 times, most recently from 1548348 to 01f58e1 Compare April 18, 2017 04:39
@dryajov dryajov requested a review from dignifiedquire April 18, 2017 18:11
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
Copy link
Member Author

@daviddias daviddias left a 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>
Copy link
Member Author

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.
Copy link
Member Author

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
Copy link
Member Author

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"
}
},
Copy link
Member Author

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"
}
Copy link
Member Author

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

'use strict'

require('setimmediate')
require('safe-buffer')
Copy link
Member Author

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)

}
}

module.exports = OnionDialer
Copy link
Member Author

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.

Copy link
Member

@dryajov dryajov May 10, 2017

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.

Copy link

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).

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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
}
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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'
}
Copy link
Member Author

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

Copy link
Member

@dryajov dryajov May 10, 2017

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'
Copy link
Member Author

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?

Copy link
Member

@dryajov dryajov May 10, 2017

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'
}
Copy link
Member Author

@daviddias daviddias May 12, 2017

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

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

@dryajov dryajov May 15, 2017

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

Copy link
Member

@dryajov dryajov May 15, 2017

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.

Copy link
Member

@dryajov dryajov May 15, 2017

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.

Copy link
Member

@dryajov dryajov May 15, 2017

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.

Copy link
Member

@dryajov dryajov May 15, 2017

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.

Copy link
Member Author

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

@dryajov
Copy link
Member

dryajov commented May 16, 2017

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.

@daviddias
Copy link
Member Author

@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.

@dryajov
Copy link
Member

dryajov commented May 16, 2017

Ah, makes sense. I'll add that.

@dryajov
Copy link
Member

dryajov commented Jun 10, 2017

@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 :)

@dryajov
Copy link
Member

dryajov commented Jun 13, 2017

@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?

@daviddias
Copy link
Member Author

As discussed in IRC. Let's finalize the spec first.

@dryajov
Copy link
Member

dryajov commented Jun 19, 2017

@diasdavid @lgierth

I've added a comment here, proposing a timeboxed decision, libp2p/specs#18.

@dryajov
Copy link
Member

dryajov commented Aug 3, 2017

@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.

@dryajov dryajov requested a review from a team August 3, 2017 22:01
@daviddias
Copy link
Member Author

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 libp2p/javascript-team to ask for reviews, you essentially notified everyone that has ever contributed to the js parts of the project to review a PR. We should only use that when we require everyone's attention.

image

@dryajov
Copy link
Member

dryajov commented Aug 10, 2017

@daviddias upps didn't know that! Thanks, looking forward for the review!

@dryajov dryajov removed the request for review from a team August 10, 2017 02:31
@dryajov dryajov closed this Aug 16, 2017
@dryajov
Copy link
Member

dryajov commented Aug 17, 2017

closed in favor of #14

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants