diff --git a/api/grpcserver/v2alpha1/network.go b/api/grpcserver/v2alpha1/network.go index 60d4ad29ce..f9454394cc 100644 --- a/api/grpcserver/v2alpha1/network.go +++ b/api/grpcserver/v2alpha1/network.go @@ -11,17 +11,19 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "github.com/spacemeshos/go-spacemesh/common/types" + "github.com/spacemeshos/go-spacemesh/config" ) const ( Network = "network_v2alpha1" ) -func NewNetworkService(genesisTime time.Time, genesisID types.Hash20, layerDuration time.Duration) *NetworkService { +func NewNetworkService(genesisTime time.Time, config *config.Config) *NetworkService { return &NetworkService{ genesisTime: genesisTime, - genesisID: genesisID, - layerDuration: layerDuration, + genesisID: config.Genesis.GenesisID(), + layerDuration: config.LayerDuration, + labelsPerUnit: config.POST.LabelsPerUnit, } } @@ -29,6 +31,7 @@ type NetworkService struct { genesisTime time.Time genesisID types.Hash20 layerDuration time.Duration + labelsPerUnit uint64 } func (s *NetworkService) RegisterService(server *grpc.Server) { @@ -54,5 +57,6 @@ func (s *NetworkService) Info(context.Context, Hrp: types.NetworkHRP(), EffectiveGenesisLayer: types.GetEffectiveGenesis().Uint32(), LayersPerEpoch: types.GetLayersPerEpoch(), + LabelsPerUnit: s.labelsPerUnit, }, nil } diff --git a/api/grpcserver/v2alpha1/network_test.go b/api/grpcserver/v2alpha1/network_test.go index 989ab92a1e..0e87e3a7d1 100644 --- a/api/grpcserver/v2alpha1/network_test.go +++ b/api/grpcserver/v2alpha1/network_test.go @@ -9,13 +9,15 @@ import ( "github.com/stretchr/testify/require" "github.com/spacemeshos/go-spacemesh/common/types" + "github.com/spacemeshos/go-spacemesh/config" ) func TestNetworkService_Info(t *testing.T) { ctx := context.Background() genesis := time.Unix(genTimeUnix, 0) + c := config.DefaultTestConfig() - svc := NewNetworkService(genesis, genesisID, layerDuration) + svc := NewNetworkService(genesis, &c) cfg, cleanup := launchServer(t, svc) t.Cleanup(cleanup) @@ -27,10 +29,11 @@ func TestNetworkService_Info(t *testing.T) { require.NoError(t, err) require.Equal(t, genesis.UTC(), info.GenesisTime.AsTime().UTC()) - require.Equal(t, layerDuration, info.LayerDuration.AsDuration()) - require.Equal(t, genesisID.Bytes(), info.GenesisId) + require.Equal(t, c.LayerDuration, info.LayerDuration.AsDuration()) + require.Equal(t, c.Genesis.GenesisID().Bytes(), info.GenesisId) require.Equal(t, types.NetworkHRP(), info.Hrp) require.Equal(t, types.GetEffectiveGenesis().Uint32(), info.EffectiveGenesisLayer) require.Equal(t, types.GetLayersPerEpoch(), info.LayersPerEpoch) + require.Equal(t, c.POST.LabelsPerUnit, info.LabelsPerUnit) }) } diff --git a/api/grpcserver/v2alpha1/v2alpha1_test.go b/api/grpcserver/v2alpha1/v2alpha1_test.go index 27d5d9f7ac..52ba08f556 100644 --- a/api/grpcserver/v2alpha1/v2alpha1_test.go +++ b/api/grpcserver/v2alpha1/v2alpha1_test.go @@ -11,7 +11,6 @@ import ( "google.golang.org/grpc/credentials/insecure" "github.com/spacemeshos/go-spacemesh/api/grpcserver" - "github.com/spacemeshos/go-spacemesh/common/types" ) const ( @@ -19,8 +18,6 @@ const ( layerDuration = 10 * time.Second ) -var genesisID = types.Hash20{} - func launchServer(tb testing.TB, services ...grpcserver.ServiceAPI) (grpcserver.Config, func()) { cfg := grpcserver.DefaultTestConfig() grpc, err := grpcserver.NewWithServices(cfg.PublicListener, zaptest.NewLogger(tb).Named("grpc"), cfg, services) diff --git a/go.mod b/go.mod index b8652db3cc..931e19278b 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/seehuhn/mt19937 v1.0.0 github.com/slok/go-http-metrics v0.12.0 - github.com/spacemeshos/api/release/go v1.50.0 + github.com/spacemeshos/api/release/go v1.51.0 github.com/spacemeshos/economics v0.1.3 github.com/spacemeshos/fixed v0.1.1 github.com/spacemeshos/go-scale v1.2.0 diff --git a/go.sum b/go.sum index 42c9cad502..be27867b00 100644 --- a/go.sum +++ b/go.sum @@ -602,8 +602,8 @@ github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:Udh github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= -github.com/spacemeshos/api/release/go v1.50.0 h1:M7Usg/LxymscwqYO7/Doyb+sU4lS1e+JIsSgqTDGk/0= -github.com/spacemeshos/api/release/go v1.50.0/go.mod h1:PvgDpjfwkZLVVNExYG7wDNzgMqT3p+ppfTU2UESSF9U= +github.com/spacemeshos/api/release/go v1.51.0 h1:MSKRIUiXBAoDrj2Lj24q9g52ZaSIC3I0UH/Y0Oaz95o= +github.com/spacemeshos/api/release/go v1.51.0/go.mod h1:Qr/pVPMmN5Q5qLHSXqVMDKDCu6LkHWzGPNflylE0u00= github.com/spacemeshos/economics v0.1.3 h1:ACkq3mTebIky4Zwbs9SeSSRZrUCjU/Zk0wq9Z0BTh2A= github.com/spacemeshos/economics v0.1.3/go.mod h1:FH7u0FzTIm6Kpk+X5HOZDvpkgNYBKclmH86rVwYaDAo= github.com/spacemeshos/fixed v0.1.1 h1:N1y4SUpq1EV+IdJrWJwUCt1oBFzeru/VKVcBsvPc2Fk= diff --git a/node/node.go b/node/node.go index 8b239cc2fa..ddc8d2dc39 100644 --- a/node/node.go +++ b/node/node.go @@ -1558,8 +1558,7 @@ func (app *App) grpcService(svc grpcserver.Service, lg log.Log) (grpcserver.Serv case v2alpha1.Network: service := v2alpha1.NewNetworkService( app.clock.GenesisTime(), - app.Config.Genesis.GenesisID(), - app.Config.LayerDuration) + app.Config) app.grpcServices[svc] = service return service, nil case v2alpha1.Node: