From 55b01b529daa19a85d9742c895aea057342cab27 Mon Sep 17 00:00:00 2001 From: Petar Tonev Date: Wed, 18 Sep 2024 17:08:21 +0300 Subject: [PATCH] chore: Add missing javadocs in Consensus Service (#15299) Signed-off-by: Petar Tonev --- .../service/consensus/impl/ConsensusServiceImpl.java | 7 +++++++ .../app/service/consensus/impl/WritableTopicStore.java | 1 + .../impl/handlers/ConsensusCreateTopicHandler.java | 3 +++ .../impl/handlers/ConsensusDeleteTopicHandler.java | 3 +++ .../impl/handlers/ConsensusGetTopicInfoHandler.java | 4 +++- .../consensus/impl/handlers/ConsensusHandlers.java | 5 +++++ .../impl/handlers/ConsensusSubmitMessageHandler.java | 10 ++++++++++ .../impl/handlers/ConsensusUpdateTopicHandler.java | 7 +++++++ .../consensus/impl/schemas/V0490ConsensusSchema.java | 3 +++ .../src/main/java/module-info.java | 3 +++ .../consensus/impl/test/ConsensusServiceImplTest.java | 3 +++ .../impl/test/handlers/ConsensusTestBase.java | 4 ++++ .../impl/test/handlers/ConsensusTestUtils.java | 3 +++ .../impl/test/schemas/V0490ConsensusSchemaTest.java | 3 +++ .../node/app/service/consensus/ConsensusService.java | 3 +++ .../service/consensus/ConsensusServiceDefinition.java | 3 +++ .../src/main/java/module-info.java | 3 +++ 17 files changed, 67 insertions(+), 1 deletion(-) diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/ConsensusServiceImpl.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/ConsensusServiceImpl.java index 790314c4877e..77f0441edffe 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/ConsensusServiceImpl.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/ConsensusServiceImpl.java @@ -26,7 +26,14 @@ * Standard implementation of the {@link ConsensusService} {@link RpcService}. */ public final class ConsensusServiceImpl implements ConsensusService { + /** + * Topic running hash + */ public static final int RUNNING_HASH_BYTE_ARRAY_SIZE = 48; + + /** + * Topics state key + */ public static final String TOPICS_KEY = "TOPICS"; @Override diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/WritableTopicStore.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/WritableTopicStore.java index 5a23dd7c709d..b3a8f2514ced 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/WritableTopicStore.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/WritableTopicStore.java @@ -76,6 +76,7 @@ public void put(@NonNull final Topic topic) { * Returns the {@link Topic} with the given number using {@link WritableKVState#getForModify}. * If no such topic exists, returns {@code Optional.empty()} * @param topicID - the id of the topic to be retrieved. + * @return the retrieved topic */ public Topic getForModify(@NonNull final TopicID topicID) { requireNonNull(topicID); diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusCreateTopicHandler.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusCreateTopicHandler.java index 85cfeba7bc62..09245289ccf2 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusCreateTopicHandler.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusCreateTopicHandler.java @@ -58,6 +58,9 @@ */ @Singleton public class ConsensusCreateTopicHandler implements TransactionHandler { + /** + * Default constructor for injection. + */ @Inject public ConsensusCreateTopicHandler() { // Exists for injection diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusDeleteTopicHandler.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusDeleteTopicHandler.java index 59c23170274f..4990cfe14d2c 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusDeleteTopicHandler.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusDeleteTopicHandler.java @@ -50,6 +50,9 @@ */ @Singleton public class ConsensusDeleteTopicHandler implements TransactionHandler { + /** + * Default constructor for injection. + */ @Inject public ConsensusDeleteTopicHandler() { // Exists for injection diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusGetTopicInfoHandler.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusGetTopicInfoHandler.java index 0465b707dc75..cd410dc27af7 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusGetTopicInfoHandler.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusGetTopicInfoHandler.java @@ -68,7 +68,9 @@ */ @Singleton public class ConsensusGetTopicInfoHandler extends PaidQueryHandler { - + /** + * Default constructor for injection. + */ @Inject public ConsensusGetTopicInfoHandler() { // Dagger 2 diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusHandlers.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusHandlers.java index 84cc13ab8897..8db34a4e212a 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusHandlers.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusHandlers.java @@ -39,6 +39,11 @@ public class ConsensusHandlers { /** * Constructor for ConsensusHandlers. + * @param consensusCreateTopicHandler the handler for create topic + * @param consensusDeleteTopicHandler the handler for delete topic + * @param consensusGetTopicInfoHandler the handler for topic info + * @param consensusSubmitMessageHandler the handler for message submit + * @param consensusUpdateTopicHandler the handler for update topic */ @Inject public ConsensusHandlers( diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusSubmitMessageHandler.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusSubmitMessageHandler.java index 5e2cc16d4324..22a855b4f494 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusSubmitMessageHandler.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusSubmitMessageHandler.java @@ -70,8 +70,14 @@ */ @Singleton public class ConsensusSubmitMessageHandler implements TransactionHandler { + /** + * Running hash version + */ public static final long RUNNING_HASH_VERSION = 3L; + /** + * Default constructor for injection. + */ @Inject public ConsensusSubmitMessageHandler() { // Exists for injection @@ -262,6 +268,10 @@ public Topic updateRunningHashAndSequenceNumber( return topicBuilder.build(); } + /** + * @param byteArray the byte array to hash + * @return the byte array of the hashed value + */ public static byte[] noThrowSha384HashOf(final byte[] byteArray) { try { return MessageDigest.getInstance("SHA-384").digest(byteArray); diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusUpdateTopicHandler.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusUpdateTopicHandler.java index d3c56633ff99..40e34d875d22 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusUpdateTopicHandler.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/handlers/ConsensusUpdateTopicHandler.java @@ -72,6 +72,9 @@ public class ConsensusUpdateTopicHandler implements TransactionHandler { private static final Logger log = LogManager.getLogger(ConsensusUpdateTopicHandler.class); + /** + * Default constructor for injection. + */ @Inject public ConsensusUpdateTopicHandler() { // Exists for injection @@ -304,6 +307,10 @@ private void validateMaybeNewSubmitKey( } } + /** + * @param op the transaction body of consensus update operation + * @return {@code true} if the operation wants to update a non-expiry field, {@code false} otherwise. + */ public static boolean wantsToMutateNonExpiryField(@NonNull final ConsensusUpdateTopicTransactionBody op) { return op.hasMemo() || op.hasAdminKey() diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/V0490ConsensusSchema.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/V0490ConsensusSchema.java index bd32d54e18d3..5cf14d857773 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/V0490ConsensusSchema.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/V0490ConsensusSchema.java @@ -42,6 +42,9 @@ public class V0490ConsensusSchema extends Schema { private static final long MAX_TOPICS = 1_000_000_000L; + /** + * Constructor for this schema. + */ public V0490ConsensusSchema() { super(VERSION); } diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/module-info.java b/hedera-node/hedera-consensus-service-impl/src/main/java/module-info.java index 60c4db706a28..4dddcd657f81 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/module-info.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/module-info.java @@ -1,5 +1,8 @@ import com.hedera.node.app.service.consensus.impl.ConsensusServiceImpl; +/** + * Module that provides the implementation of the Hedera Consensus Service. + */ module com.hedera.node.app.service.consensus.impl { requires transitive com.hedera.node.app.service.consensus; requires transitive com.hedera.node.app.spi; diff --git a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ConsensusServiceImplTest.java b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ConsensusServiceImplTest.java index 13012f01e808..d4f661233c67 100644 --- a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ConsensusServiceImplTest.java +++ b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ConsensusServiceImplTest.java @@ -26,6 +26,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +/** + * Unit tests of Consensus Service + */ public class ConsensusServiceImplTest { private ConsensusServiceImpl subject; diff --git a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestBase.java b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestBase.java index 6adf10993836..3d5691c66ae8 100644 --- a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestBase.java +++ b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestBase.java @@ -47,6 +47,9 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +/** + * Base class for consensus service tests. + */ @ExtendWith(MockitoExtension.class) public class ConsensusTestBase { private static final String A_NAME = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -64,6 +67,7 @@ public class ConsensusTestBase { KEY_BUILDER.apply(C_NAME).build()) .build())) .build(); + public static final Key A_COMPLEX_KEY = Key.newBuilder() .thresholdKey(ThresholdKey.newBuilder() .threshold(2) diff --git a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestUtils.java b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestUtils.java index a0b017a1c002..ed2d89fb47e7 100644 --- a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestUtils.java +++ b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusTestUtils.java @@ -31,6 +31,9 @@ import com.hedera.node.app.service.token.ReadableAccountStore; import com.hedera.pbj.runtime.io.buffer.Bytes; +/** + * Util class used in unit tests for Consensus Service + */ public final class ConsensusTestUtils { static final Key SIMPLE_KEY_A = Key.newBuilder() diff --git a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/schemas/V0490ConsensusSchemaTest.java b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/schemas/V0490ConsensusSchemaTest.java index 5a98130b9c23..1662b0e4b2f3 100644 --- a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/schemas/V0490ConsensusSchemaTest.java +++ b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/schemas/V0490ConsensusSchemaTest.java @@ -27,6 +27,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +/** + * Unit tests for the initial mod-service schema for the consensus service. + */ @ExtendWith(MockitoExtension.class) public class V0490ConsensusSchemaTest { private V0490ConsensusSchema subject; diff --git a/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusService.java b/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusService.java index 147177e04c8d..a3a1f26d37fd 100644 --- a/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusService.java +++ b/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusService.java @@ -29,6 +29,9 @@ * Service. */ public interface ConsensusService extends RpcService { + /** + * The name of the service + */ String NAME = "ConsensusService"; @NonNull diff --git a/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusServiceDefinition.java b/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusServiceDefinition.java index 6071781e3196..1fbb0a5d6bc1 100644 --- a/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusServiceDefinition.java +++ b/hedera-node/hedera-consensus-service/src/main/java/com/hedera/node/app/service/consensus/ConsensusServiceDefinition.java @@ -35,6 +35,9 @@ */ @SuppressWarnings("java:S6548") public final class ConsensusServiceDefinition implements RpcServiceDefinition { + /** + * Singleton instance of the Token Service + */ public static final ConsensusServiceDefinition INSTANCE = new ConsensusServiceDefinition(); private static final Set> methods = Set.of( diff --git a/hedera-node/hedera-consensus-service/src/main/java/module-info.java b/hedera-node/hedera-consensus-service/src/main/java/module-info.java index 33b830494415..d99764e9213d 100644 --- a/hedera-node/hedera-consensus-service/src/main/java/module-info.java +++ b/hedera-node/hedera-consensus-service/src/main/java/module-info.java @@ -1,3 +1,6 @@ +/** + * Provides the classes necessary to manage Hedera Consensus Service. + */ module com.hedera.node.app.service.consensus { exports com.hedera.node.app.service.consensus;