Skip to content

Commit

Permalink
Fix state upgrade log (prysmaticlabs#14316)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkapka authored Aug 7, 2024
1 parent 102f94f commit 9a7f521
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion beacon-chain/core/transition/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,17 @@ func ProcessEpoch(ctx context.Context, state state.BeaconState) (state.BeaconSta
func UpgradeState(ctx context.Context, state state.BeaconState) (state.BeaconState, error) {
ctx, span := trace.StartSpan(ctx, "core.state.UpgradeState")
defer span.End()

var err error
upgraded := false

if time.CanUpgradeToAltair(state.Slot()) {
state, err = altair.UpgradeToAltair(ctx, state)
if err != nil {
tracing.AnnotateError(span, err)
return nil, err
}
upgraded = true
}

if time.CanUpgradeToBellatrix(state.Slot()) {
Expand All @@ -334,6 +338,7 @@ func UpgradeState(ctx context.Context, state state.BeaconState) (state.BeaconSta
tracing.AnnotateError(span, err)
return nil, err
}
upgraded = true
}

if time.CanUpgradeToCapella(state.Slot()) {
Expand All @@ -342,6 +347,7 @@ func UpgradeState(ctx context.Context, state state.BeaconState) (state.BeaconSta
tracing.AnnotateError(span, err)
return nil, err
}
upgraded = true
}

if time.CanUpgradeToDeneb(state.Slot()) {
Expand All @@ -350,6 +356,7 @@ func UpgradeState(ctx context.Context, state state.BeaconState) (state.BeaconSta
tracing.AnnotateError(span, err)
return nil, err
}
upgraded = true
}

if time.CanUpgradeToElectra(state.Slot()) {
Expand All @@ -358,9 +365,13 @@ func UpgradeState(ctx context.Context, state state.BeaconState) (state.BeaconSta
tracing.AnnotateError(span, err)
return nil, err
}
upgraded = true
}

if upgraded {
log.Debugf("upgraded state to %s", version.String(state.Version()))
}

log.Debugf("upgraded state to %s", version.String(state.Version()))
return state, nil
}

Expand Down

0 comments on commit 9a7f521

Please sign in to comment.