Repository navigation
Conversation
|
|
||
| blockBuildingDecider := sm.createBlockBuildingDecider(currentValidatorSet) | ||
| // Overwrite the GetPChainHeight function to ensure that we always propose a block with a P-chain height | ||
| // that is at least as high as the parent block's P-chain height. |
There was a problem hiding this comment.
i dont get how we can verify a block that has a higher pchain height than ours? we have verifyPChainHeight in the msm, that rejects heights too big. Therefore wouldn't we not build on top of a block with a higher pchain?
There was a problem hiding this comment.
Recall that we have two P-chain height functions - one for proposing and one for verifying. The one for proposing may return a slightly stale P-chain height. The one for verifying returns the latest height.
So, when we build a block ourselves, we use the one for proposing and it may return a slightly stale height. But the parent block might have been built with a higher P-chain height that may still be lower than the P-chain height returned by the function we use for verifying. It's all legal.
There was a problem hiding this comment.
i see because we have GetMinimumPChainHeight and GetCurrentPChainHeight
| blockBuildingDecider := sm.createBlockBuildingDecider(currentValidatorSet) | ||
| // Overwrite the GetPChainHeight function to ensure that we always propose a block with a P-chain height | ||
| // that is at least as high as the parent block's P-chain height. | ||
| blockBuildingDecider.getPChainHeight = func() uint64 { |
There was a problem hiding this comment.
can we just set the getPChainHeight field in the constructor? rather than having to do it after
There was a problem hiding this comment.
which constructor? can you be more explicit? I don't understand
There was a problem hiding this comment.
im referring to the createBlockBuildingDecider constructor. We can just pass in the another variable to initialize it.
| icmEpochInfo := computeICMEpochInfo(parentBlock, sm.ComputeICMEpoch, now) | ||
| pChainHeight := sm.GetPChainHeightForProposing() | ||
| return wrapBlock(nil, newSimplexEpochInfo, pChainHeight, simplexMetadata, simplexBlacklist, now, icmEpochInfo, nil), nil | ||
| if parentBlock.Metadata.PChainHeight > pChainHeight { |
There was a problem hiding this comment.
if we have it in the constructor above, we can just call blockBuildingDecider.getPChainHeight here
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
This commit makes the MSM carry over the P-chain height of the parent in case it's higher than the sampled P-chain height, to make sure the P-chain is non-decreasing.