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

Bootnode Registry #2337

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

Bootnode Registry #2337

wants to merge 43 commits into from

Conversation

AnkushinDaniil
Copy link
Contributor

@AnkushinDaniil AnkushinDaniil commented Dec 18, 2024

This pull request introduces significant changes to the l1 package, primarily focusing on integrating the IP Address Registry functionality. The most important changes include adding the IP Address Registry ABI, updating the EthSubscriber to handle IP address events, and modifying the Client to subscribe to these events and forward them to the P2P layer.

IP Address Registry Integration:

  • l1/abi/ip_address_registry.json: Added the ABI for the IP Address Registry contract, defining functions, errors, and events related to IP address management.
  • l1/eth_subscriber.go: Updated the EthSubscriber struct to include the IP Address Registry and its filterer. Added methods to watch for IP address additions and removals, and to get the list of IP addresses. [1] [2] [3]
  • l1/l1.go: Added methods to the Client to subscribe to IP address events and forward them to the P2P layer. Modified the Client constructor to accept a channel for forwarding these events. [1] [2] [3] [4] [5] [6] [7] [8]

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 85.89744% with 22 lines in your changes missing coverage. Please review.

Project coverage is 74.88%. Comparing base (417bb0a) to head (478e8cd).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
l1/eth_subscriber.go 42.85% 15 Missing and 1 partial ⚠️
l1/l1.go 94.05% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2337      +/-   ##
==========================================
+ Coverage   74.49%   74.88%   +0.38%     
==========================================
  Files         110      109       -1     
  Lines       11771    11852      +81     
==========================================
+ Hits         8769     8875     +106     
+ Misses       2324     2291      -33     
- Partials      678      686       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AnkushinDaniil AnkushinDaniil added P2P L1 Anything relate to Layer 1 (Ethereum) labels Dec 20, 2024
@AnkushinDaniil AnkushinDaniil changed the title Daniil/ip address registry Ip address registry Dec 20, 2024
@AnkushinDaniil AnkushinDaniil added the go Pull requests that update Go code label Dec 20, 2024
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/ip-address-registry branch 3 times, most recently from 386833b to 695290d Compare December 27, 2024 00:58
@AnkushinDaniil AnkushinDaniil force-pushed the daniil/ip-address-registry branch from 695290d to 09367b3 Compare December 30, 2024 09:54
@AnkushinDaniil AnkushinDaniil marked this pull request as ready for review January 1, 2025 10:34
utils/network.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
p2p/p2p.go Outdated Show resolved Hide resolved
p2p/p2p.go Outdated
Comment on lines 418 to 424
var peerIDBytes []byte
for it.Seek(prefix); it.Valid(); it.Next() {
peerIDBytes := it.Key()[len(prefix):]
peerID, err := peer.IDFromBytes(peerIDBytes)
peerIDBytes = it.Key()
if !bytes.HasPrefix(peerIDBytes, prefix) {
break
}
peerID, err := peer.IDFromBytes(peerIDBytes[len(prefix):])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this change needed? The db iterator should give keys which match the prefix, so we don't need to do the prefix check again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to do this, without this prefix check the peer storage won't work. db iterator gives keys that don't match the prefix

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the bug now. The NewIterator should create an iterator with lower bound specified. Let me create a PR real quick.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please check this:
#2357

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@weiihann
Copy link
Contributor

weiihann commented Jan 1, 2025

I think the name IpAddress may be too vague on what this component actually does. In fact, the address from L1 is not an IP address but rather a multiaddr.

If I understand correctly, there are some peers registered on the L1 smart contract. So we listen to those and adjust the peerstore accordingly. If I'm not wrong, these peers should be bootnodes, so BootnodeRegistry would be more suitable.

Also, not sure if this has been discussed before, who is allowed to add/remove the peers on L1?

@AnkushinDaniil AnkushinDaniil changed the title Ip address registry Bootnode Registry Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code L1 Anything relate to Layer 1 (Ethereum) P2P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants