-
Notifications
You must be signed in to change notification settings - Fork 204
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
added checks on proofs parameters like epoch, nonce and shard #6698
base: equivalent-proofs-feat-stabilization
Are you sure you want to change the base?
added checks on proofs parameters like epoch, nonce and shard #6698
Conversation
process/block/baseProcess.go
Outdated
return fmt.Errorf("%w while getting header for proof hash %s", err, hex.EncodeToString(prevProof.GetHeaderHash())) | ||
} | ||
|
||
if prevProof.GetHeaderNonce() != prevHeader.GetNonce() { |
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 have now also round in header proof, so we can also add a check for round
return fmt.Errorf("%w while getting header for proof hash %s", err, hex.EncodeToString(iep.proof.GetHeaderHash())) | ||
} | ||
|
||
if iep.proof.GetHeaderNonce() != header.GetNonce() { |
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.
check for round here also
process/block/baseProcess.go
Outdated
return bp.checkPrevProofValidity(headerHandler) | ||
} | ||
|
||
func (bp *baseProcessor) checkPrevProofValidity(headerHandler data.HeaderHandler) error { |
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 think the checks can be done against the currentBlockHeader fields which is already loaded, like in the checkBlockValidity method.
currentBlockHeader can be passed as prevHeader
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.
also, do we have this kind of check as well for the proofs in the shard data included in a metablock?
e.g the prevProof from a shardData needs to be verified that it has the correct data (epoch, round, nonce) compared to the prevBlock of that shardData
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.
extended the checks over the prevProof as suggested
process/block/baseProcess.go
Outdated
} | ||
|
||
func (bp *baseProcessor) checkPrevProofValidity(headerHandler data.HeaderHandler) error { | ||
if !bp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, headerHandler.GetEpoch()) { |
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 you check with this instead:
if !common.ShouldBlockHavePrevProof(headerHandler, enableEpochsHandler, common.EquivalentMessagesFlag) {
return nil
}
the above check takes into consideration also the first block which should not have a previous proof.
if !mp.proofsPool.HasProof(shardData.ShardID, shardData.HeaderHash) { | ||
return fmt.Errorf("%w for header hash %s", process.ErrMissingHeaderProof, hex.EncodeToString(shardData.HeaderHash)) | ||
} | ||
|
||
prevProof := shardData.GetPreviousProof() | ||
headersPool := mp.dataPool.Headers() | ||
prevHeader, err := headersPool.GetHeaderByHash(prevProof.GetHeaderHash()) |
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.
here we check if there is shardData.HeaderHash proof in pool, and then we check proof fields on previousProof, is this ok?
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.
yes, the proof from pool should have already been validated
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?