Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ConvallariaMaj committed Aug 2, 2024
1 parent 0d5dfe8 commit b245229
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
11 changes: 6 additions & 5 deletions activation/nipost.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,16 @@ func (nb *NIPostBuilder) submitPoetChallenges(
}
}

misconfiguredRegistrations := make(map[string]nipost.PoETRegistration)
misconfiguredRegistrations := make(map[string]struct{})
for addr := range registrationsMap {
if reg, ok := existingRegistrationsMap[addr]; !ok {
misconfiguredRegistrations[addr] = reg
if _, ok := existingRegistrationsMap[addr]; !ok {
misconfiguredRegistrations[addr] = struct{}{}
}
}

if len(misconfiguredRegistrations) != 0 {
nb.logger.Warn(
"Invalid PoET registrations found. Local state contains PoETs not in node config",
"Found existing registrations for poets not listed in the config. Will not fetch proof from them.",
zap.Strings("registrations_addresses", maps.Keys(misconfiguredRegistrations)),
log.ZShortStringer("smesherID", nodeID),
)
Expand All @@ -441,7 +441,8 @@ func (nb *NIPostBuilder) submitPoetChallenges(
case len(existingRegistrations) == 0:
// no existing registration for given poets set
nb.logger.Panic(
"Invalid PoET registrations found. Local state only contains PoETs not in node config",
"None of the poets listed in the config matches the existing registrations. "+
"Verify your config and local database state.",
zap.Strings("registrations", maps.Keys(registrationsMap)),
zap.Strings("configured_poets", maps.Keys(nb.poetProvers)),
log.ZShortStringer("smesherID", nodeID),
Expand Down
1 change: 1 addition & 0 deletions activation/nipost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ func TestNIPoSTBuilder_PoETConfigChange(t *testing.T) {
require.NoError(t, err)

logger := zaptest.NewLogger(t)

nb, err := NewNIPostBuilder(
db,
nil,
Expand Down
9 changes: 3 additions & 6 deletions activation/poet.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ func NewHTTPPoetClient(server types.PoetServer, cfg PoetConfig, opts ...PoetClie

resp, err := poetClient.info(context.Background())
if err != nil {
return nil, err
}

if resp.PhaseShift.AsDuration() != cfg.PhaseShift {
poetClient.logger.Error("getting info about poet service configuration", zap.Error(err))
} else if resp.PhaseShift.AsDuration() != cfg.PhaseShift {
poetClient.logger.Warn("getting info about poet service configuration",
zap.Duration("server: phase shift", resp.PhaseShift.AsDuration()),
zap.Duration("config: cycle gap", cfg.PhaseShift),
Expand Down Expand Up @@ -497,7 +495,6 @@ func (c *poetService) reauthorize(
ctx context.Context,
id types.NodeID,
challenge []byte,
logger *zap.Logger,
) (*PoetAuth, error) {
if c.certifier != nil {
if _, pubkey, err := c.getCertifierInfo(ctx); err == nil {
Expand Down Expand Up @@ -538,7 +535,7 @@ func (c *poetService) Submit(
return round, nil
case errors.Is(err, ErrUnauthorized):
logger.Warn("failed to submit challenge as unauthorized - authorizing again", zap.Error(err))
auth, err := c.reauthorize(ctx, nodeID, challenge, logger)
auth, err := c.reauthorize(ctx, nodeID, challenge)
if err != nil {
return nil, fmt.Errorf("authorizing: %w", err)
}
Expand Down

0 comments on commit b245229

Please sign in to comment.