Skip to content

Commit

Permalink
fix: reindex children in demo states (#17006)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Petrov <[email protected]>
  • Loading branch information
anthony-swirldslabs authored Dec 10, 2024
1 parent 3bffe21 commit 06c74c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ private static class ClassVersion {
*/
private static final Duration INCIDENT_WINDOW = Duration.ofSeconds(10);

private static final int RUNNING_SUM_INDEX = 1;
private static final int GENESIS_TIMESTAMP_INDEX = 2;
private static final int PLANNED_ISS_LIST_INDEX = 3;
private static final int PLANNED_LOG_ERROR_LIST_INDEX = 4;
// 0 is PLATFORM_STATE, 1 is ROSTERS, 2 is ROSTER_STATE
private static final int RUNNING_SUM_INDEX = 3;
private static final int GENESIS_TIMESTAMP_INDEX = 4;
private static final int PLANNED_ISS_LIST_INDEX = 5;
private static final int PLANNED_LOG_ERROR_LIST_INDEX = 6;

private NodeId selfId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ private static class ClassVersion {
* A record of the positions of each child within this node.
*/
private static class ChildIndices {
public static final int UNUSED = 0;
public static final int MERKLE_MAP = 1;
public static final int VIRTUAL_MAP = 2;
public static final int UNUSED_PLATFORM_STATE = 0;
public static final int UNUSED_ROSTERS = 1;
public static final int UNUSED_ROSTER_STATE = 2;

public static final int CHILD_COUNT = 3;
public static final int MERKLE_MAP = 3;
public static final int VIRTUAL_MAP = 4;

public static final int CHILD_COUNT = 5;
}

public NodeId selfId;
Expand Down Expand Up @@ -136,9 +139,10 @@ public int getMaximumChildCount() {
@Override
public boolean childHasExpectedType(final int index, final long childClassId) {
switch (index) {
case ChildIndices.UNUSED:
// We used to use this for an address book, but now we don't use this index.
// Ignore whatever is found at this index.
case ChildIndices.UNUSED_PLATFORM_STATE:
case ChildIndices.UNUSED_ROSTERS:
case ChildIndices.UNUSED_ROSTER_STATE:
// Reserved for system states.
return true;
case ChildIndices.MERKLE_MAP:
return childClassId == MerkleMap.CLASS_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ public int getMaximumChildCount() {
@Override
public boolean childHasExpectedType(final int index, final long childClassId) {
switch (index) {
case ChildIndices.UNUSED:
case ChildIndices.UNUSED_PLATFORM_STATE:
case ChildIndices.UNUSED_ROSTERS:
case ChildIndices.UNUSED_ROSTER_STATE:
// We used to use this for an address book, but now we don't use this index.
// Ignore whatever is found at this index.
// platform should be here, so check for singleton if all will be ok
Expand Down Expand Up @@ -1621,16 +1623,19 @@ private static class ClassVersion {
}

private static class ChildIndices {
public static final int UNUSED = 0; // should be platform and singleton
public static final int CONFIG = 1;
public static final int UNUSED_PLATFORM_STATE = 0;
public static final int UNUSED_ROSTERS = 1;
public static final int UNUSED_ROSTER_STATE = 2;

public static final int CONFIG = 3;
/**
* last sequence by each member for consensus events
*/
public static final int NEXT_SEQUENCE_CONSENSUS = 2;
public static final int NEXT_SEQUENCE_CONSENSUS = 4;

public static final int FCM_FAMILY = 3;
public static final int TRANSACTION_COUNTER = 4;
public static final int ISS_LEAF = 5;
public static final int FCM_FAMILY = 5;
public static final int TRANSACTION_COUNTER = 6;
public static final int ISS_LEAF = 7;
/**
* Migration test need this value to be able to load state file generated by v21 sdk
*/
Expand All @@ -1641,17 +1646,17 @@ private static class ChildIndices {
* compression). But this is what Hedera is currently doing, so it is better to mimic their pattern and have
* similar inefficiencies.
*/
public static final int NFT_LEDGER = 6;
public static final int NFT_LEDGER = 8;

public static final int VIRTUAL_MERKLE = 7;
public static final int VIRTUAL_MERKLE = 9;

public static final int VIRTUAL_MERKLE_SMART_CONTRACTS = 8;
public static final int VIRTUAL_MERKLE_SMART_CONTRACTS = 10;

public static final int VIRTUAL_MERKLE_SMART_CONTRACTS_BYTE_CODE = 9;
public static final int VIRTUAL_MERKLE_SMART_CONTRACTS_BYTE_CODE = 11;

public static final int QUORUM_RESULT = 10;
public static final int QUORUM_RESULT = 12;

public static final int CHILD_COUNT = 11;
public static final int CHILD_COUNT = 13;
}

@Override
Expand Down

0 comments on commit 06c74c3

Please sign in to comment.