-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fetch peers p2p #559
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 0c9b768
Merge branch 'main' into avago1.12.0
cam-schultz 2db445c
avago poc v5
cam-schultz 472c76d
avago initial poc 8
cam-schultz 75fe28d
use latest local network framework
cam-schultz 99c58e9
bump teleporter dep
cam-schultz 92c36c6
Merge branch 'main' into avago1.12.0
cam-schultz 498cb40
Merge branch 'avago1.12.0' into fetch-peers-p2p
cam-schultz 6c29cff
manually tracked peers cfg
cam-schultz bbb2c71
wip
cam-schultz 3ca88fe
p2p tests passing
cam-schultz 9923b3e
cleanup
cam-schultz 48dcc49
track subnet on connection
cam-schultz 41362e0
enable all tests
cam-schultz 4f2a325
fetch validators on new subnet tracked
cam-schultz 3dae643
use temp avago workaround branch
cam-schultz e74f59b
remove local teleporter dep
cam-schultz 75359d9
Merge branch 'main' into fetch-peers-p2p
cam-schultz 3adfe8a
generate mocks & fix test build
cam-schultz 69c93e2
lint
cam-schultz 03485e1
remove info api metrics
cam-schultz 6ddba1f
remove test artifacts
cam-schultz 0f0671c
Merge branch 'main' into fetch-peers-p2p
cam-schultz 0c51ebd
add lock helper
cam-schultz 94fb5d5
reduce log level
cam-schultz dec5f93
updateValidatorSet appRequestNetwork method
cam-schultz 0d38d51
organize go.mod
cam-schultz 98cc1bc
warn not enough bootstrap nodes
cam-schultz fc45025
better bootstrap node sampling
cam-schultz f8eaf8b
fetch proposed validators
cam-schultz e160dcc
properly break out of loop
cam-schultz 7988e70
correct comment
cam-schultz a1d0897
Merge branch 'main' into fetch-peers-p2p
cam-schultz 9f47f1e
simplify control flow
cam-schultz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.