Skip to content

Commit 7ff3faf

Browse files
committed
nits
Signed-off-by: Nikita Lebedev <[email protected]>
1 parent d524ac7 commit 7ff3faf

File tree

29 files changed

+37
-49
lines changed

29 files changed

+37
-49
lines changed

hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/BlockStreamManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public boolean endRound(@NonNull final State state, final long roundNum) {
376376
if (closesBlock) {
377377
lifecycle.onCloseBlock(state);
378378
if (state instanceof HederaNewStateRoot hederaNewStateRoot) {
379-
hederaNewStateRoot.commitAllSingletons();
379+
hederaNewStateRoot.commitSingletons();
380380
}
381381
// Flush all boundary state changes besides the BlockStreamInfo
382382
worker.addItem(boundaryStateChangeListener.flushChanges());

hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/ReadonlyQueueStateWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public ReadonlyQueueStateWrapper(@NonNull final WritableQueueState<E> delegate)
2727
this.delegate = requireNonNull(delegate, "delegate must not be null");
2828
}
2929

30+
@NonNull
3031
@Override
3132
public String getServiceName() {
3233
return delegate.getServiceName();

hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/ReadonlySingletonStateWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public ReadonlySingletonStateWrapper(@NonNull final WritableSingletonState<T> de
2727
this.delegate = requireNonNull(delegate, "delegate must not be null");
2828
}
2929

30+
@NonNull
3031
@Override
3132
public String getServiceName() {
3233
return delegate.getServiceName();

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/stack/WritableKVStateStack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private WritableKVState<K, V> getCurrent() {
5959
* {@inheritDoc}
6060
*/
6161
@Override
62+
@NonNull
6263
public String getServiceName() {
6364
return serviceName;
6465
}

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/stack/WritableQueueStateStack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private WritableQueueState<E> getCurrent() {
5656
return writableStatesStack.getCurrent().getQueue(stateKey);
5757
}
5858

59+
@NonNull
5960
@Override
6061
public String getServiceName() {
6162
return serviceName;

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/stack/WritableSingletonStateStack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private WritableSingletonState<T> getCurrent() {
5454
}
5555

5656
@Override
57+
@NonNull
5758
public String getServiceName() {
5859
return serviceName;
5960
}

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/TransactionExecutors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,5 +331,5 @@ public List<OperationTracer> get() {
331331
}
332332
}
333333

334-
static final Metrics NO_OP_METRICS = new NoOpMetrics();
334+
private static final Metrics NO_OP_METRICS = new NoOpMetrics();
335335
}

hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/stack/SavepointStackImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.hedera.node.config.data.BlockStreamConfig;
2626
import com.hedera.node.config.testfixtures.HederaTestConfigBuilder;
2727
import com.hedera.node.config.types.StreamMode;
28-
import com.swirlds.platform.state.MerkleNodeState;
28+
import com.swirlds.state.State;
2929
import com.swirlds.state.spi.ReadableStates;
3030
import com.swirlds.state.test.fixtures.MapWritableKVState;
3131
import com.swirlds.state.test.fixtures.MapWritableStates;
@@ -60,7 +60,7 @@ class SavepointStackImplTest extends StateTestBase {
6060
G_KEY, GRAPE);
6161

6262
@Mock(strictness = LENIENT)
63-
private MerkleNodeState baseState;
63+
private State baseState;
6464

6565
@Mock
6666
private SavepointStackImpl parent;

platform-sdk/platform-apps/tests/ConsistencyTestingTool/src/main/java/com/swirlds/demo/consistency/ConsistencyTestingToolState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ protected ConsistencyTestingToolState copyingConstructor() {
266266
}
267267

268268
@Override
269-
public MerkleNode migrate(@NonNull Configuration configuration, int version) {
269+
public MerkleNode migrate(@NonNull final Configuration configuration, int version) {
270270
return this;
271271
}
272272
}

platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public boolean childHasExpectedType(final int index, final long childClassId) {
117117
}
118118

119119
@Override
120-
public MerkleNode migrate(@NonNull Configuration configuration, int version) {
120+
public MerkleNode migrate(@NonNull final Configuration configuration, int version) {
121121
if (version == ClassVersion.VIRTUAL_MAP) {
122122
TestingAppStateInitializer.DEFAULT.initRosterState(this);
123123
return this;

platform-sdk/swirlds-benchmarks/src/jmh/java/com/swirlds/benchmark/reconnect/BenchmarkMerkleInternal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public BenchmarkMerkleInternal copy() {
120120
* in position 0, and that leaf will equal this node.
121121
*/
122122
@Override
123-
public MerkleNode migrate(@NonNull Configuration configuration, final int version) {
123+
public MerkleNode migrate(@NonNull final Configuration configuration, final int version) {
124124
return migrationMapper.apply(this, version);
125125
}
126126
}

platform-sdk/swirlds-common/src/testFixtures/java/com/swirlds/common/test/fixtures/merkle/dummy/DummyMerkleInternal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public DummyMerkleInternal copy() {
149149
* in position 0, and that leaf will equal this node.
150150
*/
151151
@Override
152-
public MerkleNode migrate(@NonNull Configuration configuration, final int version) {
152+
public MerkleNode migrate(@NonNull final Configuration configuration, final int version) {
153153
return migrationMapper.apply(this, version);
154154
}
155155
}

platform-sdk/swirlds-common/src/testFixtures/java/com/swirlds/common/test/fixtures/merkle/dummy/DummyMerkleLeaf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public boolean equals(final Object obj) {
188188
* in position 0, and that leaf will equal this node.
189189
*/
190190
@Override
191-
public MerkleNode migrate(@NonNull Configuration configuration, final int version) {
191+
public MerkleNode migrate(@NonNull final Configuration configuration, final int version) {
192192
return migrationMapper.apply(this, version);
193193
}
194194
}

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/StateInitializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ public static void initializeState(
106106
* to {@code MerkleNodeState}.
107107
* </p>
108108
*
109+
* @deprecated This method should be removed together with {@code MerkleStateRoot}. Only state root function should be used then.
109110
* @param stateRootFunction a function to instantiate the state root object from a Virtual Map
110111
* @param stateRoot the root of the state to initialize
111112
* @param metrics the metrics
112113
* @return the initialized {@code MerkleNodeState}
113114
*/
115+
@Deprecated
114116
public static MerkleNodeState initializeMerkleNodeState(
115117
@NonNull final Function<VirtualMap, MerkleNodeState> stateRootFunction,
116118
@NonNull final MerkleNode stateRoot,

platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/MerkleNodeState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ default void initializeState(@NonNull final StateMetadata<?, ?> md) {
5252
* MUST have a correct label applied. If the node is already present, then this method does nothing
5353
* else.
5454
*
55-
* @deprecated This method is only required for the MerkleStateRoot class and will be removed together with that class.
55+
* @deprecated This method is only required for the {@code MerkleStateRoot} class and will be removed together with that class.
5656
* @param md The metadata associated with the state
5757
* @param nodeSupplier Returns the node to add. Cannot be null. Can be used to create the node on-the-fly.
5858
* @throws IllegalArgumentException if the node is neither a merkle map nor virtual map, or if
@@ -70,7 +70,7 @@ default void putServiceStateIfAbsent(
7070
* MUST have a correct label applied. No matter if the resulting node is newly created or already
7171
* present, calls the provided initialization consumer with the node.
7272
*
73-
* @deprecated This method is only required for the MerkleStateRoot class and will be removed together with that class.
73+
* @deprecated This method is only required for the {@code MerkleStateRoot} class and will be removed together with that class.
7474
* @param md The metadata associated with the state
7575
* @param nodeSupplier Returns the node to add. Cannot be null. Can be used to create the node on-the-fly.
7676
* @param nodeInitializer The node's initialization logic.

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/DefaultSignedStateValidatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private SignedState stateSignedByNodes(final List<Node> signingNodes) {
334334
};
335335

336336
return new RandomSignedStateGenerator()
337-
.setState(new TestMerkleStateRoot())
337+
.setState(new TestMerkleStateRoot()) // FUTURE WORK: remove this line to use TestNewMerkleStateRoot
338338
.setRound(ROUND)
339339
.setRoster(roster)
340340
.setStateHash(stateHash)

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void executeReconnect(final ReconnectMetrics reconnectMetrics) throws In
117117
.setRoster(roster)
118118
.setSigningNodeIds(nodeIds)
119119
.setCalculateHash(true)
120-
.setState(new TestMerkleStateRoot())
120+
.setState(new TestMerkleStateRoot()) // FUTURE WORK: remove this line to use TestNewMerkleStateRoot
121121
.buildWithFacade();
122122
final SignedState signedState = signedStateFacadePair.left();
123123
final PlatformStateFacade platformStateFacade = signedStateFacadePair.right();

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/StateSigningTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void allSignaturesBecomeInvalidTest(final boolean evenWeighting) {
367367
.setCalculateHash(true)
368368
.setSignatures(new HashMap<>())
369369
.setCalculateHash(true)
370-
.setState(new TestMerkleStateRoot())
370+
.setState(new TestMerkleStateRoot()) // FUTURE WORK: remove this line to use TestNewMerkleStateRoot
371371
.build();
372372

373373
final SigSet sigSet = signedState.getSigSet();

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/manager/AddIncompleteStateTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void addIncompleteStateTest() {
106106
.setRoster(roster)
107107
.setRound(firstRound)
108108
.setSignatures(signatures)
109-
.setState(new TestMerkleStateRoot())
109+
.setState(new TestMerkleStateRoot()) // FUTURE WORK: remove this line to use TestNewMerkleStateRoot
110110
.build();
111111

112112
// This is intentionally a different hash than the signed hash!

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/manager/OldCompleteStateEventuallyReleasedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void oldCompleteStateEventuallyReleased() throws InterruptedException {
9999
.setRoster(roster)
100100
.setRound(0)
101101
.setSignatures(signatures)
102-
.setState(new TestMerkleStateRoot())
102+
.setState(new TestMerkleStateRoot()) // FUTURE WORK: remove this line to use TestNewMerkleStateRoot
103103
.build();
104104
stateFromDisk.getState().setHash(stateHash);
105105

platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/manager/SequentialSignaturesRestartTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void sequentialSignaturesAfterRestartTest() throws InterruptedException {
110110
.setRound(firstRound)
111111
.setSignatures(signatures)
112112
.setCalculateHash(true)
113-
.setState(new TestMerkleStateRoot())
113+
.setState(new TestMerkleStateRoot()) // FUTURE WORK: remove this line to use TestNewMerkleStateRoot
114114
.build();
115115
stateFromDisk.getState().setHash(stateHash);
116116

platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/RandomSignedStateGenerator.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package com.swirlds.platform.test.fixtures.state;
33

4-
import static com.swirlds.platform.state.service.schemas.V0540PlatformStateSchema.PLATFORM_STATE_KEY;
54
import static com.swirlds.platform.test.fixtures.state.TestingAppStateInitializer.CONFIGURATION;
65
import static com.swirlds.platform.test.fixtures.state.TestingAppStateInitializer.registerMerkleStateRootClassIds;
76
import static org.hiero.base.crypto.test.fixtures.CryptoRandomUtils.randomHash;
@@ -28,12 +27,10 @@
2827
import com.swirlds.platform.config.StateConfig;
2928
import com.swirlds.platform.crypto.SignatureVerifier;
3029
import com.swirlds.platform.state.MerkleNodeState;
31-
import com.swirlds.platform.state.service.PlatformStateService;
3230
import com.swirlds.platform.state.signed.SignedState;
3331
import com.swirlds.platform.test.fixtures.addressbook.RandomRosterBuilder;
3432
import com.swirlds.platform.test.fixtures.state.manager.SignatureVerificationTestUtils;
3533
import com.swirlds.state.merkle.MerkleStateRoot;
36-
import com.swirlds.state.spi.WritableSingletonStateBase;
3734
import edu.umd.cs.findbugs.annotations.NonNull;
3835
import java.time.Instant;
3936
import java.util.ArrayList;
@@ -222,11 +219,6 @@ public Pair<SignedState, TestPlatformStateFacade> buildWithFacade() {
222219
v.setConsensusTimestamp(consensusTimestampInstance);
223220
});
224221

225-
((WritableSingletonStateBase<?>) stateInstance
226-
.getWritableStates(PlatformStateService.NAME)
227-
.getSingleton(PLATFORM_STATE_KEY))
228-
.commit();
229-
230222
TestingAppStateInitializer.DEFAULT.initRosterState(stateInstance);
231223
RosterUtils.setActiveRoster(stateInstance, rosterInstance, roundInstance);
232224

platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/SignedStateUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ public static SignedState randomSignedState(long seed) {
1616
return randomSignedState(new Random(seed));
1717
}
1818

19-
// FUTURE WORK: use TestNewMerkleStateRoot
2019
public static SignedState randomSignedState(Random random) {
2120
TestPlatformStateFacade platformStateFacade = new TestPlatformStateFacade();
22-
MerkleNodeState root = new TestMerkleStateRoot();
21+
MerkleNodeState root = new TestMerkleStateRoot(); // FUTURE WORK: use TestNewMerkleStateRoot
2322
TestingAppStateInitializer.DEFAULT.initPlatformState(root);
2423
randomPlatformState(random, root, platformStateFacade);
2524
boolean shouldSaveToDisk = random.nextBoolean();

platform-sdk/swirlds-platform-core/src/testFixtures/java/com/swirlds/platform/test/fixtures/state/TestingAppStateInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public List<Builder> initRosterState(@NonNull final MerkleNodeState state) {
213213
private static void initializeServiceState(
214214
MerkleNodeState state, StateMetadata<?, ?> md, Supplier<? extends MerkleNode> nodeSupplier) {
215215
switch (state) {
216-
case MerkleStateRoot<?> merkle -> state.putServiceStateIfAbsent(md, nodeSupplier);
217-
case NewStateRoot<?> newRoot -> state.initializeState(md);
216+
case MerkleStateRoot<?> ignored -> state.putServiceStateIfAbsent(md, nodeSupplier);
217+
case NewStateRoot<?> ignored -> state.initializeState(md);
218218
default ->
219219
throw new IllegalStateException(
220220
"Expecting MerkleStateRoot or NewStateRoot instance to be used for state initialization");

platform-sdk/swirlds-state-api/src/main/java/com/swirlds/state/spi/ReadableKVStateBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected ReadableKVStateBase(@NonNull final String serviceName, @NonNull final
5454
*/
5555
// This constructor is used by some consumers of the API that are outside of this repository.
5656
protected ReadableKVStateBase(
57-
@NonNull final String serviceName, @NonNull String stateKey, @NonNull ConcurrentMap<K, V> readCache) {
57+
@NonNull final String serviceName, @NonNull final String stateKey, @NonNull ConcurrentMap<K, V> readCache) {
5858
this.serviceName = Objects.requireNonNull(serviceName);
5959
this.stateKey = Objects.requireNonNull(stateKey);
6060
this.readCache = Objects.requireNonNull(readCache);

platform-sdk/swirlds-state-api/src/main/java/com/swirlds/state/spi/ReadableState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public interface ReadableState {
1414
* @return The name of the service. This will never be null, and will always be the same value for an
1515
* instance of {@link ReadableState}.
1616
*/
17+
@NonNull
1718
String getServiceName();
1819

1920
/**

platform-sdk/swirlds-state-impl/src/main/java/com/swirlds/state/merkle/MerkleStateRoot.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -903,23 +903,6 @@ private static String extractStateKey(@NonNull final StateMetadata<?, ?> md) {
903903
return md.stateDefinition().stateKey();
904904
}
905905

906-
/**
907-
* Commit all singleton states for every registered service.
908-
*/
909-
public void commitSingletons() {
910-
for (String serviceKey : services.keySet()) {
911-
final var service = services.get(serviceKey);
912-
for (String stateKey : service.keySet()) {
913-
StateMetadata<?, ?> stateMetadata = service.get(stateKey);
914-
if (stateMetadata.stateDefinition().singleton()) {
915-
WritableStates writableStates = getWritableStates(serviceKey);
916-
final var writableSingleton = (WritableSingletonStateBase<?>) writableStates.getSingleton(stateKey);
917-
writableSingleton.commit();
918-
}
919-
}
920-
}
921-
}
922-
923906
/**
924907
* {@inheritDoc}
925908
*/

platform-sdk/swirlds-state-impl/src/main/java/com/swirlds/state/merkle/NewStateRoot.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,10 @@ public void mapDeleteChange(@NonNull final K key) {
795795
}
796796
}
797797

798-
public void commitAllSingletons() {
798+
/**
799+
* Commit all singleton states for every registered service.
800+
*/
801+
public void commitSingletons() {
799802
for (String serviceKey : services.keySet()) {
800803
final var service = services.get(serviceKey);
801804
for (String stateKey : service.keySet()) {
@@ -809,6 +812,9 @@ public void commitAllSingletons() {
809812
}
810813
}
811814

815+
/**
816+
* {@inheritDoc}
817+
*/
812818
@Override
813819
public boolean isHashed() {
814820
return virtualMap.isHashed();

platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/VirtualMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ public VirtualMap copy() {
16061606
}
16071607

16081608
@Override
1609-
public MerkleNode migrate(@NonNull Configuration configuration, int version) {
1609+
public MerkleNode migrate(@NonNull final Configuration configuration, int version) {
16101610
if (version < ClassVersion.NO_VIRTUAL_ROOT_NODE) {
16111611
// removing VirtualMapState
16121612
super.setChild(0, null);

0 commit comments

Comments
 (0)