-
Notifications
You must be signed in to change notification settings - Fork 130
IBFT 2.1 Message rework, piggybacking blocks on msgs. #769
Conversation
RoundCHangeMessageValidator does not validate block vs proposal (As per NewRound). |
|
|
|
...sus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/MessageValidator.java
Outdated
Show resolved
Hide resolved
consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/MessageFactory.java
Outdated
Show resolved
Hide resolved
...ft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java
Show resolved
Hide resolved
...ft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java
Show resolved
Hide resolved
.../src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundMessageValidator.java
Outdated
Show resolved
Hide resolved
.../src/main/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundMessageValidator.java
Outdated
Show resolved
Hide resolved
.../java/tech/pegasys/pantheon/consensus/ibft/validation/ProposalBlockConsistencyValidator.java
Show resolved
Hide resolved
.../java/tech/pegasys/pantheon/consensus/ibft/validation/ProposalBlockConsistencyValidator.java
Show resolved
Hide resolved
private static final Logger LOG = LogManager.getLogger(); | ||
|
||
private final RoundChangePayloadValidator signedDataValidator; | ||
private final ProposalBlockConsistencyValidator proposalBlockConsistencyChecker; |
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.
checker to validator.
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.
done.
consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRound.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
} | ||
if (!newestRoundChange.isPresent()) { |
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.
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 = |
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.
can there be a test for this?
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.
.collect(Collectors.toList()); | ||
roundChanges.stream().map(RoundChange::getSignedPayload).collect(Collectors.toList()); | ||
|
||
Optional<RoundChange> newestRoundChange = empty(); |
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 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()) { |
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 looks like it's comparing the chain height to the round number instead of the sequence number
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.
Ooops - now corrected.
No description provided.