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

Update metrics for managed keys #5354

Merged
merged 4 commits into from Jun 21, 2023

Conversation

sstanculeanu
Copy link
Contributor

Reasoning behind the pull request

  • some of the metrics should be updated when one of the managed keys is leader

Proposed changes

  • update metrics

Testing procedure

  • will be tested with feat branch

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.02 ⚠️

Comparison is base (8fc476c) 80.31% compared to head (81fe845) 80.29%.

❗ Current head 81fe845 differs from pull request most recent head 729e925. Consider uploading reports for the commit 729e925 to get more accurate results

Additional details and impacted files
@@                    Coverage Diff                    @@
##           feat/multikey_metrics    #5354      +/-   ##
=========================================================
- Coverage                  80.31%   80.29%   -0.02%     
=========================================================
  Files                        697      697              
  Lines                      90355    90222     -133     
=========================================================
- Hits                       72570    72447     -123     
+ Misses                     12608    12607       -1     
+ Partials                    5177     5168       -9     
Impacted Files Coverage Δ
outport/process/outportDataProvider.go 51.04% <ø> (ø)
consensus/spos/bls/subroundStartRound.go 75.63% <100.00%> (+7.26%) ⬆️
factory/processing/blockProcessorCreator.go 82.19% <100.00%> (+0.04%) ⬆️
process/block/baseProcess.go 73.66% <100.00%> (+0.04%) ⬆️
process/block/metablock.go 61.96% <100.00%> (+0.02%) ⬆️
process/block/metrics.go 67.91% <100.00%> (-1.19%) ⬇️
process/block/shardblock.go 68.48% <100.00%> (+0.02%) ⬆️

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

isInConsensus := false
for index, publicKey := range pubKeys {
if index == 0 {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we skip the index 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's the leader index. I guess we can have a const like leaderIndex := 0 and use that in the if branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added constant

Comment on lines 148 to 155
if bytes.Equal([]byte(publicKey), ownPublicKey) {
if index == 0 {
return
}

isInConsensus = true
break
appStatusHandler.Increment(common.MetricCountConsensusAcceptedBlocks)
continue
}
}

if !isInConsensus {
return
if managedPeersHolder.IsKeyManagedByCurrentNode([]byte(publicKey)) {
appStatusHandler.Increment(common.MetricCountConsensusAcceptedBlocks)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be rewritten as something like:

		isMyKey := bytes.Equal([]byte(publicKey), ownPublicKey)
		isManagedByCurrentNode := managedPeersHolder.IsKeyManagedByCurrentNode([]byte(publicKey))
		if isMyKey || isManagedByCurrentNode {
			appStatusHandler.Increment(common.MetricCountConsensusAcceptedBlocks)
		}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good suggestion, applied

@@ -159,10 +159,12 @@ func (sr *subroundStartRound) initCurrentRound() bool {
msg = " (my turn in multi-key)"
}
if leader == sr.SelfPubKey() {
msg = " (my turn)"
}
if len(msg) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -181,10 +183,10 @@ func (sr *subroundStartRound) initCurrentRound() bool {
}
sr.AppStatusHandler().SetStringValue(common.MetricConsensusState, "not in consensus group")
} else {
if leader != sr.SelfPubKey() {
if leader != sr.SelfPubKey() && !sr.IsKeyManagedByCurrentNode([]byte(leader)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

good find 👍

isInConsensus := false
for index, publicKey := range pubKeys {
if index == 0 {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

that's the leader index. I guess we can have a const like leaderIndex := 0 and use that in the if branch

header.PrevRandSeed,
header.Round,
header.GetPrevRandSeed(),
header.GetRound(),
core.MetachainShardId,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this ok? Shouldn't have been header.ShardID() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, messed it up while merging the methods

@sstanculeanu sstanculeanu merged commit c2f41cb into feat/multikey_metrics Jun 21, 2023
6 checks passed
@sstanculeanu sstanculeanu deleted the update_metrics_for_managed_keys branch June 21, 2023 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants