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 extra peer endpoints to aggregator #519

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/ava-labs/awm-relayer

go 1.22.7
go 1.22.8

require (
github.com/ava-labs/avalanchego v1.11.11
github.com/ava-labs/avalanchego v1.12.0-initial-poc.0
github.com/ava-labs/coreth v0.13.8
github.com/ava-labs/subnet-evm v0.6.10
github.com/ava-labs/teleporter v1.0.7
Expand Down Expand Up @@ -85,7 +85,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/rpc v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ github.com/alexliesenfeld/health v0.8.0/go.mod h1:TfNP0f+9WQVWMQRzvMUjlws4ceXKEL
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.11 h1:MIQq8xRavRj4ZXHA4G+aMiymig7SOScGOG1SApmMvBc=
github.com/ava-labs/avalanchego v1.11.11/go.mod h1:yFx3V31Jy9NFa8GZlgGnwiVf8KGjeF2+Uc99l9Scd/8=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.0 h1:9JO0Yh4+fWfuoNenPgkJsaVuIh8cq4c1rYTD8Hv9fU8=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.0/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE=
github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8=
github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE=
github.com/ava-labs/subnet-evm v0.6.10 h1:uIh6bFMA4GCMVMQ3agBPxTMlYHL8FBR5FrhMR+drfKI=
Expand Down Expand Up @@ -355,8 +355,8 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk=
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk=
Expand Down
22 changes: 15 additions & 7 deletions peers/app_request_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"
"time"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/message"
"github.com/ava-labs/avalanchego/network"
Expand Down Expand Up @@ -58,13 +59,16 @@ type appRequestNetwork struct {
lock *sync.Mutex
validatorClient *validators.CanonicalValidatorClient
metrics *AppRequestNetworkMetrics
// endpoints for peers otherwise not available on canonical peers
extraPeerEndpoints []info.Peer
}

// NewNetwork creates a p2p network client for interacting with validators
func NewNetwork(
logLevel logging.Level,
registerer prometheus.Registerer,
trackedSubnets set.Set[ids.ID],
extraPeerEndpoints []info.Peer,
cfg Config,
) (AppRequestNetwork, error) {
logger := logging.NewLogger(
Expand Down Expand Up @@ -121,13 +125,14 @@ func NewNetwork(
validatorClient := validators.NewCanonicalValidatorClient(logger, cfg.GetPChainAPI())

arNetwork := &appRequestNetwork{
network: testNetwork,
handler: handler,
infoAPI: infoAPI,
logger: logger,
lock: new(sync.Mutex),
validatorClient: validatorClient,
metrics: metrics,
network: testNetwork,
handler: handler,
infoAPI: infoAPI,
logger: logger,
lock: new(sync.Mutex),
validatorClient: validatorClient,
metrics: metrics,
extraPeerEndpoints: extraPeerEndpoints,
}
go logger.RecoverAndPanic(func() {
testNetwork.Dispatch()
Expand Down Expand Up @@ -165,6 +170,9 @@ func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id
return nil
}

// Add specific endpoints not available at canonical peers
peers = append(peers, n.extraPeerEndpoints...)

// Attempt to connect to each peer
var trackedNodes set.Set[ids.NodeID]
for _, peer := range peers {
Expand Down
2 changes: 1 addition & 1 deletion peers/external_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewRelayerExternalHandler(
TimeoutHalflife: constants.DefaultNetworkTimeoutHalflife,
}

timeoutManager, err := timer.NewAdaptiveTimeoutManager(&cfg, prometheus.DefaultRegisterer)
timeoutManager, err := timer.NewAdaptiveTimeoutManager(&cfg, prometheus.NewRegistry())
if err != nil {
logger.Error(
"Failed to create timeout manager",
Expand Down
4 changes: 2 additions & 2 deletions peers/info_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ func (i *InfoAPI) Peers(ctx context.Context) ([]info.Peer, error) {
return i.client.Peers(ctx, i.options...)
}

func (i *InfoAPI) Uptime(ctx context.Context, subnetID ids.ID) (*info.UptimeResponse, error) {
return i.client.Uptime(ctx, subnetID, i.options...)
func (i *InfoAPI) Uptime(ctx context.Context) (*info.UptimeResponse, error) {
return i.client.Uptime(ctx, i.options...)
}
1 change: 1 addition & 0 deletions relayer/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func main() {
networkLogLevel,
registerer,
trackedSubnets,
nil,
&cfg,
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions signature-aggregator/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func main() {
networkLogLevel,
prometheus.DefaultRegisterer,
nil,
nil,
&cfg,
)
if err != nil {
Expand Down