Skip to content

Commit c8fad43

Browse files
authored
feat: Remove getOtherId (#12465)
Signed-off-by: Austin Littley <[email protected]>
1 parent f500423 commit c8fad43

File tree

8 files changed

+45
-32
lines changed

8 files changed

+45
-32
lines changed

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/EventStringBuilder.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ public EventStringBuilder appendOtherParent() {
102102
return this;
103103
}
104104
sb.append(" op");
105-
appendShortEvent(unhashedData.getOtherId(), hashedData.getOtherParentGen(), hashedData.getOtherParentHash());
105+
106+
final NodeId otherParentId;
107+
if (hashedData.hasOtherParent()) {
108+
otherParentId = hashedData.getOtherParents().getFirst().getCreator();
109+
} else {
110+
otherParentId = null;
111+
}
112+
113+
appendShortEvent(otherParentId, hashedData.getOtherParentGen(), hashedData.getOtherParentHash());
106114
return this;
107115
}
108116

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/internal/EventImpl.java

-7
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,6 @@ public Instant getConsensusTimestamp() {
521521
return consensusData.getConsensusTimestamp();
522522
}
523523

524-
/** {@inheritDoc} */
525-
@Override
526-
@Nullable
527-
public NodeId getOtherId() {
528-
return baseEvent.getUnhashedData().getOtherId();
529-
}
530-
531524
/** {@inheritDoc} */
532525
@Override
533526
public long getGeneration() {

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/events/BaseEventUnhashedData.java

-10
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ public int getMinimumSupportedVersion() {
156156
return ClassVersion.ORIGINAL;
157157
}
158158

159-
/**
160-
* Get the other parent's NodeId
161-
*
162-
* @return the other parent's NodeId
163-
*/
164-
@Nullable
165-
public NodeId getOtherId() {
166-
return otherId;
167-
}
168-
169159
/**
170160
* Get the signature
171161
*

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/events/PlatformEvent.java

-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.swirlds.common.crypto.Hash;
2020
import com.swirlds.common.platform.NodeId;
21-
import edu.umd.cs.findbugs.annotations.Nullable;
2221
import java.time.Instant;
2322

2423
/**
@@ -62,14 +61,6 @@ public interface PlatformEvent extends ConsensusEvent {
6261
*/
6362
Instant getConsensusTimestamp();
6463

65-
/**
66-
* Node ID of the otherParent. null if otherParent doesn't exist.
67-
*
68-
* @return Other parent event's ID
69-
*/
70-
@Nullable
71-
NodeId getOtherId();
72-
7364
/**
7465
* This event's parent event. null if none exists.
7566
*

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/components/appcomm/LatestCompleteStateNotifierTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.swirlds.platform.components.appcomm;
1818

1919
import static com.swirlds.common.test.fixtures.AssertionUtils.assertEventuallyEquals;
20+
import static com.swirlds.common.test.fixtures.junit.tags.TestQualifierTags.TIMING_SENSITIVE;
2021
import static com.swirlds.common.threading.manager.AdHocThreadManager.getStaticThreadManager;
2122
import static org.assertj.core.api.Assertions.assertThat;
2223
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -32,11 +33,13 @@
3233
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.atomic.AtomicInteger;
3435
import org.junit.jupiter.api.DisplayName;
36+
import org.junit.jupiter.api.Tag;
3537
import org.junit.jupiter.api.Test;
3638

3739
/**
3840
* Basic sanity check tests for the {@link DefaultLatestCompleteStateNotifier} class
3941
*/
42+
@Tag(TIMING_SENSITIVE)
4043
public class LatestCompleteStateNotifierTests {
4144

4245
@Test

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/event/orphan/OrphanBufferTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ private static GossipEvent createGossipEvent(
158158
.thenReturn(otherParent == null ? Collections.emptyList() : Collections.singletonList(otherParent));
159159

160160
final BaseEventUnhashedData unhashedData = mock(BaseEventUnhashedData.class);
161-
when(unhashedData.getOtherId()).thenReturn(otherParent.getCreator());
162161

163162
final GossipEvent event = mock(GossipEvent.class);
164163
when(event.getHashedData()).thenReturn(hashedData);

platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/consensus/GraphGeneratorTests.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,18 @@ protected void verifyExpectedOtherParentRatio(
182182

183183
int count = 0;
184184
for (final IndexedEvent event : events) {
185-
if (Objects.equals(event.getOtherId(), nodeId)) {
185+
final NodeId otherParentId;
186+
if (event.getBaseEvent().getHashedData().getOtherParents().isEmpty()) {
187+
otherParentId = null;
188+
} else {
189+
otherParentId = event.getBaseEvent()
190+
.getHashedData()
191+
.getOtherParents()
192+
.getFirst()
193+
.getCreator();
194+
}
195+
196+
if (Objects.equals(otherParentId, nodeId)) {
186197
count++;
187198
}
188199
}

platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/tipset/TipsetEventCreatorTests.java

+21-3
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,13 @@ void zeroWeightNodeTest(final boolean advancingClock, final boolean useBirthRoun
616616
}
617617
atLeastOneEventCreated = true;
618618

619-
final NodeId otherId = event.getUnhashedData().getOtherId();
619+
final NodeId otherId;
620+
if (event.getHashedData().hasOtherParent()) {
621+
otherId = event.getHashedData().getOtherParents().getFirst().getCreator();
622+
} else {
623+
otherId = null;
624+
}
625+
620626
if (otherId != null && otherId.equals(zeroWeightNode)) {
621627
zeroWeightNodeOtherParentCount++;
622628
}
@@ -707,7 +713,13 @@ void zeroWeightSlowNodeTest(final boolean advancingClock, final boolean useBirth
707713
}
708714
atLeastOneEventCreated = true;
709715

710-
final NodeId otherId = event.getUnhashedData().getOtherId();
716+
final NodeId otherId;
717+
if (event.getHashedData().hasOtherParent()) {
718+
otherId = event.getHashedData().getOtherParents().getFirst().getCreator();
719+
} else {
720+
otherId = null;
721+
}
722+
711723
if (otherId != null && otherId.equals(zeroWeightNode)) {
712724
zeroWeightNodeOtherParentCount++;
713725
}
@@ -885,7 +897,13 @@ void frozenEventCreationBug() {
885897
// Create an event from one of the other nodes that was updated in the previous snapshot,
886898
// but has not been updated in the current snapshot.
887899

888-
final NodeId otherParentId = eventA2.getUnhashedData().getOtherId();
900+
final NodeId otherParentId;
901+
if (eventA2.getHashedData().hasOtherParent()) {
902+
otherParentId = eventA2.getHashedData().getOtherParents().getFirst().getCreator();
903+
} else {
904+
otherParentId = null;
905+
}
906+
889907
final GossipEvent legalOtherParent = createTestEvent(random, otherParentId, 0, nodeA, 0);
890908

891909
eventCreator.registerEvent(legalOtherParent);

0 commit comments

Comments
 (0)