Skip to content

Commit

Permalink
Try #5209:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed Oct 31, 2023
2 parents e97c0ea + 0da0a40 commit c110994
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 246 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ See [RELEASE](./RELEASE.md) for workflow instructions.

Pruning will be enabled starting from epoch 8, e.g in epoch 8 we will prune all activesets for epochs 7 and below.
We should also run an archival node that doesn't prune them. To disable pruning we should configure

```json
"main": {
"prune-activesets-from": 4294967295
Expand All @@ -62,6 +62,8 @@ See [RELEASE](./RELEASE.md) for workflow instructions.
yet created their initial proof the operator has to specify which provider to use. For Smapp users this is done automatically by Smapp, users that do not use Smapp may use
`postcli -printProviders` (<https://github.com/spacemeshos/post/releases>) to list their OpenCL providers and associated IDs.

* [#5209](https://github.com/spacemeshos/go-spacemesh/pull/5209) Removed API to update poet servers from SmesherService.

## v1.2.0

### Upgrade information
Expand Down
8 changes: 0 additions & 8 deletions activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,6 @@ func (b *Builder) generateInitialPost(ctx context.Context) error {
return nil
}

func (b *Builder) receivePendingPoetClients() *[]poetClient {
return b.pendingPoetClients.Swap(nil)
}

func (b *Builder) run(ctx context.Context) {
defer b.log.Info("atx builder stopped")

Expand All @@ -343,10 +339,6 @@ func (b *Builder) run(ctx context.Context) {
}

for {
if poetClients := b.receivePendingPoetClients(); poetClients != nil {
b.nipostBuilder.UpdatePoETProvers(*poetClients)
}

ctx := log.WithNewSessionID(ctx)
err := b.PublishActivationTx(ctx)
if err == nil {
Expand Down
40 changes: 0 additions & 40 deletions activation/activation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,46 +1157,6 @@ func TestBuilder_InitialPostIsPersisted(t *testing.T) {
require.NoError(t, tab.generateInitialPost(context.Background()))
}

func TestBuilder_UpdatePoets(t *testing.T) {
r := require.New(t)

tab := newTestBuilder(t, WithPoETClientInitializer(func(string, PoetConfig) (poetClient, error) {
poet := NewMockpoetClient(gomock.NewController(t))
poet.EXPECT().
PoetServiceID(gomock.Any()).
AnyTimes().
Return(types.PoetServiceID{ServiceID: []byte("poetid")}, nil)
return poet, nil
}))

r.Nil(tab.Builder.receivePendingPoetClients())

err := tab.Builder.UpdatePoETServers(context.Background(), []string{"http://poet0", "http://poet1"})
r.NoError(err)

clients := tab.Builder.receivePendingPoetClients()
r.NotNil(clients)
r.Len(*clients, 2)
r.Nil(tab.Builder.receivePendingPoetClients())
}

func TestBuilder_UpdatePoetsUnstable(t *testing.T) {
r := require.New(t)

tab := newTestBuilder(t, WithPoETClientInitializer(func(string, PoetConfig) (poetClient, error) {
poet := NewMockpoetClient(gomock.NewController(t))
poet.EXPECT().
PoetServiceID(gomock.Any()).
AnyTimes().
Return(types.PoetServiceID{ServiceID: []byte("poetid")}, errors.New("ERROR"))
return poet, nil
}))

err := tab.Builder.UpdatePoETServers(context.Background(), []string{"http://poet0", "http://poet1"})
r.ErrorIs(err, ErrPoetServiceUnstable)
r.Nil(tab.receivePendingPoetClients())
}

func TestWaitPositioningAtx(t *testing.T) {
genesis := time.Now()
for _, tc := range []struct {
Expand Down
2 changes: 0 additions & 2 deletions activation/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type layerClock interface {
}

type nipostBuilder interface {
UpdatePoETProvers([]poetClient)
BuildNIPost(ctx context.Context, challenge *types.NIPostChallenge) (*types.NIPost, error)
DataDir() string
}
Expand Down Expand Up @@ -92,7 +91,6 @@ type SmeshingProvider interface {
SmesherID() types.NodeID
Coinbase() types.Address
SetCoinbase(coinbase types.Address)
UpdatePoETServers(ctx context.Context, endpoints []string) error
}

// poetClient servers as an interface to communicate with a PoET server.
Expand Down
74 changes: 0 additions & 74 deletions activation/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions api/grpcserver/grpcserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,34 +635,6 @@ func TestSmesherService(t *testing.T) {
_, err = stream.Recv()
require.ErrorContains(t, err, context.Canceled.Error())
})

t.Run("UpdatePoetServer", func(t *testing.T) {
t.Parallel()
c, ctx := setupSmesherService(t)
c.smeshingProvider.EXPECT().UpdatePoETServers(gomock.Any(), gomock.Any()).Return(nil)
res, err := c.UpdatePoetServers(ctx, &pb.UpdatePoetServersRequest{Urls: []string{"test"}})
require.NoError(t, err)
require.EqualValues(t, res.Status.Code, code.Code_OK)
})
t.Run("UpdatePoetServerUnavailable", func(t *testing.T) {
t.Parallel()
c, ctx := setupSmesherService(t)
c.smeshingProvider.EXPECT().
UpdatePoETServers(gomock.Any(), gomock.Any()).
Return(activation.ErrPoetServiceUnstable)
urls := []string{"test"}
res, err := c.UpdatePoetServers(ctx, &pb.UpdatePoetServersRequest{Urls: urls})
require.Nil(t, res)
require.ErrorIs(
t,
err,
status.Errorf(
codes.Unavailable,
"can't reach poet service (%v). retry later",
activation.ErrPoetServiceUnstable,
),
)
})
}

func TestMeshService(t *testing.T) {
Expand Down
19 changes: 0 additions & 19 deletions api/grpcserver/smesher_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package grpcserver

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -283,21 +282,3 @@ func statusToPbStatus(status *activation.PostSetupStatus) *pb.PostSetupStatus {

return pbStatus
}

// UpdatePoetServers update server that is used for generating PoETs.
func (s SmesherService) UpdatePoetServers(
ctx context.Context,
req *pb.UpdatePoetServersRequest,
) (*pb.UpdatePoetServersResponse, error) {
err := s.smeshingProvider.UpdatePoETServers(ctx, req.Urls)
if err == nil {
return &pb.UpdatePoetServersResponse{
Status: &rpcstatus.Status{Code: int32(code.Code_OK)},
}, nil
}
switch {
case errors.Is(err, activation.ErrPoetServiceUnstable):
return nil, status.Errorf(codes.Unavailable, "can't reach poet service (%v). retry later", err)
}
return nil, status.Errorf(codes.Internal, "failed to update poet server")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/prometheus/common v0.45.0
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/seehuhn/mt19937 v1.0.0
github.com/spacemeshos/api/release/go v1.22.0
github.com/spacemeshos/api/release/go v1.22.1-0.20231031115421-976938e0572f
github.com/spacemeshos/economics v0.1.1
github.com/spacemeshos/fixed v0.1.1
github.com/spacemeshos/go-scale v1.1.12
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,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.22.0 h1:a90pk3CK2QQdJRhHkjKB5dz8xdJV4ILxQRZj5bZdtLc=
github.com/spacemeshos/api/release/go v1.22.0/go.mod h1:SwqQxbhAF7tN3Qr34eVzczCB3KyTbkHH12U82eqfy6M=
github.com/spacemeshos/api/release/go v1.22.1-0.20231031115421-976938e0572f h1:zI2djzaU9JcX11bAy4H7dzn2tsDOjRMNe4qjgDjuH/0=
github.com/spacemeshos/api/release/go v1.22.1-0.20231031115421-976938e0572f/go.mod h1:SwqQxbhAF7tN3Qr34eVzczCB3KyTbkHH12U82eqfy6M=
github.com/spacemeshos/economics v0.1.1 h1:BPgMoTaeQ05ME6wEA1+MvXMp+wvXr51bIuN23thrCAk=
github.com/spacemeshos/economics v0.1.1/go.mod h1:76nTjugYRiQ5/eD/DQs2dXPPilp28URMswUKncfdanY=
github.com/spacemeshos/fixed v0.1.1 h1:N1y4SUpq1EV+IdJrWJwUCt1oBFzeru/VKVcBsvPc2Fk=
Expand Down
10 changes: 9 additions & 1 deletion systest/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (c *Cluster) GenesisID() types.Hash20 {
}

func (c *Cluster) nextSmesher() int {
if c.smeshers <= c.bootnodes {
if c.smeshers == 0 {
return 0
}
return decodeOrdinal(c.clients[len(c.clients)-1].Name) + 1
Expand Down Expand Up @@ -455,10 +455,18 @@ func (c *Cluster) AddBootnodes(cctx *testcontext.Context, n int) error {
type SmesherDeploymentConfig struct {
flags []DeploymentFlag
keys []ed25519.PrivateKey

noDefaultPoets bool
}

type DeploymentOpt func(cfg *SmesherDeploymentConfig)

func NoDefaultPoets() DeploymentOpt {
return func(cfg *SmesherDeploymentConfig) {
cfg.noDefaultPoets = true
}
}

func WithFlags(flags ...DeploymentFlag) DeploymentOpt {
return func(cfg *SmesherDeploymentConfig) {
cfg.flags = append(cfg.flags, flags...)
Expand Down
10 changes: 7 additions & 3 deletions systest/cluster/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ func labelSelector(id string) string {
}

func deployNodes(ctx *testcontext.Context, kind string, from, to int, opts ...DeploymentOpt) ([]*NodeClient, error) {
ctx.Log.Debugw("deploying nodes", "kind", kind, "from", from, "to", to)
var (
eg errgroup.Group
clients = make(chan *NodeClient, to-from)
Expand All @@ -429,8 +430,10 @@ func deployNodes(ctx *testcontext.Context, kind string, from, to int, opts ...De
i := i
finalFlags := make([]DeploymentFlag, len(cfg.flags), len(cfg.flags)+ctx.PoetSize)
copy(finalFlags, cfg.flags)
for idx := 0; idx < ctx.PoetSize; idx++ {
finalFlags = append(finalFlags, PoetEndpoint(MakePoetEndpoint(idx)))
if !cfg.noDefaultPoets {
for idx := 0; idx < ctx.PoetSize; idx++ {
finalFlags = append(finalFlags, PoetEndpoint(MakePoetEndpoint(idx)))
}
}
if ctx.BootstrapperSize > 1 {
finalFlags = append(finalFlags, BootstrapperUrl(BootstrapperEndpoint(i%ctx.BootstrapperSize)))
Expand Down Expand Up @@ -485,6 +488,7 @@ func deleteNode(ctx *testcontext.Context, id string) error {
}

func deployNode(ctx *testcontext.Context, id string, labels map[string]string, flags []DeploymentFlag) error {
ctx.Log.Debugw("deploying node", "id", id)
cmd := []string{
"/bin/go-spacemesh",
"-c=" + configDir + attachedSmesherConfig,
Expand Down Expand Up @@ -681,7 +685,7 @@ func (d DeploymentFlag) Flag() string {
return d.Name + "=" + d.Value
}

// PoetEndpoint flag.
// PoetEndpoint flag can be used multiple times to add multiple poets.
func PoetEndpoint(endpoint string) DeploymentFlag {
return DeploymentFlag{Name: "--poet-server", Value: endpoint}
}
Expand Down
12 changes: 0 additions & 12 deletions systest/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/spacemeshos/go-spacemesh/common/types"
Expand Down Expand Up @@ -441,17 +440,6 @@ func getVerifiedLayer(ctx context.Context, node *cluster.NodeClient) (*pb.Layer,
return getLayer(ctx, node, resp.Status.VerifiedLayer.Number)
}

func updatePoetServers(ctx context.Context, node *cluster.NodeClient, targets []string) (bool, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
svc := pb.NewSmesherServiceClient(node)
resp, err := svc.UpdatePoetServers(ctx, &pb.UpdatePoetServersRequest{Urls: targets})
if err != nil {
return false, err
}
return resp.Status.Code == int32(code.Code_OK), nil
}

type txClient struct {
account cluster.Account
node *cluster.NodeClient
Expand Down
Loading

0 comments on commit c110994

Please sign in to comment.