Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

NewRoundMessageValidator ignores Round Number when comparing blocks #523

Merged
merged 7 commits into from
Jan 9, 2019

Conversation

rain-on
Copy link
Contributor

@rain-on rain-on commented Jan 7, 2019

NewRoundMessageValidator previously ensured the block in the newest
PreparedCertificate was the same as that in the Proposal by comparing
block hashes.
However, the hash-function for received IBFT blocks includes round
number - thus the blocks will never be deemed 'equal'.

As such, the blocks must be compared using a hash function which
ignores the round number - i.e. the OnChain function.

PR description

Fixed Issue(s)

NewRoundMessageValidator previously ensured the block in the newest
PreparedCertificate was the same as that in the Proposal by comparing
block hashes.
However, the hash-function for received IBFT blocks includes round
number - thus the blocks will never be deemed 'equal'.

As such, the blocks must be compared using a hash function which
ignores the round number - i.e. the OnChain function.
@@ -289,4 +268,25 @@ public void lastestPreparedCertificateMatchesNewRoundProposalIsSuccessful() {

assertThat(validator.validateNewRoundMessage(msg)).isTrue();
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the name for the this test and the added comments referring to failing validation, should this assertion be a isFalse() rather than isTrue()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like this test is proving the successful case when we have multiple PrepareCertificates, so ATM, I think its correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, in GitHub interface I'd assumed choosing to expand the collapsed section fully expanded ...turns out multiple clicks were needed, the isTrue() is in the succeed test, not the fail test.

@rain-on rain-on merged commit fbd933f into PegaSysEng:master Jan 9, 2019
@rain-on rain-on deleted the new_round_hash branch January 16, 2019 21:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants