Skip to content
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

Open
wants to merge 3 commits into
base: equivalent-proofs-feat-stabilization
Choose a base branch
from

Conversation

sstanculeanu
Copy link
Collaborator

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:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@sstanculeanu sstanculeanu added the ignore-for-release-notes Do not include item in release notes label Jan 9, 2025
@sstanculeanu sstanculeanu self-assigned this Jan 9, 2025
return fmt.Errorf("%w while getting header for proof hash %s", err, hex.EncodeToString(prevProof.GetHeaderHash()))
}

if prevProof.GetHeaderNonce() != prevHeader.GetNonce() {
Copy link
Contributor

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() {
Copy link
Contributor

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

return bp.checkPrevProofValidity(headerHandler)
}

func (bp *baseProcessor) checkPrevProofValidity(headerHandler data.HeaderHandler) error {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Collaborator Author

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

}

func (bp *baseProcessor) checkPrevProofValidity(headerHandler data.HeaderHandler) error {
if !bp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, headerHandler.GetEpoch()) {
Copy link
Contributor

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.

Comment on lines 430 to +436
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())
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-for-release-notes Do not include item in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants