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 flag to choose advertising local IP to Prysm node #33

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

cortze
Copy link
Contributor

@cortze cortze commented Jun 20, 2024

This PR addresses #31

Changes work locally:

  • with the flag on the command:
level=INFO msg="Adding ourselves as a trusted peer to Prysm" peer_id=16Uiu2HAmBpAB8GPWRTC77i8ZUqJSoqTatiaPqqcJDrPGMYwhXM1M "on local maddr"=/ip4/127.0.0.1/tcp/9020
  • without the flag on the command, and the default behaviour:
level=INFO msg="Adding ourselves as a trusted peer to Prysm" peer_id=16Uiu2HAmTTJTsbhNvWAwjEBck21g3Ap4FFBUnDxnTFPzavzdWHRQ "on priv maddr"=/ip4/192.168.1.109/tcp/9020

@cortze cortze linked an issue Jun 20, 2024 that may be closed by this pull request
// this host is listening on.
func (h *Host) LocalListenMaddr() (ma.Multiaddr, error) {
for _, maddr := range h.Addrs() {
if manet.IsIPLoopback(maddr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to be specifically ip4 or ip6 or it doesn't matter and both addresses are acceptable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good question. I've been checking at the Prysm code, and it doesn't seem to check anything, it just parses the maddr info using the go-libp2p primitives:

func (s *Server) AddTrustedPeer(w http.ResponseWriter, r *http.Request) {
     ...
     info, err := peer.AddrInfoFromString(addrRequest.Addr)
     ....

Do you think that could be a problem? We don't seem to be checking anything like that for the private maddr neither:

// PrivateListenMaddr returns the first multiaddress in a private IP range that
// this host is listening on.
func (h *Host) PrivateListenMaddr() (ma.Multiaddr, error) {
	for _, maddr := range h.Addrs() {
		if manet.IsIPLoopback(maddr) {
			continue
		}
		if !manet.IsPrivateAddr(maddr) {
			continue
		}
		return maddr, nil
	}
	return nil, fmt.Errorf("no private multi address found in %s", h.Addrs())
}

Copy link
Contributor

@guillaumemichel guillaumemichel Jun 20, 2024

Choose a reason for hiding this comment

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

As long as both Hermes and Prysm have both an ip4 and ip6 and can reach each other on both stacks it is fine (or they are both using only ip4 XOR ip6). Otherwise, we could also restrict both to use ip4 (or ip6) only

@cortze
Copy link
Contributor Author

cortze commented Aug 16, 2024

Coming back to this since it got hanging for a few weeks.
We generally run both the Prysm node and Hermes on ip4, is that a blocker to merge the PR @guillaumemichel ?
Should I make it explicit on the Readme, or add a sanity check when spawning Hermes?

Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

LGTM if everything runs on the ip4 stack

@cortze cortze merged commit 3937a0a into main Aug 22, 2024
4 checks passed
@cortze cortze deleted the 31-advertising-localhost-ip-to-trusted-prysm-node branch August 22, 2024 08:54
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.

Advertising localhost IP to trusted Prysm node
2 participants