-
Notifications
You must be signed in to change notification settings - Fork 0
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
Audit #10
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for going through the audit and remedying the implementation 🙏
There are some points which need to be resolved before we proceed with merging, and issues that need to be implemented (Issue N
), otherwise it looks good 💯
|
||
round1ProposalMsg *proto.Message | ||
|
||
round0Proposer = []byte("round 0 proposer") |
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.
This is the only value that is shared in the test (checked against the proposal), the rest (below) are only used to initialize fields.
Please inline them where they are used
backend mockBackend | ||
transport mockTransport | ||
msgs mockMessages | ||
|
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.
Why not define the handlers here in-line?
It's much cleaner, and more in line with our other tests
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.
Inlined
return bytes.Equal(maxRoundProposalHash, messages.ExtractProposalHash(msg)) | ||
} | ||
|
||
func (i *IBFT) validateRoundChangeCertificate( |
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.
Why return an error from this method, if you're only using it as a boolean value anyways?
Not to mention that the error is not checked anywhere (typed) specifically
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.
Added a log line to display the error in question when validating an RCC
if len(certificate.RoundChangeMessages) < int(i.backend.Quorum(height)) { | ||
return false | ||
if len(certificate.RoundChangeMessages) < int(i.backend.Quorum(view.Height)) { | ||
return fmt.Errorf("no quorum round change messages in certificate: expected=%d actual=%d", |
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.
Where are these errors checked?
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.
See above
core/ibft_test.go
Outdated
if bytes.Equal(from, []byte("unique node")) { | ||
return true | ||
} | ||
|
||
return false |
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.
You can simplify this to
return bytes.Equal(from, []byte("unique node"))
core/ibft_test.go
Outdated
//nolint | ||
msg.Payload.(*proto.Message_RoundChangeData).RoundChangeData.LastPreparedProposedBlock = &proto.ProposedBlock{ | ||
Block: lastPreparedProposedBlock, | ||
Round: 0, | ||
} | ||
//nolint |
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.
Please resolve these linting errors instead of specifying //nolint
core/ibft_test.go
Outdated
//nolint | ||
msg.Payload.(*proto.Message_RoundChangeData).RoundChangeData.LastPreparedProposedBlock = &proto.ProposedBlock{ | ||
Block: round1PreparedProposedBlock, | ||
Round: 1, | ||
} | ||
//nolint |
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.
Please resolve these linting errors instead of specifying //nolint
core/ibft_test.go
Outdated
//nolint | ||
someRCMsg.Payload.(*proto.Message_RoundChangeData).RoundChangeData.LastPreparedProposedBlock = &proto.ProposedBlock{ | ||
Block: round1PreparedProposedBlock, | ||
Round: 1, | ||
} | ||
//nolint |
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.
Please resolve these linting errors instead of specifying //nolint
messages/proto/messages.proto
Outdated
@@ -46,7 +46,7 @@ message Message { | |||
// PrePrepareMessage is the message for the PREPREPARE phase | |||
message PrePrepareMessage { | |||
// proposal is the actual data being proposed for consensus | |||
bytes proposal = 1; | |||
ProposedBlock proposal = 1; |
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.
Why not change the Backend
interface to also accept the round number, or the new proto type?
This concern is outlined in Issue G
, and it can be resolved by this.
This is the method I'm talking about:
// InsertBlock inserts a proposal with the specified committed seals
InsertBlock(proposal []byte, committedSeals []*messages.CommittedSeal)
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.
Refactored
@@ -623,7 +626,7 @@ func (i *IBFT) validateProposal0(msg *proto.Message, view *proto.View) bool { | |||
) | |||
|
|||
// proposal must be for round 0 | |||
if msg.View.Round != 0 { | |||
if messages.ExtractProposal(msg).Round != 0 { |
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.
Unrelated to this check here, but wanted to point out an additional check is missing (both from the pseudocode and the implementation), and it is referenced as part of Issue N
:
There is no check that the r_pp
from the round change message matches the round from the proposal message (r_EB
), and this check is required for this to be safe.
Please implement this, along with a coverage test
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.
Added the check in a03cc81
The check is already triggered with existing tests effectively bypassing subsequent checks triggered by the other cases (mostly due to how messages are generated with test helpers)
The testing suite has been greatly improved in v2 branch, so I won't be amending the cases present on this one
Description
Fixed (most) issues reported by the audit.
Skipped issues: I, J, K, L, M
Changes include
Breaking changes
Certain proto types changed field type from
[]byte
toProposedBlock
Checklist