From 191fdc4a98e090ba74f5df2e70daf3c6e2a8021c Mon Sep 17 00:00:00 2001 From: Austin Littley <102969658+alittley@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:24:17 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20only=20compare=20child=20time=20created?= =?UTF-8?q?=20against=20self=20parent=20time=20created=E2=80=A6=20(#11673)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Austin Littley --- .../swirlds/platform/event/linking/InOrderLinker.java | 10 +++++++--- .../platform/event/linking/InOrderLinkerTests.java | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/linking/InOrderLinker.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/linking/InOrderLinker.java index 828818e6a770..b27ff60c3297 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/linking/InOrderLinker.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/linking/InOrderLinker.java @@ -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), diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/event/linking/InOrderLinkerTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/event/linking/InOrderLinkerTests.java index a83e09580ca4..fb37a72acbbf 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/event/linking/InOrderLinkerTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/event/linking/InOrderLinkerTests.java @@ -539,7 +539,7 @@ 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; @@ -547,7 +547,7 @@ void otherParentTimeCreatedMismatch(final boolean useBirthRoundForAncient) { final Hash lateParentHash = randomHash(random); final long lateParentGeneration = 1; final GossipEvent lateParent = generateMockEvent( - selfId, + otherId, lateParentHash, lateParentGeneration, 1, @@ -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()); } }