-
Notifications
You must be signed in to change notification settings - Fork 22
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
Missed rounds #1245
base: main
Are you sure you want to change the base?
Missed rounds #1245
Conversation
0eda6ae
to
be864c2
Compare
bd0dc99
to
94c9f4a
Compare
finalizationAwake :: !Bool | ||
finalizationAwake :: !Bool, | ||
-- | The number of missed rounds in the reward period | ||
missedRounds :: !Word16 |
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.
Use Word64
so we don't even have to consider overflow being a problem for this.
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 field also has to be conditional, because it won't be present before P8.
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.
I changed it to Word64. I think even Word16 is unlikely to overflow though. General question: Do we optimize on the size of serialized types or we don't care?
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.
I also made the field optional. Another general question: What are the benefits of this current approach of checking for backwards compatibility in the type system, over just supporting one protocol version at HEAD and have well tested migration paths from the previous protocol version? I feel the effort is not proportional to the benefits at the moment, but maybe I'm missing something.
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.
Word16 shouldn't overflow with the current chain parameters, but we shouldn't rely on that.
I think it is generally good to optimize for space somewhat, but balance the amount of space saved vs complexity. In this case, I think it could be worth doing some space saving. For instance, finalizationAwake
takes a whole byte of serialization, but only the low-order bit is used - you could use another bit to record if missedRounds
is non-zero. Usually it will be zero, and as there's going to be at least one of these written per block, the savings could be worth while.
On the backwards compatibility question, I'm not entirely sure what the alternative you are suggesting is. In practise, the node would need to support at least 2 protocol versions at once in order to migrate. As it stands, the node can catch up from the original genesis to the latest block. If we were implementing a new node fresh today, maybe we wouldn't bother with the older protocol versions at all, and we might do a bunch of things differently from the outset. However, the node as it exists is a result of a series of incremental steps, and the approach to protocol versions that we have allows us to make them reasonably easily, in my opinion.
concordium-consensus/src/Concordium/KonsensusV1/Consensus/Blocks.hs
Outdated
Show resolved
Hide resolved
concordium-consensus/src/Concordium/KonsensusV1/Consensus/Blocks.hs
Outdated
Show resolved
Hide resolved
ce3ea9a
to
f3fbeaa
Compare
-- | The current round. | ||
Round -> |
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 is not really needed, because the current round will be tcRound tc + 1
if the timeout certificate is present.
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't the tcRound
point to some earlier round?
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.
No. In the timeout certificate checking code, we have:
Present tc
-- Check that the TC round is correct.
| tcRound tc /= blockRound pendingBlock - 1 -> do
logEvent Konsensus LLTrace $ "Block " <> show pbHash <> " timeout certificate is not for the correct round."
flag $ BlockTCRoundInconsistent sBlock
rejectBlock
8c77619
to
e55f767
Compare
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. I think the main thing is to add/update testing for rotating the capital distribution.
-- | Rotate the capital distribution, so that the current capital distribution | ||
-- is replaced by the next one, and set up empty pool rewards, except that | ||
-- missed rounds are carried over from the old pool rewards. |
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.
We should have some tests for this. SchedulerTests.KonsensusV1.EpochTransition
already has tests for rotating capital distribution, so I'd suggest adding some there. In particular, we want to test cases where there are bakers with missed rounds and some bakers are added and removed to ensure the result is correct.
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.
These tests are currently pinned to P7. I will move those to P8 so we can test something meaningful.
-- | The current round. | ||
Round -> |
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.
No. In the timeout certificate checking code, we have:
Present tc
-- Check that the TC round is correct.
| tcRound tc /= blockRound pendingBlock - 1 -> do
logEvent Konsensus LLTrace $ "Block " <> show pbHash <> " timeout certificate is not for the correct round."
flag $ BlockTCRoundInconsistent sBlock
rejectBlock
concordium-consensus/src/Concordium/KonsensusV1/LeaderElection.hs
Outdated
Show resolved
Hide resolved
concordium-consensus/src/Concordium/GlobalState/Persistent/BlockState.hs
Outdated
Show resolved
Hide resolved
876fd34
to
71a853b
Compare
Co-authored-by: Thomas Dinsdale-Young <[email protected]>
Co-authored-by: Thomas Dinsdale-Young <[email protected]>
Co-authored-by: Thomas Dinsdale-Young <[email protected]>
Purpose
Compute the missed rounds for validators and update them in the scheduler.
Changes
See above
Checklist
hard-to-understand areas.
CLA acceptance
_Remove if not applicable.
By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0
link: https://developers.concordium.com/CLAs/Contributor-License-Agreement-v1.0.pdf
I accept the above linked CLA.