Skip to content
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

Merged
merged 13 commits into from
Aug 25, 2021
Merged

Conversation

kc1116
Copy link
Contributor

@kc1116 kc1116 commented Aug 22, 2021

This PR adds the following metrics

  • consensus_compliance_current_epoch_final_view : the final view of the current epoch with the greatest counter
  • consensus_compliance_current_dkg_phase1_final_view: the final view of phase 1 of the current epochs DKG with the greatest counter
  • consensus_compliance_current_dkg_phase2_final_view: the final view of phase 2 of the current epochs DKG with the greatest counter
  • consensus_compliance_current_dkg_phase3_final_view: the final view of phase 3 of the current epochs DKG with the greatest counter

@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2021

Codecov Report

Merging #1185 (313c006) into master (0e5b3f3) will increase coverage by 0.01%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 55.70% <60.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
state/protocol/badger/state.go 55.95% <60.00%> (+0.15%) ⬆️
...sus/approvals/assignment_collector_statemachine.go 42.30% <0.00%> (-7.70%) ⬇️
...ngine/common/synchronization/finalized_snapshot.go 66.66% <0.00%> (-5.13%) ⬇️
engine/consensus/dkg/reactor_engine.go 75.38% <0.00%> (-0.59%) ⬇️
module/dkg/controller.go 68.79% <0.00%> (ø)
fvm/bootstrap.go 73.99% <0.00%> (+0.58%) ⬆️
module/signature/threshold.go 76.47% <0.00%> (+1.47%) ⬆️
cmd/bootstrap/utils/key_generation.go 46.66% <0.00%> (+2.22%) ⬆️
module/signature/signer_store.go 50.00% <0.00%> (+50.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e5b3f3...313c006. Read the comment docs.

Copy link
Member

@jordanschalm jordanschalm left a 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.

module/metrics/compliance.go Outdated Show resolved Hide resolved
module/metrics/compliance.go Outdated Show resolved Hide resolved
state/protocol/badger/state.go Outdated Show resolved Hide resolved
state/protocol/badger/state.go Outdated Show resolved Hide resolved
@@ -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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here, can use

func DKGPhaseViews(epoch Epoch) (phase1FinalView uint64, phase2FinalView uint64, phase3FinalView uint64, err error) {

@@ -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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here, can use

func DKGPhaseViews(epoch Epoch) (phase1FinalView uint64, phase2FinalView uint64, phase3FinalView uint64, err error) {

require.NoError(t, err)
complianceMetrics.On("CurrentEpochFinalView", currentEpochFinalView).Once()

currentDKGPhase1FinalView, err := committedPhaseSnapshot.Epochs().Current().DKGPhase1FinalView()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here, can use

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()
Copy link
Member

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:

// 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)

kc1116 and others added 6 commits August 24, 2021 09:36
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>
Copy link
Member

@zhangchiqing zhangchiqing left a 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.

Comment on lines +521 to +530
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)
Copy link
Member

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.

Copy link
Contributor Author

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 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎸

@kc1116 kc1116 merged commit 814b004 into master Aug 25, 2021
@kc1116 kc1116 deleted the khalil/5766-improve-epochs-metrics branch August 25, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants