Skip to content

Commit

Permalink
Ensure epoch summarization is not repeated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Jan 19, 2024
1 parent 95d8a69 commit 195815a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.8.1:
- do not repeat summarization for epochs

0.8.0:
- support deneb
- add t_blob_sidecars for Deneb
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2020 - 2023 Weald Technology Trading.
// Copyright © 2020 - 2024 Weald Technology Trading.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -61,7 +61,7 @@ import (
)

// ReleaseVersion is the release version for the code.
var ReleaseVersion = "0.8.0"
var ReleaseVersion = "0.8.1"

func main() {
os.Exit(main2())
Expand Down
18 changes: 14 additions & 4 deletions services/summarizer/standard/handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 - 2023 Weald Technology Limited.
// Copyright © 2021 - 2024 Weald Technology Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -109,10 +109,15 @@ func (s *Service) summarizeEpochs(ctx context.Context, targetEpoch phase0.Epoch)
firstEpoch++
}

if targetEpoch < firstEpoch {
log.Trace().Uint64("target_epoch", uint64(targetEpoch)).Uint64("first_epoch", uint64(firstEpoch)).Msg("Target epoch before first epoch; nothing to do")
return nil
}

// Limit the number of epochs summarised per pass, if we are also pruning.
maxEpochsPerRun := phase0.Epoch(s.maxDaysPerRun) * s.epochsPerDay()
if s.validatorEpochRetention != nil && maxEpochsPerRun > 0 && targetEpoch-firstEpoch > maxEpochsPerRun {
log.Trace().Uint64("old_target_epoch", uint64(targetEpoch)).Uint64("new_target_epoch", uint64(firstEpoch+maxEpochsPerRun)).Msg("Reducing target epoch")
log.Trace().Uint64("first_epoch", uint64(firstEpoch)).Uint64("old_target_epoch", uint64(targetEpoch)).Uint64("max_epochs_per_run", uint64(maxEpochsPerRun)).Uint64("new_target_epoch", uint64(firstEpoch+maxEpochsPerRun)).Msg("Reducing target epoch")
targetEpoch = firstEpoch + maxEpochsPerRun
}
log.Trace().Uint64("first_epoch", uint64(firstEpoch)).Uint64("target_epoch", uint64(targetEpoch)).Msg("Epochs catchup bounds")
Expand Down Expand Up @@ -203,10 +208,15 @@ func (s *Service) summarizeValidators(ctx context.Context, targetEpoch phase0.Ep
targetEpoch = md.LastEpoch
}

if targetEpoch < firstEpoch {
log.Trace().Uint64("target_epoch", uint64(targetEpoch)).Uint64("first_epoch", uint64(firstEpoch)).Msg("Target epoch before first epoch; nothing to do")
return nil
}

// Limit the number of epochs summarised per pass, if we are also pruning.
maxEpochsPerRun := phase0.Epoch(s.maxDaysPerRun) * s.epochsPerDay()
if s.validatorEpochRetention != nil && maxEpochsPerRun > 0 && firstEpoch-targetEpoch > maxEpochsPerRun {
log.Trace().Uint64("first_epoch", uint64(firstEpoch)).Uint64("old_target_epoch", uint64(targetEpoch)).Uint64("new_target_epoch", uint64(firstEpoch+maxEpochsPerRun)).Msg("Reducing target epoch")
if s.validatorEpochRetention != nil && maxEpochsPerRun > 0 && targetEpoch-firstEpoch > maxEpochsPerRun {
log.Trace().Uint64("first_epoch", uint64(firstEpoch)).Uint64("old_target_epoch", uint64(targetEpoch)).Uint64("max_epochs_per_run", uint64(maxEpochsPerRun)).Uint64("new_target_epoch", uint64(firstEpoch+maxEpochsPerRun)).Msg("Reducing target validator epoch")
targetEpoch = firstEpoch + maxEpochsPerRun
}
log.Trace().Uint64("first_epoch", uint64(firstEpoch)).Uint64("target_epoch", uint64(targetEpoch)).Msg("Validators catchup bounds")
Expand Down

0 comments on commit 195815a

Please sign in to comment.