Skip to content

Commit

Permalink
Make P2PNotaryRequestPayloadPoolSize configurable (#3195)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Mar 3, 2025
2 parents d74a7ad + 28cba9f commit a483e26
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog for NeoFS Node
## [Unreleased]

### Added
- IR `fschain.consensus.p2p_notary_request_payload_pool_size` config option (#3195)

### Fixed
- Zero range denial by `neofs-cli object range|hash` commands (#3182)
Expand Down
14 changes: 8 additions & 6 deletions cmd/neofs-ir/internal/validate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ type validConfig struct {
Timeout time.Duration `mapstructure:"timeout"`
} `mapstructure:"ping"`
} `mapstructure:"p2p"`
SetRolesInGenesis bool `mapstructure:"set_roles_in_genesis"`
KeepOnlyLatestState bool `mapstructure:"keep_only_latest_state"`
RemoveUntraceableBlocks bool `mapstructure:"remove_untraceable_blocks"`
SetRolesInGenesis bool `mapstructure:"set_roles_in_genesis"`
KeepOnlyLatestState bool `mapstructure:"keep_only_latest_state"`
RemoveUntraceableBlocks bool `mapstructure:"remove_untraceable_blocks"`
P2PNotaryRequestPayloadPoolSize uint32 `mapstructure:"p2p_notary_request_payload_pool_size"`
} `mapstructure:"consensus"`
} `mapstructure:"morph"`

Expand Down Expand Up @@ -129,9 +130,10 @@ type validConfig struct {
Timeout time.Duration `mapstructure:"timeout"`
} `mapstructure:"ping"`
} `mapstructure:"p2p"`
SetRolesInGenesis bool `mapstructure:"set_roles_in_genesis"`
KeepOnlyLatestState bool `mapstructure:"keep_only_latest_state"`
RemoveUntraceableBlocks bool `mapstructure:"remove_untraceable_blocks"`
SetRolesInGenesis bool `mapstructure:"set_roles_in_genesis"`
KeepOnlyLatestState bool `mapstructure:"keep_only_latest_state"`
RemoveUntraceableBlocks bool `mapstructure:"remove_untraceable_blocks"`
P2PNotaryRequestPayloadPoolSize uint32 `mapstructure:"p2p_notary_request_payload_pool_size"`
} `mapstructure:"consensus"`
} `mapstructure:"fschain"`

Expand Down
2 changes: 2 additions & 0 deletions config/example/ir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ fschain:
keep_only_latest_state: true # Optional flag that specifies if MPT should only store the latest state.
remove_untraceable_blocks: false # Optional flag that denotes whether old blocks should be removed
# from cache and database.
p2p_notary_request_payload_pool_size: 100 # Optional size of the node's P2P Notary request payloads memory pool.
# Defaults to 1000. Must be unsigned integer in range [1:2147483647].

fschain_autodeploy: true # Optional flag to run auto-deployment procedure of the FS chain. By default,
# the chain is expected to be deployed/updated in the background (e.g. via NeoFS ADM tool).
Expand Down
7 changes: 7 additions & 0 deletions pkg/innerring/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
}
}

p2pNotaryRequestPayloadPoolSize, err := parseConfigUint64Range(v, cfgPathFSChainLocalConsensus+".p2p_notary_request_payload_pool_size",
"Size of the node's P2P Notary request payloads memory pool", 1, math.MaxUint32)
if err != nil && !errors.Is(err, errMissingConfig) {
return c, err
}
c.P2PNotaryRequestPayloadPoolSize = uint32(p2pNotaryRequestPayloadPoolSize)

