diff --git a/CHANGELOG.md b/CHANGELOG.md index cc68bb336d..d027bd6dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changelog for NeoFS Node ### Added - IR `fschain.consensus.p2p_notary_request_payload_pool_size` config option (#3195) +- IR `fschain.consensus.rpc.max_gas_invoke` config option (#3208) ### Fixed - Zero range denial by `neofs-cli object range|hash` commands (#3182) diff --git a/cmd/neofs-ir/internal/validate/config.go b/cmd/neofs-ir/internal/validate/config.go index fd98bd141e..37f62d5e7a 100644 --- a/cmd/neofs-ir/internal/validate/config.go +++ b/cmd/neofs-ir/internal/validate/config.go @@ -48,6 +48,7 @@ type validConfig struct { Listen []string `mapstructure:"listen"` MaxWebSocketClients uint32 `mapstructure:"max_websocket_clients"` SessionPoolSize uint32 `mapstructure:"session_pool_size"` + MaxGasInvoke uint32 `mapstructure:"max_gas_invoke"` TLS struct { Enabled bool `mapstructure:"enabled"` Listen []string `mapstructure:"listen"` @@ -108,6 +109,7 @@ type validConfig struct { Listen []string `mapstructure:"listen"` MaxWebSocketClients uint32 `mapstructure:"max_websocket_clients"` SessionPoolSize uint32 `mapstructure:"session_pool_size"` + MaxGasInvoke uint32 `mapstructure:"max_gas_invoke"` TLS struct { Enabled bool `mapstructure:"enabled"` Listen []string `mapstructure:"listen"` diff --git a/config/example/ir.yaml b/config/example/ir.yaml index b9c781d333..e49cb58f0e 100644 --- a/config/example/ir.yaml +++ b/config/example/ir.yaml @@ -63,6 +63,8 @@ fschain: # Must be unsigned integer in range [1:2147483647]. session_pool_size: 100 # Optional maximum number of concurrent iterator sessions. Defaults to 20. # Must be unsigned integer in range [1:2147483647]. + max_gas_invoke: 200 # Optional maximum amount of GAS which can be spent during an RPC call, + # should be taken in GAS units. Defaults to 100. Must be unsigned integer in range [1:2147483647]. tls: # Additional addresses to listen to using TLS setup; must not overlap with `listen` section enabled: false # Additional TLS serving switcher listen: # Addresses to listen to; required to be at least 1-length if 'enabled' is 'true' diff --git a/pkg/innerring/config.go b/pkg/innerring/config.go index 981636b427..ca48a8abd3 100644 --- a/pkg/innerring/config.go +++ b/pkg/innerring/config.go @@ -183,6 +183,12 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co } c.RPC.SessionPoolSize = uint(sessionPoolSize) + maxGasInvoke, err := parseConfigUint64Range(v, rpcSection+".max_gas_invoke", "maximum amount of GAS which can be spent during an RPC call", 1, math.MaxInt32) + if err != nil && !errors.Is(err, errMissingConfig) { + return c, err + } + c.RPC.MaxGasInvoke = uint(maxGasInvoke) + var rpcTLSSection = rpcSection + ".tls" if v.GetBool(rpcTLSSection + ".enabled") { c.RPC.TLSConfig.Enabled = true diff --git a/pkg/innerring/config_test.go b/pkg/innerring/config_test.go index 711ba29a81..fc9ec5cf38 100644 --- a/pkg/innerring/config_test.go +++ b/pkg/innerring/config_test.go @@ -47,6 +47,7 @@ const validBlockchainConfigOptions = ` rpc: max_websocket_clients: 100 session_pool_size: 100 + max_gas_invoke: 200 listen: - localhost:30000 - localhost:30001 @@ -179,6 +180,7 @@ func TestParseBlockchainConfig(t *testing.T) { RPC: blockchain.RPCConfig{ MaxWebSocketClients: 100, SessionPoolSize: 100, + MaxGasInvoke: 200, Addresses: []string{ "localhost:30000", "localhost:30001", @@ -295,6 +297,8 @@ func TestParseBlockchainConfig(t *testing.T) { {kvF("rpc.max_websocket_clients", math.MaxInt32+1)}, {kvF("rpc.session_pool_size", -1)}, {kvF("rpc.session_pool_size", math.MaxInt32+1)}, + {kvF("rpc.max_gas_invoke", -1)}, + {kvF("rpc.max_gas_invoke", 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 diff --git a/pkg/innerring/internal/blockchain/blockchain.go b/pkg/innerring/internal/blockchain/blockchain.go index 6c99b76129..cff24e14c6 100644 --- a/pkg/innerring/internal/blockchain/blockchain.go +++ b/pkg/innerring/internal/blockchain/blockchain.go @@ -108,6 +108,11 @@ type RPCConfig struct { // // Optional: defaults to 20. Must not be larger than math.MaxInt32. SessionPoolSize uint + + // The maximum amount of GAS which can be spent during an RPC call. + // + // Optional: defaults to 100. Must not be larger than math.MaxInt32. + MaxGasInvoke uint } // TLSConfig configures additional RPC serving over TLS. @@ -375,6 +380,9 @@ func New(cfg Config) (res *Blockchain, err error) { if cfg.P2PNotaryRequestPayloadPoolSize == 0 { cfg.P2PNotaryRequestPayloadPoolSize = 1000 } + if cfg.RPC.MaxGasInvoke == 0 { + cfg.RPC.MaxGasInvoke = 100 + } standByCommittee := make([]string, len(cfg.Committee)) for i := range cfg.Committee { @@ -420,7 +428,7 @@ func New(cfg Config) (res *Blockchain, err error) { cfgBaseApp.P2PNotary.Enabled = true cfgBaseApp.P2PNotary.UnlockWallet = cfg.Wallet cfgBaseApp.RPC.StartWhenSynchronized = true - cfgBaseApp.RPC.MaxGasInvoke = fixedn.Fixed8FromInt64(100) + cfgBaseApp.RPC.MaxGasInvoke = fixedn.Fixed8FromInt64(int64(cfg.RPC.MaxGasInvoke)) cfgBaseApp.RPC.SessionEnabled = true cfgBaseApp.P2P.Addresses = cfg.P2P.ListenAddresses cfgBaseApp.P2P.DialTimeout = cfg.P2P.DialTimeout