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

Fetch peers p2p #559

Merged
merged 34 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
366b0dc
bump to v1.12.0-initial-poc.2
iansuvak Oct 3, 2024
0c9b768
Merge branch 'main' into avago1.12.0
cam-schultz Oct 10, 2024
2db445c
avago poc v5
cam-schultz Oct 10, 2024
472c76d
avago initial poc 8
cam-schultz Nov 12, 2024
75fe28d
use latest local network framework
cam-schultz Nov 6, 2024
99c58e9
bump teleporter dep
cam-schultz Nov 13, 2024
92c36c6
Merge branch 'main' into avago1.12.0
cam-schultz Nov 14, 2024
498cb40
Merge branch 'avago1.12.0' into fetch-peers-p2p
cam-schultz Nov 14, 2024
6c29cff
manually tracked peers cfg
cam-schultz Nov 14, 2024
bbb2c71
wip
cam-schultz Nov 15, 2024
3ca88fe
p2p tests passing
cam-schultz Nov 21, 2024
9923b3e
cleanup
cam-schultz Nov 21, 2024
48dcc49
track subnet on connection
cam-schultz Nov 21, 2024
41362e0
enable all tests
cam-schultz Nov 21, 2024
4f2a325
fetch validators on new subnet tracked
cam-schultz Nov 21, 2024
3dae643
use temp avago workaround branch
cam-schultz Nov 22, 2024
e74f59b
remove local teleporter dep
cam-schultz Nov 22, 2024
75359d9
Merge branch 'main' into fetch-peers-p2p
cam-schultz Nov 22, 2024
3adfe8a
generate mocks & fix test build
cam-schultz Nov 22, 2024
69c93e2
lint
cam-schultz Nov 22, 2024
03485e1
remove info api metrics
cam-schultz Nov 22, 2024
6ddba1f
remove test artifacts
cam-schultz Nov 25, 2024
0f0671c
Merge branch 'main' into fetch-peers-p2p
cam-schultz Nov 25, 2024
0c51ebd
add lock helper
cam-schultz Nov 25, 2024
94fb5d5
reduce log level
cam-schultz Nov 25, 2024
dec5f93
updateValidatorSet appRequestNetwork method
cam-schultz Nov 25, 2024
0d38d51
organize go.mod
cam-schultz Nov 25, 2024
98cc1bc
warn not enough bootstrap nodes
cam-schultz Nov 25, 2024
fc45025
better bootstrap node sampling
cam-schultz Nov 25, 2024
f8eaf8b
fetch proposed validators
cam-schultz Nov 25, 2024
e160dcc
properly break out of loop
cam-schultz Nov 26, 2024
7988e70
correct comment
cam-schultz Nov 26, 2024
a1d0897
Merge branch 'main' into fetch-peers-p2p
cam-schultz Nov 26, 2024
9f47f1e
simplify control flow
cam-schultz Nov 26, 2024
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
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 {

Choose a reason for hiding this comment

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

Would it be better to have a constructor newPeerConfig that does the validation before building the config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do validate at construction time in the top-level config constructor: https://github.com/ava-labs/awm-relayer/blob/main/relayer/config/viper.go#L21

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not the cleanest pattern, but we have to unmarshal the config and validate it in separate steps regardless, it's just a question of code organization.

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