var validatorsHistoryKey = cfgPathFSChainLocalConsensus + ".validators_history"
if v.IsSet(validatorsHistoryKey) {
c.ValidatorsHistory = make(map[uint32]uint32)
Expand Down
22 changes: 22 additions & 0 deletions pkg/innerring/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const validBlockchainConfigOptions = `
4: 1
12: 4
rpc:
max_websocket_clients: 100
session_pool_size: 100
listen:
- localhost:30000
- localhost:30001
Expand Down Expand Up @@ -72,6 +74,9 @@ const validBlockchainConfigOptions = `
interval: 44s
timeout: 55s
set_roles_in_genesis: true
keep_only_latest_state: true
remove_untraceable_blocks: true
p2p_notary_request_payload_pool_size: 100
`

func _newConfigFromYAML(tb testing.TB, yaml1, yaml2 string) *viper.Viper {
Expand Down Expand Up @@ -172,6 +177,8 @@ func TestParseBlockchainConfig(t *testing.T) {
Committee: validCommittee,
BlockInterval: time.Second,
RPC: blockchain.RPCConfig{
MaxWebSocketClients: 100,
SessionPoolSize: 100,
Addresses: []string{
"localhost:30000",
"localhost:30001",
Expand Down Expand Up @@ -220,6 +227,11 @@ func TestParseBlockchainConfig(t *testing.T) {
12: 4,
},
SetRolesInGenesis: true,
Ledger: blockchain.LedgerConfig{
KeepOnlyLatestState: true,
RemoveUntraceableBlocks: true,
},
P2PNotaryRequestPayloadPoolSize: 100,
}, c)
})

Expand Down Expand Up @@ -279,6 +291,10 @@ func TestParseBlockchainConfig(t *testing.T) {
{kvF("validators_history", map[string]any{"0": len(validCommittee) + 1})},
{kvF("validators_history", map[string]any{"0": 1, "3": 1})}, // height is not a multiple
{kvF("rpc.listen", []string{"not a TCP address"})},
{kvF("rpc.max_websocket_clients", -1)},
{kvF("rpc.max_websocket_clients", math.MaxInt32+1)},
{kvF("rpc.session_pool_size", -1)},
{kvF("rpc.session_pool_size", math.MaxInt32+1)},
{kvF("rpc.tls.enabled", true), kvF("rpc.tls.cert_file", "")}, // enabled but no cert file is provided
{kvF("rpc.tls.enabled", true), kvF("rpc.tls.cert_file", " \t")}, // enabled but no but blank cert is provided
{kvF("rpc.tls.enabled", true), kvF("rpc.tls.cert_file", "/path/"), kvF("rpc.tls.key_file", "")}, // enabled but no key is provided
Expand All @@ -303,6 +319,12 @@ func TestParseBlockchainConfig(t *testing.T) {
{kvF("set_roles_in_genesis", "True")},
{kvF("set_roles_in_genesis", "False")},
{kvF("set_roles_in_genesis", "not a boolean")},
{kvF("p2p_notary_request_payload_pool_size", -1)},
{kvF("keep_only_latest_state", 1)},
{kvF("keep_only_latest_state", "True")},
{kvF("remove_untraceable_blocks", 1)},
{kvF("remove_untraceable_blocks", "True")},
{kvF("p2p_notary_request_payload_pool_size", math.MaxUint32+1)},
} {
var reportMsg []string

Expand Down
9 changes: 9 additions & 0 deletions pkg/innerring/internal/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ type Config struct {
//
// Optional.
Ledger LedgerConfig

// Memory pool size for P2PNotaryRequestPayloads.
//
// Optional: defaults to 1000.
P2PNotaryRequestPayloadPoolSize uint32
}

// New returns new Blockchain configured by the specified Config. New panics if
Expand Down Expand Up @@ -367,6 +372,9 @@ func New(cfg Config) (res *Blockchain, err error) {
if cfg.RPC.SessionPoolSize == 0 {
cfg.RPC.SessionPoolSize = 20
}
if cfg.P2PNotaryRequestPayloadPoolSize == 0 {
cfg.P2PNotaryRequestPayloadPoolSize = 1000
}

standByCommittee := make([]string, len(cfg.Committee))
for i := range cfg.Committee {
Expand All @@ -383,6 +391,7 @@ func New(cfg Config) (res *Blockchain, err error) {
cfgBaseProto.SeedList = cfg.SeedNodes
cfgBaseProto.VerifyTransactions = true
cfgBaseProto.P2PSigExtensions = true
cfgBaseProto.P2PNotaryRequestPayloadPoolSize = int(cfg.P2PNotaryRequestPayloadPoolSize)
cfgBaseProto.MaxTraceableBlocks = cfg.TraceableChainLength
cfgBaseProto.Hardforks = cfg.HardForks
if cfg.ValidatorsHistory != nil {
Expand Down

0 comments on commit a483e26

Please sign in to comment.