Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix to deterministic iteration order #12401

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.hedera.hapi.node.base.SemanticVersion;
import com.hedera.hapi.node.base.TopicID;
import com.hedera.hapi.node.state.consensus.Topic;
import com.hedera.node.app.service.mono.state.adapters.MerkleMapLike;
import com.hedera.node.app.service.mono.state.merkle.MerkleTopic;
import com.hedera.node.app.service.mono.utils.EntityNum;
import com.hedera.node.app.spi.state.MigrationContext;
Expand Down Expand Up @@ -70,8 +71,7 @@ public void migrate(@NonNull final MigrationContext ctx) {
final var numTopicInsertions = new AtomicLong();
final var topicStoreRef = new AtomicReference<>(ctx.newStates().<TopicID, Topic>get(TOPICS_KEY));
log.info("BBM: running consensus migration...");

fs.forEach((k, v) -> {
MerkleMapLike.from(fs).forEachNode((k, v) -> {
final var pbjTopic = stateToPbj(v);
topicStoreRef.get().put(pbjTopic.topicId(), pbjTopic);
if (numTopicInsertions.incrementAndGet() % 10_000 == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void migrate(@NonNull final MigrationContext ctx) {
// ---------- Staking Info
log.info("BBM: starting staking info");
var stakingToState = ctx.newStates().<EntityNumber, StakingNodeInfo>get(STAKING_INFO_KEY);
stakingFs.forEach((entityNum, merkleStakingInfo) -> {
MerkleMapLike.from(stakingFs).forEachNode((entityNum, merkleStakingInfo) -> {
var toStakingInfo = StakingNodeInfoStateTranslator.stakingInfoFromMerkleStakingInfo(merkleStakingInfo);
stakingToState.put(
EntityNumber.newBuilder()
Expand Down Expand Up @@ -385,7 +385,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) -> {
MerkleMapLike.from(stakingFs).forEachNode((entityNum, ignore) -> {
final var toKey = new EntityNumber(entityNum.longValue());
final var info = requireNonNull(stakingToState.get(toKey));
stakingToState.put(
Expand Down
Loading