Skip to content

Commit

Permalink
ir/config: make P2PNotaryRequestPayloadPoolSize configurable
Browse files Browse the repository at this point in the history
Add `fschain.consensus.p2p_notary_request_payload_pool_size` option in config
to configure `P2PNotaryRequestPayloadPoolSize` parameter.

Closes #3191.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
  • Loading branch information
End-rey committed Mar 3, 2025
1 parent d74a7ad commit 07dc7e9
Show file tree
Hide file tree
Showing 5 changed files with 27 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 (#3194)

### 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
}

Check warning on line 134 in pkg/innerring/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/config.go#L133-L134

Added lines #L133 - L134 were not covered by tests
c.P2PNotaryRequestPayloadPoolSize = uint32(p2pNotaryRequestPayloadPoolSize)

var validatorsHistoryKey = cfgPathFSChainLocalConsensus + ".validators_history"
if v.IsSet(validatorsHistoryKey) {
c.ValidatorsHistory = make(map[uint32]uint32)
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
}

Check warning on line 377 in pkg/innerring/internal/blockchain/blockchain.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/internal/blockchain/blockchain.go#L375-L377

Added lines #L375 - L377 were not covered by tests

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)

Check warning on line 394 in pkg/innerring/internal/blockchain/blockchain.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/internal/blockchain/blockchain.go#L394

Added line #L394 was not covered by tests
cfgBaseProto.MaxTraceableBlocks = cfg.TraceableChainLength
cfgBaseProto.Hardforks = cfg.HardForks
if cfg.ValidatorsHistory != nil {
Expand Down

0 comments on commit 07dc7e9

Please sign in to comment.