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

feat: clean up p2p & implement missing peering functionality #2852

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a929e52
Clean up NodeKey
zivkovicmilos Sep 26, 2024
a7f40f1
Drop the random command from p2p
zivkovicmilos Sep 26, 2024
e91a1a8
Drop the unused upnp package from p2p
zivkovicmilos Sep 26, 2024
ea6d19a
Clean up NetAddress
zivkovicmilos Sep 26, 2024
38a446c
Save
zivkovicmilos Sep 27, 2024
398f86a
Save
zivkovicmilos Sep 27, 2024
373f489
Tidy up node info
zivkovicmilos Sep 30, 2024
f934a84
Temporary save
zivkovicmilos Oct 1, 2024
93fa469
Tidy peer
zivkovicmilos Oct 1, 2024
8536074
Save progress on switch
zivkovicmilos Oct 3, 2024
338c93b
Save switch progress
zivkovicmilos Oct 6, 2024
e5d7861
Remove unnecessary peer filtering logic
zivkovicmilos Oct 14, 2024
fefba77
Remove unnecessary peer filtering logic from config
zivkovicmilos Oct 14, 2024
2f11de2
Save transport progress
zivkovicmilos Oct 15, 2024
1c0152e
Save progress on transport
zivkovicmilos Oct 16, 2024
1653571
Save reorg progress
zivkovicmilos Oct 17, 2024
989ea8d
Add unit tests for the config, dial queue
zivkovicmilos Oct 18, 2024
a0e1f28
Add unit tests for events
zivkovicmilos Oct 18, 2024
eb2a7a1
Add ctx to switch
zivkovicmilos Oct 21, 2024
b238bf3
Add initial discovery code
zivkovicmilos Oct 23, 2024
728742d
Make the switch modifiable in the base reactor
zivkovicmilos Oct 23, 2024
8af018a
Add coverage for discovery
zivkovicmilos Oct 23, 2024
06433ec
Improve redial logic
zivkovicmilos Oct 23, 2024
8e09e82
Simplify the persistent peer redial
zivkovicmilos Oct 23, 2024
7606475
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Oct 23, 2024
2c503c9
Minor cleanup
zivkovicmilos Oct 23, 2024
a11726e
Save switch unit test progress
zivkovicmilos Oct 24, 2024
e7a987b
Add remaining unit tests for the switch
zivkovicmilos Oct 27, 2024
a07d7a9
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Oct 30, 2024
1f96b45
Save transport test progress
zivkovicmilos Oct 31, 2024
2c96044
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 4, 2024
1d71df7
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 9, 2024
9b156bc
Respect private peer IDs
zivkovicmilos Nov 9, 2024
ba9c83d
Standardize peer lookup methods for the peer behavior
zivkovicmilos Nov 9, 2024
c744b3f
Wrap up transport Accept unit tests
zivkovicmilos Nov 9, 2024
1f952da
Add unit test for private peers in discovery
zivkovicmilos Nov 9, 2024
d32b926
Drop useless test
zivkovicmilos Nov 9, 2024
85de00e
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 15, 2024
a82475e
Add additional unit tests
zivkovicmilos Nov 15, 2024
7c59c13
Save unit test progress
zivkovicmilos Nov 16, 2024
a179026
Fix failing mempool tests
zivkovicmilos Nov 16, 2024
d4ff457
Fixup module tests
zivkovicmilos Nov 17, 2024
bf94f1e
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 17, 2024
8c0e6a6
Tidy mods
zivkovicmilos Nov 17, 2024
b02dd87
Make fmt
zivkovicmilos Nov 17, 2024
1984848
Fix lint errors
zivkovicmilos Nov 17, 2024
372e37d
Fixup condition
zivkovicmilos Nov 17, 2024
a28c814
Update config get unit tests
zivkovicmilos Nov 17, 2024
7d64ff9
Update README
zivkovicmilos Nov 17, 2024
71c9c25
Start discovery reactor, fixup tests
zivkovicmilos Nov 18, 2024
d47c2e1
Add redial backoff
zivkovicmilos Nov 18, 2024
a0a6341
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 19, 2024
585f20e
Minor cleanup
zivkovicmilos Nov 19, 2024
a9dd9dd
Remove unused test case
zivkovicmilos Nov 19, 2024
6af09bf
Update cast
zivkovicmilos Nov 19, 2024
32e019a
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 22, 2024
67749b1
Make tidy
zivkovicmilos Nov 22, 2024
6ad9353
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 29, 2024
b1ff84f
Update dial timeout for switch
zivkovicmilos Nov 29, 2024
67184aa
Merge branch 'master' into dev/zivkovicmilos/bootnodes
zivkovicmilos Nov 29, 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
1 change: 1 addition & 0 deletions .github/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ issues:
- gosec # Disabled linting of weak number generators
- makezero # Disabled linting of intentional slice appends
- goconst # Disabled linting of common mnemonics and test case strings
- unused # Disabled linting of unused mock methods
- path: _\.gno
linters:
- errorlint # Disabled linting of error comparisons, because of lacking std lib support
1 change: 1 addition & 0 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ require (
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.5.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnofaucet/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.29.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnofaucet/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contribs/gnogenesis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
Expand All @@ -50,6 +51,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnogenesis/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contribs/gnohealth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/stretchr/testify v1.9.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.29.0 // indirect
Expand All @@ -35,6 +36,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions contribs/gnohealth/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/zondax/hid v0.9.2 // indirect
Expand All @@ -53,6 +54,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contribs/gnomigrate/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
go.etcd.io/bbolt v1.3.11 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
Expand All @@ -45,6 +46,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnomigrate/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 3 additions & 51 deletions gno.land/cmd/gnoland/config_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@ func TestConfig_Get_Base(t *testing.T) {
},
true,
},
{
"filter peers flag fetched",
"filter_peers",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.FilterPeers, unmarshalJSONCommon[bool](t, value))
},
false,
},
}

