diff --git a/app/app.go b/app/app.go index 0625df5f08..b30335c128 100644 --- a/app/app.go +++ b/app/app.go @@ -574,29 +574,7 @@ func New( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. // NOTE: Cross-chain module must be initialized after observer module, as pending nonces in crosschain needs the tss pubkey from observer module - app.mm.SetOrderInitGenesis( - authtypes.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - stakingtypes.ModuleName, - slashingtypes.ModuleName, - govtypes.ModuleName, - crisistypes.ModuleName, - evmtypes.ModuleName, - feemarkettypes.ModuleName, - paramstypes.ModuleName, - group.ModuleName, - genutiltypes.ModuleName, - upgradetypes.ModuleName, - evidencetypes.ModuleName, - vestingtypes.ModuleName, - observertypes.ModuleName, - crosschaintypes.ModuleName, - fungibletypes.ModuleName, - emissionstypes.ModuleName, - authz.ModuleName, - authoritytypes.ModuleName, - ) + app.mm.SetOrderInitGenesis(InitGenesisModuleList()...) app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) diff --git a/app/init_genesis.go b/app/init_genesis.go new file mode 100644 index 0000000000..f5d12a0746 --- /dev/null +++ b/app/init_genesis.go @@ -0,0 +1,51 @@ +package app + +import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/group" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionsModuleTypes "github.com/zeta-chain/zetacore/x/emissions/types" + fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func InitGenesisModuleList() []string { + return []string{ + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + crisistypes.ModuleName, + evmtypes.ModuleName, + feemarkettypes.ModuleName, + paramstypes.ModuleName, + group.ModuleName, + genutiltypes.ModuleName, + upgradetypes.ModuleName, + evidencetypes.ModuleName, + vestingtypes.ModuleName, + observertypes.ModuleName, + crosschaintypes.ModuleName, + fungibleModuleTypes.ModuleName, + emissionsModuleTypes.ModuleName, + authz.ModuleName, + authoritytypes.ModuleName, + } +} diff --git a/app/setup_handlers.go b/app/setup_handlers.go index d9119ee8f6..46c78a3f13 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -12,7 +12,7 @@ import ( const releaseVersion = "v15" func SetupHandlers(app *App) { - app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { + app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { app.Logger().Info("Running upgrade handler for " + releaseVersion) // Updated version map to the latest consensus versions from each module for m, mb := range app.mm.Modules { diff --git a/changelog.md b/changelog.md index 1fa1f6d681..a3ae5e2cb2 100644 --- a/changelog.md +++ b/changelog.md @@ -36,6 +36,7 @@ * [1942](https://github.com/zeta-chain/node/pull/1982) - support Bitcoin P2TR, P2WSH, P2SH, P2PKH addresses * [1935](https://github.com/zeta-chain/node/pull/1935) - add an operational authority group * [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns +* [1979](https://github.com/zeta-chain/node/pull/1979) - add script to import genesis data into an existing genesis file ### Tests diff --git a/cmd/zetaclientd/debug.go b/cmd/zetaclientd/debug.go index 32cb32c772..e0f162793d 100644 --- a/cmd/zetaclientd/debug.go +++ b/cmd/zetaclientd/debug.go @@ -47,7 +47,7 @@ func DebugCmd() *cobra.Command { cmd := &cobra.Command{ Use: "get-ballot-from-intx [txHash] [chainID]", Short: "provide txHash and chainID to get the ballot status for the txHash", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { cobra.ExactArgs(2) cfg, err := config.Load(debugArgs.zetaCoreHome) if err != nil { diff --git a/cmd/zetacored/addr_converter.go b/cmd/zetacored/addr_converter.go index 63d66e6f86..557b4cc9c2 100644 --- a/cmd/zetacored/addr_converter.go +++ b/cmd/zetacored/addr_converter.go @@ -18,7 +18,7 @@ it always outputs three lines; the first line is the zeta1xxx address, the secon and the third line is the ethereum address. `, Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { addr, err := sdk.AccAddressFromBech32(args[0]) if err == nil { valAddr := sdk.ValAddress(addr.Bytes()) diff --git a/cmd/zetacored/collect_observer_info.go b/cmd/zetacored/collect_observer_info.go index f9c351636c..420b82eb6e 100644 --- a/cmd/zetacored/collect_observer_info.go +++ b/cmd/zetacored/collect_observer_info.go @@ -14,7 +14,7 @@ func CollectObserverInfoCmd() *cobra.Command { Use: "collect-observer-info [folder]", Short: "collect observer info from a folder , default path is ~/.zetacored/os_info/ \n", Args: cobra.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { defaultHome := app.DefaultNodeHome defaultFile := filepath.Join(defaultHome, "os_info") if len(args) == 0 { diff --git a/cmd/zetacored/parse_genesis.go b/cmd/zetacored/parse_genesis.go new file mode 100644 index 0000000000..24631d54c3 --- /dev/null +++ b/cmd/zetacored/parse_genesis.go @@ -0,0 +1,194 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/group" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + "github.com/spf13/cobra" + "github.com/tendermint/tendermint/types" + "github.com/zeta-chain/zetacore/app" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionsModuleTypes "github.com/zeta-chain/zetacore/x/emissions/types" + fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +const MaxItemsForList = 10 + +var Copy = map[string]bool{ + slashingtypes.ModuleName: true, + govtypes.ModuleName: true, + crisistypes.ModuleName: true, + feemarkettypes.ModuleName: true, + paramstypes.ModuleName: true, + upgradetypes.ModuleName: true, + evidencetypes.ModuleName: true, + vestingtypes.ModuleName: true, + fungibleModuleTypes.ModuleName: true, + emissionsModuleTypes.ModuleName: true, + authz.ModuleName: true, +} +var Skip = map[string]bool{ + evmtypes.ModuleName: true, + stakingtypes.ModuleName: true, + genutiltypes.ModuleName: true, + authtypes.ModuleName: true, + banktypes.ModuleName: true, + distributiontypes.ModuleName: true, + group.ModuleName: true, +} + +var Modify = map[string]bool{ + crosschaintypes.ModuleName: true, + observertypes.ModuleName: true, +} + +func CmdParseGenesisFile() *cobra.Command { + cmd := &cobra.Command{ + Use: "parse-genesis-file [import-genesis-file] [optional-genesis-file]", + Short: "Parse the provided genesis file and import the required data into the optionally provided genesis file", + Args: cobra.MaximumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + cdc := clientCtx.Codec + genesisFilePath := filepath.Join(app.DefaultNodeHome, "config", "genesis.json") + if len(args) == 2 { + genesisFilePath = args[1] + } + genDoc, err := GetGenDoc(genesisFilePath) + if err != nil { + return err + } + importData, err := GetGenDoc(args[0]) + if err != nil { + return err + } + err = ImportDataIntoFile(genDoc, importData, cdc) + if err != nil { + return err + } + + err = genutil.ExportGenesisFile(genDoc, genesisFilePath) + if err != nil { + return err + } + + return nil + }, + } + return cmd +} + +func ImportDataIntoFile(genDoc *types.GenesisDoc, importFile *types.GenesisDoc, cdc codec.Codec) error { + + appState, err := genutiltypes.GenesisStateFromGenDoc(*genDoc) + if err != nil { + return err + } + importAppState, err := genutiltypes.GenesisStateFromGenDoc(*importFile) + if err != nil { + return err + } + moduleList := app.InitGenesisModuleList() + for _, m := range moduleList { + if Skip[m] { + continue + } + if Copy[m] { + appState[m] = importAppState[m] + } + if Modify[m] { + switch m { + case crosschaintypes.ModuleName: + err := ModifyCrossChainState(appState, importAppState, cdc) + if err != nil { + return err + } + case observertypes.ModuleName: + err := ModifyObserverState(appState, importAppState, cdc) + if err != nil { + return err + } + default: + return fmt.Errorf("modify function for %s not found", m) + } + } + } + + appStateJSON, err := json.Marshal(appState) + if err != nil { + return fmt.Errorf("failed to marshal application genesis state: %w", err) + } + genDoc.AppState = appStateJSON + + return nil +} + +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(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) + } + appState[crosschaintypes.ModuleName] = importedCrossChainStateBz + return nil +} + +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(MaxItemsForList, len(importedObserverGenState.Ballots))] + importedObserverGenState.NonceToCctx = importedObserverGenState.NonceToCctx[:math.Min(MaxItemsForList, len(importedObserverGenState.NonceToCctx))] + + currentGenState := observertypes.GetGenesisStateFromAppState(cdc, appState) + currentGenState.Ballots = importedObserverGenState.Ballots + currentGenState.NonceToCctx = importedObserverGenState.NonceToCctx + + currentGenStateBz, err := cdc.MarshalJSON(¤tGenState) + if err != nil { + return fmt.Errorf("failed to marshal observer genesis state: %w", err) + } + + appState[observertypes.ModuleName] = currentGenStateBz + return nil +} + +func GetGenDoc(fp string) (*types.GenesisDoc, error) { + path, err := filepath.Abs(fp) + if err != nil { + return nil, err + } + jsonBlob, err := os.ReadFile(filepath.Clean(path)) + if err != nil { + return nil, err + } + genData, err := types.GenesisDocFromJSON(jsonBlob) + if err != nil { + return nil, err + } + return genData, nil +} diff --git a/cmd/zetacored/parse_genesis_test.go b/cmd/zetacored/parse_genesis_test.go new file mode 100644 index 0000000000..469b57c0ba --- /dev/null +++ b/cmd/zetacored/parse_genesis_test.go @@ -0,0 +1,230 @@ +package main_test + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/types" + "github.com/zeta-chain/zetacore/app" + zetacored "github.com/zeta-chain/zetacore/cmd/zetacored" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func setConfig(t *testing.T) { + defer func(t *testing.T) { + if r := recover(); r != nil { + t.Log("config is already sealed", r) + } + }(t) + cfg := sdk.GetConfig() + cfg.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub) + cfg.Seal() +} +func Test_ModifyCrossChainState(t *testing.T) { + setConfig(t) + t.Run("successfully modify cross chain state to reduce data", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 100) + err := zetacored.ModifyCrossChainState(appState, importData, cdc) + require.NoError(t, err) + + modifiedCrosschainAppState := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedCrosschainAppState.CrossChainTxs, 10) + require.Len(t, modifiedCrosschainAppState.InTxHashToCctxList, 10) + require.Len(t, modifiedCrosschainAppState.FinalizedInbounds, 10) + }) + + t.Run("successfully modify cross chain state without changing data when not needed", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 8) + err := zetacored.ModifyCrossChainState(appState, importData, cdc) + require.NoError(t, err) + + modifiedCrosschainAppState := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedCrosschainAppState.CrossChainTxs, 8) + require.Len(t, modifiedCrosschainAppState.InTxHashToCctxList, 8) + require.Len(t, modifiedCrosschainAppState.FinalizedInbounds, 8) + }) +} + +func Test_ModifyObserverState(t *testing.T) { + setConfig(t) + t.Run("successfully modify observer state to reduce data", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 100) + err := zetacored.ModifyObserverState(appState, importData, cdc) + require.NoError(t, err) + + modifiedObserverAppState := observertypes.GetGenesisStateFromAppState(cdc, appState) + 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) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 8) + err := zetacored.ModifyObserverState(appState, importData, cdc) + require.NoError(t, err) + + modifiedObserverAppState := observertypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedObserverAppState.Ballots, 8) + require.Len(t, modifiedObserverAppState.NonceToCctx, 8) + }) + +} + +func Test_ImportDataIntoFile(t *testing.T) { + setConfig(t) + cdc := keepertest.NewCodec() + genDoc := sample.GenDoc(t) + importGenDoc := ImportGenDoc(t, cdc, 100) + + err := zetacored.ImportDataIntoFile(genDoc, importGenDoc, cdc) + require.NoError(t, err) + + appState, err := genutiltypes.GenesisStateFromGenDoc(*genDoc) + require.NoError(t, err) + + // Crosschain module is in Modify list + crosschainStateAfterImport := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) + 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 + if appState[banktypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(appState[banktypes.ModuleName], &bankStateAfterImport) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + // 4 balances were present in the original genesis state + require.Len(t, bankStateAfterImport.Balances, 4) + + // Emissions module is in Copy list + var emissionStateAfterImport emissionstypes.GenesisState + if appState[emissionstypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(appState[emissionstypes.ModuleName], &emissionStateAfterImport) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + require.Len(t, emissionStateAfterImport.WithdrawableEmissions, 100) +} + +func Test_GetGenDoc(t *testing.T) { + t.Run("successfully get genesis doc from file", func(t *testing.T) { + fp := filepath.Join(os.TempDir(), "genesis.json") + err := genutil.ExportGenesisFile(sample.GenDoc(t), fp) + require.NoError(t, err) + _, err = zetacored.GetGenDoc(fp) + require.NoError(t, err) + }) + t.Run("fail to get genesis doc from file", func(t *testing.T) { + _, err := zetacored.GetGenDoc("test") + require.ErrorContains(t, err, "no such file or directory") + }) +} + +func ImportGenDoc(t *testing.T, cdc *codec.ProtoCodec, n int) *types.GenesisDoc { + importGenDoc := sample.GenDoc(t) + importStateJson, err := json.Marshal(GetImportData(t, cdc, n)) + require.NoError(t, err) + importGenDoc.AppState = importStateJson + return importGenDoc +} + +func GetImportData(t *testing.T, cdc *codec.ProtoCodec, n int) map[string]json.RawMessage { + importData := sample.AppState(t) + + // Add crosschain data to genesis state + importedCrossChainGenState := crosschaintypes.GetGenesisStateFromAppState(cdc, importData) + cctxList := make([]*crosschaintypes.CrossChainTx, n) + intxHashToCctxList := make([]crosschaintypes.InTxHashToCctx, n) + finalLizedInbounds := make([]string, n) + for i := 0; i < n; i++ { + cctxList[i] = sample.CrossChainTx(t, fmt.Sprintf("crosschain-%d", i)) + intxHashToCctxList[i] = sample.InTxHashToCctx(t, fmt.Sprintf("intxHashToCctxList-%d", i)) + finalLizedInbounds[i] = fmt.Sprintf("finalLizedInbounds-%d", i) + } + importedCrossChainGenState.CrossChainTxs = cctxList + importedCrossChainGenState.InTxHashToCctxList = intxHashToCctxList + importedCrossChainGenState.FinalizedInbounds = finalLizedInbounds + importedCrossChainStateBz, err := json.Marshal(importedCrossChainGenState) + require.NoError(t, err) + importData[crosschaintypes.ModuleName] = importedCrossChainStateBz + + // Add observer data to genesis state + importedObserverGenState := observertypes.GetGenesisStateFromAppState(cdc, importData) + ballots := make([]*observertypes.Ballot, n) + nonceToCctx := make([]observertypes.NonceToCctx, n) + for i := 0; i < n; i++ { + ballots[i] = sample.Ballot(t, fmt.Sprintf("ballots-%d", i)) + nonceToCctx[i] = sample.NonceToCCTX(t, fmt.Sprintf("nonceToCctx-%d", i)) + } + importedObserverGenState.Ballots = ballots + importedObserverGenState.NonceToCctx = nonceToCctx + importedObserverStateBz, err := cdc.MarshalJSON(&importedObserverGenState) + require.NoError(t, err) + importData[observertypes.ModuleName] = importedObserverStateBz + + // Add emission data to genesis state + var importedEmissionGenesis emissionstypes.GenesisState + if importData[emissionstypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(importData[emissionstypes.ModuleName], &importedEmissionGenesis) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + withdrawableEmissions := make([]emissionstypes.WithdrawableEmissions, n) + for i := 0; i < n; i++ { + withdrawableEmissions[i] = sample.WithdrawableEmissions(t) + } + importedEmissionGenesis.WithdrawableEmissions = withdrawableEmissions + importedEmissionGenesisBz, err := cdc.MarshalJSON(&importedEmissionGenesis) + require.NoError(t, err) + importData[emissionstypes.ModuleName] = importedEmissionGenesisBz + + // Add bank data to genesis state + var importedBankGenesis banktypes.GenesisState + if importData[banktypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(importData[banktypes.ModuleName], &importedBankGenesis) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + balances := make([]banktypes.Balance, n) + supply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.ZeroInt())) + for i := 0; i < n; i++ { + balances[i] = banktypes.Balance{ + Address: sample.AccAddress(), + Coins: sample.Coins(), + } + supply = supply.Add(balances[i].Coins...) + } + importedBankGenesis.Balances = balances + importedBankGenesis.Supply = supply + importedBankGenesisBz, err := cdc.MarshalJSON(&importedBankGenesis) + require.NoError(t, err) + importData[banktypes.ModuleName] = importedBankGenesisBz + + return importData +} diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 9f1835c9bb..7c14d1bfcb 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -134,6 +134,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(app.DefaultNodeHome), AddObserverAccountsCmd(), + CmdParseGenesisFile(), GetPubKeyCmd(), CollectObserverInfoCmd(), AddrConversionCmd(), diff --git a/docs/cli/zetacored/zetacored.md b/docs/cli/zetacored/zetacored.md index 4b5f360d55..f501a6a46b 100644 --- a/docs/cli/zetacored/zetacored.md +++ b/docs/cli/zetacored/zetacored.md @@ -29,6 +29,7 @@ Zetacore Daemon (server) * [zetacored index-eth-tx](zetacored_index-eth-tx.md) - Index historical eth txs * [zetacored init](zetacored_init.md) - Initialize private validator, p2p, genesis, and application configuration files * [zetacored keys](zetacored_keys.md) - Manage your application's keys +* [zetacored parse-genesis-file](zetacored_parse-genesis-file.md) - Parse the provided genesis file and import the required data into the optionally provided genesis file * [zetacored query](zetacored_query.md) - Querying subcommands * [zetacored rollback](zetacored_rollback.md) - rollback cosmos-sdk and tendermint state by one height * [zetacored rosetta](zetacored_rosetta.md) - spin up a rosetta server diff --git a/docs/cli/zetacored/zetacored_parse-genesis-file.md b/docs/cli/zetacored/zetacored_parse-genesis-file.md new file mode 100644 index 0000000000..b35a5c6b97 --- /dev/null +++ b/docs/cli/zetacored/zetacored_parse-genesis-file.md @@ -0,0 +1,27 @@ +# parse-genesis-file + +Parse the provided genesis file and import the required data into the optionally provided genesis file + +``` +zetacored parse-genesis-file [import-genesis-file] [optional-genesis-file] [flags] +``` + +### Options + +``` + -h, --help help for parse-genesis-file +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored](zetacored.md) - Zetacore Daemon (server) + diff --git a/docs/openapi/openapi.go b/docs/openapi/openapi.go index 11f4e40b72..187dbbe7ce 100644 --- a/docs/openapi/openapi.go +++ b/docs/openapi/openapi.go @@ -30,7 +30,7 @@ func openAPIHandler() http.HandlerFunc { panic(err) } - return func(w http.ResponseWriter, req *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { err := tmpl.Execute(w, struct { URL string }{ diff --git a/rpc/websockets.go b/rpc/websockets.go index 3c64bfdb8a..0eec84127e 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -148,7 +148,7 @@ func (s *websocketsServer) Start() { func (s *websocketsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { upgrader := websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { + CheckOrigin: func(_ *http.Request) bool { return true }, } diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 7d9d54c646..a05c4ecf52 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -264,3 +264,13 @@ func VotesSuccessOnly(voteCount int) []types.VoteType { } return votes } + +func NonceToCCTX(t *testing.T, seed string) types.NonceToCctx { + r := newRandFromStringSeed(t, seed) + return types.NonceToCctx{ + ChainId: r.Int63(), + Nonce: r.Int63(), + CctxIndex: StringRandom(r, 64), + Tss: Tss().TssPubkey, + } +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 71b9eac564..4ed1f9ce60 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -1,6 +1,7 @@ package sample import ( + "encoding/json" "errors" "hash/fnv" "math/rand" @@ -8,7 +9,9 @@ import ( "testing" sdkmath "cosmossdk.io/math" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/tendermint/tendermint/types" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -164,3 +167,15 @@ func IntInRange(low, high int64) sdkmath.Int { i := Int64InRange(low, high) return sdkmath.NewInt(i) } +func AppState(t *testing.T) map[string]json.RawMessage { + appState, err := genutiltypes.GenesisStateFromGenDoc(*GenDoc(t)) + require.NoError(t, err) + return appState +} + +func GenDoc(t *testing.T) *types.GenesisDoc { + jsonBlob := []byte("{\n \"genesis_time\": \"2024-04-12T05:07:56.004517Z\",\n \"chain_id\": \"localnet_101-1\",\n \"initial_height\": \"1\",\n \"consensus_params\": {\n \"block\": {\n \"max_bytes\": \"22020096\",\n \"max_gas\": \"10000000\",\n \"time_iota_ms\": \"1000\"\n },\n \"evidence\": {\n \"max_age_num_blocks\": \"100000\",\n \"max_age_duration\": \"172800000000000\",\n \"max_bytes\": \"1048576\"\n },\n \"validator\": {\n \"pub_key_types\": [\n \"ed25519\"\n ]\n },\n \"version\": {}\n },\n \"app_hash\": \"\",\n \"app_state\": {\n \"auth\": {\n \"params\": {\n \"max_memo_characters\": \"256\",\n \"tx_sig_limit\": \"7\",\n \"tx_size_cost_per_byte\": \"10\",\n \"sig_verify_cost_ed25519\": \"590\",\n \"sig_verify_cost_secp256k1\": \"1000\"\n },\n \"accounts\": [\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n }\n ]\n },\n \"authority\": {\n \"policies\": {\n \"items\": [\n {\n \"policy_type\": \"groupEmergency\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": \"groupOperational\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": \"groupAdmin\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n }\n ]\n }\n },\n \"authz\": {\n \"authorization\": [\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgGasPriceVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgCreateTSSVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgAddToOutTxTracker\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlameVote\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlockHeader\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgGasPriceVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgCreateTSSVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgAddToOutTxTracker\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlameVote\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlockHeader\"\n },\n \"expiration\": null\n }\n ]\n },\n \"bank\": {\n \"params\": {\n \"send_enabled\": [],\n \"default_send_enabled\": true\n },\n \"balances\": [\n {\n \"address\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"4200000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"4200000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n ]\n }\n ],\n \"supply\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"8402000000000000000000000\"\n }\n ],\n \"denom_metadata\": []\n },\n \"crisis\": {\n \"constant_fee\": {\n \"denom\": \"azeta\",\n \"amount\": \"1000\"\n }\n },\n \"crosschain\": {\n \"outTxTrackerList\": [],\n \"inTxHashToCctxList\": [],\n \"in_tx_tracker_list\": [],\n \"zeta_accounting\": {\n \"aborted_zeta_amount\": \"0\"\n }\n },\n \"distribution\": {\n \"params\": {\n \"community_tax\": \"0.020000000000000000\",\n \"base_proposer_reward\": \"0.010000000000000000\",\n \"bonus_proposer_reward\": \"0.040000000000000000\",\n \"withdraw_addr_enabled\": true\n },\n \"fee_pool\": {\n \"community_pool\": []\n },\n \"delegator_withdraw_infos\": [],\n \"previous_proposer\": \"\",\n \"outstanding_rewards\": [],\n \"validator_accumulated_commissions\": [],\n \"validator_historical_rewards\": [],\n \"validator_current_rewards\": [],\n \"delegator_starting_infos\": [],\n \"validator_slash_events\": []\n },\n \"emissions\": {\n \"params\": {\n \"max_bond_factor\": \"1.25\",\n \"min_bond_factor\": \"0.75\",\n \"avg_block_time\": \"6.00\",\n \"target_bond_ratio\": \"00.67\",\n \"validator_emission_percentage\": \"00.50\",\n \"observer_emission_percentage\": \"00.25\",\n \"tss_signer_emission_percentage\": \"00.25\",\n \"duration_factor_constant\": \"0.001877876953694702\",\n \"observer_slash_amount\": \"0\"\n },\n \"withdrawableEmissions\": []\n },\n \"evidence\": {\n \"evidence\": []\n },\n \"evm\": {\n \"accounts\": [],\n \"params\": {\n \"evm_denom\": \"azeta\",\n \"enable_create\": true,\n \"enable_call\": true,\n \"extra_eips\": [],\n \"chain_config\": {\n \"homestead_block\": \"0\",\n \"dao_fork_block\": \"0\",\n \"dao_fork_support\": true,\n \"eip150_block\": \"0\",\n \"eip150_hash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n \"eip155_block\": \"0\",\n \"eip158_block\": \"0\",\n \"byzantium_block\": \"0\",\n \"constantinople_block\": \"0\",\n \"petersburg_block\": \"0\",\n \"istanbul_block\": \"0\",\n \"muir_glacier_block\": \"0\",\n \"berlin_block\": \"0\",\n \"london_block\": \"0\",\n \"arrow_glacier_block\": \"0\",\n \"gray_glacier_block\": \"0\",\n \"merge_netsplit_block\": \"0\",\n \"shanghai_block\": \"0\",\n \"cancun_block\": \"0\"\n },\n \"allow_unprotected_txs\": false\n }\n },\n \"feemarket\": {\n \"params\": {\n \"no_base_fee\": false,\n \"base_fee_change_denominator\": 8,\n \"elasticity_multiplier\": 2,\n \"enable_height\": \"0\",\n \"base_fee\": \"1000000000\",\n \"min_gas_price\": \"0.000000000000000000\",\n \"min_gas_multiplier\": \"0.500000000000000000\"\n },\n \"block_gas\": \"0\"\n },\n \"fungible\": {\n \"params\": {},\n \"foreignCoinsList\": [],\n \"systemContract\": null\n },\n \"genutil\": {\n \"gen_txs\": [\n {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"/cosmos.staking.v1beta1.MsgCreateValidator\",\n \"description\": {\n \"moniker\": \"Zetanode-Localnet\",\n \"identity\": \"\",\n \"website\": \"\",\n \"security_contact\": \"\",\n \"details\": \"\"\n },\n \"commission\": {\n \"rate\": \"0.100000000000000000\",\n \"max_rate\": \"0.200000000000000000\",\n \"max_change_rate\": \"0.010000000000000000\"\n },\n \"min_self_delegation\": \"1\",\n \"delegator_address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"validator_address\": \"zetavaloper13c7p3xrhd6q2rx3h235jpt8pjdwvacyw7tkass\",\n \"pubkey\": {\n \"@type\": \"/cosmos.crypto.ed25519.PubKey\",\n \"key\": \"sBSs5r1vQn1idTp4uRTbdUK0jjmEscI3pn88LUXI4CQ=\"\n },\n \"value\": {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n }\n ],\n \"memo\": \"1db4f4185e68c1c17d508294de2592616dad37a5@192.168.2.12:26656\",\n \"timeout_height\": \"0\",\n \"extension_options\": [],\n \"non_critical_extension_options\": []\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"/cosmos.crypto.secp256k1.PubKey\",\n \"key\": \"A05F6QuFVpb/5KrIPvlHr209ZsD22gW0omhLSXWAtQrh\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_DIRECT\"\n }\n },\n \"sequence\": \"0\"\n }\n ],\n \"fee\": {\n \"amount\": [],\n \"gas_limit\": \"200000\",\n \"payer\": \"\",\n \"granter\": \"\"\n },\n \"tip\": null\n },\n \"signatures\": [\n \"y5YROwZmV0jcgv5BgRJCDE+Kq5OsX8+88or1ogekPLBw3ecPt8GsCeEbPQ24JONLzNwQEIUDNYTeSQnXnCfzyg==\"\n ]\n }\n ]\n },\n \"gov\": {\n \"starting_proposal_id\": \"1\",\n \"deposits\": [],\n \"votes\": [],\n \"proposals\": [],\n \"deposit_params\": {\n \"min_deposit\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"10000000\"\n }\n ],\n \"max_deposit_period\": \"172800s\"\n },\n \"voting_params\": {\n \"voting_period\": \"10s\"\n },\n \"tally_params\": {\n \"quorum\": \"0.334000000000000000\",\n \"threshold\": \"0.500000000000000000\",\n \"veto_threshold\": \"0.334000000000000000\"\n }\n },\n \"group\": {\n \"group_seq\": \"0\",\n \"groups\": [],\n \"group_members\": [],\n \"group_policy_seq\": \"0\",\n \"group_policies\": [],\n \"proposal_seq\": \"0\",\n \"proposals\": [],\n \"votes\": []\n },\n \"mint\": {\n \"params\": {\n \"mint_denom\": \"azeta\"\n }\n },\n \"observer\": {\n \"observers\": {\n \"observer_list\": [\n \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\"\n ]\n },\n \"nodeAccountList\": [\n {\n \"operator\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"granteeAddress\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"granteePubkey\": {\n \"secp256k1\": \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\"\n },\n \"nodeStatus\": 4\n },\n {\n \"operator\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"granteeAddress\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"granteePubkey\": {\n \"secp256k1\": \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n },\n \"nodeStatus\": 4\n }\n ],\n \"crosschain_flags\": {\n \"isInboundEnabled\": true,\n \"isOutboundEnabled\": true\n },\n \"params\": {\n \"observer_params\": [\n {\n \"chain\": {\n \"chain_name\": 2,\n \"chain_id\": 101\n },\n \"ballot_threshold\": \"0.660000000000000000\",\n \"min_observer_delegation\": \"1000000000000000000000.000000000000000000\",\n \"is_supported\": true\n },\n {\n \"chain\": {\n \"chain_name\": 15,\n \"chain_id\": 18444\n },\n \"ballot_threshold\": \"0.660000000000000000\",\n \"min_observer_delegation\": \"1000000000000000000000.000000000000000000\",\n \"is_supported\": true\n },\n {\n \"chain\": {\n \"chain_name\": 14,\n \"chain_id\": 1337\n },\n \"ballot_threshold\": \"0.660000000000000000\",\n \"min_observer_delegation\": \"1000000000000000000000.000000000000000000\",\n \"is_supported\": true\n }\n ],\n \"admin_policy\": [\n {\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": 1,\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n }\n ],\n \"ballot_maturity_blocks\": 100\n },\n \"keygen\": {\n \"status\": 1,\n \"granteePubkeys\": [\n \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\",\n \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n ]\n },\n \"chain_params_list\": {},\n \"tss\": {\n \"tss_pubkey\": \"zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p\",\n \"tss_participant_list\": [\n \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\",\n \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n ],\n \"operator_address_list\": [\n \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\"\n ]\n },\n \"tss_history\": [],\n \"tss_fund_migrators\": [],\n \"blame_list\": [],\n \"pending_nonces\": [],\n \"chain_nonces\": [],\n \"nonce_to_cctx\": []\n },\n \"params\": null,\n \"slashing\": {\n \"params\": {\n \"signed_blocks_window\": \"100\",\n \"min_signed_per_window\": \"0.500000000000000000\",\n \"downtime_jail_duration\": \"600s\",\n \"slash_fraction_double_sign\": \"0.050000000000000000\",\n \"slash_fraction_downtime\": \"0.010000000000000000\"\n },\n \"signing_infos\": [],\n \"missed_blocks\": []\n },\n \"staking\": {\n \"params\": {\n \"unbonding_time\": \"1814400s\",\n \"max_validators\": 100,\n \"max_entries\": 7,\n \"historical_entries\": 10000,\n \"bond_denom\": \"azeta\",\n \"min_commission_rate\": \"0.000000000000000000\"\n },\n \"last_total_power\": \"0\",\n \"last_validator_powers\": [],\n \"validators\": [],\n \"delegations\": [],\n \"unbonding_delegations\": [],\n \"redelegations\": [],\n \"exported\": false\n },\n \"upgrade\": {},\n \"vesting\": {}\n }\n}") + genDoc, err := types.GenesisDocFromJSON(jsonBlob) + require.NoError(t, err) + return genDoc +} diff --git a/x/authority/client/cli/query_policies.go b/x/authority/client/cli/query_policies.go index 66ad4e5644..723dfcf71b 100644 --- a/x/authority/client/cli/query_policies.go +++ b/x/authority/client/cli/query_policies.go @@ -15,7 +15,7 @@ func CmdShowPolicies() *cobra.Command { Use: "show-policies", Short: "show the policies", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/crosschain/client/cli/cli_cctx.go b/x/crosschain/client/cli/cli_cctx.go index 87991442d1..d28955a1a7 100644 --- a/x/crosschain/client/cli/cli_cctx.go +++ b/x/crosschain/client/cli/cli_cctx.go @@ -21,7 +21,7 @@ func CmdListSend() *cobra.Command { cmd := &cobra.Command{ Use: "list-cctx", Short: "list all CCTX", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_gas_price.go b/x/crosschain/client/cli/cli_gas_price.go index b46897b36c..b080aa7809 100644 --- a/x/crosschain/client/cli/cli_gas_price.go +++ b/x/crosschain/client/cli/cli_gas_price.go @@ -15,7 +15,7 @@ func CmdListGasPrice() *cobra.Command { cmd := &cobra.Command{ Use: "list-gas-price", Short: "list all gasPrice", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_in_tx_tracker.go b/x/crosschain/client/cli/cli_in_tx_tracker.go index 5afcec7ec8..d31257a257 100644 --- a/x/crosschain/client/cli/cli_in_tx_tracker.go +++ b/x/crosschain/client/cli/cli_in_tx_tracker.go @@ -86,7 +86,7 @@ func CmdListInTxTrackers() *cobra.Command { Use: "list-all-in-tx-trackers", Short: "shows all inTxTrackers", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) params := &types.QueryAllInTxTrackersRequest{} diff --git a/x/crosschain/client/cli/cli_last_block_height.go b/x/crosschain/client/cli/cli_last_block_height.go index b3e693dc31..3f1dfb54a9 100644 --- a/x/crosschain/client/cli/cli_last_block_height.go +++ b/x/crosschain/client/cli/cli_last_block_height.go @@ -13,7 +13,7 @@ func CmdListLastBlockHeight() *cobra.Command { cmd := &cobra.Command{ Use: "list-last-block-height", Short: "list all lastBlockHeight", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_out_tx_tracker.go b/x/crosschain/client/cli/cli_out_tx_tracker.go index 109a07d52a..143f237169 100644 --- a/x/crosschain/client/cli/cli_out_tx_tracker.go +++ b/x/crosschain/client/cli/cli_out_tx_tracker.go @@ -15,7 +15,7 @@ func CmdListOutTxTracker() *cobra.Command { cmd := &cobra.Command{ Use: "list-out-tx-tracker", Short: "list all OutTxTracker", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_zeta_height.go b/x/crosschain/client/cli/cli_zeta_height.go index 8f855cd46e..4287d561c0 100644 --- a/x/crosschain/client/cli/cli_zeta_height.go +++ b/x/crosschain/client/cli/cli_zeta_height.go @@ -12,7 +12,7 @@ func CmdLastZetaHeight() *cobra.Command { Use: "last-zeta-height", Short: "Query last Zeta Height", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go b/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go index e34d52886b..4e9444d6b6 100644 --- a/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go +++ b/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go @@ -13,7 +13,7 @@ func CmdListInTxHashToCctx() *cobra.Command { cmd := &cobra.Command{ Use: "list-in-tx-hash-to-cctx", Short: "list all inTxHashToCctx", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/query_zeta_accounting.go b/x/crosschain/client/cli/query_zeta_accounting.go index aece6e6f37..29f35cdc4b 100644 --- a/x/crosschain/client/cli/query_zeta_accounting.go +++ b/x/crosschain/client/cli/query_zeta_accounting.go @@ -12,7 +12,7 @@ func CmdGetZetaAccounting() *cobra.Command { Use: "get-zeta-accounting", Short: "Query zeta accounting", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_cctx.go b/x/crosschain/keeper/grpc_query_cctx.go index 74bdc49293..d221bc0991 100644 --- a/x/crosschain/keeper/grpc_query_cctx.go +++ b/x/crosschain/keeper/grpc_query_cctx.go @@ -38,7 +38,7 @@ func (k Keeper) CctxAll(c context.Context, req *types.QueryAllCctxRequest) (*typ store := ctx.KVStore(k.storeKey) sendStore := prefix.NewStore(store, types.KeyPrefix(types.SendKey)) - pageRes, err := query.Paginate(sendStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(sendStore, req.Pagination, func(_ []byte, value []byte) error { var send types.CrossChainTx if err := k.cdc.Unmarshal(value, &send); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_gas_price.go b/x/crosschain/keeper/grpc_query_gas_price.go index b703ff44a2..311bdc1d6b 100644 --- a/x/crosschain/keeper/grpc_query_gas_price.go +++ b/x/crosschain/keeper/grpc_query_gas_price.go @@ -23,7 +23,7 @@ func (k Keeper) GasPriceAll(c context.Context, req *types.QueryAllGasPriceReques store := ctx.KVStore(k.storeKey) gasPriceStore := prefix.NewStore(store, types.KeyPrefix(types.GasPriceKey)) - pageRes, err := query.Paginate(gasPriceStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(gasPriceStore, req.Pagination, func(_ []byte, value []byte) error { var gasPrice types.GasPrice if err := k.cdc.Unmarshal(value, &gasPrice); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go index 2d3fe05be9..a30c33edf8 100644 --- a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go +++ b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go @@ -22,7 +22,7 @@ func (k Keeper) InTxHashToCctxAll(c context.Context, req *types.QueryAllInTxHash store := ctx.KVStore(k.storeKey) inTxHashToCctxStore := prefix.NewStore(store, types.KeyPrefix(types.InTxHashToCctxKeyPrefix)) - pageRes, err := query.Paginate(inTxHashToCctxStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(inTxHashToCctxStore, req.Pagination, func(_ []byte, value []byte) error { var inTxHashToCctx types.InTxHashToCctx if err := k.cdc.Unmarshal(value, &inTxHashToCctx); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_last_block_height.go b/x/crosschain/keeper/grpc_query_last_block_height.go index 633c440dc9..875a5facf2 100644 --- a/x/crosschain/keeper/grpc_query_last_block_height.go +++ b/x/crosschain/keeper/grpc_query_last_block_height.go @@ -23,7 +23,7 @@ func (k Keeper) LastBlockHeightAll(c context.Context, req *types.QueryAllLastBlo store := ctx.KVStore(k.storeKey) lastBlockHeightStore := prefix.NewStore(store, types.KeyPrefix(types.LastBlockHeightKey)) - pageRes, err := query.Paginate(lastBlockHeightStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(lastBlockHeightStore, req.Pagination, func(_ []byte, value []byte) error { var lastBlockHeight types.LastBlockHeight if err := k.cdc.Unmarshal(value, &lastBlockHeight); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_out_tx_tracker.go b/x/crosschain/keeper/grpc_query_out_tx_tracker.go index 0eac4d35b1..0170953eb2 100644 --- a/x/crosschain/keeper/grpc_query_out_tx_tracker.go +++ b/x/crosschain/keeper/grpc_query_out_tx_tracker.go @@ -22,7 +22,7 @@ func (k Keeper) OutTxTrackerAll(c context.Context, req *types.QueryAllOutTxTrack store := ctx.KVStore(k.storeKey) outTxTrackerStore := prefix.NewStore(store, types.KeyPrefix(types.OutTxTrackerKeyPrefix)) - pageRes, err := query.Paginate(outTxTrackerStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(outTxTrackerStore, req.Pagination, func(_ []byte, value []byte) error { var outTxTracker types.OutTxTracker if err := k.cdc.Unmarshal(value, &outTxTracker); err != nil { return err @@ -49,7 +49,7 @@ func (k Keeper) OutTxTrackerAllByChain(c context.Context, req *types.QueryAllOut store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OutTxTrackerKeyPrefix)) chainStore := prefix.NewStore(store, types.KeyPrefix(fmt.Sprintf("%d-", req.Chain))) - pageRes, err := query.Paginate(chainStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(chainStore, req.Pagination, func(_ []byte, value []byte) error { var outTxTracker types.OutTxTracker if err := k.cdc.Unmarshal(value, &outTxTracker); err != nil { return err diff --git a/x/crosschain/keeper/in_tx_tracker.go b/x/crosschain/keeper/in_tx_tracker.go index d53c56c57f..2d7849ee49 100644 --- a/x/crosschain/keeper/in_tx_tracker.go +++ b/x/crosschain/keeper/in_tx_tracker.go @@ -44,7 +44,7 @@ func (k Keeper) GetAllInTxTrackerPaginated(ctx sdk.Context, pagination *query.Pa store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.InTxTrackerKeyPrefix)) iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var inTxTracker types.InTxTracker if err := k.cdc.Unmarshal(value, &inTxTracker); err != nil { return err @@ -82,7 +82,7 @@ func (k Keeper) GetAllInTxTrackerForChain(ctx sdk.Context, chainID int64) (list func (k Keeper) GetAllInTxTrackerForChainPaginated(ctx sdk.Context, chainID int64, pagination *query.PageRequest) (inTxTrackers []types.InTxTracker, pageRes *query.PageResponse, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(fmt.Sprintf("%s", types.InTxTrackerKeyPrefix))) chainStore := prefix.NewStore(store, types.KeyPrefix(fmt.Sprintf("%d-", chainID))) - pageRes, err = query.Paginate(chainStore, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(chainStore, pagination, func(_ []byte, value []byte) error { var inTxTracker types.InTxTracker if err := k.cdc.Unmarshal(value, &inTxTracker); err != nil { return err diff --git a/x/emissions/client/cli/query_get_emmisons_factors.go b/x/emissions/client/cli/query_get_emmisons_factors.go index 0749d33218..304f7760dc 100644 --- a/x/emissions/client/cli/query_get_emmisons_factors.go +++ b/x/emissions/client/cli/query_get_emmisons_factors.go @@ -12,7 +12,7 @@ func CmdGetEmmisonsFactors() *cobra.Command { Use: "get-emmisons-factors", Short: "Query GetEmmisonsFactors", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/emissions/client/cli/query_list_balances.go b/x/emissions/client/cli/query_list_balances.go index c20ca85500..83e4609fa2 100644 --- a/x/emissions/client/cli/query_list_balances.go +++ b/x/emissions/client/cli/query_list_balances.go @@ -12,7 +12,7 @@ func CmdListPoolAddresses() *cobra.Command { Use: "list-pool-addresses", Short: "Query list-pool-addresses", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/emissions/client/cli/query_params.go b/x/emissions/client/cli/query_params.go index 55b2067c40..82d3ef153a 100644 --- a/x/emissions/client/cli/query_params.go +++ b/x/emissions/client/cli/query_params.go @@ -14,7 +14,7 @@ func CmdQueryParams() *cobra.Command { Use: "params", Short: "shows the parameters of the module", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/query_foreign_coins.go b/x/fungible/client/cli/query_foreign_coins.go index 7410077321..e115fbd65b 100644 --- a/x/fungible/client/cli/query_foreign_coins.go +++ b/x/fungible/client/cli/query_foreign_coins.go @@ -13,7 +13,7 @@ func CmdListForeignCoins() *cobra.Command { cmd := &cobra.Command{ Use: "list-foreign-coins", Short: "list all ForeignCoins", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/fungible/client/cli/query_gas_stability_pool.go b/x/fungible/client/cli/query_gas_stability_pool.go index 46e2fa3ae8..516353daae 100644 --- a/x/fungible/client/cli/query_gas_stability_pool.go +++ b/x/fungible/client/cli/query_gas_stability_pool.go @@ -15,7 +15,7 @@ func CmdGasStabilityPoolAddress() *cobra.Command { Use: "gas-stability-pool-address", Short: "query the address of a gas stability pool", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) @@ -74,7 +74,7 @@ func CmdGasStabilityPoolBalances() *cobra.Command { Use: "gas-stability-pool-balances", Short: "query all gas stability pool balances", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/query_params.go b/x/fungible/client/cli/query_params.go index fad97be7dd..273bee2079 100644 --- a/x/fungible/client/cli/query_params.go +++ b/x/fungible/client/cli/query_params.go @@ -14,7 +14,7 @@ func CmdQueryParams() *cobra.Command { Use: "params", Short: "shows the parameters of the module", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/query_system_contract.go b/x/fungible/client/cli/query_system_contract.go index df79e833d9..f4fe29cc59 100644 --- a/x/fungible/client/cli/query_system_contract.go +++ b/x/fungible/client/cli/query_system_contract.go @@ -13,7 +13,7 @@ func CmdSystemContract() *cobra.Command { cmd := &cobra.Command{ Use: "system-contract", Short: "query system contract", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/tx_deploy_system_contracts.go b/x/fungible/client/cli/tx_deploy_system_contracts.go index b8ed9dd9d2..c57e68f65e 100644 --- a/x/fungible/client/cli/tx_deploy_system_contracts.go +++ b/x/fungible/client/cli/tx_deploy_system_contracts.go @@ -13,7 +13,7 @@ func CmdDeploySystemContracts() *cobra.Command { Use: "deploy-system-contracts", Short: "Broadcast message SystemContracts", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/fungible/keeper/grpc_query_foreign_coins.go b/x/fungible/keeper/grpc_query_foreign_coins.go index 2688dc6d6b..20c661d7d1 100644 --- a/x/fungible/keeper/grpc_query_foreign_coins.go +++ b/x/fungible/keeper/grpc_query_foreign_coins.go @@ -22,7 +22,7 @@ func (k Keeper) ForeignCoinsAll(c context.Context, req *types.QueryAllForeignCoi store := ctx.KVStore(k.storeKey) foreignCoinsStore := prefix.NewStore(store, types.KeyPrefix(types.ForeignCoinsKeyPrefix)) - pageRes, err := query.Paginate(foreignCoinsStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(foreignCoinsStore, req.Pagination, func(_ []byte, value []byte) error { var foreignCoins types.ForeignCoins if err := k.cdc.Unmarshal(value, &foreignCoins); err != nil { return err diff --git a/x/observer/client/cli/query_blame.go b/x/observer/client/cli/query_blame.go index 462c442279..efe7945a73 100644 --- a/x/observer/client/cli/query_blame.go +++ b/x/observer/client/cli/query_blame.go @@ -47,7 +47,7 @@ func CmdGetAllBlameRecords() *cobra.Command { Use: "list-blame", Short: "Query AllBlameRecords", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_chain_nonce.go b/x/observer/client/cli/query_chain_nonce.go index 8a0a443fca..a5a1ec1cb6 100644 --- a/x/observer/client/cli/query_chain_nonce.go +++ b/x/observer/client/cli/query_chain_nonce.go @@ -13,7 +13,7 @@ func CmdListChainNonces() *cobra.Command { cmd := &cobra.Command{ Use: "list-chain-nonces", Short: "list all chainNonces", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/observer/client/cli/query_chain_params.go b/x/observer/client/cli/query_chain_params.go index 6733c7d5c7..68433ef75e 100644 --- a/x/observer/client/cli/query_chain_params.go +++ b/x/observer/client/cli/query_chain_params.go @@ -46,7 +46,7 @@ func CmdGetChainParams() *cobra.Command { Use: "list-chain-params", Short: "Query GetChainParams", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_keygen.go b/x/observer/client/cli/query_keygen.go index d48fefc34d..85ec112bbe 100644 --- a/x/observer/client/cli/query_keygen.go +++ b/x/observer/client/cli/query_keygen.go @@ -14,7 +14,7 @@ func CmdShowKeygen() *cobra.Command { Use: "show-keygen", Short: "shows keygen", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_node_account.go b/x/observer/client/cli/query_node_account.go index 199cf87e70..51113aaac4 100644 --- a/x/observer/client/cli/query_node_account.go +++ b/x/observer/client/cli/query_node_account.go @@ -13,7 +13,7 @@ func CmdListNodeAccount() *cobra.Command { cmd := &cobra.Command{ Use: "list-node-account", Short: "list all NodeAccount", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/observer/client/cli/query_observers.go b/x/observer/client/cli/query_observers.go index e2c25d2fb0..688b32c6da 100644 --- a/x/observer/client/cli/query_observers.go +++ b/x/observer/client/cli/query_observers.go @@ -12,7 +12,7 @@ func CmdObserverSet() *cobra.Command { Use: "list-observer-set", Short: "Query observer set", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_params.go b/x/observer/client/cli/query_params.go index cb2af7efdf..78508a9443 100644 --- a/x/observer/client/cli/query_params.go +++ b/x/observer/client/cli/query_params.go @@ -14,7 +14,7 @@ func CmdQueryParams() *cobra.Command { Use: "params", Short: "shows the parameters of the module", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_pending_nonces.go b/x/observer/client/cli/query_pending_nonces.go index 0afff149fd..e15abbb893 100644 --- a/x/observer/client/cli/query_pending_nonces.go +++ b/x/observer/client/cli/query_pending_nonces.go @@ -14,7 +14,7 @@ func CmdListPendingNonces() *cobra.Command { Use: "list-pending-nonces", Short: "shows a chainNonces", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_permission_flags.go b/x/observer/client/cli/query_permission_flags.go index 917b47897c..fbd3f3adb5 100644 --- a/x/observer/client/cli/query_permission_flags.go +++ b/x/observer/client/cli/query_permission_flags.go @@ -14,7 +14,7 @@ func CmdShowCrosschainFlags() *cobra.Command { Use: "show-crosschain-flags", Short: "shows the crosschain flags", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_show_observer_count.go b/x/observer/client/cli/query_show_observer_count.go index 84ad22dde1..47240e7a74 100644 --- a/x/observer/client/cli/query_show_observer_count.go +++ b/x/observer/client/cli/query_show_observer_count.go @@ -12,7 +12,7 @@ func CmdShowObserverCount() *cobra.Command { Use: "show-observer-count", Short: "Query show-observer-count", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_supported_chains.go b/x/observer/client/cli/query_supported_chains.go index b4c0181d8c..913a2869ec 100644 --- a/x/observer/client/cli/query_supported_chains.go +++ b/x/observer/client/cli/query_supported_chains.go @@ -13,7 +13,7 @@ func CmdGetSupportedChains() *cobra.Command { cmd := &cobra.Command{ Use: "list-chains", Short: "list all SupportedChains", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_tss.go b/x/observer/client/cli/query_tss.go index 865303d423..aa917125c0 100644 --- a/x/observer/client/cli/query_tss.go +++ b/x/observer/client/cli/query_tss.go @@ -14,7 +14,7 @@ func CmdShowTSS() *cobra.Command { Use: "show-tss", Short: "shows a TSS", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) @@ -40,7 +40,7 @@ func CmdListTssHistory() *cobra.Command { Use: "list-tss-history", Short: "show historical list of TSS", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/tx_add_blame_vote.go b/x/observer/client/cli/tx_add_blame_vote.go index 95d3b0d5da..ea2272332a 100644 --- a/x/observer/client/cli/tx_add_blame_vote.go +++ b/x/observer/client/cli/tx_add_blame_vote.go @@ -71,7 +71,7 @@ func CmdEncode() *cobra.Command { Use: "encode [file.json]", Short: "Encode a json string into hex", Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(_ *cobra.Command, args []string) (err error) { fp := args[0] file, err := filepath.Abs(fp) if err != nil { diff --git a/x/observer/keeper/blame.go b/x/observer/keeper/blame.go index adbbfb0436..63e4c84809 100644 --- a/x/observer/keeper/blame.go +++ b/x/observer/keeper/blame.go @@ -37,7 +37,7 @@ func (k Keeper) GetAllBlame(ctx sdk.Context) (BlameRecords []types.Blame) { func (k Keeper) GetAllBlamePaginated(ctx sdk.Context, pagination *query.PageRequest) (blameRecords []types.Blame, pageRes *query.PageResponse, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlameKey)) - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var blame types.Blame if err := k.cdc.Unmarshal(value, &blame); err != nil { return err diff --git a/x/observer/keeper/grpc_query_block_header.go b/x/observer/keeper/grpc_query_block_header.go index 18e9c955c6..5fb29d3de2 100644 --- a/x/observer/keeper/grpc_query_block_header.go +++ b/x/observer/keeper/grpc_query_block_header.go @@ -23,7 +23,7 @@ func (k Keeper) GetAllBlockHeaders(c context.Context, req *types.QueryAllBlockHe blockHeaderStore := prefix.NewStore(store, types.KeyPrefix(types.BlockHeaderKey)) var blockHeaders []*proofs.BlockHeader - pageRes, err := query.Paginate(blockHeaderStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(blockHeaderStore, req.Pagination, func(_ []byte, value []byte) error { var blockHeader proofs.BlockHeader if err := k.cdc.Unmarshal(value, &blockHeader); err != nil { return err diff --git a/x/observer/keeper/grpc_query_node_account.go b/x/observer/keeper/grpc_query_node_account.go index 2528754448..44aa499757 100644 --- a/x/observer/keeper/grpc_query_node_account.go +++ b/x/observer/keeper/grpc_query_node_account.go @@ -22,7 +22,7 @@ func (k Keeper) NodeAccountAll(c context.Context, req *types.QueryAllNodeAccount store := ctx.KVStore(k.storeKey) nodeAccountStore := prefix.NewStore(store, types.KeyPrefix(types.NodeAccountKey)) - pageRes, err := query.Paginate(nodeAccountStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(nodeAccountStore, req.Pagination, func(_ []byte, value []byte) error { var nodeAccount types.NodeAccount if err := k.cdc.Unmarshal(value, &nodeAccount); err != nil { return err diff --git a/x/observer/keeper/grpc_query_nonces.go b/x/observer/keeper/grpc_query_nonces.go index 7c0b6d481a..80ff3a23b2 100644 --- a/x/observer/keeper/grpc_query_nonces.go +++ b/x/observer/keeper/grpc_query_nonces.go @@ -25,7 +25,7 @@ func (k Keeper) ChainNoncesAll(c context.Context, req *types.QueryAllChainNonces store := ctx.KVStore(k.storeKey) chainNoncesStore := prefix.NewStore(store, types.KeyPrefix(types.ChainNoncesKey)) - pageRes, err := query.Paginate(chainNoncesStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(chainNoncesStore, req.Pagination, func(_ []byte, value []byte) error { var chainNonces types.ChainNonces if err := k.cdc.Unmarshal(value, &chainNonces); err != nil { return err diff --git a/x/observer/keeper/pending_nonces.go b/x/observer/keeper/pending_nonces.go index 198a1219b5..34f241a10e 100644 --- a/x/observer/keeper/pending_nonces.go +++ b/x/observer/keeper/pending_nonces.go @@ -35,7 +35,7 @@ func (k Keeper) GetAllPendingNoncesPaginated(ctx sdk.Context, pagination *query. iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var val types.PendingNonces if err := k.cdc.Unmarshal(value, &val); err != nil { return err diff --git a/x/observer/keeper/tss.go b/x/observer/keeper/tss.go index 0b389d2643..43eaed47c5 100644 --- a/x/observer/keeper/tss.go +++ b/x/observer/keeper/tss.go @@ -81,7 +81,7 @@ func (k Keeper) GetAllTSS(ctx sdk.Context) (list []types.TSS) { func (k Keeper) GetAllTSSPaginated(ctx sdk.Context, pagination *query.PageRequest) (list []types.TSS, pageRes *query.PageResponse, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TSSHistoryKey)) - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var tss types.TSS if err := k.cdc.Unmarshal(value, &tss); err != nil { return err