Skip to content

Commit

Permalink
Merge pull request #559 from ava-labs/fetch-peers-p2p
Browse files Browse the repository at this point in the history
Fetch peers p2p
  • Loading branch information
cam-schultz authored Nov 26, 2024
2 parents 5d62039 + 9f47f1e commit 540a332
Show file tree
Hide file tree
Showing 23 changed files with 477 additions and 346 deletions.
44 changes: 44 additions & 0 deletions config/peer_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package config

import (
"net/netip"

"github.com/ava-labs/avalanchego/ids"
)

type PeerConfig struct {
ID string `mapstructure:"id" json:"id"`
IP string `mapstructure:"ip" json:"ip"`

id ids.NodeID
ip netip.AddrPort
}

func (c *PeerConfig) Validate() error {
var (
id ids.NodeID
ip netip.AddrPort
err error
)
if id, err = ids.NodeIDFromString(c.ID); err != nil {
return err
}
if ip, err = netip.ParseAddrPort(c.IP); err != nil {
return err
}
c.id = id
c.ip = ip

return nil
}

func (c *PeerConfig) GetID() ids.NodeID {
return c.id
}

func (c *PeerConfig) GetIP() netip.AddrPort {
return c.ip
}
6 changes: 6 additions & 0 deletions database/json_file_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ func (s *JSONFileStorage) getCurrentState(relayerID common.Hash) (chainState, bo
// Put the value into the JSON database. Read the current chain state and overwrite the key, if it exists
// If the file corresponding to {relayerID} does not exist, then it will be created
func (s *JSONFileStorage) Put(relayerID common.Hash, dataKey DataKey, value []byte) error {
s.logger.Debug(
"db put",
zap.Stringer("relayerID", relayerID),
zap.Stringer("key", dataKey),
zap.String("value", string(value)),
)
mutex, ok := s.mutexes[relayerID]
if !ok {
return errors.Wrap(
Expand Down
17 changes: 7 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ module github.com/ava-labs/awm-relayer
go 1.22.8

require (
github.com/ava-labs/avalanchego v1.12.0-fuji
github.com/alexliesenfeld/health v0.8.0
github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928
github.com/ava-labs/coreth v0.13.9-rc.1
github.com/ava-labs/subnet-evm v0.6.12
github.com/ava-labs/teleporter v1.0.8-0.20241121223552-226937a967e8
github.com/ava-labs/teleporter v1.0.8-0.20241122194201-a6e92843c3b1
github.com/aws/aws-sdk-go-v2 v1.32.5
github.com/aws/aws-sdk-go-v2/config v1.28.5
github.com/aws/aws-sdk-go-v2/service/kms v1.37.6
Expand All @@ -17,12 +18,14 @@ require (
github.com/pingcap/errors v0.11.4
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.5
github.com/redis/go-redis/v9 v9.7.0
github.com/redis/go-redis/v9 v9.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.9.0
go.uber.org/atomic v1.11.0
go.uber.org/mock v0.5.0
go.uber.org/zap v1.27.0
golang.org/x/sync v0.9.0
google.golang.org/grpc v1.68.0
google.golang.org/protobuf v1.35.2
)
Expand Down Expand Up @@ -93,6 +96,7 @@ require (
github.com/gorilla/rpc v1.2.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down Expand Up @@ -184,10 +188,3 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

require (
github.com/alexliesenfeld/health v0.8.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
go.uber.org/atomic v1.11.0
golang.org/x/sync v0.9.0
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/ava-labs/avalanchego v1.12.0-fuji h1:o/GbXrqW9CAXu2jX/a1dZtvFiiSVCWomJZyxF4hCQOA=
github.com/ava-labs/avalanchego v1.12.0-fuji/go.mod h1:yhD5dpZyStIVbxQ550EDi5w5SL7DQ/xGE6TIxosb7U0=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928 h1:th+K+wWgAYL/NsrFJyO+/sThLRdEDE0+I4vgbPLoWQQ=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928/go.mod h1:yhD5dpZyStIVbxQ550EDi5w5SL7DQ/xGE6TIxosb7U0=
github.com/ava-labs/coreth v0.13.9-rc.1 h1:qIICpC/OZGYUP37QnLgIqqwGmxnLwLpZaUlqJNI85vU=
github.com/ava-labs/coreth v0.13.9-rc.1/go.mod h1:7aMsRIo/3GBE44qWZMjnfqdqfcfZ5yShTTm2LObLaYo=
github.com/ava-labs/subnet-evm v0.6.12 h1:jL3FmjdFcNfS0qwbehwN6DkAg9y7zexB1riiGBxRsM0=
github.com/ava-labs/subnet-evm v0.6.12/go.mod h1:vffwL4UqAh7ibpWjveUuUhamm3a9w75q92bG5vXdX5k=
github.com/ava-labs/teleporter v1.0.8-0.20241121223552-226937a967e8 h1:jsH1wv1GgeztvipQG3di1OTruSHbFAwwP4K6clzTRLE=
github.com/ava-labs/teleporter v1.0.8-0.20241121223552-226937a967e8/go.mod h1:Q4/DDZPLI5f96xDykVXPT85PeJS3IqDPDJDk3UdQOuQ=
github.com/ava-labs/teleporter v1.0.8-0.20241122194201-a6e92843c3b1 h1:y1zjdfGlfTZQoPyUyPjsu9FjDK8w19OWUTpgVzQSh0w=
github.com/ava-labs/teleporter v1.0.8-0.20241122194201-a6e92843c3b1/go.mod h1:45NrpvVlms+xHL/rFZT7VrRJqajT7UUW78lzBe3hAzU=
github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo=
github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U=
github.com/aws/aws-sdk-go-v2/config v1.28.5 h1:Za41twdCXbuyyWv9LndXxZZv3QhTG1DinqlFsSuvtI0=
Expand Down Expand Up @@ -556,8 +556,8 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
Loading

0 comments on commit 540a332

Please # to comment.