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

feat: Add example for custom rlpx subprotocol #8113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

owanikin
Copy link

@owanikin owanikin commented May 5, 2024

I am creating this draft pr to solicit feedback on: 1) If I am on the right track. 2) pointers/direction on how to really solve the issue. Thanks for your help.

Closes #7130

@owanikin owanikin marked this pull request as ready for review May 5, 2024 17:01
@owanikin owanikin requested a review from gakonst as a code owner May 5, 2024 17:01
@onbjerg onbjerg marked this pull request as draft May 5, 2024 17:09
@onbjerg onbjerg changed the title draft pr: Add example crate for custom rlpx subprotocol #7130 feat: Add example for custom rlpx subprotocol May 5, 2024
Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

just as a quick side note, pls remember to add the example to examples/readme.md

@onbjerg onbjerg added the C-example Examples label May 5, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

great, this is simple yet illustrates the feature perfectly

a few nits

use tokio_stream::wrappers::UnboundedReceiverStream;

// Custom Rlpx Subprotocol
pub mod proto {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we move this to a separate file?

Comment on lines +279 to +280
// let custom_rlpx_handler = CustomRlpxProtoHandler{ state: ProtocolState { events: node.network.events.clone()}};
// node.network.add_rlpx_sub_protocol(custom_rlpx_handler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can uncomment this

@mattsse mattsse marked this pull request as ready for review May 6, 2024 15:48
Comment on lines +170 to +177
enum Command {
/// Send a custom message to the peer
CustomMessage {
msg: String,
/// The response will be sent to this channel.
response: oneshot::Sender<String>,
},
}
Copy link
Member

Choose a reason for hiding this comment

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

@mattsse this is cool -- we should demonstrate a bridge/oracle on this, and eventually build up to a full consensus example i feel?

and this is all subprotocols for commands post-establishing a connection, but what about discv? how should we do discovery of nodes that support custom subprotocols?

Copy link
Collaborator

Choose a reason for hiding this comment

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

tracking here #8017
for this we need a more sophisticated example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-example Examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example crate for custom rlpx subprotocol
4 participants