Move approval store into MSM#429
Conversation
This commit moves the approval store into the MSM, instead of being an external dependency. The reason is that the approval store needs to be initialized with the validator set of the *next* epoch and not the *current epoch*, which can only be computed inside the MSM. Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
| @@ -27,8 +28,12 @@ type ApprovalStore struct { | |||
| validators NodeBLSMappings | |||
| logger common.Logger | |||
| pkByNodeID map[nodeID][]byte | |||
There was a problem hiding this comment.
unrelated but should we change this to nodeIDToPK. we already have validatorsToPKs map[string][]byte in epoch.go
There was a problem hiding this comment.
not sure I follow, what is the problem with the field name?
There was a problem hiding this comment.
i was just suggesting we rename to pkByNodeID -> `nodeIDToPk
Just to keep it consistent with how we name the same thing in epoch.go
There was a problem hiding this comment.
| if decisionToBuildBlock.transitionEpoch && isSealingBlockFinalized { | ||
| sm.Logger.Debug("Transitioning epoch after building block", zap.Uint64("newPChainRefHeight", decisionToBuildBlock.pChainHeight)) | ||
| newSimplexEpochInfo.NextPChainReferenceHeight = decisionToBuildBlock.pChainHeight | ||
| sm.maybeInitializeApprovalStore(decisionToBuildBlock.validatorSet) |
There was a problem hiding this comment.
but if the sealing block is finalized, we must have already computed an approval store. furthermore, since this is for the next epoch aren't these validators not the right validators anyways? we want the validator set for the next, next epoch which we can't know since we are only transitioning to the next epoch.
There was a problem hiding this comment.
This is the sealing block of the previous epoch, not this epoch.
The sealing block of this epoch hasn't been created yet.
since this is for the next epoch aren't these validators not the right validators anyways?
I changed shouldBuildBlock to return the validator set at decisionToBuildBlock.pChainHeight which is written into newSimplexEpochInfo.NextPChainReferenceHeight.
we want the validator set for the next, next epoch which we can't know since we are only transitioning to the next epoch.
This function determines the P-chain reference height for the next epoch, and that's the validator set we are seeding the approval store with.
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
b563fd0 to
0be37b0
Compare
This commit moves the approval store into the MSM, instead of being an external dependency.
The reason is that the approval store needs to be initialized with the validator set of the next epoch and not the current epoch, which can only be computed inside the MSM.