Skip to content

Commit

Permalink
Merge pull request #4786 from onflow/leo/log-stop-height
Browse files Browse the repository at this point in the history
[Execution] Log stop height
  • Loading branch information
zhangchiqing authored Oct 6, 2023
2 parents 9c6f9ff + 36bd016 commit 4ee1b74
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
12 changes: 9 additions & 3 deletions engine/execution/ingestion/stop/stop_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,11 @@ func (s *StopControl) processNewVersionBeacons(
return
}

s.log.Info().
lg := s.log.With().
Str("node_version", s.nodeVersion.String()).
Str("beacon", vb.String()).
Uint64("vb_seal_height", vb.SealHeight).
Uint64("vb_sequence", vb.Sequence).
Msg("New version beacon found")
Uint64("vb_sequence", vb.Sequence).Logger()

// this is now the last handled version beacon
s.versionBeacon = vb
Expand All @@ -642,6 +643,10 @@ func (s *StopControl) processNewVersionBeacons(
return
}

lg.Info().
Uint64("stop_height", stopHeight).
Msg("New version beacon found")

var newStop = stopBoundary{
StopParameters: StopParameters{
StopBeforeHeight: stopHeight,
Expand All @@ -655,6 +660,7 @@ func (s *StopControl) processNewVersionBeacons(
// This is just informational and is expected to sometimes happen during
// normal operation. The causes for this are described here: validateStopChange.
s.log.Info().
Uint64("stop_height", stopHeight).
Err(err).
Msg("Cannot change stop boundary when detecting new version beacon")
}
Expand Down
5 changes: 5 additions & 0 deletions engine/execution/ingestion/stop/stop_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,3 +879,8 @@ func Test_StopControlWorkers(t *testing.T) {
unittest.AssertClosesBefore(t, sc.Done(), 10*time.Second)
})
}

func TestPatchedVersion(t *testing.T) {
require.True(t, semver.New("0.31.20").LessThan(*semver.New("0.31.21")))
require.True(t, semver.New("0.31.20-patch.1").LessThan(*semver.New("0.31.20"))) // be careful with this one
}
9 changes: 9 additions & 0 deletions model/flow/version_beacon.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package flow

import (
"bytes"
"fmt"

"github.com/coreos/go-semver/semver"
Expand Down Expand Up @@ -146,3 +147,11 @@ func (v *VersionBeacon) Validate() error {

return nil
}

func (v *VersionBeacon) String() string {
var buffer bytes.Buffer
for _, boundary := range v.VersionBoundaries {
buffer.WriteString(fmt.Sprintf("%d:%s ", boundary.BlockHeight, boundary.Version))
}
return buffer.String()
}
11 changes: 11 additions & 0 deletions model/flow/version_beacon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,14 @@ func TestValidate(t *testing.T) {
})
}
}

func TestVersionBeaconString(t *testing.T) {
vb := &flow.VersionBeacon{
VersionBoundaries: []flow.VersionBoundary{
{BlockHeight: 1, Version: "0.21.37"},
{BlockHeight: 200, Version: "0.21.37-patch.1"},
},
Sequence: 1,
}
require.Equal(t, "1:0.21.37 200:0.21.37-patch.1 ", vb.String())
}

0 comments on commit 4ee1b74

Please sign in to comment.