-
Notifications
You must be signed in to change notification settings - Fork 960
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
Implement the rendezvous protocol #2107
Merged
Merged
Changes from 246 commits
Commits
Show all changes
250 commits
Select commit
Hold shift + click to select a range
047840d
Define protobuf messages and add build script to generate rust bindings
rishflab 76f57bd
WIP:
rishflab aed2f95
Add crate to workspace members
thomaseizinger 61b7343
WIP
thomaseizinger 88d6fca
Add mapping between protobuf and application types
thomaseizinger e191a3d
Return Framed stream from protocol
thomaseizinger f728821
Define behaviour API
rishflab 87df759
Initial PoC for signed peer records
thomaseizinger 5c61db0
Initial PoC for signed peer records
thomaseizinger 5428d7f
Add {into,from}_protobuf_encoding for SignedEnvelope
thomaseizinger 7a12627
Do proper error handling for decoding peer records
thomaseizinger c94e215
Integrate signed peer records into rendezvous
thomaseizinger 193c016
Add {into,from}_protobuf_encoding for SignedEnvelope
thomaseizinger 5a9aae3
Do proper error handling for decoding peer records
thomaseizinger a15296e
Add feature to fix broken unsigned-varint dependency import
rishflab 4208a02
WIP: Add behaviour and handler
rishflab d5ea66b
Remove usage of unsafe code
thomaseizinger 2166e7e
Re-order contents of codec module by importance
thomaseizinger 4bbf56d
Introduce `NewRegistration` type so we have a place for the default TTL
thomaseizinger c36ac8b
Make `ttl` public so we can actually construct the type
thomaseizinger b45688d
Actually a constructor is better
thomaseizinger 1dc2580
Use convenience _unpin functions instead of manual pinning
thomaseizinger e079510
Add intermediate states to handler
rishflab a03868a
Rename substream states
rishflab 436682e
Fix inbound/outbound injection
rishflab 32a504b
Go to closing after reading from outbound
rishflab e377d5d
Prepare everything for writing tests
da-kami f925f26
Retreive discovered from hashmap
rishflab a61742a
Remove signed peer record todo from handler
rishflab b39449d
Handle unregister request in behaviour
rishflab d6fc13f
WIP - Happy path registration and discovery test
da-kami 2edc167
"Handle" connect/disconnect events
rishflab d590741
Fix todos/unimplemented except for signed peer record related
rishflab 81388db
Bubble up signed record todo to behaviour
rishflab 404b484
WIP: signed peer record
rishflab a89cffc
WIP - Aligen Behaviour, Handler and Codec
da-kami 4ffaa5f
WIP - Test running, but behaviour does not emit events as expected
da-kami 585e4a7
Fix unused imports
rishflab 20ce11f
Reorg behaviour
rishflab b484718
Added debug prints, Handler not being polled?
rishflab 6f923c2
Fix bug where inbound state never went to closing
rishflab 6a4bbec
Remove duplicated code
rishflab e1c2d17
Delete unused file
rishflab 7796a69
Use tcp transport in tests
rishflab f2f89cf
Fix bug where inbound substream was being poisoned
rishflab dbd6745
Hack: Return poll ready to force swarm to be polled
rishflab 7b22d16
Delete unused code
rishflab a00b3f8
Replace emission of dummy event with ResponseSent
rishflab 69a00cf
Reverted back to daniel/thomas test architecture
rishflab c0599c8
Make initial test pass
thomaseizinger 57d471d
Add TODO
thomaseizinger 624a72b
Remove hack fix to trigger Swarm::poll()
rishflab 1f5251a
Reduce code duplication by generating identity inside `new_swarm`
thomaseizinger 94b5dbe
Format with rustfmt
thomaseizinger 10ee7e5
Infer addresses to register from external addresses
thomaseizinger 26d1ac6
Grab PeerId from Swarm when necessary instead of passing it around
thomaseizinger 32b05a1
Remove dead code
thomaseizinger 5fc8583
Replace buggy `connect` functionality with composable extension trait
thomaseizinger 24a0c0d
Use unwrap_or_default to avoid branching
thomaseizinger dec5a43
Log events as we get them
thomaseizinger 0c3bbaa
Simplify assertion of successful registration
thomaseizinger 5c9c83e
Deal with warnings
thomaseizinger b766951
Avoid emitting events twice / erroneously
thomaseizinger a89b28d
Make discover test working
thomaseizinger acc6583
Remove role name that was only there for debugging
thomaseizinger 1ef3539
Add empty line for better formatting
thomaseizinger f42ac18
Rename `handler::Input` to `handler::InEvent`
thomaseizinger 8bb25b9
Don't wrap Message on the way up from the handler
thomaseizinger e337024
Introduce `Next` enum for making `State::poll` fns declarative
thomaseizinger 6128354
Fix documentation of {Inbound,Outbound}State
thomaseizinger 4806c96
Align order of members as per trait definition
thomaseizinger 7e0d9da
Remove noisy logs
thomaseizinger 939faa9
Simplify handling of `InEvent`
thomaseizinger e970758
Import std::mem
thomaseizinger 35c91ab
Shorten variable and fieldnames
thomaseizinger 7610d3d
Have some fun with Rust
thomaseizinger 5af486e
Use module-level public constructor for making new protocol
thomaseizinger 581cee0
Implement rendezvous protocol using `upgrade::from_fn`
thomaseizinger 43c8753
Return a hashmap of registrations instead of a vector
rishflab 344123f
Allow registration swarm to specify TTL in registration request
rishflab faa066c
Set unix timestamp in peer record
rishflab 6908659
Attach timestamp to the registration the record
rishflab 5ebb734
Test refreshing of the TTL by sending a new registration request
rishflab b9dd7d3
Reject register request if specified TTL is too high
rishflab 0d4bd9f
Add failing test for cookie behaviour
thomaseizinger e1fcdd1
Add basic tests for Registrations behaviour
thomaseizinger a92be31
Refactor `Registrations::get` to return Iterator
thomaseizinger 89348dc
Add test for overwriting existing registration
thomaseizinger edeb5b2
Store registrations by ID
thomaseizinger 3a62bee
Don't return namespace from `Registrations::add`
thomaseizinger 5349d93
Create newtype for registration id
thomaseizinger 4c28f11
Don't clone registrations unless necessary
thomaseizinger 4f03f90
Add initial cookie functionality
thomaseizinger fbea1ef
Make sure new cookie implies old cookie
thomaseizinger 7801601
Add cookies to wire messages
thomaseizinger e233850
Allow ttl to match exactly upper bound
thomaseizinger 242d444
Use defensive programming to avoid additional levels of indentation
thomaseizinger cc9a02e
Use `match` with specific error variant instead of if let
thomaseizinger 5277f6a
Remove TODO
thomaseizinger 3240bc5
Rename function to clarify that we are not using protobuf for cookies
thomaseizinger 2d96943
Allow tests to run in parallel
thomaseizinger 58ce18e
Make cookies specific to a namespace if given during DISCOVER
thomaseizinger 29b9fb1
Merge branch 'master' into signed-peer-records
thomaseizinger 36d7039
Fix typo in function name
thomaseizinger 1241d77
Remove `PeerRecord::authenticate`
thomaseizinger fb39c2c
Re-order module
thomaseizinger 0251bd4
Make `PeerRecord` private
thomaseizinger 799103e
Merge `PeerRecord` into `AuthenticatedPeerRecord` for simplicity
thomaseizinger dde489d
Use stdlib rather than bytes::BufMut
thomaseizinger a59a60d
Reduce duplication between sign and verify
thomaseizinger a9ab281
Extend docs of `SignedEnvelope`
thomaseizinger de19fda
Slightly re-organize PeerRecord implementations
thomaseizinger be4bea0
Fix link in docs
thomaseizinger b33d7d5
Improve docs wording
thomaseizinger 65d0ba6
Make `PeerRecord`s clonable
thomaseizinger 000360c
Merge branch 'signed-peer-records' into rendezvous
thomaseizinger 2f0e4c4
Remodel `RegistrationError` as a struct error
thomaseizinger 8a4d747
Fail if we don't have any external addresses
thomaseizinger b9ca692
Remove noisy logs
thomaseizinger 444e7a1
Unify naming of substream states
thomaseizinger 09ad250
Close the substream on invalid messages
thomaseizinger ee74706
Handle error upon reading from outbound gracefully
thomaseizinger 15e0c67
Handle EOF gracefully
thomaseizinger b5a5364
Handle errors during sending gracefully
thomaseizinger c4c8795
Allow converting a `ConversionError` to an error code
thomaseizinger cf8135f
DRY
thomaseizinger 7a2bc6d
Close connection on errors
thomaseizinger eca21a5
Add TODO for simplification once or-patterns hit stable
thomaseizinger 42ead09
Shorten type and field names to fit things onto one line
thomaseizinger ebc6f03
Move `SubstreamState` to dedicated module
thomaseizinger 1f3156f
Allow passing cookies to a discover request
thomaseizinger 79a49dd
Exhaustively match result on polling close and explain handling
thomaseizinger f59cdcf
Group events into client and server side
thomaseizinger 3ae1cd9
Rename event variants for consistency and add documentation
thomaseizinger a461c58
Rename `DeclinedRegisterRequest` to `PeerNotRegistered` for consistency
thomaseizinger 55be51f
Rename event variants to be more event-y
thomaseizinger 4da0f53
Return namespace in result events of behaviour
thomaseizinger 43f14f9
Remove TODOs that were erroneously copied over
thomaseizinger 82b5d78
Model success and error message variants using `Result`
thomaseizinger 4ccfbad
Add TODOs
thomaseizinger 56c92c2
Update protobuf files to latest version
thomaseizinger 5484c21
Merge branch 'signed-peer-records' into rendezvous
thomaseizinger 3161547
Fix compile errors from new protobuf description
thomaseizinger 13df0d7
Merge branch 'signed-peer-records' into rendezvous
thomaseizinger 912fcec
Add failing test for expiring registration
thomaseizinger 11647a0
Extend `Advance` with arbitrary params
thomaseizinger 756fdb5
Refactor `Advance` to make use of Result
thomaseizinger 28c0cfb
Make sure we always talk to the same handler
thomaseizinger a23829c
Add implementation of draft PoW proposal
thomaseizinger a582ea9
Remove expired registrations
rishflab 9923698
Clear registrations_for_peer upon expiry
rishflab 1b36d74
Extend expiry test
rishflab 6f0cc7f
Trigger cleanup of expired registrations using futures
rishflab e2f779d
Test expiry event is not emitted if unregistered
rishflab 7312592
Ensure next_expiry.poll_next() cannot return None
rishflab e560e24
Use tokio::test to fix broken tests
rishflab 69dfbee
Fix bug where new registration was not being added
rishflab bdc102e
Make tests prettier by adding functions on `Registrations`
thomaseizinger b8a93c3
Switch registrations in cookies to a HashSet
thomaseizinger c4f802f
Remove TODOs in favor of tasks on draft PR
thomaseizinger d31ebff
Include Registration in PeerRegistered OutEvent
rishflab 1fe1e3d
Remove redundant field from PeerRegistered
rishflab 476ddc7
Remove unused dependency
rishflab 93846e1
Apply clippy suggestions
thomaseizinger 61f4dbb
Only depend on tokio features for prod where needed
thomaseizinger e39c304
Make tests actually compile
thomaseizinger 85a0751
Apply clippy suggestions to tests
thomaseizinger 2bf0689
Don't panic on new inbound/outbound substream
thomaseizinger b6a02b5
Align naming of substream states
thomaseizinger bbeb6f3
Don't panic on unexpected event from behaviour
thomaseizinger 4a67051
Merge branch 'master' into rendezvous
thomaseizinger 17924e7
Adapt to latest master
thomaseizinger 46c058c
Make use of new `Stream` interface of `Swarm`
thomaseizinger 6d4a915
Add examples for rendezvous and discovery
rishflab e87c5b8
Add rendezous swarm
rishflab bdd2cc4
Registration is working
rishflab 26b2ac1
Remove unnecessary naming of field in single field struct variant
thomaseizinger c3b1de5
RIP PoW
thomaseizinger eae577b
Free handler from abstractions that were only needed with PoW
thomaseizinger 24c0322
Respect `limit` parameter of `Discover` requests
thomaseizinger ee53ba1
Make all modules private and only expose particular structs
thomaseizinger cd68a75
Actually use `Registrations::poll` to check for expired registrations
thomaseizinger 0dfba09
Re-export rendezvous from libp2p meta crate
thomaseizinger f6cd3b9
Streamline public interface of libp2p_rendezvous crate
thomaseizinger c25f554
Inline some variables to make examples easier to read
thomaseizinger 5d29f74
Prefer async fn main over task::block_on
thomaseizinger 77ee0ad
Polish register example a bit
thomaseizinger 189dfde
Rename examples to what they are showcasing
thomaseizinger b873f23
Discover example dials discovered nodes
thomaseizinger 7a452aa
Make discover and register share a common protocol
thomaseizinger 5d8f42f
Make register example listen on a random port
thomaseizinger ec79ba6
Rename server to rendezvous point
thomaseizinger a3270ca
Polish rendezvous point example
thomaseizinger 0fdb340
Use libp2p::development_transport for examples
thomaseizinger dae0f6e
Add Ping behaviour to rendezvous point
thomaseizinger 7776b37
Make logging prettier
thomaseizinger f1b763a
Have pings be every second for example's sake
thomaseizinger 6d14c5b
Remove timestamp that is not used for anything
thomaseizinger b2a0c6f
Return full registration from `Registrations`
thomaseizinger b34b099
Be quiet by default
thomaseizinger 798d5ab
Rename swarms in test-setup to Alice, Bob and Robert
thomaseizinger c5a968c
Verify peers can only submit registrations for themselves
thomaseizinger 7bdc277
Don't panic on invalid cookie
thomaseizinger ea20273
Model `inject_event` implementation of mapping to new events
thomaseizinger 531570e
Return a simple list in `Discovered` event
thomaseizinger fad3941
Honor min and max TTL from spec
thomaseizinger 9600210
Format exports + Cleanup + Re-naming
rishflab 6aa4c36
Introduce `Namespace` newtype to capture max-length invariant
thomaseizinger e0eaa41
Don't use latest stable features yet
thomaseizinger 4705877
Update to latest revision of spec
thomaseizinger c3cd411
Remove snake case to be consistent with type
rishflab 2e143a0
Expose Config params
da-kami 8c3b010
Fix typo in test name
thomaseizinger 622484d
Use `wasm-timer` instead of `tokio`
thomaseizinger b4a66bd
Add copyright header to all files
thomaseizinger 0a16136
Replace log with debug_assert
thomaseizinger 4cacaf2
Remove redundant result return type from register
rishflab 952fde2
Remove unwrap from example to fix build
da-kami da0e761
Redefine rendezvous behaviour using generic substream handler
thomaseizinger 082dfd0
Simplify Outbound stream by implementing it as a future
thomaseizinger d3628cf
Define helper struct for substreams that can be implemented as futures
thomaseizinger 8f46361
Add some more docs and split `inject_event` of `Rendezvous` behaviour
thomaseizinger 326c9b2
Fix clippy errors and warnings
thomaseizinger 3df6e52
Fix cargo doc errors and warnings
thomaseizinger 802b152
Make it compile on wasm
thomaseizinger 74a39f4
Store discovered addresses inside behaviour
thomaseizinger 4af8af7
Add register example that doesnt use the Identify protocol
rishflab e646e47
Merge branch 'master' into rendezvous
thomaseizinger 5f10abf
Fix test compile errors
thomaseizinger 7ec294f
Fix warnings in tests
thomaseizinger c56ab55
Remove GlobalSpawnTokioExecutor
thomaseizinger 88fa94b
Document design of `poll_substreams`
thomaseizinger f1b61a6
Minor formatting fixes
thomaseizinger c3fdd0b
Use a u64 to represent `RegistrationId`
thomaseizinger 9b1dda8
Add docs to public functions of rendezvous
thomaseizinger 433b3b5
Use naming as per https://github.com/libp2p/rust-libp2p/discussions/2174
thomaseizinger d85e38b
Expose `wasm-bindgen` feature instead of automatically activating it
thomaseizinger d5cb328
Split behaviour into client and server
thomaseizinger 8115ec3
Allow registrations on client to expire
thomaseizinger dccdebc
Merge branch 'master' into rendezvous
thomaseizinger 7d6bf59
Migrate rendezvous protocol to new NetworkBehaviourAction
thomaseizinger e3ff6c2
Make it work without uuid
thomaseizinger 8f46f84
Log errors and close connection as a result
thomaseizinger 5e3d4a1
Remove unnecessary implementation of default fn
thomaseizinger 5696a7e
Reduce duplication in test setup
thomaseizinger 2637e45
Make tests more readable
thomaseizinger f8edf2f
Final polish
thomaseizinger 700bcb2
Merge branch 'master' into rendezvous
thomaseizinger 2215f02
Adhere to formatting convention of changelog
thomaseizinger 53ce603
Fix bad link
thomaseizinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
syntax = "proto3"; | ||
|
||
package envelope_proto; | ||
|
||
import "keys.proto"; | ||
|
||
// Envelope encloses a signed payload produced by a peer, along with the public | ||
// key of the keypair it was signed with so that it can be statelessly validated | ||
// by the receiver. | ||
// | ||
// The payload is prefixed with a byte string that determines the type, so it | ||
// can be deserialized deterministically. Often, this byte string is a | ||
// multicodec. | ||
message Envelope { | ||
// public_key is the public key of the keypair the enclosed payload was | ||
// signed with. | ||
keys_proto.PublicKey public_key = 1; | ||
|
||
// payload_type encodes the type of payload, so that it can be deserialized | ||
// deterministically. | ||
bytes payload_type = 2; | ||
|
||
// payload is the actual payload carried inside this envelope. | ||
bytes payload = 3; | ||
|
||
// signature is the signature produced by the private key corresponding to | ||
// the enclosed public key, over the payload, prefixing a domain string for | ||
// additional security. | ||
bytes signature = 5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
syntax = "proto3"; | ||
|
||
package peer_record_proto; | ||
|
||
// PeerRecord messages contain information that is useful to share with other peers. | ||
// Currently, a PeerRecord contains the public listen addresses for a peer, but this | ||
// is expected to expand to include other information in the future. | ||
// | ||
// PeerRecords are designed to be serialized to bytes and placed inside of | ||
// SignedEnvelopes before sharing with other peers. | ||
message PeerRecord { | ||
|
||
// AddressInfo is a wrapper around a binary multiaddr. It is defined as a | ||
// separate message to allow us to add per-address metadata in the future. | ||
message AddressInfo { | ||
bytes multiaddr = 1; | ||
} | ||
|
||
// peer_id contains a libp2p peer id in its binary representation. | ||
bytes peer_id = 1; | ||
|
||
// seq contains a monotonically-increasing sequence counter to order PeerRecords in time. | ||
uint64 seq = 2; | ||
|
||
// addresses is a list of public listen addresses for the peer. | ||
repeated AddressInfo addresses = 3; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Fixed in #2218. Unfortunately I can not apply suggestions on a branch on the comit-network repository.