Skip to content

Commit

Permalink
Merge branch 'main' into signature-aggregation-api-acp-118
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak authored Aug 27, 2024
2 parents e1edf7e + df148f8 commit 70666da
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ require (
github.com/ava-labs/teleporter v1.0.5
github.com/aws/aws-sdk-go-v2 v1.30.4
github.com/aws/aws-sdk-go-v2/config v1.27.9
github.com/aws/aws-sdk-go-v2/service/kms v1.35.4
github.com/aws/aws-sdk-go-v2/service/kms v1.35.5
github.com/ethereum/go-ethereum v1.13.8
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/onsi/ginkgo/v2 v2.20.1
github.com/onsi/gomega v1.34.1
github.com/pingcap/errors v0.11.4
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.1
github.com/prometheus/client_golang v1.20.2
github.com/redis/go-redis/v9 v9.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.16.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 h1:EyBZibR
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1/go.mod h1:JKpmtYhhPs7D97NL/ltqz7yCkERFW5dOlHyVl66ZYF8=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6 h1:b+E7zIUHMmcB4Dckjpkapoy47W6C9QBv/zoUP+Hn8Kc=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6/go.mod h1:S2fNV0rxrP78NhPbCZeQgY8H9jdDMeGtwcfZIRxzBqU=
github.com/aws/aws-sdk-go-v2/service/kms v1.35.4 h1:mG1MH6yPwT5gNEeBrhig3FHc4mK0QaZOXsmQUbphP6Y=
github.com/aws/aws-sdk-go-v2/service/kms v1.35.4/go.mod h1:A5CS0VRmxxj2YKYLCY08l/Zzbd01m6JZn0WzxgT1OCA=
github.com/aws/aws-sdk-go-v2/service/kms v1.35.5 h1:XUomV7SiclZl1QuXORdGcfFqHxEHET7rmNGtxTfNB+M=
github.com/aws/aws-sdk-go-v2/service/kms v1.35.5/go.mod h1:A5CS0VRmxxj2YKYLCY08l/Zzbd01m6JZn0WzxgT1OCA=
github.com/aws/aws-sdk-go-v2/service/sso v1.20.3 h1:mnbuWHOcM70/OFUlZZ5rcdfA8PflGXXiefU/O+1S3+8=
github.com/aws/aws-sdk-go-v2/service/sso v1.20.3/go.mod h1:5HFu51Elk+4oRBZVxmHrSds5jFXmFj8C3w7DVF2gnrs=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.3 h1:uLq0BKatTmDzWa/Nu4WO0M1AaQDaPpwTKAeByEc6WFM=
Expand Down Expand Up @@ -518,8 +518,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8=
github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
Expand Down
2 changes: 1 addition & 1 deletion peers/app_request_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewNetwork(
}

// Create the handler for handling inbound app responses
handler, err := NewRelayerExternalHandler(logger, prometheus.DefaultRegisterer)
handler, err := NewRelayerExternalHandler(logger, metrics)
if err != nil {
logger.Error(
"Failed to create p2p network handler",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var (
type AppRequestNetworkMetrics struct {
infoAPICallLatencyMS prometheus.Histogram
pChainAPICallLatencyMS prometheus.Histogram
connects prometheus.Counter
disconnects prometheus.Counter
}

func newAppRequestNetworkMetrics(registerer prometheus.Registerer) (*AppRequestNetworkMetrics, error) {
Expand Down Expand Up @@ -40,8 +42,32 @@ func newAppRequestNetworkMetrics(registerer prometheus.Registerer) (*AppRequestN
}
registerer.MustRegister(pChainAPICallLatencyMS)

connects := prometheus.NewCounter(
prometheus.CounterOpts{
Name: "connects",
Help: "Number of connected events",
},
)
if connects == nil {
return nil, ErrFailedToCreateAppRequestNetworkMetrics
}
registerer.MustRegister(connects)

disconnects := prometheus.NewCounter(
prometheus.CounterOpts{
Name: "disconnects",
Help: "Number of disconnected events",
},
)
if disconnects == nil {
return nil, ErrFailedToCreateAppRequestNetworkMetrics
}
registerer.MustRegister(disconnects)

return &AppRequestNetworkMetrics{
infoAPICallLatencyMS: infoAPICallLatencyMS,
pChainAPICallLatencyMS: pChainAPICallLatencyMS,
connects: connects,
disconnects: disconnects,
}, nil
}
8 changes: 6 additions & 2 deletions peers/external_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type RelayerExternalHandler struct {
responseChans map[uint32]chan message.InboundMessage
responsesCount map[uint32]expectedResponses
timeoutManager timer.AdaptiveTimeoutManager
metrics *AppRequestNetworkMetrics
}

// expectedResponses counts the number of responses and compares against the expected number of responses
Expand All @@ -41,7 +42,7 @@ type expectedResponses struct {
// Teleporter application relayer, as well as handle timeouts.
func NewRelayerExternalHandler(
logger logging.Logger,
registerer prometheus.Registerer,
metrics *AppRequestNetworkMetrics,
) (*RelayerExternalHandler, error) {
// TODO: Leaving this static for now, but we may want to have this as a config option
cfg := timer.AdaptiveTimeoutConfig{
Expand All @@ -52,7 +53,7 @@ func NewRelayerExternalHandler(
TimeoutHalflife: constants.DefaultNetworkTimeoutHalflife,
}

timeoutManager, err := timer.NewAdaptiveTimeoutManager(&cfg, registerer)
timeoutManager, err := timer.NewAdaptiveTimeoutManager(&cfg, prometheus.DefaultRegisterer)
if err != nil {
logger.Error(
"Failed to create timeout manager",
Expand All @@ -69,6 +70,7 @@ func NewRelayerExternalHandler(
responseChans: make(map[uint32]chan message.InboundMessage),
responsesCount: make(map[uint32]expectedResponses),
timeoutManager: timeoutManager,
metrics: metrics,
}, nil
}

Expand Down Expand Up @@ -105,13 +107,15 @@ func (h *RelayerExternalHandler) Connected(nodeID ids.NodeID, version *version.A
zap.Stringer("version", version),
zap.Stringer("subnetID", subnetID),
)
h.metrics.connects.Inc()
}

func (h *RelayerExternalHandler) Disconnected(nodeID ids.NodeID) {
h.log.Debug(
"Disconnected",
zap.Stringer("nodeID", nodeID),
)
h.metrics.disconnects.Inc()
}

// RegisterRequestID registers an AppRequest by requestID, and marks the number of
Expand Down
3 changes: 3 additions & 0 deletions relayer/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func main() {
// TODO: remove this from here once trackedSubnets are no longer referenced
// by ping messages in avalanchego
for _, sourceBlockchain := range cfg.SourceBlockchains {
if sourceBlockchain.GetSubnetID() == constants.PrimaryNetworkID {
continue
}
trackedSubnets.Add(sourceBlockchain.GetSubnetID())
}

Expand Down

0 comments on commit 70666da

Please sign in to comment.