Skip to content

Commit

Permalink
Use base64 instead of hex to log service id / public key (#5705)
Browse files Browse the repository at this point in the history
## Motivation

Keys are logged as hex instead of base64. Since the config contains them in base64 and the `/v1/info` endpoint also displays the key in base64 the logger should too.
  • Loading branch information
fasmat committed Mar 15, 2024
1 parent bcd11a1 commit f114349
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sql/localsql/0003_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ func (m migration0003) moveNipostStateToDb(db sql.Executor, dataDir string) erro
continue
}

poetPubKey := base64.StdEncoding.EncodeToString(req.PoetServiceID.ServiceID)
address, err := m.getAddress(req.PoetServiceID)
if err != nil {
return fmt.Errorf("get address for poet service id %x: %w", req.PoetServiceID.ServiceID, err)
return fmt.Errorf("get address for poet service id %s: %w", poetPubKey, err)
}

enc := func(stmt *sql.Statement) {
Expand All @@ -178,7 +179,7 @@ func (m migration0003) moveNipostStateToDb(db sql.Executor, dataDir string) erro

m.logger.Info("PoET registration added to database",
zap.String("node_id", types.BytesToNodeID(meta.NodeId).ShortString()),
zap.String("poet_service_id", base64.StdEncoding.EncodeToString(req.PoetServiceID.ServiceID)),
zap.String("poet_service_id", poetPubKey),
zap.String("address", address),
zap.String("round_id", req.PoetRound.ID),
zap.Time("round_end", req.PoetRound.End.IntoTime()),
Expand Down Expand Up @@ -252,7 +253,8 @@ func (m migration0003) getAddress(serviceID PoetServiceID) (string, error) {
return client.Address(), nil
}
}
return "", fmt.Errorf("no poet client found for service id %x", serviceID.ServiceID)
key := base64.StdEncoding.EncodeToString(serviceID.ServiceID)
return "", fmt.Errorf("no poet client found for service id %s", key)
}

func (m migration0003) getChallengeHash(db sql.Executor, nodeID types.NodeID) (types.Hash32, error) {
Expand Down

0 comments on commit f114349

Please sign in to comment.