Skip to content

Commit

Permalink
fix: only compare child time created against self parent time created… (
Browse files Browse the repository at this point in the history
#11673)

Signed-off-by: Austin Littley <[email protected]>
  • Loading branch information
litt3 authored Feb 22, 2024
1 parent 6d5348f commit 191fdc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,15 @@ private EventImpl getParentToLink(
candidateParent.getBaseEvent().getHashedData().getTimeCreated();
final Instant childTimeCreated = child.getHashedData().getTimeCreated();

if (parentTimeCreated.compareTo(childTimeCreated) >= 0) {
// only do this check for self parent, since the event creator doesn't consider other parent creation time
// when deciding on the event creation time
if (parentDescriptor.getCreator().equals(child.getDescriptor().getCreator())
&& parentTimeCreated.compareTo(childTimeCreated) >= 0) {

timeCreatedMismatchAccumulator.update(1);
timeCreatedMismatchLogger.warn(
timeCreatedMismatchLogger.error(
EXCEPTION.getMarker(),
"Child time created isn't strictly after parent time created. "
"Child time created isn't strictly after self parent time created. "
+ "Child: {}, parent: {}, child time created: {}, parent time created: {}",
EventStrings.toMediumString(child),
EventStrings.toMediumString(candidateParent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,15 @@ void selfParentTimeCreatedMismatch(final boolean useBirthRoundForAncient) {

@ParameterizedTest
@ValueSource(booleans = {true, false})
@DisplayName("Other parent with mismatched time created should not be linked")
@DisplayName("Other parent with mismatched time created should be linked")
void otherParentTimeCreatedMismatch(final boolean useBirthRoundForAncient) {
final AncientMode ancientMode =
useBirthRoundForAncient ? AncientMode.BIRTH_ROUND_THRESHOLD : AncientMode.GENERATION_THRESHOLD;
inOrderLinkerSetup(ancientMode);
final Hash lateParentHash = randomHash(random);
final long lateParentGeneration = 1;
final GossipEvent lateParent = generateMockEvent(
selfId,
otherId,
lateParentHash,
lateParentGeneration,
1,
Expand All @@ -568,7 +568,7 @@ void otherParentTimeCreatedMismatch(final boolean useBirthRoundForAncient) {
final EventImpl linkedEvent = inOrderLinker.linkEvent(child);
assertNotEquals(null, linkedEvent);
assertNotEquals(null, linkedEvent.getSelfParent(), "Self parent should not be null");
assertNull(linkedEvent.getOtherParent(), "Other parent has mismatched time created, and should be null");
assertNotEquals(null, linkedEvent.getOtherParent(), "Other parent should not be null");
assertEquals(0, exitedIntakePipelineCount.get());
}
}

0 comments on commit 191fdc4

Please sign in to comment.