From 12a09eb2fe43e3e7fdd1d867d48a92f9eddf49d0 Mon Sep 17 00:00:00 2001 From: TimmyExogenous <144751317+TimmyExogenous@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:51:24 +0800 Subject: [PATCH] feat(genesis export): genesis exporting for assets, delegation and operator modules. (#108) * detail the return error for operator info * refine the genesis validation and add implement the genesis exporting in assets module * add genesis exporting for the delegation module * move the isGeneralInit flag to the commandline of starting node * add genesis exporting for operator module * finish genesis exporting for operator module * Remove the isGeneralInit flag that indicates whether the launch is from bootstrap or the exported genesis file. fix the issues caused by rebase * remove the opt in when init dogfood genesis fix the issue from code comments fix the error after rebasing * use panic to address the error when exporting genesis fix the unit tests fix the issue for genesis exporting launch define the common delimiter for combined key,stakerID and assetID. And add the check for the chainID * add a constant ByteLengthForUint64 and fix the issue identified by code comment * fix the issue regarding starting a local node * stop the iteration if the operator address isn't found when exporting genesis state for dogfood * rebase and correct the invalid log printing --- app/app.go | 1 - app/ethtest_helper.go | 52 +- app/test_helpers.go | 63 +- cmd/exocored/root.go | 14 +- cmd/exocored/testnet.go | 61 +- local_node.sh | 30 +- precompiles/assets/tx.go | 2 +- precompiles/avs/query_test.go | 4 +- proto/exocore/assets/v1/genesis.proto | 35 +- proto/exocore/assets/v1/query.proto | 7 +- proto/exocore/assets/v1/tx.proto | 7 +- proto/exocore/delegation/v1/genesis.proto | 34 +- proto/exocore/dogfood/v1/genesis.proto | 2 +- proto/exocore/operator/v1/genesis.proto | 123 +- proto/exocore/operator/v1/tx.proto | 4 +- testutil/utils.go | 197 +- utils/utils.go | 56 + utils/utils_test.go | 30 + .../keeper/client_chain_and_asset_test.go | 21 +- x/assets/keeper/client_chain_asset.go | 10 +- x/assets/keeper/genesis.go | 54 +- x/assets/keeper/keeper.go | 6 +- x/assets/keeper/operator_asset.go | 42 +- x/assets/keeper/staker_asset.go | 42 +- x/assets/keeper/staker_asset_test.go | 33 +- x/assets/types/errors.go | 5 + x/assets/types/general.go | 10 +- x/assets/types/genesis.go | 303 +- x/assets/types/genesis.pb.go | 596 +++- x/assets/types/genesis_test.go | 60 +- x/assets/types/keys.go | 27 +- x/assets/types/query.pb.go | 569 +-- x/assets/types/tx.pb.go | 195 +- x/avs/keeper/avs.go | 5 +- x/avs/keeper/keeper.go | 7 +- x/avs/keeper/query.go | 2 +- x/avs/types/types.go | 5 +- x/delegation/keeper/delegation.go | 4 +- x/delegation/keeper/delegation_state.go | 73 +- x/delegation/keeper/genesis.go | 75 +- x/delegation/keeper/un_delegation_state.go | 27 +- x/delegation/types/errors.go | 5 + x/delegation/types/genesis.go | 304 +- x/delegation/types/genesis.pb.go | 690 +++- x/delegation/types/genesis_test.go | 108 +- x/delegation/types/keys.go | 2 +- x/delegation/types/types/query.pb.go | 1880 ---------- x/delegation/types/types/query.pb.gw.go | 355 -- x/dogfood/keeper/genesis.go | 25 +- x/dogfood/keeper/impl_epochs_hooks.go | 1 + x/dogfood/keeper/impl_epochs_hooks_test.go | 12 +- x/dogfood/keeper/msg_server.go | 2 +- x/dogfood/keeper/opt_out_test.go | 6 +- x/dogfood/keeper/unbonding_test.go | 8 +- x/dogfood/types/expected_keepers.go | 2 +- x/dogfood/types/genesis.go | 8 - x/dogfood/types/genesis.pb.go | 2 +- x/operator/client/cli/tx.go | 16 +- x/operator/keeper/consensus_keys.go | 126 +- x/operator/keeper/genesis.go | 87 +- x/operator/keeper/keeper.go | 9 +- x/operator/keeper/operator.go | 56 +- x/operator/keeper/operator_info_test.go | 21 +- x/operator/keeper/operator_slash_state.go | 27 + x/operator/keeper/opt_test.go | 2 - x/operator/keeper/slash.go | 38 +- x/operator/keeper/slash_test.go | 6 +- x/operator/keeper/usd_value.go | 82 +- x/operator/keeper/usd_value_test.go | 10 +- x/operator/types/expected_keepers.go | 5 +- x/operator/types/genesis.go | 506 ++- x/operator/types/genesis.pb.go | 3114 +++++++++++++++-- x/operator/types/genesis_test.go | 165 +- x/operator/types/keys.go | 98 +- x/operator/types/keys_test.go | 58 + x/operator/types/tx.pb.go | 202 +- x/reward/keeper/claim_reward_test.go | 2 +- x/slash/keeper/execute_slash_test.go | 2 +- 78 files changed, 6865 insertions(+), 4070 deletions(-) delete mode 100644 x/delegation/types/types/query.pb.go delete mode 100644 x/delegation/types/types/query.pb.gw.go create mode 100644 x/operator/types/keys_test.go diff --git a/app/app.go b/app/app.go index f883ecf30..85acd0a81 100644 --- a/app/app.go +++ b/app/app.go @@ -672,7 +672,6 @@ func NewExocoreApp( // to determine whether an AVS is registered or not. app.OperatorKeeper = operatorKeeper.NewKeeper( keys[operatorTypes.StoreKey], appCodec, - bApp.CreateQueryContext, app.AssetsKeeper, &app.DelegationKeeper, // intentionally a pointer, since not yet initialized. &app.OracleKeeper, diff --git a/app/ethtest_helper.go b/app/ethtest_helper.go index afea9ae01..a31e22c0e 100644 --- a/app/ethtest_helper.go +++ b/app/ethtest_helper.go @@ -185,11 +185,10 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, assetstypes.DefaultParams(), clientChains, []assetstypes.StakingAssetInfo{ { - AssetBasicInfo: &assets[0], - // required to be 0, since deposits are handled after token init. - StakingTotalAmount: sdk.ZeroInt(), + AssetBasicInfo: assets[0], + StakingTotalAmount: depositAmount, }, - }, depositsByStaker, + }, depositsByStaker, nil, ) genesisState[assetstypes.ModuleName] = codec.MustMarshalJSON(assetsGenesis) @@ -200,31 +199,26 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, genesisState[oracletypes.ModuleName] = codec.MustMarshalJSON(oracleGenesis) // operator registration - operatorInfos := []operatortypes.OperatorInfo{ + operatorInfos := []operatortypes.OperatorDetail{ { - EarningsAddr: operator.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, } - operatorGenesis := operatortypes.NewGenesisState(operatorInfos) + operatorGenesis := operatortypes.NewGenesisState(operatorInfos, nil, nil, nil, nil, nil, nil, nil) genesisState[operatortypes.ModuleName] = codec.MustMarshalJSON(operatorGenesis) // x/delegation - delegationsByStaker := []delegationtypes.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operator.String()) + delegationStates := []delegationtypes.DelegationStates{ { - StakerID: stakerID, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, - }, + Key: string(singleStateKey), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), }, }, } @@ -234,7 +228,15 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, StakerID: stakerID, }, } - delegationGenesis := delegationtypes.NewGenesis(delegationsByStaker, associations) + stakersByOperator := []delegationtypes.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator.String(), assetID)), + Stakers: []string{ + stakerID, + }, + }, + } + delegationGenesis := delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil) genesisState[delegationtypes.ModuleName] = codec.MustMarshalJSON(delegationGenesis) dogfoodGenesis := dogfoodtypes.NewGenesis( @@ -243,7 +245,7 @@ func genesisStateWithValSet(codec codec.Codec, genesisState simapp.GenesisState, // PublicKey: consensusKeyRecords[0].Chains[0].ConsensusKey, Power: 1, PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), - OperatorAccAddr: operatorInfos[0].EarningsAddr, + OperatorAccAddr: operatorInfos[0].OperatorAddress, }, }, []dogfoodtypes.EpochToOperatorAddrs{}, []dogfoodtypes.EpochToConsensusAddrs{}, diff --git a/app/test_helpers.go b/app/test_helpers.go index a691de689..b59ac2616 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -216,39 +216,50 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, assetstypes.DefaultParams(), clientChains, []assetstypes.StakingAssetInfo{ { - AssetBasicInfo: &assets[0], + AssetBasicInfo: assets[0], // required to be 0, since deposits are handled after token init. StakingTotalAmount: sdk.ZeroInt(), }, }, depositsByStaker, + []assetstypes.AssetsByOperator{ + { + Operator: operator.String(), + AssetsState: []assetstypes.AssetByID{ + { + AssetID: assetID, + Info: assetstypes.OperatorAssetInfo{ + TotalAmount: depositAmount, + PendingUndelegationAmount: math.NewInt(0), + TotalShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), + OperatorShare: math.LegacyNewDec(0), + }, + }, + }, + }, + }, ) genesisState[assetstypes.ModuleName] = app.AppCodec().MustMarshalJSON(assetsGenesis) // operator registration - operatorInfos := []operatortypes.OperatorInfo{ + operatorInfos := []operatortypes.OperatorDetail{ { - EarningsAddr: operator.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, } - operatorGenesis := operatortypes.NewGenesisState(operatorInfos) + operatorGenesis := operatortypes.NewGenesisState(operatorInfos, nil, nil, nil, nil, nil, nil, nil) genesisState[operatortypes.ModuleName] = app.AppCodec().MustMarshalJSON(operatorGenesis) // x/delegation - delegationsByStaker := []delegationtypes.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operator.String()) + delegationStates := []delegationtypes.DelegationStates{ { - StakerID: stakerID, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, - }, + Key: string(singleStateKey), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), }, }, } @@ -258,7 +269,15 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, StakerID: stakerID, }, } - delegationGenesis := delegationtypes.NewGenesis(delegationsByStaker, associations) + stakersByOperator := []delegationtypes.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator.String(), assetID)), + Stakers: []string{ + stakerID, + }, + }, + } + delegationGenesis := delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil) genesisState[delegationtypes.ModuleName] = app.AppCodec().MustMarshalJSON(delegationGenesis) // create a dogfood genesis with just the validator set, that is, the bare @@ -268,7 +287,7 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, { Power: 1, PublicKey: hexutil.Encode(valSet.Validators[0].PubKey.Bytes()), - OperatorAccAddr: operatorInfos[0].EarningsAddr, + OperatorAccAddr: operatorInfos[0].OperatorAddress, }, }, []dogfoodtypes.EpochToOperatorAddrs{}, []dogfoodtypes.EpochToConsensusAddrs{}, diff --git a/cmd/exocored/root.go b/cmd/exocored/root.go index 285fc572a..78d4454df 100644 --- a/cmd/exocored/root.go +++ b/cmd/exocored/root.go @@ -293,7 +293,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a chainID := getChainID(appOpts, home) - evmosApp := app.NewExocoreApp( + exocoreApp := app.NewExocoreApp( logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(sdkserver.FlagInvCheckPeriod)), @@ -313,7 +313,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a baseapp.SetChainID(chainID), ) - return evmosApp + return exocoreApp } // appExport creates a new simapp (optionally at a given height) @@ -328,7 +328,7 @@ func (a appCreator) appExport( appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { - var evmosApp *app.ExocoreApp + var exocoreApp *app.ExocoreApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home not set") @@ -337,24 +337,24 @@ func (a appCreator) appExport( chainID := getChainID(appOpts, homePath) if height != -1 { - evmosApp = app.NewExocoreApp( + exocoreApp = app.NewExocoreApp( logger, db, traceStore, false, map[int64]bool{}, "", uint(1), a.encCfg, appOpts, baseapp.SetChainID(chainID), ) - if err := evmosApp.LoadHeight(height); err != nil { + if err := exocoreApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - evmosApp = app.NewExocoreApp( + exocoreApp = app.NewExocoreApp( logger, db, traceStore, true, map[int64]bool{}, "", uint(1), a.encCfg, appOpts, baseapp.SetChainID(chainID), ) } - return evmosApp.ExportAppStateAndValidators( + return exocoreApp.ExportAppStateAndValidators( forZeroHeight, jailAllowedAddrs, modulesToExport, diff --git a/cmd/exocored/testnet.go b/cmd/exocored/testnet.go index bfae2fdc0..750da69a2 100644 --- a/cmd/exocored/testnet.go +++ b/cmd/exocored/testnet.go @@ -391,8 +391,10 @@ func getTestExocoreGenesis( power := int64(300) depositAmount := sdk.TokensFromConsensusPower(power, evmostypes.PowerReduction) depositsByStaker := []assetstypes.DepositsByStaker{} - operatorInfos := []operatortypes.OperatorInfo{} - delegationsByStaker := []delegationtypes.DelegationsByStaker{} + operatorInfos := []operatortypes.OperatorDetail{} + delegationStates := []delegationtypes.DelegationStates{} + associations := []delegationtypes.StakerToOperator{} + stakersByOperator := []delegationtypes.StakersByOperator{} validators := []dogfoodtypes.GenesisValidator{} for i := range operatorAddrs { operator := operatorAddrs[i] @@ -414,27 +416,33 @@ func getTestExocoreGenesis( }, }, }) - operatorInfos = append(operatorInfos, operatortypes.OperatorInfo{ - EarningsAddr: operator.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission( - sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), - ), + operatorInfos = append(operatorInfos, operatortypes.OperatorDetail{ + OperatorAddress: operator.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission( + sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), + ), + }, }) - delegationsByStaker = append(delegationsByStaker, delegationtypes.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operator.String()) + delegationStates = append(delegationStates, delegationtypes.DelegationStates{ + Key: string(singleStateKey), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), + }, + }, + ) + associations = append(associations, delegationtypes.StakerToOperator{ + Operator: operator.String(), StakerID: stakerID, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, - }, + }) + stakersByOperator = append(stakersByOperator, delegationtypes.StakersByOperator{ + Key: string(assetstypes.GetJoinedStoreKey(operator.String(), assetID)), + Stakers: []string{ + stakerID, }, }) validators = append(validators, dogfoodtypes.GenesisValidator{ @@ -447,17 +455,14 @@ func getTestExocoreGenesis( assetstypes.DefaultParams(), clientChains, []assetstypes.StakingAssetInfo{ { - AssetBasicInfo: &assets[0], + AssetBasicInfo: assets[0], // required to be 0, since deposits are handled after token init. StakingTotalAmount: sdk.ZeroInt(), }, - }, depositsByStaker, + }, depositsByStaker, nil, ), operatortypes.NewGenesisState( - operatorInfos, - ), delegationtypes.NewGenesis( - delegationsByStaker, - nil, - ), dogfoodtypes.NewGenesis( + operatorInfos, nil, nil, nil, nil, nil, nil, nil, + ), delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil), dogfoodtypes.NewGenesis( dogfoodtypes.NewParams( dogfoodtypes.DefaultEpochsUntilUnbonded, dogfoodtypes.DefaultEpochIdentifier, diff --git a/local_node.sh b/local_node.sh index 25b6577f8..8672a38f3 100755 --- a/local_node.sh +++ b/local_node.sh @@ -95,33 +95,41 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq '.app_state["assets"]["client_chains"][0]["address_length"]="20"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["name"]="Tether USD"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["meta_info"]="Tether USD token"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["address"]="0xdAC17F958D2ee523a2206206994597C13D831ec7"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["address"]="0xdac17f958d2ee523a2206206994597c13d831ec7"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["tokens"][0]["asset_basic_info"]["layer_zero_chain_id"]="101"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["assets"]["tokens"][0]["staking_total_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["tokens"][0]["staking_total_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["staker"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["total_deposit_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["withdrawable_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["assets"]["deposits"][0]["deposits"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["operator"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["total_amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["pending_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["total_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["assets"]["operator_assets"][0]["assets_state"][0]["info"]["operator_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/oracle jq '.app_state["oracle"]["params"]["tokens"][1]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["oracle"]["params"]["token_feeders"][1]["start_base_block"]="20"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/operator - jq '.app_state["operator"]["operators"][0]["earnings_addr"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["operator_meta_info"]="operator1"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["commission"]["commission_rates"]["rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["commission"]["commission_rates"]["max_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["operator"]["operators"][0]["commission"]["commission_rates"]["max_change_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_address"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["earnings_addr"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["operator_meta_info"]="operator1"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["max_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["operator"]["operators"][0]["operator_info"]["commission"]["commission_rates"]["max_change_rate"]="0.0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/delegation - jq '.app_state["delegation"]["delegations"][0]["staker_id"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["delegations"][0]["delegations"][0]["asset_id"]="0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["delegations"][0]["delegations"][0]["per_operator_amounts"][0]["key"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["delegation"]["delegations"][0]["delegations"][0]["per_operator_amounts"][0]["value"]["amount"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["key"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65/exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["states"]["undelegatable_share"]="5000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["delegation_states"][0]["states"]["wait_undelegation_amount"]="0"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["delegation"]["associations"][0]["staker_id"]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["delegation"]["associations"][0]["operator"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["stakers_by_operator"][0]["key"]="exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph/0xdac17f958d2ee523a2206206994597c13d831ec7_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["delegation"]["stakers_by_operator"][0]["stakers"][0]="0x3e108c058e8066da635321dc3018294ca82ddedf_0x65"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # x/dogfood # for easy testing, use an epoch of 1 minute and 5 epochs until unbonded. diff --git a/precompiles/assets/tx.go b/precompiles/assets/tx.go index 8a1948803..11ea5f9c5 100644 --- a/precompiles/assets/tx.go +++ b/precompiles/assets/tx.go @@ -143,7 +143,7 @@ func (p Precompile) RegisterToken( } stakingAsset := &assetstypes.StakingAssetInfo{ - AssetBasicInfo: &asset, + AssetBasicInfo: asset, StakingTotalAmount: sdkmath.NewInt(0), } diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index fdb143850..1f204bd1e 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -154,7 +154,7 @@ func (suite *AVSManagerPrecompileSuite) TestAVSUSDValue() { err := suite.App.AssetsKeeper.SetStakingAssetInfo( suite.Ctx, &assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: sdkmath.NewInt(0), }, ) @@ -242,7 +242,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetOperatorOptedUSDValue() { err := suite.App.AssetsKeeper.SetStakingAssetInfo( suite.Ctx, &assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: sdkmath.NewInt(0), }, ) diff --git a/proto/exocore/assets/v1/genesis.proto b/proto/exocore/assets/v1/genesis.proto index cdb6fa033..aad5e3e89 100644 --- a/proto/exocore/assets/v1/genesis.proto +++ b/proto/exocore/assets/v1/genesis.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package exocore.assets.v1; -import "gogoproto/gogo.proto"; - +import "cosmos_proto/cosmos.proto"; import "exocore/assets/v1/params.proto"; import "exocore/assets/v1/tx.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; @@ -27,13 +27,38 @@ message GenesisState { // which contains deposits, withdrawable and unbonding amount. // at genesis (not chain restart), the unbonding amount must be 0. repeated DepositsByStaker deposits = 4 [(gogoproto.nullable) = false]; + + // operator_assets is the list of all operator assets information, indexed + // by the operator address and the asset id. The struct is the `OperatorAssetInfo` + repeated AssetsByOperator operator_assets = 5 [(gogoproto.nullable) = false]; +} + +// AssetsByOperator is a struct to be used in the genesis state. +// It is used to store the operator and its assets state. +message AssetsByOperator { + // operator is the address of the operator,its type should be a sdk.AccAddress + string operator = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // assets_state is the list of assets state, indexed by the asset id. + // The struct is the `OperatorAssetInfo` + repeated AssetByID assets_state = 2 [(gogoproto.nullable) = false]; +} + +// AssetByID is a helper struct to be used in the genesis state. +// It is used to store the asset id and its info for an operator. +// It is named AssetByID (since it is indexed by the assetID) +message AssetByID { + // asset_id is the id of the asset. + string asset_id = 1 [(gogoproto.customname) = "AssetID"]; + // info is the asset info. + OperatorAssetInfo info = 2 [(gogoproto.nullable) = false]; } // DepositByStaker is a helper struct to be used in the genesis state. // It is used to store the staker address and its deposits for each asset ID. message DepositsByStaker { // staker is the address of the staker. - string staker = 1 [ (gogoproto.customname) = "StakerID" ]; + string staker = 1 [(gogoproto.customname) = "StakerID"]; // deposits is the list of deposits, indexed by the asset id. // The struct is the `StakerAssetInfo` which contains deposits, // withdrawable and unbonding amount. @@ -46,9 +71,9 @@ message DepositsByStaker { // and the amount currently unbonding. // It is named DepositByAsset (since it is indexed by the assetID) // and not Deposit to prevent conflict with CrossChainOpType. -message DepositByAsset { +message DepositByAsset { // asset_id is the id of the asset. - string asset_id = 1 [ (gogoproto.customname) = "AssetID" ]; + string asset_id = 1 [(gogoproto.customname) = "AssetID"]; // info is the asset info. StakerAssetInfo info = 2 [(gogoproto.nullable) = false]; } \ No newline at end of file diff --git a/proto/exocore/assets/v1/query.proto b/proto/exocore/assets/v1/query.proto index 14b85f832..a0e69fcf5 100644 --- a/proto/exocore/assets/v1/query.proto +++ b/proto/exocore/assets/v1/query.proto @@ -4,6 +4,7 @@ package exocore.assets.v1; import "cosmos/base/query/v1beta1/pagination.proto"; import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; +import "exocore/assets/v1/genesis.proto"; import "exocore/assets/v1/params.proto"; import "exocore/assets/v1/tx.proto"; import "gogoproto/gogo.proto"; @@ -44,7 +45,7 @@ message QueryAllStakingAssetsInfo {} // indexed by the asset id. message QueryAllStakingAssetsInfoResponse { // all_staking_assets_info is the response for all staking assets info. - map all_staking_assets_info = 1; + repeated StakingAssetInfo all_staking_assets_info = 1 [(gogoproto.nullable) = false]; } // QueryStakerAssetInfo is the query for getting the staker asset info. @@ -56,7 +57,7 @@ message QueryStakerAssetInfo { // QueryAssetInfoResponse is the response for the staker asset info. message QueryAssetInfoResponse { // asset_infos is the response for the staker asset info, indexed by the asset id. - map asset_infos = 1; + repeated DepositByAsset asset_infos = 1 [(gogoproto.nullable) = false]; } // QuerySpecifiedAssetAmountReq is the query for getting the staker specified asset amount. @@ -76,7 +77,7 @@ message QueryOperatorAssetInfos { // QueryOperatorAssetInfosResponse is the response to the operator asset info query. message QueryOperatorAssetInfosResponse { // asset_infos is the response for the operator asset info, indexed by the asset id. - map asset_infos = 1; + repeated AssetByID asset_infos = 1 [(gogoproto.nullable) = false]; } // QueryOperatorSpecifiedAssetAmountReq is the query for getting the operator diff --git a/proto/exocore/assets/v1/tx.proto b/proto/exocore/assets/v1/tx.proto index 5b1585866..a4518e08c 100644 --- a/proto/exocore/assets/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -63,7 +63,7 @@ message AssetInfo { // StakingAssetInfo defines the information for an asset to be used in staking. message StakingAssetInfo { // asset_basic_info is the basic information of the asset. - AssetInfo asset_basic_info = 1; + AssetInfo asset_basic_info = 1[(gogoproto.nullable) = false]; // staking_total_amount is the total amount of the asset staked. string staking_total_amount = 2 [ @@ -110,7 +110,10 @@ message StakerAllAssetsInfo { // OperatorAssetInfo defines the information for a single asset, // for an operator. message OperatorAssetInfo { - // total_amount is the total amount of the asset deposited. + // total_amount is the total amount of the asset deposited, which excludes the + // pending_undelegation_amount. It represent the total delegated amount of asset pool, + // it will be used to calculate the asset amount of a specified staker from its + // delegated share. string total_amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", diff --git a/proto/exocore/delegation/v1/genesis.proto b/proto/exocore/delegation/v1/genesis.proto index fcc70a21d..8f38031b2 100644 --- a/proto/exocore/delegation/v1/genesis.proto +++ b/proto/exocore/delegation/v1/genesis.proto @@ -2,9 +2,9 @@ syntax = "proto3"; package exocore.delegation.v1; -import "gogoproto/gogo.proto"; - +import "exocore/delegation/v1/query.proto"; import "exocore/delegation/v1/tx.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/delegation/types"; @@ -13,10 +13,34 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/delegation/types"; // or in the event of a restart. At this point, it is only built with // the former in mind. There are no params in this module. message GenesisState { - // delegations is a list of all delegations in the system. - repeated DelegationsByStaker delegations = 1 [(gogoproto.nullable) = false]; // associations represents the association between a staker and an operator. - repeated StakerToOperator associations = 2 [(gogoproto.nullable) = false]; + repeated StakerToOperator associations = 1 [(gogoproto.nullable) = false]; + // delegation_states is a list of all delegation states. + repeated DelegationStates delegation_states = 2 [(gogoproto.nullable) = false]; + // stakers_by_operator is a staker list for the operators + repeated StakersByOperator stakers_by_operator = 3 [(gogoproto.nullable) = false]; + // undelegations is a list of all undelegations + repeated UndelegationRecord undelegations = 4 [(gogoproto.nullable) = false]; +} + +// DelegationStates is a helper struct for the delegation state +// used to construct the genesis state +message DelegationStates { + // key is used for storing the delegation states, + // which is a combination of the staker ID, asset ID, and operator address. + string key = 1; + // states is the value of undelegation state for the above key + DelegationAmounts states = 2 [(gogoproto.nullable) = false] ; +} + +// StakersByOperator is a helper struct for an operator's staker list +// used to construct the genesis state +message StakersByOperator { + // key is used for storing the staker list, + // which is a combination of the operator address and the asset ID. + string key = 1; + // stakers is the stakers list for the above key + repeated string stakers = 2 [(gogoproto.nullable) = false] ; } // DelegationsByStaker is a list of delegations for a single staker. diff --git a/proto/exocore/dogfood/v1/genesis.proto b/proto/exocore/dogfood/v1/genesis.proto index 881eba384..4ec5c79eb 100644 --- a/proto/exocore/dogfood/v1/genesis.proto +++ b/proto/exocore/dogfood/v1/genesis.proto @@ -18,7 +18,7 @@ message GenesisState { // params refers to the parameters of the module. Params params = 1 [(gogoproto.nullable) = false]; - // val_set is the initial validator set. it onyl represents the active + // val_set is the initial validator set. it only represents the active // validators. repeated GenesisValidator val_set = 2 [ (gogoproto.nullable) = false ]; diff --git a/proto/exocore/operator/v1/genesis.proto b/proto/exocore/operator/v1/genesis.proto index 3c69fa300..1a304efe3 100644 --- a/proto/exocore/operator/v1/genesis.proto +++ b/proto/exocore/operator/v1/genesis.proto @@ -12,10 +12,129 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; message GenesisState { // there are no params for this module. // operators is a list of the registered operators. - repeated OperatorInfo operators = 1 [(gogoproto.nullable) = false]; - // TODO: add non-chainID AVS opt-in information for exporting / importing. + repeated OperatorDetail operators = 1 [(gogoproto.nullable) = false]; + + // add other information for exporting / importing. // Although it is not necessary for the bootstrapped genesis, it is // necessary for chain restarts. + // operator_records refers to a list of operator records. each record + // contains an operator address and a list of chain id + + // cons key combination. + repeated OperatorConsKeyRecord operator_records = 2 + [(gogoproto.nullable) = false]; + // opt_states is a list of all opted information for the AVS and operators + repeated OptedState opt_states = 3 [(gogoproto.nullable) = false]; + // avs_usd_values is a list of AVS USD value + repeated AVSUSDValue avs_usd_values = 4[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "AVSUSDValues" + ]; + // operator_usd_values is a list of operator USD value + repeated OperatorUSDValue operator_usd_values = 5[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "OperatorUSDValues" + ]; + // slash_states is a list of all slashing information + repeated OperatorSlashState slash_states = 6 [(gogoproto.nullable) = false]; + // pre_cons_key is a list of all previous consensus public key + repeated PrevConsKey pre_cons_keys = 7 [(gogoproto.nullable) = false]; + // operator_key_removal is a list of operator with the given address + // is in the process of unbonding their key for the given chainID. + repeated OperatorKeyRemoval operator_key_removals = 8 [(gogoproto.nullable) = false]; +} + +// OperatorDetail is helper structure to store the operator information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorInfo` +message OperatorDetail { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + string operator_address = 1; + // operator_info is the detail information for the above operator + OperatorInfo operator_info = 2 [(gogoproto.nullable) = false] ; +} + +// OptedStates is helper structure to store the opted state for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorOptedAVSInfo` +message OptedState { + // key is used for storing the opted states, + // which is a combination of the operator address and AVS address. + string key = 1; + // opt_info is the value of undelegation state for the above key + OptedInfo opt_info = 2 [(gogoproto.nullable) = false] ; +} + +// AVSUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForAVS` +message AVSUSDValue { + // avs_addr + string avs_addr = 1[(gogoproto.customname) = "AVSAddr"]; + // value is the USD value for the AVS address + DecValueField value = 2 [(gogoproto.nullable) = false] ; +} + +// OperatorUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForOperator` +message OperatorUSDValue { + // key is used for storing the voting power of specified operator and AVS, + // which is the combination of operator and AVS address. + string key = 1; + // value is the USD value states for the AVS address + OperatorOptedUSDValue opted_usd_value = 2[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "OptedUSDValue" + ] ; +} + +// OperatorSlashState is helper structure to store the slash information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorSlashInfo` +message OperatorSlashState { + // key is used for storing the slash information, + // which is the combination of the operator address, AVS address, and slashID. + string key = 1; + // states is the voting power value for the above key + OperatorSlashInfo info = 2 [(gogoproto.nullable) = false] ; +} + +// PrevConsKey is helper structure to store the previous consensus key +// for the operator and chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorAndChainIDToPrevConsKey` +message PrevConsKey { + // key is used for storing the previous consensus key, + // which is the combination of chainID and operator address. + string key = 1; + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + string consensus_key = 2; +} + +// OperatorKeyRemoval is helper structure to store the operator with the given address +// is in the process of unbonding their key for the given chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorKeyRemovalForChainID` +message OperatorKeyRemoval { + // key is the combination of operator address and chainID. + string key = 1; +} + +// OperatorConsKeyRecord is a helper structure for the genesis state. Each record +// contains an operator address and a list of chain id + cons key combination. +message OperatorConsKeyRecord { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + string operator_address = 1; + // chains is a list of chain id + consensus key combination. + repeated ChainDetails chains = 2 [(gogoproto.nullable) = false]; +} + +// ChainDetails is a helper structure for the genesis state. Each record +// contains a chain id and a consensus key. +message ChainDetails { + // chain_id is the unique identifier of the chain. + string chain_id = 1 [(gogoproto.customname) = "ChainID"]; + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + string consensus_key = 2; } // all operators in the genesis (during bootstrap) are assumed to have diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index d963b207f..71d678d37 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -169,9 +169,9 @@ message SlashExecutionInfo { (gogoproto.nullable) = false ]; // SlashUndelegations records all slash info related to the undelegation - repeated SlashFromUndelegation slash_undelegations = 3; + repeated SlashFromUndelegation slash_undelegations = 3 [(gogoproto.nullable) = false] ; // SlashFromAssetsPool records all slash info related to the assets pool - repeated SlashFromAssetsPool slash_assets_pool = 4; + repeated SlashFromAssetsPool slash_assets_pool = 4 [(gogoproto.nullable) = false] ; } // OperatorSlashInfo is the slash info of operator diff --git a/testutil/utils.go b/testutil/utils.go index c45703e8a..099582bd2 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -4,6 +4,8 @@ import ( "encoding/json" "time" + avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" @@ -75,7 +77,7 @@ func (suite *BaseTestSuite) SetupTest() { // that also act as delegators. func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) - appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, false)() + appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, true)() app, ok := appI.(*exocoreapp.ExocoreApp) suite.Require().True(ok) @@ -105,6 +107,8 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc suite.Powers = []int64{power, power2} depositAmount := math.NewIntWithDecimal(power, 6) depositAmount2 := math.NewIntWithDecimal(power2, 6) + usdValue := math.LegacyNewDec(power) + usdValue2 := math.LegacyNewDec(power2) depositsByStaker := []assetstypes.DepositsByStaker{ { StakerID: stakerID1, @@ -133,6 +137,47 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc }, }, } + operatorAssets := []assetstypes.AssetsByOperator{ + { + Operator: operator1.String(), + AssetsState: []assetstypes.AssetByID{ + { + AssetID: assetID, + Info: assetstypes.OperatorAssetInfo{ + TotalAmount: depositAmount, + PendingUndelegationAmount: sdk.ZeroInt(), + TotalShare: sdk.NewDecFromBigInt(depositAmount.BigInt()), + OperatorShare: sdk.NewDecFromBigInt(depositAmount.BigInt()), + }, + }, + }, + }, + { + Operator: operator2.String(), + AssetsState: []assetstypes.AssetByID{ + { + AssetID: assetID, + Info: assetstypes.OperatorAssetInfo{ + TotalAmount: depositAmount2, + PendingUndelegationAmount: sdk.ZeroInt(), + TotalShare: sdk.NewDecFromBigInt(depositAmount2.BigInt()), + OperatorShare: sdk.NewDecFromBigInt(depositAmount2.BigInt()), + }, + }, + }, + }, + } + assetsGenesis := assetstypes.NewGenesis( + assetstypes.DefaultParams(), + suite.ClientChains, []assetstypes.StakingAssetInfo{ + { + AssetBasicInfo: suite.Assets[0], + StakingTotalAmount: depositAmount.Add(depositAmount2), + }, + }, depositsByStaker, operatorAssets, + ) + genesisState[assetstypes.ModuleName] = app.AppCodec().MustMarshalJSON(assetsGenesis) + // x/oracle initialization oracleDefaultParams := oracletypes.DefaultParams() oracleDefaultParams.Tokens[1].AssetID = "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" @@ -159,29 +204,23 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc } genesisState[oracletypes.ModuleName] = app.AppCodec().MustMarshalJSON(oracleGenesis) - assetsGenesis := assetstypes.NewGenesis( - assetstypes.DefaultParams(), - suite.ClientChains, []assetstypes.StakingAssetInfo{ - { - AssetBasicInfo: &suite.Assets[0], - // required to be 0, since deposits are handled after token init. - StakingTotalAmount: sdk.ZeroInt(), - }, - }, depositsByStaker, - ) - genesisState[assetstypes.ModuleName] = app.AppCodec().MustMarshalJSON(assetsGenesis) - - // operator registration - operatorInfos := []operatortypes.OperatorInfo{ + // x/operator registration + operatorInfos := []operatortypes.OperatorDetail{ { - EarningsAddr: operator1.String(), - OperatorMetaInfo: "operator1", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator1.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator1.String(), + OperatorMetaInfo: "operator1", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, { - EarningsAddr: operator2.String(), - OperatorMetaInfo: "operator2", - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + OperatorAddress: operator2.String(), + OperatorInfo: operatortypes.OperatorInfo{ + EarningsAddr: operator2.String(), + OperatorMetaInfo: "operator2", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, }, } // generate validator private/public key @@ -189,44 +228,90 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc suite.Require().NotNil(pubKey) pubKey2 := testutiltx.GenerateConsensusKey() suite.Require().NotNil(pubKey2) - operatorGenesis := operatortypes.NewGenesisState(operatorInfos) - genesisState[operatortypes.ModuleName] = app.AppCodec().MustMarshalJSON(operatorGenesis) - - // x/delegation - delegationsByStaker := []delegationtypes.DelegationsByStaker{ + chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(utils.DefaultChainID) + operatorConsKeys := []operatortypes.OperatorConsKeyRecord{ { - StakerID: stakerID1, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ + OperatorAddress: operator1.String(), + Chains: []operatortypes.ChainDetails{ { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator1.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount, - }, - }, - }, + ChainID: chainIDWithoutRevision, + ConsensusKey: pubKey.ToHex(), }, }, }, { - StakerID: stakerID2, - Delegations: []delegationtypes.DelegatedSingleAssetInfo{ + OperatorAddress: operator2.String(), + Chains: []operatortypes.ChainDetails{ { - AssetID: assetID, - PerOperatorAmounts: []delegationtypes.KeyValue{ - { - Key: operator2.String(), - Value: &delegationtypes.ValueField{ - Amount: depositAmount2, - }, - }, - }, + ChainID: chainIDWithoutRevision, + ConsensusKey: pubKey2.ToHex(), }, }, }, } + avsAddr := avstypes.GenerateAVSAddr(chainIDWithoutRevision) + optStates := []operatortypes.OptedState{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator1.String(), avsAddr)), + OptInfo: operatortypes.OptedInfo{ + OptedInHeight: 1, + OptedOutHeight: operatortypes.DefaultOptedOutHeight, + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(operator2.String(), avsAddr)), + OptInfo: operatortypes.OptedInfo{ + OptedInHeight: 1, + OptedOutHeight: operatortypes.DefaultOptedOutHeight, + }, + }, + } + operatorUSDValues := []operatortypes.OperatorUSDValue{ + { + Key: string(assetstypes.GetJoinedStoreKey(avsAddr, operator1.String())), + OptedUSDValue: operatortypes.OperatorOptedUSDValue{ + SelfUSDValue: usdValue, + TotalUSDValue: usdValue, + ActiveUSDValue: usdValue, + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(avsAddr, operator2.String())), + OptedUSDValue: operatortypes.OperatorOptedUSDValue{ + SelfUSDValue: usdValue2, + TotalUSDValue: usdValue2, + ActiveUSDValue: usdValue2, + }, + }, + } + avsUSDValues := []operatortypes.AVSUSDValue{ + { + AVSAddr: avsAddr, + Value: operatortypes.DecValueField{ + Amount: usdValue.Add(usdValue2), + }, + }, + } + operatorGenesis := operatortypes.NewGenesisState(operatorInfos, operatorConsKeys, optStates, operatorUSDValues, avsUSDValues, nil, nil, nil) + genesisState[operatortypes.ModuleName] = app.AppCodec().MustMarshalJSON(operatorGenesis) + + // x/delegation + delegationStates := []delegationtypes.DelegationStates{ + { + Key: string(assetstypes.GetJoinedStoreKey(stakerID1, assetID, operator1.String())), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount.BigInt()), + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(stakerID2, assetID, operator2.String())), + States: delegationtypes.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDecFromBigInt(depositAmount2.BigInt()), + }, + }, + } associations := []delegationtypes.StakerToOperator{ { Operator: operator1.String(), @@ -237,7 +322,21 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(genAccs []authtypes.GenesisAc StakerID: stakerID2, }, } - delegationGenesis := delegationtypes.NewGenesis(delegationsByStaker, associations) + stakersByOperator := []delegationtypes.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operator1.String(), assetID)), + Stakers: []string{ + stakerID1, + }, + }, + { + Key: string(assetstypes.GetJoinedStoreKey(operator2.String(), assetID)), + Stakers: []string{ + stakerID2, + }, + }, + } + delegationGenesis := delegationtypes.NewGenesis(associations, delegationStates, stakersByOperator, nil) genesisState[delegationtypes.ModuleName] = app.AppCodec().MustMarshalJSON(delegationGenesis) // create a dogfood genesis with just the validator set, that is, the bare diff --git a/utils/utils.go b/utils/utils.go index fb1672228..a291b6041 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -3,7 +3,11 @@ package utils import ( "strings" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/evmos/evmos/v16/crypto/ethsecp256k1" + "golang.org/x/exp/constraints" + "golang.org/x/xerrors" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -21,6 +25,12 @@ const ( DefaultChainID = MainnetChainID + "-1" // BaseDenom defines the Evmos mainnet denomination BaseDenom = "aexo" + + // DelimiterForCombinedKey is the delimiter used for constructing the combined key. + DelimiterForCombinedKey = "/" + + // DelimiterForID Delimiter used for constructing the stakerID and assetID. + DelimiterForID = "_" ) // IsMainnet returns true if the chain-id has the Evmos mainnet EIP155 chain prefix. @@ -33,6 +43,20 @@ func IsTestnet(chainID string) bool { return strings.HasPrefix(chainID, TestnetChainID) } +func IsValidRevisionChainID(chainID string) bool { + if strings.Contains(chainID, DelimiterForCombinedKey) { + return false + } + return ibcclienttypes.IsRevisionFormat(chainID) +} + +func IsValidChainIDWithoutRevision(chainID string) bool { + if strings.Contains(chainID, DelimiterForCombinedKey) { + return false + } + return !ibcclienttypes.IsRevisionFormat(chainID) +} + // IsSupportedKey returns true if the pubkey type is supported by the chain // (i.e eth_secp256k1, amino multisig, ed25519). // NOTE: Nested multisigs are not supported. @@ -61,6 +85,38 @@ func IsSupportedKey(pubkey cryptotypes.PubKey) bool { } } +// CommonValidation is used to check for duplicates in the input list +// and validate the input information simultaneously. +// It might be used for validating most genesis states. +// slice is the input list +// seenFieldValue return the key used to check for duplicates and the +// value stored for the other validations +// validation is a function to execute customized check for the object +func CommonValidation[T any, V constraints.Ordered, D any]( + slice []T, + seenFieldValue func(T) (V, D), + validation func(int, T) error, +) (map[V]D, error) { + seen := make(map[V]D) + for i := range slice { + v := slice[i] + field, value := seenFieldValue(v) + // check for no duplicated element + if _, ok := seen[field]; ok { + return nil, xerrors.Errorf( + "duplicate element: %v", + field, + ) + } + // perform the validation + if err := validation(i, v); err != nil { + return nil, err + } + seen[field] = value + } + return seen, nil +} + // // GetExocoreAddressFromBech32 returns the sdk.Account address of given address, // // while also changing bech32 human readable prefix (HRP) to the value set on // // the global sdk.Config (eg: `evmos`). diff --git a/utils/utils_test.go b/utils/utils_test.go index 04c2949cb..08007ed55 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -127,3 +127,33 @@ func TestExocoreCoinDenom(t *testing.T) { }) } } + +func TestIsValidChainIDWithoutRevision(t *testing.T) { + testCases := []struct { + name string + chainID string + expResult bool + }{ + { + name: "invalid chainID: include delimiter", + chainID: "exocore/testnet_233", + expResult: false, + }, + { + name: "invalid chainID: include revision", + chainID: "exocoretestnet_233-6", + expResult: false, + }, + { + name: "valid chainID", + chainID: "exocoretestnet_233", + expResult: true, + }, + } + for _, tc := range testCases { + t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { + isInvalid := IsValidChainIDWithoutRevision(tc.chainID) + require.Equal(t, tc.expResult, isInvalid) + }) + } +} diff --git a/x/assets/keeper/client_chain_and_asset_test.go b/x/assets/keeper/client_chain_and_asset_test.go index bc9b18ca2..bad0718c2 100644 --- a/x/assets/keeper/client_chain_and_asset_test.go +++ b/x/assets/keeper/client_chain_and_asset_test.go @@ -23,39 +23,30 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { MetaInfo: "Tether USD token", } stakingInfo := assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdtClientChainAsset, - StakingTotalAmount: math.NewInt(0), + AssetBasicInfo: usdtClientChainAsset, + StakingTotalAmount: math.NewIntWithDecimal(201, 6), } defaultGensisState := assetstype.NewGenesis( assetstype.DefaultParams(), []assetstype.ClientChainInfo{ethClientChain}, []assetstype.StakingAssetInfo{stakingInfo}, []assetstype.DepositsByStaker{}, + nil, ) // test the client chains getting clientChains, err := suite.App.AssetsKeeper.GetAllClientChainInfo(suite.Ctx) suite.NoError(err) - suite.Ctx.Logger().Info("the clientChains is:", "info", clientChains) - for _, clientChain := range defaultGensisState.ClientChains { - suite.Contains(clientChains, clientChain) - } + suite.Contains(clientChains, defaultGensisState.ClientChains[0]) chainInfo, err := suite.App.AssetsKeeper.GetClientChainInfoByIndex(suite.Ctx, 101) suite.NoError(err) - suite.Contains(clientChains, *chainInfo) + suite.Equal(clientChains[0], *chainInfo) // test the client chain assets getting assets, err := suite.App.AssetsKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) - for _, assetX := range defaultGensisState.Tokens { - asset := assetX.AssetBasicInfo - _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) - suite.Ctx.Logger().Info("the asset id is:", "assetID", assetID) - info, ok := assets[assetID] - suite.True(ok) - suite.Equal(asset, info.AssetBasicInfo) - } + suite.Contains(assets, defaultGensisState.Tokens[0]) usdtAssetX := defaultGensisState.Tokens[0] usdtAsset := usdtAssetX.AssetBasicInfo diff --git a/x/assets/keeper/client_chain_asset.go b/x/assets/keeper/client_chain_asset.go index 5886099d0..6e399ca69 100644 --- a/x/assets/keeper/client_chain_asset.go +++ b/x/assets/keeper/client_chain_asset.go @@ -40,6 +40,9 @@ func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *assetstype.StakingAss if info.AssetBasicInfo.Decimals > assetstype.MaxDecimal { return errorsmod.Wrapf(assetstype.ErrInvalidInputParameter, "the decimal is greater than the MaxDecimal,decimal:%v,MaxDecimal:%v", info.AssetBasicInfo.Decimals, assetstype.MaxDecimal) } + if info.StakingTotalAmount.IsNegative() { + return errorsmod.Wrapf(assetstype.ErrInvalidInputParameter, "the total staking amount is negative, StakingTotalAmount:%v", info.StakingTotalAmount) + } store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakingAssetInfo) // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) @@ -85,17 +88,16 @@ func (k Keeper) GetAssetsDecimal(ctx sdk.Context, assets map[string]interface{}) return decimals, nil } -func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) { +func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets []assetstype.StakingAssetInfo, err error) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, assetstype.KeyPrefixReStakingAssetInfo) defer iterator.Close() - ret := make(map[string]*assetstype.StakingAssetInfo, 0) + ret := make([]assetstype.StakingAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { var assetInfo assetstype.StakingAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) - _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainID, "", assetInfo.AssetBasicInfo.Address) - ret[assetID] = &assetInfo + ret = append(ret, assetInfo) } return ret, nil } diff --git a/x/assets/keeper/genesis.go b/x/assets/keeper/genesis.go index 12ce7b949..7a544172a 100644 --- a/x/assets/keeper/genesis.go +++ b/x/assets/keeper/genesis.go @@ -1,6 +1,7 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -15,18 +16,18 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { for i := range data.ClientChains { info := data.ClientChains[i] if err := k.SetClientChainInfo(ctx, &info); err != nil { - panic(err) + panic(errorsmod.Wrap(err, "failed to set client chain info")) } } // client_chain_asset.go for i := range data.Tokens { info := data.Tokens[i] if err := k.SetStakingAssetInfo(ctx, &info); err != nil { - panic(err) + panic(errorsmod.Wrap(err, "failed to set staking asset info")) } } // staker_asset.go (deposits) - // we simulate the behavior of the depositKeeper.Deposit call + // we set the assets state related to deposits // it constructs the stakerID and the assetID, which we have validated previously. // it checks that the deposited amount is not negative, which we have already done. // and that the asset is registered, which we have also already done. @@ -40,21 +41,52 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { if err := k.UpdateStakerAssetState( ctx, stakerID, assetID, infoAsChange, ); err != nil { - panic(err) + panic(errorsmod.Wrap(err, "failed to set deposit info")) } - // now for the asset, increase the deposit value - if err := k.UpdateStakingAssetTotalAmount( - ctx, assetID, info.TotalDepositAmount, - ); err != nil { - panic(err) + } + } + + for _, assets := range data.OperatorAssets { + for _, assetInfo := range assets.AssetsState { + // #nosec G703 // already validated + accAddress, _ := sdk.AccAddressFromBech32(assets.Operator) + infoAsChange := types.DeltaOperatorSingleAsset(assetInfo.Info) + err := k.UpdateOperatorAssetState(ctx, accAddress, assetInfo.AssetID, infoAsChange) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set operator asset info")) } } } } // ExportGenesis returns the module's exported genesis. -func (Keeper) ExportGenesis(sdk.Context) *types.GenesisState { +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { res := types.GenesisState{} - // TODO + var err error + params, err := k.GetParams(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get parameter").Error()) + } + res.Params = *params + + res.ClientChains, err = k.GetAllClientChainInfo(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all client chains").Error()) + } + + res.Tokens, err = k.GetAllStakingAssetsInfo(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all staking assets info").Error()) + } + + res.Deposits, err = k.AllDeposits(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all deposits").Error()) + } + + res.OperatorAssets, err = k.AllOperatorAssets(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all assets info for the operators").Error()) + } return &res } diff --git a/x/assets/keeper/keeper.go b/x/assets/keeper/keeper.go index cc6fcf166..c2477d076 100644 --- a/x/assets/keeper/keeper.go +++ b/x/assets/keeper/keeper.go @@ -47,13 +47,13 @@ type IAssets interface { SetStakingAssetInfo(ctx sdk.Context, info *assetstype.StakingAssetInfo) (err error) GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *assetstype.StakingAssetInfo, err error) - GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) + GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets []assetstype.StakingAssetInfo, err error) - GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerAssetInfo, err error) + GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo []assetstype.DepositByAsset, err error) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerAssetInfo, err error) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount assetstype.DeltaStakerSingleAsset) (err error) - GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorAssetInfo, err error) + GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo []assetstype.AssetByID, err error) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorAssetInfo, err error) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.DeltaOperatorSingleAsset) (err error) PerformDepositOrWithdraw(ctx sdk.Context, params *DepositWithdrawParams) error diff --git a/x/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go index 6168e4f39..0f6a725c2 100644 --- a/x/assets/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -10,10 +10,46 @@ import ( // This file provides all functions about operator assets state management. -func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorAssetInfo, err error) { - ret := make(map[string]*assetstype.OperatorAssetInfo, 0) +// AllOperatorAssets +func (k Keeper) AllOperatorAssets(ctx sdk.Context) (operatorAssets []assetstype.AssetsByOperator, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]assetstype.AssetsByOperator, 0) + var previousOperator string + for ; iterator.Valid(); iterator.Next() { + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + operator, assetID := keyList[0], keyList[1] + if previousOperator != operator { + assetsByOperator := assetstype.AssetsByOperator{ + Operator: operator, + AssetsState: make([]assetstype.AssetByID, 0), + } + ret = append(ret, assetsByOperator) + } + var assetInfo assetstype.OperatorAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) + index := len(ret) - 1 + ret[index].AssetsState = append(ret[index].AssetsState, assetstype.AssetByID{ + AssetID: assetID, + Info: assetInfo, + }) + previousOperator = operator + } + return ret, nil +} + +func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo []assetstype.AssetByID, err error) { + ret := make([]assetstype.AssetByID, 0) opFunc := func(assetID string, state *assetstype.OperatorAssetInfo) error { - ret[assetID] = state + ret = append(ret, assetstype.AssetByID{ + AssetID: assetID, + Info: *state, + }) return nil } err = k.IterateAssetsForOperator(ctx, false, operatorAddr.String(), assetsFilter, opFunc) diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index f7e9cb3fb..0d90d47ce 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -11,12 +11,45 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerAssetInfo, err error) { +// AllDeposits +func (k Keeper) AllDeposits(ctx sdk.Context) (deposits []assetstype.DepositsByStaker, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]assetstype.DepositsByStaker, 0) + var previousStakerID string + for ; iterator.Valid(); iterator.Next() { + var stateInfo assetstype.StakerAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + stakerID, assetID := keyList[0], keyList[1] + if previousStakerID != stakerID { + depositsByStaker := assetstype.DepositsByStaker{ + StakerID: stakerID, + Deposits: make([]assetstype.DepositByAsset, 0), + } + ret = append(ret, depositsByStaker) + } + index := len(ret) - 1 + ret[index].Deposits = append(ret[index].Deposits, assetstype.DepositByAsset{ + AssetID: assetID, + Info: stateInfo, + }) + previousStakerID = stakerID + } + return ret, nil +} + +func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo []assetstype.DepositByAsset, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) iterator := sdk.KVStorePrefixIterator(store, []byte(stakerID)) defer iterator.Close() - ret := make(map[string]*assetstype.StakerAssetInfo, 0) + ret := make([]assetstype.DepositByAsset, 0) for ; iterator.Valid(); iterator.Next() { var stateInfo assetstype.StakerAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) @@ -25,7 +58,10 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInf return nil, err } assetID := keyList[1] - ret[assetID] = &stateInfo + ret = append(ret, assetstype.DepositByAsset{ + AssetID: assetID, + Info: stateInfo, + }) } return ret, nil } diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go index 56843bb21..27e3e72be 100644 --- a/x/assets/keeper/staker_asset_test.go +++ b/x/assets/keeper/staker_asset_test.go @@ -85,12 +85,24 @@ func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUniInitialChangeValue := assetstype.DeltaStakerSingleAsset{ - TotalDepositAmount: math.NewInt(1000), - WithdrawableAmount: math.NewInt(1000), + TotalDepositAmount: math.NewInt(1000), + WithdrawableAmount: math.NewInt(1000), + PendingUndelegationAmount: math.NewInt(0), } ethUsdtInitialChangeValue := assetstype.DeltaStakerSingleAsset{ - TotalDepositAmount: math.NewInt(2000), - WithdrawableAmount: math.NewInt(2000), + TotalDepositAmount: math.NewInt(2000), + WithdrawableAmount: math.NewInt(2000), + PendingUndelegationAmount: math.NewInt(0), + } + assetsInfo := []assetstype.DepositByAsset{ + { + AssetID: ethUniAssetID, + Info: assetstype.StakerAssetInfo(ethUniInitialChangeValue), + }, + { + AssetID: ethUsdtAssetID, + Info: assetstype.StakerAssetInfo(ethUsdtInitialChangeValue), + }, } err := suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) @@ -98,15 +110,8 @@ func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { suite.Require().NoError(err) // test get all assets state of staker - assetsInfo, err := suite.App.AssetsKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) + getAssetsInfo, err := suite.App.AssetsKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) suite.Require().NoError(err) - uniState, isExist := assetsInfo[ethUniAssetID] - suite.Require().True(isExist) - suite.Require().True(uniState.TotalDepositAmount.Equal(math.NewInt(1000))) - suite.Require().True(uniState.WithdrawableAmount.Equal(math.NewInt(1000))) - - usdtState, isExist := assetsInfo[ethUsdtAssetID] - suite.Require().True(isExist) - suite.Require().True(usdtState.TotalDepositAmount.Equal(math.NewInt(2000))) - suite.Require().True(usdtState.WithdrawableAmount.Equal(math.NewInt(2000))) + suite.Contains(getAssetsInfo, assetsInfo[0]) + suite.Contains(getAssetsInfo, assetsInfo[1]) } diff --git a/x/assets/types/errors.go b/x/assets/types/errors.go index 0d8c15354..e65862e6f 100644 --- a/x/assets/types/errors.go +++ b/x/assets/types/errors.go @@ -91,4 +91,9 @@ var ( ErrRegisterDuplicateAssetID = errorsmod.Register( ModuleName, 19, "register new asset with an existing assetID") + + ErrParseJoinedKey = errorsmod.Register( + ModuleName, 20, + "the joined key can't be parsed", + ) ) diff --git a/x/assets/types/general.go b/x/assets/types/general.go index f3c5fd651..bcbd0f8f5 100644 --- a/x/assets/types/general.go +++ b/x/assets/types/general.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/ExocoreNetwork/exocore/utils" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -64,11 +66,11 @@ func GetStakeIDAndAssetID( ) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(clientChainLzID) if stakerAddress != nil { - stakeID = strings.Join([]string{hexutil.Encode(stakerAddress), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(stakerAddress), clientChainLzIDStr}, utils.DelimiterForID) } if assetsAddress != nil { - assetID = strings.Join([]string{hexutil.Encode(assetsAddress), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(assetsAddress), clientChainLzIDStr}, utils.DelimiterForID) } return } @@ -85,14 +87,14 @@ func GetStakeIDAndAssetIDFromStr( if stakerAddress != "" { stakeID = strings.Join( []string{strings.ToLower(stakerAddress), clientChainLzIDStr}, - "_", + utils.DelimiterForID, ) } if assetsAddress != "" { assetID = strings.Join( []string{strings.ToLower(assetsAddress), clientChainLzIDStr}, - "_", + utils.DelimiterForID, ) } return diff --git a/x/assets/types/genesis.go b/x/assets/types/genesis.go index 2b5272bbf..5902d9bd0 100644 --- a/x/assets/types/genesis.go +++ b/x/assets/types/genesis.go @@ -1,7 +1,12 @@ package types import ( + "strings" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/utils" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) @@ -9,12 +14,14 @@ import ( func NewGenesis( params Params, chains []ClientChainInfo, tokens []StakingAssetInfo, deposits []DepositsByStaker, + operatorAssets []AssetsByOperator, ) *GenesisState { return &GenesisState{ - Params: params, - ClientChains: chains, - Tokens: tokens, - Deposits: deposits, + Params: params, + ClientChains: chains, + Tokens: tokens, + Deposits: deposits, + OperatorAssets: operatorAssets, } } @@ -24,28 +31,18 @@ func NewGenesis( // for any unit / integration tests. func DefaultGenesis() *GenesisState { return NewGenesis( - DefaultParams(), []ClientChainInfo{}, []StakingAssetInfo{}, []DepositsByStaker{}, + DefaultParams(), []ClientChainInfo{}, []StakingAssetInfo{}, []DepositsByStaker{}, []AssetsByOperator{}, ) } -// Validate performs basic genesis state validation returning an error -// upon any failure. -func (gs GenesisState) Validate() error { - // client_chain.go -> check no repeat chain - lzIDs := make(map[uint64]struct{}, len(gs.ClientChains)) - for i, info := range gs.ClientChains { - if info.Name == "" || len(info.Name) > MaxChainTokenNameLength { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil Name or too long for chain %d, name:%s, maxLength:%d", - i, info.Name, MaxChainTokenNameLength, - ) - } - if info.MetaInfo == "" || len(info.MetaInfo) > MaxChainTokenMetaInfoLength { +// ValidateClientChains performs basic client chains validation +func (gs GenesisState) ValidateClientChains() (map[uint64]struct{}, error) { + validationFunc := func(i int, info ClientChainInfo) error { + if info.Name == "" { return errorsmod.Wrapf( ErrInvalidGenesisData, - "nil meta info or too long for chain %d, metaInfo:%s, maxLength:%d", - i, info.MetaInfo, MaxChainTokenMetaInfoLength, + "nil Name for chain %d", + i, ) } // this is our primary method of cross-chain communication. @@ -64,95 +61,80 @@ func (gs GenesisState) Validate() error { info.Name, ) } - // check for no duplicated chain, indexed by LayerZeroChainID. - if _, ok := lzIDs[info.LayerZeroChainID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate LayerZeroChainID: %d", - info.LayerZeroChainID, - ) - } - lzIDs[info.LayerZeroChainID] = struct{}{} + return nil } - // client_chain_asset.go -> check presence of client chain - // for all assets and no duplicates - tokens := make(map[string]struct{}, len(gs.Tokens)) - for _, info := range gs.Tokens { - if info.AssetBasicInfo == nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil AssetBasicInfo for token %s", - info.AssetBasicInfo.MetaInfo, - ) - } - if info.AssetBasicInfo.Name == "" || len(info.AssetBasicInfo.Name) > MaxChainTokenNameLength { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil Name or too long for token, name:%s, maxLength:%d", - info.AssetBasicInfo.Name, MaxChainTokenNameLength, - ) - } - if info.AssetBasicInfo.MetaInfo == "" || len(info.AssetBasicInfo.MetaInfo) > MaxChainTokenMetaInfoLength { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil meta info or too long for token, metaInfo:%s, maxLength:%d", - info.AssetBasicInfo.MetaInfo, MaxChainTokenMetaInfoLength, - ) - } + seenFieldValueFunc := func(info ClientChainInfo) (uint64, struct{}) { + return info.LayerZeroChainID, struct{}{} + } + lzIDs, err := utils.CommonValidation(gs.ClientChains, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + return lzIDs, nil +} + +// ValidateTokens performs basic client chain assets validation +func (gs GenesisState) ValidateTokens(lzIDs map[uint64]struct{}) (map[string]math.Int, error) { + validationFunc := func(_ int, info StakingAssetInfo) error { id := info.AssetBasicInfo.LayerZeroChainID // check that the chain is registered if _, ok := lzIDs[id]; !ok { return errorsmod.Wrapf( ErrInvalidGenesisData, - "unknown LayerZeroChainID for token %s: %d", + "unknown LayerZeroChainID for token %s, clientChainID: %d", info.AssetBasicInfo.MetaInfo, id, ) } address := info.AssetBasicInfo.Address + if strings.ToLower(address) != address { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "contains uppercase characters for token %s, address: %s", + info.AssetBasicInfo.Name, address, + ) + } // build for 0x addresses only. // TODO: consider removing this check for non-EVM client chains. if !common.IsHexAddress(address) { return errorsmod.Wrapf( ErrInvalidGenesisData, - "not hex address for token %s: %s", - info.AssetBasicInfo.MetaInfo, address, + "not hex address for token %s, address: %s", + info.AssetBasicInfo.Name, address, ) } - // calculate the asset id. - _, assetID := GetStakeIDAndAssetIDFromStr( - info.AssetBasicInfo.LayerZeroChainID, - "", address, - ) + // ensure there are no deposits for this asset already (since they are handled in the // genesis exec). while it is possible to remove this field entirely (and assume 0), // i did not do so in order to make the genesis state more explicit. - if info.StakingTotalAmount.IsNil() { + if info.StakingTotalAmount.IsNil() || + info.StakingTotalAmount.IsNegative() { return errorsmod.Wrapf( ErrInvalidGenesisData, - "nil staking total amount for asset %s", - assetID, + "nil total staking amount for asset %s", + info.AssetBasicInfo.Address, ) } - if !info.StakingTotalAmount.IsZero() { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "non-zero deposit amount for asset %s", - assetID, - ) - } - // check that it is not a duplicate. - if _, ok := tokens[assetID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate assetID: %s", - assetID, - ) - } - tokens[assetID] = struct{}{} + return nil + } + seenFieldValueFunc := func(info StakingAssetInfo) (string, math.Int) { + // calculate the asset id. + _, assetID := GetStakeIDAndAssetIDFromStr( + info.AssetBasicInfo.LayerZeroChainID, + "", info.AssetBasicInfo.Address, + ) + return assetID, info.StakingTotalAmount } - // staker_asset.go -> check deposits and withdrawals and that there is no unbonding. - stakers := make(map[string]struct{}, len(gs.Deposits)) - for _, depositByStaker := range gs.Deposits { + totalStaking, err := utils.CommonValidation(gs.Tokens, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return totalStaking, nil +} + +// ValidateDeposits performs basic deposits validation +func (gs GenesisState) ValidateDeposits(lzIDs map[uint64]struct{}, tokensTotalStaking map[string]math.Int) error { + validationFunc := func(_ int, depositByStaker DepositsByStaker) error { stakerID := depositByStaker.StakerID // validate the stakerID var stakerClientChainID uint64 @@ -172,23 +154,15 @@ func (gs GenesisState) Validate() error { stakerID, stakerClientChainID, ) } - // check that it is not a duplicate - if _, ok := stakers[stakerID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate stakerID: %s", - stakerID, - ) - } - stakers[stakerID] = struct{}{} - // map to check for duplicate tokens for the staker. - tokensForStaker := make(map[string]struct{}, len(depositByStaker.Deposits)) - for _, deposit := range depositByStaker.Deposits { + + // validate the deposits + depositValidationF := func(_ int, deposit DepositByAsset) error { assetID := deposit.AssetID // check that the asset is registered // no need to check for the validity of the assetID, since // an invalid assetID cannot be in the tokens map. - if _, ok := tokens[assetID]; !ok { + tokenTotalStaking, ok := tokensTotalStaking[assetID] + if !ok { return errorsmod.Wrapf( ErrInvalidGenesisData, "unknown assetID for deposit %s: %s", @@ -207,15 +181,7 @@ func (gs GenesisState) Validate() error { stakerID, assetID, ) } - // check that it is not a duplicate - if _, ok := tokensForStaker[assetID]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate assetID for staker %s: %s", - stakerID, assetID, - ) - } - tokensForStaker[assetID] = struct{}{} + info := deposit.Info // check that there is no nil value provided. if info.TotalDepositAmount.IsNil() || info.WithdrawableAmount.IsNil() || @@ -226,33 +192,132 @@ func (gs GenesisState) Validate() error { assetID, info, ) } - // at genesis (not chain restart), there is no unbonding amount. - if !info.PendingUndelegationAmount.IsZero() { + + // check for negative values. + if info.TotalDepositAmount.IsNegative() || info.WithdrawableAmount.IsNegative() || + info.PendingUndelegationAmount.IsNegative() { return errorsmod.Wrapf( ErrInvalidGenesisData, - "non-zero unbonding amount for %s: %s", - assetID, info.PendingUndelegationAmount, + "negative deposit amount for %s: %+v", + assetID, info, ) } - // check for negative values. - if info.TotalDepositAmount.IsNegative() || info.WithdrawableAmount.IsNegative() { + + if info.TotalDepositAmount.GT(tokenTotalStaking) { return errorsmod.Wrapf( ErrInvalidGenesisData, - "negative deposit amount for %s: %+v", + "invalid deposit amount that is greater than the total staking, assetID: %s: %+v", assetID, info, ) } - // check that the withdrawable amount and the deposited amount are equal. - // this is because this module's genesis only sets up free deposits. - // the delegation module bonds them, thereby altering the withdrawable amount. - if !info.WithdrawableAmount.Equal(info.TotalDepositAmount) { + + if info.PendingUndelegationAmount.Add(info.WithdrawableAmount).GT(info.TotalDepositAmount) { return errorsmod.Wrapf( ErrInvalidGenesisData, - "withdrawable amount is not equal to total deposit amount for %s: %+v", + "the sum of PendingUndelegationAmount and WithdrawableAmount is greater than the TotalDepositAmount, assetID: %s: %+v", assetID, info, ) } + return nil + } + depositFieldValueF := func(deposit DepositByAsset) (string, struct{}) { + return deposit.AssetID, struct{}{} + } + _, err = utils.CommonValidation(depositByStaker.Deposits, depositFieldValueF, depositValidationF) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(deposits DepositsByStaker) (string, struct{}) { + return deposits.StakerID, struct{}{} + } + _, err := utils.CommonValidation(gs.Deposits, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// ValidateOperatorAssets performs basic operator assets validation +func (gs GenesisState) ValidateOperatorAssets(tokensTotalStaking map[string]math.Int) error { + validationFunc := func(_ int, assets AssetsByOperator) error { + _, err := sdk.AccAddressFromBech32(assets.Operator) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid operator address %s: %s", assets.Operator, err, + ) + } + + // validate the assets list for the specified operator + assetValidationFunc := func(_ int, asset AssetByID) error { + // check that the asset is registered + // no need to check for the validity of the assetID, since + // an invalid assetID cannot be in the tokens map. + totalStaking, ok := tokensTotalStaking[asset.AssetID] + if !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown assetID for operator assets %s: %s", + assets.Operator, asset.AssetID, + ) + } + // the sum amount of operators shouldn't be greater than the total staking amount of this asset + if asset.Info.TotalAmount.Add(asset.Info.PendingUndelegationAmount).GT(totalStaking) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "operator's sum amount exceeds the total staking amount for %s: %+v", + assets.Operator, asset, + ) + } + + if asset.Info.OperatorShare.GT(asset.Info.TotalShare) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "operator's share exceeds the total share for %s: %+v", + assets.Operator, asset, + ) + } + return nil + } + assetFieldValueFunc := func(asset AssetByID) (string, struct{}) { + return asset.AssetID, struct{}{} } + _, err = utils.CommonValidation(assets.AssetsState, assetFieldValueFunc, assetValidationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(assets AssetsByOperator) (string, struct{}) { + return assets.Operator, struct{}{} + } + _, err := utils.CommonValidation(gs.OperatorAssets, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// Validate performs basic genesis state validation returning an error +// upon any failure. +func (gs GenesisState) Validate() error { + lzIDs, err := gs.ValidateClientChains() + if err != nil { + return err + } + totalStaking, err := gs.ValidateTokens(lzIDs) + if err != nil { + return err + } + err = gs.ValidateDeposits(lzIDs, totalStaking) + if err != nil { + return err + } + err = gs.ValidateOperatorAssets(totalStaking) + if err != nil { + return err } return gs.Params.Validate() } diff --git a/x/assets/types/genesis.pb.go b/x/assets/types/genesis.pb.go index b4f5a02a9..e3f38ba77 100644 --- a/x/assets/types/genesis.pb.go +++ b/x/assets/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -42,6 +43,9 @@ type GenesisState struct { // which contains deposits, withdrawable and unbonding amount. // at genesis (not chain restart), the unbonding amount must be 0. Deposits []DepositsByStaker `protobuf:"bytes,4,rep,name=deposits,proto3" json:"deposits"` + // operator_assets is the list of all operator assets information, indexed + // by the operator address and the asset id. The struct is the `OperatorAssetInfo` + OperatorAssets []AssetsByOperator `protobuf:"bytes,5,rep,name=operator_assets,json=operatorAssets,proto3" json:"operator_assets"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -105,6 +109,127 @@ func (m *GenesisState) GetDeposits() []DepositsByStaker { return nil } +func (m *GenesisState) GetOperatorAssets() []AssetsByOperator { + if m != nil { + return m.OperatorAssets + } + return nil +} + +// AssetsByOperator is a struct to be used in the genesis state. +// It is used to store the operator and its assets state. +type AssetsByOperator struct { + // operator is the address of the operator,its type should be a sdk.AccAddress + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + // assets_state is the list of assets state, indexed by the asset id. + // The struct is the `OperatorAssetInfo` + AssetsState []AssetByID `protobuf:"bytes,2,rep,name=assets_state,json=assetsState,proto3" json:"assets_state"` +} + +func (m *AssetsByOperator) Reset() { *m = AssetsByOperator{} } +func (m *AssetsByOperator) String() string { return proto.CompactTextString(m) } +func (*AssetsByOperator) ProtoMessage() {} +func (*AssetsByOperator) Descriptor() ([]byte, []int) { + return fileDescriptor_caf4f124d39d82ce, []int{1} +} +func (m *AssetsByOperator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetsByOperator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetsByOperator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AssetsByOperator) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetsByOperator.Merge(m, src) +} +func (m *AssetsByOperator) XXX_Size() int { + return m.Size() +} +func (m *AssetsByOperator) XXX_DiscardUnknown() { + xxx_messageInfo_AssetsByOperator.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetsByOperator proto.InternalMessageInfo + +func (m *AssetsByOperator) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *AssetsByOperator) GetAssetsState() []AssetByID { + if m != nil { + return m.AssetsState + } + return nil +} + +// AssetByID is a helper struct to be used in the genesis state. +// It is used to store the asset id and its info for an operator. +// It is named AssetByID (since it is indexed by the assetID) +type AssetByID struct { + // asset_id is the id of the asset. + AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` + // info is the asset info. + Info OperatorAssetInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` +} + +func (m *AssetByID) Reset() { *m = AssetByID{} } +func (m *AssetByID) String() string { return proto.CompactTextString(m) } +func (*AssetByID) ProtoMessage() {} +func (*AssetByID) Descriptor() ([]byte, []int) { + return fileDescriptor_caf4f124d39d82ce, []int{2} +} +func (m *AssetByID) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetByID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetByID.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AssetByID) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetByID.Merge(m, src) +} +func (m *AssetByID) XXX_Size() int { + return m.Size() +} +func (m *AssetByID) XXX_DiscardUnknown() { + xxx_messageInfo_AssetByID.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetByID proto.InternalMessageInfo + +func (m *AssetByID) GetAssetID() string { + if m != nil { + return m.AssetID + } + return "" +} + +func (m *AssetByID) GetInfo() OperatorAssetInfo { + if m != nil { + return m.Info + } + return OperatorAssetInfo{} +} + // DepositByStaker is a helper struct to be used in the genesis state. // It is used to store the staker address and its deposits for each asset ID. type DepositsByStaker struct { @@ -120,7 +245,7 @@ func (m *DepositsByStaker) Reset() { *m = DepositsByStaker{} } func (m *DepositsByStaker) String() string { return proto.CompactTextString(m) } func (*DepositsByStaker) ProtoMessage() {} func (*DepositsByStaker) Descriptor() ([]byte, []int) { - return fileDescriptor_caf4f124d39d82ce, []int{1} + return fileDescriptor_caf4f124d39d82ce, []int{3} } func (m *DepositsByStaker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -180,7 +305,7 @@ func (m *DepositByAsset) Reset() { *m = DepositByAsset{} } func (m *DepositByAsset) String() string { return proto.CompactTextString(m) } func (*DepositByAsset) ProtoMessage() {} func (*DepositByAsset) Descriptor() ([]byte, []int) { - return fileDescriptor_caf4f124d39d82ce, []int{2} + return fileDescriptor_caf4f124d39d82ce, []int{4} } func (m *DepositByAsset) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -225,6 +350,8 @@ func (m *DepositByAsset) GetInfo() StakerAssetInfo { func init() { proto.RegisterType((*GenesisState)(nil), "exocore.assets.v1.GenesisState") + proto.RegisterType((*AssetsByOperator)(nil), "exocore.assets.v1.AssetsByOperator") + proto.RegisterType((*AssetByID)(nil), "exocore.assets.v1.AssetByID") proto.RegisterType((*DepositsByStaker)(nil), "exocore.assets.v1.DepositsByStaker") proto.RegisterType((*DepositByAsset)(nil), "exocore.assets.v1.DepositByAsset") } @@ -232,33 +359,41 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/genesis.proto", fileDescriptor_caf4f124d39d82ce) } var fileDescriptor_caf4f124d39d82ce = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xb1, 0x8e, 0xda, 0x30, - 0x1c, 0xc6, 0x13, 0x40, 0x81, 0x1a, 0x5a, 0xb5, 0x56, 0x87, 0x34, 0x43, 0x42, 0xd3, 0xaa, 0x62, - 0x4a, 0x0a, 0x1d, 0xba, 0x74, 0x21, 0x80, 0x2a, 0x2a, 0xb5, 0xaa, 0x60, 0xeb, 0x82, 0x42, 0x30, - 0xc1, 0xa2, 0xc4, 0x51, 0xec, 0xe3, 0x60, 0xb8, 0x77, 0xb8, 0x47, 0xb8, 0xc7, 0x61, 0x64, 0xbc, - 0x09, 0x9d, 0xc2, 0x8b, 0x9c, 0x62, 0x9b, 0x3b, 0x8e, 0xc0, 0x66, 0xf9, 0xfb, 0xbe, 0x9f, 0xff, - 0xf9, 0xf2, 0x07, 0x16, 0x5a, 0x91, 0x80, 0x24, 0xc8, 0xf5, 0x29, 0x45, 0x8c, 0xba, 0xcb, 0xa6, - 0x1b, 0xa2, 0x08, 0x51, 0x4c, 0x9d, 0x38, 0x21, 0x8c, 0xc0, 0x77, 0xd2, 0xe0, 0x08, 0x83, 0xb3, - 0x6c, 0x1a, 0xef, 0x43, 0x12, 0x12, 0xae, 0xba, 0xd9, 0x49, 0x18, 0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f0, 0x44, 0x3e, 0x5f, 0x4d, 0x77, 0x56, 0x59, 0xd4, 0xd0, 0x1d, 0x94, 0xb9, 0xd8, 0x9f, - 0xc0, 0x1f, 0xa0, 0x84, 0xa3, 0x29, 0xd1, 0x0b, 0xfc, 0x47, 0xda, 0x17, 0x0a, 0x44, 0xc9, 0x69, - 0x7f, 0x3c, 0xe5, 0xfd, 0xda, 0xa4, 0xa6, 0xba, 0x4d, 0x4d, 0xf5, 0x21, 0x35, 0xd5, 0xdb, 0xbd, - 0xa9, 0x6c, 0xf7, 0xa6, 0x72, 0xbf, 0x37, 0x95, 0x7f, 0x5f, 0x43, 0xcc, 0x66, 0x57, 0x63, 0x27, - 0x20, 0x0b, 0xb7, 0x27, 0x98, 0x7f, 0x10, 0xbb, 0x26, 0xc9, 0xdc, 0x3d, 0x6c, 0xda, 0xea, 0xb0, - 0x6b, 0x6c, 0x1d, 0x23, 0x3a, 0xd6, 0xf8, 0xb2, 0x7d, 0x7b, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xf2, - 0x41, 0x0b, 0xdb, 0xf4, 0x02, 0x00, 0x00, + // 531 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0x6e, 0xd3, 0x4a, + 0x14, 0xc6, 0xe3, 0x34, 0x37, 0x4d, 0x27, 0xb9, 0xa5, 0x8c, 0xba, 0x70, 0x23, 0xe4, 0x14, 0x53, + 0xa1, 0x6e, 0xb0, 0x69, 0x41, 0x62, 0x83, 0x90, 0xe2, 0x24, 0x42, 0x41, 0x82, 0x22, 0x67, 0xc7, + 0xc6, 0x72, 0xed, 0xa9, 0x6b, 0x85, 0x78, 0x2c, 0x9f, 0x21, 0xc4, 0x0b, 0x9e, 0x01, 0x1e, 0x86, + 0x87, 0xe8, 0xb2, 0x62, 0xc5, 0x2a, 0x42, 0xce, 0x2b, 0xf0, 0x00, 0xc8, 0x33, 0xe3, 0x90, 0x26, + 0xb1, 0xc4, 0xce, 0x9e, 0xef, 0x3b, 0xbf, 0x39, 0x7f, 0xe6, 0xa0, 0x0e, 0x99, 0x51, 0x8f, 0x26, + 0xc4, 0x74, 0x01, 0x08, 0x03, 0x73, 0x7a, 0x66, 0x06, 0x24, 0x22, 0x10, 0x82, 0x11, 0x27, 0x94, + 0x51, 0x7c, 0x5f, 0x1a, 0x0c, 0x61, 0x30, 0xa6, 0x67, 0xed, 0x23, 0x8f, 0xc2, 0x84, 0x82, 0xc3, + 0x0d, 0xa6, 0xf8, 0x11, 0xee, 0xb6, 0xb6, 0x89, 0x8b, 0xdd, 0xc4, 0x9d, 0x14, 0x7a, 0x7b, 0x53, + 0x67, 0x33, 0xa9, 0x1d, 0x06, 0x34, 0xa0, 0x82, 0x99, 0x7f, 0x89, 0x53, 0xfd, 0x77, 0x15, 0xb5, + 0x5e, 0x8b, 0x8c, 0x46, 0xcc, 0x65, 0x04, 0xbf, 0x40, 0x75, 0x81, 0x54, 0x95, 0x63, 0xe5, 0xb4, + 0x79, 0x7e, 0x64, 0x6c, 0x64, 0x68, 0xbc, 0xe7, 0x06, 0xab, 0x76, 0x33, 0xef, 0x54, 0x6c, 0x69, + 0xc7, 0x6f, 0xd1, 0xff, 0xde, 0xc7, 0x90, 0x44, 0xcc, 0xf1, 0xae, 0xdd, 0x30, 0x02, 0xb5, 0x7a, + 0xbc, 0x73, 0xda, 0x3c, 0xd7, 0xb7, 0xc4, 0xf7, 0xb8, 0xaf, 0x97, 0xdb, 0x86, 0xd1, 0x15, 0x95, + 0xa0, 0x96, 0xf7, 0xf7, 0x18, 0x70, 0x17, 0xd5, 0x19, 0x1d, 0x93, 0x08, 0xd4, 0x1d, 0xce, 0x79, + 0xb4, 0x85, 0x33, 0x62, 0xee, 0x38, 0x8c, 0x82, 0x6e, 0x7e, 0xb0, 0x02, 0x92, 0x81, 0x78, 0x80, + 0x1a, 0x3e, 0x89, 0x29, 0x84, 0x0c, 0xd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, 0x53, 0xb4, 0x7f, 0xd7, + 0xf1, 0xcf, 0x85, 0xbf, 0xbc, 0x53, 0xb8, 0x5e, 0xf2, 0x36, 0xc9, 0xf6, 0xb2, 0xad, 0x37, 0x37, + 0x99, 0xa6, 0xdc, 0x66, 0x9a, 0xf2, 0x2b, 0xd3, 0x94, 0x6f, 0x0b, 0xad, 0x72, 0xbb, 0xd0, 0x2a, + 0x3f, 0x17, 0x5a, 0xe5, 0xc3, 0xd3, 0x20, 0x64, 0xd7, 0x9f, 0x2e, 0x0d, 0x8f, 0x4e, 0xcc, 0x81, + 0x60, 0xbe, 0x23, 0xec, 0x33, 0x4d, 0xc6, 0x66, 0xb1, 0xda, 0xb3, 0x62, 0xb9, 0x59, 0x1a, 0x13, + 0xb8, 0xac, 0xf3, 0x3d, 0x7e, 0xf6, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x6e, 0x63, 0xe0, 0x6a, + 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -281,6 +416,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.OperatorAssets) > 0 { + for iNdEx := len(m.OperatorAssets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorAssets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } if len(m.Deposits) > 0 { for iNdEx := len(m.Deposits) - 1; iNdEx >= 0; iNdEx-- { { @@ -336,6 +485,90 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AssetsByOperator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AssetsByOperator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetsByOperator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AssetsState) > 0 { + for iNdEx := len(m.AssetsState) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetsState[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AssetByID) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AssetByID) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetByID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AssetID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *DepositsByStaker) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -457,6 +690,46 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.OperatorAssets) > 0 { + for _, e := range m.OperatorAssets { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *AssetsByOperator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.AssetsState) > 0 { + for _, e := range m.AssetsState { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *AssetByID) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AssetID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Info.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -664,6 +937,271 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAssets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAssets = append(m.OperatorAssets, AssetsByOperator{}) + if err := m.OperatorAssets[len(m.OperatorAssets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AssetsByOperator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AssetsByOperator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetsByOperator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetsState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetsState = append(m.AssetsState, AssetByID{}) + if err := m.AssetsState[len(m.AssetsState)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AssetByID) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AssetByID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetByID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/assets/types/genesis_test.go b/x/assets/types/genesis_test.go index f9648f6ee..650ffcbcc 100644 --- a/x/assets/types/genesis_test.go +++ b/x/assets/types/genesis_test.go @@ -1,7 +1,6 @@ package types_test import ( - "fmt" "strings" "testing" @@ -26,8 +25,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { params := types.DefaultParams() params.ExocoreLzAppAddress = "0x0000000000000000000000000000000000000001" newGen := types.NewGenesis( - params, []types.ClientChainInfo{}, - []types.StakingAssetInfo{}, []types.DepositsByStaker{}, + params, nil, + nil, nil, nil, ) // genesis data that is hardcoded for use in the tests ethClientChain := types.ClientChainInfo{ @@ -39,7 +38,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { AddressLength: 20, } // do not hardcode the address to avoid gitleaks complaining. - tokenAddress := utiltx.GenerateAddress().String() + tokenAddress := strings.ToLower(utiltx.GenerateAddress().String()) usdtClientChainAsset := types.AssetInfo{ Name: "Tether USD", Symbol: "USDT", @@ -49,8 +48,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { MetaInfo: "Tether USD token", } stakingInfo := types.StakingAssetInfo{ - AssetBasicInfo: &usdtClientChainAsset, - StakingTotalAmount: math.NewInt(0), + AssetBasicInfo: usdtClientChainAsset, + StakingTotalAmount: math.NewInt(100), } // generated information ethAddress := utiltx.GenerateAddress() @@ -181,25 +180,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, expPass: false, }, - { - name: "invalid genesis due to non zero deposit", - genState: &types.GenesisState{ - Params: types.DefaultParams(), - ClientChains: []types.ClientChainInfo{ - ethClientChain, - }, - Tokens: []types.StakingAssetInfo{ - stakingInfo, - }, - }, - expPass: false, - malleate: func(gs *types.GenesisState) { - gs.Tokens[0].StakingTotalAmount = math.NewInt(1) - }, - unmalleate: func(gs *types.GenesisState) { - gs.Tokens[0].StakingTotalAmount = math.NewInt(0) - }, - }, { name: "invalid genesis due to upper case staker id", genState: &types.GenesisState{ @@ -345,7 +325,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { MetaInfo: "Circle USD token", } stakingInfo := types.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: math.NewInt(0), } gs.Tokens[1] = stakingInfo @@ -411,31 +391,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info }, }, - { - name: "invalid genesis due to non zero unbonding amount for staker", - genState: &types.GenesisState{ - Params: types.DefaultParams(), - ClientChains: []types.ClientChainInfo{ - ethClientChain, - }, - Tokens: []types.StakingAssetInfo{ - stakingInfo, - }, - Deposits: []types.DepositsByStaker{genesisDeposit}, - }, - expPass: false, - malleate: func(gs *types.GenesisState) { - gs.Deposits[0].Deposits[0].Info.PendingUndelegationAmount = math.NewInt(1) - }, - unmalleate: func(gs *types.GenesisState) { - genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ - TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(0), - PendingUndelegationAmount: math.NewInt(0), - } - gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info - }, - }, { name: "invalid genesis due to negative amount for staker", genState: &types.GenesisState{ @@ -481,7 +436,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { unmalleate: func(gs *types.GenesisState) { genesisDeposit.Deposits[0].Info = types.StakerAssetInfo{ TotalDepositAmount: math.NewInt(100), - WithdrawableAmount: math.NewInt(100), + WithdrawableAmount: math.NewInt(0), PendingUndelegationAmount: math.NewInt(0), } gs.Deposits[0].Deposits[0].Info = genesisDeposit.Deposits[0].Info @@ -512,7 +467,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { } err := tc.genState.Validate() if tc.expPass { - fmt.Println("name is:", tc.name) suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) diff --git a/x/assets/types/keys.go b/x/assets/types/keys.go index f3ed3ef8f..b257e9b92 100644 --- a/x/assets/types/keys.go +++ b/x/assets/types/keys.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/ExocoreNetwork/exocore/utils" + errorsmod "cosmossdk.io/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -63,13 +65,6 @@ var ( // or operatorAddr->mapping(AssetID->OperatorAssetInfo) ? KeyPrefixOperatorAssetInfos = []byte{prefixOperatorAssetInfo} - // KeyPrefixOperatorOptedInMiddleWareAssetInfos key->value: - // operatorAddr+'_'+AssetID->mapping(middleWareAddr->struct{}) - // or operatorAddr->mapping(AssetID->mapping(middleWareAddr->struct{})) ? - KeyPrefixOperatorOptedInMiddleWareAssetInfos = []byte{ - prefixOperatorOptedInMiddlewareAssetInfo, - } - // KeyPrefixReStakerExoCoreAddr restakerID = clientChainAddr+'_'+ExoCoreChainIndex // KeyPrefixReStakerExoCoreAddr key-value: restakerID->exoCoreAddr KeyPrefixReStakerExoCoreAddr = []byte{prefixRestakerExocoreAddr} @@ -84,25 +79,29 @@ var ( ) func GetJoinedStoreKey(keys ...string) []byte { - return []byte(strings.Join(keys, "/")) + return []byte(strings.Join(keys, utils.DelimiterForCombinedKey)) } func GetJoinedStoreKeyForPrefix(keys ...string) []byte { - ret := []byte(strings.Join(keys, "/")) - ret = append(ret, '/') + ret := []byte(strings.Join(keys, utils.DelimiterForCombinedKey)) + ret = append(ret, []byte(utils.DelimiterForCombinedKey)...) return ret } func ParseJoinedKey(key []byte) (keys []string, err error) { - stringList := strings.Split(string(key), "/") + stringList := strings.Split(string(key), utils.DelimiterForCombinedKey) return stringList, nil } +func IsJoinedStoreKey(key string) bool { + return strings.Contains(key, utils.DelimiterForCombinedKey) +} + func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { - stringList := strings.Split(string(key), "/") + stringList := strings.Split(string(key), utils.DelimiterForCombinedKey) if len(stringList) != number { return nil, errorsmod.Wrap( - ErrParseAssetsStateKey, + ErrParseJoinedKey, fmt.Sprintf( "expected length:%d,actual length:%d,the stringList is:%v", number, @@ -118,7 +117,7 @@ func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { // It constraints the key to be in the format of "clientAddress_0xid" // The 0xid must be in hex. func ParseID(key string) (string, uint64, error) { - keys := strings.Split(key, "_") + keys := strings.Split(key, utils.DelimiterForID) if len(keys) != 2 { return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("invalid length:%s", key)) } diff --git a/x/assets/types/query.pb.go b/x/assets/types/query.pb.go index 677849520..801360bba 100644 --- a/x/assets/types/query.pb.go +++ b/x/assets/types/query.pb.go @@ -265,7 +265,7 @@ var xxx_messageInfo_QueryAllStakingAssetsInfo proto.InternalMessageInfo // indexed by the asset id. type QueryAllStakingAssetsInfoResponse struct { // all_staking_assets_info is the response for all staking assets info. - AllStakingAssetsInfo map[string]*StakingAssetInfo `protobuf:"bytes,1,rep,name=all_staking_assets_info,json=allStakingAssetsInfo,proto3" json:"all_staking_assets_info,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AllStakingAssetsInfo []StakingAssetInfo `protobuf:"bytes,1,rep,name=all_staking_assets_info,json=allStakingAssetsInfo,proto3" json:"all_staking_assets_info"` } func (m *QueryAllStakingAssetsInfoResponse) Reset() { *m = QueryAllStakingAssetsInfoResponse{} } @@ -301,7 +301,7 @@ func (m *QueryAllStakingAssetsInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllStakingAssetsInfoResponse proto.InternalMessageInfo -func (m *QueryAllStakingAssetsInfoResponse) GetAllStakingAssetsInfo() map[string]*StakingAssetInfo { +func (m *QueryAllStakingAssetsInfoResponse) GetAllStakingAssetsInfo() []StakingAssetInfo { if m != nil { return m.AllStakingAssetsInfo } @@ -357,7 +357,7 @@ func (m *QueryStakerAssetInfo) GetStakerID() string { // QueryAssetInfoResponse is the response for the staker asset info. type QueryAssetInfoResponse struct { // asset_infos is the response for the staker asset info, indexed by the asset id. - AssetInfos map[string]*StakerAssetInfo `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AssetInfos []DepositByAsset `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos"` } func (m *QueryAssetInfoResponse) Reset() { *m = QueryAssetInfoResponse{} } @@ -393,7 +393,7 @@ func (m *QueryAssetInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAssetInfoResponse proto.InternalMessageInfo -func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerAssetInfo { +func (m *QueryAssetInfoResponse) GetAssetInfos() []DepositByAsset { if m != nil { return m.AssetInfos } @@ -504,7 +504,7 @@ func (m *QueryOperatorAssetInfos) GetOperatorAddr() string { // QueryOperatorAssetInfosResponse is the response to the operator asset info query. type QueryOperatorAssetInfosResponse struct { // asset_infos is the response for the operator asset info, indexed by the asset id. - AssetInfos map[string]*OperatorAssetInfo `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AssetInfos []AssetByID `protobuf:"bytes,1,rep,name=asset_infos,json=assetInfos,proto3" json:"asset_infos"` } func (m *QueryOperatorAssetInfosResponse) Reset() { *m = QueryOperatorAssetInfosResponse{} } @@ -540,7 +540,7 @@ func (m *QueryOperatorAssetInfosResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryOperatorAssetInfosResponse proto.InternalMessageInfo -func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorAssetInfo { +func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() []AssetByID { if m != nil { return m.AssetInfos } @@ -787,14 +787,11 @@ func init() { proto.RegisterType((*QueryStakingAssetInfo)(nil), "exocore.assets.v1.QueryStakingAssetInfo") proto.RegisterType((*QueryAllStakingAssetsInfo)(nil), "exocore.assets.v1.QueryAllStakingAssetsInfo") proto.RegisterType((*QueryAllStakingAssetsInfoResponse)(nil), "exocore.assets.v1.QueryAllStakingAssetsInfoResponse") - proto.RegisterMapType((map[string]*StakingAssetInfo)(nil), "exocore.assets.v1.QueryAllStakingAssetsInfoResponse.AllStakingAssetsInfoEntry") proto.RegisterType((*QueryStakerAssetInfo)(nil), "exocore.assets.v1.QueryStakerAssetInfo") proto.RegisterType((*QueryAssetInfoResponse)(nil), "exocore.assets.v1.QueryAssetInfoResponse") - proto.RegisterMapType((map[string]*StakerAssetInfo)(nil), "exocore.assets.v1.QueryAssetInfoResponse.AssetInfosEntry") proto.RegisterType((*QuerySpecifiedAssetAmountReq)(nil), "exocore.assets.v1.QuerySpecifiedAssetAmountReq") proto.RegisterType((*QueryOperatorAssetInfos)(nil), "exocore.assets.v1.QueryOperatorAssetInfos") proto.RegisterType((*QueryOperatorAssetInfosResponse)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse") - proto.RegisterMapType((map[string]*OperatorAssetInfo)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse.AssetInfosEntry") proto.RegisterType((*QueryOperatorSpecifiedAssetAmountReq)(nil), "exocore.assets.v1.QueryOperatorSpecifiedAssetAmountReq") proto.RegisterType((*QueryStakerExCoreAddr)(nil), "exocore.assets.v1.QueryStakerExCoreAddr") proto.RegisterType((*QueryStakerExCoreAddrResponse)(nil), "exocore.assets.v1.QueryStakerExCoreAddrResponse") @@ -805,75 +802,71 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/query.proto", fileDescriptor_1de33a8cf38ccb9d) } var fileDescriptor_1de33a8cf38ccb9d = []byte{ - // 1076 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xa6, 0x34, 0x4d, 0xc7, 0x41, 0xc0, 0xd4, 0xa4, 0xf1, 0xa6, 0xb5, 0xdb, 0xa5, 0x24, - 0xae, 0x15, 0x76, 0x6b, 0x17, 0x94, 0xa6, 0x52, 0x85, 0x9c, 0x34, 0x40, 0x7a, 0x28, 0x65, 0x7b, - 0x00, 0xf5, 0x62, 0x4d, 0xbc, 0x13, 0x77, 0x15, 0x67, 0xc7, 0xd9, 0x59, 0x07, 0x9b, 0x23, 0x12, - 0x12, 0x17, 0x24, 0x24, 0x4e, 0xbd, 0x70, 0xe1, 0x8e, 0x90, 0x40, 0x5c, 0x39, 0x70, 0xe1, 0x58, - 0xc1, 0x01, 0x4e, 0x11, 0x72, 0x90, 0x38, 0xf0, 0x17, 0x70, 0x43, 0x3b, 0x33, 0xf6, 0xfe, 0x9a, - 0x71, 0xb6, 0xf4, 0xe6, 0x9d, 0xf7, 0xeb, 0x7b, 0xdf, 0x7b, 0x33, 0x5f, 0x02, 0x2e, 0xe3, 0x01, - 0x69, 0x13, 0x1f, 0x5b, 0x88, 0x52, 0x1c, 0x50, 0xeb, 0xa8, 0x6e, 0x1d, 0xf6, 0xb1, 0x3f, 0x34, - 0x7b, 0x3e, 0x09, 0x08, 0x7c, 0x45, 0x98, 0x4d, 0x6e, 0x36, 0x8f, 0xea, 0x7a, 0xad, 0x4d, 0xe8, - 0x01, 0xa1, 0xd6, 0x2e, 0xa2, 0x98, 0xfb, 0x5a, 0x47, 0xf5, 0x5d, 0x1c, 0xa0, 0xba, 0xd5, 0x43, - 0x1d, 0xd7, 0x43, 0x81, 0x4b,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f, 0xc2, 0x77, 0x13, 0x4d, 0xcc, - 0xb2, 0x26, 0x56, 0x4f, 0x6d, 0x82, 0xa3, 0x4a, 0x74, 0xf1, 0x36, 0x78, 0x95, 0x35, 0xf1, 0x30, - 0x40, 0xfb, 0xae, 0xd7, 0x69, 0x86, 0x30, 0x18, 0x4d, 0x2b, 0x60, 0x9e, 0x61, 0x6a, 0xb9, 0x0e, - 0x23, 0xe9, 0xfc, 0x66, 0x61, 0x74, 0x5c, 0x39, 0xc7, 0x1d, 0xee, 0xda, 0xe7, 0x98, 0x71, 0xc7, - 0x31, 0x96, 0x41, 0x69, 0xcc, 0x42, 0x3c, 0x07, 0x0d, 0x93, 0x18, 0x4f, 0x66, 0xc1, 0x55, 0xa5, - 0x75, 0xc2, 0xd2, 0x67, 0x1a, 0xb8, 0x18, 0xd2, 0x44, 0xb9, 0x47, 0x8b, 0x73, 0xc1, 0x88, 0x12, - 0x3c, 0xdd, 0x97, 0xf0, 0x74, 0x6a, 0x5e, 0x53, 0x66, 0xdc, 0xf6, 0x02, 0x7f, 0x68, 0x17, 0x91, - 0xc4, 0xa4, 0x77, 0x41, 0x49, 0x19, 0x02, 0x5f, 0x06, 0x67, 0xf6, 0xf1, 0x90, 0x53, 0x61, 0x87, - 0x3f, 0xe1, 0x06, 0x38, 0x7b, 0x84, 0xba, 0x7d, 0x2c, 0xe8, 0x7f, 0x4d, 0x82, 0x31, 0xcd, 0xaa, - 0xcd, 0x23, 0x6e, 0xcf, 0xde, 0xd2, 0x8c, 0xa6, 0xd8, 0xed, 0xd0, 0x07, 0xfb, 0x11, 0xf1, 0xd7, - 0xc1, 0x79, 0xca, 0x8e, 0x22, 0xe6, 0x17, 0x46, 0xc7, 0x95, 0x79, 0xee, 0xb7, 0x73, 0xd7, 0x9e, - 0xe7, 0xe6, 0x1d, 0xc7, 0xf8, 0x5d, 0x03, 0x8b, 0x9c, 0x86, 0x49, 0x81, 0x31, 0xa7, 0x8f, 0x40, - 0x41, 0x8c, 0x2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0x32, 0xab, 0x7b, 0x60, 0x41, 0x70, 0x12, 0xc7, 0xbd, - 0x3a, 0x3a, 0xae, 0x14, 0xb6, 0x07, 0x64, 0xec, 0xae, 0x6c, 0xa3, 0x20, 0x82, 0xd9, 0x6e, 0x14, - 0x01, 0x64, 0xc5, 0x1e, 0x30, 0x19, 0x15, 0x3a, 0x63, 0xbc, 0x07, 0x2e, 0x24, 0x4e, 0x45, 0xe1, - 0x3a, 0x98, 0xe3, 0x72, 0x2b, 0x64, 0xab, 0x24, 0x99, 0x8d, 0x08, 0x11, 0x8e, 0x8d, 0x7f, 0x0b, - 0xe0, 0x2c, 0x4b, 0x05, 0x3f, 0x01, 0x73, 0xdc, 0x06, 0x5f, 0x57, 0xad, 0x55, 0x02, 0x84, 0xbe, - 0x72, 0x9a, 0x1b, 0x47, 0x65, 0x5c, 0xfd, 0xf4, 0xb7, 0xbf, 0xbe, 0x9a, 0x5d, 0x86, 0x25, 0x2b, - 0xab, 0xfe, 0xa2, 0xe2, 0x37, 0x1a, 0x53, 0x89, 0x94, 0x8c, 0x6d, 0x0e, 0x99, 0x58, 0xc3, 0x55, - 0x55, 0xa1, 0x94, 0xbf, 0x9e, 0x43, 0x2e, 0x8d, 0x8d, 0xcf, 0xff, 0xfe, 0xae, 0xa6, 0x31, 0x48, - 0x26, 0x5c, 0x93, 0x40, 0x52, 0xe3, 0xf8, 0x56, 0x63, 0xab, 0x22, 0xf9, 0x9b, 0xa1, 0x36, 0x45, - 0x7f, 0xd2, 0x20, 0x1b, 0xf9, 0x7d, 0x27, 0x14, 0xbe, 0x15, 0x81, 0xae, 0xc1, 0xaa, 0x1c, 0xb4, - 0x04, 0xd6, 0x13, 0x8d, 0xed, 0x49, 0x46, 0xbb, 0xab, 0x2a, 0x08, 0x69, 0x4f, 0x3d, 0x8f, 0x68, - 0x19, 0x37, 0x23, 0x74, 0x55, 0xb8, 0x22, 0x47, 0x97, 0xc1, 0xf0, 0xa3, 0xc6, 0xde, 0x53, 0x99, - 0xa0, 0xc2, 0xb5, 0x67, 0x91, 0x73, 0xfd, 0xcd, 0xff, 0x23, 0xfe, 0xc6, 0x7a, 0x04, 0x7a, 0x0d, - 0xd6, 0x94, 0x94, 0x66, 0xc1, 0x7d, 0x1d, 0x91, 0x8a, 0xe3, 0x22, 0xb0, 0x3a, 0x8d, 0xd4, 0x98, - 0xa7, 0x7e, 0x3d, 0xb7, 0xca, 0xe6, 0x66, 0x36, 0x01, 0xe4, 0x7b, 0x8d, 0x3d, 0x50, 0xfc, 0x5c, - 0xf6, 0xb8, 0x42, 0x4b, 0x09, 0x55, 0xfe, 0x14, 0xeb, 0x39, 0xd4, 0xd9, 0xb8, 0x13, 0x61, 0x6d, - 0xc0, 0x1b, 0xd3, 0xb0, 0x4a, 0x31, 0x89, 0xcb, 0x25, 0x51, 0xd7, 0x5a, 0x7e, 0x95, 0x53, 0x5f, - 0x2e, 0xb5, 0x22, 0xe6, 0xba, 0x5c, 0x12, 0x58, 0x3f, 0x71, 0xd5, 0x9e, 0xa6, 0x62, 0x70, 0xfd, - 0x34, 0x38, 0x2a, 0xc2, 0x73, 0xa9, 0xea, 0x73, 0x52, 0xbe, 0x79, 0xef, 0x97, 0x51, 0x59, 0x7b, - 0x3a, 0x2a, 0x6b, 0x7f, 0x8e, 0xca, 0xda, 0x97, 0x27, 0xe5, 0x99, 0xa7, 0x27, 0xe5, 0x99, 0x3f, - 0x4e, 0xca, 0x33, 0x8f, 0x6e, 0x74, 0xdc, 0xe0, 0x71, 0x7f, 0xd7, 0x6c, 0x93, 0x03, 0x6b, 0x9b, - 0x67, 0xbd, 0x8f, 0x83, 0x8f, 0x89, 0xbf, 0x3f, 0x29, 0x32, 0x18, 0x97, 0x09, 0x86, 0x3d, 0x4c, - 0x77, 0xe7, 0xd8, 0x3f, 0x64, 0x37, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x65, 0xa2, 0xf2, 0x57, - 0x98, 0x0e, 0x00, 0x00, + // 1023 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x97, 0xc1, 0x6f, 0x1b, 0x45, + 0x14, 0xc6, 0xb3, 0xa1, 0xa4, 0xe9, 0x38, 0x1c, 0x98, 0x9a, 0x34, 0xd9, 0xa4, 0x76, 0xb3, 0x94, + 0xc4, 0xb5, 0xc2, 0x6e, 0xed, 0x82, 0x22, 0x0e, 0x15, 0xb2, 0x93, 0x40, 0xdd, 0x03, 0x94, 0xed, + 0x01, 0xc4, 0xc5, 0x8c, 0xbd, 0x93, 0xed, 0x2a, 0xce, 0xce, 0x66, 0x67, 0x12, 0x1c, 0x8e, 0x48, + 0x48, 0x5c, 0x90, 0x90, 0x38, 0x71, 0xe1, 0xc2, 0x1d, 0x21, 0x81, 0xb8, 0x72, 0xe0, 0xd2, 0x63, + 0x05, 0x17, 0x4e, 0x16, 0x72, 0x90, 0xf8, 0x1b, 0xb8, 0x55, 0x3b, 0x33, 0xeb, 0xb5, 0x77, 0x67, + 0x1d, 0x57, 0xb9, 0x65, 0xf7, 0x7d, 0xf3, 0xde, 0xef, 0x7d, 0xb3, 0xf3, 0x26, 0x06, 0x37, 0x71, + 0x9f, 0x74, 0x49, 0x88, 0x2d, 0x44, 0x29, 0x66, 0xd4, 0x3a, 0xad, 0x59, 0xc7, 0x27, 0x38, 0x3c, + 0x33, 0x83, 0x90, 0x30, 0x02, 0x5f, 0x95, 0x61, 0x53, 0x84, 0xcd, 0xd3, 0x9a, 0x5e, 0xed, 0x12, + 0x7a, 0x44, 0xa8, 0xd5, 0x41, 0x14, 0x0b, 0xad, 0x75, 0x5a, 0xeb, 0x60, 0x86, 0x6a, 0x56, 0x80, + 0x5c, 0xcf, 0x47, 0xcc, 0x23, 0xbe, 0x58, 0xae, 0xaf, 0x49, 0x6d, 0x2c, 0x1b, 0xcf, 0xad, 0xaf, + 0x8a, 0x60, 0x9b, 0x3f, 0x59, 0xe2, 0x41, 0x86,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, 0x24, 0x0f, 0x97, + 0xe2, 0x5e, 0xcb, 0x3d, 0x5c, 0x59, 0x6d, 0xfe, 0xe1, 0xca, 0xbf, 0xd5, 0x66, 0x3a, 0x5c, 0x0a, + 0xac, 0xdf, 0xc5, 0xff, 0x93, 0xd3, 0x6e, 0x31, 0xb8, 0x73, 0x11, 0x4e, 0x9e, 0xe1, 0xb7, 0x15, + 0x0b, 0x33, 0x0c, 0x97, 0xb4, 0xbc, 0xf9, 0xf0, 0xe9, 0xb0, 0xa4, 0x3d, 0x1b, 0x96, 0xb4, 0x7f, + 0x86, 0x25, 0xed, 0xdb, 0xf3, 0xd2, 0xdc, 0xb3, 0xf3, 0xd2, 0xdc, 0xdf, 0xe7, 0xa5, 0xb9, 0x4f, + 0xef, 0xba, 0x1e, 0x7b, 0x72, 0xd2, 0x31, 0xbb, 0xe4, 0xc8, 0xda, 0x17, 0x59, 0x3f, 0xc0, 0xec, + 0x73, 0x12, 0x1e, 0x8e, 0x8a, 0xf4, 0xe3, 0x32, 0xec, 0x2c, 0xc0, 0xb4, 0xb3, 0xc0, 0x7f, 0x00, + 0xdc, 0x7b, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x72, 0x6a, 0xe1, 0xc9, 0x29, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1448,27 +1441,15 @@ func (m *QueryAllStakingAssetsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (i var l int _ = l if len(m.AllStakingAssetsInfo) > 0 { - for k := range m.AllStakingAssetsInfo { - v := m.AllStakingAssetsInfo[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + for iNdEx := len(m.AllStakingAssetsInfo) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AllStakingAssetsInfo[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0xa } @@ -1527,27 +1508,15 @@ func (m *QueryAssetInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if len(m.AssetInfos) > 0 { - for k := range m.AssetInfos { - v := m.AssetInfos[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + for iNdEx := len(m.AssetInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0xa } @@ -1643,27 +1612,15 @@ func (m *QueryOperatorAssetInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int var l int _ = l if len(m.AssetInfos) > 0 { - for k := range m.AssetInfos { - v := m.AssetInfos[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + for iNdEx := len(m.AssetInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0xa } @@ -1910,16 +1867,9 @@ func (m *QueryAllStakingAssetsInfoResponse) Size() (n int) { var l int _ = l if len(m.AllStakingAssetsInfo) > 0 { - for k, v := range m.AllStakingAssetsInfo { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + for _, e := range m.AllStakingAssetsInfo { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } return n @@ -1945,16 +1895,9 @@ func (m *QueryAssetInfoResponse) Size() (n int) { var l int _ = l if len(m.AssetInfos) > 0 { - for k, v := range m.AssetInfos { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + for _, e := range m.AssetInfos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } return n @@ -1997,16 +1940,9 @@ func (m *QueryOperatorAssetInfosResponse) Size() (n int) { var l int _ = l if len(m.AssetInfos) > 0 { - for k, v := range m.AssetInfos { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + for _, e := range m.AssetInfos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } return n @@ -2548,105 +2484,10 @@ func (m *QueryAllStakingAssetsInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AllStakingAssetsInfo == nil { - m.AllStakingAssetsInfo = make(map[string]*StakingAssetInfo) - } - var mapkey string - var mapvalue *StakingAssetInfo - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &StakingAssetInfo{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.AllStakingAssetsInfo = append(m.AllStakingAssetsInfo, StakingAssetInfo{}) + if err := m.AllStakingAssetsInfo[len(m.AllStakingAssetsInfo)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.AllStakingAssetsInfo[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -2809,105 +2650,10 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*StakerAssetInfo) - } - var mapkey string - var mapvalue *StakerAssetInfo - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &StakerAssetInfo{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.AssetInfos = append(m.AssetInfos, DepositByAsset{}) + if err := m.AssetInfos[len(m.AssetInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.AssetInfos[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -3184,105 +2930,10 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*OperatorAssetInfo) - } - var mapkey string - var mapvalue *OperatorAssetInfo - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &OperatorAssetInfo{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } + m.AssetInfos = append(m.AssetInfos, AssetByID{}) + if err := m.AssetInfos[len(m.AssetInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.AssetInfos[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/assets/types/tx.pb.go b/x/assets/types/tx.pb.go index 08a0c2961..455286ff2 100644 --- a/x/assets/types/tx.pb.go +++ b/x/assets/types/tx.pb.go @@ -285,7 +285,7 @@ func (m *AssetInfo) GetMetaInfo() string { // StakingAssetInfo defines the information for an asset to be used in staking. type StakingAssetInfo struct { // asset_basic_info is the basic information of the asset. - AssetBasicInfo *AssetInfo `protobuf:"bytes,1,opt,name=asset_basic_info,json=assetBasicInfo,proto3" json:"asset_basic_info,omitempty"` + AssetBasicInfo AssetInfo `protobuf:"bytes,1,opt,name=asset_basic_info,json=assetBasicInfo,proto3" json:"asset_basic_info"` // staking_total_amount is the total amount of the asset staked. StakingTotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=staking_total_amount,json=stakingTotalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"staking_total_amount"` } @@ -323,11 +323,11 @@ func (m *StakingAssetInfo) XXX_DiscardUnknown() { var xxx_messageInfo_StakingAssetInfo proto.InternalMessageInfo -func (m *StakingAssetInfo) GetAssetBasicInfo() *AssetInfo { +func (m *StakingAssetInfo) GetAssetBasicInfo() AssetInfo { if m != nil { return m.AssetBasicInfo } - return nil + return AssetInfo{} } // StakerAssetInfo defines the information for a single asset. @@ -425,7 +425,10 @@ func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerAssetInfo { // OperatorAssetInfo defines the information for a single asset, // for an operator. type OperatorAssetInfo struct { - // total_amount is the total amount of the asset deposited. + // total_amount is the total amount of the asset deposited, which excludes the + // pending_undelegation_amount. It represent the total delegated amount of asset pool, + // it will be used to calculate the asset amount of a specified staker from its + // delegated share. TotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_amount,json=totalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amount"` // pending_undelegation_amount is the amount that is waiting for unbonding. PendingUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=pending_undelegation_amount,json=pendingUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"pending_undelegation_amount"` @@ -832,84 +835,85 @@ func init() { func init() { proto.RegisterFile("exocore/assets/v1/tx.proto", fileDescriptor_adb6ebd423a2c426) } var fileDescriptor_adb6ebd423a2c426 = []byte{ - // 1230 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0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f, 0x9e, - 0x90, 0xc5, 0xb4, 0x81, 0xec, 0x32, 0x9c, 0x39, 0x94, 0x53, 0x96, 0xef, 0xd2, 0x0f, 0x16, 0xf4, - 0xdf, 0xe4, 0x21, 0xfa, 0xc6, 0x82, 0x53, 0xb9, 0xa4, 0xbb, 0xb5, 0xc8, 0x21, 0x90, 0xca, 0xc2, - 0xc9, 0x36, 0x2d, 0x62, 0x16, 0x1f, 0xfc, 0xfa, 0xc7, 0xf7, 0x85, 0xb7, 0xec, 0x0b, 0x4e, 0xb7, - 0x5f, 0x30, 0xce, 0x61, 0xe8, 0xc1, 0x2f, 0x0f, 0x1e, 0x2d, 0x58, 0xab, 0x1f, 0x3e, 0xd9, 0xaf, - 0x5a, 0x4f, 0xf7, 0xab, 0xd6, 0x8b, 0xfd, 0xaa, 0xf5, 0xed, 0xcb, 0x6a, 0xdf, 0xd3, 0x97, 0xd5, - 0xbe, 0xdf, 0x5e, 0x56, 0xfb, 0xee, 0x5c, 0xec, 0x38, 0xed, 0xae, 0x69, 0xc4, 0x8f, 0x88, 0xb8, - 0xc7, 0xd2, 0x9d, 0x56, 0x80, 0xbd, 0x2c, 0x84, 0x3a, 0xfb, 0xea, 0x43, 0xea, 0x77, 0xc7, 0x3b, - 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x15, 0x4d, 0x8c, 0xa1, 0x43, 0x0d, 0x00, 0x00, + // 1234 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x3a, 0xff, 0x5f, 0x9a, 0xc4, 0x99, 0x84, 0xd6, 0x76, 0x5a, 0xa7, 0x5a, 0xa9, 0x10, + 0x45, 0xc4, 0xdb, 0x06, 0x51, 0x4a, 0xca, 0x25, 0x7f, 0x5a, 0x29, 0xa8, 0x05, 0xb4, 0x6e, 0x39, + 0x54, 0x42, 0xab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, 0x81, 0x4f, 0xb1, 0x68, 0xc6, 0xc4, 0x91, 0x92, 0x15, 0xc6, 0x15, 0xc5, 0xe9, 0xce, + 0xec, 0xad, 0x76, 0x83, 0x48, 0x37, 0xec, 0x79, 0x31, 0xe1, 0xdc, 0x09, 0x09, 0xf5, 0x45, 0xbd, + 0x30, 0x71, 0xde, 0x58, 0x9e, 0xb6, 0xa7, 0xf5, 0xec, 0x0d, 0x35, 0x69, 0xfe, 0x6d, 0xc0, 0xe4, + 0x86, 0x6c, 0x83, 0x63, 0xd5, 0x3c, 0x0d, 0x63, 0xbc, 0x1d, 0xd5, 0x58, 0xa8, 0xa5, 0xd4, 0x23, + 0x54, 0x80, 0x71, 0x0d, 0xa5, 0x74, 0x9c, 0xb4, 0xd3, 0x21, 0x2a, 0xc1, 0x84, 0x47, 0xdc, 0x20, + 0xc2, 0x21, 0x57, 0xe2, 0x4d, 0xdb, 0x9d, 0xf1, 0x71, 0x12, 0x8c, 0xfe, 0x2b, 0x09, 0x8e, 0x59, + 0xa8, 0xb1, 0xe3, 0x16, 0x2a, 0xd3, 0x10, 0xe3, 0xd9, 0x86, 0x30, 0x9f, 0x1a, 0x90, 0xaf, 0x0a, + 0xbc, 0x17, 0x50, 0xbf, 0x2b, 0xc4, 0x0d, 0xc8, 0xab, 0xcd, 0xe1, 0xd4, 0x30, 0x0f, 0xdc, 0x24, + 0x50, 0x8a, 0x32, 0xb5, 0x76, 0xb6, 0x72, 0x64, 0x5f, 0x56, 0x3a, 0x71, 0x9b, 0x23, 0xb2, 0xd1, + 0xed, 0x19, 0x65, 0xda, 0x94, 0xa1, 0x0a, 0x8d, 0xc2, 0x02, 0x4f, 0x32, 0x38, 0x82, 0x09, 0x1c, + 0x3a, 0x7a, 0x73, 0xe4, 0x06, 0xb0, 0x39, 0x90, 0x46, 0xbe, 0x25, 0x81, 0x37, 0x92, 0x8d, 0xf2, + 0x57, 0x0e, 0x66, 0x25, 0x25, 0x12, 0x77, 0x19, 0x51, 0x58,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x07, 0xbf, 0xfe, 0xf1, 0x7d, 0xee, 0x2d, + 0xf3, 0x82, 0xd5, 0xef, 0x77, 0x8c, 0x75, 0x18, 0x7a, 0xf4, 0xcb, 0x83, 0x47, 0x2b, 0xc6, 0xe6, + 0x87, 0x4f, 0xf6, 0xcb, 0xc6, 0xd3, 0xfd, 0xb2, 0xf1, 0x62, 0xbf, 0x6c, 0x7c, 0xfb, 0xb2, 0x3c, + 0xf4, 0xf4, 0x65, 0x79, 0xe8, 0xb7, 0x97, 0xe5, 0xa1, 0x3b, 0x17, 0x7b, 0x4e, 0xbb, 0x6b, 0x09, + 0xe2, 0x47, 0x44, 0xdc, 0x63, 0xf1, 0x5e, 0x27, 0x41, 0x2b, 0x4d, 0xa1, 0xce, 0xbe, 0xda, 0x98, + 0xfa, 0xf5, 0xf1, 0xce, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x24, 0xc2, 0xb0, 0x49, 0x0d, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1192,18 +1196,16 @@ func (m *StakingAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - if m.AssetBasicInfo != nil { - { - size, err := m.AssetBasicInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + { + size, err := m.AssetBasicInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1742,10 +1744,8 @@ func (m *StakingAssetInfo) Size() (n int) { } var l int _ = l - if m.AssetBasicInfo != nil { - l = m.AssetBasicInfo.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = m.AssetBasicInfo.Size() + n += 1 + l + sovTx(uint64(l)) l = m.StakingTotalAmount.Size() n += 1 + l + sovTx(uint64(l)) return n @@ -2542,9 +2542,6 @@ func (m *StakingAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AssetBasicInfo == nil { - m.AssetBasicInfo = &AssetInfo{} - } if err := m.AssetBasicInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index fc7fa2774..0ae2b0b18 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -122,7 +122,8 @@ func (k Keeper) RegisterAVSWithChainID( if len(params.ChainID) == 0 { return common.Address{}, errorsmod.Wrap(types.ErrNotNull, "RegisterAVSWithChainID: chainID is null") } - avsAddr = types.GenerateAVSAddr(params.ChainID) + avsAddrStr := types.GenerateAVSAddr(params.ChainID) + avsAddr = common.HexToAddress(avsAddrStr) defer func() { if err == nil { // store the reverse lookup from AVSAddress to ChainID @@ -147,7 +148,7 @@ func (k Keeper) RegisterAVSWithChainID( return common.Address{}, err } // SetAVSInfo expects HexAddress for the AvsAddress - params.AvsAddress = avsAddr.String() + params.AvsAddress = avsAddrStr params.Action = RegisterAction if err := k.UpdateAVSInfo(ctx, params); err != nil { diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 551c02b2b..5a7cd0355 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -290,10 +290,11 @@ func (k *Keeper) IsAVS(ctx sdk.Context, addr string) (bool, error) { // IsAVSByChainID queries whether an AVS exists by chainID. // It returns the AVS address if it exists. -func (k Keeper) IsAVSByChainID(ctx sdk.Context, chainID string) (bool, common.Address) { - avsAddr := types.GenerateAVSAddr(chainID) +func (k Keeper) IsAVSByChainID(ctx sdk.Context, chainID string) (bool, string) { + avsAddrStr := types.GenerateAVSAddr(chainID) + avsAddr := common.HexToAddress(avsAddrStr) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSInfo) - return store.Has(avsAddr.Bytes()), avsAddr + return store.Has(avsAddr.Bytes()), avsAddrStr } func (k Keeper) DeleteAVSInfo(ctx sdk.Context, addr string) error { diff --git a/x/avs/keeper/query.go b/x/avs/keeper/query.go index ff1a7c7be..db70877ce 100644 --- a/x/avs/keeper/query.go +++ b/x/avs/keeper/query.go @@ -26,5 +26,5 @@ func (k Keeper) QueryAVSAddrByChainID(ctx context.Context, req *types.QueryAVSAd if !isChainAvs { return nil, types.ErrNotYetRegistered } - return &types.QueryAVSAddrByChainIDResponse{AVSAddress: avsAddr.String()}, nil + return &types.QueryAVSAddrByChainIDResponse{AVSAddress: avsAddr}, nil } diff --git a/x/avs/types/types.go b/x/avs/types/types.go index 0638ac8cf..6cc3f71b7 100644 --- a/x/avs/types/types.go +++ b/x/avs/types/types.go @@ -82,8 +82,8 @@ func ChainIDWithoutRevision(chainID string) string { // GenerateAVSAddr generates a hex AVS address based on the chainID. // It returns a hex address as a string. -func GenerateAVSAddr(chainID string) common.Address { - return common.BytesToAddress( +func GenerateAVSAddr(chainID string) string { + avsAddr := common.BytesToAddress( crypto.Keccak256( append( ChainIDPrefix, @@ -91,4 +91,5 @@ func GenerateAVSAddr(chainID string) common.Address { ), ), ) + return strings.ToLower(avsAddr.String()) } diff --git a/x/delegation/keeper/delegation.go b/x/delegation/keeper/delegation.go index e73859511..344ccc4c7 100644 --- a/x/delegation/keeper/delegation.go +++ b/x/delegation/keeper/delegation.go @@ -126,7 +126,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *delegationtype.Delegati return err } // record Undelegation event - r := &delegationtype.UndelegationRecord{ + r := delegationtype.UndelegationRecord{ StakerID: stakerID, AssetID: assetID, OperatorAddr: params.OperatorAddress.String(), @@ -138,7 +138,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *delegationtype.Delegati ActualCompletedAmount: removeToken, } r.CompleteBlockNumber = k.operatorKeeper.GetUnbondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) - err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) + err = k.SetUndelegationRecords(ctx, []delegationtype.UndelegationRecord{r}) if err != nil { return err } diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index e55934bce..6a1fb1ae0 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -14,6 +14,33 @@ import ( type DelegationOpFunc func(keys *delegationtype.SingleDelegationInfoReq, amounts *delegationtype.DelegationAmounts) error +func (k Keeper) AllDelegationStates(ctx sdk.Context) (delegationStates []delegationtype.DelegationStates, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]delegationtype.DelegationStates, 0) + for ; iterator.Valid(); iterator.Next() { + var stateInfo delegationtype.DelegationAmounts + k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) + ret = append(ret, delegationtype.DelegationStates{ + Key: string(iterator.Key()), + States: stateInfo, + }) + } + return ret, nil +} + +func (k Keeper) SetAllDelegationStates(ctx sdk.Context, delegationStates []delegationtype.DelegationStates) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + for i := range delegationStates { + singleElement := delegationStates[i] + bz := k.cdc.MustMarshal(&singleElement.States) + store.Set([]byte(singleElement.Key), bz) + } + return nil +} + // IterateDelegationsForStakerAndAsset processes all operations // that require iterating over delegations for a specified staker and asset. func (k Keeper) IterateDelegationsForStakerAndAsset(ctx sdk.Context, stakerID string, assetID string, opFunc DelegationOpFunc) error { @@ -24,7 +51,7 @@ func (k Keeper) IterateDelegationsForStakerAndAsset(ctx sdk.Context, stakerID st for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := delegationtype.ParseStakerAssetIDAndOperatorAddrFromKey(iterator.Key()) + keys, err := delegationtype.ParseStakerAssetIDAndOperator(iterator.Key()) if err != nil { return err } @@ -44,7 +71,7 @@ func (k Keeper) IterateDelegationsForStaker(ctx sdk.Context, stakerID string, op for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := delegationtype.ParseStakerAssetIDAndOperatorAddrFromKey(iterator.Key()) + keys, err := delegationtype.ParseStakerAssetIDAndOperator(iterator.Key()) if err != nil { return err } @@ -249,6 +276,33 @@ func (k *Keeper) GetStakersByOperator(ctx sdk.Context, operator, assetID string) return stakerList, nil } +func (k Keeper) AllStakerList(ctx sdk.Context) (stakerList []delegationtype.StakersByOperator, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixStakersByOperator) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]delegationtype.StakersByOperator, 0) + for ; iterator.Valid(); iterator.Next() { + var stakers delegationtype.StakerList + k.cdc.MustUnmarshal(iterator.Value(), &stakers) + ret = append(ret, delegationtype.StakersByOperator{ + Key: string(iterator.Key()), + Stakers: stakers.Stakers, + }) + } + return ret, nil +} + +func (k Keeper) SetAllStakerList(ctx sdk.Context, stakersByOperator []delegationtype.StakersByOperator) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixStakersByOperator) + for i := range stakersByOperator { + singleElement := stakersByOperator[i] + bz := k.cdc.MustMarshal(&delegationtype.StakerList{Stakers: singleElement.Stakers}) + store.Set([]byte(singleElement.Key), bz) + } + return nil +} + func (k *Keeper) SetStakerShareToZero(ctx sdk.Context, operator, assetID string, stakerList delegationtype.StakerList) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) for _, stakerID := range stakerList.Stakers { @@ -325,3 +379,18 @@ func (k *Keeper) GetAssociatedOperator(ctx sdk.Context, stakerID string) (string } return "", nil } + +func (k *Keeper) GetAllAssociations(ctx sdk.Context) ([]delegationtype.StakerToOperator, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixAssociatedOperatorByStaker) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]delegationtype.StakerToOperator, 0) + for ; iterator.Valid(); iterator.Next() { + ret = append(ret, delegationtype.StakerToOperator{ + StakerID: string(iterator.Key()), + Operator: string(iterator.Value()), + }) + } + return ret, nil +} diff --git a/x/delegation/keeper/genesis.go b/x/delegation/keeper/genesis.go index 3bfd436ed..8e3e35cc3 100644 --- a/x/delegation/keeper/genesis.go +++ b/x/delegation/keeper/genesis.go @@ -15,41 +15,6 @@ func (k Keeper) InitGenesis( ctx sdk.Context, gs delegationtype.GenesisState, ) []abci.ValidatorUpdate { - // TODO(mm): is it possible to parallelize these without using goroutines? - for _, level1 := range gs.Delegations { - stakerID := level1.StakerID - // #nosec G703 // already validated - stakerAddress, lzID, _ := assetstype.ParseID(stakerID) - // we have checked IsHexAddress already - stakerAddressBytes := common.HexToAddress(stakerAddress) - for _, level2 := range level1.Delegations { - assetID := level2.AssetID - // #nosec G703 // already validated - assetAddress, _, _ := assetstype.ParseID(assetID) - // we have checked IsHexAddress already - assetAddressBytes := common.HexToAddress(assetAddress) - for _, level3 := range level2.PerOperatorAmounts { - operator := level3.Key - wrappedAmount := level3.Value - amount := wrappedAmount.Amount - // #nosec G703 // already validated - accAddress, _ := sdk.AccAddressFromBech32(operator) - delegationParams := &delegationtype.DelegationOrUndelegationParams{ - ClientChainID: lzID, - Action: assetstype.DelegateTo, - AssetsAddress: assetAddressBytes.Bytes(), - OperatorAddress: accAddress, - StakerAddress: stakerAddressBytes.Bytes(), - OpAmount: amount, - // the uninitialized members are not used in this context - // they are the LzNonce and TxHash - } - if err := k.delegateTo(ctx, delegationParams, false); err != nil { - panic(errorsmod.Wrap(err, "failed to delegate to operator")) - } - } - } - } for _, association := range gs.Associations { stakerID := association.StakerID operatorAddress := association.Operator @@ -66,12 +31,44 @@ func (k Keeper) InitGenesis( panic(errorsmod.Wrap(err, "failed to associate operator with staker")) } } + + // init the state from the general exporting genesis file + err := k.SetAllDelegationStates(ctx, gs.DelegationStates) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all delegation states")) + } + err = k.SetAllStakerList(ctx, gs.StakersByOperator) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all staker list")) + } + err = k.SetUndelegationRecords(ctx, gs.Undelegations) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all undelegation records")) + } return []abci.ValidatorUpdate{} } // ExportGenesis returns the module's exported genesis -func (Keeper) ExportGenesis(sdk.Context) *delegationtype.GenesisState { - genesis := delegationtype.DefaultGenesis() - // TODO - return genesis +func (k Keeper) ExportGenesis(ctx sdk.Context) *delegationtype.GenesisState { + res := delegationtype.GenesisState{} + var err error + res.Associations, err = k.GetAllAssociations(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all associations").Error()) + } + + res.DelegationStates, err = k.AllDelegationStates(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all delegation states").Error()) + } + res.StakersByOperator, err = k.AllStakerList(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all staker list").Error()) + } + + res.Undelegations, err = k.AllUndelegations(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all undelegations").Error()) + } + return &res } diff --git a/x/delegation/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index 8853817d7..d0b1f72df 100644 --- a/x/delegation/keeper/un_delegation_state.go +++ b/x/delegation/keeper/un_delegation_state.go @@ -13,17 +13,34 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) +func (k Keeper) AllUndelegations(ctx sdk.Context) (undelegations []types.UndelegationRecord, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixUndelegationInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.UndelegationRecord, 0) + for ; iterator.Valid(); iterator.Next() { + var undelegation types.UndelegationRecord + k.cdc.MustUnmarshal(iterator.Value(), &undelegation) + ret = append(ret, undelegation) + } + return ret, nil +} + // SetUndelegationRecords function saves the undelegation records to be handled when the handle time expires. // When we save the undelegation records, we save them in three kv stores which are `KeyPrefixUndelegationInfo` `KeyPrefixStakerUndelegationInfo` and `KeyPrefixPendingUndelegations` -func (k *Keeper) SetUndelegationRecords(ctx sdk.Context, records []*types.UndelegationRecord) error { +func (k *Keeper) SetUndelegationRecords(ctx sdk.Context, records []types.UndelegationRecord) error { singleRecordStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixUndelegationInfo) stakerUndelegationStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixStakerUndelegationInfo) pendingUndelegationStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixPendingUndelegations) - // key := common.HexToAddress(incentive.Contract) - for _, record := range records { - bz := k.cdc.MustMarshal(record) + currentHeight := ctx.BlockHeight() + for i := range records { + record := records[i] + if record.CompleteBlockNumber < uint64(currentHeight) { + return errorsmod.Wrapf(types.ErrInvalidCompletedHeight, "currentHeight:%d,CompleteBlockNumber:%d", currentHeight, record.CompleteBlockNumber) + } + bz := k.cdc.MustMarshal(&record) // todo: check if the following state can only be set once? - singleRecKey := types.GetUndelegationRecordKey(record.BlockNumber, record.LzTxNonce, record.TxHash, record.OperatorAddr) singleRecordStore.Set(singleRecKey, bz) diff --git a/x/delegation/types/errors.go b/x/delegation/types/errors.go index 320b059b9..c9bf63ee8 100644 --- a/x/delegation/types/errors.go +++ b/x/delegation/types/errors.go @@ -79,4 +79,9 @@ var ( ModuleName, 17, "the client chain has not been registered", ) + + ErrInvalidCompletedHeight = errorsmod.Register( + ModuleName, 23, + "the block height to complete the unelegation is invalid", + ) ) diff --git a/x/delegation/types/genesis.go b/x/delegation/types/genesis.go index 947c1c977..749de733e 100644 --- a/x/delegation/types/genesis.go +++ b/x/delegation/types/genesis.go @@ -1,113 +1,68 @@ package types import ( + "encoding/hex" + + "github.com/ExocoreNetwork/exocore/utils" + errorsmod "cosmossdk.io/errors" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "golang.org/x/xerrors" ) // NewGenesis returns a new genesis state with the given inputs. func NewGenesis( - delegations []DelegationsByStaker, associations []StakerToOperator, + delegationStates []DelegationStates, + stakersByOperator []StakersByOperator, + undelegations []UndelegationRecord, ) *GenesisState { return &GenesisState{ - Delegations: delegations, - Associations: associations, + Associations: associations, + DelegationStates: delegationStates, + StakersByOperator: stakersByOperator, + Undelegations: undelegations, } } // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - return NewGenesis(nil, nil) + return NewGenesis(nil, nil, nil, nil) } -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - // TODO(mm): this can be a very big hash table and impact system performance. - // This is likely to be the biggest one amongst the three, and the others - // are garbage collected within the loop anyway. Maybe reordering the genesis - // structure could potentially help with this. - stakers := make(map[string]struct{}, len(gs.Delegations)) - for _, level1 := range gs.Delegations { - stakerID := level1.StakerID - // validate staker ID - var stakerClientChainID uint64 - var err error - if _, stakerClientChainID, err = assetstypes.ValidateID( - stakerID, true, true, - ); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, "invalid staker ID %s: %s", stakerID, err, - ) - } - // check for duplicate stakers - if _, ok := stakers[stakerID]; ok { - return errorsmod.Wrapf(ErrInvalidGenesisData, "duplicate staker ID %s", stakerID) - } - stakers[stakerID] = struct{}{} - assets := make(map[string]struct{}, len(level1.Delegations)) - for _, level2 := range level1.Delegations { - assetID := level2.AssetID - // check for duplicate assets - if _, ok := assets[assetID]; ok { - return errorsmod.Wrapf(ErrInvalidGenesisData, "duplicate asset ID %s", assetID) - } - assets[assetID] = struct{}{} - // validate asset ID - var assetClientChainID uint64 - if _, assetClientChainID, err = assetstypes.ValidateID( - assetID, true, true, - ); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, "invalid asset ID %s: %s", assetID, err, - ) - } - if assetClientChainID != stakerClientChainID { - // a staker from chain A is delegating an asset on chain B, which is not - // something we support right now. - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "asset %s client chain ID %d does not match staker %s client chain ID %d", - assetID, assetClientChainID, stakerID, stakerClientChainID, - ) - } - operators := make(map[string]struct{}, len(level2.PerOperatorAmounts)) - for _, level3 := range level2.PerOperatorAmounts { - operator := level3.Key - wrappedAmount := level3.Value - // check supplied amount - if wrappedAmount == nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, "nil operator amount for operator %s", operator, - ) - } - amount := wrappedAmount.Amount - if amount.IsNil() || amount.IsNegative() { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "invalid operator amount %s for operator %s", amount, operator, - ) - } - // check operator address - if _, err := sdk.AccAddressFromBech32(operator); err != nil { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "invalid operator address for operator %s", operator, - ) - } - // check for duplicate operators - if _, ok := operators[operator]; ok { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "duplicate operator %s for asset %s", operator, assetID, - ) - } - operators[operator] = struct{}{} - } - } +func ValidateIDAndOperator(stakerID, assetID, operator string) error { + // validate the operator address + if _, err := sdk.AccAddressFromBech32(operator); err != nil { + return xerrors.Errorf( + "ValidateIDAndOperator: invalid operator address for operator %s", operator, + ) } + _, stakerClientChainID, err := assetstypes.ValidateID(stakerID, true, false) + if err != nil { + return xerrors.Errorf( + "ValidateIDAndOperator: invalid stakerID: %s", + stakerID, + ) + } + _, assetClientChainID, err := assetstypes.ValidateID(assetID, true, false) + if err != nil { + return xerrors.Errorf( + "ValidateIDAndOperator: invalid assetID: %s", + assetID, + ) + } + if stakerClientChainID != assetClientChainID { + return xerrors.Errorf( + "ValidateIDAndOperator: the client chain layerZero IDs of the staker and asset are different, stakerID:%s, assetID:%s", + stakerID, assetID) + } + return nil +} + +func (gs GenesisState) ValidateAssociations() error { // for associations, one stakerID can be associated only with one operator. // but one operator may have multiple stakerIDs associated with it. associatedStakerIDs := make(map[string]struct{}, len(gs.Associations)) @@ -140,3 +95,174 @@ func (gs GenesisState) Validate() error { } return nil } + +func (gs GenesisState) ValidateDelegationStates() error { + validationFunc := func(_ int, info DelegationStates) error { + keys, err := ParseStakerAssetIDAndOperator([]byte(info.Key)) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + err = ValidateIDAndOperator(keys.StakerID, keys.AssetID, keys.OperatorAddr) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + // check that there is no nil value provided. + if info.States.UndelegatableShare.IsNil() || info.States.WaitUndelegationAmount.IsNil() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "nil delegation state for %s: %+v", + info.Key, info, + ) + } + + // check for negative values. + if info.States.UndelegatableShare.IsNegative() || info.States.WaitUndelegationAmount.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "negative delegation state for %s: %+v", + info.Key, info, + ) + } + + return nil + } + seenFieldValueFunc := func(info DelegationStates) (string, struct{}) { + return info.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.DelegationStates, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateStakerList() error { + validationFunc := func(_ int, stakersByOperator StakersByOperator) error { + // validate the key + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(stakersByOperator.Key), 2) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + // validate the operator address + if _, err := sdk.AccAddressFromBech32(stringList[0]); err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid operator address for operator %s", stringList[0], + ) + } + // validate the assetID + _, assetClientChainID, err := assetstypes.ValidateID(stringList[1], true, false) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid assetID: %s", + stringList[1], + ) + } + // validate the staker list + stakerValidationFunc := func(_ int, stakerID string) error { + _, stakerClientChainID, err := assetstypes.ValidateID(stakerID, true, false) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid stakerID: %s", + stakerID, + ) + } + if stakerClientChainID != assetClientChainID { + return errorsmod.Wrapf(ErrInvalidGenesisData, "the client chain layerZero IDs of the staker and asset are different,key:%s stakerID:%s", stakersByOperator.Key, stakerID) + } + return nil + } + seenStakerFunc := func(stakerID string) (string, struct{}) { + return stakerID, struct{}{} + } + _, err = utils.CommonValidation(stakersByOperator.Stakers, seenStakerFunc, stakerValidationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(info StakersByOperator) (string, struct{}) { + return info.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.StakersByOperator, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateUndelegations() error { + validationFunc := func(_ int, undelegation UndelegationRecord) error { + err := ValidateIDAndOperator(undelegation.StakerID, undelegation.AssetID, undelegation.OperatorAddr) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + + bytes, err := hex.DecodeString(undelegation.TxHash) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "TxHash isn't a hex string, TxHash: %s", + undelegation.TxHash, + ) + } + if len(bytes) != common.HashLength { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "invalid length of TxHash ,TxHash:%s length: %d, should:%d", + undelegation.TxHash, len(bytes), common.HashLength, + ) + } + if !undelegation.IsPending { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "all undelegations should be pending, undelegation:%v", + undelegation, + ) + } + if undelegation.CompleteBlockNumber < undelegation.BlockNumber { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "the block number to complete shouldn't be less than the submitted , undelegation:%v", + undelegation, + ) + } + if undelegation.ActualCompletedAmount.GT(undelegation.Amount) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, "the completed amount shouldn't be greater than the submitted amount , undelegation:%v", + undelegation, + ) + } + return nil + } + seenFieldValueFunc := func(undelegation UndelegationRecord) (string, struct{}) { + return undelegation.TxHash, struct{}{} + } + _, err := utils.CommonValidation(gs.Undelegations, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + err := gs.ValidateAssociations() + if err != nil { + return err + } + err = gs.ValidateDelegationStates() + if err != nil { + return err + } + err = gs.ValidateStakerList() + if err != nil { + return err + } + err = gs.ValidateUndelegations() + if err != nil { + return err + } + return nil +} diff --git a/x/delegation/types/genesis.pb.go b/x/delegation/types/genesis.pb.go index 713674d2d..8964ed1db 100644 --- a/x/delegation/types/genesis.pb.go +++ b/x/delegation/types/genesis.pb.go @@ -28,10 +28,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // or in the event of a restart. At this point, it is only built with // the former in mind. There are no params in this module. type GenesisState struct { - // delegations is a list of all delegations in the system. - Delegations []DelegationsByStaker `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // associations represents the association between a staker and an operator. - Associations []StakerToOperator `protobuf:"bytes,2,rep,name=associations,proto3" json:"associations"` + Associations []StakerToOperator `protobuf:"bytes,1,rep,name=associations,proto3" json:"associations"` + // delegation_states is a list of all delegation states. + DelegationStates []DelegationStates `protobuf:"bytes,2,rep,name=delegation_states,json=delegationStates,proto3" json:"delegation_states"` + // stakers_by_operator is a staker list for the operators + StakersByOperator []StakersByOperator `protobuf:"bytes,3,rep,name=stakers_by_operator,json=stakersByOperator,proto3" json:"stakers_by_operator"` + // undelegations is a list of all undelegations + Undelegations []UndelegationRecord `protobuf:"bytes,4,rep,name=undelegations,proto3" json:"undelegations"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -67,23 +71,151 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetDelegations() []DelegationsByStaker { +func (m *GenesisState) GetAssociations() []StakerToOperator { if m != nil { - return m.Delegations + return m.Associations } return nil } -func (m *GenesisState) GetAssociations() []StakerToOperator { +func (m *GenesisState) GetDelegationStates() []DelegationStates { if m != nil { - return m.Associations + return m.DelegationStates + } + return nil +} + +func (m *GenesisState) GetStakersByOperator() []StakersByOperator { + if m != nil { + return m.StakersByOperator + } + return nil +} + +func (m *GenesisState) GetUndelegations() []UndelegationRecord { + if m != nil { + return m.Undelegations + } + return nil +} + +// DelegationStates is a helper struct for the delegation state +// used to construct the genesis state +type DelegationStates struct { + // key is used for storing the delegation states, + // which is a combination of the staker ID, asset ID, and operator address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // states is the value of undelegation state for the above key + States DelegationAmounts `protobuf:"bytes,2,opt,name=states,proto3" json:"states"` +} + +func (m *DelegationStates) Reset() { *m = DelegationStates{} } +func (m *DelegationStates) String() string { return proto.CompactTextString(m) } +func (*DelegationStates) ProtoMessage() {} +func (*DelegationStates) Descriptor() ([]byte, []int) { + return fileDescriptor_c26dd0d733927603, []int{1} +} +func (m *DelegationStates) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegationStates) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegationStates.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DelegationStates) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegationStates.Merge(m, src) +} +func (m *DelegationStates) XXX_Size() int { + return m.Size() +} +func (m *DelegationStates) XXX_DiscardUnknown() { + xxx_messageInfo_DelegationStates.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegationStates proto.InternalMessageInfo + +func (m *DelegationStates) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *DelegationStates) GetStates() DelegationAmounts { + if m != nil { + return m.States + } + return DelegationAmounts{} +} + +// StakersByOperator is a helper struct for an operator's staker list +// used to construct the genesis state +type StakersByOperator struct { + // key is used for storing the staker list, + // which is a combination of the operator address and the asset ID. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // stakers is the stakers list for the above key + Stakers []string `protobuf:"bytes,2,rep,name=stakers,proto3" json:"stakers,omitempty"` +} + +func (m *StakersByOperator) Reset() { *m = StakersByOperator{} } +func (m *StakersByOperator) String() string { return proto.CompactTextString(m) } +func (*StakersByOperator) ProtoMessage() {} +func (*StakersByOperator) Descriptor() ([]byte, []int) { + return fileDescriptor_c26dd0d733927603, []int{2} +} +func (m *StakersByOperator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakersByOperator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakersByOperator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StakersByOperator) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakersByOperator.Merge(m, src) +} +func (m *StakersByOperator) XXX_Size() int { + return m.Size() +} +func (m *StakersByOperator) XXX_DiscardUnknown() { + xxx_messageInfo_StakersByOperator.DiscardUnknown(m) +} + +var xxx_messageInfo_StakersByOperator proto.InternalMessageInfo + +func (m *StakersByOperator) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *StakersByOperator) GetStakers() []string { + if m != nil { + return m.Stakers } return nil } // DelegationsByStaker is a list of delegations for a single staker. type DelegationsByStaker struct { - // staker_id is the staker's account address + _ + l0 chain id (hex).`` + // staker_id is the staker's account address + _ + l0 chain id (hex).“ StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` // delegations is the list of delegations for the staker, indexed by the // asset_id. @@ -94,7 +226,7 @@ func (m *DelegationsByStaker) Reset() { *m = DelegationsByStaker{} } func (m *DelegationsByStaker) String() string { return proto.CompactTextString(m) } func (*DelegationsByStaker) ProtoMessage() {} func (*DelegationsByStaker) Descriptor() ([]byte, []int) { - return fileDescriptor_c26dd0d733927603, []int{1} + return fileDescriptor_c26dd0d733927603, []int{3} } func (m *DelegationsByStaker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -149,7 +281,7 @@ func (m *StakerToOperator) Reset() { *m = StakerToOperator{} } func (m *StakerToOperator) String() string { return proto.CompactTextString(m) } func (*StakerToOperator) ProtoMessage() {} func (*StakerToOperator) Descriptor() ([]byte, []int) { - return fileDescriptor_c26dd0d733927603, []int{2} + return fileDescriptor_c26dd0d733927603, []int{4} } func (m *StakerToOperator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -194,6 +326,8 @@ func (m *StakerToOperator) GetOperator() string { func init() { proto.RegisterType((*GenesisState)(nil), "exocore.delegation.v1.GenesisState") + proto.RegisterType((*DelegationStates)(nil), "exocore.delegation.v1.DelegationStates") + proto.RegisterType((*StakersByOperator)(nil), "exocore.delegation.v1.StakersByOperator") proto.RegisterType((*DelegationsByStaker)(nil), "exocore.delegation.v1.DelegationsByStaker") proto.RegisterType((*StakerToOperator)(nil), "exocore.delegation.v1.StakerToOperator") } @@ -203,29 +337,37 @@ func init() { } var fileDescriptor_c26dd0d733927603 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x4e, 0xc2, 0x40, - 0x10, 0x86, 0xbb, 0x68, 0x0c, 0x2c, 0x1c, 0x4c, 0xd5, 0x84, 0x70, 0x58, 0x08, 0x1e, 0x44, 0x0f, - 0xdd, 0xa0, 0xbe, 0x80, 0x0d, 0xc6, 0x70, 0xc1, 0x58, 0x4c, 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0x9a, - 0x93, 0xd6, 0xed, 0xba, 0x67, 0xde, 0xac, 0x27, 0xd5, 0x4b, 0xf1, 0xbf, 0x93, 0x82, 0xd7, 0x14, - 0x81, 0xdf, 0x85, 0x33, 0x29, 0x41, 0xd5, 0x83, 0x07, 0x4c, 0x88, 0x5b, 0xbe, 0xa5, 0xdb, 0x3f, - 0x33, 0xfc, 0x67, 0xaf, 0x02, 0x4d, 0xe3, 0xfc, 0x5b, 0x3e, 0x35, 0x23, 0x9d, 0xef, 0xb7, 0xdd, - 0x18, 0x45, 0x8c, 0x8c, 0x23, 0x46, 0x3e, 0x23, 0x46, 0x5e, 0xa7, 0xcc, 0x18, 0x4f, 0x99, 0xf1, - 0x31, 0x65, 0xc6, 0xdd, 0xa9, 0x2f, 0xd4, 0xe3, 0x73, 0xcb, 0x6a, 0xe3, 0x13, 0x3f, 0xd7, 0x11, - 0x1a, 0xa0, 0x5e, 0x30, 0xec, 0xf0, 0xc5, 0x09, 0x0c, 0x56, 0x8f, 0x40, 0x0d, 0x7b, 0x20, 0x5b, - 0x5b, 0xf1, 0x15, 0x9c, 0x7c, 0x05, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xea, 0x40, 0xc1, 0x79, 0x02, - 0x00, 0x00, + // 471 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe3, 0xa4, 0x2a, 0xc9, 0x36, 0x48, 0xc9, 0x16, 0x24, 0x2b, 0x07, 0xb7, 0x98, 0x03, + 0xe9, 0xc5, 0x56, 0x81, 0x17, 0xa8, 0xd5, 0x82, 0x72, 0x29, 0x22, 0xa1, 0x42, 0xf4, 0x40, 0xe4, + 0xc4, 0x83, 0xb1, 0x92, 0x7a, 0x82, 0x67, 0x53, 0xe2, 0xb7, 0xe0, 0xca, 0x1b, 0xf5, 0xd8, 0x23, + 0xa7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03, 0x67, 0x88, + 0x57, 0xee, 0x99, 0x6a, 0xe1, 0x1c, 0xc4, 0x77, 0x4c, 0x46, 0xee, 0xea, 0x18, 0x67, 0x9b, 0xe7, + 0x28, 0xd2, 0x09, 0xd0, 0x60, 0x57, 0x5e, 0xde, 0xab, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0f, + 0x22, 0xc1, 0x73, 0x10, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -248,10 +390,38 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Associations) > 0 { - for iNdEx := len(m.Associations) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Undelegations) > 0 { + for iNdEx := len(m.Undelegations) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Associations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Undelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.StakersByOperator) > 0 { + for iNdEx := len(m.StakersByOperator) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakersByOperator[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.DelegationStates) > 0 { + for iNdEx := len(m.DelegationStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DelegationStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -262,10 +432,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if len(m.Delegations) > 0 { - for iNdEx := len(m.Delegations) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Associations) > 0 { + for iNdEx := len(m.Associations) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Delegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Associations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -279,6 +449,85 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DelegationStates) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DelegationStates) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegationStates) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.States.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakersByOperator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StakersByOperator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakersByOperator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Stakers) > 0 { + for iNdEx := len(m.Stakers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Stakers[iNdEx]) + copy(dAtA[i:], m.Stakers[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Stakers[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *DelegationsByStaker) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -377,14 +626,26 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if len(m.Delegations) > 0 { - for _, e := range m.Delegations { + if len(m.Associations) > 0 { + for _, e := range m.Associations { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Associations) > 0 { - for _, e := range m.Associations { + if len(m.DelegationStates) > 0 { + for _, e := range m.DelegationStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.StakersByOperator) > 0 { + for _, e := range m.StakersByOperator { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Undelegations) > 0 { + for _, e := range m.Undelegations { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -392,6 +653,40 @@ func (m *GenesisState) Size() (n int) { return n } +func (m *DelegationStates) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.States.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *StakersByOperator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Stakers) > 0 { + for _, s := range m.Stakers { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + func (m *DelegationsByStaker) Size() (n int) { if m == nil { return 0 @@ -465,7 +760,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Associations", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -492,14 +787,14 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, DelegationsByStaker{}) - if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Associations = append(m.Associations, StakerToOperator{}) + if err := m.Associations[len(m.Associations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Associations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DelegationStates", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -526,8 +821,76 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Associations = append(m.Associations, StakerToOperator{}) - if err := m.Associations[len(m.Associations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.DelegationStates = append(m.DelegationStates, DelegationStates{}) + if err := m.DelegationStates[len(m.DelegationStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakersByOperator", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakersByOperator = append(m.StakersByOperator, StakersByOperator{}) + if err := m.StakersByOperator[len(m.StakersByOperator)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Undelegations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Undelegations = append(m.Undelegations, UndelegationRecord{}) + if err := m.Undelegations[len(m.Undelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -552,6 +915,235 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } +func (m *DelegationStates) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DelegationStates: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegationStates: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field States", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.States.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakersByOperator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StakersByOperator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakersByOperator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stakers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stakers = append(m.Stakers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *DelegationsByStaker) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/delegation/types/genesis_test.go b/x/delegation/types/genesis_test.go index 4ec0b0988..08bde0839 100644 --- a/x/delegation/types/genesis_test.go +++ b/x/delegation/types/genesis_test.go @@ -30,21 +30,21 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { lzID, stakerAddress[:], assetAddress[:], ) operatorAddress := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) - delegations := []types.DelegationsByStaker{ + singleStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operatorAddress.String()) + delegationStates := []types.DelegationStates{ { - StakerID: stakerID, - Delegations: []types.DelegatedSingleAssetInfo{ - { - AssetID: assetID, - PerOperatorAmounts: []types.KeyValue{ - { - Key: operatorAddress.String(), - Value: &types.ValueField{ - Amount: math.NewInt(1000), - }, - }, - }, - }, + Key: string(singleStateKey), + States: types.DelegationAmounts{ + WaitUndelegationAmount: math.NewInt(0), + UndelegatableShare: math.LegacyNewDec(1000), + }, + }, + } + stakersByOperator := []types.StakersByOperator{ + { + Key: string(assetstypes.GetJoinedStoreKey(operatorAddress.String(), assetID)), + Stakers: []string{ + stakerID, }, }, } @@ -67,117 +67,107 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, { name: "base, should pass", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: true, }, { name: "invalid staker id", - genState: types.NewGenesis(delegations, nil), - expPass: false, - malleate: func(gs *types.GenesisState) { - gs.Delegations[0].StakerID = "invalid" - }, - unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].StakerID = stakerID - }, - }, - { - name: "duplicate staker id", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations = append(gs.Delegations, gs.Delegations[0]) + invalidStateKey := assetstypes.GetJoinedStoreKey("invalid", assetID, operatorAddress.String()) + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations = gs.Delegations[:1] + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { - name: "duplicate asset id", - genState: types.NewGenesis(delegations, nil), + name: "duplicate state key", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations = append( - gs.Delegations[0].Delegations, - gs.Delegations[0].Delegations[0], - ) + gs.DelegationStates = append(gs.DelegationStates, gs.DelegationStates[0]) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations = gs.Delegations[0].Delegations[:1] + gs.DelegationStates = gs.DelegationStates[:1] }, }, { name: "invalid asset id", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].AssetID = "invalid" + invalidStateKey := assetstypes.GetJoinedStoreKey(stakerID, "invalid", operatorAddress.String()) + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].AssetID = assetID + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { name: "asset id mismatch", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { stakerID, _ := assetstypes.GetStakeIDAndAssetID( lzID+1, stakerAddress[:], assetAddress[:], ) - gs.Delegations[0].StakerID = stakerID + invalidStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, operatorAddress.String()) + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].StakerID = stakerID + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { - name: "nil wrapped amount", - genState: types.NewGenesis(delegations, nil), + name: "nil wrapped undelegatable share", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = nil + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyDec{} }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(1000)} + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyNewDec(1000) }, }, { - name: "nil unwrapped amount", - genState: types.NewGenesis(delegations, nil), + name: "nil wrapped unbonding amount", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{} + gs.DelegationStates[0].States.WaitUndelegationAmount = math.Int{} }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(1000)} + gs.DelegationStates[0].States.WaitUndelegationAmount = math.NewInt(0) }, }, { - name: "negative unwrapped amount", - genState: types.NewGenesis(delegations, nil), + name: "negative wrapped undelegatable share", + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(-1)} + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyNewDec(-1) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Value = &types.ValueField{Amount: math.NewInt(1000)} + gs.DelegationStates[0].States.UndelegatableShare = math.LegacyNewDec(1000) }, }, { name: "invalid operator address", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Key = "invalid" + invalidStateKey := assetstypes.GetJoinedStoreKey(stakerID, assetID, "invalid") + gs.DelegationStates[0].Key = string(invalidStateKey) }, unmalleate: func(gs *types.GenesisState) { - gs.Delegations[0].Delegations[0].PerOperatorAmounts[0].Key = operatorAddress.String() + gs.DelegationStates[0].Key = string(singleStateKey) }, }, { name: "duplicate stakerID in associations", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: false, malleate: func(gs *types.GenesisState) { gs.Associations = make([]types.StakerToOperator, 2) @@ -192,7 +182,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, { name: "one stakerID in associations", - genState: types.NewGenesis(delegations, nil), + genState: types.NewGenesis(nil, delegationStates, stakersByOperator, nil), expPass: true, malleate: func(gs *types.GenesisState) { gs.Associations = make([]types.StakerToOperator, 1) diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index 5eb7d7feb..4aeaf36e6 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -72,7 +72,7 @@ func GetDelegationStateIteratorPrefix(stakerID, assetID string) []byte { return tmp } -func ParseStakerAssetIDAndOperatorAddrFromKey(key []byte) (keys *SingleDelegationInfoReq, err error) { +func ParseStakerAssetIDAndOperator(key []byte) (keys *SingleDelegationInfoReq, err error) { stringList, err := assetstypes.ParseJoinedStoreKey(key, 3) if err != nil { return nil, err diff --git a/x/delegation/types/types/query.pb.go b/x/delegation/types/types/query.pb.go deleted file mode 100644 index d5b83e649..000000000 --- a/x/delegation/types/types/query.pb.go +++ /dev/null @@ -1,1880 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/delegation/v1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// DelegationInfoReq is the request to obtain the delegation information -// by staker id and asset id. -type DelegationInfoReq struct { - // staker_id is the staker id. - StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` - // asset_id is the asset id. - AssetID string `protobuf:"bytes,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` -} - -func (m *DelegationInfoReq) Reset() { *m = DelegationInfoReq{} } -func (m *DelegationInfoReq) String() string { return proto.CompactTextString(m) } -func (*DelegationInfoReq) ProtoMessage() {} -func (*DelegationInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{0} -} -func (m *DelegationInfoReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegationInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegationInfoReq.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DelegationInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegationInfoReq.Merge(m, src) -} -func (m *DelegationInfoReq) XXX_Size() int { - return m.Size() -} -func (m *DelegationInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_DelegationInfoReq.DiscardUnknown(m) -} - -var xxx_messageInfo_DelegationInfoReq proto.InternalMessageInfo - -func (m *DelegationInfoReq) GetStakerID() string { - if m != nil { - return m.StakerID - } - return "" -} - -func (m *DelegationInfoReq) GetAssetID() string { - if m != nil { - return m.AssetID - } - return "" -} - -// StakerList is a list to save a batch of stakers -type StakerList struct { - // stakers is a list of stakers. the caller is responsible for ensuring - // uniqueness of the stakers, since dumping this into a map could lead - // to non-deterministic behavior. - Stakers []string `protobuf:"bytes,1,rep,name=stakers,proto3" json:"stakers,omitempty"` -} - -func (m *StakerList) Reset() { *m = StakerList{} } -func (m *StakerList) String() string { return proto.CompactTextString(m) } -func (*StakerList) ProtoMessage() {} -func (*StakerList) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{1} -} -func (m *StakerList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakerList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakerList.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakerList) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerList.Merge(m, src) -} -func (m *StakerList) XXX_Size() int { - return m.Size() -} -func (m *StakerList) XXX_DiscardUnknown() { - xxx_messageInfo_StakerList.DiscardUnknown(m) -} - -var xxx_messageInfo_StakerList proto.InternalMessageInfo - -func (m *StakerList) GetStakers() []string { - if m != nil { - return m.Stakers - } - return nil -} - -// DelegationAmounts is the delegation amount response for a single delegation. -type DelegationAmounts struct { - // undelegatable_share is the share that can be undelegated. - // It's to reduce the state updating when slash occurs. - // S_j = S * T_j / T, `S` and `T` is the current asset share and amount of operator, - // and the T_j represents the change in staker's asset amount when some external - // operations occur, such as: delegation, undelegation and non-instantaneous slashing. - // S_j represents the change in the staker's asset share, - // so the updated share should be added by it. - // A special case is the initial delegation, when T = 0 and S = 0, so T_j / T is undefined. - // For the initial delegation, delegator j who delegates T_j tokens receive S_j = T_j shares. - UndelegatableShare github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=undelegatable_share,json=undelegatableShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"undelegatable_share"` - // wait_undelegation_amount is the amount that is waiting to be unbonded. - WaitUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=wait_undelegation_amount,json=waitUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_undelegation_amount"` -} - -func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } -func (m *DelegationAmounts) String() string { return proto.CompactTextString(m) } -func (*DelegationAmounts) ProtoMessage() {} -func (*DelegationAmounts) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{2} -} -func (m *DelegationAmounts) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegationAmounts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegationAmounts.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DelegationAmounts) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegationAmounts.Merge(m, src) -} -func (m *DelegationAmounts) XXX_Size() int { - return m.Size() -} -func (m *DelegationAmounts) XXX_DiscardUnknown() { - xxx_messageInfo_DelegationAmounts.DiscardUnknown(m) -} - -var xxx_messageInfo_DelegationAmounts proto.InternalMessageInfo - -// QueryDelegationInfoResponse is the response for delegations by staker id and -// asset id. -type QueryDelegationInfoResponse struct { - // delegation_infos is the delegation information for each operator. - DelegationInfos map[string]*DelegationAmounts `protobuf:"bytes,1,rep,name=delegation_infos,json=delegationInfos,proto3" json:"delegation_infos,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *QueryDelegationInfoResponse) Reset() { *m = QueryDelegationInfoResponse{} } -func (m *QueryDelegationInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDelegationInfoResponse) ProtoMessage() {} -func (*QueryDelegationInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{3} -} -func (m *QueryDelegationInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDelegationInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDelegationInfoResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryDelegationInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDelegationInfoResponse.Merge(m, src) -} -func (m *QueryDelegationInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryDelegationInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDelegationInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDelegationInfoResponse proto.InternalMessageInfo - -func (m *QueryDelegationInfoResponse) GetDelegationInfos() map[string]*DelegationAmounts { - if m != nil { - return m.DelegationInfos - } - return nil -} - -// SingleDelegationInfoReq is the request to obtain the single delegation information. -type SingleDelegationInfoReq struct { - // staker_id is the staker id. - StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` - // operator_addr is the operator address. - OperatorAddr string `protobuf:"bytes,2,opt,name=operator_addr,json=operatorAddr,proto3" json:"operator_addr,omitempty"` - // asset_id is the asset id. - AssetID string `protobuf:"bytes,3,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` -} - -func (m *SingleDelegationInfoReq) Reset() { *m = SingleDelegationInfoReq{} } -func (m *SingleDelegationInfoReq) String() string { return proto.CompactTextString(m) } -func (*SingleDelegationInfoReq) ProtoMessage() {} -func (*SingleDelegationInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{4} -} -func (m *SingleDelegationInfoReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SingleDelegationInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SingleDelegationInfoReq.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SingleDelegationInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_SingleDelegationInfoReq.Merge(m, src) -} -func (m *SingleDelegationInfoReq) XXX_Size() int { - return m.Size() -} -func (m *SingleDelegationInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_SingleDelegationInfoReq.DiscardUnknown(m) -} - -var xxx_messageInfo_SingleDelegationInfoReq proto.InternalMessageInfo - -func (m *SingleDelegationInfoReq) GetStakerID() string { - if m != nil { - return m.StakerID - } - return "" -} - -func (m *SingleDelegationInfoReq) GetOperatorAddr() string { - if m != nil { - return m.OperatorAddr - } - return "" -} - -func (m *SingleDelegationInfoReq) GetAssetID() string { - if m != nil { - return m.AssetID - } - return "" -} - -// UndelegationHoldCountReq is the request to obtain the undelegation hold count. -type UndelegationHoldCountReq struct { - // record_key is the record key of the undelegation record. - RecordKey string `protobuf:"bytes,1,opt,name=record_key,json=recordKey,proto3" json:"record_key,omitempty"` -} - -func (m *UndelegationHoldCountReq) Reset() { *m = UndelegationHoldCountReq{} } -func (m *UndelegationHoldCountReq) String() string { return proto.CompactTextString(m) } -func (*UndelegationHoldCountReq) ProtoMessage() {} -func (*UndelegationHoldCountReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{5} -} -func (m *UndelegationHoldCountReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UndelegationHoldCountReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UndelegationHoldCountReq.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *UndelegationHoldCountReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_UndelegationHoldCountReq.Merge(m, src) -} -func (m *UndelegationHoldCountReq) XXX_Size() int { - return m.Size() -} -func (m *UndelegationHoldCountReq) XXX_DiscardUnknown() { - xxx_messageInfo_UndelegationHoldCountReq.DiscardUnknown(m) -} - -var xxx_messageInfo_UndelegationHoldCountReq proto.InternalMessageInfo - -func (m *UndelegationHoldCountReq) GetRecordKey() string { - if m != nil { - return m.RecordKey - } - return "" -} - -// UndelegationHoldCountResponse is the response for the undelegation hold count. -type UndelegationHoldCountResponse struct { - // hold_count is the number of undelegations that are on hold. - HoldCount uint64 `protobuf:"varint,1,opt,name=hold_count,json=holdCount,proto3" json:"hold_count,omitempty"` -} - -func (m *UndelegationHoldCountResponse) Reset() { *m = UndelegationHoldCountResponse{} } -func (m *UndelegationHoldCountResponse) String() string { return proto.CompactTextString(m) } -func (*UndelegationHoldCountResponse) ProtoMessage() {} -func (*UndelegationHoldCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{6} -} -func (m *UndelegationHoldCountResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UndelegationHoldCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UndelegationHoldCountResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *UndelegationHoldCountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_UndelegationHoldCountResponse.Merge(m, src) -} -func (m *UndelegationHoldCountResponse) XXX_Size() int { - return m.Size() -} -func (m *UndelegationHoldCountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_UndelegationHoldCountResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_UndelegationHoldCountResponse proto.InternalMessageInfo - -func (m *UndelegationHoldCountResponse) GetHoldCount() uint64 { - if m != nil { - return m.HoldCount - } - return 0 -} - -func init() { - proto.RegisterType((*DelegationInfoReq)(nil), "exocore.delegation.v1.DelegationInfoReq") - proto.RegisterType((*StakerList)(nil), "exocore.delegation.v1.StakerList") - proto.RegisterType((*DelegationAmounts)(nil), "exocore.delegation.v1.DelegationAmounts") - proto.RegisterType((*QueryDelegationInfoResponse)(nil), "exocore.delegation.v1.QueryDelegationInfoResponse") - proto.RegisterMapType((map[string]*DelegationAmounts)(nil), "exocore.delegation.v1.QueryDelegationInfoResponse.DelegationInfosEntry") - proto.RegisterType((*SingleDelegationInfoReq)(nil), "exocore.delegation.v1.SingleDelegationInfoReq") - proto.RegisterType((*UndelegationHoldCountReq)(nil), "exocore.delegation.v1.UndelegationHoldCountReq") - proto.RegisterType((*UndelegationHoldCountResponse)(nil), "exocore.delegation.v1.UndelegationHoldCountResponse") -} - -func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } - -var fileDescriptor_aab345e1cf20490c = []byte{ - // 727 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x4f, 0x13, 0x4f, - 0x1c, 0xed, 0xf0, 0xe3, 0x0b, 0x1d, 0xf8, 0x46, 0x1c, 0x50, 0x4b, 0x91, 0x16, 0xf7, 0x40, 0x2a, - 0x09, 0xbb, 0x52, 0x31, 0x51, 0x23, 0x44, 0xb0, 0x04, 0x1b, 0x0c, 0x89, 0xdb, 0x78, 0xf1, 0xb2, - 0x59, 0xba, 0xc3, 0x76, 0xd3, 0xed, 0x4c, 0x99, 0x99, 0x16, 0x1a, 0xe3, 0xc5, 0x93, 0x47, 0x13, - 0xff, 0x0b, 0xbd, 0x78, 0xe0, 0xec, 0x99, 0x23, 0xc1, 0x8b, 0xf1, 0xd0, 0x98, 0x62, 0xe2, 0xff, - 0xe0, 0x45, 0xb3, 0xbb, 0x03, 0xdd, 0xe2, 0x2e, 0x4a, 0x3c, 0x75, 0xe7, 0xf3, 0xf3, 0xcd, 0x7b, - 0x2f, 0x53, 0x78, 0x03, 0xef, 0xd1, 0x32, 0x65, 0x58, 0xb3, 0xb0, 0x8b, 0x6d, 0x53, 0x38, 0x94, - 0x68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xb9, 0xba, 0x79, 0xd0, 0xc9, 0x80, 0xc3, 0x4e, 0x06, 0x7c, - 0xed, 0x64, 0xc0, 0x9b, 0xe3, 0x4c, 0xe2, 0xf0, 0x38, 0x93, 0xf8, 0x7c, 0x9c, 0x49, 0x3c, 0x5f, - 0x0c, 0xbd, 0x69, 0x6b, 0xc1, 0x8e, 0x4d, 0x2c, 0x76, 0x29, 0xab, 0x9e, 0xae, 0xdc, 0x0b, 0x2f, - 0xf5, 0x5f, 0xb9, 0xad, 0xff, 0xfc, 0xff, 0x93, 0xdb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd6, - 0xd3, 0x4d, 0x1e, 0xf7, 0x06, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // DelegationInfo queries the delegation information for {stakerID, assetID}. - QueryDelegationInfo(ctx context.Context, in *DelegationInfoReq, opts ...grpc.CallOption) (*QueryDelegationInfoResponse, error) - // SingleDelegationInfo queries the single delegation information for - // {chain, staker, asset, operator}. - QuerySingleDelegationInfo(ctx context.Context, in *SingleDelegationInfoReq, opts ...grpc.CallOption) (*DelegationAmounts, error) - // QueryUndelegationHoldCount queries the undelegation hold count. - QueryUndelegationHoldCount(ctx context.Context, in *UndelegationHoldCountReq, opts ...grpc.CallOption) (*UndelegationHoldCountResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) QueryDelegationInfo(ctx context.Context, in *DelegationInfoReq, opts ...grpc.CallOption) (*QueryDelegationInfoResponse, error) { - out := new(QueryDelegationInfoResponse) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QueryDelegationInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QuerySingleDelegationInfo(ctx context.Context, in *SingleDelegationInfoReq, opts ...grpc.CallOption) (*DelegationAmounts, error) { - out := new(DelegationAmounts) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QuerySingleDelegationInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryUndelegationHoldCount(ctx context.Context, in *UndelegationHoldCountReq, opts ...grpc.CallOption) (*UndelegationHoldCountResponse, error) { - out := new(UndelegationHoldCountResponse) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QueryUndelegationHoldCount", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // DelegationInfo queries the delegation information for {stakerID, assetID}. - QueryDelegationInfo(context.Context, *DelegationInfoReq) (*QueryDelegationInfoResponse, error) - // SingleDelegationInfo queries the single delegation information for - // {chain, staker, asset, operator}. - QuerySingleDelegationInfo(context.Context, *SingleDelegationInfoReq) (*DelegationAmounts, error) - // QueryUndelegationHoldCount queries the undelegation hold count. - QueryUndelegationHoldCount(context.Context, *UndelegationHoldCountReq) (*UndelegationHoldCountResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) QueryDelegationInfo(ctx context.Context, req *DelegationInfoReq) (*QueryDelegationInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryDelegationInfo not implemented") -} -func (*UnimplementedQueryServer) QuerySingleDelegationInfo(ctx context.Context, req *SingleDelegationInfoReq) (*DelegationAmounts, error) { - return nil, status.Errorf(codes.Unimplemented, "method QuerySingleDelegationInfo not implemented") -} -func (*UnimplementedQueryServer) QueryUndelegationHoldCount(ctx context.Context, req *UndelegationHoldCountReq) (*UndelegationHoldCountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryUndelegationHoldCount not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_QueryDelegationInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DelegationInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryDelegationInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QueryDelegationInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryDelegationInfo(ctx, req.(*DelegationInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QuerySingleDelegationInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SingleDelegationInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QuerySingleDelegationInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QuerySingleDelegationInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QuerySingleDelegationInfo(ctx, req.(*SingleDelegationInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryUndelegationHoldCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UndelegationHoldCountReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryUndelegationHoldCount(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QueryUndelegationHoldCount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryUndelegationHoldCount(ctx, req.(*UndelegationHoldCountReq)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "exocore.delegation.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "QueryDelegationInfo", - Handler: _Query_QueryDelegationInfo_Handler, - }, - { - MethodName: "QuerySingleDelegationInfo", - Handler: _Query_QuerySingleDelegationInfo_Handler, - }, - { - MethodName: "QueryUndelegationHoldCount", - Handler: _Query_QueryUndelegationHoldCount_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "exocore/delegation/v1/query.proto", -} - -func (m *DelegationInfoReq) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DelegationInfoReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AssetID) > 0 { - i -= len(m.AssetID) - copy(dAtA[i:], m.AssetID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.AssetID))) - i-- - dAtA[i] = 0x12 - } - if len(m.StakerID) > 0 { - i -= len(m.StakerID) - copy(dAtA[i:], m.StakerID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *StakerList) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakerList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakerList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Stakers) > 0 { - for iNdEx := len(m.Stakers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Stakers[iNdEx]) - copy(dAtA[i:], m.Stakers[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Stakers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DelegationAmounts) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DelegationAmounts) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.WaitUndelegationAmount.Size() - i -= size - if _, err := m.WaitUndelegationAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.UndelegatableShare.Size() - i -= size - if _, err := m.UndelegatableShare.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryDelegationInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryDelegationInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDelegationInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DelegationInfos) > 0 { - for k := range m.DelegationInfos { - v := m.DelegationInfos[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SingleDelegationInfoReq) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SingleDelegationInfoReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SingleDelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AssetID) > 0 { - i -= len(m.AssetID) - copy(dAtA[i:], m.AssetID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.AssetID))) - i-- - dAtA[i] = 0x1a - } - if len(m.OperatorAddr) > 0 { - i -= len(m.OperatorAddr) - copy(dAtA[i:], m.OperatorAddr) - i = encodeVarintQuery(dAtA, i, uint64(len(m.OperatorAddr))) - i-- - dAtA[i] = 0x12 - } - if len(m.StakerID) > 0 { - i -= len(m.StakerID) - copy(dAtA[i:], m.StakerID) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UndelegationHoldCountReq) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UndelegationHoldCountReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UndelegationHoldCountReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RecordKey) > 0 { - i -= len(m.RecordKey) - copy(dAtA[i:], m.RecordKey) - i = encodeVarintQuery(dAtA, i, uint64(len(m.RecordKey))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UndelegationHoldCountResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UndelegationHoldCountResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UndelegationHoldCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.HoldCount != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.HoldCount)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *DelegationInfoReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.AssetID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *StakerList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Stakers) > 0 { - for _, s := range m.Stakers { - l = len(s) - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *DelegationAmounts) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.UndelegatableShare.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.WaitUndelegationAmount.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryDelegationInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DelegationInfos) > 0 { - for k, v := range m.DelegationInfos { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) - } - } - return n -} - -func (m *SingleDelegationInfoReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.OperatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.AssetID) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *UndelegationHoldCountReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RecordKey) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *UndelegationHoldCountResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.HoldCount != 0 { - n += 1 + sovQuery(uint64(m.HoldCount)) - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *DelegationInfoReq) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DelegationInfoReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakerID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AssetID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *StakerList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakerList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakerList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stakers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Stakers = append(m.Stakers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DelegationAmounts: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationAmounts: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UndelegatableShare", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UndelegatableShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUndelegationAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.WaitUndelegationAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryDelegationInfoResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryDelegationInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDelegationInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegationInfos", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DelegationInfos == nil { - m.DelegationInfos = make(map[string]*DelegationAmounts) - } - var mapkey string - var mapvalue *DelegationAmounts - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &DelegationAmounts{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.DelegationInfos[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SingleDelegationInfoReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SingleDelegationInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakerID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OperatorAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AssetID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UndelegationHoldCountReq) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UndelegationHoldCountReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UndelegationHoldCountReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RecordKey", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RecordKey = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UndelegationHoldCountResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UndelegationHoldCountResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UndelegationHoldCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field HoldCount", wireType) - } - m.HoldCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.HoldCount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/delegation/types/types/query.pb.gw.go b/x/delegation/types/types/query.pb.gw.go deleted file mode 100644 index dac6b2f70..000000000 --- a/x/delegation/types/types/query.pb.gw.go +++ /dev/null @@ -1,355 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: exocore/delegation/v1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_QueryDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DelegationInfoReq - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryDelegationInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DelegationInfoReq - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryDelegationInfo(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QuerySingleDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SingleDelegationInfoReq - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QuerySingleDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QuerySingleDelegationInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq SingleDelegationInfoReq - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QuerySingleDelegationInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QuerySingleDelegationInfo(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryUndelegationHoldCount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UndelegationHoldCountReq - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["record_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "record_key") - } - - protoReq.RecordKey, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "record_key", err) - } - - msg, err := client.QueryUndelegationHoldCount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryUndelegationHoldCount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UndelegationHoldCountReq - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["record_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "record_key") - } - - protoReq.RecordKey, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "record_key", err) - } - - msg, err := server.QueryUndelegationHoldCount(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_QueryDelegationInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_QueryDelegationInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QuerySingleDelegationInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_QuerySingleDelegationInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QuerySingleDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryUndelegationHoldCount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_QueryUndelegationHoldCount_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryUndelegationHoldCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_QueryDelegationInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_QueryDelegationInfo_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QuerySingleDelegationInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_QuerySingleDelegationInfo_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QuerySingleDelegationInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryUndelegationHoldCount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_QueryUndelegationHoldCount_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryUndelegationHoldCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_QueryDelegationInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetDelegationInfo"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QuerySingleDelegationInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "QuerySingleDelegationInfo"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryUndelegationHoldCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"exocore", "delegation", "v1", "QueryUndelegationHoldCount", "record_key"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_QueryDelegationInfo_0 = runtime.ForwardResponseMessage - - forward_Query_QuerySingleDelegationInfo_0 = runtime.ForwardResponseMessage - - forward_Query_QueryUndelegationHoldCount_0 = runtime.ForwardResponseMessage -) diff --git a/x/dogfood/keeper/genesis.go b/x/dogfood/keeper/genesis.go index b7ccdff36..8a229db47 100644 --- a/x/dogfood/keeper/genesis.go +++ b/x/dogfood/keeper/genesis.go @@ -58,13 +58,13 @@ func (k Keeper) InitGenesis( // wrappedKey can never be nil wrappedKey := operatortypes.NewWrappedConsKeyFromHex(val.PublicKey) // #nosec G703 // already validated - operatorAddr, _ := sdk.AccAddressFromBech32(val.OperatorAccAddr) - // OptIntoAVS checks that the operator exists and will error if it does not. - if err := k.operatorKeeper.OptInWithConsKey( - ctx, operatorAddr, avsAddrString, wrappedKey, - ); err != nil { - panic(fmt.Errorf("failed to opt into avs: %s", err)) - } + /* operatorAddr, _ := sdk.AccAddressFromBech32(val.OperatorAccAddr) + // OptIntoAVS checks that the operator exists and will error if it does not. + if err := k.operatorKeeper.OptInWithConsKey( + ctx, operatorAddr, avsAddrString, wrappedKey, + ); err != nil { + panic(fmt.Errorf("failed to opt into avs: %s", err)) + }*/ out = append(out, abci.ValidatorUpdate{ PubKey: *wrappedKey.ToTmProtoKey(), Power: val.Power, @@ -127,10 +127,17 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { pubKey, _ := val.ConsPubKey() // #nosec G703 // already validated convKey, _ := cryptocodec.ToTmPubKeyInterface(pubKey) + addr := sdk.GetConsAddress(pubKey) + found, operatorAddr := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr(ctx, avstypes.ChainIDWithoutRevision(ctx.ChainID()), addr) + if !found { + ctx.Logger().Error("Operator address not found for validator", "consAddr", addr.String()) + return true + } validators = append(validators, types.GenesisValidator{ - PublicKey: hexutil.Encode(convKey.Bytes()), - Power: val.GetConsensusPower(sdk.DefaultPowerReduction), + PublicKey: hexutil.Encode(convKey.Bytes()), + Power: val.GetConsensusPower(sdk.DefaultPowerReduction), + OperatorAccAddr: operatorAddr.String(), }, ) return false /* stop */ diff --git a/x/dogfood/keeper/impl_epochs_hooks.go b/x/dogfood/keeper/impl_epochs_hooks.go index d1490fb65..cff81133c 100644 --- a/x/dogfood/keeper/impl_epochs_hooks.go +++ b/x/dogfood/keeper/impl_epochs_hooks.go @@ -34,6 +34,7 @@ func (wrapper EpochsHooksWrapper) AfterEpochEnd( // applied within this block. however, for clarity, it is highlighted that unbonding // takes N epochs + 1 block to complete. wrapper.keeper.MarkEpochEnd(ctx) + ctx.Logger().Info("mark epoch end", "height", ctx.BlockHeight(), "identifier", identifier, "epoch", epoch) // find the opt outs that mature when this epoch ends, and move them to pending. optOuts := wrapper.keeper.GetOptOutsToFinish(ctx, epoch) wrapper.keeper.SetPendingOptOuts(ctx, types.AccountAddresses{List: optOuts}) diff --git a/x/dogfood/keeper/impl_epochs_hooks_test.go b/x/dogfood/keeper/impl_epochs_hooks_test.go index a7c4b6b79..532f06c1e 100644 --- a/x/dogfood/keeper/impl_epochs_hooks_test.go +++ b/x/dogfood/keeper/impl_epochs_hooks_test.go @@ -81,7 +81,7 @@ func (suite *KeeperTestSuite) TestSameEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -92,7 +92,7 @@ func (suite *KeeperTestSuite) TestSameEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) return err @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestSameEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.SetConsKeyReq{ Address: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: newKey.ToJSON(), }, ) @@ -261,7 +261,7 @@ func (suite *KeeperTestSuite) TestDifferentEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -272,7 +272,7 @@ func (suite *KeeperTestSuite) TestDifferentEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) return err @@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestDifferentEpochOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.SetConsKeyReq{ Address: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: newKey.ToJSON(), }, ) diff --git a/x/dogfood/keeper/msg_server.go b/x/dogfood/keeper/msg_server.go index ea1002b69..f4ced9f73 100644 --- a/x/dogfood/keeper/msg_server.go +++ b/x/dogfood/keeper/msg_server.go @@ -116,7 +116,7 @@ func (k Keeper) UpdateParams( } err := k.avsKeeper.UpdateAVSInfo(c, &avstypes.AVSRegisterOrDeregisterParams{ AvsName: c.ChainID(), - AvsAddress: avsAddr.String(), + AvsAddress: avsAddr, AssetID: nextParams.AssetIDs, UnbondingPeriod: uint64(nextParams.EpochsUntilUnbonded), MinSelfDelegation: nextParams.MinSelfDelegation.Uint64(), diff --git a/x/dogfood/keeper/opt_out_test.go b/x/dogfood/keeper/opt_out_test.go index 93fa4edb5..be78ced50 100644 --- a/x/dogfood/keeper/opt_out_test.go +++ b/x/dogfood/keeper/opt_out_test.go @@ -34,7 +34,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { key := utiltx.GenerateConsensusKey() _, err = suite.OperatorMsgServer.OptIntoAVS(sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: key.ToJSON(), }) suite.NoError(err) @@ -227,7 +227,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { &operatortypes.SetConsKeyReq{ Address: operatorAddressString, PublicKeyJSON: newKey.ToJSON(), - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) suite.NoError(err) @@ -287,7 +287,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) suite.NoError(err) diff --git a/x/dogfood/keeper/unbonding_test.go b/x/dogfood/keeper/unbonding_test.go index a9e76d10e..d4a590e03 100644 --- a/x/dogfood/keeper/unbonding_test.go +++ b/x/dogfood/keeper/unbonding_test.go @@ -73,7 +73,7 @@ func (suite *KeeperTestSuite) TestUndelegations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -114,7 +114,7 @@ func (suite *KeeperTestSuite) TestUndelegations() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptOutOfAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, }, ) suite.NoError(err) @@ -234,7 +234,7 @@ func (suite *KeeperTestSuite) TestUndelegationEdgeCases() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: oldKey.ToJSON(), }, ) @@ -285,7 +285,7 @@ func (suite *KeeperTestSuite) TestUndelegationEdgeCases() { sdk.WrapSDKContext(suite.Ctx), &operatortypes.SetConsKeyReq{ Address: operatorAddressString, - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, PublicKeyJSON: newKey.ToJSON(), }, ) diff --git a/x/dogfood/types/expected_keepers.go b/x/dogfood/types/expected_keepers.go index 41c6886cd..f97bd7e29 100644 --- a/x/dogfood/types/expected_keepers.go +++ b/x/dogfood/types/expected_keepers.go @@ -93,6 +93,6 @@ type AssetsKeeper interface { type AVSKeeper interface { RegisterAVSWithChainID(sdk.Context, *avstypes.AVSRegisterOrDeregisterParams) (common.Address, error) - IsAVSByChainID(ctx sdk.Context, chainID string) (bool, common.Address) + IsAVSByChainID(ctx sdk.Context, chainID string) (bool, string) UpdateAVSInfo(ctx sdk.Context, params *avstypes.AVSRegisterOrDeregisterParams) error } diff --git a/x/dogfood/types/genesis.go b/x/dogfood/types/genesis.go index e6dba4e06..79056b074 100644 --- a/x/dogfood/types/genesis.go +++ b/x/dogfood/types/genesis.go @@ -271,13 +271,5 @@ func (gs GenesisState) Validate() error { ) } - if !gs.LastTotalPower.Equal(math.NewInt(totalPower)) { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "last total power mismatch %s, expected %d", - gs.LastTotalPower, totalPower, - ) - } - return nil } diff --git a/x/dogfood/types/genesis.pb.go b/x/dogfood/types/genesis.pb.go index 537536141..584aebea2 100644 --- a/x/dogfood/types/genesis.pb.go +++ b/x/dogfood/types/genesis.pb.go @@ -33,7 +33,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // params refers to the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // val_set is the initial validator set. it onyl represents the active + // val_set is the initial validator set. it only represents the active // validators. ValSet []GenesisValidator `protobuf:"bytes,2,rep,name=val_set,json=valSet,proto3" json:"val_set"` // opt_out_expiries is a list of (future) epochs at the end of which the diff --git a/x/operator/client/cli/tx.go b/x/operator/client/cli/tx.go index 1ad4aaef3..967e2bfb7 100644 --- a/x/operator/client/cli/tx.go +++ b/x/operator/client/cli/tx.go @@ -19,6 +19,7 @@ import ( ) const ( + FlagEarningAddr = "earning-addr" FlagApproveAddr = "approve-addr" FlagMetaInfo = "meta-info" FlagClientChainData = "client-chain-data" @@ -73,10 +74,12 @@ func CmdRegisterOperator() *cobra.Command { }, } - // EarningsAddr is the same as the sender's address, since the operator registration must be - // done by the operators themselves. - f := cmd.Flags() + // EarningAddr may be different from the sender's address. + f.String( + FlagEarningAddr, "", "The address which is used to receive the earning reward in the Exocore chain. "+ + "If not provided, it will default to the sender's address.", + ) // ApproveAddr may be different from the sender's address. f.String( FlagApproveAddr, "", "The address which is used to approve the delegations made to "+ @@ -112,11 +115,16 @@ func newBuildRegisterOperatorMsg( if approveAddr == "" { approveAddr = sender.String() } + // #nosec G703 // this only errors if the flag isn't defined. + earningAddr, _ := fs.GetString(FlagEarningAddr) + if earningAddr == "" { + earningAddr = sender.String() + } metaInfo, _ := fs.GetString(FlagMetaInfo) msg := &types.RegisterOperatorReq{ FromAddress: sender.String(), Info: &types.OperatorInfo{ - EarningsAddr: sender.String(), + EarningsAddr: earningAddr, ApproveAddr: approveAddr, OperatorMetaInfo: metaInfo, }, diff --git a/x/operator/keeper/consensus_keys.go b/x/operator/keeper/consensus_keys.go index fd24600af..6e164f037 100644 --- a/x/operator/keeper/consensus_keys.go +++ b/x/operator/keeper/consensus_keys.go @@ -3,6 +3,11 @@ package keeper import ( "fmt" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" + + "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" @@ -293,7 +298,6 @@ func (k Keeper) CompleteOperatorKeyRemovalForChainID( func (k *Keeper) GetOperatorsForChainID( ctx sdk.Context, chainID string, ) ([]sdk.AccAddress, []types.WrappedConsKey) { - k.Logger(ctx).Info("GetOperatorsForChainID", "chainID", chainID) if isAvs, _ := k.avsKeeper.IsAVSByChainID(ctx, chainID); !isAvs { k.Logger(ctx).Info("GetOperatorsForChainID the chainID is not supported by AVS", "chainID", chainID) return nil, nil @@ -330,13 +334,12 @@ func (k *Keeper) GetOperatorsForChainID( func (k Keeper) GetActiveOperatorsForChainID( ctx sdk.Context, chainID string, ) ([]sdk.AccAddress, []types.WrappedConsKey) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) + isAvs, avsAddrString := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { k.Logger(ctx).Error("GetActiveOperatorsForChainID the chainID is not supported by AVS", "chainID", chainID) return nil, nil } operatorsAddr, pks := k.GetOperatorsForChainID(ctx, chainID) - avsAddrString := avsAddr.String() activeOperator := make([]sdk.AccAddress, 0) activePks := make([]types.WrappedConsKey, 0) // check if the operator is active @@ -356,7 +359,7 @@ func (k Keeper) GetActiveOperatorsForChainID( func (k Keeper) ValidatorByConsAddrForChainID( ctx sdk.Context, consAddr sdk.ConsAddress, chainID string, ) (stakingtypes.Validator, bool) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) + isAvs, avsAddrStr := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { ctx.Logger().Error("ValidatorByConsAddrForChainID the chainID is not supported by AVS", "chainID", chainID) return stakingtypes.Validator{}, false @@ -389,9 +392,9 @@ func (k Keeper) ValidatorByConsAddrForChainID( val.Jailed = k.IsOperatorJailedForChainID(ctx, consAddr, chainID) // set the tokens, delegated shares and minimum self delegation for unjail - minSelfDelegation, err := k.avsKeeper.GetAVSMinimumSelfDelegation(ctx, avsAddr.String()) + minSelfDelegation, err := k.avsKeeper.GetAVSMinimumSelfDelegation(ctx, avsAddrStr) if err != nil { - ctx.Logger().Error("ValidatorByConsAddrForChainID get minimum self delegation for AVS error", "avsAddr", avsAddr.String(), "err", err) + ctx.Logger().Error("ValidatorByConsAddrForChainID get minimum self delegation for AVS error", "avsAddrStr", avsAddrStr, "err", err) return stakingtypes.Validator{}, false } val.MinSelfDelegation = sdk.TokensFromConsensusPower(minSelfDelegation.TruncateInt64(), sdk.DefaultPowerReduction) @@ -438,3 +441,114 @@ func (k Keeper) ClearPreviousConsensusKeys(ctx sdk.Context, chainID string) { store.Delete(iterator.Key()) } } + +func (k *Keeper) SetAllPrevConsKeys(ctx sdk.Context, prevConsKeys []types.PrevConsKey) error { + store := ctx.KVStore(k.storeKey) + for i := range prevConsKeys { + prevKey := prevConsKeys[i] + keys, err := assetstypes.ParseJoinedStoreKey([]byte(prevKey.Key), 2) + if err != nil { + return err + } + chainID := keys[0] + opAccAddr, err := sdk.AccAddressFromBech32(keys[1]) + if err != nil { + return err + } + wrappedKey := types.NewWrappedConsKeyFromHex(prevKey.ConsensusKey) + bz := k.cdc.MustMarshal(wrappedKey.ToTmProtoKey()) + + store.Set(types.KeyForChainIDAndOperatorToPrevConsKey(chainID, opAccAddr), bz) + } + return nil +} + +func (k *Keeper) GetAllPrevConsKeys(ctx sdk.Context) ([]types.PrevConsKey, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.BytePrefixForOperatorAndChainIDToPrevConsKey}) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.PrevConsKey, 0) + for ; iterator.Valid(); iterator.Next() { + var consKey tmprotocrypto.PublicKey + k.cdc.MustUnmarshal(iterator.Value(), &consKey) + chainID, operatorAddr, err := types.ParsePrevConsKey(iterator.Key()) + if err != nil { + return nil, err + } + wrappedConsKey := types.NewWrappedConsKeyFromTmProtoKey(&consKey) + ret = append(ret, types.PrevConsKey{ + Key: string(assetstypes.GetJoinedStoreKey(chainID, operatorAddr.String())), + ConsensusKey: wrappedConsKey.ToHex(), + }) + } + return ret, nil +} + +func (k *Keeper) SetAllOperatorKeyRemovals(ctx sdk.Context, operatorKeyRemoval []types.OperatorKeyRemoval) error { + store := ctx.KVStore(k.storeKey) + for i := range operatorKeyRemoval { + keyRemoval := operatorKeyRemoval[i] + keys, err := assetstypes.ParseJoinedStoreKey([]byte(keyRemoval.Key), 2) + if err != nil { + return err + } + chainID := keys[1] + opAccAddr, err := sdk.AccAddressFromBech32(keys[0]) + if err != nil { + return err + } + store.Set(types.KeyForOperatorKeyRemovalForChainID(opAccAddr, chainID), []byte{}) + } + return nil +} + +func (k *Keeper) GetAllOperatorKeyRemovals(ctx sdk.Context) ([]types.OperatorKeyRemoval, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.BytePrefixForOperatorKeyRemovalForChainID}) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.OperatorKeyRemoval, 0) + for ; iterator.Valid(); iterator.Next() { + operatorAddr, chainID, err := types.ParseKeyForOperatorKeyRemoval(iterator.Key()) + if err != nil { + return nil, err + } + + ret = append(ret, types.OperatorKeyRemoval{ + Key: string(assetstypes.GetJoinedStoreKey(operatorAddr.String(), chainID)), + }) + } + return ret, nil +} + +func (k *Keeper) GetAllOperatorConsKeyRecords(ctx sdk.Context) ([]types.OperatorConsKeyRecord, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.BytePrefixForOperatorAndChainIDToConsKey}) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]types.OperatorConsKeyRecord, 0) + var previousOperator string + for ; iterator.Valid(); iterator.Next() { + operator, chainID, err := types.ParseKeyForOperatorAndChainIDToConsKey(iterator.Key()) + if err != nil { + return nil, err + } + if previousOperator != operator.String() { + assetsByOperator := types.OperatorConsKeyRecord{ + OperatorAddress: operator.String(), + Chains: make([]types.ChainDetails, 0), + } + ret = append(ret, assetsByOperator) + } + var consKey tmprotocrypto.PublicKey + k.cdc.MustUnmarshal(iterator.Value(), &consKey) + index := len(ret) - 1 + ret[index].Chains = append(ret[index].Chains, types.ChainDetails{ + ChainID: chainID, + ConsensusKey: hexutil.Encode(consKey.GetEd25519()), + }) + previousOperator = operator.String() + } + return ret, nil +} diff --git a/x/operator/keeper/genesis.go b/x/operator/keeper/genesis.go index 7edfaea6e..c0faa6346 100644 --- a/x/operator/keeper/genesis.go +++ b/x/operator/keeper/genesis.go @@ -1,6 +1,7 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/operator/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -9,14 +10,90 @@ import ( func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) []abci.ValidatorUpdate { for i := range state.Operators { op := state.Operators[i] // avoid implicit memory aliasing - if err := k.SetOperatorInfo(ctx, op.EarningsAddr, &op); err != nil { - panic(err) + if op.OperatorInfo.EarningsAddr == "" { + op.OperatorInfo.EarningsAddr = op.OperatorAddress } + if err := k.SetOperatorInfo(ctx, op.OperatorAddress, &op.OperatorInfo); err != nil { + panic(errorsmod.Wrap(err, "failed to set operator info")) + } + } + for _, record := range state.OperatorRecords { + addr := record.OperatorAddress + // #nosec G703 // already validated + operatorAddr, _ := sdk.AccAddressFromBech32(addr) + for _, detail := range record.Chains { + wrappedKey := types.NewWrappedConsKeyFromHex(detail.ConsensusKey) + bz := k.cdc.MustMarshal(wrappedKey.ToTmProtoKey()) + k.setOperatorConsKeyForChainIDUnchecked(ctx, operatorAddr, wrappedKey.ToConsAddr(), detail.ChainID, bz) + } + } + // init the state from the general exporting genesis file + err := k.SetAllOptedInfo(ctx, state.OptStates) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all opted info")) + } + err = k.SetAllOperatorUSDValues(ctx, state.OperatorUSDValues) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all operator USD values")) + } + err = k.SetAllAVSUSDValues(ctx, state.AVSUSDValues) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all AVS USD values")) + } + err = k.SetAllSlashStates(ctx, state.SlashStates) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all slash info")) + } + err = k.SetAllPrevConsKeys(ctx, state.PreConsKeys) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all previous consensus keys")) + } + err = k.SetAllOperatorKeyRemovals(ctx, state.OperatorKeyRemovals) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all key removals for operators")) } return []abci.ValidatorUpdate{} } -func (Keeper) ExportGenesis(sdk.Context) *types.GenesisState { - // TODO - return types.DefaultGenesis() +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + res := types.GenesisState{} + var err error + res.Operators = k.AllOperators(ctx) + + res.OperatorRecords, err = k.GetAllOperatorConsKeyRecords(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all consensus keys for operators").Error()) + } + + res.OptStates, err = k.GetAllOptedInfo(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all opted info").Error()) + } + + res.AVSUSDValues, err = k.GetAllAVSUSDValues(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all AVS USD values").Error()) + } + + res.OperatorUSDValues, err = k.GetAllOperatorUSDValues(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all operator USD values").Error()) + } + + res.SlashStates, err = k.GetAllSlashStates(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to set all slashing info").Error()) + } + + res.PreConsKeys, err = k.GetAllPrevConsKeys(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all previous consensus keys").Error()) + } + + res.OperatorKeyRemovals, err = k.GetAllOperatorKeyRemovals(ctx) + if err != nil { + panic(errorsmod.Wrap(err, "failed to get all key removals for operators").Error()) + } + + return &res } diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index bf0c0a0c9..da67b0151 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -6,8 +6,6 @@ import ( sdkmath "cosmossdk.io/math" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ExocoreNetwork/exocore/x/assets/types" - operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -15,9 +13,8 @@ import ( ) type Keeper struct { - storeKey storetypes.StoreKey - cdc codec.BinaryCodec - historicalCtx types.CreateQueryContext + storeKey storetypes.StoreKey + cdc codec.BinaryCodec // other keepers assetsKeeper operatortypes.AssetsKeeper delegationKeeper operatortypes.DelegationKeeper @@ -31,7 +28,6 @@ type Keeper struct { func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - historicalCtx types.CreateQueryContext, assetsKeeper operatortypes.AssetsKeeper, delegationKeeper operatortypes.DelegationKeeper, oracleKeeper operatortypes.OracleKeeper, @@ -41,7 +37,6 @@ func NewKeeper( return Keeper{ storeKey: storeKey, cdc: cdc, - historicalCtx: historicalCtx, assetsKeeper: assetsKeeper, delegationKeeper: delegationKeeper, oracleKeeper: oracleKeeper, diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 5b7990d07..55361bdce 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -21,15 +21,11 @@ import ( func (k *Keeper) SetOperatorInfo( ctx sdk.Context, addr string, info *operatortypes.OperatorInfo, ) (err error) { - // the operator's `addr` must match the earnings address. - if addr != info.EarningsAddr { - return errorsmod.Wrap( - operatortypes.ErrParameterInvalid, - "SetOperatorInfo: earnings address is not equal to the operator address", - ) - } // #nosec G703 // already validated in `ValidateBasic` - opAccAddr, _ := sdk.AccAddressFromBech32(info.EarningsAddr) + opAccAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return errorsmod.Wrap(err, "SetOperatorInfo: error occurred when parse acc address from Bech32") + } // if already registered, this request should go to EditOperator. if k.IsOperator(ctx, opAccAddr) { return errorsmod.Wrap( @@ -79,16 +75,21 @@ func (k *Keeper) OperatorInfo(ctx sdk.Context, addr string) (info *operatortypes return &ret, nil } -// AllOperators return the address list of all operators -func (k *Keeper) AllOperators(ctx sdk.Context) []string { +// AllOperators return the list of all operators' detailed information +func (k *Keeper) AllOperators(ctx sdk.Context) []operatortypes.OperatorDetail { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() - ret := make([]string, 0) + ret := make([]operatortypes.OperatorDetail, 0) for ; iterator.Valid(); iterator.Next() { - accAddr := sdk.AccAddress(iterator.Key()) - ret = append(ret, accAddr.String()) + var operatorInfo operatortypes.OperatorInfo + operatorAddr := sdk.AccAddress(iterator.Key()) + k.cdc.MustUnmarshal(iterator.Value(), &operatorInfo) + ret = append(ret, operatortypes.OperatorDetail{ + OperatorAddress: operatorAddr.String(), + OperatorInfo: operatorInfo, + }) } return ret } @@ -144,7 +145,7 @@ func (k *Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (in infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) value := store.Get(infoKey) if value == nil { - return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %s", opAccAddr)) + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: operator is %s, avs address is %s", opAccAddr, avsAddr)) } ret := operatortypes.OptedInfo{} @@ -194,6 +195,33 @@ func (k *Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) return avsList, nil } +func (k *Keeper) SetAllOptedInfo(ctx sdk.Context, optedStates []operatortypes.OptedState) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + for i := range optedStates { + state := optedStates[i] + bz := k.cdc.MustMarshal(&state.OptInfo) + store.Set([]byte(state.Key), bz) + } + return nil +} + +func (k *Keeper) GetAllOptedInfo(ctx sdk.Context) ([]operatortypes.OptedState, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.OptedState, 0) + for ; iterator.Valid(); iterator.Next() { + var optedInfo operatortypes.OptedInfo + k.cdc.MustUnmarshal(iterator.Value(), &optedInfo) + ret = append(ret, operatortypes.OptedState{ + Key: string(iterator.Key()), + OptInfo: optedInfo, + }) + } + return ret, nil +} + func (k *Keeper) GetOptedInOperatorListByAVS(ctx sdk.Context, avsAddr string) ([]string, error) { // get all opted-in info store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index bbf047312..8570181a6 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -1,8 +1,12 @@ package keeper_test import ( + "fmt" + "cosmossdk.io/math" + operatortype "github.com/ExocoreNetwork/exocore/x/operator/types" + sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -18,6 +22,8 @@ func (suite *OperatorTestSuite) TestOperatorInfo() { }, Commission: stakingtypes.NewCommission(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()), } + suite.Equal(operatortype.AccAddressLength, len(suite.AccAddress)) + fmt.Println("the acc address length is:", len(suite.AccAddress)) err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), info) suite.NoError(err) @@ -28,16 +34,19 @@ func (suite *OperatorTestSuite) TestOperatorInfo() { func (suite *OperatorTestSuite) TestAllOperators() { suite.prepare() - operators := []string{suite.operatorAddr.String(), suite.AccAddress.String()} - info := &operatortype.OperatorInfo{ - EarningsAddr: suite.AccAddress.String(), + operatorDetail := operatortype.OperatorDetail{ + OperatorAddress: suite.AccAddress.String(), + OperatorInfo: operatortype.OperatorInfo{ + EarningsAddr: suite.AccAddress.String(), + OperatorMetaInfo: "testOperator", + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + }, } - err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), info) + err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), &operatorDetail.OperatorInfo) suite.NoError(err) getOperators := suite.App.OperatorKeeper.AllOperators(suite.Ctx) - suite.Contains(getOperators, operators[0]) - suite.Contains(getOperators, operators[1]) + suite.Contains(getOperators, operatorDetail) } // TODO: enable this test when editing operator is implemented. allow for querying diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 4644b7645..683fd8cef 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -155,3 +155,30 @@ func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator return ret.Amount, nil } + +func (k *Keeper) SetAllSlashStates(ctx sdk.Context, slashStates []operatortypes.OperatorSlashState) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) + for i := range slashStates { + state := slashStates[i] + bz := k.cdc.MustMarshal(&state.Info) + store.Set([]byte(state.Key), bz) + } + return nil +} + +func (k *Keeper) GetAllSlashStates(ctx sdk.Context) ([]operatortypes.OperatorSlashState, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.OperatorSlashState, 0) + for ; iterator.Valid(); iterator.Next() { + var slashInfo operatortypes.OperatorSlashInfo + k.cdc.MustUnmarshal(iterator.Value(), &slashInfo) + ret = append(ret, operatortypes.OperatorSlashState{ + Key: string(iterator.Key()), + Info: slashInfo, + }) + } + return ret, nil +} diff --git a/x/operator/keeper/opt_test.go b/x/operator/keeper/opt_test.go index 1b68e2988..f8dedea1e 100644 --- a/x/operator/keeper/opt_test.go +++ b/x/operator/keeper/opt_test.go @@ -1,7 +1,6 @@ package keeper_test import ( - "fmt" "strings" "time" @@ -123,7 +122,6 @@ func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { optedUSDValues, err := suite.App.OperatorKeeper.GetOperatorOptedUSDValue(suite.Ctx, suite.avsAddr, suite.operatorAddr.String()) if expectedState.AVSOperatorShare.IsNil() { - fmt.Println("the err is:", err) suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { suite.NoError(err) diff --git a/x/operator/keeper/slash.go b/x/operator/keeper/slash.go index e9fb2223c..89cfc6594 100644 --- a/x/operator/keeper/slash.go +++ b/x/operator/keeper/slash.go @@ -1,8 +1,9 @@ package keeper import ( - "fmt" + "strings" + "github.com/ExocoreNetwork/exocore/utils" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common/hexutil" @@ -16,10 +17,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// GetSlashIDForDogfood It use infractionType+'/'+'infractionHeight' as the slashID, because /* the slash */event occurs in dogfood doesn't have a TxID. It isn't submitted through an external transaction. +// GetSlashIDForDogfood It use infractionType+'_'+'infractionHeight' as the slashID, because /* the slash */event occurs in dogfood doesn't have a TxID. It isn't submitted through an external transaction. func GetSlashIDForDogfood(infraction stakingtypes.Infraction, infractionHeight int64) string { // #nosec G701 - return string(assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(uint64(infraction)), hexutil.EncodeUint64(uint64(infractionHeight)))) + return strings.Join([]string{hexutil.EncodeUint64(uint64(infraction)), hexutil.EncodeUint64(uint64(infractionHeight))}, utils.DelimiterForID) } // SlashFromUndelegation executes the slash from an undelegation @@ -44,9 +45,12 @@ func SlashFromUndelegation(undelegation *delegationtype.UndelegationRecord, slas } func (k *Keeper) CheckSlashParameter(ctx sdk.Context, parameter *types.SlashInputInfo) error { + if parameter.SlashProportion.IsNil() || parameter.SlashProportion.IsNegative() { + return errorsmod.Wrapf(types.ErrValueIsNilOrZero, "Invalid SlashProportion; expected non-nil and non-negative, got: %+v", parameter.SlashProportion) + } height := ctx.BlockHeight() if parameter.SlashEventHeight > height { - return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("slashEventHeight:%d,curHeight:%d", parameter.SlashEventHeight, height)) + return errorsmod.Wrapf(types.ErrSlashOccurredHeight, "slashEventHeight:%d,curHeight:%d", parameter.SlashEventHeight, height) } if parameter.IsDogFood { @@ -82,8 +86,8 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) ( executionInfo := &types.SlashExecutionInfo{ SlashProportion: newSlashProportion, SlashValue: slashUSDValue, - SlashUndelegations: make([]*types.SlashFromUndelegation, 0), - SlashAssetsPool: make([]*types.SlashFromAssetsPool, 0), + SlashUndelegations: make([]types.SlashFromUndelegation, 0), + SlashAssetsPool: make([]types.SlashFromAssetsPool, 0), } // slash from the unbonding stakers if parameter.SlashEventHeight < ctx.BlockHeight() { @@ -91,7 +95,7 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) ( opFunc := func(undelegation *delegationtype.UndelegationRecord) error { slashFromUndelegation := SlashFromUndelegation(undelegation, newSlashProportion) if slashFromUndelegation != nil { - executionInfo.SlashUndelegations = append(executionInfo.SlashUndelegations, slashFromUndelegation) + executionInfo.SlashUndelegations = append(executionInfo.SlashUndelegations, *slashFromUndelegation) } return nil } @@ -131,7 +135,7 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) ( state.OperatorShare = sdkmath.LegacyNewDec(0) } state.TotalAmount = remainingAmount - executionInfo.SlashAssetsPool = append(executionInfo.SlashAssetsPool, &types.SlashFromAssetsPool{ + executionInfo.SlashAssetsPool = append(executionInfo.SlashAssetsPool, types.SlashFromAssetsPool{ AssetID: assetID, Amount: slashAmount, }) @@ -181,7 +185,7 @@ func (k Keeper) SlashWithInfractionReason( chainID := avstypes.ChainIDWithoutRevision(ctx.ChainID()) isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { - k.Logger(ctx).Error("the chainID is not supported by AVS", chainID) + k.Logger(ctx).Error("the chainID is not supported by AVS", "chainID", chainID) return sdkmath.NewInt(0) } slashID := GetSlashIDForDogfood(infraction, infractionHeight) @@ -190,14 +194,14 @@ func (k Keeper) SlashWithInfractionReason( Power: power, SlashType: uint32(infraction), Operator: addr, - AVSAddr: avsAddr.Hex(), + AVSAddr: avsAddr, SlashID: slashID, SlashEventHeight: infractionHeight, SlashProportion: slashFactor, } err := k.Slash(ctx, slashParam) if err != nil { - k.Logger(ctx).Error(err.Error(), avsAddr.Hex()) + k.Logger(ctx).Error(err.Error(), avsAddr) return sdkmath.NewInt(0) } // todo: The returned value should be the amount of burned Exo if we considering a slash from the reward @@ -209,7 +213,7 @@ func (k Keeper) SlashWithInfractionReason( func (k Keeper) IsOperatorJailedForChainID(ctx sdk.Context, consAddr sdk.ConsAddress, chainID string) bool { found, operatorAddr := k.GetOperatorAddressForChainIDAndConsAddr(ctx, chainID, consAddr) if !found { - k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", consAddr, chainID) + k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", "consAddr", consAddr, "chainID", chainID) return false } @@ -218,9 +222,9 @@ func (k Keeper) IsOperatorJailedForChainID(ctx sdk.Context, consAddr sdk.ConsAdd k.Logger(ctx).Error("the chainID is not supported by AVS", chainID) return false } - optInfo, err := k.GetOptedInfo(ctx, operatorAddr.String(), avsAddr.Hex()) + optInfo, err := k.GetOptedInfo(ctx, operatorAddr.String(), avsAddr) if err != nil { - k.Logger(ctx).Error(err.Error(), operatorAddr, avsAddr.Hex()) + k.Logger(ctx).Error(err.Error(), operatorAddr, avsAddr) return false } return optInfo.Jailed @@ -229,20 +233,20 @@ func (k Keeper) IsOperatorJailedForChainID(ctx sdk.Context, consAddr sdk.ConsAdd func (k *Keeper) SetJailedState(ctx sdk.Context, consAddr sdk.ConsAddress, chainID string, jailed bool) { found, operatorAddr := k.GetOperatorAddressForChainIDAndConsAddr(ctx, chainID, consAddr) if !found { - k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", consAddr, chainID) + k.Logger(ctx).Info("couldn't find operator by consensus address and chainID", "consAddr", consAddr, "chainID", chainID) return } isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainID) if !isAvs { - k.Logger(ctx).Error("the chainID is not supported by AVS", chainID) + k.Logger(ctx).Error("the chainID is not supported by AVS", "chainID", chainID) return } handleFunc := func(info *types.OptedInfo) { info.Jailed = jailed } - err := k.HandleOptedInfo(ctx, operatorAddr.String(), avsAddr.Hex(), handleFunc) + err := k.HandleOptedInfo(ctx, operatorAddr.String(), avsAddr, handleFunc) if err != nil { k.Logger(ctx).Error(err.Error(), chainID) } diff --git a/x/operator/keeper/slash_test.go b/x/operator/keeper/slash_test.go index 9ec64dcb8..a0576cadc 100644 --- a/x/operator/keeper/slash_test.go +++ b/x/operator/keeper/slash_test.go @@ -23,7 +23,7 @@ func (suite *OperatorTestSuite) TestSlashWithInfractionReason() { suite.prepareDelegation(true, suite.assetAddr, delegationAmount) // opt into the AVS - avsAddr := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())).String() + avsAddr := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())) err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, avsAddr) suite.NoError(err) // call the EndBlock to update the voting power @@ -72,11 +72,11 @@ func (suite *OperatorTestSuite) TestSlashWithInfractionReason() { StakerID: suite.stakerID, AssetID: suite.assetID, Amount: newSlashProportion.MulInt(undelegationAmount).TruncateInt(), - }, *slashInfo.ExecutionInfo.SlashUndelegations[0]) + }, slashInfo.ExecutionInfo.SlashUndelegations[0]) suite.Equal(types.SlashFromAssetsPool{ AssetID: suite.assetID, Amount: newSlashProportion.MulInt(delegationRemaining).TruncateInt(), - }, *slashInfo.ExecutionInfo.SlashAssetsPool[0]) + }, slashInfo.ExecutionInfo.SlashAssetsPool[0]) // check the assets state of undelegation and assets pool assetsInfo, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, suite.operatorAddr, suite.assetID) diff --git a/x/operator/keeper/usd_value.go b/x/operator/keeper/usd_value.go index 6a952b793..ee1009948 100644 --- a/x/operator/keeper/usd_value.go +++ b/x/operator/keeper/usd_value.go @@ -22,7 +22,7 @@ import ( // AVSAddr + '/' + operatorAddr -> types.OperatorOptedUSDValue (the total USD share of specified operator and Avs) // This function will be called when some assets supported by Avs are delegated/undelegated or slashed. func (k *Keeper) UpdateOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr string, delta operatortypes.DeltaOperatorUSDInfo) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") @@ -57,7 +57,7 @@ func (k *Keeper) UpdateOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s } func (k *Keeper) InitOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") @@ -82,7 +82,7 @@ func (k *Keeper) InitOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr str // This function will be called when the operator opts out of the AVS, because the USD share // doesn't need to be stored. func (k *Keeper) DeleteOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") @@ -94,7 +94,7 @@ func (k *Keeper) DeleteOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s } func (k *Keeper) DeleteAllOperatorsUSDValueForAVS(ctx sdk.Context, avsAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(avsAddr)) defer iterator.Close() @@ -120,7 +120,7 @@ func (k *Keeper) GetOperatorOptedUSDValue(ctx sdk.Context, avsAddr, operatorAddr }, nil } - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) var ret operatortypes.OperatorOptedUSDValue var key []byte if operatorAddr == "" { @@ -146,7 +146,7 @@ func (k *Keeper) UpdateAVSUSDValue(ctx sdk.Context, avsAddr string, opAmount sdk if opAmount.IsNil() || opAmount.IsZero() { return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, fmt.Sprintf("UpdateAVSUSDValue the opAmount is:%v", opAmount)) } - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForAVS) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) key := []byte(avsAddr) totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} value := store.Get(key) @@ -168,7 +168,7 @@ func (k *Keeper) SetAVSUSDValue(ctx sdk.Context, avsAddr string, amount sdkmath. if amount.IsNil() { return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, fmt.Sprintf("SetAVSUSDValue the amount is:%v", amount)) } - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForAVS) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) key := []byte(avsAddr) setValue := operatortypes.DecValueField{Amount: amount} bz := k.cdc.MustMarshal(&setValue) @@ -177,7 +177,7 @@ func (k *Keeper) SetAVSUSDValue(ctx sdk.Context, avsAddr string, amount sdkmath. } func (k *Keeper) DeleteAVSUSDValue(ctx sdk.Context, avsAddr string) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForAVS) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) key := []byte(avsAddr) store.Delete(key) return nil @@ -189,7 +189,7 @@ func (k *Keeper) DeleteAVSUSDValue(ctx sdk.Context, avsAddr string) error { func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore( ctx.KVStore(k.storeKey), - operatortypes.KeyPrefixVotingPowerForAVS, + operatortypes.KeyPrefixUSDValueForAVS, ) var ret operatortypes.DecValueField key := []byte(avsAddr) @@ -205,7 +205,7 @@ func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.Legacy // IterateOperatorsForAVS is used to iterate the operators of a specified AVS and do some external operations // `isUpdate` is a flag to indicate whether the change of the state should be set to the store. func (k *Keeper) IterateOperatorsForAVS(ctx sdk.Context, avsAddr string, isUpdate bool, opFunc func(operator string, optedUSDValues *operatortypes.OperatorOptedUSDValue) error) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixVotingPowerForOperator) + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(avsAddr)) defer iterator.Close() @@ -231,12 +231,11 @@ func (k *Keeper) IterateOperatorsForAVS(ctx sdk.Context, avsAddr string, isUpdat func (k Keeper) GetVotePowerForChainID( ctx sdk.Context, operators []sdk.AccAddress, chainIDWithoutRevision string, ) ([]int64, error) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) + isAvs, avsAddrString := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) if !isAvs { return nil, errorsmod.Wrap(operatortypes.ErrUnknownChainID, fmt.Sprintf("GetVotePowerForChainID: chainIDWithoutRevision is %s", chainIDWithoutRevision)) } ret := make([]int64, 0) - avsAddrString := avsAddr.String() for _, operator := range operators { // this already filters by the required assetIDs optedUSDValues, err := k.GetOperatorOptedUSDValue(ctx, avsAddrString, operator.String()) @@ -255,7 +254,7 @@ func (k *Keeper) GetOperatorAssetValue(ctx sdk.Context, operator sdk.AccAddress, if !isAvs { return 0, errorsmod.Wrap(operatortypes.ErrUnknownChainID, fmt.Sprintf("GetOperatorAssetValue: chainIDWithoutRevision is %s", chainIDWithoutRevision)) } - optedUSDValues, err := k.GetOperatorOptedUSDValue(ctx, operator.String(), avsAddr.String()) + optedUSDValues, err := k.GetOperatorOptedUSDValue(ctx, operator.String(), avsAddr) if err != nil { return 0, err } @@ -263,6 +262,60 @@ func (k *Keeper) GetOperatorAssetValue(ctx sdk.Context, operator sdk.AccAddress, return optedUSDValues.ActiveUSDValue.TruncateInt64(), nil } +func (k *Keeper) SetAllOperatorUSDValues(ctx sdk.Context, usdValues []operatortypes.OperatorUSDValue) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) + for i := range usdValues { + usdValue := usdValues[i] + bz := k.cdc.MustMarshal(&usdValue.OptedUSDValue) + store.Set([]byte(usdValue.Key), bz) + } + return nil +} + +func (k *Keeper) GetAllOperatorUSDValues(ctx sdk.Context) ([]operatortypes.OperatorUSDValue, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.OperatorUSDValue, 0) + for ; iterator.Valid(); iterator.Next() { + var usdValues operatortypes.OperatorOptedUSDValue + k.cdc.MustUnmarshal(iterator.Value(), &usdValues) + ret = append(ret, operatortypes.OperatorUSDValue{ + Key: string(iterator.Key()), + OptedUSDValue: usdValues, + }) + } + return ret, nil +} + +func (k *Keeper) SetAllAVSUSDValues(ctx sdk.Context, usdValues []operatortypes.AVSUSDValue) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) + for i := range usdValues { + usdValue := usdValues[i] + bz := k.cdc.MustMarshal(&usdValue.Value) + store.Set([]byte(usdValue.AVSAddr), bz) + } + return nil +} + +func (k *Keeper) GetAllAVSUSDValues(ctx sdk.Context) ([]operatortypes.AVSUSDValue, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + ret := make([]operatortypes.AVSUSDValue, 0) + for ; iterator.Valid(); iterator.Next() { + var usdValue operatortypes.DecValueField + k.cdc.MustUnmarshal(iterator.Value(), &usdValue) + ret = append(ret, operatortypes.AVSUSDValue{ + AVSAddr: string(iterator.Key()), + Value: usdValue, + }) + } + return ret, nil +} + // CalculateUSDValueForOperator calculates the total and self usd value for the // operator according to the input assets filter and prices. // This function will be used in slashing calculations and voting power updates per epoch. @@ -347,11 +400,10 @@ func (k Keeper) GetOrCalculateOperatorUSDValues( operator sdk.AccAddress, chainIDWithoutRevision string, ) (optedUSDValues operatortypes.OperatorOptedUSDValue, err error) { - isAvs, avsAddr := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) + isAvs, avsAddrString := k.avsKeeper.IsAVSByChainID(ctx, chainIDWithoutRevision) if !isAvs { return operatortypes.OperatorOptedUSDValue{}, errorsmod.Wrap(operatortypes.ErrUnknownChainID, fmt.Sprintf("GetOrCalculateOperatorUSDValues: chainIDWithoutRevision is %s", chainIDWithoutRevision)) } - avsAddrString := avsAddr.String() // the usd values will be deleted if the operator opts out, so recalculate the // voting power to set the tokens and shares for this case. if !k.IsOptedIn(ctx, operator.String(), avsAddrString) { diff --git a/x/operator/keeper/usd_value_test.go b/x/operator/keeper/usd_value_test.go index 7596c5b15..116f3c6b4 100644 --- a/x/operator/keeper/usd_value_test.go +++ b/x/operator/keeper/usd_value_test.go @@ -14,9 +14,7 @@ const ( MaxDecForTotalSupply = 38 ) -var ( - MaxAssetTotalSupply = sdkmath.NewIntWithDecimal(1, MaxDecForTotalSupply) -) +var MaxAssetTotalSupply = sdkmath.NewIntWithDecimal(1, MaxDecForTotalSupply) func (suite *OperatorTestSuite) TestCalculateUSDValue() { suite.prepare() @@ -81,7 +79,7 @@ func (suite *OperatorTestSuite) TestAVSUSDValue() { err := suite.App.AssetsKeeper.SetStakingAssetInfo( suite.Ctx, &assetstype.StakingAssetInfo{ - AssetBasicInfo: &usdcClientChainAsset, + AssetBasicInfo: usdcClientChainAsset, StakingTotalAmount: sdkmath.NewInt(0), }, ) @@ -122,7 +120,7 @@ func (suite *OperatorTestSuite) TestVotingPowerForDogFood() { addUSDValue := sdkmath.LegacyNewDec(1) chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID()) - avsAddress := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())).String() + avsAddress := avstypes.GenerateAVSAddr(avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID())) // CommitAfter causes the epoch hook to be triggered, and results in writing // of the AVS usd value to the store. suite.CommitAfter(time.Hour*24 + time.Nanosecond) @@ -139,7 +137,7 @@ func (suite *OperatorTestSuite) TestVotingPowerForDogFood() { suite.Equal(1, len(allAssets)) var asset assetstype.AssetInfo for _, value := range allAssets { - asset = *value.AssetBasicInfo + asset = value.AssetBasicInfo } assetAddr := common.HexToAddress(asset.Address) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index b8259014d..f17ff26dc 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -7,7 +7,6 @@ import ( delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" oracletype "github.com/ExocoreNetwork/exocore/x/oracle/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) var _ OracleKeeper = MockOracle{} @@ -24,8 +23,8 @@ type AssetsKeeper interface { f func(assetID string, state *assetstype.OperatorAssetInfo) error, ) error ClientChainExists(ctx sdk.Context, index uint64) bool - GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorAssetInfo, err error) + GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets []assetstype.StakingAssetInfo, err error) } var _ DelegationKeeper = &delegationkeeper.Keeper{} @@ -108,7 +107,7 @@ type AVSKeeper interface { GetEpochEndAVSs(ctx sdk.Context, epochIdentifier string, epochNumber int64) []string // IsAVS returns true if the address is a registered AVS address. IsAVS(ctx sdk.Context, addr string) (bool, error) - IsAVSByChainID(ctx sdk.Context, chainID string) (bool, common.Address) + IsAVSByChainID(ctx sdk.Context, chainID string) (bool, string) } type SlashKeeper interface { diff --git a/x/operator/types/genesis.go b/x/operator/types/genesis.go index 8a44c77be..4a182db95 100644 --- a/x/operator/types/genesis.go +++ b/x/operator/types/genesis.go @@ -2,53 +2,80 @@ package types import ( errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/utils" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) func NewGenesisState( - operators []OperatorInfo, + operators []OperatorDetail, + operatorConsKeys []OperatorConsKeyRecord, + optStates []OptedState, + operatorUSDValues []OperatorUSDValue, + avsUSDValues []AVSUSDValue, + slashStates []OperatorSlashState, + prevConsKeys []PrevConsKey, + operatorKeyRemovals []OperatorKeyRemoval, ) *GenesisState { return &GenesisState{ - Operators: operators, + Operators: operators, + OperatorRecords: operatorConsKeys, + OptStates: optStates, + OperatorUSDValues: operatorUSDValues, + AVSUSDValues: avsUSDValues, + SlashStates: slashStates, + PreConsKeys: prevConsKeys, + OperatorKeyRemovals: operatorKeyRemovals, } } // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - return NewGenesisState(nil) + return NewGenesisState(nil, nil, nil, nil, nil, nil, nil, nil) } -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { +// ValidateOperators rationale for the validation: +// 1. since this function should support chain restarts and upgrades, we cannot require +// the format of the earnings address be EVM only. +func (gs GenesisState) ValidateOperators() (map[string]struct{}, error) { // checks list: // - no duplicate addresses in `gs.Operators`. // - correct bech32 format for each address in `gs.Operators` // - no `chainID` duplicates for earnings addresses list in `gs.Operators`. operators := make(map[string]struct{}, len(gs.Operators)) for _, op := range gs.Operators { - address := op.EarningsAddr + address := op.OperatorAddress if _, found := operators[address]; found { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "duplicate operator address %s", address, ) } _, err := sdk.AccAddressFromBech32(address) if err != nil { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "invalid operator address %s: %s", address, err, ) } + if op.OperatorInfo.EarningsAddr != "" { + _, err := sdk.AccAddressFromBech32(op.OperatorInfo.EarningsAddr) + if err != nil { + return nil, errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid operator earning address %s: %s", op.OperatorInfo.EarningsAddr, err, + ) + } + } operators[address] = struct{}{} - if op.ClientChainEarningsAddr != nil { - lzIDs := make(map[uint64]struct{}, len(op.ClientChainEarningsAddr.EarningInfoList)) - for _, info := range op.ClientChainEarningsAddr.EarningInfoList { + if op.OperatorInfo.ClientChainEarningsAddr != nil { + lzIDs := make(map[uint64]struct{}, len(op.OperatorInfo.ClientChainEarningsAddr.EarningInfoList)) + for _, info := range op.OperatorInfo.ClientChainEarningsAddr.EarningInfoList { lzID := info.LzClientChainID if _, found := lzIDs[lzID]; found { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "duplicate lz client chain id %d", lzID, ) @@ -57,27 +84,466 @@ func (gs GenesisState) Validate() error { // TODO: when moving to support non-EVM chains, this check should be modified // to work based on the `lzID` or possibly removed. if !common.IsHexAddress(info.ClientChainEarningAddr) { - return errorsmod.Wrapf( + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "invalid client chain earning address %s", info.ClientChainEarningAddr, ) } } } - if op.Commission.CommissionRates.Rate.IsNil() || - op.Commission.CommissionRates.MaxRate.IsNil() || - op.Commission.CommissionRates.MaxChangeRate.IsNil() { - return errorsmod.Wrapf( + if op.OperatorInfo.Commission.CommissionRates.Rate.IsNil() || + op.OperatorInfo.Commission.CommissionRates.MaxRate.IsNil() || + op.OperatorInfo.Commission.CommissionRates.MaxChangeRate.IsNil() { + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "missing commission for operator %s", address, ) } - if err := op.Commission.Validate(); err != nil { - return errorsmod.Wrapf( + if err := op.OperatorInfo.Commission.Validate(); err != nil { + return nil, errorsmod.Wrapf( ErrInvalidGenesisData, "invalid commission for operator %s: %s", address, err, ) } } + return operators, nil +} + +// ValidateOperatorConsKeyRecords rationale for the validation: +// 2. since the operator module is not meant to handle dogfooding, we should not check +// whether an operator has keys defined for our chainID. this is left for the dogfood +// module. +func (gs GenesisState) ValidateOperatorConsKeyRecords(operators map[string]struct{}) error { + // - correct bech32 format for each address in `gs.OperatorRecords`. + // - no duplicate addresses in `gs.OperatorRecords`. + // - no operator that is in `gs.OperatorRecords` but not in `gs.Operators`. + // - validity of consensus key format for each entry in `gs.OperatorRecords`. + // - within each chainID, no duplicate consensus keys. + operatorRecords := make(map[string]struct{}, len(gs.OperatorRecords)) + keysByChainID := make(map[string]map[string]struct{}) + for _, record := range gs.OperatorRecords { + addr := record.OperatorAddress + if _, err := sdk.AccAddressFromBech32(addr); err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: invalid operator address %s: %s", record.OperatorAddress, err, + ) + } + if _, found := operatorRecords[addr]; found { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: duplicate operator record for operator %s", addr, + ) + } + operatorRecords[addr] = struct{}{} + if _, opFound := operators[addr]; !opFound { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: operator record for un-registered operator %s", addr, + ) + } + for _, chain := range record.Chains { + chainID := chain.ChainID + if !utils.IsValidChainIDWithoutRevision(chainID) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: invalid chainID without revision, operator %s: chainID: %s", addr, chainID, + ) + } + // Cosmos does not describe a specific `chainID` format, so can't validate it. + if _, found := keysByChainID[chainID]; !found { + keysByChainID[chainID] = make(map[string]struct{}) + } + + if wrappedKey := NewWrappedConsKeyFromHex( + chain.ConsensusKey, + ); wrappedKey == nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: invalid consensus key for operator %s: %s", addr, chain.ConsensusKey, + ) + } + + // within a chain id, there should not be duplicate consensus keys + if _, found := keysByChainID[chainID][chain.ConsensusKey]; found { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidateOperatorConsKeyRecords: duplicate consensus key for operator %s on chain %s", addr, chainID, + ) + } + keysByChainID[chainID][chain.ConsensusKey] = struct{}{} + } + } + return nil +} + +func (gs GenesisState) ValidateOptedStates(operators map[string]struct{}) (map[string]struct{}, error) { + avs := make(map[string]struct{}) + validationFunc := func(_ int, state OptedState) error { + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(state.Key), 2) + if err != nil { + return errorsmod.Wrapf(ErrInvalidGenesisData, "ValidateOptedStates can't parse the joined key: %s", err.Error()) + } + operator, avsAddr := stringList[0], stringList[1] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the opted state, %+v", + state, + ) + } + if state.OptInfo.OptedOutHeight < state.OptInfo.OptedInHeight { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the opted-out height should be greater than the opted-in height, %+v", + state, + ) + } + if !common.IsHexAddress(avsAddr) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the AVS address isn't an ethereum hex address, %+v", + state, + ) + } + avs[avsAddr] = struct{}{} + return nil + } + seenFieldValueFunc := func(state OptedState) (string, struct{}) { + return state.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.OptStates, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return avs, nil +} + +func (gs GenesisState) ValidateAVSUSDValues(optedAVS map[string]struct{}) (map[string]DecValueField, error) { + avsUSDValueMap := make(map[string]DecValueField, 0) + validationFunc := func(_ int, avsUSDValue AVSUSDValue) error { + if !common.IsHexAddress(avsUSDValue.AVSAddr) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the AVS address isn't an ethereum hex address, avsUSDValue: %+v", + avsUSDValue, + ) + } + if _, ok := optedAVS[avsUSDValue.AVSAddr]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the avs address should be in the opted-in map, avsUSDValue: %+v", avsUSDValue, + ) + } + if avsUSDValue.Value.Amount.IsNil() || + avsUSDValue.Value.Amount.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "avsUSDValue is nil or negative, avsUSDValue: %+v", avsUSDValue, + ) + } + avsUSDValueMap[avsUSDValue.AVSAddr] = avsUSDValue.Value + return nil + } + seenFieldValueFunc := func(usdValue AVSUSDValue) (string, struct{}) { + return usdValue.AVSAddr, struct{}{} + } + _, err := utils.CommonValidation(gs.AVSUSDValues, seenFieldValueFunc, validationFunc) + if err != nil { + return nil, errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return avsUSDValueMap, nil +} + +func (gs GenesisState) ValidateOperatorUSDValues(operators map[string]struct{}, avsUSDValues map[string]DecValueField) error { + validationFunc := func(_ int, operatorUSDValue OperatorUSDValue) error { + if operatorUSDValue.OptedUSDValue.SelfUSDValue.IsNil() || + operatorUSDValue.OptedUSDValue.TotalUSDValue.IsNil() || + operatorUSDValue.OptedUSDValue.ActiveUSDValue.IsNil() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "nil field in operatorUSDValue: %+v", + operatorUSDValue, + ) + } + if operatorUSDValue.OptedUSDValue.SelfUSDValue.IsNegative() || + operatorUSDValue.OptedUSDValue.TotalUSDValue.IsNegative() || + operatorUSDValue.OptedUSDValue.ActiveUSDValue.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "negative field in operatorUSDValue: %+v", + operatorUSDValue, + ) + } + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(operatorUSDValue.Key), 2) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + avsAddress, operator := stringList[0], stringList[1] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the voting power, %+v", + operatorUSDValue, + ) + } + avsUSDValue, ok := avsUSDValues[avsAddress] + if !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the parsed AVS address should be in the avsUSDValues map, AVS: %s, avsUSDValues: %+v", + avsAddress, avsUSDValues, + ) + } + + if operatorUSDValue.OptedUSDValue.TotalUSDValue.GT(avsUSDValue.Amount) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the total USD value of operator shouldn't be greater than the total USD value of the AVS, avsUSDValue: %s, operatorUSDValue: %+v", + avsUSDValue.Amount.String(), operatorUSDValue, + ) + } + + if operatorUSDValue.OptedUSDValue.SelfUSDValue.GT(operatorUSDValue.OptedUSDValue.TotalUSDValue) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the operator's self USD value shouldn't be greater than its total USD value, operatorUSDValue: %+v", operatorUSDValue, + ) + } + + if operatorUSDValue.OptedUSDValue.ActiveUSDValue.GT(operatorUSDValue.OptedUSDValue.TotalUSDValue) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the operator's active USD value shouldn't be greater than its total USD value, operatorUSDValue: %+v", operatorUSDValue, + ) + } + return nil + } + seenFieldValueFunc := func(vp OperatorUSDValue) (string, struct{}) { + return vp.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.OperatorUSDValues, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateSlashStates(operators, avs map[string]struct{}) error { + validationFunc := func(_ int, slash OperatorSlashState) error { + stringList, err := assetstypes.ParseJoinedStoreKey([]byte(slash.Key), 3) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + operator, avsAddr := stringList[0], stringList[1] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the slashing state, %+v", + slash, + ) + } + // check whether the AVS is in the opted states. + // This check might be removed if the opted-in states are deleted when + // the operator opts out of the AVS. + if _, ok := avs[avsAddr]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown AVS address for the slashing state, %+v", + slash, + ) + } + if slash.Info.EventHeight > slash.Info.SubmittedHeight { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "the submitted height shouldn't be greater than the event height for a slashing record, %+v", + slash, + ) + } + if slash.Info.SlashProportion.IsNil() || slash.Info.SlashProportion.LTE(sdkmath.LegacyNewDec(0)) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slash proportion, it's nil, zero, or negative: %+v", + slash, + ) + } + + // validate the slashing execution information + // the actual executed proportion and value might be zero because of the rounding in an extreme case + if slash.Info.ExecutionInfo.SlashProportion.IsNil() || slash.Info.ExecutionInfo.SlashProportion.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing execution proportion, it's nil, or negative: %+v", + slash, + ) + } + if slash.Info.ExecutionInfo.SlashValue.IsNil() || slash.Info.ExecutionInfo.SlashValue.IsNegative() { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing execution value, it's nil, or negative: %+v", + slash, + ) + } + // validate the slashing record regarding undelegation + SlashFromUndelegationVal := func(_ int, slashFromUndelegation SlashFromUndelegation) error { + if slashFromUndelegation.Amount.IsNil() || slashFromUndelegation.Amount.LTE(sdkmath.NewInt(0)) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing amount from the undelegation, it's nil, zero, or negative: %+v", + slash, + ) + } + return nil + } + seenFieldValueFunc := func(slashFromUndelegation SlashFromUndelegation) (string, struct{}) { + key := assetstypes.GetJoinedStoreKey(slashFromUndelegation.StakerID, slashFromUndelegation.AssetID) + return string(key), struct{}{} + } + _, err = utils.CommonValidation(slash.Info.ExecutionInfo.SlashUndelegations, seenFieldValueFunc, SlashFromUndelegationVal) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + // validate the slashing record regarding assets pool + SlashFromAssetsPoolVal := func(_ int, slashFromAssetsPool SlashFromAssetsPool) error { + if slashFromAssetsPool.Amount.IsNil() || slashFromAssetsPool.Amount.LTE(sdkmath.NewInt(0)) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid slashing amount from the assets pool, it's nil, zero, or negative: %+v", + slash, + ) + } + return nil + } + SlashFromAssetsPooLSeenFunc := func(slashFromAssetsPool SlashFromAssetsPool) (string, struct{}) { + return slashFromAssetsPool.AssetID, struct{}{} + } + _, err = utils.CommonValidation(slash.Info.ExecutionInfo.SlashAssetsPool, SlashFromAssetsPooLSeenFunc, SlashFromAssetsPoolVal) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil + } + seenFieldValueFunc := func(slash OperatorSlashState) (string, struct{}) { + return slash.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.SlashStates, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidatePrevConsKeys(operators map[string]struct{}) error { + validationFunc := func(_ int, prevConsKey PrevConsKey) error { + keys, err := assetstypes.ParseJoinedStoreKey([]byte(prevConsKey.Key), 2) + if err != nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidatePrevConsKeys can't parse the combined key, %+v", + prevConsKey, + ) + } + + chainID, operator := keys[0], keys[1] + if !utils.IsValidChainIDWithoutRevision(chainID) { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "ValidatePrevConsKeys: invalid chainID without revision, operator %s: chainID: %s", operator, chainID, + ) + } + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the previous consensus key, %+v", + prevConsKey, + ) + } + if wrappedKey := NewWrappedConsKeyFromHex( + prevConsKey.ConsensusKey, + ); wrappedKey == nil { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "invalid previous consensus key for operator, %+v", prevConsKey, + ) + } + // todo: not sure if the duplication of previous consensus keys needs to be checked + return nil + } + seenFieldValueFunc := func(prevConsKey PrevConsKey) (string, struct{}) { + return prevConsKey.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.PreConsKeys, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +func (gs GenesisState) ValidateOperatorKeyRemovals(operators map[string]struct{}) error { + validationFunc := func(_ int, operatorKeyRemoval OperatorKeyRemoval) error { + keys, err := assetstypes.ParseJoinedStoreKey([]byte(operatorKeyRemoval.Key), 2) + if err != nil { + return err + } + operator := keys[0] + // check that the operator is registered + if _, ok := operators[operator]; !ok { + return errorsmod.Wrapf( + ErrInvalidGenesisData, + "unknown operator address for the operator key removal, %+v", + operatorKeyRemoval, + ) + } + return nil + } + seenFieldValueFunc := func(operatorKeyRemoval OperatorKeyRemoval) (string, struct{}) { + return operatorKeyRemoval.Key, struct{}{} + } + _, err := utils.CommonValidation(gs.OperatorKeyRemovals, seenFieldValueFunc, validationFunc) + if err != nil { + return errorsmod.Wrap(ErrInvalidGenesisData, err.Error()) + } + return nil +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + operators, err := gs.ValidateOperators() + if err != nil { + return err + } + err = gs.ValidateOperatorConsKeyRecords(operators) + if err != nil { + return err + } + avsMap, err := gs.ValidateOptedStates(operators) + if err != nil { + return err + } + avsUSDValueMap, err := gs.ValidateAVSUSDValues(avsMap) + if err != nil { + return err + } + err = gs.ValidateOperatorUSDValues(operators, avsUSDValueMap) + if err != nil { + return err + } + err = gs.ValidateSlashStates(operators, avsMap) + if err != nil { + return err + } + err = gs.ValidatePrevConsKeys(operators) + if err != nil { + return err + } + err = gs.ValidateOperatorKeyRemovals(operators) + if err != nil { + return err + } return nil } diff --git a/x/operator/types/genesis.pb.go b/x/operator/types/genesis.pb.go index 184ea96d0..0b55379ab 100644 --- a/x/operator/types/genesis.pb.go +++ b/x/operator/types/genesis.pb.go @@ -29,7 +29,27 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // there are no params for this module. // operators is a list of the registered operators. - Operators []OperatorInfo `protobuf:"bytes,1,rep,name=operators,proto3" json:"operators"` + Operators []OperatorDetail `protobuf:"bytes,1,rep,name=operators,proto3" json:"operators"` + // add other information for exporting / importing. + // Although it is not necessary for the bootstrapped genesis, it is + // necessary for chain restarts. + // operator_records refers to a list of operator records. each record + // contains an operator address and a list of chain id + + // cons key combination. + OperatorRecords []OperatorConsKeyRecord `protobuf:"bytes,2,rep,name=operator_records,json=operatorRecords,proto3" json:"operator_records"` + // opt_states is a list of all opted information for the AVS and operators + OptStates []OptedState `protobuf:"bytes,3,rep,name=opt_states,json=optStates,proto3" json:"opt_states"` + // avs_usd_values is a list of AVS USD value + AVSUSDValues []AVSUSDValue `protobuf:"bytes,4,rep,name=avs_usd_values,json=avsUsdValues,proto3" json:"avs_usd_values"` + // operator_usd_values is a list of operator USD value + OperatorUSDValues []OperatorUSDValue `protobuf:"bytes,5,rep,name=operator_usd_values,json=operatorUsdValues,proto3" json:"operator_usd_values"` + // slash_states is a list of all slashing information + SlashStates []OperatorSlashState `protobuf:"bytes,6,rep,name=slash_states,json=slashStates,proto3" json:"slash_states"` + // pre_cons_key is a list of all previous consensus public key + PreConsKeys []PrevConsKey `protobuf:"bytes,7,rep,name=pre_cons_keys,json=preConsKeys,proto3" json:"pre_cons_keys"` + // operator_key_removal is a list of operator with the given address + // is in the process of unbonding their key for the given chainID. + OperatorKeyRemovals []OperatorKeyRemoval `protobuf:"bytes,8,rep,name=operator_key_removals,json=operatorKeyRemovals,proto3" json:"operator_key_removals"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -65,35 +85,84 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetOperators() []OperatorInfo { +func (m *GenesisState) GetOperators() []OperatorDetail { if m != nil { return m.Operators } return nil } -// StakerRecord is a helper structure for the genesis state. Each record -// contains a staker address and a list of asset IDs with their operator + -// amount combination. -type StakerRecord struct { - // staker_id denotes the address + l0id of the staker. - StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` - // staker_details is a list of asset ID + operator + amount combination. - StakerDetails []StakerDetails `protobuf:"bytes,2,rep,name=staker_details,json=stakerDetails,proto3" json:"staker_details"` +func (m *GenesisState) GetOperatorRecords() []OperatorConsKeyRecord { + if m != nil { + return m.OperatorRecords + } + return nil } -func (m *StakerRecord) Reset() { *m = StakerRecord{} } -func (m *StakerRecord) String() string { return proto.CompactTextString(m) } -func (*StakerRecord) ProtoMessage() {} -func (*StakerRecord) Descriptor() ([]byte, []int) { +func (m *GenesisState) GetOptStates() []OptedState { + if m != nil { + return m.OptStates + } + return nil +} + +func (m *GenesisState) GetAVSUSDValues() []AVSUSDValue { + if m != nil { + return m.AVSUSDValues + } + return nil +} + +func (m *GenesisState) GetOperatorUSDValues() []OperatorUSDValue { + if m != nil { + return m.OperatorUSDValues + } + return nil +} + +func (m *GenesisState) GetSlashStates() []OperatorSlashState { + if m != nil { + return m.SlashStates + } + return nil +} + +func (m *GenesisState) GetPreConsKeys() []PrevConsKey { + if m != nil { + return m.PreConsKeys + } + return nil +} + +func (m *GenesisState) GetOperatorKeyRemovals() []OperatorKeyRemoval { + if m != nil { + return m.OperatorKeyRemovals + } + return nil +} + +// OperatorDetail is helper structure to store the operator information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorInfo` +type OperatorDetail struct { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // operator_info is the detail information for the above operator + OperatorInfo OperatorInfo `protobuf:"bytes,2,opt,name=operator_info,json=operatorInfo,proto3" json:"operator_info"` +} + +func (m *OperatorDetail) Reset() { *m = OperatorDetail{} } +func (m *OperatorDetail) String() string { return proto.CompactTextString(m) } +func (*OperatorDetail) ProtoMessage() {} +func (*OperatorDetail) Descriptor() ([]byte, []int) { return fileDescriptor_bb7040bc6ae6ddee, []int{1} } -func (m *StakerRecord) XXX_Unmarshal(b []byte) error { +func (m *OperatorDetail) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OperatorDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerRecord.Marshal(b, m, deterministic) + return xxx_messageInfo_OperatorDetail.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -103,53 +172,54 @@ func (m *StakerRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *StakerRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerRecord.Merge(m, src) +func (m *OperatorDetail) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorDetail.Merge(m, src) } -func (m *StakerRecord) XXX_Size() int { +func (m *OperatorDetail) XXX_Size() int { return m.Size() } -func (m *StakerRecord) XXX_DiscardUnknown() { - xxx_messageInfo_StakerRecord.DiscardUnknown(m) +func (m *OperatorDetail) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorDetail.DiscardUnknown(m) } -var xxx_messageInfo_StakerRecord proto.InternalMessageInfo +var xxx_messageInfo_OperatorDetail proto.InternalMessageInfo -func (m *StakerRecord) GetStakerID() string { +func (m *OperatorDetail) GetOperatorAddress() string { if m != nil { - return m.StakerID + return m.OperatorAddress } return "" } -func (m *StakerRecord) GetStakerDetails() []StakerDetails { +func (m *OperatorDetail) GetOperatorInfo() OperatorInfo { if m != nil { - return m.StakerDetails + return m.OperatorInfo } - return nil + return OperatorInfo{} } -// StakerDetails is a helper structure for the genesis state. Each record -// contains an asset ID and a list of operator + amount combination. -type StakerDetails struct { - // asset_id is the unique identifier of the asset. - AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` - // details is a list of operator + amount combination. - Details []AssetDetails `protobuf:"bytes,2,rep,name=details,proto3" json:"details"` +// OptedStates is helper structure to store the opted state for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorOptedAVSInfo` +type OptedState struct { + // key is used for storing the opted states, + // which is a combination of the operator address and AVS address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // opt_info is the value of undelegation state for the above key + OptInfo OptedInfo `protobuf:"bytes,2,opt,name=opt_info,json=optInfo,proto3" json:"opt_info"` } -func (m *StakerDetails) Reset() { *m = StakerDetails{} } -func (m *StakerDetails) String() string { return proto.CompactTextString(m) } -func (*StakerDetails) ProtoMessage() {} -func (*StakerDetails) Descriptor() ([]byte, []int) { +func (m *OptedState) Reset() { *m = OptedState{} } +func (m *OptedState) String() string { return proto.CompactTextString(m) } +func (*OptedState) ProtoMessage() {} +func (*OptedState) Descriptor() ([]byte, []int) { return fileDescriptor_bb7040bc6ae6ddee, []int{2} } -func (m *StakerDetails) XXX_Unmarshal(b []byte) error { +func (m *OptedState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptedState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerDetails.Marshal(b, m, deterministic) + return xxx_messageInfo_OptedState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -159,55 +229,53 @@ func (m *StakerDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } -func (m *StakerDetails) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerDetails.Merge(m, src) +func (m *OptedState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptedState.Merge(m, src) } -func (m *StakerDetails) XXX_Size() int { +func (m *OptedState) XXX_Size() int { return m.Size() } -func (m *StakerDetails) XXX_DiscardUnknown() { - xxx_messageInfo_StakerDetails.DiscardUnknown(m) +func (m *OptedState) XXX_DiscardUnknown() { + xxx_messageInfo_OptedState.DiscardUnknown(m) } -var xxx_messageInfo_StakerDetails proto.InternalMessageInfo +var xxx_messageInfo_OptedState proto.InternalMessageInfo -func (m *StakerDetails) GetAssetID() string { +func (m *OptedState) GetKey() string { if m != nil { - return m.AssetID + return m.Key } return "" } -func (m *StakerDetails) GetDetails() []AssetDetails { +func (m *OptedState) GetOptInfo() OptedInfo { if m != nil { - return m.Details + return m.OptInfo } - return nil + return OptedInfo{} } -// AssetDetails is a helper structure for the genesis state. Each record -// contains an operator and an amount. -type AssetDetails struct { - // operator_address is the address of the operator as the bech32 - // version of sdk.AccAddress. - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` - // amount is the amount of the asset staked by the staker for this - // asset and operator. - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +// AVSUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForAVS` +type AVSUSDValue struct { + // avs_addr + AVSAddr string `protobuf:"bytes,1,opt,name=avs_addr,json=avsAddr,proto3" json:"avs_addr,omitempty"` + // value is the USD value for the AVS address + Value DecValueField `protobuf:"bytes,2,opt,name=value,proto3" json:"value"` } -func (m *AssetDetails) Reset() { *m = AssetDetails{} } -func (m *AssetDetails) String() string { return proto.CompactTextString(m) } -func (*AssetDetails) ProtoMessage() {} -func (*AssetDetails) Descriptor() ([]byte, []int) { +func (m *AVSUSDValue) Reset() { *m = AVSUSDValue{} } +func (m *AVSUSDValue) String() string { return proto.CompactTextString(m) } +func (*AVSUSDValue) ProtoMessage() {} +func (*AVSUSDValue) Descriptor() ([]byte, []int) { return fileDescriptor_bb7040bc6ae6ddee, []int{3} } -func (m *AssetDetails) XXX_Unmarshal(b []byte) error { +func (m *AVSUSDValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *AssetDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AVSUSDValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_AssetDetails.Marshal(b, m, deterministic) + return xxx_messageInfo_AVSUSDValue.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -217,316 +285,2584 @@ func (m *AssetDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *AssetDetails) XXX_Merge(src proto.Message) { - xxx_messageInfo_AssetDetails.Merge(m, src) +func (m *AVSUSDValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_AVSUSDValue.Merge(m, src) } -func (m *AssetDetails) XXX_Size() int { +func (m *AVSUSDValue) XXX_Size() int { return m.Size() } -func (m *AssetDetails) XXX_DiscardUnknown() { - xxx_messageInfo_AssetDetails.DiscardUnknown(m) +func (m *AVSUSDValue) XXX_DiscardUnknown() { + xxx_messageInfo_AVSUSDValue.DiscardUnknown(m) } -var xxx_messageInfo_AssetDetails proto.InternalMessageInfo +var xxx_messageInfo_AVSUSDValue proto.InternalMessageInfo -func (m *AssetDetails) GetOperatorAddress() string { +func (m *AVSUSDValue) GetAVSAddr() string { if m != nil { - return m.OperatorAddress + return m.AVSAddr } return "" } -func init() { - proto.RegisterType((*GenesisState)(nil), "exocore.operator.v1.GenesisState") - proto.RegisterType((*StakerRecord)(nil), "exocore.operator.v1.StakerRecord") - proto.RegisterType((*StakerDetails)(nil), "exocore.operator.v1.StakerDetails") - proto.RegisterType((*AssetDetails)(nil), "exocore.operator.v1.AssetDetails") +func (m *AVSUSDValue) GetValue() DecValueField { + if m != nil { + return m.Value + } + return DecValueField{} } -func init() { proto.RegisterFile("exocore/operator/v1/genesis.proto", fileDescriptor_bb7040bc6ae6ddee) } - -var fileDescriptor_bb7040bc6ae6ddee = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0xae, 0xd2, 0x40, - 0x14, 0x86, 0x3b, 0x57, 0x73, 0x81, 0xb9, 0xbd, 0x6a, 0x46, 0x17, 0xf5, 0xc6, 0xb4, 0x97, 0x2e, - 0x08, 0x2c, 0x68, 0x03, 0x6e, 0xdd, 0x40, 0x20, 0xa6, 0x89, 0x91, 0xa4, 0xe8, 0xc6, 0x0d, 0x29, - 0x9d, 0xb1, 0x36, 0x48, 0x87, 0xcc, 0x0c, 0x88, 0x3e, 0x82, 0x1b, 0x7d, 0x18, 0x1f, 0x82, 0x25, - 0x71, 0x65, 0x5c, 0x34, 0xa6, 0xbc, 0x88, 0x61, 0x66, 0x1a, 0x20, 0xe9, 0xaa, 0x33, 0xff, 0xf9, - 0xcf, 0x39, 0x5f, 0x27, 0x3f, 0x6c, 0x92, 0x2d, 0x8d, 0x29, 0x23, 0x3e, 0x5d, 0x11, 0x16, 0x09, - 0xca, 0xfc, 0x4d, 0xcf, 0x4f, 0x48, 0x46, 0x78, 0xca, 0xbd, 0x15, 0xa3, 0x82, 0xa2, 0xa7, 0xda, - 0xe2, 0x95, 0x16, 0x6f, 0xd3, 0xbb, 0x7b, 0x1e, 0x53, 0xbe, 0xa4, 0x7c, 0x26, 0x2d, 0xbe, 0xba, - 0x28, 0xff, 0xdd, 0xb3, 0x84, 0x26, 0x54, 0xe9, 0xc7, 0x93, 0x56, 0x5f, 0x54, 0x2d, 0x12, 0x5b, - 0x55, 0x75, 0xdf, 0x43, 0xf3, 0xb5, 0x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, 0x74, 0xa9, 0x03, - 0xa0, 0x3f, 0x5d, 0x8e, 0x17, 0xbe, 0xf8, 0xba, 0x22, 0xdc, 0x0b, 0x32, 0xf1, 0xfb, 0x57, 0x17, - 0xea, 0x7c, 0x04, 0x99, 0x08, 0xf5, 0xac, 0xe1, 0x9b, 0x5d, 0x61, 0x83, 0x7d, 0x61, 0x83, 0x7f, - 0x85, 0x0d, 0x7e, 0x1e, 0x6c, 0x63, 0x7f, 0xb0, 0x8d, 0x3f, 0x07, 0xdb, 0xf8, 0xd0, 0x3f, 0x9b, - 0x3b, 0x56, 0xff, 0xf9, 0x96, 0x88, 0x2f, 0x94, 0x2d, 0xfc, 0x32, 0x43, 0xdb, 0x53, 0x8a, 0xe4, - 0x9e, 0xf9, 0xb5, 0x8c, 0xd1, 0xcb, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x40, 0x9d, 0xcc, - 0xcf, 0x02, 0x00, 0x00, +// OperatorUSDValue is helper structure to store the USD value for the genesis state. +// it's corresponding to the kvStore `KeyPrefixUSDValueForOperator` +type OperatorUSDValue struct { + // key is used for storing the voting power of specified operator and AVS, + // which is the combination of operator and AVS address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // value is the USD value states for the AVS address + OptedUSDValue OperatorOptedUSDValue `protobuf:"bytes,2,opt,name=opted_usd_value,json=optedUsdValue,proto3" json:"opted_usd_value"` } -func (m *GenesisState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *OperatorUSDValue) Reset() { *m = OperatorUSDValue{} } +func (m *OperatorUSDValue) String() string { return proto.CompactTextString(m) } +func (*OperatorUSDValue) ProtoMessage() {} +func (*OperatorUSDValue) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{4} +} +func (m *OperatorUSDValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorUSDValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorUSDValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *OperatorUSDValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorUSDValue.Merge(m, src) +} +func (m *OperatorUSDValue) XXX_Size() int { + return m.Size() +} +func (m *OperatorUSDValue) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorUSDValue.DiscardUnknown(m) } -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Operators) > 0 { - for iNdEx := len(m.Operators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Operators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +var xxx_messageInfo_OperatorUSDValue proto.InternalMessageInfo + +func (m *OperatorUSDValue) GetKey() string { + if m != nil { + return m.Key } - return len(dAtA) - i, nil + return "" } -func (m *StakerRecord) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *OperatorUSDValue) GetOptedUSDValue() OperatorOptedUSDValue { + if m != nil { + return m.OptedUSDValue } - return dAtA[:n], nil + return OperatorOptedUSDValue{} } -func (m *StakerRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// OperatorSlashState is helper structure to store the slash information for the genesis state. +// it's corresponding to the kvStore `KeyPrefixOperatorSlashInfo` +type OperatorSlashState struct { + // key is used for storing the slash information, + // which is the combination of the operator address, AVS address, and slashID. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // states is the voting power value for the above key + Info OperatorSlashInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` } -func (m *StakerRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StakerDetails) > 0 { - for iNdEx := len(m.StakerDetails) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StakerDetails[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func (m *OperatorSlashState) Reset() { *m = OperatorSlashState{} } +func (m *OperatorSlashState) String() string { return proto.CompactTextString(m) } +func (*OperatorSlashState) ProtoMessage() {} +func (*OperatorSlashState) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{5} +} +func (m *OperatorSlashState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorSlashState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorSlashState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } + return b[:n], nil } - if len(m.StakerID) > 0 { - i -= len(m.StakerID) - copy(dAtA[i:], m.StakerID) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.StakerID))) - i-- - dAtA[i] = 0xa +} +func (m *OperatorSlashState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorSlashState.Merge(m, src) +} +func (m *OperatorSlashState) XXX_Size() int { + return m.Size() +} +func (m *OperatorSlashState) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorSlashState.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorSlashState proto.InternalMessageInfo + +func (m *OperatorSlashState) GetKey() string { + if m != nil { + return m.Key } - return len(dAtA) - i, nil + return "" } -func (m *StakerDetails) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *OperatorSlashState) GetInfo() OperatorSlashInfo { + if m != nil { + return m.Info } - return dAtA[:n], nil + return OperatorSlashInfo{} } -func (m *StakerDetails) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// PrevConsKey is helper structure to store the previous consensus key +// for the operator and chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorAndChainIDToPrevConsKey` +type PrevConsKey struct { + // key is used for storing the previous consensus key, + // which is the combination of chainID and operator address. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + ConsensusKey string `protobuf:"bytes,2,opt,name=consensus_key,json=consensusKey,proto3" json:"consensus_key,omitempty"` } -func (m *StakerDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Details) > 0 { - for iNdEx := len(m.Details) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Details[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.AssetID) > 0 { - i -= len(m.AssetID) - copy(dAtA[i:], m.AssetID) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.AssetID))) - i-- - dAtA[i] = 0xa +func (m *PrevConsKey) Reset() { *m = PrevConsKey{} } +func (m *PrevConsKey) String() string { return proto.CompactTextString(m) } +func (*PrevConsKey) ProtoMessage() {} +func (*PrevConsKey) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{6} +} +func (m *PrevConsKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrevConsKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrevConsKey.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return len(dAtA) - i, nil +} +func (m *PrevConsKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrevConsKey.Merge(m, src) +} +func (m *PrevConsKey) XXX_Size() int { + return m.Size() +} +func (m *PrevConsKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrevConsKey.DiscardUnknown(m) } -func (m *AssetDetails) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_PrevConsKey proto.InternalMessageInfo + +func (m *PrevConsKey) GetKey() string { + if m != nil { + return m.Key } - return dAtA[:n], nil + return "" } -func (m *AssetDetails) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *PrevConsKey) GetConsensusKey() string { + if m != nil { + return m.ConsensusKey + } + return "" } -func (m *AssetDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err +// OperatorKeyRemoval is helper structure to store the operator with the given address +// is in the process of unbonding their key for the given chainID. +// it's corresponding to the kvStore `BytePrefixForOperatorKeyRemovalForChainID` +type OperatorKeyRemoval struct { + // key is the combination of operator address and chainID. + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *OperatorKeyRemoval) Reset() { *m = OperatorKeyRemoval{} } +func (m *OperatorKeyRemoval) String() string { return proto.CompactTextString(m) } +func (*OperatorKeyRemoval) ProtoMessage() {} +func (*OperatorKeyRemoval) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{7} +} +func (m *OperatorKeyRemoval) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorKeyRemoval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorKeyRemoval.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i = encodeVarintGenesis(dAtA, i, uint64(size)) + return b[:n], nil } - i-- - dAtA[i] = 0x12 - if len(m.OperatorAddress) > 0 { - i -= len(m.OperatorAddress) - copy(dAtA[i:], m.OperatorAddress) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) - i-- - dAtA[i] = 0xa +} +func (m *OperatorKeyRemoval) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorKeyRemoval.Merge(m, src) +} +func (m *OperatorKeyRemoval) XXX_Size() int { + return m.Size() +} +func (m *OperatorKeyRemoval) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorKeyRemoval.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorKeyRemoval proto.InternalMessageInfo + +func (m *OperatorKeyRemoval) GetKey() string { + if m != nil { + return m.Key } - return len(dAtA) - i, nil + return "" } -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +// OperatorConsKeyRecord is a helper structure for the genesis state. Each record +// contains an operator address and a list of chain id + cons key combination. +type OperatorConsKeyRecord struct { + // operator_address is the address of the operator as the bech32 + // encoded version of sdk.AccAddress. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // chains is a list of chain id + consensus key combination. + Chains []ChainDetails `protobuf:"bytes,2,rep,name=chains,proto3" json:"chains"` +} + +func (m *OperatorConsKeyRecord) Reset() { *m = OperatorConsKeyRecord{} } +func (m *OperatorConsKeyRecord) String() string { return proto.CompactTextString(m) } +func (*OperatorConsKeyRecord) ProtoMessage() {} +func (*OperatorConsKeyRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{8} +} +func (m *OperatorConsKeyRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorConsKeyRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorConsKeyRecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - dAtA[offset] = uint8(v) - return base } -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 +func (m *OperatorConsKeyRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorConsKeyRecord.Merge(m, src) +} +func (m *OperatorConsKeyRecord) XXX_Size() int { + return m.Size() +} +func (m *OperatorConsKeyRecord) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorConsKeyRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorConsKeyRecord proto.InternalMessageInfo + +func (m *OperatorConsKeyRecord) GetOperatorAddress() string { + if m != nil { + return m.OperatorAddress } - var l int - _ = l - if len(m.Operators) > 0 { - for _, e := range m.Operators { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + return "" +} + +func (m *OperatorConsKeyRecord) GetChains() []ChainDetails { + if m != nil { + return m.Chains + } + return nil +} + +// ChainDetails is a helper structure for the genesis state. Each record +// contains a chain id and a consensus key. +type ChainDetails struct { + // chain_id is the unique identifier of the chain. + ChainID string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // consensus_key is the consensus key of the operator on the chain. + // the length of this key should be exactly 32 bytes, and must be enforced + // outside of protobuf. It's the hex encoding of the 32 bytes. + ConsensusKey string `protobuf:"bytes,2,opt,name=consensus_key,json=consensusKey,proto3" json:"consensus_key,omitempty"` +} + +func (m *ChainDetails) Reset() { *m = ChainDetails{} } +func (m *ChainDetails) String() string { return proto.CompactTextString(m) } +func (*ChainDetails) ProtoMessage() {} +func (*ChainDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{9} +} +func (m *ChainDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ChainDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ChainDetails.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } + return b[:n], nil } - return n +} +func (m *ChainDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChainDetails.Merge(m, src) +} +func (m *ChainDetails) XXX_Size() int { + return m.Size() +} +func (m *ChainDetails) XXX_DiscardUnknown() { + xxx_messageInfo_ChainDetails.DiscardUnknown(m) } -func (m *StakerRecord) Size() (n int) { - if m == nil { - return 0 +var xxx_messageInfo_ChainDetails proto.InternalMessageInfo + +func (m *ChainDetails) GetChainID() string { + if m != nil { + return m.ChainID } - var l int - _ = l - l = len(m.StakerID) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + return "" +} + +func (m *ChainDetails) GetConsensusKey() string { + if m != nil { + return m.ConsensusKey } - if len(m.StakerDetails) > 0 { - for _, e := range m.StakerDetails { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + return "" +} + +// StakerRecord is a helper structure for the genesis state. Each record +// contains a staker address and a list of asset IDs with their operator + +// amount combination. +type StakerRecord struct { + // staker_id denotes the address + l0id of the staker. + StakerID string `protobuf:"bytes,1,opt,name=staker_id,json=stakerId,proto3" json:"staker_id,omitempty"` + // staker_details is a list of asset ID + operator + amount combination. + StakerDetails []StakerDetails `protobuf:"bytes,2,rep,name=staker_details,json=stakerDetails,proto3" json:"staker_details"` +} + +func (m *StakerRecord) Reset() { *m = StakerRecord{} } +func (m *StakerRecord) String() string { return proto.CompactTextString(m) } +func (*StakerRecord) ProtoMessage() {} +func (*StakerRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{10} +} +func (m *StakerRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakerRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakerRecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StakerRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerRecord.Merge(m, src) +} +func (m *StakerRecord) XXX_Size() int { + return m.Size() +} +func (m *StakerRecord) XXX_DiscardUnknown() { + xxx_messageInfo_StakerRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_StakerRecord proto.InternalMessageInfo + +func (m *StakerRecord) GetStakerID() string { + if m != nil { + return m.StakerID + } + return "" +} + +func (m *StakerRecord) GetStakerDetails() []StakerDetails { + if m != nil { + return m.StakerDetails + } + return nil +} + +// StakerDetails is a helper structure for the genesis state. Each record +// contains an asset ID and a list of operator + amount combination. +type StakerDetails struct { + // asset_id is the unique identifier of the asset. + AssetID string `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` + // details is a list of operator + amount combination. + Details []AssetDetails `protobuf:"bytes,2,rep,name=details,proto3" json:"details"` +} + +func (m *StakerDetails) Reset() { *m = StakerDetails{} } +func (m *StakerDetails) String() string { return proto.CompactTextString(m) } +func (*StakerDetails) ProtoMessage() {} +func (*StakerDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{11} +} +func (m *StakerDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakerDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakerDetails.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StakerDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerDetails.Merge(m, src) +} +func (m *StakerDetails) XXX_Size() int { + return m.Size() +} +func (m *StakerDetails) XXX_DiscardUnknown() { + xxx_messageInfo_StakerDetails.DiscardUnknown(m) +} + +var xxx_messageInfo_StakerDetails proto.InternalMessageInfo + +func (m *StakerDetails) GetAssetID() string { + if m != nil { + return m.AssetID + } + return "" +} + +func (m *StakerDetails) GetDetails() []AssetDetails { + if m != nil { + return m.Details + } + return nil +} + +// AssetDetails is a helper structure for the genesis state. Each record +// contains an operator and an amount. +type AssetDetails struct { + // operator_address is the address of the operator as the bech32 + // version of sdk.AccAddress. + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // amount is the amount of the asset staked by the staker for this + // asset and operator. + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *AssetDetails) Reset() { *m = AssetDetails{} } +func (m *AssetDetails) String() string { return proto.CompactTextString(m) } +func (*AssetDetails) ProtoMessage() {} +func (*AssetDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_bb7040bc6ae6ddee, []int{12} +} +func (m *AssetDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetDetails.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AssetDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetDetails.Merge(m, src) +} +func (m *AssetDetails) XXX_Size() int { + return m.Size() +} +func (m *AssetDetails) XXX_DiscardUnknown() { + xxx_messageInfo_AssetDetails.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetDetails proto.InternalMessageInfo + +func (m *AssetDetails) GetOperatorAddress() string { + if m != nil { + return m.OperatorAddress + } + return "" +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "exocore.operator.v1.GenesisState") + proto.RegisterType((*OperatorDetail)(nil), "exocore.operator.v1.OperatorDetail") + proto.RegisterType((*OptedState)(nil), "exocore.operator.v1.OptedState") + proto.RegisterType((*AVSUSDValue)(nil), "exocore.operator.v1.AVSUSDValue") + proto.RegisterType((*OperatorUSDValue)(nil), "exocore.operator.v1.OperatorUSDValue") + proto.RegisterType((*OperatorSlashState)(nil), "exocore.operator.v1.OperatorSlashState") + proto.RegisterType((*PrevConsKey)(nil), "exocore.operator.v1.PrevConsKey") + proto.RegisterType((*OperatorKeyRemoval)(nil), "exocore.operator.v1.OperatorKeyRemoval") + proto.RegisterType((*OperatorConsKeyRecord)(nil), "exocore.operator.v1.OperatorConsKeyRecord") + proto.RegisterType((*ChainDetails)(nil), "exocore.operator.v1.ChainDetails") + proto.RegisterType((*StakerRecord)(nil), "exocore.operator.v1.StakerRecord") + proto.RegisterType((*StakerDetails)(nil), "exocore.operator.v1.StakerDetails") + proto.RegisterType((*AssetDetails)(nil), "exocore.operator.v1.AssetDetails") +} + +func init() { proto.RegisterFile("exocore/operator/v1/genesis.proto", fileDescriptor_bb7040bc6ae6ddee) } + +var fileDescriptor_bb7040bc6ae6ddee = []byte{ + // 886 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0xe3, 0x1f, 0xc9, 0x23, 0xca, 0x71, 0x36, 0x31, 0xa0, 0x04, 0x85, 0xe4, 0x30, 0xa8, + 0xeb, 0x16, 0x88, 0x84, 0xb8, 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0x11, 0x32, 0x5e, 0x43, 0xe7, 0xb3, 0x2d, 0x3c, 0xe8, 0xfc, 0x6a, 0xc1, 0xce, 0xb2, 0x2e, 0xc9, + 0xa7, 0x86, 0x0c, 0xfd, 0x20, 0x48, 0x28, 0x0a, 0x59, 0x5b, 0x87, 0xdb, 0x85, 0xa8, 0xba, 0xca, + 0x4c, 0x1e, 0x43, 0x3d, 0x0f, 0x0d, 0xa3, 0x97, 0xac, 0x71, 0x65, 0xdf, 0x3a, 0xac, 0x1d, 0xdd, + 0x5e, 0x59, 0xd8, 0x20, 0x7a, 0xc9, 0x74, 0x49, 0x36, 0x33, 0x6c, 0x8e, 0x07, 0x50, 0x68, 0x8f, + 0xec, 0xc2, 0xfa, 0x98, 0xce, 0x34, 0xb3, 0x38, 0x92, 0xfb, 0x50, 0x15, 0x12, 0x36, 0x88, 0x9a, + 0x6f, 0x17, 0xb0, 0xc1, 0x52, 0x61, 0x31, 0x97, 0x04, 0x53, 0xa8, 0x19, 0xea, 0x23, 0x07, 0x50, + 0x15, 0x62, 0x16, 0x3d, 0x2a, 0x9a, 0x5e, 0x6d, 0x31, 0x6f, 0x55, 0xba, 0xc7, 0x43, 0xd1, 0x9f, + 0x5b, 0xf1, 0x53, 0x14, 0x07, 0xf2, 0x25, 0x6c, 0x4a, 0x25, 0x6a, 0x52, 0xa7, 0x94, 0xb4, 0x4f, + 0x47, 0x12, 0xf5, 0x9b, 0x90, 0x4e, 0xb2, 0x25, 0x54, 0x69, 0xce, 0xef, 0x16, 0xec, 0x5e, 0x56, + 0x63, 0x49, 0x7b, 0x21, 0x5c, 0x65, 0xa2, 0xf2, 0x42, 0xfa, 0x9a, 0x70, 0xf5, 0xf6, 0xcb, 0x6e, + 0x73, 0xf9, 0xef, 0x69, 0xf9, 0xd7, 0x97, 0xcc, 0x6e, 0x5d, 0x22, 0x67, 0xba, 0x77, 0x4e, 0x81, + 0xbc, 0xa9, 0xe6, 0x92, 0x92, 0xbe, 0x82, 0x0d, 0x63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e, 0xe2, 0xef, + 0x61, 0xcb, 0x3f, 0x63, 0xd3, 0x88, 0xab, 0x11, 0xf7, 0xbe, 0x10, 0xd0, 0xff, 0xce, 0x5b, 0x07, + 0x27, 0x21, 0x3f, 0x9d, 0xbe, 0x68, 0x8f, 0xd8, 0x99, 0x7e, 0x28, 0xe8, 0x9f, 0xbb, 0x18, 0x8c, + 0x3b, 0x7c, 0x16, 0x53, 0x6c, 0x0f, 0x22, 0xfe, 0xf7, 0x9f, 0x77, 0x41, 0xbf, 0x23, 0x06, 0x11, + 0x77, 0x35, 0x56, 0xef, 0xf1, 0xab, 0x45, 0xd3, 0x7a, 0xbd, 0x68, 0x5a, 0xff, 0x2d, 0x9a, 0xd6, + 0x1f, 0x17, 0xcd, 0xb5, 0xd7, 0x17, 0xcd, 0xb5, 0x7f, 0x2e, 0x9a, 0x6b, 0x3f, 0x1c, 0x19, 0xb8, + 0x5f, 0xab, 0x3e, 0xbf, 0xa3, 0xfc, 0x27, 0x96, 0x8c, 0x3b, 0xd9, 0x5b, 0xe3, 0xbc, 0x78, 0x6d, + 0x48, 0x9e, 0x17, 0x5b, 0xf2, 0xb9, 0xf1, 0xf9, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x55, + 0xa8, 0x87, 0xf7, 0x08, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OperatorKeyRemovals) > 0 { + for iNdEx := len(m.OperatorKeyRemovals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorKeyRemovals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.PreConsKeys) > 0 { + for iNdEx := len(m.PreConsKeys) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PreConsKeys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.SlashStates) > 0 { + for iNdEx := len(m.SlashStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SlashStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.OperatorUSDValues) > 0 { + for iNdEx := len(m.OperatorUSDValues) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorUSDValues[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.AVSUSDValues) > 0 { + for iNdEx := len(m.AVSUSDValues) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AVSUSDValues[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.OptStates) > 0 { + for iNdEx := len(m.OptStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OptStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.OperatorRecords) > 0 { + for iNdEx := len(m.OperatorRecords) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OperatorRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Operators) > 0 { + for iNdEx := len(m.Operators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Operators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OperatorDetail) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperatorDetail) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorDetail) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.OperatorInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OptedState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OptedState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptedState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.OptInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AVSUSDValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AVSUSDValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AVSUSDValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.AVSAddr) > 0 { + i -= len(m.AVSAddr) + copy(dAtA[i:], m.AVSAddr) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AVSAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorUSDValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperatorUSDValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorUSDValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.OptedUSDValue.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorSlashState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperatorSlashState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorSlashState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrevConsKey) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrevConsKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrevConsKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsensusKey) > 0 { + i -= len(m.ConsensusKey) + copy(dAtA[i:], m.ConsensusKey) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConsensusKey))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorKeyRemoval) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperatorKeyRemoval) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorKeyRemoval) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperatorConsKeyRecord) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperatorConsKeyRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorConsKeyRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Chains) > 0 { + for iNdEx := len(m.Chains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Chains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ChainDetails) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ChainDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ChainDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsensusKey) > 0 { + i -= len(m.ConsensusKey) + copy(dAtA[i:], m.ConsensusKey) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConsensusKey))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainID) > 0 { + i -= len(m.ChainID) + copy(dAtA[i:], m.ChainID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChainID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakerRecord) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StakerRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakerRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StakerDetails) > 0 { + for iNdEx := len(m.StakerDetails) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakerDetails[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.StakerID) > 0 { + i -= len(m.StakerID) + copy(dAtA[i:], m.StakerID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.StakerID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakerDetails) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StakerDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakerDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Details) > 0 { + for iNdEx := len(m.Details) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Details[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AssetID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AssetDetails) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AssetDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Operators) > 0 { + for _, e := range m.Operators { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OperatorRecords) > 0 { + for _, e := range m.OperatorRecords { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OptStates) > 0 { + for _, e := range m.OptStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.AVSUSDValues) > 0 { + for _, e := range m.AVSUSDValues { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OperatorUSDValues) > 0 { + for _, e := range m.OperatorUSDValues { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.SlashStates) > 0 { + for _, e := range m.SlashStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PreConsKeys) > 0 { + for _, e := range m.PreConsKeys { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OperatorKeyRemovals) > 0 { + for _, e := range m.OperatorKeyRemovals { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *OperatorDetail) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.OperatorInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *OptedState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.OptInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *AVSUSDValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AVSAddr) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Value.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *OperatorUSDValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.OptedUSDValue.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *OperatorSlashState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Info.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *PrevConsKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ConsensusKey) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *OperatorKeyRemoval) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *OperatorConsKeyRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Chains) > 0 { + for _, e := range m.Chains { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *ChainDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ConsensusKey) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *StakerRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakerID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.StakerDetails) > 0 { + for _, e := range m.StakerDetails { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *StakerDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AssetID) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Details) > 0 { + for _, e := range m.Details { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *AssetDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operators = append(m.Operators, OperatorDetail{}) + if err := m.Operators[len(m.Operators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorRecords", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorRecords = append(m.OperatorRecords, OperatorConsKeyRecord{}) + if err := m.OperatorRecords[len(m.OperatorRecords)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptStates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OptStates = append(m.OptStates, OptedState{}) + if err := m.OptStates[len(m.OptStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSUSDValues", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AVSUSDValues = append(m.AVSUSDValues, AVSUSDValue{}) + if err := m.AVSUSDValues[len(m.AVSUSDValues)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorUSDValues", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorUSDValues = append(m.OperatorUSDValues, OperatorUSDValue{}) + if err := m.OperatorUSDValues[len(m.OperatorUSDValues)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashStates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SlashStates = append(m.SlashStates, OperatorSlashState{}) + if err := m.SlashStates[len(m.SlashStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreConsKeys", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreConsKeys = append(m.PreConsKeys, PrevConsKey{}) + if err := m.PreConsKeys[len(m.PreConsKeys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorKeyRemovals", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorKeyRemovals = append(m.OperatorKeyRemovals, OperatorKeyRemoval{}) + if err := m.OperatorKeyRemovals[len(m.OperatorKeyRemovals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorDetail) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperatorDetail: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorDetail: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OperatorInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OptedState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OptedState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptedState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OptInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AVSUSDValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AVSUSDValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AVSUSDValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AVSAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorUSDValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperatorUSDValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorUSDValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptedUSDValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OptedUSDValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorSlashState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperatorSlashState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorSlashState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrevConsKey) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrevConsKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrevConsKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsensusKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func (m *StakerDetails) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.AssetID) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - if len(m.Details) > 0 { - for _, e := range m.Details { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + return nil +} +func (m *OperatorKeyRemoval) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperatorKeyRemoval: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorKeyRemoval: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func (m *AssetDetails) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddress) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - l = m.Amount.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *OperatorConsKeyRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -549,15 +2885,47 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: OperatorConsKeyRecord: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OperatorConsKeyRecord: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Chains", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -584,10 +2952,124 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Operators = append(m.Operators, OperatorInfo{}) - if err := m.Operators[len(m.Operators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Chains = append(m.Chains, ChainDetails{}) + if err := m.Chains[len(m.Chains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { return err } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ChainDetails) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ChainDetails: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ChainDetails: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsensusKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/operator/types/genesis_test.go b/x/operator/types/genesis_test.go index c5f92a283..1acf60f34 100644 --- a/x/operator/types/genesis_test.go +++ b/x/operator/types/genesis_test.go @@ -3,6 +3,10 @@ package types_test import ( "testing" + "github.com/ExocoreNetwork/exocore/utils" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/ethereum/go-ethereum/common/hexutil" + utiltx "github.com/ExocoreNetwork/exocore/testutil/tx" "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -21,7 +25,9 @@ func TestGenesisTestSuite(t *testing.T) { } func (suite *GenesisTestSuite) TestValidateGenesis() { + key := hexutil.Encode(ed25519.GenPrivKey().PubKey().Bytes()) accAddress1 := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) + accAddress2 := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) newGen := &types.GenesisState{} testCases := []struct { @@ -43,9 +49,9 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { name: "invalid genesis state due to non bech32 operator address", genState: &types.GenesisState{ - Operators: []types.OperatorInfo{ + Operators: []types.OperatorDetail{ { - EarningsAddr: "invalid", + OperatorAddress: "invalid", }, }, }, @@ -54,12 +60,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { name: "invalid genesis state due to duplicate operator address", genState: &types.GenesisState{ - Operators: []types.OperatorInfo{ + Operators: []types.OperatorDetail{ { - EarningsAddr: accAddress1.String(), + OperatorAddress: accAddress1.String(), }, { - EarningsAddr: accAddress1.String(), + OperatorAddress: accAddress1.String(), }, }, }, @@ -68,18 +74,21 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { { name: "invalid genesis state due to duplicate lz chain id", genState: &types.GenesisState{ - Operators: []types.OperatorInfo{ - { - EarningsAddr: accAddress1.String(), - ClientChainEarningsAddr: &types.ClientChainEarningAddrList{ - EarningInfoList: []*types.ClientChainEarningAddrInfo{ - { - LzClientChainID: 1, - ClientChainEarningAddr: utiltx.GenerateAddress().String(), - }, - { - LzClientChainID: 1, - ClientChainEarningAddr: utiltx.GenerateAddress().String(), + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + OperatorInfo: types.OperatorInfo{ + EarningsAddr: accAddress1.String(), + ClientChainEarningsAddr: &types.ClientChainEarningAddrList{ + EarningInfoList: []*types.ClientChainEarningAddrInfo{ + { + LzClientChainID: 1, + ClientChainEarningAddr: utiltx.GenerateAddress().String(), + }, + { + LzClientChainID: 1, + ClientChainEarningAddr: utiltx.GenerateAddress().String(), + }, }, }, }, @@ -88,6 +97,128 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, expPass: false, }, + { + name: "invalid genesis state due to invalid cons key operator address", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: "invalid", + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to unregistered operator in cons key", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress2.String(), + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to duplicate operator in cons key", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + { + OperatorAddress: accAddress2.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key, + }, + }, + }, + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: hexutil.Encode(ed25519.GenPrivKey().PubKey().Bytes()), + }, + }, + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to invalid cons key", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key + "fake", + }, + }, + }, + }, + }, + expPass: false, + }, + { + name: "invalid genesis state due to duplicate cons key for the same chain id", + genState: &types.GenesisState{ + Operators: []types.OperatorDetail{ + { + OperatorAddress: accAddress1.String(), + }, + { + OperatorAddress: accAddress2.String(), + }, + }, + OperatorRecords: []types.OperatorConsKeyRecord{ + { + OperatorAddress: accAddress1.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key, + }, + }, + }, + { + OperatorAddress: accAddress2.String(), + Chains: []types.ChainDetails{ + { + ChainID: utils.TestnetChainID, + ConsensusKey: key, + }, + }, + }, + }, + }, + expPass: false, + }, } for _, tc := range testCases { diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 6ce14a873..1033799af 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -3,6 +3,8 @@ package types import ( "math" + "golang.org/x/xerrors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -25,6 +27,13 @@ const ( SlashVetoDuration = int64(1000) UnbondingExpiration = 10 + + // AccAddressLength is used to parse the key, because the length isn't padded in the key + // This might be removed if the address length is padded in the key + AccAddressLength = 20 + + // ByteLengthForUint64 the type of chainID length is uint64, uint64 has 8 bytes. + ByteLengthForUint64 = 8 ) const ( @@ -32,8 +41,8 @@ const ( prefixOperatorOptedAVSInfo - prefixVotingPowerForAVS - prefixVotingPowerForOperator + prefixUSDValueForAVS + prefixUSDValueForOperator prefixOperatorSlashInfo @@ -68,13 +77,13 @@ var ( // operatorAddr + '/' + AVSAddr -> OptedInfo KeyPrefixOperatorOptedAVSInfo = []byte{prefixOperatorOptedAVSInfo} - // KeyPrefixVotingPowerForAVS key-value: - // AVSAddr -> types.DecValueField(the voting power of specified Avs) - KeyPrefixVotingPowerForAVS = []byte{prefixVotingPowerForAVS} + // KeyPrefixUSDValueForAVS key-value: + // AVSAddr -> types.DecValueField(the USD value of specified Avs) + KeyPrefixUSDValueForAVS = []byte{prefixUSDValueForAVS} - // KeyPrefixVotingPowerForOperator key-value: - // AVSAddr + '/' + operatorAddr -> types.OperatorUSDInfo (the voting power of specified operator and Avs) - KeyPrefixVotingPowerForOperator = []byte{prefixVotingPowerForOperator} + // KeyPrefixUSDValueForOperator key-value: + // AVSAddr + '/' + operatorAddr -> types.OperatorOptedUSDValue (the voting power of specified operator and Avs) + KeyPrefixUSDValueForOperator = []byte{prefixUSDValueForOperator} // KeyPrefixOperatorSlashInfo key-value: // operator + '/' + AVSAddr + '/' + slashId -> OperatorSlashInfo @@ -126,6 +135,29 @@ func KeyForOperatorAndChainIDToConsKey(addr sdk.AccAddress, chainID string) []by ) } +func ParseKeyForOperatorAndChainIDToConsKey(key []byte) (addr sdk.AccAddress, chainID string, err error) { + if len(key) < AccAddressLength+ByteLengthForUint64 { + return nil, "", xerrors.New("key length is too short to contain address and chainID length") + } + // Extract the address + addr = key[0:AccAddressLength] + if len(addr) == 0 { + return nil, "", xerrors.New("missing address") + } + + // Extract the chainID length + chainIDLen := sdk.BigEndianToUint64(key[AccAddressLength : AccAddressLength+ByteLengthForUint64]) + if len(key) != int(AccAddressLength+ByteLengthForUint64+chainIDLen) { + return nil, "", xerrors.Errorf("invalid key length,expected:%d,got:%d", AccAddressLength+ByteLengthForUint64+chainIDLen, len(key)) + } + + // Extract the chainID + chainIDBytes := key[AccAddressLength+ByteLengthForUint64:] + chainID = string(chainIDBytes) + + return addr, chainID, nil +} + func KeyForChainIDAndOperatorToPrevConsKey(chainID string, addr sdk.AccAddress) []byte { return ChainIDAndAddrKey( BytePrefixForOperatorAndChainIDToPrevConsKey, @@ -133,6 +165,31 @@ func KeyForChainIDAndOperatorToPrevConsKey(chainID string, addr sdk.AccAddress) ) } +func ParsePrevConsKey(key []byte) (chainID string, addr sdk.AccAddress, err error) { + // Check if the key has at least eight byte for the chainID length + if len(key) < ByteLengthForUint64 { + return "", nil, xerrors.New("key length is too short to contain chainID length") + } + + // Extract the chainID length + chainIDLen := sdk.BigEndianToUint64(key[0:ByteLengthForUint64]) + if len(key) < int(ByteLengthForUint64+chainIDLen) { + return "", nil, xerrors.New("key too short for chainID length") + } + + // Extract the chainID + chainIDBytes := key[ByteLengthForUint64 : ByteLengthForUint64+chainIDLen] + chainID = string(chainIDBytes) + + // Extract the address + addr = key[ByteLengthForUint64+chainIDLen:] + if len(addr) == 0 { + return "", nil, xerrors.New("missing address") + } + + return chainID, addr, nil +} + func KeyForChainIDAndOperatorToConsKey(chainID string, addr sdk.AccAddress) []byte { return ChainIDAndAddrKey( BytePrefixForChainIDAndOperatorToConsKey, @@ -155,6 +212,31 @@ func KeyForOperatorKeyRemovalForChainID(addr sdk.AccAddress, chainID string) []b ) } +func ParseKeyForOperatorKeyRemoval(key []byte) (addr sdk.AccAddress, chainID string, err error) { + // Check if the key has at least 20 byte for the operator and eight byte for the chainID length + if len(key) < AccAddressLength+ByteLengthForUint64 { + return nil, "", xerrors.New("key length is too short to contain operator address and chainID length") + } + + // Extract the address + addr = key[0:AccAddressLength] + if len(addr) == 0 { + return nil, "", xerrors.New("missing address") + } + + // Extract the chainID length + chainIDLen := sdk.BigEndianToUint64(key[AccAddressLength : AccAddressLength+ByteLengthForUint64]) + if len(key) != int(AccAddressLength+ByteLengthForUint64+chainIDLen) { + return nil, "", xerrors.Errorf("invalid key length,expected:%d,got:%d", AccAddressLength+ByteLengthForUint64+chainIDLen, len(key)) + } + + // Extract the chainID + chainIDBytes := key[AccAddressLength+ByteLengthForUint64:] + chainID = string(chainIDBytes) + + return addr, chainID, nil +} + func IterateOperatorsForAVSPrefix(avsAddr string) []byte { tmp := append([]byte(avsAddr), '/') return tmp diff --git a/x/operator/types/keys_test.go b/x/operator/types/keys_test.go new file mode 100644 index 000000000..713b6609a --- /dev/null +++ b/x/operator/types/keys_test.go @@ -0,0 +1,58 @@ +package types + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) + +type KeysTestSuite struct { + suite.Suite +} + +func (suite *KeysTestSuite) SetupTest() { +} + +func TestKeysTestSuite(t *testing.T) { + suite.Run(t, new(KeysTestSuite)) +} + +func (suite *KeysTestSuite) TestParseKeyForOperatorAndChainIDToConsKey() { + operator := "exo1rtg0cgw94ep744epyvanc0wdd5kedwql73vlmr" + operatorAddr, err := sdk.AccAddressFromBech32(operator) + suite.NoError(err) + chainIDWithoutRevision := "exocoretestnet_233" + key := KeyForOperatorAndChainIDToConsKey(operatorAddr, chainIDWithoutRevision) + + parsedAddr, parsedChainID, err := ParseKeyForOperatorAndChainIDToConsKey(key[1:]) + suite.NoError(err) + suite.Equal(operatorAddr, parsedAddr) + suite.Equal(chainIDWithoutRevision, parsedChainID) +} + +func (suite *KeysTestSuite) TestParsePrevConsKey() { + operator := "exo1rtg0cgw94ep744epyvanc0wdd5kedwql73vlmr" + operatorAddr, err := sdk.AccAddressFromBech32(operator) + suite.NoError(err) + chainIDWithoutRevision := "exocoretestnet_233" + key := KeyForChainIDAndOperatorToPrevConsKey(chainIDWithoutRevision, operatorAddr) + + parsedChainID, parsedAddr, err := ParsePrevConsKey(key[1:]) + suite.NoError(err) + suite.Equal(operatorAddr, parsedAddr) + suite.Equal(chainIDWithoutRevision, parsedChainID) +} + +func (suite *KeysTestSuite) TestParseKeyForOperatorKeyRemoval() { + operator := "exo1rtg0cgw94ep744epyvanc0wdd5kedwql73vlmr" + operatorAddr, err := sdk.AccAddressFromBech32(operator) + suite.NoError(err) + chainIDWithoutRevision := "exocoretestnet_233" + key := KeyForOperatorKeyRemovalForChainID(operatorAddr, chainIDWithoutRevision) + + parsedAddr, parsedChainID, err := ParseKeyForOperatorKeyRemoval(key[1:]) + suite.NoError(err) + suite.Equal(operatorAddr, parsedAddr) + suite.Equal(chainIDWithoutRevision, parsedChainID) +} diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 363ddcfd0..1f5a8c1ed 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -564,9 +564,9 @@ type SlashExecutionInfo struct { // slash_value is the usd value of all slashed assets SlashValue github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=slash_value,json=slashValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_value"` // SlashUndelegations records all slash info related to the undelegation - SlashUndelegations []*SlashFromUndelegation `protobuf:"bytes,3,rep,name=slash_undelegations,json=slashUndelegations,proto3" json:"slash_undelegations,omitempty"` + SlashUndelegations []SlashFromUndelegation `protobuf:"bytes,3,rep,name=slash_undelegations,json=slashUndelegations,proto3" json:"slash_undelegations"` // SlashFromAssetsPool records all slash info related to the assets pool - SlashAssetsPool []*SlashFromAssetsPool `protobuf:"bytes,4,rep,name=slash_assets_pool,json=slashAssetsPool,proto3" json:"slash_assets_pool,omitempty"` + SlashAssetsPool []SlashFromAssetsPool `protobuf:"bytes,4,rep,name=slash_assets_pool,json=slashAssetsPool,proto3" json:"slash_assets_pool"` } func (m *SlashExecutionInfo) Reset() { *m = SlashExecutionInfo{} } @@ -602,14 +602,14 @@ func (m *SlashExecutionInfo) XXX_DiscardUnknown() { var xxx_messageInfo_SlashExecutionInfo proto.InternalMessageInfo -func (m *SlashExecutionInfo) GetSlashUndelegations() []*SlashFromUndelegation { +func (m *SlashExecutionInfo) GetSlashUndelegations() []SlashFromUndelegation { if m != nil { return m.SlashUndelegations } return nil } -func (m *SlashExecutionInfo) GetSlashAssetsPool() []*SlashFromAssetsPool { +func (m *SlashExecutionInfo) GetSlashAssetsPool() []SlashFromAssetsPool { if m != nil { return m.SlashAssetsPool } @@ -1057,104 +1057,104 @@ func init() { func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 1540 bytes of a gzipped FileDescriptorProto + // 1545 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcb, 0x4f, 0x1b, 0xd7, 0x1a, 0x67, 0x6c, 0x5e, 0xfe, 0x6c, 0x63, 0x33, 0xe4, 0xe1, 0xf8, 0xe6, 0xe2, 0x30, 0xb9, 0x21, 0x84, 0x7b, 0xb1, 0x05, 0xb9, 0xb9, 0x52, 0x72, 0xef, 0xe2, 0x1a, 0x0c, 0x8a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, - 0x45, 0x3f, 0x64, 0x05, 0xd1, 0x0f, 0xb1, 0xb7, 0xdd, 0x46, 0xd8, 0x39, 0xc0, 0xe0, 0xaf, 0xe4, - 0xc6, 0x20, 0xff, 0x2f, 0xc5, 0xe5, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x70, 0x53, 0xec, 0xcd, - 0x7b, 0x11, 0x00, 0x00, + 0x0c, 0x44, 0x6a, 0xaa, 0x6a, 0x34, 0x8c, 0x0f, 0x66, 0xc2, 0x78, 0xce, 0x74, 0xce, 0xb1, 0x0b, + 0x59, 0x55, 0x59, 0x45, 0x55, 0x17, 0x95, 0xb2, 0xaa, 0xda, 0x45, 0x56, 0x55, 0x97, 0x59, 0x64, + 0x5b, 0xb5, 0xdd, 0x65, 0x19, 0xa5, 0x5d, 0x54, 0x5d, 0xd0, 0x8a, 0x54, 0x4a, 0xff, 0x88, 0x56, + 0xaa, 0xce, 0x99, 0x33, 0x66, 0x9c, 0xd8, 0x24, 0x28, 0xa4, 0x1b, 0xe0, 0x7c, 0xaf, 0xdf, 0xef, + 0x7b, 0x9c, 0xef, 0xd8, 0xc0, 0x59, 0xb4, 0x83, 0x4d, 0xec, 0xa1, 0x02, 0x76, 0x91, 0x67, 0x50, + 0xec, 0x15, 0x5a, 0xb3, 0x05, 0xba, 0x93, 0x77, 0x3d, 0x4c, 0xb1, 0x3c, 0x26, 0xb4, 0xf9, 0x40, + 0x9b, 0x6f, 0xcd, 0x66, 0x47, 0x8d, 0x86, 0xe5, 0xe0, 0x02, 0xff, 0xe9, 0xdb, 0x65, 0x4f, 0x9b, + 0x98, 0x34, 0x30, 0x29, 0x34, 0x48, 0x9d, 0xf9, 0x37, 0x48, 0x5d, 0x28, 0xfe, 0x21, 0x14, 0x84, + 0x1a, 0xdb, 0x96, 0xc3, 0x94, 0x1b, 0x88, 0x1a, 0xb3, 0xc1, 0x59, 0x58, 0x9d, 0xf1, 0xad, 0x74, + 0x7e, 0x2a, 0xf8, 0x07, 0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, 0x7c, 0xc4, 0xbe, 0x27, 0xcc, 0x2f, 0x3f, 0xde, 0x1f, 0x97, 0x9e, 0xec, 0x8f, 0x4b, 0xbf, + 0xec, 0x8f, 0x4b, 0x9f, 0x3e, 0x1b, 0xef, 0x7b, 0xf2, 0x6c, 0xbc, 0xef, 0xc7, 0x67, 0xe3, 0x7d, + 0xb7, 0xe6, 0x42, 0xaf, 0xe2, 0xa2, 0x1f, 0xb2, 0x82, 0xe8, 0x87, 0xd8, 0xdb, 0x6e, 0x23, 0xec, + 0x1c, 0x60, 0xf0, 0x57, 0x72, 0x63, 0x90, 0xff, 0xc7, 0xe2, 0xf2, 0x9f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x47, 0x83, 0x3c, 0x87, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3788,7 +3788,7 @@ func (m *SlashExecutionInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SlashUndelegations = append(m.SlashUndelegations, &SlashFromUndelegation{}) + m.SlashUndelegations = append(m.SlashUndelegations, SlashFromUndelegation{}) if err := m.SlashUndelegations[len(m.SlashUndelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3822,7 +3822,7 @@ func (m *SlashExecutionInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SlashAssetsPool = append(m.SlashAssetsPool, &SlashFromAssetsPool{}) + m.SlashAssetsPool = append(m.SlashAssetsPool, SlashFromAssetsPool{}) if err := m.SlashAssetsPool[len(m.SlashAssetsPool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/reward/keeper/claim_reward_test.go b/x/reward/keeper/claim_reward_test.go index b8f27193f..5a275401e 100644 --- a/x/reward/keeper/claim_reward_test.go +++ b/x/reward/keeper/claim_reward_test.go @@ -43,5 +43,5 @@ func (suite *RewardTestSuite) TestClaimWithdrawRequest() { assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) - suite.Equal(sdkmath.NewInt(10).Add(assets[assetID].StakingTotalAmount), assetInfo.StakingTotalAmount) + suite.Equal(sdkmath.NewInt(10).Add(assets[0].StakingTotalAmount), assetInfo.StakingTotalAmount) } diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index 6fbc06b68..e2cb683b6 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -66,5 +66,5 @@ func (suite *SlashTestSuite) TestSlash() { assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) - suite.Equal(assets[assetID].StakingTotalAmount.Add(depositEvent.OpAmount).Sub(event.OpAmount), assetInfo.StakingTotalAmount) + suite.Equal(assets[0].StakingTotalAmount.Add(depositEvent.OpAmount).Sub(event.OpAmount), assetInfo.StakingTotalAmount) }