From 0d65071abc9c8a64fd88928cc36e8c0765759188 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 7 Dec 2022 21:16:12 +0300 Subject: [PATCH 1/2] config: use string type for Port 6b4dd5703e3a2255c915406c60c2d91bb83fee06 made it to be a uint16 which was somewhat important for RPC, but now it's irrelevant and the fact that it was a string in some cases may lead to errors like these: failed to unmarshal config YAML: yaml: unmarshal errors: line 48: cannot unmarshal !!str `20011` into uint16 line 52: cannot unmarshal !!str `40001` into uint16 So for maximum backwards compatibility we better have string here and eventually it'll be deleted anyway. --- pkg/config/basic_service.go | 7 +++---- pkg/config/basic_service_test.go | 2 +- pkg/config/rpc_config_test.go | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/config/basic_service.go b/pkg/config/basic_service.go index 50014b06b..171b55f51 100644 --- a/pkg/config/basic_service.go +++ b/pkg/config/basic_service.go @@ -2,7 +2,6 @@ package config import ( "net" - "strconv" ) // BasicService is used as a simple base for node services like Pprof, RPC or @@ -12,7 +11,7 @@ type BasicService struct { // Deprecated: please, use Addresses section instead. This field will be removed later. Address *string `yaml:"Address,omitempty"` // Deprecated: please, use Addresses section instead. This field will be removed later. - Port *uint16 `yaml:"Port,omitempty"` + Port *string `yaml:"Port,omitempty"` // Addresses holds the list of bind addresses in the form of "address:port". Addresses []string `yaml:"Addresses"` } @@ -25,7 +24,7 @@ func (s BasicService) GetAddresses() []string { if s.Address != nil || s.Port != nil { //nolint:staticcheck // SA1019: s.Address is deprecated var ( addr string - port uint16 + port string ) if s.Address != nil { //nolint:staticcheck // SA1019: s.Address is deprecated addr = *s.Address //nolint:staticcheck // SA1019: s.Address is deprecated @@ -33,7 +32,7 @@ func (s BasicService) GetAddresses() []string { if s.Port != nil { //nolint:staticcheck // SA1019: s.Port is deprecated port = *s.Port //nolint:staticcheck // SA1019: s.Port is deprecated } - addrs = append(addrs, net.JoinHostPort(addr, strconv.FormatUint(uint64(port), 10))) + addrs = append(addrs, net.JoinHostPort(addr, port)) } return addrs } diff --git a/pkg/config/basic_service_test.go b/pkg/config/basic_service_test.go index 685ddd9da..4e4f4d761 100644 --- a/pkg/config/basic_service_test.go +++ b/pkg/config/basic_service_test.go @@ -8,7 +8,7 @@ import ( func TestBasicService_GetAddresses(t *testing.T) { addr := "1.2.3.4" - port := uint16(1234) + port := "1234" s := BasicService{ Enabled: false, Address: &addr, diff --git a/pkg/config/rpc_config_test.go b/pkg/config/rpc_config_test.go index 2d9a02dcf..af4e82e69 100644 --- a/pkg/config/rpc_config_test.go +++ b/pkg/config/rpc_config_test.go @@ -20,5 +20,5 @@ MaxGasInvoke: 15 err := yaml.Unmarshal([]byte(data), &cfg) require.NoError(t, err) require.True(t, cfg.Enabled) - require.Equal(t, uint16(10332), *cfg.Port) + require.Equal(t, "10332", *cfg.Port) } From 3ce1fc41a4e64d4eca602dd05a90ec2ddeb4a488 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 7 Dec 2022 21:29:40 +0300 Subject: [PATCH 2/2] config: fix the default P2P ping settings 54c2aa858295a38f79b1bf375a79e48194d4ceb9 broke them, they're in seconds and we have a 90s timeout. --- pkg/config/config.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 094eba209..93cc4ca43 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "time" "github.com/nspcc-dev/neo-go/pkg/config/netmode" "gopkg.in/yaml.v3" @@ -66,8 +67,8 @@ func LoadFile(configPath string) (Config, error) { config := Config{ ApplicationConfiguration: ApplicationConfiguration{ P2P: P2P{ - PingInterval: 30, - PingTimeout: 30, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, }, RPC: RPC{ MaxIteratorResultItems: DefaultMaxIteratorResultItems,