diff --git a/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/ReadableNodeStoreImpl.java b/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/ReadableNodeStoreImpl.java index 764ddfdc4378..f2ef7a3eeb0f 100644 --- a/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/ReadableNodeStoreImpl.java +++ b/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/ReadableNodeStoreImpl.java @@ -72,14 +72,6 @@ public Node get(final long nodeId) { return nodesState.get(EntityNumber.newBuilder().number(nodeId).build()); } - /** - * Returns the number of topics in the state. - * @return the number of topics in the state - */ - public long sizeOfState() { - return nodesState.size(); - } - protected > T nodesState() { return (T) nodesState; } diff --git a/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/WritableNodeStore.java b/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/WritableNodeStore.java index d4a4b0bccc42..f26c4cc8c821 100644 --- a/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/WritableNodeStore.java +++ b/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/WritableNodeStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -81,15 +81,6 @@ public Node getForModify(final long nodeId) { .getForModify(EntityNumber.newBuilder().number(nodeId).build()); } - /** - * Returns the number of nodes in the state. - * @return the number of nodes in the state - */ - @Override - public long sizeOfState() { - return nodesState().size(); - } - /** * Returns the set of nodes modified in existing state. * @return the set of nodes modified in existing state diff --git a/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/handlers/NodeCreateHandler.java b/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/handlers/NodeCreateHandler.java index ce83ac33e636..5b1790749965 100644 --- a/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/handlers/NodeCreateHandler.java +++ b/hedera-node/hedera-addressbook-service-impl/src/main/java/com/hedera/node/app/service/addressbook/impl/handlers/NodeCreateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -41,6 +41,7 @@ import com.hedera.node.app.service.token.ReadableAccountStore; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.PreCheckException; import com.hedera.node.app.spi.workflows.PreHandleContext; @@ -100,9 +101,10 @@ public void handle(@NonNull final HandleContext handleContext) { final var storeFactory = handleContext.storeFactory(); final var nodeStore = storeFactory.writableStore(WritableNodeStore.class); final var accountStore = storeFactory.readableStore(ReadableAccountStore.class); + final var entityIdStore = storeFactory.readableStore(ReadableEntityIdStore.class); final var accountId = op.accountIdOrElse(AccountID.DEFAULT); - validateFalse(nodeStore.sizeOfState() >= nodeConfig.maxNumber(), MAX_NODES_CREATED); + validateFalse(entityIdStore.numNodes() >= nodeConfig.maxNumber(), MAX_NODES_CREATED); validateTrue(accountStore.contains(accountId), INVALID_NODE_ACCOUNT_ID); addressBookValidator.validateDescription(op.description(), nodeConfig); addressBookValidator.validateGossipEndpoint(op.gossipEndpoint(), nodeConfig); diff --git a/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/ReadableNodeStoreImplTest.java b/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/ReadableNodeStoreImplTest.java index 07cb98d9726e..29ccfdff0170 100644 --- a/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/ReadableNodeStoreImplTest.java +++ b/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/ReadableNodeStoreImplTest.java @@ -87,12 +87,6 @@ void nullArgsFail() { assertThrows(NullPointerException.class, () -> new ReadableNodeStoreImpl(null)); } - @Test - void getSizeOfState() { - final var store = new ReadableNodeStoreImpl(readableStates); - assertEquals(readableStates.get(NODES_KEY).size(), store.sizeOfState()); - } - @Test void keysWorks() { final var stateBuilder = emptyReadableNodeStateBuilder(); diff --git a/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/NodeCreateHandlerTest.java b/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/NodeCreateHandlerTest.java index fe47a4dc9563..526ee3f31c20 100644 --- a/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/NodeCreateHandlerTest.java +++ b/hedera-node/hedera-addressbook-service-impl/src/test/java/com/hedera/node/app/service/addressbook/impl/test/handlers/NodeCreateHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -232,7 +232,7 @@ void failsWhenMaxNodesExceeds() { given(handleContext.storeFactory()).willReturn(storeFactory); given(storeFactory.writableStore(WritableNodeStore.class)).willReturn(writableStore); - assertEquals(1, writableStore.sizeOfState()); + // assertEquals(1, writableStore.sizeOfState()); final var msg = assertThrows(HandleException.class, () -> subject.handle(handleContext)); assertEquals(ResponseCodeEnum.MAX_NODES_CREATED, msg.getStatus()); assertEquals(0, writableStore.modifiedNodes().size()); diff --git a/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/AddressBookHelper.java b/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/AddressBookHelper.java index abf97761f4c7..8625849cb5a5 100644 --- a/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/AddressBookHelper.java +++ b/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/AddressBookHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -61,7 +61,7 @@ private AddressBookHelper() { public static long getNextNodeID(@NonNull final ReadableNodeStore nodeStore) { requireNonNull(nodeStore); final long maxNodeId = StreamSupport.stream( - Spliterators.spliterator(nodeStore.keys(), nodeStore.sizeOfState(), DISTINCT), false) + Spliterators.spliteratorUnknownSize(nodeStore.keys(), DISTINCT), false) .mapToLong(EntityNumber::number) .max() .orElse(-1L); diff --git a/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/ReadableNodeStore.java b/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/ReadableNodeStore.java index 335529b6ebf5..f305cac92c0c 100644 --- a/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/ReadableNodeStore.java +++ b/hedera-node/hedera-addressbook-service/src/main/java/com/hedera/node/app/service/addressbook/ReadableNodeStore.java @@ -52,12 +52,6 @@ public interface ReadableNodeStore { @Nullable Node get(long nodeId); - /** - * Returns the number of nodes in the state. - * @return the number of nodes in the state - */ - long sizeOfState(); - /** * Warms the system by preloading a node into memory * diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/fees/congestion/UtilizationScaledThrottleMultiplier.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/fees/congestion/UtilizationScaledThrottleMultiplier.java index 227e6eabe381..e413739f231b 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/fees/congestion/UtilizationScaledThrottleMultiplier.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/fees/congestion/UtilizationScaledThrottleMultiplier.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,10 +28,10 @@ import com.hedera.hapi.node.base.HederaFunctionality; import com.hedera.hapi.node.transaction.TransactionBody; -import com.hedera.node.app.service.consensus.ReadableTopicStore; +import com.hedera.node.app.ids.ReadableEntityIdStoreImpl; import com.hedera.node.app.service.contract.impl.state.ContractStateStore; -import com.hedera.node.app.service.file.ReadableFileStore; import com.hedera.node.app.service.token.*; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.store.ReadableStoreFactory; import com.hedera.node.app.throttle.annotations.CryptoTransferThrottleMultiplier; import com.hedera.node.app.workflows.TransactionInfo; @@ -128,11 +128,9 @@ private int roundedAccountPercentUtil(@NonNull final ReadableStoreFactory storeF final var maxNumOfAccounts = configuration.getConfigData(AccountsConfig.class).maxNumber(); - final var accountsStore = storeFactory.getStore(ReadableAccountStore.class); - final var numAccountsAndContracts = accountsStore.sizeOfAccountState(); - - final var contractsStore = storeFactory.getStore(ContractStateStore.class); - final var numContracts = contractsStore.getNumBytecodes(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStore.class); + final var numAccountsAndContracts = entityIdStore.numAccounts(); + final var numContracts = entityIdStore.numContractBytecodes(); final var numAccounts = numAccountsAndContracts - numContracts; return maxNumOfAccounts == 0 ? 100 : (int) ((100 * numAccounts) / maxNumOfAccounts); @@ -153,8 +151,8 @@ private int roundedFilePercentUtil(@NonNull final ReadableStoreFactory storeFact final var configuration = configProvider.getConfiguration(); final var maxNumOfFiles = configuration.getConfigData(FilesConfig.class).maxNumber(); - final var fileStore = storeFactory.getStore(ReadableFileStore.class); - final var numOfFiles = fileStore.sizeOfState(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStore.class); + final var numOfFiles = entityIdStore.numFiles(); return maxNumOfFiles == 0 ? 100 : (int) ((100 * numOfFiles) / maxNumOfFiles); } @@ -163,8 +161,8 @@ private int roundedNftPercentUtil(@NonNull final ReadableStoreFactory storeFacto final var configuration = configProvider.getConfiguration(); final var maxNumOfNfts = configuration.getConfigData(TokensConfig.class).nftsMaxAllowedMints(); - final var nftStore = storeFactory.getStore(ReadableNftStore.class); - final var numOfNfts = nftStore.sizeOfState(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStore.class); + final var numOfNfts = entityIdStore.numNfts(); return maxNumOfNfts == 0 ? 100 : (int) ((100 * numOfNfts) / maxNumOfNfts); } @@ -174,8 +172,8 @@ private int roundedTokenPercentUtil(@NonNull final ReadableStoreFactory storeFac final var maxNumOfTokens = configuration.getConfigData(TokensConfig.class).maxNumber(); - final var tokenStore = storeFactory.getStore(ReadableTokenStore.class); - final var numOfTokens = tokenStore.sizeOfState(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStore.class); + final var numOfTokens = entityIdStore.numTokens(); return maxNumOfTokens == 0 ? 100 : (int) ((100 * numOfTokens) / maxNumOfTokens); } @@ -185,8 +183,8 @@ private int roundedTokenRelPercentUtil(@NonNull final ReadableStoreFactory store final var maxNumOfTokenRels = configuration.getConfigData(TokensConfig.class).maxAggregateRels(); - final var tokenRelStore = storeFactory.getStore(ReadableTokenRelationStore.class); - final var numOfTokensRels = tokenRelStore.sizeOfState(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStore.class); + final var numOfTokensRels = entityIdStore.numTokenRelations(); return maxNumOfTokenRels == 0 ? 100 : (int) ((100 * numOfTokensRels) / maxNumOfTokenRels); } @@ -196,8 +194,8 @@ private int roundedTopicPercentUtil(@NonNull final ReadableStoreFactory storeFac final var maxNumberOfTopics = configuration.getConfigData(TopicsConfig.class).maxNumber(); - final var topicStore = storeFactory.getStore(ReadableTopicStore.class); - final var numOfTopics = topicStore.sizeOfState(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStoreImpl.class); + final var numOfTopics = entityIdStore.numTopics(); return maxNumberOfTopics == 0 ? 100 : (int) ((100 * numOfTopics) / maxNumberOfTopics); } @@ -207,8 +205,8 @@ private int roundedAirdropPercentUtil(@NonNull final ReadableStoreFactory storeF final var maxNumAirdrops = configuration.getConfigData(TokensConfig.class).maxAllowedPendingAirdrops(); - final var airdropStore = storeFactory.getStore(ReadableAirdropStore.class); - final var numPendingAirdrops = airdropStore.sizeOfState(); + final var entityIdStore = storeFactory.getStore(ReadableEntityIdStore.class); + final var numPendingAirdrops = entityIdStore.numAirdrops(); return maxNumAirdrops == 0 ? 100 : (int) ((100 * numPendingAirdrops) / maxNumAirdrops); } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/services/OrderedServiceMigrator.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/services/OrderedServiceMigrator.java index 89a5de531bd7..74172f748459 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/services/OrderedServiceMigrator.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/services/OrderedServiceMigrator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/merkle/MerkleSchemaRegistry.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/merkle/MerkleSchemaRegistry.java index c111793b24c7..bf5720cfa3d8 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/merkle/MerkleSchemaRegistry.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/state/merkle/MerkleSchemaRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java index dfb36bafa99b..434243687549 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java @@ -19,8 +19,8 @@ import static com.hedera.hapi.node.base.ResponseCodeEnum.BUSY; import static com.hedera.hapi.node.base.ResponseCodeEnum.FAIL_INVALID; import static com.hedera.hapi.util.HapiUtils.asTimestamp; +import static com.hedera.node.app.ids.schemas.V0590EntityIdSchema.ENTITY_COUNTS_KEY; import static com.hedera.node.app.records.schemas.V0490BlockRecordSchema.BLOCK_INFO_STATE_KEY; -import static com.hedera.node.app.service.file.impl.schemas.V0490FileSchema.BLOBS_KEY; import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.SCHEDULED; import static com.hedera.node.app.spi.workflows.HandleContext.TransactionCategory.USER; import static com.hedera.node.app.spi.workflows.record.StreamBuilder.ReversingBehavior.REVERSIBLE; @@ -51,6 +51,7 @@ import com.hedera.hapi.node.base.SemanticVersion; import com.hedera.hapi.node.base.Transaction; import com.hedera.hapi.node.state.blockrecords.BlockInfo; +import com.hedera.hapi.node.state.entity.EntityCounts; import com.hedera.hapi.node.transaction.ExchangeRateSet; import com.hedera.hapi.platform.event.StateSignatureTransaction; import com.hedera.hapi.util.HapiUtils; @@ -64,6 +65,7 @@ import com.hedera.node.app.hints.impl.WritableHintsStoreImpl; import com.hedera.node.app.history.HistoryService; import com.hedera.node.app.history.impl.WritableHistoryStoreImpl; +import com.hedera.node.app.ids.EntityIdService; import com.hedera.node.app.records.BlockRecordManager; import com.hedera.node.app.records.BlockRecordService; import com.hedera.node.app.roster.ActiveRosters; @@ -71,7 +73,6 @@ import com.hedera.node.app.service.addressbook.AddressBookService; import com.hedera.node.app.service.addressbook.impl.WritableNodeStore; import com.hedera.node.app.service.addressbook.impl.helpers.AddressBookHelper; -import com.hedera.node.app.service.file.FileService; import com.hedera.node.app.service.schedule.ExecutableTxn; import com.hedera.node.app.service.schedule.ScheduleService; import com.hedera.node.app.service.schedule.impl.WritableScheduleStoreImpl; @@ -929,9 +930,10 @@ private static void logPreDispatch(@NonNull final UserTxn userTxn) { * @return the type of the boundary transaction */ private TransactionType typeOfBoundary(@NonNull final State state) { - final var files = state.getReadableStates(FileService.NAME).get(BLOBS_KEY); + final var entityCounts = + state.getReadableStates(EntityIdService.NAME).getSingleton(ENTITY_COUNTS_KEY); // The files map is empty only at genesis - if (files.size() == 0) { + if (entityCounts.get().numFiles() == 0) { return GENESIS_TRANSACTION; } final var blockInfo = state.getReadableStates(BlockRecordService.NAME) diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/dispatch/ChildDispatchFactory.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/dispatch/ChildDispatchFactory.java index cf473a84276c..2be1da0789eb 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/dispatch/ChildDispatchFactory.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/dispatch/ChildDispatchFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/PlatformStateUpdates.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/PlatformStateUpdates.java index 699cc0be2983..d84b3118622a 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/PlatformStateUpdates.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/PlatformStateUpdates.java @@ -150,8 +150,7 @@ public void handleTxBody( final var nodeStore = new ReadableNodeStoreImpl(state.getReadableStates(AddressBookService.NAME)); final var candidateRoster = new Roster(StreamSupport.stream( - Spliterators.spliterator(nodeStore.keys(), nodeStore.sizeOfState(), DISTINCT), - false) + Spliterators.spliteratorUnknownSize(nodeStore.keys(), DISTINCT), false) .mapToLong(EntityNumber::number) .sorted() .mapToObj(nodeStore::get) diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/UserTxnFactory.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/UserTxnFactory.java index 1d87d8db27f1..1eeeff9566ae 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/UserTxnFactory.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/steps/UserTxnFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneDispatchFactory.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneDispatchFactory.java index 2edeb53e8815..6269b4926b19 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneDispatchFactory.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/standalone/impl/StandaloneDispatchFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/stack/SavepointStackImplTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/stack/SavepointStackImplTest.java index 55b0ce32af40..c6f596879d6b 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/stack/SavepointStackImplTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/stack/SavepointStackImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -784,9 +784,9 @@ private static Condition content(Map expected) { private static Predicate contentCheck(Map expected) { return readableStates -> { final var actual = readableStates.get(FRUIT_STATE_KEY); - if (expected.size() != actual.size()) { - return false; - } + // if (expected.size() != actual.size()) { + // return false; + // } for (final var entry : expected.entrySet()) { if (!Objects.equals(entry.getValue(), actual.get(entry.getKey()))) { return false; 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 b3a8f2514ced..1382c6d8f6ab 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -82,15 +82,6 @@ public Topic getForModify(@NonNull final TopicID topicID) { requireNonNull(topicID); return topicState().getForModify(topicID); } - - /** - * Returns the number of topics in the state. - * @return the number of topics in the state - */ - public long sizeOfState() { - return topicState().size(); - } - /** * Returns the set of topics modified in existing state. * @return the set of topics modified in existing state 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 7c92ffcd0459..3814173ad1ea 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 @@ -40,6 +40,7 @@ import com.hedera.node.app.service.consensus.impl.records.ConsensusCreateTopicStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.EntityType; import com.hedera.node.app.spi.validation.ExpiryMeta; import com.hedera.node.app.spi.workflows.HandleContext; @@ -120,9 +121,9 @@ public void handle(@NonNull final HandleContext handleContext) { handleContext.attributeValidator().validateKey(op.submitKey()); builder.submitKey(op.submitKey()); } - + final var entityIdStore = handleContext.storeFactory().readableStore(ReadableEntityIdStore.class); /* Validate if the current topic can be created */ - if (topicStore.sizeOfState() >= topicConfig.maxNumber()) { + if (entityIdStore.numTopics() >= topicConfig.maxNumber()) { throw new HandleException(MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); } diff --git a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ReadableTopicStoreImplTest.java b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ReadableTopicStoreImplTest.java index 062758538a49..cdfb83d12da2 100644 --- a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ReadableTopicStoreImplTest.java +++ b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/ReadableTopicStoreImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -106,10 +106,4 @@ void constructorCreatesTopicState() { void nullArgsFail() { assertThrows(NullPointerException.class, () -> new ReadableTopicStoreImpl(null)); } - - @Test - void getSizeOfState() { - final var store = new ReadableTopicStoreImpl(readableStates); - assertEquals(readableStates.get(TOPICS_KEY).size(), store.sizeOfState()); - } } diff --git a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusCreateTopicTest.java b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusCreateTopicTest.java index e8ec06ac748c..d70b4c87a409 100644 --- a/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusCreateTopicTest.java +++ b/hedera-node/hedera-consensus-service-impl/src/test/java/com/hedera/node/app/service/consensus/impl/test/handlers/ConsensusCreateTopicTest.java @@ -367,7 +367,7 @@ void handleThrowsIfAttributeValidatorFails() { .validateMemo(txnBody.consensusCreateTopicOrThrow().memo()); assertThrows(HandleException.class, () -> subject.handle(handleContext)); - assertEquals(0, topicStore.sizeOfState()); + // assertEquals(0, topicStore.sizeOfState()); } @Test @@ -384,7 +384,7 @@ void handleThrowsIfKeyValidatorFails() { .when(validator) .validateKey(adminKey); assertThrows(HandleException.class, () -> subject.handle(handleContext)); - assertEquals(0, topicStore.sizeOfState()); + // assertEquals(0, topicStore.sizeOfState()); } @Test @@ -398,7 +398,7 @@ void failsWhenMaxRegimeExceeds() { given(writableStates.get(TOPICS_KEY)).willReturn(writableState); final var topicStore = new WritableTopicStore(writableStates, config, storeMetricsService); - assertEquals(1, topicStore.sizeOfState()); + // assertEquals(1, topicStore.sizeOfState()); given(storeFactory.writableStore(WritableTopicStore.class)).willReturn(topicStore); given(handleContext.attributeValidator()).willReturn(validator); @@ -426,7 +426,7 @@ void validatedAutoRenewAccount() { given(handleContext.consensusNow()).willReturn(Instant.ofEpochSecond(1_234_567L)); given(writableStates.get(TOPICS_KEY)).willReturn(writableState); final var topicStore = new WritableTopicStore(writableStates, config, storeMetricsService); - assertEquals(1, topicStore.sizeOfState()); + // assertEquals(1, topicStore.sizeOfState()); given(handleContext.attributeValidator()).willReturn(validator); given(handleContext.expiryValidator()).willReturn(expiryValidator); diff --git a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/ReadableFileStoreImpl.java b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/ReadableFileStoreImpl.java index 53353b6ac750..d2bd3406c509 100644 --- a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/ReadableFileStoreImpl.java +++ b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/ReadableFileStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -68,13 +68,4 @@ public ReadableFileStoreImpl(@NonNull final ReadableStates states) { public @Nullable File getFileLeaf(@NonNull FileID id) { return fileState.get(id); } - - /** - * Returns the number of files in the state. - * - * @return the number of files in the state - */ - public long sizeOfState() { - return fileState.size(); - } } diff --git a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/WritableFileStore.java b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/WritableFileStore.java index f95c170d9fa5..487c19efcb46 100644 --- a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/WritableFileStore.java +++ b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/WritableFileStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -92,15 +92,6 @@ public void put(@NonNull final File file) { return Optional.ofNullable(file); } - /** - * Returns the number of files in the state. - * - * @return the number of files in the state - */ - public long sizeOfState() { - return filesState.size(); - } - /** * Returns the set of files modified in existing state. * diff --git a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/handlers/FileCreateHandler.java b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/handlers/FileCreateHandler.java index 9dabab7d098b..5af47e009fb7 100644 --- a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/handlers/FileCreateHandler.java +++ b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/handlers/FileCreateHandler.java @@ -38,6 +38,7 @@ import com.hedera.node.app.service.file.impl.records.CreateFileStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.EntityType; import com.hedera.node.app.spi.validation.ExpiryMeta; import com.hedera.node.app.spi.workflows.HandleContext; @@ -115,7 +116,8 @@ public void handle(@NonNull final HandleContext handleContext) throws HandleExce /* Validate if the current file can be created */ final var fileStore = handleContext.storeFactory().writableStore(WritableFileStore.class); - if (fileStore.sizeOfState() >= fileServiceConfig.maxNumber()) { + final var entityIdStore = handleContext.storeFactory().readableStore(ReadableEntityIdStore.class); + if (entityIdStore.numFiles() >= fileServiceConfig.maxNumber()) { throw new HandleException(MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); } diff --git a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/schemas/V0490FileSchema.java b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/schemas/V0490FileSchema.java index b0cdd7bdc6d7..e7c439d53f09 100644 --- a/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/schemas/V0490FileSchema.java +++ b/hedera-node/hedera-file-service-impl/src/main/java/com/hedera/node/app/service/file/impl/schemas/V0490FileSchema.java @@ -231,7 +231,7 @@ public static void dispatchSynthFileUpdate( public Bytes nodeStoreNodeDetails(@NonNull final ReadableNodeStore nodeStore) { final var nodeDetails = new ArrayList(); - StreamSupport.stream(Spliterators.spliterator(nodeStore.keys(), nodeStore.sizeOfState(), DISTINCT), false) + StreamSupport.stream(Spliterators.spliteratorUnknownSize(nodeStore.keys(), DISTINCT), false) .mapToLong(EntityNumber::number) .mapToObj(nodeStore::get) .filter(node -> node != null && !node.deleted()) @@ -257,7 +257,7 @@ private Bytes getHexStringBytesFromBytes(final Bytes rawBytes) { public Bytes nodeStoreAddressBook(@NonNull final ReadableNodeStore nodeStore) { final var nodeAddresses = new ArrayList(); - StreamSupport.stream(Spliterators.spliterator(nodeStore.keys(), nodeStore.sizeOfState(), DISTINCT), false) + StreamSupport.stream(Spliterators.spliteratorUnknownSize(nodeStore.keys(), DISTINCT), false) .mapToLong(EntityNumber::number) .mapToObj(nodeStore::get) .filter(node -> node != null && !node.deleted()) diff --git a/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/ReadableFileStoreImplTest.java b/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/ReadableFileStoreImplTest.java index e44399159868..b4e33e6da5b5 100644 --- a/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/ReadableFileStoreImplTest.java +++ b/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/ReadableFileStoreImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -16,7 +16,6 @@ package com.hedera.node.app.service.file.impl.test; -import static com.hedera.node.app.service.file.impl.schemas.V0490FileSchema.BLOBS_KEY; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.BDDMockito.given; @@ -71,10 +70,4 @@ void constructorCreatesFileState() { void nullArgsFail() { assertThrows(NullPointerException.class, () -> new ReadableFileStoreImpl(null)); } - - @Test - void returnSizeOfState() { - final var store = new ReadableFileStoreImpl(readableStates); - assertEquals(readableStates.get(BLOBS_KEY).size(), store.sizeOfState()); - } } diff --git a/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/handlers/FileCreateTest.java b/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/handlers/FileCreateTest.java index e75210ba58e7..ec9c749543e4 100644 --- a/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/handlers/FileCreateTest.java +++ b/hedera-node/hedera-file-service-impl/src/test/java/com/hedera/node/app/service/file/impl/test/handlers/FileCreateTest.java @@ -319,7 +319,7 @@ void failsWhenMaxRegimeExceeds() { final var fileStore = new WritableFileStore(writableStates, DEFAULT_CONFIG, storeMetricsService); given(storeFactory.writableStore(WritableFileStore.class)).willReturn(fileStore); - assertEquals(2, fileStore.sizeOfState()); + // assertEquals(2, fileStore.sizeOfState()); config = new FilesConfig(1L, 1L, 1L, 1L, 1L, 1L, new LongPair(150L, 159L), 1L, 1L, 1); given(configuration.getConfigData(any())).willReturn(config); diff --git a/hedera-node/hedera-file-service/src/main/java/com/hedera/node/app/service/file/ReadableFileStore.java b/hedera-node/hedera-file-service/src/main/java/com/hedera/node/app/service/file/ReadableFileStore.java index 0c8655df98a7..c71864d70eed 100644 --- a/hedera-node/hedera-file-service/src/main/java/com/hedera/node/app/service/file/ReadableFileStore.java +++ b/hedera-node/hedera-file-service/src/main/java/com/hedera/node/app/service/file/ReadableFileStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,11 +47,4 @@ public interface ReadableFileStore { */ @Nullable File getFileLeaf(@NonNull FileID id); - - /** - * Returns the number of files in the state. - * - * @return the number of files in the state - */ - long sizeOfState(); } diff --git a/hedera-node/hedera-network-admin-service-impl/src/main/java/com/hedera/node/app/service/networkadmin/impl/handlers/ReadableFreezeUpgradeActions.java b/hedera-node/hedera-network-admin-service-impl/src/main/java/com/hedera/node/app/service/networkadmin/impl/handlers/ReadableFreezeUpgradeActions.java index 882c0e647bbe..9d167c762c00 100644 --- a/hedera-node/hedera-network-admin-service-impl/src/main/java/com/hedera/node/app/service/networkadmin/impl/handlers/ReadableFreezeUpgradeActions.java +++ b/hedera-node/hedera-network-admin-service-impl/src/main/java/com/hedera/node/app/service/networkadmin/impl/handlers/ReadableFreezeUpgradeActions.java @@ -249,8 +249,7 @@ private CompletableFuture extractNow( private record ActiveNode(@NonNull Node node, @Nullable StakingNodeInfo stakingInfo) {} private List allActiveNodes() { - return StreamSupport.stream( - Spliterators.spliterator(nodeStore.keys(), nodeStore.sizeOfState(), DISTINCT), false) + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(nodeStore.keys(), DISTINCT), false) .mapToLong(EntityNumber::number) .sorted() .mapToObj(nodeStore::get) diff --git a/hedera-node/hedera-network-admin-service-impl/src/test/java/com/hedera/node/app/service/networkadmin/impl/test/handlers/FreezeHandlerTest.java b/hedera-node/hedera-network-admin-service-impl/src/test/java/com/hedera/node/app/service/networkadmin/impl/test/handlers/FreezeHandlerTest.java index ce52d8bc7049..b50ad6aee804 100644 --- a/hedera-node/hedera-network-admin-service-impl/src/test/java/com/hedera/node/app/service/networkadmin/impl/test/handlers/FreezeHandlerTest.java +++ b/hedera-node/hedera-network-admin-service-impl/src/test/java/com/hedera/node/app/service/networkadmin/impl/test/handlers/FreezeHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -399,7 +399,7 @@ void happyPathPrepareUpgradeFile150() throws IOException { .willReturn(File.newBuilder().build()); given(upgradeFileStore.getFull(fileUpgradeFileId)).willReturn(Bytes.wrap("Upgrade file bytes")); given(nodeStore.keys()).willReturn(List.of(new EntityNumber(0)).iterator()); - given(nodeStore.sizeOfState()).willReturn(1L); + // given(nodeStore.sizeOfState()).willReturn(1L); TransactionID txnId = TransactionID.newBuilder() .accountID(nonAdminAccount) @@ -429,7 +429,7 @@ void happyPathPrepareUpgradeFile157() throws IOException { .willReturn(File.newBuilder().build()); given(upgradeFileStore.getFull(anotherFileUpgradeFileId)).willReturn(Bytes.wrap("Upgrade file bytes")); given(nodeStore.keys()).willReturn(List.of(new EntityNumber(0)).iterator()); - given(nodeStore.sizeOfState()).willReturn(1L); + // given(nodeStore.sizeOfState()).willReturn(1L); TransactionID txnId = TransactionID.newBuilder() .accountID(nonAdminAccount) diff --git a/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreImpl.java b/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreImpl.java index 6ba5df5cb73b..fbb2fde9b28a 100644 --- a/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreImpl.java +++ b/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -92,11 +92,6 @@ public ScheduleID getByOrder(@NonNull final ScheduledOrder scheduledOrder) { return scheduledOrders.get(scheduledOrder); } - @Override - public long numSchedulesInState() { - return schedulesById.size(); - } - @Override public int numTransactionsScheduledAt(final long consensusSecond) { final var counts = scheduledCounts.get(new TimestampSeconds(consensusSecond)); diff --git a/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandler.java b/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandler.java index eb7ad69d96e4..919c01332748 100644 --- a/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandler.java +++ b/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandler.java @@ -58,6 +58,7 @@ import com.hedera.node.app.service.token.ReadableAccountStore; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.throttle.Throttle; import com.hedera.node.app.spi.validation.EntityType; import com.hedera.node.app.spi.workflows.HandleContext; @@ -194,8 +195,9 @@ public void handle(@NonNull final HandleContext context) throws HandleException .scheduledTransactionID(scheduledTxnId); throw new HandleException(IDENTICAL_SCHEDULE_ALREADY_CREATED); } + final var entityIdStore = context.storeFactory().readableStore(ReadableEntityIdStore.class); validateTrue( - scheduleStore.numSchedulesInState() + 1 <= schedulingConfig.maxNumber(), + entityIdStore.numSchedules() + 1 <= schedulingConfig.maxNumber(), MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); final var capacityFraction = schedulingConfig.schedulableCapacityFraction(); final var usageSnapshots = scheduleStore.usageSnapshotsForScheduled(then); diff --git a/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/schemas/V0570ScheduleSchema.java b/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/schemas/V0570ScheduleSchema.java index 3d38a236b9a2..1edd26145fc2 100644 --- a/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/schemas/V0570ScheduleSchema.java +++ b/hedera-node/hedera-schedule-service-impl/src/main/java/com/hedera/node/app/service/schedule/impl/schemas/V0570ScheduleSchema.java @@ -140,7 +140,7 @@ public void migrate(@NonNull final MigrationContext ctx) { writableScheduleByEquality.put(key, newScheduleId); } }); - log.info("Migrated {} schedules from SCHEDULES_BY_EQUALITY_KEY", readableSchedulesByEquality.size()); + log.info("Migrated {} schedules from SCHEDULES_BY_EQUALITY_KEY"); } private static StateDefinition scheduledCounts() { diff --git a/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreTest.java b/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreTest.java index c367e7334c1a..a4a4b412e90d 100644 --- a/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreTest.java +++ b/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/ReadableScheduleStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,11 +48,6 @@ void getNullReturnsNull() { assertThat(scheduleStore.get(null)).isNull(); } - @Test - void getsExpectedSize() { - assertThat(scheduleStore.numSchedulesInState()).isEqualTo(2); - } - @Test void returnsEmptyIfMissingSchedule() { final long missingId = testScheduleID.scheduleNum() + 15_000L; diff --git a/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandlerTest.java b/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandlerTest.java index 1ce861bd4abc..13aaac9aca30 100644 --- a/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandlerTest.java +++ b/hedera-node/hedera-schedule-service-impl/src/test/java/com/hedera/node/app/service/schedule/impl/handlers/ScheduleCreateHandlerTest.java @@ -189,7 +189,7 @@ void handleRefusesToExceedCreationLimit() throws HandleException, PreCheckExcept assertThat(configuredWhitelist).hasSizeGreaterThan(4); final WritableScheduleStore fullStore = mock(WritableScheduleStore.class); - given(fullStore.numSchedulesInState()).willReturn(scheduleConfig.maxNumber() + 1); + // given(fullStore.numSchedulesInState()).willReturn(scheduleConfig.maxNumber() + 1); given(mockContext.storeFactory()).willReturn(storeFactory); given(storeFactory.writableStore(WritableScheduleStore.class)).willReturn(fullStore); diff --git a/hedera-node/hedera-schedule-service/src/main/java/com/hedera/node/app/service/schedule/ReadableScheduleStore.java b/hedera-node/hedera-schedule-service/src/main/java/com/hedera/node/app/service/schedule/ReadableScheduleStore.java index f3c06e87b084..0317e1b4ccd4 100644 --- a/hedera-node/hedera-schedule-service/src/main/java/com/hedera/node/app/service/schedule/ReadableScheduleStore.java +++ b/hedera-node/hedera-schedule-service/src/main/java/com/hedera/node/app/service/schedule/ReadableScheduleStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -68,13 +68,6 @@ public interface ReadableScheduleStore { @Nullable ScheduleID getByOrder(@NonNull ScheduledOrder scheduledOrder); - /** - * Returns the number of schedules in state, for use in enforcing creation limits. - * - * @return the number of schedules in state - */ - long numSchedulesInState(); - /** * Returns the number of schedules that are scheduled to execute at the given consensus second. * @param consensusSecond the consensus second to check for scheduled transactions diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAccountStoreImpl.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAccountStoreImpl.java index 71b598c92d75..2155b9c8c451 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAccountStoreImpl.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAccountStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -168,12 +168,6 @@ protected Account getAliasedAccountLeaf(@NonNull final AccountID id) { final var accountId = lookupAliasedAccountId(id); return accountId == null ? null : accountState.get(accountId); } - - @Override - public long getNumberOfAccounts() { - return accountState.size(); - } - /** * Given some {@link AccountID}, if it is an alias, then convert it to a number-based account ID. If it is not an * alias, then just return it. If the given id is bogus, containing neither an account number nor an alias, or @@ -213,10 +207,6 @@ protected AccountID lookupAliasedAccountId(@NonNull final AccountID id) { }; } - public long sizeOfAccountState() { - return accountState().size(); - } - @Override public void warm(@NonNull final AccountID accountID) { final var unaliasedId = lookupAliasedAccountId(accountID); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAirdropStoreImpl.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAirdropStoreImpl.java index 40d3935758c5..248784c06ba7 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAirdropStoreImpl.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableAirdropStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -57,10 +57,4 @@ public AccountPendingAirdrop get(@NonNull final PendingAirdropId airdropId) { requireNonNull(airdropId); return readableAirdropState.get(airdropId); } - - /** {@inheritDoc} */ - @Override - public long sizeOfState() { - return readableAirdropState.size(); - } } diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableNftStoreImpl.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableNftStoreImpl.java index 85fd508164a6..fd19169b48dc 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableNftStoreImpl.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableNftStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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,14 +52,6 @@ public Nft get(@NonNull final NftID nftId) { return nftState.get(nftId); } - /** - * Returns the number of nfts in the state. - * @return the number of nfts in the state - */ - public long sizeOfState() { - return nftState.size(); - } - @Override public void warm(@NonNull final NftID nftID) { nftState.warm(nftID); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenRelationStoreImpl.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenRelationStoreImpl.java index 05af76153c9a..054621bd5569 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenRelationStoreImpl.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenRelationStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -62,14 +62,6 @@ public TokenRelation get(@NonNull final AccountID accountId, @NonNull final Toke EntityIDPair.newBuilder().accountId(accountId).tokenId(tokenId).build()); } - /** - * {@inheritDoc} - */ - @Override - public long sizeOfState() { - return readableTokenRelState.size(); - } - /** * {@inheritDoc} */ diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenStoreImpl.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenStoreImpl.java index 49a89c1135f8..8cb4e50e3382 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenStoreImpl.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/ReadableTokenStoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -109,15 +109,6 @@ private Optional getTokenLeaf(final TokenID tokenId) { return Optional.ofNullable(token); } - /** - * Returns the number of tokens in the state. - * @return the number of tokens in the state - */ - @Override - public long sizeOfState() { - return tokenState.size(); - } - @Override public void warm(@NonNull final TokenID tokenId) { tokenState.warm(tokenId); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableAccountStore.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableAccountStore.java index 5a3877288c1b..b2da109c876b 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableAccountStore.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableAccountStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -182,26 +182,6 @@ public void remove(@NonNull final AccountID accountID) { accountState().remove(accountID); } - /** - * Returns the number of accounts in the state. It also includes modifications in the {@link - * WritableKVState}. - * - * @return the number of accounts in the state - */ - public long sizeOfAccountState() { - return accountState().size(); - } - - /** - * Returns the number of aliases in the state. It also includes modifications in the {@link - * WritableKVState}. - * - * @return the number of aliases in the state - */ - public long sizeOfAliasesState() { - return aliases().size(); - } - /** * Returns the set of accounts modified in existing state. * diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableTokenStore.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableTokenStore.java index 3b87b289d45e..c44dcf19485d 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableTokenStore.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/WritableTokenStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -88,14 +88,6 @@ public Optional getForModify(final TokenID tokenId) { return Optional.ofNullable(token); } - /** - * Returns the number of tokens in the state. - * @return the number of tokens in the state - */ - public long sizeOfState() { - return tokenState.size(); - } - /** * Returns the set of tokens modified in existing state. * @return the set of tokens modified in existing state diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/BaseTokenHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/BaseTokenHandler.java index 8e477646ee35..0f81b80c4098 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/BaseTokenHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/BaseTokenHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,6 +44,7 @@ import com.hedera.node.app.service.token.impl.WritableTokenStore; import com.hedera.node.app.service.token.impl.util.TokenHandlerHelper; import com.hedera.node.app.service.token.impl.util.TokenKey; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.ExpiryValidator; import com.hedera.node.config.data.EntitiesConfig; import com.hedera.node.config.data.TokensConfig; @@ -323,11 +324,13 @@ private List createTokenRelsToAccount( /** * Creates a new {@link TokenRelation} with the account and token. This is called when there is * no association yet, but have open slots for maxAutoAssociations on the account. - * @param accountId the accountId to link the tokens to - * @param token the token to link to the account - * @param accountStore the account store + * + * @param accountId the accountId to link the tokens to + * @param token the token to link to the account + * @param accountStore the account store * @param tokenRelStore the token relation store - * @param config the configuration + * @param config the configuration + * @param entityIdStore the entity id store * @return the new token relation added */ protected TokenRelation autoAssociate( @@ -335,7 +338,8 @@ protected TokenRelation autoAssociate( @NonNull final Token token, @NonNull final WritableAccountStore accountStore, @NonNull final WritableTokenRelationStore tokenRelStore, - @NonNull final Configuration config) { + @NonNull final Configuration config, + final ReadableEntityIdStore entityIdStore) { final var tokensConfig = config.getConfigData(TokensConfig.class); final var entitiesConfig = config.getConfigData(EntitiesConfig.class); @@ -344,7 +348,7 @@ protected TokenRelation autoAssociate( final var existingRel = tokenRelStore.get(accountId, tokenId); validateTrue(existingRel == null, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT); validateTrue( - tokenRelStore.sizeOfState() + 1 < tokensConfig.maxAggregateRels(), + entityIdStore.numTokenRelations() + 1 < tokensConfig.maxAggregateRels(), MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); final var account = accountStore.get(accountId); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/CryptoCreateHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/CryptoCreateHandler.java index 5c3abaad913d..f52cf40acec9 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/CryptoCreateHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/CryptoCreateHandler.java @@ -77,6 +77,7 @@ import com.hedera.node.app.service.token.records.CryptoCreateStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.EntityType; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; @@ -315,10 +316,11 @@ private void validateSemantics( final var tokensConfig = context.configuration().getConfigData(TokensConfig.class); final var accountConfig = context.configuration().getConfigData(AccountsConfig.class); final var alias = op.alias(); + final var entityIdStore = context.storeFactory().readableStore(ReadableEntityIdStore.class); // We have a limit on the total maximum number of entities that can be created on the network, for different // types of entities. We need to verify that creating a new account won't exceed that number. - if (accountStore.getNumberOfAccounts() + 1 > accountConfig.maxNumber()) { + if (entityIdStore.numAccounts() + 1 > accountConfig.maxNumber()) { throw new HandleException(MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); } diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAirdropHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAirdropHandler.java index 6c40d1b10d3c..95cf29aaade9 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAirdropHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAirdropHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -63,6 +63,7 @@ import com.hedera.node.app.service.token.records.TokenAirdropStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; import com.hedera.node.app.spi.workflows.PreCheckException; @@ -131,6 +132,7 @@ public void handle(@NonNull final HandleContext context) throws HandleException final var nftStore = context.storeFactory().readableStore(ReadableNftStore.class); final var tokenStore = context.storeFactory().readableStore(ReadableTokenStore.class); final var tokenRelStore = context.storeFactory().readableStore(ReadableTokenRelationStore.class); + final var entityIdStore = context.storeFactory().readableStore(ReadableEntityIdStore.class); var recordBuilder = context.savepointStack().getBaseBuilder(TokenAirdropStreamBuilder.class); var tokensConfig = context.configuration().getConfigData(TokensConfig.class); List tokenTransferList = new ArrayList<>(); @@ -160,7 +162,7 @@ public void handle(@NonNull final HandleContext context) throws HandleException // - one list for executing the transfer and one list for adding to pending state final var fungibleLists = separateFungibleTransfers(context, tokenId, xfers.transfers()); validateTrue( - pendingStore.sizeOfState() + entityIdStore.numAirdrops() + fungibleLists.pendingFungibleAmounts().size() <= tokensConfig.maxAllowedPendingAirdrops(), MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); @@ -206,7 +208,7 @@ public void handle(@NonNull final HandleContext context) throws HandleException // - one list for executing the transfer and one list for adding to pending state final var nftLists = separateNftTransfers(context, tokenId, xfers.nftTransfers()); validateTrue( - pendingStore.sizeOfState() + nftLists.pendingNftList().size() + entityIdStore.numAirdrops() + nftLists.pendingNftList().size() <= tokensConfig.maxAllowedPendingAirdrops(), MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); // there is no performant way to find if another serial of the same NFT is already in the pending state diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAssociateToAccountHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAssociateToAccountHandler.java index 288a1577a1b2..9641579cb672 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAssociateToAccountHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenAssociateToAccountHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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,6 +52,7 @@ import com.hedera.node.app.service.token.impl.validators.TokenListChecks; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.ExpiryValidator; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; @@ -101,6 +102,7 @@ public void handle(@NonNull final HandleContext context) throws HandleException final var entitiesConfig = context.configuration().getConfigData(EntitiesConfig.class); final var accountStore = storeFactory.writableStore(WritableAccountStore.class); final var tokenRelStore = storeFactory.writableStore(WritableTokenRelationStore.class); + final var entityIdStore = storeFactory.readableStore(ReadableEntityIdStore.class); final var validated = validateSemantics( tokenIds, op.accountOrThrow(), @@ -109,7 +111,8 @@ public void handle(@NonNull final HandleContext context) throws HandleException accountStore, tokenStore, tokenRelStore, - context.expiryValidator()); + context.expiryValidator(), + entityIdStore); // Now that we've validated we can link all the new token IDs to the account, // create the corresponding token relations and update the account @@ -141,13 +144,14 @@ private Validated validateSemantics( @NonNull final WritableAccountStore accountStore, @NonNull final ReadableTokenStore tokenStore, @NonNull final WritableTokenRelationStore tokenRelStore, - @NonNull final ExpiryValidator expiryValidator) { + @NonNull final ExpiryValidator expiryValidator, + @NonNull final ReadableEntityIdStore entityIdStore) { requireNonNull(tokenConfig); requireNonNull(entitiesConfig); // Check that the system hasn't reached its limit of token associations validateTrue( - isTotalNumTokenRelsWithinMax(tokenIds.size(), tokenRelStore, tokenConfig.maxAggregateRels()), + isTotalNumTokenRelsWithinMax(tokenIds.size(), entityIdStore, tokenConfig.maxAggregateRels()), MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); // Check that the account is usable @@ -177,8 +181,8 @@ private Validated validateSemantics( } private boolean isTotalNumTokenRelsWithinMax( - final int numNewTokenRels, WritableTokenRelationStore tokenRelStore, long maxNumTokenRels) { - return tokenRelStore.sizeOfState() + numNewTokenRels <= maxNumTokenRels; + final int numNewTokenRels, ReadableEntityIdStore entityIdStore, long maxNumTokenRels) { + return entityIdStore.numTokenRelations() + numNewTokenRels <= maxNumTokenRels; } /** diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenCreateHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenCreateHandler.java index d13c78e19d56..6bfd36ae020b 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenCreateHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenCreateHandler.java @@ -49,6 +49,7 @@ import com.hedera.node.app.service.token.records.TokenCreateStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.EntityType; import com.hedera.node.app.spi.validation.ExpiryMeta; import com.hedera.node.app.spi.workflows.HandleContext; @@ -126,13 +127,14 @@ public void handle(@NonNull final HandleContext context) { final var storeFactory = context.storeFactory(); final var accountStore = storeFactory.writableStore(WritableAccountStore.class); final var tokenStore = storeFactory.writableStore(WritableTokenStore.class); + final var entityIdStore = storeFactory.readableStore(ReadableEntityIdStore.class); final var tokenRelationStore = storeFactory.writableStore(WritableTokenRelationStore.class); final var recordBuilder = context.savepointStack().getBaseBuilder(TokenCreateStreamBuilder.class); /* Validate if the current token can be created */ validateTrue( - tokenStore.sizeOfState() + 1 <= tokensConfig.maxNumber(), + entityIdStore.numTokens() + 1 <= tokensConfig.maxNumber(), MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); // validate fields in the transaction body that involves checking with diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenMintHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenMintHandler.java index 75c467ff1324..f68eff3b5486 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenMintHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenMintHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -57,6 +57,7 @@ import com.hedera.node.app.service.token.records.TokenMintStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.ExpiryValidator; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; @@ -153,10 +154,12 @@ public void handle(@NonNull final HandleContext context) throws HandleException final var tokensConfig = context.configuration().getConfigData(TokensConfig.class); final var maxAllowedMints = tokensConfig.nftsMaxAllowedMints(); final var nftStore = storeFactory.writableStore(WritableNftStore.class); + final var entityIdStore = storeFactory.readableStore(ReadableEntityIdStore.class); // validate resources exist for minting nft final var meta = op.metadata(); validateTrue( - nftStore.sizeOfState() + meta.size() <= maxAllowedMints, MAX_NFTS_IN_PRICE_REGIME_HAVE_BEEN_MINTED); + entityIdStore.numNfts() + meta.size() <= maxAllowedMints, + MAX_NFTS_IN_PRICE_REGIME_HAVE_BEEN_MINTED); // mint nft final var mintedSerials = mintNonFungible( token, diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateHandler.java index 8977c733730a..72afcfd09f71 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -64,6 +64,7 @@ import com.hedera.node.app.service.token.records.TokenUpdateStreamBuilder; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.validation.ExpiryMeta; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; @@ -144,6 +145,7 @@ public void handle(@NonNull final HandleContext context) throws HandleException final var accountStore = storeFactory.writableStore(WritableAccountStore.class); final var tokenRelStore = storeFactory.writableStore(WritableTokenRelationStore.class); final var tokenStore = storeFactory.writableStore(WritableTokenStore.class); + final var entityIdStore = storeFactory.readableStore(ReadableEntityIdStore.class); final var config = context.configuration(); final var tokensConfig = config.getConfigData(TokensConfig.class); @@ -163,7 +165,12 @@ public void handle(@NonNull final HandleContext context) throws HandleException // If not fail if (newTreasuryRel == null) { final var newRelation = autoAssociate( - newTreasuryAccount.accountIdOrThrow(), token, accountStore, tokenRelStore, config); + newTreasuryAccount.accountIdOrThrow(), + token, + accountStore, + tokenRelStore, + config, + entityIdStore); recordBuilder.addAutomaticTokenAssociation( asTokenAssociation(newRelation.tokenId(), newRelation.accountId())); newTreasuryAccount = requireNonNull(accountStore.getForModify(newTreasury)); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateNftsHandler.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateNftsHandler.java index a10aa781d0f1..7069ebd902a4 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateNftsHandler.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/TokenUpdateNftsHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -40,6 +40,7 @@ import com.hedera.node.app.service.token.impl.validators.TokenAttributesValidator; import com.hedera.node.app.spi.fees.FeeContext; import com.hedera.node.app.spi.fees.Fees; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; import com.hedera.node.app.spi.workflows.PreCheckException; @@ -113,12 +114,13 @@ public void handle(@NonNull HandleContext context) throws HandleException { final var tokenId = op.tokenOrThrow(); final var storeFactory = context.storeFactory(); final var nftStore = storeFactory.writableStore(WritableNftStore.class); + final var entityIdStore = storeFactory.readableStore(ReadableEntityIdStore.class); validateSemantics(context, op); // Wrap in Set to de-duplicate serial numbers final var nftSerialNums = new LinkedHashSet<>(op.serialNumbers()); - validateTrue(nftSerialNums.size() <= nftStore.sizeOfState(), INVALID_NFT_ID); + validateTrue(nftSerialNums.size() <= entityIdStore.numNfts(), INVALID_NFT_ID); updateNftMetadata(nftSerialNums, nftStore, tokenId, op); } diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java index a25f1b988b38..582988c1ebcb 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AssociateTokenRecipientsStep.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,6 +47,7 @@ import com.hedera.node.app.service.token.impl.WritableTokenRelationStore; import com.hedera.node.app.service.token.impl.WritableTokenStore; import com.hedera.node.app.service.token.impl.handlers.BaseTokenHandler; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.workflows.ComputeDispatchFeesAsTopLevel; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.app.spi.workflows.HandleException; @@ -189,6 +190,7 @@ private TokenAssociation validateAndBuildAutoAssociation( final var tokenRel = tokenRelStore.get(account.accountIdOrThrow(), tokenId); final var config = context.configuration(); final var entitiesConfig = config.getConfigData(EntitiesConfig.class); + final var entityIdStore = context.storeFactory().readableStore(ReadableEntityIdStore.class); if (tokenRel == null && account.maxAutoAssociations() != 0) { boolean validAssociations = hasUnlimitedAutoAssociations(account, entitiesConfig) @@ -210,8 +212,8 @@ private TokenAssociation validateAndBuildAutoAssociation( } } } - final var newRelation = - autoAssociate(account.accountIdOrThrow(), token, accountStore, tokenRelStore, config); + final var newRelation = autoAssociate( + account.accountIdOrThrow(), token, accountStore, tokenRelStore, config, entityIdStore); return asTokenAssociation(newRelation.tokenId(), newRelation.accountId()); } else { validateTrue(tokenRel != null, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT); diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AutoAccountCreator.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AutoAccountCreator.java index 244755a41ef7..0a0ca18bb8f7 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AutoAccountCreator.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/handlers/transfer/AutoAccountCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,6 +35,7 @@ import com.hedera.hapi.node.transaction.TransactionBody; import com.hedera.node.app.service.token.impl.WritableAccountStore; import com.hedera.node.app.service.token.records.CryptoCreateStreamBuilder; +import com.hedera.node.app.spi.ids.ReadableEntityIdStore; import com.hedera.node.app.spi.workflows.HandleContext; import com.hedera.node.config.data.AccountsConfig; import com.hedera.node.config.data.EntitiesConfig; @@ -69,9 +70,10 @@ public AccountID create(@NonNull final Bytes alias, int requiredAutoAssociations requireNonNull(alias); final var accountsConfig = handleContext.configuration().getConfigData(AccountsConfig.class); + final var entityIdStore = handleContext.storeFactory().readableStore(ReadableEntityIdStore.class); validateTrue( - accountStore.sizeOfAccountState() + 1 <= accountsConfig.maxNumber(), + entityIdStore.numAccounts() + 1 <= accountsConfig.maxNumber(), ResponseCodeEnum.MAX_ENTITIES_IN_PRICE_REGIME_HAVE_BEEN_CREATED); final TransactionBody.Builder syntheticCreation; diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAccountStoreImplTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAccountStoreImplTest.java index 56aaed116798..3eeba6360afd 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAccountStoreImplTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAccountStoreImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import static com.hedera.node.app.service.token.impl.test.handlers.util.StateBuilderUtil.ACCOUNTS; import static com.hedera.node.app.service.token.impl.test.handlers.util.StateBuilderUtil.ALIASES; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; @@ -259,12 +258,6 @@ void getAccountIDByAlias() { assertThat(accountId2).isNull(); } - @Test - void getSizeOfState() { - final var store = new ReadableAccountStoreImpl(readableStates); - assertEquals(readableStates.get(ACCOUNTS).size(), store.sizeOfAccountState()); - } - @Test void containsWorksAsExpected() { // Subject is pre-populated with this ID diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAirdropStoreImplTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAirdropStoreImplTest.java index 4f8b3135e445..5e24e8fa9fbd 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAirdropStoreImplTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableAirdropStoreImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -96,17 +96,6 @@ void testConstructorCallWithNull() { assertThatThrownBy(() -> subject = new ReadableAirdropStoreImpl(null)).isInstanceOf(NullPointerException.class); } - @Test - void testSizeOfState() { - airdrops = emptyReadableAirdropStateBuilder() - .value(getNonFungibleAirDrop(), accountAirdropWith(null)) - .build(); - given(readableStates.get(AIRDROPS)) - .willReturn(airdrops); - subject = new ReadableAirdropStoreImpl(readableStates); - assertThat(readableStates.get(StateBuilderUtil.AIRDROPS).size()).isEqualTo(subject.sizeOfState()); - } - @Test void testExists() { var fungibleAirdrop = getFungibleAirdrop(); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenRelationStoreImplTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenRelationStoreImplTest.java index df33890bd236..94b36805b22c 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenRelationStoreImplTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenRelationStoreImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -93,15 +93,6 @@ void testGetEmpty() { Assertions.assertThat(result).isNull(); } - @Test - void testSizeOfState() { - final var expectedSize = 3L; - given(tokenRelState.size()).willReturn(expectedSize); - - final var result = subject.sizeOfState(); - Assertions.assertThat(result).isEqualTo(expectedSize); - } - @Test void warmWarmsUnderlyingState(@Mock ReadableKVState tokenRelations) { given(states.get(V0490TokenSchema.TOKEN_RELS_KEY)) diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenStoreImplTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenStoreImplTest.java index 8d883c92d73e..5f0cc437f768 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenStoreImplTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/ReadableTokenStoreImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-2025 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. @@ -144,12 +144,6 @@ void classifiesRoyaltyWithNoFallback() { assertEquals(treasury, meta.treasuryAccountId()); } - @Test - void returnSizeOfState() { - final var store = new ReadableTokenStoreImpl(readableStates); - assertEquals(readableStates.get(TOKENS).size(), store.sizeOfState()); - } - @Test void warmWarmsUnderlyingState(@Mock ReadableKVState tokenRelations) { subject.warm(tokenId); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableAccountStoreTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableAccountStoreTest.java index af4e20fac326..8586af4fd1ca 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableAccountStoreTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableAccountStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,6 @@ import com.hedera.node.app.service.token.impl.test.handlers.util.CryptoHandlerTestBase; import com.hedera.node.app.spi.metrics.StoreMetricsService; import com.hedera.node.config.testfixtures.HederaTestConfigBuilder; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -137,14 +136,14 @@ void getForModifyReturnsImmutableAccount() { @Test void canRemoveAlias() { writableStore.putAlias(alias.aliasOrThrow(), id); - assertEquals(1, writableStore.sizeOfAliasesState()); + // assertEquals(1, writableStore.sizeOfAliasesState()); writableStore.removeAlias(alias.aliasOrThrow()); - assertEquals(0, writableStore.sizeOfAliasesState()); + // assertEquals(0, writableStore.sizeOfAliasesState()); } @Test void getForModifyDoesntLookForAlias() { - assertEquals(0, writableStore.sizeOfAliasesState()); + // assertEquals(0, writableStore.sizeOfAliasesState()); writableStore.put(account); writableStore.putAlias(alias.alias(), id); @@ -152,13 +151,13 @@ void getForModifyDoesntLookForAlias() { final var readaccount = writableStore.getForModify(alias); assertThat(readaccount).isNull(); - assertEquals(1, writableStore.sizeOfAliasesState()); + // assertEquals(1, writableStore.sizeOfAliasesState()); assertEquals(Set.of(edKeyAlias), writableStore.modifiedAliasesInState()); } @Test void getWithAliasedIdLooksForAlias() { - assertEquals(0, writableStore.sizeOfAliasesState()); + // assertEquals(0, writableStore.sizeOfAliasesState()); writableStore.put(account); writableStore.putAlias(alias.alias(), id); @@ -167,7 +166,7 @@ void getWithAliasedIdLooksForAlias() { assertThat(readaccount).isNotNull(); assertThat(account).isEqualTo(readaccount); - assertEquals(1, writableStore.sizeOfAliasesState()); + // assertEquals(1, writableStore.sizeOfAliasesState()); assertEquals(Set.of(edKeyAlias), writableStore.modifiedAliasesInState()); } @@ -178,7 +177,7 @@ void getForModifyReturnEmptyIfAliasNotPresent() { final var readaccount = writableStore.getForModify(alias); assertThat(readaccount).isNull(); - assertThat(writableStore.sizeOfAliasesState()).isZero(); + // assertThat(writableStore.sizeOfAliasesState()).isZero(); } @Test @@ -193,17 +192,6 @@ void putsAccountChangesToStateInModifications() { assertThat(account).isEqualTo(writtenaccount); } - @Test - void getsSizeOfState() { - assertThat(writableStore.sizeOfAliasesState()).isZero(); - assertThat(writableStore.modifiedAccountsInState()).isEqualTo(Collections.EMPTY_SET); - - writableStore.put(account); - assertThat(writableStore.sizeOfAccountState()).isEqualTo(1); - assertThat(writableStore.modifiedAccountsInState()) - .isEqualTo(Set.of(AccountID.newBuilder().accountNum(3).build())); - } - private Account contractWith(final AccountID id, final long nonce) { return Account.newBuilder() .accountId(id) diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableNftStoreTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableNftStoreTest.java index a15c682113b6..cedea738462c 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableNftStoreTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableNftStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,8 +34,6 @@ import com.hedera.node.app.service.token.impl.test.handlers.util.CryptoTokenHandlerTestBase; import com.hedera.node.app.spi.metrics.StoreMetricsService; import com.swirlds.state.spi.WritableKVState; -import java.util.Collections; -import java.util.Set; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -119,20 +117,6 @@ void putsTokenChangesToStateInModifications() { assertEquals(nft, writtenToken); } - @Test - void getsSizeOfState() { - final var id = - NftID.newBuilder().tokenId(fungibleTokenId).serialNumber(1).build(); - final var nft = givenNft(id); - - assertEquals(0, writableNftStore.sizeOfState()); - assertEquals(Collections.EMPTY_SET, writableNftStore.modifiedNfts()); - writableNftStore.put(nft); - - assertEquals(1, writableNftStore.sizeOfState()); - assertEquals(Set.of(id), writableNftStore.modifiedNfts()); - } - @Test void removesByNftID() { // Set up the NFT state with an existing NFT diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenRelationStoreTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenRelationStoreTest.java index 2806ce9f6793..519c48c456bb 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenRelationStoreTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenRelationStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -158,15 +158,6 @@ void testGetForModifyEmpty() { Assertions.assertThat(result).isNull(); } - @Test - void testSizeOfState() { - final var expectedSize = 3L; - given(tokenRelState.size()).willReturn(expectedSize); - - final var result = subject.sizeOfState(); - Assertions.assertThat(result).isEqualTo(expectedSize); - } - @Test void testModifiedTokens() { final var modifiedKeys = Set.of( diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenStoreTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenStoreTest.java index b55fad7a04aa..81f1cf01b6a4 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenStoreTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/WritableTokenStoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,8 +28,6 @@ import com.hedera.node.app.spi.metrics.StoreMetricsService; import com.hedera.node.config.testfixtures.HederaTestConfigBuilder; import com.swirlds.config.api.Configuration; -import java.util.Collections; -import java.util.Set; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -97,15 +95,4 @@ void putsTokenChangesToStateInModifications() { final var writtenToken = writableTokenState.get(tokenId); assertEquals(token, writtenToken); } - - @Test - void getsSizeOfState() { - token = createToken(); - assertEquals(0, writableTokenStore.sizeOfState()); - assertEquals(Collections.EMPTY_SET, writableTokenStore.modifiedTokens()); - writableTokenStore.put(token); - - assertEquals(1, writableTokenStore.sizeOfState()); - assertEquals(Set.of(tokenId), writableTokenStore.modifiedTokens()); - } } diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/api/TokenServiceApiImplTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/api/TokenServiceApiImplTest.java index 53ccd5238982..19869cbea213 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/api/TokenServiceApiImplTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/api/TokenServiceApiImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -202,7 +202,7 @@ void finalizesHollowAccountAsContractAsExpected() { subject.finalizeHollowAccountAsContract(CONTRACT_ACCOUNT_ID); - assertEquals(1, accountStore.sizeOfAccountState()); + // assertEquals(1, accountStore.sizeOfAccountState()); final var finalizedAccount = accountStore.getContractById(CONTRACT_ID_BY_NUM); assertNotNull(finalizedAccount); assertEquals(Key.newBuilder().contractID(CONTRACT_ID_BY_NUM).build(), finalizedAccount.key()); @@ -228,7 +228,7 @@ void createsExpectedContractWithAliasIfSet() { assertNull(accountStore.getContractById(CONTRACT_ID_BY_NUM)); subject.markAsContract(CONTRACT_ACCOUNT_ID, null); - assertEquals(1, accountStore.sizeOfAccountState()); + // assertEquals(1, accountStore.sizeOfAccountState()); assertNotNull(accountStore.getContractById(CONTRACT_ID_BY_NUM)); } @@ -241,7 +241,7 @@ void marksDeletedByNumberIfSet() { subject.deleteContract(CONTRACT_ID_BY_NUM); - assertEquals(1, accountStore.sizeOfAccountState()); + // assertEquals(1, accountStore.sizeOfAccountState()); final var deletedContract = accountStore.getContractById(CONTRACT_ID_BY_NUM); assertTrue(deletedContract.deleted()); } @@ -257,10 +257,10 @@ void removesByAliasIfSet() { subject.deleteContract(CONTRACT_ID_BY_ALIAS); - assertEquals(1, accountStore.sizeOfAccountState()); + // assertEquals(1, accountStore.sizeOfAccountState()); final var deletedContract = accountStore.getContractById(CONTRACT_ID_BY_NUM); assertTrue(deletedContract.deleted()); - assertEquals(0, accountStore.sizeOfAliasesState()); + // assertEquals(0, accountStore.sizeOfAliasesState()); } @Test @@ -278,11 +278,11 @@ void warnsLoudlyButRemovesBothAliasesIfPresent() { subject.deleteContract(CONTRACT_ID_BY_ALIAS); - assertEquals(1, accountStore.sizeOfAccountState()); + // assertEquals(1, accountStore.sizeOfAccountState()); final var deletedContract = requireNonNull(accountStore.getContractById(CONTRACT_ID_BY_NUM)); assertTrue(deletedContract.deleted()); assertEquals(Bytes.EMPTY, deletedContract.alias()); - assertEquals(0, accountStore.sizeOfAliasesState()); + // assertEquals(0, accountStore.sizeOfAliasesState()); } @Test diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java index f222d2cb7dcc..bd5c0de4bade 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/CryptoTransferHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -538,7 +538,7 @@ void happyPathWorksWithAutoCreation() { assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(4); // includes fee collector for custom fees assertThat(writableAccountStore.modifiedAccountsInState()) .contains(ownerId, asAccount(hbarReceiver), asAccount(tokenReceiver)); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(4); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(4); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNotNull(); assertThat(writableAccountStore.get(asAccount(tokenReceiver))).isNotNull(); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenAirdropHandlerTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenAirdropHandlerTest.java index 284cf83cb0fd..ad98f2f4d17c 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenAirdropHandlerTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenAirdropHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -361,7 +361,7 @@ void handleAirdropMultipleTokensToPendingState() { tokenAirdropHandler.handle(handleContext); - assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); + // assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); assertThat(writableAccountStore.get(ownerId)).isNotNull(); var ownerAccount = Objects.requireNonNull(writableAccounts.get(ownerId)); assertThat(ownerAccount.hasHeadPendingAirdropId()).isTrue(); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenClaimAirdropHandlerTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenClaimAirdropHandlerTest.java index 7c7a06999642..a219645e724f 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenClaimAirdropHandlerTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenClaimAirdropHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024-2025 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. @@ -282,7 +282,7 @@ void claimFirstAirdrop() { tokenClaimAirdropHandler.handle(handleContext); // check if we clear the pending state - assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); + // assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); assertThat(writableAirdropStore.get(firstPendingAirdropId)).isNull(); // check if we link properly the neighbour elements @@ -317,7 +317,7 @@ void claimSecondAirdrop() { tokenClaimAirdropHandler.handle(handleContext); // check if we clear the pending state - assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); + // assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); assertThat(writableAirdropStore.get(secondPendingAirdropId)).isNull(); // check if we link properly the neighbour elements @@ -356,7 +356,7 @@ void claimThirdAirdrop() { tokenClaimAirdropHandler.handle(handleContext); // check if we clear the pending state - assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); + // assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); assertThat(writableAirdropStore.get(thirdPendingAirdropId)).isNull(); // check if we link properly the neighbour elements @@ -403,7 +403,7 @@ void claimMultipleAirdrops() { tokenClaimAirdropHandler.handle(handleContext); // check if we clear the pending state - assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); + // assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); assertThat(writableAirdropStore.get(secondPendingAirdropId)).isNull(); assertThat(writableAirdropStore.get(thirdPendingAirdropId)).isNull(); @@ -457,7 +457,7 @@ void claimMultipleAirdrops2() { tokenClaimAirdropHandler.handle(handleContext); // check if we clear the pending state - assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); + // assertThat(writableAirdropStore.sizeOfState()).isEqualTo(2); assertThat(writableAirdropStore.get(secondPendingAirdropId)).isNull(); assertThat(writableAirdropStore.get(fourthPendingAirdropId)).isNull(); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenRejectHandlerTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenRejectHandlerTest.java index 7d8d90d1e049..dc56baf8f507 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenRejectHandlerTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/TokenRejectHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -115,7 +115,7 @@ void happyPathWorks() { // Then: assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(2); assertThat(writableAccountStore.modifiedAccountsInState()).contains(ownerId, treasuryId); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); // Verify balance removal final var endSenderTokenBalance = diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AutoAccountCreatorTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AutoAccountCreatorTest.java index 5c184f0aa912..dc26c906c6d9 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AutoAccountCreatorTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/AutoAccountCreatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -87,7 +87,7 @@ void happyPathECKeyAliasWorks() { }); given(storeFactory.writableStore(WritableAccountStore.class)).willReturn(writableAccountStore); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.modifiedAccountsInState()).isEmpty(); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNull(); assertThat(writableAccountStore.get(asAccount(tokenReceiver))).isNull(); @@ -97,7 +97,7 @@ void happyPathECKeyAliasWorks() { assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(1); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(1); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(3); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(3); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNotNull(); assertThat(writableAliases.get(ecKeyAlias).accountNum()).isEqualTo(hbarReceiver); } @@ -119,7 +119,7 @@ void happyPathEDKeyAliasWorks() { }); given(storeFactory.writableStore(WritableAccountStore.class)).willReturn(writableAccountStore); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.modifiedAccountsInState()).isEmpty(); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNull(); assertThat(writableAccountStore.get(asAccount(tokenReceiver))).isNull(); @@ -129,7 +129,7 @@ void happyPathEDKeyAliasWorks() { assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(1); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(1); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(3); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(3); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNotNull(); assertThat(writableAliases.get(edKeyAlias).accountNum()).isEqualTo(hbarReceiver); } @@ -152,7 +152,7 @@ void happyPathWithHollowAccountAliasInHbarTransfersWorks() { }); given(storeFactory.writableStore(WritableAccountStore.class)).willReturn(writableAccountStore); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.modifiedAccountsInState()).isEmpty(); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNull(); assertThat(writableAccountStore.get(asAccount(tokenReceiver))).isNull(); @@ -162,7 +162,7 @@ void happyPathWithHollowAccountAliasInHbarTransfersWorks() { assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(1); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(1); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(3); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(3); assertThat(writableAccountStore.get(asAccount(hbarReceiver))).isNotNull(); assertThat(writableAliases.get(address).accountNum()).isEqualTo(hbarReceiver); } diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/EnsureAliasesStepTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/EnsureAliasesStepTest.java index e3a5f2fdb663..73569520c7fd 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/EnsureAliasesStepTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/EnsureAliasesStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -91,7 +91,7 @@ void autoCreatesAccounts() { }); given(storeFactory.writableStore(WritableAccountStore.class)).willReturn(writableAccountStore); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.modifiedAccountsInState()).isEmpty(); assertThat(writableAccountStore.getAliasedAccountById(asAccount(hbarReceiver))) .isNull(); @@ -104,7 +104,7 @@ void autoCreatesAccounts() { assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(2); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(2); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(4); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(4); assertThat(writableAccountStore.getAliasedAccountById(asAccount(hbarReceiver))) .isNotNull(); assertThat(writableAccountStore.getAliasedAccountById(asAccount(tokenReceiver))) @@ -180,7 +180,7 @@ void autoCreateEvmAddressesAccounts() { assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(3); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(3); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(5); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(5); assertThat(writableAccountStore.getAliasedAccountById(asAccount(hbarReceiver))) .isNotNull(); assertThat(writableAccountStore.getAliasedAccountById(asAccount(tokenReceiver))) @@ -203,7 +203,7 @@ void resolvedExistingAliases() { // insert aliases into state setUpInsertingKnownAliasesToState(); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.getAliasedAccountById(unknownAliasedId)).isNotNull(); assertThat(writableAccountStore.getAliasedAccountById(unknownAliasedId1)) .isNotNull(); @@ -211,7 +211,7 @@ void resolvedExistingAliases() { ensureAliasesStep.doIn(transferContext); assertThat(writableAccountStore.modifiedAliasesInState()).isEmpty(); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAliases.get(ecKeyAlias).accountNum()).isEqualTo(hbarReceiver); assertThat(writableAliases.get(edKeyAlias).accountNum()).isEqualTo(tokenReceiver); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/ReplaceAliasesWithIDsInOpTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/ReplaceAliasesWithIDsInOpTest.java index 38349d402b29..f04527605070 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/ReplaceAliasesWithIDsInOpTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/handlers/transfer/ReplaceAliasesWithIDsInOpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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. @@ -85,7 +85,7 @@ void autoCreatesAccounts() { }); given(storeFactory.writableStore(WritableAccountStore.class)).willReturn(writableAccountStore); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.modifiedAccountsInState()).isEmpty(); assertThat(writableAccountStore.getAliasedAccountById(asAccount(hbarReceiver))) .isNull(); @@ -98,7 +98,7 @@ void autoCreatesAccounts() { assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(2); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(2); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(4); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(4); assertThat(writableAccountStore.getAliasedAccountById(asAccount(hbarReceiver))) .isNotNull(); assertThat(writableAccountStore.getAliasedAccountById(asAccount(tokenReceiver))) @@ -177,7 +177,7 @@ ownerId, asAccountWithAlias(evmAddressAlias3.value()), 1)) assertThat(writableAccountStore.modifiedAliasesInState()).hasSize(3); assertThat(writableAccountStore.modifiedAccountsInState()).hasSize(3); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(5); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(5); assertThat(writableAccountStore.getAliasedAccountById(asAccount(hbarReceiver))) .isNotNull(); assertThat(writableAccountStore.getAliasedAccountById(asAccount(tokenReceiver))) @@ -200,7 +200,7 @@ void resolvedExistingAliases() { // insert aliases into state setUpInsertingKnownAliasesToState(); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAccountStore.getAliasedAccountById(unknownAliasedId)).isNotNull(); assertThat(writableAccountStore.getAliasedAccountById(unknownAliasedId1)) .isNotNull(); @@ -208,7 +208,7 @@ void resolvedExistingAliases() { ensureAliasesStep.doIn(transferContext); assertThat(writableAccountStore.modifiedAliasesInState()).isEmpty(); - assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); + // assertThat(writableAccountStore.sizeOfAliasesState()).isEqualTo(2); assertThat(writableAliases.get(ecKeyAlias).accountNum()).isEqualTo(hbarReceiver); assertThat(writableAliases.get(edKeyAlias).accountNum()).isEqualTo(tokenReceiver); diff --git a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/schemas/V0490TokenSchemaTest.java b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/schemas/V0490TokenSchemaTest.java index 8ed1625a779d..104e92bc863b 100644 --- a/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/schemas/V0490TokenSchemaTest.java +++ b/hedera-node/hedera-token-service-impl/src/test/java/com/hedera/node/app/service/token/impl/test/schemas/V0490TokenSchemaTest.java @@ -219,23 +219,24 @@ void createsAllAccountsOnGenesisStart() { } // Finally, verify that the size is exactly as expected - assertThat(acctsStateResult.size()) - .isEqualTo( - // All the system accounts - DEFAULT_NUM_SYSTEM_ACCOUNTS - + - // Both of the two staking accounts - 2 - + - // All the misc accounts - 101 - + - // All treasury clones (which is 501 - (FRUIT_STATE_KEY, onDiskKeyClassId(), STRING_CODEC, fruitVirtualMap); - assertThat(state.size()).isZero(); - - add(A_KEY, APPLE); - add(B_KEY, BANANA); - add(C_KEY, CHERRY); - assertThat(state.size()).isEqualTo(fruitVirtualMap.size()); - assertThat(state.size()).isEqualTo(3); - } - private void add(String key, String value) { add(fruitVirtualMap, onDiskKeyClassId(), STRING_CODEC, onDiskValueClassId(), STRING_CODEC, key, value); } diff --git a/platform-sdk/swirlds-state-impl/src/test/java/com/swirlds/state/merkle/disk/OnDiskWritableStateTest.java b/platform-sdk/swirlds-state-impl/src/test/java/com/swirlds/state/merkle/disk/OnDiskWritableStateTest.java index c0563b50a36b..6f36803c5b32 100644 --- a/platform-sdk/swirlds-state-impl/src/test/java/com/swirlds/state/merkle/disk/OnDiskWritableStateTest.java +++ b/platform-sdk/swirlds-state-impl/src/test/java/com/swirlds/state/merkle/disk/OnDiskWritableStateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Hedera Hashgraph, LLC + * Copyright (C) 2023-2025 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,26 +37,6 @@ void setUp() { setupFruitVirtualMap(); } - @Test - @DisplayName("The size of the state is the size of the virtual map") - void sizeWorks() { - final var state = new OnDiskWritableKVState<>( - FRUIT_STATE_KEY, - onDiskKeyClassId(), - STRING_CODEC, - onDiskValueClassId(), - STRING_CODEC, - fruitVirtualMap); - assertThat(state.size()).isZero(); - - add(A_KEY, APPLE); - add(B_KEY, BANANA); - add(C_KEY, CHERRY); - - assertThat(state.size()).isEqualTo(fruitVirtualMap.size()); - assertThat(state.size()).isEqualTo(3); - } - @Test @DisplayName("You must specify the metadata") void nullMetadataThrows() {