diff --git a/node/config.go b/node/config.go index 1608525a07..8a2d951433 100644 --- a/node/config.go +++ b/node/config.go @@ -72,6 +72,7 @@ type Config struct { ClientIPHeader string UseSecureGrpc bool ReachabilityPollIntervalSec uint64 + DisableNodeInfoResources bool EthClientConfig geth.EthClientConfig LoggerConfig common.LoggerConfig @@ -201,5 +202,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) { NumBatchDeserializationWorkers: ctx.GlobalInt(flags.NumBatchDeserializationWorkersFlag.Name), ClientIPHeader: ctx.GlobalString(flags.ClientIPHeaderFlag.Name), UseSecureGrpc: ctx.GlobalBoolT(flags.ChurnerUseSecureGRPC.Name), + DisableNodeInfoResources: ctx.GlobalBool(flags.DisableNodeInfoResourcesFlag.Name), }, nil } diff --git a/node/flags/flags.go b/node/flags/flags.go index d6a5d8abf5..7e81119c4d 100644 --- a/node/flags/flags.go +++ b/node/flags/flags.go @@ -259,6 +259,13 @@ var ( Value: "", EnvVar: common.PrefixEnvVar(EnvVarPrefix, "CLIENT_IP_HEADER"), } + + DisableNodeInfoResourcesFlag = cli.BoolFlag{ + Name: common.PrefixFlag(FlagPrefix, "disable-node-info-resources"), + Usage: "Disable system resource information (OS, architecture, CPU, memory) on the NodeInfo API", + Required: false, + EnvVar: common.PrefixEnvVar(EnvVarPrefix, "DISABLE_NODE_INFO_RESOURCES"), + } ) var requiredFlags = []cli.Flag{ @@ -299,6 +306,7 @@ var optionalFlags = []cli.Flag{ EcdsaKeyFileFlag, EcdsaKeyPasswordFlag, DataApiUrlFlag, + DisableNodeInfoResourcesFlag, } func init() { diff --git a/node/grpc/server.go b/node/grpc/server.go index 4f65981b9e..9d249e2138 100644 --- a/node/grpc/server.go +++ b/node/grpc/server.go @@ -135,6 +135,10 @@ func (s *Server) serveRetrieval() error { } func (s *Server) NodeInfo(ctx context.Context, in *pb.NodeInfoRequest) (*pb.NodeInfoReply, error) { + if s.config.DisableNodeInfoResources { + return &pb.NodeInfoReply{Semver: node.SemVer, Os: "", Arch: "", NumCpu: 0, MemBytes: 0}, nil + } + memBytes := uint64(0) v, err := mem.VirtualMemory() if err == nil { diff --git a/node/grpc/server_test.go b/node/grpc/server_test.go index 9a333ff6b9..84623ec94c 100644 --- a/node/grpc/server_test.go +++ b/node/grpc/server_test.go @@ -282,10 +282,6 @@ func TestNodeInfoRequest(t *testing.T) { server := newTestServer(t, true) resp, err := server.NodeInfo(context.Background(), &pb.NodeInfoRequest{}) assert.True(t, resp.Semver == "0.0.0") - assert.True(t, resp.Os != "") - assert.True(t, resp.Arch != "") - assert.True(t, resp.NumCpu > 0) - assert.True(t, resp.MemBytes >= 0) assert.True(t, err == nil) }