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

IBFT 2.1 Message rework, piggybacking blocks on msgs. #769

Merged
merged 16 commits into from
Feb 8, 2019

Conversation

rain-on
Copy link
Contributor

@rain-on rain-on commented Feb 5, 2019

No description provided.

@rain-on rain-on requested review from jframe and CjHare February 5, 2019 02:11
@rain-on
Copy link
Contributor Author

rain-on commented Feb 5, 2019

RoundCHangeMessageValidator does not validate block vs proposal (As per NewRound).
[Now resolved]

@rain-on
Copy link
Contributor Author

rain-on commented Feb 5, 2019

  • Do we need to fully validate a block on reception of a RoundChange message? or only Proposal/NewRound?
  • Why don't we check the block number against the sequence number?

@rain-on
Copy link
Contributor Author

rain-on commented Feb 5, 2019

  • Move Block Validation out of ProposalBlockConsistencyChecker, and put it in the Message Validator(s).
    [Now Resolved]

@rain-on
Copy link
Contributor Author

rain-on commented Feb 5, 2019

  • Can we merge *MessageData with correlated MessageWrapper?

private static final Logger LOG = LogManager.getLogger();

private final RoundChangePayloadValidator signedDataValidator;
private final ProposalBlockConsistencyValidator proposalBlockConsistencyChecker;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

checker to validator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

}
}
}
if (!newestRoundChange.isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

try

Optional<Block> proposedBlock = newestRoundChange.flatMap(RoundChange::getProposedBlock);
return new RoundChangeArtifacts(proposedBlock, payloads);

@@ -47,16 +48,35 @@ public RoundChangeCertificate getRoundChangeCertificate() {
public static RoundChangeArtifacts create(final Collection<RoundChange> roundChanges) {

final Collection<SignedData<RoundChangePayload>> payloads =
Copy link
Contributor

Choose a reason for hiding this comment

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

can there be a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added.

.collect(Collectors.toList());
roundChanges.stream().map(RoundChange::getSignedPayload).collect(Collectors.toList());

Optional<RoundChange> newestRoundChange = empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

you could probably use max or min change your compareNewRound to return an int so can be used as a comparator.

Something like

 Optional<RoundChange> newestRoundChange = roundChanges.stream().max(RoundChangeArtifacts::compareNewRound);
...
private static int compareNewRound(
      final RoundChange first, final RoundChange second) {
    final PreparedCertificate firstCert = first.getPreparedCertificate().get();
    final PreparedCertificate secondCert = second.getPreparedCertificate().get();
    return Integer.compare(secondCert.getProposalPayload().getPayload().getRoundIdentifier().getRoundNumber(),
        firstCert.getProposalPayload().getPayload().getRoundIdentifier().getRoundNumber());
  }

}

if (proposedBlock.getHeader().getNumber()
!= signedPayload.getPayload().getRoundIdentifier().getRoundNumber()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks like it's comparing the chain height to the round number instead of the sequence number

Copy link
Contributor Author

@rain-on rain-on Feb 7, 2019

Choose a reason for hiding this comment

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

Ooops - now corrected.

@rain-on rain-on merged commit c044749 into PegaSysEng:master Feb 8, 2019
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