verifyGetTestTableCommon(t, testTable)
Expand Down Expand Up @@ -616,27 +608,19 @@ func TestConfig_Get_P2P(t *testing.T) {
},
true,
},
{
"upnp toggle",
"p2p.upnp",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.UPNP, unmarshalJSONCommon[bool](t, value))
},
false,
},
{
"max inbound peers",
"p2p.max_num_inbound_peers",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.MaxNumInboundPeers, unmarshalJSONCommon[int](t, value))
assert.Equal(t, loadedCfg.P2P.MaxNumInboundPeers, unmarshalJSONCommon[uint64](t, value))
},
false,
},
{
"max outbound peers",
"p2p.max_num_outbound_peers",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.MaxNumOutboundPeers, unmarshalJSONCommon[int](t, value))
assert.Equal(t, loadedCfg.P2P.MaxNumOutboundPeers, unmarshalJSONCommon[uint64](t, value))
},
false,
},
Expand Down Expand Up @@ -676,15 +660,7 @@ func TestConfig_Get_P2P(t *testing.T) {
"pex reactor toggle",
"p2p.pex",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.PexReactor, unmarshalJSONCommon[bool](t, value))
},
false,
},
{
"seed mode",
"p2p.seed_mode",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.SeedMode, unmarshalJSONCommon[bool](t, value))
assert.Equal(t, loadedCfg.P2P.PeerExchange, unmarshalJSONCommon[bool](t, value))
},
false,
},
Expand All @@ -704,30 +680,6 @@ func TestConfig_Get_P2P(t *testing.T) {
},
true,
},
{
"allow duplicate IP",
"p2p.allow_duplicate_ip",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.AllowDuplicateIP, unmarshalJSONCommon[bool](t, value))
},
false,
},
{
"handshake timeout",
"p2p.handshake_timeout",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.HandshakeTimeout, unmarshalJSONCommon[time.Duration](t, value))
},
false,
},
{
"dial timeout",
"p2p.dial_timeout",
func(loadedCfg *config.Config, value []byte) {
assert.Equal(t, loadedCfg.P2P.DialTimeout, unmarshalJSONCommon[time.Duration](t, value))
},
false,
},
}

