From 83988662ff8810102e529927e6d0963159a3954e Mon Sep 17 00:00:00 2001
From: timfn-hg
Date: Fri, 20 Dec 2024 10:27:59 -0600
Subject: [PATCH 01/13] chore: refactor DefaultIssDetector to use rosters
(#17141)
Signed-off-by: Tim Farber-Newman
---
.../builder/PlatformComponentBuilder.java | 20 ++-
.../swirlds/platform/metrics/IssMetrics.java | 21 ++--
.../state/iss/DefaultIssDetector.java | 27 ++--
.../platform/test/state/IssDetectorTests.java | 104 +++++++--------
.../platform/test/state/IssMetricsTests.java | 74 +++++------
.../test/state/RoundHashValidatorTests.java | 119 +++++++++---------
6 files changed, 198 insertions(+), 167 deletions(-)
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java
index de3262924a35..eefe64b3d020 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/builder/PlatformComponentBuilder.java
@@ -1,10 +1,24 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.swirlds.platform.builder;
import static com.swirlds.platform.builder.internal.StaticPlatformBuilder.getGlobalMetrics;
import static com.swirlds.platform.builder.internal.StaticPlatformBuilder.getMetricsProvider;
import static com.swirlds.platform.gui.internal.BrowserWindowManager.getPlatforms;
-import static com.swirlds.platform.roster.RosterUtils.buildAddressBook;
import static com.swirlds.platform.state.iss.IssDetector.DO_NOT_IGNORE_ROUNDS;
import com.swirlds.common.merkle.utility.SerializableLong;
@@ -876,7 +890,7 @@ public IssDetector buildIssDetector() {
issDetector = new DefaultIssDetector(
blocks.platformContext(),
- buildAddressBook(blocks.rosterHistory().getCurrentRoster()),
+ blocks.rosterHistory().getCurrentRoster(),
blocks.appVersion().getPbjSemanticVersion(),
ignorePreconsensusSignatures,
roundToIgnore);
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/IssMetrics.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/IssMetrics.java
index 311d7f16efef..773e184e3b77 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/IssMetrics.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/IssMetrics.java
@@ -16,13 +16,14 @@
package com.swirlds.platform.metrics;
+import com.hedera.hapi.node.state.roster.Roster;
+import com.hedera.hapi.node.state.roster.RosterEntry;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.platform.NodeId;
import com.swirlds.metrics.api.IntegerGauge;
import com.swirlds.metrics.api.LongGauge;
import com.swirlds.metrics.api.Metrics;
-import com.swirlds.platform.system.address.Address;
-import com.swirlds.platform.system.address.AddressBook;
+import com.swirlds.platform.roster.RosterUtils;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.HashMap;
import java.util.Map;
@@ -33,7 +34,7 @@
*/
public class IssMetrics {
- private final AddressBook addressBook;
+ private final Roster roster;
/**
* The current number of nodes experiencing an ISS.
@@ -109,9 +110,9 @@ public void setRound(final long round) {
* @throws IllegalArgumentException
* if {@code metrics} is {@code null}
*/
- public IssMetrics(@NonNull final Metrics metrics, @NonNull final AddressBook addressBook) {
+ public IssMetrics(@NonNull final Metrics metrics, @NonNull final Roster roster) {
Objects.requireNonNull(metrics, "metrics must not be null");
- this.addressBook = Objects.requireNonNull(addressBook, "addressBook must not be null");
+ this.roster = Objects.requireNonNull(roster, "roster must not be null");
issCountGauge = metrics.getOrCreate(new IntegerGauge.Config(Metrics.INTERNAL_CATEGORY, "issCount")
.withDescription("the number of nodes that currently disagree with the consensus hash"));
@@ -119,8 +120,8 @@ public IssMetrics(@NonNull final Metrics metrics, @NonNull final AddressBook add
issWeightGage = metrics.getOrCreate(new LongGauge.Config(Metrics.INTERNAL_CATEGORY, "issWeight")
.withDescription("the amount of weight tied up by ISS events"));
- for (final Address address : addressBook) {
- issDataByNode.put(address.getNodeId(), new IssStatus());
+ for (final RosterEntry node : roster.rosterEntries()) {
+ issDataByNode.put(NodeId.of(node.nodeId()), new IssStatus());
}
}
@@ -176,7 +177,7 @@ public void stateHashValidityObserver(
issStatus.setRound(round);
if (issStatus.hasIss() != hasIss) {
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = RosterUtils.getRosterEntry(roster, nodeId.id()).weight();
if (hasIss) {
issCount++;
issWeight += weight;
@@ -208,8 +209,8 @@ public void catastrophicIssObserver(final long round) {
status.setRound(round);
}
- issCount = addressBook.getSize();
- issWeight = addressBook.getTotalWeight();
+ issCount = roster.rosterEntries().size();
+ issWeight = RosterUtils.computeTotalWeight(roster);
issCountGauge.set(issCount);
issWeightGage.set(issWeight);
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/iss/DefaultIssDetector.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/iss/DefaultIssDetector.java
index 08f0cd191dc7..bcbedf51a00a 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/iss/DefaultIssDetector.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/iss/DefaultIssDetector.java
@@ -21,6 +21,8 @@
import static com.swirlds.logging.legacy.LogMarker.STATE_HASH;
import com.hedera.hapi.node.base.SemanticVersion;
+import com.hedera.hapi.node.state.roster.Roster;
+import com.hedera.hapi.node.state.roster.RosterEntry;
import com.hedera.hapi.platform.event.StateSignatureTransaction;
import com.swirlds.common.context.PlatformContext;
import com.swirlds.common.crypto.Hash;
@@ -31,13 +33,13 @@
import com.swirlds.platform.config.StateConfig;
import com.swirlds.platform.consensus.ConsensusConfig;
import com.swirlds.platform.metrics.IssMetrics;
+import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.sequence.map.ConcurrentSequenceMap;
import com.swirlds.platform.sequence.map.SequenceMap;
import com.swirlds.platform.state.iss.internal.ConsensusHashFinder;
import com.swirlds.platform.state.iss.internal.HashValidityStatus;
import com.swirlds.platform.state.iss.internal.RoundHashValidator;
import com.swirlds.platform.state.signed.ReservedSignedState;
-import com.swirlds.platform.system.address.AddressBook;
import com.swirlds.platform.system.state.notifications.IssNotification;
import com.swirlds.platform.system.state.notifications.IssNotification.IssType;
import com.swirlds.platform.util.MarkerFileWriter;
@@ -64,9 +66,9 @@ public class DefaultIssDetector implements IssDetector {
private long previousRound = -1;
/**
- * The address book of this network.
+ * The roster of this network.
*/
- private final AddressBook addressBook;
+ private final Roster roster;
/**
* The current software version
@@ -117,7 +119,7 @@ public class DefaultIssDetector implements IssDetector {
* Create an object that tracks reported hashes and detects ISS events.
*
* @param platformContext the platform context
- * @param addressBook the address book for the network
+ * @param roster the roster for the network
* @param currentSoftwareVersion the current software version
* @param ignorePreconsensusSignatures If true, ignore signatures from the preconsensus event stream, otherwise
* validate them like normal.
@@ -126,7 +128,7 @@ public class DefaultIssDetector implements IssDetector {
*/
public DefaultIssDetector(
@NonNull final PlatformContext platformContext,
- @NonNull final AddressBook addressBook,
+ @NonNull final Roster roster,
@NonNull final SemanticVersion currentSoftwareVersion,
final boolean ignorePreconsensusSignatures,
final long ignoredRound) {
@@ -142,7 +144,7 @@ public DefaultIssDetector(
selfIssRateLimiter = new RateLimiter(platformContext.getTime(), timeBetweenIssLogs);
catastrophicIssRateLimiter = new RateLimiter(platformContext.getTime(), timeBetweenIssLogs);
- this.addressBook = Objects.requireNonNull(addressBook);
+ this.roster = Objects.requireNonNull(roster);
this.currentSoftwareVersion = Objects.requireNonNull(currentSoftwareVersion);
this.roundData = new ConcurrentSequenceMap<>(
@@ -157,7 +159,7 @@ public DefaultIssDetector(
if (ignoredRound != DO_NOT_IGNORE_ROUNDS) {
logger.warn(STARTUP.getMarker(), "No ISS detection will be performed for round {}", ignoredRound);
}
- this.issMetrics = new IssMetrics(platformContext.getMetrics(), addressBook);
+ this.issMetrics = new IssMetrics(platformContext.getMetrics(), roster);
}
/**
@@ -214,7 +216,8 @@ private List shiftRoundDataWindow(final long roundNumber) {
previousRound = roundNumber;
- roundData.put(roundNumber, new RoundHashValidator(roundNumber, addressBook.getTotalWeight(), issMetrics));
+ roundData.put(
+ roundNumber, new RoundHashValidator(roundNumber, RosterUtils.computeTotalWeight(roster), issMetrics));
return removedRounds.stream()
.map(this::handleRemovedRound)
@@ -341,7 +344,9 @@ private IssNotification handlePostconsensusSignature(
return null;
}
- if (!addressBook.contains(signerId)) {
+ final RosterEntry node = RosterUtils.getRosterEntryOrNull(roster, signerId.id());
+
+ if (node == null) {
// we don't care about nodes not in the address book
return null;
}
@@ -351,8 +356,6 @@ private IssNotification handlePostconsensusSignature(
return null;
}
- final long nodeWeight = addressBook.getAddress(signerId).getWeight();
-
final RoundHashValidator roundValidator = roundData.get(signaturePayload.round());
if (roundValidator == null) {
// We are being asked to validate a signature from the far future or far past, or a round that has already
@@ -361,7 +364,7 @@ private IssNotification handlePostconsensusSignature(
}
final boolean decided =
- roundValidator.reportHashFromNetwork(signerId, nodeWeight, new Hash(signaturePayload.hash()));
+ roundValidator.reportHashFromNetwork(signerId, node.weight(), new Hash(signaturePayload.hash()));
if (decided) {
return checkValidity(roundValidator);
}
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java
index 7e75693d7691..38ad75bf149e 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java
@@ -30,6 +30,8 @@
import static org.mockito.Mockito.when;
import com.hedera.hapi.node.base.SemanticVersion;
+import com.hedera.hapi.node.state.roster.Roster;
+import com.hedera.hapi.node.state.roster.RosterEntry;
import com.hedera.hapi.platform.event.StateSignatureTransaction;
import com.hedera.pbj.runtime.OneOf;
import com.hedera.pbj.runtime.io.buffer.Bytes;
@@ -41,18 +43,17 @@
import com.swirlds.platform.consensus.ConsensusConfig;
import com.swirlds.platform.internal.ConsensusRound;
import com.swirlds.platform.internal.EventImpl;
+import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.iss.DefaultIssDetector;
import com.swirlds.platform.state.iss.IssDetector;
import com.swirlds.platform.state.iss.internal.HashValidityStatus;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
-import com.swirlds.platform.system.address.Address;
-import com.swirlds.platform.system.address.AddressBook;
import com.swirlds.platform.system.state.notifications.IssNotification;
import com.swirlds.platform.system.state.notifications.IssNotification.IssType;
import com.swirlds.platform.test.PlatformTest;
-import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder;
+import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
import com.swirlds.platform.test.fixtures.event.EventImplTestUtils;
import com.swirlds.platform.test.fixtures.event.TestingEventBuilder;
import com.swirlds.platform.wiring.components.StateAndRound;
@@ -62,6 +63,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Random;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -108,20 +110,21 @@ private static List generateEventsContainingSignatures(
* consistent hash.
*
* @param random a source of randomness
- * @param addressBook the address book to use to generate the signature transactions
+ * @param roster the roster to use to generate the signature transactions
* @param roundNumber the round that signature transactions will be for
* @param roundHash the hash that all signature transactions will be made on
* @return a list of events, each containing a signature transaction from a node for the given round
*/
private static List generateEventsWithConsistentSignatures(
@NonNull final Randotron random,
- @NonNull final AddressBook addressBook,
+ @NonNull final Roster roster,
final long roundNumber,
@NonNull final Hash roundHash) {
final List nodeHashInfos = new ArrayList<>();
- addressBook.forEach(address -> nodeHashInfos.add(
- new RoundHashValidatorTests.NodeHashInfo(address.getNodeId(), roundHash, roundNumber)));
+ roster.rosterEntries()
+ .forEach(node -> nodeHashInfos.add(
+ new RoundHashValidatorTests.NodeHashInfo(NodeId.of(node.nodeId()), roundHash, roundNumber)));
// create signature transactions for this round
return generateEventsContainingSignatures(
@@ -172,7 +175,7 @@ private static ConsensusRound createRoundWithSignatureEvents(
@DisplayName("No ISSes Test")
void noIss() {
final Randotron random = Randotron.create();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(100)
.withAverageWeight(100)
.withWeightStandardDeviation(50)
@@ -180,8 +183,8 @@ void noIss() {
final PlatformContext platformContext = createDefaultPlatformContext();
- final IssDetector issDetector = new DefaultIssDetector(
- platformContext, addressBook, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
+ final IssDetector issDetector =
+ new DefaultIssDetector(platformContext, roster, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
final IssDetectorTestHelper issDetectorTestHelper = new IssDetectorTestHelper(issDetector);
// signature events are generated for each round when that round is handled, and then are included randomly
@@ -196,8 +199,7 @@ void noIss() {
final Hash roundHash = randomHash(random);
// create signature transactions for this round
- signatureEvents.addAll(
- generateEventsWithConsistentSignatures(random, addressBook, currentRound, roundHash));
+ signatureEvents.addAll(generateEventsWithConsistentSignatures(random, roster, currentRound, roundHash));
// randomly select half of unsubmitted signature events to include in this round
final List eventsToInclude = selectRandomEvents(random, signatureEvents);
@@ -238,7 +240,7 @@ void noIss() {
void mixedOrderTest() {
final Randotron random = Randotron.create();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
@@ -246,7 +248,7 @@ void mixedOrderTest() {
final PlatformContext platformContext = createDefaultPlatformContext();
- final NodeId selfId = addressBook.getNodeId(0);
+ final NodeId selfId = NodeId.of(roster.rosterEntries().getFirst().nodeId());
final int roundsNonAncient = platformContext
.getConfiguration()
.getConfigData(ConsensusConfig.class)
@@ -264,7 +266,7 @@ void mixedOrderTest() {
if (random.nextDouble() < 2.0 / 3) {
// Choose hashes so that there is a valid consensus hash
- data = generateRegularNodeHashes(random, addressBook, round);
+ data = generateRegularNodeHashes(random, roster, round);
HashValidityStatus expectedStatus = null;
@@ -288,7 +290,7 @@ void mixedOrderTest() {
expectedRoundStatus.add(expectedStatus);
} else {
// Choose hashes that will result in a catastrophic ISS
- data = generateCatastrophicNodeHashes(random, addressBook, round);
+ data = generateCatastrophicNodeHashes(random, roster, round);
roundData.add(data);
expectedRoundStatus.add(HashValidityStatus.CATASTROPHIC_ISS);
expectedCatastrophicIssCount++;
@@ -304,8 +306,8 @@ void mixedOrderTest() {
}
}
- final IssDetector issDetector = new DefaultIssDetector(
- platformContext, addressBook, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
+ final IssDetector issDetector =
+ new DefaultIssDetector(platformContext, roster, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
final IssDetectorTestHelper issDetectorTestHelper = new IssDetectorTestHelper(issDetector);
long currentRound = 0;
@@ -387,15 +389,15 @@ void decideForCatastrophicIss() {
final Randotron random = Randotron.create();
final PlatformContext platformContext = createDefaultPlatformContext();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(100)
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final NodeId selfId = addressBook.getNodeId(0);
+ final NodeId selfId = NodeId.of(roster.rosterEntries().getFirst().nodeId());
- final IssDetector issDetector = new DefaultIssDetector(
- platformContext, addressBook, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
+ final IssDetector issDetector =
+ new DefaultIssDetector(platformContext, roster, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
final IssDetectorTestHelper issDetectorTestHelper = new IssDetectorTestHelper(issDetector);
long currentRound = 0;
@@ -406,7 +408,7 @@ void decideForCatastrophicIss() {
// the round after the initial state will have a catastrophic iss
final RoundHashValidatorTests.HashGenerationData catastrophicHashData =
- generateCatastrophicNodeHashes(random, addressBook, currentRound);
+ generateCatastrophicNodeHashes(random, roster, currentRound);
final Hash selfHashForCatastrophicRound = catastrophicHashData.nodeList().stream()
.filter(info -> info.nodeId() == selfId)
.findFirst()
@@ -434,13 +436,15 @@ void decideForCatastrophicIss() {
mockState(currentRound, randomHash()), anotherRound, systemTransactionsForRoundWithoutSignatures));
}
+ final Map nodesById = RosterUtils.toMap(roster);
+
// submit signatures on the ISS round that represent a minority of the weight
long submittedWeight = 0;
final List signaturesToSubmit = new ArrayList<>();
for (final EventImpl signatureEvent : signaturesOnCatastrophicRound) {
final long weight =
- addressBook.getAddress(signatureEvent.getCreatorId()).getWeight();
- if (MAJORITY.isSatisfiedBy(submittedWeight + weight, addressBook.getTotalWeight())) {
+ nodesById.get(signatureEvent.getCreatorId().id()).weight();
+ if (MAJORITY.isSatisfiedBy(submittedWeight + weight, RosterUtils.computeTotalWeight(roster))) {
// If we add less than a majority then we won't be able to detect the ISS no matter what
break;
}
@@ -482,7 +486,7 @@ void decideForCatastrophicIss() {
* signatures being on an incorrect hash.
*/
private static List generateCatastrophicTimeoutIss(
- final Random random, final AddressBook addressBook, final long targetRound) {
+ final Random random, final Roster roster, final long targetRound) {
final List data = new LinkedList<>();
@@ -493,13 +497,13 @@ private static List generateCatastrophicTi
final Hash almostConsensusHash = randomHash(random);
long almostConsensusWeight = 0;
- for (final Address address : addressBook) {
- if (MAJORITY.isSatisfiedBy(almostConsensusWeight + address.getWeight(), addressBook.getTotalWeight())) {
- data.add(new RoundHashValidatorTests.NodeHashInfo(address.getNodeId(), randomHash(), targetRound));
+ for (final RosterEntry node : roster.rosterEntries()) {
+ final NodeId nodeId = NodeId.of(node.nodeId());
+ if (MAJORITY.isSatisfiedBy(almostConsensusWeight + node.weight(), RosterUtils.computeTotalWeight(roster))) {
+ data.add(new RoundHashValidatorTests.NodeHashInfo(nodeId, randomHash(), targetRound));
} else {
- almostConsensusWeight += address.getWeight();
- data.add(new RoundHashValidatorTests.NodeHashInfo(
- address.getNodeId(), almostConsensusHash, targetRound));
+ almostConsensusWeight += node.weight();
+ data.add(new RoundHashValidatorTests.NodeHashInfo(nodeId, almostConsensusHash, targetRound));
}
}
@@ -521,21 +525,21 @@ void catastrophicShiftBeforeCompleteTest() {
.getConfiguration()
.getConfigData(ConsensusConfig.class)
.roundsNonAncient();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(100)
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final NodeId selfId = addressBook.getNodeId(0);
+ final NodeId selfId = NodeId.of(roster.rosterEntries().getFirst().nodeId());
- final IssDetector issDetector = new DefaultIssDetector(
- platformContext, addressBook, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
+ final IssDetector issDetector =
+ new DefaultIssDetector(platformContext, roster, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
final IssDetectorTestHelper issDetectorTestHelper = new IssDetectorTestHelper(issDetector);
long currentRound = 0;
final List catastrophicData =
- generateCatastrophicTimeoutIss(random, addressBook, currentRound);
+ generateCatastrophicTimeoutIss(random, roster, currentRound);
final Hash selfHashForCatastrophicRound = catastrophicData.stream()
.filter(info -> info.nodeId() == selfId)
.findFirst()
@@ -544,18 +548,19 @@ void catastrophicShiftBeforeCompleteTest() {
final List signaturesOnCatastrophicRound = generateEventsContainingSignatures(
random, currentRound, new RoundHashValidatorTests.HashGenerationData(catastrophicData, null));
+ final Map nodesById = RosterUtils.toMap(roster);
long submittedWeight = 0;
final List signaturesToSubmit = new ArrayList<>();
for (final EventImpl signatureEvent : signaturesOnCatastrophicRound) {
final long weight =
- addressBook.getAddress(signatureEvent.getCreatorId()).getWeight();
+ nodesById.get(signatureEvent.getCreatorId().id()).weight();
signaturesToSubmit.add(signatureEvent);
// Stop once we have added >2/3. We should not have decided yet, but will
// have gathered enough to declare a catastrophic ISS
submittedWeight += weight;
- if (SUPER_MAJORITY.isSatisfiedBy(submittedWeight, addressBook.getTotalWeight())) {
+ if (SUPER_MAJORITY.isSatisfiedBy(submittedWeight, RosterUtils.computeTotalWeight(roster))) {
break;
}
}
@@ -619,15 +624,15 @@ void bigShiftTest() {
.getConfiguration()
.getConfigData(ConsensusConfig.class)
.roundsNonAncient();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(100)
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final NodeId selfId = addressBook.getNodeId(0);
+ final NodeId selfId = NodeId.of(roster.rosterEntries().getFirst().nodeId());
- final IssDetector issDetector = new DefaultIssDetector(
- platformContext, addressBook, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
+ final IssDetector issDetector =
+ new DefaultIssDetector(platformContext, roster, SemanticVersion.DEFAULT, false, DO_NOT_IGNORE_ROUNDS);
final IssDetectorTestHelper issDetectorTestHelper = new IssDetectorTestHelper(issDetector);
long currentRound = 0;
@@ -637,7 +642,7 @@ void bigShiftTest() {
currentRound++;
final List catastrophicData =
- generateCatastrophicTimeoutIss(random, addressBook, currentRound);
+ generateCatastrophicTimeoutIss(random, roster, currentRound);
final Hash selfHashForCatastrophicRound = catastrophicData.stream()
.filter(info -> info.nodeId() == selfId)
.findFirst()
@@ -656,17 +661,18 @@ void bigShiftTest() {
catastrophicRound,
systemTransactionsForCatastrophicRound));
+ final Map nodesById = RosterUtils.toMap(roster);
long submittedWeight = 0;
final List signaturesToSubmit = new ArrayList<>();
for (final EventImpl signatureEvent : signaturesOnCatastrophicRound) {
final long weight =
- addressBook.getAddress(signatureEvent.getCreatorId()).getWeight();
+ nodesById.get(signatureEvent.getCreatorId().id()).weight();
// Stop once we have added >2/3. We should not have decided yet, but will have gathered enough to declare a
// catastrophic ISS
submittedWeight += weight;
signaturesToSubmit.add(signatureEvent);
- if (SUPER_MAJORITY.isSatisfiedBy(submittedWeight + weight, addressBook.getTotalWeight())) {
+ if (SUPER_MAJORITY.isSatisfiedBy(submittedWeight + weight, RosterUtils.computeTotalWeight(roster))) {
break;
}
}
@@ -702,7 +708,7 @@ void bigShiftTest() {
void ignoredRoundTest() {
final Randotron random = Randotron.create();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(100)
.withAverageWeight(100)
.withWeightStandardDeviation(50)
@@ -715,7 +721,7 @@ void ignoredRoundTest() {
.roundsNonAncient();
final IssDetector issDetector =
- new DefaultIssDetector(platformContext, addressBook, SemanticVersion.DEFAULT, false, 1);
+ new DefaultIssDetector(platformContext, roster, SemanticVersion.DEFAULT, false, 1);
final IssDetectorTestHelper issDetectorTestHelper = new IssDetectorTestHelper(issDetector);
long currentRound = 0;
@@ -724,7 +730,7 @@ void ignoredRoundTest() {
currentRound++;
final List catastrophicData =
- generateCatastrophicTimeoutIss(random, addressBook, currentRound);
+ generateCatastrophicTimeoutIss(random, roster, currentRound);
final List signaturesOnCatastrophicRound = generateEventsContainingSignatures(
random, currentRound, new RoundHashValidatorTests.HashGenerationData(catastrophicData, null));
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssMetricsTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssMetricsTests.java
index e39406d869ff..8561e04e3eaf 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssMetricsTests.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssMetricsTests.java
@@ -21,14 +21,15 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import com.hedera.hapi.node.state.roster.Roster;
+import com.hedera.hapi.node.state.roster.RosterEntry;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.metrics.noop.NoOpMetrics;
import com.swirlds.common.platform.NodeId;
import com.swirlds.common.test.fixtures.Randotron;
import com.swirlds.platform.metrics.IssMetrics;
-import com.swirlds.platform.system.address.Address;
-import com.swirlds.platform.system.address.AddressBook;
-import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder;
+import com.swirlds.platform.roster.RosterUtils;
+import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
import java.util.Random;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -40,16 +41,16 @@ class IssMetricsTests {
@DisplayName("Update Non-Existent Node")
void updateNonExistentNode() {
final Randotron randotron = Randotron.create();
-
- final AddressBook addressBook =
- RandomAddressBookBuilder.create(randotron).withSize(100).build();
-
- final IssMetrics issMetrics = new IssMetrics(new NoOpMetrics(), addressBook);
+ final Roster roster =
+ RandomRosterBuilder.create(randotron).withSize(100).build();
+ final IssMetrics issMetrics = new IssMetrics(new NoOpMetrics(), roster);
+ final Hash hashA = randomHash();
+ final Hash hashB = randomHash();
+ final NodeId nodeId = NodeId.of(Integer.MAX_VALUE);
assertThrows(
IllegalArgumentException.class,
- () -> issMetrics.stateHashValidityObserver(
- 0L, NodeId.of(Integer.MAX_VALUE), randomHash(), randomHash()),
+ () -> issMetrics.stateHashValidityObserver(0L, nodeId, hashA, hashB),
"should not be able to update stats for non-existent node");
}
@@ -61,10 +62,9 @@ void updateTest() {
final Hash hashA = randomHash(random);
final Hash hashB = randomHash(random);
- final AddressBook addressBook =
- RandomAddressBookBuilder.create(random).withSize(100).build();
+ final Roster roster = RandomRosterBuilder.create(random).withSize(100).build();
- final IssMetrics issMetrics = new IssMetrics(new NoOpMetrics(), addressBook);
+ final IssMetrics issMetrics = new IssMetrics(new NoOpMetrics(), roster);
assertEquals(0, issMetrics.getIssCount(), "there shouldn't be any nodes in an ISS state");
assertEquals(0, issMetrics.getIssWeight(), "there shouldn't be any weight in an ISS state");
@@ -74,13 +74,14 @@ void updateTest() {
long expectedIssweight = 0;
// Change even numbered nodes to have an ISS
- for (final Address address : addressBook) {
- if (address.getNodeId().id() % 2 == 0) {
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hashB);
+ for (final RosterEntry node : roster.rosterEntries()) {
+ final NodeId nodeId = NodeId.of(node.nodeId());
+ if (node.nodeId() % 2 == 0) {
+ issMetrics.stateHashValidityObserver(round, nodeId, hashA, hashB);
expectedIssCount++;
- expectedIssweight += address.getWeight();
+ expectedIssweight += node.weight();
} else {
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hashA);
+ issMetrics.stateHashValidityObserver(round, nodeId, hashA, hashA);
}
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
@@ -88,38 +89,39 @@ void updateTest() {
// For the next round, report the same statuses. No change is expected.
round++;
- for (final Address address : addressBook) {
- final Hash hash = address.getNodeId().id() % 2 != 0 ? hashA : hashB;
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hash);
+ for (final RosterEntry node : roster.rosterEntries()) {
+ final Hash hash = node.nodeId() % 2 != 0 ? hashA : hashB;
+ issMetrics.stateHashValidityObserver(round, NodeId.of(node.nodeId()), hashA, hash);
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
}
// Report data from the same round number. This is expected to be ignored.
- for (final Address address : addressBook) {
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hashA);
+ for (final RosterEntry node : roster.rosterEntries()) {
+ issMetrics.stateHashValidityObserver(round, NodeId.of(node.nodeId()), hashA, hashA);
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
}
// Report data from a lower round number. This is expected to be ignored.
- for (final Address address : addressBook) {
- issMetrics.stateHashValidityObserver(round - 1, address.getNodeId(), hashA, hashA);
+ for (final RosterEntry node : roster.rosterEntries()) {
+ issMetrics.stateHashValidityObserver(round - 1, NodeId.of(node.nodeId()), hashA, hashA);
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
}
// Switch the status of each node.
round++;
- for (final Address address : addressBook) {
- if (address.getNodeId().id() % 2 == 0) {
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hashA);
+ for (final RosterEntry node : roster.rosterEntries()) {
+ final NodeId nodeId = NodeId.of(node.nodeId());
+ if (node.nodeId() % 2 == 0) {
+ issMetrics.stateHashValidityObserver(round, nodeId, hashA, hashA);
expectedIssCount--;
- expectedIssweight -= address.getWeight();
+ expectedIssweight -= node.weight();
} else {
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hashB);
+ issMetrics.stateHashValidityObserver(round, nodeId, hashA, hashB);
expectedIssCount++;
- expectedIssweight += address.getWeight();
+ expectedIssweight += node.weight();
}
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
@@ -133,17 +135,17 @@ void updateTest() {
// Report a catastrophic ISS.
round++;
issMetrics.catastrophicIssObserver(round);
- expectedIssCount = addressBook.getSize();
- expectedIssweight = addressBook.getTotalWeight();
+ expectedIssCount = roster.rosterEntries().size();
+ expectedIssweight = RosterUtils.computeTotalWeight(roster);
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
// Heal all nodes.
round++;
- for (final Address address : addressBook) {
- issMetrics.stateHashValidityObserver(round, address.getNodeId(), hashA, hashA);
+ for (final RosterEntry node : roster.rosterEntries()) {
+ issMetrics.stateHashValidityObserver(round, NodeId.of(node.nodeId()), hashA, hashA);
expectedIssCount--;
- expectedIssweight -= address.getWeight();
+ expectedIssweight -= node.weight();
assertEquals(expectedIssCount, issMetrics.getIssCount(), "unexpected ISS count");
assertEquals(expectedIssweight, issMetrics.getIssWeight(), "unexpected ISS weight");
}
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/RoundHashValidatorTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/RoundHashValidatorTests.java
index 8c6e64f4d5e7..463c394d6b22 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/RoundHashValidatorTests.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/RoundHashValidatorTests.java
@@ -24,17 +24,20 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import com.hedera.hapi.node.state.roster.Roster;
+import com.hedera.hapi.node.state.roster.RosterEntry;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.platform.NodeId;
import com.swirlds.platform.metrics.IssMetrics;
+import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.state.iss.internal.HashValidityStatus;
import com.swirlds.platform.state.iss.internal.RoundHashValidator;
-import com.swirlds.platform.system.address.AddressBook;
-import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder;
+import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Random;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
@@ -75,19 +78,19 @@ record HashGenerationData(List nodeList, Hash consensusHash) {}
* Based on the desired network status, generate hashes for all nodes.
*
* @param random a source of randomness
- * @param addressBook the address book for the round
+ * @param roster the roster for the round
* @param desiredValidityStatus the desired validity status
* @return a list of node IDs in the order they should be added to the hash validator
*/
static HashGenerationData generateNodeHashes(
final Random random,
- final AddressBook addressBook,
+ final Roster roster,
final HashValidityStatus desiredValidityStatus,
final long round) {
if (desiredValidityStatus == HashValidityStatus.VALID || desiredValidityStatus == HashValidityStatus.SELF_ISS) {
- return generateRegularNodeHashes(random, addressBook, round);
+ return generateRegularNodeHashes(random, roster, round);
} else if (desiredValidityStatus == HashValidityStatus.CATASTROPHIC_ISS) {
- return generateCatastrophicNodeHashes(random, addressBook, round);
+ return generateCatastrophicNodeHashes(random, roster, round);
} else {
throw new IllegalArgumentException("Unsupported case " + desiredValidityStatus);
}
@@ -96,8 +99,7 @@ static HashGenerationData generateNodeHashes(
/**
* Generate node hashes without there being a catastrophic ISS.
*/
- static HashGenerationData generateRegularNodeHashes(
- final Random random, final AddressBook addressBook, final long round) {
+ static HashGenerationData generateRegularNodeHashes(final Random random, final Roster roster, final long round) {
// Greater than 1/2 must have the same hash. But all other nodes are free to take whatever other hash
// they want. Choose that fraction randomly.
@@ -105,10 +107,10 @@ static HashGenerationData generateRegularNodeHashes(
final List nodes = new LinkedList<>();
final List randomNodeOrder = new LinkedList<>();
- addressBook.iterator().forEachRemaining(address -> randomNodeOrder.add(address.getNodeId()));
+ roster.rosterEntries().forEach(node -> randomNodeOrder.add(NodeId.of(node.nodeId())));
Collections.shuffle(randomNodeOrder, random);
- final long totalWeight = addressBook.getTotalWeight();
+ final long totalWeight = RosterUtils.computeTotalWeight(roster);
// This is the hash we want to be chosen for the consensus hash.
final Hash consensusHash = randomHash(random);
@@ -124,8 +126,9 @@ static HashGenerationData generateRegularNodeHashes(
final List randomHashNodes = new LinkedList<>();
// Assign each node to one of the hashing strategies described above.
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeId nodeId : randomNodeOrder) {
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
if (!MAJORITY.isSatisfiedBy(correctHashWeight, totalWeight)) {
correctHashNodes.add(nodeId);
@@ -146,7 +149,7 @@ static HashGenerationData generateRegularNodeHashes(
// Now, decide what order the hashes should be processed. Make sure that the
// consensus hash is the first to reach a strong minority.
- while (nodes.size() < addressBook.getSize()) {
+ while (nodes.size() < roster.rosterEntries().size()) {
final double choice = random.nextDouble();
allowedIterations--;
@@ -155,14 +158,14 @@ static HashGenerationData generateRegularNodeHashes(
if (choice < 1.0 / 3) {
if (!correctHashNodes.isEmpty()) {
final NodeId nodeId = correctHashNodes.remove(0);
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
nodes.add(new NodeHashInfo(nodeId, consensusHash, round));
correctHashWeight += weight;
}
} else if (choice < 2.0 / 3) {
if (!otherHashNodes.isEmpty()) {
final NodeId nodeId = otherHashNodes.get(0);
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
if (MAJORITY.isSatisfiedBy(otherHashWeight + weight, totalWeight)) {
// We don't want to allow the other hash to accumulate >1/2
@@ -172,7 +175,7 @@ static HashGenerationData generateRegularNodeHashes(
otherHashNodes.remove(0);
nodes.add(new NodeHashInfo(nodeId, otherHash, round));
- otherHashWeight += addressBook.getAddress(nodeId).getWeight();
+ otherHashWeight += nodesById.get(nodeId.id()).weight();
}
} else {
// The random hashes will never reach a majority, so they can go in whenever
@@ -190,24 +193,25 @@ static HashGenerationData generateRegularNodeHashes(
* Generate node hashes that result in a catastrophic ISS.
*/
static HashGenerationData generateCatastrophicNodeHashes(
- final Random random, final AddressBook addressBook, final long round) {
+ final Random random, final Roster roster, final long round) {
// There should exist no group of nodes with the same hash that >1/2
final List nodes = new ArrayList<>();
- final long totalWeight = addressBook.getTotalWeight();
+ final long totalWeight = RosterUtils.computeTotalWeight(roster);
final List randomNodeOrder = new LinkedList<>();
- addressBook.iterator().forEachRemaining(address -> randomNodeOrder.add(address.getNodeId()));
+ roster.rosterEntries().forEach(node -> randomNodeOrder.add(NodeId.of(node.nodeId())));
Collections.shuffle(randomNodeOrder, random);
// A large group of nodes may decide to use this hash. But it won't become the consensus hash.
final Hash otherHash = randomHash(random);
long otherHashWeight = 0;
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeId nodeId : randomNodeOrder) {
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final double choice = random.nextDouble();
if (choice < 1.0 / 3 && !MAJORITY.isSatisfiedBy(otherHashWeight + weight, totalWeight)) {
@@ -260,24 +264,25 @@ private static NodeHashInfo chooseSelfNode(
void selfSignatureLastTest(final HashValidityStatus expectedStatus) {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final HashGenerationData hashGenerationData = generateNodeHashes(random, addressBook, expectedStatus, 0);
+ final HashGenerationData hashGenerationData = generateNodeHashes(random, roster, expectedStatus, 0);
final NodeHashInfo thisNode = chooseSelfNode(random, hashGenerationData, expectedStatus);
final long round = random.nextInt(1000);
final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ new RoundHashValidator(round, RosterUtils.computeTotalWeight(roster), Mockito.mock(IssMetrics.class));
boolean decided = false;
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
final boolean operationCausedDecision = validator.reportHashFromNetwork(nodeId, weight, hash);
@@ -306,18 +311,18 @@ void selfSignatureLastTest(final HashValidityStatus expectedStatus) {
void selfSignatureFirstTest(final HashValidityStatus expectedStatus) {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final HashGenerationData hashGenerationData = generateNodeHashes(random, addressBook, expectedStatus, 0);
+ final HashGenerationData hashGenerationData = generateNodeHashes(random, roster, expectedStatus, 0);
final NodeHashInfo thisNode = chooseSelfNode(random, hashGenerationData, expectedStatus);
final long round = random.nextInt(1000);
final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ new RoundHashValidator(round, RosterUtils.computeTotalWeight(roster), Mockito.mock(IssMetrics.class));
boolean decided = false;
@@ -325,9 +330,10 @@ void selfSignatureFirstTest(final HashValidityStatus expectedStatus) {
validator.reportSelfHash(thisNode.nodeStateHash),
"we should need to gather more data before becoming decided");
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
final boolean operationCausedDecision = validator.reportHashFromNetwork(nodeId, weight, hash);
@@ -350,27 +356,28 @@ void selfSignatureFirstTest(final HashValidityStatus expectedStatus) {
void selfSignatureInMiddleTest(final HashValidityStatus expectedStatus) {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final HashGenerationData hashGenerationData = generateNodeHashes(random, addressBook, expectedStatus, 0);
+ final HashGenerationData hashGenerationData = generateNodeHashes(random, roster, expectedStatus, 0);
final NodeHashInfo thisNode = chooseSelfNode(random, hashGenerationData, expectedStatus);
final long round = random.nextInt(1000);
final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ new RoundHashValidator(round, RosterUtils.computeTotalWeight(roster), Mockito.mock(IssMetrics.class));
boolean decided = false;
- final int addSelfHashIndex = random.nextInt(addressBook.getSize() - 1);
+ final int addSelfHashIndex = random.nextInt(roster.rosterEntries().size() - 1);
int index = 0;
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
if (index == addSelfHashIndex) {
@@ -400,22 +407,22 @@ void selfSignatureInMiddleTest(final HashValidityStatus expectedStatus) {
void timeoutSelfHashTest() {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final HashGenerationData hashGenerationData =
- generateNodeHashes(random, addressBook, HashValidityStatus.VALID, 0);
+ final HashGenerationData hashGenerationData = generateNodeHashes(random, roster, HashValidityStatus.VALID, 0);
final long round = random.nextInt(1000);
final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ new RoundHashValidator(round, RosterUtils.computeTotalWeight(roster), Mockito.mock(IssMetrics.class));
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
assertFalse(validator.reportHashFromNetwork(nodeId, weight, hash), "insufficient data to make decision");
@@ -433,25 +440,24 @@ void timeoutSelfHashTest() {
void timeoutSelfHashAndSignaturesTest() {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final long totalWeight = addressBook.getTotalWeight();
+ final long totalWeight = RosterUtils.computeTotalWeight(roster);
- final HashGenerationData hashGenerationData =
- generateNodeHashes(random, addressBook, HashValidityStatus.VALID, 0);
+ final HashGenerationData hashGenerationData = generateNodeHashes(random, roster, HashValidityStatus.VALID, 0);
final long round = random.nextInt(1000);
- final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ final RoundHashValidator validator = new RoundHashValidator(round, totalWeight, Mockito.mock(IssMetrics.class));
long addedWeight = 0;
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
if (MAJORITY.isSatisfiedBy(addedWeight + weight, totalWeight)) {
@@ -474,28 +480,27 @@ void timeoutSelfHashAndSignaturesTest() {
void timeoutSignaturesTest() {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final long totalWeight = addressBook.getTotalWeight();
+ final long totalWeight = RosterUtils.computeTotalWeight(roster);
- final HashGenerationData hashGenerationData =
- generateNodeHashes(random, addressBook, HashValidityStatus.VALID, 0);
+ final HashGenerationData hashGenerationData = generateNodeHashes(random, roster, HashValidityStatus.VALID, 0);
final NodeHashInfo thisNode = chooseSelfNode(random, hashGenerationData, HashValidityStatus.VALID);
final long round = random.nextInt(1000);
- final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ final RoundHashValidator validator = new RoundHashValidator(round, totalWeight, Mockito.mock(IssMetrics.class));
assertFalse(validator.reportSelfHash(thisNode.nodeStateHash), "should not allow a decision");
long addedWeight = 0;
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
if (MAJORITY.isSatisfiedBy(addedWeight + weight, totalWeight)) {
@@ -519,28 +524,28 @@ void timeoutSignaturesTest() {
void timeoutWithSuperMajorityTest() {
final Random random = getRandomPrintSeed();
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
+ final Roster roster = RandomRosterBuilder.create(random)
.withSize(Math.max(10, random.nextInt(1000)))
.withAverageWeight(100)
.withWeightStandardDeviation(50)
.build();
- final long totalWeight = addressBook.getTotalWeight();
+ final long totalWeight = RosterUtils.computeTotalWeight(roster);
final HashGenerationData hashGenerationData =
- generateNodeHashes(random, addressBook, HashValidityStatus.CATASTROPHIC_ISS, 0);
+ generateNodeHashes(random, roster, HashValidityStatus.CATASTROPHIC_ISS, 0);
final NodeHashInfo thisNode = chooseSelfNode(random, hashGenerationData, HashValidityStatus.CATASTROPHIC_ISS);
final long round = random.nextInt(1000);
- final RoundHashValidator validator =
- new RoundHashValidator(round, addressBook.getTotalWeight(), Mockito.mock(IssMetrics.class));
+ final RoundHashValidator validator = new RoundHashValidator(round, totalWeight, Mockito.mock(IssMetrics.class));
assertFalse(validator.reportSelfHash(thisNode.nodeStateHash), "should not allow a decision");
long addedWeight = 0;
+ final Map nodesById = RosterUtils.toMap(roster);
for (final NodeHashInfo nodeHashInfo : hashGenerationData.nodeList) {
final NodeId nodeId = nodeHashInfo.nodeId;
- final long weight = addressBook.getAddress(nodeId).getWeight();
+ final long weight = nodesById.get(nodeId.id()).weight();
final Hash hash = nodeHashInfo.nodeStateHash;
boolean decided = validator.reportHashFromNetwork(nodeId, weight, hash);
From 0bf0e37aa58a620bc3b334be4d289f434965553f Mon Sep 17 00:00:00 2001
From: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com>
Date: Fri, 20 Dec 2024 17:07:27 +0000
Subject: [PATCH 02/13] chore: schedule release cutting 0.58 (#17120)
Signed-off-by: Thomas Moran <152873392+thomas-swirlds-labs@users.noreply.github.com>
---
.github/workflows/config/node-release.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/config/node-release.yaml b/.github/workflows/config/node-release.yaml
index 18a52d366e68..6be706bec502 100644
--- a/.github/workflows/config/node-release.yaml
+++ b/.github/workflows/config/node-release.yaml
@@ -1,9 +1,9 @@
release:
branching:
execution:
- time: "18:00:00"
+ time: "20:00:00"
schedule:
- - on: "2024-12-13"
+ - on: "2024-12-20"
name: release/0.58
initial-tag:
create: true
From a9692704da783ef3754b84a23fa1b1aa0654f920 Mon Sep 17 00:00:00 2001
From: anthony-swirldslabs
<152534762+anthony-swirldslabs@users.noreply.github.com>
Date: Fri, 20 Dec 2024 10:41:49 -0800
Subject: [PATCH 03/13] chore: replace setAddressBook with setActiveRoster
(#17139)
Signed-off-by: Anthony Petrov
---
.../cli/GenesisPlatformStateCommand.java | 16 ++++
.../swirlds/platform/roster/RosterUtils.java | 28 ++++++-
.../state/service/WritableRosterStore.java | 33 ++++++++-
.../state/signed/StartupStateUtils.java | 23 ++++--
.../system/address/AddressBookUtils.java | 74 ++++++++++++-------
.../platform/state/SignedStateTests.java | 12 ++-
.../addressbook/RandomAddressBuilder.java | 2 +-
.../addressbook/RandomRosterEntryBuilder.java | 2 +-
.../platform/test/PlatformStateUtils.java | 8 --
9 files changed, 148 insertions(+), 50 deletions(-)
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java
index 77ea6e1959e6..4606b861ed51 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java
@@ -22,6 +22,7 @@
import com.swirlds.cli.commands.StateCommand;
import com.swirlds.cli.utility.AbstractCommand;
import com.swirlds.cli.utility.SubcommandOf;
+import com.swirlds.common.RosterStateId;
import com.swirlds.common.context.PlatformContext;
import com.swirlds.common.merkle.crypto.MerkleCryptoFactory;
import com.swirlds.config.api.Configuration;
@@ -30,10 +31,14 @@
import com.swirlds.platform.consensus.SyntheticSnapshot;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.PlatformStateModifier;
+import com.swirlds.platform.state.service.WritableRosterStore;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.snapshot.DeserializedSignedState;
import com.swirlds.platform.state.snapshot.SignedStateFileReader;
import com.swirlds.platform.util.BootstrapUtils;
+import com.swirlds.state.State;
+import com.swirlds.state.spi.CommittableWritableStates;
+import com.swirlds.state.spi.WritableStates;
import java.io.IOException;
import java.nio.file.Path;
import java.util.concurrent.ExecutionException;
@@ -81,10 +86,21 @@ public Integer call() throws IOException, ExecutionException, InterruptedExcepti
System.out.printf("Replacing platform data %n");
v.setRound(PlatformStateAccessor.GENESIS_ROUND);
v.setSnapshot(SyntheticSnapshot.getGenesisSnapshot());
+
+ // FUTURE WORK: remove once the AddressBook setters are deprecated and the fields are nullified.
+ // For now, we have to keep these calls to ensure RosterRetriever won't fall back to using these values.
System.out.printf("Nullifying Address Books %n");
v.setAddressBook(null);
v.setPreviousAddressBook(null);
});
+ {
+ System.out.printf("Resetting the RosterService state %n");
+ final State state = (State) reservedSignedState.get().getState().getSwirldState();
+ final WritableStates writableStates = state.getWritableStates(RosterStateId.NAME);
+ final WritableRosterStore writableRosterStore = new WritableRosterStore(writableStates);
+ writableRosterStore.resetRosters();
+ ((CommittableWritableStates) writableStates).commit();
+ }
System.out.printf("Hashing state %n");
MerkleCryptoFactory.getInstance()
.digestTreeAsync(reservedSignedState.get().getState())
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/roster/RosterUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/roster/RosterUtils.java
index c71747b005d8..28fddcf62c60 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/roster/RosterUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/roster/RosterUtils.java
@@ -1,4 +1,19 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.swirlds.platform.roster;
import com.hedera.hapi.node.base.ServiceEndpoint;
@@ -293,6 +308,17 @@ public static void setActiveRoster(@NonNull final State state, @NonNull final Ro
((CommittableWritableStates) writableStates).commit();
}
+ /**
+ * Formats a human-readable Roster representation, currently using its JSON codec,
+ * or returns {@code null} if the given roster object is null.
+ * @param roster a roster to format
+ * @return roster JSON string, or null
+ */
+ @Nullable
+ public static String toString(@Nullable final Roster roster) {
+ return roster == null ? null : Roster.JSON.toJSON(roster);
+ }
+
/**
* Build an Address object out of a given RosterEntry object.
*
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/service/WritableRosterStore.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/service/WritableRosterStore.java
index cb6da5ceed31..4bd55e8fe99f 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/service/WritableRosterStore.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/service/WritableRosterStore.java
@@ -33,6 +33,9 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.LinkedList;
import java.util.List;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.StreamSupport;
/**
* Read-write implementation for accessing rosters states.
@@ -114,19 +117,28 @@ public void putActiveRoster(@NonNull final Roster roster, final long round) {
requireNonNull(roster);
RosterValidator.validate(roster);
+ final Bytes rosterHash = RosterUtils.hash(roster).getBytes();
+
// update the roster state
final RosterState previousRosterState = rosterStateOrDefault();
final List roundRosterPairs = new LinkedList<>(previousRosterState.roundRosterPairs());
if (!roundRosterPairs.isEmpty()) {
final RoundRosterPair activeRosterPair = roundRosterPairs.getFirst();
+ if (activeRosterPair.activeRosterHash().equals(rosterHash)) {
+ // We're trying to set the exact same active roster, maybe even with the same roundNumber.
+ // This may happen if, for whatever reason, roster updates come from different code paths.
+ // This shouldn't be considered an error because the system wants to use the exact same
+ // roster that is currently active anyway. So we silently ignore such a putActiveRoster request
+ // because it's a no-op:
+ return;
+ }
if (round < 0 || round <= activeRosterPair.roundNumber()) {
throw new IllegalArgumentException("incoming round number = " + round
+ " must be greater than the round number of the current active roster = "
+ activeRosterPair.roundNumber() + ".");
}
}
- final Bytes activeRosterHash = RosterUtils.hash(roster).getBytes();
- roundRosterPairs.addFirst(new RoundRosterPair(round, activeRosterHash));
+ roundRosterPairs.addFirst(new RoundRosterPair(round, rosterHash));
if (roundRosterPairs.size() > MAXIMUM_ROSTER_HISTORY_SIZE) {
final RoundRosterPair lastRemovedRoster = roundRosterPairs.removeLast();
@@ -149,7 +161,22 @@ public void putActiveRoster(@NonNull final Roster roster, final long round) {
// so we remove it if it meets removal criteria.
removeRoster(previousRosterState.candidateRosterHash());
rosterState.put(newRosterStateBuilder.build());
- rosterMap.put(ProtoBytes.newBuilder().value(activeRosterHash).build(), roster);
+ rosterMap.put(ProtoBytes.newBuilder().value(rosterHash).build(), roster);
+ }
+
+ /**
+ * Reset the roster state to an empty list and remove all entries from the roster map.
+ * This method is primarily intended to be used in CLI tools that may need to reset
+ * the RosterService states to a vanilla state, for example to reproduce the genesis state.
+ */
+ public void resetRosters() {
+ rosterState.put(RosterState.DEFAULT);
+
+ // To avoid modifying the map while iterating over all the keys, collect them into a list first:
+ final List keys = StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(rosterMap.keys(), Spliterator.ORDERED), false)
+ .toList();
+ keys.forEach(rosterMap::remove);
}
/**
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java
index 09e1e772815d..60c29102456f 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java
@@ -35,6 +35,8 @@
import com.swirlds.platform.config.StateConfig;
import com.swirlds.platform.crypto.CryptoStatic;
import com.swirlds.platform.internal.SignedStateLoadingException;
+import com.swirlds.platform.roster.RosterRetriever;
+import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.state.snapshot.DeserializedSignedState;
@@ -42,6 +44,7 @@
import com.swirlds.platform.state.snapshot.SignedStateFilePath;
import com.swirlds.platform.system.SoftwareVersion;
import com.swirlds.platform.system.address.AddressBook;
+import com.swirlds.state.State;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.IOException;
@@ -326,7 +329,12 @@ private static ReservedSignedState buildGenesisState(
@NonNull final MerkleRoot stateRoot) {
if (!configuration.getConfigData(AddressBookConfig.class).useRosterLifecycle()) {
- initGenesisPlatformState(configuration, stateRoot.getWritablePlatformState(), addressBook, appVersion);
+ initGenesisState(
+ configuration,
+ (State) stateRoot.getSwirldState(),
+ stateRoot.getWritablePlatformState(),
+ addressBook,
+ appVersion);
}
final SignedState signedState = new SignedState(
@@ -335,21 +343,24 @@ private static ReservedSignedState buildGenesisState(
}
/**
- * Initializes a genesis platform state.
+ * Initializes a genesis platform state and RosterService state.
* @param configuration the configuration for this node
+ * @param state the State instance to initialize
* @param platformState the platform state to initialize
* @param addressBook the current address book
* @param appVersion the software version of the app
*/
- private static void initGenesisPlatformState(
+ private static void initGenesisState(
final Configuration configuration,
+ final State state,
final PlatformStateModifier platformState,
final AddressBook addressBook,
final SoftwareVersion appVersion) {
+ final long round = 0L;
+
platformState.bulkUpdate(v -> {
- v.setAddressBook(addressBook.copy());
v.setCreationSoftwareVersion(appVersion);
- v.setRound(0);
+ v.setRound(round);
v.setLegacyRunningEventHash(null);
v.setConsensusTimestamp(Instant.ofEpochSecond(0L));
@@ -360,5 +371,7 @@ private static void initGenesisPlatformState(
v.setFreezeTime(Instant.ofEpochSecond(genesisFreezeTime));
}
});
+
+ RosterUtils.setActiveRoster(state, RosterRetriever.buildRoster(addressBook), round);
}
}
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java
index 9e5a05e2a175..3e7991e05800 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java
@@ -1,18 +1,31 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.swirlds.platform.system.address;
-import static com.swirlds.platform.roster.RosterRetriever.retrieveActiveOrGenesisRoster;
-import static com.swirlds.platform.roster.RosterUtils.buildAddressBook;
import static com.swirlds.platform.util.BootstrapUtils.detectSoftwareUpgrade;
import com.hedera.hapi.node.base.ServiceEndpoint;
+import com.hedera.hapi.node.state.roster.Roster;
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.swirlds.common.context.PlatformContext;
import com.swirlds.common.formatting.TextTable;
import com.swirlds.common.platform.NodeId;
-import com.swirlds.platform.config.AddressBookConfig;
-import com.swirlds.platform.state.MerkleRoot;
-import com.swirlds.platform.state.PlatformStateModifier;
+import com.swirlds.platform.roster.RosterRetriever;
+import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.state.address.AddressBookInitializer;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.system.SoftwareVersion;
@@ -238,31 +251,38 @@ public static ServiceEndpoint endpointFor(@NonNull final String host, final int
// Initialize the address book from the configuration and platform saved state.
final AddressBookInitializer addressBookInitializer = new AddressBookInitializer(
selfId, version, softwareUpgrade, initialState.get(), bootstrapAddressBook.copy(), platformContext);
+ final State state = (State) initialState.get().getState().getSwirldState();
+
+ if (addressBookInitializer.hasAddressBookChanged()) {
+ if (addressBookInitializer.getPreviousAddressBook() != null) {
+ // We cannot really "update" the previous roster because we don't know the round number
+ // at which it became active. And we shouldn't do that anyway because under normal circumstances
+ // the RosterService tracks the roster history correctly. However, since we're given a non-null
+ // previous AddressBook, and per the current implementation we know it comes from the state,
+ // we might as well validate this fact here just to ensure the update is correct.
+ final Roster previousRoster =
+ RosterRetriever.buildRoster(addressBookInitializer.getPreviousAddressBook());
+ if (!previousRoster.equals(RosterRetriever.retrieveActiveOrGenesisRoster(state))
+ && !previousRoster.equals(RosterRetriever.retrievePreviousRoster(state))) {
+ throw new IllegalStateException(
+ "The previousRoster in the AddressBookInitializer doesn't match either the active or previous roster in state."
+ + " AddressBookInitializer previousRoster = " + RosterUtils.toString(previousRoster)
+ + ", state currentRoster = "
+ + RosterUtils.toString(RosterRetriever.retrieveActiveOrGenesisRoster(state))
+ + ", state previousRoster = "
+ + RosterUtils.toString(RosterRetriever.retrievePreviousRoster(state)));
+ }
+ }
- final boolean useRosterLifecycle = platformContext
- .getConfiguration()
- .getConfigData(AddressBookConfig.class)
- .useRosterLifecycle();
- if (!useRosterLifecycle && addressBookInitializer.hasAddressBookChanged()) {
- final MerkleRoot state = initialState.get().getState();
- // Update the address book with the current address book read from config.txt.
- // Eventually we will not do this, and only transactions will be capable of
- // modifying the address book.
- final PlatformStateModifier platformState = state.getWritablePlatformState();
- platformState.bulkUpdate(v -> {
- v.setAddressBook(addressBookInitializer.getCurrentAddressBook().copy());
- v.setPreviousAddressBook(
- addressBookInitializer.getPreviousAddressBook() == null
- ? null
- : addressBookInitializer
- .getPreviousAddressBook()
- .copy());
- });
+ RosterUtils.setActiveRoster(
+ state,
+ RosterRetriever.buildRoster(addressBookInitializer.getCurrentAddressBook()),
+ RosterRetriever.getRound(state));
}
// At this point the initial state must have the current address book set. If not, something is wrong.
- final AddressBook addressBook = buildAddressBook(retrieveActiveOrGenesisRoster(
- (State) initialState.get().getState().getSwirldState()));
+ final AddressBook addressBook =
+ RosterUtils.buildAddressBook(RosterRetriever.retrieveActiveOrGenesisRoster(state));
if (addressBook == null) {
throw new IllegalStateException("The current address book of the initial state is null.");
}
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SignedStateTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SignedStateTests.java
index 96ff4de12905..8be6f986bd77 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SignedStateTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SignedStateTests.java
@@ -32,10 +32,11 @@
import com.swirlds.common.test.fixtures.platform.TestPlatformContextBuilder;
import com.swirlds.merkledb.MerkleDb;
import com.swirlds.platform.crypto.SignatureVerifier;
+import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.system.BasicSoftwareVersion;
-import com.swirlds.platform.system.address.AddressBook;
+import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
import com.swirlds.platform.test.fixtures.state.RandomSignedStateGenerator;
import java.time.Duration;
import java.util.ArrayList;
@@ -73,14 +74,15 @@ void tearDown() {
* @param reserveCallback this method is called when the State is reserved
* @param releaseCallback this method is called when the State is released
*/
- private PlatformMerkleStateRoot buildMockState(final Runnable reserveCallback, final Runnable releaseCallback) {
+ private PlatformMerkleStateRoot buildMockState(
+ final Random random, final Runnable reserveCallback, final Runnable releaseCallback) {
final var real = new PlatformMerkleStateRoot(
FAKE_MERKLE_STATE_LIFECYCLES, version -> new BasicSoftwareVersion(version.major()));
- FAKE_MERKLE_STATE_LIFECYCLES.initPlatformState(real);
+ FAKE_MERKLE_STATE_LIFECYCLES.initStates(real);
+ RosterUtils.setActiveRoster(real, RandomRosterBuilder.create(random).build(), 0L);
final PlatformMerkleStateRoot state = spy(real);
final PlatformStateModifier platformState = new PlatformState();
- platformState.setAddressBook(mock(AddressBook.class));
when(state.getWritablePlatformState()).thenReturn(platformState);
if (reserveCallback != null) {
doAnswer(invocation -> {
@@ -112,6 +114,7 @@ void reservationTest() throws InterruptedException {
final AtomicBoolean released = new AtomicBoolean(false);
final PlatformMerkleStateRoot state = buildMockState(
+ random,
() -> {
assertFalse(reserved.get(), "should only be reserved once");
reserved.set(true);
@@ -173,6 +176,7 @@ void noGarbageCollectorTest() {
final Thread mainThread = Thread.currentThread();
final PlatformMerkleStateRoot state = buildMockState(
+ random,
() -> {
assertFalse(reserved.get(), "should only be reserved once");
reserved.set(true);
diff --git a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomAddressBuilder.java b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomAddressBuilder.java
index eba550453381..8172eb2fe2cf 100644
--- a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomAddressBuilder.java
+++ b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomAddressBuilder.java
@@ -82,7 +82,7 @@ public Address build() {
}
if (port == null) {
- port = random.nextInt(0, 65535);
+ port = random.nextInt(1, 65535);
}
if (hostname == null) {
diff --git a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomRosterEntryBuilder.java b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomRosterEntryBuilder.java
index ea83dc3be459..afe5ce028356 100644
--- a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomRosterEntryBuilder.java
+++ b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/addressbook/RandomRosterEntryBuilder.java
@@ -79,7 +79,7 @@ public RosterEntry build() {
}
if (port == null) {
- port = random.nextInt(0, 65535);
+ port = random.nextInt(1, 65535);
}
if (hostname == null) {
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/PlatformStateUtils.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/PlatformStateUtils.java
index 2732a4ca36b7..25e7395f8089 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/PlatformStateUtils.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/PlatformStateUtils.java
@@ -24,9 +24,6 @@
import com.swirlds.platform.state.MinimumJudgeInfo;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.system.BasicSoftwareVersion;
-import com.swirlds.platform.system.address.AddressBook;
-import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder;
-import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder.WeightDistributionStrategy;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
@@ -46,13 +43,8 @@ public static PlatformStateModifier randomPlatformState(PlatformStateModifier pl
* Generate a randomized PlatformState object. Values contained internally may be nonsensical.
*/
public static PlatformStateModifier randomPlatformState(final Random random, PlatformStateModifier platformState) {
- final AddressBook addressBook = RandomAddressBookBuilder.create(random)
- .withSize(4)
- .withWeightDistributionStrategy(WeightDistributionStrategy.BALANCED)
- .build();
platformState.bulkUpdate(v -> {
- v.setAddressBook(addressBook);
v.setLegacyRunningEventHash(randomHash(random));
v.setRound(random.nextLong());
v.setConsensusTimestamp(randomInstant(random));
From aee0358054a31cceddb90b366251c431b845c4a5 Mon Sep 17 00:00:00 2001
From: Oleg Mazurov <23125269+OlegMazurov@users.noreply.github.com>
Date: Fri, 20 Dec 2024 11:45:39 -0800
Subject: [PATCH 04/13] perf: enable compaction during reconnects (#17129)
Signed-off-by: Oleg Mazurov
---
.../src/main/java/com/swirlds/merkledb/MerkleDb.java | 2 +-
.../swirlds/virtualmap/internal/merkle/VirtualRootNode.java | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/platform-sdk/swirlds-merkledb/src/main/java/com/swirlds/merkledb/MerkleDb.java b/platform-sdk/swirlds-merkledb/src/main/java/com/swirlds/merkledb/MerkleDb.java
index 3b0b2119199c..c55f121a09ca 100644
--- a/platform-sdk/swirlds-merkledb/src/main/java/com/swirlds/merkledb/MerkleDb.java
+++ b/platform-sdk/swirlds-merkledb/src/main/java/com/swirlds/merkledb/MerkleDb.java
@@ -398,7 +398,7 @@ public MerkleDbDataSource copyDataSource(
final String label = dataSource.getTableName();
final int tableId = getNextTableId();
importDataSource(dataSource, tableId, !makeCopyPrimary, makeCopyPrimary); // import to itself == copy
- return getDataSource(tableId, label, false, offlineUse);
+ return getDataSource(tableId, label, makeCopyPrimary, offlineUse);
}
private void importDataSource(
diff --git a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/merkle/VirtualRootNode.java b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/merkle/VirtualRootNode.java
index 060a182fafdd..94ec0d1c38ca 100644
--- a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/merkle/VirtualRootNode.java
+++ b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/merkle/VirtualRootNode.java
@@ -1704,9 +1704,6 @@ public void endLearnerReconnect() {
originalMap = null;
logger.info(RECONNECT.getMarker(), "call postInit()");
postInit(fullyReconnectedState);
- // Start up data source compaction now
- logger.info(RECONNECT.getMarker(), "call dataSource.enableBackgroundCompaction()");
- dataSource.enableBackgroundCompaction();
} catch (ExecutionException e) {
final var message = "VirtualMap@" + getRoute() + " failed to get hash during learner reconnect";
throw new MerkleSynchronizationException(message, e);
From 0679def5e84f19ac75bec401565f61bc59f10b92 Mon Sep 17 00:00:00 2001
From: Ivan Malygin
Date: Fri, 20 Dec 2024 16:48:18 -0500
Subject: [PATCH 05/13] refactor: 16436 Removed `MerkleRoot` interface.
(#17130)
Signed-off-by: Ivan Malygin
---
.../main/java/com/hedera/node/app/Hedera.java | 5 +-
.../com/hedera/node/app/ServicesMain.java | 33 +++++---
.../app/state/merkle/SerializationTest.java | 4 +-
.../block/StateChangesValidator.java | 19 ++++-
.../platform/ReconnectStateLoader.java | 7 +-
.../swirlds/platform/StateInitializer.java | 8 +-
.../com/swirlds/platform/SwirldsPlatform.java | 8 +-
.../cli/GenesisPlatformStateCommand.java | 2 +-
.../cli/ValidateAddressBookStateCommand.java | 3 +-
.../DefaultTransactionHandler.java | 6 +-
.../platform/reconnect/ReconnectHelper.java | 8 +-
.../platform/reconnect/ReconnectLearner.java | 10 +--
.../reconnect/ReconnectLearnerFactory.java | 6 +-
.../platform/reconnect/ReconnectUtils.java | 6 +-
.../recovery/EventRecoveryWorkflow.java | 10 +--
.../state/BirthRoundStateMigration.java | 2 +-
.../swirlds/platform/state/MerkleRoot.java | 76 -------------------
.../state/PlatformMerkleStateRoot.java | 33 ++++----
.../platform/state/SwirldStateManager.java | 34 ++++-----
.../state/SwirldStateManagerUtils.java | 10 +--
.../platform/state/TransactionHandler.java | 6 +-
.../state/address/AddressBookInitializer.java | 21 ++++-
.../state/hashlogger/DefaultHashLogger.java | 6 +-
.../platform/state/signed/SignedState.java | 16 ++--
.../state/signed/StartupStateUtils.java | 17 ++---
.../state/snapshot/SavedStateMetadata.java | 6 +-
.../state/snapshot/SignedStateFileReader.java | 6 +-
.../state/snapshot/SignedStateFileWriter.java | 13 ++--
.../swirlds/platform/system/SwirldMain.java | 6 +-
.../system/address/AddressBookUtils.java | 2 +-
.../swirlds/platform/util/BootstrapUtils.java | 6 +-
.../platform/AddressBookInitializerTest.java | 37 +++++----
.../platform/SavedStateMetadataTests.java | 13 +---
.../SignedStateFileReadWriteTest.java | 6 +-
.../consensus/RoundCalculationUtilsTest.java | 6 +-
.../DefaultTransactionHandlerTests.java | 5 +-
.../TransactionHandlerTester.java | 8 +-
.../reconnect/ReconnectProtocolTests.java | 6 +-
.../platform/reconnect/ReconnectTest.java | 4 +-
.../platform/state/StateRegistryTests.java | 10 +--
.../state/SwirldStateManagerTests.java | 6 +-
.../state/SwirldStateManagerUtilsTests.java | 5 +-
.../state/hashlogger/HashLoggerTest.java | 8 +-
.../StateHashedNotificationTest.java | 4 +-
.../platform/turtle/runner/TurtleNode.java | 4 +-
.../turtle/runner/TurtleTestingToolState.java | 2 +-
.../wiring/SignedStateReserverTest.java | 6 +-
.../fixtures/state/BlockingSwirldState.java | 7 +-
.../state/RandomSignedStateGenerator.java | 7 +-
.../com/swirlds/platform/test/StateTest.java | 9 +--
.../com/swirlds/platform/test/StateTests.java | 6 +-
.../platform/test/state/IssDetectorTests.java | 4 +-
52 files changed, 250 insertions(+), 308 deletions(-)
delete mode 100644 platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/MerkleRoot.java
diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java
index ac8a769a966d..0adf358ddf9b 100644
--- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java
+++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -133,7 +133,6 @@
import com.swirlds.platform.listeners.ReconnectCompleteListener;
import com.swirlds.platform.listeners.ReconnectCompleteNotification;
import com.swirlds.platform.listeners.StateWriteToDiskCompleteListener;
-import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.service.PlatformStateService;
import com.swirlds.platform.state.service.ReadablePlatformStateStore;
@@ -505,7 +504,7 @@ public SoftwareVersion getSoftwareVersion() {
*/
@Override
@NonNull
- public MerkleRoot newMerkleStateRoot() {
+ public PlatformMerkleStateRoot newMerkleStateRoot() {
return stateRootSupplier.get();
}
diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/ServicesMain.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/ServicesMain.java
index e4269a149bf5..05b2b2326812 100644
--- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/ServicesMain.java
+++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/ServicesMain.java
@@ -1,4 +1,19 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.hedera.node.app;
import static com.swirlds.common.io.utility.FileUtils.getAbsolutePath;
@@ -60,7 +75,6 @@
import com.swirlds.platform.crypto.CryptoStatic;
import com.swirlds.platform.roster.RosterHistory;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.address.AddressBookInitializer;
import com.swirlds.platform.state.service.ReadableRosterStore;
@@ -130,7 +144,7 @@ public void init(@NonNull final Platform platform, @NonNull final NodeId nodeId)
* {@inheritDoc}
*/
@Override
- public @NonNull MerkleRoot newMerkleStateRoot() {
+ public @NonNull PlatformMerkleStateRoot newMerkleStateRoot() {
return hederaOrThrow().newMerkleStateRoot();
}
@@ -254,7 +268,7 @@ public static void main(final String... args) throws Exception {
version,
() -> {
isGenesis.set(true);
- final var genesisState = (PlatformMerkleStateRoot) hedera.newMerkleStateRoot();
+ final var genesisState = hedera.newMerkleStateRoot();
final var genesisNetwork = DiskStartupNetworks.fromLegacyAddressBook(diskAddressBook);
hedera.initializeStatesApi(
genesisState,
@@ -271,17 +285,12 @@ public static void main(final String... args) throws Exception {
final var initialState = reservedState.state();
if (!isGenesis.get()) {
hedera.initializeStatesApi(
- (PlatformMerkleStateRoot) initialState.get().getState().getSwirldState(),
- metrics,
- InitTrigger.RESTART,
- null,
- platformConfig,
- diskAddressBook);
+ initialState.get().getState(), metrics, InitTrigger.RESTART, null, platformConfig, diskAddressBook);
}
hedera.setInitialStateHash(reservedState.hash());
// --- Now build the platform and start it ---
- final var stateRoot = (PlatformMerkleStateRoot) initialState.get().getState();
+ final var stateRoot = initialState.get().getState();
final RosterHistory rosterHistory;
if (hedera.isRosterLifecycleEnabled()) {
final var rosterStore = new ReadableStoreFactory(stateRoot).getStore(ReadableRosterStore.class);
@@ -461,7 +470,7 @@ private static HashedReservedSignedState loadInitialState(
@NonNull final Configuration configuration,
@NonNull final RecycleBin recycleBin,
@NonNull final SoftwareVersion softwareVersion,
- @NonNull final Supplier stateRootSupplier,
+ @NonNull final Supplier stateRootSupplier,
@NonNull final String mainClassName,
@NonNull final String swirldName,
@NonNull final NodeId selfId) {
diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/state/merkle/SerializationTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/state/merkle/SerializationTest.java
index e0576d1b7c2e..9194fff928ea 100644
--- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/state/merkle/SerializationTest.java
+++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/state/merkle/SerializationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -326,7 +326,7 @@ private PlatformMerkleStateRoot createMerkleHederaState(Schema schemaV1) {
final SignedState randomState =
new RandomSignedStateGenerator().setRound(1).build();
- final var originalTree = (PlatformMerkleStateRoot) randomState.getState();
+ final var originalTree = randomState.getState();
final var originalRegistry =
new MerkleSchemaRegistry(registry, FIRST_SERVICE, DEFAULT_CONFIG, new SchemaApplications());
originalRegistry.register(schemaV1);
diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/junit/support/validators/block/StateChangesValidator.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/junit/support/validators/block/StateChangesValidator.java
index b9250731dfaa..6bfd3b0ba426 100644
--- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/junit/support/validators/block/StateChangesValidator.java
+++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/junit/support/validators/block/StateChangesValidator.java
@@ -1,4 +1,19 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.hedera.services.bdd.junit.support.validators.block;
import static com.hedera.node.app.blocks.impl.BlockImplUtils.combine;
@@ -191,7 +206,7 @@ public StateChangesValidator(
final var addressBook = loadLegacyBookWithGeneratedCerts(pathToAddressBook);
final var metrics = new NoOpMetrics();
final var hedera = ServicesMain.newHedera(NodeId.of(0L), metrics);
- this.state = (PlatformMerkleStateRoot) hedera.newMerkleStateRoot();
+ this.state = hedera.newMerkleStateRoot();
final var platformConfig = ServicesMain.buildPlatformConfig();
hedera.initializeStatesApi(
state,
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/ReconnectStateLoader.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/ReconnectStateLoader.java
index b5b4448f4470..944ef5e116b6 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/ReconnectStateLoader.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/ReconnectStateLoader.java
@@ -39,7 +39,6 @@
import com.swirlds.platform.system.status.actions.ReconnectCompleteAction;
import com.swirlds.platform.wiring.PlatformWiring;
import com.swirlds.state.State;
-import com.swirlds.state.merkle.MerkleStateRoot;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Objects;
import org.apache.logging.log4j.LogManager;
@@ -118,7 +117,7 @@ public void loadReconnectState(@NonNull final SignedState signedState) {
}
// Before attempting to load the state, verify that the platform roster matches the state roster.
- final State state = (MerkleStateRoot>) signedState.getState().getSwirldState();
+ final State state = signedState.getState();
final Roster stateRoster = RosterRetriever.retrieveActiveOrGenesisRoster(state);
if (!roster.equals(stateRoster)) {
throw new IllegalStateException("Current roster and state-based roster do not contain the same nodes "
@@ -170,9 +169,7 @@ public void loadReconnectState(@NonNull final SignedState signedState) {
.getNotifierWiring()
.getInputWire(AppNotifier::sendReconnectCompleteNotification)
.put(new ReconnectCompleteNotification(
- signedState.getRound(),
- signedState.getConsensusTimestamp(),
- signedState.getState().getSwirldState()));
+ signedState.getRound(), signedState.getConsensusTimestamp(), signedState.getState()));
} catch (final RuntimeException e) {
logger.debug(RECONNECT.getMarker(), "`loadReconnectState` : FAILED, reason: {}", e.getMessage());
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/StateInitializer.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/StateInitializer.java
index 743639e48fd4..8db8764cbaeb 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/StateInitializer.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/StateInitializer.java
@@ -25,7 +25,7 @@
import com.swirlds.common.context.PlatformContext;
import com.swirlds.common.merkle.crypto.MerkleCryptoFactory;
import com.swirlds.platform.config.StateConfig;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.system.InitTrigger;
import com.swirlds.platform.system.Platform;
@@ -70,18 +70,18 @@ public static void initializeState(
trigger = RESTART;
}
- final MerkleRoot initialState = signedState.getState();
+ final PlatformMerkleStateRoot initialState = signedState.getState();
// Although the state from disk / genesis state is initially hashed, we are actually dealing with a copy
// of that state here. That copy should have caused the hash to be cleared.
if (initialState.getHash() != null) {
throw new IllegalStateException("Expected initial state to be unhashed");
}
- if (initialState.getSwirldState().getHash() != null) {
+ if (initialState.getHash() != null) {
throw new IllegalStateException("Expected initial swirld state to be unhashed");
}
- initialState.getSwirldState().init(platform, trigger, previousSoftwareVersion);
+ initialState.init(platform, trigger, previousSoftwareVersion);
abortAndThrowIfInterrupted(
() -> {
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java
index 8ed09fafd540..3363353ec5e0 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
import com.swirlds.platform.pool.TransactionPoolNexus;
import com.swirlds.platform.publisher.DefaultPlatformPublisher;
import com.swirlds.platform.publisher.PlatformPublisher;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.SwirldStateManager;
import com.swirlds.platform.state.nexus.DefaultLatestCompleteStateNexus;
@@ -365,7 +365,7 @@ private BirthRoundMigrationShim buildBirthRoundMigrationShim(
return null;
}
- final MerkleRoot state = initialState.getState();
+ final PlatformMerkleStateRoot state = initialState.getState();
final PlatformStateAccessor platformState = state.getReadablePlatformState();
return new DefaultBirthRoundMigrationShim(
@@ -515,6 +515,6 @@ public AutoCloseableWrapper getLatestImmutableState(@
final ReservedSignedState wrapper = latestImmutableStateNexus.getState(reason);
return wrapper == null
? AutoCloseableWrapper.empty()
- : new AutoCloseableWrapper<>((T) wrapper.get().getState().getSwirldState(), wrapper::close);
+ : new AutoCloseableWrapper<>((T) wrapper.get().getState(), wrapper::close);
}
}
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java
index 4606b861ed51..88566146dc68 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/GenesisPlatformStateCommand.java
@@ -95,7 +95,7 @@ public Integer call() throws IOException, ExecutionException, InterruptedExcepti
});
{
System.out.printf("Resetting the RosterService state %n");
- final State state = (State) reservedSignedState.get().getState().getSwirldState();
+ final State state = reservedSignedState.get().getState();
final WritableStates writableStates = state.getWritableStates(RosterStateId.NAME);
final WritableRosterStore writableRosterStore = new WritableRosterStore(writableStates);
writableRosterStore.resetRosters();
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/ValidateAddressBookStateCommand.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/ValidateAddressBookStateCommand.java
index 7b4b53bfd771..43be509a695d 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/ValidateAddressBookStateCommand.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/ValidateAddressBookStateCommand.java
@@ -31,7 +31,6 @@
import com.swirlds.platform.system.address.AddressBookUtils;
import com.swirlds.platform.system.address.AddressBookValidator;
import com.swirlds.platform.util.BootstrapUtils;
-import com.swirlds.state.State;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -81,7 +80,7 @@ public Integer call() throws IOException, ExecutionException, InterruptedExcepti
try (final ReservedSignedState reservedSignedState = deserializedSignedState.reservedSignedState()) {
System.out.printf("Extracting the state address book for comparison %n");
stateAddressBook = RosterUtils.buildAddressBook(RosterRetriever.retrieveActiveOrGenesisRoster(
- (State) reservedSignedState.get().getState().getSwirldState()));
+ reservedSignedState.get().getState()));
}
System.out.printf("Validating address book %n");
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/DefaultTransactionHandler.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/DefaultTransactionHandler.java
index 12e36f6ae397..c01d2b661f9c 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/DefaultTransactionHandler.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/DefaultTransactionHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
import com.swirlds.platform.event.PlatformEvent;
import com.swirlds.platform.internal.ConsensusRound;
import com.swirlds.platform.metrics.RoundHandlingMetrics;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.state.SwirldStateManager;
import com.swirlds.platform.state.signed.ReservedSignedState;
@@ -282,7 +282,7 @@ private StateAndRound createSignedState(
swirldStateManager.sealConsensusRound(consensusRound);
handlerMetrics.setPhase(GETTING_STATE_TO_SIGN);
- final MerkleRoot immutableStateCons = swirldStateManager.getStateForSigning();
+ final PlatformMerkleStateRoot immutableStateCons = swirldStateManager.getStateForSigning();
handlerMetrics.setPhase(CREATING_SIGNED_STATE);
final SignedState signedState = new SignedState(
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectHelper.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectHelper.java
index 2268e509265a..5fefc4912583 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectHelper.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
import com.swirlds.logging.legacy.payload.ReconnectStartPayload;
import com.swirlds.platform.config.StateConfig;
import com.swirlds.platform.network.Connection;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.state.signed.SignedStateValidator;
@@ -51,7 +51,7 @@ public class ReconnectHelper {
/** clears all data that is no longer needed since we fell behind */
private final Clearable clearAll;
/** supplier of the initial signed state against which to perform a delta based reconnect */
- private final Supplier workingStateSupplier;
+ private final Supplier workingStateSupplier;
/** provides the latest signed state round for which we have a supermajority of signatures */
private final LongSupplier lastCompleteRoundSupplier;
/** throttles reconnect learner attempts */
@@ -66,7 +66,7 @@ public class ReconnectHelper {
public ReconnectHelper(
final Runnable pauseGossip,
final Clearable clearAll,
- final Supplier workingStateSupplier,
+ final Supplier workingStateSupplier,
final LongSupplier lastCompleteRoundSupplier,
final ReconnectLearnerThrottle reconnectLearnerThrottle,
final Consumer loadSignedState,
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearner.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearner.java
index c92a02a0f808..67a2b6c4459b 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearner.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
import com.swirlds.platform.crypto.CryptoStatic;
import com.swirlds.platform.metrics.ReconnectMetrics;
import com.swirlds.platform.network.Connection;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SigSet;
import com.swirlds.platform.state.signed.SignedState;
@@ -57,7 +57,7 @@ public class ReconnectLearner {
private final Connection connection;
private final Roster roster;
- private final MerkleRoot currentState;
+ private final PlatformMerkleStateRoot currentState;
private final Duration reconnectSocketTimeout;
private final ReconnectMetrics statistics;
private final SignedStateValidationData stateValidationData;
@@ -89,7 +89,7 @@ public ReconnectLearner(
@NonNull final ThreadManager threadManager,
@NonNull final Connection connection,
@NonNull final Roster roster,
- @NonNull final MerkleRoot currentState,
+ @NonNull final PlatformMerkleStateRoot currentState,
@NonNull final Duration reconnectSocketTimeout,
@NonNull final ReconnectMetrics statistics) {
@@ -204,7 +204,7 @@ private ReservedSignedState reconnect() throws InterruptedException {
platformContext.getMetrics());
synchronizer.synchronize();
- final MerkleRoot state = (MerkleRoot) synchronizer.getRoot();
+ final PlatformMerkleStateRoot state = (PlatformMerkleStateRoot) synchronizer.getRoot();
final SignedState newSignedState = new SignedState(
platformContext.getConfiguration(),
CryptoStatic::verifySignature,
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearnerFactory.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearnerFactory.java
index ea1bb9342d0a..47fe3b7bfb34 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearnerFactory.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectLearnerFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
import com.swirlds.common.threading.manager.ThreadManager;
import com.swirlds.platform.metrics.ReconnectMetrics;
import com.swirlds.platform.network.Connection;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.time.Duration;
import java.util.Objects;
@@ -63,7 +63,7 @@ public ReconnectLearnerFactory(
* @param workingState the state to use to perform a delta based reconnect
* @return a new instance
*/
- public ReconnectLearner create(final Connection conn, final MerkleRoot workingState) {
+ public ReconnectLearner create(final Connection conn, final PlatformMerkleStateRoot workingState) {
return new ReconnectLearner(
platformContext, threadManager, conn, roster, workingState, reconnectSocketTimeout, statistics);
}
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectUtils.java
index 4a02423aca51..7a187fd6976f 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
import com.swirlds.common.merkle.crypto.MerkleCryptoFactory;
import com.swirlds.logging.legacy.payload.ReconnectFailurePayload;
import com.swirlds.platform.network.Connection;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
@@ -60,7 +60,7 @@ static void endReconnectHandshake(@NonNull final Connection connection) throws I
/**
* Hash the working state to prepare for reconnect
*/
- static void hashStateForReconnect(final MerkleRoot workingState) {
+ static void hashStateForReconnect(final PlatformMerkleStateRoot workingState) {
try {
MerkleCryptoFactory.getInstance().digestTreeAsync(workingState).get();
} catch (final ExecutionException e) {
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/EventRecoveryWorkflow.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/EventRecoveryWorkflow.java
index 5acb363bb1fe..a9e67fc85656 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/EventRecoveryWorkflow.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/EventRecoveryWorkflow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@
import com.swirlds.platform.recovery.internal.RecoveredState;
import com.swirlds.platform.recovery.internal.RecoveryPlatform;
import com.swirlds.platform.recovery.internal.StreamedRound;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.state.signed.ReservedSignedState;
@@ -185,7 +185,7 @@ public static void recoverState(
resultingStateDirectory);
// Make one more copy to force the state in recoveredState to be immutable.
- final MerkleRoot mutableStateCopy =
+ final PlatformMerkleStateRoot mutableStateCopy =
recoveredState.state().get().getState().copy();
SignedStateFileWriter.writeSignedStateFilesToDirectory(
@@ -376,7 +376,7 @@ private static ReservedSignedState handleNextRound(
final Instant currentRoundTimestamp = getRoundTimestamp(round);
previousState.get().getState().throwIfImmutable();
- final MerkleRoot newState = previousState.get().getState().copy();
+ final PlatformMerkleStateRoot newState = previousState.get().getState().copy();
final PlatformEvent lastEvent = ((CesEvent) getLastEvent(round)).getPlatformEvent();
new DefaultEventHasher().hashEvent(lastEvent);
@@ -397,7 +397,7 @@ private static ReservedSignedState handleNextRound(
applyTransactions(
previousState.get().getSwirldState().cast(),
- newState.getSwirldState().cast(),
+ newState.cast(),
newState.getWritablePlatformState(),
round);
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/BirthRoundStateMigration.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/BirthRoundStateMigration.java
index 925a96cb6e25..a1f5772cedf7 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/BirthRoundStateMigration.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/BirthRoundStateMigration.java
@@ -63,7 +63,7 @@ public static void modifyStateForBirthRoundMigration(
return;
}
- final MerkleRoot state = initialState.getState();
+ final PlatformMerkleStateRoot state = initialState.getState();
final PlatformStateModifier writablePlatformState = state.getWritablePlatformState();
final boolean alreadyMigrated = writablePlatformState.getFirstVersionInBirthRoundMode() != null;
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/MerkleRoot.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/MerkleRoot.java
deleted file mode 100644
index a3cf03cf860c..000000000000
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/MerkleRoot.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2024 Hedera Hashgraph, LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.swirlds.platform.state;
-
-import com.swirlds.common.merkle.MerkleInternal;
-import com.swirlds.platform.system.SwirldState;
-import edu.umd.cs.findbugs.annotations.NonNull;
-import java.nio.file.Path;
-
-/**
- * This interface represents the root node of the Merkle tree.
- */
-public interface MerkleRoot extends MerkleInternal {
- /**
- * Get the application state.
- *
- * @return the application state
- */
- @NonNull
- SwirldState getSwirldState();
- /**
- * Get readable platform state.
- * Works on both - mutable and immutable {@link MerkleRoot} and, therefore, this method should be preferred.
- *
- * @return immutable platform state
- */
- @NonNull
- PlatformStateAccessor getReadablePlatformState();
-
- /**
- * Get writable platform state. Works only on mutable {@link MerkleRoot}.
- * Call this method only if you need to modify the platform state.
- *
- * @return mutable platform state
- */
- @NonNull
- PlatformStateModifier getWritablePlatformState();
-
- /**
- * Set the platform state.
- *
- * @param platformState the platform state
- */
- void updatePlatformState(@NonNull final PlatformStateModifier platformState);
-
- /**
- * Generate a string that describes this state.
- *
- * @param hashDepth the depth of the tree to visit and print
- */
- @NonNull
- String getInfoString(final int hashDepth);
-
- /** {@inheritDoc} */
- @NonNull
- MerkleRoot copy();
-
- /** Creates a snapshots for the state. The state has to be hashed and immutable before calling this method.
- * @param targetPath The path to save the snapshot.
- */
- void createSnapshot(final @NonNull Path targetPath);
-}
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/PlatformMerkleStateRoot.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/PlatformMerkleStateRoot.java
index 7fff84b01b46..e4cb5cd77cc1 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/PlatformMerkleStateRoot.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/PlatformMerkleStateRoot.java
@@ -70,8 +70,7 @@
* consider nesting service nodes in a MerkleMap, or some other such approach to get a binary tree.
*/
@ConstructableIgnored
-public class PlatformMerkleStateRoot extends MerkleStateRoot
- implements SwirldState, MerkleRoot {
+public class PlatformMerkleStateRoot extends MerkleStateRoot implements SwirldState {
private static final long CLASS_ID = 0x8e300b0dfdafbb1aL;
/**
@@ -157,6 +156,9 @@ public void handleConsensusRound(
lifecycles.onHandleConsensusRound(round, this);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void sealConsensusRound(@NonNull final Round round) {
requireNonNull(round);
@@ -183,10 +185,12 @@ public Function getVersionFactory() {
}
/**
- * {@inheritDoc}
+ * Get writable platform state. Works only on mutable {@link PlatformMerkleStateRoot}.
+ * Call this method only if you need to modify the platform state.
+ *
+ * @return mutable platform state
*/
@NonNull
- @Override
public PlatformStateModifier getWritablePlatformState() {
if (isImmutable()) {
throw new IllegalStateException("Cannot get writable platform state when state is immutable");
@@ -199,16 +203,17 @@ public PlatformStateModifier getWritablePlatformState() {
*
* @param accessor a source of values
*/
- @Override
public void updatePlatformState(@NonNull final PlatformStateModifier accessor) {
writablePlatformStateStore().setAllFrom(accessor);
}
/**
- * {@inheritDoc}
+ * Get readable platform state.
+ * Works on both - mutable and immutable {@link PlatformMerkleStateRoot} and, therefore, this method should be preferred.
+ *
+ * @return immutable platform state
*/
@NonNull
- @Override
public PlatformStateAccessor getReadablePlatformState() {
return getServices().isEmpty()
? new SnapshotPlatformStateAccessor(getPlatformState(), versionFactory)
@@ -240,25 +245,17 @@ public long getCurrentRound() {
: getPlatformState().consensusSnapshot().round();
}
- /**
- * {@inheritDoc}
- */
- @NonNull
- @Override
- public SwirldState getSwirldState() {
- return this;
- }
-
@Override
public long getClassId() {
return CLASS_ID;
}
/**
- * {@inheritDoc}
+ * Generate a string that describes this state.
+ *
+ * @param hashDepth the depth of the tree to visit and print
*/
@NonNull
- @Override
public String getInfoString(final int hashDepth) {
return createInfoString(hashDepth, getReadablePlatformState(), getHash(), this);
}
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManager.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManager.java
index 06a9d89e1456..7630af120a77 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManager.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,12 +53,12 @@ public class SwirldStateManager implements FreezePeriodChecker {
/**
* reference to the state that reflects all known consensus transactions
*/
- private final AtomicReference stateRef = new AtomicReference<>();
+ private final AtomicReference stateRef = new AtomicReference<>();
/**
* The most recent immutable state. No value until the first fast copy is created.
*/
- private final AtomicReference latestImmutableState = new AtomicReference<>();
+ private final AtomicReference latestImmutableState = new AtomicReference<>();
/**
* Handle transactions by applying them to a state
@@ -107,7 +107,7 @@ public SwirldStateManager(
*
* @param state the initial state
*/
- public void setInitialState(@NonNull final MerkleRoot state) {
+ public void setInitialState(@NonNull final PlatformMerkleStateRoot state) {
Objects.requireNonNull(state);
state.throwIfDestroyed("state must not be destroyed");
state.throwIfImmutable("state must be mutable");
@@ -128,7 +128,7 @@ public void setInitialState(@NonNull final MerkleRoot state) {
* @param round the round to handle
*/
public List> handleConsensusRound(final ConsensusRound round) {
- final MerkleRoot state = stateRef.get();
+ final PlatformMerkleStateRoot state = stateRef.get();
uptimeTracker.handleRound(round);
transactionHandler.handleRound(round, state);
@@ -144,15 +144,15 @@ public List> handleConsensusR
*/
public void sealConsensusRound(@NonNull final Round round) {
Objects.requireNonNull(round);
- final MerkleRoot state = stateRef.get();
- state.getSwirldState().sealConsensusRound(round);
+ final PlatformMerkleStateRoot state = stateRef.get();
+ state.sealConsensusRound(round);
}
/**
* Returns the consensus state. The consensus state could become immutable at any time. Modifications must not be
* made to the returned state.
*/
- public MerkleRoot getConsensusState() {
+ public PlatformMerkleStateRoot getConsensusState() {
return stateRef.get();
}
@@ -176,7 +176,7 @@ public void savedStateInFreezePeriod() {
* @param signedState the signed state to load
*/
public void loadFromSignedState(@NonNull final SignedState signedState) {
- final MerkleRoot state = signedState.getState();
+ final PlatformMerkleStateRoot state = signedState.getState();
state.throwIfDestroyed("state must not be destroyed");
state.throwIfImmutable("state must be mutable");
@@ -184,8 +184,8 @@ public void loadFromSignedState(@NonNull final SignedState signedState) {
fastCopyAndUpdateRefs(state);
}
- private void fastCopyAndUpdateRefs(final MerkleRoot state) {
- final MerkleRoot consState = fastCopy(state, stats, softwareVersion);
+ private void fastCopyAndUpdateRefs(final PlatformMerkleStateRoot state) {
+ final PlatformMerkleStateRoot consState = fastCopy(state, stats, softwareVersion);
// Set latest immutable first to prevent the newly immutable state from being deleted between setting the
// stateRef and the latestImmutableState
@@ -198,8 +198,8 @@ private void fastCopyAndUpdateRefs(final MerkleRoot state) {
*
* @param state the new mutable state
*/
- private void setState(final MerkleRoot state) {
- final MerkleRoot currVal = stateRef.get();
+ private void setState(final PlatformMerkleStateRoot state) {
+ final PlatformMerkleStateRoot currVal = stateRef.get();
if (currVal != null) {
currVal.release();
}
@@ -208,8 +208,8 @@ private void setState(final MerkleRoot state) {
stateRef.set(state);
}
- private void setLatestImmutableState(final MerkleRoot immutableState) {
- final MerkleRoot currVal = latestImmutableState.get();
+ private void setLatestImmutableState(final PlatformMerkleStateRoot immutableState) {
+ final PlatformMerkleStateRoot currVal = latestImmutableState.get();
if (currVal != null) {
currVal.release();
}
@@ -237,9 +237,9 @@ public boolean isInFreezePeriod(final Instant timestamp) {
* event handling may or may not be blocked depending on the implementation.
*
* @return a copy of the state to use for the next signed state
- * @see MerkleRoot#copy()
+ * @see PlatformMerkleStateRoot#copy()
*/
- public MerkleRoot getStateForSigning() {
+ public PlatformMerkleStateRoot getStateForSigning() {
fastCopyAndUpdateRefs(stateRef.get());
return latestImmutableState.get();
}
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerUtils.java
index bb42bcd48af6..efbff35b36a4 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,15 +34,15 @@ public final class SwirldStateManagerUtils {
private SwirldStateManagerUtils() {}
/**
- * Performs a fast copy on a {@link MerkleRoot}. The {@code state} must not be modified during execution of this method.
+ * Performs a fast copy on a {@link PlatformMerkleStateRoot}. The {@code state} must not be modified during execution of this method.
*
* @param state the state object to fast copy
* @param stats object to record stats in
* @param softwareVersion the current software version
* @return the newly created state copy
*/
- public static MerkleRoot fastCopy(
- @NonNull final MerkleRoot state,
+ public static PlatformMerkleStateRoot fastCopy(
+ @NonNull final PlatformMerkleStateRoot state,
@NonNull final SwirldStateMetrics stats,
@NonNull final SoftwareVersion softwareVersion) {
@@ -51,7 +51,7 @@ public static MerkleRoot fastCopy(
final long copyStart = System.nanoTime();
// Create a fast copy
- final MerkleRoot copy = state.copy();
+ final PlatformMerkleStateRoot copy = state.copy();
final var platformState = copy.getWritablePlatformState();
platformState.setCreationSoftwareVersion(softwareVersion);
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java
index 59f7c3374cff..9f40a4671f86 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,12 +52,12 @@ public TransactionHandler(final NodeId selfId, final SwirldStateMetrics stats) {
* @param state
* the state to apply {@code round} to
*/
- public void handleRound(final ConsensusRound round, final MerkleRoot state) {
+ public void handleRound(final ConsensusRound round, final PlatformMerkleStateRoot state) {
try {
final Instant timeOfHandle = Instant.now();
final long startTime = System.nanoTime();
- state.getSwirldState().handleConsensusRound(round, state.getWritablePlatformState(), NO_OP_CONSUMER);
+ state.handleConsensusRound(round, state.getWritablePlatformState(), NO_OP_CONSUMER);
final double secondsElapsed = (System.nanoTime() - startTime) * NANOSECONDS_TO_SECONDS;
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookInitializer.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookInitializer.java
index 15cc9a257794..9e174784b375 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookInitializer.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookInitializer.java
@@ -1,4 +1,19 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.swirlds.platform.state.address;
import static com.swirlds.logging.legacy.LogMarker.EXCEPTION;
@@ -14,7 +29,6 @@
import com.swirlds.platform.system.address.Address;
import com.swirlds.platform.system.address.AddressBook;
import com.swirlds.platform.system.address.AddressBookValidator;
-import com.swirlds.state.State;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.File;
@@ -118,8 +132,7 @@ public AddressBookInitializer(
platformContext.getConfiguration().getConfigData(AddressBookConfig.class);
this.initialState = Objects.requireNonNull(initialState, "The initialState must not be null.");
- final var book = buildAddressBook(
- retrieveActiveOrGenesisRoster((State) initialState.getState().getSwirldState()));
+ final var book = buildAddressBook(retrieveActiveOrGenesisRoster(initialState.getState()));
this.stateAddressBook = (book == null || book.getSize() == 0) ? null : book;
if (stateAddressBook == null && !initialState.isGenesisState()) {
throw new IllegalStateException("Only genesis states can have null address books.");
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/hashlogger/DefaultHashLogger.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/hashlogger/DefaultHashLogger.java
index 27fef2693beb..5c5a0a8b6c40 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/hashlogger/DefaultHashLogger.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/hashlogger/DefaultHashLogger.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
import com.swirlds.common.context.PlatformContext;
import com.swirlds.platform.config.StateConfig;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -107,7 +107,7 @@ public void logHashes(@NonNull final ReservedSignedState reservedState) {
*/
@NonNull
private Message generateLogMessage(@NonNull final SignedState signedState) {
- final MerkleRoot state = signedState.getState();
+ final PlatformMerkleStateRoot state = signedState.getState();
final String platformInfo = state.getInfoString(depth);
return MESSAGE_FACTORY.newMessage(
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedState.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedState.java
index 4b2f9e462f96..0f1da7772bf9 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedState.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedState.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,12 +39,11 @@
import com.swirlds.platform.crypto.SignatureVerifier;
import com.swirlds.platform.roster.RosterRetriever;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.SignedStateHistory.SignedStateAction;
import com.swirlds.platform.state.snapshot.StateToDiskReason;
import com.swirlds.platform.system.SwirldState;
import com.swirlds.platform.system.address.Address;
-import com.swirlds.state.merkle.MerkleStateRoot;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.security.cert.X509Certificate;
@@ -106,7 +105,7 @@ public class SignedState implements SignedStateInfo {
/**
* The root of the merkle state.
*/
- private final MerkleRoot state;
+ private final PlatformMerkleStateRoot state;
/**
* The timestamp of when this object was created.
@@ -188,7 +187,7 @@ public class SignedState implements SignedStateInfo {
public SignedState(
@NonNull final Configuration configuration,
@NonNull final SignatureVerifier signatureVerifier,
- @NonNull final MerkleRoot state,
+ @NonNull final PlatformMerkleStateRoot state,
@NonNull final String reason,
final boolean freezeState,
final boolean deleteOnBackgroundThread,
@@ -270,8 +269,7 @@ public void setSigSet(@NonNull final SigSet sigSet) {
Ideally the roster would be captured in the constructor but due to the mutable underlying state, the roster
can change from underneath us. Therefore, the roster must be regenerated on each access.
*/
- final Roster roster = RosterRetriever.retrieveActiveOrGenesisRoster(
- (MerkleStateRoot) getState().getSwirldState());
+ final Roster roster = RosterRetriever.retrieveActiveOrGenesisRoster(state);
return requireNonNull(roster, "Roster stored in signed state is null (this should never happen)");
}
@@ -281,7 +279,7 @@ public void setSigSet(@NonNull final SigSet sigSet) {
*
* @return the state contained in the signed state
*/
- public @NonNull MerkleRoot getState() {
+ public @NonNull PlatformMerkleStateRoot getState() {
return state;
}
@@ -484,7 +482,7 @@ public String toString() {
* @return the root node of the application's state.
*/
public @NonNull SwirldState getSwirldState() {
- return state.getSwirldState();
+ return state;
}
/**
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java
index 60c29102456f..f6414825dac2 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/StartupStateUtils.java
@@ -37,7 +37,7 @@
import com.swirlds.platform.internal.SignedStateLoadingException;
import com.swirlds.platform.roster.RosterRetriever;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.state.snapshot.DeserializedSignedState;
import com.swirlds.platform.state.snapshot.SavedStateInfo;
@@ -85,7 +85,7 @@ public static HashedReservedSignedState getInitialState(
@NonNull final Configuration configuration,
@NonNull final RecycleBin recycleBin,
@NonNull final SoftwareVersion softwareVersion,
- @NonNull final Supplier genesisStateBuilder,
+ @NonNull final Supplier genesisStateBuilder,
@NonNull final String mainClassName,
@NonNull final String swirldName,
@NonNull final NodeId selfId,
@@ -172,7 +172,7 @@ public static ReservedSignedState loadStateFile(
requireNonNull(configuration);
requireNonNull(initialSignedState);
- final MerkleRoot stateCopy = initialSignedState.getState().copy();
+ final PlatformMerkleStateRoot stateCopy = initialSignedState.getState().copy();
final SignedState signedStateCopy = new SignedState(
configuration,
CryptoStatic::verifySignature,
@@ -266,7 +266,7 @@ private static ReservedSignedState loadStateFile(
}
}
- final MerkleRoot state =
+ final PlatformMerkleStateRoot state =
deserializedSignedState.reservedSignedState().get().getState();
final Hash oldHash = deserializedSignedState.originalHash();
@@ -326,15 +326,10 @@ private static ReservedSignedState buildGenesisState(
@NonNull final Configuration configuration,
@NonNull final AddressBook addressBook,
@NonNull final SoftwareVersion appVersion,
- @NonNull final MerkleRoot stateRoot) {
+ @NonNull final PlatformMerkleStateRoot stateRoot) {
if (!configuration.getConfigData(AddressBookConfig.class).useRosterLifecycle()) {
- initGenesisState(
- configuration,
- (State) stateRoot.getSwirldState(),
- stateRoot.getWritablePlatformState(),
- addressBook,
- appVersion);
+ initGenesisState(configuration, stateRoot, stateRoot.getWritablePlatformState(), addressBook, appVersion);
}
final SignedState signedState = new SignedState(
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SavedStateMetadata.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SavedStateMetadata.java
index f684241e94a2..5325751bd92f 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SavedStateMetadata.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SavedStateMetadata.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,6 @@
import com.swirlds.platform.roster.RosterUtils;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.signed.SignedState;
-import com.swirlds.state.State;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.BufferedReader;
@@ -172,8 +171,7 @@ public static SavedStateMetadata create(
Objects.requireNonNull(now, "now must not be null");
final PlatformStateAccessor platformState = signedState.getState().getReadablePlatformState();
- final Roster roster = RosterRetriever.retrieveActiveOrGenesisRoster(
- (State) signedState.getState().getSwirldState());
+ final Roster roster = RosterRetriever.retrieveActiveOrGenesisRoster(signedState.getState());
final List signingNodes = signedState.getSigSet().getSigningNodes();
Collections.sort(signingNodes);
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileReader.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileReader.java
index 322e36c5a94a..e98b289cea32 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileReader.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
import com.swirlds.common.platform.NodeId;
import com.swirlds.config.api.Configuration;
import com.swirlds.platform.crypto.CryptoStatic;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.service.PlatformStateService;
import com.swirlds.platform.state.service.schemas.V0540PlatformStateSchema;
import com.swirlds.platform.state.service.schemas.V0540RosterBaseSchema;
@@ -106,7 +106,7 @@ public static List getSavedStateFiles(
final SignedState newSignedState = new SignedState(
configuration,
CryptoStatic::verifySignature,
- (MerkleRoot) data.stateRoot(),
+ (PlatformMerkleStateRoot) data.stateRoot(),
"SignedStateFileReader.readStateFile()",
false,
false,
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileWriter.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileWriter.java
index 87407dc7d3f8..972c87c2bdbf 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileWriter.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/snapshot/SignedStateFileWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,11 +35,10 @@
import com.swirlds.platform.config.StateConfig;
import com.swirlds.platform.recovery.emergencyfile.EmergencyRecoveryFile;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.SigSet;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.system.address.AddressBook;
-import com.swirlds.state.merkle.MerkleStateRoot;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.BufferedWriter;
@@ -70,7 +69,7 @@ private SignedStateFileWriter() {}
* @param directory the directory where the state is being written
*/
public static void writeHashInfoFile(
- @NonNull final PlatformContext platformContext, final Path directory, final MerkleRoot state)
+ @NonNull final PlatformContext platformContext, final Path directory, final PlatformMerkleStateRoot state)
throws IOException {
final StateConfig stateConfig = platformContext.getConfiguration().getConfigData(StateConfig.class);
final String platformInfo = state.getInfoString(stateConfig.debugHashDepth());
@@ -151,10 +150,8 @@ public static void writeSignedStateFilesToDirectory(
Objects.requireNonNull(directory);
Objects.requireNonNull(signedState);
- final MerkleRoot state = signedState.getState();
- if (state instanceof MerkleStateRoot merkleStateRoot) {
- merkleStateRoot.setTime(platformContext.getTime());
- }
+ final PlatformMerkleStateRoot state = signedState.getState();
+ state.setTime(platformContext.getTime());
state.createSnapshot(directory);
writeSignatureSetFile(directory, signedState);
writeHashInfoFile(platformContext, directory, signedState.getState());
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/SwirldMain.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/SwirldMain.java
index 588a58b8e530..35a902c9821f 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/SwirldMain.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/SwirldMain.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
package com.swirlds.platform.system;
import com.swirlds.common.platform.NodeId;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.List;
@@ -67,7 +67,7 @@ default List> getConfigDataTypes() {
* @return merkle state tree root node
*/
@NonNull
- MerkleRoot newMerkleStateRoot();
+ PlatformMerkleStateRoot newMerkleStateRoot();
/**
*
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java
index 3e7991e05800..8a1d5fd6ed23 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/address/AddressBookUtils.java
@@ -251,7 +251,7 @@ public static ServiceEndpoint endpointFor(@NonNull final String host, final int
// Initialize the address book from the configuration and platform saved state.
final AddressBookInitializer addressBookInitializer = new AddressBookInitializer(
selfId, version, softwareUpgrade, initialState.get(), bootstrapAddressBook.copy(), platformContext);
- final State state = (State) initialState.get().getState().getSwirldState();
+ final State state = initialState.get().getState();
if (addressBookInitializer.hasAddressBookChanged()) {
if (addressBookInitializer.getPreviousAddressBook() != null) {
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/util/BootstrapUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/util/BootstrapUtils.java
index 080f643123a4..71657da66a3b 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/util/BootstrapUtils.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/util/BootstrapUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@
import com.swirlds.platform.health.entropy.OSEntropyChecker;
import com.swirlds.platform.health.filesystem.OSFileSystemChecker;
import com.swirlds.platform.network.Network;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.address.AddressBookNetworkUtils;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.swirldapp.AppLoaderException;
@@ -213,7 +213,7 @@ public static boolean detectSoftwareUpgrade(
if (loadedSignedState == null) {
loadedSoftwareVersion = null;
} else {
- MerkleRoot state = loadedSignedState.getState();
+ PlatformMerkleStateRoot state = loadedSignedState.getState();
loadedSoftwareVersion = state.getReadablePlatformState().getCreationSoftwareVersion();
}
final int versionComparison = loadedSoftwareVersion == null ? 1 : appVersion.compareTo(loadedSoftwareVersion);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/AddressBookInitializerTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/AddressBookInitializerTest.java
index 8d2bf9aa94ad..4db717f954be 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/AddressBookInitializerTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/AddressBookInitializerTest.java
@@ -1,4 +1,19 @@
-// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.swirlds.platform;
import static com.swirlds.platform.roster.RosterUtils.buildAddressBook;
@@ -16,7 +31,6 @@
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.withSettings;
import com.hedera.hapi.node.state.roster.Roster;
import com.swirlds.common.context.PlatformContext;
@@ -27,18 +41,16 @@
import com.swirlds.config.extensions.test.fixtures.TestConfigBuilder;
import com.swirlds.platform.config.AddressBookConfig_;
import com.swirlds.platform.roster.RosterRetriever;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.address.AddressBookInitializer;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.system.SoftwareVersion;
-import com.swirlds.platform.system.SwirldState;
import com.swirlds.platform.system.address.Address;
import com.swirlds.platform.system.address.AddressBook;
import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder;
import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
import com.swirlds.platform.test.fixtures.roster.RosterServiceStateMock;
-import com.swirlds.state.State;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.File;
@@ -379,15 +391,14 @@ private SignedState getMockSignedState(
boolean fromGenesis) {
final SignedState signedState = mock(SignedState.class);
final SoftwareVersion softwareVersion = getMockSoftwareVersion(2);
- final SwirldState swirldState = getMockSwirldStateSupplier(weightValue).get();
- when(signedState.getSwirldState()).thenReturn(swirldState);
+ final PlatformMerkleStateRoot state =
+ getMockSwirldStateSupplier(weightValue).get();
+ when(signedState.getSwirldState()).thenReturn(state);
final PlatformStateAccessor platformState = mock(PlatformStateAccessor.class);
when(platformState.getCreationSoftwareVersion()).thenReturn(softwareVersion);
- RosterServiceStateMock.setup(
- (State) swirldState, currentRoster, 1L, RosterRetriever.buildRoster(previousAddressBook));
- final MerkleRoot state = mock(MerkleRoot.class);
+ RosterServiceStateMock.setup(state, currentRoster, 1L, RosterRetriever.buildRoster(previousAddressBook));
+
when(state.getReadablePlatformState()).thenReturn(platformState);
- when(state.getSwirldState()).thenReturn(swirldState);
when(signedState.getState()).thenReturn(state);
when(signedState.isGenesisState()).thenReturn(fromGenesis);
when(signedState.getRoster()).thenReturn(currentRoster);
@@ -400,10 +411,10 @@ private SignedState getMockSignedState(
* @param scenario The scenario to load.
* @return A SwirldState which behaves according to the input scenario.
*/
- private Supplier getMockSwirldStateSupplier(int scenario) {
+ private Supplier getMockSwirldStateSupplier(int scenario) {
final AtomicReference configAddressBook = new AtomicReference<>();
- final SwirldState swirldState = mock(SwirldState.class, withSettings().extraInterfaces(State.class));
+ final PlatformMerkleStateRoot swirldState = mock(PlatformMerkleStateRoot.class);
final OngoingStubbing stub = when(swirldState.updateWeight(
argThat(confAB -> {
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SavedStateMetadataTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SavedStateMetadataTests.java
index 66d513611c38..9858084d3b14 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SavedStateMetadataTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SavedStateMetadataTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,14 +37,13 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.withSettings;
import com.hedera.hapi.node.state.roster.Roster;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.platform.NodeId;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.platform.consensus.ConsensusSnapshot;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.signed.SigSet;
import com.swirlds.platform.state.signed.SignedState;
@@ -52,9 +51,7 @@
import com.swirlds.platform.state.snapshot.SavedStateMetadataField;
import com.swirlds.platform.system.BasicSoftwareVersion;
import com.swirlds.platform.system.SoftwareVersion;
-import com.swirlds.platform.system.SwirldState;
import com.swirlds.platform.test.fixtures.roster.RosterServiceStateMock;
-import com.swirlds.state.State;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.nio.file.Files;
@@ -209,16 +206,14 @@ void signingNodesSortedTest() {
final SignedState signedState = mock(SignedState.class);
final SigSet sigSet = mock(SigSet.class);
- final MerkleRoot state = mock(MerkleRoot.class);
+ final PlatformMerkleStateRoot state = mock(PlatformMerkleStateRoot.class);
when(state.getHash()).thenReturn(randomHash(random));
final PlatformStateAccessor platformState = mock(PlatformStateAccessor.class);
when(platformState.getLegacyRunningEventHash()).thenReturn(randomHash(random));
when(platformState.getSnapshot()).thenReturn(mock(ConsensusSnapshot.class));
final Roster roster = mock(Roster.class);
- final State theState = mock(State.class, withSettings().extraInterfaces(SwirldState.class));
- when(state.getSwirldState()).thenReturn((SwirldState) theState);
- RosterServiceStateMock.setup(theState, roster);
+ RosterServiceStateMock.setup(state, roster);
when(signedState.getState()).thenReturn(state);
when(state.getReadablePlatformState()).thenReturn(platformState);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java
index b611d823dfff..d48611bafb62 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@
import com.swirlds.config.extensions.test.fixtures.TestConfigBuilder;
import com.swirlds.merkledb.MerkleDb;
import com.swirlds.platform.config.StateConfig;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.state.snapshot.DeserializedSignedState;
import com.swirlds.platform.state.snapshot.SignedStateFileUtils;
@@ -107,7 +107,7 @@ void writeHashInfoFileTest() throws IOException {
final SignedState signedState = new RandomSignedStateGenerator()
.setSoftwareVersion(new BasicSoftwareVersion(platformVersion.minor()))
.build();
- MerkleRoot state = signedState.getState();
+ PlatformMerkleStateRoot state = signedState.getState();
writeHashInfoFile(platformContext, testDirectory, state);
final StateConfig stateConfig =
new TestConfigBuilder().getOrCreateConfig().getConfigData(StateConfig.class);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/consensus/RoundCalculationUtilsTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/consensus/RoundCalculationUtilsTest.java
index 5fdda8434044..477d12c0f578 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/consensus/RoundCalculationUtilsTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/consensus/RoundCalculationUtilsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.system.events.EventConstants;
@@ -69,7 +69,7 @@ void getMinGenNonAncientFromSignedState() {
final Map map =
LongStream.range(1, 50).collect(HashMap::new, (m, l) -> m.put(l, l * 10), HashMap::putAll);
final SignedState signedState = mock(SignedState.class);
- final MerkleRoot state = mock(MerkleRoot.class);
+ final PlatformMerkleStateRoot state = mock(PlatformMerkleStateRoot.class);
final PlatformStateModifier platformState = mock(PlatformStateModifier.class);
when(signedState.getState()).thenReturn(state);
when(state.getReadablePlatformState()).thenReturn(platformState);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/DefaultTransactionHandlerTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/DefaultTransactionHandlerTests.java
index 125d4a27678c..037f5c12b3d4 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/DefaultTransactionHandlerTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/DefaultTransactionHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -156,8 +156,7 @@ void normalOperation(final boolean pcesRound) throws InterruptedException {
pcesRound,
handlerOutput.reservedSignedState().get().isPcesRound(),
"the state should match the PCES boolean");
- verify(tester.getSwirldStateManager().getConsensusState().getSwirldState())
- .sealConsensusRound(consensusRound);
+ verify(tester.getSwirldStateManager().getConsensusState()).sealConsensusRound(consensusRound);
}
@Test
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/TransactionHandlerTester.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/TransactionHandlerTester.java
index b985df4b09a9..2fac032faca8 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/TransactionHandlerTester.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/TransactionHandlerTester.java
@@ -25,7 +25,7 @@
import com.swirlds.common.platform.NodeId;
import com.swirlds.common.test.fixtures.platform.TestPlatformContextBuilder;
import com.swirlds.platform.roster.RosterRetriever;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.state.SwirldStateManager;
import com.swirlds.platform.state.service.PlatformStateValueAccumulator;
@@ -59,9 +59,7 @@ public TransactionHandlerTester(final AddressBook addressBook) {
TestPlatformContextBuilder.create().build();
platformState = new PlatformStateValueAccumulator();
- final MerkleRoot consensusState = mock(MerkleRoot.class);
- final SwirldState swirldState = mock(SwirldState.class);
- when(consensusState.getSwirldState()).thenReturn(swirldState);
+ final PlatformMerkleStateRoot consensusState = mock(PlatformMerkleStateRoot.class);
when(consensusState.copy()).thenReturn(consensusState);
when(consensusState.getReadablePlatformState()).thenReturn(platformState);
when(consensusState.getWritablePlatformState()).thenReturn(platformState);
@@ -69,7 +67,7 @@ public TransactionHandlerTester(final AddressBook addressBook) {
handledRounds.add(i.getArgument(0));
return null;
})
- .when(swirldState)
+ .when(consensusState)
.handleConsensusRound(any(), any(), any());
final StatusActionSubmitter statusActionSubmitter = submittedActions::add;
swirldStateManager = new SwirldStateManager(
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java
index 9403b24625a0..0c99753b12c3 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@
import com.swirlds.platform.network.protocol.Protocol;
import com.swirlds.platform.network.protocol.ProtocolFactory;
import com.swirlds.platform.network.protocol.ReconnectProtocolFactory;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.state.signed.SignedStateValidator;
@@ -308,7 +308,7 @@ void testTeacherThrottleReleased() {
Time.getCurrent());
final SignedState signedState = spy(new RandomSignedStateGenerator().build());
when(signedState.isComplete()).thenReturn(true);
- final MerkleRoot state = mock(MerkleRoot.class);
+ final PlatformMerkleStateRoot state = mock(PlatformMerkleStateRoot.class);
when(signedState.getState()).thenReturn(state);
final ReservedSignedState reservedSignedState = signedState.reserve("test");
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectTest.java
index dc133ae5adc4..ab823330c2c9 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectTest.java
@@ -39,7 +39,7 @@
import com.swirlds.platform.metrics.ReconnectMetrics;
import com.swirlds.platform.network.Connection;
import com.swirlds.platform.network.SocketConnection;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.state.signed.SignedStateValidator;
import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
@@ -182,7 +182,7 @@ private ReconnectTeacher buildSender(final SocketConnection connection, final Re
}
private ReconnectLearner buildReceiver(
- final MerkleRoot state, final Connection connection, final ReconnectMetrics reconnectMetrics) {
+ final PlatformMerkleStateRoot state, final Connection connection, final ReconnectMetrics reconnectMetrics) {
final Roster roster =
RandomRosterBuilder.create(getRandomPrintSeed()).withSize(5).build();
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/StateRegistryTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/StateRegistryTests.java
index 0165713bc1ed..0da53f98a5bb 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/StateRegistryTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/StateRegistryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ void activeStateCountTest() throws IOException {
RuntimeObjectRegistry.getActiveObjectsCount(PlatformMerkleStateRoot.class),
"no states have been created yet");
- final List states = new LinkedList<>();
+ final List states = new LinkedList<>();
// Create a bunch of states
for (int i = 0; i < 100; i++) {
states.add(new PlatformMerkleStateRoot(FAKE_MERKLE_STATE_LIFECYCLES, softwareVersionSupplier));
@@ -94,10 +94,10 @@ void activeStateCountTest() throws IOException {
}
// Fast copy a state
- final MerkleRoot stateToCopy =
+ final PlatformMerkleStateRoot stateToCopy =
new PlatformMerkleStateRoot(FAKE_MERKLE_STATE_LIFECYCLES, softwareVersionSupplier);
states.add(stateToCopy);
- final MerkleRoot copyOfStateToCopy = stateToCopy.copy();
+ final PlatformMerkleStateRoot copyOfStateToCopy = stateToCopy.copy();
states.add(copyOfStateToCopy);
assertEquals(
states.size(),
@@ -120,7 +120,7 @@ void activeStateCountTest() throws IOException {
final InputOutputStream io = new InputOutputStream();
io.getOutput().writeMerkleTree(dir, stateToSerialize);
io.startReading();
- final MerkleRoot deserializedState = io.getInput().readMerkleTree(dir, 5);
+ final PlatformMerkleStateRoot deserializedState = io.getInput().readMerkleTree(dir, 5);
states.add(deserializedState);
assertEquals(
states.size(),
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerTests.java
index 21238be8a06d..80ccb927b3c7 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
class SwirldStateManagerTests {
private SwirldStateManager swirldStateManager;
- private MerkleRoot initialState;
+ private PlatformMerkleStateRoot initialState;
@BeforeEach
void setup() {
@@ -125,7 +125,7 @@ void loadFromSignedStateRefCount() {
+ "decremented.");
}
- private static MerkleRoot newState() {
+ private static PlatformMerkleStateRoot newState() {
final PlatformMerkleStateRoot state = new PlatformMerkleStateRoot(
FAKE_MERKLE_STATE_LIFECYCLES, version -> new BasicSoftwareVersion(version.major()));
FAKE_MERKLE_STATE_LIFECYCLES.initPlatformState(state);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerUtilsTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerUtilsTests.java
index 76cfe53cde02..4bf8fc0bbed8 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerUtilsTests.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerUtilsTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,8 @@ void testFastCopyIsMutable() {
FAKE_MERKLE_STATE_LIFECYCLES.initPlatformState(state);
state.reserve();
final SwirldStateMetrics stats = mock(SwirldStateMetrics.class);
- final MerkleRoot result = SwirldStateManagerUtils.fastCopy(state, stats, new BasicSoftwareVersion(1));
+ final PlatformMerkleStateRoot result =
+ SwirldStateManagerUtils.fastCopy(state, stats, new BasicSoftwareVersion(1));
assertFalse(result.isImmutable(), "The copy state should be mutable.");
assertEquals(
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/hashlogger/HashLoggerTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/hashlogger/HashLoggerTest.java
index 09d5beadc45e..3b56272a8e6f 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/hashlogger/HashLoggerTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/hashlogger/HashLoggerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@
import com.swirlds.config.api.Configuration;
import com.swirlds.config.extensions.test.fixtures.TestConfigBuilder;
import com.swirlds.platform.config.StateConfig_;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateAccessor;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
@@ -150,7 +150,8 @@ private ReservedSignedState createSignedState(final long round) {
final MerkleNode merkleNode = MerkleTestUtils.buildLessSimpleTree();
MerkleCryptoFactory.getInstance().digestTreeSync(merkleNode);
final SignedState signedState = mock(SignedState.class);
- final MerkleRoot state = mock(MerkleRoot.class, withSettings().extraInterfaces(State.class, SwirldState.class));
+ final PlatformMerkleStateRoot state =
+ mock(PlatformMerkleStateRoot.class, withSettings().extraInterfaces(State.class, SwirldState.class));
final PlatformStateAccessor platformState = mock(PlatformStateAccessor.class);
when(platformState.getRound()).thenReturn(round);
@@ -160,7 +161,6 @@ private ReservedSignedState createSignedState(final long round) {
when(state.getHash()).thenReturn(merkleNode.getHash());
when(signedState.getState()).thenReturn(state);
- when(state.getSwirldState()).thenReturn((SwirldState) state);
when(signedState.getRound()).thenReturn(round);
ReservedSignedState reservedSignedState = mock(ReservedSignedState.class);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/system/state/notifications/StateHashedNotificationTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/system/state/notifications/StateHashedNotificationTest.java
index 3f6c32024fc7..f44c8b942200 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/system/state/notifications/StateHashedNotificationTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/system/state/notifications/StateHashedNotificationTest.java
@@ -23,7 +23,7 @@
import com.swirlds.common.crypto.Hash;
import com.swirlds.platform.components.transaction.system.ScopedSystemTransaction;
import com.swirlds.platform.internal.ConsensusRound;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.wiring.components.StateAndRound;
@@ -39,7 +39,7 @@ class StateHashedNotificationTest {
private static final Hash HASH = new Hash(new byte[48]);
@Mock
- private MerkleRoot merkleRoot;
+ private PlatformMerkleStateRoot merkleRoot;
@Mock
private SignedState signedState;
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleNode.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleNode.java
index b3f17736b056..227ef6dd2588 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleNode.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleNode.java
@@ -37,7 +37,7 @@
import com.swirlds.platform.config.BasicConfig_;
import com.swirlds.platform.crypto.KeysAndCerts;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.system.BasicSoftwareVersion;
import com.swirlds.platform.system.Platform;
import com.swirlds.platform.system.address.AddressBook;
@@ -103,7 +103,7 @@ public class TurtleNode {
model = WiringModelBuilder.create(platformContext)
.withDeterministicModeEnabled(true)
.build();
- final Supplier genesisStateSupplier = TurtleTestingToolState::getStateRootNode;
+ final Supplier genesisStateSupplier = TurtleTestingToolState::getStateRootNode;
final var version = new BasicSoftwareVersion(1);
final var metrics = getMetricsProvider().createPlatformMetrics(nodeId);
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleTestingToolState.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleTestingToolState.java
index f4547d45a1cd..9e9231159cbe 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleTestingToolState.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/turtle/runner/TurtleTestingToolState.java
@@ -107,7 +107,7 @@ public TurtleTestingToolState copy() {
* @return merkle tree root
*/
@NonNull
- public static MerkleRoot getStateRootNode() {
+ public static PlatformMerkleStateRoot getStateRootNode() {
final PlatformMerkleStateRoot state = new TurtleTestingToolState();
FAKE_MERKLE_STATE_LIFECYCLES.initPlatformState(state);
return state;
diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/SignedStateReserverTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/SignedStateReserverTest.java
index 2ac17245facf..a1acab1071d8 100644
--- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/SignedStateReserverTest.java
+++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/wiring/SignedStateReserverTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
import com.swirlds.common.wiring.wires.input.BindableInputWire;
import com.swirlds.common.wiring.wires.output.OutputWire;
import com.swirlds.platform.crypto.SignatureVerifier;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.ReservedSignedState;
import com.swirlds.platform.state.signed.SignedState;
import java.util.List;
@@ -51,7 +51,7 @@ void basicTest() {
final SignedState signedState = new SignedState(
platformContext.getConfiguration(),
Mockito.mock(SignatureVerifier.class),
- Mockito.mock(MerkleRoot.class),
+ Mockito.mock(PlatformMerkleStateRoot.class),
"create",
false,
false,
diff --git a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/BlockingSwirldState.java b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/BlockingSwirldState.java
index 29b3ade2f864..7b18be87da68 100644
--- a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/BlockingSwirldState.java
+++ b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/BlockingSwirldState.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
import com.swirlds.common.io.streams.SerializableDataInputStream;
import com.swirlds.common.io.streams.SerializableDataOutputStream;
import com.swirlds.platform.components.transaction.system.ScopedSystemTransaction;
-import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateModifier;
import com.swirlds.platform.system.BasicSoftwareVersion;
@@ -41,8 +40,8 @@
import java.util.function.Consumer;
/**
- * A test implementation of {@link MerkleRoot} and {@link SwirldState} state for SignedStateManager unit tests.
- * Node that some of the {@link MerkleRoot} methods are intentionally not implemented. If a test needs these methods,
+ * A test implementation of {@link PlatformMerkleStateRoot} and {@link SwirldState} state for SignedStateManager unit tests.
+ * Node that some of the {@link PlatformMerkleStateRoot} methods are intentionally not implemented. If a test needs these methods,
* {@link MerkleStateRoot} should be used instead.
*/
public class BlockingSwirldState extends PlatformMerkleStateRoot {
diff --git a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/RandomSignedStateGenerator.java b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/RandomSignedStateGenerator.java
index 15069294bd83..80536e8ea87a 100644
--- a/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/RandomSignedStateGenerator.java
+++ b/platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/RandomSignedStateGenerator.java
@@ -39,7 +39,6 @@
import com.swirlds.platform.consensus.ConsensusSnapshot;
import com.swirlds.platform.crypto.SignatureVerifier;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.MinimumJudgeInfo;
import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.PlatformStateModifier;
@@ -77,7 +76,7 @@ public class RandomSignedStateGenerator {
final Random random;
- private MerkleRoot state;
+ private PlatformMerkleStateRoot state;
private Long round;
private Hash legacyRunningEventHash;
private Roster roster;
@@ -138,7 +137,7 @@ public SignedState build() {
softwareVersionInstance = softwareVersion;
}
- final MerkleRoot stateInstance;
+ final PlatformMerkleStateRoot stateInstance;
registerMerkleStateRootClassIds();
if (state == null) {
if (useBlockingState) {
@@ -147,7 +146,7 @@ public SignedState build() {
stateInstance = new PlatformMerkleStateRoot(
FAKE_MERKLE_STATE_LIFECYCLES, version -> new BasicSoftwareVersion(version.major()));
}
- ((MerkleStateRoot) stateInstance).setTime(Time.getCurrent());
+ stateInstance.setTime(Time.getCurrent());
} else {
stateInstance = state;
}
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTest.java
index 375b1f708f8b..6b6d36b915e8 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTest.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
import com.swirlds.common.test.fixtures.junit.tags.TestComponentTags;
import com.swirlds.common.test.fixtures.platform.TestPlatformContextBuilder;
import com.swirlds.platform.crypto.CryptoStatic;
-import com.swirlds.platform.state.MerkleRoot;
import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.signed.SignedState;
import com.swirlds.platform.system.BasicSoftwareVersion;
@@ -45,8 +44,8 @@ class StateTest {
@DisplayName("Test Copy")
void testCopy() {
- final MerkleRoot state = randomSignedState().getState();
- final MerkleRoot copy = state.copy();
+ final PlatformMerkleStateRoot state = randomSignedState().getState();
+ final PlatformMerkleStateRoot copy = state.copy();
assertNotSame(state, copy, "copy should not return the same object");
@@ -67,7 +66,7 @@ void testCopy() {
@Tag(TestComponentTags.MERKLE)
@DisplayName("Test Try Reserve")
void tryReserveTest() {
- final MerkleRoot state = randomSignedState().getState();
+ final PlatformMerkleStateRoot state = randomSignedState().getState();
assertEquals(
1,
state.getReservationCount(),
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTests.java
index 5457d9b685eb..f06478b51f4a 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTests.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/StateTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021-2024 Hedera Hashgraph, LLC
+ * Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
import com.swirlds.common.test.fixtures.io.InputOutputStream;
import com.swirlds.common.test.fixtures.junit.tags.TestComponentTags;
import com.swirlds.config.extensions.test.fixtures.TestConfigBuilder;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.test.fixtures.state.BlockingSwirldState;
import com.swirlds.state.merkle.MerkleStateRoot;
import java.io.IOException;
@@ -70,7 +70,7 @@ void stateSerializationTest() throws IOException {
io.startReading();
- final MerkleRoot decodedState = io.getInput().readMerkleTree(testDirectory, Integer.MAX_VALUE);
+ final PlatformMerkleStateRoot decodedState = io.getInput().readMerkleTree(testDirectory, Integer.MAX_VALUE);
MerkleCryptoFactory.getInstance().digestTreeSync(decodedState);
assertEquals(merkleStateRoot.getHash(), decodedState.getHash(), "expected trees to be equal");
diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java
index 38ad75bf149e..a8e5a5bc1464 100644
--- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java
+++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/state/IssDetectorTests.java
@@ -44,7 +44,7 @@
import com.swirlds.platform.internal.ConsensusRound;
import com.swirlds.platform.internal.EventImpl;
import com.swirlds.platform.roster.RosterUtils;
-import com.swirlds.platform.state.MerkleRoot;
+import com.swirlds.platform.state.PlatformMerkleStateRoot;
import com.swirlds.platform.state.iss.DefaultIssDetector;
import com.swirlds.platform.state.iss.IssDetector;
import com.swirlds.platform.state.iss.internal.HashValidityStatus;
@@ -764,7 +764,7 @@ void ignoredRoundTest() {
private static ReservedSignedState mockState(final long round, final Hash hash) {
final ReservedSignedState rs = mock(ReservedSignedState.class);
final SignedState ss = mock(SignedState.class);
- final MerkleRoot s = mock(MerkleRoot.class);
+ final PlatformMerkleStateRoot s = mock(PlatformMerkleStateRoot.class);
when(rs.get()).thenReturn(ss);
when(ss.getState()).thenReturn(s);
when(ss.getRound()).thenReturn(round);
From 2f5f838cb48758d9c0533ace5c2547540b0ac65a Mon Sep 17 00:00:00 2001
From: Matt Riben
Date: Fri, 20 Dec 2024 16:34:09 -0600
Subject: [PATCH 06/13] fix: move and change value of Dockerfile environment
variable (#16239)
Signed-off-by: Matt Riben
---
.../containers/production-next/consensus-node/Dockerfile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile
index 94d8bc1ef2f6..c165fed92372 100644
--- a/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile
+++ b/hedera-node/infrastructure/docker/containers/production-next/consensus-node/Dockerfile
@@ -227,8 +227,6 @@ ENV JAVA_VERSION "jdk-21.0.4+7"
ENV JAVA_HOME /usr/local/java
ENV PATH ${JAVA_HOME}/bin:${PATH}
-ENV CONTAINER_TSR_ENABLED "true"
-
# Install Java
COPY --from=java-builder ${JAVA_HOME}/ ${JAVA_HOME}/
@@ -285,6 +283,10 @@ ENV MALLOC_ARENA_MAX 4
# Log Folder Name Override
ENV LOG_DIR_NAME ""
+# If "true" or an integer between 1 & 2^63-1 after running consensus entrypoint.sh will block indefinitely.
+# Otherwise entrypoint.sh will return the exit code from consensus.
+ENV CONTAINER_TSR_ENABLED "false"
+
# Define Volume Bindpoints
VOLUME "/opt/hgcapp/accountBalances"
VOLUME "/opt/hgcapp/eventsStreams"
From 1e4a206e62fa64ef9f95ba814c155ba0e78c792e Mon Sep 17 00:00:00 2001
From: Andrew Brandt
Date: Fri, 20 Dec 2024 20:44:00 -0500
Subject: [PATCH 07/13] build: Roll hiero gradle conventions to version 0.1.4
(#17149)
Signed-off-by: Andrew Brandt
---
settings.gradle.kts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 0630c1461051..f1d55a92049b 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-plugins { id("org.hiero.gradle.build") version "0.1.2" }
+plugins { id("org.hiero.gradle.build") version "0.1.4" }
javaModules {
// This "intermediate parent project" should be removed
From 2934ba68a58ee3dffd547c4376f3c86ca5d96d3d Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 20 Dec 2024 21:15:26 -0500
Subject: [PATCH 08/13] build(deps): bump actions/setup-java from 4.5.0 to
4.6.0 (#17113)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Brandt
---
.github/workflows/node-zxc-build-release-artifact.yaml | 6 +++---
.github/workflows/node-zxc-compile-application-code.yaml | 2 +-
.github/workflows/node-zxf-snyk-monitor.yaml | 2 +-
.github/workflows/zxc-jrs-regression.yaml | 2 +-
.github/workflows/zxc-verify-docker-build-determinism.yaml | 2 +-
.github/workflows/zxc-verify-gradle-build-determinism.yaml | 4 ++--
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/node-zxc-build-release-artifact.yaml b/.github/workflows/node-zxc-build-release-artifact.yaml
index bd079e5fc89c..a38f58079d43 100644
--- a/.github/workflows/node-zxc-build-release-artifact.yaml
+++ b/.github/workflows/node-zxc-build-release-artifact.yaml
@@ -179,7 +179,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
@@ -284,7 +284,7 @@ jobs:
if: ${{ inputs.dry-run-enabled != true && !cancelled() && !failure() }}
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
@@ -714,7 +714,7 @@ jobs:
if: ${{ inputs.dry-run-enabled != true && !cancelled() && !failure() }}
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
diff --git a/.github/workflows/node-zxc-compile-application-code.yaml b/.github/workflows/node-zxc-compile-application-code.yaml
index 258bac714ab0..8110da5684a1 100644
--- a/.github/workflows/node-zxc-compile-application-code.yaml
+++ b/.github/workflows/node-zxc-compile-application-code.yaml
@@ -176,7 +176,7 @@ jobs:
run: git fetch --unshallow --no-recurse-submodules
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
diff --git a/.github/workflows/node-zxf-snyk-monitor.yaml b/.github/workflows/node-zxf-snyk-monitor.yaml
index 3c6fa5cef88e..818fa8743810 100644
--- a/.github/workflows/node-zxf-snyk-monitor.yaml
+++ b/.github/workflows/node-zxf-snyk-monitor.yaml
@@ -40,7 +40,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: temurin
java-version: 21
diff --git a/.github/workflows/zxc-jrs-regression.yaml b/.github/workflows/zxc-jrs-regression.yaml
index d8e1f7c1844f..204b0295288f 100644
--- a/.github/workflows/zxc-jrs-regression.yaml
+++ b/.github/workflows/zxc-jrs-regression.yaml
@@ -336,7 +336,7 @@ jobs:
node-version: 18
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
diff --git a/.github/workflows/zxc-verify-docker-build-determinism.yaml b/.github/workflows/zxc-verify-docker-build-determinism.yaml
index 5c4c1d0876a1..6cc6b1869c14 100644
--- a/.github/workflows/zxc-verify-docker-build-determinism.yaml
+++ b/.github/workflows/zxc-verify-docker-build-determinism.yaml
@@ -118,7 +118,7 @@ jobs:
echo "file=${BASELINE_FILE}" >> "${GITHUB_OUTPUT}"
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
if: ${{ steps.baseline.outputs.exists == 'false' && !failure() && !cancelled() }}
with:
distribution: ${{ inputs.java-distribution }}
diff --git a/.github/workflows/zxc-verify-gradle-build-determinism.yaml b/.github/workflows/zxc-verify-gradle-build-determinism.yaml
index 76f00b1f7972..6cf2ebc75954 100644
--- a/.github/workflows/zxc-verify-gradle-build-determinism.yaml
+++ b/.github/workflows/zxc-verify-gradle-build-determinism.yaml
@@ -78,7 +78,7 @@ jobs:
ref: ${{ inputs.ref }}
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
@@ -175,7 +175,7 @@ jobs:
python-version: 3.9
- name: Setup Java
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
From 54b2dcc0f58ad1f67473045b409ac03f6509c554 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 20 Dec 2024 21:19:27 -0500
Subject: [PATCH 09/13] build(deps): bump gradle/actions from 4.2.1 to 4.2.2
(#17111)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Brandt
---
.github/workflows/node-zxc-build-release-artifact.yaml | 6 +++---
.github/workflows/node-zxc-compile-application-code.yaml | 2 +-
.github/workflows/node-zxf-snyk-monitor.yaml | 2 +-
.github/workflows/zxc-jrs-regression.yaml | 2 +-
.github/workflows/zxc-verify-docker-build-determinism.yaml | 2 +-
.github/workflows/zxc-verify-gradle-build-determinism.yaml | 4 ++--
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/node-zxc-build-release-artifact.yaml b/.github/workflows/node-zxc-build-release-artifact.yaml
index a38f58079d43..5aded7a22df4 100644
--- a/.github/workflows/node-zxc-build-release-artifact.yaml
+++ b/.github/workflows/node-zxc-build-release-artifact.yaml
@@ -185,7 +185,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
gradle-version: ${{ inputs.gradle-version }}
@@ -290,7 +290,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
gradle-version: ${{ inputs.gradle-version }}
@@ -720,7 +720,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
gradle-version: ${{ inputs.gradle-version }}
diff --git a/.github/workflows/node-zxc-compile-application-code.yaml b/.github/workflows/node-zxc-compile-application-code.yaml
index 8110da5684a1..70fc3377f7e4 100644
--- a/.github/workflows/node-zxc-compile-application-code.yaml
+++ b/.github/workflows/node-zxc-compile-application-code.yaml
@@ -182,7 +182,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
cache-read-only: false
diff --git a/.github/workflows/node-zxf-snyk-monitor.yaml b/.github/workflows/node-zxf-snyk-monitor.yaml
index 818fa8743810..aa2f0f628ba2 100644
--- a/.github/workflows/node-zxf-snyk-monitor.yaml
+++ b/.github/workflows/node-zxf-snyk-monitor.yaml
@@ -46,7 +46,7 @@ jobs:
java-version: 21
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
build-root-directory: hedera-node
gradle-version: wrapper
diff --git a/.github/workflows/zxc-jrs-regression.yaml b/.github/workflows/zxc-jrs-regression.yaml
index 204b0295288f..ae3e455af617 100644
--- a/.github/workflows/zxc-jrs-regression.yaml
+++ b/.github/workflows/zxc-jrs-regression.yaml
@@ -342,7 +342,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
gradle-version: ${{ inputs.gradle-version }}
gradle-home-cache-strict-match: false
diff --git a/.github/workflows/zxc-verify-docker-build-determinism.yaml b/.github/workflows/zxc-verify-docker-build-determinism.yaml
index 6cc6b1869c14..83c7bcfe4df1 100644
--- a/.github/workflows/zxc-verify-docker-build-determinism.yaml
+++ b/.github/workflows/zxc-verify-docker-build-determinism.yaml
@@ -125,7 +125,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
if: ${{ steps.baseline.outputs.exists == 'false' && !failure() && !cancelled() }}
with:
cache-disabled: true
diff --git a/.github/workflows/zxc-verify-gradle-build-determinism.yaml b/.github/workflows/zxc-verify-gradle-build-determinism.yaml
index 6cf2ebc75954..119e0e923e5a 100644
--- a/.github/workflows/zxc-verify-gradle-build-determinism.yaml
+++ b/.github/workflows/zxc-verify-gradle-build-determinism.yaml
@@ -84,7 +84,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
cache-disabled: true
@@ -181,7 +181,7 @@ jobs:
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
- uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
+ uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
with:
cache-disabled: true
From fb3467929f95f51547f2b7d2e8a51dffb52f4a15 Mon Sep 17 00:00:00 2001
From: Roger Barker
Date: Fri, 20 Dec 2024 22:06:29 -0600
Subject: [PATCH 10/13] chore: Update hedera-services to rename develop as main
(#17091)
Signed-off-by: Roger Barker
Signed-off-by: Jendrik Johannes
Co-authored-by: Jendrik Johannes
Co-authored-by: Andrew Brandt
---
.../workflows/flow-artifact-determinism.yaml | 2 +-
.../node-flow-build-application.yaml | 3 +-
.../node-flow-deploy-release-artifact.yaml | 8 ++---
.../node-zxcron-develop-fsts-regression.yaml | 2 +-
.github/workflows/node-zxf-snyk-monitor.yaml | 2 +-
...latform-zxcron-develop-jrs-regression.yaml | 2 +-
.github/workflows/zxc-jrs-regression.yaml | 4 +--
.../workflows/zxcron-extended-test-suite.yaml | 12 ++++----
.../zxcron-promote-build-candidate.yaml | 6 ++--
.../workflows/zxf-collect-workflow-logs.yaml | 2 +-
.../zxf-prepare-extended-test-suite.yaml | 6 ++--
docs/branch-naming-conventions.md | 9 +++---
...continuous-integration-testing-overview.md | 8 ++---
docs/glossary.md | 4 +--
docs/maintainers-guide.md | 29 +++++++++----------
gradle/development-branch.txt | 1 -
hedera-node/docs/design/app/workflows.md | 14 ++++-----
.../cancun-fork-support.md | 2 +-
.../contract-accounts-nonces.md | 10 +++----
hedera-node/docs/dev/JRS-GettingStarted.md | 4 +--
platform-sdk/README.md | 2 +-
platform-sdk/description.txt | 2 +-
.../docs/core/address-book-management.md | 2 +-
platform-sdk/docs/core/wiring-diagram.svg | 2 +-
platform-sdk/docs/proposals/README.md | 2 +-
.../docs/proposals/metric-labels/README.md | 2 +-
.../model/diagram/HyperlinkBuilder.java | 8 ++---
.../cli/JrsTestReaderReportCommand.java | 4 +--
28 files changed, 75 insertions(+), 79 deletions(-)
delete mode 100644 gradle/development-branch.txt
diff --git a/.github/workflows/flow-artifact-determinism.yaml b/.github/workflows/flow-artifact-determinism.yaml
index f638b1c915bd..7c6c71f9ff49 100644
--- a/.github/workflows/flow-artifact-determinism.yaml
+++ b/.github/workflows/flow-artifact-determinism.yaml
@@ -35,7 +35,7 @@ on:
default: "21.0.4"
push:
branches:
- - develop
+ - main
- 'release/**'
tags:
- 'v*.*.*'
diff --git a/.github/workflows/node-flow-build-application.yaml b/.github/workflows/node-flow-build-application.yaml
index 8630c2aa0358..befc83899548 100644
--- a/.github/workflows/node-flow-build-application.yaml
+++ b/.github/workflows/node-flow-build-application.yaml
@@ -50,7 +50,6 @@ on:
default: "temurin"
push:
branches:
- - develop
- main
- 'release/*'
@@ -124,7 +123,7 @@ jobs:
with:
workflow: .github/workflows/node-flow-deploy-release-artifact.yaml
repo: hashgraph/hedera-services # ensure we are executing in the hashgraph org
- ref: develop # ensure we are always using the workflow definition from the develop branch
+ ref: main # ensure we are always using the workflow definition from the main branch
token: ${{ secrets.GH_ACCESS_TOKEN }}
inputs: '{
"ref": "${{ steps.workflow-inputs.outputs.input-ref }}",
diff --git a/.github/workflows/node-flow-deploy-release-artifact.yaml b/.github/workflows/node-flow-deploy-release-artifact.yaml
index 50e13ca7da0d..9f6e09aa930e 100644
--- a/.github/workflows/node-flow-deploy-release-artifact.yaml
+++ b/.github/workflows/node-flow-deploy-release-artifact.yaml
@@ -150,7 +150,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- ref: develop
+ ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Trigger ZXF Prepare Extended Test Suite
@@ -159,7 +159,7 @@ jobs:
with:
workflow: .github/workflows/zxf-prepare-extended-test-suite.yaml
repo: hashgraph/hedera-services # ensure we are executing in the hashgraph org
- ref: develop # ensure we are always using the workflow definition from the develop branch
+ ref: main # ensure we are always using the workflow definition from the main branch
token: ${{ secrets.GH_ACCESS_TOKEN }}
inputs: '{ "ref": "${{ inputs.ref }}" }'
@@ -171,7 +171,7 @@ jobs:
with:
workflow: .github/workflows/node-zxf-deploy-integration.yaml
repo: hashgraph/hedera-services # ensure we are executing in the hashgraph org
- ref: develop # ensure we are always using the workflow definition from the develop branch
+ ref: main # ensure we are always using the workflow definition from the main branch
token: ${{ secrets.GH_ACCESS_TOKEN }}
inputs: '{
"ref": "${{ inputs.ref }}",
@@ -195,7 +195,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
- ref: develop
+ ref: main
fetch-depth: '0'
- name: Checkout Hedera Protobufs Code
diff --git a/.github/workflows/node-zxcron-develop-fsts-regression.yaml b/.github/workflows/node-zxcron-develop-fsts-regression.yaml
index df2b6a3d7352..ff7b86573758 100644
--- a/.github/workflows/node-zxcron-develop-fsts-regression.yaml
+++ b/.github/workflows/node-zxcron-develop-fsts-regression.yaml
@@ -14,7 +14,7 @@
# limitations under the License.
##
-name: "ZXCron: [Node] Develop JRS Tests"
+name: "ZXCron: [Node] Main JRS Tests"
on:
workflow_dispatch:
diff --git a/.github/workflows/node-zxf-snyk-monitor.yaml b/.github/workflows/node-zxf-snyk-monitor.yaml
index aa2f0f628ba2..a86e0d52f997 100644
--- a/.github/workflows/node-zxf-snyk-monitor.yaml
+++ b/.github/workflows/node-zxf-snyk-monitor.yaml
@@ -19,7 +19,7 @@ name: "ZXF: Snyk Monitor"
on:
push:
branches:
- - develop
+ - main
workflow_dispatch:
permissions:
diff --git a/.github/workflows/platform-zxcron-develop-jrs-regression.yaml b/.github/workflows/platform-zxcron-develop-jrs-regression.yaml
index 6cfc2218a2c0..82de7cc2dde5 100644
--- a/.github/workflows/platform-zxcron-develop-jrs-regression.yaml
+++ b/.github/workflows/platform-zxcron-develop-jrs-regression.yaml
@@ -14,7 +14,7 @@
# limitations under the License.
##
-name: "ZXCron: [Platform] Develop JRS Regression"
+name: "ZXCron: [Platform] Main JRS Regression"
on:
schedule:
- cron: '30 5 * * *'
diff --git a/.github/workflows/zxc-jrs-regression.yaml b/.github/workflows/zxc-jrs-regression.yaml
index ae3e455af617..e42b76a6046d 100644
--- a/.github/workflows/zxc-jrs-regression.yaml
+++ b/.github/workflows/zxc-jrs-regression.yaml
@@ -486,8 +486,8 @@ jobs:
fi
if [[ -n "${HEDERA_TESTS_ENABLED}" && "${HEDERA_TESTS_ENABLED}" = true ]]; then
- # Override for the develop branch
- if [[ "${SLACK_BRANCH}" != "develop" ]]; then
+ # Override for the main branch
+ if [[ "${SLACK_BRANCH}" != "main" ]]; then
SLACK_SUMMARY="hedera-gcp-${SLACK_BRANCH}-summary"
SLACK_RESULTS="hedera-gcp-${SLACK_BRANCH}-regression"
else
diff --git a/.github/workflows/zxcron-extended-test-suite.yaml b/.github/workflows/zxcron-extended-test-suite.yaml
index 53b467047dfa..49be04128ab8 100644
--- a/.github/workflows/zxcron-extended-test-suite.yaml
+++ b/.github/workflows/zxcron-extended-test-suite.yaml
@@ -57,12 +57,12 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- ref: develop
+ ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}
# Check if the xts-candidate tag exists
# the command git branch --contains xts-tag-commit | grep --quiet
- # will return an exit code of 1 if the tagged commit is not found on the develop
+ # will return an exit code of 1 if the tagged commit is not found on the main
# branch.
- name: Check for tags
id: check-tags-exist
@@ -93,9 +93,9 @@ jobs:
gh run cancel ${{ github.run_id }}
fi
- # Check if the tag exists on the develop branch
+ # Check if the tag exists on the main branch
set +e
- git branch --contains "${XTS_COMMIT}" | grep --quiet develop >/dev/null 2>&1
+ git branch --contains "${XTS_COMMIT}" | grep --quiet main >/dev/null 2>&1
BRANCH_ON_DEVELOP="${?}"
set -e
@@ -103,7 +103,7 @@ jobs:
AUTHOR_NAME=$(git log -1 --format='%an' "${XTS_COMMIT}")
AUTHOR_EMAIL=$(git log -1 --format='%ae' "${XTS_COMMIT}")
- # If the tag exists on the Develop Branch set the output variables as appropriate
+ # If the tag exists on the Main Branch set the output variables as appropriate
# Otherwise cancel out
if [[ "${BRANCH_ON_DEVELOP}" -eq 0 ]]; then
echo "xts-tag-exists=true" >> $GITHUB_OUTPUT
@@ -260,7 +260,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- ref: develop
+ ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Collect run logs in a log file
diff --git a/.github/workflows/zxcron-promote-build-candidate.yaml b/.github/workflows/zxcron-promote-build-candidate.yaml
index 7976fe9bf686..8cbf7e23598d 100644
--- a/.github/workflows/zxcron-promote-build-candidate.yaml
+++ b/.github/workflows/zxcron-promote-build-candidate.yaml
@@ -52,7 +52,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- ref: develop
+ ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Find Build Candidates
@@ -74,8 +74,8 @@ jobs:
gh run cancel ${{ github.run_id }}
fi
- # Verify the commit is on develop and continue
- if git branch --contains "${CANDIDATE_COMMIT}" | grep --quiet develop >/dev/null 2>&1; then
+ # Verify the commit is on main and continue
+ if git branch --contains "${CANDIDATE_COMMIT}" | grep --quiet main >/dev/null 2>&1; then
git push --delete origin $(git tag --list "${TAG_PATTERN}")
git tag --delete $(git tag --list "${TAG_PATTERN}")
echo "build-candidate-exists=true" >> "${GITHUB_OUTPUT}"
diff --git a/.github/workflows/zxf-collect-workflow-logs.yaml b/.github/workflows/zxf-collect-workflow-logs.yaml
index 14d12a8e4a35..113fe7f82c35 100644
--- a/.github/workflows/zxf-collect-workflow-logs.yaml
+++ b/.github/workflows/zxf-collect-workflow-logs.yaml
@@ -50,7 +50,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- ref: develop
+ ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Get run logs
diff --git a/.github/workflows/zxf-prepare-extended-test-suite.yaml b/.github/workflows/zxf-prepare-extended-test-suite.yaml
index e3f021b98eb5..d0dce64f6081 100644
--- a/.github/workflows/zxf-prepare-extended-test-suite.yaml
+++ b/.github/workflows/zxf-prepare-extended-test-suite.yaml
@@ -50,7 +50,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- ref: 'develop'
+ ref: 'main'
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Validate Input Ref
@@ -58,10 +58,10 @@ jobs:
env:
COMMIT_ID: ${{ inputs.ref }}
run: |
- if git merge-base --is-ancestor "${COMMIT_ID}" develop >/dev/null 2>&1; then
+ if git merge-base --is-ancestor "${COMMIT_ID}" main >/dev/null 2>&1; then
echo "commit_on_dev=true" >> $GITHUB_OUTPUT
else
- echo "::error title=Branch Alignment::The provided commit (${COMMIT_ID}) is not present on the develop branch."
+ echo "::error title=Branch Alignment::The provided commit (${COMMIT_ID}) is not present on the main branch."
exit 1
fi
diff --git a/docs/branch-naming-conventions.md b/docs/branch-naming-conventions.md
index c77ccb33ac26..841bc329a4d8 100644
--- a/docs/branch-naming-conventions.md
+++ b/docs/branch-naming-conventions.md
@@ -20,18 +20,19 @@ naming standard.
### Permanent & Default Branches
-The repository will contain two permanent branches as per the GitFlow Workflow `main` and `develop`
-branches.
+The repository will contain one permanent branch, `main`, per the Hashgraph Continuous Integration
+Test and Release workflow
**Default Branches**
-The default branch for a repository will be `develop` as per the branching workflow.
+The default branch for a repository will be `main` as per the Hashgraph Continuous Integration
+Test and Release workflow.
### Branch to Issue Relationship
Aside from the permanent or release branches, no short-lived (feature, hotfix, bugfix) branch should
be created without being associated to an issue number. No short-lived branch should be merged into
-`develop` or `main` without an associated and approved pull request.
+`main` without an associated and approved pull request.
### Feature Branch Naming
diff --git a/docs/continuous-integration-testing-overview.md b/docs/continuous-integration-testing-overview.md
index 036a82d983de..6afc43f6e52c 100644
--- a/docs/continuous-integration-testing-overview.md
+++ b/docs/continuous-integration-testing-overview.md
@@ -20,11 +20,11 @@ two major components of CITR: MATS and XTS.
MATS is the Minimal Acceptable Test Suite; this suite of tests is run against every pull request (PR) that is opened in
the `hashgraph/hedera-services` repository.
-XTS is the eXtended Test Suite; this suite of tests is run against the latest commit on the develop branch every three
+XTS is the eXtended Test Suite; this suite of tests is run against the latest commit on the main branch every three
hours (provided there is a new commit to run against).
MATS tests are inclusive of a series of unit tests and performance tests that must be executed against a PR branch prior
-to merging into develop. The MATS tests are intended to complete within a 30-minute time window to provide developers
+to merging into main. The MATS tests are intended to complete within a 30-minute time window to provide developers
with valuable insight of the impact of new code on the default branch.
XTS tests are run against the default branch once every three hours. These cover test cases that are unable to complete
@@ -38,14 +38,14 @@ There is an additional workflow: `ZXF: Extended Test Suite - Dry Run` which is a
`hashgraph/hedera-services` repository.
The XTS Dry-Run workflow runs a provided commit on any branch through the same XTS tests that would be run against the
-latest on develop every three hours. This workflow is run with a manual trigger and will execute in parallel to any
+latest on main every three hours. This workflow is run with a manual trigger and will execute in parallel to any
other actions ongoing in the `hashgraph/hedera-services` repository.
A developer can manually trigger a run using the parameters in the web UI:
```text
Use Workflow From
- Branch: develop # this should always be `develop`
+ Branch: main # this should always be `main`
The commit sha to check out
The branch name, for JRS Panel output
diff --git a/docs/glossary.md b/docs/glossary.md
index 929f3be8a125..b83eb5cc03c6 100644
--- a/docs/glossary.md
+++ b/docs/glossary.md
@@ -193,9 +193,9 @@ This file contains the address book to use when starting from genesis.
**Congestion Pricing**: A mechanism designed to manage network congestion by dynamically adjusting
transaction fees based on network demand. The primary goal of congestion pricing is to discourage
excessive network usage during peak times. Refer to
-[Congestion Pricing](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/docs/fees/automated-congestion-pricing.md)
+[Congestion Pricing](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/docs/fees/automated-congestion-pricing.md)
and
-[Fees](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/docs/design/app/fees.md).
+[Fees](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/docs/design/app/fees.md).
## Consensus Time
diff --git a/docs/maintainers-guide.md b/docs/maintainers-guide.md
index 755796a0bfa3..34502f5d0319 100644
--- a/docs/maintainers-guide.md
+++ b/docs/maintainers-guide.md
@@ -58,12 +58,10 @@ pattern for the development life cycle.
![gitflow-branching-model](./assets/gitflow-branching-model.png)
-Note especially the roles of the `main` and `develop` branches:
+Note especially the roles of the `main` branch:
-- `develop` is the default branch, the target of active development, and should at all times
+- `main` is the default branch, the target of active development, and should at all times
should be a viable candidate for the next release.
-- `main` is a tightly-controlled branch that release engineering uses for final tags deployed to
- production.
### Creating issues on GitHub
@@ -92,35 +90,34 @@ with 0.30 milestone on it.
![labels-on-issue](./assets/labels-on-issue.png)
-### Release Engineering Responsibilities
+### DevOps-CI Responsibilities
-The release engineering team will handle the following:
+The DevOps-CI team will handle the following:
-- Create a release branch from `develop` branch at the end of first sprint in the release cycle
-- Will merge the release branch for current deploying release into `main`
- Will provide automated release processes and coordinate release schedules
- Will handle production releases
+- Note: no release branch will be created
### User Stories
#### As a developer, I would like to create a branch to work on the feature for the upcoming release
-As per the development model, every developer should create a feature branch from `develop` branch
+As per the development model, every developer should create a feature branch from `main` branch
for working on a change targeted for the current release. The created branch should follow
[naming conventions](branch-naming-conventions.md).
-The `develop` branch should be up-to-date with all the features going into the next release.
+The `main` branch should be up-to-date with all the features going into the next release.
#### As a developer, I would like to create a branch to work on the feature NOT targeted for upcoming release
-As per the development model, every developer should create a feature branch to work from `develop`
+As per the development model, every developer should create a feature branch to work from `main`
branch. The created branch should follow [naming conventions](branch-naming-conventions.md). But,
-the feature branch should NOT be merged into `develop` until the decision is made if the feature is
+the feature branch should NOT be merged into `main` until the decision is made if the feature is
going into upcoming release.
#### As a developer, I would like to merge my feature branch or bug fix for the upcoming release
-Open a pull request (PR) from the feature branch to `develop` branch and add
+Open a pull request (PR) from the feature branch to `main` branch and add
`hashgraph/hedera-services-team` as reviewers.
Also add the following labels on the PR :
@@ -134,7 +131,7 @@ PR should be merged after an approving review and all the checks are passed.
NOTE:
1. Any feature that is not going into the upcoming release should stay in the feature branch and
- should not be merged to `develop`.
+ should not be merged to `main`.
2. Please use either the Gradle command line `./gradlew qualityGate` or the
[Google Java Format IntelliJ Plugin](https://github.com/google/google-java-format#intellij-android-studio-and-other-jetbrains-ides)
to format your code to avoid failing checks in CI pipeline.
@@ -146,14 +143,14 @@ Once the release branch is created, only bugfixes or hotfixes should be merged i
To do that, create a `hotfix` from the `release` branch. The created branch should follow
[naming conventions](branch-naming-conventions.md). Once the fix is in the branch, open a PR to the
release branch. Once the fix is merged into `release` branch, it should be cherry-picked into the
-`develop` branch.
+`main` branch.
#### As a developer, I would like to merge a bugfix/hotfix from the production code
To fix a bug from one of the previous releases(production code), create a hotfix branch from `main`.
Once the fix is in the branch, create a PR targeting to `main`. Once bugfix is merged into `main`and
it should be cherry-picked back into the current `release` branch(if the release branch is still
-open), and also into `develop`.
+open).
### DCO Sign Off
diff --git a/gradle/development-branch.txt b/gradle/development-branch.txt
deleted file mode 100644
index ce57f6456319..000000000000
--- a/gradle/development-branch.txt
+++ /dev/null
@@ -1 +0,0 @@
-develop
\ No newline at end of file
diff --git a/hedera-node/docs/design/app/workflows.md b/hedera-node/docs/design/app/workflows.md
index bab72146b5d2..b1532d5b6439 100644
--- a/hedera-node/docs/design/app/workflows.md
+++ b/hedera-node/docs/design/app/workflows.md
@@ -118,18 +118,18 @@ All the objects used while handling the transaction belong to one of the followi
Examples include the `NodeInfo` and `WorkingStateAccessor`.
- **UserTxnScope** - Objects that are created once for platform transaction.
Examples include the `Configuration`, `RecordListBuilder` and `TokenContext`.
-Dagger provides all the objects that can be constructed in this scope [here](https://github.com/hashgraph/hedera-services/tree/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/txn/modules)
-and [UserTxnComponent](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/txn/UserTransactionComponent.java)
+Dagger provides all the objects that can be constructed in this scope [here](https://github.com/hashgraph/hedera-services/tree/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/txn/modules)
+and [UserTxnComponent](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/txn/UserTransactionComponent.java)
takes all the inputs that are needed to execute the user transaction.
- **UserDispatchScope** - Objects that are created once for each user transaction that will be dispatched.
Examples include the `SingleTransactionRecordBuilder` for user transaction and `FeeContext`.
-Dagger provides all the objects that can be constructed in this scope in [UserDispatchModule](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/user/modules/UserDispatchModule.java) and `UserDispatchComponent`.
-and [UserDispatchComponent](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/user/UserDispatchComponent.java)
+Dagger provides all the objects that can be constructed in this scope in [UserDispatchModule](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/user/modules/UserDispatchModule.java) and `UserDispatchComponent`.
+and [UserDispatchComponent](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/user/UserDispatchComponent.java)
takes all the inputs that are needed to create the user dispatch.
- **ChildDispatchScope** - Objects that are created once for each child transaction dispatch.
Examples include the `ReadableStoreFactory` and `ChildFeeContext`.
-Dagger provides all the objects that can be constructed in the [ChildDispatchModule](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/child/modules/ChildDispatchModule.java)
-and [ChildDispatchComponent](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/child/ChildDispatchComponent.java)
+Dagger provides all the objects that can be constructed in the [ChildDispatchModule](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/child/modules/ChildDispatchModule.java)
+and [ChildDispatchComponent](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/dispatch/child/ChildDispatchComponent.java)
takes all the inputs that are needed to create the child dispatch.
#### HandleWorkflow overview:
@@ -169,7 +169,7 @@ The overall high level steps are as follows:
The `DispatchProcessor.processDispatch` will be called for user and child dispatches. This avoids duplicating
any logic between user and child transactions, since both are treated as dispatches.
-For the child transactions, when a service calls one of the [dispatchXXXTransaction](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/DispatchHandleContext.java#L459)
+For the child transactions, when a service calls one of the [dispatchXXXTransaction](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/flow/DispatchHandleContext.java#L459)
methods in `DispatchHandleContext`, a new child dispatch is created and `DispatchProcessor.processDispatch` is called.
1. **Error Validation:** Checks if there is any error by node or user by re-assessing preHandleResult. It validates the following:
diff --git a/hedera-node/docs/design/services/smart-contract-service/cancun-fork-support.md b/hedera-node/docs/design/services/smart-contract-service/cancun-fork-support.md
index ddb829613f3a..6c546aceebf2 100644
--- a/hedera-node/docs/design/services/smart-contract-service/cancun-fork-support.md
+++ b/hedera-node/docs/design/services/smart-contract-service/cancun-fork-support.md
@@ -36,7 +36,7 @@ Generally speaking there are four strategies that will be used:
specifications change (e.g., `SELFDESTRUCT`)
* As a Hedera developer, I want to preserve maximum future design space to adopt, or not adopt, blobs.
* As an end user, I want prompt and accurate failures if I attempt to use Blob features in Hedera.
- * And as a smart contract develop I want attempts to _use_ internal blob-support features (e.g.,
+ * And as a smart contract developer I want attempts to _use_ internal blob-support features (e.g.,
opcodes `VERSIONEDHASH` and `BLOBBASEFEE`) to behave in a predictable manner
## Goals
diff --git a/hedera-node/docs/design/services/smart-contract-service/contract-accounts-nonces.md b/hedera-node/docs/design/services/smart-contract-service/contract-accounts-nonces.md
index 311a0b10e552..ae65ca89e953 100644
--- a/hedera-node/docs/design/services/smart-contract-service/contract-accounts-nonces.md
+++ b/hedera-node/docs/design/services/smart-contract-service/contract-accounts-nonces.md
@@ -28,13 +28,13 @@ The following is a table with general use cases and behavior for Ethereum and He
| Contract transaction resulting in `CREATE/CREATE2` (`ContractCall` or `ContractCreate`) | - | initial contract nonce value is 1; nonce is incremented for each contract creation initiated by an account, updates are not externalized to Mirror Node | initial contract nonce value is 1; nonce is incremented for each contract creation initiated by an account, updates are externalized to Mirror Node |
### Contract Nonce Externalization
-- We keep a `ContractId -> nonce` tree map inside [HederaWorldState](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/store/contracts/HederaWorldState.java#L79), it is updated on each call of `commit()` (using newly added method `trackContractNonces()`).
-- Method `trackContractNonces` in [HederaWorldState](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/store/contracts/HederaWorldState.java#L393) follows the pattern of `trackNewlyCreatedAccounts`.
+- We keep a `ContractId -> nonce` tree map inside [HederaWorldState](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/store/contracts/HederaWorldState.java#L79), it is updated on each call of `commit()` (using newly added method `trackContractNonces()`).
+- Method `trackContractNonces` in [HederaWorldState](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/store/contracts/HederaWorldState.java#L393) follows the pattern of `trackNewlyCreatedAccounts`.
- Checks if an account is a new smart contract and externalizes its nonce.
- Checks if an existing smart contract's nonce is updated and externalizes it.
-- Added a `ContractId -> nonce` tree map inside [TransactionProcessingResult](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/contracts/execution/TransactionProcessingResult.java#L45).
-- Persists account contract nonces into state in [ContractCreateTransitionLogic](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/txns/contract/ContractCreateTransitionLogic.java#L209) and [ContractCallTransitionLogic](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/txns/contract/ContractCallTransitionLogic.java#L148) using `setContractNonces` from `TransactionProcessingResult`.
-- Created new [ContractNonceInfo](https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/submerkle/ContractNonceInfo.java) submerkle class with two main entities - `contractId` and `nonce`
+- Added a `ContractId -> nonce` tree map inside [TransactionProcessingResult](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/contracts/execution/TransactionProcessingResult.java#L45).
+- Persists account contract nonces into state in [ContractCreateTransitionLogic](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/txns/contract/ContractCreateTransitionLogic.java#L209) and [ContractCallTransitionLogic](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/txns/contract/ContractCallTransitionLogic.java#L148) using `setContractNonces` from `TransactionProcessingResult`.
+- Created new [ContractNonceInfo](https://github.com/hashgraph/hedera-services/blob/main/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/submerkle/ContractNonceInfo.java) submerkle class with two main entities - `contractId` and `nonce`
- Added new method `serializableContractNoncesFrom` in [EvmFnResult](https://github.com/hashgraph/hedera-services/blob/96a85f0e08f82582bbf25328d14ca90fc630c5ef/hedera-node/hedera-mono-service/src/main/java/com/hedera/node/app/service/mono/state/submerkle/EvmFnResult.java) that builds `List` (submerkle) from `Map`
- Added new verison `7` (`RELEASE_0400_VERSION`) and externalized logic for `serialize` and `deserialize` of `contractNonces` in `EvmFnResult`
diff --git a/hedera-node/docs/dev/JRS-GettingStarted.md b/hedera-node/docs/dev/JRS-GettingStarted.md
index 9a4d8c604994..3fb9ec19dc4d 100644
--- a/hedera-node/docs/dev/JRS-GettingStarted.md
+++ b/hedera-node/docs/dev/JRS-GettingStarted.md
@@ -127,7 +127,7 @@ Providing very long `name` will cause failure to create instances.
## **Naming Conventions for the JSONs**
-Naming conventions described in [file](https://github.com/swirlds/swirlds-platform-regression/blob/develop/docs/regression-test-naming-standards.md) are required to be followed for both types of configuration JSONs.
+Naming conventions described in [file](https://github.com/swirlds/swirlds-platform-regression/blob/main/docs/regression-test-naming-standards.md) are required to be followed for both types of configuration JSONs.
Any new naming conventions need to be added to the file if required, after seeking approval from the code owners in `swirlds-platform-regression` repository.
@@ -167,7 +167,7 @@ Current Services nightly regression runs the following tests based on the cron t
All the above tests are under the following path `swirlds-platform/regression/configs/services/suites` under `daily` or `weekly` with appropriate names.
-**NOTE** : To validate the regression results follow steps defined in [regression-validation-checklist.md](https://github.com/swirlds/swirlds-platform-regression/blob/develop/docs/regression-validation-checklist.md).
+**NOTE** : To validate the regression results follow steps defined in [regression-validation-checklist.md](https://github.com/swirlds/swirlds-platform-regression/blob/main/docs/regression-validation-checklist.md).
diff --git a/platform-sdk/README.md b/platform-sdk/README.md
index 55ae640891fb..52919c105e2a 100644
--- a/platform-sdk/README.md
+++ b/platform-sdk/README.md
@@ -46,7 +46,7 @@ Portions of this Hedera Hashgraph, LLC Software may utilize the following copyri
use of which is hereby acknowledged.
The full list of acknowledgements is available at
-[https://github.com/hashgraph/hedera-services/raw/develop/platform-sdk/sdk/docs/acknowledgments.html](sdk/docs/acknowledgments.html)
+[https://github.com/hashgraph/hedera-services/raw/main/platform-sdk/sdk/docs/acknowledgments.html](sdk/docs/acknowledgments.html)
## License
diff --git a/platform-sdk/description.txt b/platform-sdk/description.txt
index 90ec8bd24256..c8bb0806c141 100644
--- a/platform-sdk/description.txt
+++ b/platform-sdk/description.txt
@@ -1,3 +1,3 @@
-Swirlds is a software platform designed to build fully-distributed applications that harness the power of the cloud
+Hedera Hashgraph is a software platform designed to build fully-distributed applications that harness the power of the cloud
without servers. Now you can develop applications with fairness in decision making, speed, trust and reliability, at
a fraction of the cost of traditional server-based platforms.
diff --git a/platform-sdk/docs/core/address-book-management.md b/platform-sdk/docs/core/address-book-management.md
index c0f70b980a71..08acda44ffed 100644
--- a/platform-sdk/docs/core/address-book-management.md
+++ b/platform-sdk/docs/core/address-book-management.md
@@ -3,7 +3,7 @@
## WIP
The address book management pipeline is currently a work in progress.
-This document reflects the address book pipeline as we want it to be, not necessarily as it is in `develop` today.
+This document reflects the address book pipeline as we want it to be, not necessarily as it is in `main` today.
## Summary
diff --git a/platform-sdk/docs/core/wiring-diagram.svg b/platform-sdk/docs/core/wiring-diagram.svg
index 1e314abde54d..098ffc251b92 100644
--- a/platform-sdk/docs/core/wiring-diagram.svg
+++ b/platform-sdk/docs/core/wiring-diagram.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/platform-sdk/docs/proposals/README.md b/platform-sdk/docs/proposals/README.md
index a11874f047ab..f421e5e234a2 100644
--- a/platform-sdk/docs/proposals/README.md
+++ b/platform-sdk/docs/proposals/README.md
@@ -128,7 +128,7 @@ to `Withdrawn` and closed.
## Delivery of A Proposal
-Once an accepted proposal has been completely implemented, tested, the code merged into `develop`, and the feature is
+Once an accepted proposal has been completely implemented, tested, the code merged into `main`, and the feature is
planned to be enabled for production, the proposal's content should be merged with the documentation of the platform
in `platform-sdk/docs` (or other relevant location such as `module-info.java`), as applicable, and removed
from `platform-sdk/docs/proposals`. Once the feature is live on mainnet, the status of the proposal PR in the proposal
diff --git a/platform-sdk/docs/proposals/metric-labels/README.md b/platform-sdk/docs/proposals/metric-labels/README.md
index b61074586088..f27b61e7e460 100644
--- a/platform-sdk/docs/proposals/metric-labels/README.md
+++ b/platform-sdk/docs/proposals/metric-labels/README.md
@@ -227,7 +227,7 @@ interface MetricsFactory {
}
```
-The definition of the api should follow our rules regarding services as defined at https://github.com/hashgraph/hedera-services/blob/develop/platform-sdk/docs/base/service-architecture/service-architecture.md
+The definition of the api should follow our rules regarding services as defined at https://github.com/hashgraph/hedera-services/blob/main/platform-sdk/docs/base/service-architecture/service-architecture.md
##### Examples
diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/wiring/model/diagram/HyperlinkBuilder.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/wiring/model/diagram/HyperlinkBuilder.java
index 73f6afa65374..20b74254b1d9 100644
--- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/wiring/model/diagram/HyperlinkBuilder.java
+++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/wiring/model/diagram/HyperlinkBuilder.java
@@ -19,15 +19,15 @@
import edu.umd.cs.findbugs.annotations.NonNull;
/**
- * Given a class, derive a hyperlink to the github for that class's source code (in develop).
+ * Given a class, derive a hyperlink to the github for that class's source code (in main).
*/
public final class HyperlinkBuilder {
- public static final String PLATFORM_CORE_ROOT = "https://github.com/hashgraph/hedera-services/blob/develop/"
+ public static final String PLATFORM_CORE_ROOT = "https://github.com/hashgraph/hedera-services/blob/main/"
+ "platform-sdk/swirlds-platform-core/src/main/java";
public static final String PLATFORM_COMMON_ROOT =
- "https://github.com/hashgraph/hedera-services/blob/develop/platform-sdk/swirlds-common/src/main/java";
+ "https://github.com/hashgraph/hedera-services/blob/main/platform-sdk/swirlds-common/src/main/java";
/**
* Build a hyperlink to the platform core source code for the given class. Only works for things in the core
@@ -52,7 +52,7 @@ public static String platformCommonHyperlink(@NonNull final Class> clazz) {
}
/**
- * Get a github hyperlink to this class (in develop).
+ * Get a github hyperlink to this class (in main).
*
* @param clazz the class
* @return the hyperlink
diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java
index d1aa66743ff4..a3e96840f9dc 100644
--- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java
+++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java
@@ -185,9 +185,9 @@ private static Path autoGenerateOutputDirectoryName(@NonNull final String target
@Override
public Integer call() {
- // if no targets were specified, then default to the develop branch
+ // if no targets were specified, then default to the main branch
if (targets == null) {
- targets = List.of("develop");
+ targets = List.of("main");
}
final Map metadata = JtrUtils.getTestMetadata(metadataFile);
From 79111094d04fd1ff8e49ab7aa4d9d87875bedb80 Mon Sep 17 00:00:00 2001
From: Roger Barker
Date: Fri, 20 Dec 2024 23:11:45 -0600
Subject: [PATCH 11/13] chore: Update workrflow names to point to main instead
of develop (#17158)
Signed-off-by: Roger Barker
---
.../node-flow-deploy-release-artifact.yaml | 24 +++++++++++++++++--
... => node-zxcron-main-fsts-regression.yaml} | 0
... platform-zxcron-main-jrs-regression.yaml} | 0
3 files changed, 22 insertions(+), 2 deletions(-)
rename .github/workflows/{node-zxcron-develop-fsts-regression.yaml => node-zxcron-main-fsts-regression.yaml} (100%)
rename .github/workflows/{platform-zxcron-develop-jrs-regression.yaml => platform-zxcron-main-jrs-regression.yaml} (100%)
diff --git a/.github/workflows/node-flow-deploy-release-artifact.yaml b/.github/workflows/node-flow-deploy-release-artifact.yaml
index 9f6e09aa930e..5bffa1821ea8 100644
--- a/.github/workflows/node-flow-deploy-release-artifact.yaml
+++ b/.github/workflows/node-flow-deploy-release-artifact.yaml
@@ -153,8 +153,17 @@ jobs:
ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}
- - name: Trigger ZXF Prepare Extended Test Suite
+ - name: Check Prep XTS Job State
+ id: check-xts-job
if: ${{ needs.release-branch.result == 'success' }}
+ run: |
+ JOB_ENABLED="true"
+ JOB_STATE=$(gh workflow list --all --json name,state | jq -r '.[]|select(.name=="ZXF: Prepare Extended Test Suite")|.state')
+ [[ "${JOB_STATE}" == "disabled_manually" ]] && JOB_ENABLED="false"
+ echo "enabled=${JOB_ENABLED}" >> $GITHUB_OUTPUT
+
+ - name: Trigger ZXF Prepare Extended Test Suite
+ if: ${{ needs.release-branch.result == 'success' && steps.check-xts-job.outputs.enabled == 'true' }}
uses: step-security/workflow-dispatch@4d1049025980f72b1327cbfdeecb07fe7a20f577 # v1.2.4
with:
workflow: .github/workflows/zxf-prepare-extended-test-suite.yaml
@@ -163,8 +172,19 @@ jobs:
token: ${{ secrets.GH_ACCESS_TOKEN }}
inputs: '{ "ref": "${{ inputs.ref }}" }'
- - name: Trigger ZXF Deploy Integration
+ - name: Check Integration Job State
+ id: check-integration-job
if: ${{ needs.release-branch.result == 'success' &&
+ (inputs.author != '' && inputs.msg != '' && inputs.sha != '') &&
+ !cancelled() }}
+ run: |
+ JOB_ENABLED="true"
+ JOB_STATE=$(gh workflow list --all --json name,state | jq -r '.[]|select(.name=="ZXF: [Node] Deploy Integration Network Release")|.state')
+ [[ "${JOB_STATE}" == "disabled_manually" ]] && JOB_ENABLED="false"
+ echo "enabled=${JOB_ENABLED}" >> $GITHUB_OUTPUT
+
+ - name: Trigger ZXF Deploy Integration
+ if: ${{ needs.release-branch.result == 'success' && steps.check-integration-job.outputs.enabled == 'true' &&
(inputs.author != '' && inputs.msg != '' && inputs.sha != '') &&
!cancelled() }}
uses: step-security/workflow-dispatch@4d1049025980f72b1327cbfdeecb07fe7a20f577 # v1.2.4
diff --git a/.github/workflows/node-zxcron-develop-fsts-regression.yaml b/.github/workflows/node-zxcron-main-fsts-regression.yaml
similarity index 100%
rename from .github/workflows/node-zxcron-develop-fsts-regression.yaml
rename to .github/workflows/node-zxcron-main-fsts-regression.yaml
diff --git a/.github/workflows/platform-zxcron-develop-jrs-regression.yaml b/.github/workflows/platform-zxcron-main-jrs-regression.yaml
similarity index 100%
rename from .github/workflows/platform-zxcron-develop-jrs-regression.yaml
rename to .github/workflows/platform-zxcron-main-jrs-regression.yaml
From 904d976934a62bac720ba584c1a1f0d75df13d2d Mon Sep 17 00:00:00 2001
From: Roger Barker
Date: Fri, 20 Dec 2024 23:38:38 -0600
Subject: [PATCH 12/13] ci: Update Check Integration/XTS Job State to include
GH_TOKEN (#17160)
Signed-off-by: Roger Barker
---
.github/workflows/node-flow-deploy-release-artifact.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.github/workflows/node-flow-deploy-release-artifact.yaml b/.github/workflows/node-flow-deploy-release-artifact.yaml
index 5bffa1821ea8..fee3555bb96d 100644
--- a/.github/workflows/node-flow-deploy-release-artifact.yaml
+++ b/.github/workflows/node-flow-deploy-release-artifact.yaml
@@ -41,6 +41,10 @@ defaults:
run:
shell: bash
+permissions:
+ contents: read
+ actions: read
+
jobs:
prepare-tag-release:
name: Prepare Release [Tag]
@@ -156,6 +160,8 @@ jobs:
- name: Check Prep XTS Job State
id: check-xts-job
if: ${{ needs.release-branch.result == 'success' }}
+ env:
+ GH_TOKEN: ${{ github.token }}
run: |
JOB_ENABLED="true"
JOB_STATE=$(gh workflow list --all --json name,state | jq -r '.[]|select(.name=="ZXF: Prepare Extended Test Suite")|.state')
@@ -177,6 +183,8 @@ jobs:
if: ${{ needs.release-branch.result == 'success' &&
(inputs.author != '' && inputs.msg != '' && inputs.sha != '') &&
!cancelled() }}
+ env:
+ GH_TOKEN: ${{ github.token }}
run: |
JOB_ENABLED="true"
JOB_STATE=$(gh workflow list --all --json name,state | jq -r '.[]|select(.name=="ZXF: [Node] Deploy Integration Network Release")|.state')
From d3dcd588885c1dc6d54b9b062da5fe36a3afa5b7 Mon Sep 17 00:00:00 2001
From: Roger Barker
Date: Fri, 20 Dec 2024 23:53:05 -0600
Subject: [PATCH 13/13] ci: add id_token write permission to
node-flow-deploy-release-artifact.yaml (#17161)
Signed-off-by: Roger Barker
---
.github/workflows/node-flow-deploy-release-artifact.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/node-flow-deploy-release-artifact.yaml b/.github/workflows/node-flow-deploy-release-artifact.yaml
index fee3555bb96d..a66aff48bee5 100644
--- a/.github/workflows/node-flow-deploy-release-artifact.yaml
+++ b/.github/workflows/node-flow-deploy-release-artifact.yaml
@@ -42,6 +42,7 @@ defaults:
shell: bash
permissions:
+ id-token: write
contents: read
actions: read