-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Khalil/5766 improve epochs metrics #1185
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1185 +/- ##
==========================================
+ Coverage 55.69% 55.70% +0.01%
==========================================
Files 482 482
Lines 29584 29632 +48
==========================================
+ Hits 16476 16507 +31
- Misses 10858 10868 +10
- Partials 2250 2257 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 Looks good. Once we extend the tests to cover the epoch 1->2 transition, this is good to go for me.
@@ -470,6 +470,20 @@ func TestExtendEpochTransitionValid(t *testing.T) { | |||
metrics.On("CurrentEpochPhase", initialPhase).Once() | |||
metrics.On("CommittedEpochFinalView", finalView).Once() | |||
|
|||
metrics.On("CurrentEpochFinalView", finalView).Once() | |||
|
|||
currentDKGPhase1FinalView, err := initialCurrentEpoch.DKGPhase1FinalView() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here, can use
flow-go/state/protocol/convert.go
Line 150 in 3d3a19b
func DKGPhaseViews(epoch Epoch) (phase1FinalView uint64, phase2FinalView uint64, phase3FinalView uint64, err error) { |
state/protocol/badger/state_test.go
Outdated
@@ -47,6 +47,19 @@ func TestBootstrapAndOpen(t *testing.T) { | |||
complianceMetrics.On("CommittedEpochFinalView", finalView).Once() | |||
complianceMetrics.On("CurrentEpochCounter", counter).Once() | |||
complianceMetrics.On("CurrentEpochPhase", phase).Once() | |||
complianceMetrics.On("CurrentEpochFinalView", finalView).Once() | |||
|
|||
currentDKGPhase1FinalView, err := epoch.DKGPhase1FinalView() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here, can use
flow-go/state/protocol/convert.go
Line 150 in 3d3a19b
func DKGPhaseViews(epoch Epoch) (phase1FinalView uint64, phase2FinalView uint64, phase3FinalView uint64, err error) { |
state/protocol/badger/state_test.go
Outdated
require.NoError(t, err) | ||
complianceMetrics.On("CurrentEpochFinalView", currentEpochFinalView).Once() | ||
|
||
currentDKGPhase1FinalView, err := committedPhaseSnapshot.Epochs().Current().DKGPhase1FinalView() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here, can use
flow-go/state/protocol/convert.go
Line 150 in 3d3a19b
func DKGPhaseViews(epoch Epoch) (phase1FinalView uint64, phase2FinalView uint64, phase3FinalView uint64, err error) { |
|
||
currentDKGPhase3FinalView, err := initialCurrentEpoch.DKGPhase3FinalView() | ||
require.NoError(t, err) | ||
metrics.On("CurrentDKGPhase3FinalView", currentDKGPhase3FinalView).Once() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Could we also assert that the metrics are updated correctly after the epoch transition. Can use the same pattern as is used for checking current epoch counter on lines 697/702 below:
flow-go/state/protocol/badger/mutator_test.go
Lines 695 to 705 in a603c08
// expect epoch transition once we finalize block 9 | |
consumer.On("EpochTransition", epoch2Setup.Counter, block9.Header).Once() | |
metrics.On("CurrentEpochCounter", epoch2Setup.Counter) | |
err = state.Finalize(block8.ID()) | |
require.NoError(t, err) | |
err = state.Finalize(block9.ID()) | |
require.NoError(t, err) | |
metrics.AssertCalled(t, "CurrentEpochCounter", epoch2Setup.Counter) | |
consumer.AssertCalled(t, "EpochTransition", epoch2Setup.Counter, block9.Header) | |
metrics.AssertExpectations(t) |
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for adding the metrics. Only left a minor comment.
state.metrics.CurrentEpochFinalView(currentEpochFinalView) | ||
|
||
dkgPhase1FinalView, dkgPhase2FinalView, dkgPhase3FinalView, err := protocol.DKGPhaseViews(snap.Epochs().Current()) | ||
if err != nil { | ||
return fmt.Errorf("could not get dkg phase final view: %w", err) | ||
} | ||
|
||
state.metrics.CurrentDKGPhase1FinalView(dkgPhase1FinalView) | ||
state.metrics.CurrentDKGPhase2FinalView(dkgPhase2FinalView) | ||
state.metrics.CurrentDKGPhase3FinalView(dkgPhase3FinalView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we report all these metrics in one call?
Better that all these metrics are updated atomically, since they are all pointing at the "current" epoch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by in one call , In a single function call ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸
This PR adds the following metrics