Skip to content
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

Add basic support for multiaddr addresses and improvement around peer id #75

Merged
merged 8 commits into from
Nov 29, 2018

Conversation

zaibon
Copy link
Contributor

@zaibon zaibon commented Nov 26, 2018

relates to #65

I'm already creating this PR so my fork doesn't diverge too far away from here.

# Get peer info from peer store
addrs = self.peerstore.addrs(peer_id)

if not addrs:
raise SwarmException("No known addresses to peer")

# TODO: define logic to choose which address to use, or try them all ?
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we should try them all and use whichever address responds the fastest

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what the go-libp2p repo is doing at the moment, and there are plans to upgrade it to a smarter dial. I forgot if it's called a traffic shaper or a dial manager. There is a bit of design freedom here. We should participate in the discussion with the rest of the community.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zixuanzh do you have a link to the issue where they discuss this dial manager ?

Copy link
Contributor

@zixuanzh zixuanzh Nov 26, 2018

Choose a reason for hiding this comment

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

@zaibon this is the thread libp2p/go-libp2p-swarm#88, dial manager might be a make-up name.

requirements.txt Outdated Show resolved Hide resolved
@stuckinaboot
Copy link
Contributor

Hi @zaibon, is this PR intented to be merged right now? Some of the tests are failing, please fix before merging

@zaibon
Copy link
Contributor Author

zaibon commented Nov 26, 2018

@stuckinaboot
as explained at #65 (comment)
The multiaddr lib needs to be moved to the proper account and probably updated with my fixes too before we can merge this.

With the proper lib installed, I don't have any tests failing, can you point me to which test is not working with you ?

Copy link
Contributor

@zixuanzh zixuanzh left a comment

Choose a reason for hiding this comment

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

@zaibon Makes sense, let us check with Raul and see if there are any updates there about ownership transfer of py-multiaddr to libp2p but I think it might still take some time. In the mean time, how can we point to your py-multiaddr fork? We don't see that in your py-libp2p fork either. If we can try this, then we can retest locally.

@zaibon
Copy link
Contributor Author

zaibon commented Nov 26, 2018

What I did is locally install my fork: https://github.com/zaibon/py-multiaddr
then I develop the rest based on this multiaddr code

@robzajac
Copy link
Contributor

@zaibon I'm trying to recreate this setup - what are the steps I should follow to locally install the fork? Thanks!

@zaibon
Copy link
Contributor Author

zaibon commented Nov 26, 2018

@robzajac

cd py-libp2p
source venv/bin/activate
cd ..
git clone  https://github.com/zaibon/py-multiaddr
cd py-multiaddr
pip install .
cd ../py-libp2p
pytest -v

@robzajac
Copy link
Contributor

robzajac commented Nov 28, 2018

Hi @zaibon apologies for the pause in communication. Recently we were focusing on pushing up big design improvements over our PoC (#82 and #83).

We have reached out to @raulk regarding the discussion in #65, particularly transferring ownership of sbuss/py-multiaddr to libp2p and accepting the changes in your fork. We haven't heard back yet, but I think we're ready to use your py-multiaddr fork in this repo.

Is there a way to integrate your py-multiaddr fork into our pip dependencies automatically, so that other contributors do not have to manually follow the steps above? Critically, we'd also like this fork to be pulled in as a dependency during CI. If we can have that set up and have this PR pass in CI I think we will be ready to merge.

Thanks for your great work!

@zaibon
Copy link
Contributor Author

zaibon commented Nov 28, 2018

Hi @robzajac, no worries, I see you're making good progress here.

Regarding my fork. I can publish it to pypi so it can be easily integrated with pip and CI. But I guess this will be temporary until we move sbuss/py-multiaddr since I won't be able to use the same package name. But that can be done, no problem.

no need to cast from a string to an ID
- keep multiaddr object into peerstore instead of string
- update network code to use new multiaddr lib
- update tests and example
This has side effect where the same peerstore
is used for different instance of Libp2p
@codecov-io
Copy link

Codecov Report

Merging #75 into master will increase coverage by 0.44%.
The diff coverage is 95.96%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #75      +/-   ##
=========================================
+ Coverage   53.45%   53.9%   +0.44%     
=========================================
  Files          49      51       +2     
  Lines        1463    1551      +88     
=========================================
+ Hits          782     836      +54     
- Misses        681     715      +34
Impacted Files Coverage Δ
libp2p/libp2p.py 100% <100%> (ø) ⬆️
network/network_interface.py 100% <100%> (ø) ⬆️
host/basic_host.py 96.66% <100%> (+8.43%) ⬆️
host/host_interface.py 100% <100%> (ø) ⬆️
tests/protocol_muxer/test_protocol_muxer.py 100% <100%> (ø) ⬆️
tests/peer/test_peerid.py 100% <100%> (ø)
tests/libp2p/test_libp2p.py 100% <100%> (ø) ⬆️
peer/peerstore.py 98.24% <100%> (ø) ⬆️
tests/peer/test_peerinfo.py 100% <100%> (ø)
transport/tcp/tcp.py 78.37% <100%> (+0.87%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fa674d...0bd6e88. Read the comment docs.

@zaibon
Copy link
Contributor Author

zaibon commented Nov 29, 2018

@robzajac ok I think it's ready now. Please have another look if I didn't mess up with the code. I had to rebase a few commits.

Copy link
Contributor

@robzajac robzajac left a comment

Choose a reason for hiding this comment

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

LGTM! I will let one of @alexh @zixuanzh @stuckinaboot take a look as well.

@@ -56,3 +69,22 @@ def set_stream_handler(self, protocol_id, stream_handler):
"""
stream = await self.network.new_stream(peer_id, protocol_ids)
return stream

async def connect(self, peer_info):
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding reference if anyone is wondering where this comes from.

Copy link
Contributor

@zixuanzh zixuanzh left a comment

Choose a reason for hiding this comment

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

LGTM as well, thank you for the great work!

@robzajac robzajac merged commit 611de28 into libp2p:master Nov 29, 2018
@zaibon zaibon deleted the multiaddr branch September 18, 2019 18:05
pacrob added a commit to pacrob/py-libp2p that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants