Skip to content

Commit

Permalink
chore: cherry-pick, do not update file 102 during the first transacti…
Browse files Browse the repository at this point in the history
…on after a freeze upgrade when DAB is disabled (#16045)

Signed-off-by: Iris Simon <[email protected]>
  • Loading branch information
iwsimon authored Oct 18, 2024
1 parent e635547 commit 49429ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.updateAddressBookAndNodeDetailsAfterFreeze(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.updateAddressBookAndNodeDetailsAfterFreeze(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<AutoSysFileUpdate> autoUpdates = List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ void setup() {
void successfulAutoUpdatesAreDispatchedWithFilesAvailable() throws IOException {
final var config = HederaTestConfigBuilder.create()
.withValue("networkAdmin.upgradeSysFilesLoc", tempDir.toString())
.withValue("nodes.enableDAB", true)
.getOrCreateConfig();
final var adminConfig = config.getConfigData(NetworkAdminConfig.class);
Files.writeString(tempDir.resolve(adminConfig.upgradePropertyOverridesFile()), validPropertyOverrides());
Expand All @@ -169,10 +170,10 @@ 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);
given(handleContext.storeFactory()).willReturn(storeFactory);
given(storeFactory.readableStore(ReadableNodeStore.class)).willReturn(readableNodeStore);

subject.doPostUpgradeSetup(dispatch);

Expand All @@ -189,6 +190,7 @@ void successfulAutoUpdatesAreDispatchedWithFilesAvailable() throws IOException {
void onlyAddressBookAndNodeDetailsAutoUpdateIsDispatchedWithNoFilesAvailable() {
final var config = HederaTestConfigBuilder.create()
.withValue("networkAdmin.upgradeSysFilesLoc", tempDir.toString())
.withValue("nodes.enableDAB", true)
.getOrCreateConfig();
given(dispatch.stack()).willReturn(stack);
given(dispatch.config()).willReturn(config);
Expand All @@ -213,6 +215,7 @@ void onlyAddressBookAndNodeDetailsAutoUpdateIsDispatchedWithNoFilesAvailable() {
void onlyAddressBookAndNodeDetailsAutoUpdateIsDispatchedWithInvalidFilesAvailable() throws IOException {
final var config = HederaTestConfigBuilder.create()
.withValue("networkAdmin.upgradeSysFilesLoc", tempDir.toString())
.withValue("nodes.enableDAB", true)
.getOrCreateConfig();
final var adminConfig = config.getConfigData(NetworkAdminConfig.class);
Files.writeString(tempDir.resolve(adminConfig.upgradePropertyOverridesFile()), invalidPropertyOverrides());
Expand Down

0 comments on commit 49429ec

Please sign in to comment.