From 3166f30057d554edf2a2d5c5e3b053332c9e0f34 Mon Sep 17 00:00:00 2001 From: Neeharika Sompalli <52669918+Neeharika-Sompalli@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:19:40 -0500 Subject: [PATCH] test: (cherry-pick) Added a test to submit DAB transactions for JRS test (#15549) (#15616) Signed-off-by: Neeharika-Sompalli --- .../mainnet/upgrade/throttles.json | 8 ++- .../testnet/upgrade/throttles.json | 8 ++- .../main/java/com/hedera/node/app/Hedera.java | 15 +++-- .../main/resources/genesis/throttles-dev.json | 8 ++- .../src/main/resources/genesis/throttles.json | 8 ++- .../services/bdd/suites/SuiteRunner.java | 2 + .../bdd/suites/hip869/NodeCreateTest.java | 6 +- .../bdd/suites/hip869/NodeDeleteTest.java | 5 +- .../bdd/suites/hip869/NodeUpdateTest.java | 6 +- .../bdd/suites/jrs/NodeOpsForUpgrade.java | 66 +++++++++++++++++++ 10 files changed, 110 insertions(+), 22 deletions(-) create mode 100644 hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/jrs/NodeOpsForUpgrade.java diff --git a/hedera-node/configuration/mainnet/upgrade/throttles.json b/hedera-node/configuration/mainnet/upgrade/throttles.json index 06ae864ff7c7..0103b63300c8 100644 --- a/hedera-node/configuration/mainnet/upgrade/throttles.json +++ b/hedera-node/configuration/mainnet/upgrade/throttles.json @@ -39,7 +39,10 @@ "TokenGetNftInfos", "CryptoApproveAllowance", "CryptoDeleteAllowance", - "UtilPrng" + "UtilPrng", + "NodeCreate", + "NodeUpdate", + "NodeDelete" ] }, { @@ -146,7 +149,8 @@ "opsPerSec": 0, "milliOpsPerSec": 2000, "operations": [ - "CryptoCreate" + "CryptoCreate", + "NodeCreate" ] }, { diff --git a/hedera-node/configuration/testnet/upgrade/throttles.json b/hedera-node/configuration/testnet/upgrade/throttles.json index e1d83b109ac0..74f19f55bca0 100644 --- a/hedera-node/configuration/testnet/upgrade/throttles.json +++ b/hedera-node/configuration/testnet/upgrade/throttles.json @@ -40,7 +40,10 @@ "TokenGetNftInfos", "CryptoApproveAllowance", "CryptoDeleteAllowance", - "UtilPrng" + "UtilPrng", + "NodeCreate", + "NodeUpdate", + "NodeDelete" ] }, { @@ -146,7 +149,8 @@ "opsPerSec": 0, "milliOpsPerSec": 2000, "operations": [ - "CryptoCreate" + "CryptoCreate", + "NodeCreate" ] }, { diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java index e4f0e2a79e23..c5011536e07d 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java @@ -301,9 +301,9 @@ public final class Hedera implements SwirldMain, PlatformStatusChangeListener { *

This registration is a critical side effect that must happen called before any Platform initialization * steps that try to create or deserialize a {@link MerkleStateRoot}. * - * @param constructableRegistry the registry to register {@link RuntimeConstructable} factories with - * @param registryFactory the factory to use for creating the services registry - * @param migrator the migrator to use with the services + * @param constructableRegistry the registry to register {@link RuntimeConstructable} factories with + * @param registryFactory the factory to use for creating the services registry + * @param migrator the migrator to use with the services * @param tssBaseServiceSupplier the supplier for the TSS base service */ public Hedera( @@ -531,9 +531,9 @@ public void onStateInitialized( *

If the {@code deserializedVersion} is {@code null}, then this is the first time the node has been started, * and thus all schemas will be executed. * - * @param state current state + * @param state current state * @param deserializedVersion version deserialized - * @param trigger trigger that is calling migration + * @param trigger trigger that is calling migration * @return the state changes caused by the migration */ private List onMigrate( @@ -769,6 +769,7 @@ public void shutdownGrpcServer() { /** * Called to set the starting state hash after genesis or restart. + * * @param stateHash the starting state hash */ public void setInitialStateHash(@NonNull final Hash stateHash) { @@ -854,6 +855,10 @@ private void initializeDagger( initialStateHashFuture = new CompletableFuture<>(); notifications.register(ReconnectCompleteListener.class, new ReadReconnectStartingStateHash(notifications)); } + if (initialStateHashFuture == null) { + logger.warn("Starting from Browser is deprecated. Setting initial start hash to empty hash."); + initialStateHashFuture = completedFuture(Bytes.wrap(new byte[48])); + } // For other triggers the initial state hash must have been set already requireNonNull(initialStateHashFuture); final var roundNum = requireNonNull(state.getReadableStates(PlatformStateService.NAME) diff --git a/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles-dev.json b/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles-dev.json index 3585961b5488..39d8a47f12e5 100644 --- a/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles-dev.json +++ b/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles-dev.json @@ -36,7 +36,10 @@ "ContractGetRecords", "ContractCallLocal", "TransactionGetRecord", - "GetVersionInfo" + "GetVersionInfo", + "NodeCreate", + "NodeUpdate", + "NodeDelete" ] }, { @@ -104,7 +107,8 @@ { "opsPerSec": 2000, "operations": [ - "CryptoCreate" + "CryptoCreate", + "NodeCreate" ] }, { diff --git a/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles.json b/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles.json index 753f3c656931..80eb081806c7 100644 --- a/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles.json +++ b/hedera-node/hedera-file-service-impl/src/main/resources/genesis/throttles.json @@ -39,7 +39,10 @@ "TokenGetNftInfos", "CryptoApproveAllowance", "CryptoDeleteAllowance", - "UtilPrng" + "UtilPrng", + "NodeCreate", + "NodeUpdate", + "NodeDelete" ] }, { @@ -146,7 +149,8 @@ "opsPerSec": 0, "milliOpsPerSec": 2000, "operations": [ - "CryptoCreate" + "CryptoCreate", + "NodeCreate" ] }, { diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/SuiteRunner.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/SuiteRunner.java index 4495a39f7756..9c10d14897fb 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/SuiteRunner.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/SuiteRunner.java @@ -34,6 +34,7 @@ import com.hedera.services.bdd.suites.freeze.PrepareUpgrade; import com.hedera.services.bdd.suites.freeze.SimpleFreezeOnly; import com.hedera.services.bdd.suites.freeze.UpdateFileForUpgrade; +import com.hedera.services.bdd.suites.jrs.NodeOpsForUpgrade; import com.hedera.services.bdd.suites.meta.VersionInfoSpec; import com.hedera.services.bdd.suites.perf.AdjustFeeScheduleSuite; import com.hedera.services.bdd.suites.perf.crypto.*; @@ -91,6 +92,7 @@ public class SuiteRunner { put("CreateFilesBeforeReconnect", aof(CreateFilesBeforeReconnect::new)); put("SubmitMessageLoadTest", aof(SubmitMessageLoadTest::new)); put("AdjustFeeSchedule", aof(AdjustFeeScheduleSuite::new)); + put("NodeOpsForUpgrade", aof(NodeOpsForUpgrade::new)); } }; diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeCreateTest.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeCreateTest.java index 12a85b3aace7..3b8d9e25a725 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeCreateTest.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeCreateTest.java @@ -35,7 +35,6 @@ import static com.hedera.services.bdd.suites.HapiSuite.NONSENSE_KEY; import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR; import static com.hedera.services.bdd.suites.HapiSuite.ONE_HUNDRED_HBARS; -import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINTS_EXCEEDED_LIMIT; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE; @@ -495,15 +494,16 @@ final Stream validateFeesInsufficientAmount() throws CertificateEnc } @HapiTest - final Stream failsAtIngestForUnAuthorizedTxns() { + final Stream failsAtIngestForUnAuthorizedTxns() throws CertificateEncodingException { final String description = "His vorpal blade went snicker-snack!"; return hapiTest( cryptoCreate("payer").balance(ONE_HUNDRED_HBARS), nodeCreate("ntb") .payingWith("payer") .description(description) + .gossipCaCertificate(gossipCertificates.getFirst().getEncoded()) .fee(ONE_HBAR) - .hasPrecheck(BUSY) + .hasKnownStatus(UNAUTHORIZED) .via("nodeCreation")); } diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeDeleteTest.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeDeleteTest.java index c610a9b53d69..d386eec3b6fa 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeDeleteTest.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeDeleteTest.java @@ -31,7 +31,6 @@ import static com.hedera.services.bdd.suites.HapiSuite.GENESIS; import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR; import static com.hedera.services.bdd.suites.hip869.NodeCreateTest.generateX509Certificates; -import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NODE_ID; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.NODE_DELETED; @@ -159,7 +158,7 @@ final Stream failsAtIngestForUnAuthorizedTxns() throws CertificateE nodeDelete("ntb") .payingWith("payer") .fee(ONE_HBAR) - .hasPrecheck(BUSY) + .hasKnownStatus(UNAUTHORIZED) .via("failedDeletion")) .when() .then(); @@ -195,7 +194,7 @@ final Stream handleCanBeExecutedJustWithPrivilegedAccount() throws nodeDelete(nodeName) .payingWith("payer") .signedBy("payer", "wrongKey") - .hasPrecheck(BUSY), + .hasKnownStatus(UNAUTHORIZED), nodeDelete(nodeName)); } diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeUpdateTest.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeUpdateTest.java index 4fd1ca16805f..9dda2e1d4a33 100644 --- a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeUpdateTest.java +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/NodeUpdateTest.java @@ -37,7 +37,6 @@ import static com.hedera.services.bdd.suites.HapiSuite.NONSENSE_KEY; import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR; import static com.hedera.services.bdd.suites.hip869.NodeCreateTest.generateX509Certificates; -import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINTS_EXCEEDED_LIMIT; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ADMIN_KEY; @@ -271,7 +270,8 @@ final Stream updateAccountIdWork() throws CertificateEncodingExcept "Node grpcCertificateHash should be updated"); assertEquals(toPbj(updateOp.getAdminKey()), node.adminKey(), "Node adminKey should be updated"); assertEquals(toPbj(asAccount("0.0.100")), node.accountId()); - })); + }), + overriding("nodes.updateAccountIdAllowed", "false")); } @HapiTest @@ -291,7 +291,7 @@ final Stream failsAtIngestForUnAuthorizedTxns() throws CertificateE nodeUpdate("ntb") .payingWith("payer") .accountId("0.0.1000") - .hasPrecheck(BUSY) + .hasPrecheck(UPDATE_NODE_ACCOUNT_NOT_ALLOWED) .fee(ONE_HBAR) .via("updateNode")) .when() diff --git a/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/jrs/NodeOpsForUpgrade.java b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/jrs/NodeOpsForUpgrade.java new file mode 100644 index 000000000000..bd3e4ac27bd8 --- /dev/null +++ b/hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/jrs/NodeOpsForUpgrade.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.services.bdd.suites.jrs; + +import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec; +import static com.hedera.services.bdd.spec.transactions.TxnVerbs.nodeDelete; +import static com.hedera.services.bdd.spec.transactions.TxnVerbs.nodeUpdate; +import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed; +import static com.hedera.services.bdd.spec.utilops.UtilVerbs.overridingTwo; +import static com.hedera.services.bdd.suites.crypto.CryptoCreateSuite.ED_25519_KEY; +import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.initializeSettings; + +import com.hedera.services.bdd.spec.keys.KeyShape; +import com.hedera.services.bdd.suites.HapiSuite; +import java.util.List; +import java.util.stream.Stream; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.DynamicTest; + +public class NodeOpsForUpgrade extends HapiSuite { + private static final Logger log = LogManager.getLogger(NodeOpsForUpgrade.class); + + public static void main(String... args) { + new NodeOpsForUpgrade().runSuiteSync(); + } + + @Override + public List> getSpecsInSuite() { + return List.of(doDelete()); + } + + final Stream doDelete() { + return defaultHapiSpec("NodeOpsForUpgrade") + .given(initializeSettings()) + .when( + overridingTwo("nodes.enableDAB", "true", "nodes.updateAccountIdAllowed", "true"), + newKeyNamed(ED_25519_KEY).shape(KeyShape.ED25519), + nodeDelete("3").payingWith(GENESIS).signedBy(GENESIS), + nodeUpdate("2") + .description("UpdatedNode0") + .accountId("0.0.100") + .payingWith(GENESIS) + .signedBy(GENESIS)) + .then(overridingTwo("nodes.enableDAB", "true", "nodes.updateAccountIdAllowed", "false")); + } + + @Override + protected Logger getResultsLogger() { + return log; + } +}