Skip to content

Move approval store into MSM#429

Merged
yacovm merged 3 commits into
mainfrom
approvalStoreInMSM
Jul 6, 2026
Merged

Move approval store into MSM#429
yacovm merged 3 commits into
mainfrom
approvalStoreInMSM

Conversation

@yacovm

@yacovm yacovm commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

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.

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>
Comment thread msm/approvals.go Outdated
@@ -27,8 +28,12 @@ type ApprovalStore struct {
validators NodeBLSMappings
logger common.Logger
pkByNodeID map[nodeID][]byte

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

unrelated but should we change this to nodeIDToPK. we already have validatorsToPKs map[string][]byte in epoch.go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not sure I follow, what is the problem with the field name?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i was just suggesting we rename to pkByNodeID -> `nodeIDToPk

Just to keep it consistent with how we name the same thing in epoch.go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread msm/approvals.go
Comment thread msm/approvals.go Outdated
Comment thread msm/approvals.go Outdated
Comment thread msm/approvals.go Outdated
Comment thread msm/approvals_test.go
Comment thread msm/msm.go Outdated
Comment thread msm/msm.go
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread msm/approvals.go
Comment thread msm/approvals.go
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
@yacovm yacovm force-pushed the approvalStoreInMSM branch from b563fd0 to 0be37b0 Compare July 6, 2026 16:59
@yacovm yacovm merged commit 11592ab into main Jul 6, 2026
6 checks passed
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.

2 participants