From 2e8fcc931219b06641294630dd3c9b6caee55ca4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Brandst=C3=A4tter?=
Date: Thu, 19 Dec 2024 21:59:03 +0100
Subject: [PATCH 01/12] feat: Support for Yaml configuration and List values
(#17088)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Timo Brandstätter
---
.../node/app/test/grpc/GrpcTestBase.java | 12 +
.../node/config/VersionedConfigImpl.java | 5 +
.../config/converter/AccountIDConverter.java | 3 +-
.../CongestionMultipliersConverter.java | 4 +-
.../config/converter/ContractIDConverter.java | 3 +-
.../EntityScaleFactorsConverter.java | 4 +-
.../config/converter/FileIDConverter.java | 3 +-
.../converter/KeyValuePairConverter.java | 3 +-
.../converter/KnownBlockValuesConverter.java | 3 +-
.../config/converter/LongPairConverter.java | 3 +-
.../converter/ScaleFactorConverter.java | 3 +-
.../config/sources/DynamicConfigSource.java | 12 +
.../config/sources/PropertyConfigSource.java | 12 +
.../docs/base/configuration/configuration.md | 20 +-
.../com/swirlds/config/api/Configuration.java | 7 +
.../config/api/source/ConfigSource.java | 37 +--
.../sources/AbstractConfigSource.java | 19 ++
.../extensions/sources/ConfigMapping.java | 4 -
.../sources/MappedConfigSource.java | 111 ++++++--
.../sources/SimpleConfigSource.java | 84 ++++--
.../SystemEnvironmentConfigSource.java | 19 ++
.../sources/SystemPropertiesConfigSource.java | 19 ++
.../extensions/sources/YamlConfigSource.java | 251 ++++++++++++++++++
.../src/main/java/module-info.java | 3 +
.../test/MappedConfigSourceTest.java | 15 +-
.../test/sources/YamlConfigSourceTest.java | 71 +++++
.../src/test/resources/test.yaml | 17 ++
.../test/fixtures/TestConfigBuilder.java | 2 -
.../impl/converters/BigDecimalConverter.java | 3 +-
.../impl/converters/BigIntegerConverter.java | 3 +-
.../impl/converters/BooleanConverter.java | 3 +-
.../config/impl/converters/ByteConverter.java | 3 +-
.../impl/converters/ChronoUnitConverter.java | 3 +-
.../impl/converters/DoubleConverter.java | 3 +-
.../impl/converters/DurationConverter.java | 3 +-
.../config/impl/converters/FileConverter.java | 3 +-
.../impl/converters/FloatConverter.java | 3 +-
.../impl/converters/InetAddressConverter.java | 44 +++
.../impl/converters/IntegerConverter.java | 3 +-
.../config/impl/converters/LongConverter.java | 3 +-
.../config/impl/converters/PathConverter.java | 3 +-
.../impl/converters/ShortConverter.java | 3 +-
.../impl/converters/StringConverter.java | 3 +-
.../config/impl/converters/UriConverter.java | 3 +-
.../config/impl/converters/UrlConverter.java | 3 +-
.../converters/ZonedDateTimeConverter.java | 3 +-
.../impl/internal/ConfigDataFactory.java | 6 +-
.../internal/ConfigPropertiesService.java | 42 ++-
.../impl/internal/ConfigurationImpl.java | 34 ++-
.../impl/internal/ConverterService.java | 5 +
.../swirlds/config/impl/ConfigApiTests.java | 2 +-
.../config/impl/TestDateConverter.java | 3 +-
52 files changed, 815 insertions(+), 121 deletions(-)
create mode 100644 platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/YamlConfigSource.java
create mode 100644 platform-sdk/swirlds-config-extensions/src/test/java/com/swirlds/config/extensions/test/sources/YamlConfigSourceTest.java
create mode 100644 platform-sdk/swirlds-config-extensions/src/test/resources/test.yaml
create mode 100644 platform-sdk/swirlds-config-impl/src/main/java/com/swirlds/config/impl/converters/InetAddressConverter.java
diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/test/grpc/GrpcTestBase.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/test/grpc/GrpcTestBase.java
index 88fcc00be632..e06f66f51325 100644
--- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/test/grpc/GrpcTestBase.java
+++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/test/grpc/GrpcTestBase.java
@@ -59,6 +59,7 @@
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.Executors;
@@ -334,6 +335,17 @@ public String getValue(@NonNull String s) throws NoSuchElementException {
};
}
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return false;
+ }
+
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ return List.of();
+ }
+
public int port() {
return port;
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/VersionedConfigImpl.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/VersionedConfigImpl.java
index 57de26c83404..9c390501b230 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/VersionedConfigImpl.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/VersionedConfigImpl.java
@@ -56,6 +56,11 @@ public boolean exists(@NonNull final String s) {
return wrappedConfig.exists(s);
}
+ @Override
+ public boolean isListValue(@NonNull final String propertyName) {
+ return wrappedConfig.isListValue(propertyName);
+ }
+
@Override
public String getValue(@NonNull final String s) throws NoSuchElementException {
return wrappedConfig.getValue(s);
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/AccountIDConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/AccountIDConverter.java
index 43d4f4b70516..3a191eb0d962 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/AccountIDConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/AccountIDConverter.java
@@ -18,6 +18,7 @@
import com.hedera.hapi.node.base.AccountID;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.stream.Stream;
/**
@@ -26,7 +27,7 @@
public class AccountIDConverter implements ConfigConverter {
@Override
- public AccountID convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public AccountID convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/CongestionMultipliersConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/CongestionMultipliersConverter.java
index a5c957a2e178..1b123f182991 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/CongestionMultipliersConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/CongestionMultipliersConverter.java
@@ -18,6 +18,7 @@
import com.hedera.node.config.types.CongestionMultipliers;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
/**
* Config api {@link ConfigConverter} implementation for the type {@link CongestionMultipliers}.
@@ -25,7 +26,8 @@
public class CongestionMultipliersConverter implements ConfigConverter {
@Override
- public CongestionMultipliers convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public CongestionMultipliers convert(@NonNull final String value)
+ throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ContractIDConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ContractIDConverter.java
index f0ac1580dc1d..3b23efb9ef02 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ContractIDConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ContractIDConverter.java
@@ -18,6 +18,7 @@
import com.hedera.hapi.node.base.ContractID;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.stream.Stream;
/**
@@ -26,7 +27,7 @@
public class ContractIDConverter implements ConfigConverter {
@Override
- public ContractID convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public ContractID convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/EntityScaleFactorsConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/EntityScaleFactorsConverter.java
index 11f884161131..d6e57f2baba1 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/EntityScaleFactorsConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/EntityScaleFactorsConverter.java
@@ -18,6 +18,7 @@
import com.hedera.node.config.types.EntityScaleFactors;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
/**
* Config api {@link ConfigConverter} implementation for the type {@link EntityScaleFactors}.
@@ -25,7 +26,8 @@
public class EntityScaleFactorsConverter implements ConfigConverter {
@Override
- public EntityScaleFactors convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public EntityScaleFactors convert(@NonNull final String value)
+ throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/FileIDConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/FileIDConverter.java
index fce0b94aba2d..5c7703e874aa 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/FileIDConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/FileIDConverter.java
@@ -18,6 +18,7 @@
import com.hedera.hapi.node.base.FileID;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.stream.Stream;
/**
@@ -26,7 +27,7 @@
public class FileIDConverter implements ConfigConverter {
@Override
- public FileID convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public FileID convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KeyValuePairConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KeyValuePairConverter.java
index f6c28ee1570b..b21df2adb40a 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KeyValuePairConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KeyValuePairConverter.java
@@ -18,6 +18,7 @@
import com.hedera.node.config.types.KeyValuePair;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Objects;
import java.util.regex.Pattern;
@@ -29,7 +30,7 @@ public class KeyValuePairConverter implements ConfigConverter {
private static final String PATTERN = Pattern.quote("=");
@Override
- public KeyValuePair convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public KeyValuePair convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
Objects.requireNonNull(value, "Parameter 'value' cannot be null");
final String[] split = value.split(PATTERN, 2);
if (split.length == 1) {
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KnownBlockValuesConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KnownBlockValuesConverter.java
index 0cd5ce932798..5047cf1f7c7a 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KnownBlockValuesConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/KnownBlockValuesConverter.java
@@ -18,6 +18,7 @@
import com.hedera.node.app.hapi.utils.sysfiles.domain.KnownBlockValues;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
/**
* Config api {@link ConfigConverter} implementation for the type {@link KnownBlockValues}.
@@ -25,7 +26,7 @@
public class KnownBlockValuesConverter implements ConfigConverter {
@Override
- public KnownBlockValues convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public KnownBlockValues convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/LongPairConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/LongPairConverter.java
index 272456f0b04b..e769b8aa339e 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/LongPairConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/LongPairConverter.java
@@ -18,6 +18,7 @@
import com.hedera.node.config.types.LongPair;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Objects;
import java.util.regex.Pattern;
@@ -29,7 +30,7 @@ public class LongPairConverter implements ConfigConverter {
private static final String PATTERN = Pattern.quote("-");
@Override
- public LongPair convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public LongPair convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
Objects.requireNonNull(value, "Parameter 'value' cannot be null");
final String[] split = value.split(PATTERN, 2);
if (split.length <= 1) {
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ScaleFactorConverter.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ScaleFactorConverter.java
index 6212c631b631..8a0c76177a60 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ScaleFactorConverter.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/converter/ScaleFactorConverter.java
@@ -18,6 +18,7 @@
import com.hedera.node.app.hapi.utils.sysfiles.domain.throttling.ScaleFactor;
import com.swirlds.config.api.converter.ConfigConverter;
+import edu.umd.cs.findbugs.annotations.NonNull;
/**
* Config api {@link ConfigConverter} implementation for the type {@link ScaleFactor}.
@@ -25,7 +26,7 @@
public class ScaleFactorConverter implements ConfigConverter {
@Override
- public ScaleFactor convert(final String value) throws IllegalArgumentException, NullPointerException {
+ public ScaleFactor convert(@NonNull final String value) throws IllegalArgumentException, NullPointerException {
if (value == null) {
throw new NullPointerException("null can not be converted");
}
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/DynamicConfigSource.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/DynamicConfigSource.java
index 6cf7434cfbff..87163df11674 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/DynamicConfigSource.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/DynamicConfigSource.java
@@ -19,6 +19,7 @@
import com.swirlds.config.api.source.ConfigSource;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Properties;
@@ -54,6 +55,17 @@ public String getValue(@NonNull final String s) throws NoSuchElementException {
return properties.getProperty(s);
}
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return false;
+ }
+
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ return List.of();
+ }
+
@Override
public int getOrdinal() {
return 500;
diff --git a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/PropertyConfigSource.java b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/PropertyConfigSource.java
index 4046f6240bed..907d5233ee4b 100644
--- a/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/PropertyConfigSource.java
+++ b/hedera-node/hedera-config/src/main/java/com/hedera/node/config/sources/PropertyConfigSource.java
@@ -23,6 +23,7 @@
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
@@ -88,6 +89,17 @@ public String getValue(@NonNull String key) throws NoSuchElementException {
return properties.getProperty(key);
}
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return false;
+ }
+
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ return List.of();
+ }
+
@Override
public int getOrdinal() {
return ordinal;
diff --git a/platform-sdk/docs/base/configuration/configuration.md b/platform-sdk/docs/base/configuration/configuration.md
index 47249fcc0736..c77d5575fd93 100644
--- a/platform-sdk/docs/base/configuration/configuration.md
+++ b/platform-sdk/docs/base/configuration/configuration.md
@@ -119,22 +119,22 @@ final Configuration config = ConfigurationBuilder.create()
String value1 = config.getValue("app.var"); // value1 will be null
String value2 = config.getValue("app.var", "default"); // value2 will be null
String value3 = config.getValue("app.var", String.class); // value3 will be null
-String value4 = config.getValue("app.var", String.class, "default"); // value4 will be null
-
+String value4 = config.getValue("app.var", String.class, "default"); // value4 will be null
+
String value5 = config.getValue("app.foo"); // expression will throw a NoSuchElementException
String value6 = config.getValue("app.foo", "default"); // value6 will be "default"
String value7 = config.getValue("app.foo", String.class); // expression will throw a NoSuchElementException
-String value8 = config.getValue("app.foo", String.class, "default"); // value8 will be "default"
-
+String value8 = config.getValue("app.foo", String.class, "default"); // value8 will be "default"
+
List value9 = config.getValues("app.vars"); // value9 will be null
List value10 = config.getValues("app.vars", List.of()); // value10 will be null
List value11 = config.getValues("app.vars", String.class); // value11 will be null
-List value12 = config.getValues("app.vars", String.class, List.of()); // value12 will be null
-
+List value12 = config.getValues("app.vars", String.class, List.of()); // value12 will be null
+
List value13 = config.getValues("app.foos"); // expression will throw a NoSuchElementException
-List value14 = config.getValues("app.foos", List.of()); // value14 will be the empty default list
+List value14 = config.getValues("app.foos", List.of()); // value14 will be the empty default list
List value15 = config.getValues("app.foos", String.class); // expression will throw a NoSuchElementException
-List value16 = config.getValues("app.foos", String.class, List.of()); // value16 will be the empty default list
+List value16 = config.getValues("app.foos", String.class, List.of()); // value16 will be the empty default list
```
**Note:** if you want to define an empty list as a value for a property you should define it by
@@ -171,7 +171,8 @@ The config API supports several datatypes for reading config properties. The fol
1994-11-05T08:15:30-05:00"
- `Duration`: the custom format from the old settings is supported; examples are "2ms" or "10s"
- `ChronoUnit`: examples are "millis" or "seconds"
-- `Enum`
+- `Enum`
+- `InetAddress`
The support for all data types is done by using the `com.swirlds.config.api.converter.ConfigConverter` API. The
`com.swirlds.config.api.ConfigurationBuilder` must be used to add support for custom datatypes. The following code
@@ -494,4 +495,3 @@ be changed directly.
For the platform the config is provided by the `com.swirlds.common.context.PlatformContext`. Like the context the config
is defined in the `com.swirlds.platform.Browser` class.
-
diff --git a/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/Configuration.java b/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/Configuration.java
index 14759a021220..f7f477f1e99b 100644
--- a/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/Configuration.java
+++ b/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/Configuration.java
@@ -51,6 +51,13 @@ public interface Configuration {
*/
boolean exists(@NonNull String propertyName);
+ /**
+ * Checks if the property with the given name is a list property.
+ * @param propertyName the name of the property that should be checked
+ * @return true if the property is a list property, false otherwise
+ */
+ boolean isListValue(@NonNull String propertyName);
+
/**
* Returns the {@link String} value of the property with the given name.
*
diff --git a/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/source/ConfigSource.java b/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/source/ConfigSource.java
index 6a73b7e92888..e756d4a2a27d 100644
--- a/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/source/ConfigSource.java
+++ b/platform-sdk/swirlds-config-api/src/main/java/com/swirlds/config/api/source/ConfigSource.java
@@ -18,9 +18,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -49,11 +47,30 @@ public interface ConfigSource {
*
* @param propertyName the name of the property
* @return the string value of the property
- * @throws NoSuchElementException if the property with the given name is not defined in the source
+ * @throws NoSuchElementException if the property with the given name is not defined in the source OR is a list property
*/
@Nullable
String getValue(@NonNull String propertyName) throws NoSuchElementException;
+ /**
+ * Checks if the property with the given name is a list property.
+ *
+ * @param propertyName the name of the property
+ * @return {@code true} if the property is a list property, {@code false} otherwise
+ * @throws NoSuchElementException if the property with the given name is not defined in the source OR is not a list property
+ */
+ boolean isListProperty(@NonNull String propertyName) throws NoSuchElementException;
+
+ /**
+ * Returns the list value of the property with the given name.
+ *
+ * @param propertyName the name of the property
+ * @return the list value of the property
+ * @throws NoSuchElementException if the property with the given name is not defined in the source OR is not a list property
+ */
+ @NonNull
+ List getListValue(@NonNull String propertyName) throws NoSuchElementException;
+
/**
* Returns the ordinal. The ordinal is used to define a priority order of all config sources while the config source
* with the highest ordinal has the highest priority. A config source will overwrite values of properties that are
@@ -66,18 +83,6 @@ default int getOrdinal() {
return DEFAULT_ORDINAL;
}
- /**
- * Returns all properties of this source as an immutable map.
- *
- * @return the map with all properties
- */
- @NonNull
- default Map getProperties() {
- final Map props = new HashMap<>();
- getPropertyNames().forEach(prop -> props.put(prop, getValue(prop)));
- return Collections.unmodifiableMap(props);
- }
-
/**
* Returns the name of the config source. A name must not be unique.
*
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/AbstractConfigSource.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/AbstractConfigSource.java
index 730607974756..50bfd976cba9 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/AbstractConfigSource.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/AbstractConfigSource.java
@@ -19,6 +19,7 @@
import com.swirlds.base.ArgumentUtils;
import com.swirlds.config.api.source.ConfigSource;
import edu.umd.cs.findbugs.annotations.NonNull;
+import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -38,6 +39,7 @@ public abstract class AbstractConfigSource implements ConfigSource {
/**
* {@inheritDoc}
*/
+ @NonNull
@Override
public final Set getPropertyNames() {
return getInternalProperties().keySet();
@@ -54,4 +56,21 @@ public final String getValue(@NonNull final String propertyName) {
}
return getInternalProperties().get(propertyName);
}
+
+ /**
+ * This implementation always returns {@code false}.
+ */
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return false;
+ }
+
+ /**
+ * This implementation always returns an empty list.
+ */
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ return List.of();
+ }
}
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/ConfigMapping.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/ConfigMapping.java
index 8f7847204353..39382d652d90 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/ConfigMapping.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/ConfigMapping.java
@@ -19,8 +19,6 @@
import com.swirlds.base.ArgumentUtils;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Objects;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
/**
* Represents a mapping between an original name and a mapped name. This class is used to hold the mapping configuration
@@ -31,8 +29,6 @@
*/
public record ConfigMapping(@NonNull String mappedName, @NonNull String originalName) {
- private static final Logger logger = LogManager.getLogger(MappedConfigSource.class);
-
/**
* Creates a new {@code ConfigMapping}.
*
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/MappedConfigSource.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/MappedConfigSource.java
index 4b33c46d5456..a94cb8c607d4 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/MappedConfigSource.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/MappedConfigSource.java
@@ -18,12 +18,17 @@
import com.swirlds.config.api.source.ConfigSource;
import edu.umd.cs.findbugs.annotations.NonNull;
-import java.util.Collections;
+import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Queue;
+import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -52,7 +57,7 @@
* @see ConfigSource
* @see ConfigMapping
*/
-public class MappedConfigSource extends AbstractConfigSource {
+public class MappedConfigSource implements ConfigSource {
private static final String PROPERTY_NOT_FOUND = "Property '{}' not found in original config source";
private static final String PROPERTY_ALREADY_DEFINED = "Property '%s' already defined";
private static final String DUPLICATE_PROPERTY = "Property '{}' already found in original config source";
@@ -63,6 +68,7 @@ public class MappedConfigSource extends AbstractConfigSource {
private final Queue configMappings;
private final Map properties;
+ private final Map> listProperties;
/**
* Constructor that takes the wrapped config.
@@ -73,6 +79,7 @@ public MappedConfigSource(@NonNull final ConfigSource wrappedSource) {
this.wrappedSource = Objects.requireNonNull(wrappedSource, "wrappedSource must not be null");
configMappings = new ConcurrentLinkedQueue<>();
properties = new HashMap<>();
+ listProperties = new HashMap<>();
}
/**
@@ -106,34 +113,90 @@ public void addMapping(@NonNull final ConfigMapping configMapping) {
}
configMappings.add(configMapping);
+ properties.clear();
+ listProperties.clear();
}
- /**
- * {@inheritDoc}
- */
- @Override
- @NonNull
- protected Map getInternalProperties() {
- if (properties.isEmpty()) {
- final Map internalProperties = wrappedSource.getProperties();
- final Map mappedProperties = new HashMap<>();
-
- configMappings.forEach(configMapping -> {
- if (internalProperties.containsKey(configMapping.mappedName())) {
- logger.warn(DUPLICATE_PROPERTY, configMapping.mappedName());
- } else if (!internalProperties.containsKey(configMapping.originalName())) {
- logger.warn(PROPERTY_NOT_FOUND, configMapping.originalName());
+ private void generateMapping() {
+ if (!properties.isEmpty() || !listProperties.isEmpty()) {
+ return;
+ }
+
+ final Map internalProperties = new HashMap<>();
+ final Map> internalListProperties = new HashMap<>();
+ wrappedSource.getPropertyNames().forEach(propertyName -> {
+ if (wrappedSource.isListProperty(propertyName)) {
+ internalListProperties.put(propertyName, wrappedSource.getListValue(propertyName));
+ } else {
+ internalProperties.put(propertyName, wrappedSource.getValue(propertyName));
+ }
+ });
+
+ final Map mappedProperties = new HashMap<>();
+ final Map> mappedListProperties = new HashMap<>();
+
+ configMappings.forEach(configMapping -> {
+ final String mappedName = configMapping.mappedName();
+ final String originalName = configMapping.originalName();
+
+ if (internalProperties.containsKey(mappedName) || internalListProperties.containsKey(mappedName)) {
+ logger.warn(DUPLICATE_PROPERTY, mappedName);
+ } else if (!internalProperties.containsKey(originalName)
+ && !internalListProperties.containsKey(originalName)) {
+ logger.warn(PROPERTY_NOT_FOUND, originalName);
+ } else {
+ if (wrappedSource.isListProperty(originalName)) {
+ mappedListProperties.put(mappedName, internalListProperties.get(originalName));
} else {
- mappedProperties.put(
- configMapping.mappedName(), internalProperties.get(configMapping.originalName()));
- logger.debug("Added config mapping: {}", configMapping);
+ mappedProperties.put(mappedName, internalProperties.get(originalName));
}
- });
+ logger.debug("Added config mapping: {}", configMapping);
+ }
+ });
- properties.putAll(internalProperties);
- properties.putAll(mappedProperties);
+ properties.putAll(internalProperties);
+ properties.putAll(mappedProperties);
+ listProperties.putAll(internalListProperties);
+ listProperties.putAll(mappedListProperties);
+ }
+
+ @NonNull
+ @Override
+ public Set getPropertyNames() {
+ generateMapping();
+ return Stream.concat(properties.keySet().stream(), listProperties.keySet().stream())
+ .collect(Collectors.toSet());
+ }
+
+ @Nullable
+ @Override
+ public String getValue(@NonNull final String propertyName) throws NoSuchElementException {
+ generateMapping();
+ Objects.requireNonNull(propertyName, "propertyName must not be null");
+ if (isListProperty(propertyName)) {
+ throw new NoSuchElementException("Property " + propertyName + " is a list property");
}
- return Collections.unmodifiableMap(properties);
+
+ return properties.get(propertyName);
+ }
+
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ generateMapping();
+ Objects.requireNonNull(propertyName, "propertyName must not be null");
+ return listProperties.containsKey(propertyName);
+ }
+
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ generateMapping();
+ Objects.requireNonNull(propertyName, "propertyName must not be null");
+ if (!isListProperty(propertyName)) {
+ throw new NoSuchElementException("Property " + propertyName + " is not a list property");
+ }
+
+ return listProperties.get(propertyName);
}
/**
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SimpleConfigSource.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SimpleConfigSource.java
index 6d3d2e0d432a..a17fbf941877 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SimpleConfigSource.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SimpleConfigSource.java
@@ -19,41 +19,54 @@
import static com.swirlds.config.extensions.sources.ConfigSourceOrdinalConstants.PROGRAMMATIC_VALUES_ORDINAL;
import com.swirlds.base.ArgumentUtils;
-import com.swirlds.config.api.Configuration;
+import com.swirlds.config.api.source.ConfigSource;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Optional;
+import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
- * A {@link com.swirlds.config.api.source.ConfigSource} implementation that can be used to provide values of properties
+ * A {@link ConfigSource} implementation that can be used to provide values of properties
* programmatically by calling {@link #withValue(String, Long)} (String, String)}.
*/
-public final class SimpleConfigSource extends AbstractConfigSource {
+public final class SimpleConfigSource implements ConfigSource {
private final Map internalProperties;
+ private final Map> internalListProperties;
- private int oridinal = PROGRAMMATIC_VALUES_ORDINAL;
+ private int ordinal = PROGRAMMATIC_VALUES_ORDINAL;
/**
* Creates an instance without any config properties.
*/
public SimpleConfigSource() {
- this.internalProperties = new HashMap<>();
+ internalProperties = new HashMap<>();
+ internalListProperties = new HashMap<>();
}
/**
- * Creates an instance without any config properties.
+ * Creates an instance with the given config properties and empty list properties.
*/
public SimpleConfigSource(@NonNull final Map properties) {
+ this(properties, new HashMap<>());
+ }
+
+ /**
+ * Creates an instance with the given config properties and list properties.
+ */
+ public SimpleConfigSource(
+ @NonNull final Map properties, @NonNull final Map> listProperties) {
// defensive copy
- this.internalProperties = new HashMap<>(Objects.requireNonNull(properties));
+ internalProperties = new HashMap<>(Objects.requireNonNull(properties));
+ internalListProperties = new HashMap<>(Objects.requireNonNull(listProperties));
}
/**
@@ -67,6 +80,11 @@ public SimpleConfigSource(final String propertyName, final String value) {
withValue(propertyName, value);
}
+ public SimpleConfigSource(final String propertyName, final List> value) {
+ this();
+ setValues(propertyName, value, Object::toString);
+ }
+
/**
* Creates an instance and directly adds the given config property.
*
@@ -259,12 +277,12 @@ private void setValues(
ArgumentUtils.throwArgBlank(propertyName, "propertyName");
Objects.requireNonNull(converter, "converter must not be null");
if (values == null) {
- internalProperties.put(propertyName, null);
+ internalListProperties.put(propertyName, null);
} else if (values.isEmpty()) {
- internalProperties.put(propertyName, Configuration.EMPTY_LIST);
+ internalListProperties.put(propertyName, List.of());
} else {
- String rawValues = values.stream().map(converter).collect(Collectors.joining(","));
- internalProperties.put(propertyName, rawValues);
+ final List rawValues = values.stream().map(converter).toList();
+ internalListProperties.put(propertyName, rawValues);
}
}
@@ -275,7 +293,7 @@ private void setValues(
* @return this
*/
public SimpleConfigSource withOrdinal(final int ordinal) {
- this.oridinal = ordinal;
+ this.ordinal = ordinal;
return this;
}
@@ -289,9 +307,43 @@ public void reset() {
/**
* {@inheritDoc}
*/
+ @NonNull
+ @Override
+ public Set getPropertyNames() {
+ return Stream.concat(internalProperties.keySet().stream(), internalListProperties.keySet().stream())
+ .collect(Collectors.toSet());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Nullable
@Override
- protected Map getInternalProperties() {
- return Collections.unmodifiableMap(internalProperties);
+ public String getValue(@NonNull final String propertyName) throws NoSuchElementException {
+ if (internalProperties.containsKey(propertyName)) {
+ return internalProperties.get(propertyName);
+ }
+ throw new NoSuchElementException("Property " + propertyName + " not found");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return internalListProperties.containsKey(propertyName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ if (internalListProperties.containsKey(propertyName)) {
+ return internalListProperties.get(propertyName);
+ }
+ throw new NoSuchElementException("Property " + propertyName + " not found");
}
/**
@@ -299,6 +351,6 @@ protected Map getInternalProperties() {
*/
@Override
public int getOrdinal() {
- return oridinal;
+ return ordinal;
}
}
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemEnvironmentConfigSource.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemEnvironmentConfigSource.java
index f747ea93d1ba..7702289ff69c 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemEnvironmentConfigSource.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemEnvironmentConfigSource.java
@@ -19,6 +19,7 @@
import com.swirlds.base.ArgumentUtils;
import com.swirlds.config.api.source.ConfigSource;
import edu.umd.cs.findbugs.annotations.NonNull;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -52,6 +53,7 @@ public static SystemEnvironmentConfigSource getInstance() {
/**
* {@inheritDoc}
*/
+ @NonNull
@Override
public Set getPropertyNames() {
return System.getenv().keySet();
@@ -69,6 +71,23 @@ public String getValue(@NonNull final String propertyName) {
return System.getenv(propertyName);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ return List.of();
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemPropertiesConfigSource.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemPropertiesConfigSource.java
index 8c060c08f20f..239aed5869fa 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemPropertiesConfigSource.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/SystemPropertiesConfigSource.java
@@ -19,6 +19,7 @@
import com.swirlds.base.ArgumentUtils;
import com.swirlds.config.api.source.ConfigSource;
import edu.umd.cs.findbugs.annotations.NonNull;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -52,6 +53,7 @@ public static SystemPropertiesConfigSource getInstance() {
/**
* {@inheritDoc}
*/
+ @NonNull
@Override
public Set getPropertyNames() {
return System.getProperties().stringPropertyNames();
@@ -69,6 +71,23 @@ public String getValue(@NonNull final String propertyName) {
return System.getProperty(propertyName);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ return List.of();
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/YamlConfigSource.java b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/YamlConfigSource.java
new file mode 100644
index 000000000000..f61911748a5b
--- /dev/null
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/com/swirlds/config/extensions/sources/YamlConfigSource.java
@@ -0,0 +1,251 @@
+/*
+ * 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.config.extensions.sources;
+
+import static java.util.Objects.requireNonNull;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.swirlds.config.api.source.ConfigSource;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import edu.umd.cs.findbugs.annotations.Nullable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * A config source that reads properties from a YAML file.
+ *
+ * The config source reads the properties from the YAML file.
+ *
+ * The keys of the properties are the full path of the property in the YAML file, separated by dots.
+ * For example:
+ *
+ * a:
+ * b:
+ * c: value
+ *
+ * For the above YAML file, the key for the property would be "a.b.c" to retrieve the "value". This complies with the way the
+ * properties are stored and accessed in the {@link ConfigSource} interface.
+ *
+ * All list elements are stored as JSON strings and can be deserialized in an {@link com.swirlds.config.api.converter.ConfigConverter}
+ */
+public class YamlConfigSource implements ConfigSource {
+
+ /**
+ * The {@link ObjectMapper} used to convert maps to JSON.
+ */
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ /**
+ * The map that contains all not-list properties.
+ */
+ private final Map properties;
+
+ /**
+ * The map that contains all list properties.
+ */
+ private final Map> listProperties;
+
+ /**
+ * The ordinal of this config source.
+ */
+ private final int ordinal;
+
+ /**
+ * Creates a new {@link YamlConfigSource} instance with the given file name and default ordinal.
+ *
+ * @param fileName the name of the file that contains the properties
+ * @see ConfigSource#DEFAULT_ORDINAL
+ */
+ public YamlConfigSource(@NonNull final String fileName) {
+ this(fileName, DEFAULT_ORDINAL);
+ }
+
+ /**
+ * Creates a new {@link YamlConfigSource} instance with the given file name and ordinal.
+ *
+ * @param fileName the name of the file that contains the properties
+ * @param ordinal the ordinal of this config source
+ */
+ public YamlConfigSource(@NonNull final String fileName, final int ordinal) {
+ requireNonNull(fileName, "fileName must not be null");
+ this.properties = new HashMap<>();
+ this.listProperties = new HashMap<>();
+ this.ordinal = ordinal;
+
+ try (InputStream resource =
+ Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)) {
+ if (resource == null) {
+ throw new UncheckedIOException(new IOException("Resource not found: " + fileName));
+ }
+ convertYamlToMaps(resource);
+ } catch (IOException e) {
+ throw new UncheckedIOException("Failed to read YAML file " + fileName, e);
+ }
+ }
+
+ /**
+ * Creates a new {@link YamlConfigSource} instance with the given file path and default ordinal.
+ *
+ * @param filePath the name of the file that contains the properties
+ * @see ConfigSource#DEFAULT_ORDINAL
+ */
+ public YamlConfigSource(@NonNull final Path filePath) {
+ this(filePath, DEFAULT_ORDINAL);
+ }
+
+ /**
+ * Creates a new {@link YamlConfigSource} instance with the given file path and ordinal.
+ *
+ * @param filePath the name of the file that contains the properties
+ * @param ordinal the ordinal of this config source
+ */
+ public YamlConfigSource(@NonNull final Path filePath, final int ordinal) {
+ requireNonNull(filePath, "filePath must not be null");
+ this.properties = new HashMap<>();
+ this.listProperties = new HashMap<>();
+ this.ordinal = ordinal;
+
+ try (InputStream resource = Files.newInputStream(filePath)) {
+ convertYamlToMaps(resource);
+ } catch (IOException e) {
+ throw new UncheckedIOException("Failed to read YAML file " + filePath, e);
+ }
+ }
+
+ private void convertYamlToMaps(@NonNull final InputStream resource) {
+ Objects.requireNonNull(resource, "resource must not be null");
+ final Yaml yaml = new Yaml();
+ final Object rawData = yaml.load(resource);
+ processYamlNode("", rawData, properties, listProperties);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void processYamlNode(
+ @NonNull final String prefix,
+ @NonNull final Object node,
+ @NonNull final Map simpleProps,
+ @NonNull final Map> listProps) {
+
+ if (!(node instanceof Map)) {
+ return;
+ }
+
+ final Map map = (Map) node;
+ for (final Map.Entry entry : map.entrySet()) {
+ final String newPrefix = prefix.isEmpty() ? entry.getKey() : prefix + "." + entry.getKey();
+ final Object value = entry.getValue();
+
+ try {
+ switch (value) {
+ case final List> list -> handleList(listProps, list, newPrefix);
+ case final Map, ?> mapValue -> handleMap(simpleProps, listProps, mapValue, newPrefix);
+ case null -> simpleProps.put(newPrefix, null);
+ default -> simpleProps.put(newPrefix, value.toString());
+ }
+ } catch (JsonProcessingException e) {
+ throw new IllegalStateException("Failed to convert map to JSON for key: " + newPrefix, e);
+ }
+ }
+ }
+
+ private void handleMap(
+ final @NonNull Map simpleProps,
+ final @NonNull Map> listProps,
+ final Map, ?> mapValue,
+ final String newPrefix)
+ throws JsonProcessingException {
+ if (mapValue.values().stream().noneMatch(v -> v instanceof Map || v instanceof List)) {
+ simpleProps.put(newPrefix, OBJECT_MAPPER.writeValueAsString(mapValue));
+ } else {
+ processYamlNode(newPrefix, mapValue, simpleProps, listProps);
+ }
+ }
+
+ private void handleList(
+ final @NonNull Map> listProps, final List> list, final String newPrefix) {
+ if (!list.isEmpty() && list.getFirst() instanceof Map) {
+ final List jsonList = list.stream()
+ .map(item -> {
+ try {
+ return OBJECT_MAPPER.writeValueAsString(item);
+ } catch (JsonProcessingException e) {
+ throw new IllegalStateException("Failed to convert map to JSON", e);
+ }
+ })
+ .toList();
+ listProps.put(newPrefix, jsonList);
+ } else {
+ listProps.put(newPrefix, list.stream().map(Object::toString).toList());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @NonNull
+ @Override
+ public Set getPropertyNames() {
+ return Stream.concat(properties.keySet().stream(), listProperties.keySet().stream())
+ .collect(Collectors.toSet());
+ }
+
+ /** {@inheritDoc} */
+ @Nullable
+ @Override
+ public String getValue(@NonNull String propertyName) throws NoSuchElementException {
+ requireNonNull(propertyName, "propertyName must not be null");
+ if (isListProperty(propertyName)) {
+ throw new NoSuchElementException("Property " + propertyName + " is a list property");
+ }
+ return properties.get(propertyName);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isListProperty(@NonNull final String propertyName) throws NoSuchElementException {
+ requireNonNull(propertyName, "propertyName must not be null");
+ return listProperties.containsKey(propertyName);
+ }
+
+ /** {@inheritDoc} */
+ @NonNull
+ @Override
+ public List getListValue(@NonNull final String propertyName) throws NoSuchElementException {
+ requireNonNull(propertyName, "propertyName must not be null");
+ if (!isListProperty(propertyName)) {
+ throw new NoSuchElementException("Property " + propertyName + " is not a list property");
+ }
+ return listProperties.get(propertyName);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int getOrdinal() {
+ return ordinal;
+ }
+}
diff --git a/platform-sdk/swirlds-config-extensions/src/main/java/module-info.java b/platform-sdk/swirlds-config-extensions/src/main/java/module-info.java
index 5c238d8d0cf9..be27eda4e69b 100644
--- a/platform-sdk/swirlds-config-extensions/src/main/java/module-info.java
+++ b/platform-sdk/swirlds-config-extensions/src/main/java/module-info.java
@@ -7,6 +7,9 @@
requires transitive com.swirlds.config.api;
requires com.swirlds.base;
+ requires com.fasterxml.jackson.core;
+ requires com.fasterxml.jackson.databind;
requires org.apache.logging.log4j;
+ requires org.yaml.snakeyaml;
requires static transitive com.github.spotbugs.annotations;
}
diff --git a/platform-sdk/swirlds-config-extensions/src/test/java/com/swirlds/config/extensions/test/MappedConfigSourceTest.java b/platform-sdk/swirlds-config-extensions/src/test/java/com/swirlds/config/extensions/test/MappedConfigSourceTest.java
index 20b4fb8e9887..22ea64ef2392 100644
--- a/platform-sdk/swirlds-config-extensions/src/test/java/com/swirlds/config/extensions/test/MappedConfigSourceTest.java
+++ b/platform-sdk/swirlds-config-extensions/src/test/java/com/swirlds/config/extensions/test/MappedConfigSourceTest.java
@@ -19,6 +19,7 @@
import com.swirlds.config.extensions.sources.MappedConfigSource;
import com.swirlds.config.extensions.sources.SimpleConfigSource;
import com.swirlds.config.extensions.test.fixtures.TestConfigBuilder;
+import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.Set;
import org.junit.jupiter.api.Assertions;
@@ -48,7 +49,7 @@ void testNoAlias() {
final var mappedConfigSource = new MappedConfigSource(configSource);
// when
- final var properties = mappedConfigSource.getProperties();
+ final var properties = getObjectObjectHashMap(mappedConfigSource);
// then
Assertions.assertNotNull(properties);
@@ -65,7 +66,7 @@ void testAlias() {
// when
mappedConfigSource.addMapping("b", "a");
- final var properties = mappedConfigSource.getProperties();
+ final var properties = getObjectObjectHashMap(mappedConfigSource);
// then
Assertions.assertNotNull(properties);
@@ -97,7 +98,7 @@ void testAliasForNotExistingProperty() {
mappedConfigSource.addMapping("b", "not-available");
// then
- Assertions.assertEquals(1, mappedConfigSource.getProperties().size());
+ Assertions.assertEquals(1, mappedConfigSource.getPropertyNames().size());
Assertions.assertEquals(Set.of("a"), mappedConfigSource.getPropertyNames());
}
@@ -177,7 +178,7 @@ void testNoMappingIfAlreadyInSource() {
// when
mappedConfigSource.addMapping("foo.a", "a");
- final var properties = mappedConfigSource.getProperties();
+ final var properties = getObjectObjectHashMap(mappedConfigSource);
// then
Assertions.assertNotNull(properties);
@@ -185,4 +186,10 @@ void testNoMappingIfAlreadyInSource() {
Assertions.assertEquals("1", properties.get("a"));
Assertions.assertEquals("2", properties.get("foo.a"));
}
+
+ private static HashMap
*
* @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 11/12] 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 12/12] 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