Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Simplify switch to different poet services #6116

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
726b49d
check registrations by poet address
ConvallariaMaj Jul 2, 2024
3f68831
Merge branch 'refs/heads/develop' into fix/issue-5563
ConvallariaMaj Jul 9, 2024
5bba175
added:
ConvallariaMaj Jul 10, 2024
8080ed0
fixed:
ConvallariaMaj Jul 11, 2024
7a371a2
fix lint
ConvallariaMaj Jul 11, 2024
89696b1
fix lint2
ConvallariaMaj Jul 11, 2024
189aa4c
- added new test
ConvallariaMaj Jul 14, 2024
97aed33
Merge branch 'refs/heads/develop' into fix/issue-5563
ConvallariaMaj Jul 14, 2024
66ea05e
make linter happy
ConvallariaMaj Jul 15, 2024
f6f2277
fixed review issues
ConvallariaMaj Jul 18, 2024
9a5bad8
refactor tests
ConvallariaMaj Jul 23, 2024
9ffb962
refactored tests
ConvallariaMaj Jul 23, 2024
c4bb081
fix text and make linter happy
ConvallariaMaj Jul 24, 2024
46ce146
fix minor issues
ConvallariaMaj Jul 29, 2024
105e872
final review issues fix
ConvallariaMaj Aug 1, 2024
11a5323
fix test
ConvallariaMaj Aug 1, 2024
0d5dfe8
Merge branch 'refs/heads/develop' into fix/issue-5563
ConvallariaMaj Aug 1, 2024
b245229
fix issues
ConvallariaMaj Aug 2, 2024
8140012
verifying poets configuration
ConvallariaMaj Aug 2, 2024
a02a90c
verifying poets configuration on poet service layer, fixing tests, fi…
ConvallariaMaj Aug 6, 2024
e910e34
test fix
ConvallariaMaj Aug 6, 2024
28f8c17
Merge branch 'refs/heads/develop' into fix/issue-5563
ConvallariaMaj Aug 6, 2024
6d12ab6
review fixes
ConvallariaMaj Aug 6, 2024
71bd472
fix lint
ConvallariaMaj Aug 6, 2024
0ea3dc1
fix merge
ConvallariaMaj Aug 6, 2024
9dc3874
fix mocks
ConvallariaMaj Aug 6, 2024
4c44a49
Fix tests
fasmat Aug 6, 2024
15ebc7b
Fix e2e tests
fasmat Aug 6, 2024
8c8945a
Merge branch 'refs/heads/develop' into fix/issue-5563
ConvallariaMaj Aug 7, 2024
2206f37
fix test
ConvallariaMaj Aug 7, 2024
f9af85a
fix test2
ConvallariaMaj Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ the build folder you need to ensure that you have the gpu setup dynamic library
binary. The simplest way to do this is just copy the library file to be in the
same directory as the go-spacemesh binary. Alternatively you can modify your
system's library search paths (e.g. LD_LIBRARY_PATH) to ensure that the
library is found._
library is found.

go-spacemesh is p2p software which is designed to form a decentralized network by connecting to other instances of
go-spacemesh running on remote computers.
Expand Down
26 changes: 25 additions & 1 deletion activation/activation_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"errors"
"fmt"
"strings"
)

var (
Expand All @@ -21,8 +22,31 @@
source error
}