verifyGetTestTableCommon(t, testTable)
Expand Down
74 changes: 1 addition & 73 deletions gno.land/cmd/gnoland/config_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,6 @@ func TestConfig_Set_Base(t *testing.T) {
assert.Equal(t, value, loadedCfg.ProfListenAddress)
},
},
{
"filter peers flag updated",
[]string{
"filter_peers",
"true",
},
func(loadedCfg *config.Config, value string) {
boolVal, err := strconv.ParseBool(value)
require.NoError(t, err)

assert.Equal(t, boolVal, loadedCfg.FilterPeers)
},
},
}

verifySetTestTableCommon(t, testTable)
Expand Down Expand Up @@ -505,19 +492,6 @@ func TestConfig_Set_P2P(t *testing.T) {
assert.Equal(t, value, loadedCfg.P2P.PersistentPeers)
},
},
{
"upnp toggle updated",
[]string{
"p2p.upnp",
"false",
},
func(loadedCfg *config.Config, value string) {
boolVal, err := strconv.ParseBool(value)
require.NoError(t, err)

assert.Equal(t, boolVal, loadedCfg.P2P.UPNP)
},
},
{
"max inbound peers updated",
[]string{
Expand Down Expand Up @@ -588,20 +562,7 @@ func TestConfig_Set_P2P(t *testing.T) {
boolVal, err := strconv.ParseBool(value)
require.NoError(t, err)

assert.Equal(t, boolVal, loadedCfg.P2P.PexReactor)
},
},
{
"seed mode updated",
[]string{
"p2p.seed_mode",
"false",
},
func(loadedCfg *config.Config, value string) {
boolVal, err := strconv.ParseBool(value)
require.NoError(t, err)

assert.Equal(t, boolVal, loadedCfg.P2P.SeedMode)
assert.Equal(t, boolVal, loadedCfg.P2P.PeerExchange)
},
},
{
Expand All @@ -614,39 +575,6 @@ func TestConfig_Set_P2P(t *testing.T) {
assert.Equal(t, value, loadedCfg.P2P.PrivatePeerIDs)
},
},
{
"allow duplicate IPs updated",
[]string{
"p2p.allow_duplicate_ip",
"false",
},
func(loadedCfg *config.Config, value string) {
boolVal, err := strconv.ParseBool(value)
require.NoError(t, err)

assert.Equal(t, boolVal, loadedCfg.P2P.AllowDuplicateIP)
},
},
{
"handshake timeout updated",
[]string{
"p2p.handshake_timeout",
"1s",
},
func(loadedCfg *config.Config, value string) {
assert.Equal(t, value, loadedCfg.P2P.HandshakeTimeout.String())
},
},
{
"dial timeout updated",
[]string{
"p2p.dial_timeout",
"1s",
},
func(loadedCfg *config.Config, value string) {
assert.Equal(t, value, loadedCfg.P2P.DialTimeout.String())
},
},
}

verifySetTestTableCommon(t, testTable)
Expand Down
6 changes: 3 additions & 3 deletions gno.land/cmd/gnoland/secrets_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/gnolang/gno/tm2/pkg/amino"
"github.com/gnolang/gno/tm2/pkg/bft/privval"
"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/p2p"
"github.com/gnolang/gno/tm2/pkg/p2p/types"
)

var (
Expand Down Expand Up @@ -54,7 +54,7 @@ func isValidDirectory(dirPath string) bool {
}

type secretData interface {
privval.FilePVKey | privval.FilePVLastSignState | p2p.NodeKey
privval.FilePVKey | privval.FilePVLastSignState | types.NodeKey
}

// readSecretData reads the secret data from the given path
Expand Down Expand Up @@ -145,7 +145,7 @@ func validateValidatorStateSignature(
}

// validateNodeKey validates the node's p2p key
func validateNodeKey(key *p2p.NodeKey) error {
func validateNodeKey(key *types.NodeKey) error {
if key.PrivKey == nil {
return errInvalidNodeKey
}
Expand Down
Loading
Loading