diff --git a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/InitialModServiceConsensusSchema.java b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/InitialModServiceConsensusSchema.java index b014ce203664..384dcbbb624b 100644 --- a/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/InitialModServiceConsensusSchema.java +++ b/hedera-node/hedera-consensus-service-impl/src/main/java/com/hedera/node/app/service/consensus/impl/schemas/InitialModServiceConsensusSchema.java @@ -71,8 +71,9 @@ public void migrate(@NonNull final MigrationContext ctx) { final var topicStoreRef = new AtomicReference<>(ctx.newStates().get(TOPICS_KEY)); log.info("BBM: running consensus migration..."); - fs.forEach((k, v) -> { - final var pbjTopic = stateToPbj(v); + fs.keySet().stream().sorted().forEach(k -> { + final var topic = fs.get(k); + final var pbjTopic = stateToPbj(topic); topicStoreRef.get().put(pbjTopic.topicId(), pbjTopic); if (numTopicInsertions.incrementAndGet() % 10_000 == 0) { // Make sure we are flushing data to disk as we go diff --git a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/schemas/InitialModServiceTokenSchema.java b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/schemas/InitialModServiceTokenSchema.java index 209605ac3fe2..247dbe074121 100644 --- a/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/schemas/InitialModServiceTokenSchema.java +++ b/hedera-node/hedera-token-service-impl/src/main/java/com/hedera/node/app/service/token/impl/schemas/InitialModServiceTokenSchema.java @@ -299,7 +299,8 @@ public void migrate(@NonNull final MigrationContext ctx) { // ---------- Staking Info log.info("BBM: starting staking info"); var stakingToState = ctx.newStates().get(STAKING_INFO_KEY); - stakingFs.forEach((entityNum, merkleStakingInfo) -> { + stakingFs.keySet().stream().sorted().forEach(entityNum -> { + final var merkleStakingInfo = stakingFs.get(entityNum); var toStakingInfo = StakingNodeInfoStateTranslator.stakingInfoFromMerkleStakingInfo(merkleStakingInfo); stakingToState.put( EntityNumber.newBuilder() @@ -385,7 +386,7 @@ public void migrate(@NonNull final MigrationContext ctx) { if (acctsToState.get().isModified()) ((WritableKVStateBase) acctsToState.get()).commit(); if (aliasesState.get().isModified()) ((WritableKVStateBase) aliasesState.get()).commit(); // Also persist the per-node pending reward information - stakingFs.forEach((entityNum, ignore) -> { + stakingFs.keySet().stream().sorted().forEach(entityNum -> { final var toKey = new EntityNumber(entityNum.longValue()); final var info = requireNonNull(stakingToState.get(toKey)); stakingToState.put(