diff --git a/cmd/zetacored/parse_genesis.go b/cmd/zetacored/parse_genesis.go index ff752a9ddc..bf672a69d5 100644 --- a/cmd/zetacored/parse_genesis.go +++ b/cmd/zetacored/parse_genesis.go @@ -35,7 +35,7 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -const Max_items_for_list = 10 +const MaxItemsForList = 10 var Copy = map[string]bool{ slashingtypes.ModuleName: true, @@ -143,9 +143,9 @@ func ImportDataIntoFile(genDoc *types.GenesisDoc, importFile *types.GenesisDoc, func ModifyCrossChainState(appState map[string]json.RawMessage, importAppState map[string]json.RawMessage, cdc codec.Codec) error { importedCrossChainGenState := crosschaintypes.GetGenesisStateFromAppState(cdc, importAppState) - importedCrossChainGenState.CrossChainTxs = importedCrossChainGenState.CrossChainTxs[:math.Min(Max_items_for_list, len(importedCrossChainGenState.CrossChainTxs))] - importedCrossChainGenState.InTxHashToCctxList = importedCrossChainGenState.InTxHashToCctxList[:math.Min(Max_items_for_list, len(importedCrossChainGenState.InTxHashToCctxList))] - importedCrossChainGenState.FinalizedInbounds = importedCrossChainGenState.FinalizedInbounds[:math.Min(Max_items_for_list, len(importedCrossChainGenState.FinalizedInbounds))] + importedCrossChainGenState.CrossChainTxs = importedCrossChainGenState.CrossChainTxs[:math.Min(MaxItemsForList, len(importedCrossChainGenState.CrossChainTxs))] + importedCrossChainGenState.InTxHashToCctxList = importedCrossChainGenState.InTxHashToCctxList[:math.Min(MaxItemsForList, len(importedCrossChainGenState.InTxHashToCctxList))] + importedCrossChainGenState.FinalizedInbounds = importedCrossChainGenState.FinalizedInbounds[:math.Min(MaxItemsForList, len(importedCrossChainGenState.FinalizedInbounds))] importedCrossChainStateBz, err := json.Marshal(importedCrossChainGenState) if err != nil { return fmt.Errorf("failed to marshal zetacrosschain genesis state: %w", err) @@ -156,8 +156,8 @@ func ModifyCrossChainState(appState map[string]json.RawMessage, importAppState m func ModifyObserverState(appState map[string]json.RawMessage, importAppState map[string]json.RawMessage, cdc codec.Codec) error { importedObserverGenState := observertypes.GetGenesisStateFromAppState(cdc, importAppState) - importedObserverGenState.Ballots = importedObserverGenState.Ballots[:math.Min(Max_items_for_list, len(importedObserverGenState.Ballots))] - importedObserverGenState.NonceToCctx = importedObserverGenState.NonceToCctx[:math.Min(Max_items_for_list, len(importedObserverGenState.NonceToCctx))] + importedObserverGenState.Ballots = importedObserverGenState.Ballots[:math.Min(MaxItemsForList, len(importedObserverGenState.Ballots))] + importedObserverGenState.NonceToCctx = importedObserverGenState.NonceToCctx[:math.Min(MaxItemsForList, len(importedObserverGenState.NonceToCctx))] currentGenState := observertypes.GetGenesisStateFromAppState(cdc, appState) currentGenState.Ballots = importedObserverGenState.Ballots diff --git a/cmd/zetacored/parse_genesis_test.go b/cmd/zetacored/parse_genesis_test.go index 3c51a2da04..469b57c0ba 100644 --- a/cmd/zetacored/parse_genesis_test.go +++ b/cmd/zetacored/parse_genesis_test.go @@ -72,8 +72,8 @@ func Test_ModifyObserverState(t *testing.T) { require.NoError(t, err) modifiedObserverAppState := observertypes.GetGenesisStateFromAppState(cdc, appState) - require.Len(t, modifiedObserverAppState.Ballots, zetacored.Max_items_for_list) - require.Len(t, modifiedObserverAppState.NonceToCctx, zetacored.Max_items_for_list) + require.Len(t, modifiedObserverAppState.Ballots, zetacored.MaxItemsForList) + require.Len(t, modifiedObserverAppState.NonceToCctx, zetacored.MaxItemsForList) }) t.Run("successfully modify observer state without changing data when not needed", func(t *testing.T) { @@ -104,9 +104,9 @@ func Test_ImportDataIntoFile(t *testing.T) { // Crosschain module is in Modify list crosschainStateAfterImport := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) - require.Len(t, crosschainStateAfterImport.CrossChainTxs, zetacored.Max_items_for_list) - require.Len(t, crosschainStateAfterImport.InTxHashToCctxList, zetacored.Max_items_for_list) - require.Len(t, crosschainStateAfterImport.FinalizedInbounds, zetacored.Max_items_for_list) + require.Len(t, crosschainStateAfterImport.CrossChainTxs, zetacored.MaxItemsForList) + require.Len(t, crosschainStateAfterImport.InTxHashToCctxList, zetacored.MaxItemsForList) + require.Len(t, crosschainStateAfterImport.FinalizedInbounds, zetacored.MaxItemsForList) // Bank module is in Skip list var bankStateAfterImport banktypes.GenesisState