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

Integrate the native LibP2P implementation #632

Merged
merged 4 commits into from
Dec 10, 2019
Merged

Integrate the native LibP2P implementation #632

merged 4 commits into from
Dec 10, 2019

Conversation

zah
Copy link
Contributor

@zah zah commented Dec 9, 2019

Local network sim (and testnet1) will now use the native libp2p by default.

@tersec
Copy link
Contributor

tersec commented Dec 9, 2019

Probably worth using this for #122 at this point, rather than implementing it twice.

template libp2pProtocol*(name: string, version: int) {.pragma.}
# TODO: This exists only as a compatibility layer between the daemon
# APIs and the native LibP2P ones. It won't be necessary once the
# daemon is removed.
Copy link
Member

Choose a reason for hiding this comment

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

or we can move some of it to the libp2p library - I believe there was interest in maintaining both daemon and non-daemon versions (though generally I'd prefer we drop the daemon api completely and focus our limited resources on making the native version excellent)

Copy link
Contributor

Choose a reason for hiding this comment

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

Supporting both also means keeping a significantly more complex build setup and build dependency documentation, due to the daemon being in Go. I'd prefer to drop all that when feasible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm very eager to drop the daemon as soon as possible, because it's holding back the API in some sense (the daemon is not providing enough events to which you can hook up and it cannot be interrogated regarding the supported protocols of another peer).

To do this, we need to be more confident that we have working interop with all other clients though. Also, with the current state of nim-libp2p, we are back to the star topology that we managed to escape with the daemon. Discovery V5 should solve this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Keeping the Go daemon wrapper helps with interoperability tests, unless you want to write half of them in Go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having the daemon wrapper as an optional module is perfectly fine. I was referring to the limitations imposed from trying to maintain the same facade API in front of the native implementation and the daemon.

if not stream.closed:
await close(stream)

include eth/p2p/p2p_backends_helpers
Copy link
Member

Choose a reason for hiding this comment

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

any way we can avoid the includes? they are difficult for tooling to analyze

Copy link
Member

Choose a reason for hiding this comment

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

as an alternative, let's at least start calling them something like .inc.nim so they're clearly marked / can be excluded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of these includes is to simulate "generic code" without introducing actual generics. In the included file, types such as P2PStream will be different depending on the backend file that uses it. If all the code was generic instead, this would have lead to a more baroque structure and slightly worse compilation error messages, so I think the current trade-off is worthwhile.

@zah zah merged commit 10e6d48 into devel Dec 10, 2019
@delete-merged-branch delete-merged-branch bot deleted the native-libp2p branch December 10, 2019 13:02
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.

4 participants