func (e *PoetSvcUnstableError) Error() string {
func (e PoetSvcUnstableError) Error() string {
return fmt.Sprintf("poet service is unstable: %s (%v)", e.msg, e.source)
}

func (e *PoetSvcUnstableError) Unwrap() error { return e.source }

type PoetRegistrationMismatchError struct {
registrations []string
configuredPoets []string
}

func (e PoetRegistrationMismatchError) Error() string {
var sb strings.Builder
sb.WriteString("builder: none of configured poets matches the existing registrations.\n")
sb.WriteString("registrations:\n")
for _, r := range e.registrations {
sb.WriteString("\t")
sb.WriteString(r)
sb.WriteString("\n")

Check warning on line 43 in activation/activation_errors.go

View check run for this annotation

Codecov / codecov/patch

activation/activation_errors.go#L36-L43

Added lines #L36 - L43 were not covered by tests
}
sb.WriteString("\nconfigured poets:\n")
for _, p := range e.configuredPoets {
sb.WriteString("\t")
sb.WriteString(p)
sb.WriteString("\n")

Check warning on line 49 in activation/activation_errors.go

View check run for this annotation

Codecov / codecov/patch

activation/activation_errors.go#L45-L49

Added lines #L45 - L49 were not covered by tests
}
return sb.String()

Check warning on line 51 in activation/activation_errors.go

View check run for this annotation

Codecov / codecov/patch

activation/activation_errors.go#L51

Added line #L51 was not covered by tests
}
2 changes: 1 addition & 1 deletion activation/e2e/atx_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func Test_MarryAndMerge(t *testing.T) {
GracePeriod: epoch / 4,
}

client := ae2e.NewTestPoetClient(2)
client := ae2e.NewTestPoetClient(2, poetCfg)
poetSvc := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

clock, err := timesync.NewClock(
Expand Down
2 changes: 1 addition & 1 deletion activation/e2e/builds_atx_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestBuilder_SwitchesToBuildV2(t *testing.T) {
require.NoError(t, err)
t.Cleanup(clock.Close)

client := ae2e.NewTestPoetClient(1)
client := ae2e.NewTestPoetClient(1, poetCfg)
poetClient := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

localDB := localsql.InMemory()
Expand Down
2 changes: 1 addition & 1 deletion activation/e2e/checkpoint_merged_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Test_CheckpointAfterMerge(t *testing.T) {
GracePeriod: epoch / 4,
}

client := ae2e.NewTestPoetClient(2)
client := ae2e.NewTestPoetClient(2, poetCfg)
poetSvc := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

clock, err := timesync.NewClock(
Expand Down
2 changes: 1 addition & 1 deletion activation/e2e/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestCheckpoint_PublishingSoloATXs(t *testing.T) {
CycleGap: 3 * epoch / 4,
GracePeriod: epoch / 4,
}
client := ae2e.NewTestPoetClient(1)
client := ae2e.NewTestPoetClient(1, poetCfg)
poetService := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

// ensure that genesis aligns with layer timings
Expand Down
4 changes: 2 additions & 2 deletions activation/e2e/nipost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestNIPostBuilderWithClients(t *testing.T) {
err = nipost.AddPost(localDb, sig.NodeID(), *fullPost(post, info, shared.ZeroChallenge))
require.NoError(t, err)

client := ae2e.NewTestPoetClient(1)
client := ae2e.NewTestPoetClient(1, poetCfg)
poetService := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

localDB := localsql.InMemory()
Expand Down Expand Up @@ -272,7 +272,7 @@ func Test_NIPostBuilderWithMultipleClients(t *testing.T) {
}

poetDb := activation.NewPoetDb(db, logger.Named("poetDb"))
client := ae2e.NewTestPoetClient(len(signers))
client := ae2e.NewTestPoetClient(len(signers), poetCfg)
poetService := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

mclock := activation.NewMocklayerClock(ctrl)
Expand Down
20 changes: 14 additions & 6 deletions activation/e2e/poet_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"context"
"errors"
"fmt"
"net/url"
"strconv"
"sync"
"time"
Expand All @@ -20,15 +19,17 @@
)

type TestPoet struct {
mu sync.Mutex
round int
mu sync.Mutex
round int
poetCfg activation.PoetConfig

expectedMembers int
registrations chan []byte
}

func NewTestPoetClient(expectedMembers int) *TestPoet {
func NewTestPoetClient(expectedMembers int, poetCfg activation.PoetConfig) *TestPoet {
return &TestPoet{
poetCfg: poetCfg,
expectedMembers: expectedMembers,
registrations: make(chan []byte, expectedMembers),
}
Expand Down Expand Up @@ -66,8 +67,15 @@
return &types.PoetRound{ID: strconv.Itoa(round), End: time.Now()}, nil
}

func (p *TestPoet) CertifierInfo(ctx context.Context) (*url.URL, []byte, error) {
return nil, nil, errors.New("not supported")
func (p *TestPoet) CertifierInfo(ctx context.Context) (*types.CertifierInfo, error) {
return nil, errors.New("CertifierInfo: not supported")

Check warning on line 71 in activation/e2e/poet_client.go

View check run for this annotation

Codecov / codecov/patch

activation/e2e/poet_client.go#L70-L71

Added lines #L70 - L71 were not covered by tests
}

func (p *TestPoet) Info(ctx context.Context) (*types.PoetInfo, error) {
return &types.PoetInfo{
PhaseShift: p.poetCfg.PhaseShift,
CycleGap: p.poetCfg.CycleGap,
}, nil
}

// Build a proof.
Expand Down
8 changes: 4 additions & 4 deletions activation/e2e/poet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ func TestCertifierInfo(t *testing.T) {
)
require.NoError(t, err)

url, pubkey, err := client.CertifierInfo(context.Background())
certInfo, err := client.CertifierInfo(context.Background())
r.NoError(err)
r.Equal("http://localhost:8080", url.String())
r.Equal([]byte("pubkey"), pubkey)
r.Equal("http://localhost:8080", certInfo.Url.String())
r.Equal([]byte("pubkey"), certInfo.Pubkey)
}

func TestNoCertifierInfo(t *testing.T) {
Expand Down Expand Up @@ -291,6 +291,6 @@ func TestNoCertifierInfo(t *testing.T) {
)
require.NoError(t, err)

_, _, err = client.CertifierInfo(context.Background())
_, err = client.CertifierInfo(context.Background())
r.ErrorContains(err, "poet doesn't support certificates")
}
2 changes: 1 addition & 1 deletion activation/e2e/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestValidator_Validate(t *testing.T) {
}

poetDb := activation.NewPoetDb(sql.InMemory(), logger.Named("poetDb"))
client := ae2e.NewTestPoetClient(1)
client := ae2e.NewTestPoetClient(1, poetCfg)
poetService := activation.NewPoetServiceWithClient(poetDb, client, poetCfg, logger)

mclock := activation.NewMocklayerClock(ctrl)
Expand Down
Loading
Loading