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

Fixes header sig verification #6665

Merged
merged 14 commits into from
Dec 16, 2024

Conversation

AdoAdoAdo
Copy link
Contributor

@AdoAdoAdo AdoAdoAdo commented Dec 10, 2024

Reasoning behind the pull request

  • The proof verification (aggregated signature) with equivalent proofs is for the unaltered header, so it also needs to be verified on the unaltered header
  • Add more safety and integrity checks

Proposed changes

  • Leader signature is not removed from the header before verifying the proof aggregated signature
  • Make sure new header fields (proof related) are validated for both before activation - throw an error if the new fields are present, and after activation - throw an error if the fields are not present

Testing procedure

  • Unit tests
  • Regular system test with transitioning from old to new consensus will be done on the feat branch

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?

Base automatically changed from fix_header_verification to feat/equivalent-messages December 11, 2024 14:17
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 37.50000% with 25 lines in your changes missing coverage. Please review.

Project coverage is 78.74%. Comparing base (3d254f2) to head (d663d3c).
Report is 313 commits behind head on feat/equivalent-messages.

Files with missing lines Patch % Lines
process/headerCheck/headerSignatureVerify.go 39.28% 16 Missing and 1 partial ⚠️
consensus/spos/worker.go 37.50% 3 Missing and 2 partials ⚠️
dataRetriever/dataPool/proofsCache/proofsPool.go 0.00% 0 Missing and 1 partial ⚠️
process/block/baseProcess.go 0.00% 0 Missing and 1 partial ⚠️
process/peer/process.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           feat/equivalent-messages    #6665      +/-   ##
============================================================
- Coverage                     78.82%   78.74%   -0.08%     
============================================================
  Files                           756      769      +13     
  Lines                         99946   101810    +1864     
============================================================
+ Hits                          78778    80167    +1389     
- Misses                        15872    16215     +343     
- Partials                       5296     5428     +132     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AdoAdoAdo AdoAdoAdo marked this pull request as ready for review December 16, 2024 14:53
if check.IfNil(headerHandler) {
return true
}
return headerHandler.GetPreviousProof() != nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return headerHandler.GetPreviousProof() != nil
return !check.IfNilReflect(headerHandler.GetPreviousProof())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, forgot the Get was returning an interface not a pointer to the proof

@@ -535,6 +545,13 @@ func (sr *subroundBlock) receivedBlockHeader(ctx context.Context, cnsDta *consen
return blockProcessedWithSuccess
}

func headerHasProof(headerHandler data.HeaderHandler) bool {
if check.IfNil(headerHandler) {
return true
Copy link
Collaborator

Choose a reason for hiding this comment

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

return true to force return false on the main methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meant to return false

@@ -69,6 +71,8 @@ func TestConsensusWithInvalidSigners(t *testing.T) {
t.Skip("this is not a short test")
}

_ = logger.SetLogLevel("*:DEBUG")
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, forgot this

@@ -103,7 +107,7 @@ func TestConsensusWithInvalidSigners(t *testing.T) {
go checkBlockProposedEveryRound(numCommBlock, nonceForRoundMap, mutex, chDone, t)

extraTime := uint64(2)
endTime := time.Duration(roundTime)*time.Duration(numCommBlock+extraTime)*time.Millisecond + time.Minute
endTime := time.Duration(roundTime)*time.Duration(numCommBlock+extraTime)*time.Millisecond + 10*time.Minute
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to extend end time so much?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgot it, used while debugging

@ssd04 ssd04 merged commit d7089a9 into feat/equivalent-messages Dec 16, 2024
5 checks passed
@ssd04 ssd04 deleted the fixes-header-sig-verification branch December 16, 2024 16:15
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.

3 participants