diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index b021f2b4d..69587c1db 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -16,7 +16,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/morph/client" nmwrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper" "github.com/nspcc-dev/neofs-node/pkg/network" - "github.com/nspcc-dev/neofs-node/pkg/services/object" tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage" "github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/spf13/viper" @@ -39,6 +38,7 @@ const ( // config keys for cfgGRPC cfgListenAddress = "grpc.endpoint" + cfgMaxMsgSize = "grpc.maxmessagesize" // config keys for cfgMorph cfgMorphRPCAddress = "morph.endpoint" @@ -58,6 +58,10 @@ const ( cfgMaxObjectSize = "node.maxobjectsize" // get value from chain ) +const ( + addressSize = 72 // 32 bytes oid, 32 bytes cid, 8 bytes protobuf encoding +) + type cfg struct { ctx context.Context @@ -166,6 +170,9 @@ func initCfg(path string) *cfg { netAddr, err := network.AddressFromString(viperCfg.GetString(cfgBootstrapAddress)) fatalOnErr(err) + maxChunkSize := viperCfg.GetUint64(cfgMaxMsgSize) * 3 / 4 // 25% to meta, 75% to payload + maxAddrAmount := maxChunkSize / addressSize // each address is about 72 bytes + return &cfg{ ctx: context.Background(), viper: viperCfg, @@ -192,8 +199,8 @@ func initCfg(path string) *cfg { maxObjectSize: viperCfg.GetUint64(cfgMaxObjectSize), }, cfgGRPC: cfgGRPC{ - maxChunkSize: object.GRPCPayloadChunkSize, - maxAddrAmount: object.GRPCSearchAddrAmount, + maxChunkSize: maxChunkSize, + maxAddrAmount: maxAddrAmount, }, localAddr: netAddr, } @@ -228,6 +235,7 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgMorphRPCAddress, "http://morph_chain.localtest.nspcc.ru:30333/") v.SetDefault(cfgListenAddress, "127.0.0.1:50501") // listen address + v.SetDefault(cfgMaxMsgSize, 4<<20) // transport msg limit 4 MiB v.SetDefault(cfgAccountingContract, "1aeefe1d0dfade49740fff779c02cd4a0538ffb1") v.SetDefault(cfgAccountingFee, "1") diff --git a/cmd/neofs-node/grpc.go b/cmd/neofs-node/grpc.go index be28a4303..e65205e57 100644 --- a/cmd/neofs-node/grpc.go +++ b/cmd/neofs-node/grpc.go @@ -13,7 +13,9 @@ func initGRPC(c *cfg) { c.cfgGRPC.listener, err = net.Listen("tcp", c.viper.GetString(cfgListenAddress)) fatalOnErr(err) - c.cfgGRPC.server = grpc.NewServer() + c.cfgGRPC.server = grpc.NewServer( + grpc.MaxSendMsgSize(c.viper.GetInt(cfgMaxMsgSize)), + ) } func serveGRPC(c *cfg) { diff --git a/pkg/services/object/transport_splitter.go b/pkg/services/object/transport_splitter.go index d0c3533ed..b3713f5d0 100644 --- a/pkg/services/object/transport_splitter.go +++ b/pkg/services/object/transport_splitter.go @@ -9,11 +9,6 @@ import ( "github.com/pkg/errors" ) -const ( - GRPCPayloadChunkSize = 1024 * 1024 * 3 // 4 MiB is a max limit, 3 MiB should be okay - GRPCSearchAddrAmount = 1024 * 32 // 64 bytes per addr, in total about 2 MiB -) - var ( errChunking = errors.New("can't split message to stream chunks") )