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

Rating improvement hard fork stuck shard #3545

Merged

Conversation

mariusmihaic
Copy link
Contributor

@mariusmihaic mariusmihaic commented Oct 27, 2021

  • Added MaxConsecutiveRoundsOfRatingDecrease , which represents the max number of consecutive rounds in which a validator's rating can be decrease in case of not processing/signing a block. If, for instance, a shard gets stuck for more rounds than this value, then we should stop decreasing validator's rating so they won't get jailed.
  • Added StopDecreasingValidatorRatingWhenStuckEnableEpoch which represents the epoch when we should stop decreasing validator's rating if, for instance, a shard gets stuck
  • Added simple logic to check if enable epoch flag is set AND missed rounds > MaxConsecutiveRoundsOfRatingDecrease => do not decrease validator rating
  • Added unit test

@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #3545 (2aa7a26) into development (8aa73b5) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #3545      +/-   ##
===============================================
+ Coverage        73.94%   73.95%   +0.01%     
===============================================
  Files              581      581              
  Lines            74780    74794      +14     
===============================================
+ Hits             55293    55311      +18     
+ Misses           15077    15075       -2     
+ Partials          4410     4408       -2     
Impacted Files Coverage Δ
factory/processComponents.go 62.67% <100.00%> (+0.08%) ⬆️
process/peer/process.go 72.99% <100.00%> (+0.46%) ⬆️
process/block/baseProcess.go 68.71% <0.00%> (+0.25%) ⬆️
p2p/libp2p/netMessenger.go 75.00% <0.00%> (+0.27%) ⬆️

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 1eef8df...2aa7a26. Read the comment docs.

@@ -144,6 +144,9 @@
# RemoveNonUpdatedStorageEnableEpoch represents the epoch when the backward compatibility for removing non updated storage is enabled
RemoveNonUpdatedStorageEnableEpoch = 2

# StopDecreasingValidatorRatingWhenStuckEpoch represents the epoch when we should stop decreasing validator's rating if, for instance, a shard gets stuck
StopDecreasingValidatorRatingWhenStuckEpoch = 1000000
Copy link
Contributor

Choose a reason for hiding this comment

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

StopDecreasingValidatorRatingWhenStuckEnableEpoch to keep the same pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed it for consistency

