Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fetch peers over P2P #534

Closed
cam-schultz opened this issue Oct 29, 2024 · 2 comments
Closed

Fetch peers over P2P #534

cam-schultz opened this issue Oct 29, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@cam-schultz
Copy link
Collaborator

Context and scope
With Etna, primary network API nodes will no longer be expected to be connected to all L1 validators. info.Peers will return peers only for tracked subnets. Rather than requiring Info API nodes for all tracked subnets, we can instead fetch the global peer list over p2p. ava-labs/avalanchego#3491 relaxes the p2p.GetPeers constraints such that any primary network validator will return the list of peers across all L1s to non-primary network validator nodes. We can use this in the signature aggregator to fetch the global list of peers, and manually connect to each.

Discussion and alternatives
Peers can be fetched over p2p using the p2p.GetPeerList message type. We need to ensure that we are requesting this from a primary network validator. We can do this by calling info.Peers on a primary network API node, which matches the current API requirements.

Open questions
Is manually connecting to each of the peers the preferred approach? Currently, we connect to peers like so:

  • Fetch the canonical validator set of an L1
  • Fetch the global peer list (previously via info.Peers, with this change via p2p.GetPeerList)
  • Manually connect to the canonical validator set using the IP addresses from the previous step

Instead, we should be able to transitively connect to all L1 peers by manually connecting to a subset of the L1's validators. See the example here. We may be able to instead maintain an in-memory list of connected/tracked subnets that we bootstrap connections to only once. This would likely be a larger change, but could simplify peer discovery overall. Some additional research is required here, especially given potential changes to subnet tracking semantics in the Avalanchego networking code.

@cam-schultz cam-schultz added the enhancement New feature or request label Oct 29, 2024
@cam-schultz cam-schultz added this to the Etna compatibility milestone Oct 29, 2024
@cam-schultz cam-schultz self-assigned this Nov 1, 2024
@perfilev-faraway
Copy link

We're waiting for this feature. Current our workaround is using manuallyTrackedPeers, but it doesn't work with PoS chains when new validators can be added permissionless.

The patch below allows us to connect only to this bootstrap validator. The signature aggregator observes new validators correctly but unable to connect to them.

diff --git a/signature-aggregator/main/main.go b/signature-aggregator/main/main.go
index 829f860..3416aa9 100644
--- a/signature-aggregator/main/main.go
+++ b/signature-aggregator/main/main.go
@@ -4,12 +4,14 @@
 package main
 
 import (
+	"encoding/json"
 	"errors"
 	"fmt"
 	"log"
 	"net/http"
 	"os"
 
+	"github.com/ava-labs/avalanchego/api/info"
 	"github.com/ava-labs/avalanchego/message"
 	"github.com/ava-labs/avalanchego/utils/constants"
 	"github.com/ava-labs/avalanchego/utils/logging"
@@ -73,6 +75,24 @@ func main() {
 		),
 	)
 
+	var peer info.Peer
+
+	err = json.Unmarshal([]byte(`{
+		"ip": "44.218.255.99:9651",
+		"publicIP": "44.218.255.99:9651",
+		"nodeID": "NodeID-KQi8kBX1xZFanG7n9aWkiN16mrQARGs4P",
+		"version": "v1.2.3",
+		"lastSent": "2024-11-07T15:04:05Z",
+		"lastReceived": "2024-11-07T15:04:05Z",
+		"observedUptime": 95,
+		"trackedSubnets": [],
+		"supportedACPs": [],
+		"objectedACPs": []
+	}`), &peer)
+	if err != nil {
+		log.Fatalf("Error unmarshalling JSON: %v", err)
+	}
+
 	logger.Info("Initializing signature-aggregator")
 
 	// Initialize the global app request network
@@ -88,7 +108,7 @@ func main() {
 		networkLogLevel,
 		prometheus.DefaultRegisterer,
 		nil,
-		nil,
+		[]info.Peer{peer},
 		&cfg,
 	)
 	if err != nil {

@cam-schultz
Copy link
Collaborator Author

Fixed by #559

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants