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

cmd/devp2p: add eth cmd to send new block announcements #25212

Closed
wants to merge 6 commits into from

Conversation

lightclient
Copy link
Member

@lightclient lightclient commented Jun 30, 2022

This PR adds a new subcommand to devp2p: eth. This subcommand has a single command of it's own currently, new-block which sends the specified hex as a devp2p block announcement message. We can expand eth to support more arbitrary message sending in the future.

$ devp2p eth new-block <enode> <msg>

@lightclient lightclient marked this pull request as ready for review August 9, 2022 03:37
@lightclient
Copy link
Member Author

@fjl PTAL when you have a chance!

}

// runGeth creates and starts a geth node
func runGeth() (*node.Node, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

It's unfortunate this is mostly copied exactly from cmd/devp2p/internal/ethtest/suite_test.go. Not sure if there is anything better that could be done.

Comment on lines 86 to 102
code := uint64((ethtest.NewBlock{}).Code())
if _, err = conn.Conn.Write(code, msg); err != nil {
exit(fmt.Errorf("failed to write to connection: %w", err))
}
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 a pretty generic send already. You could basically do

Suggested change
code := uint64((ethtest.NewBlock{}).Code())
if _, err = conn.Conn.Write(code, msg); err != nil {
exit(fmt.Errorf("failed to write to connection: %w", err))
}
func ethMessage(..)(
...
msgCode, err := hex.DecodeString(ctx.Args().Get(1))
msg, err := hex.DecodeString(ctx.Args().Get(2))
...
code := uint64((msgCode)
if _, err = conn.Conn.Write(code, msg); err != nil {
exit(fmt.Errorf("failed to write to connection: %w", err))
}

And then we'd increase the generality of this tool quite a lot. The UX-cost would be an additional uint argument to add the NewBlock msg code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lightclient want to pursue this?

Copy link
Contributor

Choose a reason for hiding this comment

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

..... ping ....

Copy link
Contributor

Choose a reason for hiding this comment

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

I rebased + made it generic now :)

Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

The generic command is great, but a cli command with 3 args is not very ergonomic. We already have a command with 3 args, devp2p rlpx eth-test, and I could never remember the parameter order... It would be better to handle the args as flags. I suggest that it should be handled like this:

devp2p rlpx eth-msg -version 67 -node enr:... <code || msg>

i.e. only one positional argument and combined msg code + data.

}
// Peer with node.
status := &ethtest.Status{
ProtocolVersion: 66,
Copy link
Contributor

Choose a reason for hiding this comment

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

This hard-coded version is going to be a problem. I think it should be passed as a flag.

@fjl
Copy link
Contributor

fjl commented Mar 14, 2023

Another note: the original purpose of this command is kind of lost since the merge, because block announcements are not accepted via eth anymore. We could probably realize the bad block test with the engine API now.

@lightclient
Copy link
Member Author

Yeah that is a good point, I'll see if I can update that hive PR to use the engine API instead.

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