Skip to content

Commit ea6486d

Browse files
authored
chore: Implemented migration with Turtle framework (#18902)
Signed-off-by: Michael Heinrichs <[email protected]>
1 parent e6f7185 commit ea6486d

File tree

8 files changed

+53
-7
lines changed

8 files changed

+53
-7
lines changed

platform-sdk/consensus-otter-tests/src/test/java/org/hiero/otter/test/BirthRoundMigrationTest.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package org.hiero.otter.test;
33

4+
import static org.hiero.otter.fixtures.turtle.TurtleNodeConfiguration.SOFTWARE_VERSION;
5+
46
import java.time.Duration;
57
import org.hiero.consensus.config.EventConfig_;
68
import org.hiero.otter.fixtures.Network;
@@ -15,6 +17,9 @@ class BirthRoundMigrationTest {
1517
private static final Duration THIRTY_SECONDS = Duration.ofSeconds(30L);
1618
private static final Duration ONE_MINUTE = Duration.ofMinutes(1L);
1719

20+
private static final String OLD_VERSION = "1.0.0";
21+
private static final String NEW_VERSION = "1.0.1";
22+
1823
@OtterTest
1924
@Disabled
2025
void testBirthRoundMigration(TestEnvironment env) throws InterruptedException {
@@ -23,6 +28,9 @@ void testBirthRoundMigration(TestEnvironment env) throws InterruptedException {
2328

2429
// Setup simulation
2530
network.addNodes(4);
31+
for (final Node node : network.getNodes()) {
32+
node.getConfiguration().set(SOFTWARE_VERSION, OLD_VERSION);
33+
}
2634
network.start(ONE_MINUTE);
2735
env.generator().start();
2836

@@ -35,7 +43,9 @@ void testBirthRoundMigration(TestEnvironment env) throws InterruptedException {
3543

3644
// update the configuration
3745
for (final Node node : network.getNodes()) {
38-
node.getConfiguration().set(EventConfig_.USE_BIRTH_ROUND_ANCIENT_THRESHOLD, true);
46+
node.getConfiguration()
47+
.set(EventConfig_.USE_BIRTH_ROUND_ANCIENT_THRESHOLD, true)
48+
.set(SOFTWARE_VERSION, NEW_VERSION);
3949
}
4050

4151
// restart the network

platform-sdk/consensus-otter-tests/src/testFixtures/java/module-info.java

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
requires transitive com.swirlds.platform.core;
66
requires transitive org.apache.logging.log4j.core;
77
requires transitive org.junit.jupiter.api;
8+
requires com.hedera.node.config;
89
requires com.hedera.node.hapi;
910
requires com.hedera.pbj.runtime;
1011
requires com.swirlds.base.test.fixtures;

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/NodeConfiguration.java

+9
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ public interface NodeConfiguration<T extends NodeConfiguration> {
1717
* @return this {@code NodeConfiguration} instance for method chaining
1818
*/
1919
T set(@NonNull String key, boolean value);
20+
21+
/**
22+
* Updates a single property of the configuration.
23+
*
24+
* @param key the key of the property
25+
* @param value the value of the property
26+
* @return this {@code NodeConfiguration} instance for method chaining
27+
*/
28+
T set(@NonNull String key, @NonNull String value);
2029
}

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/turtle/TurtleApp.java

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.hiero.consensus.model.hashgraph.Round;
2424
import org.hiero.consensus.model.transaction.ScopedSystemTransaction;
2525

26+
@SuppressWarnings("removal")
2627
public enum TurtleApp implements ConsensusStateEventHandler<TurtleTestingToolState> {
2728
INSTANCE;
2829

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/turtle/TurtleNode.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@
5959
*
6060
* <p>This class implements the {@link Node} interface and provides methods to control the state of the node.
6161
*/
62+
@SuppressWarnings("removal")
6263
public class TurtleNode implements Node, TurtleTimeManager.TimeTickReceiver {
6364

65+
private static final SemanticVersion DEFAULT_VERSION =
66+
SemanticVersion.newBuilder().major(1).build();
67+
6468
public static final String THREAD_CONTEXT_NODE_ID = "nodeId";
6569
private static final Logger log = LogManager.getLogger(TurtleNode.class);
6670

@@ -294,7 +298,8 @@ private void doStartNode() {
294298
model = WiringModelBuilder.create(platformContext.getMetrics(), time)
295299
.withDeterministicModeEnabled(true)
296300
.build();
297-
final SemanticVersion version = SemanticVersion.newBuilder().major(1).build();
301+
final SemanticVersion version = currentConfiguration.getValue(
302+
TurtleNodeConfiguration.SOFTWARE_VERSION, SemanticVersion.class, DEFAULT_VERSION);
298303
final PlatformStateFacade platformStateFacade = new PlatformStateFacade();
299304
MerkleDb.resetDefaultInstancePath();
300305
final Metrics metrics = getMetricsProvider().createPlatformMetrics(selfId);

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/turtle/TurtleNodeConfiguration.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33

44
import static java.util.Objects.requireNonNull;
55

6+
import com.hedera.hapi.node.base.SemanticVersion;
7+
import com.hedera.node.config.converter.SemanticVersionConverter;
68
import com.swirlds.common.config.StateCommonConfig_;
79
import com.swirlds.common.io.config.FileSystemManagerConfig_;
810
import com.swirlds.config.api.Configuration;
911
import com.swirlds.config.extensions.sources.SimpleConfigSource;
1012
import com.swirlds.config.extensions.test.fixtures.TestConfigBuilder;
1113
import com.swirlds.platform.config.BasicConfig_;
14+
import com.swirlds.platform.event.preconsensus.PcesConfig_;
1215
import com.swirlds.platform.wiring.PlatformSchedulersConfig_;
1316
import edu.umd.cs.findbugs.annotations.NonNull;
1417
import java.nio.file.Path;
@@ -21,6 +24,8 @@
2124
*/
2225
public class TurtleNodeConfiguration implements NodeConfiguration<TurtleNodeConfiguration> {
2326

27+
public static final String SOFTWARE_VERSION = "turtle.software.version";
28+
2429
private final Map<String, String> overriddenProperties = new HashMap<>();
2530
private final Path outputDirectory;
2631

@@ -50,16 +55,28 @@ Configuration createConfiguration() {
5055
*/
5156
@Override
5257
@NonNull
53-
public TurtleNodeConfiguration set(@NonNull String key, boolean value) {
58+
public TurtleNodeConfiguration set(@NonNull final String key, final boolean value) {
5459
overriddenProperties.put(key, Boolean.toString(value));
5560
return this;
5661
}
5762

63+
/**
64+
* {@inheritDoc}
65+
*/
66+
@Override
67+
@NonNull
68+
public TurtleNodeConfiguration set(@NonNull final String key, @NonNull final String value) {
69+
overriddenProperties.put(key, value);
70+
return this;
71+
}
72+
5873
private TestConfigBuilder createBasicConfigBuilder() {
5974
return new TestConfigBuilder()
75+
.withConverter(SemanticVersion.class, new SemanticVersionConverter())
6076
.withValue(PlatformSchedulersConfig_.CONSENSUS_EVENT_STREAM, "NO_OP")
61-
.withValue(BasicConfig_.JVM_PAUSE_DETECTOR_SLEEP_MS, "0")
77+
.withValue(BasicConfig_.JVM_PAUSE_DETECTOR_SLEEP_MS, 0)
6278
.withValue(StateCommonConfig_.SAVED_STATE_DIRECTORY, outputDirectory.toString())
63-
.withValue(FileSystemManagerConfig_.ROOT_PATH, outputDirectory.toString());
79+
.withValue(FileSystemManagerConfig_.ROOT_PATH, outputDirectory.toString())
80+
.withValue(PcesConfig_.LIMIT_REPLAY_FREQUENCY, false);
6481
}
6582
}

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/turtle/TurtleTestEnvironment.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package org.hiero.otter.fixtures.turtle;
33

4+
import static com.swirlds.platform.test.fixtures.state.FakeConsensusStateEventHandler.registerMerkleStateRootClassIds;
5+
46
import com.swirlds.base.test.fixtures.time.FakeTime;
57
import com.swirlds.common.io.utility.FileUtils;
68
import com.swirlds.common.test.fixtures.Randotron;
@@ -82,6 +84,7 @@ public TurtleTestEnvironment() {
8284
final ConstructableRegistry registry = ConstructableRegistry.getInstance();
8385
registry.registerConstructables("org.hiero");
8486
registry.registerConstructables("com.swirlds");
87+
registerMerkleStateRootClassIds();
8588
} catch (final ConstructableRegistryException e) {
8689
throw new RuntimeException(e);
8790
}

platform-sdk/swirlds-component-framework/src/main/java/com/swirlds/component/framework/model/internal/deterministic/DeterministicHeartbeatScheduler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class DeterministicHeartbeatScheduler extends AbstractHeartbeatScheduler
3535
* Constructor.
3636
*
3737
* @param model the wiring model containing this heartbeat scheduler
38-
* @param time provides wall clock time
39-
* @param name the name of the heartbeat scheduler
38+
* @param time provides wall clock time
39+
* @param name the name of the heartbeat scheduler
4040
*/
4141
public DeterministicHeartbeatScheduler(
4242
@NonNull final TraceableWiringModel model, @NonNull final Time time, @NonNull final String name) {

0 commit comments

Comments
 (0)