diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/record/SystemSetup.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/record/SystemSetup.java index 71a8a41cc422..9491865bfc1b 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/record/SystemSetup.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/record/SystemSetup.java @@ -53,6 +53,7 @@ import com.hedera.node.config.data.FilesConfig; import com.hedera.node.config.data.HederaConfig; import com.hedera.node.config.data.NetworkAdminConfig; +import com.hedera.node.config.data.NodesConfig; import com.hedera.pbj.runtime.io.buffer.Bytes; import com.swirlds.config.api.Configuration; import com.swirlds.platform.system.InitTrigger; @@ -133,15 +134,18 @@ public void doGenesisSetup(@NonNull final Dispatch dispatch) { */ public void doPostUpgradeSetup(@NonNull final Dispatch dispatch) { final var systemContext = systemContextFor(dispatch); + final var config = dispatch.config(); // We update the node details file from the address book that resulted from all pre-upgrade HAPI node changes - final var nodeStore = dispatch.handleContext().storeFactory().readableStore(ReadableNodeStore.class); - fileService.updateNodeDetailsAfterFreeze(systemContext, nodeStore); - dispatch.stack().commitFullStack(); + final var nodesConfig = config.getConfigData(NodesConfig.class); + if (nodesConfig.enableDAB()) { + final var nodeStore = dispatch.handleContext().storeFactory().readableStore(ReadableNodeStore.class); + fileService.updateNodeDetailsAfterFreeze(systemContext, nodeStore); + dispatch.stack().commitFullStack(); + } // And then we update the system files for fees schedules, throttles, override properties, and override // permissions from any upgrade files that are present in the configured directory - final var config = dispatch.config(); final var filesConfig = config.getConfigData(FilesConfig.class); final var adminConfig = config.getConfigData(NetworkAdminConfig.class); final List autoUpdates = List.of( diff --git a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/steps/SystemSetupTest.java b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/steps/SystemSetupTest.java index 5f66a2df666e..2b05519b83f8 100644 --- a/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/steps/SystemSetupTest.java +++ b/hedera-node/hedera-app/src/test/java/com/hedera/node/app/workflows/handle/steps/SystemSetupTest.java @@ -53,7 +53,6 @@ import com.hedera.node.app.spi.fixtures.util.LoggingTarget; import com.hedera.node.app.spi.store.StoreFactory; import com.hedera.node.app.spi.workflows.HandleContext; -import com.hedera.node.app.spi.workflows.SystemContext; import com.hedera.node.app.spi.workflows.record.StreamBuilder; import com.hedera.node.app.workflows.handle.Dispatch; import com.hedera.node.app.workflows.handle.record.SystemSetup; @@ -169,20 +168,17 @@ void successfulAutoUpdatesAreDispatchedWithFilesAvailable() throws IOException { given(dispatch.config()).willReturn(config); given(dispatch.consensusNow()).willReturn(CONSENSUS_NOW); given(dispatch.handleContext()).willReturn(handleContext); - given(handleContext.storeFactory()).willReturn(storeFactory); - given(storeFactory.readableStore(ReadableNodeStore.class)).willReturn(readableNodeStore); given(handleContext.dispatchPrecedingTransaction(any(), any(), any(), any())) .willReturn(streamBuilder); subject.doPostUpgradeSetup(dispatch); final var filesConfig = config.getConfigData(FilesConfig.class); - verify(fileService).updateNodeDetailsAfterFreeze(any(SystemContext.class), eq(readableNodeStore)); verifyUpdateDispatch(filesConfig.networkProperties(), serializedPropertyOverrides()); verifyUpdateDispatch(filesConfig.hapiPermissions(), serializedPermissionOverrides()); verifyUpdateDispatch(filesConfig.throttleDefinitions(), serializedThrottleOverrides()); verifyUpdateDispatch(filesConfig.feeSchedules(), serializedFeeSchedules()); - verify(stack, times(5)).commitFullStack(); + verify(stack, times(4)).commitFullStack(); } @Test @@ -190,16 +186,11 @@ void onlyNodeDetailsAutoUpdateIsDispatchedWithNoFilesAvailable() { final var config = HederaTestConfigBuilder.create() .withValue("networkAdmin.upgradeSysFilesLoc", tempDir.toString()) .getOrCreateConfig(); - given(dispatch.stack()).willReturn(stack); given(dispatch.config()).willReturn(config); - given(dispatch.handleContext()).willReturn(handleContext); - given(handleContext.storeFactory()).willReturn(storeFactory); - given(storeFactory.readableStore(ReadableNodeStore.class)).willReturn(readableNodeStore); subject.doPostUpgradeSetup(dispatch); - verify(fileService).updateNodeDetailsAfterFreeze(any(SystemContext.class), eq(readableNodeStore)); - verify(stack, times(1)).commitFullStack(); + verify(stack, times(0)).commitFullStack(); final var infoLogs = logCaptor.infoLogs(); assertThat(infoLogs.size()).isEqualTo(4); @@ -209,36 +200,6 @@ void onlyNodeDetailsAutoUpdateIsDispatchedWithNoFilesAvailable() { assertThat(infoLogs.getLast()).startsWith("No post-upgrade file for api-permission-override.properties"); } - @Test - void onlyNodeDetailsAutoUpdateIsDispatchedWithInvalidFilesAvailable() throws IOException { - final var config = HederaTestConfigBuilder.create() - .withValue("networkAdmin.upgradeSysFilesLoc", tempDir.toString()) - .getOrCreateConfig(); - final var adminConfig = config.getConfigData(NetworkAdminConfig.class); - Files.writeString(tempDir.resolve(adminConfig.upgradePropertyOverridesFile()), invalidPropertyOverrides()); - Files.writeString(tempDir.resolve(adminConfig.upgradePermissionOverridesFile()), invalidPermissionOverrides()); - Files.writeString(tempDir.resolve(adminConfig.upgradeThrottlesFile()), invalidThrottleOverrides()); - Files.writeString(tempDir.resolve(adminConfig.upgradeFeeSchedulesFile()), invalidFeeScheduleOverrides()); - given(dispatch.stack()).willReturn(stack); - given(dispatch.config()).willReturn(config); - given(dispatch.handleContext()).willReturn(handleContext); - given(handleContext.storeFactory()).willReturn(storeFactory); - given(storeFactory.readableStore(ReadableNodeStore.class)).willReturn(readableNodeStore); - - subject.doPostUpgradeSetup(dispatch); - - verify(fileService).updateNodeDetailsAfterFreeze(any(SystemContext.class), eq(readableNodeStore)); - verify(stack, times(1)).commitFullStack(); - - final var errorLogs = logCaptor.errorLogs(); - assertThat(errorLogs.size()).isEqualTo(4); - assertThat(errorLogs.getFirst()).startsWith("Failed to parse upgrade file for feeSchedules.json"); - assertThat(errorLogs.get(1)).startsWith("Failed to parse upgrade file for throttles.json"); - assertThat(errorLogs.get(2)).startsWith("Failed to parse upgrade file for application-override.properties"); - assertThat(errorLogs.getLast()) - .startsWith("Failed to parse upgrade file for api-permission-override.properties"); - } - @Test @SuppressWarnings("unchecked") void externalizeInitSideEffectsCreatesAllRecords() {