@@ -61,6 +61,7 @@ type EnableEpochs struct {
FixOOGReturnCodeEnableEpoch uint32
RemoveNonUpdatedStorageEnableEpoch uint32
DeleteDelegatorAfterClaimRewardsEnableEpoch uint32
StopDecreasingValidatorRatingWhenStuckEpoch uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

StopDecreasingValidatorRatingWhenStuckEnableEpoch to keep the same pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed it for consistency

SwitchJailWaitingEnableEpoch uint32
BelowSignedThresholdEnableEpoch uint32
StakingV2EnableEpoch uint32
StopDecreasingValidatorRatingWhenStuckEpoch uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

StopDecreasingValidatorRatingWhenStuckEnableEpoch to keep the same pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed it for consistency

jailedEnableEpoch uint32
belowSignedThresholdEnableEpoch uint32
stakingV2EnableEpoch uint32
stopDecreasingValidatorRatingWhenStuckEpoch uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

stopDecreasingValidatorRatingWhenStuckEpoch to keep the same pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed it for consistency

stopDecreasingValidatorRatingWhenStuckEpoch uint32
flagJailedEnabled atomic.Flag
flagStakingV2Enabled atomic.Flag
flagStopDecreasingValidatorRating atomic.Flag
Copy link
Contributor

Choose a reason for hiding this comment

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

flagStopDecreasingValidatorRatingEnabled to keep the same pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed it for consistency

@mariusmihaic mariusmihaic marked this pull request as ready for review October 28, 2021 11:01
@mariusmihaic mariusmihaic self-assigned this Oct 28, 2021
@raduchis raduchis self-requested a review October 28, 2021 11:15
@@ -144,6 +144,9 @@
# RemoveNonUpdatedStorageEnableEpoch represents the epoch when the backward compatibility for removing non updated storage is enabled
RemoveNonUpdatedStorageEnableEpoch = 2

# StopDecreasingValidatorRatingWhenStuckEnableEpoch represents the epoch when we should stop decreasing validator's rating if, for instance, a shard gets stuck
StopDecreasingValidatorRatingWhenStuckEnableEpoch = 1000000
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have this enabled though?
you can set it to 2, then we can try to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, changed it as requested

@@ -1230,4 +1243,6 @@ func (vs *validatorStatistics) EpochConfirmed(epoch uint32, _ uint64) {
log.Debug("validatorStatistics: jailed", "enabled", vs.flagJailedEnabled.IsSet())
vs.flagStakingV2Enabled.Toggle(epoch > vs.stakingV2EnableEpoch)
log.Debug("validatorStatistics: stakingV2", vs.flagStakingV2Enabled.IsSet())
vs.flagStopDecreasingValidatorRatingEnabled.Toggle(epoch >= vs.stopDecreasingValidatorRatingWhenStuckEnableEpoch)
log.Debug("validatorStatistics: stop decreasing validator rating", vs.flagStopDecreasingValidatorRatingEnabled.IsSet())
Copy link
Contributor

Choose a reason for hiding this comment

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

can you log also the maximum number of rounds?
in case we miss initializing it in the DTO and it ends up default = 0, there will never be any rating decrease.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good point!
Added a log for maxConsecutiveRoundsOfRatingDecrease as well.
Also, I've added a check on constructor to check if maxConsecutiveRoundsOfRatingDecrease == 0 => return error

@@ -23,6 +23,11 @@
# GenesisMaxNumberOfShards represents the maximum number of shards to be created at genesis (excluding metaChain shard)
GenesisMaxNumberOfShards = 3

# MaxConsecutiveRoundsOfRatingDecrease represents the max number of consecutive rounds in which a validator's rating
Copy link
Contributor

Choose a reason for hiding this comment

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

#MaxConsecutiveRoundsOfRatingDecrease representes the max number of consecutive rounds in which a block is not proposed on a shard and the validators' rating could be decreased. (...) then we should stop decreasing validator's rating so they won't get jailed => then the validators rating decrease should stop...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the description as suggested !

@@ -1333,6 +1337,43 @@ func TestValidatorStatisticsProcessor_CheckForMissedBlocksNoMissedBlocks(t *test
assert.False(t, computeValidatorGroupCalled)
}

func TestValidatorStatisticsProcessor_CheckForMissedBlocksMissedRoundsGreaterThanMaxConsecutiveRoundsOfRatingDecrease(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check for actual rating decrease before and after fix is missing.

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 point. I've changed the test.

cmd/node/config/config.toml Outdated Show resolved Hide resolved
cmd/node/config/config.toml Outdated Show resolved Hide resolved
process/errors.go Outdated Show resolved Hide resolved
raduchis
raduchis previously approved these changes Nov 1, 2021
AdoAdoAdo
AdoAdoAdo previously approved these changes Nov 1, 2021
SebastianMarian
SebastianMarian previously approved these changes Nov 2, 2021
…stuck_shard

# Conflicts:
#	config/epochConfig.go
AdoAdoAdo
AdoAdoAdo previously approved these changes Nov 8, 2021
SebastianMarian
SebastianMarian previously approved these changes Nov 8, 2021
raduchis
raduchis previously approved these changes Nov 8, 2021
mariusmihaic and others added 2 commits November 12, 2021 15:39
…stuck_shard

# Conflicts:
#	cmd/node/config/enableEpochs.toml
#	config/epochConfig.go
Copy link
Collaborator

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

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

System test passed.

@mariusmihaic mariusmihaic merged commit 6c0d7c2 into development Nov 12, 2021
@mariusmihaic mariusmihaic deleted the EN-10889-Rating_improvement_hardfork_stuck_shard branch November 12, 2021 20:16
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

6 participants