Skip to content

Commit

Permalink
Add more logs in bootstrap generator (#6507)
Browse files Browse the repository at this point in the history
## Motivation

Increase bootstrapper verbosity for a better understanding of what it does.
  • Loading branch information
poszu committed Nov 30, 2024
1 parent ace4e45 commit feda54f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions bootstrap/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ type EpochData struct {
ActiveSet []string `json:"activeSet"`
}

func (ed *EpochData) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
encoder.AddUint32("epoch", ed.ID)
encoder.AddString("beacon", ed.Beacon)
encoder.AddInt("activeset_size", len(ed.ActiveSet))
return nil
}

type VerifiedUpdate struct {
Data *EpochOverride
Persisted string
Expand Down
7 changes: 4 additions & 3 deletions cmd/bootstrapper/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ func (g *Generator) Generate(
}

if genBeacon {
g.logger.Info("bootstrapping beacon", zap.Uint32("epoch", targetEpoch.Uint32()))
beacon, err = g.genBeacon(ctx, g.logger)
if err != nil {
return "", err
}
}
if genActiveSet {
g.logger.Info("bootstrapping activeset", zap.Uint32("epoch", targetEpoch.Uint32()))
activeSet, err = getActiveSet(ctx, g.smEndpoint, targetEpoch-1)
if err != nil {
return "", err
Expand Down Expand Up @@ -245,6 +247,7 @@ func (g *Generator) GenUpdate(
if len(activeSet) > 0 {
edata.ActiveSet = as
}
g.logger.Info("generated bootstrap", zap.Inline(&edata))
update.Data = bootstrap.InnerData{
Epoch: edata,
}
Expand All @@ -261,8 +264,6 @@ func (g *Generator) GenUpdate(
if err != nil {
return "", fmt.Errorf("persist epoch update %v: %w", filename, err)
}
g.logger.Info("generated update",
zap.String("filename", filename),
)
g.logger.Info("generated update", zap.String("filename", filename))
return filename, nil
}

0 comments on commit feda54f

Please sign in to comment.