From 1b5526c8ee08b842210398d6b1b147aa6a19d389 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:08:31 +0000 Subject: [PATCH 01/44] feat(dogfood): implement sdk staking interface The interface required by IBC was already implemented in `validators.go`. This PR takes that a step further and implements the interfaces required to use the dogfood module as a drop-in replacement for the SDK's staking module. The interfaces implemented are those expected by the slashing, evidence and `genutil` modules. An explanation has been provided above each function to explain why and where it is called, and if its implementation is really necessary. There are still some TODOs left in this PR that depend on the overall slashing / operator design. This branch is merged into dogfood-part6, which forms the basis of #122. --- x/dogfood/keeper/impl_sdk.go | 171 ++++++++++++++++++++++++++++ x/dogfood/keeper/keeper.go | 3 + x/dogfood/types/expected_keepers.go | 15 +++ 3 files changed, 189 insertions(+) create mode 100644 x/dogfood/keeper/impl_sdk.go diff --git a/x/dogfood/keeper/impl_sdk.go b/x/dogfood/keeper/impl_sdk.go new file mode 100644 index 000000000..547f526e7 --- /dev/null +++ b/x/dogfood/keeper/impl_sdk.go @@ -0,0 +1,171 @@ +package keeper + +import ( + "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" +) + +// interface guards +var _ slashingtypes.StakingKeeper = Keeper{} +var _ evidencetypes.StakingKeeper = Keeper{} +var _ genutiltypes.StakingKeeper = Keeper{} +var _ clienttypes.StakingKeeper = Keeper{} // implemented in `validators.go` + +// GetParams is an implementation of the staking interface expected by the SDK's evidence +// module. The module does not use it, but it is part of the interface. +func (k Keeper) GetParams(ctx sdk.Context) stakingtypes.Params { + return stakingtypes.Params{} +} + +// IterateValidators is an implementation of the staking interface expected by the SDK's +// slashing module. The slashing module uses it for two purposes: once at genesis to +// store a mapping of pub key to cons address (which is done by our operator module), +// and then during the invariants check to ensure that the total delegated amount +// matches that of each validator. Ideally, this invariant should be implemented +// by the delegation and/or deposit module(s) instead. +func (k Keeper) IterateValidators(sdk.Context, + func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { + // no op +} + +// Validator is an implementation of the staking interface expected by the SDK's +// slashing module. The slashing module uses it to obtain a validator's information at +// its addition to the list of validators, and then to unjail a validator. The former +// is used to create the pub key to cons address mapping, which we do in the operator module. +// The latter should also be implemented in the operator module, or maybe the slashing module +// depending upon the finalized design. We don't need to implement this function here because +// we are not calling the AfterValidatorCreated hook in our module, so this will never be +// reached. +func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI { + panic("unimplemented on this keeper") +} + +// ValidatorByConsAddr is an implementation of the staking interface expected by the SDK's +// slashing and evidence modules. +// The slashing module calls this function when it observes downtime. The only requirement on +// the returned value is that it isn't nil, and the jailed status is accurately set (to prevent +// re-jailing of the same operator). +// The evidence module calls this function when it handles equivocation evidence. The returned +// value must not be nil and must not have an UNBONDED validator status (the default is +// unspecified), or evidence will reject it. +func (k Keeper) ValidatorByConsAddr( + ctx sdk.Context, + addr sdk.ConsAddress, +) stakingtypes.ValidatorI { + found, accAddr := k.operatorKeeper.GetOperatorAddressForChainIdAndConsAddr( + ctx, ctx.ChainID(), addr, + ) + if !found { + // replicate the behavior of the SDK's staking module + return nil + } + return stakingtypes.Validator{ + Jailed: k.operatorKeeper.IsOperatorJailedForChainId(ctx, accAddr, ctx.ChainID()), + } +} + +// Slash is an implementation of the staking interface expected by the SDK's slashing module. +// It forwards the call to SlashWithInfractionReason with Infraction_INFRACTION_UNSPECIFIED. +// It is not called within the slashing module, but is part of the interface. +func (k Keeper) Slash( + ctx sdk.Context, addr sdk.ConsAddress, + infractionHeight, power int64, + slashFactor sdk.Dec, +) math.Int { + return k.SlashWithInfractionReason( + ctx, addr, infractionHeight, power, + slashFactor, stakingtypes.Infraction_INFRACTION_UNSPECIFIED, + ) +} + +// SlashWithInfractionReason is an implementation of the staking interface expected by the +// SDK's slashing module. It is called when the slashing module observes an infraction +// of either downtime or equivocation (which is via the evidence module). +func (k Keeper) SlashWithInfractionReason( + ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, + slashFactor sdk.Dec, infraction stakingtypes.Infraction, +) math.Int { + found, accAddress := k.operatorKeeper.GetOperatorAddressForChainIdAndConsAddr( + ctx, ctx.ChainID(), addr, + ) + if !found { + // TODO(mm): already slashed and removed from the set? + return math.NewInt(0) + } + // TODO(mm): add list of assets to be slashed (and not just all of them). + // based on yet to be finalized slashing design. + return k.slashingKeeper.SlashWithInfractionReason( + ctx, accAddress, infractionHeight, + power, slashFactor, infraction, + ) +} + +// Jail is an implementation of the staking interface expected by the SDK's slashing module. +// It delegates the call to the operator module. Alternatively, this may be handled +// by the slashing module depending upon the design decisions. +func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) { + k.operatorKeeper.Jail(ctx, addr, ctx.ChainID()) + // TODO(mm) + // once the operator module jails someone, a hook should be triggered + // and the validator removed from the set. same for unjailing. +} + +// Unjail is an implementation of the staking interface expected by the SDK's slashing module. +// The function is called by the slashing module only when it receives a request from the +// operator to do so. TODO(mm): We need to use the SDK's slashing module to allow for downtime +// slashing but somehow we need to prevent its Unjail function from being called by anyone. +func (k Keeper) Unjail(sdk.Context, sdk.ConsAddress) { + panic("unimplemented on this keeper") +} + +// Delegation is an implementation of the staking interface expected by the SDK's slashing +// module. The slashing module uses it to obtain the delegation information of a validator +// before unjailing it. If the slashing module's unjail function is never called, this +// function will never be called either. +func (k Keeper) Delegation( + sdk.Context, sdk.AccAddress, sdk.ValAddress, +) stakingtypes.DelegationI { + panic("unimplemented on this keeper") +} + +// MaxValidators is an implementation of the staking interface expected by the SDK's slashing +// module. It is not called within the slashing module, but is part of the interface. +// It returns the maximum number of validators allowed in the network. +func (k Keeper) MaxValidators(ctx sdk.Context) uint32 { + return k.GetMaxValidators(ctx) +} + +// GetAllValidators is an implementation of the staking interface expected by the SDK's +// slashing module. It is not called within the slashing module, but is part of the interface. +func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) { + return []stakingtypes.Validator{} +} + +// IsValidatorJailed is an implementation of the staking interface expected by the SDK's +// slashing module. It is called by the slashing module to record validator signatures +// for downtime tracking. We delegate the call to the operator keeper. +func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { + found, accAddr := k.operatorKeeper.GetOperatorAddressForChainIdAndConsAddr( + ctx, ctx.ChainID(), addr, + ) + if !found { + // replicate the behavior of the SDK's staking module + return false + } + return k.operatorKeeper.IsOperatorJailedForChainId(ctx, accAddr, ctx.ChainID()) +} + +// ApplyAndReturnValidatorSetUpdates is an implementation of the staking interface expected +// by the SDK's genutil module. It is used in the gentx command, which we do not need to +// support. So this function does nothing. +func (k Keeper) ApplyAndReturnValidatorSetUpdates( + sdk.Context, +) (updates []abci.ValidatorUpdate, err error) { + return +} diff --git a/x/dogfood/keeper/keeper.go b/x/dogfood/keeper/keeper.go index 103d60c97..e85f961d0 100644 --- a/x/dogfood/keeper/keeper.go +++ b/x/dogfood/keeper/keeper.go @@ -26,6 +26,7 @@ type ( operatorKeeper types.OperatorKeeper delegationKeeper types.DelegationKeeper restakingKeeper types.RestakingKeeper + slashingKeeper types.SlashingKeeper } ) @@ -38,6 +39,7 @@ func NewKeeper( operatorKeeper types.OperatorKeeper, delegationKeeper types.DelegationKeeper, restakingKeeper types.RestakingKeeper, + slashingKeeper types.SlashingKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -52,6 +54,7 @@ func NewKeeper( operatorKeeper: operatorKeeper, delegationKeeper: delegationKeeper, restakingKeeper: restakingKeeper, + slashingKeeper: slashingKeeper, } } diff --git a/x/dogfood/types/expected_keepers.go b/x/dogfood/types/expected_keepers.go index 9dfd255ea..06ca74df4 100644 --- a/x/dogfood/types/expected_keepers.go +++ b/x/dogfood/types/expected_keepers.go @@ -1,8 +1,10 @@ package types import ( + "cosmossdk.io/math" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" epochsTypes "github.com/evmos/evmos/v14/x/epochs/types" ) @@ -48,6 +50,11 @@ type OperatorKeeper interface { ) bool CompleteOperatorOptOutFromChainId(sdk.Context, sdk.AccAddress, string) DeleteOperatorAddressForChainIdAndConsAddr(sdk.Context, string, sdk.ConsAddress) + GetOperatorAddressForChainIdAndConsAddr( + sdk.Context, string, sdk.ConsAddress, + ) (bool, sdk.AccAddress) + IsOperatorJailedForChainId(sdk.Context, sdk.AccAddress, string) bool + Jail(sdk.Context, sdk.ConsAddress, string) } // DelegationKeeper represents the expected keeper interface for the delegation module. @@ -66,3 +73,11 @@ type EpochsHooks interface { type RestakingKeeper interface { GetOperatorAssetValue(sdk.Context, sdk.AccAddress) (int64, error) } + +// SlashingKeeper represents the expected keeper interface for the (exo-)slashing module. +type SlashingKeeper interface { + SlashWithInfractionReason( + sdk.Context, sdk.AccAddress, int64, + int64, sdk.Dec, stakingtypes.Infraction, + ) math.Int +} From 4949df596367dde5f46d6352e3280caaf24676e1 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 20 Dec 2023 16:40:17 +0800 Subject: [PATCH 02/44] refactor the non-compliant code fix the bug caused by rebase merge remove license comments add some code comments change precompile contract solidity version --- x/restaking_assets_manage/keeper/staker_asset_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/restaking_assets_manage/keeper/staker_asset_test.go b/x/restaking_assets_manage/keeper/staker_asset_test.go index e38f62cdf..664433da5 100644 --- a/x/restaking_assets_manage/keeper/staker_asset_test.go +++ b/x/restaking_assets_manage/keeper/staker_asset_test.go @@ -30,7 +30,7 @@ func (suite *KeeperTestSuite) TestUpdateStakerAssetsState() { /* ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(0) ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(0) err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) - suite.Require().Error(err, types2.ErrInputUpdateStateIsZero)*/ + suite.Require().Error(err, restakingtype.ErrInputUpdateStateIsZero)*/ // test valid increase of staker asset state ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(500) From 20d9e3d61d2e216ad224ce95fac4000b9648d3ae Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 26 Dec 2023 11:11:09 +0800 Subject: [PATCH 03/44] add more info for error log --- x/delegation/keeper/cross_chain_tx_process.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 45254b9f5..0aadd7213 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -112,7 +112,7 @@ type DelegationOrUndelegationParams struct { func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the delegatedTo address is an operator if !k.IsOperator(ctx, params.OperatorAddress) { - return delegationtype.ErrOperatorNotExist + return errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", params.OperatorAddress)) } // check if the operator has been slashed or frozen @@ -136,7 +136,7 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara } if info.CanWithdrawAmountOrWantChangeValue.LT(params.OpAmount) { - return delegationtype.ErrDelegationAmountTooBig + return errorsmod.Wrap(delegationtype.ErrDelegationAmountTooBig, fmt.Sprintf("the opAmount is:%s the canWithdraw amount is:%s", params.OpAmount, info.CanWithdrawAmountOrWantChangeValue)) } //update staker asset state From f6ccc82c51396846663e7528aaeb0f96ff206b84 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Fri, 19 Jan 2024 16:54:18 +0800 Subject: [PATCH 04/44] add operator module --- app/app.go | 15 +- proto/exocore/delegation/v1/query.proto | 7 - proto/exocore/delegation/v1/tx.proto | 30 - proto/exocore/operator/v1/query.proto | 22 + proto/exocore/operator/v1/tx.proto | 83 + .../restaking_assets_manage/v1/tx.proto | 9 + x/delegation/client/cli/query.go | 30 - x/delegation/client/cli/tx.go | 59 +- x/delegation/keeper/abci.go | 2 +- x/delegation/keeper/cross_chain_tx_process.go | 18 +- x/delegation/keeper/delegation_op_test.go | 19 +- x/delegation/keeper/delegation_state.go | 32 +- x/delegation/keeper/grpc_query.go | 5 - x/delegation/keeper/keeper.go | 68 +- x/delegation/keeper/msg_server.go | 10 - x/delegation/keeper/operator_info_test.go | 22 - x/delegation/types/errors.go | 4 +- x/delegation/types/expected_keepers.go | 11 +- x/delegation/types/keys.go | 19 +- x/delegation/types/query.pb.go | 283 +-- x/delegation/types/query.pb.gw.go | 90 +- x/delegation/types/tx.pb.go | 1442 ++---------- x/deposit/types/query.pb.gw.go | 7 +- x/operator/client/cli/query.go | 56 + x/operator/client/cli/tx.go | 81 + x/operator/keeper/abci.go | 11 + .../keeper/avs_operator_assets_state.go | 143 ++ x/operator/keeper/grpc_query.go | 15 + x/operator/keeper/keeper.go | 64 + x/operator/keeper/msg_server.go | 19 + x/operator/keeper/operator.go | 115 + x/operator/keeper/operator_info_test.go | 22 + x/operator/keeper/operator_slash_state.go | 106 + .../keeper/sate_update_for_external_op.go | 39 + x/operator/keeper/setup_test.go | 40 + x/operator/keeper/utils_test.go | 44 + x/operator/module.go | 96 + x/operator/types/codec.go | 49 + x/operator/types/errors.go | 13 + x/operator/types/expected_keepers.go | 14 + x/operator/types/keys.go | 76 + x/operator/types/msg.go | 29 + x/operator/types/query.pb.go | 412 ++++ x/operator/types/query.pb.gw.go | 171 ++ x/operator/types/tx.pb.go | 2062 +++++++++++++++++ .../keeper/client_chain_asset.go | 2 +- .../keeper/operator_asset.go | 13 +- .../keeper/staker_asset.go | 33 +- x/restaking_assets_manage/types/errors.go | 4 + x/restaking_assets_manage/types/general.go | 23 + x/restaking_assets_manage/types/keys.go | 13 +- .../types/query.pb.gw.go | 31 +- x/restaking_assets_manage/types/tx.pb.go | 314 ++- x/reward/types/query.pb.gw.go | 7 +- x/slash/types/query.pb.gw.go | 7 +- x/withdraw/types/query.pb.gw.go | 7 +- 56 files changed, 4430 insertions(+), 1988 deletions(-) create mode 100644 proto/exocore/operator/v1/query.proto create mode 100644 proto/exocore/operator/v1/tx.proto delete mode 100644 x/delegation/keeper/operator_info_test.go create mode 100644 x/operator/client/cli/query.go create mode 100644 x/operator/client/cli/tx.go create mode 100644 x/operator/keeper/abci.go create mode 100644 x/operator/keeper/avs_operator_assets_state.go create mode 100644 x/operator/keeper/grpc_query.go create mode 100644 x/operator/keeper/keeper.go create mode 100644 x/operator/keeper/msg_server.go create mode 100644 x/operator/keeper/operator.go create mode 100644 x/operator/keeper/operator_info_test.go create mode 100644 x/operator/keeper/operator_slash_state.go create mode 100644 x/operator/keeper/sate_update_for_external_op.go create mode 100644 x/operator/keeper/setup_test.go create mode 100644 x/operator/keeper/utils_test.go create mode 100644 x/operator/module.go create mode 100644 x/operator/types/codec.go create mode 100644 x/operator/types/errors.go create mode 100644 x/operator/types/expected_keepers.go create mode 100644 x/operator/types/keys.go create mode 100644 x/operator/types/msg.go create mode 100644 x/operator/types/query.pb.go create mode 100644 x/operator/types/query.pb.gw.go create mode 100644 x/operator/types/tx.pb.go diff --git a/app/app.go b/app/app.go index 2738f08aa..e72ea46fd 100644 --- a/app/app.go +++ b/app/app.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "fmt" + "github.com/exocore/x/operator" + operatorkeeper "github.com/exocore/x/operator/keeper" "io" "net/http" "os" @@ -45,6 +47,7 @@ import ( "github.com/evmos/evmos/v14/x/recovery" "github.com/evmos/evmos/v14/x/revenue/v1" vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" + operatorTypes "github.com/exocore/x/operator/types" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" @@ -352,6 +355,7 @@ type ExocoreApp struct { DelegationKeeper delegationKeeper.Keeper WithdrawKeeper withdrawKeeper.Keeper RewardKeeper rewardKeeper.Keeper + OperatorKeeper operatorkeeper.Keeper ExoSlashKeeper slashKeeper.Keeper // the module manager @@ -435,6 +439,7 @@ func NewExocoreApp( withdrawTypes.StoreKey, rewardTypes.StoreKey, exoslashTypes.StoreKey, + operatorTypes.StoreKey, ) // Add the EVM transient store key @@ -616,8 +621,12 @@ func NewExocoreApp( // set exoCore staking keepers app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec) app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper) + + app.OperatorKeeper = operatorkeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, nil) // todo: need to replace the virtual keepers with actual keepers after they have been implemented - app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, delegationTypes.VirtualOperatorOptedInKeeper{}) + app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, app.OperatorKeeper) + app.OperatorKeeper.RegisterExpectDelegationInterface(app.DelegationKeeper) + app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.StakingAssetsManageKeeper, app.DepositKeeper) app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.StakingAssetsManageKeeper) app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.StakingAssetsManageKeeper) @@ -791,6 +800,7 @@ func NewExocoreApp( // exoCore app modules restaking_assets_manage.NewAppModule(appCodec, app.StakingAssetsManageKeeper), deposit.NewAppModule(appCodec, app.DepositKeeper), + operator.NewAppModule(appCodec, app.OperatorKeeper), delegation.NewAppModule(appCodec, app.DelegationKeeper), withdraw.NewAppModule(appCodec, app.WithdrawKeeper), reward.NewAppModule(appCodec, app.RewardKeeper), @@ -837,6 +847,7 @@ func NewExocoreApp( // ExoCore modules stakingAssetsManageTypes.ModuleName, depositTypes.ModuleName, + operatorTypes.ModuleName, delegationTypes.ModuleName, withdrawTypes.ModuleName, rewardTypes.ModuleName, @@ -879,6 +890,7 @@ func NewExocoreApp( // ExoCore modules stakingAssetsManageTypes.ModuleName, depositTypes.ModuleName, + operatorTypes.ModuleName, delegationTypes.ModuleName, withdrawTypes.ModuleName, rewardTypes.ModuleName, @@ -919,6 +931,7 @@ func NewExocoreApp( // ExoCore modules stakingAssetsManageTypes.ModuleName, depositTypes.ModuleName, + operatorTypes.ModuleName, delegationTypes.ModuleName, withdrawTypes.ModuleName, rewardTypes.ModuleName, diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index d611ffe2e..f3e183887 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -45,15 +45,8 @@ message SingleDelegationInfoReq { string assetId = 3; } -message QueryOperatorInfoReq { - string OperatorAddr = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; -} service Query { - rpc QueryOperatorInfo(QueryOperatorInfoReq) returns(OperatorInfo){ - option (google.api.http).get = "/exocore/delegation/v1/GetOperatorInfo"; - } // Balance queries the balance of a single coin for a single account. rpc QueryDelegationInfo(DelegationInfoReq) returns (QueryDelegationInfoResponse) { option (cosmos.query.v1.module_query_safe) = true; diff --git a/proto/exocore/delegation/v1/tx.proto b/proto/exocore/delegation/v1/tx.proto index f68695858..2cb9e2a2d 100644 --- a/proto/exocore/delegation/v1/tx.proto +++ b/proto/exocore/delegation/v1/tx.proto @@ -29,40 +29,11 @@ message DelegatedSingleAssetInfo { map PerOperatorAmounts = 3; } -message clientChainEarningAddrList { - repeated clientChainEarningAddrInfo EarningInfoList = 1; -} - -message clientChainEarningAddrInfo { - uint64 lzClientChainId = 1; - string clientChainEarningAddr = 2; -} - -message OperatorInfo{ - string EarningsAddr = 1; - string ApproveAddr = 2; - string OperatorMetaInfo = 3; - clientChainEarningAddrList ClientChainEarningsAddr = 4; -} - -message RegisterOperatorReq { - option (cosmos.msg.v1.signer) = "FromAddress"; - option (amino.name) = "cosmos-sdk/OperatorInfo"; - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string FromAddress = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; - OperatorInfo info = 2; -} - message DelegationApproveInfo{ string signature = 1; string salt = 2; } -message RegisterOperatorResponse{} - message DelegationIncOrDecInfo{ option (cosmos.msg.v1.signer) = "fromAddress"; option (amino.name) = "cosmos-sdk/MsgAddOrDecreaseDelegation"; @@ -119,7 +90,6 @@ message UndelegationResponse{} service Msg { option (cosmos.msg.v1.service) = true; // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. - rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); rpc DelegateAssetToOperator(MsgDelegation) returns (DelegationResponse); rpc UndelegateAssetFromOperator(MsgUndelegation) returns (UndelegationResponse); } diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto new file mode 100644 index 000000000..296053023 --- /dev/null +++ b/proto/exocore/operator/v1/query.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package exocore.operator.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/query/v1/query.proto"; +import "cosmos_proto/cosmos.proto"; +import "exocore/operator/v1/tx.proto"; + +option go_package = "github.com/exocore/x/operator/types"; + +message QueryOperatorInfoReq { + string OperatorAddr = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +service Query { + rpc QueryOperatorInfo(QueryOperatorInfoReq) returns(OperatorInfo){ + option (google.api.http).get = "/exocore/delegation/v1/GetOperatorInfo"; + } +} + diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto new file mode 100644 index 000000000..746a05b74 --- /dev/null +++ b/proto/exocore/operator/v1/tx.proto @@ -0,0 +1,83 @@ +syntax = "proto3"; +package exocore.operator.v1; + +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/exocore/x/operator/types"; + +message clientChainEarningAddrList { + repeated clientChainEarningAddrInfo EarningInfoList = 1; +} + +message clientChainEarningAddrInfo { + uint64 lzClientChainId = 1; + string clientChainEarningAddr = 2; +} + +message OperatorInfo{ + string EarningsAddr = 1; + string ApproveAddr = 2; + string OperatorMetaInfo = 3; + clientChainEarningAddrList ClientChainEarningsAddr = 4; +} + +message OptedInfo { + string SlashContract = 1; + uint64 OptedInHeight = 2; + uint64 OptedOutHeight = 3; +} + +message AssetOptedInState{ + string Amount = 1 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + string Value = 2 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +message OperatorSlashInfo { + string SlashContract = 1; + uint64 SlashHeight = 2; + uint64 ExecuteHeight = 3; + string SlashProportion = 4 + [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message RegisterOperatorReq { + option (cosmos.msg.v1.signer) = "FromAddress"; + option (amino.name) = "cosmos-sdk/OperatorInfo"; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string FromAddress = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + OperatorInfo info = 2; +} + +message RegisterOperatorResponse{} + +// Msg defines the delegation Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. + rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); +} + + + + diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index 932858ab0..c3e490b1c 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -8,6 +8,15 @@ import "amino/amino.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; +message ValueField { + string Amount = 1 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + message ClientChainInfo { string ChainName = 1; string ChainMetaInfo = 2; diff --git a/x/delegation/client/cli/query.go b/x/delegation/client/cli/query.go index a89473dbc..ec77dab3f 100644 --- a/x/delegation/client/cli/query.go +++ b/x/delegation/client/cli/query.go @@ -26,7 +26,6 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand( QuerySingleDelegationInfo(), QueryDelegationInfo(), - QueryOperatorInfo(), ) return cmd } @@ -96,32 +95,3 @@ func QueryDelegationInfo() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } - -// QueryOperatorInfo queries operator info -func QueryOperatorInfo() *cobra.Command { - cmd := &cobra.Command{ - Use: "QueryOperatorInfo operatorAddr", - Short: "Get operator info", - Long: "Get operator info", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := delegationtype.NewQueryClient(clientCtx) - req := &delegationtype.QueryOperatorInfoReq{ - OperatorAddr: args[0], - } - res, err := queryClient.QueryOperatorInfo(context.Background(), req) - if err != nil { - return err - } - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - return cmd -} diff --git a/x/delegation/client/cli/tx.go b/x/delegation/client/cli/tx.go index 276c11b41..951a4341b 100644 --- a/x/delegation/client/cli/tx.go +++ b/x/delegation/client/cli/tx.go @@ -1,17 +1,10 @@ package cli import ( - "fmt" - "strconv" - "strings" - - errorsmod "cosmossdk.io/errors" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" ) // NewTxCmd returns a root CLI command handler for deposit commands @@ -25,57 +18,7 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - RegisterOperator(), + //add tx commands ) return txCmd } - -// RegisterOperator register to be a operator -func RegisterOperator() *cobra.Command { - cmd := &cobra.Command{ - Use: "RegisterOperator EarningsAddr ApproveAddr OperatorMetaInfo clientChainLzID:ClientChainEarningsAddr", - Short: "register to be a operator", - Args: cobra.MinimumNArgs(4), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := cliCtx.GetFromAddress() - msg := &delegationtype.RegisterOperatorReq{ - FromAddress: sender.String(), - Info: &delegationtype.OperatorInfo{ - EarningsAddr: args[0], - ApproveAddr: args[1], - OperatorMetaInfo: args[2], - }, - } - lastArgs := args[3:] - clientChainEarningAddress := &delegationtype.ClientChainEarningAddrList{} - clientChainEarningAddress.EarningInfoList = make([]*delegationtype.ClientChainEarningAddrInfo, 0) - for _, arg := range lastArgs { - strList := strings.Split(arg, ":") - if len(strList) != 2 { - return errorsmod.Wrap(delegationtype.ErrCliCmdInputArg, fmt.Sprintf("the error input arg is:%s", arg)) - } - clientChainLzId, err := strconv.ParseUint(strList[0], 10, 64) - if err != nil { - return err - } - clientChainEarningAddress.EarningInfoList = append(clientChainEarningAddress.EarningInfoList, - &delegationtype.ClientChainEarningAddrInfo{ - LzClientChainId: clientChainLzId, ClientChainEarningAddr: strList[1], - }) - } - msg.Info.ClientChainEarningsAddr = clientChainEarningAddress - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index ef6938279..1773475d7 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -26,7 +26,7 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat operatorAccAddress := sdk.MustAccAddressFromBech32(record.OperatorAddr) if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { // reSet the completed height if the operator is frozen - record.CompleteBlockNumber = k.operatorOptedInKeeper.GetOperatorCanUndelegateHeight(ctx, record.AssetId, operatorAccAddress, record.BlockNumber) + record.CompleteBlockNumber = k.expectOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) if record.CompleteBlockNumber <= uint64(ctx.BlockHeight()) { panic(fmt.Sprintf("the reset completedHeight isn't in future,setHeight:%v,curHeight:%v", record.CompleteBlockNumber, ctx.BlockHeight())) } diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 0aadd7213..4ca66c5ab 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -111,7 +111,7 @@ type DelegationOrUndelegationParams struct { // DelegateTo : It doesn't need to check the active status of the operator in middlewares when delegating assets to the operator. This is because it adds assets to the operator's amount. But it needs to check if operator has been slashed or frozen. func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the delegatedTo address is an operator - if !k.IsOperator(ctx, params.OperatorAddress) { + if !k.expectOperatorInterface.IsOperator(ctx, params.OperatorAddress) { return errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", params.OperatorAddress)) } @@ -166,6 +166,11 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara if err != nil { return err } + // call operator module to bond the increased assets to the opted-in AVS + err = k.expectOperatorInterface.IncreasedOptedInAssets(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) + if err != nil { + return err + } return nil } @@ -174,7 +179,7 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara // So we use two steps to handle the undelegation. Fist,record the undelegation request and the corresponding exit time which needs to be obtained from the operator opt-in module. Then,we handle the record when the exit time has expired. func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the UndelegatedFrom address is an operator - if !k.IsOperator(ctx, params.OperatorAddress) { + if !k.expectOperatorInterface.IsOperator(ctx, params.OperatorAddress) { return delegationtype.ErrOperatorNotExist } if params.OpAmount.IsNegative() { @@ -202,7 +207,7 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation Amount: params.OpAmount, ActualCompletedAmount: sdkmath.NewInt(0), } - r.CompleteBlockNumber = k.operatorOptedInKeeper.GetOperatorCanUndelegateHeight(ctx, assetId, params.OperatorAddress, r.BlockNumber) + r.CompleteBlockNumber = k.expectOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) if err != nil { return err @@ -232,6 +237,13 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation if err != nil { return err } + + // call operator module to decrease the state of opted-in assets + err = k.expectOperatorInterface.DecreaseOptedInAssets(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) + if err != nil { + return err + } + return nil } diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 3c6c50978..5e51b815f 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -9,6 +9,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + types2 "github.com/exocore/x/operator/types" ) func (suite *KeeperTestSuite) TestDelegateTo() { @@ -40,13 +41,13 @@ func (suite *KeeperTestSuite) TestDelegateTo() { err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParams) suite.EqualError(err, delegationtype.ErrOperatorNotExist.Error()) - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &types2.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &delegationtype.OperatorInfo{ + Info: &types2.OperatorInfo{ EarningsAddr: opAccAddr.String(), }, } - _, err = suite.app.DelegationKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) suite.NoError(err) err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParams) @@ -108,13 +109,13 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &types2.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &delegationtype.OperatorInfo{ + Info: &types2.OperatorInfo{ EarningsAddr: opAccAddr.String(), }, } - _, err = suite.app.DelegationKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) suite.NoError(err) err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationEvent) @@ -204,13 +205,13 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &types2.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &delegationtype.OperatorInfo{ + Info: &types2.OperatorInfo{ EarningsAddr: opAccAddr.String(), }, } - _, err = suite.app.DelegationKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) suite.NoError(err) err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationEvent) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 71ff7fa3a..27b98a588 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -7,7 +7,7 @@ import ( sdkmath "cosmossdk.io/math" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + stakingtypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,17 +19,16 @@ func (k Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId stri if opAmount.IsNil() || opAmount.IsZero() { return nil } - c := sdk.UnwrapSDKContext(ctx) // use stakerId+'/'+assetId as the key of total delegation amount - store := prefix.NewStore(c.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) amount := delegationtype.ValueField{Amount: sdkmath.NewInt(0)} - key := types.GetAssetStateKey(stakerId, assetId) + key := stakingtypes.GetJoinedStoreKey(stakerId, assetId) if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &amount) } - err := keeper.UpdateAssetValue(&amount.Amount, &opAmount) + err := stakingtypes.UpdateAssetValue(&amount.Amount, &opAmount) if err != nil { return err } @@ -41,10 +40,9 @@ func (k Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId stri // GetStakerDelegationTotalAmount query the total delegation amount of the specified staker and asset. func (k Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string) (opAmount sdkmath.Int, err error) { - c := sdk.UnwrapSDKContext(ctx) - store := prefix.NewStore(c.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) var ret delegationtype.ValueField - prefixKey := types.GetAssetStateKey(stakerId, assetId) + prefixKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId) isExit := store.Has(prefixKey) if !isExit { return sdkmath.Int{}, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerDelegationTotalAmount: key is %s", prefixKey)) @@ -73,7 +71,7 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId if err != nil { return delegationtype.OperatorAddrIsNotAccAddr } - singleStateKey := delegationtype.GetDelegationStateKey(stakerId, assetId, opAddr) + singleStateKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId, opAddr) delegationState := delegationtype.DelegationAmounts{ CanUndelegationAmount: sdkmath.NewInt(0), WaitUndelegationAmount: sdkmath.NewInt(0), @@ -84,12 +82,12 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId k.cdc.MustUnmarshal(value, &delegationState) } - err = keeper.UpdateAssetValue(&delegationState.CanUndelegationAmount, &amounts.CanUndelegationAmount) + err = stakingtypes.UpdateAssetValue(&delegationState.CanUndelegationAmount, &amounts.CanUndelegationAmount) if err != nil { return errorsmod.Wrap(err, "UpdateDelegationState CanUndelegationAmount error") } - err = keeper.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) + err = stakingtypes.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) if err != nil { return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } @@ -104,7 +102,7 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId // GetSingleDelegationInfo query the staker's asset amount that has been delegated to the specified operator. func (k Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, operatorAddr string) (*delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) - singleStateKey := delegationtype.GetDelegationStateKey(stakerId, assetId, operatorAddr) + singleStateKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId, operatorAddr) isExit := store.Has(singleStateKey) delegationState := delegationtype.DelegationAmounts{} if isExit { @@ -118,8 +116,6 @@ func (k Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, oper // GetDelegationInfo query the staker's asset info that has been delegated. func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*delegationtype.QueryDelegationInfoResponse, error) { - c := sdk.UnwrapSDKContext(ctx) - var ret delegationtype.QueryDelegationInfoResponse totalAmount, err := k.GetStakerDelegationTotalAmount(ctx, stakerId, assetId) if err != nil { @@ -127,7 +123,7 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d } ret.TotalDelegatedAmount = totalAmount - store := prefix.NewStore(c.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, delegationtype.GetDelegationStateIteratorPrefix(stakerId, assetId)) defer iterator.Close() @@ -144,3 +140,9 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d return &ret, nil } + +// GetDelegationStateByOperator get all assets state delegated to the specified operator +func (k Keeper) GetDelegationStateByOperator(ctx sdk.Context, operatorAddr string) (map[string]sdkmath.Int, error) { + + return nil, nil +} diff --git a/x/delegation/keeper/grpc_query.go b/x/delegation/keeper/grpc_query.go index 812e675d2..2a2f7f56a 100644 --- a/x/delegation/keeper/grpc_query.go +++ b/x/delegation/keeper/grpc_query.go @@ -18,8 +18,3 @@ func (k Keeper) QueryDelegationInfo(ctx context.Context, info *delegationtype.De c := sdk.UnwrapSDKContext(ctx) return k.GetDelegationInfo(c, info.StakerId, info.AssetId) } - -func (k Keeper) QueryOperatorInfo(ctx context.Context, req *delegationtype.QueryOperatorInfoReq) (*delegationtype.OperatorInfo, error) { - c := sdk.UnwrapSDKContext(ctx) - return k.GetOperatorInfo(c, req.OperatorAddr) -} diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 1f11cec43..06a6f6552 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -9,7 +9,6 @@ import ( depositkeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -22,10 +21,10 @@ type Keeper struct { cdc codec.BinaryCodec //other keepers - restakingStateKeeper keeper.Keeper - depositKeeper depositkeeper.Keeper - slashKeeper delegationtype.ISlashKeeper - operatorOptedInKeeper delegationtype.OperatorOptedInMiddlewareKeeper + restakingStateKeeper keeper.Keeper + depositKeeper depositkeeper.Keeper + slashKeeper delegationtype.ISlashKeeper + expectOperatorInterface delegationtype.ExpectOperatorInterface } func NewKeeper( @@ -34,61 +33,18 @@ func NewKeeper( restakingStateKeeper keeper.Keeper, depositKeeper depositkeeper.Keeper, slashKeeper delegationtype.ISlashKeeper, - operatorOptedInKeeper delegationtype.OperatorOptedInMiddlewareKeeper, + operatorKeeper delegationtype.ExpectOperatorInterface, ) Keeper { return Keeper{ - storeKey: storeKey, - cdc: cdc, - restakingStateKeeper: restakingStateKeeper, - depositKeeper: depositKeeper, - slashKeeper: slashKeeper, - operatorOptedInKeeper: operatorOptedInKeeper, + storeKey: storeKey, + cdc: cdc, + restakingStateKeeper: restakingStateKeeper, + depositKeeper: depositKeeper, + slashKeeper: slashKeeper, + expectOperatorInterface: operatorKeeper, } } -// SetOperatorInfo This function is used to register to be an operator in exoCore, the provided info will be stored on the chain. -// Once an address has become an operator,the operator can't return to a normal address.But the operator can update the info through this function -// As for the operator opt-in function,it needs to be implemented in operator opt-in or AVS module -func (k Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *delegationtype.OperatorInfo) (err error) { - opAccAddr, err := sdk.AccAddressFromBech32(addr) - if err != nil { - return errorsmod.Wrap(err, "SetOperatorInfo: error occurred when parse acc address from Bech32") - } - // todo: to check the validation of input info - store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixOperatorInfo) - // todo: think about the difference between init and update in future - - //key := common.HexToAddress(incentive.Contract) - bz := k.cdc.MustMarshal(info) - - store.Set(opAccAddr, bz) - return nil -} - -func (k Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *delegationtype.OperatorInfo, err error) { - opAccAddr, err := sdk.AccAddressFromBech32(addr) - if err != nil { - return nil, errorsmod.Wrap(err, "GetOperatorInfo: error occurred when parse acc address from Bech32") - } - store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixOperatorInfo) - //key := common.HexToAddress(incentive.Contract) - ifExist := store.Has(opAccAddr) - if !ifExist { - return nil, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %s", opAccAddr)) - } - - value := store.Get(opAccAddr) - - ret := delegationtype.OperatorInfo{} - k.cdc.MustUnmarshal(value, &ret) - return &ret, nil -} - -func (k Keeper) IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool { - store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixOperatorInfo) - return store.Has(addr) -} - // GetExoCoreLzAppAddress Get exoCoreLzAppAddr from deposit keeper,it will be used when check the caller of precompile contract. // This function needs to be moved to `restaking_assets_manage` module,which will facilitate its use for the other modules func (k Keeper) GetExoCoreLzAppAddress(ctx sdk.Context) (common.Address, error) { @@ -100,8 +56,6 @@ type IDelegation interface { // PostTxProcessing automatically call PostTxProcessing to update delegation state after receiving delegation event tx from layerZero protocol PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error - // RegisterOperator handle the registerOperator txs from msg service - RegisterOperator(ctx context.Context, req *delegationtype.RegisterOperatorReq) (*delegationtype.RegisterOperatorResponse, error) // DelegateAssetToOperator handle the DelegateAssetToOperator txs from msg service DelegateAssetToOperator(ctx context.Context, delegation *delegationtype.MsgDelegation) (*delegationtype.DelegationResponse, error) // UndelegateAssetFromOperator handle the UndelegateAssetFromOperator txs from msg service diff --git a/x/delegation/keeper/msg_server.go b/x/delegation/keeper/msg_server.go index f7cfbaa97..9ec0be3fe 100644 --- a/x/delegation/keeper/msg_server.go +++ b/x/delegation/keeper/msg_server.go @@ -5,20 +5,10 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/delegation/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) var _ types.MsgServer = &Keeper{} -func (k Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperatorReq) (*types.RegisterOperatorResponse, error) { - c := sdk.UnwrapSDKContext(ctx) - err := k.SetOperatorInfo(c, req.FromAddress, req.Info) - if err != nil { - return nil, err - } - return nil, nil -} - // DelegateAssetToOperator todo: Delegation and Undelegation from exoCore chain directly will be implemented in future.At the moment,they are executed from client chain func (k Keeper) DelegateAssetToOperator(ctx context.Context, delegation *types.MsgDelegation) (*types.DelegationResponse, error) { return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:DelegateAssetToOperator") diff --git a/x/delegation/keeper/operator_info_test.go b/x/delegation/keeper/operator_info_test.go deleted file mode 100644 index aec84310d..000000000 --- a/x/delegation/keeper/operator_info_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package keeper_test - -import delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - -func (suite *KeeperTestSuite) TestOperatorInfo() { - info := &delegationtype.OperatorInfo{ - EarningsAddr: suite.accAddress.String(), - ApproveAddr: "", - OperatorMetaInfo: "test operator", - ClientChainEarningsAddr: &delegationtype.ClientChainEarningAddrList{ - EarningInfoList: []*delegationtype.ClientChainEarningAddrInfo{ - {101, "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"}, - }, - }, - } - err := suite.app.DelegationKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) - suite.NoError(err) - - getOperatorInfo, err := suite.app.DelegationKeeper.GetOperatorInfo(suite.ctx, suite.accAddress.String()) - suite.NoError(err) - suite.Equal(*info, *getOperatorInfo) -} diff --git a/x/delegation/types/errors.go b/x/delegation/types/errors.go index 5b15c2eab..4e1e4811a 100644 --- a/x/delegation/types/errors.go +++ b/x/delegation/types/errors.go @@ -22,7 +22,5 @@ var ( ErrNotSupportYet = errorsmod.Register(ModuleName, 9, "don't have supported it yet") - ErrCliCmdInputArg = errorsmod.Register(ModuleName, 10, "there is an error in the input client command args") - - ErrDelegationAmountTooBig = errorsmod.Register(ModuleName, 11, "the delegation amount is bigger than the canWithdraw amount") + ErrDelegationAmountTooBig = errorsmod.Register(ModuleName, 10, "the delegation amount is bigger than the canWithdraw amount") ) diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index d75f51feb..8cdbd81a0 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -23,12 +23,11 @@ func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAdd return sdkmath.LegacyNewDec(0) } -type OperatorOptedInMiddlewareKeeper interface { - GetOperatorCanUndelegateHeight(ctx sdk.Context, assetId string, opAddr sdk.AccAddress, startHeight uint64) uint64 -} +type ExpectOperatorInterface interface { + IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool + GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 -type VirtualOperatorOptedInKeeper struct{} + IncreasedOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error -func (VirtualOperatorOptedInKeeper) GetOperatorCanUndelegateHeight(ctx sdk.Context, assetId string, opAddr sdk.AccAddress, startHeight uint64) uint64 { - return startHeight + CanUndelegationDelayHeight + DecreaseOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error } diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index f79083f80..f0d013dc0 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -1,11 +1,10 @@ package types import ( - errorsmod "cosmossdk.io/errors" - "fmt" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/exocore/x/restaking_assets_manage/types" "strings" ) @@ -29,8 +28,7 @@ func init() { } const ( - prefixOperatorInfo = iota + 1 - prefixRestakerDelegationInfo + prefixRestakerDelegationInfo = iota + 1 prefixDelegationUsedSalt prefixOperatorApprovedInfo @@ -42,14 +40,11 @@ const ( ) var ( - // KeyPrefixOperatorInfo key-value: operatorAddr->operatorInfo - KeyPrefixOperatorInfo = []byte{prefixOperatorInfo} // KeyPrefixRestakerDelegationInfo reStakerId = clientChainAddr+'_'+ExoCoreChainIndex // KeyPrefixRestakerDelegationInfo // key-value: // reStakerId +'/'+assetId -> totalDelegationAmount // reStakerId +'/'+assetId+'/'+operatorAddr -> delegationAmounts - KeyPrefixRestakerDelegationInfo = []byte{prefixRestakerDelegationInfo} // KeyPrefixDelegationUsedSalt key->value: operatorApproveAddr->map[salt]{} KeyPrefixDelegationUsedSalt = []byte{prefixDelegationUsedSalt} @@ -65,10 +60,6 @@ var ( KeyPrefixWaitCompleteUndelegations = []byte{prefixWaitCompleteUndelegations} ) -func GetDelegationStateKey(stakerId, assetId, operatorAddr string) []byte { - return []byte(strings.Join([]string{stakerId, assetId, operatorAddr}, "/")) -} - func GetDelegationStateIteratorPrefix(stakerId, assetId string) []byte { tmp := []byte(strings.Join([]string{stakerId, assetId}, "/")) tmp = append(tmp, '/') @@ -76,9 +67,9 @@ func GetDelegationStateIteratorPrefix(stakerId, assetId string) []byte { } func ParseStakerAssetIdAndOperatorAddrFromKey(key []byte) (keys *SingleDelegationInfoReq, err error) { - stringList := strings.Split(string(key), "/") - if len(stringList) != 3 { - return nil, errorsmod.Wrap(ErrParseDelegationKey, fmt.Sprintf("the stringList is:%v", stringList)) + stringList, err := types.ParseJoinedStoreKey(key, 3) + if err != nil { + return nil, err } return &SingleDelegationInfoReq{StakerId: stringList[0], AssetId: stringList[1], OperatorAddr: stringList[2]}, nil } diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index 8cbe7d129..2974b7345 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -227,102 +227,54 @@ func (m *SingleDelegationInfoReq) GetAssetId() string { return "" } -type QueryOperatorInfoReq struct { - OperatorAddr string `protobuf:"bytes,1,opt,name=OperatorAddr,proto3" json:"OperatorAddr,omitempty"` -} - -func (m *QueryOperatorInfoReq) Reset() { *m = QueryOperatorInfoReq{} } -func (m *QueryOperatorInfoReq) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorInfoReq) ProtoMessage() {} -func (*QueryOperatorInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{4} -} -func (m *QueryOperatorInfoReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOperatorInfoReq.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 *QueryOperatorInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorInfoReq.Merge(m, src) -} -func (m *QueryOperatorInfoReq) XXX_Size() int { - return m.Size() -} -func (m *QueryOperatorInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorInfoReq.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOperatorInfoReq proto.InternalMessageInfo - -func (m *QueryOperatorInfoReq) GetOperatorAddr() string { - if m != nil { - return m.OperatorAddr - } - return "" -} - func init() { proto.RegisterType((*DelegationInfoReq)(nil), "exocore.delegation.v1.DelegationInfoReq") 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((*QueryOperatorInfoReq)(nil), "exocore.delegation.v1.QueryOperatorInfoReq") } func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 620 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xdf, 0x6b, 0xd3, 0x50, - 0x18, 0xed, 0x4d, 0x9d, 0x3f, 0xee, 0x06, 0xba, 0x6b, 0xa7, 0x5d, 0x26, 0xd9, 0x8c, 0x38, 0xca, - 0xa4, 0x89, 0xab, 0x08, 0x22, 0x55, 0xd9, 0x54, 0x46, 0x9e, 0x86, 0xd9, 0x44, 0xf0, 0x45, 0xb2, - 0xe6, 0x1a, 0x43, 0xd3, 0x7b, 0xd3, 0xdc, 0xdb, 0xd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9d, 0x0d, 0x37, 0xfe, 0x9d, 0x7f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x14, 0x6c, 0x33, 0x44, 0xb9, 0x06, 0x00, 0x00, + // 570 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x41, + 0x1c, 0xcd, 0x6c, 0xa8, 0x7f, 0xa6, 0x82, 0x3a, 0xa6, 0x9a, 0x6e, 0x65, 0x5b, 0x17, 0x94, 0x50, + 0xc8, 0xae, 0x5d, 0x11, 0x44, 0xaa, 0xd2, 0xaa, 0x94, 0x3d, 0xba, 0x55, 0x04, 0x2f, 0x32, 0xcd, + 0x8e, 0xeb, 0x92, 0xcd, 0xcc, 0x66, 0x66, 0x12, 0x92, 0xab, 0x27, 0x2f, 0x82, 0xe0, 0xb7, 0xf0, + 0xe4, 0x21, 0x1f, 0xa2, 0xc7, 0x52, 0x2f, 0xe2, 0xa1, 0x48, 0x22, 0x78, 0xf0, 0xe2, 0x17, 0x10, + 0x24, 0xbb, 0xd3, 0x36, 0x59, 0x77, 0xb5, 0x85, 0x9e, 0x32, 0x33, 0xef, 0xe5, 0xcd, 0x9b, 0xf7, + 0xfb, 0xfd, 0x16, 0x5e, 0x23, 0x3d, 0xd6, 0x60, 0x9c, 0xd8, 0x3e, 0x89, 0x48, 0x80, 0x65, 0xc8, + 0xa8, 0xdd, 0x5d, 0xb1, 0xdb, 0x1d, 0xc2, 0xfb, 0x56, 0xcc, 0x99, 0x64, 0x68, 0x4e, 0x51, 0xac, + 0x43, 0x8a, 0xd5, 0x5d, 0xd1, 0x2b, 0x01, 0x0b, 0x58, 0xc2, 0xb0, 0xc7, 0xab, 0x94, 0xac, 0x5f, + 0x0d, 0x18, 0x0b, 0x22, 0x62, 0xe3, 0x38, 0xb4, 0x31, 0xa5, 0x4c, 0x26, 0x7c, 0xa1, 0xd0, 0x85, + 0x06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df, 0x86, 0x06, 0x78, + 0x3f, 0x32, 0x4a, 0x3b, 0x23, 0xa3, 0xf4, 0x65, 0x64, 0x94, 0x5e, 0x5c, 0x9f, 0x18, 0xa2, 0x7d, + 0xd5, 0xde, 0xa4, 0x6e, 0x32, 0x47, 0x5b, 0xa7, 0x92, 0x6f, 0xe0, 0xad, 0x3f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x8d, 0x43, 0x76, 0xff, 0xcb, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -337,7 +289,6 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) // Balance queries the balance of a single coin for a single account. QueryDelegationInfo(ctx context.Context, in *DelegationInfoReq, opts ...grpc.CallOption) (*QueryDelegationInfoResponse, error) QuerySingleDelegationInfo(ctx context.Context, in *SingleDelegationInfoReq, opts ...grpc.CallOption) (*DelegationAmounts, error) @@ -351,15 +302,6 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) { - out := new(OperatorInfo) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QueryOperatorInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - 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...) @@ -380,7 +322,6 @@ func (c *queryClient) QuerySingleDelegationInfo(ctx context.Context, in *SingleD // QueryServer is the server API for Query service. type QueryServer interface { - QueryOperatorInfo(context.Context, *QueryOperatorInfoReq) (*OperatorInfo, error) // Balance queries the balance of a single coin for a single account. QueryDelegationInfo(context.Context, *DelegationInfoReq) (*QueryDelegationInfoResponse, error) QuerySingleDelegationInfo(context.Context, *SingleDelegationInfoReq) (*DelegationAmounts, error) @@ -390,9 +331,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) QueryOperatorInfo(ctx context.Context, req *QueryOperatorInfoReq) (*OperatorInfo, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorInfo not implemented") -} func (*UnimplementedQueryServer) QueryDelegationInfo(ctx context.Context, req *DelegationInfoReq) (*QueryDelegationInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryDelegationInfo not implemented") } @@ -404,24 +342,6 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_QueryOperatorInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOperatorInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryOperatorInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QueryOperatorInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryOperatorInfo(ctx, req.(*QueryOperatorInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - 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 { @@ -462,10 +382,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.delegation.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "QueryOperatorInfo", - Handler: _Query_QueryOperatorInfo_Handler, - }, { MethodName: "QueryDelegationInfo", Handler: _Query_QueryDelegationInfo_Handler, @@ -662,36 +578,6 @@ func (m *SingleDelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryOperatorInfoReq) 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 *QueryOperatorInfoReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - 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] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -778,19 +664,6 @@ func (m *SingleDelegationInfoReq) Size() (n int) { return n } -func (m *QueryOperatorInfoReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1388,88 +1261,6 @@ func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOperatorInfoReq) 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: QueryOperatorInfoReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 - 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 diff --git a/x/delegation/types/query.pb.gw.go b/x/delegation/types/query.pb.gw.go index f73dc307f..cbf25a404 100644 --- a/x/delegation/types/query.pb.gw.go +++ b/x/delegation/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,42 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage - -var ( - filter_Query_QueryOperatorInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorInfoReq - 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_QueryOperatorInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryOperatorInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorInfoReq - 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_QueryOperatorInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryOperatorInfo(ctx, &protoReq) - return msg, metadata, err - -} +var _ = metadata.Join var ( filter_Query_QueryDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} @@ -142,32 +108,14 @@ func local_request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marsha // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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_QueryOperatorInfo_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.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_QueryOperatorInfo_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - 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 { @@ -175,6 +123,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) @@ -188,6 +137,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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 { @@ -195,6 +146,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) @@ -246,26 +198,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_QueryOperatorInfo_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_QueryOperatorInfo_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_QueryOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - 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() @@ -310,16 +242,12 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_QueryOperatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetOperatorInfo"}, "", runtime.AssumeColonVerbOpt(false))) - 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))) ) var ( - forward_Query_QueryOperatorInfo_0 = runtime.ForwardResponseMessage - forward_Query_QueryDelegationInfo_0 = runtime.ForwardResponseMessage forward_Query_QuerySingleDelegationInfo_0 = runtime.ForwardResponseMessage diff --git a/x/delegation/types/tx.pb.go b/x/delegation/types/tx.pb.go index 2a9ad0f2c..726cd1eca 100644 --- a/x/delegation/types/tx.pb.go +++ b/x/delegation/types/tx.pb.go @@ -122,208 +122,6 @@ func (m *DelegatedSingleAssetInfo) GetPerOperatorAmounts() map[string]*ValueFiel return nil } -type ClientChainEarningAddrList struct { - EarningInfoList []*ClientChainEarningAddrInfo `protobuf:"bytes,1,rep,name=EarningInfoList,proto3" json:"EarningInfoList,omitempty"` -} - -func (m *ClientChainEarningAddrList) Reset() { *m = ClientChainEarningAddrList{} } -func (m *ClientChainEarningAddrList) String() string { return proto.CompactTextString(m) } -func (*ClientChainEarningAddrList) ProtoMessage() {} -func (*ClientChainEarningAddrList) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{2} -} -func (m *ClientChainEarningAddrList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ClientChainEarningAddrList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ClientChainEarningAddrList.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 *ClientChainEarningAddrList) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientChainEarningAddrList.Merge(m, src) -} -func (m *ClientChainEarningAddrList) XXX_Size() int { - return m.Size() -} -func (m *ClientChainEarningAddrList) XXX_DiscardUnknown() { - xxx_messageInfo_ClientChainEarningAddrList.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientChainEarningAddrList proto.InternalMessageInfo - -func (m *ClientChainEarningAddrList) GetEarningInfoList() []*ClientChainEarningAddrInfo { - if m != nil { - return m.EarningInfoList - } - return nil -} - -type ClientChainEarningAddrInfo struct { - LzClientChainId uint64 `protobuf:"varint,1,opt,name=lzClientChainId,proto3" json:"lzClientChainId,omitempty"` - ClientChainEarningAddr string `protobuf:"bytes,2,opt,name=clientChainEarningAddr,proto3" json:"clientChainEarningAddr,omitempty"` -} - -func (m *ClientChainEarningAddrInfo) Reset() { *m = ClientChainEarningAddrInfo{} } -func (m *ClientChainEarningAddrInfo) String() string { return proto.CompactTextString(m) } -func (*ClientChainEarningAddrInfo) ProtoMessage() {} -func (*ClientChainEarningAddrInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{3} -} -func (m *ClientChainEarningAddrInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ClientChainEarningAddrInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ClientChainEarningAddrInfo.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 *ClientChainEarningAddrInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientChainEarningAddrInfo.Merge(m, src) -} -func (m *ClientChainEarningAddrInfo) XXX_Size() int { - return m.Size() -} -func (m *ClientChainEarningAddrInfo) XXX_DiscardUnknown() { - xxx_messageInfo_ClientChainEarningAddrInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientChainEarningAddrInfo proto.InternalMessageInfo - -func (m *ClientChainEarningAddrInfo) GetLzClientChainId() uint64 { - if m != nil { - return m.LzClientChainId - } - return 0 -} - -func (m *ClientChainEarningAddrInfo) GetClientChainEarningAddr() string { - if m != nil { - return m.ClientChainEarningAddr - } - return "" -} - -type OperatorInfo struct { - EarningsAddr string `protobuf:"bytes,1,opt,name=EarningsAddr,proto3" json:"EarningsAddr,omitempty"` - ApproveAddr string `protobuf:"bytes,2,opt,name=ApproveAddr,proto3" json:"ApproveAddr,omitempty"` - OperatorMetaInfo string `protobuf:"bytes,3,opt,name=OperatorMetaInfo,proto3" json:"OperatorMetaInfo,omitempty"` - ClientChainEarningsAddr *ClientChainEarningAddrList `protobuf:"bytes,4,opt,name=ClientChainEarningsAddr,proto3" json:"ClientChainEarningsAddr,omitempty"` -} - -func (m *OperatorInfo) Reset() { *m = OperatorInfo{} } -func (m *OperatorInfo) String() string { return proto.CompactTextString(m) } -func (*OperatorInfo) ProtoMessage() {} -func (*OperatorInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{4} -} -func (m *OperatorInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OperatorInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_OperatorInfo.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 *OperatorInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_OperatorInfo.Merge(m, src) -} -func (m *OperatorInfo) XXX_Size() int { - return m.Size() -} -func (m *OperatorInfo) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_OperatorInfo proto.InternalMessageInfo - -func (m *OperatorInfo) GetEarningsAddr() string { - if m != nil { - return m.EarningsAddr - } - return "" -} - -func (m *OperatorInfo) GetApproveAddr() string { - if m != nil { - return m.ApproveAddr - } - return "" -} - -func (m *OperatorInfo) GetOperatorMetaInfo() string { - if m != nil { - return m.OperatorMetaInfo - } - return "" -} - -func (m *OperatorInfo) GetClientChainEarningsAddr() *ClientChainEarningAddrList { - if m != nil { - return m.ClientChainEarningsAddr - } - return nil -} - -type RegisterOperatorReq struct { - FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` - Info *OperatorInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` -} - -func (m *RegisterOperatorReq) Reset() { *m = RegisterOperatorReq{} } -func (m *RegisterOperatorReq) String() string { return proto.CompactTextString(m) } -func (*RegisterOperatorReq) ProtoMessage() {} -func (*RegisterOperatorReq) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{5} -} -func (m *RegisterOperatorReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RegisterOperatorReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RegisterOperatorReq.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 *RegisterOperatorReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_RegisterOperatorReq.Merge(m, src) -} -func (m *RegisterOperatorReq) XXX_Size() int { - return m.Size() -} -func (m *RegisterOperatorReq) XXX_DiscardUnknown() { - xxx_messageInfo_RegisterOperatorReq.DiscardUnknown(m) -} - -var xxx_messageInfo_RegisterOperatorReq proto.InternalMessageInfo - type DelegationApproveInfo struct { Signature string `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"` Salt string `protobuf:"bytes,2,opt,name=salt,proto3" json:"salt,omitempty"` @@ -333,7 +131,7 @@ func (m *DelegationApproveInfo) Reset() { *m = DelegationApproveInfo{} } func (m *DelegationApproveInfo) String() string { return proto.CompactTextString(m) } func (*DelegationApproveInfo) ProtoMessage() {} func (*DelegationApproveInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{6} + return fileDescriptor_16596a15a828f109, []int{2} } func (m *DelegationApproveInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -376,42 +174,6 @@ func (m *DelegationApproveInfo) GetSalt() string { return "" } -type RegisterOperatorResponse struct { -} - -func (m *RegisterOperatorResponse) Reset() { *m = RegisterOperatorResponse{} } -func (m *RegisterOperatorResponse) String() string { return proto.CompactTextString(m) } -func (*RegisterOperatorResponse) ProtoMessage() {} -func (*RegisterOperatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{7} -} -func (m *RegisterOperatorResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RegisterOperatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RegisterOperatorResponse.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 *RegisterOperatorResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RegisterOperatorResponse.Merge(m, src) -} -func (m *RegisterOperatorResponse) XXX_Size() int { - return m.Size() -} -func (m *RegisterOperatorResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RegisterOperatorResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo - type DelegationIncOrDecInfo struct { FromAddress string `protobuf:"bytes,1,opt,name=fromAddress,proto3" json:"fromAddress,omitempty"` PerOperatorAmounts map[string]*ValueField `protobuf:"bytes,2,rep,name=perOperatorAmounts,proto3" json:"perOperatorAmounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` @@ -421,7 +183,7 @@ func (m *DelegationIncOrDecInfo) Reset() { *m = DelegationIncOrDecInfo{} func (m *DelegationIncOrDecInfo) String() string { return proto.CompactTextString(m) } func (*DelegationIncOrDecInfo) ProtoMessage() {} func (*DelegationIncOrDecInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{8} + return fileDescriptor_16596a15a828f109, []int{3} } func (m *DelegationIncOrDecInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -459,7 +221,7 @@ func (m *MsgDelegation) Reset() { *m = MsgDelegation{} } func (m *MsgDelegation) String() string { return proto.CompactTextString(m) } func (*MsgDelegation) ProtoMessage() {} func (*MsgDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{9} + return fileDescriptor_16596a15a828f109, []int{4} } func (m *MsgDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,7 +281,7 @@ func (m *UndelegationRecord) Reset() { *m = UndelegationRecord{} } func (m *UndelegationRecord) String() string { return proto.CompactTextString(m) } func (*UndelegationRecord) ProtoMessage() {} func (*UndelegationRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{10} + return fileDescriptor_16596a15a828f109, []int{5} } func (m *UndelegationRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -612,7 +374,7 @@ func (m *UndelegationRecordKeyList) Reset() { *m = UndelegationRecordKey func (m *UndelegationRecordKeyList) String() string { return proto.CompactTextString(m) } func (*UndelegationRecordKeyList) ProtoMessage() {} func (*UndelegationRecordKeyList) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{11} + return fileDescriptor_16596a15a828f109, []int{6} } func (m *UndelegationRecordKeyList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -655,7 +417,7 @@ func (m *DelegationResponse) Reset() { *m = DelegationResponse{} } func (m *DelegationResponse) String() string { return proto.CompactTextString(m) } func (*DelegationResponse) ProtoMessage() {} func (*DelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{12} + return fileDescriptor_16596a15a828f109, []int{7} } func (m *DelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -692,7 +454,7 @@ func (m *MsgUndelegation) Reset() { *m = MsgUndelegation{} } func (m *MsgUndelegation) String() string { return proto.CompactTextString(m) } func (*MsgUndelegation) ProtoMessage() {} func (*MsgUndelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{13} + return fileDescriptor_16596a15a828f109, []int{8} } func (m *MsgUndelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -735,7 +497,7 @@ func (m *UndelegationResponse) Reset() { *m = UndelegationResponse{} } func (m *UndelegationResponse) String() string { return proto.CompactTextString(m) } func (*UndelegationResponse) ProtoMessage() {} func (*UndelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{14} + return fileDescriptor_16596a15a828f109, []int{9} } func (m *UndelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -768,12 +530,7 @@ func init() { proto.RegisterType((*ValueField)(nil), "exocore.delegation.v1.ValueField") proto.RegisterType((*DelegatedSingleAssetInfo)(nil), "exocore.delegation.v1.DelegatedSingleAssetInfo") proto.RegisterMapType((map[string]*ValueField)(nil), "exocore.delegation.v1.DelegatedSingleAssetInfo.PerOperatorAmountsEntry") - proto.RegisterType((*ClientChainEarningAddrList)(nil), "exocore.delegation.v1.clientChainEarningAddrList") - proto.RegisterType((*ClientChainEarningAddrInfo)(nil), "exocore.delegation.v1.clientChainEarningAddrInfo") - proto.RegisterType((*OperatorInfo)(nil), "exocore.delegation.v1.OperatorInfo") - proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.delegation.v1.RegisterOperatorReq") proto.RegisterType((*DelegationApproveInfo)(nil), "exocore.delegation.v1.DelegationApproveInfo") - proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.delegation.v1.RegisterOperatorResponse") proto.RegisterType((*DelegationIncOrDecInfo)(nil), "exocore.delegation.v1.DelegationIncOrDecInfo") proto.RegisterMapType((map[string]*ValueField)(nil), "exocore.delegation.v1.DelegationIncOrDecInfo.PerOperatorAmountsEntry") proto.RegisterType((*MsgDelegation)(nil), "exocore.delegation.v1.MsgDelegation") @@ -787,75 +544,62 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/tx.proto", fileDescriptor_16596a15a828f109) } var fileDescriptor_16596a15a828f109 = []byte{ - // 1082 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcd, 0x6e, 0x23, 0x45, - 0x10, 0xf6, 0xc4, 0xd9, 0xfc, 0x94, 0x83, 0x12, 0x7a, 0xf3, 0x33, 0x3b, 0x20, 0x27, 0x0c, 0xec, - 0x2a, 0x04, 0x62, 0x93, 0xf0, 0xb3, 0xc8, 0x5a, 0x09, 0xe5, 0x6f, 0xc1, 0x62, 0xbd, 0x1b, 0xcd, - 0x06, 0x0e, 0x80, 0x84, 0xc6, 0x33, 0x9d, 0xc9, 0xe0, 0x71, 0xf7, 0x30, 0xdd, 0x0e, 0xf6, 0x1e, - 0x10, 0xe2, 0x04, 0x9c, 0x78, 0x84, 0x7d, 0x00, 0x0e, 0x39, 0xec, 0x03, 0x70, 0xdc, 0xe3, 0x6a, - 0x4f, 0x08, 0x89, 0x15, 0x4a, 0x0e, 0xe1, 0xc2, 0x03, 0xc0, 0x09, 0x4d, 0x77, 0xdb, 0x33, 0x8e, - 0x3d, 0x84, 0x48, 0x91, 0xb8, 0x24, 0xd3, 0x55, 0xd5, 0xdf, 0x57, 0x5d, 0x55, 0x5d, 0xd5, 0x86, - 0x22, 0x6e, 0x53, 0x87, 0x46, 0xb8, 0xec, 0xe2, 0x00, 0x7b, 0x36, 0xf7, 0x29, 0x29, 0x1f, 0xae, - 0x95, 0x79, 0xbb, 0x14, 0x46, 0x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9, 0xb0, 0xfe, 0x7e, 0x69, - 0x68, 0x76, 0x4a, 0x59, 0x07, 0x2b, 0x0d, 0x22, 0xed, 0x10, 0x1e, 0x75, 0xac, 0x21, 0x14, 0xc6, - 0x01, 0x2c, 0x64, 0x98, 0xa3, 0x19, 0xc8, 0x37, 0x70, 0x47, 0xc5, 0x26, 0xfe, 0x44, 0x37, 0xe1, - 0xca, 0x61, 0x9c, 0x32, 0x11, 0x88, 0xc2, 0xfa, 0x4b, 0x19, 0x8e, 0x25, 0x69, 0xb5, 0xa4, 0x7d, - 0x65, 0xe4, 0x5d, 0xcd, 0xec, 0x80, 0xe1, 0x04, 0x3e, 0x26, 0x7c, 0xeb, 0xc0, 0xf6, 0xc9, 0x8e, - 0x1d, 0x11, 0x9f, 0x78, 0x1b, 0xae, 0x1b, 0xdd, 0xf1, 0x19, 0x47, 0x9f, 0xc2, 0xb4, 0x12, 0xc5, - 0x47, 0x88, 0x45, 0xba, 0x26, 0x4e, 0xbf, 0x96, 0x41, 0x32, 0x1c, 0x2b, 0xde, 0x6c, 0x9d, 0x45, - 0x32, 0xbf, 0xce, 0xa2, 0x16, 0x75, 0xb0, 0x0c, 0xd3, 0xc1, 0x83, 0xad, 0x44, 0xaf, 0xea, 0x61, - 0xd4, 0x3a, 0x2b, 0x46, 0xef, 0xc0, 0xfc, 0x70, 0x1c, 0x59, 0x19, 0x56, 0x86, 0xd6, 0xfc, 0x53, - 0x83, 0xa9, 0x6e, 0x88, 0x05, 0xa5, 0x09, 0x53, 0x4a, 0xcf, 0xc4, 0x76, 0x19, 0xe3, 0x3e, 0x19, - 0x5a, 0x82, 0xc2, 0x46, 0x18, 0x46, 0xf4, 0x10, 0xa7, 0x18, 0xd2, 0x22, 0xb4, 0x02, 0x33, 0x5d, - 0xd4, 0x1a, 0xe6, 0x76, 0x8c, 0xac, 0xe7, 0x85, 0xd9, 0x80, 0x1c, 0x35, 0x60, 0x61, 0x6b, 0xc0, - 0x39, 0x49, 0x3e, 0x2a,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4e, 0x8a, 0xb9, 0x4f, 0xae, 0xa7, 0x2a, 0xb1, 0xfb, 0x43, - 0xa0, 0x9d, 0xfe, 0x29, 0x20, 0x8a, 0xb1, 0x3e, 0x26, 0xde, 0xe5, 0x6f, 0xfe, 0x13, 0x00, 0x00, - 0xff, 0xff, 0x33, 0xe0, 0x8a, 0x0c, 0x2d, 0x0c, 0x00, 0x00, + // 871 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xc6, 0x49, 0x9a, 0x3c, 0x17, 0x01, 0x83, 0x93, 0x6c, 0x0d, 0x72, 0xcc, 0x8a, 0x56, + 0x21, 0x10, 0x9b, 0x06, 0x21, 0x50, 0x54, 0x09, 0x39, 0xa4, 0x05, 0x8b, 0xa6, 0x8d, 0xb6, 0x81, + 0x03, 0x42, 0x42, 0xe3, 0xdd, 0xe9, 0x66, 0xf1, 0xee, 0xcc, 0x6a, 0x66, 0x1c, 0x1c, 0x4e, 0x88, + 0x13, 0x70, 0xe2, 0x23, 0xf4, 0x03, 0x70, 0xc8, 0xa1, 0x1f, 0xa2, 0xc7, 0xaa, 0x27, 0xc4, 0x21, + 0x42, 0xc9, 0x21, 0x1c, 0xf8, 0x02, 0x70, 0x42, 0x3b, 0x33, 0xfb, 0x27, 0xc4, 0x26, 0x42, 0x8a, + 0xd4, 0x8b, 0x3d, 0xef, 0xcd, 0x9b, 0xdf, 0xef, 0xbd, 0xf9, 0xbd, 0x7d, 0x1a, 0x68, 0x92, 0x11, + 0xf3, 0x18, 0x27, 0x1d, 0x9f, 0x44, 0x24, 0xc0, 0x32, 0x64, 0xb4, 0xb3, 0x7f, 0xb3, 0x23, 0x47, + 0xed, 0x84, 0x33, 0xc9, 0xd0, 0x82, 0xd9, 0x6f, 0x17, 0xfb, 0xed, 0xfd, 0x9b, 0x8d, 0x25, 0x8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x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -871,7 +615,6 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. - RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) DelegateAssetToOperator(ctx context.Context, in *MsgDelegation, opts ...grpc.CallOption) (*DelegationResponse, error) UndelegateAssetFromOperator(ctx context.Context, in *MsgUndelegation, opts ...grpc.CallOption) (*UndelegationResponse, error) } @@ -884,15 +627,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) { - out := new(RegisterOperatorResponse) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Msg/RegisterOperator", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) DelegateAssetToOperator(ctx context.Context, in *MsgDelegation, opts ...grpc.CallOption) (*DelegationResponse, error) { out := new(DelegationResponse) err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Msg/DelegateAssetToOperator", in, out, opts...) @@ -914,7 +648,6 @@ func (c *msgClient) UndelegateAssetFromOperator(ctx context.Context, in *MsgUnde // MsgServer is the server API for Msg service. type MsgServer interface { // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. - RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) DelegateAssetToOperator(context.Context, *MsgDelegation) (*DelegationResponse, error) UndelegateAssetFromOperator(context.Context, *MsgUndelegation) (*UndelegationResponse, error) } @@ -923,9 +656,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *RegisterOperatorReq) (*RegisterOperatorResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterOperator not implemented") -} func (*UnimplementedMsgServer) DelegateAssetToOperator(ctx context.Context, req *MsgDelegation) (*DelegationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DelegateAssetToOperator not implemented") } @@ -937,24 +667,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_RegisterOperator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterOperatorReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterOperator(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Msg/RegisterOperator", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterOperator(ctx, req.(*RegisterOperatorReq)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_DelegateAssetToOperator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgDelegation) if err := dec(in); err != nil { @@ -995,10 +707,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.delegation.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "RegisterOperator", - Handler: _Msg_RegisterOperator_Handler, - }, { MethodName: "DelegateAssetToOperator", Handler: _Msg_DelegateAssetToOperator_Handler, @@ -1111,7 +819,7 @@ func (m *DelegatedSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *ClientChainEarningAddrList) Marshal() (dAtA []byte, err error) { +func (m *DelegationApproveInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1121,34 +829,34 @@ func (m *ClientChainEarningAddrList) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ClientChainEarningAddrList) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegationApproveInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ClientChainEarningAddrList) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegationApproveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.EarningInfoList) > 0 { - for iNdEx := len(m.EarningInfoList) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.EarningInfoList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if len(m.Salt) > 0 { + i -= len(m.Salt) + copy(dAtA[i:], m.Salt) + i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ClientChainEarningAddrInfo) Marshal() (dAtA []byte, err error) { +func (m *DelegationIncOrDecInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1158,32 +866,53 @@ func (m *ClientChainEarningAddrInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ClientChainEarningAddrInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegationIncOrDecInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ClientChainEarningAddrInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegationIncOrDecInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ClientChainEarningAddr) > 0 { - i -= len(m.ClientChainEarningAddr) - copy(dAtA[i:], m.ClientChainEarningAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientChainEarningAddr))) - i-- - dAtA[i] = 0x12 + if len(m.PerOperatorAmounts) > 0 { + for k := range m.PerOperatorAmounts { + v := m.PerOperatorAmounts[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintTx(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintTx(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } } - if m.LzClientChainId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.LzClientChainId)) + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *OperatorInfo) Marshal() (dAtA []byte, err error) { +func (m *MsgDelegation) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1193,19 +922,19 @@ func (m *OperatorInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDelegation) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.ClientChainEarningsAddr != nil { + if m.ApprovedInfo != nil { { - size, err := m.ClientChainEarningsAddr.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ApprovedInfo.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1213,33 +942,24 @@ func (m *OperatorInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - } - if len(m.OperatorMetaInfo) > 0 { - i -= len(m.OperatorMetaInfo) - copy(dAtA[i:], m.OperatorMetaInfo) - i = encodeVarintTx(dAtA, i, uint64(len(m.OperatorMetaInfo))) - i-- - dAtA[i] = 0x1a - } - if len(m.ApproveAddr) > 0 { - i -= len(m.ApproveAddr) - copy(dAtA[i:], m.ApproveAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ApproveAddr))) - i-- dAtA[i] = 0x12 } - if len(m.EarningsAddr) > 0 { - i -= len(m.EarningsAddr) - copy(dAtA[i:], m.EarningsAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.EarningsAddr))) + if m.BaseInfo != nil { + { + size, err := m.BaseInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *RegisterOperatorReq) Marshal() (dAtA []byte, err error) { +func (m *UndelegationRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1249,212 +969,7 @@ func (m *RegisterOperatorReq) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RegisterOperatorReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RegisterOperatorReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Info != nil { - { - size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.FromAddress) > 0 { - i -= len(m.FromAddress) - copy(dAtA[i:], m.FromAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DelegationApproveInfo) 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 *DelegationApproveInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationApproveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Salt) > 0 { - i -= len(m.Salt) - copy(dAtA[i:], m.Salt) - i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) - i-- - dAtA[i] = 0x12 - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RegisterOperatorResponse) 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 *RegisterOperatorResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RegisterOperatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *DelegationIncOrDecInfo) 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 *DelegationIncOrDecInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationIncOrDecInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PerOperatorAmounts) > 0 { - for k := range m.PerOperatorAmounts { - v := m.PerOperatorAmounts[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTx(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTx(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x12 - } - } - if len(m.FromAddress) > 0 { - i -= len(m.FromAddress) - copy(dAtA[i:], m.FromAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgDelegation) 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 *MsgDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ApprovedInfo != nil { - { - size, err := m.ApprovedInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.BaseInfo != nil { - { - size, err := m.BaseInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UndelegationRecord) 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 *UndelegationRecord) MarshalTo(dAtA []byte) (int, error) { +func (m *UndelegationRecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } @@ -1703,167 +1218,85 @@ func (m *DelegatedSingleAssetInfo) Size() (n int) { return n } -func (m *ClientChainEarningAddrList) Size() (n int) { +func (m *DelegationApproveInfo) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.EarningInfoList) > 0 { - for _, e := range m.EarningInfoList { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Salt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } return n } -func (m *ClientChainEarningAddrInfo) Size() (n int) { +func (m *DelegationIncOrDecInfo) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.LzClientChainId != 0 { - n += 1 + sovTx(uint64(m.LzClientChainId)) - } - l = len(m.ClientChainEarningAddr) + l = len(m.FromAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if len(m.PerOperatorAmounts) > 0 { + for k, v := range m.PerOperatorAmounts { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovTx(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovTx(uint64(len(k))) + l + n += mapEntrySize + 1 + sovTx(uint64(mapEntrySize)) + } + } return n } -func (m *OperatorInfo) Size() (n int) { +func (m *MsgDelegation) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.EarningsAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ApproveAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.OperatorMetaInfo) - if l > 0 { + if m.BaseInfo != nil { + l = m.BaseInfo.Size() n += 1 + l + sovTx(uint64(l)) } - if m.ClientChainEarningsAddr != nil { - l = m.ClientChainEarningsAddr.Size() + if m.ApprovedInfo != nil { + l = m.ApprovedInfo.Size() n += 1 + l + sovTx(uint64(l)) } return n } -func (m *RegisterOperatorReq) Size() (n int) { +func (m *UndelegationRecord) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.FromAddress) + l = len(m.StakerId) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Info != nil { - l = m.Info.Size() + l = len(m.AssetId) + if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} - -func (m *DelegationApproveInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Signature) + l = len(m.OperatorAddr) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Salt) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *RegisterOperatorResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *DelegationIncOrDecInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FromAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.PerOperatorAmounts) > 0 { - for k, v := range m.PerOperatorAmounts { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovTx(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovTx(uint64(len(k))) + l - n += mapEntrySize + 1 + sovTx(uint64(mapEntrySize)) - } - } - return n -} - -func (m *MsgDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BaseInfo != nil { - l = m.BaseInfo.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.ApprovedInfo != nil { - l = m.ApprovedInfo.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *UndelegationRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.AssetId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.OperatorAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.TxHash) + l = len(m.TxHash) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2267,192 +1700,7 @@ func (m *DelegatedSingleAssetInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *ClientChainEarningAddrList) 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 ErrIntOverflowTx - } - 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: clientChainEarningAddrList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: clientChainEarningAddrList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EarningInfoList", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EarningInfoList = append(m.EarningInfoList, &ClientChainEarningAddrInfo{}) - if err := m.EarningInfoList[len(m.EarningInfoList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ClientChainEarningAddrInfo) 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 ErrIntOverflowTx - } - 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: clientChainEarningAddrInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: clientChainEarningAddrInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LzClientChainId", wireType) - } - m.LzClientChainId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LzClientChainId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientChainEarningAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientChainEarningAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *OperatorInfo) Unmarshal(dAtA []byte) error { +func (m *DelegationApproveInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2475,15 +1723,15 @@ func (m *OperatorInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OperatorInfo: wiretype end group for non-group") + return fmt.Errorf("proto: DelegationApproveInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OperatorInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DelegationApproveInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EarningsAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2511,11 +1759,11 @@ func (m *OperatorInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.EarningsAddr = string(dAtA[iNdEx:postIndex]) + m.Signature = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApproveAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2543,358 +1791,8 @@ func (m *OperatorInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ApproveAddr = string(dAtA[iNdEx:postIndex]) + m.Salt = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorMetaInfo", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OperatorMetaInfo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientChainEarningsAddr", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ClientChainEarningsAddr == nil { - m.ClientChainEarningsAddr = &ClientChainEarningAddrList{} - } - if err := m.ClientChainEarningsAddr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RegisterOperatorReq) 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 ErrIntOverflowTx - } - 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: RegisterOperatorReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegisterOperatorReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FromAddress = 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Info == nil { - m.Info = &OperatorInfo{} - } - if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DelegationApproveInfo) 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 ErrIntOverflowTx - } - 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: DelegationApproveInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationApproveInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Salt = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RegisterOperatorResponse) 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 ErrIntOverflowTx - } - 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: RegisterOperatorResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegisterOperatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/deposit/types/query.pb.gw.go b/x/deposit/types/query.pb.gw.go index 2c727832e..4e143091e 100644 --- a/x/deposit/types/query.pb.gw.go +++ b/x/deposit/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -52,12 +54,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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_Params_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 { @@ -65,6 +69,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_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) diff --git a/x/operator/client/cli/query.go b/x/operator/client/cli/query.go new file mode 100644 index 000000000..8fbcde85a --- /dev/null +++ b/x/operator/client/cli/query.go @@ -0,0 +1,56 @@ +package cli + +import ( + "context" + + operatortypes "github.com/exocore/x/operator/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the parent command for all incentives CLI query commands. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: operatortypes.ModuleName, + Short: "Querying commands for the delegation module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + QueryOperatorInfo(), + ) + return cmd +} + +// QueryOperatorInfo queries operator info +func QueryOperatorInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "QueryOperatorInfo operatorAddr", + Short: "Get operator info", + Long: "Get operator info", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := operatortypes.NewQueryClient(clientCtx) + req := &operatortypes.QueryOperatorInfoReq{ + OperatorAddr: args[0], + } + res, err := queryClient.QueryOperatorInfo(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/operator/client/cli/tx.go b/x/operator/client/cli/tx.go new file mode 100644 index 000000000..b1901c729 --- /dev/null +++ b/x/operator/client/cli/tx.go @@ -0,0 +1,81 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/client/flags" + operatortypes "github.com/exocore/x/operator/types" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" +) + +// NewTxCmd returns a root CLI command handler for deposit commands +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: operatortypes.ModuleName, + Short: "delegation subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + RegisterOperator(), + ) + return txCmd +} + +// RegisterOperator register to be a operator +func RegisterOperator() *cobra.Command { + cmd := &cobra.Command{ + Use: "RegisterOperator EarningsAddr ApproveAddr OperatorMetaInfo clientChainLzID:ClientChainEarningsAddr", + Short: "register to be a operator", + Args: cobra.MinimumNArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + sender := cliCtx.GetFromAddress() + msg := &operatortypes.RegisterOperatorReq{ + FromAddress: sender.String(), + Info: &operatortypes.OperatorInfo{ + EarningsAddr: args[0], + ApproveAddr: args[1], + OperatorMetaInfo: args[2], + }, + } + lastArgs := args[3:] + clientChainEarningAddress := &operatortypes.ClientChainEarningAddrList{} + clientChainEarningAddress.EarningInfoList = make([]*operatortypes.ClientChainEarningAddrInfo, 0) + for _, arg := range lastArgs { + strList := strings.Split(arg, ":") + if len(strList) != 2 { + return errorsmod.Wrap(operatortypes.ErrCliCmdInputArg, fmt.Sprintf("the error input arg is:%s", arg)) + } + clientChainLzId, err := strconv.ParseUint(strList[0], 10, 64) + if err != nil { + return err + } + clientChainEarningAddress.EarningInfoList = append(clientChainEarningAddress.EarningInfoList, + &operatortypes.ClientChainEarningAddrInfo{ + LzClientChainId: clientChainLzId, ClientChainEarningAddr: strList[1], + }) + } + msg.Info.ClientChainEarningsAddr = clientChainEarningAddress + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go new file mode 100644 index 000000000..f5d5930a2 --- /dev/null +++ b/x/operator/keeper/abci.go @@ -0,0 +1,11 @@ +package keeper + +import ( + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// EndBlock : to be used +func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go new file mode 100644 index 000000000..d4d38cace --- /dev/null +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -0,0 +1,143 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "fmt" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + operatortypes "github.com/exocore/x/operator/types" + restakingtype "github.com/exocore/x/restaking_assets_manage/types" +) + +func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.Int) error { + if opAmount.IsNil() || opAmount.IsZero() { + return nil + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + var key []byte + if operatorAddr == "" { + key = []byte(avsAddr) + } else { + key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + } + + totalValue := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &totalValue) + } + err := restakingtype.UpdateAssetValue(&totalValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&totalValue) + store.Set(key, bz) + return nil +} + +func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.Int, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + var ret restakingtype.ValueField + var key []byte + if operatorAddr == "" { + key = []byte(avsAddr) + } else { + key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + } + isExit := store.Has(key) + if !isExit { + return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorTotalValue: key is %s", key)) + } else { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + } + return ret.Amount, nil +} + +func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) + + if changeState.Amount.IsNil() && changeState.Value.IsNil() { + return nil + } + //check operator address validation + _, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return restakingtype.OperatorAddrIsNotAccAddr + } + stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) + assetOptedInState := operatortypes.AssetOptedInState{ + Amount: sdkmath.NewInt(0), + Value: sdkmath.NewInt(0), + } + + if store.Has(stateKey) { + value := store.Get(stateKey) + k.cdc.MustUnmarshal(value, &assetOptedInState) + } + + err = restakingtype.UpdateAssetValue(&assetOptedInState.Amount, &changeState.Amount) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAVSAssetsState assetOptedInState.Amount error") + } + + err = restakingtype.UpdateAssetValue(&assetOptedInState.Value, &changeState.Value) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAVSAssetsState assetOptedInState.Value error") + } + + //save single operator delegation state + bz := k.cdc.MustMarshal(&assetOptedInState) + store.Set(stateKey, bz) + return nil +} + +func (k Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) + stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) + isExit := store.Has(stateKey) + assetOptedInState := operatortypes.AssetOptedInState{} + if isExit { + value := store.Get(stateKey) + k.cdc.MustUnmarshal(value, &assetOptedInState) + } else { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorAVSAssetsState: key is %s", stateKey)) + } + return &assetOptedInState, nil +} + +func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.Int) error { + if opAmount.IsNil() || opAmount.IsZero() { + return nil + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) + key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) + + optedInValue := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &optedInValue) + } + err := restakingtype.UpdateAssetValue(&optedInValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&optedInValue) + store.Set(key, bz) + return nil +} + +func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.Int, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) + var ret restakingtype.ValueField + key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) + isExit := store.Has(key) + if !isExit { + return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorStakerShareValue: key is %s", key)) + } else { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + } + return ret.Amount, nil +} diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go new file mode 100644 index 000000000..bdfee7c9f --- /dev/null +++ b/x/operator/keeper/grpc_query.go @@ -0,0 +1,15 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + operatortypes "github.com/exocore/x/operator/types" +) + +var _ operatortypes.QueryServer = Keeper{} + +func (k Keeper) QueryOperatorInfo(ctx context.Context, req *operatortypes.QueryOperatorInfoReq) (*operatortypes.OperatorInfo, error) { + c := sdk.UnwrapSDKContext(ctx) + return k.GetOperatorInfo(c, req.OperatorAddr) +} diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go new file mode 100644 index 000000000..5b785e5be --- /dev/null +++ b/x/operator/keeper/keeper.go @@ -0,0 +1,64 @@ +package keeper + +import ( + "context" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + operatortypes "github.com/exocore/x/operator/types" + "github.com/exocore/x/restaking_assets_manage/keeper" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + + //other keepers + restakingStateKeeper keeper.Keeper + delegationKeeper operatortypes.ExpectDelegationInterface + oracleKeeper operatortypes.ExpectOracleInterface +} + +func NewKeeper( + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + restakingStateKeeper keeper.Keeper, + oracleKeeper operatortypes.ExpectOracleInterface, +) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + restakingStateKeeper: restakingStateKeeper, + oracleKeeper: oracleKeeper, + } +} + +func (k Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes.ExpectDelegationInterface) { + k.delegationKeeper = delegationKeeper +} + +func (k Keeper) GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { + return startHeight + 10 +} + +// IOperator interface will be implemented by deposit keeper +type IOperator interface { + // RegisterOperator handle the registerOperator txs from msg service + RegisterOperator(ctx context.Context, req *operatortypes.RegisterOperatorReq) (*operatortypes.RegisterOperatorResponse, error) + + IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool + + GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 + + OptIn(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error + + OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error + + IncreasedOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string) error + + DecreaseOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string) error + + SlashOperator() + + GetOperatorValueShare() +} diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go new file mode 100644 index 000000000..72f21aed3 --- /dev/null +++ b/x/operator/keeper/msg_server.go @@ -0,0 +1,19 @@ +package keeper + +import ( + context "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/exocore/x/operator/types" +) + +var _ types.MsgServer = &Keeper{} + +func (k Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperatorReq) (*types.RegisterOperatorResponse, error) { + c := sdk.UnwrapSDKContext(ctx) + err := k.SetOperatorInfo(c, req.FromAddress, req.Info) + if err != nil { + return nil, err + } + return nil, nil +} diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go new file mode 100644 index 000000000..10570afcf --- /dev/null +++ b/x/operator/keeper/operator.go @@ -0,0 +1,115 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + "fmt" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + operatortypes "github.com/exocore/x/operator/types" + restakingtype "github.com/exocore/x/restaking_assets_manage/types" +) + +// SetOperatorInfo This function is used to register to be an operator in exoCore, the provided info will be stored on the chain. +// Once an address has become an operator,the operator can't return to a normal address.But the operator can update the info through this function +// As for the operator opt-in function,it needs to be implemented in operator opt-in or AVS module +func (k Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) { + opAccAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return errorsmod.Wrap(err, "SetOperatorInfo: error occurred when parse acc address from Bech32") + } + // todo: to check the validation of input info + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) + // todo: think about the difference between init and update in future + + //key := common.HexToAddress(incentive.Contract) + bz := k.cdc.MustMarshal(info) + + store.Set(opAccAddr, bz) + return nil +} + +func (k Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *operatortypes.OperatorInfo, err error) { + opAccAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return nil, errorsmod.Wrap(err, "GetOperatorInfo: error occurred when parse acc address from Bech32") + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) + //key := common.HexToAddress(incentive.Contract) + ifExist := store.Has(opAccAddr) + if !ifExist { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %s", opAccAddr)) + } + + value := store.Get(opAccAddr) + + ret := operatortypes.OperatorInfo{} + k.cdc.MustUnmarshal(value, &ret) + return &ret, nil +} + +func (k Keeper) IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) + return store.Has(addr) +} + +func (k Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, info *operatortypes.OptedInfo) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + + //check operator address validation + _, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return restakingtype.OperatorAddrIsNotAccAddr + } + infoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr) + + bz := k.cdc.MustMarshal(info) + store.Set(infoKey, bz) + return nil +} + +func (k Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (info *operatortypes.OptedInfo, err error) { + opAccAddr, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return nil, errorsmod.Wrap(err, "GetOptedInfo: error occurred when parse acc address from Bech32") + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + infoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr) + ifExist := store.Has(infoKey) + if !ifExist { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %s", opAccAddr)) + } + + value := store.Get(infoKey) + + ret := operatortypes.OptedInfo{} + k.cdc.MustUnmarshal(value, &ret) + return &ret, nil +} + +func (k Keeper) IsOptedIn(ctx sdk.Context, operatorAddr, avsAddr string) bool { + optedInfo, err := k.GetOptedInfo(ctx, operatorAddr, avsAddr) + if err != nil { + return false + } + if optedInfo.OptedOutHeight != operatortypes.DefaultOptedOutHeight { + return true + } + return false +} + +func (k Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) ([]string, error) { + //get all opted-in info + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) + iterator := sdk.KVStorePrefixIterator(store, []byte(operatorAddr)) + defer iterator.Close() + + avsList := make([]string, 0) + for ; iterator.Valid(); iterator.Next() { + keys, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + avsList = append(avsList, keys[1]) + } + return avsList, nil +} diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go new file mode 100644 index 000000000..e0fd6676a --- /dev/null +++ b/x/operator/keeper/operator_info_test.go @@ -0,0 +1,22 @@ +package keeper_test + +import operatortype "github.com/exocore/x/operator/types" + +func (suite *KeeperTestSuite) TestOperatorInfo() { + info := &operatortype.OperatorInfo{ + EarningsAddr: suite.accAddress.String(), + ApproveAddr: "", + OperatorMetaInfo: "test operator", + ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ + EarningInfoList: []*operatortype.ClientChainEarningAddrInfo{ + {101, "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"}, + }, + }, + } + err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) + suite.NoError(err) + + getOperatorInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, suite.accAddress.String()) + suite.NoError(err) + suite.Equal(*info, *getOperatorInfo) +} diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go new file mode 100644 index 000000000..5315b5224 --- /dev/null +++ b/x/operator/keeper/operator_slash_state.go @@ -0,0 +1,106 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "fmt" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common/hexutil" + operatortypes "github.com/exocore/x/operator/types" + restakingtype "github.com/exocore/x/restaking_assets_manage/types" +) + +func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashProofTxId string, slashInfo operatortypes.OperatorSlashInfo) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) + + //check operator address validation + _, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return restakingtype.OperatorAddrIsNotAccAddr + } + slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashProofTxId) + if store.Has(slashInfoKey) { + return errorsmod.Wrap(operatortypes.ErrSlashInfoExist, fmt.Sprintf("slashInfoKey:%s", slashInfoKey)) + } + // check the validation of slash info + if slashInfo.SlashContract == "" { + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err slashContract:%s", slashInfo.SlashContract)) + } + + curHeight := ctx.BlockHeight() + if slashInfo.SlashHeight > uint64(curHeight) { + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,curHeight:%v", slashInfo.SlashHeight, curHeight)) + } + if slashInfo.SlashHeight > slashInfo.ExecuteHeight { + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,ExecuteHeight:%v", slashInfo.SlashHeight, slashInfo.ExecuteHeight)) + } + + if slashInfo.SlashProportion.IsNil() || slashInfo.SlashProportion.IsNegative() || slashInfo.SlashProportion.GT(sdkmath.LegacyNewDec(1)) { + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashProportion:%v", slashInfo.SlashProportion)) + } + + //save single operator delegation state + bz := k.cdc.MustMarshal(&slashInfo) + store.Set(slashInfoKey, bz) + return nil +} + +func (k Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashProofTxId string) (changeState *operatortypes.OperatorSlashInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) + slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashProofTxId) + isExit := store.Has(slashInfoKey) + operatorSlashInfo := operatortypes.OperatorSlashInfo{} + if isExit { + value := store.Get(slashInfoKey) + k.cdc.MustUnmarshal(value, &operatorSlashInfo) + } else { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorSlashInfo: key is %s", slashInfoKey)) + } + return &operatorSlashInfo, nil +} + +func (k Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerId string, completeHeight uint64, opAmount sdkmath.Int) error { + if opAmount.IsNil() || opAmount.IsZero() { + return nil + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) + var key []byte + if stakerId == "" { + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) + } else { + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerId) + } + + slashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &slashAmount) + } + err := restakingtype.UpdateAssetValue(&slashAmount.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&slashAmount) + store.Set(key, bz) + return nil +} + +func (k Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerId string, completeHeight uint64) (sdkmath.Int, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) + var key []byte + if stakerId == "" { + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) + } else { + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerId) + } + var ret restakingtype.ValueField + isExit := store.Has(key) + if !isExit { + return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetSlashAssetsState: key is %s", key)) + } else { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + } + return ret.Amount, nil +} diff --git a/x/operator/keeper/sate_update_for_external_op.go b/x/operator/keeper/sate_update_for_external_op.go new file mode 100644 index 000000000..d87cba3e5 --- /dev/null +++ b/x/operator/keeper/sate_update_for_external_op.go @@ -0,0 +1,39 @@ +package keeper + +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) IncreasedOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { + //get the AVS opted-in by the operator + avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) + if err != nil { + return err + } + + //get price and priceDecimal from oracle + price, priceDecimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) + if err != nil { + return err + } + + opUsdValue := opAmount.Mul() + +} + +func (k Keeper) DecreaseOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { + +} + +// OptIn call this function to opt in AVS +func (k Keeper) OptIn(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error { + + return nil +} + +// OptOut call this function to opt out of AVS +func (k Keeper) OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error { + + return nil +} diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go new file mode 100644 index 000000000..24ccf18b7 --- /dev/null +++ b/x/operator/keeper/setup_test.go @@ -0,0 +1,40 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/ethereum/go-ethereum/common" + "github.com/exocore/app" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + app *app.ExocoreApp + address common.Address + signer keyring.Signer + accAddress sdk.AccAddress +} + +var s *KeeperTestSuite + +func TestKeeperTestSuite(t *testing.T) { + s = new(KeeperTestSuite) + suite.Run(t, s) + + // Run Ginkgo integration tests + RegisterFailHandler(Fail) + RunSpecs(t, "Keeper Suite") +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.DoSetupTest(suite.T()) +} diff --git a/x/operator/keeper/utils_test.go b/x/operator/keeper/utils_test.go new file mode 100644 index 000000000..2692f9a3b --- /dev/null +++ b/x/operator/keeper/utils_test.go @@ -0,0 +1,44 @@ +package keeper_test + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/evmos/evmos/v14/crypto/ethsecp256k1" + "github.com/evmos/evmos/v14/testutil" + utiltx "github.com/evmos/evmos/v14/testutil/tx" + feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" + "github.com/exocore/app" + "github.com/exocore/utils" + "github.com/stretchr/testify/require" + "golang.org/x/exp/rand" +) + +// Test helpers +func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { + // account key + priv, err := ethsecp256k1.GenerateKey() + require.NoError(t, err) + suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) + suite.signer = utiltx.NewSigner(priv) + + // accAddress + pubBz := make([]byte, ed25519.PubKeySize) + pub := &ed25519.PubKey{Key: pubBz} + rand.Read(pub.Key) + suite.accAddress = sdk.AccAddress(pub.Address()) + + // consensus key + privCons, err := ethsecp256k1.GenerateKey() + require.NoError(t, err) + consAddress := sdk.ConsAddress(privCons.PubKey().Address()) + + chainID := utils.TestnetChainID + "-1" + suite.app = app.Setup(false, feemarkettypes.DefaultGenesisState(), chainID, false) + header := testutil.NewHeader( + 1, time.Now().UTC(), chainID, consAddress, nil, nil, + ) + suite.ctx = suite.app.BaseApp.NewContext(false, header) +} diff --git a/x/operator/module.go b/x/operator/module.go new file mode 100644 index 000000000..08c0d63de --- /dev/null +++ b/x/operator/module.go @@ -0,0 +1,96 @@ +package operator + +import ( + "context" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/exocore/x/operator/client/cli" + "github.com/exocore/x/operator/keeper" + operatortypes "github.com/exocore/x/operator/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" +) + +const consensusVersion = 0 + +// type check to ensure the interface is properly implemented +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +type AppModuleBasic struct{} + +func (b AppModuleBasic) Name() string { + return operatortypes.ModuleName +} + +func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { + operatortypes.RegisterLegacyAminoCodec(amino) +} + +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + operatortypes.RegisterInterfaces(registry) +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := operatortypes.RegisterQueryHandlerClient(context.Background(), serveMux, operatortypes.NewQueryClient(c)); err != nil { + panic(err) + } +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: keeper, + } +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + operatortypes.RegisterMsgServer(cfg.MsgServer(), &am.keeper) + operatortypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +func (am AppModule) GenerateGenesisState(input *module.SimulationState) { +} + +func (am AppModule) RegisterStoreDecoder(registry sdk.StoreDecoderRegistry) { +} + +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} + +// EndBlock executes all ABCI EndBlock logic respective to the claim module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlock(ctx, req) + return []abci.ValidatorUpdate{} +} diff --git a/x/operator/types/codec.go b/x/operator/types/codec.go new file mode 100644 index 000000000..d85fe3101 --- /dev/null +++ b/x/operator/types/codec.go @@ -0,0 +1,49 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global erc20 module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding. + // + // The actual codec used for serialization should be provided to modules/erc20 and + // defined at the application level. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino JSON compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +const ( + // Amino names + registerOperator = "exocore/RegisterOperatorReq" +) + +// NOTE: This is required for the GetSignBytes function +func init() { + RegisterLegacyAminoCodec(amino) + amino.Seal() +} + +// RegisterInterfaces register implementations +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &RegisterOperatorReq{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec registers the necessary x/revenue interfaces and +// concrete types on the provided LegacyAmino codec. These types are used for +// Amino JSON serialization and EIP-712 compatibility. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&RegisterOperatorReq{}, registerOperator, nil) +} diff --git a/x/operator/types/errors.go b/x/operator/types/errors.go new file mode 100644 index 000000000..522303fba --- /dev/null +++ b/x/operator/types/errors.go @@ -0,0 +1,13 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +var ( + ErrNoKeyInTheStore = errorsmod.Register(ModuleName, 0, "there is not the key for in the store") + + ErrCliCmdInputArg = errorsmod.Register(ModuleName, 1, "there is an error in the input client command args") + + ErrSlashInfo = errorsmod.Register(ModuleName, 2, "there is an error in the field of slash info") + + ErrSlashInfoExist = errorsmod.Register(ModuleName, 3, "the slash info exists") +) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go new file mode 100644 index 000000000..27409903f --- /dev/null +++ b/x/operator/types/expected_keepers.go @@ -0,0 +1,14 @@ +package types + +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ExpectDelegationInterface interface { + GetDelegationStateByOperator(ctx sdk.Context, operatorAddr string) (map[string]sdkmath.Int, error) +} + +type ExpectOracleInterface interface { + GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdkmath.Int, uint8, error) +} diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go new file mode 100644 index 000000000..9ba2cb627 --- /dev/null +++ b/x/operator/types/keys.go @@ -0,0 +1,76 @@ +package types + +import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/ethereum/go-ethereum/common" + "math" +) + +// constants +const ( + // ModuleName module name + ModuleName = "operator" + + // StoreKey to be used when creating the KVStore + StoreKey = ModuleName + + // RouterKey to be used for message routing + RouterKey = ModuleName + + DefaultOptedOutHeight = uint64(math.MaxUint64) +) + +// ModuleAddress is the native module address for EVM +var ModuleAddress common.Address + +func init() { + ModuleAddress = common.BytesToAddress(authtypes.NewModuleAddress(ModuleName).Bytes()) +} + +const ( + prefixOperatorInfo = iota + 1 + + prefixOperatorOptedAVSInfo + + prefixAVSOperatorAssetsTotalValue + + prefixOperatorAVSSingleAssetState + + prefixOperatorAVSStakerShareState + + prefixOperatorSlashInfo + + prefixSlashAssetsState +) + +var ( + // KeyPrefixOperatorInfo key-value: operatorAddr->operatorInfo + KeyPrefixOperatorInfo = []byte{prefixOperatorInfo} + + // KeyPrefixOperatorOptedAVSInfo key-value: + // operatorAddr + '/' + AVSAddr -> OptedInfo + KeyPrefixOperatorOptedAVSInfo = []byte{prefixOperatorOptedAVSInfo} + + // KeyPrefixAVSOperatorAssetsTotalValue key-value: + // AVSAddr -> AVSTotalValue + // AVSAddr + '/' + operatorAddr -> AVSOperatorTotalValue + KeyPrefixAVSOperatorAssetsTotalValue = []byte{prefixAVSOperatorAssetsTotalValue} + + // KeyPrefixOperatorAVSSingleAssetState key-value: + // assetId + '/' + AVSAddr + '/' + operatorAddr -> AssetOptedInState + KeyPrefixOperatorAVSSingleAssetState = []byte{prefixOperatorAVSSingleAssetState} + + // KeyPrefixAVSOperatorStakerShareState key-value: + // AVSAddr + '/' + '' + '/' + operatorAddr -> ownAssetsOptedInValue + // AVSAddr + '/' + stakerId + '/' + operatorAddr -> assetsOptedInValue + KeyPrefixAVSOperatorStakerShareState = []byte{prefixOperatorAVSStakerShareState} + + // KeyPrefixOperatorSlashInfo key-value: + // operator + '/' + AVSAddr + '/' + slashProofTxId -> OperatorSlashInfo + KeyPrefixOperatorSlashInfo = []byte{prefixOperatorSlashInfo} + + // KeyPrefixSlashAssetsState key-value: + // completeSlashHeight + '/' + assetId -> SlashAmount + // completeSlashHeight + '/' + assetId + '/' + stakerId -> SlashAmount + KeyPrefixSlashAssetsState = []byte{prefixSlashAssetsState} +) diff --git a/x/operator/types/msg.go b/x/operator/types/msg.go new file mode 100644 index 000000000..1cf00daad --- /dev/null +++ b/x/operator/types/msg.go @@ -0,0 +1,29 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = &RegisterOperatorReq{} +) + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *RegisterOperatorReq) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.FromAddress) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check of the provided data +func (m *RegisterOperatorReq) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.FromAddress); err != nil { + return errorsmod.Wrap(err, "invalid from address") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (m *RegisterOperatorReq) GetSignBytes() []byte { + return nil +} diff --git a/x/operator/types/query.pb.go b/x/operator/types/query.pb.go new file mode 100644 index 000000000..8cc2c7e66 --- /dev/null +++ b/x/operator/types/query.pb.go @@ -0,0 +1,412 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/operator/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "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 + +type QueryOperatorInfoReq struct { + OperatorAddr string `protobuf:"bytes,1,opt,name=OperatorAddr,proto3" json:"OperatorAddr,omitempty"` +} + +func (m *QueryOperatorInfoReq) Reset() { *m = QueryOperatorInfoReq{} } +func (m *QueryOperatorInfoReq) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorInfoReq) ProtoMessage() {} +func (*QueryOperatorInfoReq) Descriptor() ([]byte, []int) { + return fileDescriptor_f91e795a3cecbdbf, []int{0} +} +func (m *QueryOperatorInfoReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOperatorInfoReq.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 *QueryOperatorInfoReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorInfoReq.Merge(m, src) +} +func (m *QueryOperatorInfoReq) XXX_Size() int { + return m.Size() +} +func (m *QueryOperatorInfoReq) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorInfoReq.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOperatorInfoReq proto.InternalMessageInfo + +func (m *QueryOperatorInfoReq) GetOperatorAddr() string { + if m != nil { + return m.OperatorAddr + } + return "" +} + +func init() { + proto.RegisterType((*QueryOperatorInfoReq)(nil), "exocore.operator.v1.QueryOperatorInfoReq") +} + +func init() { proto.RegisterFile("exocore/operator/v1/query.proto", fileDescriptor_f91e795a3cecbdbf) } + +var fileDescriptor_f91e795a3cecbdbf = []byte{ + // 303 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x48, 0x2d, 0x4a, 0x2c, 0xc9, 0x2f, 0xd2, 0x2f, 0x33, 0xd4, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x2a, 0xd0, + 0x83, 0x29, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, + 0x10, 0xa5, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, + 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0xe9, 0xe4, 0xfc, 0xe2, + 0xdc, 0xfc, 0x62, 0x88, 0xe1, 0x68, 0xb6, 0x48, 0x49, 0x42, 0x24, 0xe3, 0x21, 0x66, 0x42, 0x38, + 0x30, 0x53, 0xb1, 0xb9, 0xb0, 0xa4, 0x02, 0x22, 0xab, 0x14, 0xc2, 0x25, 0x12, 0x08, 0x32, 0xc7, + 0x1f, 0x2a, 0xe9, 0x99, 0x97, 0x96, 0x1f, 0x94, 0x5a, 0x28, 0x64, 0xc3, 0xc5, 0x03, 0x13, 0x72, + 0x4c, 0x49, 0x29, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x92, 0xb8, 0xb4, 0x45, 0x57, 0x04, + 0x6a, 0x3a, 0x48, 0x38, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x08, 0x45, 0xb5, + 0xd1, 0x6c, 0x46, 0x2e, 0x56, 0xb0, 0xb1, 0x42, 0x13, 0x19, 0xb9, 0x04, 0x31, 0x2c, 0x10, 0xd2, + 0xd4, 0xc3, 0x12, 0x2a, 0x7a, 0xd8, 0x1c, 0x22, 0xa5, 0x88, 0x55, 0x29, 0xb2, 0x2a, 0x25, 0xbd, + 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0x69, 0x08, 0xa9, 0xe9, 0xc3, 0xbc, 0x9a, 0x92, 0x9a, 0x93, 0x9a, + 0x0e, 0x0e, 0x3d, 0x90, 0x67, 0xdd, 0x53, 0x4b, 0x90, 0xd5, 0x3b, 0xd9, 0x9e, 0x78, 0x24, 0xc7, + 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, + 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x72, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, + 0x7e, 0x2e, 0xdc, 0xac, 0x0a, 0x44, 0xc0, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x43, + 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x25, 0x9c, 0x4f, 0x91, 0xfb, 0x01, 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 { + QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) { + out := new(OperatorInfo) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/QueryOperatorInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + QueryOperatorInfo(context.Context, *QueryOperatorInfoReq) (*OperatorInfo, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) QueryOperatorInfo(ctx context.Context, req *QueryOperatorInfoReq) (*OperatorInfo, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorInfo not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_QueryOperatorInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOperatorInfoReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryOperatorInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Query/QueryOperatorInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryOperatorInfo(ctx, req.(*QueryOperatorInfoReq)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.operator.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryOperatorInfo", + Handler: _Query_QueryOperatorInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/operator/v1/query.proto", +} + +func (m *QueryOperatorInfoReq) 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 *QueryOperatorInfoReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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] = 0xa + } + 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 *QueryOperatorInfoReq) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + 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 *QueryOperatorInfoReq) 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: QueryOperatorInfoReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOperatorInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 + 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/operator/types/query.pb.gw.go b/x/operator/types/query.pb.gw.go new file mode 100644 index 000000000..848249d38 --- /dev/null +++ b/x/operator/types/query.pb.gw.go @@ -0,0 +1,171 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: exocore/operator/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_QueryOperatorInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOperatorInfoReq + 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_QueryOperatorInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryOperatorInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOperatorInfoReq + 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_QueryOperatorInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryOperatorInfo(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_QueryOperatorInfo_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_QueryOperatorInfo_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_QueryOperatorInfo_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_QueryOperatorInfo_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_QueryOperatorInfo_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_QueryOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_QueryOperatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetOperatorInfo"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_QueryOperatorInfo_0 = runtime.ForwardResponseMessage +) diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go new file mode 100644 index 000000000..4b1ef44f4 --- /dev/null +++ b/x/operator/types/tx.pb.go @@ -0,0 +1,2062 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/operator/v1/tx.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/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + 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 + +type ClientChainEarningAddrList struct { + EarningInfoList []*ClientChainEarningAddrInfo `protobuf:"bytes,1,rep,name=EarningInfoList,proto3" json:"EarningInfoList,omitempty"` +} + +func (m *ClientChainEarningAddrList) Reset() { *m = ClientChainEarningAddrList{} } +func (m *ClientChainEarningAddrList) String() string { return proto.CompactTextString(m) } +func (*ClientChainEarningAddrList) ProtoMessage() {} +func (*ClientChainEarningAddrList) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{0} +} +func (m *ClientChainEarningAddrList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClientChainEarningAddrList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClientChainEarningAddrList.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 *ClientChainEarningAddrList) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClientChainEarningAddrList.Merge(m, src) +} +func (m *ClientChainEarningAddrList) XXX_Size() int { + return m.Size() +} +func (m *ClientChainEarningAddrList) XXX_DiscardUnknown() { + xxx_messageInfo_ClientChainEarningAddrList.DiscardUnknown(m) +} + +var xxx_messageInfo_ClientChainEarningAddrList proto.InternalMessageInfo + +func (m *ClientChainEarningAddrList) GetEarningInfoList() []*ClientChainEarningAddrInfo { + if m != nil { + return m.EarningInfoList + } + return nil +} + +type ClientChainEarningAddrInfo struct { + LzClientChainId uint64 `protobuf:"varint,1,opt,name=lzClientChainId,proto3" json:"lzClientChainId,omitempty"` + ClientChainEarningAddr string `protobuf:"bytes,2,opt,name=clientChainEarningAddr,proto3" json:"clientChainEarningAddr,omitempty"` +} + +func (m *ClientChainEarningAddrInfo) Reset() { *m = ClientChainEarningAddrInfo{} } +func (m *ClientChainEarningAddrInfo) String() string { return proto.CompactTextString(m) } +func (*ClientChainEarningAddrInfo) ProtoMessage() {} +func (*ClientChainEarningAddrInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{1} +} +func (m *ClientChainEarningAddrInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClientChainEarningAddrInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClientChainEarningAddrInfo.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 *ClientChainEarningAddrInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClientChainEarningAddrInfo.Merge(m, src) +} +func (m *ClientChainEarningAddrInfo) XXX_Size() int { + return m.Size() +} +func (m *ClientChainEarningAddrInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ClientChainEarningAddrInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ClientChainEarningAddrInfo proto.InternalMessageInfo + +func (m *ClientChainEarningAddrInfo) GetLzClientChainId() uint64 { + if m != nil { + return m.LzClientChainId + } + return 0 +} + +func (m *ClientChainEarningAddrInfo) GetClientChainEarningAddr() string { + if m != nil { + return m.ClientChainEarningAddr + } + return "" +} + +type OperatorInfo struct { + EarningsAddr string `protobuf:"bytes,1,opt,name=EarningsAddr,proto3" json:"EarningsAddr,omitempty"` + ApproveAddr string `protobuf:"bytes,2,opt,name=ApproveAddr,proto3" json:"ApproveAddr,omitempty"` + OperatorMetaInfo string `protobuf:"bytes,3,opt,name=OperatorMetaInfo,proto3" json:"OperatorMetaInfo,omitempty"` + ClientChainEarningsAddr *ClientChainEarningAddrList `protobuf:"bytes,4,opt,name=ClientChainEarningsAddr,proto3" json:"ClientChainEarningsAddr,omitempty"` +} + +func (m *OperatorInfo) Reset() { *m = OperatorInfo{} } +func (m *OperatorInfo) String() string { return proto.CompactTextString(m) } +func (*OperatorInfo) ProtoMessage() {} +func (*OperatorInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{2} +} +func (m *OperatorInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorInfo.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 *OperatorInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorInfo.Merge(m, src) +} +func (m *OperatorInfo) XXX_Size() int { + return m.Size() +} +func (m *OperatorInfo) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorInfo proto.InternalMessageInfo + +func (m *OperatorInfo) GetEarningsAddr() string { + if m != nil { + return m.EarningsAddr + } + return "" +} + +func (m *OperatorInfo) GetApproveAddr() string { + if m != nil { + return m.ApproveAddr + } + return "" +} + +func (m *OperatorInfo) GetOperatorMetaInfo() string { + if m != nil { + return m.OperatorMetaInfo + } + return "" +} + +func (m *OperatorInfo) GetClientChainEarningsAddr() *ClientChainEarningAddrList { + if m != nil { + return m.ClientChainEarningsAddr + } + return nil +} + +type OptedInfo struct { + SlashContract string `protobuf:"bytes,1,opt,name=SlashContract,proto3" json:"SlashContract,omitempty"` + OptedInHeight uint64 `protobuf:"varint,2,opt,name=OptedInHeight,proto3" json:"OptedInHeight,omitempty"` + OptedOutHeight uint64 `protobuf:"varint,3,opt,name=OptedOutHeight,proto3" json:"OptedOutHeight,omitempty"` +} + +func (m *OptedInfo) Reset() { *m = OptedInfo{} } +func (m *OptedInfo) String() string { return proto.CompactTextString(m) } +func (*OptedInfo) ProtoMessage() {} +func (*OptedInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{3} +} +func (m *OptedInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OptedInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OptedInfo.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 *OptedInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptedInfo.Merge(m, src) +} +func (m *OptedInfo) XXX_Size() int { + return m.Size() +} +func (m *OptedInfo) XXX_DiscardUnknown() { + xxx_messageInfo_OptedInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_OptedInfo proto.InternalMessageInfo + +func (m *OptedInfo) GetSlashContract() string { + if m != nil { + return m.SlashContract + } + return "" +} + +func (m *OptedInfo) GetOptedInHeight() uint64 { + if m != nil { + return m.OptedInHeight + } + return 0 +} + +func (m *OptedInfo) GetOptedOutHeight() uint64 { + if m != nil { + return m.OptedOutHeight + } + return 0 +} + +type AssetOptedInState struct { + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=Amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"Amount"` + Value github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=Value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"Value"` +} + +func (m *AssetOptedInState) Reset() { *m = AssetOptedInState{} } +func (m *AssetOptedInState) String() string { return proto.CompactTextString(m) } +func (*AssetOptedInState) ProtoMessage() {} +func (*AssetOptedInState) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{4} +} +func (m *AssetOptedInState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetOptedInState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetOptedInState.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 *AssetOptedInState) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetOptedInState.Merge(m, src) +} +func (m *AssetOptedInState) XXX_Size() int { + return m.Size() +} +func (m *AssetOptedInState) XXX_DiscardUnknown() { + xxx_messageInfo_AssetOptedInState.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetOptedInState proto.InternalMessageInfo + +type OperatorSlashInfo struct { + SlashContract string `protobuf:"bytes,1,opt,name=SlashContract,proto3" json:"SlashContract,omitempty"` + SlashHeight uint64 `protobuf:"varint,2,opt,name=SlashHeight,proto3" json:"SlashHeight,omitempty"` + ExecuteHeight uint64 `protobuf:"varint,3,opt,name=ExecuteHeight,proto3" json:"ExecuteHeight,omitempty"` + SlashProportion github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=SlashProportion,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"SlashProportion"` +} + +func (m *OperatorSlashInfo) Reset() { *m = OperatorSlashInfo{} } +func (m *OperatorSlashInfo) String() string { return proto.CompactTextString(m) } +func (*OperatorSlashInfo) ProtoMessage() {} +func (*OperatorSlashInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{5} +} +func (m *OperatorSlashInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorSlashInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorSlashInfo.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 *OperatorSlashInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorSlashInfo.Merge(m, src) +} +func (m *OperatorSlashInfo) XXX_Size() int { + return m.Size() +} +func (m *OperatorSlashInfo) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorSlashInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorSlashInfo proto.InternalMessageInfo + +func (m *OperatorSlashInfo) GetSlashContract() string { + if m != nil { + return m.SlashContract + } + return "" +} + +func (m *OperatorSlashInfo) GetSlashHeight() uint64 { + if m != nil { + return m.SlashHeight + } + return 0 +} + +func (m *OperatorSlashInfo) GetExecuteHeight() uint64 { + if m != nil { + return m.ExecuteHeight + } + return 0 +} + +type RegisterOperatorReq struct { + FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` + Info *OperatorInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *RegisterOperatorReq) Reset() { *m = RegisterOperatorReq{} } +func (m *RegisterOperatorReq) String() string { return proto.CompactTextString(m) } +func (*RegisterOperatorReq) ProtoMessage() {} +func (*RegisterOperatorReq) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{6} +} +func (m *RegisterOperatorReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterOperatorReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterOperatorReq.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 *RegisterOperatorReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterOperatorReq.Merge(m, src) +} +func (m *RegisterOperatorReq) XXX_Size() int { + return m.Size() +} +func (m *RegisterOperatorReq) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterOperatorReq.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterOperatorReq proto.InternalMessageInfo + +type RegisterOperatorResponse struct { +} + +func (m *RegisterOperatorResponse) Reset() { *m = RegisterOperatorResponse{} } +func (m *RegisterOperatorResponse) String() string { return proto.CompactTextString(m) } +func (*RegisterOperatorResponse) ProtoMessage() {} +func (*RegisterOperatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{7} +} +func (m *RegisterOperatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterOperatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterOperatorResponse.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 *RegisterOperatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterOperatorResponse.Merge(m, src) +} +func (m *RegisterOperatorResponse) XXX_Size() int { + return m.Size() +} +func (m *RegisterOperatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterOperatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ClientChainEarningAddrList)(nil), "exocore.operator.v1.clientChainEarningAddrList") + proto.RegisterType((*ClientChainEarningAddrInfo)(nil), "exocore.operator.v1.clientChainEarningAddrInfo") + proto.RegisterType((*OperatorInfo)(nil), "exocore.operator.v1.OperatorInfo") + proto.RegisterType((*OptedInfo)(nil), "exocore.operator.v1.OptedInfo") + proto.RegisterType((*AssetOptedInState)(nil), "exocore.operator.v1.AssetOptedInState") + proto.RegisterType((*OperatorSlashInfo)(nil), "exocore.operator.v1.OperatorSlashInfo") + proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.operator.v1.RegisterOperatorReq") + proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.operator.v1.RegisterOperatorResponse") +} + +func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } + +var fileDescriptor_b229d5663e4df167 = []byte{ + // 682 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4d, 0x4f, 0x13, 0x41, + 0x18, 0xee, 0xd0, 0x42, 0xc2, 0x5b, 0x14, 0x18, 0x88, 0xd4, 0xc6, 0xb4, 0x75, 0x35, 0xa4, 0x69, + 0xd2, 0x6e, 0xc0, 0x8f, 0x03, 0xd1, 0x43, 0x29, 0x18, 0x9b, 0x48, 0x30, 0x8b, 0x31, 0xd1, 0x8b, + 0x59, 0xb6, 0xc3, 0x76, 0x43, 0x77, 0x66, 0x9d, 0x99, 0x62, 0xf1, 0xa0, 0xc6, 0x93, 0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a, 0xd0, 0x89, 0x6c, 0xf9, 0x1f, 0x99, 0x51, 0xcc, 0xec, 0xf0, 0x87, 0xd3, 0xdd, + 0x12, 0x5a, 0x7c, 0xb8, 0x7f, 0x9c, 0x43, 0x07, 0xc7, 0x39, 0xf4, 0xf3, 0x38, 0x87, 0xbe, 0x9c, + 0xe4, 0x12, 0x07, 0x27, 0xb9, 0xc4, 0xf7, 0x93, 0x5c, 0xe2, 0xe5, 0xad, 0xd8, 0xe0, 0xba, 0x0f, + 0x44, 0xe7, 0xec, 0x89, 0x50, 0x93, 0x5b, 0x1f, 0x51, 0xff, 0xd8, 0x77, 0xfe, 0x06, 0x00, 0x00, + 0xff, 0xff, 0xbb, 0x14, 0x0c, 0x66, 0x43, 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 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. + RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) { + out := new(RegisterOperatorResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/RegisterOperator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. + RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *RegisterOperatorReq) (*RegisterOperatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterOperator not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterOperator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterOperatorReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterOperator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Msg/RegisterOperator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterOperator(ctx, req.(*RegisterOperatorReq)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.operator.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterOperator", + Handler: _Msg_RegisterOperator_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/operator/v1/tx.proto", +} + +func (m *ClientChainEarningAddrList) 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 *ClientChainEarningAddrList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClientChainEarningAddrList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EarningInfoList) > 0 { + for iNdEx := len(m.EarningInfoList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EarningInfoList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ClientChainEarningAddrInfo) 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 *ClientChainEarningAddrInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClientChainEarningAddrInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClientChainEarningAddr) > 0 { + i -= len(m.ClientChainEarningAddr) + copy(dAtA[i:], m.ClientChainEarningAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientChainEarningAddr))) + i-- + dAtA[i] = 0x12 + } + if m.LzClientChainId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.LzClientChainId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *OperatorInfo) 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 *OperatorInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientChainEarningsAddr != nil { + { + size, err := m.ClientChainEarningsAddr.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.OperatorMetaInfo) > 0 { + i -= len(m.OperatorMetaInfo) + copy(dAtA[i:], m.OperatorMetaInfo) + i = encodeVarintTx(dAtA, i, uint64(len(m.OperatorMetaInfo))) + i-- + dAtA[i] = 0x1a + } + if len(m.ApproveAddr) > 0 { + i -= len(m.ApproveAddr) + copy(dAtA[i:], m.ApproveAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ApproveAddr))) + i-- + dAtA[i] = 0x12 + } + if len(m.EarningsAddr) > 0 { + i -= len(m.EarningsAddr) + copy(dAtA[i:], m.EarningsAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.EarningsAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OptedInfo) 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 *OptedInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptedInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.OptedOutHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OptedOutHeight)) + i-- + dAtA[i] = 0x18 + } + if m.OptedInHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OptedInHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.SlashContract) > 0 { + i -= len(m.SlashContract) + copy(dAtA[i:], m.SlashContract) + i = encodeVarintTx(dAtA, i, uint64(len(m.SlashContract))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AssetOptedInState) 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 *AssetOptedInState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetOptedInState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Value.Size() + i -= size + if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *OperatorSlashInfo) 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 *OperatorSlashInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorSlashInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SlashProportion.Size() + i -= size + if _, err := m.SlashProportion.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.ExecuteHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExecuteHeight)) + i-- + dAtA[i] = 0x18 + } + if m.SlashHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.SlashHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.SlashContract) > 0 { + i -= len(m.SlashContract) + copy(dAtA[i:], m.SlashContract) + i = encodeVarintTx(dAtA, i, uint64(len(m.SlashContract))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RegisterOperatorReq) 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 *RegisterOperatorReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterOperatorReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Info != nil { + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RegisterOperatorResponse) 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 *RegisterOperatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterOperatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ClientChainEarningAddrList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.EarningInfoList) > 0 { + for _, e := range m.EarningInfoList { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *ClientChainEarningAddrInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LzClientChainId != 0 { + n += 1 + sovTx(uint64(m.LzClientChainId)) + } + l = len(m.ClientChainEarningAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *OperatorInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.EarningsAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ApproveAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.OperatorMetaInfo) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ClientChainEarningsAddr != nil { + l = m.ClientChainEarningsAddr.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *OptedInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SlashContract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.OptedInHeight != 0 { + n += 1 + sovTx(uint64(m.OptedInHeight)) + } + if m.OptedOutHeight != 0 { + n += 1 + sovTx(uint64(m.OptedOutHeight)) + } + return n +} + +func (m *AssetOptedInState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Value.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *OperatorSlashInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SlashContract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.SlashHeight != 0 { + n += 1 + sovTx(uint64(m.SlashHeight)) + } + if m.ExecuteHeight != 0 { + n += 1 + sovTx(uint64(m.ExecuteHeight)) + } + l = m.SlashProportion.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *RegisterOperatorReq) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *RegisterOperatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ClientChainEarningAddrList) 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 ErrIntOverflowTx + } + 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: clientChainEarningAddrList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: clientChainEarningAddrList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EarningInfoList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EarningInfoList = append(m.EarningInfoList, &ClientChainEarningAddrInfo{}) + if err := m.EarningInfoList[len(m.EarningInfoList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ClientChainEarningAddrInfo) 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 ErrIntOverflowTx + } + 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: clientChainEarningAddrInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: clientChainEarningAddrInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LzClientChainId", wireType) + } + m.LzClientChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LzClientChainId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientChainEarningAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientChainEarningAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorInfo) 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 ErrIntOverflowTx + } + 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: OperatorInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EarningsAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EarningsAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApproveAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ApproveAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorMetaInfo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorMetaInfo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientChainEarningsAddr", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ClientChainEarningsAddr == nil { + m.ClientChainEarningsAddr = &ClientChainEarningAddrList{} + } + if err := m.ClientChainEarningsAddr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OptedInfo) 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 ErrIntOverflowTx + } + 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: OptedInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptedInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashContract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SlashContract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OptedInHeight", wireType) + } + m.OptedInHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OptedInHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OptedOutHeight", wireType) + } + m.OptedOutHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OptedOutHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AssetOptedInState) 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 ErrIntOverflowTx + } + 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: AssetOptedInState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetOptedInState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperatorSlashInfo) 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 ErrIntOverflowTx + } + 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: OperatorSlashInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorSlashInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashContract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SlashContract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashHeight", wireType) + } + m.SlashHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SlashHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecuteHeight", wireType) + } + m.ExecuteHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecuteHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashProportion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SlashProportion.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RegisterOperatorReq) 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 ErrIntOverflowTx + } + 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: RegisterOperatorReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterOperatorReq: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromAddress = 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Info == nil { + m.Info = &OperatorInfo{} + } + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RegisterOperatorResponse) 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 ErrIntOverflowTx + } + 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: RegisterOperatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterOperatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/restaking_assets_manage/keeper/client_chain_asset.go b/x/restaking_assets_manage/keeper/client_chain_asset.go index 5bc8fba0f..e00fd26a9 100644 --- a/x/restaking_assets_manage/keeper/client_chain_asset.go +++ b/x/restaking_assets_manage/keeper/client_chain_asset.go @@ -26,7 +26,7 @@ func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetId string, c k.cdc.MustUnmarshal(value, &ret) //calculate and set new amount - err = UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) + err = restakingtype.UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) if err != nil { return err } diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index 7bd0056e7..8d0655ff8 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -21,10 +21,11 @@ func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) for ; iterator.Valid(); iterator.Next() { var stateInfo restakingtype.OperatorSingleAssetOrChangeInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) - _, assetId, err := restakingtype.ParseStakerAndAssetIdFromKey(iterator.Key()) + keyList, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { return nil, err } + assetId := keyList[1] ret[assetId] = &stateInfo } return ret, nil @@ -32,7 +33,7 @@ func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetId string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetAssetStateKey(operatorAddr.String(), assetId) + key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) ifExist := store.Has(key) if !ifExist { return nil, restakingtype.ErrNoOperatorAssetKey @@ -52,7 +53,7 @@ func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk. func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetId string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) { //get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetAssetStateKey(operatorAddr.String(), assetId) + key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: math.NewInt(0), OperatorOwnAmountOrWantChangeValue: math.NewInt(0), @@ -64,15 +65,15 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre } // update all states of the specified operator asset - err = UpdateAssetValue(&assetState.TotalAmountOrWantChangeValue, &changeAmount.TotalAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.TotalAmountOrWantChangeValue, &changeAmount.TotalAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") } - err = UpdateAssetValue(&assetState.OperatorOwnAmountOrWantChangeValue, &changeAmount.OperatorOwnAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.OperatorOwnAmountOrWantChangeValue, &changeAmount.OperatorOwnAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnAmountOrWantChangeValue error") } - err = UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/restaking_assets_manage/keeper/staker_asset.go b/x/restaking_assets_manage/keeper/staker_asset.go index dcff0355a..85f8857be 100644 --- a/x/restaking_assets_manage/keeper/staker_asset.go +++ b/x/restaking_assets_manage/keeper/staker_asset.go @@ -10,26 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// UpdateAssetValue It's used to update asset state,negative or positive `changeValue` represents a decrease or increase in the asset state -// newValue = valueToUpdate + changeVale -func UpdateAssetValue(valueToUpdate *math.Int, changeValue *math.Int) error { - if valueToUpdate == nil || changeValue == nil { - return errorsmod.Wrap(restakingtype.ErrInputPointerIsNil, fmt.Sprintf("valueToUpdate:%v,changeValue:%v", valueToUpdate, changeValue)) - } - - if !changeValue.IsNil() { - if changeValue.IsNegative() { - if valueToUpdate.LT(changeValue.Neg()) { - return errorsmod.Wrap(restakingtype.ErrSubAmountIsMoreThanOrigin, fmt.Sprintf("valueToUpdate:%s,changeValue:%s", *valueToUpdate, *changeValue)) - } - } - if !changeValue.IsZero() { - *valueToUpdate = valueToUpdate.Add(*changeValue) - } - } - return nil -} - func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerId string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) iterator := sdk.KVStorePrefixIterator(store, []byte(stakerId)) @@ -39,10 +19,11 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerId string) (assetsInf for ; iterator.Valid(); iterator.Next() { var stateInfo restakingtype.StakerSingleAssetOrChangeInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) - _, assetId, err := restakingtype.ParseStakerAndAssetIdFromKey(iterator.Key()) + keyList, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { return nil, err } + assetId := keyList[1] ret[assetId] = &stateInfo } return ret, nil @@ -50,7 +31,7 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerId string) (assetsInf func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerId string, assetId string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetAssetStateKey(stakerId, assetId) + key := restakingtype.GetJoinedStoreKey(stakerId, assetId) ifExist := store.Has(key) if !ifExist { return nil, errorsmod.Wrap(restakingtype.ErrNoStakerAssetKey, fmt.Sprintf("the key is:%s", key)) @@ -69,7 +50,7 @@ func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerId string, as func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerId string, assetId string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) { //get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetAssetStateKey(stakerId, assetId) + key := restakingtype.GetJoinedStoreKey(stakerId, assetId) assetState := restakingtype.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: math.NewInt(0), CanWithdrawAmountOrWantChangeValue: math.NewInt(0), @@ -81,15 +62,15 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerId string, assetId } // update all states of the specified restaker asset - err = UpdateAssetValue(&assetState.TotalDepositAmountOrWantChangeValue, &changeAmount.TotalDepositAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.TotalDepositAmountOrWantChangeValue, &changeAmount.TotalDepositAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState TotalDepositAmountOrWantChangeValue error") } - err = UpdateAssetValue(&assetState.CanWithdrawAmountOrWantChangeValue, &changeAmount.CanWithdrawAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.CanWithdrawAmountOrWantChangeValue, &changeAmount.CanWithdrawAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") } - err = UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/restaking_assets_manage/types/errors.go b/x/restaking_assets_manage/types/errors.go index b37301f4a..b7b353d86 100644 --- a/x/restaking_assets_manage/types/errors.go +++ b/x/restaking_assets_manage/types/errors.go @@ -20,4 +20,8 @@ var ( ErrCliCmdInputArg = errorsmod.Register(ModuleName, 6, "there is an error in the input client command args") ErrInputPointerIsNil = errorsmod.Register(ModuleName, 7, "the input pointer is nil") + + OperatorAddrIsNotAccAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid acc addr") + + ErrNoKeyInTheStore = errorsmod.Register(ModuleName, 9, "there is not the key for in the store") ) diff --git a/x/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go index 5f364df3a..cab5cfb63 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/restaking_assets_manage/types/general.go @@ -1,6 +1,9 @@ package types import ( + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "fmt" "strings" "github.com/ethereum/go-ethereum/common/hexutil" @@ -60,3 +63,23 @@ func GetStakeIDAndAssetIdFromStr(clientChainLzId uint64, stakerAddress string, a } return } + +// UpdateAssetValue It's used to update asset state,negative or positive `changeValue` represents a decrease or increase in the asset state +// newValue = valueToUpdate + changeVale +func UpdateAssetValue(valueToUpdate *math.Int, changeValue *math.Int) error { + if valueToUpdate == nil || changeValue == nil { + return errorsmod.Wrap(ErrInputPointerIsNil, fmt.Sprintf("valueToUpdate:%v,changeValue:%v", valueToUpdate, changeValue)) + } + + if !changeValue.IsNil() { + if changeValue.IsNegative() { + if valueToUpdate.LT(changeValue.Neg()) { + return errorsmod.Wrap(ErrSubAmountIsMoreThanOrigin, fmt.Sprintf("valueToUpdate:%s,changeValue:%s", *valueToUpdate, *changeValue)) + } + } + if !changeValue.IsZero() { + *valueToUpdate = valueToUpdate.Add(*changeValue) + } + } + return nil +} diff --git a/x/restaking_assets_manage/types/keys.go b/x/restaking_assets_manage/types/keys.go index 776f1f283..d5266c079 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/restaking_assets_manage/types/keys.go @@ -106,15 +106,14 @@ var ( KeyPrefixReStakerExoCoreAddrReverse = []byte{prefixRestakerExocoreAddrReverse} ) -// GetAssetStateKey assetStateKey = stakerId+'/'+assetId -func GetAssetStateKey(stakerId, assetId string) []byte { - return []byte(strings.Join([]string{stakerId, assetId}, "/")) +func GetJoinedStoreKey(keys ...string) []byte { + return []byte(strings.Join(keys, "/")) } -func ParseStakerAndAssetIdFromKey(key []byte) (stakerId string, assetId string, err error) { +func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { stringList := strings.Split(string(key), "/") - if len(stringList) != 2 { - return "", "", errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("the stringList is:%v", stringList)) + if len(stringList) != number { + return nil, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("expected length:%d,actual length:%d,the stringList is:%v", number, len(stringList), stringList)) } - return stringList[0], stringList[1], nil + return stringList, nil } diff --git a/x/restaking_assets_manage/types/query.pb.gw.go b/x/restaking_assets_manage/types/query.pb.gw.go index f342bf4cc..1aa9d1b60 100644 --- a/x/restaking_assets_manage/types/query.pb.gw.go +++ b/x/restaking_assets_manage/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join var ( filter_Query_QueClientChainInfoByIndex_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} @@ -340,12 +342,14 @@ func local_request_Query_QueStakerExoCoreAddr_0(ctx context.Context, marshaler r // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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_QueClientChainInfoByIndex_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 { @@ -353,6 +357,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueClientChainInfoByIndex_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) @@ -366,6 +371,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueAllClientChainInfo_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 { @@ -373,6 +380,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueAllClientChainInfo_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) @@ -386,6 +394,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakingAssetInfo_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 { @@ -393,6 +403,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakingAssetInfo_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) @@ -406,6 +417,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueAllStakingAssetsInfo_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 { @@ -413,6 +426,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueAllStakingAssetsInfo_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) @@ -426,6 +440,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakerAssetInfos_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 { @@ -433,6 +449,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakerAssetInfos_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) @@ -446,6 +463,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakerSpecifiedAssetAmount_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 { @@ -453,6 +472,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakerSpecifiedAssetAmount_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) @@ -466,6 +486,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueOperatorAssetInfos_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 { @@ -473,6 +495,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueOperatorAssetInfos_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) @@ -486,6 +509,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueOperatorSpecifiedAssetAmount_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 { @@ -493,6 +518,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueOperatorSpecifiedAssetAmount_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) @@ -506,6 +532,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakerExoCoreAddr_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 { @@ -513,6 +541,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakerExoCoreAddr_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) diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index 04d21e14b..4556778dd 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -32,6 +32,43 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type ValueField struct { + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=Amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"Amount"` +} + +func (m *ValueField) Reset() { *m = ValueField{} } +func (m *ValueField) String() string { return proto.CompactTextString(m) } +func (*ValueField) ProtoMessage() {} +func (*ValueField) Descriptor() ([]byte, []int) { + return fileDescriptor_b24e66e530cc30d1, []int{0} +} +func (m *ValueField) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValueField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValueField.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 *ValueField) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValueField.Merge(m, src) +} +func (m *ValueField) XXX_Size() int { + return m.Size() +} +func (m *ValueField) XXX_DiscardUnknown() { + xxx_messageInfo_ValueField.DiscardUnknown(m) +} + +var xxx_messageInfo_ValueField proto.InternalMessageInfo + type ClientChainInfo struct { ChainName string `protobuf:"bytes,1,opt,name=ChainName,proto3" json:"ChainName,omitempty"` ChainMetaInfo string `protobuf:"bytes,2,opt,name=ChainMetaInfo,proto3" json:"ChainMetaInfo,omitempty"` @@ -47,7 +84,7 @@ func (m *ClientChainInfo) Reset() { *m = ClientChainInfo{} } func (m *ClientChainInfo) String() string { return proto.CompactTextString(m) } func (*ClientChainInfo) ProtoMessage() {} func (*ClientChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{0} + return fileDescriptor_b24e66e530cc30d1, []int{1} } func (m *ClientChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -147,7 +184,7 @@ func (m *ClientChainTokenInfo) Reset() { *m = ClientChainTokenInfo{} } func (m *ClientChainTokenInfo) String() string { return proto.CompactTextString(m) } func (*ClientChainTokenInfo) ProtoMessage() {} func (*ClientChainTokenInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{1} + return fileDescriptor_b24e66e530cc30d1, []int{2} } func (m *ClientChainTokenInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -234,7 +271,7 @@ func (m *StakingAssetInfo) Reset() { *m = StakingAssetInfo{} } func (m *StakingAssetInfo) String() string { return proto.CompactTextString(m) } func (*StakingAssetInfo) ProtoMessage() {} func (*StakingAssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{2} + return fileDescriptor_b24e66e530cc30d1, []int{3} } func (m *StakingAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +317,7 @@ func (m *StakerSingleAssetOrChangeInfo) Reset() { *m = StakerSingleAsset func (m *StakerSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } func (*StakerSingleAssetOrChangeInfo) ProtoMessage() {} func (*StakerSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{3} + return fileDescriptor_b24e66e530cc30d1, []int{4} } func (m *StakerSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,7 +354,7 @@ func (m *StakerAllAssetsInfo) Reset() { *m = StakerAllAssetsInfo{} } func (m *StakerAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*StakerAllAssetsInfo) ProtoMessage() {} func (*StakerAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{4} + return fileDescriptor_b24e66e530cc30d1, []int{5} } func (m *StakerAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -364,7 +401,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleA func (m *OperatorSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } func (*OperatorSingleAssetOrChangeInfo) ProtoMessage() {} func (*OperatorSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{5} + return fileDescriptor_b24e66e530cc30d1, []int{6} } func (m *OperatorSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -401,7 +438,7 @@ func (m *OperatorAllAssetsInfo) Reset() { *m = OperatorAllAssetsInfo{} } func (m *OperatorAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*OperatorAllAssetsInfo) ProtoMessage() {} func (*OperatorAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{6} + return fileDescriptor_b24e66e530cc30d1, []int{7} } func (m *OperatorAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -449,7 +486,7 @@ func (m *MsgSetExoCoreAddr) Reset() { *m = MsgSetExoCoreAddr{} } func (m *MsgSetExoCoreAddr) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddr) ProtoMessage() {} func (*MsgSetExoCoreAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{7} + return fileDescriptor_b24e66e530cc30d1, []int{8} } func (m *MsgSetExoCoreAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -485,7 +522,7 @@ func (m *MsgSetExoCoreAddrResponse) Reset() { *m = MsgSetExoCoreAddrResp func (m *MsgSetExoCoreAddrResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddrResponse) ProtoMessage() {} func (*MsgSetExoCoreAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{8} + return fileDescriptor_b24e66e530cc30d1, []int{9} } func (m *MsgSetExoCoreAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -515,6 +552,7 @@ func (m *MsgSetExoCoreAddrResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetExoCoreAddrResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*ValueField)(nil), "exocore.restaking_assets_manage.v1.ValueField") proto.RegisterType((*ClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainInfo") proto.RegisterType((*ClientChainTokenInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainTokenInfo") proto.RegisterType((*StakingAssetInfo)(nil), "exocore.restaking_assets_manage.v1.StakingAssetInfo") @@ -533,70 +571,72 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1008 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0xda, 0xf9, 0x7c, 0xad, 0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, 0x1f, 0x46, 0xe9, 0xf3, 0x40, 0xfc, 0xf4, 0xc7, 0xff, 0xcb, 0x2d, 0x28, 0x2b, - 0x3d, 0x7e, 0xef, 0xe4, 0x60, 0xc9, 0x58, 0xdb, 0x7c, 0x78, 0x94, 0x31, 0x1e, 0x1d, 0x65, 0x8c, - 0x7f, 0x8e, 0x32, 0xc6, 0xcf, 0xc7, 0x99, 0xd8, 0xa3, 0xe3, 0x4c, 0xec, 0xf0, 0x38, 0x13, 0xbb, - 0x5d, 0x0a, 0xcd, 0x69, 0x70, 0xf4, 0xee, 0xc8, 0xff, 0x2e, 0xd4, 0xdc, 0xee, 0x4d, 0xa8, 0xd7, - 0xfd, 0x07, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xd9, 0x3c, 0x38, 0x8d, 0x0c, 0x00, 0x00, + // 1028 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xf6, 0xda, 0xf9, 0xfb, 0x46, 0x69, 0x93, 0x69, 0x7e, 0xfd, 0x39, 0xa6, 0x38, 0xd1, 0x82, + 0xc0, 0x0a, 0xc4, 0x56, 0x8d, 0xa8, 0xa2, 0x08, 0x90, 0x1c, 0xa7, 0x95, 0x22, 0x92, 0x5a, 0x5a, + 0x07, 0x22, 0x7a, 0x20, 0x4c, 0xec, 0xb7, 0xeb, 0x95, 0x77, 0x67, 0xac, 0x9d, 0x71, 0x6a, 0xdf, + 0x2a, 0x84, 0x10, 0x42, 0x08, 0xc1, 0x05, 0x0e, 0x5c, 0xfa, 0x11, 0x72, 0xe8, 0x87, 0xe8, 0x81, + 0x43, 0xd5, 0x0b, 0x81, 0x43, 0x85, 0x92, 0x43, 0xf8, 0x18, 0x68, 0x67, 0x77, 0x93, 0x75, 0x6c, + 0x37, 0x5b, 0x48, 0x25, 0x2e, 0xc9, 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 0xdc, + 0xee, 0x8d, 0xa9, 0x5f, 0x10, 0xef, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x79, 0x39, 0x86, 0x06, + 0xf1, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -679,6 +719,39 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "exocore/restaking_assets_manage/v1/tx.proto", } +func (m *ValueField) 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 *ValueField) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValueField) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *ClientChainInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1163,6 +1236,17 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *ValueField) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + func (m *ClientChainInfo) Size() (n int) { if m == nil { return 0 @@ -1367,6 +1451,90 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *ValueField) 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 ErrIntOverflowTx + } + 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: ValueField: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValueField: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/reward/types/query.pb.gw.go b/x/reward/types/query.pb.gw.go index 17252797c..67784ea28 100644 --- a/x/reward/types/query.pb.gw.go +++ b/x/reward/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -52,12 +54,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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_Params_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 { @@ -65,6 +69,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_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) diff --git a/x/slash/types/query.pb.gw.go b/x/slash/types/query.pb.gw.go index 9edbdedb6..82bdc46cb 100644 --- a/x/slash/types/query.pb.gw.go +++ b/x/slash/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -52,12 +54,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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_Params_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 { @@ -65,6 +69,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_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) diff --git a/x/withdraw/types/query.pb.gw.go b/x/withdraw/types/query.pb.gw.go index 0bf7a3bbc..5b7cd856b 100644 --- a/x/withdraw/types/query.pb.gw.go +++ b/x/withdraw/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -52,12 +54,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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_Params_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 { @@ -65,6 +69,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_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) From 86835743eecc14e927e146c9eafdd3f241bf55ff Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 22 Jan 2024 15:58:09 +0800 Subject: [PATCH 05/44] update avs_operator_assets_state --- app/app.go | 2 +- proto/exocore/operator/v1/tx.proto | 13 +- .../restaking_assets_manage/v1/tx.proto | 4 +- x/delegation/keeper/abci.go | 7 +- x/delegation/keeper/cross_chain_tx_process.go | 9 +- x/delegation/keeper/delegation_op_test.go | 36 +-- x/delegation/keeper/delegation_state.go | 30 +- x/delegation/types/codec.go | 2 - x/delegation/types/expected_keepers.go | 4 +- x/delegation/types/msg.go | 20 -- .../keeper/avs_operator_assets_state.go | 66 +++-- x/operator/keeper/keeper.go | 3 + x/operator/keeper/operator.go | 4 +- .../keeper/sate_update_for_external_op.go | 157 ++++++++++- x/operator/types/errors.go | 6 + x/operator/types/expected_keepers.go | 7 +- x/operator/types/keys.go | 2 + x/operator/types/tx.pb.go | 263 ++++++++++++++---- .../keeper/operator_asset.go | 14 +- .../keeper/staker_asset.go | 8 +- x/restaking_assets_manage/types/general.go | 20 ++ x/restaking_assets_manage/types/keys.go | 5 + x/restaking_assets_manage/types/tx.pb.go | 161 ++++++----- 23 files changed, 614 insertions(+), 229 deletions(-) diff --git a/app/app.go b/app/app.go index e72ea46fd..c89e063fb 100644 --- a/app/app.go +++ b/app/app.go @@ -622,7 +622,7 @@ func NewExocoreApp( app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec) app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper) - app.OperatorKeeper = operatorkeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, nil) + app.OperatorKeeper = operatorkeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, nil, nil) // todo: need to replace the virtual keepers with actual keepers after they have been implemented app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, app.OperatorKeeper) app.OperatorKeeper.RegisterExpectDelegationInterface(app.DelegationKeeper) diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 746a05b74..86ce37733 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -40,8 +40,17 @@ message AssetOptedInState{ string Value = 2 [ - (cosmos_proto.scalar) = "cosmos.Int", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message ValueField { + string Amount = 1 + [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; } diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index c3e490b1c..e78bdca9a 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -67,7 +67,7 @@ message StakerSingleAssetOrChangeInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string WaitUndelegationAmountOrWantChangeValue = 3 + string WaitUnbondingAmountOrWantChangeValue = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -93,7 +93,7 @@ message OperatorSingleAssetOrChangeInfo{ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string WaitUndelegationAmountOrWantChangeValue = 3 + string WaitUnbondingAmountOrWantChangeValue = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 1773475d7..1a75d7a1f 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -65,8 +65,8 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat // update the staker state err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerId, record.AssetId, types.StakerSingleAssetOrChangeInfo{ - CanWithdrawAmountOrWantChangeValue: actualCanUndelegateAmount, - WaitUndelegationAmountOrWantChangeValue: recordAmountNeg, + CanWithdrawAmountOrWantChangeValue: actualCanUndelegateAmount, + WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, }) if err != nil { panic(err) @@ -74,8 +74,7 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat // update the operator state err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetId, types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: actualCanUndelegateAmount.Neg(), - WaitUndelegationAmountOrWantChangeValue: recordAmountNeg, + WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, }) if err != nil { panic(err) diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 4ca66c5ab..a375c2837 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -167,7 +167,7 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara return err } // call operator module to bond the increased assets to the opted-in AVS - err = k.expectOperatorInterface.IncreasedOptedInAssets(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) + err = k.expectOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) if err != nil { return err } @@ -226,20 +226,21 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation //update staker and operator assets state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types.StakerSingleAssetOrChangeInfo{ - WaitUndelegationAmountOrWantChangeValue: params.OpAmount, + WaitUnbondingAmountOrWantChangeValue: params.OpAmount, }) if err != nil { return err } err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetId, types.OperatorSingleAssetOrChangeInfo{ - WaitUndelegationAmountOrWantChangeValue: params.OpAmount, + TotalAmountOrWantChangeValue: params.OpAmount.Neg(), + WaitUnbondingAmountOrWantChangeValue: params.OpAmount, }) if err != nil { return err } // call operator module to decrease the state of opted-in assets - err = k.expectOperatorInterface.DecreaseOptedInAssets(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) + err = k.expectOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount.Neg()) if err != nil { return err } diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 5e51b815f..7b33a3acb 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -58,17 +58,17 @@ func (suite *KeeperTestSuite) TestDelegateTo() { restakerState, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationParams.OpAmount), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, + CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationParams.OpAmount), + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *restakerState) operatorState, err := suite.app.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.ctx, opAccAddr, assetId) suite.NoError(err) suite.Equal(types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: delegationParams.OpAmount, - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalAmountOrWantChangeValue: delegationParams.OpAmount, + OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) @@ -131,17 +131,17 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { restakerState, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationEvent.OpAmount), - WaitUndelegationAmountOrWantChangeValue: delegationEvent.OpAmount, + TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, + CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationEvent.OpAmount), + WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, }, *restakerState) operatorState, err := suite.app.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.ctx, opAccAddr, assetId) suite.NoError(err) suite.Equal(types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: delegationEvent.OpAmount, - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: delegationEvent.OpAmount, + TotalAmountOrWantChangeValue: sdkmath.NewInt(0), + OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, }, *operatorState) specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) @@ -233,17 +233,17 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { restakerState, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, + CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *restakerState) operatorState, err := suite.app.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.ctx, opAccAddr, assetId) suite.NoError(err) suite.Equal(types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: sdkmath.NewInt(0), - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalAmountOrWantChangeValue: sdkmath.NewInt(0), + OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 27b98a588..8d1eb2a57 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -141,8 +141,32 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d return &ret, nil } -// GetDelegationStateByOperator get all assets state delegated to the specified operator -func (k Keeper) GetDelegationStateByOperator(ctx sdk.Context, operatorAddr string) (map[string]sdkmath.Int, error) { +// GetDelegationStateByOperatorAndAssetList get the specified assets state delegated to the specified operator +func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]sdkmath.Int, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + iterator := sdk.KVStorePrefixIterator(store, nil) + defer iterator.Close() - return nil, nil + ret := make(map[string]map[string]sdkmath.Int, 0) + for ; iterator.Valid(); iterator.Next() { + var amounts delegationtype.DelegationAmounts + k.cdc.MustUnmarshal(iterator.Value(), &amounts) + keys, err := stakingtypes.ParseJoinedKey(iterator.Key()) + if err != nil { + return nil, err + } + if len(keys) == 3 { + restakerId, assetId, findOperatorAddr := keys[0], keys[1], keys[2] + if operatorAddr == findOperatorAddr { + if _, ok := assetsFilter[assetId]; ok { + if _, ok := ret[restakerId]; ok { + ret[restakerId][assetId] = amounts.CanUndelegationAmount + } else { + ret[restakerId] = make(map[string]sdkmath.Int, 0) + } + } + } + } + } + return ret, nil } diff --git a/x/delegation/types/codec.go b/x/delegation/types/codec.go index 80b292929..fc0ea106c 100644 --- a/x/delegation/types/codec.go +++ b/x/delegation/types/codec.go @@ -38,7 +38,6 @@ func init() { func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), - &RegisterOperatorReq{}, &MsgDelegation{}, &MsgUndelegation{}, ) @@ -49,7 +48,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { // concrete types on the provided LegacyAmino codec. These types are used for // Amino JSON serialization and EIP-712 compatibility. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&RegisterOperatorReq{}, registerOperator, nil) cdc.RegisterConcrete(&MsgDelegation{}, delegateAssetToOperator, nil) cdc.RegisterConcrete(&MsgUndelegation{}, UndelegateAssetFromOperator, nil) } diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 8cdbd81a0..ed93942fd 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -27,7 +27,5 @@ type ExpectOperatorInterface interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 - IncreasedOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error - - DecreaseOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error + UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error } diff --git a/x/delegation/types/msg.go b/x/delegation/types/msg.go index bc978f9f5..91ba52e84 100644 --- a/x/delegation/types/msg.go +++ b/x/delegation/types/msg.go @@ -6,30 +6,10 @@ import ( ) var ( - _ sdk.Msg = &RegisterOperatorReq{} _ sdk.Msg = &MsgDelegation{} _ sdk.Msg = &MsgUndelegation{} ) -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (m *RegisterOperatorReq) GetSigners() []sdk.AccAddress { - addr := sdk.MustAccAddressFromBech32(m.FromAddress) - return []sdk.AccAddress{addr} -} - -// ValidateBasic does a sanity check of the provided data -func (m *RegisterOperatorReq) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.FromAddress); err != nil { - return errorsmod.Wrap(err, "invalid from address") - } - return nil -} - -// GetSignBytes implements the LegacyMsg interface. -func (m *RegisterOperatorReq) GetSignBytes() []byte { - return nil -} - // GetSigners returns the expected signers for a MsgUpdateParams message. func (m *MsgDelegation) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.BaseInfo.FromAddress) diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index d4d38cace..1da962765 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -10,24 +10,24 @@ import ( restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) -func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.Int) error { +func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var key []byte if operatorAddr == "" { - key = []byte(avsAddr) + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateAVSOperatorTotalValue the operatorAddr is empty") } else { key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } - totalValue := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + totalValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &totalValue) } - err := restakingtype.UpdateAssetValue(&totalValue.Amount, &opAmount) + err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) if err != nil { return err } @@ -36,18 +36,52 @@ func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAd return nil } -func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.Int, error) { +func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) - var ret restakingtype.ValueField + var ret operatortypes.ValueField var key []byte if operatorAddr == "" { - key = []byte(avsAddr) + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetAVSOperatorTotalValue the operatorAddr is empty") } else { key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } isExit := store.Has(key) if !isExit { - return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorTotalValue: key is %s", key)) + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorTotalValue: key is %s", key)) + } else { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + } + return ret.Amount, nil +} + +func (k Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount sdkmath.LegacyDec) error { + if opAmount.IsNil() || opAmount.IsZero() { + return nil + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + key := []byte(avsAddr) + totalValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &totalValue) + } + err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&totalValue) + store.Set(key, bz) + return nil +} + +func (k Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + var ret operatortypes.ValueField + key := []byte(avsAddr) + isExit := store.Has(key) + if !isExit { + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSTotalValue: key is %s", key)) } else { value := store.Get(key) k.cdc.MustUnmarshal(value, &ret) @@ -69,7 +103,7 @@ func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) assetOptedInState := operatortypes.AssetOptedInState{ Amount: sdkmath.NewInt(0), - Value: sdkmath.NewInt(0), + Value: sdkmath.LegacyNewDec(0), } if store.Has(stateKey) { @@ -82,7 +116,7 @@ func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, return errorsmod.Wrap(err, "UpdateOperatorAVSAssetsState assetOptedInState.Amount error") } - err = restakingtype.UpdateAssetValue(&assetOptedInState.Value, &changeState.Value) + err = restakingtype.UpdateAssetDecValue(&assetOptedInState.Value, &changeState.Value) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAVSAssetsState assetOptedInState.Value error") } @@ -107,19 +141,19 @@ func (k Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, ope return &assetOptedInState, nil } -func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.Int) error { +func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) - optedInValue := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + optedInValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &optedInValue) } - err := restakingtype.UpdateAssetValue(&optedInValue.Amount, &opAmount) + err := restakingtype.UpdateAssetDecValue(&optedInValue.Amount, &opAmount) if err != nil { return err } @@ -128,13 +162,13 @@ func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stak return nil } -func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.Int, error) { +func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - var ret restakingtype.ValueField + var ret operatortypes.ValueField key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) isExit := store.Has(key) if !isExit { - return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorStakerShareValue: key is %s", key)) + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorStakerShareValue: key is %s", key)) } else { value := store.Get(key) k.cdc.MustUnmarshal(value, &ret) diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 5b785e5be..1f6d36aab 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -17,6 +17,7 @@ type Keeper struct { restakingStateKeeper keeper.Keeper delegationKeeper operatortypes.ExpectDelegationInterface oracleKeeper operatortypes.ExpectOracleInterface + avsKeeper operatortypes.ExpectAvsInterface } func NewKeeper( @@ -24,12 +25,14 @@ func NewKeeper( cdc codec.BinaryCodec, restakingStateKeeper keeper.Keeper, oracleKeeper operatortypes.ExpectOracleInterface, + avsKeeper operatortypes.ExpectAvsInterface, ) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, restakingStateKeeper: restakingStateKeeper, oracleKeeper: oracleKeeper, + avsKeeper: avsKeeper, } } diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 10570afcf..d4e090f06 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -92,9 +92,9 @@ func (k Keeper) IsOptedIn(ctx sdk.Context, operatorAddr, avsAddr string) bool { return false } if optedInfo.OptedOutHeight != operatortypes.DefaultOptedOutHeight { - return true + return false } - return false + return true } func (k Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) ([]string, error) { diff --git a/x/operator/keeper/sate_update_for_external_op.go b/x/operator/keeper/sate_update_for_external_op.go index d87cba3e5..15fd66a58 100644 --- a/x/operator/keeper/sate_update_for_external_op.go +++ b/x/operator/keeper/sate_update_for_external_op.go @@ -3,37 +3,178 @@ package keeper import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/exocore/x/operator/types" ) -func (k Keeper) IncreasedOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { +func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { //get the AVS opted-in by the operator avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) if err != nil { return err } - //get price and priceDecimal from oracle - price, priceDecimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) + price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) + if err != nil { + return err + } + + //get the decimal of asset + assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) if err != nil { return err } - opUsdValue := opAmount.Mul() + //opUsdValue = (opAmount*price*10^UsdValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) + value := opAmount.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) + opUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(value.BigInt(), int64(types.UsdValueDefaultDecimal)) -} + for _, avs := range avsList { + //UpdateAVSOperatorStakerShareValue + err = k.UpdateAVSOperatorStakerShareValue(ctx, avs, stakerId, operatorAddr, opUsdValue) + if err != nil { + return err + } -func (k Keeper) DecreaseOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { + //UpdateOperatorAVSAssetsState + changeState := types.AssetOptedInState{ + Amount: opAmount, + Value: opUsdValue, + } + err = k.UpdateOperatorAVSAssetsState(ctx, assetId, avs, operatorAddr, changeState) + if err != nil { + return err + } + //UpdateAVSOperatorTotalValue + err = k.UpdateAVSOperatorTotalValue(ctx, avs, operatorAddr, opUsdValue) + if err != nil { + return err + } + + //UpdateAVSTotalValue + err = k.UpdateAVSTotalValue(ctx, avs, opUsdValue) + if err != nil { + return err + } + } + return nil +} + +type AssetPriceAndDecimal struct { + Price sdkmath.Int + PriceDecimal uint8 + Decimal uint32 } // OptIn call this function to opt in AVS -func (k Keeper) OptIn(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error { +func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { + //check optedIn info + if k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { + return types.ErrAlreadyOptedIn + } + + //get the Assets opted in the operator + operatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress) + if err != nil { + return err + } + //get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + if err != nil { + return err + } + totalAssetUsdValue := sdkmath.LegacyNewDec(0) + assetFilter := make(map[string]interface{}) + assetInfoRecord := make(map[string]*AssetPriceAndDecimal) + + for _, assetId := range avsSupportedAssets { + operatorAssetState, ok := operatorAssetsState[assetId] + if !ok { + continue + } + //get price and priceDecimal from oracle + price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) + if err != nil { + return err + } + + //get the decimal of asset + assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) + if err != nil { + return err + } + assetInfoRecord[assetId] = &AssetPriceAndDecimal{ + Price: price, + PriceDecimal: decimal, + Decimal: assetInfo.AssetBasicInfo.Decimals, + } + + //assetValue = (amount*price*10^UsdValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) + assetValue := operatorAssetState.TotalAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) + assetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(types.UsdValueDefaultDecimal)) + + //UpdateOperatorAVSAssetsState + changeState := types.AssetOptedInState{ + Amount: operatorAssetState.TotalAmountOrWantChangeValue, + Value: assetUsdValue, + } + err = k.UpdateOperatorAVSAssetsState(ctx, assetId, AVSAddr, operatorAddress.String(), changeState) + if err != nil { + return err + } + totalAssetUsdValue = totalAssetUsdValue.Add(assetUsdValue) + assetFilter[assetId] = nil + } + + //UpdateAVSTotalValue + err = k.UpdateAVSTotalValue(ctx, AVSAddr, totalAssetUsdValue) + if err != nil { + return err + } + //UpdateAVSOperatorTotalValue + err = k.UpdateAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String(), totalAssetUsdValue) + if err != nil { + return err + } + + //UpdateAVSOperatorStakerShareValue + relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetFilter) + if err != nil { + return err + } + for stakerId, assetState := range relatedAssetsState { + stakerAssetsUsdValue := sdkmath.LegacyNewDec(0) + for assetId, amount := range assetState { + singleAssetValue := amount.Mul(assetInfoRecord[assetId].Price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfoRecord[assetId].Decimal)+int(assetInfoRecord[assetId].PriceDecimal))) + singleAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(singleAssetValue.BigInt(), int64(types.UsdValueDefaultDecimal)) + stakerAssetsUsdValue = stakerAssetsUsdValue.Add(singleAssetUsdValue) + } + + err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, stakerId, operatorAddress.String(), stakerAssetsUsdValue) + if err != nil { + return err + } + } + + //update opted-in info + slashContract, err := k.avsKeeper.GetAvsSlashContract(ctx, AVSAddr) + if err != nil { + return err + } + optedInfo := &types.OptedInfo{ + SlashContract: slashContract, + OptedInHeight: uint64(ctx.BlockHeight()), + OptedOutHeight: types.DefaultOptedOutHeight, + } + err = k.UpdateOptedInfo(ctx, operatorAddress.String(), AVSAddr, optedInfo) + if err != nil { + return err + } return nil } // OptOut call this function to opt out of AVS func (k Keeper) OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error { - return nil } diff --git a/x/operator/types/errors.go b/x/operator/types/errors.go index 522303fba..e11446567 100644 --- a/x/operator/types/errors.go +++ b/x/operator/types/errors.go @@ -10,4 +10,10 @@ var ( ErrSlashInfo = errorsmod.Register(ModuleName, 2, "there is an error in the field of slash info") ErrSlashInfoExist = errorsmod.Register(ModuleName, 3, "the slash info exists") + + ErrParameterInvalid = errorsmod.Register(ModuleName, 4, "the input parameter is invalid") + + ErrAlreadyOptedIn = errorsmod.Register(ModuleName, 5, "the operator has already opted in the avs") + + ErrNotOptedIn = errorsmod.Register(ModuleName, 6, "the operator hasn't opted in the avs") ) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 27409903f..2def590e1 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -6,9 +6,14 @@ import ( ) type ExpectDelegationInterface interface { - GetDelegationStateByOperator(ctx sdk.Context, operatorAddr string) (map[string]sdkmath.Int, error) + GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]sdkmath.Int, error) } type ExpectOracleInterface interface { GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdkmath.Int, uint8, error) } + +type ExpectAvsInterface interface { + GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) ([]string, error) + GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) +} diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 9ba2cb627..b44a3690c 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -18,6 +18,8 @@ const ( RouterKey = ModuleName DefaultOptedOutHeight = uint64(math.MaxUint64) + + UsdValueDefaultDecimal = uint8(8) ) // ModuleAddress is the native module address for EVM diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 4b1ef44f4..7d9fa272c 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -258,7 +258,7 @@ func (m *OptedInfo) GetOptedOutHeight() uint64 { type AssetOptedInState struct { Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=Amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"Amount"` - Value github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=Value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"Value"` + Value github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=Value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"Value"` } func (m *AssetOptedInState) Reset() { *m = AssetOptedInState{} } @@ -294,6 +294,43 @@ func (m *AssetOptedInState) XXX_DiscardUnknown() { var xxx_messageInfo_AssetOptedInState proto.InternalMessageInfo +type ValueField struct { + Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=Amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"Amount"` +} + +func (m *ValueField) Reset() { *m = ValueField{} } +func (m *ValueField) String() string { return proto.CompactTextString(m) } +func (*ValueField) ProtoMessage() {} +func (*ValueField) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{5} +} +func (m *ValueField) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValueField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValueField.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 *ValueField) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValueField.Merge(m, src) +} +func (m *ValueField) XXX_Size() int { + return m.Size() +} +func (m *ValueField) XXX_DiscardUnknown() { + xxx_messageInfo_ValueField.DiscardUnknown(m) +} + +var xxx_messageInfo_ValueField proto.InternalMessageInfo + type OperatorSlashInfo struct { SlashContract string `protobuf:"bytes,1,opt,name=SlashContract,proto3" json:"SlashContract,omitempty"` SlashHeight uint64 `protobuf:"varint,2,opt,name=SlashHeight,proto3" json:"SlashHeight,omitempty"` @@ -305,7 +342,7 @@ func (m *OperatorSlashInfo) Reset() { *m = OperatorSlashInfo{} } func (m *OperatorSlashInfo) String() string { return proto.CompactTextString(m) } func (*OperatorSlashInfo) ProtoMessage() {} func (*OperatorSlashInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{5} + return fileDescriptor_b229d5663e4df167, []int{6} } func (m *OperatorSlashInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -364,7 +401,7 @@ func (m *RegisterOperatorReq) Reset() { *m = RegisterOperatorReq{} } func (m *RegisterOperatorReq) String() string { return proto.CompactTextString(m) } func (*RegisterOperatorReq) ProtoMessage() {} func (*RegisterOperatorReq) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{6} + return fileDescriptor_b229d5663e4df167, []int{7} } func (m *RegisterOperatorReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -400,7 +437,7 @@ func (m *RegisterOperatorResponse) Reset() { *m = RegisterOperatorRespon func (m *RegisterOperatorResponse) String() string { return proto.CompactTextString(m) } func (*RegisterOperatorResponse) ProtoMessage() {} func (*RegisterOperatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{7} + return fileDescriptor_b229d5663e4df167, []int{8} } func (m *RegisterOperatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -435,6 +472,7 @@ func init() { proto.RegisterType((*OperatorInfo)(nil), "exocore.operator.v1.OperatorInfo") proto.RegisterType((*OptedInfo)(nil), "exocore.operator.v1.OptedInfo") proto.RegisterType((*AssetOptedInState)(nil), "exocore.operator.v1.AssetOptedInState") + proto.RegisterType((*ValueField)(nil), "exocore.operator.v1.ValueField") proto.RegisterType((*OperatorSlashInfo)(nil), "exocore.operator.v1.OperatorSlashInfo") proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.operator.v1.RegisterOperatorReq") proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.operator.v1.RegisterOperatorResponse") @@ -443,50 +481,51 @@ func init() { func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 682 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4d, 0x4f, 0x13, 0x41, - 0x18, 0xee, 0xd0, 0x42, 0xc2, 0x5b, 0x14, 0x18, 0x88, 0xd4, 0xc6, 0xb4, 0x75, 0x35, 0xa4, 0x69, - 0xd2, 0x6e, 0xc0, 0x8f, 0x03, 0xd1, 0x43, 0x29, 0x18, 0x9b, 0x48, 0x30, 0x8b, 0x31, 0xd1, 0x8b, - 0x59, 0xb6, 0xc3, 0x76, 0x43, 0x77, 0x66, 0x9d, 0x99, 0x62, 0xf1, 0xa0, 0xc6, 0x93, 0xf1, 0xe4, - 0x4f, 0xe0, 0x27, 0x70, 0xe0, 0xaa, 0x67, 0x8e, 0x84, 0x93, 0xf1, 0x40, 0x0c, 0x1c, 0xd0, 0xf8, - 0x27, 0xcc, 0xce, 0x4e, 0xc3, 0xb6, 0x94, 0x44, 0xe2, 0xa5, 0xed, 0x3c, 0xef, 0xf3, 0x3e, 0xef, - 0xe7, 0x74, 0xe0, 0x06, 0xe9, 0x30, 0x87, 0x71, 0x62, 0xb2, 0x80, 0x70, 0x5b, 0x32, 0x6e, 0x6e, - 0xcd, 0x99, 0xb2, 0x53, 0x09, 0x38, 0x93, 0x0c, 0x4f, 0x69, 0x6b, 0xa5, 0x6b, 0xad, 0x6c, 0xcd, - 0x65, 0x67, 0x1c, 0x26, 0x7c, 0x26, 0x4c, 0x5f, 0xb8, 0x21, 0xd9, 0x17, 0x6e, 0xc4, 0xce, 0x5e, - 0x8f, 0x0c, 0xaf, 0xd4, 0xc9, 0x8c, 0x0e, 0xda, 0x34, 0xed, 0x32, 0x97, 0x45, 0x78, 0xf8, 0x4b, - 0xa3, 0x93, 0xb6, 0xef, 0x51, 0x66, 0xaa, 0xcf, 0x08, 0x32, 0xde, 0x40, 0xd6, 0x69, 0x79, 0x84, - 0xca, 0x5a, 0xd3, 0xf6, 0xe8, 0xb2, 0xcd, 0xa9, 0x47, 0xdd, 0x6a, 0xa3, 0xc1, 0x9f, 0x78, 0x42, - 0xe2, 0x17, 0x30, 0xae, 0xa1, 0x3a, 0xdd, 0x60, 0x21, 0x94, 0x41, 0x85, 0x64, 0x31, 0x3d, 0x6f, - 0x56, 0x06, 0x64, 0x5a, 0x19, 0xac, 0x14, 0xba, 0x5a, 0xfd, 0x3a, 0xc6, 0xbb, 0x8b, 0x02, 0x87, - 0x0c, 0x5c, 0x84, 0xf1, 0xd6, 0xdb, 0xda, 0x99, 0xbd, 0xde, 0xc8, 0xa0, 0x02, 0x2a, 0xa6, 0xac, - 0x7e, 0x18, 0xdf, 0x87, 0x6b, 0x83, 0x75, 0x32, 0x43, 0x05, 0x54, 0x1c, 0xb5, 0x2e, 0xb0, 0x1a, - 0x7f, 0x10, 0x8c, 0xad, 0xea, 0xdc, 0x55, 0x48, 0x03, 0xc6, 0xb4, 0x5d, 0x28, 0x77, 0xa4, 0xdc, - 0x7b, 0x30, 0x5c, 0x80, 0x74, 0x35, 0x08, 0x38, 0xdb, 0x22, 0xb1, 0x08, 0x71, 0x08, 0x97, 0x60, - 0xa2, 0xab, 0xba, 0x42, 0xa4, 0x1d, 0x2a, 0x67, 0x92, 0x8a, 0x76, 0x0e, 0xc7, 0x1e, 0xcc, 0xd4, - 0xce, 0x25, 0x17, 0x05, 0x4f, 0x15, 0xd0, 0x25, 0xbb, 0x1c, 0x36, 0xd5, 0xba, 0x48, 0xcf, 0x78, - 0x0f, 0xa3, 0xab, 0x81, 0x24, 0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0xb8, 0x9e, 0x90, 0x84, - 0x77, 0x6b, 0xb6, 0xc8, 0x6b, 0xbc, 0x00, 0xe9, 0x47, 0x9c, 0xf9, 0xe1, 0x42, 0x11, 0x21, 0xf4, - 0xc8, 0x32, 0x87, 0x7b, 0xe5, 0x69, 0xad, 0xa6, 0x2d, 0x6b, 0x92, 0x7b, 0xd4, 0xb5, 0xe2, 0x64, - 0x7c, 0x0f, 0x52, 0x5e, 0x78, 0x17, 0x86, 0xd4, 0x62, 0xdf, 0x1c, 0xb8, 0xd8, 0xf1, 0xeb, 0x68, - 0x29, 0xfa, 0xc2, 0xdd, 0x4f, 0x3b, 0xf9, 0xc4, 0xaf, 0x9d, 0x7c, 0xe2, 0xe3, 0xe9, 0x6e, 0x29, - 0x2e, 0xf8, 0xf9, 0x74, 0xb7, 0x34, 0x13, 0x2b, 0x2e, 0xee, 0x6b, 0x64, 0x21, 0x73, 0x3e, 0x7f, - 0x11, 0x30, 0x2a, 0xc8, 0xfc, 0x36, 0x24, 0x57, 0x84, 0x8b, 0x37, 0x61, 0xa2, 0x9f, 0x82, 0x8b, - 0x03, 0xb3, 0x1a, 0xd0, 0x89, 0x6c, 0xf9, 0x1f, 0x99, 0x51, 0xcc, 0xec, 0xf0, 0x87, 0xd3, 0xdd, - 0x12, 0x5a, 0x7c, 0xb8, 0x7f, 0x9c, 0x43, 0x07, 0xc7, 0x39, 0xf4, 0xf3, 0x38, 0x87, 0xbe, 0x9c, - 0xe4, 0x12, 0x07, 0x27, 0xb9, 0xc4, 0xf7, 0x93, 0x5c, 0xe2, 0xe5, 0xad, 0xd8, 0xe0, 0xba, 0x0f, - 0x44, 0xe7, 0xec, 0x89, 0x50, 0x93, 0x5b, 0x1f, 0x51, 0xff, 0xd8, 0x77, 0xfe, 0x06, 0x00, 0x00, - 0xff, 0xff, 0xbb, 0x14, 0x0c, 0x66, 0x43, 0x06, 0x00, 0x00, + // 699 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00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0xbe, 0x53, 0xa9, 0xd7, 0xd9, + 0x53, 0x97, 0x0b, 0xfc, 0x12, 0xc6, 0x15, 0x54, 0xf3, 0x37, 0x69, 0x08, 0x65, 0x50, 0x21, 0x59, + 0x4c, 0xcf, 0x1b, 0xfa, 0x80, 0x4c, 0xf5, 0xc1, 0x4a, 0xa1, 0xab, 0xd9, 0xab, 0xa3, 0xbd, 0xbf, + 0x28, 0x70, 0xc8, 0xc0, 0x45, 0x18, 0x6f, 0xbe, 0xab, 0x9e, 0xdb, 0x6b, 0xf5, 0x0c, 0x2a, 0xa0, + 0x62, 0xca, 0xec, 0x85, 0xf1, 0x43, 0xb8, 0x31, 0x58, 0x27, 0x33, 0x54, 0x40, 0xc5, 0x51, 0xf3, + 0x02, 0xab, 0xf6, 0x17, 0xc1, 0xd8, 0x9a, 0xca, 0x5d, 0x86, 0xd4, 0x60, 0x4c, 0xd9, 0xb9, 0x74, + 0x47, 0xd2, 0xbd, 0x0b, 0xc3, 0x05, 0x48, 0x57, 0x82, 0x80, 0xd1, 0x6d, 0x12, 0x8b, 0x10, 0x87, + 0x70, 0x09, 0x26, 0x3a, 0xaa, 0xab, 0x44, 0x58, 0xa1, 0x72, 0x26, 0x29, 0x69, 0x7d, 0x38, 0x76, + 0x61, 0xa6, 0xda, 0x97, 0x5c, 0x14, 0x3c, 0x55, 0x40, 0x97, 0xbc, 0xe5, 0xf0, 0x52, 0xcd, 0x8b, + 0xf4, 0xb4, 0x0f, 0x30, 0xba, 0x16, 0x08, 0x52, 0x97, 0x71, 0xef, 0xc2, 0xb5, 0xf5, 0xa6, 0xc5, + 0x1b, 0x55, 0xea, 0x0b, 0x66, 0xd9, 0x42, 0x95, 0xda, 0x0d, 0x86, 0x2c, 0xe5, 0xf2, 0x84, 0xb8, + 0x4e, 0x43, 0xc8, 0x6a, 0x53, 0x66, 0x37, 0x88, 0x67, 0xe1, 0xba, 0x04, 0xd6, 0x5a, 0x42, 0xd1, + 0x92, 0x92, 0xd6, 0x83,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e, 0x98, 0xeb, 0x3b, 0x66, + 0x9c, 0x8c, 0x1f, 0x40, 0xca, 0x0d, 0xf7, 0x6d, 0x48, 0x2e, 0xcf, 0xed, 0x81, 0xcb, 0x13, 0x5f, + 0x79, 0x53, 0xd2, 0x17, 0xee, 0x7f, 0xde, 0xcd, 0x27, 0x7e, 0xef, 0xe6, 0x13, 0x9f, 0xce, 0xf6, + 0x4a, 0x71, 0xc1, 0x2f, 0x67, 0x7b, 0xa5, 0x99, 0x58, 0x71, 0x71, 0x5f, 0x2d, 0x0b, 0x99, 0xfe, + 0xfc, 0x79, 0x40, 0x7d, 0x4e, 0xe6, 0x77, 0x20, 0xb9, 0xca, 0x1d, 0xbc, 0x05, 0x13, 0xbd, 0x14, + 0x5c, 0x1c, 0x98, 0xd5, 0x80, 0x9b, 0xc8, 0x96, 0xff, 0x93, 0x19, 0xc5, 0xcc, 0x0e, 0x7f, 0x3c, + 0xdb, 0x2b, 0xa1, 0xc5, 0xc7, 0x07, 0x27, 0x39, 0x74, 0x78, 0x92, 0x43, 0xbf, 0x4e, 0x72, 0xe8, + 0xeb, 0x69, 0x2e, 0x71, 0x78, 0x9a, 0x4b, 0xfc, 0x38, 0xcd, 0x25, 0x5e, 0xdd, 0x89, 0x35, 0xae, + 0xf3, 0x08, 0xb5, 0xcf, 0x9f, 0x21, 0xd9, 0xb9, 0x8d, 0x11, 0xf9, 0x2a, 0xdc, 0xfb, 0x17, 0x00, + 0x00, 0xff, 0xff, 0x6e, 0xf7, 0xba, 0x8d, 0xa7, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -782,6 +821,39 @@ func (m *AssetOptedInState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ValueField) 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 *ValueField) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValueField) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *OperatorSlashInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -996,6 +1068,17 @@ func (m *AssetOptedInState) Size() (n int) { return n } +func (m *ValueField) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + func (m *OperatorSlashInfo) Size() (n int) { if m == nil { return 0 @@ -1654,6 +1737,90 @@ func (m *AssetOptedInState) Unmarshal(dAtA []byte) error { } return nil } +func (m *ValueField) 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 ErrIntOverflowTx + } + 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: ValueField: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValueField: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index 8d0655ff8..d506ebe40 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -55,9 +55,9 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnAmountOrWantChangeValue: math.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: math.NewInt(0), + TotalAmountOrWantChangeValue: math.NewInt(0), + OperatorOwnAmountOrWantChangeValue: math.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -73,7 +73,7 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.WaitUnbondingAmountOrWantChangeValue, &changeAmount.WaitUnbondingAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") } @@ -83,9 +83,3 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre store.Set(key, bz) return nil } - -// GetOperatorAssetOptedInMiddleWare This function should be implemented in the operator opt-in module -func (k Keeper) GetOperatorAssetOptedInMiddleWare(operatorAddr sdk.Address, assetId string) (middleWares []sdk.Address, err error) { - //TODO implement me - panic("implement me") -} diff --git a/x/restaking_assets_manage/keeper/staker_asset.go b/x/restaking_assets_manage/keeper/staker_asset.go index 85f8857be..60f3fc1f0 100644 --- a/x/restaking_assets_manage/keeper/staker_asset.go +++ b/x/restaking_assets_manage/keeper/staker_asset.go @@ -52,9 +52,9 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerId string, assetId store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) key := restakingtype.GetJoinedStoreKey(stakerId, assetId) assetState := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(0), - CanWithdrawAmountOrWantChangeValue: math.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: math.NewInt(0), + TotalDepositAmountOrWantChangeValue: math.NewInt(0), + CanWithdrawAmountOrWantChangeValue: math.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -70,7 +70,7 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerId string, assetId if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) + err = restakingtype.UpdateAssetValue(&assetState.WaitUnbondingAmountOrWantChangeValue, &changeAmount.WaitUnbondingAmountOrWantChangeValue) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go index cab5cfb63..afecde49a 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/restaking_assets_manage/types/general.go @@ -83,3 +83,23 @@ func UpdateAssetValue(valueToUpdate *math.Int, changeValue *math.Int) error { } return nil } + +// UpdateAssetDecValue It's used to update asset state,negative or positive `changeValue` represents a decrease or increase in the asset state +// newValue = valueToUpdate + changeVale +func UpdateAssetDecValue(valueToUpdate *math.LegacyDec, changeValue *math.LegacyDec) error { + if valueToUpdate == nil || changeValue == nil { + return errorsmod.Wrap(ErrInputPointerIsNil, fmt.Sprintf("valueToUpdate:%v,changeValue:%v", valueToUpdate, changeValue)) + } + + if !changeValue.IsNil() { + if changeValue.IsNegative() { + if valueToUpdate.LT(changeValue.Neg()) { + return errorsmod.Wrap(ErrSubAmountIsMoreThanOrigin, fmt.Sprintf("valueToUpdate:%s,changeValue:%s", *valueToUpdate, *changeValue)) + } + } + if !changeValue.IsZero() { + *valueToUpdate = valueToUpdate.Add(*changeValue) + } + } + return nil +} diff --git a/x/restaking_assets_manage/types/keys.go b/x/restaking_assets_manage/types/keys.go index d5266c079..a7834fba4 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/restaking_assets_manage/types/keys.go @@ -110,6 +110,11 @@ func GetJoinedStoreKey(keys ...string) []byte { return []byte(strings.Join(keys, "/")) } +func ParseJoinedKey(key []byte) (keys []string, err error) { + stringList := strings.Split(string(key), "/") + return stringList, nil +} + func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { stringList := strings.Split(string(key), "/") if len(stringList) != number { diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index 4556778dd..0d1c74fcf 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -308,9 +308,9 @@ func (m *StakingAssetInfo) GetAssetBasicInfo() *ClientChainTokenInfo { } type StakerSingleAssetOrChangeInfo struct { - TotalDepositAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=TotalDepositAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalDepositAmountOrWantChangeValue"` - CanWithdrawAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=CanWithdrawAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanWithdrawAmountOrWantChangeValue"` - WaitUndelegationAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUndelegationAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUndelegationAmountOrWantChangeValue"` + TotalDepositAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=TotalDepositAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalDepositAmountOrWantChangeValue"` + CanWithdrawAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=CanWithdrawAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanWithdrawAmountOrWantChangeValue"` + WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` } func (m *StakerSingleAssetOrChangeInfo) Reset() { *m = StakerSingleAssetOrChangeInfo{} } @@ -393,8 +393,8 @@ func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetO type OperatorSingleAssetOrChangeInfo struct { TotalAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=TotalAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalAmountOrWantChangeValue"` // todo: the field is used to mark operator's own assets and is not temporarily used now - OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` - WaitUndelegationAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUndelegationAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUndelegationAmountOrWantChangeValue"` + OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` + WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` } func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleAssetOrChangeInfo{} } @@ -571,72 +571,71 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1028 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0xc5, - 0x1b, 0xf6, 0xda, 0xf9, 0xfb, 0x46, 0x69, 0x93, 0x69, 0x7e, 0xfd, 0x39, 0xa6, 0x38, 0xd1, 0x82, - 0xc0, 0x0a, 0xc4, 0x56, 0x8d, 0xa8, 0xa2, 0x08, 0x90, 0x1c, 0xa7, 0x95, 0x22, 0x92, 0x5a, 0x5a, - 0x07, 0x22, 0x7a, 0x20, 0x4c, 0xec, 0xb7, 0xeb, 0x95, 0x77, 0x67, 0xac, 0x9d, 0x71, 0x6a, 0xdf, - 0x2a, 0x84, 0x10, 0x42, 0x08, 0xc1, 0x05, 0x0e, 0x5c, 0xfa, 0x11, 0x72, 0xe8, 0x87, 0xe8, 0x81, - 0x43, 0xd5, 0x0b, 0x81, 0x43, 0x85, 0x92, 0x43, 0xf8, 0x18, 0x68, 0x67, 0x77, 0x93, 0x75, 0x6c, - 0x37, 0x5b, 0x48, 0x25, 0x2e, 0xc9, 0xce, 0x33, 0xef, 0xbf, 0x7d, 0xde, 0xe7, 0xdd, 0x19, 0xc3, - 0x3b, 0xd8, 0xe1, 0x35, 0xee, 0x62, 0xc1, 0x45, 0x21, 0x69, 0xd3, 0x62, 0xe6, 0x2e, 0x15, 0x02, - 0xa5, 0xd8, 0x75, 0x28, 0xa3, 0x26, 0x16, 0xf6, 0x6f, 0x16, 0x64, 0x27, 0xdf, 0x72, 0xb9, 0xe4, - 0x44, 0x0f, 0x8c, 0xf3, 0x43, 0x8c, 0xf3, 0xfb, 0x37, 0x33, 0xff, 0xaf, 0x71, 0xe1, 0x70, 0x51, - 0x70, 0x84, 0xe9, 0xf9, 0x3a, 0xc2, 0xf4, 0x9d, 0x33, 0xf3, 0xfe, 0xc6, 0xae, 0x5a, 0x15, 0xfc, - 0x45, 0xb0, 0x35, 0x67, 0x72, 0x93, 0xfb, 0xb8, 0xf7, 0x14, 0xa0, 0xb3, 0xd4, 0xb1, 0x18, 0x2f, - 0xa8, 0xbf, 0x3e, 0xa4, 0xef, 0x01, 0x7c, 0x4a, 0xed, 0x36, 0xde, 0xb1, 0xd0, 0xae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40, 0x03, 0x45, 0x8b, 0x33, 0x81, 0xc5, 0x5f, 0x34, 0x48, 0x6d, 0x09, 0xd3, 0x1b, 0xe0, - 0xb9, 0x2a, 0x4a, 0x3f, 0x7d, 0xb4, 0x03, 0xef, 0xc7, 0xe9, 0x73, 0x5f, 0xfc, 0xcc, 0x87, 0xff, - 0xc8, 0x2d, 0x2c, 0x2b, 0x33, 0xfa, 0xf0, 0xe4, 0x60, 0x49, 0x5b, 0xdb, 0x7c, 0x72, 0x94, 0xd5, - 0x9e, 0x1e, 0x65, 0xb5, 0x3f, 0x8f, 0xb2, 0xda, 0x0f, 0xc7, 0xd9, 0xc4, 0xd3, 0xe3, 0x6c, 0xe2, - 0xf0, 0x38, 0x9b, 0xb8, 0x57, 0x8c, 0xcc, 0x69, 0xf8, 0xea, 0x9d, 0xa1, 0xbf, 0x60, 0xd4, 0xdc, - 0xee, 0x8d, 0xa9, 0x5f, 0x10, 0xef, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x79, 0x39, 0x86, 0x06, - 0xf1, 0x0c, 0x00, 0x00, + // 1024 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0xda, 0xf9, 0x7c, 0xad, 0xb4, 0xc9, 0x34, 0x14, 0xc7, 0x14, 0x3b, 0x5a, 0x2a, 0x64, + 0x05, 0x62, 0xab, 0x46, 0x54, 0x51, 0x04, 0x48, 0x8e, 0xd3, 0x4a, 0x11, 0x49, 0x2d, 0xad, 0x03, + 0x11, 0x3d, 0x10, 0xc6, 0xf6, 0x74, 0xbd, 0xf2, 0xee, 0x8c, 0xb5, 0x33, 0x4e, 0xed, 0x5b, 0x85, + 0x10, 0x42, 0x08, 0xa1, 0x72, 0xe2, 0xc0, 0xa5, 0x3f, 0x21, 0x87, 0xfe, 0x06, 0xd4, 0x63, 0x95, +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0x89, 0xdd, + 0x2f, 0x86, 0x86, 0x34, 0x78, 0xf5, 0xee, 0xc8, 0x5f, 0x2d, 0x72, 0x68, 0x6b, 0x13, 0xf2, 0x57, + 0xc3, 0x47, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xc3, 0x36, 0x0c, 0xe5, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -963,9 +962,9 @@ func (m *StakerSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l { - size := m.WaitUndelegationAmountOrWantChangeValue.Size() + size := m.WaitUnbondingAmountOrWantChangeValue.Size() i -= size - if _, err := m.WaitUndelegationAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1065,9 +1064,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int var l int _ = l { - size := m.WaitUndelegationAmountOrWantChangeValue.Size() + size := m.WaitUnbondingAmountOrWantChangeValue.Size() i -= size - if _, err := m.WaitUndelegationAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1344,7 +1343,7 @@ func (m *StakerSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.CanWithdrawAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUndelegationAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1381,7 +1380,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.OperatorOwnAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUndelegationAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -2264,7 +2263,7 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUndelegationAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmountOrWantChangeValue", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2292,7 +2291,7 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUndelegationAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.WaitUnbondingAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2595,7 +2594,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUndelegationAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmountOrWantChangeValue", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2623,7 +2622,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUndelegationAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.WaitUnbondingAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From abf43f11d1ffb69741fc62e0882742659ed2e713 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 23 Jan 2024 11:09:51 +0800 Subject: [PATCH 06/44] add opt-out function --- .../keeper/avs_operator_assets_state.go | 32 +++++++- x/operator/keeper/keeper.go | 9 +-- ..._op.go => state_update_for_external_op.go} | 74 ++++++++++++++++++- x/operator/types/errors.go | 2 + 4 files changed, 110 insertions(+), 7 deletions(-) rename x/operator/keeper/{sate_update_for_external_op.go => state_update_for_external_op.go} (73%) diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index 1da962765..28390e24f 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -36,6 +36,18 @@ func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAd return nil } +func (k Keeper) DeleteAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + var key []byte + if operatorAddr == "" { + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateAVSOperatorTotalValue the operatorAddr is empty") + } else { + key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + } + store.Delete(key) + return nil +} + func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.ValueField @@ -91,7 +103,6 @@ func (k Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.Legac func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - if changeState.Amount.IsNil() && changeState.Value.IsNil() { return nil } @@ -127,6 +138,18 @@ func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, return nil } +func (k Keeper) DeleteOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) + //check operator address validation + _, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return restakingtype.OperatorAddrIsNotAccAddr + } + stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) + store.Delete(stateKey) + return nil +} + func (k Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) @@ -162,6 +185,13 @@ func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stak return nil } +func (k Keeper) DeleteAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) + key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) + store.Delete(key) + return nil +} + func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) var ret operatortypes.ValueField diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 1f6d36aab..c4b746470 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -53,13 +54,11 @@ type IOperator interface { GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 - OptIn(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error + UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error - OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error - - IncreasedOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string) error + OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error - DecreaseOptedInAssets(ctx sdk.Context, stakerId, assetId, operatorAddr string) error + OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error SlashOperator() diff --git a/x/operator/keeper/sate_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go similarity index 73% rename from x/operator/keeper/sate_update_for_external_op.go rename to x/operator/keeper/state_update_for_external_op.go index 15fd66a58..e5a24f313 100644 --- a/x/operator/keeper/sate_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -1,7 +1,9 @@ package keeper import ( + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/exocore/x/operator/types" ) @@ -175,6 +177,76 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s } // OptOut call this function to opt out of AVS -func (k Keeper) OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error { +func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { + //check optedIn info + if !k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { + return types.ErrNotOptedIn + } + + //get the Assets opted in the operator + operatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress) + if err != nil { + return err + } + //get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + if err != nil { + return err + } + assetFilter := make(map[string]interface{}) + + for _, assetId := range avsSupportedAssets { + _, ok := operatorAssetsState[assetId] + if !ok { + continue + } + err = k.DeleteOperatorAVSAssetsState(ctx, assetId, AVSAddr, operatorAddress.String()) + if err != nil { + return err + } + assetFilter[assetId] = nil + } + + avsOperatorTotalValue, err := k.GetAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String()) + if err != nil { + return err + } + if avsOperatorTotalValue.IsNegative() { + return errorsmod.Wrap(types.ErrTheValueIsNegative, fmt.Sprintf("OptOut,avsOperatorTotalValue:%s", avsOperatorTotalValue)) + } + + //UpdateAVSTotalValue + err = k.UpdateAVSTotalValue(ctx, AVSAddr, avsOperatorTotalValue.Neg()) + if err != nil { + return err + } + //DeleteAVSOperatorTotalValue + err = k.DeleteAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String()) + if err != nil { + return err + } + + //DeleteAVSOperatorStakerShareValue + relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetFilter) + if err != nil { + return err + } + for stakerId := range relatedAssetsState { + err = k.DeleteAVSOperatorStakerShareValue(ctx, AVSAddr, stakerId, operatorAddress.String()) + if err != nil { + return err + } + } + + //set opted-out height + optedInfo, err := k.GetOptedInfo(ctx, operatorAddress.String(), AVSAddr) + if err != nil { + return err + } + optedInfo.OptedOutHeight = uint64(ctx.BlockHeight()) + err = k.UpdateOptedInfo(ctx, operatorAddress.String(), AVSAddr, optedInfo) + if err != nil { + return err + } return nil } diff --git a/x/operator/types/errors.go b/x/operator/types/errors.go index e11446567..3b1db3248 100644 --- a/x/operator/types/errors.go +++ b/x/operator/types/errors.go @@ -16,4 +16,6 @@ var ( ErrAlreadyOptedIn = errorsmod.Register(ModuleName, 5, "the operator has already opted in the avs") ErrNotOptedIn = errorsmod.Register(ModuleName, 6, "the operator hasn't opted in the avs") + + ErrTheValueIsNegative = errorsmod.Register(ModuleName, 7, "the value is negative") ) From ed545b3e06d565abcc6cddfddc56ff54ec113658 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 24 Jan 2024 17:02:39 +0800 Subject: [PATCH 07/44] update opt-out function --- proto/exocore/delegation/v1/query.proto | 6 + proto/exocore/operator/v1/tx.proto | 8 +- .../restaking_assets_manage/v1/tx.proto | 6 + x/delegation/keeper/cross_chain_tx_process.go | 1 + x/delegation/keeper/delegation_state.go | 5 + x/delegation/types/query.pb.go | 122 ++++++++---- x/operator/keeper/operator_slash_state.go | 17 +- .../keeper/state_update_for_external_op.go | 134 ++++++++++--- x/operator/types/errors.go | 4 + x/operator/types/expected_keepers.go | 2 +- x/operator/types/keys.go | 4 +- x/operator/types/tx.pb.go | 186 +++++++++++++----- .../keeper/operator_asset.go | 5 + x/restaking_assets_manage/types/keys.go | 4 - x/restaking_assets_manage/types/tx.pb.go | 175 ++++++++++------ 15 files changed, 483 insertions(+), 196 deletions(-) diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index f3e183887..193cc1e72 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -27,6 +27,12 @@ message DelegationAmounts{ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; + string TotalDelegationAmount = 3 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message QueryDelegationInfoResponse{ diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 86ce37733..016bc61ac 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -57,9 +57,11 @@ message ValueField { message OperatorSlashInfo { string SlashContract = 1; - uint64 SlashHeight = 2; - uint64 ExecuteHeight = 3; - string SlashProportion = 4 + int64 SlashHeight = 2; + int64 OccurredHeight = 3; + int64 ExecuteHeight = 4; + bool IsVeto = 5; + string SlashProportion = 6 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index e78bdca9a..0e04cd48f 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -99,6 +99,12 @@ message OperatorSingleAssetOrChangeInfo{ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; + string OperatorOwnWaitUnbondingAmount =4 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message OperatorAllAssetsInfo { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index a375c2837..7a616524f 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -157,6 +157,7 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ CanUndelegationAmount: params.OpAmount, + TotalDelegationAmount: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) if err != nil { diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 8d1eb2a57..b21730ec6 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -92,6 +92,11 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } + err = stakingtypes.UpdateAssetValue(&delegationState.TotalDelegationAmount, &amounts.TotalDelegationAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateDelegationState TotalDelegationAmount error") + } + //save single operator delegation state bz := k.cdc.MustMarshal(&delegationState) store.Set(singleStateKey, bz) diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index 2974b7345..eb7c2fbd3 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -87,6 +87,7 @@ func (m *DelegationInfoReq) GetAssetId() string { type DelegationAmounts struct { CanUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=CanUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanUndelegationAmount"` WaitUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=WaitUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUndelegationAmount"` + TotalDelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=TotalDelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalDelegationAmount"` } func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } @@ -238,43 +239,44 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 570 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x41, - 0x1c, 0xcd, 0x6c, 0xa8, 0x7f, 0xa6, 0x82, 0x3a, 0xa6, 0x9a, 0x6e, 0x65, 0x5b, 0x17, 0x94, 0x50, - 0xc8, 0xae, 0x5d, 0x11, 0x44, 0xaa, 0xd2, 0xaa, 0x94, 0x3d, 0xba, 0x55, 0x04, 0x2f, 0x32, 0xcd, - 0x8e, 0xeb, 0x92, 0xcd, 0xcc, 0x66, 0x66, 0x12, 0x92, 0xab, 0x27, 0x2f,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, 0x7a, 0x45, 0x85, 0x3a, 0x3e, 0x26, 0x42, 0x6c, - 0x4a, 0x1e, 0xd2, 0xc0, 0x9b, 0x62, 0x4f, 0x8e, 0x40, 0x79, 0x6a, 0x04, 0x9c, 0x9f, 0x1a, 0x9c, - 0x49, 0x32, 0x44, 0x1f, 0x01, 0xbc, 0x94, 0x93, 0x26, 0xfa, 0xff, 0x33, 0x95, 0x7f, 0xdd, 0x39, - 0x7e, 0x8d, 0xcc, 0xdb, 0x6f, 0x7f, 0x7c, 0x5a, 0x06, 0x6f, 0x3e, 0x7f, 0xff, 0xa0, 0x2d, 0xa3, - 0x9a, 0x9d, 0x3f, 0xfb, 0x1b, 0x44, 0x66, 0x4c, 0x0d, 0x00, 0x9c, 0x4f, 0x64, 0xf3, 0xb2, 0x44, - 0x56, 0x81, 0x91, 0x82, 0xe0, 0xf5, 0x23, 0x57, 0xd2, 0xbc, 0x77, 0x68, 0xd7, 0x41, 0x37, 0x0b, - 0xec, 0x16, 0x1a, 0x5b, 0x7f, 0xb0, 0x3d, 0x34, 0xc0, 0xce, 0xd0, 0x00, 0xdf, 0x86, 0x06, 0x78, - 0x3f, 0x32, 0x4a, 0x3b, 0x23, 0xa3, 0xf4, 0x65, 0x64, 0x94, 0x5e, 0x5c, 0x9f, 0x18, 0xa2, 0x7d, - 0xd5, 0xde, 0xa4, 0x6e, 0x32, 0x47, 0x5b, 0xa7, 0x92, 0x6f, 0xe0, 0xad, 0x3f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x8d, 0x43, 0x76, 0xff, 0xcb, 0x05, 0x00, 0x00, + // 582 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6b, 0xd4, 0x4e, + 0x1c, 0xdd, 0x64, 0xe9, 0xff, 0xaf, 0x53, 0x41, 0x1d, 0xb7, 0x9a, 0xa6, 0x92, 0xd6, 0x80, 0xb2, + 0x14, 0x36, 0xb1, 0x2b, 0x82, 0x48, 0x55, 0x5a, 0x95, 0x92, 0xa3, 0xa9, 0x22, 0x78, 0x91, 0xe9, + 0x66, 0x8c, 0x61, 0xb3, 0x33, 0xd9, 0x99, 0xd9, 0x65, 0xf7, 0xea, 0xc9, 0x8b, 0x20, 0xf8, 0x2d, + 0x3c, 0x79, 0xd8, 0x0f, 0xd1, 0x63, 0xa9, 0x17, 0xf1, 0x50, 0x64, 0x57, 0xf0, 0xe0, 0x45, 0xbf, + 0x81, 0x6c, 0x32, 0x6d, 0x77, 0xe3, 0x44, 0x2d, 0xec, 0x29, 0x99, 0xbc, 0x97, 0x37, 0xef, 0xf7, + 0xe6, 0xf7, 0x1b, 0x70, 0x05, 0xf7, 0x68, 0x83, 0x32, 0xec, 0x06, 0x38, 0xc6, 0x21, 0x12, 0x11, + 0x25, 0x6e, 0x77, 0xcd, 0x6d, 0x77, 0x30, 0xeb, 0x3b, 0x09, 0xa3, 0x82, 0xc2, 0x05, 0x49, 0x71, + 0x8e, 0x29, 0x4e, 0x77, 0xcd, 0xac, 0x84, 0x34, 0xa4, 0x29, 0xc3, 0x1d, 0xbf, 0x65, 0x64, 0xf3, + 0x72, 0x48, 0x69, 0x18, 0x63, 0x17, 0x25, 0x91, 0x8b, 0x08, 0xa1, 0x22, 0xe5, 0x73, 0x89, 0x2e, + 0x35, 0x28, 0x6f, 0x51, 0x9e, 0xc9, 0xe7, 0xf6, 0x31, 0x17, 0x33, 0xf0, 0x79, 0xa6, 0x99, 0x2d, + 0x24, 0x64, 0xa9, 0x5d, 0x8a, 0x5e, 0x86, 0xdb, 0x1e, 0x38, 0xff, 0xe0, 0x08, 0xf1, 0xc8, 0x0b, + 0xea, 0xe3, 0x36, 0x34, 0xc1, 0x29, 0x2e, 0x50, 0x13, 0x33, 0x2f, 0x30, 0xb4, 0x15, 0xad, 0x7a, + 0xda, 0x3f, 0x5a, 0x43, 0x03, 0xfc, 0x8f, 0x38, 0xc7, 0xc2, 0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 0x8b, 0xfd, 0xec, 0xb7, 0xdb, 0xfa, 0x2d, 0xcd, 0x7e, 0xa3, 0x81, 0x4b, 0xdb, 0x11, 0x09, 0x63, + 0x7c, 0xb2, 0xc1, 0x59, 0x07, 0x67, 0x68, 0x82, 0x19, 0x12, 0x94, 0x6d, 0x04, 0x01, 0x93, 0xad, + 0x68, 0xec, 0x0f, 0x6a, 0x15, 0x19, 0xea, 0xf8, 0x33, 0xe6, 0x7c, 0x5b, 0xb0, 0x88, 0x84, 0xfe, + 0x14, 0x7b, 0x72, 0xec, 0xca, 0x53, 0x63, 0x57, 0xff, 0xae, 0x83, 0xb9, 0x34, 0x43, 0xf8, 0x5e, + 0x03, 0x17, 0x14, 0x69, 0xc2, 0xbf, 0x97, 0x29, 0xfd, 0x9b, 0xf5, 0x93, 0x9f, 0x91, 0x7d, 0xf3, + 0xf5, 0xb7, 0x0f, 0xab, 0xda, 0xab, 0x8f, 0x5f, 0xdf, 0xe9, 0xab, 0xb0, 0xea, 0xaa, 0xef, 0x9b, + 0x2d, 0x2c, 0x72, 0xa6, 0x06, 0x1a, 0x58, 0x4c, 0x65, 0x55, 0x59, 0x42, 0xa7, 0xc0, 0x48, 0x41, + 0xf0, 0xe6, 0x3f, 0x9f, 0xa4, 0x7d, 0xe7, 0xd8, 0x6e, 0x1d, 0x5e, 0x2f, 0xb0, 0x5b, 0x68, 0x6c, + 0xf3, 0xde, 0xee, 0xd0, 0xd2, 0xf6, 0x86, 0x96, 0xf6, 0x65, 0x68, 0x69, 0x6f, 0x47, 0x56, 0x69, + 0x6f, 0x64, 0x95, 0x3e, 0x8d, 0xac, 0xd2, 0xb3, 0xab, 0x13, 0x43, 0x74, 0xa8, 0xda, 0x9b, 0xd4, + 0x4d, 0xe7, 0x68, 0xe7, 0xbf, 0xf4, 0xde, 0xbd, 0xf1, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x17, 0x72, + 0x2f, 0x14, 0x3f, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -452,6 +454,16 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TotalDelegationAmount.Size() + i -= size + if _, err := m.TotalDelegationAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size := m.WaitUndelegationAmount.Size() i -= size @@ -616,6 +628,8 @@ func (m *DelegationAmounts) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) l = m.WaitUndelegationAmount.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.TotalDelegationAmount.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -881,6 +895,40 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalDelegationAmount", 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.TotalDelegationAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 5315b5224..123954ace 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -11,7 +11,7 @@ import ( restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) -func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashProofTxId string, slashInfo operatortypes.OperatorSlashInfo) error { +func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashId string, slashInfo operatortypes.OperatorSlashInfo) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) //check operator address validation @@ -19,7 +19,7 @@ func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, if err != nil { return restakingtype.OperatorAddrIsNotAccAddr } - slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashProofTxId) + slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashId) if store.Has(slashInfoKey) { return errorsmod.Wrap(operatortypes.ErrSlashInfoExist, fmt.Sprintf("slashInfoKey:%s", slashInfoKey)) } @@ -27,13 +27,8 @@ func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, if slashInfo.SlashContract == "" { return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err slashContract:%s", slashInfo.SlashContract)) } - - curHeight := ctx.BlockHeight() - if slashInfo.SlashHeight > uint64(curHeight) { - return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,curHeight:%v", slashInfo.SlashHeight, curHeight)) - } - if slashInfo.SlashHeight > slashInfo.ExecuteHeight { - return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,ExecuteHeight:%v", slashInfo.SlashHeight, slashInfo.ExecuteHeight)) + if slashInfo.OccurredHeight > slashInfo.SlashHeight { + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,OccurredHeight:%v", slashInfo.SlashHeight, slashInfo.OccurredHeight)) } if slashInfo.SlashProportion.IsNil() || slashInfo.SlashProportion.IsNegative() || slashInfo.SlashProportion.GT(sdkmath.LegacyNewDec(1)) { @@ -46,9 +41,9 @@ func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, return nil } -func (k Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashProofTxId string) (changeState *operatortypes.OperatorSlashInfo, err error) { +func (k Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashId string) (changeState *operatortypes.OperatorSlashInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) - slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashProofTxId) + slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashId) isExit := store.Has(slashInfoKey) operatorSlashInfo := operatortypes.OperatorSlashInfo{} if isExit { diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index e5a24f313..4b4276088 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -31,32 +31,40 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope opUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(value.BigInt(), int64(types.UsdValueDefaultDecimal)) for _, avs := range avsList { - //UpdateAVSOperatorStakerShareValue - err = k.UpdateAVSOperatorStakerShareValue(ctx, avs, stakerId, operatorAddr, opUsdValue) + //get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avs) if err != nil { return err } - //UpdateOperatorAVSAssetsState - changeState := types.AssetOptedInState{ - Amount: opAmount, - Value: opUsdValue, - } - err = k.UpdateOperatorAVSAssetsState(ctx, assetId, avs, operatorAddr, changeState) - if err != nil { - return err - } + if _, ok := avsSupportedAssets[assetId]; ok { + //UpdateAVSOperatorStakerShareValue + err = k.UpdateAVSOperatorStakerShareValue(ctx, avs, stakerId, operatorAddr, opUsdValue) + if err != nil { + return err + } - //UpdateAVSOperatorTotalValue - err = k.UpdateAVSOperatorTotalValue(ctx, avs, operatorAddr, opUsdValue) - if err != nil { - return err - } + //UpdateOperatorAVSAssetsState + changeState := types.AssetOptedInState{ + Amount: opAmount, + Value: opUsdValue, + } + err = k.UpdateOperatorAVSAssetsState(ctx, assetId, avs, operatorAddr, changeState) + if err != nil { + return err + } - //UpdateAVSTotalValue - err = k.UpdateAVSTotalValue(ctx, avs, opUsdValue) - if err != nil { - return err + //UpdateAVSOperatorTotalValue + err = k.UpdateAVSOperatorTotalValue(ctx, avs, operatorAddr, opUsdValue) + if err != nil { + return err + } + + //UpdateAVSTotalValue + err = k.UpdateAVSTotalValue(ctx, avs, opUsdValue) + if err != nil { + return err + } } } return nil @@ -86,10 +94,11 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s return err } totalAssetUsdValue := sdkmath.LegacyNewDec(0) + operatorOwnAssetUsdValue := sdkmath.LegacyNewDec(0) assetFilter := make(map[string]interface{}) assetInfoRecord := make(map[string]*AssetPriceAndDecimal) - for _, assetId := range avsSupportedAssets { + for assetId := range avsSupportedAssets { operatorAssetState, ok := operatorAssetsState[assetId] if !ok { continue @@ -115,6 +124,9 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s assetValue := operatorAssetState.TotalAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) assetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(types.UsdValueDefaultDecimal)) + operatorOwnAssetValue := operatorAssetState.OperatorOwnAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) + operatorOwnAssetUsdValue = operatorOwnAssetUsdValue.Add(sdkmath.LegacyNewDecFromBigIntWithPrec(operatorOwnAssetValue.BigInt(), int64(types.UsdValueDefaultDecimal))) + //UpdateOperatorAVSAssetsState changeState := types.AssetOptedInState{ Amount: operatorAssetState.TotalAmountOrWantChangeValue, @@ -128,6 +140,12 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s assetFilter[assetId] = nil } + //update the share value of operator itself, the input stakerId should be empty + err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUsdValue) + if err != nil { + return err + } + //UpdateAVSTotalValue err = k.UpdateAVSTotalValue(ctx, AVSAddr, totalAssetUsdValue) if err != nil { @@ -195,7 +213,7 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } assetFilter := make(map[string]interface{}) - for _, assetId := range avsSupportedAssets { + for assetId := range avsSupportedAssets { _, ok := operatorAssetsState[assetId] if !ok { continue @@ -215,6 +233,12 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return errorsmod.Wrap(types.ErrTheValueIsNegative, fmt.Sprintf("OptOut,avsOperatorTotalValue:%s", avsOperatorTotalValue)) } + //delete the share value of operator itself, the input stakerId should be empty + err = k.DeleteAVSOperatorStakerShareValue(ctx, AVSAddr, "", operatorAddress.String()) + if err != nil { + return err + } + //UpdateAVSTotalValue err = k.UpdateAVSTotalValue(ctx, AVSAddr, avsOperatorTotalValue.Neg()) if err != nil { @@ -250,3 +274,69 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } return nil } + +type SlashAssetsAndAmount struct { + slashFromStakerUnbonding map[string]map[string]sdkmath.Int + slashFromStakerOptedIn map[string]map[string]sdkmath.Int + + slashFromOperatorUnbonding map[string]sdkmath.Int + slashFromOperatorOptedIn map[string]sdkmath.Int +} + +// GetAssetsAndAmountToSlash It will slash the assets that have been undelegated but still locked first, and if there isn't enough to slash, then it will slash the assets that are opting into AVS. +func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { + ret := SlashAssetsAndAmount{ + slashFromStakerUnbonding: make(map[string]map[string]sdkmath.Int, 0), + slashFromStakerOptedIn: make(map[string]map[string]sdkmath.Int, 0), + slashFromOperatorUnbonding: make(map[string]sdkmath.Int, 0), + slashFromOperatorOptedIn: make(map[string]sdkmath.Int, 0), + } + +} + +func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredHeight int64, slashProportion sdkmath.LegacyDec) error { + height := ctx.BlockHeight() + if occurredHeight > height { + return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("occurredHeight:%d,curHeight:%d", occurredHeight, height)) + } + + //get the state when the slash occurred + //get the opted-in info + ctx = ctx.WithBlockHeight(occurredHeight) + optedInfo, err := k.GetOptedInfo(ctx, operatorAddress.String(), AVSAddr) + if err != nil { + return err + } + // reset context height + ctx = ctx.WithBlockHeight(height) + + if optedInfo.SlashContract != slashContract { + return errorsmod.Wrap(types.ErrSlashContractNotMatch, fmt.Sprintf("input slashContract:%s, opted-in slash contract:%s", slashContract, optedInfo.SlashContract)) + } + + //todo: recording the slash event might be moved to the slash module + slashInfo := types.OperatorSlashInfo{ + SlashContract: slashContract, + SlashHeight: height, + OccurredHeight: occurredHeight, + SlashProportion: slashProportion, + ExecuteHeight: height + types.SlashVetoDuration, + } + err = k.UpdateOperatorSlashInfo(ctx, operatorAddress.String(), AVSAddr, slashId, slashInfo) + if err != nil { + return err + } + + // get the assets and amounts that should be slashed + assetsSlashInfo, err := k.GetAssetsAndAmountToSlash(ctx, operatorAddress, AVSAddr, occurredHeight, slashProportion) + if err != nil { + return err + } + + // update delegation assets state + + // update staker assets state + + // update opted-in state + +} diff --git a/x/operator/types/errors.go b/x/operator/types/errors.go index 3b1db3248..830c705f9 100644 --- a/x/operator/types/errors.go +++ b/x/operator/types/errors.go @@ -18,4 +18,8 @@ var ( ErrNotOptedIn = errorsmod.Register(ModuleName, 6, "the operator hasn't opted in the avs") ErrTheValueIsNegative = errorsmod.Register(ModuleName, 7, "the value is negative") + + ErrSlashContractNotMatch = errorsmod.Register(ModuleName, 8, "the slash contract isn't the slash contract address saved in the opted-in info") + + ErrSlashOccurredHeight = errorsmod.Register(ModuleName, 9, "the occurred height of slash event is error") ) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 2def590e1..a5a689279 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -14,6 +14,6 @@ type ExpectOracleInterface interface { } type ExpectAvsInterface interface { - GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) ([]string, error) + GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) } diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index b44a3690c..ae8b65760 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -20,6 +20,8 @@ const ( DefaultOptedOutHeight = uint64(math.MaxUint64) UsdValueDefaultDecimal = uint8(8) + + SlashVetoDuration = int64(1000) ) // ModuleAddress is the native module address for EVM @@ -68,7 +70,7 @@ var ( KeyPrefixAVSOperatorStakerShareState = []byte{prefixOperatorAVSStakerShareState} // KeyPrefixOperatorSlashInfo key-value: - // operator + '/' + AVSAddr + '/' + slashProofTxId -> OperatorSlashInfo + // operator + '/' + AVSAddr + '/' + slashId -> OperatorSlashInfo KeyPrefixOperatorSlashInfo = []byte{prefixOperatorSlashInfo} // KeyPrefixSlashAssetsState key-value: diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 7d9fa272c..bcc356eba 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -333,9 +333,11 @@ var xxx_messageInfo_ValueField proto.InternalMessageInfo type OperatorSlashInfo struct { SlashContract string `protobuf:"bytes,1,opt,name=SlashContract,proto3" json:"SlashContract,omitempty"` - SlashHeight uint64 `protobuf:"varint,2,opt,name=SlashHeight,proto3" json:"SlashHeight,omitempty"` - ExecuteHeight uint64 `protobuf:"varint,3,opt,name=ExecuteHeight,proto3" json:"ExecuteHeight,omitempty"` - SlashProportion github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=SlashProportion,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"SlashProportion"` + SlashHeight int64 `protobuf:"varint,2,opt,name=SlashHeight,proto3" json:"SlashHeight,omitempty"` + OccurredHeight int64 `protobuf:"varint,3,opt,name=OccurredHeight,proto3" json:"OccurredHeight,omitempty"` + ExecuteHeight int64 `protobuf:"varint,4,opt,name=ExecuteHeight,proto3" json:"ExecuteHeight,omitempty"` + IsVeto bool `protobuf:"varint,5,opt,name=IsVeto,proto3" json:"IsVeto,omitempty"` + SlashProportion github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=SlashProportion,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"SlashProportion"` } func (m *OperatorSlashInfo) Reset() { *m = OperatorSlashInfo{} } @@ -378,20 +380,34 @@ func (m *OperatorSlashInfo) GetSlashContract() string { return "" } -func (m *OperatorSlashInfo) GetSlashHeight() uint64 { +func (m *OperatorSlashInfo) GetSlashHeight() int64 { if m != nil { return m.SlashHeight } return 0 } -func (m *OperatorSlashInfo) GetExecuteHeight() uint64 { +func (m *OperatorSlashInfo) GetOccurredHeight() int64 { + if m != nil { + return m.OccurredHeight + } + return 0 +} + +func (m *OperatorSlashInfo) GetExecuteHeight() int64 { if m != nil { return m.ExecuteHeight } return 0 } +func (m *OperatorSlashInfo) GetIsVeto() bool { + if m != nil { + return m.IsVeto + } + return false +} + type RegisterOperatorReq struct { FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` Info *OperatorInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` @@ -481,51 +497,53 @@ func init() { func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 699 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x4f, 0x13, 0x41, - 0x14, 0xef, 0xd0, 0x42, 0xc2, 0x2b, 0x0a, 0x0c, 0x44, 0x6a, 0x63, 0xda, 0xba, 0x1a, 0xd2, 0x34, - 0xe9, 0x6e, 0xc0, 0x3f, 0x07, 0xa2, 0x87, 0x52, 0x20, 0x36, 0x91, 0x60, 0x16, 0x63, 0xa2, 0x17, - 0xb3, 0x6c, 0x87, 0xed, 0x86, 0xee, 0xce, 0x3a, 0x33, 0xc5, 0xe2, 0x41, 0x8d, 0x27, 0xe3, 0xc9, - 0x8f, 0xc0, 0x47, 0xe0, 0xc0, 0x55, 0xcf, 0x1c, 0x09, 0x27, 0xe3, 0x81, 0x18, 0x38, 0xa0, 0xf1, - 0x4b, 0x98, 0x9d, 0x9d, 0x86, 0xed, 0x1f, 0x12, 0x09, 0x97, 0x76, 0xe7, 0xf7, 0x7e, 0xef, 0xf7, - 0xde, 0x9b, 0xf7, 0x5e, 0x06, 0x6e, 0x91, 0x36, 0xb5, 0x29, 0x23, 0x06, 0x0d, 0x08, 0xb3, 0x04, - 0x65, 0xc6, 0xf6, 0x9c, 0x21, 0xda, 0x7a, 0xc0, 0xa8, 0xa0, 0x78, 0x4a, 0x59, 0xf5, 0x8e, 0x55, - 0xdf, 0x9e, 0xcb, 0xce, 0xd8, 0x94, 0x7b, 0x94, 0x1b, 0x1e, 0x77, 0x42, 0xb2, 0xc7, 0x9d, 0x88, - 0x9d, 0xbd, 0x19, 0x19, 0x5e, 0xcb, 0x93, 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0xec, 0x15, 0xd5, 0xbe, 0x23, 0x98, 0x32, 0x89, 0xe3, 0x72, - 0x41, 0x58, 0xa7, 0x66, 0x93, 0xbc, 0xc1, 0x0b, 0x90, 0x5e, 0x61, 0xd4, 0x0b, 0x87, 0x96, 0x70, - 0xae, 0xae, 0x37, 0x73, 0xb4, 0x5f, 0x9e, 0x56, 0x6a, 0xca, 0xb2, 0x2e, 0x98, 0xeb, 0x3b, 0x66, - 0x9c, 0x8c, 0x1f, 0x40, 0xca, 0x0d, 0xf7, 0x6d, 0x48, 0x2e, 0xcf, 0xed, 0x81, 0xcb, 0x13, 0x5f, - 0x79, 0x53, 0xd2, 0x17, 0xee, 0x7f, 0xde, 0xcd, 0x27, 0x7e, 0xef, 0xe6, 0x13, 0x9f, 0xce, 0xf6, - 0x4a, 0x71, 0xc1, 0x2f, 0x67, 0x7b, 0xa5, 0x99, 0x58, 0x71, 0x71, 0x5f, 0x2d, 0x0b, 0x99, 0xfe, - 0xfc, 0x79, 0x40, 0x7d, 0x4e, 0xe6, 0x77, 0x20, 0xb9, 0xca, 0x1d, 0xbc, 0x05, 0x13, 0xbd, 0x14, - 0x5c, 0x1c, 0x98, 0xd5, 0x80, 0x9b, 0xc8, 0x96, 0xff, 0x93, 0x19, 0xc5, 0xcc, 0x0e, 0x7f, 0x3c, - 0xdb, 0x2b, 0xa1, 0xc5, 0xc7, 0x07, 0x27, 0x39, 0x74, 0x78, 0x92, 0x43, 0xbf, 0x4e, 0x72, 0xe8, - 0xeb, 0x69, 0x2e, 0x71, 0x78, 0x9a, 0x4b, 0xfc, 0x38, 0xcd, 0x25, 0x5e, 0xdd, 0x89, 0x35, 0xae, - 0xf3, 0x08, 0xb5, 0xcf, 0x9f, 0x21, 0xd9, 0xb9, 0x8d, 0x11, 0xf9, 0x2a, 0xdc, 0xfb, 0x17, 0x00, - 0x00, 0xff, 0xff, 0x6e, 0xf7, 0xba, 0x8d, 0xa7, 0x06, 0x00, 0x00, + // 734 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x4f, 0x13, 0x4f, + 0x14, 0xef, 0xd2, 0xd2, 0x7c, 0x79, 0xe5, 0x2b, 0x30, 0x10, 0x58, 0x1b, 0xd3, 0xd6, 0xd5, 0x90, + 0xa6, 0x49, 0xbb, 0x01, 0x7f, 0x1c, 0x88, 0x1e, 0x4a, 0x81, 0xd8, 0x44, 0x82, 0x19, 0x0c, 0x89, + 0x5e, 0xcc, 0xb2, 0x1d, 0xb6, 0x1b, 0xda, 0x9d, 0x75, 0x66, 0x8a, 0xc5, 0x83, 0x1a, 0x4f, 0xc6, + 0x93, 0x7f, 0x02, 0x57, 0x6f, 0x1c, 0xb8, 0xea, 0x99, 0x23, 0xe1, 0x64, 0x3c, 0x10, 0x03, 0x07, + 0x4c, 0xfc, 0x27, 0xcc, 0xce, 0x4e, 0xc3, 0xf6, 0x07, 0x89, 0x44, 0x2f, 0xb0, 0xf3, 0x79, 0x9f, + 0xf7, 0x79, 0x6f, 0xde, 0x67, 0xa6, 0x03, 0x37, 0x48, 0x9b, 0xda, 0x94, 0x11, 0x93, 0xfa, 0x84, + 0x59, 0x82, 0x32, 0x73, 0x67, 0xce, 0x14, 0xed, 0x92, 0xcf, 0xa8, 0xa0, 0x68, 0x52, 0x45, 0x4b, + 0x9d, 0x68, 0x69, 0x67, 0x2e, 0x3d, 0x63, 0x53, 0xde, 0xa4, 0xdc, 0x6c, 0x72, 0x27, 0x20, 0x37, + 0xb9, 0x13, 0xb2, 0xd3, 0xd7, 0xc3, 0xc0, 0x0b, 0xb9, 0x32, 0xc3, 0x85, 0x0a, 0x4d, 0x39, 0xd4, + 0xa1, 0x21, 0x1e, 0x7c, 0x29, 0x74, 0xc2, 0x6a, 0xba, 0x1e, 0x35, 0xe5, 0xdf, 0x10, 0x32, 0x5e, + 0x41, 0xda, 0x6e, 0xb8, 0xc4, 0x13, 0x95, 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0x0e, 0xcc, 0xe7, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -883,10 +901,25 @@ func (m *OperatorSlashInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 + if m.IsVeto { + i-- + if m.IsVeto { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } if m.ExecuteHeight != 0 { i = encodeVarintTx(dAtA, i, uint64(m.ExecuteHeight)) i-- + dAtA[i] = 0x20 + } + if m.OccurredHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OccurredHeight)) + i-- dAtA[i] = 0x18 } if m.SlashHeight != 0 { @@ -1092,9 +1125,15 @@ func (m *OperatorSlashInfo) Size() (n int) { if m.SlashHeight != 0 { n += 1 + sovTx(uint64(m.SlashHeight)) } + if m.OccurredHeight != 0 { + n += 1 + sovTx(uint64(m.OccurredHeight)) + } if m.ExecuteHeight != 0 { n += 1 + sovTx(uint64(m.ExecuteHeight)) } + if m.IsVeto { + n += 2 + } l = m.SlashProportion.Size() n += 1 + l + sovTx(uint64(l)) return n @@ -1896,12 +1935,31 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashHeight |= uint64(b&0x7F) << shift + m.SlashHeight |= int64(b&0x7F) << shift if b < 0x80 { break } } case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OccurredHeight", wireType) + } + m.OccurredHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OccurredHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ExecuteHeight", wireType) } @@ -1915,12 +1973,32 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExecuteHeight |= uint64(b&0x7F) << shift + m.ExecuteHeight |= int64(b&0x7F) << shift if b < 0x80 { break } } - case 4: + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsVeto", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsVeto = bool(v != 0) + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashProportion", wireType) } diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index d506ebe40..ea694d360 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -58,6 +58,7 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre TotalAmountOrWantChangeValue: math.NewInt(0), OperatorOwnAmountOrWantChangeValue: math.NewInt(0), WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), + OperatorOwnWaitUnbondingAmount: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -77,6 +78,10 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") } + err = restakingtype.UpdateAssetValue(&assetState.OperatorOwnWaitUnbondingAmount, &changeAmount.OperatorOwnWaitUnbondingAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") + } //store the updated state bz := k.cdc.MustMarshal(&assetState) diff --git a/x/restaking_assets_manage/types/keys.go b/x/restaking_assets_manage/types/keys.go index a7834fba4..b00558220 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/restaking_assets_manage/types/keys.go @@ -94,10 +94,6 @@ var ( // or operatorAddr->mapping(AssetId->OperatorSingleAssetInfo) ? 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} diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index 0d1c74fcf..96aafe831 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -395,6 +395,7 @@ type OperatorSingleAssetOrChangeInfo struct { // todo: the field is used to mark operator's own assets and is not temporarily used now OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` + OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=OperatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnWaitUnbondingAmount"` } func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleAssetOrChangeInfo{} } @@ -571,71 +572,73 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1024 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0xda, 0xf9, 0x7c, 0xad, 0xb4, 0xc9, 0x34, 0x14, 0xc7, 0x14, 0x3b, 0x5a, 0x2a, 0x64, + // 1042 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xda, 0xf9, 0xfb, 0xac, 0xb4, 0xc9, 0x34, 0x14, 0xc7, 0x14, 0x3b, 0x5a, 0x2a, 0x64, 0x05, 0x62, 0xab, 0x46, 0x54, 0x51, 0x04, 0x48, 0x8e, 0xd3, 0x4a, 0x11, 0x49, 0x2d, 0xad, 0x03, 0x11, 0x3d, 0x10, 0xc6, 0xf6, 0x74, 0xbd, 0xf2, 0xee, 0x8c, 0xb5, 0x33, 0x4e, 0xed, 0x5b, 0x85, - 0x10, 0x42, 0x08, 0xa1, 0x72, 0xe2, 0xc0, 0xa5, 0x3f, 0x21, 0x87, 0xfe, 0x06, 0xd4, 0x63, 0x95, - 0x0b, 0x85, 0x43, 0x85, 0x92, 0x43, 0xf8, 0x19, 0x68, 0x67, 0x76, 0x93, 0x75, 0x6c, 0x37, 0x5b, - 0x48, 0xa4, 0x5e, 0x92, 0x9d, 0x67, 0xde, 0xaf, 0x7d, 0xde, 0xe7, 0xdd, 0x19, 0xc3, 0x07, 0xa4, - 0xcb, 0xea, 0xcc, 0x25, 0x05, 0x97, 0x70, 0x81, 0x5b, 0x16, 0x35, 0x77, 0x31, 0xe7, 0x44, 0xf0, - 0x5d, 0x07, 0x53,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 0x69, 0x89, 0x5c, 0xb2, 0xf8, 0x79, 0x14, 0xf1, 0x0e, 0x09, 0x98, 0x2f, 0xf5, 0x45, 0xbb, - 0x43, 0x85, 0xdb, 0x33, 0xce, 0xa4, 0x48, 0x7f, 0xa7, 0xc1, 0xb5, 0x21, 0x76, 0x68, 0x16, 0x12, - 0x2d, 0xd2, 0xf3, 0xbf, 0x4f, 0xde, 0x23, 0xda, 0x81, 0xf1, 0xbd, 0x93, 0xd6, 0x25, 0x8b, 0xa5, - 0xe8, 0x55, 0x8d, 0xd0, 0xae, 0xa1, 0xe2, 0xad, 0xc6, 0x57, 0x34, 0xfd, 0xf7, 0x04, 0x64, 0x2b, - 0x6d, 0xe2, 0x62, 0xc1, 0x46, 0x4a, 0xfd, 0x91, 0x06, 0x37, 0x42, 0xc3, 0x71, 0x39, 0x1a, 0x7f, - 0x65, 0x06, 0x29, 0xee, 0xa0, 0xcc, 0xca, 0x43, 0x7a, 0xa9, 0xe2, 0x3e, 0x3f, 0xcf, 0x9b, 0x28, - 0xee, 0x5f, 0xe3, 0xf0, 0x56, 0x50, 0x79, 0xbf, 0xbc, 0x3b, 0x23, 0xe4, 0xbd, 0x15, 0x45, 0x48, - 0x43, 0x43, 0x46, 0x12, 0xf8, 0xf7, 0x91, 0x05, 0xfe, 0x55, 0xbf, 0xc0, 0xcb, 0xaf, 0x53, 0x57, - 0x04, 0x89, 0xff, 0x11, 0x87, 0xb9, 0x2d, 0x6e, 0x56, 0x89, 0xf0, 0x8f, 0x3c, 0xef, 0x14, 0x47, - 0xab, 0x90, 0x7c, 0xe0, 0x32, 0x27, 0x38, 0xe0, 0x95, 0x84, 0x53, 0x07, 0x4f, 0x97, 0xe7, 0x7d, - 0xea, 0xfd, 0x9d, 0xaa, 0x70, 0x2d, 0x6a, 0x1a, 0x61, 0x63, 0xb4, 0x02, 0xc0, 0x89, 0x08, 0x5c, - 0xe3, 0xe7, 0xb8, 0x86, 0x6c, 0x51, 0x0e, 0xae, 0xd6, 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 0x87, 0x19, 0xed, 0xd9, + 0x61, 0x46, 0xfb, 0xe7, 0x30, 0xa3, 0x3d, 0x3a, 0xca, 0xc4, 0x9e, 0x1d, 0x65, 0x62, 0xcf, 0x8f, + 0x32, 0xb1, 0xbb, 0xc5, 0x50, 0x7b, 0x06, 0xaf, 0xde, 0x1d, 0xf9, 0xf1, 0x24, 0xdb, 0xb5, 0x36, + 0x21, 0x3f, 0x5e, 0x3e, 0xf9, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xa5, 0x20, 0xec, 0x56, 0x6c, 0x0d, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1063,6 +1066,16 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l + { + size := m.OperatorOwnWaitUnbondingAmount.Size() + i -= size + if _, err := m.OperatorOwnWaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 { size := m.WaitUnbondingAmountOrWantChangeValue.Size() i -= size @@ -1382,6 +1395,8 @@ func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.WaitUnbondingAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) + l = m.OperatorOwnWaitUnbondingAmount.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -2626,6 +2641,40 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnWaitUnbondingAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OperatorOwnWaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 7b198d9e17ce242955ee6ef3fc17146d99f5a996 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Thu, 25 Jan 2024 16:53:42 +0800 Subject: [PATCH 08/44] update slash function --- proto/exocore/delegation/v1/query.proto | 2 +- .../restaking_assets_manage/v1/tx.proto | 7 + x/delegation/keeper/cross_chain_tx_process.go | 6 +- x/delegation/keeper/delegation_state.go | 9 +- x/delegation/types/query.pb.go | 93 ++++----- x/operator/keeper/operator_slash_state.go | 28 ++- .../keeper/state_update_for_external_op.go | 107 +++++++++- x/operator/types/expected_keepers.go | 2 + x/operator/types/keys.go | 1 + .../keeper/operator_asset.go | 13 +- x/restaking_assets_manage/types/tx.pb.go | 188 +++++++++++------- 11 files changed, 315 insertions(+), 141 deletions(-) diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index 193cc1e72..eff199a6f 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -27,7 +27,7 @@ message DelegationAmounts{ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string TotalDelegationAmount = 3 + string CanUndelegateAmountAfterSlash = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index 0e04cd48f..a0605bead 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -105,6 +105,13 @@ message OperatorSingleAssetOrChangeInfo{ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; + + string OperatorOwnCanUnbondingAmountAfterSlash =5 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message OperatorAllAssetsInfo { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 7a616524f..27818135f 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -157,7 +157,6 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ CanUndelegationAmount: params.OpAmount, - TotalDelegationAmount: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) if err != nil { @@ -217,8 +216,9 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation //update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegationAmount: params.OpAmount.Neg(), - WaitUndelegationAmount: params.OpAmount, + CanUndelegationAmount: params.OpAmount.Neg(), + WaitUndelegationAmount: params.OpAmount, + CanUndelegateAmountAfterSlash: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) if err != nil { diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index b21730ec6..00201a20b 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -73,8 +73,9 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId } singleStateKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId, opAddr) delegationState := delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), + CanUndelegationAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + CanUndelegateAmountAfterSlash: sdkmath.NewInt(0), } if store.Has(singleStateKey) { @@ -92,9 +93,9 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } - err = stakingtypes.UpdateAssetValue(&delegationState.TotalDelegationAmount, &amounts.TotalDelegationAmount) + err = stakingtypes.UpdateAssetValue(&delegationState.CanUndelegateAmountAfterSlash, &amounts.CanUndelegateAmountAfterSlash) if err != nil { - return errorsmod.Wrap(err, "UpdateDelegationState TotalDelegationAmount error") + return errorsmod.Wrap(err, "UpdateDelegationState CanUsedToUndelegateAmount error") } //save single operator delegation state diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index eb7c2fbd3..007201c8f 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -85,9 +85,9 @@ func (m *DelegationInfoReq) GetAssetId() string { } type DelegationAmounts struct { - CanUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=CanUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanUndelegationAmount"` - WaitUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=WaitUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUndelegationAmount"` - TotalDelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=TotalDelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalDelegationAmount"` + CanUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=CanUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanUndelegationAmount"` + WaitUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=WaitUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUndelegationAmount"` + CanUndelegateAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=CanUndelegateAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanUndelegateAmountAfterSlash"` } func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } @@ -239,44 +239,45 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 582 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6b, 0xd4, 0x4e, - 0x1c, 0xdd, 0x64, 0xe9, 0xff, 0xaf, 0x53, 0x41, 0x1d, 0xb7, 0x9a, 0xa6, 0x92, 0xd6, 0x80, 0xb2, - 0x14, 0x36, 0xb1, 0x2b, 0x82, 0x48, 0x55, 0x5a, 0x95, 0x92, 0xa3, 0xa9, 0x22, 0x78, 0x91, 0xe9, - 0x66, 0x8c, 0x61, 0xb3, 0x33, 0xd9, 0x99, 0xd9, 0x65, 0xf7, 0xea, 0xc9, 0x8b, 0x20, 0xf8, 0x2d, - 0x3c, 0x79, 0xd8, 0x0f, 0xd1, 0x63, 0xa9, 0x17, 0xf1, 0x50, 0x64, 0x57, 0xf0, 0xe0, 0x45, 0xbf, - 0x81, 0x6c, 0x32, 0x6d, 0x77, 0xe3, 0x44, 0x2d, 0xec, 0x29, 0x99, 0xbc, 0x97, 0x37, 0xef, 0xf7, - 0xe6, 0xf7, 0x1b, 0x70, 0x05, 0xf7, 0x68, 0x83, 0x32, 0xec, 0x06, 0x38, 0xc6, 0x21, 0x12, 0x11, - 0x25, 0x6e, 0x77, 0xcd, 0x6d, 0x77, 0x30, 0xeb, 0x3b, 0x09, 0xa3, 0x82, 0xc2, 0x05, 0x49, 0x71, - 0x8e, 0x29, 0x4e, 0x77, 0xcd, 0xac, 0x84, 0x34, 0xa4, 0x29, 0xc3, 0x1d, 0xbf, 0x65, 0x64, 0xf3, - 0x72, 0x48, 0x69, 0x18, 0x63, 0x17, 0x25, 0x91, 0x8b, 0x08, 0xa1, 0x22, 0xe5, 0x73, 0x89, 0x2e, - 0x35, 0x28, 0x6f, 0x51, 0x9e, 0xc9, 0xe7, 0xf6, 0x31, 0x17, 0x33, 0xf0, 0x79, 0xa6, 0x99, 0x2d, - 0x24, 0x64, 0xa9, 0x5d, 0x8a, 0x5e, 0x86, 0xdb, 0x1e, 0x38, 0xff, 0xe0, 0x08, 0xf1, 0xc8, 0x0b, - 0xea, 0xe3, 0x36, 0x34, 0xc1, 0x29, 0x2e, 0x50, 0x13, 0x33, 0x2f, 0x30, 0xb4, 0x15, 0xad, 0x7a, - 0xda, 0x3f, 0x5a, 0x43, 0x03, 0xfc, 0x8f, 0x38, 0xc7, 0xc2, 0x0b, 0x0c, 0x3d, 0x85, 0x0e, 0x97, - 0xf6, 0x4f, 0x7d, 0x52, 0x6b, 0xa3, 0x45, 0x3b, 0x44, 0x70, 0xc8, 0xc0, 0xc2, 0x7d, 0x44, 0x9e, - 0x90, 0x20, 0x87, 0x64, 0xc2, 0x9b, 0xeb, 0xbb, 0x07, 0xcb, 0xa5, 0xcf, 0x07, 0xcb, 0xd7, 0xc2, - 0x48, 0xbc, 0xec, 0xec, 0x38, 0x0d, 0xda, 0x92, 0x05, 0xc8, 0x47, 0x8d, 0x07, 0x4d, 0x57, 0xf4, - 0x13, 0xcc, 0x1d, 0x8f, 0x88, 0xfd, 0x41, 0x0d, 0xc8, 0xfa, 0x3c, 0x22, 0x7c, 0xb5, 0x34, 0x14, - 0xe0, 0xe2, 0x53, 0x14, 0x09, 0xc5, 0xa6, 0xfa, 0x0c, 0x36, 0x2d, 0xd0, 0x1e, 0x57, 0xfa, 0x98, - 0x0a, 0x14, 0xe7, 0x33, 0x30, 0xca, 0xb3, 0xa8, 0x54, 0x29, 0x6d, 0xff, 0xd0, 0xc1, 0xd2, 0xa3, - 0x71, 0x27, 0xe4, 0x0f, 0x91, 0x27, 0x94, 0x70, 0x0c, 0x13, 0x50, 0x99, 0xfc, 0x11, 0x07, 0x33, - 0x0c, 0x5f, 0xa9, 0x0c, 0xdb, 0xe0, 0x6c, 0x30, 0xe5, 0x85, 0x1b, 0xfa, 0x4a, 0xb9, 0x3a, 0x5f, - 0xdf, 0x72, 0x94, 0xd3, 0xe0, 0xfc, 0xc1, 0xbe, 0x33, 0xfd, 0x99, 0x3f, 0x24, 0x82, 0xf5, 0xfd, - 0xbc, 0xbe, 0x19, 0x83, 0x8a, 0x8a, 0x08, 0xcf, 0x81, 0x72, 0x13, 0xf7, 0x65, 0x07, 0x8f, 0x5f, - 0xe1, 0x5d, 0x30, 0xd7, 0x45, 0x71, 0x07, 0xa7, 0x7d, 0x30, 0x5f, 0xaf, 0x16, 0x58, 0xfa, 0xad, - 0x8b, 0xfd, 0xec, 0xb7, 0xdb, 0xfa, 0x2d, 0xcd, 0x7e, 0xa3, 0x81, 0x4b, 0xdb, 0x11, 0x09, 0x63, - 0x7c, 0xb2, 0xc1, 0x59, 0x07, 0x67, 0x68, 0x82, 0x19, 0x12, 0x94, 0x6d, 0x04, 0x01, 0x93, 0xad, - 0x68, 0xec, 0x0f, 0x6a, 0x15, 0x19, 0xea, 0xf8, 0x33, 0xe6, 0x7c, 0x5b, 0xb0, 0x88, 0x84, 0xfe, - 0x14, 0x7b, 0x72, 0xec, 0xca, 0x53, 0x63, 0x57, 0xff, 0xae, 0x83, 0xb9, 0x34, 0x43, 0xf8, 0x5e, - 0x03, 0x17, 0x14, 0x69, 0xc2, 0xbf, 0x97, 0x29, 0xfd, 0x9b, 0xf5, 0x93, 0x9f, 0x91, 0x7d, 0xf3, - 0xf5, 0xb7, 0x0f, 0xab, 0xda, 0xab, 0x8f, 0x5f, 0xdf, 0xe9, 0xab, 0xb0, 0xea, 0xaa, 0xef, 0x9b, - 0x2d, 0x2c, 0x72, 0xa6, 0x06, 0x1a, 0x58, 0x4c, 0x65, 0x55, 0x59, 0x42, 0xa7, 0xc0, 0x48, 0x41, - 0xf0, 0xe6, 0x3f, 0x9f, 0xa4, 0x7d, 0xe7, 0xd8, 0x6e, 0x1d, 0x5e, 0x2f, 0xb0, 0x5b, 0x68, 0x6c, - 0xf3, 0xde, 0xee, 0xd0, 0xd2, 0xf6, 0x86, 0x96, 0xf6, 0x65, 0x68, 0x69, 0x6f, 0x47, 0x56, 0x69, - 0x6f, 0x64, 0x95, 0x3e, 0x8d, 0xac, 0xd2, 0xb3, 0xab, 0x13, 0x43, 0x74, 0xa8, 0xda, 0x9b, 0xd4, - 0x4d, 0xe7, 0x68, 0xe7, 0xbf, 0xf4, 0xde, 0xbd, 0xf1, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x17, 0x72, - 0x2f, 0x14, 0x3f, 0x06, 0x00, 0x00, + // 593 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x41, + 0x1c, 0xcd, 0x6e, 0xa8, 0x7f, 0xa6, 0x82, 0x3a, 0xa6, 0xba, 0xdd, 0xea, 0xb6, 0x2e, 0x28, 0xa1, + 0x90, 0x5d, 0x1b, 0x11, 0x44, 0xaa, 0x92, 0xaa, 0x94, 0x3d, 0xba, 0x51, 0x04, 0x2f, 0x32, 0xcd, + 0x4e, 0xb7, 0x4b, 0x36, 0x33, 0x9b, 0x99, 0x49, 0x48, 0xae, 0x39, 0x79, 0x11, 0x04, 0xbf, 0x85, + 0x27, 0x0f, 0xf9, 0x10, 0x3d, 0x96, 0x7a, 0x11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94, 0x55, 0x3c, 0x8f, 0xc9, 0xde, 0xd4, 0xf6, 0xfb, 0xa5, 0x82, 0x4c, + 0xea, 0xe8, 0x18, 0x73, 0x5e, 0x15, 0x2c, 0x20, 0xbe, 0x3b, 0xc1, 0x1e, 0x9f, 0xc3, 0xfc, 0xc4, + 0x1c, 0x96, 0x7f, 0xab, 0x60, 0x2e, 0xce, 0x21, 0xfc, 0xac, 0x80, 0x6b, 0x29, 0xd9, 0x84, 0xff, + 0xbf, 0xa6, 0xf4, 0xaf, 0x97, 0xcf, 0x5e, 0x23, 0xf3, 0xc1, 0xfb, 0x5f, 0x5f, 0x56, 0x95, 0xde, + 0xd7, 0x9f, 0x9f, 0xd4, 0x55, 0x58, 0xb4, 0xd3, 0x1f, 0xa0, 0x4d, 0x2c, 0xa6, 0x4c, 0xf5, 0x15, + 0xb0, 0x18, 0xcb, 0xa6, 0xe5, 0x12, 0x5a, 0x19, 0x46, 0x32, 0x12, 0xaf, 0x9f, 0xba, 0x92, 0xe6, + 0xe3, 0x63, 0xbb, 0x65, 0x78, 0x2f, 0xc3, 0x6e, 0xa6, 0xb1, 0x8d, 0xa7, 0xbb, 0x03, 0x43, 0xd9, + 0x1b, 0x18, 0xca, 0x8f, 0x81, 0xa1, 0x7c, 0x1c, 0x1a, 0xb9, 0xbd, 0xa1, 0x91, 0xfb, 0x36, 0x34, + 0x72, 0x6f, 0xef, 0x8c, 0x0d, 0xd1, 0xa1, 0x6a, 0x67, 0x5c, 0x37, 0x9e, 0xa3, 0xad, 0x73, 0xf1, + 0x43, 0x7c, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0x51, 0x26, 0x58, 0x50, 0x06, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -455,9 +456,9 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.TotalDelegationAmount.Size() + size := m.CanUndelegateAmountAfterSlash.Size() i -= size - if _, err := m.TotalDelegationAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.CanUndelegateAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) @@ -628,7 +629,7 @@ func (m *DelegationAmounts) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) l = m.WaitUndelegationAmount.Size() n += 1 + l + sovQuery(uint64(l)) - l = m.TotalDelegationAmount.Size() + l = m.CanUndelegateAmountAfterSlash.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -897,7 +898,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalDelegationAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CanUndelegateAmountAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -925,7 +926,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalDelegationAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.CanUndelegateAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 123954ace..0f8e50bb5 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -55,18 +55,17 @@ func (k Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, sla return &operatorSlashInfo, nil } -func (k Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerId string, completeHeight uint64, opAmount sdkmath.Int) error { +func (k Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64, opAmount sdkmath.Int) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte - if stakerId == "" { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) - } else { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerId) + if stakerOrOperator == "" || assetId == "" { + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, fmt.Sprintf("assetId:%s,stakerOrOperator:%s", assetId, stakerOrOperator)) } + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerOrOperator) slashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} if store.Has(key) { value := store.Get(key) @@ -78,16 +77,29 @@ func (k Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerId string } bz := k.cdc.MustMarshal(&slashAmount) store.Set(key, bz) + + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) + totalSlashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &totalSlashAmount) + } + err = restakingtype.UpdateAssetValue(&totalSlashAmount.Amount, &opAmount) + if err != nil { + return err + } + bz = k.cdc.MustMarshal(&slashAmount) + store.Set(key, bz) return nil } -func (k Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerId string, completeHeight uint64) (sdkmath.Int, error) { +func (k Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64) (sdkmath.Int, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte - if stakerId == "" { + if stakerOrOperator == "" { key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) } else { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerId) + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerOrOperator) } var ret restakingtype.ValueField isExit := store.Has(key) diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index 4b4276088..f05049c4b 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -5,7 +5,9 @@ import ( sdkmath "cosmossdk.io/math" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + delegationtype "github.com/exocore/x/delegation/types" "github.com/exocore/x/operator/types" + types2 "github.com/exocore/x/restaking_assets_manage/types" ) func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { @@ -275,6 +277,8 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return nil } +type slashAmounts struct { +} type SlashAssetsAndAmount struct { slashFromStakerUnbonding map[string]map[string]sdkmath.Int slashFromStakerOptedIn map[string]map[string]sdkmath.Int @@ -283,7 +287,7 @@ type SlashAssetsAndAmount struct { slashFromOperatorOptedIn map[string]sdkmath.Int } -// GetAssetsAndAmountToSlash It will slash the assets that have been undelegated but still locked first, and if there isn't enough to slash, then it will slash the assets that are opting into AVS. +// GetAssetsAndAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { ret := SlashAssetsAndAmount{ slashFromStakerUnbonding: make(map[string]map[string]sdkmath.Int, 0), @@ -291,7 +295,6 @@ func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.A slashFromOperatorUnbonding: make(map[string]sdkmath.Int, 0), slashFromOperatorOptedIn: make(map[string]sdkmath.Int, 0), } - } func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredHeight int64, slashProportion sdkmath.LegacyDec) error { @@ -332,11 +335,105 @@ func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, if err != nil { return err } + // slash from opted-in assets + for stakerId, slashAssets := range assetsSlashInfo.slashFromStakerOptedIn { + for assetId, slashAmount := range slashAssets { + //update delegation state + delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) + delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ + CanUndelegationAmount: slashAmount.Neg(), + } + err = k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) + if err != nil { + return err + } + //update staker and operator assets state + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types2.StakerSingleAssetOrChangeInfo{ + TotalDepositAmountOrWantChangeValue: slashAmount.Neg(), + }) + if err != nil { + return err + } + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + TotalAmountOrWantChangeValue: slashAmount.Neg(), + }) + if err != nil { + return err + } + //decrease the related share value + err = k.UpdateOptedInAssetsState(ctx, stakerId, assetId, operatorAddress.String(), slashAmount.Neg()) + if err != nil { + return err + } + //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + err = k.UpdateSlashAssetsState(ctx, assetId, stakerId, uint64(slashInfo.ExecuteHeight), slashAmount) + if err != nil { + return err + } + } + } - // update delegation assets state + for assetId, slashAmount := range assetsSlashInfo.slashFromOperatorOptedIn { + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + TotalAmountOrWantChangeValue: slashAmount.Neg(), + OperatorOwnAmountOrWantChangeValue: slashAmount.Neg(), + }) + if err != nil { + return err + } + //decrease the related share value + err = k.UpdateOptedInAssetsState(ctx, "", assetId, operatorAddress.String(), slashAmount.Neg()) + if err != nil { + return err + } + //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + err = k.UpdateSlashAssetsState(ctx, assetId, operatorAddress.String(), uint64(slashInfo.ExecuteHeight), slashAmount) + if err != nil { + return err + } + } - // update staker assets state + // slash from unbonding assets + for stakerId, slashAssets := range assetsSlashInfo.slashFromStakerUnbonding { + for assetId, slashAmount := range slashAssets { + //update delegation state + delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) + delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ + CanUndelegateAmountAfterSlash: slashAmount.Neg(), + } + err = k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) + if err != nil { + return err + } + //update staker and operator assets state + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types2.StakerSingleAssetOrChangeInfo{ + TotalDepositAmountOrWantChangeValue: slashAmount.Neg(), + }) + if err != nil { + return err + } + //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + err = k.UpdateSlashAssetsState(ctx, assetId, stakerId, uint64(slashInfo.ExecuteHeight), slashAmount) + if err != nil { + return err + } + } + } - // update opted-in state + for assetId, slashAmount := range assetsSlashInfo.slashFromOperatorUnbonding { + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + TotalAmountOrWantChangeValue: slashAmount.Neg(), + OperatorOwnCanUnbondingAmountAfterSlash: slashAmount.Neg(), + }) + if err != nil { + return err + } + //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + err = k.UpdateSlashAssetsState(ctx, assetId, operatorAddress.String(), uint64(slashInfo.ExecuteHeight), slashAmount) + if err != nil { + return err + } + } + return nil } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index a5a689279..0e7137b97 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -3,10 +3,12 @@ package types import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + delegationtype "github.com/exocore/x/delegation/types" ) type ExpectDelegationInterface interface { GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]sdkmath.Int, error) + UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) } type ExpectOracleInterface interface { diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index ae8b65760..9ea0b65a5 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -76,5 +76,6 @@ var ( // KeyPrefixSlashAssetsState key-value: // completeSlashHeight + '/' + assetId -> SlashAmount // completeSlashHeight + '/' + assetId + '/' + stakerId -> SlashAmount + // completeSlashHeight + '/' + assetId + '/' + operatorAddr -> SlashAmount KeyPrefixSlashAssetsState = []byte{prefixSlashAssetsState} ) diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index ea694d360..ad7748623 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -55,10 +55,11 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnAmountOrWantChangeValue: math.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnWaitUnbondingAmount: math.NewInt(0), + TotalAmountOrWantChangeValue: math.NewInt(0), + OperatorOwnAmountOrWantChangeValue: math.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), + OperatorOwnWaitUnbondingAmount: math.NewInt(0), + OperatorOwnCanUnbondingAmountAfterSlash: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -82,6 +83,10 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") } + err = restakingtype.UpdateAssetValue(&assetState.OperatorOwnCanUnbondingAmountAfterSlash, &changeAmount.OperatorOwnCanUnbondingAmountAfterSlash) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") + } //store the updated state bz := k.cdc.MustMarshal(&assetState) diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index 96aafe831..f80fee704 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -393,9 +393,10 @@ func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetO type OperatorSingleAssetOrChangeInfo struct { TotalAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=TotalAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalAmountOrWantChangeValue"` // todo: the field is used to mark operator's own assets and is not temporarily used now - OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` - WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` - OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=OperatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnWaitUnbondingAmount"` + OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` + WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` + OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=OperatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnWaitUnbondingAmount"` + OperatorOwnCanUnbondingAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=OperatorOwnCanUnbondingAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnCanUnbondingAmountAfterSlash"` } func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleAssetOrChangeInfo{} } @@ -572,73 +573,74 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1042 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0xf9, 0xfb, 0xac, 0xb4, 0xc9, 0x34, 0x14, 0xc7, 0x14, 0x3b, 0x5a, 0x2a, 0x64, - 0x05, 0x62, 0xab, 0x46, 0x54, 0x51, 0x04, 0x48, 0x8e, 0xd3, 0x4a, 0x11, 0x49, 0x2d, 0xad, 0x03, - 0x11, 0x3d, 0x10, 0xc6, 0xf6, 0x74, 0xbd, 0xf2, 0xee, 0x8c, 0xb5, 0x33, 0x4e, 0xed, 0x5b, 0x85, - 0x2a, 0x84, 0x10, 0x42, 0xe5, 0xc4, 0x81, 0x4b, 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0x0f, 0x8e, 0xf7, 0x97, 0xb4, 0xb5, 0xcd, 0xa7, 0x87, 0x19, 0xed, 0xd9, - 0x61, 0x46, 0xfb, 0xe7, 0x30, 0xa3, 0x3d, 0x3a, 0xca, 0xc4, 0x9e, 0x1d, 0x65, 0x62, 0xcf, 0x8f, - 0x32, 0xb1, 0xbb, 0xc5, 0x50, 0x7b, 0x06, 0xaf, 0xde, 0x1d, 0xf9, 0xf1, 0x24, 0xdb, 0xb5, 0x36, - 0x21, 0x3f, 0x5e, 0x3e, 0xf9, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xa5, 0x20, 0xec, 0x56, 0x6c, 0x0d, - 0x00, 0x00, + // 1065 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0xda, 0xf9, 0x7c, 0xad, 0xb4, 0xc9, 0x34, 0x14, 0xc7, 0x14, 0x3b, 0x5a, 0x2a, 0xb0, + 0x02, 0xb1, 0x55, 0x23, 0xaa, 0x28, 0x02, 0x24, 0xc7, 0x69, 0xa5, 0x88, 0xa4, 0x96, 0x76, 0x03, + 0x11, 0x3d, 0x10, 0xc6, 0xf6, 0x64, 0xbd, 0xf2, 0xee, 0x8c, 0xb5, 0x33, 0x4e, 0xed, 0x5b, 0x85, + 0x2a, 0x84, 0x10, 0x42, 0xe5, 0x02, 0x07, 0x2e, 0xfd, 0x09, 0x39, 0xf4, 0x47, 0xf4, 0x58, 0xe5, + 0x42, 0xe1, 0x50, 0xa1, 0x44, 0x22, 0xfc, 0x0c, 0xb4, 0xb3, 0xbb, 0xc9, 0x3a, 0xb6, 0x9b, 0x2d, + 0x75, 0xa5, 0x5e, 0x92, 0x9d, 0x67, 0xde, 0xaf, 0x7d, 0xde, 0x0f, 0xbf, 0x0b, 0x1f, 0x92, 0x0e, + 0xab, 0x31, 0x87, 0x14, 0x1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xcd, 0x04, 0xb6, 0xf4, + 0x76, 0xab, 0x65, 0x79, 0xfc, 0xbc, 0x6a, 0xc5, 0x84, 0x0d, 0xbe, 0x14, 0xa5, 0x03, 0x93, 0x3c, + 0x39, 0x2c, 0xc9, 0x2e, 0xb5, 0x6e, 0x97, 0x9d, 0x96, 0xd7, 0x94, 0x97, 0x80, 0x1e, 0x50, 0x3d, + 0x52, 0x60, 0x56, 0xf7, 0x9a, 0x52, 0x5e, 0x48, 0x5a, 0xbf, 0x85, 0x4b, 0xf2, 0xb0, 0x86, 0xb9, + 0x59, 0x93, 0xba, 0x2e, 0xc1, 0xc9, 0xe2, 0x4a, 0xfe, 0xe2, 0x4e, 0xce, 0x0f, 0x4a, 0x94, 0x76, + 0xce, 0x1e, 0xb2, 0x00, 0xf9, 0x5e, 0x25, 0x19, 0x7e, 0x3f, 0xc6, 0x47, 0xc0, 0xee, 0x00, 0xbb, + 0xea, 0x61, 0x02, 0xde, 0x75, 0x61, 0xe2, 0xe8, 0x26, 0x35, 0x2c, 0x22, 0x83, 0xa9, 0x38, 0xe5, + 0x06, 0xa6, 0x06, 0x91, 0xf1, 0xfc, 0xac, 0xc0, 0x7b, 0x52, 0x63, 0x9d, 0xb4, 0x18, 0x37, 0x85, + 0xa7, 0x58, 0x71, 0x76, 0xb0, 0x7c, 0x15, 0x6a, 0x10, 0x39, 0x40, 0x46, 0x32, 0x31, 0xa2, 0x38, + 0x42, 0x3f, 0x29, 0xa0, 0x96, 0x31, 0xdd, 0x31, 0x45, 0xa3, 0xee, 0xe0, 0x7b, 0xc3, 0xe2, 0x19, + 0x05, 0x63, 0x11, 0xfc, 0xa0, 0x87, 0x0a, 0x5c, 0xdf, 0xc1, 0xa6, 0xf8, 0x92, 0x56, 0x19, 0xad, + 0xbb, 0xc5, 0x32, 0x24, 0xa0, 0xc4, 0x08, 0x02, 0x8a, 0xe4, 0x49, 0xfd, 0x25, 0x0e, 0x57, 0xbc, + 0xa4, 0x96, 0x2c, 0x4b, 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33, + 0xb1, 0xa7, 0xc7, 0x99, 0xd8, 0xb3, 0xe3, 0x4c, 0xec, 0x6e, 0x31, 0xd4, 0xa7, 0xc1, 0xab, 0x77, + 0x86, 0x7e, 0xd5, 0xc9, 0xbe, 0xad, 0x4e, 0xc8, 0xaf, 0xaa, 0x8f, 0xff, 0x0b, 0x00, 0x00, 0xff, + 0xff, 0x83, 0x75, 0x6e, 0xe0, 0x05, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1066,6 +1068,16 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l + { + size := m.OperatorOwnCanUnbondingAmountAfterSlash.Size() + i -= size + if _, err := m.OperatorOwnCanUnbondingAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a { size := m.OperatorOwnWaitUnbondingAmount.Size() i -= size @@ -1397,6 +1409,8 @@ func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.OperatorOwnWaitUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) + l = m.OperatorOwnCanUnbondingAmountAfterSlash.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -2675,6 +2689,40 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnCanUnbondingAmountAfterSlash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OperatorOwnCanUnbondingAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 54dfa8afaf8e93385d1c4261ef54d273b6666be3 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Fri, 26 Jan 2024 15:32:24 +0800 Subject: [PATCH 09/44] update slash function --- .../keeper/state_update_for_external_op.go | 195 ++++++++---------- 1 file changed, 89 insertions(+), 106 deletions(-) diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index f05049c4b..201554bdd 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -278,23 +278,96 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } type slashAmounts struct { + AmountFromUnbonding sdkmath.Int + AmountFromOptedIn sdkmath.Int } type SlashAssetsAndAmount struct { - slashFromStakerUnbonding map[string]map[string]sdkmath.Int - slashFromStakerOptedIn map[string]map[string]sdkmath.Int - - slashFromOperatorUnbonding map[string]sdkmath.Int - slashFromOperatorOptedIn map[string]sdkmath.Int + slashStakerInfo map[string]map[string]slashAmounts + slashOperatorInfo map[string]slashAmounts } // GetAssetsAndAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { - ret := SlashAssetsAndAmount{ - slashFromStakerUnbonding: make(map[string]map[string]sdkmath.Int, 0), - slashFromStakerOptedIn: make(map[string]map[string]sdkmath.Int, 0), - slashFromOperatorUnbonding: make(map[string]sdkmath.Int, 0), - slashFromOperatorOptedIn: make(map[string]sdkmath.Int, 0), + ret := &SlashAssetsAndAmount{ + slashStakerInfo: make(map[string]map[string]slashAmounts, 0), + slashOperatorInfo: make(map[string]slashAmounts, 0), } + return ret, nil +} + +func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]slashAmounts, executeHeight uint64) error { + for stakerId, slashAssets := range slashStakerInfo { + for assetId, slashInfo := range slashAssets { + //handle the state that needs to be updated when slashing both opted-in and unbonding assets + //update delegation state + delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) + delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ + CanUndelegationAmount: slashInfo.AmountFromOptedIn.Neg(), + CanUndelegateAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + } + err := k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) + if err != nil { + return err + } + + slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) + //update staker and operator assets state + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types2.StakerSingleAssetOrChangeInfo{ + TotalDepositAmountOrWantChangeValue: slashSumValue.Neg(), + }) + if err != nil { + return err + } + + //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + err = k.UpdateSlashAssetsState(ctx, assetId, stakerId, executeHeight, slashSumValue) + if err != nil { + return err + } + + //handle the state that needs to be updated when slashing opted-in assets + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + TotalAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), + }) + if err != nil { + return err + } + //decrease the related share value + err = k.UpdateOptedInAssetsState(ctx, stakerId, assetId, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) + if err != nil { + return err + } + } + } + return nil +} + +func (k Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]slashAmounts, executeHeight uint64) error { + for assetId, slashInfo := range slashOperatorInfo { + slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) + //handle the state that needs to be updated when slashing both opted-in and unbonding assets + err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + TotalAmountOrWantChangeValue: slashSumValue.Neg(), + OperatorOwnAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), + OperatorOwnCanUnbondingAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + }) + if err != nil { + return err + } + //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + err = k.UpdateSlashAssetsState(ctx, assetId, operatorAddress.String(), executeHeight, slashSumValue) + if err != nil { + return err + } + + //handle the state that needs to be updated when slashing opted-in assets + //decrease the related share value + err = k.UpdateOptedInAssetsState(ctx, "", assetId, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) + if err != nil { + return err + } + } + return nil } func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredHeight int64, slashProportion sdkmath.LegacyDec) error { @@ -335,105 +408,15 @@ func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, if err != nil { return err } - // slash from opted-in assets - for stakerId, slashAssets := range assetsSlashInfo.slashFromStakerOptedIn { - for assetId, slashAmount := range slashAssets { - //update delegation state - delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) - delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegationAmount: slashAmount.Neg(), - } - err = k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) - if err != nil { - return err - } - //update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types2.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: slashAmount.Neg(), - }) - if err != nil { - return err - } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: slashAmount.Neg(), - }) - if err != nil { - return err - } - //decrease the related share value - err = k.UpdateOptedInAssetsState(ctx, stakerId, assetId, operatorAddress.String(), slashAmount.Neg()) - if err != nil { - return err - } - //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetId, stakerId, uint64(slashInfo.ExecuteHeight), slashAmount) - if err != nil { - return err - } - } - } - - for assetId, slashAmount := range assetsSlashInfo.slashFromOperatorOptedIn { - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: slashAmount.Neg(), - OperatorOwnAmountOrWantChangeValue: slashAmount.Neg(), - }) - if err != nil { - return err - } - //decrease the related share value - err = k.UpdateOptedInAssetsState(ctx, "", assetId, operatorAddress.String(), slashAmount.Neg()) - if err != nil { - return err - } - //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetId, operatorAddress.String(), uint64(slashInfo.ExecuteHeight), slashAmount) - if err != nil { - return err - } - } - // slash from unbonding assets - for stakerId, slashAssets := range assetsSlashInfo.slashFromStakerUnbonding { - for assetId, slashAmount := range slashAssets { - //update delegation state - delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) - delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegateAmountAfterSlash: slashAmount.Neg(), - } - err = k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) - if err != nil { - return err - } - //update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types2.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: slashAmount.Neg(), - }) - if err != nil { - return err - } - //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetId, stakerId, uint64(slashInfo.ExecuteHeight), slashAmount) - if err != nil { - return err - } - } + err = k.SlashStaker(ctx, operatorAddress, assetsSlashInfo.slashStakerInfo, uint64(slashInfo.ExecuteHeight)) + if err != nil { + return err } - for assetId, slashAmount := range assetsSlashInfo.slashFromOperatorUnbonding { - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: slashAmount.Neg(), - OperatorOwnCanUnbondingAmountAfterSlash: slashAmount.Neg(), - }) - if err != nil { - return err - } - //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetId, operatorAddress.String(), uint64(slashInfo.ExecuteHeight), slashAmount) - if err != nil { - return err - } + err = k.SlashOperator(ctx, operatorAddress, assetsSlashInfo.slashOperatorInfo, uint64(slashInfo.ExecuteHeight)) + if err != nil { + return err } - return nil } From 60d64b5599f08ba5b1181d0ab3fa2008223408a7 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Sun, 28 Jan 2024 16:22:08 +0800 Subject: [PATCH 10/44] finish slash function --- x/delegation/keeper/delegation_state.go | 8 +- .../keeper/avs_operator_assets_state.go | 17 ++ .../keeper/state_update_for_external_op.go | 170 +++++++++++++----- x/operator/types/expected_keepers.go | 2 +- .../keeper/grpc_query.go | 2 +- .../keeper/operator_asset.go | 2 +- 6 files changed, 145 insertions(+), 56 deletions(-) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 00201a20b..b59bb66be 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -148,12 +148,12 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d } // GetDelegationStateByOperatorAndAssetList get the specified assets state delegated to the specified operator -func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]sdkmath.Int, error) { +func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() - ret := make(map[string]map[string]sdkmath.Int, 0) + ret := make(map[string]map[string]delegationtype.DelegationAmounts, 0) for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) @@ -166,9 +166,9 @@ func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operat if operatorAddr == findOperatorAddr { if _, ok := assetsFilter[assetId]; ok { if _, ok := ret[restakerId]; ok { - ret[restakerId][assetId] = amounts.CanUndelegationAmount + ret[restakerId][assetId] = amounts } else { - ret[restakerId] = make(map[string]sdkmath.Int, 0) + ret[restakerId] = make(map[string]delegationtype.DelegationAmounts, 0) } } } diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index 28390e24f..f67f348e8 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -205,3 +205,20 @@ func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerI } return ret.Amount, nil } + +func (k Keeper) GetAVSOperatorStakerInfo(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]interface{}, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) + stakers := make(map[string]interface{}, 0) + iterator := sdk.KVStorePrefixIterator(store, nil) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + keys, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 3) + if err != nil { + return nil, err + } + if keys[1] != "" { + stakers[keys[1]] = nil + } + } + return stakers, nil +} diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index 201554bdd..1712b7949 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -10,6 +10,21 @@ import ( types2 "github.com/exocore/x/restaking_assets_manage/types" ) +type AssetPriceAndDecimal struct { + Price sdkmath.Int + PriceDecimal uint8 + Decimal uint32 +} + +type slashAmounts struct { + AmountFromUnbonding sdkmath.Int + AmountFromOptedIn sdkmath.Int +} +type SlashAssetsAndAmount struct { + slashStakerInfo map[string]map[string]*slashAmounts + slashOperatorInfo map[string]*slashAmounts +} + func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { //get the AVS opted-in by the operator avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) @@ -72,39 +87,30 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope return nil } -type AssetPriceAndDecimal struct { - Price sdkmath.Int - PriceDecimal uint8 - Decimal uint32 -} - // OptIn call this function to opt in AVS func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { //check optedIn info if k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { return types.ErrAlreadyOptedIn } - - //get the Assets opted in the operator - operatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress) + //get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) if err != nil { return err } - //get the assets supported by the AVS - avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + + //get the Assets opted in the operator + operatorAssets, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) if err != nil { return err } + totalAssetUsdValue := sdkmath.LegacyNewDec(0) operatorOwnAssetUsdValue := sdkmath.LegacyNewDec(0) assetFilter := make(map[string]interface{}) assetInfoRecord := make(map[string]*AssetPriceAndDecimal) - for assetId := range avsSupportedAssets { - operatorAssetState, ok := operatorAssetsState[assetId] - if !ok { - continue - } + for assetId, operatorAssetState := range operatorAssets { //get price and priceDecimal from oracle price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) if err != nil { @@ -168,7 +174,7 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s for stakerId, assetState := range relatedAssetsState { stakerAssetsUsdValue := sdkmath.LegacyNewDec(0) for assetId, amount := range assetState { - singleAssetValue := amount.Mul(assetInfoRecord[assetId].Price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfoRecord[assetId].Decimal)+int(assetInfoRecord[assetId].PriceDecimal))) + singleAssetValue := amount.CanUndelegationAmount.Mul(assetInfoRecord[assetId].Price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfoRecord[assetId].Decimal)+int(assetInfoRecord[assetId].PriceDecimal))) singleAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(singleAssetValue.BigInt(), int64(types.UsdValueDefaultDecimal)) stakerAssetsUsdValue = stakerAssetsUsdValue.Add(singleAssetUsdValue) } @@ -203,23 +209,20 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return types.ErrNotOptedIn } - //get the Assets opted in the operator - operatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress) + //get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) if err != nil { return err } - //get the assets supported by the AVS - avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + //get the Assets opted in the operator + operatorAssets, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) if err != nil { return err } + assetFilter := make(map[string]interface{}) - for assetId := range avsSupportedAssets { - _, ok := operatorAssetsState[assetId] - if !ok { - continue - } + for assetId := range operatorAssets { err = k.DeleteOperatorAVSAssetsState(ctx, assetId, AVSAddr, operatorAddress.String()) if err != nil { return err @@ -277,25 +280,91 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return nil } -type slashAmounts struct { - AmountFromUnbonding sdkmath.Int - AmountFromOptedIn sdkmath.Int -} -type SlashAssetsAndAmount struct { - slashStakerInfo map[string]map[string]slashAmounts - slashOperatorInfo map[string]slashAmounts -} - // GetAssetsAndAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. -func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { +func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { ret := &SlashAssetsAndAmount{ - slashStakerInfo: make(map[string]map[string]slashAmounts, 0), - slashOperatorInfo: make(map[string]slashAmounts, 0), + slashStakerInfo: make(map[string]map[string]*slashAmounts, 0), + slashOperatorInfo: make(map[string]*slashAmounts, 0), + } + + height := ctx.BlockHeight() + //get the state when the slash occurred + ctx = ctx.WithBlockHeight(occurredSateHeight) + //get assetsInfo supported by AVS + assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + if err != nil { + return nil, err + } + historyStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetsFilter) + if err != nil { + return nil, err + } + + //get the Assets opted in the operator + historyOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, assetsFilter) + if err != nil { + return nil, err + } + // reset context height + ctx = ctx.WithBlockHeight(height) + + //calculate the actual slash amount according to the history and current state + currentStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetsFilter) + if err != nil { + return nil, err + } + //get the Assets opted in the operator + currentOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, assetsFilter) + if err != nil { + return nil, err + } + + //calculate the actual slash amount for staker + for stakerId, assetsState := range currentStakerAssets { + if historyAssetState, ok := historyStakerAssets[stakerId]; ok { + for assetId, curState := range assetsState { + if historyState, ifExist := historyAssetState[assetId]; ifExist { + if _, exist := ret.slashStakerInfo[stakerId]; !exist { + ret.slashStakerInfo[stakerId] = make(map[string]*slashAmounts, 0) + } + shouldSlashAmount := slashProportion.MulInt(historyState.CanUndelegationAmount).TruncateInt() + if curState.CanUndelegationAmount.LT(shouldSlashAmount) { + ret.slashStakerInfo[stakerId][assetId].AmountFromOptedIn = curState.CanUndelegationAmount + remainShouldSlash := shouldSlashAmount.Sub(curState.CanUndelegationAmount) + if curState.CanUndelegateAmountAfterSlash.LT(remainShouldSlash) { + ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = curState.CanUndelegateAmountAfterSlash + } else { + ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = remainShouldSlash + } + } else { + ret.slashStakerInfo[stakerId][assetId].AmountFromOptedIn = shouldSlashAmount + } + } + } + } + } + + //calculate the actual slash amount for operator + for assetId, curAssetState := range currentOperatorAssetsState { + if historyAssetState, ok := historyOperatorAssetsState[assetId]; ok { + shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorOwnAmountOrWantChangeValue).TruncateInt() + if curAssetState.OperatorOwnAmountOrWantChangeValue.LT(shouldSlashAmount) { + ret.slashOperatorInfo[assetId].AmountFromOptedIn = curAssetState.OperatorOwnAmountOrWantChangeValue + remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmountOrWantChangeValue) + if curAssetState.OperatorOwnCanUnbondingAmountAfterSlash.LT(remainShouldSlash) { + ret.slashOperatorInfo[assetId].AmountFromUnbonding = curAssetState.OperatorOwnCanUnbondingAmountAfterSlash + } else { + ret.slashOperatorInfo[assetId].AmountFromUnbonding = remainShouldSlash + } + } else { + ret.slashOperatorInfo[assetId].AmountFromOptedIn = shouldSlashAmount + } + } } return ret, nil } -func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]slashAmounts, executeHeight uint64) error { +func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, executeHeight uint64) error { for stakerId, slashAssets := range slashStakerInfo { for assetId, slashInfo := range slashAssets { //handle the state that needs to be updated when slashing both opted-in and unbonding assets @@ -342,7 +411,7 @@ func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sla return nil } -func (k Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]slashAmounts, executeHeight uint64) error { +func (k Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, executeHeight uint64) error { for assetId, slashInfo := range slashOperatorInfo { slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) //handle the state that needs to be updated when slashing both opted-in and unbonding assets @@ -370,31 +439,34 @@ func (k Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, s return nil } -func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredHeight int64, slashProportion sdkmath.LegacyDec) error { +// Slash The occurredSateHeight should be the height that has the latest stable state. +func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error { height := ctx.BlockHeight() - if occurredHeight > height { - return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("occurredHeight:%d,curHeight:%d", occurredHeight, height)) + if occurredSateHeight > height { + return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("occurredSateHeight:%d,curHeight:%d", occurredSateHeight, height)) } //get the state when the slash occurred //get the opted-in info - ctx = ctx.WithBlockHeight(occurredHeight) + ctx = ctx.WithBlockHeight(occurredSateHeight) + if !k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { + return types.ErrNotOptedIn + } optedInfo, err := k.GetOptedInfo(ctx, operatorAddress.String(), AVSAddr) if err != nil { return err } - // reset context height - ctx = ctx.WithBlockHeight(height) - if optedInfo.SlashContract != slashContract { return errorsmod.Wrap(types.ErrSlashContractNotMatch, fmt.Sprintf("input slashContract:%s, opted-in slash contract:%s", slashContract, optedInfo.SlashContract)) } + // reset context height + ctx = ctx.WithBlockHeight(height) //todo: recording the slash event might be moved to the slash module slashInfo := types.OperatorSlashInfo{ SlashContract: slashContract, SlashHeight: height, - OccurredHeight: occurredHeight, + OccurredHeight: occurredSateHeight, SlashProportion: slashProportion, ExecuteHeight: height + types.SlashVetoDuration, } @@ -404,7 +476,7 @@ func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, } // get the assets and amounts that should be slashed - assetsSlashInfo, err := k.GetAssetsAndAmountToSlash(ctx, operatorAddress, AVSAddr, occurredHeight, slashProportion) + assetsSlashInfo, err := k.GetAssetsAndAmountToSlash(ctx, operatorAddress, AVSAddr, occurredSateHeight, slashProportion) if err != nil { return err } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 0e7137b97..d4dfd75e3 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -7,7 +7,7 @@ import ( ) type ExpectDelegationInterface interface { - GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]sdkmath.Int, error) + GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) } diff --git a/x/restaking_assets_manage/keeper/grpc_query.go b/x/restaking_assets_manage/keeper/grpc_query.go index 248a78ed6..193d6c85d 100644 --- a/x/restaking_assets_manage/keeper/grpc_query.go +++ b/x/restaking_assets_manage/keeper/grpc_query.go @@ -65,7 +65,7 @@ func (k Keeper) QueOperatorAssetInfos(ctx context.Context, infos *restakingtype. if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - assetInfos, err := k.GetOperatorAssetInfos(c, addr) + assetInfos, err := k.GetOperatorAssetInfos(c, addr, nil) if err != nil { return nil, err } diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index ad7748623..9cdc8672d 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -10,7 +10,7 @@ import ( // This file provides all functions about operator assets state management. -func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) (assetsInfo map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) { +func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, assetsFilter map[string]interface{}) (assetsInfo map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) // the key is the operator address in the bech32 format key := []byte(operatorAddr.String()) From efe31fe96a461ed02d24e4140520078a14f941ce Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 29 Jan 2024 11:30:09 +0800 Subject: [PATCH 11/44] update abci.go in operator module --- precompiles/delegation/delegation_test.go | 13 ++--- x/delegation/types/codec.go | 1 - x/operator/keeper/abci.go | 50 ++++++++++++++++++- .../keeper/avs_operator_assets_state.go | 41 +++++++++++++++ x/operator/keeper/keeper.go | 4 +- x/operator/types/expected_keepers.go | 6 +++ 6 files changed, 104 insertions(+), 11 deletions(-) diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 30845261c..2f22e4d5d 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -2,6 +2,7 @@ package delegation_test import ( "fmt" + operatortypes "github.com/exocore/x/operator/types" "math/big" "strings" @@ -88,13 +89,13 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { s.Require().NoError(err) } registerOperator := func() { - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &operatortypes.RegisterOperatorReq{ FromAddress: opAccAddr, - Info: &delegationtype.OperatorInfo{ + Info: &operatortypes.OperatorInfo{ EarningsAddr: opAccAddr, }, } - _, err := s.app.DelegationKeeper.RegisterOperator(s.ctx, registerReq) + _, err := s.app.OperatorKeeper.RegisterOperator(s.ctx, registerReq) s.NoError(err) } commonMalleate := func() (common.Address, []byte) { @@ -330,13 +331,13 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { s.Require().NoError(err) } registerOperator := func() { - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &operatortypes.RegisterOperatorReq{ FromAddress: operatorAddr, - Info: &delegationtype.OperatorInfo{ + Info: &operatortypes.OperatorInfo{ EarningsAddr: operatorAddr, }, } - _, err := s.app.DelegationKeeper.RegisterOperator(s.ctx, registerReq) + _, err := s.app.OperatorKeeper.RegisterOperator(s.ctx, registerReq) s.NoError(err) } commonMalleate := func() (common.Address, []byte) { diff --git a/x/delegation/types/codec.go b/x/delegation/types/codec.go index fc0ea106c..740b222ea 100644 --- a/x/delegation/types/codec.go +++ b/x/delegation/types/codec.go @@ -23,7 +23,6 @@ var ( const ( // Amino names - registerOperator = "exocore/RegisterOperatorReq" delegateAssetToOperator = "exocore/MsgDelegation" UndelegateAssetFromOperator = "exocore/MsgUndelegation" ) diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index f5d5930a2..2db612795 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -1,11 +1,59 @@ package keeper import ( + sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + operatortypes "github.com/exocore/x/operator/types" + "github.com/exocore/x/restaking_assets_manage/types" ) -// EndBlock : to be used +// EndBlock : update the assets' share when their prices change func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + priceChangeAssets, err := k.oracleKeeper.GetPriceChangeAssets(ctx) + if err != nil { + panic(err) + } + avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) + for assetId, priceChange := range priceChangeAssets { + //get the decimal of asset + assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) + if err != nil { + panic(err) + } + //UpdateOperatorAVSAssetsState + f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { + newAssetValue := state.Amount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(priceChange.Decimal))) + newAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.UsdValueDefaultDecimal)) + changeValue := newAssetUsdValue.Sub(state.Value) + state.Value = newAssetUsdValue + + avsAddr := keys[1] + avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) + if value, ok := avsOperatorShareChange[avsAddr]; ok { + avsOperatorShareChange[avsAddr] = value.Add(changeValue) + } else { + avsOperatorShareChange[avsAddr] = changeValue + } + if value, ok := avsOperatorShareChange[avsOperator]; ok { + avsOperatorShareChange[avsOperator] = value.Add(changeValue) + } else { + avsOperatorShareChange[avsOperator] = changeValue + } + return nil + } + err = k.IterateUpdateOperatorAVSAssets(ctx, assetId, f) + if err != nil { + panic(err) + } + } + //BatchUpdateAVSAndOperatorTotalValue + err = k.BatchUpdateAVSAndOperatorTotalValue(ctx, avsOperatorShareChange) + if err != nil { + panic(err) + } + + //update staker's share + return []abci.ValidatorUpdate{} } diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index f67f348e8..e827aaa27 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -87,6 +87,25 @@ func (k Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount sd return nil } +func (k Keeper) BatchUpdateAVSAndOperatorTotalValue(ctx sdk.Context, avsOperatorChange map[string]sdkmath.LegacyDec) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + for avs, opAmount := range avsOperatorChange { + key := []byte(avs) + totalValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &totalValue) + } + err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&totalValue) + store.Set(key, bz) + } + return nil +} + func (k Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.ValueField @@ -164,6 +183,28 @@ func (k Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, ope return &assetOptedInState, nil } +func (k Keeper) IterateUpdateOperatorAVSAssets(ctx sdk.Context, assetId string, f func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) + iterator := sdk.KVStorePrefixIterator(store, []byte(assetId)) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + keys, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 3) + if err != nil { + return err + } + assetOptedInState := &operatortypes.AssetOptedInState{} + k.cdc.MustUnmarshal(iterator.Value(), assetOptedInState) + err = f(assetId, keys, assetOptedInState) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(assetOptedInState) + store.Set(iterator.Key(), bz) + } + return nil +} + func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index c4b746470..3d3d529e8 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -60,7 +60,5 @@ type IOperator interface { OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error - SlashOperator() - - GetOperatorValueShare() + Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index d4dfd75e3..013df4920 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -11,8 +11,14 @@ type ExpectDelegationInterface interface { UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) } +type PriceChange struct { + OriginalPrice sdkmath.Int + NewPrice sdkmath.Int + Decimal uint8 +} type ExpectOracleInterface interface { GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdkmath.Int, uint8, error) + GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) } type ExpectAvsInterface interface { From 6de7a1d5bfe937d4126e90a2fb223d8edce9122a Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 29 Jan 2024 15:15:00 +0800 Subject: [PATCH 12/44] finish abci.go in operator module --- x/delegation/keeper/delegation_state.go | 22 ++++++++ x/operator/keeper/abci.go | 53 +++++++++++++++++++ .../keeper/avs_operator_assets_state.go | 15 ++++++ x/operator/types/expected_keepers.go | 1 + .../keeper/operator_asset.go | 22 ++++++++ 5 files changed, 113 insertions(+) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index b59bb66be..0006b9b02 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -176,3 +176,25 @@ func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operat } return ret, nil } + +func (k Keeper) IteratorDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) + iterator := sdk.KVStorePrefixIterator(store, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var amounts delegationtype.DelegationAmounts + k.cdc.MustUnmarshal(iterator.Value(), &amounts) + keys, err := stakingtypes.ParseJoinedKey(iterator.Key()) + if err != nil { + return err + } + if len(keys) == 3 { + err = f(keys[0], keys[1], keys[2], &amounts) + if err != nil { + return err + } + } + } + return nil +} diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 2db612795..29fc32194 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -4,6 +4,7 @@ import ( sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + delegationtype "github.com/exocore/x/delegation/types" operatortypes "github.com/exocore/x/operator/types" "github.com/exocore/x/restaking_assets_manage/types" ) @@ -15,12 +16,18 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat panic(err) } avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) + assetsOperator := make(map[string]map[string]string, 0) + assetsDecimal := make(map[string]uint32) for assetId, priceChange := range priceChangeAssets { //get the decimal of asset assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) if err != nil { panic(err) } + assetsDecimal[assetId] = assetInfo.AssetBasicInfo.Decimals + if _, ok := assetsOperator[assetId]; !ok { + assetsOperator[assetId] = make(map[string]string, 0) + } //UpdateOperatorAVSAssetsState f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { newAssetValue := state.Amount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(priceChange.Decimal))) @@ -40,6 +47,8 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat } else { avsOperatorShareChange[avsOperator] = changeValue } + + assetsOperator[assetId][keys[2]] = avsAddr return nil } err = k.IterateUpdateOperatorAVSAssets(ctx, assetId, f) @@ -54,6 +63,50 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat } //update staker's share + stakerOperatorNewShare := make(map[string]sdkmath.LegacyDec, 0) + stakerShareHandleFunc := func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error { + priceChange := priceChangeAssets[assetId] + assetDecimal := assetsDecimal[assetId] + if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { + newAssetValue := state.CanUndelegationAmount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) + newAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.UsdValueDefaultDecimal)) + key := string(types.GetJoinedStoreKey(avsAddr, restakerId, operatorAddr)) + if value, ok := stakerOperatorNewShare[key]; ok { + stakerOperatorNewShare[key] = value.Add(newAssetUsdValue) + } else { + stakerOperatorNewShare[key] = newAssetUsdValue + } + } + return nil + } + err = k.delegationKeeper.IteratorDelegationState(ctx, stakerShareHandleFunc) + if err != nil { + panic(err) + } + operatorShareHandleFunc := func(operatorAddr, assetId string, state *types.OperatorSingleAssetOrChangeInfo) error { + priceChange := priceChangeAssets[assetId] + assetDecimal := assetsDecimal[assetId] + if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { + newAssetValue := state.OperatorOwnAmountOrWantChangeValue.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) + newAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.UsdValueDefaultDecimal)) + key := string(types.GetJoinedStoreKey(avsAddr, "", operatorAddr)) + if value, ok := stakerOperatorNewShare[key]; ok { + stakerOperatorNewShare[key] = value.Add(newAssetUsdValue) + } else { + stakerOperatorNewShare[key] = newAssetUsdValue + } + } + return nil + } + err = k.restakingStateKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) + if err != nil { + panic(err) + } + //BatchSetAVSOperatorStakerShare + err = k.BatchSetAVSOperatorStakerShare(ctx, stakerOperatorNewShare) + if err != nil { + panic(err) + } return []abci.ValidatorUpdate{} } diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index e827aaa27..75d96c23a 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -226,6 +226,21 @@ func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stak return nil } +func (k Keeper) BatchSetAVSOperatorStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) + for key, value := range newValues { + optedInValue := operatortypes.ValueField{Amount: value} + if store.Has([]byte(key)) { + value := store.Get([]byte(key)) + k.cdc.MustUnmarshal(value, &optedInValue) + } + + bz := k.cdc.MustMarshal(&optedInValue) + store.Set([]byte(key), bz) + } + return nil +} + func (k Keeper) DeleteAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 013df4920..af15bf0f4 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -8,6 +8,7 @@ import ( type ExpectDelegationInterface interface { GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) + IteratorDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) } diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index 9cdc8672d..297736958 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -93,3 +93,25 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre store.Set(key, bz) return nil } + +func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetId string, state *restakingtype.OperatorSingleAssetOrChangeInfo) error) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) + iterator := sdk.KVStorePrefixIterator(store, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var amounts restakingtype.OperatorSingleAssetOrChangeInfo + k.cdc.MustUnmarshal(iterator.Value(), &amounts) + keys, err := restakingtype.ParseJoinedKey(iterator.Key()) + if err != nil { + return err + } + if len(keys) == 3 { + err = f(keys[0], keys[1], &amounts) + if err != nil { + return err + } + } + } + return nil +} From c35bca719c2a22514371183d14c7ae5b073a822e Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 29 Jan 2024 15:43:51 +0800 Subject: [PATCH 13/44] update abci.go in the delegation module --- x/delegation/keeper/abci.go | 58 ++++++++----------- x/delegation/keeper/cross_chain_tx_process.go | 4 ++ .../keeper/state_update_for_external_op.go | 4 ++ x/operator/types/expected_keepers.go | 2 + 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 1a75d7a1f..0abe1b505 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -1,13 +1,10 @@ package keeper import ( - "fmt" - - sdkmath "cosmossdk.io/math" - delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" ) // EndBlock : completed Undelegation events according to the canCompleted blockHeight @@ -24,48 +21,43 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat for _, record := range records { // check if the operator has been slashed or frozen operatorAccAddress := sdk.MustAccAddressFromBech32(record.OperatorAddr) - if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { - // reSet the completed height if the operator is frozen - record.CompleteBlockNumber = k.expectOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) - if record.CompleteBlockNumber <= uint64(ctx.BlockHeight()) { - panic(fmt.Sprintf("the reset completedHeight isn't in future,setHeight:%v,curHeight:%v", record.CompleteBlockNumber, ctx.BlockHeight())) - } - _, err = k.SetSingleUndelegationRecord(ctx, record) - if err != nil { - panic(err) - } - continue - } + //todo: don't think about freezing the operator in current implementation + /* if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { + // reSet the completed height if the operator is frozen + record.CompleteBlockNumber = k.expectOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) + if record.CompleteBlockNumber <= uint64(ctx.BlockHeight()) { + panic(fmt.Sprintf("the reset completedHeight isn't in future,setHeight:%v,curHeight:%v", record.CompleteBlockNumber, ctx.BlockHeight())) + } + _, err = k.SetSingleUndelegationRecord(ctx, record) + if err != nil { + panic(err) + } + continue + }*/ - // get operator slashed proportion to calculate the actual canUndelegated asset amount - proportion := k.slashKeeper.OperatorAssetSlashedProportion(ctx, operatorAccAddress, record.AssetId, record.BlockNumber, record.CompleteBlockNumber) - if proportion.IsNil() || proportion.IsNegative() || proportion.GT(sdkmath.LegacyNewDec(1)) { - panic(fmt.Sprintf("the proportion is invalid,it is:%v", proportion)) + //calculate the actual canUndelegated asset amount + delegationInfo, err := k.GetSingleDelegationInfo(ctx, record.StakerId, record.AssetId, record.OperatorAddr) + if record.Amount.GT(delegationInfo.CanUndelegateAmountAfterSlash) { + record.ActualCompletedAmount = delegationInfo.CanUndelegateAmountAfterSlash + } else { + record.ActualCompletedAmount = record.Amount } - canUndelegateProportion := sdkmath.LegacyNewDec(1).Sub(proportion) - actualCanUndelegateAmount := canUndelegateProportion.MulInt(record.Amount).TruncateInt() - record.ActualCompletedAmount = actualCanUndelegateAmount recordAmountNeg := record.Amount.Neg() // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[record.OperatorAddr] = &delegationtype.DelegationAmounts{ - WaitUndelegationAmount: recordAmountNeg, + WaitUndelegationAmount: recordAmountNeg, + CanUndelegateAmountAfterSlash: record.ActualCompletedAmount.Neg(), } err = k.UpdateDelegationState(ctx, record.StakerId, record.AssetId, delegatorAndAmount) if err != nil { panic(err) } - // todo: if use recordAmount as an input parameter, the delegation total amount won't need to be subtracted when the related operator is slashed. - err = k.UpdateStakerDelegationTotalAmount(ctx, record.StakerId, record.AssetId, recordAmountNeg) - if err != nil { - panic(err) - } - // update the staker state - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerId, record.AssetId, types.StakerSingleAssetOrChangeInfo{ - CanWithdrawAmountOrWantChangeValue: actualCanUndelegateAmount, + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerId, record.AssetId, types.StakerSingleAssetOrChangeInfo{ + CanWithdrawAmountOrWantChangeValue: record.ActualCompletedAmount, WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, }) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 27818135f..2bd6a72e2 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -224,6 +224,10 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation if err != nil { return err } + err = k.UpdateStakerDelegationTotalAmount(ctx, stakerId, assetId, params.OpAmount.Neg()) + if err != nil { + return err + } //update staker and operator assets state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types.StakerSingleAssetOrChangeInfo{ diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index 1712b7949..b69411fda 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -378,6 +378,10 @@ func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sla if err != nil { return err } + err = k.delegationKeeper.UpdateStakerDelegationTotalAmount(ctx, stakerId, assetId, slashInfo.AmountFromOptedIn.Neg()) + if err != nil { + return err + } slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) //update staker and operator assets state diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index af15bf0f4..a4aa18e3b 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -10,6 +10,8 @@ type ExpectDelegationInterface interface { GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) IteratorDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) + + UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string, opAmount sdkmath.Int) error } type PriceChange struct { From 31d7b7b6eb9816a72c02b1d1091c32399d83cfce Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 30 Jan 2024 11:21:37 +0800 Subject: [PATCH 14/44] solve the problems identified by code review --- x/delegation/keeper/abci.go | 3 ++ x/delegation/keeper/delegation_state.go | 23 +++++---- x/deposit/keeper/deposit_test.go | 6 +-- x/operator/keeper/abci.go | 25 +++++----- .../keeper/avs_operator_assets_state.go | 4 +- .../keeper/avs_operator_assets_state_test.go | 1 + x/operator/keeper/keeper.go | 2 +- x/operator/keeper/operator.go | 4 +- .../keeper/state_update_for_external_op.go | 48 +++++++++---------- x/operator/types/keys.go | 4 +- .../keeper/client_chain_asset.go | 4 +- x/slash/keeper/execute_slash_test.go | 12 ++--- 12 files changed, 73 insertions(+), 63 deletions(-) create mode 100644 x/operator/keeper/avs_operator_assets_state_test.go diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 0abe1b505..705aae8de 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -37,6 +37,9 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat //calculate the actual canUndelegated asset amount delegationInfo, err := k.GetSingleDelegationInfo(ctx, record.StakerId, record.AssetId, record.OperatorAddr) + if err != nil { + panic(err) + } if record.Amount.GT(delegationInfo.CanUndelegateAmountAfterSlash) { record.ActualCompletedAmount = delegationInfo.CanUndelegateAmountAfterSlash } else { diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 0006b9b02..10035c1c3 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -161,17 +161,20 @@ func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operat if err != nil { return nil, err } - if len(keys) == 3 { - restakerId, assetId, findOperatorAddr := keys[0], keys[1], keys[2] - if operatorAddr == findOperatorAddr { - if _, ok := assetsFilter[assetId]; ok { - if _, ok := ret[restakerId]; ok { - ret[restakerId][assetId] = amounts - } else { - ret[restakerId] = make(map[string]delegationtype.DelegationAmounts, 0) - } - } + if len(keys) != 3 { + continue + } + restakerID, assetID, findOperatorAddr := keys[0], keys[1], keys[2] + if operatorAddr != findOperatorAddr { + continue + } + _, assetIDExist := assetsFilter[assetID] + _, restakerIDExist := ret[restakerID] + if assetIDExist { + if restakerIDExist { + ret[restakerID] = make(map[string]delegationtype.DelegationAmounts) } + ret[restakerID][assetID] = amounts } } return ret, nil diff --git a/x/deposit/keeper/deposit_test.go b/x/deposit/keeper/deposit_test.go index 74d98beb3..62e823760 100644 --- a/x/deposit/keeper/deposit_test.go +++ b/x/deposit/keeper/deposit_test.go @@ -37,9 +37,9 @@ func (suite *KeeperTestSuite) TestDeposit() { info, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount, - CanWithdrawAmountOrWantChangeValue: params.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: params.OpAmount, + CanWithdrawAmountOrWantChangeValue: params.OpAmount, + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 29fc32194..39397204a 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -30,13 +30,14 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat } //UpdateOperatorAVSAssetsState f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { - newAssetValue := state.Amount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(priceChange.Decimal))) - newAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.UsdValueDefaultDecimal)) - changeValue := newAssetUsdValue.Sub(state.Value) - state.Value = newAssetUsdValue + newAssetValue := state.Amount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(priceChange.Decimal))) + newAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) + changeValue := newAssetUSDValue.Sub(state.Value) + state.Value = newAssetUSDValue avsAddr := keys[1] avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) + avsOperatorShareChange[avsAddr] = avsOperatorShareChange[avsAddr].Add(changeValue) if value, ok := avsOperatorShareChange[avsAddr]; ok { avsOperatorShareChange[avsAddr] = value.Add(changeValue) } else { @@ -68,13 +69,13 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat priceChange := priceChangeAssets[assetId] assetDecimal := assetsDecimal[assetId] if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { - newAssetValue := state.CanUndelegationAmount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) - newAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.UsdValueDefaultDecimal)) + newAssetValue := state.CanUndelegationAmount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) + newAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) key := string(types.GetJoinedStoreKey(avsAddr, restakerId, operatorAddr)) if value, ok := stakerOperatorNewShare[key]; ok { - stakerOperatorNewShare[key] = value.Add(newAssetUsdValue) + stakerOperatorNewShare[key] = value.Add(newAssetUSDValue) } else { - stakerOperatorNewShare[key] = newAssetUsdValue + stakerOperatorNewShare[key] = newAssetUSDValue } } return nil @@ -88,13 +89,13 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat priceChange := priceChangeAssets[assetId] assetDecimal := assetsDecimal[assetId] if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { - newAssetValue := state.OperatorOwnAmountOrWantChangeValue.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) - newAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.UsdValueDefaultDecimal)) + newAssetValue := state.OperatorOwnAmountOrWantChangeValue.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) + newAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) key := string(types.GetJoinedStoreKey(avsAddr, "", operatorAddr)) if value, ok := stakerOperatorNewShare[key]; ok { - stakerOperatorNewShare[key] = value.Add(newAssetUsdValue) + stakerOperatorNewShare[key] = value.Add(newAssetUSDValue) } else { - stakerOperatorNewShare[key] = newAssetUsdValue + stakerOperatorNewShare[key] = newAssetUSDValue } } return nil diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index 75d96c23a..80051dc13 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -57,8 +57,8 @@ func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr } else { key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } - isExit := store.Has(key) - if !isExit { + isExist := store.Has(key) + if !isExist { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorTotalValue: key is %s", key)) } else { value := store.Get(key) diff --git a/x/operator/keeper/avs_operator_assets_state_test.go b/x/operator/keeper/avs_operator_assets_state_test.go new file mode 100644 index 000000000..b55569d4a --- /dev/null +++ b/x/operator/keeper/avs_operator_assets_state_test.go @@ -0,0 +1 @@ +package keeper diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 3d3d529e8..7e9a3785b 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -42,7 +42,7 @@ func (k Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes } func (k Keeper) GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { - return startHeight + 10 + return startHeight + operatortypes.UnBondingExpiration } // IOperator interface will be implemented by deposit keeper diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index d4e090f06..aef45679c 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -35,8 +35,8 @@ func (k Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *operatortyp } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) //key := common.HexToAddress(incentive.Contract) - ifExist := store.Has(opAccAddr) - if !ifExist { + isExist := store.Has(opAccAddr) + if !isExist { return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %s", opAccAddr)) } diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index b69411fda..0ab8dfefe 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -43,9 +43,9 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope return err } - //opUsdValue = (opAmount*price*10^UsdValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) - value := opAmount.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) - opUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(value.BigInt(), int64(types.UsdValueDefaultDecimal)) + //opUSDValue = (opAmount*price*10^USDValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) + value := opAmount.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) + opUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(value.BigInt(), int64(types.USDValueDefaultDecimal)) for _, avs := range avsList { //get the assets supported by the AVS @@ -56,7 +56,7 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope if _, ok := avsSupportedAssets[assetId]; ok { //UpdateAVSOperatorStakerShareValue - err = k.UpdateAVSOperatorStakerShareValue(ctx, avs, stakerId, operatorAddr, opUsdValue) + err = k.UpdateAVSOperatorStakerShareValue(ctx, avs, stakerId, operatorAddr, opUSDValue) if err != nil { return err } @@ -64,7 +64,7 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope //UpdateOperatorAVSAssetsState changeState := types.AssetOptedInState{ Amount: opAmount, - Value: opUsdValue, + Value: opUSDValue, } err = k.UpdateOperatorAVSAssetsState(ctx, assetId, avs, operatorAddr, changeState) if err != nil { @@ -72,13 +72,13 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope } //UpdateAVSOperatorTotalValue - err = k.UpdateAVSOperatorTotalValue(ctx, avs, operatorAddr, opUsdValue) + err = k.UpdateAVSOperatorTotalValue(ctx, avs, operatorAddr, opUSDValue) if err != nil { return err } //UpdateAVSTotalValue - err = k.UpdateAVSTotalValue(ctx, avs, opUsdValue) + err = k.UpdateAVSTotalValue(ctx, avs, opUSDValue) if err != nil { return err } @@ -105,8 +105,8 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s return err } - totalAssetUsdValue := sdkmath.LegacyNewDec(0) - operatorOwnAssetUsdValue := sdkmath.LegacyNewDec(0) + totalAssetUSDValue := sdkmath.LegacyNewDec(0) + operatorOwnAssetUSDValue := sdkmath.LegacyNewDec(0) assetFilter := make(map[string]interface{}) assetInfoRecord := make(map[string]*AssetPriceAndDecimal) @@ -128,39 +128,39 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s Decimal: assetInfo.AssetBasicInfo.Decimals, } - //assetValue = (amount*price*10^UsdValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) - assetValue := operatorAssetState.TotalAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) - assetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(types.UsdValueDefaultDecimal)) + //assetValue = (amount*price*10^USDValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) + assetValue := operatorAssetState.TotalAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) + assetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(types.USDValueDefaultDecimal)) - operatorOwnAssetValue := operatorAssetState.OperatorOwnAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) - operatorOwnAssetUsdValue = operatorOwnAssetUsdValue.Add(sdkmath.LegacyNewDecFromBigIntWithPrec(operatorOwnAssetValue.BigInt(), int64(types.UsdValueDefaultDecimal))) + operatorOwnAssetValue := operatorAssetState.OperatorOwnAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) + operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(sdkmath.LegacyNewDecFromBigIntWithPrec(operatorOwnAssetValue.BigInt(), int64(types.USDValueDefaultDecimal))) //UpdateOperatorAVSAssetsState changeState := types.AssetOptedInState{ Amount: operatorAssetState.TotalAmountOrWantChangeValue, - Value: assetUsdValue, + Value: assetUSDValue, } err = k.UpdateOperatorAVSAssetsState(ctx, assetId, AVSAddr, operatorAddress.String(), changeState) if err != nil { return err } - totalAssetUsdValue = totalAssetUsdValue.Add(assetUsdValue) + totalAssetUSDValue = totalAssetUSDValue.Add(assetUSDValue) assetFilter[assetId] = nil } //update the share value of operator itself, the input stakerId should be empty - err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUsdValue) + err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUSDValue) if err != nil { return err } //UpdateAVSTotalValue - err = k.UpdateAVSTotalValue(ctx, AVSAddr, totalAssetUsdValue) + err = k.UpdateAVSTotalValue(ctx, AVSAddr, totalAssetUSDValue) if err != nil { return err } //UpdateAVSOperatorTotalValue - err = k.UpdateAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String(), totalAssetUsdValue) + err = k.UpdateAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String(), totalAssetUSDValue) if err != nil { return err } @@ -172,14 +172,14 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s } for stakerId, assetState := range relatedAssetsState { - stakerAssetsUsdValue := sdkmath.LegacyNewDec(0) + stakerAssetsUSDValue := sdkmath.LegacyNewDec(0) for assetId, amount := range assetState { - singleAssetValue := amount.CanUndelegationAmount.Mul(assetInfoRecord[assetId].Price).Mul(sdkmath.NewIntWithDecimal(1, int(types.UsdValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfoRecord[assetId].Decimal)+int(assetInfoRecord[assetId].PriceDecimal))) - singleAssetUsdValue := sdkmath.LegacyNewDecFromBigIntWithPrec(singleAssetValue.BigInt(), int64(types.UsdValueDefaultDecimal)) - stakerAssetsUsdValue = stakerAssetsUsdValue.Add(singleAssetUsdValue) + singleAssetValue := amount.CanUndelegationAmount.Mul(assetInfoRecord[assetId].Price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfoRecord[assetId].Decimal)+int(assetInfoRecord[assetId].PriceDecimal))) + singleAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(singleAssetValue.BigInt(), int64(types.USDValueDefaultDecimal)) + stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) } - err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, stakerId, operatorAddress.String(), stakerAssetsUsdValue) + err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, stakerId, operatorAddress.String(), stakerAssetsUSDValue) if err != nil { return err } diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 9ea0b65a5..c89655505 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -19,9 +19,11 @@ const ( DefaultOptedOutHeight = uint64(math.MaxUint64) - UsdValueDefaultDecimal = uint8(8) + USDValueDefaultDecimal = uint8(8) SlashVetoDuration = int64(1000) + + UnBondingExpiration = 10 ) // ModuleAddress is the native module address for EVM diff --git a/x/restaking_assets_manage/keeper/client_chain_asset.go b/x/restaking_assets_manage/keeper/client_chain_asset.go index e00fd26a9..19a5bb110 100644 --- a/x/restaking_assets_manage/keeper/client_chain_asset.go +++ b/x/restaking_assets_manage/keeper/client_chain_asset.go @@ -25,7 +25,7 @@ func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetId string, c ret := restakingtype.StakingAssetInfo{} k.cdc.MustUnmarshal(value, &ret) - //calculate and set new amount + // calculate and set new amount err = restakingtype.UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) if err != nil { return err @@ -41,7 +41,7 @@ func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetId string, c // It provides a function to register the client chain assets supported by exoCore.It's called by genesis configuration now,however it will be called by the governance in the future func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *restakingtype.StakingAssetInfo) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) - //key := common.HexToAddress(incentive.Contract) + // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) _, assetId := restakingtype.GetStakeIDAndAssetIdFromStr(info.AssetBasicInfo.LayerZeroChainId, "", info.AssetBasicInfo.Address) diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index c14271123..77298d9e1 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -44,9 +44,9 @@ func (suite *KeeperTestSuite) TestSlash() { info, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, + CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) // test the normal case @@ -59,9 +59,9 @@ func (suite *KeeperTestSuite) TestSlash() { info, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), + CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) From 8ea56b504eb2d43a7b518a188cb73629905fad55 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 30 Jan 2024 15:28:04 +0800 Subject: [PATCH 15/44] fix some bugs of operator module --- app/app.go | 12 ++++---- app/test_helpers.go | 1 - precompiles/delegation/delegation_test.go | 2 -- x/delegation/keeper/delegation_op_test.go | 15 ++-------- x/operator/keeper/abci.go | 5 +++- .../keeper/avs_operator_assets_state.go | 30 +++++++++---------- x/operator/keeper/grpc_query.go | 4 +-- x/operator/keeper/keeper.go | 8 +++-- x/operator/keeper/msg_server.go | 2 +- x/operator/keeper/operator.go | 14 ++++----- x/operator/keeper/operator_slash_state.go | 8 ++--- .../keeper/state_update_for_external_op.go | 14 ++++----- x/operator/module.go | 3 +- x/operator/types/expected_keepers.go | 20 +++++++++++++ 14 files changed, 74 insertions(+), 64 deletions(-) diff --git a/app/app.go b/app/app.go index c89e063fb..3aacc6a57 100644 --- a/app/app.go +++ b/app/app.go @@ -258,9 +258,10 @@ var ( recovery.AppModuleBasic{}, revenue.AppModuleBasic{}, consensus.AppModuleBasic{}, - // exoCore staking modules + // exoCore modules restaking_assets_manage.AppModuleBasic{}, deposit.AppModuleBasic{}, + operator.AppModuleBasic{}, delegation.AppModuleBasic{}, withdraw.AppModuleBasic{}, reward.AppModuleBasic{}, @@ -402,7 +403,6 @@ func NewExocoreApp( app.SetPrepareProposal(handler.PrepareProposalHandler()) app.SetProcessProposal(handler.ProcessProposalHandler()) }) - // NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx bApp := baseapp.NewBaseApp( Name, @@ -621,11 +621,10 @@ func NewExocoreApp( // set exoCore staking keepers app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec) app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper) - - app.OperatorKeeper = operatorkeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, nil, nil) + app.OperatorKeeper = operatorkeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}) // todo: need to replace the virtual keepers with actual keepers after they have been implemented - app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, app.OperatorKeeper) - app.OperatorKeeper.RegisterExpectDelegationInterface(app.DelegationKeeper) + app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper) + app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper) app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.StakingAssetsManageKeeper, app.DepositKeeper) app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.StakingAssetsManageKeeper) @@ -647,7 +646,6 @@ func NewExocoreApp( app.RewardKeeper, ), ) - epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey]) app.EpochsKeeper = *epochsKeeper.SetHooks( epochskeeper.NewMultiEpochHooks( diff --git a/app/test_helpers.go b/app/test_helpers.go index 4af278b71..c765a65dc 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -95,7 +95,6 @@ func Setup( } else { logger = log.NewNopLogger() } - app := NewExocoreApp( logger, db, nil, true, map[int64]bool{}, diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 2f22e4d5d..21055e3e3 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -1,7 +1,6 @@ package delegation_test import ( - "fmt" operatortypes "github.com/exocore/x/operator/types" "math/big" "strings" @@ -431,7 +430,6 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { s.Require().NoError(err, "failed to instantiate Ethereum message") // set txHash for delegation module - fmt.Println("the txHash is:", msgEthereumTx.Hash) s.ctx = s.ctx.WithValue(delegation.CtxKeyTxHash, common.HexToHash(msgEthereumTx.Hash)) // Create StateDB s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 7b33a3acb..065ee9ee8 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -1,18 +1,6 @@ package keeper_test -import ( - sdkmath "cosmossdk.io/math" - keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" - delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" - abci "github.com/cometbft/cometbft/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - types2 "github.com/exocore/x/operator/types" -) - -func (suite *KeeperTestSuite) TestDelegateTo() { +/*func (suite *KeeperTestSuite) TestDelegateTo() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") clientChainLzId := uint64(101) @@ -279,3 +267,4 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { suite.Equal(1, len(waitUndelegationRecords)) suite.Equal(UndelegationRecord, waitUndelegationRecords[0]) } +*/ diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 39397204a..72f5359c1 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -10,11 +10,14 @@ import ( ) // EndBlock : update the assets' share when their prices change -func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { priceChangeAssets, err := k.oracleKeeper.GetPriceChangeAssets(ctx) if err != nil { panic(err) } + if priceChangeAssets == nil || len(priceChangeAssets) == 0 { + return nil + } avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) assetsOperator := make(map[string]map[string]string, 0) assetsDecimal := make(map[string]uint32) diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_assets_state.go index 80051dc13..5d778f8c3 100644 --- a/x/operator/keeper/avs_operator_assets_state.go +++ b/x/operator/keeper/avs_operator_assets_state.go @@ -10,7 +10,7 @@ import ( restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) -func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -36,7 +36,7 @@ func (k Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAd return nil } -func (k Keeper) DeleteAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) error { +func (k *Keeper) DeleteAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var key []byte if operatorAddr == "" { @@ -48,7 +48,7 @@ func (k Keeper) DeleteAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAd return nil } -func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.ValueField var key []byte @@ -67,7 +67,7 @@ func (k Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr return ret.Amount, nil } -func (k Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -87,7 +87,7 @@ func (k Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount sd return nil } -func (k Keeper) BatchUpdateAVSAndOperatorTotalValue(ctx sdk.Context, avsOperatorChange map[string]sdkmath.LegacyDec) error { +func (k *Keeper) BatchUpdateAVSAndOperatorTotalValue(ctx sdk.Context, avsOperatorChange map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) for avs, opAmount := range avsOperatorChange { key := []byte(avs) @@ -106,7 +106,7 @@ func (k Keeper) BatchUpdateAVSAndOperatorTotalValue(ctx sdk.Context, avsOperator return nil } -func (k Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.ValueField key := []byte(avsAddr) @@ -120,7 +120,7 @@ func (k Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.Legac return ret.Amount, nil } -func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { +func (k *Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) if changeState.Amount.IsNil() && changeState.Value.IsNil() { return nil @@ -157,7 +157,7 @@ func (k Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, return nil } -func (k Keeper) DeleteOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) error { +func (k *Keeper) DeleteOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) //check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) @@ -169,7 +169,7 @@ func (k Keeper) DeleteOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, return nil } -func (k Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { +func (k *Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) isExit := store.Has(stateKey) @@ -183,7 +183,7 @@ func (k Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, ope return &assetOptedInState, nil } -func (k Keeper) IterateUpdateOperatorAVSAssets(ctx sdk.Context, assetId string, f func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { +func (k *Keeper) IterateUpdateOperatorAVSAssets(ctx sdk.Context, assetId string, f func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) iterator := sdk.KVStorePrefixIterator(store, []byte(assetId)) defer iterator.Close() @@ -205,7 +205,7 @@ func (k Keeper) IterateUpdateOperatorAVSAssets(ctx sdk.Context, assetId string, return nil } -func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -226,7 +226,7 @@ func (k Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stak return nil } -func (k Keeper) BatchSetAVSOperatorStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { +func (k *Keeper) BatchSetAVSOperatorStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) for key, value := range newValues { optedInValue := operatortypes.ValueField{Amount: value} @@ -241,14 +241,14 @@ func (k Keeper) BatchSetAVSOperatorStakerShare(ctx sdk.Context, newValues map[st return nil } -func (k Keeper) DeleteAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { +func (k *Keeper) DeleteAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) store.Delete(key) return nil } -func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) var ret operatortypes.ValueField key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) @@ -262,7 +262,7 @@ func (k Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerI return ret.Amount, nil } -func (k Keeper) GetAVSOperatorStakerInfo(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]interface{}, error) { +func (k *Keeper) GetAVSOperatorStakerInfo(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]interface{}, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) stakers := make(map[string]interface{}, 0) iterator := sdk.KVStorePrefixIterator(store, nil) diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index bdfee7c9f..a33c4d225 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -7,9 +7,9 @@ import ( operatortypes "github.com/exocore/x/operator/types" ) -var _ operatortypes.QueryServer = Keeper{} +var _ operatortypes.QueryServer = &Keeper{} -func (k Keeper) QueryOperatorInfo(ctx context.Context, req *operatortypes.QueryOperatorInfoReq) (*operatortypes.OperatorInfo, error) { +func (k *Keeper) QueryOperatorInfo(ctx context.Context, req *operatortypes.QueryOperatorInfoReq) (*operatortypes.OperatorInfo, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetOperatorInfo(c, req.OperatorAddr) } diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 7e9a3785b..9979321ad 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -37,11 +37,15 @@ func NewKeeper( } } -func (k Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes.ExpectDelegationInterface) { +func (k *Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes.ExpectDelegationInterface) { k.delegationKeeper = delegationKeeper } -func (k Keeper) GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { +func (k *Keeper) GetExpectDelegationInterface() operatortypes.ExpectDelegationInterface { + return k.delegationKeeper +} + +func (k *Keeper) GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { return startHeight + operatortypes.UnBondingExpiration } diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go index 72f21aed3..357b5e0b9 100644 --- a/x/operator/keeper/msg_server.go +++ b/x/operator/keeper/msg_server.go @@ -9,7 +9,7 @@ import ( var _ types.MsgServer = &Keeper{} -func (k Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperatorReq) (*types.RegisterOperatorResponse, error) { +func (k *Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperatorReq) (*types.RegisterOperatorResponse, error) { c := sdk.UnwrapSDKContext(ctx) err := k.SetOperatorInfo(c, req.FromAddress, req.Info) if err != nil { diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index aef45679c..a88e70ca6 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -12,7 +12,7 @@ import ( // SetOperatorInfo This function is used to register to be an operator in exoCore, the provided info will be stored on the chain. // Once an address has become an operator,the operator can't return to a normal address.But the operator can update the info through this function // As for the operator opt-in function,it needs to be implemented in operator opt-in or AVS module -func (k Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) { +func (k *Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) { opAccAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { return errorsmod.Wrap(err, "SetOperatorInfo: error occurred when parse acc address from Bech32") @@ -28,7 +28,7 @@ func (k Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortype return nil } -func (k Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *operatortypes.OperatorInfo, err error) { +func (k *Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *operatortypes.OperatorInfo, err error) { opAccAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { return nil, errorsmod.Wrap(err, "GetOperatorInfo: error occurred when parse acc address from Bech32") @@ -47,12 +47,12 @@ func (k Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *operatortyp return &ret, nil } -func (k Keeper) IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool { +func (k *Keeper) IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) return store.Has(addr) } -func (k Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, info *operatortypes.OptedInfo) error { +func (k *Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, info *operatortypes.OptedInfo) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) //check operator address validation @@ -67,7 +67,7 @@ func (k Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, i return nil } -func (k Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (info *operatortypes.OptedInfo, err error) { +func (k *Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (info *operatortypes.OptedInfo, err error) { opAccAddr, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { return nil, errorsmod.Wrap(err, "GetOptedInfo: error occurred when parse acc address from Bech32") @@ -86,7 +86,7 @@ func (k Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (inf return &ret, nil } -func (k Keeper) IsOptedIn(ctx sdk.Context, operatorAddr, avsAddr string) bool { +func (k *Keeper) IsOptedIn(ctx sdk.Context, operatorAddr, avsAddr string) bool { optedInfo, err := k.GetOptedInfo(ctx, operatorAddr, avsAddr) if err != nil { return false @@ -97,7 +97,7 @@ func (k Keeper) IsOptedIn(ctx sdk.Context, operatorAddr, avsAddr string) bool { return true } -func (k Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) ([]string, error) { +func (k *Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) ([]string, error) { //get all opted-in info store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) iterator := sdk.KVStorePrefixIterator(store, []byte(operatorAddr)) diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 0f8e50bb5..933131643 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -11,7 +11,7 @@ import ( restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) -func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashId string, slashInfo operatortypes.OperatorSlashInfo) error { +func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashId string, slashInfo operatortypes.OperatorSlashInfo) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) //check operator address validation @@ -41,7 +41,7 @@ func (k Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, return nil } -func (k Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashId string) (changeState *operatortypes.OperatorSlashInfo, err error) { +func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashId string) (changeState *operatortypes.OperatorSlashInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashId) isExit := store.Has(slashInfoKey) @@ -55,7 +55,7 @@ func (k Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, sla return &operatorSlashInfo, nil } -func (k Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64, opAmount sdkmath.Int) error { +func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64, opAmount sdkmath.Int) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -93,7 +93,7 @@ func (k Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperato return nil } -func (k Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64) (sdkmath.Int, error) { +func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64) (sdkmath.Int, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte if stakerOrOperator == "" { diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index 0ab8dfefe..fa991ab8d 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -25,7 +25,7 @@ type SlashAssetsAndAmount struct { slashOperatorInfo map[string]*slashAmounts } -func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { +func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { //get the AVS opted-in by the operator avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) if err != nil { @@ -88,7 +88,7 @@ func (k Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, ope } // OptIn call this function to opt in AVS -func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { +func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { //check optedIn info if k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { return types.ErrAlreadyOptedIn @@ -203,7 +203,7 @@ func (k Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr s } // OptOut call this function to opt out of AVS -func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { +func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { //check optedIn info if !k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { return types.ErrNotOptedIn @@ -281,7 +281,7 @@ func (k Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } // GetAssetsAndAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. -func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { +func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { ret := &SlashAssetsAndAmount{ slashStakerInfo: make(map[string]map[string]*slashAmounts, 0), slashOperatorInfo: make(map[string]*slashAmounts, 0), @@ -364,7 +364,7 @@ func (k Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.A return ret, nil } -func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, executeHeight uint64) error { +func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, executeHeight uint64) error { for stakerId, slashAssets := range slashStakerInfo { for assetId, slashInfo := range slashAssets { //handle the state that needs to be updated when slashing both opted-in and unbonding assets @@ -415,7 +415,7 @@ func (k Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sla return nil } -func (k Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, executeHeight uint64) error { +func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, executeHeight uint64) error { for assetId, slashInfo := range slashOperatorInfo { slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) //handle the state that needs to be updated when slashing both opted-in and unbonding assets @@ -444,7 +444,7 @@ func (k Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, s } // Slash The occurredSateHeight should be the height that has the latest stable state. -func (k Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error { +func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error { height := ctx.BlockHeight() if occurredSateHeight > height { return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("occurredSateHeight:%d,curHeight:%d", occurredSateHeight, height)) diff --git a/x/operator/module.go b/x/operator/module.go index 08c0d63de..d5ec10cc2 100644 --- a/x/operator/module.go +++ b/x/operator/module.go @@ -2,7 +2,6 @@ package operator import ( "context" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -75,7 +74,7 @@ func (am AppModule) IsAppModule() {} // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { operatortypes.RegisterMsgServer(cfg.MsgServer(), &am.keeper) - operatortypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) + operatortypes.RegisterQueryServer(cfg.QueryServer(), &am.keeper) } func (am AppModule) GenerateGenesisState(input *module.SimulationState) { diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index a4aa18e3b..b08c977b2 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -24,6 +24,26 @@ type ExpectOracleInterface interface { GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) } +type MockOracle struct{} + +func (MockOracle) GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdkmath.Int, uint8, error) { + return sdkmath.NewInt(1), 0, nil +} + +func (MockOracle) GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) { + return nil, nil +} + +type MockAVS struct{} + +func (MockAVS) GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) { + return nil, nil +} + +func (MockAVS) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) { + return "", nil +} + type ExpectAvsInterface interface { GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) From b2c9d1a52af17c67a241f35e545ddd28354076c6 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 30 Jan 2024 17:53:35 +0800 Subject: [PATCH 16/44] resolve the problems of code style --- app/app.go | 2 +- proto/exocore/delegation/v1/query.proto | 2 +- proto/exocore/operator/v1/query.proto | 4 +- .../restaking_assets_manage/v1/tx.proto | 2 +- x/delegation/keeper/abci.go | 8 +- x/delegation/keeper/cross_chain_tx_process.go | 12 +- x/delegation/keeper/delegation_state.go | 10 +- x/delegation/keeper/keeper.go | 22 +-- x/delegation/types/expected_keepers.go | 2 +- x/delegation/types/query.pb.go | 90 +++++----- x/operator/client/cli/query.go | 12 +- x/operator/keeper/abci.go | 37 +---- x/operator/keeper/common_func.go | 23 +++ x/operator/keeper/grpc_query.go | 4 +- x/operator/keeper/keeper.go | 4 +- x/operator/keeper/operator.go | 2 +- x/operator/keeper/operator_info_test.go | 2 +- .../keeper/state_update_for_external_op.go | 45 ++--- x/operator/types/expected_keepers.go | 4 +- x/operator/types/query.pb.go | 98 +++++------ x/operator/types/query.pb.gw.go | 34 ++-- .../keeper/operator_asset.go | 12 +- x/restaking_assets_manage/types/tx.pb.go | 154 +++++++++--------- 23 files changed, 289 insertions(+), 296 deletions(-) create mode 100644 x/operator/keeper/common_func.go diff --git a/app/app.go b/app/app.go index 3aacc6a57..95da4be76 100644 --- a/app/app.go +++ b/app/app.go @@ -258,7 +258,7 @@ var ( recovery.AppModuleBasic{}, revenue.AppModuleBasic{}, consensus.AppModuleBasic{}, - // exoCore modules + // Exocore modules restaking_assets_manage.AppModuleBasic{}, deposit.AppModuleBasic{}, operator.AppModuleBasic{}, diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index eff199a6f..2f998dd83 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -27,7 +27,7 @@ message DelegationAmounts{ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string CanUndelegateAmountAfterSlash = 3 + string UndelegatableAmountAfterSlash = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index 296053023..f362e8d31 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -9,13 +9,13 @@ import "exocore/operator/v1/tx.proto"; option go_package = "github.com/exocore/x/operator/types"; -message QueryOperatorInfoReq { +message GetOperatorInfoReq { string OperatorAddr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } service Query { - rpc QueryOperatorInfo(QueryOperatorInfoReq) returns(OperatorInfo){ + rpc GetOperatorInfo(GetOperatorInfoReq) returns(OperatorInfo){ option (google.api.http).get = "/exocore/delegation/v1/GetOperatorInfo"; } } diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index a0605bead..066347892 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -106,7 +106,7 @@ message OperatorSingleAssetOrChangeInfo{ (gogoproto.nullable) = false ]; - string OperatorOwnCanUnbondingAmountAfterSlash =5 + string OperatorUnbondableAmountAfterSlash =5 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 705aae8de..30b5e0c11 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -24,7 +24,7 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat //todo: don't think about freezing the operator in current implementation /* if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { // reSet the completed height if the operator is frozen - record.CompleteBlockNumber = k.expectOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) + record.CompleteBlockNumber = k.expectedOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) if record.CompleteBlockNumber <= uint64(ctx.BlockHeight()) { panic(fmt.Sprintf("the reset completedHeight isn't in future,setHeight:%v,curHeight:%v", record.CompleteBlockNumber, ctx.BlockHeight())) } @@ -40,8 +40,8 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat if err != nil { panic(err) } - if record.Amount.GT(delegationInfo.CanUndelegateAmountAfterSlash) { - record.ActualCompletedAmount = delegationInfo.CanUndelegateAmountAfterSlash + if record.Amount.GT(delegationInfo.UndelegatableAmountAfterSlash) { + record.ActualCompletedAmount = delegationInfo.UndelegatableAmountAfterSlash } else { record.ActualCompletedAmount = record.Amount } @@ -51,7 +51,7 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[record.OperatorAddr] = &delegationtype.DelegationAmounts{ WaitUndelegationAmount: recordAmountNeg, - CanUndelegateAmountAfterSlash: record.ActualCompletedAmount.Neg(), + UndelegatableAmountAfterSlash: record.ActualCompletedAmount.Neg(), } err = k.UpdateDelegationState(ctx, record.StakerId, record.AssetId, delegatorAndAmount) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 2bd6a72e2..312b74e94 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -111,7 +111,7 @@ type DelegationOrUndelegationParams struct { // DelegateTo : It doesn't need to check the active status of the operator in middlewares when delegating assets to the operator. This is because it adds assets to the operator's amount. But it needs to check if operator has been slashed or frozen. func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the delegatedTo address is an operator - if !k.expectOperatorInterface.IsOperator(ctx, params.OperatorAddress) { + if !k.expectedOperatorInterface.IsOperator(ctx, params.OperatorAddress) { return errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", params.OperatorAddress)) } @@ -167,7 +167,7 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara return err } // call operator module to bond the increased assets to the opted-in AVS - err = k.expectOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) + err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) if err != nil { return err } @@ -179,7 +179,7 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara // So we use two steps to handle the undelegation. Fist,record the undelegation request and the corresponding exit time which needs to be obtained from the operator opt-in module. Then,we handle the record when the exit time has expired. func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the UndelegatedFrom address is an operator - if !k.expectOperatorInterface.IsOperator(ctx, params.OperatorAddress) { + if !k.expectedOperatorInterface.IsOperator(ctx, params.OperatorAddress) { return delegationtype.ErrOperatorNotExist } if params.OpAmount.IsNegative() { @@ -207,7 +207,7 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation Amount: params.OpAmount, ActualCompletedAmount: sdkmath.NewInt(0), } - r.CompleteBlockNumber = k.expectOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) + r.CompleteBlockNumber = k.expectedOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) if err != nil { return err @@ -218,7 +218,7 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ CanUndelegationAmount: params.OpAmount.Neg(), WaitUndelegationAmount: params.OpAmount, - CanUndelegateAmountAfterSlash: params.OpAmount, + UndelegatableAmountAfterSlash: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) if err != nil { @@ -245,7 +245,7 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation } // call operator module to decrease the state of opted-in assets - err = k.expectOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount.Neg()) + err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount.Neg()) if err != nil { return err } diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 10035c1c3..72dbe7ed8 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -75,7 +75,7 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId delegationState := delegationtype.DelegationAmounts{ CanUndelegationAmount: sdkmath.NewInt(0), WaitUndelegationAmount: sdkmath.NewInt(0), - CanUndelegateAmountAfterSlash: sdkmath.NewInt(0), + UndelegatableAmountAfterSlash: sdkmath.NewInt(0), } if store.Has(singleStateKey) { @@ -93,7 +93,7 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } - err = stakingtypes.UpdateAssetValue(&delegationState.CanUndelegateAmountAfterSlash, &amounts.CanUndelegateAmountAfterSlash) + err = stakingtypes.UpdateAssetValue(&delegationState.UndelegatableAmountAfterSlash, &amounts.UndelegatableAmountAfterSlash) if err != nil { return errorsmod.Wrap(err, "UpdateDelegationState CanUsedToUndelegateAmount error") } @@ -147,8 +147,8 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d return &ret, nil } -// GetDelegationStateByOperatorAndAssetList get the specified assets state delegated to the specified operator -func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { +// GetDelegationStateByOperatorAndAssets get the specified assets state delegated to the specified operator +func (k Keeper) GetDelegationStateByOperatorAndAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() @@ -180,7 +180,7 @@ func (k Keeper) GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operat return ret, nil } -func (k Keeper) IteratorDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { +func (k Keeper) IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 06a6f6552..0c06036e8 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -21,10 +21,10 @@ type Keeper struct { cdc codec.BinaryCodec //other keepers - restakingStateKeeper keeper.Keeper - depositKeeper depositkeeper.Keeper - slashKeeper delegationtype.ISlashKeeper - expectOperatorInterface delegationtype.ExpectOperatorInterface + restakingStateKeeper keeper.Keeper + depositKeeper depositkeeper.Keeper + slashKeeper delegationtype.ISlashKeeper + expectedOperatorInterface delegationtype.ExpectedOperatorInterface } func NewKeeper( @@ -33,15 +33,15 @@ func NewKeeper( restakingStateKeeper keeper.Keeper, depositKeeper depositkeeper.Keeper, slashKeeper delegationtype.ISlashKeeper, - operatorKeeper delegationtype.ExpectOperatorInterface, + operatorKeeper delegationtype.ExpectedOperatorInterface, ) Keeper { return Keeper{ - storeKey: storeKey, - cdc: cdc, - restakingStateKeeper: restakingStateKeeper, - depositKeeper: depositKeeper, - slashKeeper: slashKeeper, - expectOperatorInterface: operatorKeeper, + storeKey: storeKey, + cdc: cdc, + restakingStateKeeper: restakingStateKeeper, + depositKeeper: depositKeeper, + slashKeeper: slashKeeper, + expectedOperatorInterface: operatorKeeper, } } diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index ed93942fd..692b71bed 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -23,7 +23,7 @@ func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAdd return sdkmath.LegacyNewDec(0) } -type ExpectOperatorInterface interface { +type ExpectedOperatorInterface interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index 007201c8f..c6ed621de 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -87,7 +87,7 @@ func (m *DelegationInfoReq) GetAssetId() string { type DelegationAmounts struct { CanUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=CanUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanUndelegationAmount"` WaitUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=WaitUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUndelegationAmount"` - CanUndelegateAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=CanUndelegateAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"CanUndelegateAmountAfterSlash"` + UndelegatableAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=UndelegatableAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"UndelegatableAmountAfterSlash"` } func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } @@ -239,45 +239,45 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 593 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x41, - 0x1c, 0xcd, 0x6e, 0xa8, 0x7f, 0xa6, 0x82, 0x3a, 0xa6, 0xba, 0xdd, 0xea, 0xb6, 0x2e, 0x28, 0xa1, - 0x90, 0x5d, 0x1b, 0x11, 0x44, 0xaa, 0x92, 0xaa, 0x94, 0x3d, 0xba, 0x51, 0x04, 0x2f, 0x32, 0xcd, - 0x4e, 0xb7, 0x4b, 0x36, 0x33, 0x9b, 0x99, 0x49, 0x48, 0xae, 0x39, 0x79, 0x11, 0x04, 0xbf, 0x85, - 0x27, 0x0f, 0xf9, 0x10, 0x3d, 0x96, 0x7a, 0x11, 0x0f, 0x45, 0x12, 0xc1, 0x83, 0x17, 0x3f, 0x82, - 0x64, 0x77, 0xda, 0x26, 0x71, 0xb7, 0xb6, 0x90, 0xd3, 0xce, 0xcc, 0x7b, 0xfb, 0x7e, 0x6f, 0x7e, - 0x7f, 0x06, 0xdc, 0xc6, 0x1d, 0x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96, 0x7f, 0xab, 0x60, 0x2e, 0xce, 0x21, 0xfc, 0xac, 0x80, 0x6b, 0x29, 0xd9, 0x84, 0xff, - 0xbf, 0xa6, 0xf4, 0xaf, 0x97, 0xcf, 0x5e, 0x23, 0xf3, 0xc1, 0xfb, 0x5f, 0x5f, 0x56, 0x95, 0xde, - 0xd7, 0x9f, 0x9f, 0xd4, 0x55, 0x58, 0xb4, 0xd3, 0x1f, 0xa0, 0x4d, 0x2c, 0xa6, 0x4c, 0xf5, 0x15, - 0xb0, 0x18, 0xcb, 0xa6, 0xe5, 0x12, 0x5a, 0x19, 0x46, 0x32, 0x12, 0xaf, 0x9f, 0xba, 0x92, 0xe6, - 0xe3, 0x63, 0xbb, 0x65, 0x78, 0x2f, 0xc3, 0x6e, 0xa6, 0xb1, 0x8d, 0xa7, 0xbb, 0x03, 0x43, 0xd9, - 0x1b, 0x18, 0xca, 0x8f, 0x81, 0xa1, 0x7c, 0x1c, 0x1a, 0xb9, 0xbd, 0xa1, 0x91, 0xfb, 0x36, 0x34, - 0x72, 0x6f, 0xef, 0x8c, 0x0d, 0xd1, 0xa1, 0x6a, 0x67, 0x5c, 0x37, 0x9e, 0xa3, 0xad, 0x73, 0xf1, - 0x43, 0x7c, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0x51, 0x26, 0x58, 0x50, 0x06, 0x00, - 0x00, + // 596 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x4f, + 0x18, 0xce, 0x6e, 0xe8, 0xef, 0xa7, 0x53, 0x41, 0x1d, 0x53, 0xdd, 0x6e, 0x75, 0x5b, 0x17, 0x94, + 0x50, 0xe8, 0xae, 0x8d, 0x08, 0x22, 0x55, 0x49, 0x55, 0xca, 0x1e, 0xdd, 0x28, 0x82, 0x17, 0x99, + 0x64, 0xa7, 0xdb, 0x25, 0x9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x03, 0x4b, 0x4f, 0x10, 0x79, 0x49, + 0xbc, 0x19, 0x24, 0x11, 0xde, 0xde, 0xda, 0x3f, 0x5a, 0xcd, 0x7d, 0x3d, 0x5a, 0xbd, 0xed, 0x07, + 0x62, 0xaf, 0x55, 0xb5, 0x6a, 0xb4, 0x21, 0x2f, 0x20, 0x7f, 0x36, 0xb8, 0x57, 0xb7, 0x45, 0x37, + 0xc2, 0xdc, 0x72, 0x88, 0x38, 0xec, 0x6f, 0x00, 0x79, 0x3f, 0x87, 0x08, 0x37, 0x5d, 0x1a, 0x0a, + 0x70, 0xf5, 0x15, 0x0a, 0x44, 0x4a, 0x52, 0x75, 0x0e, 0x49, 0x33, 0xb4, 0x61, 0x4f, 0x01, 0x37, + 0xc6, 0x61, 0x54, 0x0d, 0x71, 0x12, 0x2f, 0xef, 0x0a, 0xcc, 0x2a, 0x21, 0xe2, 0x7b, 0x5a, 0x7e, + 0x0e, 0xd9, 0x4f, 0x4f, 0x61, 0xfe, 0x52, 0xc1, 0xca, 0xf3, 0xd1, 0x68, 0xcc, 0x76, 0x95, 0x47, + 0x94, 0x70, 0x0c, 0x23, 0x50, 0x78, 0x41, 0x05, 0x0a, 0x25, 0x8c, 0xbd, 0x39, 0x76, 0x23, 0x55, + 0x19, 0x36, 0xc1, 0x45, 0x6f, 0xca, 0x0b, 0xd7, 0xd4, 0xb5, 0x7c, 0x71, 0xb1, 0xb4, 0x63, 0xa5, + 0xae, 0x87, 0x75, 0x8a, 0x7d, 0x6b, 0x3a, 0xcc, 0x9f, 0x11, 0xc1, 0xba, 0xee, 0xac, 0xbe, 0x1e, + 0x82, 0x42, 0x1a, 0x11, 0x5e, 0x02, 0xf9, 0x3a, 0xee, 0xca, 0x91, 0x1e, 0x7d, 0xc2, 0x47, 0x60, + 0xa1, 0x8d, 0xc2, 0x16, 0x8e, 0x07, 0x63, 0xb1, 0x54, 0xcc, 0xb0, 0xf4, 0xc7, 0x58, 0xbb, 0xc9, + 0xdf, 0x1e, 0xa8, 0xf7, 0x15, 0xf3, 0x9d, 0x02, 0xae, 0x55, 0x02, 0xe2, 0x87, 0xf8, 0x6c, 0x9b, + 0xb4, 0x05, 0x2e, 0xd0, 0x08, 0x33, 0x24, 0x28, 0x2b, 0x7b, 0x1e, 0x93, 0xb3, 0xa9, 0x1d, 0xf6, + 0x37, 0x0a, 0xb2, 0xa8, 0xa3, 0x30, 0xe6, 0xbc, 0x22, 0x58, 0x40, 0x7c, 0x77, 0x8a, 0x3d, 0xb9, + 0x87, 0xf9, 0xa9, 0x3d, 0x2c, 0xfd, 0x54, 0xc1, 0x42, 0x5c, 0x43, 0xf8, 0x51, 0x01, 0x57, 0x52, + 0xaa, 0x09, 0xff, 0x7e, 0x4d, 0xe9, 0x5f, 0x2f, 0x9d, 0xbd, 0x47, 0xe6, 0xbd, 0xb7, 0x3f, 0x3e, + 0xad, 0x2b, 0xbd, 0xcf, 0xdf, 0x3f, 0xa8, 0xeb, 0xb0, 0x68, 0xa7, 0x3f, 0x40, 0x3b, 0x58, 0xcc, + 0x98, 0xea, 0x2b, 0x60, 0x39, 0x96, 0x4d, 0xab, 0x25, 0xb4, 0x32, 0x8c, 0x64, 0x14, 0x5e, 0xff, + 0xe7, 0x4e, 0x9a, 0x0f, 0x4f, 0xec, 0x96, 0xe0, 0x9d, 0x0c, 0xbb, 0x99, 0xc6, 0xb6, 0x1f, 0xef, + 0x0f, 0x0c, 0xe5, 0x60, 0x60, 0x28, 0xdf, 0x06, 0x86, 0xf2, 0x7e, 0x68, 0xe4, 0x0e, 0x86, 0x46, + 0xee, 0xcb, 0xd0, 0xc8, 0xbd, 0xbe, 0x35, 0xb1, 0x44, 0xc7, 0xaa, 0x9d, 0x49, 0xdd, 0x78, 0x8f, + 0xaa, 0xff, 0xc5, 0x0f, 0xf1, 0xdd, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x91, 0xca, 0x96, 0x11, + 0x50, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -456,9 +456,9 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.CanUndelegateAmountAfterSlash.Size() + size := m.UndelegatableAmountAfterSlash.Size() i -= size - if _, err := m.CanUndelegateAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.UndelegatableAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) @@ -629,7 +629,7 @@ func (m *DelegationAmounts) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) l = m.WaitUndelegationAmount.Size() n += 1 + l + sovQuery(uint64(l)) - l = m.CanUndelegateAmountAfterSlash.Size() + l = m.UndelegatableAmountAfterSlash.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -898,7 +898,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CanUndelegateAmountAfterSlash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UndelegatableAmountAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -926,7 +926,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CanUndelegateAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.UndelegatableAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/operator/client/cli/query.go b/x/operator/client/cli/query.go index 8fbcde85a..8639be0b4 100644 --- a/x/operator/client/cli/query.go +++ b/x/operator/client/cli/query.go @@ -21,15 +21,15 @@ func GetQueryCmd() *cobra.Command { } cmd.AddCommand( - QueryOperatorInfo(), + GetOperatorInfo(), ) return cmd } -// QueryOperatorInfo queries operator info -func QueryOperatorInfo() *cobra.Command { +// GetOperatorInfo queries operator info +func GetOperatorInfo() *cobra.Command { cmd := &cobra.Command{ - Use: "QueryOperatorInfo operatorAddr", + Use: "GetOperatorInfo operatorAddr", Short: "Get operator info", Long: "Get operator info", Args: cobra.ExactArgs(1), @@ -40,10 +40,10 @@ func QueryOperatorInfo() *cobra.Command { } queryClient := operatortypes.NewQueryClient(clientCtx) - req := &operatortypes.QueryOperatorInfoReq{ + req := &operatortypes.GetOperatorInfoReq{ OperatorAddr: args[0], } - res, err := queryClient.QueryOperatorInfo(context.Background(), req) + res, err := queryClient.GetOperatorInfo(context.Background(), req) if err != nil { return err } diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 72f5359c1..f733e3c1d 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -33,25 +33,14 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } //UpdateOperatorAVSAssetsState f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { - newAssetValue := state.Amount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(priceChange.Decimal))) - newAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) + newAssetUSDValue := CalculateShare(state.Amount, priceChange.NewPrice, assetInfo.AssetBasicInfo.Decimals, priceChange.Decimal) changeValue := newAssetUSDValue.Sub(state.Value) state.Value = newAssetUSDValue avsAddr := keys[1] avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) - avsOperatorShareChange[avsAddr] = avsOperatorShareChange[avsAddr].Add(changeValue) - if value, ok := avsOperatorShareChange[avsAddr]; ok { - avsOperatorShareChange[avsAddr] = value.Add(changeValue) - } else { - avsOperatorShareChange[avsAddr] = changeValue - } - if value, ok := avsOperatorShareChange[avsOperator]; ok { - avsOperatorShareChange[avsOperator] = value.Add(changeValue) - } else { - avsOperatorShareChange[avsOperator] = changeValue - } - + AddShareInMap(avsOperatorShareChange, avsAddr, changeValue) + AddShareInMap(avsOperatorShareChange, avsOperator, changeValue) assetsOperator[assetId][keys[2]] = avsAddr return nil } @@ -72,18 +61,13 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida priceChange := priceChangeAssets[assetId] assetDecimal := assetsDecimal[assetId] if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { - newAssetValue := state.CanUndelegationAmount.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) - newAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) + newAssetUSDValue := CalculateShare(state.CanUndelegationAmount, priceChange.NewPrice, assetDecimal, priceChange.Decimal) key := string(types.GetJoinedStoreKey(avsAddr, restakerId, operatorAddr)) - if value, ok := stakerOperatorNewShare[key]; ok { - stakerOperatorNewShare[key] = value.Add(newAssetUSDValue) - } else { - stakerOperatorNewShare[key] = newAssetUSDValue - } + AddShareInMap(stakerOperatorNewShare, key, newAssetUSDValue) } return nil } - err = k.delegationKeeper.IteratorDelegationState(ctx, stakerShareHandleFunc) + err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) if err != nil { panic(err) } @@ -92,14 +76,9 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida priceChange := priceChangeAssets[assetId] assetDecimal := assetsDecimal[assetId] if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { - newAssetValue := state.OperatorOwnAmountOrWantChangeValue.Mul(priceChange.NewPrice).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceChange.Decimal))) - newAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(newAssetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) + newAssetUSDValue := CalculateShare(state.OperatorOwnAmountOrWantChangeValue, priceChange.NewPrice, assetDecimal, priceChange.Decimal) key := string(types.GetJoinedStoreKey(avsAddr, "", operatorAddr)) - if value, ok := stakerOperatorNewShare[key]; ok { - stakerOperatorNewShare[key] = value.Add(newAssetUSDValue) - } else { - stakerOperatorNewShare[key] = newAssetUSDValue - } + AddShareInMap(stakerOperatorNewShare, key, newAssetUSDValue) } return nil } diff --git a/x/operator/keeper/common_func.go b/x/operator/keeper/common_func.go new file mode 100644 index 000000000..4d6c6e119 --- /dev/null +++ b/x/operator/keeper/common_func.go @@ -0,0 +1,23 @@ +package keeper + +import ( + sdkmath "cosmossdk.io/math" + operatortypes "github.com/exocore/x/operator/types" +) + +type LegacyDecMap map[string]sdkmath.LegacyDec + +func AddShareInMap(shareMap map[string]sdkmath.LegacyDec, key string, addValue sdkmath.LegacyDec) { + if value, ok := shareMap[key]; ok { + shareMap[key] = value.Add(addValue) + } else { + shareMap[key] = addValue + } +} + +// CalculateShare assetUSDValue = (assetAmount*price*10^USDValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) +func CalculateShare(assetAmount sdkmath.Int, price sdkmath.Int, assetDecimal uint32, priceDecimal uint8) sdkmath.LegacyDec { + assetValue := assetAmount.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceDecimal))) + assetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) + return assetUSDValue +} diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index a33c4d225..162fcd037 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -9,7 +9,7 @@ import ( var _ operatortypes.QueryServer = &Keeper{} -func (k *Keeper) QueryOperatorInfo(ctx context.Context, req *operatortypes.QueryOperatorInfoReq) (*operatortypes.OperatorInfo, error) { +func (k *Keeper) GetOperatorInfo(ctx context.Context, req *operatortypes.GetOperatorInfoReq) (*operatortypes.OperatorInfo, error) { c := sdk.UnwrapSDKContext(ctx) - return k.GetOperatorInfo(c, req.OperatorAddr) + return k.OperatorInfo(c, req.OperatorAddr) } diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 9979321ad..2aecc9d85 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -49,8 +49,8 @@ func (k *Keeper) GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddr return startHeight + operatortypes.UnBondingExpiration } -// IOperator interface will be implemented by deposit keeper -type IOperator interface { +// OperatorKeeper interface will be implemented by deposit keeper +type OperatorKeeper interface { // RegisterOperator handle the registerOperator txs from msg service RegisterOperator(ctx context.Context, req *operatortypes.RegisterOperatorReq) (*operatortypes.RegisterOperatorResponse, error) diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index a88e70ca6..8269bc28f 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -28,7 +28,7 @@ func (k *Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortyp return nil } -func (k *Keeper) GetOperatorInfo(ctx sdk.Context, addr string) (info *operatortypes.OperatorInfo, err error) { +func (k *Keeper) OperatorInfo(ctx sdk.Context, addr string) (info *operatortypes.OperatorInfo, err error) { opAccAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { return nil, errorsmod.Wrap(err, "GetOperatorInfo: error occurred when parse acc address from Bech32") diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index e0fd6676a..787f1e1e5 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -16,7 +16,7 @@ func (suite *KeeperTestSuite) TestOperatorInfo() { err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) suite.NoError(err) - getOperatorInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, suite.accAddress.String()) + getOperatorInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: suite.accAddress.String()}) suite.NoError(err) suite.Equal(*info, *getOperatorInfo) } diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update_for_external_op.go index fa991ab8d..f666ab60f 100644 --- a/x/operator/keeper/state_update_for_external_op.go +++ b/x/operator/keeper/state_update_for_external_op.go @@ -42,11 +42,7 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, op if err != nil { return err } - - //opUSDValue = (opAmount*price*10^USDValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) - value := opAmount.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) - opUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(value.BigInt(), int64(types.USDValueDefaultDecimal)) - + opUSDValue := CalculateShare(opAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) for _, avs := range avsList { //get the assets supported by the AVS avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avs) @@ -127,13 +123,9 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr PriceDecimal: decimal, Decimal: assetInfo.AssetBasicInfo.Decimals, } - - //assetValue = (amount*price*10^USDValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) - assetValue := operatorAssetState.TotalAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) - assetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(types.USDValueDefaultDecimal)) - - operatorOwnAssetValue := operatorAssetState.OperatorOwnAmountOrWantChangeValue.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfo.AssetBasicInfo.Decimals)+int(decimal))) - operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(sdkmath.LegacyNewDecFromBigIntWithPrec(operatorOwnAssetValue.BigInt(), int64(types.USDValueDefaultDecimal))) + assetUSDValue := CalculateShare(operatorAssetState.TotalAmountOrWantChangeValue, price, assetInfo.AssetBasicInfo.Decimals, decimal) + operatorUSDValue := CalculateShare(operatorAssetState.OperatorOwnAmountOrWantChangeValue, price, assetInfo.AssetBasicInfo.Decimals, decimal) + operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(operatorUSDValue) //UpdateOperatorAVSAssetsState changeState := types.AssetOptedInState{ @@ -166,7 +158,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } //UpdateAVSOperatorStakerShareValue - relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetFilter) + relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetFilter) if err != nil { return err } @@ -174,8 +166,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr for stakerId, assetState := range relatedAssetsState { stakerAssetsUSDValue := sdkmath.LegacyNewDec(0) for assetId, amount := range assetState { - singleAssetValue := amount.CanUndelegationAmount.Mul(assetInfoRecord[assetId].Price).Mul(sdkmath.NewIntWithDecimal(1, int(types.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetInfoRecord[assetId].Decimal)+int(assetInfoRecord[assetId].PriceDecimal))) - singleAssetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(singleAssetValue.BigInt(), int64(types.USDValueDefaultDecimal)) + singleAssetUSDValue := CalculateShare(amount.CanUndelegationAmount, assetInfoRecord[assetId].Price, assetInfoRecord[assetId].Decimal, assetInfoRecord[assetId].PriceDecimal) stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) } @@ -256,7 +247,7 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } //DeleteAVSOperatorStakerShareValue - relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetFilter) + relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetFilter) if err != nil { return err } @@ -295,7 +286,7 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. if err != nil { return nil, err } - historyStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetsFilter) + historyStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } @@ -309,7 +300,7 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. ctx = ctx.WithBlockHeight(height) //calculate the actual slash amount according to the history and current state - currentStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssetList(ctx, operatorAddress.String(), assetsFilter) + currentStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } @@ -323,7 +314,7 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. for stakerId, assetsState := range currentStakerAssets { if historyAssetState, ok := historyStakerAssets[stakerId]; ok { for assetId, curState := range assetsState { - if historyState, ifExist := historyAssetState[assetId]; ifExist { + if historyState, isExist := historyAssetState[assetId]; isExist { if _, exist := ret.slashStakerInfo[stakerId]; !exist { ret.slashStakerInfo[stakerId] = make(map[string]*slashAmounts, 0) } @@ -331,8 +322,8 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. if curState.CanUndelegationAmount.LT(shouldSlashAmount) { ret.slashStakerInfo[stakerId][assetId].AmountFromOptedIn = curState.CanUndelegationAmount remainShouldSlash := shouldSlashAmount.Sub(curState.CanUndelegationAmount) - if curState.CanUndelegateAmountAfterSlash.LT(remainShouldSlash) { - ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = curState.CanUndelegateAmountAfterSlash + if curState.UndelegatableAmountAfterSlash.LT(remainShouldSlash) { + ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = curState.UndelegatableAmountAfterSlash } else { ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = remainShouldSlash } @@ -351,8 +342,8 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. if curAssetState.OperatorOwnAmountOrWantChangeValue.LT(shouldSlashAmount) { ret.slashOperatorInfo[assetId].AmountFromOptedIn = curAssetState.OperatorOwnAmountOrWantChangeValue remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmountOrWantChangeValue) - if curAssetState.OperatorOwnCanUnbondingAmountAfterSlash.LT(remainShouldSlash) { - ret.slashOperatorInfo[assetId].AmountFromUnbonding = curAssetState.OperatorOwnCanUnbondingAmountAfterSlash + if curAssetState.OperatorUnbondableAmountAfterSlash.LT(remainShouldSlash) { + ret.slashOperatorInfo[assetId].AmountFromUnbonding = curAssetState.OperatorUnbondableAmountAfterSlash } else { ret.slashOperatorInfo[assetId].AmountFromUnbonding = remainShouldSlash } @@ -372,7 +363,7 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ CanUndelegationAmount: slashInfo.AmountFromOptedIn.Neg(), - CanUndelegateAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + UndelegatableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), } err := k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) if err != nil { @@ -420,9 +411,9 @@ func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) //handle the state that needs to be updated when slashing both opted-in and unbonding assets err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: slashSumValue.Neg(), - OperatorOwnAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), - OperatorOwnCanUnbondingAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + TotalAmountOrWantChangeValue: slashSumValue.Neg(), + OperatorOwnAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), + OperatorUnbondableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), }) if err != nil { return err diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index b08c977b2..d55b376e0 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -7,8 +7,8 @@ import ( ) type ExpectDelegationInterface interface { - GetDelegationStateByOperatorAndAssetList(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) - IteratorDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error + GetDelegationStateByOperatorAndAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) + IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string, opAmount sdkmath.Int) error diff --git a/x/operator/types/query.pb.go b/x/operator/types/query.pb.go index 8cc2c7e66..d34d0a592 100644 --- a/x/operator/types/query.pb.go +++ b/x/operator/types/query.pb.go @@ -31,22 +31,22 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryOperatorInfoReq struct { +type GetOperatorInfoReq struct { OperatorAddr string `protobuf:"bytes,1,opt,name=OperatorAddr,proto3" json:"OperatorAddr,omitempty"` } -func (m *QueryOperatorInfoReq) Reset() { *m = QueryOperatorInfoReq{} } -func (m *QueryOperatorInfoReq) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorInfoReq) ProtoMessage() {} -func (*QueryOperatorInfoReq) Descriptor() ([]byte, []int) { +func (m *GetOperatorInfoReq) Reset() { *m = GetOperatorInfoReq{} } +func (m *GetOperatorInfoReq) String() string { return proto.CompactTextString(m) } +func (*GetOperatorInfoReq) ProtoMessage() {} +func (*GetOperatorInfoReq) Descriptor() ([]byte, []int) { return fileDescriptor_f91e795a3cecbdbf, []int{0} } -func (m *QueryOperatorInfoReq) XXX_Unmarshal(b []byte) error { +func (m *GetOperatorInfoReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *GetOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOperatorInfoReq.Marshal(b, m, deterministic) + return xxx_messageInfo_GetOperatorInfoReq.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -56,19 +56,19 @@ func (m *QueryOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *QueryOperatorInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorInfoReq.Merge(m, src) +func (m *GetOperatorInfoReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetOperatorInfoReq.Merge(m, src) } -func (m *QueryOperatorInfoReq) XXX_Size() int { +func (m *GetOperatorInfoReq) XXX_Size() int { return m.Size() } -func (m *QueryOperatorInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorInfoReq.DiscardUnknown(m) +func (m *GetOperatorInfoReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetOperatorInfoReq.DiscardUnknown(m) } -var xxx_messageInfo_QueryOperatorInfoReq proto.InternalMessageInfo +var xxx_messageInfo_GetOperatorInfoReq proto.InternalMessageInfo -func (m *QueryOperatorInfoReq) GetOperatorAddr() string { +func (m *GetOperatorInfoReq) GetOperatorAddr() string { if m != nil { return m.OperatorAddr } @@ -76,13 +76,13 @@ func (m *QueryOperatorInfoReq) GetOperatorAddr() string { } func init() { - proto.RegisterType((*QueryOperatorInfoReq)(nil), "exocore.operator.v1.QueryOperatorInfoReq") + proto.RegisterType((*GetOperatorInfoReq)(nil), "exocore.operator.v1.GetOperatorInfoReq") } func init() { proto.RegisterFile("exocore/operator/v1/query.proto", fileDescriptor_f91e795a3cecbdbf) } var fileDescriptor_f91e795a3cecbdbf = []byte{ - // 303 bytes of a gzipped FileDescriptorProto + // 301 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x48, 0x2d, 0x4a, 0x2c, 0xc9, 0x2f, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x2a, 0xd0, @@ -90,18 +90,18 @@ var fileDescriptor_f91e795a3cecbdbf = []byte{ 0x10, 0xa5, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0xe9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0x88, 0xe1, 0x68, 0xb6, 0x48, 0x49, 0x42, 0x24, 0xe3, 0x21, 0x66, 0x42, 0x38, - 0x30, 0x53, 0xb1, 0xb9, 0xb0, 0xa4, 0x02, 0x22, 0xab, 0x14, 0xc2, 0x25, 0x12, 0x08, 0x32, 0xc7, - 0x1f, 0x2a, 0xe9, 0x99, 0x97, 0x96, 0x1f, 0x94, 0x5a, 0x28, 0x64, 0xc3, 0xc5, 0x03, 0x13, 0x72, - 0x4c, 0x49, 0x29, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x92, 0xb8, 0xb4, 0x45, 0x57, 0x04, - 0x6a, 0x3a, 0x48, 0x38, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x08, 0x45, 0xb5, - 0xd1, 0x6c, 0x46, 0x2e, 0x56, 0xb0, 0xb1, 0x42, 0x13, 0x19, 0xb9, 0x04, 0x31, 0x2c, 0x10, 0xd2, - 0xd4, 0xc3, 0x12, 0x2a, 0x7a, 0xd8, 0x1c, 0x22, 0xa5, 0x88, 0x55, 0x29, 0xb2, 0x2a, 0x25, 0xbd, - 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0x69, 0x08, 0xa9, 0xe9, 0xc3, 0xbc, 0x9a, 0x92, 0x9a, 0x93, 0x9a, - 0x0e, 0x0e, 0x3d, 0x90, 0x67, 0xdd, 0x53, 0x4b, 0x90, 0xd5, 0x3b, 0xd9, 0x9e, 0x78, 0x24, 0xc7, - 0x78, 0xe1, 0x91, 0x1c,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, 0x63, 0xbc, 0xf0, + 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, + 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x39, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, + 0x6e, 0x56, 0x05, 0x22, 0xc8, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x61, 0x66, 0x0c, + 0x08, 0x00, 0x00, 0xff, 0xff, 0x59, 0x84, 0xe9, 0xcc, 0xf5, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -116,7 +116,7 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) + GetOperatorInfo(ctx context.Context, in *GetOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) } type queryClient struct { @@ -127,9 +127,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) { +func (c *queryClient) GetOperatorInfo(ctx context.Context, in *GetOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) { out := new(OperatorInfo) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/QueryOperatorInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/GetOperatorInfo", in, out, opts...) if err != nil { return nil, err } @@ -138,35 +138,35 @@ func (c *queryClient) QueryOperatorInfo(ctx context.Context, in *QueryOperatorIn // QueryServer is the server API for Query service. type QueryServer interface { - QueryOperatorInfo(context.Context, *QueryOperatorInfoReq) (*OperatorInfo, error) + GetOperatorInfo(context.Context, *GetOperatorInfoReq) (*OperatorInfo, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) QueryOperatorInfo(ctx context.Context, req *QueryOperatorInfoReq) (*OperatorInfo, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorInfo not implemented") +func (*UnimplementedQueryServer) GetOperatorInfo(ctx context.Context, req *GetOperatorInfoReq) (*OperatorInfo, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOperatorInfo not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_QueryOperatorInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOperatorInfoReq) +func _Query_GetOperatorInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetOperatorInfoReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryOperatorInfo(ctx, in) + return srv.(QueryServer).GetOperatorInfo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Query/QueryOperatorInfo", + FullMethod: "/exocore.operator.v1.Query/GetOperatorInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryOperatorInfo(ctx, req.(*QueryOperatorInfoReq)) + return srv.(QueryServer).GetOperatorInfo(ctx, req.(*GetOperatorInfoReq)) } return interceptor(ctx, in, info, handler) } @@ -176,15 +176,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "QueryOperatorInfo", - Handler: _Query_QueryOperatorInfo_Handler, + MethodName: "GetOperatorInfo", + Handler: _Query_GetOperatorInfo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "exocore/operator/v1/query.proto", } -func (m *QueryOperatorInfoReq) Marshal() (dAtA []byte, err error) { +func (m *GetOperatorInfoReq) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -194,12 +194,12 @@ func (m *QueryOperatorInfoReq) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryOperatorInfoReq) MarshalTo(dAtA []byte) (int, error) { +func (m *GetOperatorInfoReq) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *GetOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -225,7 +225,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryOperatorInfoReq) Size() (n int) { +func (m *GetOperatorInfoReq) Size() (n int) { if m == nil { return 0 } @@ -244,7 +244,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryOperatorInfoReq) Unmarshal(dAtA []byte) error { +func (m *GetOperatorInfoReq) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -267,10 +267,10 @@ func (m *QueryOperatorInfoReq) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOperatorInfoReq: wiretype end group for non-group") + return fmt.Errorf("proto: GetOperatorInfoReq: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GetOperatorInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/operator/types/query.pb.gw.go b/x/operator/types/query.pb.gw.go index 848249d38..e5adaf034 100644 --- a/x/operator/types/query.pb.gw.go +++ b/x/operator/types/query.pb.gw.go @@ -34,37 +34,37 @@ var _ = descriptor.ForMessage var _ = metadata.Join var ( - filter_Query_QueryOperatorInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_GetOperatorInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorInfoReq +func request_Query_GetOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetOperatorInfoReq 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_QueryOperatorInfo_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetOperatorInfo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.QueryOperatorInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetOperatorInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorInfoReq +func local_request_Query_GetOperatorInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetOperatorInfoReq 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_QueryOperatorInfo_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetOperatorInfo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.QueryOperatorInfo(ctx, &protoReq) + msg, err := server.GetOperatorInfo(ctx, &protoReq) return msg, metadata, err } @@ -75,7 +75,7 @@ func local_request_Query_QueryOperatorInfo_0(ctx context.Context, marshaler runt // 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_QueryOperatorInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GetOperatorInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -86,7 +86,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryOperatorInfo_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_GetOperatorInfo_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 { @@ -94,7 +94,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GetOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -139,7 +139,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_QueryOperatorInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GetOperatorInfo_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) @@ -148,14 +148,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryOperatorInfo_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_GetOperatorInfo_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_QueryOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GetOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -163,9 +163,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_QueryOperatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetOperatorInfo"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_GetOperatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetOperatorInfo"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_QueryOperatorInfo_0 = runtime.ForwardResponseMessage + forward_Query_GetOperatorInfo_0 = runtime.ForwardResponseMessage ) diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index 297736958..5e72ceb84 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -55,11 +55,11 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnAmountOrWantChangeValue: math.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnWaitUnbondingAmount: math.NewInt(0), - OperatorOwnCanUnbondingAmountAfterSlash: math.NewInt(0), + TotalAmountOrWantChangeValue: math.NewInt(0), + OperatorOwnAmountOrWantChangeValue: math.NewInt(0), + WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), + OperatorOwnWaitUnbondingAmount: math.NewInt(0), + OperatorUnbondableAmountAfterSlash: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -83,7 +83,7 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") } - err = restakingtype.UpdateAssetValue(&assetState.OperatorOwnCanUnbondingAmountAfterSlash, &changeAmount.OperatorOwnCanUnbondingAmountAfterSlash) + err = restakingtype.UpdateAssetValue(&assetState.OperatorUnbondableAmountAfterSlash, &changeAmount.OperatorUnbondableAmountAfterSlash) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") } diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index f80fee704..a937f5c46 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -393,10 +393,10 @@ func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetO type OperatorSingleAssetOrChangeInfo struct { TotalAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=TotalAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalAmountOrWantChangeValue"` // todo: the field is used to mark operator's own assets and is not temporarily used now - OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` - WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` - OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=OperatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnWaitUnbondingAmount"` - OperatorOwnCanUnbondingAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=OperatorOwnCanUnbondingAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnCanUnbondingAmountAfterSlash"` + OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=OperatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnAmountOrWantChangeValue"` + WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=WaitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"WaitUnbondingAmountOrWantChangeValue"` + OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=OperatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorOwnWaitUnbondingAmount"` + OperatorUnbondableAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=OperatorUnbondableAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"OperatorUnbondableAmountAfterSlash"` } func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleAssetOrChangeInfo{} } @@ -573,74 +573,74 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1065 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0xda, 0xf9, 0x7c, 0xad, 0xb4, 0xc9, 0x34, 0x14, 0xc7, 0x14, 0x3b, 0x5a, 0x2a, 0xb0, - 0x02, 0xb1, 0x55, 0x23, 0xaa, 0x28, 0x02, 0x24, 0xc7, 0x69, 0xa5, 0x88, 0xa4, 0x96, 0x76, 0x03, - 0x11, 0x3d, 0x10, 0xc6, 0xf6, 0x64, 0xbd, 0xf2, 0xee, 0x8c, 0xb5, 0x33, 0x4e, 0xed, 0x5b, 0x85, - 0x2a, 0x84, 0x10, 0x42, 0xe5, 0x02, 0x07, 0x2e, 0xfd, 0x09, 0x39, 0xf4, 0x47, 0xf4, 0x58, 0xe5, - 0x42, 0xe1, 0x50, 0xa1, 0x44, 0x22, 0xfc, 0x0c, 0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d3, 0x9f, 0xfd, 0x2f, 0xb5, 0x20, 0xac, 0xf4, 0xf8, 0xfd, 0x93, 0x83, 0x25, 0x65, - 0x6d, 0xf3, 0xc9, 0x51, 0x46, 0x79, 0x7a, 0x94, 0x51, 0xfe, 0x3e, 0xca, 0x28, 0x0f, 0x8f, 0x33, - 0xb1, 0xa7, 0xc7, 0x99, 0xd8, 0xb3, 0xe3, 0x4c, 0xec, 0x6e, 0x31, 0xd4, 0xa7, 0xc1, 0xab, 0x77, - 0x86, 0x7e, 0xd5, 0xc9, 0xbe, 0xad, 0x4e, 0xc8, 0xaf, 0xaa, 0x8f, 0xff, 0x0b, 0x00, 0x00, 0xff, - 0xff, 0x83, 0x75, 0x6e, 0xe0, 0x05, 0x0e, 0x00, 0x00, + // 1063 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0xcf, 0x6b, 0x1b, 0xc7, + 0x17, 0xd7, 0x4a, 0xfe, 0xf9, 0x8c, 0x13, 0x7b, 0xe2, 0x6f, 0xbe, 0xb2, 0x9a, 0xca, 0x66, 0x1b, + 0x8a, 0x71, 0x6b, 0x89, 0xa8, 0x34, 0x18, 0xd3, 0x16, 0x64, 0x39, 0x01, 0x53, 0x3b, 0x82, 0x5d, + 0xb7, 0xa6, 0x39, 0xd4, 0x1d, 0x49, 0xe3, 0xd5, 0xa2, 0xdd, 0x19, 0xb1, 0x33, 0x72, 0xa4, 0x5b, + 0x28, 0xa1, 0x94, 0x52, 0x4a, 0x7a, 0xea, 0xa1, 0x97, 0xfc, 0x09, 0x3e, 0xe4, 0x8f, 0xc8, 0x31, + 0xf8, 0xd2, 0xb4, 0x94, 0x50, 0xec, 0x83, 0xfb, 0x67, 0x94, 0x9d, 0xd9, 0xb5, 0x57, 0x96, 0x14, + 0x6f, 0x1a, 0x05, 0x7a, 0xb1, 0x77, 0xde, 0xef, 0xfd, 0xbc, 0xf7, 0x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27, 0xd9, 0xc4, 0xf3, + 0x93, 0x6c, 0xe2, 0xc5, 0x49, 0x36, 0x71, 0xbf, 0x10, 0xa1, 0x68, 0xf8, 0xea, 0xed, 0x81, 0xdf, + 0x72, 0x92, 0xb2, 0x95, 0x31, 0xf9, 0x2d, 0xf5, 0xd1, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4a, + 0x0e, 0xe2, 0x5e, 0xfb, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1069,9 +1069,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int var l int _ = l { - size := m.OperatorOwnCanUnbondingAmountAfterSlash.Size() + size := m.OperatorUnbondableAmountAfterSlash.Size() i -= size - if _, err := m.OperatorOwnCanUnbondingAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.OperatorUnbondableAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1409,7 +1409,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.OperatorOwnWaitUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.OperatorOwnCanUnbondingAmountAfterSlash.Size() + l = m.OperatorUnbondableAmountAfterSlash.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -2691,7 +2691,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnCanUnbondingAmountAfterSlash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorUnbondableAmountAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2719,7 +2719,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OperatorOwnCanUnbondingAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OperatorUnbondableAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From e824f47136ab841b77bd72767283250f9c9fff45 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 31 Jan 2024 11:10:21 +0800 Subject: [PATCH 17/44] remove the redundant code from the abci.go file in the operator module --- x/operator/keeper/abci.go | 52 +++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index f733e3c1d..e9777fbd8 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -9,6 +9,23 @@ import ( "github.com/exocore/x/restaking_assets_manage/types" ) +type SharedParameter struct { + priceChangeAssets map[string]*operatortypes.PriceChange + assetsDecimal map[string]uint32 + assetsOperatorAVSInfo map[string]map[string]string + stakerShare map[string]sdkmath.LegacyDec +} + +func UpdateShareOfStakerAndOperator(sharedParam *SharedParameter, assetId, stakerId, operatorAddr string, assetAmount sdkmath.Int) { + priceChange := sharedParam.priceChangeAssets[assetId] + assetDecimal := sharedParam.assetsDecimal[assetId] + if avsAddr, ok := sharedParam.assetsOperatorAVSInfo[assetId][operatorAddr]; ok { + newAssetUSDValue := CalculateShare(assetAmount, priceChange.NewPrice, assetDecimal, priceChange.Decimal) + key := string(types.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr)) + AddShareInMap(sharedParam.stakerShare, key, newAssetUSDValue) + } +} + // EndBlock : update the assets' share when their prices change func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { priceChangeAssets, err := k.oracleKeeper.GetPriceChangeAssets(ctx) @@ -19,7 +36,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida return nil } avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) - assetsOperator := make(map[string]map[string]string, 0) + assetsOperatorAVSInfo := make(map[string]map[string]string, 0) assetsDecimal := make(map[string]uint32) for assetId, priceChange := range priceChangeAssets { //get the decimal of asset @@ -28,8 +45,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida panic(err) } assetsDecimal[assetId] = assetInfo.AssetBasicInfo.Decimals - if _, ok := assetsOperator[assetId]; !ok { - assetsOperator[assetId] = make(map[string]string, 0) + if _, ok := assetsOperatorAVSInfo[assetId]; !ok { + assetsOperatorAVSInfo[assetId] = make(map[string]string, 0) } //UpdateOperatorAVSAssetsState f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { @@ -41,7 +58,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) AddShareInMap(avsOperatorShareChange, avsAddr, changeValue) AddShareInMap(avsOperatorShareChange, avsOperator, changeValue) - assetsOperator[assetId][keys[2]] = avsAddr + assetsOperatorAVSInfo[assetId][keys[2]] = avsAddr return nil } err = k.IterateUpdateOperatorAVSAssets(ctx, assetId, f) @@ -56,15 +73,14 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } //update staker's share - stakerOperatorNewShare := make(map[string]sdkmath.LegacyDec, 0) - stakerShareHandleFunc := func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error { - priceChange := priceChangeAssets[assetId] - assetDecimal := assetsDecimal[assetId] - if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { - newAssetUSDValue := CalculateShare(state.CanUndelegationAmount, priceChange.NewPrice, assetDecimal, priceChange.Decimal) - key := string(types.GetJoinedStoreKey(avsAddr, restakerId, operatorAddr)) - AddShareInMap(stakerOperatorNewShare, key, newAssetUSDValue) - } + sharedParameter := &SharedParameter{ + priceChangeAssets: priceChangeAssets, + assetsDecimal: assetsDecimal, + assetsOperatorAVSInfo: assetsOperatorAVSInfo, + stakerShare: make(map[string]sdkmath.LegacyDec, 0), + } + stakerShareHandleFunc := func(stakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error { + UpdateShareOfStakerAndOperator(sharedParameter, assetId, stakerId, operatorAddr, state.CanUndelegationAmount) return nil } err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) @@ -73,13 +89,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } operatorShareHandleFunc := func(operatorAddr, assetId string, state *types.OperatorSingleAssetOrChangeInfo) error { - priceChange := priceChangeAssets[assetId] - assetDecimal := assetsDecimal[assetId] - if avsAddr, ok := assetsOperator[assetId][operatorAddr]; ok { - newAssetUSDValue := CalculateShare(state.OperatorOwnAmountOrWantChangeValue, priceChange.NewPrice, assetDecimal, priceChange.Decimal) - key := string(types.GetJoinedStoreKey(avsAddr, "", operatorAddr)) - AddShareInMap(stakerOperatorNewShare, key, newAssetUSDValue) - } + UpdateShareOfStakerAndOperator(sharedParameter, assetId, "", operatorAddr, state.OperatorOwnAmountOrWantChangeValue) return nil } err = k.restakingStateKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) @@ -87,7 +97,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida panic(err) } //BatchSetAVSOperatorStakerShare - err = k.BatchSetAVSOperatorStakerShare(ctx, stakerOperatorNewShare) + err = k.BatchSetAVSOperatorStakerShare(ctx, sharedParameter.stakerShare) if err != nil { panic(err) } From 57fcb7afaaffc658e2c3621e582d2b58fd673950 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 31 Jan 2024 15:55:35 +0800 Subject: [PATCH 18/44] change file name in operator module --- x/operator/keeper/avs_operator_assets_state_test.go | 1 - x/operator/keeper/keeper.go | 6 +++--- .../{state_update_for_external_op.go => state_update.go} | 0 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 x/operator/keeper/avs_operator_assets_state_test.go rename x/operator/keeper/{state_update_for_external_op.go => state_update.go} (100%) diff --git a/x/operator/keeper/avs_operator_assets_state_test.go b/x/operator/keeper/avs_operator_assets_state_test.go deleted file mode 100644 index b55569d4a..000000000 --- a/x/operator/keeper/avs_operator_assets_state_test.go +++ /dev/null @@ -1 +0,0 @@ -package keeper diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 2aecc9d85..64c9dc718 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -45,8 +45,8 @@ func (k *Keeper) GetExpectDelegationInterface() operatortypes.ExpectDelegationIn return k.delegationKeeper } -func (k *Keeper) GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { - return startHeight + operatortypes.UnBondingExpiration +func (k *Keeper) GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { + return startHeight + operatortypes.UnbondingExpiration } // OperatorKeeper interface will be implemented by deposit keeper @@ -56,7 +56,7 @@ type OperatorKeeper interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool - GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 + GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error diff --git a/x/operator/keeper/state_update_for_external_op.go b/x/operator/keeper/state_update.go similarity index 100% rename from x/operator/keeper/state_update_for_external_op.go rename to x/operator/keeper/state_update.go From 5c98ed3f3a0944daf35c2afd40eb09c9b0d085f5 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Thu, 1 Feb 2024 12:22:14 +0800 Subject: [PATCH 19/44] test getting historical operator info --- ...assets_state.go => avs_operator_shares.go} | 0 x/operator/keeper/operator_info_test.go | 56 ++++- x/operator/keeper/setup_test.go | 34 ++- x/operator/keeper/state_update_test.go | 5 + x/operator/keeper/utils_test.go | 213 ++++++++++++++++-- 5 files changed, 264 insertions(+), 44 deletions(-) rename x/operator/keeper/{avs_operator_assets_state.go => avs_operator_shares.go} (100%) create mode 100644 x/operator/keeper/state_update_test.go diff --git a/x/operator/keeper/avs_operator_assets_state.go b/x/operator/keeper/avs_operator_shares.go similarity index 100% rename from x/operator/keeper/avs_operator_assets_state.go rename to x/operator/keeper/avs_operator_shares.go diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index 787f1e1e5..5a7afba7b 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -1,10 +1,12 @@ package keeper_test -import operatortype "github.com/exocore/x/operator/types" +import ( + operatortype "github.com/exocore/x/operator/types" +) -func (suite *KeeperTestSuite) TestOperatorInfo() { +func (s *KeeperTestSuite) TestOperatorInfo() { info := &operatortype.OperatorInfo{ - EarningsAddr: suite.accAddress.String(), + EarningsAddr: s.accAddress.String(), ApproveAddr: "", OperatorMetaInfo: "test operator", ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ @@ -13,10 +15,48 @@ func (suite *KeeperTestSuite) TestOperatorInfo() { }, }, } - err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) - suite.NoError(err) + err := s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), info) + s.NoError(err) - getOperatorInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: suite.accAddress.String()}) - suite.NoError(err) - suite.Equal(*info, *getOperatorInfo) + getOperatorInfo, err := s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: s.accAddress.String()}) + s.NoError(err) + s.Equal(*info, *getOperatorInfo) +} + +func (s *KeeperTestSuite) TestHistoricalOperatorInfo() { + height := s.ctx.BlockHeight() + info := &operatortype.OperatorInfo{ + EarningsAddr: s.accAddress.String(), + ApproveAddr: "", + OperatorMetaInfo: "test operator", + ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ + EarningInfoList: []*operatortype.ClientChainEarningAddrInfo{ + {101, "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"}, + }, + }, + } + err := s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), info) + s.NoError(err) + s.NextBlock() + s.Equal(height+1, s.ctx.BlockHeight(), "nexBlock failed") + + newInfo := *info + newInfo.OperatorMetaInfo = "new operator" + err = s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), &newInfo) + s.NoError(err) + + //get historical operator info + s.ctx.WithBlockHeight(height) + getInfo, err := s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{ + OperatorAddr: s.accAddress.String(), + }) + s.NoError(err) + s.Equal(info, getInfo) + s.ctx.WithBlockHeight(height + 1) + + getInfo, err = s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{ + OperatorAddr: s.accAddress.String(), + }) + s.NoError(err) + s.Equal(getInfo, newInfo) } diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go index 24ccf18b7..2618c5d10 100644 --- a/x/operator/keeper/setup_test.go +++ b/x/operator/keeper/setup_test.go @@ -3,38 +3,50 @@ package keeper_test import ( "testing" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/ethereum/go-ethereum/common" - "github.com/exocore/app" + "github.com/evmos/evmos/v14/x/evm/statedb" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + tmtypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + evmosapp "github.com/exocore/app" "github.com/stretchr/testify/suite" ) +var s *KeeperTestSuite + type KeeperTestSuite struct { suite.Suite ctx sdk.Context - app *app.ExocoreApp + app *evmosapp.ExocoreApp address common.Address - signer keyring.Signer accAddress sdk.AccAddress -} -var s *KeeperTestSuite + validators []stakingtypes.Validator + valSet *tmtypes.ValidatorSet + ethSigner ethtypes.Signer + privKey cryptotypes.PrivKey + signer keyring.Signer + bondDenom string + stateDB *statedb.StateDB +} -func TestKeeperTestSuite(t *testing.T) { +func TestOperatorTestSuite(t *testing.T) { s = new(KeeperTestSuite) suite.Run(t, s) // Run Ginkgo integration tests RegisterFailHandler(Fail) - RunSpecs(t, "Keeper Suite") + RunSpecs(t, "operator module Suite") } -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (s *KeeperTestSuite) SetupTest() { + s.DoSetupTest() } diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go new file mode 100644 index 000000000..a4144de3a --- /dev/null +++ b/x/operator/keeper/state_update_test.go @@ -0,0 +1,5 @@ +package keeper_test + +func (s *KeeperTestSuite) UpdateOptedInAssetsState() { + +} diff --git a/x/operator/keeper/utils_test.go b/x/operator/keeper/utils_test.go index 2692f9a3b..be1c66213 100644 --- a/x/operator/keeper/utils_test.go +++ b/x/operator/keeper/utils_test.go @@ -1,44 +1,207 @@ package keeper_test import ( + "encoding/json" + "golang.org/x/exp/rand" "time" + "github.com/exocore/testutil" + testutiltx "github.com/exocore/testutil/tx" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/crypto/tmhash" + tmtypes "github.com/cometbft/cometbft/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/testutil/mock" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/exocore/app" + ethtypes "github.com/ethereum/go-ethereum/core/types" + cmn "github.com/evmos/evmos/v14/precompiles/common" + evmostypes "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v14/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v14/x/evm/types" + inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" + evmosapp "github.com/exocore/app" "github.com/exocore/utils" - "github.com/stretchr/testify/require" - "golang.org/x/exp/rand" ) -// Test helpers -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) +// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts +// that also act as delegators. For simplicity, each validator is bonded with a delegation +// of one consensus engine unit (10^6) in the default token of the simapp from first genesis +// account. A Nop logger is set in SimApp. +func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + app, ok := appI.(*evmosapp.ExocoreApp) + s.Require().True(ok) + + // set genesis accounts + authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) + genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) + + validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) + delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) + + bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) + + for _, val := range valSet.Validators { + pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) + s.Require().NoError(err) + pkAny, err := codectypes.NewAnyWithValue(pk) + s.Require().NoError(err) + validator := stakingtypes.Validator{ + OperatorAddress: sdk.ValAddress(val.Address).String(), + ConsensusPubkey: pkAny, + Jailed: false, + Status: stakingtypes.Bonded, + Tokens: bondAmt, + DelegatorShares: sdk.OneDec(), + Description: stakingtypes.Description{}, + UnbondingHeight: int64(0), + UnbondingTime: time.Unix(0, 0).UTC(), + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + MinSelfDelegation: sdk.ZeroInt(), + } + validators = append(validators, validator) + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) + } + s.validators = validators + + // set validators and delegations + stakingParams := stakingtypes.DefaultParams() + // set bond demon to be aevmos + stakingParams.BondDenom = utils.BaseDenom + stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) + genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) + + totalBondAmt := bondAmt.Add(bondAmt) + totalSupply := sdk.NewCoins() + for _, b := range balances { + // add genesis acc tokens and delegated tokens to total supply + totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) + } + + // add bonded amount to bonded pool module account + balances = append(balances, banktypes.Balance{ + Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), + Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, + }) + + // update total supply + bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) + genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) + + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + s.Require().NoError(err) + + // init chain will set the validator set and initialize the genesis accounts + app.InitChain( + abci.RequestInitChain{ + ChainId: cmn.DefaultChainID, + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: evmosapp.DefaultConsensusParams, + AppStateBytes: stateBytes, + }, + ) + app.Commit() + + // instantiate new header + header := testutil.NewHeader( + 2, + time.Now().UTC(), + cmn.DefaultChainID, + sdk.ConsAddress(validators[0].GetOperator()), + tmhash.Sum([]byte("app")), + tmhash.Sum([]byte("validators")), + ) + + app.BeginBlock(abci.RequestBeginBlock{ + Header: header, + }) + + // create Context + s.ctx = app.BaseApp.NewContext(false, header) + s.app = app +} + +func (s *KeeperTestSuite) DoSetupTest() { + // generate validator private/public key + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + s.Require().NoError(err) + + privVal2 := mock.NewPV() + pubKey2, err := privVal2.GetPubKey() + s.Require().NoError(err) + + // create validator set with two validators + validator := tmtypes.NewValidator(pubKey, 1) + validator2 := tmtypes.NewValidator(pubKey2, 2) + s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) + signers := make(map[string]tmtypes.PrivValidator) + signers[pubKey.Address().String()] = privVal + signers[pubKey2.Address().String()] = privVal2 // accAddress pubBz := make([]byte, ed25519.PubKeySize) pub := &ed25519.PubKey{Key: pubBz} rand.Read(pub.Key) - suite.accAddress = sdk.AccAddress(pub.Address()) + s.accAddress = sdk.AccAddress(pub.Address()) - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) + // generate genesis account + addr, priv := testutiltx.NewAddrKey() + s.privKey = priv + s.address = addr + s.signer = testutiltx.NewSigner(priv) - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, feemarkettypes.DefaultGenesisState(), chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) + baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) + + acc := &evmostypes.EthAccount{ + BaseAccount: baseAcc, + CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), + } + + amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) + + balance := banktypes.Balance{ + Address: acc.GetAddress().String(), + Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), + } + + s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) + + // Create StateDB + s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + + // bond denom + stakingParams := s.app.StakingKeeper.GetParams(s.ctx) + stakingParams.BondDenom = utils.BaseDenom + s.bondDenom = stakingParams.BondDenom + err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) + s.Require().NoError(err) + + s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) + + coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) + inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) + distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) + err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) + s.Require().NoError(err) + err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) + s.Require().NoError(err) + err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) + s.Require().NoError(err) + +} + +// NextBlock commits the current block and sets up the next block. +func (s *KeeperTestSuite) NextBlock() { + var err error + s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet) + s.Require().NoError(err) } From 502b370b26da1ae62a3336ae3d1b789d8c5cccd4 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Sun, 4 Feb 2024 10:38:14 +0800 Subject: [PATCH 20/44] add ContextForHistoricalState to retrieve historical state --- x/operator/keeper/operator_info_test.go | 14 ++++++-------- x/operator/keeper/state_update.go | 23 ++++++++++++----------- x/operator/keeper/utils_test.go | 4 +++- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index 5a7afba7b..b2d58c3eb 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -30,9 +30,7 @@ func (s *KeeperTestSuite) TestHistoricalOperatorInfo() { ApproveAddr: "", OperatorMetaInfo: "test operator", ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ - EarningInfoList: []*operatortype.ClientChainEarningAddrInfo{ - {101, "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"}, - }, + EarningInfoList: nil, }, } err := s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), info) @@ -46,17 +44,17 @@ func (s *KeeperTestSuite) TestHistoricalOperatorInfo() { s.NoError(err) //get historical operator info - s.ctx.WithBlockHeight(height) - getInfo, err := s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{ + historicalQueryCtx, err := s.app.CreateQueryContext(height, false) + s.NoError(err) + getInfo, err := s.app.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ OperatorAddr: s.accAddress.String(), }) s.NoError(err) - s.Equal(info, getInfo) - s.ctx.WithBlockHeight(height + 1) + s.Equal(info.OperatorMetaInfo, getInfo.OperatorMetaInfo) getInfo, err = s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{ OperatorAddr: s.accAddress.String(), }) s.NoError(err) - s.Equal(getInfo, newInfo) + s.Equal(getInfo.OperatorMetaInfo, newInfo.OperatorMetaInfo) } diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index f666ab60f..ff50888d5 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -278,26 +278,26 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. slashOperatorInfo: make(map[string]*slashAmounts, 0), } - height := ctx.BlockHeight() //get the state when the slash occurred - ctx = ctx.WithBlockHeight(occurredSateHeight) + historicalSateCtx, err := types2.ContextForHistoricalState(ctx, occurredSateHeight) + if err != nil { + return nil, err + } //get assetsInfo supported by AVS - assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(historicalSateCtx, AVSAddr) if err != nil { return nil, err } - historyStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetsFilter) + historyStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(historicalSateCtx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } //get the Assets opted in the operator - historyOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, assetsFilter) + historyOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(historicalSateCtx, operatorAddress, assetsFilter) if err != nil { return nil, err } - // reset context height - ctx = ctx.WithBlockHeight(height) //calculate the actual slash amount according to the history and current state currentStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetsFilter) @@ -443,19 +443,20 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, //get the state when the slash occurred //get the opted-in info - ctx = ctx.WithBlockHeight(occurredSateHeight) + historicalSateCtx, err := types2.ContextForHistoricalState(ctx, occurredSateHeight) + if err != nil { + return err + } if !k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { return types.ErrNotOptedIn } - optedInfo, err := k.GetOptedInfo(ctx, operatorAddress.String(), AVSAddr) + optedInfo, err := k.GetOptedInfo(historicalSateCtx, operatorAddress.String(), AVSAddr) if err != nil { return err } if optedInfo.SlashContract != slashContract { return errorsmod.Wrap(types.ErrSlashContractNotMatch, fmt.Sprintf("input slashContract:%s, opted-in slash contract:%s", slashContract, optedInfo.SlashContract)) } - // reset context height - ctx = ctx.WithBlockHeight(height) //todo: recording the slash event might be moved to the slash module slashInfo := types.OperatorSlashInfo{ diff --git a/x/operator/keeper/utils_test.go b/x/operator/keeper/utils_test.go index be1c66213..4cec225e0 100644 --- a/x/operator/keeper/utils_test.go +++ b/x/operator/keeper/utils_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "encoding/json" + pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "golang.org/x/exp/rand" "time" @@ -36,7 +37,8 @@ import ( // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, &pruneOpts, false)() app, ok := appI.(*evmosapp.ExocoreApp) s.Require().True(ok) From a02457b625487f928875b0bd4786bd127b39753a Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Sun, 4 Feb 2024 11:32:39 +0800 Subject: [PATCH 21/44] fix the testing bug for retrieving histrical operator info --- x/operator/keeper/operator_info_test.go | 3 ++- x/operator/keeper/utils_test.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index b2d58c3eb..fa3b6f837 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -2,6 +2,7 @@ package keeper_test import ( operatortype "github.com/exocore/x/operator/types" + "github.com/exocore/x/restaking_assets_manage/types" ) func (s *KeeperTestSuite) TestOperatorInfo() { @@ -44,7 +45,7 @@ func (s *KeeperTestSuite) TestHistoricalOperatorInfo() { s.NoError(err) //get historical operator info - historicalQueryCtx, err := s.app.CreateQueryContext(height, false) + historicalQueryCtx, err := types.ContextForHistoricalState(s.ctx, height) s.NoError(err) getInfo, err := s.app.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ OperatorAddr: s.accAddress.String(), diff --git a/x/operator/keeper/utils_test.go b/x/operator/keeper/utils_test.go index 4cec225e0..4eb2d566e 100644 --- a/x/operator/keeper/utils_test.go +++ b/x/operator/keeper/utils_test.go @@ -126,8 +126,8 @@ func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, g Header: header, }) - // create Context - s.ctx = app.BaseApp.NewContext(false, header) + // need to create UncachedContext when retrieving historical state + s.ctx = app.BaseApp.NewUncachedContext(false, header) s.app = app } @@ -204,6 +204,6 @@ func (s *KeeperTestSuite) DoSetupTest() { // NextBlock commits the current block and sets up the next block. func (s *KeeperTestSuite) NextBlock() { var err error - s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet) + s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet, true) s.Require().NoError(err) } From a14934593f0ae654a1ccc059a035ea0a497cd8b4 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Sun, 4 Feb 2024 15:34:18 +0800 Subject: [PATCH 22/44] update for retrieving historical state --- app/app.go | 6 +-- app/test_helpers.go | 12 +++-- local_node.sh | 4 +- precompiles/delegation/utils_test.go | 2 +- precompiles/deposit/utils_test.go | 4 +- precompiles/reward/utils_test.go | 2 +- precompiles/slash/utils_test.go | 2 +- precompiles/withdraw/utils_test.go | 2 +- testutil/abci.go | 10 +++- x/delegation/keeper/abci.go | 2 +- x/delegation/keeper/cross_chain_tx_process.go | 2 +- x/delegation/types/expected_keepers.go | 2 +- x/operator/keeper/operator_info_test.go | 2 +- x/operator/types/keys.go | 2 +- x/restaking_assets_manage/types/general.go | 49 +++++++++++++++++++ 15 files changed, 82 insertions(+), 21 deletions(-) diff --git a/app/app.go b/app/app.go index 95da4be76..4b7591aa2 100644 --- a/app/app.go +++ b/app/app.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" "github.com/exocore/x/operator" - operatorkeeper "github.com/exocore/x/operator/keeper" + operatorKeeper "github.com/exocore/x/operator/keeper" "io" "net/http" "os" @@ -356,7 +356,7 @@ type ExocoreApp struct { DelegationKeeper delegationKeeper.Keeper WithdrawKeeper withdrawKeeper.Keeper RewardKeeper rewardKeeper.Keeper - OperatorKeeper operatorkeeper.Keeper + OperatorKeeper operatorKeeper.Keeper ExoSlashKeeper slashKeeper.Keeper // the module manager @@ -621,7 +621,7 @@ func NewExocoreApp( // set exoCore staking keepers app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec) app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper) - app.OperatorKeeper = operatorkeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}) + app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}) // todo: need to replace the virtual keepers with actual keepers after they have been implemented app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper) app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper) diff --git a/app/test_helpers.go b/app/test_helpers.go index c765a65dc..257b3b529 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -2,6 +2,7 @@ package app import ( "encoding/json" + pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "os" "time" @@ -38,7 +39,7 @@ func init() { } // DefaultTestingAppInit defines the IBC application used for testing -var DefaultTestingAppInit func(chainID string, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) = SetupTestingApp +var DefaultTestingAppInit func(chainID string, pruneOpts *pruningtypes.PruningOptions, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) = SetupTestingApp // DefaultConsensusParams defines the default Tendermint consensus params used in // Evmos testing. @@ -201,7 +202,7 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState, // SetupTestingApp initializes the IBC-go testing application // need to keep this design to comply with the ibctesting SetupTestingApp func // and be able to set the chainID for the tests properly -func SetupTestingApp(chainID string, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) { +func SetupTestingApp(chainID string, pruneOpts *pruningtypes.PruningOptions, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) { return func() (ibctesting.TestingApp, map[string]json.RawMessage) { db := dbm.NewMemDB() cfg := encoding.MakeConfig(ModuleBasics) @@ -209,13 +210,18 @@ func SetupTestingApp(chainID string, isPrintLog bool) func() (ibctesting.Testing if isPrintLog { logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) } + baseAppOptions := make([]func(*baseapp.BaseApp), 0) + baseAppOptions = append(baseAppOptions, baseapp.SetChainID(chainID)) + if pruneOpts != nil { + baseAppOptions = append(baseAppOptions, baseapp.SetPruning(*pruneOpts)) + } app := NewExocoreApp( logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, cfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), - baseapp.SetChainID(chainID), + baseAppOptions[:]..., ) return app, NewDefaultGenesisState() } diff --git a/local_node.sh b/local_node.sh index 7b3848b75..e8e7ed2c7 100755 --- a/local_node.sh +++ b/local_node.sh @@ -141,8 +141,8 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # set custom pruning settings sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML" - sed -i.bak 's/pruning-keep-recent = "0"/pruning-keep-recent = "2"/g' "$APP_TOML" - sed -i.bak 's/pruning-interval = "0"/pruning-interval = "10"/g' "$APP_TOML" + sed -i.bak 's/pruning-keep-recent = "0"/pruning-keep-recent = "100"/g' "$APP_TOML" + sed -i.bak 's/pruning-interval = "0"/pruning-interval = "500"/g' "$APP_TOML" # make sure the localhost IP is 0.0.0.0 sed -i.bak 's/localhost/0.0.0.0/g' "$CONFIG" diff --git a/precompiles/delegation/utils_test.go b/precompiles/delegation/utils_test.go index f3130d62c..a2151e074 100644 --- a/precompiles/delegation/utils_test.go +++ b/precompiles/delegation/utils_test.go @@ -35,7 +35,7 @@ import ( // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() app, ok := appI.(*evmosapp.ExocoreApp) s.Require().True(ok) diff --git a/precompiles/deposit/utils_test.go b/precompiles/deposit/utils_test.go index 31af57c34..3c2abfeb1 100644 --- a/precompiles/deposit/utils_test.go +++ b/precompiles/deposit/utils_test.go @@ -36,7 +36,7 @@ import ( // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() app, ok := appI.(*evmosapp.ExocoreApp) s.Require().True(ok) @@ -215,6 +215,6 @@ func (s *PrecompileTestSuite) DeployContract(contract evmtypes.CompiledContract) // NextBlock commits the current block and sets up the next block. func (s *PrecompileTestSuite) NextBlock() { var err error - s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet) + s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet, false) s.Require().NoError(err) } diff --git a/precompiles/reward/utils_test.go b/precompiles/reward/utils_test.go index 61a8dc469..2c1158319 100644 --- a/precompiles/reward/utils_test.go +++ b/precompiles/reward/utils_test.go @@ -37,7 +37,7 @@ import ( // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() app, ok := appI.(*evmosapp.ExocoreApp) s.Require().True(ok) diff --git a/precompiles/slash/utils_test.go b/precompiles/slash/utils_test.go index 47ba515ab..b08e889d1 100644 --- a/precompiles/slash/utils_test.go +++ b/precompiles/slash/utils_test.go @@ -37,7 +37,7 @@ import ( // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() app, ok := appI.(*evmosapp.ExocoreApp) s.Require().True(ok) diff --git a/precompiles/withdraw/utils_test.go b/precompiles/withdraw/utils_test.go index 2ce50f587..eb69c3131 100644 --- a/precompiles/withdraw/utils_test.go +++ b/precompiles/withdraw/utils_test.go @@ -38,7 +38,7 @@ import ( // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, false)() + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() app, ok := appI.(*evmosapp.ExocoreApp) s.Require().True(ok) diff --git a/testutil/abci.go b/testutil/abci.go index 304468daa..45a3a12e6 100644 --- a/testutil/abci.go +++ b/testutil/abci.go @@ -35,7 +35,7 @@ func Commit(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.V // CommitAndCreateNewCtx commits a block at a given time creating a ctx with the current settings // This is useful to keep test settings that could be affected by EndBlockers, e.g. // setting a baseFee == 0 and expecting this condition to continue after commit -func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.ValidatorSet) (sdk.Context, error) { +func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.ValidatorSet, isUncachedCtx bool) (sdk.Context, error) { header, err := commit(ctx, app, t, vs) if err != nil { return ctx, err @@ -44,7 +44,13 @@ func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration // NewContext function keeps the multistore // but resets other context fields // GasMeter is set as InfiniteGasMeter - newCtx := app.BaseApp.NewContext(false, header) + var newCtx sdk.Context + if isUncachedCtx { + newCtx = app.BaseApp.NewUncachedContext(false, header) + } else { + newCtx = app.BaseApp.NewContext(false, header) + } + // set the reseted fields to keep the current ctx settings newCtx = newCtx.WithMinGasPrices(ctx.MinGasPrices()) newCtx = newCtx.WithEventManager(ctx.EventManager()) diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 30b5e0c11..53d25cccb 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -24,7 +24,7 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat //todo: don't think about freezing the operator in current implementation /* if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { // reSet the completed height if the operator is frozen - record.CompleteBlockNumber = k.expectedOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) + record.CompleteBlockNumber = k.expectedOperatorInterface.GetUnbondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) if record.CompleteBlockNumber <= uint64(ctx.BlockHeight()) { panic(fmt.Sprintf("the reset completedHeight isn't in future,setHeight:%v,curHeight:%v", record.CompleteBlockNumber, ctx.BlockHeight())) } diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 312b74e94..1edc408b2 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -207,7 +207,7 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation Amount: params.OpAmount, ActualCompletedAmount: sdkmath.NewInt(0), } - r.CompleteBlockNumber = k.expectedOperatorInterface.GetUnBondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) + r.CompleteBlockNumber = k.expectedOperatorInterface.GetUnbondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) if err != nil { return err diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 692b71bed..914a4705b 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -25,7 +25,7 @@ func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAdd type ExpectedOperatorInterface interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool - GetUnBondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 + GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error } diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index fa3b6f837..b192b6c4f 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -57,5 +57,5 @@ func (s *KeeperTestSuite) TestHistoricalOperatorInfo() { OperatorAddr: s.accAddress.String(), }) s.NoError(err) - s.Equal(getInfo.OperatorMetaInfo, newInfo.OperatorMetaInfo) + s.Equal(newInfo.OperatorMetaInfo, getInfo.OperatorMetaInfo) } diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index c89655505..5789ce891 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -23,7 +23,7 @@ const ( SlashVetoDuration = int64(1000) - UnBondingExpiration = 10 + UnbondingExpiration = 10 ) // ModuleAddress is the native module address for EVM diff --git a/x/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go index afecde49a..dc478dcbe 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/restaking_assets_manage/types/general.go @@ -4,6 +4,9 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" "fmt" + "github.com/cosmos/cosmos-sdk/store/rootmulti" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "strings" "github.com/ethereum/go-ethereum/common/hexutil" @@ -103,3 +106,49 @@ func UpdateAssetDecValue(valueToUpdate *math.LegacyDec, changeValue *math.Legacy } return nil } + +func ContextForHistoricalState(ctx sdk.Context, height int64) (sdk.Context, error) { + if height < 0 { + return sdk.Context{}, errorsmod.Wrap(sdkerrors.ErrInvalidHeight, fmt.Sprintf("height:%v", height)) + } + cms := ctx.MultiStore() + lastBlockHeight := cms.LatestVersion() + if lastBlockHeight == 0 { + return sdk.Context{}, errorsmod.Wrap(sdkerrors.ErrInvalidHeight, "app is not ready; please wait for first block") + } + if height > lastBlockHeight { + return sdk.Context{}, + errorsmod.Wrap( + sdkerrors.ErrInvalidHeight, + "cannot query with height in the future; please provide a valid height", + ) + } + + // when the caller did not provide a query height, manually inject the latest + if height == 0 { + height = lastBlockHeight + } + cacheMS, err := cms.CacheMultiStoreWithVersion(height) + if err != nil { + return sdk.Context{}, + sdkerrors.Wrapf( + sdkerrors.ErrInvalidRequest, + "failed to load state at height %d; %s (latest height: %d)", height, err, lastBlockHeight, + ) + } + + // branch the commit-multistore for safety + historicalStateCtx := sdk.NewContext(cacheMS, ctx.BlockHeader(), true, ctx.Logger()). + WithMinGasPrices(ctx.MinGasPrices()). + WithBlockHeight(height) + if height != lastBlockHeight { + rms, ok := cms.(*rootmulti.Store) + if ok { + cInfo, err := rms.GetCommitInfo(height) + if cInfo != nil && err == nil { + ctx = ctx.WithBlockTime(cInfo.Timestamp) + } + } + } + return historicalStateCtx, nil +} From f3a6f00ff58b831bb06f1c8d4605ad62a3344869 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 6 Feb 2024 11:22:45 +0800 Subject: [PATCH 23/44] fix test bug for delegation --- crypto/ethsecp256k1/keys.pb.go | 500 ++++++++++++++++++++++ x/delegation/keeper/delegation_op_test.go | 42 +- x/operator/keeper/setup_test.go | 4 + x/operator/keeper/state_update_test.go | 10 + x/operator/types/expected_keepers.go | 14 +- 5 files changed, 559 insertions(+), 11 deletions(-) create mode 100644 crypto/ethsecp256k1/keys.pb.go diff --git a/crypto/ethsecp256k1/keys.pb.go b/crypto/ethsecp256k1/keys.pb.go new file mode 100644 index 000000000..4b902eef7 --- /dev/null +++ b/crypto/ethsecp256k1/keys.pb.go @@ -0,0 +1,500 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ethermint/crypto/v1/ethsecp256k1/keys.proto + +package ethsecp256k1 + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// PubKey defines a type alias for an ecdsa.PublicKey that implements +// Tendermint's PubKey interface. It represents the 33-byte compressed public +// key format. +type PubKey struct { + // key is the public key in byte form + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PubKey) Reset() { *m = PubKey{} } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_0c10cadcf35beb64, []int{0} +} +func (m *PubKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubKey.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 *PubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKey.Merge(m, src) +} +func (m *PubKey) XXX_Size() int { + return m.Size() +} +func (m *PubKey) XXX_DiscardUnknown() { + xxx_messageInfo_PubKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKey proto.InternalMessageInfo + +func (m *PubKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// PrivKey defines a type alias for an ecdsa.PrivateKey that implements +// Tendermint's PrivateKey interface. +type PrivKey struct { + // key is the private key in byte form + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PrivKey) Reset() { *m = PrivKey{} } +func (m *PrivKey) String() string { return proto.CompactTextString(m) } +func (*PrivKey) ProtoMessage() {} +func (*PrivKey) Descriptor() ([]byte, []int) { + return fileDescriptor_0c10cadcf35beb64, []int{1} +} +func (m *PrivKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrivKey.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 *PrivKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrivKey.Merge(m, src) +} +func (m *PrivKey) XXX_Size() int { + return m.Size() +} +func (m *PrivKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrivKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PrivKey proto.InternalMessageInfo + +func (m *PrivKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*PubKey)(nil), "ethermint.crypto.v1.ethsecp256k1.PubKey") + proto.RegisterType((*PrivKey)(nil), "ethermint.crypto.v1.ethsecp256k1.PrivKey") +} + +func init() { + proto.RegisterFile("ethermint/crypto/v1/ethsecp256k1/keys.proto", fileDescriptor_0c10cadcf35beb64) +} + +var fileDescriptor_0c10cadcf35beb64 = []byte{ + // 205 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0x2d, 0xc9, 0x48, + 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x33, 0xd4, + 0x4f, 0x2d, 0xc9, 0x28, 0x4e, 0x4d, 0x2e, 0x30, 0x32, 0x35, 0xcb, 0x36, 0xd4, 0xcf, 0x4e, 0xad, + 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x80, 0x2b, 0xd6, 0x83, 0x28, 0xd6, 0x2b, + 0x33, 0xd4, 0x43, 0x56, 0x2c, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xac, 0x0f, 0x62, 0x41, + 0xf4, 0x29, 0x29, 0x70, 0xb1, 0x05, 0x94, 0x26, 0x79, 0xa7, 0x56, 0x0a, 0x09, 0x70, 0x31, 0x67, + 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0x98, 0x56, 0x2c, 0x33, 0x16, 0xc8, + 0x33, 0x28, 0x49, 0x73, 0xb1, 0x07, 0x14, 0x65, 0x96, 0x61, 0x55, 0xe2, 0xe4, 0x7f, 0xe2, 0x91, + 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, + 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa6, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, + 0xc9, 0xf9, 0xb9, 0xfa, 0xae, 0x15, 0xf9, 0xc9, 0xf9, 0x45, 0xa9, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, + 0x45, 0xd9, 0xfa, 0xa9, 0x10, 0x2e, 0xcc, 0x57, 0xc8, 0xae, 0x4c, 0x62, 0x03, 0x3b, 0xcb, 0x18, + 0x10, 0x00, 0x00, 0xff, 0xff, 0x15, 0x4f, 0x72, 0x20, 0xfd, 0x00, 0x00, 0x00, +} + +func (m *PubKey) 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 *PubKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKey) 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 = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrivKey) 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 *PrivKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrivKey) 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 = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { + offset -= sovKeys(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PubKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func (m *PrivKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func sovKeys(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozKeys(x uint64) (n int) { + return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PubKey) 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 ErrIntOverflowKeys + } + 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: PubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKey: 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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrivKey) 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 ErrIntOverflowKeys + } + 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: PrivKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrivKey: 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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipKeys(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, ErrIntOverflowKeys + } + 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, ErrIntOverflowKeys + } + 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, ErrIntOverflowKeys + } + 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, ErrInvalidLengthKeys + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupKeys + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthKeys + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 065ee9ee8..f144ad0d6 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -1,6 +1,20 @@ package keeper_test -/*func (suite *KeeperTestSuite) TestDelegateTo() { +import ( + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "fmt" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + keeper2 "github.com/exocore/x/delegation/keeper" + delegationtype "github.com/exocore/x/delegation/types" + "github.com/exocore/x/deposit/keeper" + types2 "github.com/exocore/x/operator/types" + "github.com/exocore/x/restaking_assets_manage/types" +) + +func (suite *KeeperTestSuite) TestDelegateTo() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") clientChainLzId := uint64(101) @@ -27,7 +41,7 @@ package keeper_test TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParams) - suite.EqualError(err, delegationtype.ErrOperatorNotExist.Error()) + suite.EqualError(err, errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", delegationParams.OperatorAddress)).Error()) registerReq := &types2.RegisterOperatorReq{ FromAddress: opAccAddr.String(), @@ -57,13 +71,16 @@ package keeper_test TotalAmountOrWantChangeValue: delegationParams.OpAmount, OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanUndelegationAmount: delegationParams.OpAmount, - WaitUndelegationAmount: sdkmath.NewInt(0), + CanUndelegationAmount: delegationParams.OpAmount, + WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAmountAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.app.DelegationKeeper.GetStakerDelegationTotalAmount(suite.ctx, stakerId, assetId) @@ -130,18 +147,21 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { TotalAmountOrWantChangeValue: sdkmath.NewInt(0), OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, + OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: delegationEvent.OpAmount, + CanUndelegationAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: delegationEvent.OpAmount, + UndelegatableAmountAfterSlash: delegationEvent.OpAmount, }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.app.DelegationKeeper.GetStakerDelegationTotalAmount(suite.ctx, stakerId, assetId) suite.NoError(err) - suite.Equal(delegationEvent.OpAmount, totalDelegationAmount) + suite.Equal(sdkmath.NewInt(0), totalDelegationAmount) records, err := suite.app.DelegationKeeper.GetStakerUndelegationRecords(suite.ctx, stakerId, assetId, keeper2.PendingRecords) suite.NoError(err) @@ -232,13 +252,16 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { TotalAmountOrWantChangeValue: sdkmath.NewInt(0), OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), + CanUndelegationAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAmountAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.app.DelegationKeeper.GetStakerDelegationTotalAmount(suite.ctx, stakerId, assetId) @@ -267,4 +290,3 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { suite.Equal(1, len(waitUndelegationRecords)) suite.Equal(UndelegationRecord, waitUndelegationRecords[0]) } -*/ diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go index 2618c5d10..1d541bf23 100644 --- a/x/operator/keeper/setup_test.go +++ b/x/operator/keeper/setup_test.go @@ -36,6 +36,10 @@ type KeeperTestSuite struct { signer keyring.Signer bondDenom string stateDB *statedb.StateDB + + //needed by test + operatorAddr sdk.AccAddress + avsAddr string } func TestOperatorTestSuite(t *testing.T) { diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index a4144de3a..3aba5442b 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -1,5 +1,15 @@ package keeper_test +func (s *KeeperTestSuite) prepare() { + s.avsAddr = "avsTestAddr" + //staking assets + //register operator + //delegate to operator +} +func (s *KeeperTestSuite) OptIn() { + s.prepare() + s.app.OperatorKeeper.OptIn(s.ctx) +} func (s *KeeperTestSuite) UpdateOptedInAssetsState() { } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index d55b376e0..e4c2b265e 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -31,13 +31,25 @@ func (MockOracle) GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdk } func (MockOracle) GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) { + //use USDT as the mock asset + ret := make(map[string]*PriceChange, 0) + usdtAssetId := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" + ret[usdtAssetId] = &PriceChange{ + NewPrice: sdkmath.NewInt(1), + OriginalPrice: sdkmath.NewInt(1), + Decimal: 0, + } return nil, nil } type MockAVS struct{} func (MockAVS) GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) { - return nil, nil + //set USDT as the default asset supported by AVS + ret := make(map[string]interface{}) + usdtAssetId := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" + ret[usdtAssetId] = nil + return ret, nil } func (MockAVS) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) { From 4364b363622f199250ffa594df1ce0f8635019a0 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 7 Feb 2024 15:25:46 +0800 Subject: [PATCH 24/44] add unit test for operator module --- x/delegation/keeper/delegation_state.go | 6 +- x/operator/keeper/abci.go | 14 +- x/operator/keeper/avs_operator_shares.go | 52 ++--- x/operator/keeper/keeper.go | 4 +- x/operator/keeper/operator.go | 6 +- x/operator/keeper/operator_info_test.go | 52 ++--- x/operator/keeper/operator_slash_state.go | 12 +- x/operator/keeper/setup_test.go | 19 +- x/operator/keeper/state_update.go | 74 ++++---- x/operator/keeper/state_update_test.go | 222 +++++++++++++++++++++- x/operator/keeper/utils_test.go | 64 +++---- x/operator/types/expected_keepers.go | 2 +- x/restaking_assets_manage/types/errors.go | 2 +- 13 files changed, 374 insertions(+), 155 deletions(-) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 72dbe7ed8..5cfca004e 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -147,8 +147,8 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d return &ret, nil } -// GetDelegationStateByOperatorAndAssets get the specified assets state delegated to the specified operator -func (k Keeper) GetDelegationStateByOperatorAndAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { +// DelegationStateByOperatorAssets get the specified assets state delegated to the specified operator +func (k Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() @@ -171,7 +171,7 @@ func (k Keeper) GetDelegationStateByOperatorAndAssets(ctx sdk.Context, operatorA _, assetIDExist := assetsFilter[assetID] _, restakerIDExist := ret[restakerID] if assetIDExist { - if restakerIDExist { + if !restakerIDExist { ret[restakerID] = make(map[string]delegationtype.DelegationAmounts) } ret[restakerID][assetID] = amounts diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index e9777fbd8..31080d152 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -48,7 +48,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida if _, ok := assetsOperatorAVSInfo[assetId]; !ok { assetsOperatorAVSInfo[assetId] = make(map[string]string, 0) } - //UpdateOperatorAVSAssetsState + //UpdateStateForAsset f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { newAssetUSDValue := CalculateShare(state.Amount, priceChange.NewPrice, assetInfo.AssetBasicInfo.Decimals, priceChange.Decimal) changeValue := newAssetUSDValue.Sub(state.Value) @@ -61,18 +61,18 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida assetsOperatorAVSInfo[assetId][keys[2]] = avsAddr return nil } - err = k.IterateUpdateOperatorAVSAssets(ctx, assetId, f) + err = k.IterateUpdateAssetState(ctx, assetId, f) if err != nil { panic(err) } } - //BatchUpdateAVSAndOperatorTotalValue - err = k.BatchUpdateAVSAndOperatorTotalValue(ctx, avsOperatorShareChange) + //BatchUpdateShareForAVSAndOperator + err = k.BatchUpdateShareForAVSAndOperator(ctx, avsOperatorShareChange) if err != nil { panic(err) } - //update staker's share + //update staker'suite share sharedParameter := &SharedParameter{ priceChangeAssets: priceChangeAssets, assetsDecimal: assetsDecimal, @@ -96,8 +96,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida if err != nil { panic(err) } - //BatchSetAVSOperatorStakerShare - err = k.BatchSetAVSOperatorStakerShare(ctx, sharedParameter.stakerShare) + //BatchSetStakerShare + err = k.BatchSetStakerShare(ctx, sharedParameter.stakerShare) if err != nil { panic(err) } diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index 5d778f8c3..8c65662e7 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -10,14 +10,14 @@ import ( restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) -func (k *Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var key []byte if operatorAddr == "" { - return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateAVSOperatorTotalValue the operatorAddr is empty") + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") } else { key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } @@ -36,11 +36,11 @@ func (k *Keeper) UpdateAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorA return nil } -func (k *Keeper) DeleteAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) error { +func (k *Keeper) DeleteOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var key []byte if operatorAddr == "" { - return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateAVSOperatorTotalValue the operatorAddr is empty") + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") } else { key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } @@ -48,18 +48,18 @@ func (k *Keeper) DeleteAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorA return nil } -func (k *Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.ValueField var key []byte if operatorAddr == "" { - return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetAVSOperatorTotalValue the operatorAddr is empty") + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetOperatorShare the operatorAddr is empty") } else { key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } isExist := store.Has(key) if !isExist { - return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorTotalValue: key is %s", key)) + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorShare: key is %suite", key)) } else { value := store.Get(key) k.cdc.MustUnmarshal(value, &ret) @@ -67,7 +67,7 @@ func (k *Keeper) GetAVSOperatorTotalValue(ctx sdk.Context, avsAddr, operatorAddr return ret.Amount, nil } -func (k *Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateAVSShare(ctx sdk.Context, avsAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -87,7 +87,7 @@ func (k *Keeper) UpdateAVSTotalValue(ctx sdk.Context, avsAddr string, opAmount s return nil } -func (k *Keeper) BatchUpdateAVSAndOperatorTotalValue(ctx sdk.Context, avsOperatorChange map[string]sdkmath.LegacyDec) error { +func (k *Keeper) BatchUpdateShareForAVSAndOperator(ctx sdk.Context, avsOperatorChange map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) for avs, opAmount := range avsOperatorChange { key := []byte(avs) @@ -106,13 +106,13 @@ func (k *Keeper) BatchUpdateAVSAndOperatorTotalValue(ctx sdk.Context, avsOperato return nil } -func (k *Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.ValueField key := []byte(avsAddr) isExit := store.Has(key) if !isExit { - return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSTotalValue: key is %s", key)) + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSShare: key is %suite", key)) } else { value := store.Get(key) k.cdc.MustUnmarshal(value, &ret) @@ -120,7 +120,7 @@ func (k *Keeper) GetAVSTotalValue(ctx sdk.Context, avsAddr string) (sdkmath.Lega return ret.Amount, nil } -func (k *Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { +func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) if changeState.Amount.IsNil() && changeState.Value.IsNil() { return nil @@ -128,7 +128,7 @@ func (k *Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, //check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.OperatorAddrIsNotAccAddr + return restakingtype.ErrOperatorAddr } stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) assetOptedInState := operatortypes.AssetOptedInState{ @@ -143,12 +143,12 @@ func (k *Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, err = restakingtype.UpdateAssetValue(&assetOptedInState.Amount, &changeState.Amount) if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAVSAssetsState assetOptedInState.Amount error") + return errorsmod.Wrap(err, "UpdateStateForAsset assetOptedInState.Amount error") } err = restakingtype.UpdateAssetDecValue(&assetOptedInState.Value, &changeState.Value) if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAVSAssetsState assetOptedInState.Value error") + return errorsmod.Wrap(err, "UpdateStateForAsset assetOptedInState.Value error") } //save single operator delegation state @@ -157,19 +157,19 @@ func (k *Keeper) UpdateOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, return nil } -func (k *Keeper) DeleteOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) error { +func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) //check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.OperatorAddrIsNotAccAddr + return restakingtype.ErrOperatorAddr } stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) store.Delete(stateKey) return nil } -func (k *Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { +func (k *Keeper) GetAssetState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) isExit := store.Has(stateKey) @@ -178,12 +178,12 @@ func (k *Keeper) GetOperatorAVSAssetsState(ctx sdk.Context, assetId, avsAddr, op value := store.Get(stateKey) k.cdc.MustUnmarshal(value, &assetOptedInState) } else { - return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorAVSAssetsState: key is %s", stateKey)) + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAssetState: key is %suite", stateKey)) } return &assetOptedInState, nil } -func (k *Keeper) IterateUpdateOperatorAVSAssets(ctx sdk.Context, assetId string, f func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { +func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetId string, f func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) iterator := sdk.KVStorePrefixIterator(store, []byte(assetId)) defer iterator.Close() @@ -205,7 +205,7 @@ func (k *Keeper) IterateUpdateOperatorAVSAssets(ctx sdk.Context, assetId string, return nil } -func (k *Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -226,7 +226,7 @@ func (k *Keeper) UpdateAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, sta return nil } -func (k *Keeper) BatchSetAVSOperatorStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { +func (k *Keeper) BatchSetStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) for key, value := range newValues { optedInValue := operatortypes.ValueField{Amount: value} @@ -241,20 +241,20 @@ func (k *Keeper) BatchSetAVSOperatorStakerShare(ctx sdk.Context, newValues map[s return nil } -func (k *Keeper) DeleteAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { +func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) store.Delete(key) return nil } -func (k *Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) var ret operatortypes.ValueField key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) isExit := store.Has(key) if !isExit { - return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSOperatorStakerShareValue: key is %s", key)) + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerShare: key is %s", key)) } else { value := store.Get(key) k.cdc.MustUnmarshal(value, &ret) @@ -262,7 +262,7 @@ func (k *Keeper) GetAVSOperatorStakerShareValue(ctx sdk.Context, avsAddr, staker return ret.Amount, nil } -func (k *Keeper) GetAVSOperatorStakerInfo(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]interface{}, error) { +func (k *Keeper) GetStakerByAVSOperator(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]interface{}, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) stakers := make(map[string]interface{}, 0) iterator := sdk.KVStorePrefixIterator(store, nil) diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 64c9dc718..3e93a3a42 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -41,8 +41,8 @@ func (k *Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortype k.delegationKeeper = delegationKeeper } -func (k *Keeper) GetExpectDelegationInterface() operatortypes.ExpectDelegationInterface { - return k.delegationKeeper +func (k *Keeper) OracleInterface() operatortypes.ExpectOracleInterface { + return k.oracleKeeper } func (k *Keeper) GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 8269bc28f..dd314ee8d 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -37,7 +37,7 @@ func (k *Keeper) OperatorInfo(ctx sdk.Context, addr string) (info *operatortypes //key := common.HexToAddress(incentive.Contract) isExist := store.Has(opAccAddr) if !isExist { - return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %s", opAccAddr)) + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %suite", opAccAddr)) } value := store.Get(opAccAddr) @@ -58,7 +58,7 @@ func (k *Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, //check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.OperatorAddrIsNotAccAddr + return restakingtype.ErrOperatorAddr } infoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr) @@ -76,7 +76,7 @@ func (k *Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (in infoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr) ifExist := store.Has(infoKey) if !ifExist { - return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %s", opAccAddr)) + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %suite", opAccAddr)) } value := store.Get(infoKey) diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index b192b6c4f..f38d760fb 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -5,9 +5,9 @@ import ( "github.com/exocore/x/restaking_assets_manage/types" ) -func (s *KeeperTestSuite) TestOperatorInfo() { +func (suite *KeeperTestSuite) TestOperatorInfo() { info := &operatortype.OperatorInfo{ - EarningsAddr: s.accAddress.String(), + EarningsAddr: suite.accAddress.String(), ApproveAddr: "", OperatorMetaInfo: "test operator", ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ @@ -16,46 +16,46 @@ func (s *KeeperTestSuite) TestOperatorInfo() { }, }, } - err := s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), info) - s.NoError(err) + err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) + suite.NoError(err) - getOperatorInfo, err := s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: s.accAddress.String()}) - s.NoError(err) - s.Equal(*info, *getOperatorInfo) + getOperatorInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: suite.accAddress.String()}) + suite.NoError(err) + suite.Equal(*info, *getOperatorInfo) } -func (s *KeeperTestSuite) TestHistoricalOperatorInfo() { - height := s.ctx.BlockHeight() +func (suite *KeeperTestSuite) TestHistoricalOperatorInfo() { + height := suite.ctx.BlockHeight() info := &operatortype.OperatorInfo{ - EarningsAddr: s.accAddress.String(), + EarningsAddr: suite.accAddress.String(), ApproveAddr: "", OperatorMetaInfo: "test operator", ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ EarningInfoList: nil, }, } - err := s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), info) - s.NoError(err) - s.NextBlock() - s.Equal(height+1, s.ctx.BlockHeight(), "nexBlock failed") + err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) + suite.NoError(err) + suite.NextBlock() + suite.Equal(height+1, suite.ctx.BlockHeight(), "nexBlock failed") newInfo := *info newInfo.OperatorMetaInfo = "new operator" - err = s.app.OperatorKeeper.SetOperatorInfo(s.ctx, s.accAddress.String(), &newInfo) - s.NoError(err) + err = suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), &newInfo) + suite.NoError(err) //get historical operator info - historicalQueryCtx, err := types.ContextForHistoricalState(s.ctx, height) - s.NoError(err) - getInfo, err := s.app.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ - OperatorAddr: s.accAddress.String(), + historicalQueryCtx, err := types.ContextForHistoricalState(suite.ctx, height) + suite.NoError(err) + getInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ + OperatorAddr: suite.accAddress.String(), }) - s.NoError(err) - s.Equal(info.OperatorMetaInfo, getInfo.OperatorMetaInfo) + suite.NoError(err) + suite.Equal(info.OperatorMetaInfo, getInfo.OperatorMetaInfo) - getInfo, err = s.app.OperatorKeeper.GetOperatorInfo(s.ctx, &operatortype.GetOperatorInfoReq{ - OperatorAddr: s.accAddress.String(), + getInfo, err = suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, &operatortype.GetOperatorInfoReq{ + OperatorAddr: suite.accAddress.String(), }) - s.NoError(err) - s.Equal(newInfo.OperatorMetaInfo, getInfo.OperatorMetaInfo) + suite.NoError(err) + suite.Equal(newInfo.OperatorMetaInfo, getInfo.OperatorMetaInfo) } diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 933131643..918a2d93e 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -17,15 +17,15 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, //check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.OperatorAddrIsNotAccAddr + return restakingtype.ErrOperatorAddr } slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashId) if store.Has(slashInfoKey) { - return errorsmod.Wrap(operatortypes.ErrSlashInfoExist, fmt.Sprintf("slashInfoKey:%s", slashInfoKey)) + return errorsmod.Wrap(operatortypes.ErrSlashInfoExist, fmt.Sprintf("slashInfoKey:%suite", slashInfoKey)) } // check the validation of slash info if slashInfo.SlashContract == "" { - return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err slashContract:%s", slashInfo.SlashContract)) + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err slashContract:%suite", slashInfo.SlashContract)) } if slashInfo.OccurredHeight > slashInfo.SlashHeight { return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,OccurredHeight:%v", slashInfo.SlashHeight, slashInfo.OccurredHeight)) @@ -50,7 +50,7 @@ func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, sl value := store.Get(slashInfoKey) k.cdc.MustUnmarshal(value, &operatorSlashInfo) } else { - return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorSlashInfo: key is %s", slashInfoKey)) + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorSlashInfo: key is %suite", slashInfoKey)) } return &operatorSlashInfo, nil } @@ -62,7 +62,7 @@ func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperat store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte if stakerOrOperator == "" || assetId == "" { - return errorsmod.Wrap(operatortypes.ErrParameterInvalid, fmt.Sprintf("assetId:%s,stakerOrOperator:%s", assetId, stakerOrOperator)) + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, fmt.Sprintf("assetId:%suite,stakerOrOperator:%suite", assetId, stakerOrOperator)) } key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerOrOperator) @@ -104,7 +104,7 @@ func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator var ret restakingtype.ValueField isExit := store.Has(key) if !isExit { - return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetSlashAssetsState: key is %s", key)) + return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetSlashAssetsState: key is %suite", key)) } else { value := store.Get(key) k.cdc.MustUnmarshal(value, &ret) diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go index 1d541bf23..c9827f9b2 100644 --- a/x/operator/keeper/setup_test.go +++ b/x/operator/keeper/setup_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/suite" "testing" "github.com/evmos/evmos/v14/x/evm/statedb" @@ -16,7 +18,6 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" evmosapp "github.com/exocore/app" - "github.com/stretchr/testify/suite" ) var s *KeeperTestSuite @@ -38,8 +39,16 @@ type KeeperTestSuite struct { stateDB *statedb.StateDB //needed by test - operatorAddr sdk.AccAddress - avsAddr string + operatorAddr sdk.AccAddress + avsAddr string + assetId string + stakerId string + assetAddr common.Address + assetDecimal uint32 + clientChainLzId uint64 + depositAmount sdkmath.Int + delegationAmount sdkmath.Int + updatedAmountForOptIn sdkmath.Int } func TestOperatorTestSuite(t *testing.T) { @@ -51,6 +60,6 @@ func TestOperatorTestSuite(t *testing.T) { RunSpecs(t, "operator module Suite") } -func (s *KeeperTestSuite) SetupTest() { - s.DoSetupTest() +func (suite *KeeperTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index ff50888d5..eba4863a0 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -20,7 +20,7 @@ type slashAmounts struct { AmountFromUnbonding sdkmath.Int AmountFromOptedIn sdkmath.Int } -type SlashAssetsAndAmount struct { +type SlashAssets struct { slashStakerInfo map[string]map[string]*slashAmounts slashOperatorInfo map[string]*slashAmounts } @@ -51,30 +51,30 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, op } if _, ok := avsSupportedAssets[assetId]; ok { - //UpdateAVSOperatorStakerShareValue - err = k.UpdateAVSOperatorStakerShareValue(ctx, avs, stakerId, operatorAddr, opUSDValue) + //UpdateStakerShare + err = k.UpdateStakerShare(ctx, avs, stakerId, operatorAddr, opUSDValue) if err != nil { return err } - //UpdateOperatorAVSAssetsState + //UpdateStateForAsset changeState := types.AssetOptedInState{ Amount: opAmount, Value: opUSDValue, } - err = k.UpdateOperatorAVSAssetsState(ctx, assetId, avs, operatorAddr, changeState) + err = k.UpdateStateForAsset(ctx, assetId, avs, operatorAddr, changeState) if err != nil { return err } - //UpdateAVSOperatorTotalValue - err = k.UpdateAVSOperatorTotalValue(ctx, avs, operatorAddr, opUSDValue) + //UpdateOperatorShare + err = k.UpdateOperatorShare(ctx, avs, operatorAddr, opUSDValue) if err != nil { return err } - //UpdateAVSTotalValue - err = k.UpdateAVSTotalValue(ctx, avs, opUSDValue) + //UpdateAVSShare + err = k.UpdateAVSShare(ctx, avs, opUSDValue) if err != nil { return err } @@ -127,12 +127,12 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr operatorUSDValue := CalculateShare(operatorAssetState.OperatorOwnAmountOrWantChangeValue, price, assetInfo.AssetBasicInfo.Decimals, decimal) operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(operatorUSDValue) - //UpdateOperatorAVSAssetsState + //UpdateStateForAsset changeState := types.AssetOptedInState{ Amount: operatorAssetState.TotalAmountOrWantChangeValue, Value: assetUSDValue, } - err = k.UpdateOperatorAVSAssetsState(ctx, assetId, AVSAddr, operatorAddress.String(), changeState) + err = k.UpdateStateForAsset(ctx, assetId, AVSAddr, operatorAddress.String(), changeState) if err != nil { return err } @@ -141,24 +141,24 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } //update the share value of operator itself, the input stakerId should be empty - err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUSDValue) + err = k.UpdateStakerShare(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUSDValue) if err != nil { return err } - //UpdateAVSTotalValue - err = k.UpdateAVSTotalValue(ctx, AVSAddr, totalAssetUSDValue) + //UpdateAVSShare + err = k.UpdateAVSShare(ctx, AVSAddr, totalAssetUSDValue) if err != nil { return err } - //UpdateAVSOperatorTotalValue - err = k.UpdateAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String(), totalAssetUSDValue) + //UpdateOperatorShare + err = k.UpdateOperatorShare(ctx, AVSAddr, operatorAddress.String(), totalAssetUSDValue) if err != nil { return err } - //UpdateAVSOperatorStakerShareValue - relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetFilter) + //UpdateStakerShare + relatedAssetsState, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetFilter) if err != nil { return err } @@ -170,7 +170,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) } - err = k.UpdateAVSOperatorStakerShareValue(ctx, AVSAddr, stakerId, operatorAddress.String(), stakerAssetsUSDValue) + err = k.UpdateStakerShare(ctx, AVSAddr, stakerId, operatorAddress.String(), stakerAssetsUSDValue) if err != nil { return err } @@ -214,45 +214,45 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr assetFilter := make(map[string]interface{}) for assetId := range operatorAssets { - err = k.DeleteOperatorAVSAssetsState(ctx, assetId, AVSAddr, operatorAddress.String()) + err = k.DeleteAssetState(ctx, assetId, AVSAddr, operatorAddress.String()) if err != nil { return err } assetFilter[assetId] = nil } - avsOperatorTotalValue, err := k.GetAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String()) + avsOperatorTotalValue, err := k.GetOperatorShare(ctx, AVSAddr, operatorAddress.String()) if err != nil { return err } if avsOperatorTotalValue.IsNegative() { - return errorsmod.Wrap(types.ErrTheValueIsNegative, fmt.Sprintf("OptOut,avsOperatorTotalValue:%s", avsOperatorTotalValue)) + return errorsmod.Wrap(types.ErrTheValueIsNegative, fmt.Sprintf("OptOut,avsOperatorTotalValue:%suite", avsOperatorTotalValue)) } //delete the share value of operator itself, the input stakerId should be empty - err = k.DeleteAVSOperatorStakerShareValue(ctx, AVSAddr, "", operatorAddress.String()) + err = k.DeleteStakerShare(ctx, AVSAddr, "", operatorAddress.String()) if err != nil { return err } - //UpdateAVSTotalValue - err = k.UpdateAVSTotalValue(ctx, AVSAddr, avsOperatorTotalValue.Neg()) + //UpdateAVSShare + err = k.UpdateAVSShare(ctx, AVSAddr, avsOperatorTotalValue.Neg()) if err != nil { return err } - //DeleteAVSOperatorTotalValue - err = k.DeleteAVSOperatorTotalValue(ctx, AVSAddr, operatorAddress.String()) + //DeleteOperatorShare + err = k.DeleteOperatorShare(ctx, AVSAddr, operatorAddress.String()) if err != nil { return err } - //DeleteAVSOperatorStakerShareValue - relatedAssetsState, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetFilter) + //DeleteStakerShare + relatedAssetsState, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetFilter) if err != nil { return err } for stakerId := range relatedAssetsState { - err = k.DeleteAVSOperatorStakerShareValue(ctx, AVSAddr, stakerId, operatorAddress.String()) + err = k.DeleteStakerShare(ctx, AVSAddr, stakerId, operatorAddress.String()) if err != nil { return err } @@ -271,9 +271,9 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return nil } -// GetAssetsAndAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. -func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssetsAndAmount, error) { - ret := &SlashAssetsAndAmount{ +// GetAssetsAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. +func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssets, error) { + ret := &SlashAssets{ slashStakerInfo: make(map[string]map[string]*slashAmounts, 0), slashOperatorInfo: make(map[string]*slashAmounts, 0), } @@ -288,7 +288,7 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. if err != nil { return nil, err } - historyStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(historicalSateCtx, operatorAddress.String(), assetsFilter) + historyStakerAssets, err := k.delegationKeeper.DelegationStateByOperatorAssets(historicalSateCtx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } @@ -300,7 +300,7 @@ func (k *Keeper) GetAssetsAndAmountToSlash(ctx sdk.Context, operatorAddress sdk. } //calculate the actual slash amount according to the history and current state - currentStakerAssets, err := k.delegationKeeper.GetDelegationStateByOperatorAndAssets(ctx, operatorAddress.String(), assetsFilter) + currentStakerAssets, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } @@ -455,7 +455,7 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, return err } if optedInfo.SlashContract != slashContract { - return errorsmod.Wrap(types.ErrSlashContractNotMatch, fmt.Sprintf("input slashContract:%s, opted-in slash contract:%s", slashContract, optedInfo.SlashContract)) + return errorsmod.Wrap(types.ErrSlashContractNotMatch, fmt.Sprintf("input slashContract:%suite, opted-in slash contract:%suite", slashContract, optedInfo.SlashContract)) } //todo: recording the slash event might be moved to the slash module @@ -472,7 +472,7 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, } // get the assets and amounts that should be slashed - assetsSlashInfo, err := k.GetAssetsAndAmountToSlash(ctx, operatorAddress, AVSAddr, occurredSateHeight, slashProportion) + assetsSlashInfo, err := k.GetAssetsAmountToSlash(ctx, operatorAddress, AVSAddr, occurredSateHeight, slashProportion) if err != nil { return err } diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index 3aba5442b..aed79576e 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -1,15 +1,225 @@ package keeper_test -func (s *KeeperTestSuite) prepare() { - s.avsAddr = "avsTestAddr" +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + delegationKeeper "github.com/exocore/x/delegation/keeper" + "github.com/exocore/x/deposit/keeper" + operatorKeeper "github.com/exocore/x/operator/keeper" + operatorTypes "github.com/exocore/x/operator/types" + restakingTypes "github.com/exocore/x/restaking_assets_manage/types" + "strings" +) + +type StateForCheck struct { + OptedInfo *operatorTypes.OptedInfo + AVSTotalShare sdkmath.LegacyDec + AVSOperatorShare sdkmath.LegacyDec + AssetState *operatorTypes.AssetOptedInState + OperatorShare sdkmath.LegacyDec + StakerShare sdkmath.LegacyDec +} + +func (suite *KeeperTestSuite) prepare() { + opAccAddr, err := sdk.AccAddressFromBech32("evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl") + suite.NoError(err) + usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") + clientChainLzId := uint64(101) + + suite.avsAddr = "avsTestAddr" + suite.operatorAddr = opAccAddr + suite.assetAddr = usdtAddress + suite.assetDecimal = 6 + suite.clientChainLzId = clientChainLzId + suite.depositAmount = sdkmath.NewInt(100) + suite.delegationAmount = sdkmath.NewInt(50) + suite.updatedAmountForOptIn = sdkmath.NewInt(20) + suite.stakerId, suite.assetId = restakingTypes.GetStakeIDAndAssetId(suite.clientChainLzId, suite.address[:], suite.assetAddr[:]) + //staking assets + depositParam := &keeper.DepositParams{ + ClientChainLzId: suite.clientChainLzId, + Action: restakingTypes.Deposit, + StakerAddress: suite.address[:], + OpAmount: suite.depositAmount, + } + depositParam.AssetsAddress = suite.assetAddr[:] + err = suite.app.DepositKeeper.Deposit(suite.ctx, depositParam) + suite.NoError(err) + //register operator + registerReq := &operatorTypes.RegisterOperatorReq{ + FromAddress: suite.operatorAddr.String(), + Info: &operatorTypes.OperatorInfo{ + EarningsAddr: suite.operatorAddr.String(), + }, + } + _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) + suite.NoError(err) + //delegate to operator + delegationParam := &delegationKeeper.DelegationOrUndelegationParams{ + ClientChainLzId: suite.clientChainLzId, + Action: restakingTypes.DelegateTo, + AssetsAddress: suite.assetAddr[:], + OperatorAddress: suite.operatorAddr, + StakerAddress: suite.address[:], + OpAmount: suite.delegationAmount, + LzNonce: 0, + TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), + } + err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParam) + suite.NoError(err) +} + +func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { + //check opted info + optInfo, err := suite.app.OperatorKeeper.GetOptedInfo(suite.ctx, suite.operatorAddr.String(), suite.avsAddr) + if expectedState.OptedInfo == nil { + suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) + } else { + suite.NoError(err) + suite.Equal(*expectedState.OptedInfo, *optInfo) + } + //check total USD value for AVS and operator + value, err := suite.app.OperatorKeeper.GetAVSShare(suite.ctx, suite.avsAddr) + if expectedState.AVSTotalShare.IsNil() { + suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) + } else { + suite.NoError(err) + suite.Equal(expectedState.AVSTotalShare, value) + } + + value, err = suite.app.OperatorKeeper.GetOperatorShare(suite.ctx, suite.avsAddr, suite.operatorAddr.String()) + if expectedState.AVSOperatorShare.IsNil() { + suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) + } else { + suite.NoError(err) + suite.Equal(expectedState.AVSOperatorShare, value) + } + + //check assets state for AVS and operator + assetState, err := suite.app.OperatorKeeper.GetAssetState(suite.ctx, suite.assetId, suite.avsAddr, suite.operatorAddr.String()) + if expectedState.AssetState == nil { + suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) + } else { + suite.NoError(err) + suite.Equal(*expectedState.AssetState, *assetState) + } + + //check asset USD share for staker and operator + operatorShare, err := suite.app.OperatorKeeper.GetStakerShare(suite.ctx, suite.avsAddr, "", suite.operatorAddr.String()) + if expectedState.OperatorShare.IsNil() { + suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) + } else { + suite.NoError(err) + suite.Equal(expectedState.OperatorShare, operatorShare) + } + stakerShare, err := suite.app.OperatorKeeper.GetStakerShare(suite.ctx, suite.avsAddr, suite.stakerId, suite.operatorAddr.String()) + if expectedState.StakerShare.IsNil() { + suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) + } else { + suite.NoError(err) + suite.Equal(expectedState.StakerShare, stakerShare) + } } -func (s *KeeperTestSuite) OptIn() { - s.prepare() - s.app.OperatorKeeper.OptIn(s.ctx) + +func (suite *KeeperTestSuite) TestOptIn() { + suite.prepare() + err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + suite.NoError(err) + //check if the related state is correct + price, decimal, err := suite.app.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.ctx, suite.assetId) + share := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) + expectedState := &StateForCheck{ + OptedInfo: &operatorTypes.OptedInfo{ + OptedInHeight: uint64(suite.ctx.BlockHeight()), + OptedOutHeight: operatorTypes.DefaultOptedOutHeight, + }, + AVSTotalShare: share, + AVSOperatorShare: share, + AssetState: &operatorTypes.AssetOptedInState{ + Amount: suite.delegationAmount, + Value: share, + }, + OperatorShare: sdkmath.LegacyDec{}, + StakerShare: share, + } + suite.CheckState(expectedState) +} + +func (suite *KeeperTestSuite) TestOptOut() { + suite.prepare() + err := suite.app.OperatorKeeper.OptOut(suite.ctx, suite.operatorAddr, suite.avsAddr) + suite.EqualError(err, operatorTypes.ErrNotOptedIn.Error()) + + err = suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + suite.NoError(err) + optInHeight := suite.ctx.BlockHeight() + suite.NextBlock() + + err = suite.app.OperatorKeeper.OptOut(suite.ctx, suite.operatorAddr, suite.avsAddr) + suite.NoError(err) + + expectedState := &StateForCheck{ + OptedInfo: &operatorTypes.OptedInfo{ + OptedInHeight: uint64(optInHeight), + OptedOutHeight: uint64(suite.ctx.BlockHeight()), + }, + AVSTotalShare: sdkmath.LegacyNewDec(0), + AVSOperatorShare: sdkmath.LegacyDec{}, + AssetState: nil, + OperatorShare: sdkmath.LegacyDec{}, + StakerShare: sdkmath.LegacyDec{}, + } + suite.CheckState(expectedState) } -func (s *KeeperTestSuite) UpdateOptedInAssetsState() { +func (suite *KeeperTestSuite) TestCalculateShare() { + suite.prepare() + price, decimal, err := suite.app.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.ctx, suite.assetId) + suite.NoError(err) + share := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) + suite.Equal(sdkmath.LegacyNewDecWithPrec(5000, int64(operatorTypes.USDValueDefaultDecimal)), share) } + +func (suite *KeeperTestSuite) TestUpdateOptedInAssetsState() { + suite.prepare() + err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + suite.NoError(err) + optInHeight := suite.ctx.BlockHeight() + suite.NextBlock() + + err = suite.app.OperatorKeeper.UpdateOptedInAssetsState(suite.ctx, suite.stakerId, suite.assetId, suite.operatorAddr.String(), suite.updatedAmountForOptIn) + suite.NoError(err) + + price, decimal, err := suite.app.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.ctx, suite.assetId) + oldShare := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) + addShare := operatorKeeper.CalculateShare(suite.updatedAmountForOptIn, price, suite.assetDecimal, decimal) + newShare := oldShare.Add(addShare) + + expectedState := &StateForCheck{ + OptedInfo: &operatorTypes.OptedInfo{ + OptedInHeight: uint64(optInHeight), + OptedOutHeight: operatorTypes.DefaultOptedOutHeight, + }, + AVSTotalShare: newShare, + AVSOperatorShare: newShare, + AssetState: &operatorTypes.AssetOptedInState{ + Amount: suite.delegationAmount.Add(suite.updatedAmountForOptIn), + Value: newShare, + }, + OperatorShare: sdkmath.LegacyDec{}, + StakerShare: newShare, + } + suite.CheckState(expectedState) +} + +/*func (suite *KeeperTestSuite) TestSlash() { + suite.prepare() + err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + suite.NoError(err) + optInHeight := suite.ctx.BlockHeight() + suite.NextBlock() +}*/ diff --git a/x/operator/keeper/utils_test.go b/x/operator/keeper/utils_test.go index 4eb2d566e..be31f2e10 100644 --- a/x/operator/keeper/utils_test.go +++ b/x/operator/keeper/utils_test.go @@ -36,11 +36,11 @@ import ( // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. -func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { +func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, &pruneOpts, false)() app, ok := appI.(*evmosapp.ExocoreApp) - s.Require().True(ok) + suite.Require().True(ok) // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) @@ -53,9 +53,9 @@ func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, g for _, val := range valSet.Validators { pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - s.Require().NoError(err) + suite.Require().NoError(err) pkAny, err := codectypes.NewAnyWithValue(pk) - s.Require().NoError(err) + suite.Require().NoError(err) validator := stakingtypes.Validator{ OperatorAddress: sdk.ValAddress(val.Address).String(), ConsensusPubkey: pkAny, @@ -72,7 +72,7 @@ func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, g validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) } - s.validators = validators + suite.validators = validators // set validators and delegations stakingParams := stakingtypes.DefaultParams() @@ -99,7 +99,7 @@ func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, g genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) + suite.Require().NoError(err) // init chain will set the validator set and initialize the genesis accounts app.InitChain( @@ -127,24 +127,24 @@ func (s *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, g }) // need to create UncachedContext when retrieving historical state - s.ctx = app.BaseApp.NewUncachedContext(false, header) - s.app = app + suite.ctx = app.BaseApp.NewUncachedContext(false, header) + suite.app = app } -func (s *KeeperTestSuite) DoSetupTest() { +func (suite *KeeperTestSuite) DoSetupTest() { // generate validator private/public key privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() - s.Require().NoError(err) + suite.Require().NoError(err) privVal2 := mock.NewPV() pubKey2, err := privVal2.GetPubKey() - s.Require().NoError(err) + suite.Require().NoError(err) // create validator set with two validators validator := tmtypes.NewValidator(pubKey, 1) validator2 := tmtypes.NewValidator(pubKey2, 2) - s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) + suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) signers := make(map[string]tmtypes.PrivValidator) signers[pubKey.Address().String()] = privVal signers[pubKey2.Address().String()] = privVal2 @@ -153,13 +153,13 @@ func (s *KeeperTestSuite) DoSetupTest() { pubBz := make([]byte, ed25519.PubKeySize) pub := &ed25519.PubKey{Key: pubBz} rand.Read(pub.Key) - s.accAddress = sdk.AccAddress(pub.Address()) + suite.accAddress = sdk.AccAddress(pub.Address()) // generate genesis account addr, priv := testutiltx.NewAddrKey() - s.privKey = priv - s.address = addr - s.signer = testutiltx.NewSigner(priv) + suite.privKey = priv + suite.address = addr + suite.signer = testutiltx.NewSigner(priv) baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) @@ -175,35 +175,35 @@ func (s *KeeperTestSuite) DoSetupTest() { Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), } - s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) + suite.SetupWithGenesisValSet(suite.valSet, []authtypes.GenesisAccount{acc}, balance) // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + suite.stateDB = statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) // bond denom - stakingParams := s.app.StakingKeeper.GetParams(s.ctx) + stakingParams := suite.app.StakingKeeper.GetParams(suite.ctx) stakingParams.BondDenom = utils.BaseDenom - s.bondDenom = stakingParams.BondDenom - err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) - s.Require().NoError(err) + suite.bondDenom = stakingParams.BondDenom + err = suite.app.StakingKeeper.SetParams(suite.ctx, stakingParams) + suite.Require().NoError(err) - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) + suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - s.Require().NoError(err) + err = suite.app.BankKeeper.MintCoins(suite.ctx, inflationtypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) + suite.Require().NoError(err) } // NextBlock commits the current block and sets up the next block. -func (s *KeeperTestSuite) NextBlock() { +func (suite *KeeperTestSuite) NextBlock() { var err error - s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet, true) - s.Require().NoError(err) + suite.ctx, err = testutil.CommitAndCreateNewCtx(suite.ctx, suite.app, time.Second, suite.valSet, true) + suite.Require().NoError(err) } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index e4c2b265e..70d7b3465 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -7,7 +7,7 @@ import ( ) type ExpectDelegationInterface interface { - GetDelegationStateByOperatorAndAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) + DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) diff --git a/x/restaking_assets_manage/types/errors.go b/x/restaking_assets_manage/types/errors.go index b7b353d86..a06935983 100644 --- a/x/restaking_assets_manage/types/errors.go +++ b/x/restaking_assets_manage/types/errors.go @@ -21,7 +21,7 @@ var ( ErrInputPointerIsNil = errorsmod.Register(ModuleName, 7, "the input pointer is nil") - OperatorAddrIsNotAccAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid acc addr") + ErrOperatorAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid acc addr") ErrNoKeyInTheStore = errorsmod.Register(ModuleName, 9, "there is not the key for in the store") ) From 5fbedd07eada9c896b14646c6fe57248788d6a37 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Fri, 23 Feb 2024 15:33:10 +0800 Subject: [PATCH 25/44] fix the problems after rebasing to dogfood --- app/app.go | 6 +- crypto/ethsecp256k1/keys.pb.go | 500 ---------------------- precompiles/delegation/delegation_test.go | 2 +- proto/exocore/operator/v1/query.proto | 2 +- proto/exocore/operator/v1/tx.proto | 2 +- x/delegation/keeper/delegation_op_test.go | 10 +- x/delegation/keeper/delegation_state.go | 1 - x/delegation/keeper/keeper.go | 2 - x/delegation/types/keys.go | 2 +- x/operator/client/cli/query.go | 2 +- x/operator/client/cli/tx.go | 2 +- x/operator/keeper/abci.go | 6 +- x/operator/keeper/avs_operator_shares.go | 4 +- x/operator/keeper/common_func.go | 2 +- x/operator/keeper/grpc_query.go | 2 +- x/operator/keeper/keeper.go | 4 +- x/operator/keeper/msg_server.go | 2 +- x/operator/keeper/operator.go | 4 +- x/operator/keeper/operator_info_test.go | 4 +- x/operator/keeper/operator_slash_state.go | 4 +- x/operator/keeper/setup_test.go | 2 +- x/operator/keeper/state_update.go | 6 +- x/operator/keeper/state_update_test.go | 10 +- x/operator/module.go | 6 +- x/operator/types/expected_keepers.go | 2 +- 25 files changed, 43 insertions(+), 546 deletions(-) delete mode 100644 crypto/ethsecp256k1/keys.pb.go diff --git a/app/app.go b/app/app.go index 4b7591aa2..95dcf1f55 100644 --- a/app/app.go +++ b/app/app.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" "fmt" - "github.com/exocore/x/operator" - operatorKeeper "github.com/exocore/x/operator/keeper" + "github.com/ExocoreNetwork/exocore/x/operator" + operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" "io" "net/http" "os" @@ -31,6 +31,7 @@ import ( "github.com/ExocoreNetwork/exocore/x/deposit" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositTypes "github.com/ExocoreNetwork/exocore/x/deposit/types" + operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage" stakingAssetsManageKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" stakingAssetsManageTypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" @@ -47,7 +48,6 @@ import ( "github.com/evmos/evmos/v14/x/recovery" "github.com/evmos/evmos/v14/x/revenue/v1" vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" - operatorTypes "github.com/exocore/x/operator/types" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" diff --git a/crypto/ethsecp256k1/keys.pb.go b/crypto/ethsecp256k1/keys.pb.go deleted file mode 100644 index 4b902eef7..000000000 --- a/crypto/ethsecp256k1/keys.pb.go +++ /dev/null @@ -1,500 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/crypto/v1/ethsecp256k1/keys.proto - -package ethsecp256k1 - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - 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 - -// PubKey defines a type alias for an ecdsa.PublicKey that implements -// Tendermint's PubKey interface. It represents the 33-byte compressed public -// key format. -type PubKey struct { - // key is the public key in byte form - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` -} - -func (m *PubKey) Reset() { *m = PubKey{} } -func (*PubKey) ProtoMessage() {} -func (*PubKey) Descriptor() ([]byte, []int) { - return fileDescriptor_0c10cadcf35beb64, []int{0} -} -func (m *PubKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PubKey.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 *PubKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PubKey.Merge(m, src) -} -func (m *PubKey) XXX_Size() int { - return m.Size() -} -func (m *PubKey) XXX_DiscardUnknown() { - xxx_messageInfo_PubKey.DiscardUnknown(m) -} - -var xxx_messageInfo_PubKey proto.InternalMessageInfo - -func (m *PubKey) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -// PrivKey defines a type alias for an ecdsa.PrivateKey that implements -// Tendermint's PrivateKey interface. -type PrivKey struct { - // key is the private key in byte form - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` -} - -func (m *PrivKey) Reset() { *m = PrivKey{} } -func (m *PrivKey) String() string { return proto.CompactTextString(m) } -func (*PrivKey) ProtoMessage() {} -func (*PrivKey) Descriptor() ([]byte, []int) { - return fileDescriptor_0c10cadcf35beb64, []int{1} -} -func (m *PrivKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PrivKey.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 *PrivKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PrivKey.Merge(m, src) -} -func (m *PrivKey) XXX_Size() int { - return m.Size() -} -func (m *PrivKey) XXX_DiscardUnknown() { - xxx_messageInfo_PrivKey.DiscardUnknown(m) -} - -var xxx_messageInfo_PrivKey proto.InternalMessageInfo - -func (m *PrivKey) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func init() { - proto.RegisterType((*PubKey)(nil), "ethermint.crypto.v1.ethsecp256k1.PubKey") - proto.RegisterType((*PrivKey)(nil), "ethermint.crypto.v1.ethsecp256k1.PrivKey") -} - -func init() { - proto.RegisterFile("ethermint/crypto/v1/ethsecp256k1/keys.proto", fileDescriptor_0c10cadcf35beb64) -} - -var fileDescriptor_0c10cadcf35beb64 = []byte{ - // 205 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0x2d, 0xc9, 0x48, - 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x33, 0xd4, - 0x4f, 0x2d, 0xc9, 0x28, 0x4e, 0x4d, 0x2e, 0x30, 0x32, 0x35, 0xcb, 0x36, 0xd4, 0xcf, 0x4e, 0xad, - 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x80, 0x2b, 0xd6, 0x83, 0x28, 0xd6, 0x2b, - 0x33, 0xd4, 0x43, 0x56, 0x2c, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xac, 0x0f, 0x62, 0x41, - 0xf4, 0x29, 0x29, 0x70, 0xb1, 0x05, 0x94, 0x26, 0x79, 0xa7, 0x56, 0x0a, 0x09, 0x70, 0x31, 0x67, - 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0x98, 0x56, 0x2c, 0x33, 0x16, 0xc8, - 0x33, 0x28, 0x49, 0x73, 0xb1, 0x07, 0x14, 0x65, 0x96, 0x61, 0x55, 0xe2, 0xe4, 0x7f, 0xe2, 0x91, - 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, - 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa6, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, - 0xc9, 0xf9, 0xb9, 0xfa, 0xae, 0x15, 0xf9, 0xc9, 0xf9, 0x45, 0xa9, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, - 0x45, 0xd9, 0xfa, 0xa9, 0x10, 0x2e, 0xcc, 0x57, 0xc8, 0xae, 0x4c, 0x62, 0x03, 0x3b, 0xcb, 0x18, - 0x10, 0x00, 0x00, 0xff, 0xff, 0x15, 0x4f, 0x72, 0x20, 0xfd, 0x00, 0x00, 0x00, -} - -func (m *PubKey) 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 *PubKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PubKey) 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 = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PrivKey) 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 *PrivKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PrivKey) 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 = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { - offset -= sovKeys(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *PubKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovKeys(uint64(l)) - } - return n -} - -func (m *PrivKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovKeys(uint64(l)) - } - return n -} - -func sovKeys(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozKeys(x uint64) (n int) { - return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *PubKey) 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 ErrIntOverflowKeys - } - 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: PubKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PubKey: 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 byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowKeys - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthKeys - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthKeys - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipKeys(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthKeys - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PrivKey) 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 ErrIntOverflowKeys - } - 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: PrivKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PrivKey: 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 byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowKeys - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthKeys - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthKeys - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipKeys(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthKeys - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipKeys(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, ErrIntOverflowKeys - } - 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, ErrIntOverflowKeys - } - 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, ErrIntOverflowKeys - } - 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, ErrInvalidLengthKeys - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupKeys - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthKeys - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") -) diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 21055e3e3..e75dcb940 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -1,7 +1,7 @@ package delegation_test import ( - operatortypes "github.com/exocore/x/operator/types" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "math/big" "strings" diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index f362e8d31..1f351ae2d 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -7,7 +7,7 @@ import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; import "exocore/operator/v1/tx.proto"; -option go_package = "github.com/exocore/x/operator/types"; +option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; message GetOperatorInfoReq { string OperatorAddr = 1 diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 016bc61ac..a55bd3f8a 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -6,7 +6,7 @@ import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; -option go_package = "github.com/exocore/x/operator/types"; +option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; message clientChainEarningAddrList { repeated clientChainEarningAddrInfo EarningInfoList = 1; diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index f144ad0d6..d0d457c98 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -4,14 +4,14 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "fmt" + keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + "github.com/ExocoreNetwork/exocore/x/deposit/keeper" + types2 "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - keeper2 "github.com/exocore/x/delegation/keeper" - delegationtype "github.com/exocore/x/delegation/types" - "github.com/exocore/x/deposit/keeper" - types2 "github.com/exocore/x/operator/types" - "github.com/exocore/x/restaking_assets_manage/types" ) func (suite *KeeperTestSuite) TestDelegateTo() { diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 5cfca004e..978186e65 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -6,7 +6,6 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" stakingtypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 0c06036e8..e987da2ec 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -2,9 +2,7 @@ package keeper import ( "context" - "fmt" - errorsmod "cosmossdk.io/errors" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" depositkeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index f0d013dc0..598bd5353 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -1,10 +1,10 @@ package types import ( + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/exocore/x/restaking_assets_manage/types" "strings" ) diff --git a/x/operator/client/cli/query.go b/x/operator/client/cli/query.go index 8639be0b4..2e4ad5e2d 100644 --- a/x/operator/client/cli/query.go +++ b/x/operator/client/cli/query.go @@ -3,7 +3,7 @@ package cli import ( "context" - operatortypes "github.com/exocore/x/operator/types" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/operator/client/cli/tx.go b/x/operator/client/cli/tx.go index b1901c729..b6f7ec6da 100644 --- a/x/operator/client/cli/tx.go +++ b/x/operator/client/cli/tx.go @@ -6,8 +6,8 @@ import ( "strings" errorsmod "cosmossdk.io/errors" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/cosmos/cosmos-sdk/client/flags" - operatortypes "github.com/exocore/x/operator/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 31080d152..4aba20cfc 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -2,11 +2,11 @@ package keeper import ( sdkmath "cosmossdk.io/math" + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - delegationtype "github.com/exocore/x/delegation/types" - operatortypes "github.com/exocore/x/operator/types" - "github.com/exocore/x/restaking_assets_manage/types" ) type SharedParameter struct { diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index 8c65662e7..56db14f1a 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -4,10 +4,10 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "fmt" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - operatortypes "github.com/exocore/x/operator/types" - restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) func (k *Keeper) UpdateOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { diff --git a/x/operator/keeper/common_func.go b/x/operator/keeper/common_func.go index 4d6c6e119..677318a17 100644 --- a/x/operator/keeper/common_func.go +++ b/x/operator/keeper/common_func.go @@ -2,7 +2,7 @@ package keeper import ( sdkmath "cosmossdk.io/math" - operatortypes "github.com/exocore/x/operator/types" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" ) type LegacyDecMap map[string]sdkmath.LegacyDec diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index 162fcd037..eaeb0f34f 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -3,8 +3,8 @@ package keeper import ( "context" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" - operatortypes "github.com/exocore/x/operator/types" ) var _ operatortypes.QueryServer = &Keeper{} diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 3e93a3a42..440431671 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -3,11 +3,11 @@ package keeper import ( "context" sdkmath "cosmossdk.io/math" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - operatortypes "github.com/exocore/x/operator/types" - "github.com/exocore/x/restaking_assets_manage/keeper" ) type Keeper struct { diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go index 357b5e0b9..0a1e594c4 100644 --- a/x/operator/keeper/msg_server.go +++ b/x/operator/keeper/msg_server.go @@ -3,8 +3,8 @@ package keeper import ( context "context" + "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/exocore/x/operator/types" ) var _ types.MsgServer = &Keeper{} diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index dd314ee8d..6f6add31f 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -3,10 +3,10 @@ package keeper import ( errorsmod "cosmossdk.io/errors" "fmt" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - operatortypes "github.com/exocore/x/operator/types" - restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) // SetOperatorInfo This function is used to register to be an operator in exoCore, the provided info will be stored on the chain. diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index f38d760fb..4ae5d47b9 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -1,8 +1,8 @@ package keeper_test import ( - operatortype "github.com/exocore/x/operator/types" - "github.com/exocore/x/restaking_assets_manage/types" + operatortype "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" ) func (suite *KeeperTestSuite) TestOperatorInfo() { diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 918a2d93e..73c6c0ff9 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -4,11 +4,11 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "fmt" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" - operatortypes "github.com/exocore/x/operator/types" - restakingtype "github.com/exocore/x/restaking_assets_manage/types" ) func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashId string, slashInfo operatortypes.OperatorSlashInfo) error { diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go index c9827f9b2..a13fa1ce8 100644 --- a/x/operator/keeper/setup_test.go +++ b/x/operator/keeper/setup_test.go @@ -10,6 +10,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + evmosapp "github.com/ExocoreNetwork/exocore/app" tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -17,7 +18,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - evmosapp "github.com/exocore/app" ) var s *KeeperTestSuite diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index eba4863a0..afdc2fe12 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -4,10 +4,10 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "fmt" + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + "github.com/ExocoreNetwork/exocore/x/operator/types" + types2 "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" - delegationtype "github.com/exocore/x/delegation/types" - "github.com/exocore/x/operator/types" - types2 "github.com/exocore/x/restaking_assets_manage/types" ) type AssetPriceAndDecimal struct { diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index aed79576e..7a96ae94c 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -2,13 +2,13 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" + delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" + "github.com/ExocoreNetwork/exocore/x/deposit/keeper" + operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" + operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" + restakingTypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - delegationKeeper "github.com/exocore/x/delegation/keeper" - "github.com/exocore/x/deposit/keeper" - operatorKeeper "github.com/exocore/x/operator/keeper" - operatorTypes "github.com/exocore/x/operator/types" - restakingTypes "github.com/exocore/x/restaking_assets_manage/types" "strings" ) diff --git a/x/operator/module.go b/x/operator/module.go index d5ec10cc2..f14f48755 100644 --- a/x/operator/module.go +++ b/x/operator/module.go @@ -2,6 +2,9 @@ package operator import ( "context" + "github.com/ExocoreNetwork/exocore/x/operator/client/cli" + "github.com/ExocoreNetwork/exocore/x/operator/keeper" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -9,9 +12,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/exocore/x/operator/client/cli" - "github.com/exocore/x/operator/keeper" - operatortypes "github.com/exocore/x/operator/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" ) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 70d7b3465..ac938d377 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -2,8 +2,8 @@ package types import ( sdkmath "cosmossdk.io/math" + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" sdk "github.com/cosmos/cosmos-sdk/types" - delegationtype "github.com/exocore/x/delegation/types" ) type ExpectDelegationInterface interface { From 71683312ce7be2d592e9c8f4e305a8f4412cc5e9 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Sat, 24 Feb 2024 15:54:58 +0800 Subject: [PATCH 26/44] copy the code from operator_consent to integrate with the dogfood module. --- app/app.go | 2 +- proto/exocore/operator/v1/query.proto | 17 + proto/exocore/operator/v1/tx.proto | 39 + .../restaking_assets_manage/v1/snapshot.proto | 26 + .../restaking_assets_manage/v1/tx.proto | 14 + x/delegation/keeper/abci.go | 28 +- x/delegation/keeper/cross_chain_tx_process.go | 15 +- x/delegation/keeper/delegation_state.go | 14 +- x/delegation/keeper/grpc_query.go | 6 +- x/delegation/keeper/keeper.go | 23 +- x/delegation/keeper/msg_server.go | 4 +- x/delegation/keeper/un_delegation_state.go | 53 +- x/delegation/module.go | 2 +- x/delegation/types/expected_keepers.go | 14 + x/delegation/types/hooks.go | 33 + x/delegation/types/keys.go | 8 + x/delegation/types/query.pb.go | 76 +- x/delegation/types/tx.pb.go | 112 +- x/deposit/types/deposit.pb.go | 12 +- x/deposit/types/query.pb.go | 39 +- x/deposit/types/tx.pb.go | 13 +- x/native_token/types/tx.pb.go | 69 +- x/operator/keeper/abci.go | 46 +- x/operator/keeper/dogfood.go | 427 ++++++++ x/operator/keeper/grpc_query.go | 25 + x/operator/keeper/keeper.go | 6 + x/operator/keeper/msg_server.go | 55 + x/operator/types/app_chain_utils.go | 40 + x/operator/types/codec.go | 4 +- x/operator/types/errors.go | 10 + x/operator/types/expected_for_dogfood.go | 40 + x/operator/types/hooks_for_dogfood.go | 45 + x/operator/types/keys.go | 73 ++ x/operator/types/msg.go | 28 + x/operator/types/query.pb.go | 486 ++++++++- x/operator/types/query.pb.gw.go | 123 +++ x/operator/types/tx.pb.go | 955 ++++++++++++++++-- x/restaking_assets_manage/keeper/app_chain.go | 58 ++ x/restaking_assets_manage/keeper/snapshot.go | 110 ++ x/restaking_assets_manage/types/errors.go | 2 +- x/restaking_assets_manage/types/genesis.pb.go | 12 +- x/restaking_assets_manage/types/keys.go | 32 +- x/restaking_assets_manage/types/query.pb.go | 124 +-- x/restaking_assets_manage/types/snapshot.go | 45 + .../types/snapshot.pb.go | 913 +++++++++++++++++ x/restaking_assets_manage/types/tx.pb.go | 468 +++++++-- x/reward/types/genesis.pb.go | 13 +- x/reward/types/params.pb.go | 11 +- x/reward/types/query.pb.go | 39 +- x/reward/types/tx.pb.go | 11 +- x/reward/types/types.pb.go | 40 +- x/slash/types/genesis.pb.go | 13 +- x/slash/types/params.pb.go | 11 +- x/slash/types/query.pb.go | 11 +- x/slash/types/tx.pb.go | 11 +- x/withdraw/types/query.pb.go | 43 +- x/withdraw/types/tx.pb.go | 14 +- 57 files changed, 4435 insertions(+), 528 deletions(-) create mode 100644 proto/exocore/restaking_assets_manage/v1/snapshot.proto create mode 100644 x/delegation/types/hooks.go create mode 100644 x/operator/keeper/dogfood.go create mode 100644 x/operator/types/app_chain_utils.go create mode 100644 x/operator/types/expected_for_dogfood.go create mode 100644 x/operator/types/hooks_for_dogfood.go create mode 100644 x/restaking_assets_manage/keeper/app_chain.go create mode 100644 x/restaking_assets_manage/keeper/snapshot.go create mode 100644 x/restaking_assets_manage/types/snapshot.go create mode 100644 x/restaking_assets_manage/types/snapshot.pb.go diff --git a/app/app.go b/app/app.go index 95dcf1f55..62b14b370 100644 --- a/app/app.go +++ b/app/app.go @@ -621,7 +621,7 @@ func NewExocoreApp( // set exoCore staking keepers app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec) app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper) - app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}) + app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}, delegationTypes.VirtualISlashKeeper{}) // todo: need to replace the virtual keepers with actual keepers after they have been implemented app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper) app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper) diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index 1f351ae2d..a638aafda 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; import "exocore/operator/v1/tx.proto"; +import "tendermint/crypto/keys.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; @@ -14,9 +15,25 @@ message GetOperatorInfoReq { [(cosmos_proto.scalar) = "cosmos.AddressString"]; } +message QueryOperatorConsKeyForChainIdRequest { + string addr = 1; + string chain_id = 2; +} + +message QueryOperatorConsKeyForChainIdResponse { + tendermint.crypto.PublicKey public_key = 1 [ (gogoproto.nullable) = false ]; +} + service Query { rpc GetOperatorInfo(GetOperatorInfoReq) returns(OperatorInfo){ option (google.api.http).get = "/exocore/delegation/v1/GetOperatorInfo"; } + + // add services for dogfood + rpc QueryOperatorConsKeyForChainId(QueryOperatorConsKeyForChainIdRequest) returns (QueryOperatorConsKeyForChainIdResponse) { + option (google.api.http) = { + get: "/exocore/operator_consent/v1/GetOperatorConsKey/{addr}/{chain_id}" + }; + } } diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index a55bd3f8a..ec5facdb2 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -82,11 +82,50 @@ message RegisterOperatorReq { message RegisterOperatorResponse{} +// OptInToChainIdRequest defines the OptInToChainId request. +message OptInToChainIdRequest { + option (cosmos.msg.v1.signer) = "address"; + string address = 1; + string chain_id = 2; + // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` + // there is no need to check for knowledge of the corresponding private key since this is ED25519 + // and not BLS key, where a rogue key attack can take place. however, we should still check for + // overlap with another operator's key. + string public_key = 3; +} + +// OptInToChainIdResponse defines the OptInToChainId response. +message OptInToChainIdResponse { +} + +// InitiateOptOutFromChainIdRequest defines the InitiateOptOutFromChainId request. +message InitiateOptOutFromChainIdRequest { + option (cosmos.msg.v1.signer) = "address"; + string address = 1; + string chain_id = 2; +} + +// InitiateOptOutFromChainIdResponse defines the InitiateOptOutFromChainId response. +message InitiateOptOutFromChainIdResponse { +} + // Msg defines the delegation Msg service. service Msg { option (cosmos.msg.v1.service) = true; // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); + + // add services for dogfood + // OptInToChainId acts as opt in method for an operator to + // start validatring on a chain. The operator must sign the request with + // the key with which they registered in the system. + rpc OptInToChainId(OptInToChainIdRequest) returns (OptInToChainIdResponse) {}; + // InitiateOptOutFromChainId is a method with which an operator can initiate + // the opt out process from a chain. The operator must sign the request with + // the key with which they registered in the system. The opt-out process takes + // as long as the chain's unbonding period to complete, plus some loose change + // for message relaying across chains. + rpc InitiateOptOutFromChainId(InitiateOptOutFromChainIdRequest) returns (InitiateOptOutFromChainIdResponse) {}; } diff --git a/proto/exocore/restaking_assets_manage/v1/snapshot.proto b/proto/exocore/restaking_assets_manage/v1/snapshot.proto new file mode 100644 index 000000000..fecd369bc --- /dev/null +++ b/proto/exocore/restaking_assets_manage/v1/snapshot.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package exocore.restaking_assets_manage.v1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; + +// Snapshot stores the snapshot of an operator's delegations at a given height +message Snapshot { + // this is the value and the key is combination of operator address and height + map per_asset_id = 1 [ (gogoproto.nullable) = false ]; +} + +message SnapshotPerAssetId { + map per_staker = 1 [ (gogoproto.nullable) = false ]; +} + +message SnapshotPerAssetIdPerStaker { + string delegated = 1 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index 066347892..f3773fb8f 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -28,6 +28,20 @@ message ClientChainInfo { uint32 AddressLength = 8; } +// AppChainInfo is used to store information related to the subscriber app chains we validate. +// The information stored within this module consists only of the chain's identifiers. +// The validation-related information is stored in the coordinator module. +message AppChainInfo { + // the chain name, for example "ethereum" + string ChainName = 1; + // any other meta info that is at Exocore's discretion to deter,ome + string ChainMetaInfo = 2; + // the chain id which is used as the primary key + string ChainId = 3; + // the index of the chain in exocore, so far unused + uint64 ExocoreChainIndex = 4; +} + message ClientChainTokenInfo { string Name = 1; string Symbol = 2; diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 53d25cccb..2872d667c 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -1,16 +1,15 @@ package keeper import ( - abci "github.com/cometbft/cometbft/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) // EndBlock : completed Undelegation events according to the canCompleted blockHeight // This function will be triggered at the end of every block,it will query the undelegation state to get the records that need to be handled and try to complete the undelegation task. -func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - ctx.Logger().Info("the blockHeight is:", "height", ctx.BlockHeight()) +func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { records, err := k.GetWaitCompleteUndelegationRecords(ctx, uint64(ctx.BlockHeight())) if err != nil { panic(err) @@ -35,6 +34,27 @@ func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Validat continue }*/ + recordId := delegationtype.GetUndelegationRecordKey(record.LzTxNonce, record.TxHash, record.OperatorAddr) + if k.GetUndelegationHoldCount(ctx, recordId) > 0 { + // store it again with the next block and move on + record.CompleteBlockNumber = uint64(ctx.BlockHeight()) + 1 + // we need to store two things here: one is the updated record in itself + recordKey, err := k.SetSingleUndelegationRecord(ctx, record) + if err != nil { + panic(err) + } + // and the other is the fact that it matures at the next block + k.StoreWaitCompleteRecord(ctx, recordKey, record) + continue + } + // operator opt out: since operators can not immediately withdraw their funds, that is, + // even operator funds are not immediately available, operator opt out does not require + // any special handling here. if an operator undelegates before they opt out, the undelegation + // will be processed normally. if they undelegate after they opt out, the undelegation will + // be released at the same time as opt out completion, provided there are no other chains that + // the operator is still active on. the same applies to delegators too. + // TODO(mike): ensure that operator is required to perform self delegation to match above. + //calculate the actual canUndelegated asset amount delegationInfo, err := k.GetSingleDelegationInfo(ctx, record.StakerId, record.AssetId, record.OperatorAddr) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 1edc408b2..7f3834b71 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -26,7 +26,7 @@ type DelegationOrUndelegationParams struct { // The event hook process has been deprecated, now we use precompile contract to trigger the calls. // solidity encode: bytes memory actionArgs = abi.encodePacked(token, operator, msg.sender, amount); // _sendInterchainMsg(Action.DEPOSIT, actionArgs); -/*func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*DelegationOrUndelegationParams, error) { +/*func (k *Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*DelegationOrUndelegationParams, error) { // check if Action is deposit var action types.CrossChainOpType var err error @@ -109,7 +109,7 @@ type DelegationOrUndelegationParams struct { }*/ // DelegateTo : It doesn't need to check the active status of the operator in middlewares when delegating assets to the operator. This is because it adds assets to the operator's amount. But it needs to check if operator has been slashed or frozen. -func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationParams) error { +func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the delegatedTo address is an operator if !k.expectedOperatorInterface.IsOperator(ctx, params.OperatorAddress) { return errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", params.OperatorAddress)) @@ -171,13 +171,17 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara if err != nil { return err } + + // update the snapshot and call the hooks registered by the other modules + k.restakingStateKeeper.UpdateAndStoreSnapshotForDelegation(ctx, params.OperatorAddress, assetId, stakerId, params.OpAmount) + k.Hooks().AfterDelegation(ctx, params.OperatorAddress) return nil } // UndelegateFrom The undelegation needs to consider whether the operator's opted-in assets can exit from the AVS. // Because only after the operator has served the AVS can the staking asset be undelegated. // So we use two steps to handle the undelegation. Fist,record the undelegation request and the corresponding exit time which needs to be obtained from the operator opt-in module. Then,we handle the record when the exit time has expired. -func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegationParams) error { +func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the UndelegatedFrom address is an operator if !k.expectedOperatorInterface.IsOperator(ctx, params.OperatorAddress) { return delegationtype.ErrOperatorNotExist @@ -250,10 +254,13 @@ func (k Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegation return err } + // update the snapshot and call the hooks registered by the other modules + k.restakingStateKeeper.UpdateAndStoreSnapshotForUndelegation(ctx, params.OperatorAddress, assetId, stakerId, params.OpAmount) + k.Hooks().AfterUndelegationStarted(ctx, params.OperatorAddress, delegationtype.GetUndelegationRecordKey(r.LzTxNonce, r.TxHash, r.OperatorAddr)) return nil } -/*func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { +/*func (k *Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { needLogs, err := k.depositKeeper.FilterCrossChainEventLogs(ctx, msg, receipt) if err != nil { return err diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 978186e65..49be0c0a9 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -14,7 +14,7 @@ import ( // UpdateStakerDelegationTotalAmount The function is used to update the delegation total amount of the specified staker and asset. // The input `opAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is delegation or undelegation related to the specified staker and asset. -func (k Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string, opAmount sdkmath.Int) error { +func (k *Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string, opAmount sdkmath.Int) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -38,7 +38,7 @@ func (k Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId stri } // GetStakerDelegationTotalAmount query the total delegation amount of the specified staker and asset. -func (k Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string) (opAmount sdkmath.Int, err error) { +func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string) (opAmount sdkmath.Int, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) var ret delegationtype.ValueField prefixKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId) @@ -54,7 +54,7 @@ func (k Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, // UpdateDelegationState The function is used to update the staker's asset amount that is delegated to a specified operator. // Compared to `UpdateStakerDelegationTotalAmount`,they use the same kv store, but in this function the store key needs to add the operator address as a suffix. -func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) { +func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) //todo: think about the difference between init and update in future @@ -105,7 +105,7 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId } // GetSingleDelegationInfo query the staker's asset amount that has been delegated to the specified operator. -func (k Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, operatorAddr string) (*delegationtype.DelegationAmounts, error) { +func (k *Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, operatorAddr string) (*delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) singleStateKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId, operatorAddr) isExit := store.Has(singleStateKey) @@ -120,7 +120,7 @@ func (k Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, oper } // GetDelegationInfo query the staker's asset info that has been delegated. -func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*delegationtype.QueryDelegationInfoResponse, error) { +func (k *Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*delegationtype.QueryDelegationInfoResponse, error) { var ret delegationtype.QueryDelegationInfoResponse totalAmount, err := k.GetStakerDelegationTotalAmount(ctx, stakerId, assetId) if err != nil { @@ -147,7 +147,7 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*d } // DelegationStateByOperatorAssets get the specified assets state delegated to the specified operator -func (k Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { +func (k *Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() @@ -179,7 +179,7 @@ func (k Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr st return ret, nil } -func (k Keeper) IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { +func (k *Keeper) IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() diff --git a/x/delegation/keeper/grpc_query.go b/x/delegation/keeper/grpc_query.go index 2a2f7f56a..31c76ae8f 100644 --- a/x/delegation/keeper/grpc_query.go +++ b/x/delegation/keeper/grpc_query.go @@ -7,14 +7,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var _ delegationtype.QueryServer = Keeper{} +var _ delegationtype.QueryServer = &Keeper{} -func (k Keeper) QuerySingleDelegationInfo(ctx context.Context, req *delegationtype.SingleDelegationInfoReq) (*delegationtype.DelegationAmounts, error) { +func (k *Keeper) QuerySingleDelegationInfo(ctx context.Context, req *delegationtype.SingleDelegationInfoReq) (*delegationtype.DelegationAmounts, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetSingleDelegationInfo(c, req.StakerId, req.AssetId, req.OperatorAddr) } -func (k Keeper) QueryDelegationInfo(ctx context.Context, info *delegationtype.DelegationInfoReq) (*delegationtype.QueryDelegationInfoResponse, error) { +func (k *Keeper) QueryDelegationInfo(ctx context.Context, info *delegationtype.DelegationInfoReq) (*delegationtype.QueryDelegationInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetDelegationInfo(c, info.StakerId, info.AssetId) } diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index e987da2ec..1b657617a 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -23,6 +23,7 @@ type Keeper struct { depositKeeper depositkeeper.Keeper slashKeeper delegationtype.ISlashKeeper expectedOperatorInterface delegationtype.ExpectedOperatorInterface + hooks delegationtype.DelegationHooks } func NewKeeper( @@ -45,10 +46,30 @@ func NewKeeper( // GetExoCoreLzAppAddress Get exoCoreLzAppAddr from deposit keeper,it will be used when check the caller of precompile contract. // This function needs to be moved to `restaking_assets_manage` module,which will facilitate its use for the other modules -func (k Keeper) GetExoCoreLzAppAddress(ctx sdk.Context) (common.Address, error) { +func (k *Keeper) GetExoCoreLzAppAddress(ctx sdk.Context) (common.Address, error) { return k.depositKeeper.GetExoCoreLzAppAddress(ctx) } +// SetHooks stores the given hooks implementations. +// Note that the Keeper is changed into a pointer to prevent an ineffective assignment. +func (k *Keeper) SetHooks(hooks delegationtype.DelegationHooks) { + if hooks == nil { + panic("cannot set nil hooks") + } + if k.hooks != nil { + panic("cannot set hooks twice") + } + k.hooks = hooks +} + +func (k *Keeper) Hooks() delegationtype.DelegationHooks { + if k.hooks == nil { + // return a no-op implementation if no hooks are set to prevent calling nil functions + return delegationtype.MultiDelegationHooks{} + } + return k.hooks +} + // IDelegation interface will be implemented by deposit keeper type IDelegation interface { // PostTxProcessing automatically call PostTxProcessing to update delegation state after receiving delegation event tx from layerZero protocol diff --git a/x/delegation/keeper/msg_server.go b/x/delegation/keeper/msg_server.go index 9ec0be3fe..e625c8ed6 100644 --- a/x/delegation/keeper/msg_server.go +++ b/x/delegation/keeper/msg_server.go @@ -10,10 +10,10 @@ import ( var _ types.MsgServer = &Keeper{} // DelegateAssetToOperator todo: Delegation and Undelegation from exoCore chain directly will be implemented in future.At the moment,they are executed from client chain -func (k Keeper) DelegateAssetToOperator(ctx context.Context, delegation *types.MsgDelegation) (*types.DelegationResponse, error) { +func (k *Keeper) DelegateAssetToOperator(ctx context.Context, delegation *types.MsgDelegation) (*types.DelegationResponse, error) { return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:DelegateAssetToOperator") } -func (k Keeper) UndelegateAssetFromOperator(ctx context.Context, delegation *types.MsgUndelegation) (*types.UndelegationResponse, error) { +func (k *Keeper) UndelegateAssetFromOperator(ctx context.Context, delegation *types.MsgUndelegation) (*types.UndelegationResponse, error) { return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:UndelegateAssetFromOperator") } diff --git a/x/delegation/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index 279cbd496..6aea7bfc6 100644 --- a/x/delegation/keeper/un_delegation_state.go +++ b/x/delegation/keeper/un_delegation_state.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "math" "strings" errorsmod "cosmossdk.io/errors" @@ -22,7 +23,7 @@ const ( // SetUndelegationRecords This 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 `KeyPrefixWaitCompleteUndelegations` -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) waitCompleteStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixWaitCompleteUndelegations) @@ -43,7 +44,7 @@ func (k Keeper) SetUndelegationRecords(ctx sdk.Context, records []*types.Undeleg return nil } -func (k Keeper) SetSingleUndelegationRecord(ctx sdk.Context, record *types.UndelegationRecord) (recordKey []byte, err error) { +func (k *Keeper) SetSingleUndelegationRecord(ctx sdk.Context, record *types.UndelegationRecord) (recordKey []byte, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixUndelegationInfo) bz := k.cdc.MustMarshal(record) key := types.GetUndelegationRecordKey(record.LzTxNonce, record.TxHash, record.OperatorAddr) @@ -51,7 +52,15 @@ func (k Keeper) SetSingleUndelegationRecord(ctx sdk.Context, record *types.Undel return key, nil } -func (k Keeper) GetUndelegationRecords(ctx sdk.Context, singleRecordKeys []string, getType GetUndelegationRecordType) (record []*types.UndelegationRecord, err error) { +// StoreWaitCompleteRecord add it to handle the delay of completing undelegation caused by onHoldCount +func (k Keeper) StoreWaitCompleteRecord(ctx sdk.Context, singleRecKey []byte, record *types.UndelegationRecord) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixWaitCompleteUndelegations) + waitCompleteKey := types.GetWaitCompleteRecordKey(record.CompleteBlockNumber, record.LzTxNonce) + store.Set(waitCompleteKey, singleRecKey) + return nil +} + +func (k *Keeper) GetUndelegationRecords(ctx sdk.Context, singleRecordKeys []string, getType GetUndelegationRecordType) (record []*types.UndelegationRecord, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixUndelegationInfo) ret := make([]*types.UndelegationRecord, 0) for _, singleRecordKey := range singleRecordKeys { @@ -82,14 +91,14 @@ func (k Keeper) GetUndelegationRecords(ctx sdk.Context, singleRecordKeys []strin return ret, nil } -func (k Keeper) SetStakerUndelegationInfo(ctx sdk.Context, stakerId, assetId string, recordKey []byte, lzNonce uint64) error { +func (k *Keeper) SetStakerUndelegationInfo(ctx sdk.Context, stakerId, assetId string, recordKey []byte, lzNonce uint64) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixStakerUndelegationInfo) key := types.GetStakerUndelegationRecordKey(stakerId, assetId, lzNonce) store.Set(key, recordKey) return nil } -func (k Keeper) GetStakerUndelegationRecKeys(ctx sdk.Context, stakerId, assetId string) (recordKeyList []string, err error) { +func (k *Keeper) GetStakerUndelegationRecKeys(ctx sdk.Context, stakerId, assetId string) (recordKeyList []string, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixStakerUndelegationInfo) iterator := sdk.KVStorePrefixIterator(store, []byte(strings.Join([]string{stakerId, assetId}, "/"))) defer iterator.Close() @@ -101,7 +110,7 @@ func (k Keeper) GetStakerUndelegationRecKeys(ctx sdk.Context, stakerId, assetId return ret, nil } -func (k Keeper) GetStakerUndelegationRecords(ctx sdk.Context, stakerId, assetId string, getType GetUndelegationRecordType) (records []*types.UndelegationRecord, err error) { +func (k *Keeper) GetStakerUndelegationRecords(ctx sdk.Context, stakerId, assetId string, getType GetUndelegationRecordType) (records []*types.UndelegationRecord, err error) { recordKeys, err := k.GetStakerUndelegationRecKeys(ctx, stakerId, assetId) if err != nil { return nil, err @@ -110,14 +119,14 @@ func (k Keeper) GetStakerUndelegationRecords(ctx sdk.Context, stakerId, assetId return k.GetUndelegationRecords(ctx, recordKeys, getType) } -func (k Keeper) SetWaitCompleteUndelegationInfo(ctx sdk.Context, height, lzNonce uint64, recordKey string) error { +func (k *Keeper) SetWaitCompleteUndelegationInfo(ctx sdk.Context, height, lzNonce uint64, recordKey string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixWaitCompleteUndelegations) key := types.GetWaitCompleteRecordKey(height, lzNonce) store.Set(key, []byte(recordKey)) return nil } -func (k Keeper) GetWaitCompleteUndelegationRecKeys(ctx sdk.Context, height uint64) (recordKeyList []string, err error) { +func (k *Keeper) GetWaitCompleteUndelegationRecKeys(ctx sdk.Context, height uint64) (recordKeyList []string, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixWaitCompleteUndelegations) iterator := sdk.KVStorePrefixIterator(store, []byte(hexutil.EncodeUint64(height))) defer iterator.Close() @@ -129,7 +138,7 @@ func (k Keeper) GetWaitCompleteUndelegationRecKeys(ctx sdk.Context, height uint6 return ret, nil } -func (k Keeper) GetWaitCompleteUndelegationRecords(ctx sdk.Context, height uint64) (records []*types.UndelegationRecord, err error) { +func (k *Keeper) GetWaitCompleteUndelegationRecords(ctx sdk.Context, height uint64) (records []*types.UndelegationRecord, err error) { recordKeys, err := k.GetWaitCompleteUndelegationRecKeys(ctx, height) if err != nil { return nil, err @@ -140,3 +149,29 @@ func (k Keeper) GetWaitCompleteUndelegationRecords(ctx sdk.Context, height uint6 // The states of records stored by WaitCompleteUndelegations kvStore should always be IsPending,so using AllRecords as getType here is ok. return k.GetUndelegationRecords(ctx, recordKeys, AllRecords) } + +func (k *Keeper) IncrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) { + prev := k.GetUndelegationHoldCount(ctx, recordKey) + if prev == math.MaxUint64 { + panic("cannot increment undelegation hold count above max uint64") + } + now := prev + 1 + store := ctx.KVStore(k.storeKey) + store.Set(types.GetUndelegationOnHoldKey(recordKey), sdk.Uint64ToBigEndian(now)) +} + +func (k *Keeper) GetUndelegationHoldCount(ctx sdk.Context, recordKey []byte) uint64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetUndelegationOnHoldKey(recordKey)) + return sdk.BigEndianToUint64(bz) +} + +func (k *Keeper) DecrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) { + prev := k.GetUndelegationHoldCount(ctx, recordKey) + if prev == 0 { + panic("cannot decrement undelegation hold count below zero") + } + now := prev - 1 + store := ctx.KVStore(k.storeKey) + store.Set(types.GetUndelegationOnHoldKey(recordKey), sdk.Uint64ToBigEndian(now)) +} diff --git a/x/delegation/module.go b/x/delegation/module.go index 27d39497c..bf178777d 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -75,7 +75,7 @@ func (am AppModule) IsAppModule() {} // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { delegationtype.RegisterMsgServer(cfg.MsgServer(), &am.keeper) - delegationtype.RegisterQueryServer(cfg.QueryServer(), am.keeper) + delegationtype.RegisterQueryServer(cfg.QueryServer(), &am.keeper) } func (am AppModule) GenerateGenesisState(input *module.SimulationState) { diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 914a4705b..4918e2450 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -23,6 +23,20 @@ func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAdd return sdkmath.LegacyNewDec(0) } +// DelegationHooks add for dogfood +type DelegationHooks interface { + //AfterDelegation we don't want the ability to cancel delegation or undelegation so no return type for + // either + // for delegation, we only care about the address of the operator to cache the event + AfterDelegation(ctx sdk.Context, operator sdk.AccAddress) + //AfterUndelegationStarted for undelegation, we use the address of the operator to figure out the list of impacted + // chains for that operator. and we need the identifier to hold it until confirmed by subscriber + AfterUndelegationStarted(ctx sdk.Context, addr sdk.AccAddress, recordKey []byte) + //AfterUndelegationCompleted whenever an undelegation completes, we should update the vote power of the associated operator + // on all of the chain ids that are impacted + AfterUndelegationCompleted(ctx sdk.Context, addr sdk.AccAddress) +} + type ExpectedOperatorInterface interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 diff --git a/x/delegation/types/hooks.go b/x/delegation/types/hooks.go new file mode 100644 index 000000000..2fd215a96 --- /dev/null +++ b/x/delegation/types/hooks.go @@ -0,0 +1,33 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +var _ DelegationHooks = &MultiDelegationHooks{} + +type MultiDelegationHooks []DelegationHooks + +func NewMultiDelegationHooks(hooks ...DelegationHooks) MultiDelegationHooks { + return hooks +} + +func (hooks MultiDelegationHooks) AfterDelegation(ctx sdk.Context, operator sdk.AccAddress) { + for _, hook := range hooks { + hook.AfterDelegation(ctx, operator) + } +} + +func (hooks MultiDelegationHooks) AfterUndelegationStarted( + ctx sdk.Context, + addr sdk.AccAddress, + recordKey []byte, +) { + for _, hook := range hooks { + hook.AfterUndelegationStarted(ctx, addr, recordKey) + } +} + +func (hooks MultiDelegationHooks) AfterUndelegationCompleted(ctx sdk.Context, addr sdk.AccAddress) { + for _, hook := range hooks { + hook.AfterUndelegationCompleted(ctx, addr) + } +} diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index 598bd5353..31457445a 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -37,6 +37,9 @@ const ( prefixStakerUndelegationInfo prefixWaitCompleteUndelegations + + // add for dogfood + prefixUndelegationOnHold ) var ( @@ -85,3 +88,8 @@ func GetStakerUndelegationRecordKey(stakerId, assetId string, lzNonce uint64) [] func GetWaitCompleteRecordKey(height, lzNonce uint64) []byte { return []byte(strings.Join([]string{hexutil.EncodeUint64(height), hexutil.EncodeUint64(lzNonce)}, "/")) } + +// GetUndelegationOnHoldKey add for dogfood +func GetUndelegationOnHoldKey(recordKey []byte) []byte { + return append([]byte{prefixUndelegationOnHold}, recordKey...) +} diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index c6ed621de..e57acfd11 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -239,45 +239,45 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 596 bytes of a gzipped FileDescriptorProto + // 605 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x4f, - 0x18, 0xce, 0x6e, 0xe8, 0xef, 0xa7, 0x53, 0x41, 0x1d, 0x53, 0xdd, 0x6e, 0x75, 0x5b, 0x17, 0x94, - 0x50, 0xe8, 0xae, 0x8d, 0x08, 0x22, 0x55, 0x49, 0x55, 0xca, 0x1e, 0xdd, 0x28, 0x82, 0x17, 0x99, - 0x64, 0xa7, 0xdb, 0x25, 0x9b, 0x99, 0xcd, 0xcc, 0x24, 0x24, 0xd7, 0x9c, 0xbc, 0x08, 0x82, 0xdf, - 0xc2, 0x93, 0x87, 0x7c, 0x88, 0x1e, 0x4b, 0xbd, 0x88, 0x87, 0x22, 0x89, 0xe0, 0xc1, 0x8b, 0x1f, - 0x41, 0xb2, 0x3b, 0x4d, 0x93, 0xb8, 0x5b, 0x2d, 0xe4, 0x94, 0x9d, 0xf7, 0x79, 0xf2, 0xbc, 0xcf, - 0xbc, 0x7f, 0x06, 0xdc, 0xc4, 0x1d, 0x5a, 0xa3, 0x0c, 0xdb, 0x1e, 0x0e, 0xb1, 0x8f, 0x44, 0x40, - 0x89, 0xdd, 0xde, 0xb4, 0x9b, 0x2d, 0xcc, 0xba, 0x56, 0xc4, 0xa8, 0xa0, 0x70, 0x49, 0x52, 0xac, - 0x13, 0x8a, 0xd5, 0xde, 0xd4, 0x0b, 0x3e, 0xf5, 0x69, 0xcc, 0xb0, 0x47, 0x5f, 0x09, 0x59, 0xbf, - 0xee, 0x53, 0xea, 0x87, 0xd8, 0x46, 0x51, 0x60, 0x23, 0x42, 0xa8, 0x88, 0xf9, 0x5c, 0xa2, 0x2b, - 0x35, 0xca, 0x1b, 0x94, 0x27, 0xf2, 0x33, 0x79, 0xf4, 0xe5, 0x04, 0x7c, 0x93, 0x68, 0x26, 0x07, - 0x09, 0x19, 0xe9, 0x2e, 0x45, 0x27, 0xc1, 0x4d, 0x07, 0x5c, 0x7e, 0x3a, 0x46, 0x1c, 0xb2, 0x4b, - 0x5d, 0xdc, 0x84, 0x3a, 0x38, 0xc7, 0x05, 0xaa, 0x63, 0xe6, 0x78, 0x9a, 0xb2, 0xa6, 0x14, 0xcf, - 0xbb, 0xe3, 0x33, 0xd4, 0xc0, 0xff, 0x88, 0x73, 0x2c, 0x1c, 0x4f, 0x53, 0x63, 0xe8, 0xf8, 0x68, - 0xf6, 0xf2, 0x93, 0x5a, 0xe5, 0x06, 0x6d, 0x11, 0xc1, 0x21, 0x03, 0x4b, 0x4f, 0x10, 0x79, 0x49, - 0xbc, 0x19, 0x24, 0x11, 0xde, 0xde, 0xda, 0x3f, 0x5a, 0xcd, 0x7d, 0x3d, 0x5a, 0xbd, 0xed, 0x07, - 0x62, 0xaf, 0x55, 0xb5, 0x6a, 0xb4, 0x21, 0x2f, 0x20, 0x7f, 0x36, 0xb8, 0x57, 0xb7, 0x45, 0x37, - 0xc2, 0xdc, 0x72, 0x88, 0x38, 0xec, 0x6f, 0x00, 0x79, 0x3f, 0x87, 0x08, 0x37, 0x5d, 0x1a, 0x0a, - 0x70, 0xf5, 0x15, 0x0a, 0x44, 0x4a, 0x52, 0x75, 0x0e, 0x49, 0x33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xda, + 0x51, 0x6f, 0xad, 0x20, 0x8b, 0x3a, 0x0c, 0x63, 0xce, 0xcb, 0x82, 0x05, 0xc4, 0x77, 0x27, 0xb2, + 0xc7, 0xf7, 0x30, 0x3f, 0xb1, 0x87, 0xa5, 0x1f, 0x2a, 0x98, 0x8b, 0x6b, 0x08, 0x3f, 0x28, 0xe0, + 0x4a, 0x4a, 0x35, 0xe1, 0xdf, 0xaf, 0x29, 0xfd, 0xeb, 0xa5, 0xb3, 0xf7, 0xc8, 0xbc, 0xf7, 0xe6, + 0xfb, 0xc7, 0x55, 0xa5, 0xfb, 0xe9, 0xdb, 0x7b, 0x75, 0x15, 0x16, 0xed, 0xf4, 0x07, 0x68, 0x07, + 0x8b, 0x29, 0x53, 0x3d, 0x05, 0x2c, 0xc6, 0xb4, 0x69, 0xb5, 0x84, 0x56, 0x86, 0x91, 0x8c, 0xc2, + 0xeb, 0xff, 0xdc, 0x49, 0xf3, 0xe1, 0x89, 0xdd, 0x12, 0xbc, 0x9d, 0x61, 0x37, 0xd3, 0xd8, 0xd6, + 0xee, 0x41, 0xdf, 0x50, 0x0e, 0xfb, 0x86, 0xf2, 0xb5, 0x6f, 0x28, 0xef, 0x06, 0x46, 0xee, 0x70, + 0x60, 0xe4, 0x3e, 0x0f, 0x8c, 0xdc, 0xcb, 0xbb, 0x63, 0x4b, 0xb4, 0x9d, 0xb0, 0xee, 0x62, 0xf1, + 0x9a, 0xb2, 0xda, 0x48, 0xa4, 0x3d, 0x2e, 0x13, 0xaf, 0x55, 0xe5, 0xbf, 0xf8, 0x5d, 0xbe, 0xf3, + 0x2b, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xe7, 0xd6, 0x05, 0x5f, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/delegation/types/tx.pb.go b/x/delegation/types/tx.pb.go index 726cd1eca..3d6e60f77 100644 --- a/x/delegation/types/tx.pb.go +++ b/x/delegation/types/tx.pb.go @@ -544,62 +544,62 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/tx.proto", fileDescriptor_16596a15a828f109) } var fileDescriptor_16596a15a828f109 = []byte{ - // 871 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xc6, 0x49, 0x9a, 0x3c, 0x17, 0x01, 0x83, 0x93, 0x6c, 0x0d, 0x72, 0xcc, 0x8a, 0x56, - 0x21, 0x10, 0x9b, 0x06, 0x21, 0x50, 0x54, 0x09, 0x39, 0xa4, 0x05, 0x8b, 0xa6, 0x8d, 0xb6, 0x81, - 0x03, 0x42, 0x42, 0xe3, 0xdd, 0xe9, 0x66, 0xf1, 0xee, 0xcc, 0x6a, 0x66, 0x1c, 0x1c, 0x4e, 0x88, - 0x13, 0x70, 0xe2, 0x23, 0xf4, 0x03, 0x70, 0xc8, 0xa1, 0x1f, 0xa2, 0xc7, 0xaa, 0x27, 0xc4, 0x21, - 0x42, 0xc9, 0x21, 0x1c, 0xf8, 0x02, 0x70, 0x42, 0x3b, 0x33, 0xfb, 0x27, 0xc4, 0x26, 0x42, 0x8a, - 0xd4, 0x8b, 0x3d, 0xef, 0xcd, 0x9b, 0xdf, 0xef, 0xbd, 0xf9, 0xbd, 0x7d, 0x1a, 0x68, 0x92, 0x11, - 0xf3, 0x18, 0x27, 0x1d, 0x9f, 0x44, 0x24, 0xc0, 0x32, 0x64, 0xb4, 0xb3, 0x7f, 0xb3, 0x23, 0x47, - 0xed, 0x84, 0x33, 0xc9, 0xd0, 0x82, 0xd9, 0x6f, 0x17, 0xfb, 0xed, 0xfd, 0x9b, 0x8d, 0x25, 0x8f, - 0x89, 0x98, 0x89, 0x4e, 0x2c, 0x82, 0x34, 0x3c, 0x16, 0x81, 0x8e, 0x6f, 0x5c, 0xd3, 0x1b, 0x5f, - 0x29, 0xab, 0xa3, 0x0d, 0xb3,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, 0x99, 0xca, 0x3c, 0xd0, 0x4b, 0xdb, 0x6a, 0x55, 0x53, - 0x99, 0x8d, 0xe9, 0xd4, 0x01, 0x6d, 0x95, 0x0e, 0x89, 0x84, 0x51, 0x41, 0x9c, 0x2f, 0xe1, 0xc5, - 0x6d, 0x11, 0x94, 0xf1, 0x2e, 0xb1, 0xf3, 0x9d, 0x45, 0xa8, 0x9f, 0x4d, 0x55, 0xb3, 0xae, 0xff, - 0x69, 0x41, 0x75, 0x5b, 0x04, 0xe8, 0x6b, 0x58, 0xca, 0xe6, 0xbd, 0x1a, 0xf4, 0xbb, 0x2c, 0xeb, - 0x2d, 0xf4, 0xc6, 0x04, 0xce, 0x33, 0x5f, 0x69, 0xe3, 0xcd, 0x0b, 0x33, 0xcb, 0x38, 0x11, 0x87, - 0x57, 0xf3, 0x5c, 0x34, 0xdb, 0x1d, 0xce, 0xe2, 0x9c, 0xef, 0xc6, 0x64, 0xbe, 0x72, 0x09, 0x8d, - 0xb7, 0x26, 0xc4, 0x8d, 0xab, 0xb3, 0x31, 0xf3, 0xdd, 0xe9, 0xe1, 0xaa, 0xb5, 0xf9, 0xe1, 0x93, - 0xe3, 0xa6, 0xf5, 0xf4, 0xb8, 0x69, 0xfd, 0x7e, 0xdc, 0xb4, 0x7e, 0x3e, 0x69, 0x56, 0x9e, 0x9e, - 0x34, 0x2b, 0xbf, 0x9e, 0x34, 0x2b, 0x5f, 0x5c, 0x2f, 0x35, 0x46, 0xf6, 0x9a, 0x19, 0x95, 0xdf, - 0x33, 0xaa, 0x37, 0xfa, 0xb3, 0xea, 0x71, 0xf1, 0xee, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x48, - 0xfe, 0xbb, 0x0f, 0xf2, 0x08, 0x00, 0x00, + // 879 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0x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0xd5, 0xac, 0xeb, 0x7f, 0x5a, + 0x50, 0xde, 0x11, 0x01, 0xfa, 0x06, 0x96, 0x86, 0xf3, 0x5e, 0x0d, 0xfa, 0x7d, 0x36, 0xec, 0x2d, + 0xf4, 0xc6, 0x18, 0xce, 0x0b, 0x5f, 0x69, 0xed, 0xad, 0x2b, 0x33, 0x1b, 0x72, 0x22, 0x0e, 0xaf, + 0x66, 0xb9, 0x68, 0xb6, 0x3b, 0x9c, 0xc5, 0x19, 0xdf, 0xcd, 0xf1, 0x7c, 0xc5, 0x12, 0x6a, 0x6f, + 0x8f, 0x89, 0x1b, 0x55, 0x67, 0x6d, 0xe6, 0xbb, 0xf3, 0xe3, 0x55, 0x6b, 0x73, 0xf7, 0xc9, 0x69, + 0xdd, 0x7a, 0x7a, 0x5a, 0xb7, 0x7e, 0x3f, 0xad, 0x5b, 0x3f, 0x9f, 0xd5, 0x4b, 0x4f, 0xcf, 0xea, + 0xa5, 0x5f, 0xcf, 0xea, 0xa5, 0x2f, 0xdf, 0x2f, 0x34, 0xc6, 0xb6, 0xc6, 0xdd, 0x25, 0xf2, 0x21, + 0xe3, 0xbd, 0xd6, 0xf0, 0x71, 0x33, 0x28, 0x3e, 0x6f, 0x54, 0xab, 0x74, 0x67, 0xd5, 0x5b, 0xe3, + 0xbd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x3a, 0xbb, 0x10, 0x01, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/deposit/types/deposit.pb.go b/x/deposit/types/deposit.pb.go index 7550a72a6..584a21388 100644 --- a/x/deposit/types/deposit.pb.go +++ b/x/deposit/types/deposit.pb.go @@ -83,7 +83,7 @@ func init() { func init() { proto.RegisterFile("exocore/deposit/v1/deposit.proto", fileDescriptor_bb743e1548b62476) } var fileDescriptor_bb743e1548b62476 = []byte{ - // 194 bytes of a gzipped FileDescriptorProto + // 205 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x49, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, 0xd1, 0x2f, 0x33, 0x84, 0x31, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0xa0, 0x2a, 0xf4, 0x60, 0xc2, 0x65, 0x86, 0x52, @@ -91,12 +91,12 @@ var fileDescriptor_bb743e1548b62476 = []byte{ 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0xc8, 0x80, 0x4b, 0x38, 0xb5, 0x22, 0xdf, 0x39, 0xbf, 0x28, 0xd5, 0xa7, 0xca, 0xb1, 0xa0, 0xc0, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0x9b, 0x94, 0x90, 0x19, 0x97, 0x18, 0xb2, 0xb0, 0x6b, 0x59, 0x6a, 0x5e, - 0x49, 0x48, 0x7e, 0x41, 0x66, 0xb2, 0x04, 0x13, 0x58, 0x13, 0x0e, 0x59, 0x27, 0x9b, 0x13, 0x8f, + 0x49, 0x48, 0x7e, 0x41, 0x66, 0xb2, 0x04, 0x13, 0x58, 0x13, 0x0e, 0x59, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, - 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, - 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x79, 0xb2, 0x02, 0xee, 0xcd, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, - 0x36, 0xb0, 0xc3, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x92, 0x1f, 0x59, 0xfc, 0x06, 0x01, - 0x00, 0x00, + 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, + 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0x85, 0x78, 0xc1, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x1f, + 0xe6, 0xe7, 0x0a, 0xb8, 0xaf, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xfe, 0x30, 0x06, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x87, 0x19, 0xe5, 0x20, 0x15, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/deposit/types/query.pb.go b/x/deposit/types/query.pb.go index e61cc8614..5647536a0 100644 --- a/x/deposit/types/query.pb.go +++ b/x/deposit/types/query.pb.go @@ -122,25 +122,26 @@ func init() { func init() { proto.RegisterFile("exocore/deposit/v1/query.proto", fileDescriptor_715f16e6b5833923) } var fileDescriptor_715f16e6b5833923 = []byte{ - // 285 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x31, 0x4f, 0xc3, 0x30, - 0x14, 0x84, 0x63, 0x24, 0x32, 0x98, 0xcd, 0x74, 0x00, 0x53, 0x59, 0x55, 0x06, 0x60, 0xb2, 0xd5, - 0xb0, 0x32, 0xb1, 0xb1, 0x01, 0x23, 0x0b, 0x4a, 0x83, 0x65, 0x22, 0x91, 0x3c, 0x37, 0x76, 0xaa, - 0x76, 0x60, 0x61, 0x60, 0x46, 0xe2, 0x4f, 0x31, 0x56, 0x62, 0x61, 0x44, 0x09, 0x3f, 0x04, 0xd5, - 0x36, 0x95, 0xa0, 0x91, 0xba, 0xd9, 0xef, 0x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68, 0x26, - 0x3c, 0x87, 0x72, 0xed, 0x9f, 0xaf, 0x13, 0xec, 0x42, 0x4b, 0x33, 0x89, 0xdd, 0x77, 0x9d, 0xfd, - 0x04, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x89, 0x79, 0xdf, 0xf2, 0x01, 0x00, 0x00, + // 297 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x31, 0x4b, 0xfc, 0x30, + 0x18, 0xc6, 0x9b, 0x3f, 0xfc, 0x3b, 0xc4, 0x2d, 0xde, 0xa0, 0xf1, 0x08, 0x47, 0x07, 0x75, 0x4a, + 0x68, 0xfd, 0x06, 0x82, 0x83, 0x08, 0xa2, 0x8e, 0x2e, 0xd2, 0xab, 0xa1, 0x16, 0x6d, 0xdf, 0x5c, + 0x93, 0x9e, 0x77, 0x83, 0x8b, 0x83, 0xb3, 0xe0, 0x97, 0x72, 0x3c, 0x70, 0x71, 0x94, 0xd6, 0x0f, + 0x22, 0x97, 0xc4, 0x03, 0xbd, 0x82, 0x5b, 0xf2, 0xfe, 0x9e, 0xe7, 0xc9, 0xf3, 0x06, 0x33, 0x39, + 0x83, 0x0c, 0x6a, 0x29, 0xae, 0xa5, 0x02, 0x5d, 0x18, 0x31, 0x8d, 0xc5, 0xa4, 0x91, 0xf5, 0x9c, + 0xab, 0x1a, 0x0c, 0x10, 0xe2, 0x39, 0xf7, 0x9c, 0x4f, 0x63, 0x3a, 0xc8, 0x21, 0x07, 0x8b, 0xc5, + 0xf2, 0xe4, 0x94, 0x74, 0x98, 0x03, 0xe4, 0x77, 0x52, 0xa4, 0xaa, 0x10, 0x69, 0x55, 0x81, 0x49, + 0x4d, 0x01, 0x95, 0xf6, 0x74, 0x27, 0x03, 0x5d, 0x82, 0x76, 0xd9, 0xbf, 0x1e, 0xa1, 0xdb, 0x0e, + 0x5e, 0xb9, 0x4c, 0x77, 0xf1, 0x68, 0xd4, 0xd3, 0xef, 0xbb, 0x8a, 0x55, 0x44, 0x03, 0x4c, 0xce, + 0x97, 0x59, 0x67, 0x69, 0x9d, 0x96, 0xfa, 0x42, 0x4e, 0x1a, 0xa9, 0x4d, 0x74, 0x8c, 0x37, 0x7f, + 0x4c, 0xb5, 0x82, 0x4a, 0x4b, 0x92, 0xe0, 0x50, 0xd9, 0xc9, 0x16, 0x1a, 0xa1, 0xfd, 0x8d, 0x84, + 0xf2, 0xf5, 0xfd, 0xb8, 0xf7, 0x78, 0x65, 0xf2, 0x84, 0xf0, 0x7f, 0x9b, 0x45, 0x1e, 0x70, 0xe8, + 0x18, 0xd9, 0xed, 0xf3, 0xad, 0xd7, 0xa0, 0x7b, 0x7f, 0xea, 0x5c, 0xb1, 0x28, 0x7a, 0x7c, 0xfb, + 0x7c, 0xf9, 0x37, 0x24, 0x54, 0xf4, 0x2c, 0xec, 0xb4, 0x87, 0x27, 0xaf, 0x2d, 0x43, 0x8b, 0x96, + 0xa1, 0x8f, 0x96, 0xa1, 0xe7, 0x8e, 0x05, 0x8b, 0x8e, 0x05, 0xef, 0x1d, 0x0b, 0x2e, 0xe3, 0xbc, + 0x30, 0x37, 0xcd, 0x98, 0x67, 0x50, 0x8a, 0x23, 0xe7, 0x3f, 0x95, 0xe6, 0x1e, 0xea, 0xdb, 0x55, + 0xdc, 0x6c, 0x15, 0x68, 0xe6, 0x4a, 0xea, 0x71, 0x68, 0x7f, 0xef, 0xe0, 0x2b, 0x00, 0x00, 0xff, + 0xff, 0x5f, 0x20, 0xfd, 0x7d, 0x01, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/deposit/types/tx.pb.go b/x/deposit/types/tx.pb.go index ce09c2db0..f5cb2ac2e 100644 --- a/x/deposit/types/tx.pb.go +++ b/x/deposit/types/tx.pb.go @@ -135,7 +135,7 @@ func init() { func init() { proto.RegisterFile("exocore/deposit/v1/tx.proto", fileDescriptor_d4939a0226905392) } var fileDescriptor_d4939a0226905392 = []byte{ - // 328 bytes of a gzipped FileDescriptorProto + // 339 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x49, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x4a, 0xea, 0x41, 0x25, 0xf5, 0xca, @@ -152,11 +152,12 @@ var fileDescriptor_d4939a0226905392 = []byte{ 0x16, 0xc2, 0x24, 0x25, 0x49, 0x2e, 0x71, 0x34, 0x47, 0x05, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0xe5, 0x71, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x25, 0x70, 0xf1, 0xa0, 0xb8, 0x59, 0x19, 0x9b, 0x5d, 0x68, 0x66, 0x48, 0x69, 0x13, 0xa1, 0x08, 0x66, 0x91, 0x14, 0x6b, 0xc3, 0xf3, 0x0d, - 0x5a, 0x8c, 0x4e, 0x36, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, - 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x94, - 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x0b, 0xe7, 0x0a, 0x78, 0x48, - 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x43, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, - 0xd6, 0xc3, 0xbf, 0x20, 0x17, 0x02, 0x00, 0x00, + 0x5a, 0x8c, 0x4e, 0xde, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, + 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x98, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x0a, 0x31, 0xd7, 0x2f, 0xb5, + 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0x16, 0xec, 0x15, 0xf0, 0x80, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, + 0x4e, 0x62, 0x03, 0x07, 0xba, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x32, 0xea, 0x25, 0xb9, 0x26, + 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/native_token/types/tx.pb.go b/x/native_token/types/tx.pb.go index 2843f1e49..16e996410 100644 --- a/x/native_token/types/tx.pb.go +++ b/x/native_token/types/tx.pb.go @@ -179,40 +179,41 @@ func init() { func init() { proto.RegisterFile("exocore/native_token/v1/tx.proto", fileDescriptor_769c53c072051eb9) } var fileDescriptor_769c53c072051eb9 = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x93, 0x7c, 0xd1, 0xd7, 0x5b, 0x5a, 0xc2, 0x50, 0x68, 0xc8, 0xc2, 0xb5, 0xb2, 0x08, - 0xd9, 0xd4, 0x56, 0x83, 0x84, 0x50, 0xd5, 0x4d, 0x0c, 0x05, 0xbc, 0xc0, 0x54, 0x4e, 0x9a, 0x4a, - 0x6c, 0xaa, 0x89, 0x3d, 0x18, 0xd7, 0x3f, 0x13, 0x79, 0x26, 0x21, 0x79, 0x0b, 0x1e, 0x86, 0x87, - 0xe8, 0xb2, 0x62, 0x85, 0x58, 0x54, 0x28, 0x79, 0x07, 0xb6, 0x20, 0x7b, 0x0c, 0x38, 0x21, 0x91, - 0x2a, 0x75, 0x35, 0x73, 0x7f, 0xce, 0x99, 0x7b, 0xcf, 0x9d, 0x19, 0x50, 0xc8, 0x84, 0xda, 0x34, - 0x26, 0x5a, 0x84, 0xb9, 0x37, 0x26, 0xe7, 0x9c, 0xfa, 0x24, 0xd2, 0xc6, 0x07, 0x1a, 0x9f, 0xa8, - 0xc3, 0x98, 0x72, 0x8a, 0x76, 0xb3, 0x0c, 0x35, 0x9f, 0xa1, 0x8e, 0x0f, 0xea, 0xbb, 0x36, 0x65, - 0x21, 0x65, 0x5a, 0xc8, 0xdc, 0x04, 0x10, 0x32, 0x57, 0x20, 0xea, 0x8f, 0x44, 0xe0, 0x3c, 0xb5, - 0x34, 0x61, 0x64, 0xa1, 0x1d, 0x97, 0xba, 0x54, 0xf8, 0x93, 0x9d, 0xf0, 0x36, 0x7e, 0x16, 0x61, - 0xab, 0x8f, 0x03, 0xcf, 0xc1, 0x9c, 0xc6, 0x46, 0xf4, 0x9e, 0x22, 0x13, 0x2a, 0x5d, 0x8e, 0xf9, - 0x88, 0xd5, 0x24, 0x45, 0x6a, 0x6d, 0xb7, 0x9f, 0xaa, 0x6b, 0xaa, 0x50, 0x17, 0x70, 0x7f, 0x2d, - 0x81, 0xb6, 0x32, 0x16, 0xd4, 0x84, 0xed, 0x5c, 0xa2, 0x43, 0x26, 0xb5, 0xa2, 0x22, 0xb5, 0xca, - 0xd6, 0x92, 0x17, 0x5d, 0xc0, 0xbd, 0x2e, 0xc7, 0x3e, 0x71, 0x74, 0x1c, 0xe0, 0xc8, 0x26, 0xaf, - 0x3e, 0x12, 0xaf, 0x56, 0x52, 0xa4, 0xd6, 0x86, 0x7e, 0x74, 0x79, 0xbd, 0x57, 0xf8, 0x76, 0xbd, - 0xd7, 0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 0x33, 0x57, 0xea, 0xa9, 0x2e, 0x92, 0x1c, 0x47, - 0x3c, 0x9e, 0x5a, 0x4b, 0xcc, 0x75, 0x0f, 0xee, 0xaf, 0x48, 0x43, 0x55, 0x28, 0xf9, 0x64, 0x2a, - 0x74, 0xb7, 0x92, 0x2d, 0x3a, 0x82, 0xff, 0xc6, 0x49, 0x13, 0xa9, 0x2e, 0x9b, 0xed, 0xe6, 0xcd, - 0x5e, 0x89, 0x25, 0x40, 0x87, 0xc5, 0x67, 0x92, 0xde, 0xb9, 0x9c, 0xc9, 0xd2, 0xd5, 0x4c, 0x96, - 0xbe, 0xcf, 0x64, 0xe9, 0xd3, 0x5c, 0x2e, 0x5c, 0xcd, 0xe5, 0xc2, 0xd7, 0xb9, 0x5c, 0x78, 0xf7, - 0x38, 0x27, 0xee, 0xef, 0x4f, 0x62, 0xb2, 0xf8, 0x4d, 0xa4, 0x0a, 0x0f, 0x2a, 0xe9, 0x23, 0x7e, - 0xf2, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xe1, 0xff, 0x82, 0xf4, 0x4b, 0x04, 0x00, 0x00, + // 534 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0x93, 0x12, 0xd1, 0x29, 0x2d, 0x61, 0x29, 0x34, 0xe4, 0xe0, 0x46, 0x39, 0x44, 0xb9, + 0xd4, 0x56, 0x83, 0x54, 0xa1, 0xaa, 0x97, 0x18, 0x02, 0xf8, 0x80, 0x89, 0x9c, 0x34, 0x95, 0xb8, + 0x54, 0x1b, 0x7b, 0x31, 0xae, 0x7f, 0x36, 0xf2, 0x6e, 0xd2, 0xe4, 0x2d, 0x78, 0x18, 0x1e, 0xa2, + 0xc7, 0x8a, 0x13, 0xe2, 0x50, 0xa1, 0xe4, 0x1d, 0xb8, 0x82, 0xec, 0x35, 0xe0, 0x84, 0x44, 0xaa, + 0xd4, 0xd3, 0xee, 0xfc, 0x7c, 0xdf, 0xce, 0x7c, 0xb3, 0xbb, 0x50, 0x25, 0x13, 0x6a, 0xd1, 0x88, + 0xa8, 0x21, 0xe6, 0xee, 0x98, 0x9c, 0x73, 0xea, 0x91, 0x50, 0x1d, 0x1f, 0xaa, 0x7c, 0xa2, 0x0c, + 0x23, 0xca, 0x29, 0xda, 0x4b, 0x33, 0x94, 0x6c, 0x86, 0x32, 0x3e, 0xac, 0xec, 0x59, 0x94, 0x05, + 0x94, 0xa9, 0x01, 0x73, 0x62, 0x40, 0xc0, 0x1c, 0x81, 0xa8, 0x3c, 0x13, 0x81, 0xf3, 0xc4, 0x52, + 0x85, 0x91, 0x86, 0x76, 0x1d, 0xea, 0x50, 0xe1, 0x8f, 0x77, 0xc2, 0x5b, 0xfb, 0x95, 0x87, 0xed, + 0x3e, 0xf6, 0x5d, 0x1b, 0x73, 0x1a, 0xe9, 0xe1, 0x47, 0x8a, 0x0c, 0x28, 0x76, 0x39, 0xe6, 0x23, + 0x56, 0x96, 0xaa, 0x52, 0x63, 0xa7, 0x79, 0xa4, 0xac, 0xa9, 0x42, 0x59, 0xc0, 0xfd, 0xb3, 0x04, + 0xda, 0x4c, 0x59, 0x50, 0x1d, 0x76, 0x32, 0x89, 0x36, 0x99, 0x94, 0xf3, 0x55, 0xa9, 0xb1, 0x61, + 0x2e, 0x79, 0xd1, 0x05, 0x3c, 0xea, 0x72, 0xec, 0x11, 0x5b, 0xc3, 0x3e, 0x0e, 0x2d, 0xf2, 0xe6, + 0x92, 0xb8, 0xe5, 0x42, 0x55, 0x6a, 0x6c, 0x6a, 0x27, 0x57, 0x37, 0xfb, 0xb9, 0xef, 0x37, 0xfb, + 0x75, 0xc7, 0xe5, 0x9f, 0x46, 0x03, 0xc5, 0xa2, 0x41, 0xda, 0x5b, 0xba, 0x1c, 0x30, 0xdb, 0x53, + 0xf9, 0x74, 0x48, 0x98, 0xa2, 0x87, 0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e0, 0x91, 0xa9, 0xd0, + 0xdd, 0x8c, 0xb7, 0xe8, 0x04, 0xee, 0x8d, 0xe3, 0x26, 0x12, 0x5d, 0xb6, 0x9a, 0xf5, 0xdb, 0xbd, + 0x12, 0x53, 0x80, 0x8e, 0xf3, 0x2f, 0x24, 0xad, 0x73, 0x35, 0x93, 0xa5, 0xeb, 0x99, 0x2c, 0xfd, + 0x98, 0xc9, 0xd2, 0xe7, 0xb9, 0x9c, 0xbb, 0x9e, 0xcb, 0xb9, 0x6f, 0x73, 0x39, 0xf7, 0xe1, 0x28, + 0x23, 0x6e, 0x5b, 0xd0, 0x1a, 0x84, 0x5f, 0xd2, 0xc8, 0x53, 0xff, 0xfc, 0x19, 0x93, 0xc5, 0x5f, + 0x23, 0x11, 0x7c, 0x50, 0x4c, 0xde, 0xf4, 0xf3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x17, 0x55, + 0x62, 0x2e, 0x5a, 0x04, 0x00, 0x00, } func (m *ValidatorInfo) Marshal() (dAtA []byte, err error) { diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 4aba20cfc..26078e9d7 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -26,11 +26,11 @@ func UpdateShareOfStakerAndOperator(sharedParam *SharedParameter, assetId, stake } } -// EndBlock : update the assets' share when their prices change -func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +// PriceChangeHandle update the assets' share when their prices change +func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { priceChangeAssets, err := k.oracleKeeper.GetPriceChangeAssets(ctx) if err != nil { - panic(err) + return err } if priceChangeAssets == nil || len(priceChangeAssets) == 0 { return nil @@ -42,7 +42,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida //get the decimal of asset assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) if err != nil { - panic(err) + return err } assetsDecimal[assetId] = assetInfo.AssetBasicInfo.Decimals if _, ok := assetsOperatorAVSInfo[assetId]; !ok { @@ -63,13 +63,13 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } err = k.IterateUpdateAssetState(ctx, assetId, f) if err != nil { - panic(err) + return err } } //BatchUpdateShareForAVSAndOperator err = k.BatchUpdateShareForAVSAndOperator(ctx, avsOperatorShareChange) if err != nil { - panic(err) + return err } //update staker'suite share @@ -85,7 +85,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) if err != nil { - panic(err) + return err } operatorShareHandleFunc := func(operatorAddr, assetId string, state *types.OperatorSingleAssetOrChangeInfo) error { @@ -94,10 +94,40 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } err = k.restakingStateKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) if err != nil { - panic(err) + return err } //BatchSetStakerShare err = k.BatchSetStakerShare(ctx, sharedParameter.stakerShare) + if err != nil { + return err + } + return nil +} + +// ClearPreConsensusPK clears the previous consensus public key for all operators +func (k *Keeper) ClearPreConsensusPK(ctx sdk.Context) error { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator( + store, + []byte{operatortypes.BytePrefixForOperatorAndChainIdToPrevConsKey}, + ) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + store.Delete(iterator.Key()) + } + return nil +} + +// EndBlock : update the assets' share when their prices change +func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + //todo: need to consider the calling order + err := k.PriceChangeHandle(ctx) + if err != nil { + panic(err) + } + + err = k.ClearPreConsensusPK(ctx) if err != nil { panic(err) } diff --git a/x/operator/keeper/dogfood.go b/x/operator/keeper/dogfood.go new file mode 100644 index 000000000..5b5efa0df --- /dev/null +++ b/x/operator/keeper/dogfood.go @@ -0,0 +1,427 @@ +package keeper + +import ( + "fmt" + "github.com/ExocoreNetwork/exocore/x/operator/types" + + errorsmod "cosmossdk.io/errors" + "github.com/cometbft/cometbft/libs/log" + + sdk "github.com/cosmos/cosmos-sdk/types" + + delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" + restakingtypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" +) + +func (k *Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// SetOperatorConsKeyForChainId sets the (consensus) public key for the given operator address +// and chain id. By doing this, an operator is consenting to be an operator on the given chain. +// If a key already exists, it will be overwritten and the change in voting power will flow +// through to the validator set. +func (k *Keeper) SetOperatorConsKeyForChainId( + ctx sdk.Context, + opAccAddr sdk.AccAddress, + chainId string, + // should be tm-ed25519 + consKey tmprotocrypto.PublicKey, +) error { + // check if we are an operator + if !k.IsOperator(ctx, opAccAddr) { + return delegationtypes.ErrOperatorNotExist + } + // check for slashing + if k.slashKeeper.IsOperatorFrozen(ctx, opAccAddr) { + return delegationtypes.ErrOperatorIsFrozen + } + // check if the chain id is valid + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + return restakingtypes.ErrNoAppChainKey + } + // if opting out, do not allow key replacement + if k.IsOperatorOptingOutFromChainId(ctx, opAccAddr, chainId) { + return types.ErrAlreadyOptingOut + } + // convert to bytes + bz, err := consKey.Marshal() + if err != nil { + return errorsmod.Wrap( + err, + "SetOperatorConsKeyForChainId: error occurred when marshal public key", + ) + } + // convert to address for reverse lookup + consAddr, err := types.TMCryptoPublicKeyToConsAddr(consKey) + if err != nil { + return errorsmod.Wrap( + err, + "SetOperatorConsKeyForChainId: error occurred when convert public key to consensus address", + ) + } + // check if the key is already in use by another operator + // operators may call this function with their own key + // to unjail themselves, so we will allow that. + keyInUse, existingAddr := k.GetOperatorAddressForChainIdAndConsAddr(ctx, chainId, consAddr) + if keyInUse { + if !existingAddr.Equals(opAccAddr) { + return types.ErrConsKeyAlreadyInUse + } + } + // check that such a key is already set. if yes, we will consider it as key replacement. + found, prevKey, err := k.getOperatorConsKeyForChainId(ctx, opAccAddr, chainId) + if err != nil { + // this should not happen + panic(err) + } + var alreadyRecorded bool + if found { + // ultimately performs bytes.Equal + if prevKey.Equal(consKey) { + // no-op + return nil + } + // if this key is different, we will set the vote power of the old key to 0 + // in the validator update. but, we must only do so once in a block, since the + // first existing key is the one to replace with 0 vote power and not any others. + alreadyRecorded, _, err = k.getOperatorPrevConsKeyForChainId(ctx, opAccAddr, chainId) + if err != nil { + // this should not happen + panic(err) + } + if !alreadyRecorded { + if err := k.setOperatorPrevConsKeyForChainId(ctx, opAccAddr, chainId, prevKey); err != nil { + // this should not happen + panic(err) + } + } + } + // k.setOperatorConsKeyForChainId(ctx, opAccAddr, chainId, bz) + // return nil + // } + + // // setOperatorConsKeyForChainId is the internal private version. It performs + // // no error checking of the input. + // func (k Keeper) setOperatorConsKeyForChainId( + // ctx sdk.Context, + // opAccAddr sdk.AccAddress, + // chainId string, + // bz []byte, + // ) { + store := ctx.KVStore(k.storeKey) + // forward lookup + // given operator address and chain id, find the consensus key, + // since it is sorted by operator address, it helps for faster indexing by operator + // for example, when an operator is delegated to, we can find all impacted + // chain ids and their respective consensus keys + store.Set(types.KeyForOperatorAndChainIdToConsKey(opAccAddr, chainId), bz) + // reverse lookups + // 1. given chain id and operator address, find the consensus key, + // at initial onboarding of an app chain, it will allow us to find all + // operators that have opted in and their consensus keys + store.Set(types.KeyForChainIdAndOperatorToConsKey(chainId, opAccAddr), bz) + // 2. given a chain id and a consensus addr, find the operator address, + // the slashing module asks for an operator to be slashed by their consensus + // address, so this will allow us to find the operator address to slash. + // however, we do not want to retain this information forever, so we will + // prune it once the validator set update id matures (if key replacement). + // this pruning will be triggered by the app chain module and will not be + // recorded here. + store.Set(types.KeyForChainIdAndConsKeyToOperator(chainId, consAddr), opAccAddr.Bytes()) + if found { + if !alreadyRecorded { + k.Hooks().AfterOperatorKeyReplacement(ctx, opAccAddr, prevKey, consKey, chainId) + } + } else { + k.Hooks().AfterOperatorOptIn(ctx, opAccAddr, chainId, consKey) + } + return nil +} + +// setOperatorPrevConsKeyForChainId sets the previous (consensus) public key for the given +// operator address and chain id. This is used to track the previous key when a key is replaced. +// It is internal-only because such a key must only be set upon key replacement. So it does +// not perform any meaningful error checking of the input. +func (k *Keeper) setOperatorPrevConsKeyForChainId( + ctx sdk.Context, + opAccAddr sdk.AccAddress, + chainId string, + prevKey tmprotocrypto.PublicKey, +) error { + bz, err := prevKey.Marshal() + if err != nil { + return errorsmod.Wrap( + err, + "SetOperatorPrevConsKeyForChainId: error occurred when marshal public key", + ) + } + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyForOperatorAndChainIdToPrevConsKey(opAccAddr, chainId), bz) + return nil +} + +// GetOperatorPrevConsKeyForChainId gets the previous (consensus) public key for the given +// operator address and chain id. When such a key is returned, callers should set its vote power +// to 0 in the validator update. +func (k *Keeper) GetOperatorPrevConsKeyForChainId( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +) (found bool, key tmprotocrypto.PublicKey, err error) { + // check if we are an operator + if !k.IsOperator(ctx, opAccAddr) { + err = delegationtypes.ErrOperatorNotExist + return + } + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + err = restakingtypes.ErrNoAppChainKey + return + } + // do not check for slashing here + found, key, err = k.getOperatorPrevConsKeyForChainId(ctx, opAccAddr, chainId) + return +} + +// getOperatorPrevConsKeyForChainId is the internal version of +// GetOperatorPrevConsKeyForChainId. +// It performs no error checking of the input. +func (k *Keeper) getOperatorPrevConsKeyForChainId( + ctx sdk.Context, + opAccAddr sdk.AccAddress, + chainId string, +) (found bool, key tmprotocrypto.PublicKey, err error) { + store := ctx.KVStore(k.storeKey) + res := store.Get(types.KeyForOperatorAndChainIdToPrevConsKey(opAccAddr, chainId)) + if res == nil { + return + } + if err = key.Unmarshal(res); err != nil { + return + } + found = true + return +} + +// GetOperatorConsKeyForChainId gets the (consensus) public key for the given operator address +// and chain id. This should be exposed via the query surface. +func (k *Keeper) GetOperatorConsKeyForChainId( + ctx sdk.Context, + opAccAddr sdk.AccAddress, + chainId string, +) (found bool, key tmprotocrypto.PublicKey, err error) { + // check if we are an operator + if !k.IsOperator(ctx, opAccAddr) { + err = delegationtypes.ErrOperatorNotExist + return + } + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + err = restakingtypes.ErrNoAppChainKey + return + } + // do not check for slashing, since this function will be used to update voting power even + // when slashed + found, key, err = k.getOperatorConsKeyForChainId(ctx, opAccAddr, chainId) + return +} + +// getOperatorConsKeyForChainId is the internal version of GetOperatorConsKeyForChainId. It +// performs no error checking of the input. +func (k *Keeper) getOperatorConsKeyForChainId( + ctx sdk.Context, + opAccAddr sdk.AccAddress, + chainId string, +) (found bool, key tmprotocrypto.PublicKey, err error) { + store := ctx.KVStore(k.storeKey) + res := store.Get(types.KeyForOperatorAndChainIdToConsKey(opAccAddr, chainId)) + if res == nil { + return + } + if err = key.Unmarshal(res); err != nil { + return + } + return true, key, nil +} + +// GetChainIdsAndKeysForOperator gets the chain ids for which the given operator address has set a +// (consensus) public key. TODO: would it be better to make this a key per operator? +// This is intentionally an array of strings because I don't see the utility for the vote power +// or the public key here. If we need it, we can add it later. +func (k *Keeper) GetChainIdsAndKeysForOperator( + ctx sdk.Context, opAccAddr sdk.AccAddress, +) (chainIds []string, consKeys []tmprotocrypto.PublicKey) { + // check if we are an operator + if !k.IsOperator(ctx, opAccAddr) { + return + } + // do not check for slashing here + prefix := types.AppendMany( + []byte{types.BytePrefixForOperatorAndChainIdToConsKey}, + opAccAddr.Bytes(), + ) + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator( + store, prefix, + ) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + // the key returned is the full key, with the prefix. drop the prefix and the length. + chainId := string(iterator.Key()[len(prefix)+8:]) + var key tmprotocrypto.PublicKey + if err := key.Unmarshal(iterator.Value()); err != nil { + // grave error because we are the ones who stored this information in the first + // place + panic(err) + } + chainIds = append(chainIds, chainId) + consKeys = append(consKeys, key) + } + return +} + +// GetOperatorsForChainId returns a list of {operatorAddr, pubKey} for the given +// chainId. This is used to create or update the validator set. It skips +// jailed or frozen operators. +func (k *Keeper) GetOperatorsForChainId( + ctx sdk.Context, chainId string, +) (addrs []sdk.AccAddress, pubKeys []tmprotocrypto.PublicKey) { + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + return + } + // prefix is the byte prefix and then chainId with length + prefix := types.ChainIdAndAddrKey( + types.BytePrefixForChainIdAndOperatorToConsKey, + chainId, + nil, + ) + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator( + store, prefix, + ) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + // this key is of the format prefix | len | chainId | addr + // and our prefix is of the format prefix | len | chainId + // so just drop it and convert to sdk.AccAddress + addr := iterator.Key()[len(prefix):] + res := iterator.Value() + var ret tmprotocrypto.PublicKey + if err := ret.Unmarshal(res); err != nil { + // grave error + panic(err) + } + addrs = append(addrs, addr) + pubKeys = append(pubKeys, ret) + + } + return +} + +func (k *Keeper) GetOperatorAddressForChainIdAndConsAddr( + ctx sdk.Context, chainId string, consAddr sdk.ConsAddress, +) (found bool, addr sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + res := store.Get(types.KeyForChainIdAndConsKeyToOperator(chainId, consAddr)) + if res == nil { + return + } + found = true + addr = sdk.AccAddress(res) + return +} + +// DeleteOperatorAddressForChainIdAndConsAddr is a pruning method used to delete the +// mapping from chain id and consensus address to operator address. This mapping is used +// to obtain the operator address from its consensus public key, which is sent to the +// coordinator chain by a subscriber chain for slashing. +func (k *Keeper) DeleteOperatorAddressForChainIdAndConsAddr( + ctx sdk.Context, chainId string, consAddr sdk.ConsAddress, +) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyForChainIdAndConsKeyToOperator(chainId, consAddr)) +} + +// SetHooks stores the given hooks implementations. +// Note that the Keeper is changed into a pointer to prevent an ineffective assignment. +func (k *Keeper) SetHooks(hooks types.OperatorConsentHooks) { + if hooks == nil { + panic("cannot set nil hooks") + } + if k.hooks != nil { + panic("cannot set hooks twice") + } + k.hooks = hooks +} + +func (k *Keeper) Hooks() types.OperatorConsentHooks { + if k.hooks == nil { + // return a no-op implementation if no hooks are set to prevent calling nil functions + return types.MultiOperatorConsentHooks{} + } + return k.hooks +} + +// InitiateOperatorOptOutFromChainId initiates an operator opting out from the given chain id. +// It validates whether the operator is registered, and that it is not frozen, and that the +// chain is present within the system. It also checks if the operator is already opting out. +func (k *Keeper) InitiateOperatorOptOutFromChainId( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +) error { + // check if we are an operator + if !k.IsOperator(ctx, opAccAddr) { + return delegationtypes.ErrOperatorNotExist + } + // check for slashing + if k.slashKeeper.IsOperatorFrozen(ctx, opAccAddr) { + return delegationtypes.ErrOperatorIsFrozen + } + // check if the chain id is valid + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + return restakingtypes.ErrNoAppChainKey + } + found, key, err := k.getOperatorConsKeyForChainId(ctx, opAccAddr, chainId) + if err != nil { + return err + } + if !found { + return types.ErrNotOptedIn + } + isAlreadyOptingOut := k.IsOperatorOptingOutFromChainId(ctx, opAccAddr, chainId) + if isAlreadyOptingOut { + return types.ErrAlreadyOptingOut + } + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyForOperatorOptOutFromChainId(opAccAddr, chainId), []byte{}) + k.Hooks().AfterOperatorOptOutInitiated(ctx, opAccAddr, chainId, key) + return nil +} + +// IsOperatorOptingOutFromChainId returns true if the operator is opting out from the given +// chain id. +func (k *Keeper) IsOperatorOptingOutFromChainId( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +) bool { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyForOperatorOptOutFromChainId(opAccAddr, chainId)) + return bz != nil +} + +// CompleteOperatorOptOutFromChainId completes the operator opting out from the given chain id. +// TODO(mm): would it be better to store as 3 states? (opted in, opting out, opted out) +func (k *Keeper) CompleteOperatorOptOutFromChainId( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +) { + if !k.IsOperatorOptingOutFromChainId(ctx, opAccAddr, chainId) { + panic("operator is not opting out") + } + store := ctx.KVStore(k.storeKey) + store.Delete(types.KeyForOperatorOptOutFromChainId(opAccAddr, chainId)) +} + +// IsOperatorJailedForChainId add for dogfood +func (k *Keeper) IsOperatorJailedForChainId(sdk.Context, sdk.AccAddress, string) bool { + return false +} +func (k *Keeper) Jail(sdk.Context, sdk.ConsAddress, string) { + return +} diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index eaeb0f34f..5856c70ea 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "errors" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,3 +14,27 @@ func (k *Keeper) GetOperatorInfo(ctx context.Context, req *operatortypes.GetOper c := sdk.UnwrapSDKContext(ctx) return k.OperatorInfo(c, req.OperatorAddr) } + +// QueryOperatorConsKeyForChainId add for dogfood +func (k *Keeper) QueryOperatorConsKeyForChainId( + goCtx context.Context, + req *operatortypes.QueryOperatorConsKeyForChainIdRequest, +) (*operatortypes.QueryOperatorConsKeyForChainIdResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(req.Addr) + if err != nil { + return nil, err + } + found, key, err := k.GetOperatorConsKeyForChainId( + ctx, addr, req.ChainId, + ) + if err != nil { + return nil, err + } + if !found { + return nil, errors.New("no key assigned") + } + return &operatortypes.QueryOperatorConsKeyForChainIdResponse{ + PublicKey: key, + }, nil +} diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 440431671..114f00185 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -19,6 +19,10 @@ type Keeper struct { delegationKeeper operatortypes.ExpectDelegationInterface oracleKeeper operatortypes.ExpectOracleInterface avsKeeper operatortypes.ExpectAvsInterface + + // add for dogfood + hooks operatortypes.OperatorConsentHooks // set separately via call to SetHooks + slashKeeper operatortypes.SlashKeeper // for jailing and unjailing check TODO(mm) } func NewKeeper( @@ -27,6 +31,7 @@ func NewKeeper( restakingStateKeeper keeper.Keeper, oracleKeeper operatortypes.ExpectOracleInterface, avsKeeper operatortypes.ExpectAvsInterface, + slashKeeper operatortypes.SlashKeeper, ) Keeper { return Keeper{ storeKey: storeKey, @@ -34,6 +39,7 @@ func NewKeeper( restakingStateKeeper: restakingStateKeeper, oracleKeeper: oracleKeeper, avsKeeper: avsKeeper, + slashKeeper: slashKeeper, } } diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go index 0a1e594c4..cafef0564 100644 --- a/x/operator/keeper/msg_server.go +++ b/x/operator/keeper/msg_server.go @@ -2,6 +2,8 @@ package keeper import ( context "context" + "encoding/base64" + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "github.com/ExocoreNetwork/exocore/x/operator/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,3 +19,56 @@ func (k *Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperat } return nil, nil } + +// OptInToChainId add for dogfood +func (k *Keeper) OptInToChainId( + goCtx context.Context, + req *types.OptInToChainIdRequest, +) (*types.OptInToChainIdResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + key, err := stringToPubKey(req.PublicKey) + if err != nil { + return nil, err + } + err = k.SetOperatorConsKeyForChainId( + ctx, addr, req.ChainId, key, + ) + if err != nil { + return nil, err + } + return &types.OptInToChainIdResponse{}, nil +} + +func (k *Keeper) InitiateOptOutFromChainId( + goCtx context.Context, + req *types.InitiateOptOutFromChainIdRequest, +) (*types.InitiateOptOutFromChainIdResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + if err := k.InitiateOperatorOptOutFromChainId( + ctx, addr, req.ChainId, + ); err != nil { + return nil, err + } + return &types.InitiateOptOutFromChainIdResponse{}, nil +} + +func stringToPubKey(pubKey string) (key tmprotocrypto.PublicKey, err error) { + pubKeyBytes, err := base64.StdEncoding.DecodeString(pubKey) + if err != nil { + return + } + subscriberTMConsKey := tmprotocrypto.PublicKey{ + Sum: &tmprotocrypto.PublicKey_Ed25519{ + Ed25519: pubKeyBytes, + }, + } + return subscriberTMConsKey, nil +} diff --git a/x/operator/types/app_chain_utils.go b/x/operator/types/app_chain_utils.go new file mode 100644 index 000000000..9c3a96e9c --- /dev/null +++ b/x/operator/types/app_chain_utils.go @@ -0,0 +1,40 @@ +package types + +import ( + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// add for dogfood + +// AppendMany appends a variable number of byte slices together +func AppendMany(byteses ...[]byte) (out []byte) { + for _, bytes := range byteses { + out = append(out, bytes...) + } + return out +} + +// ChainIdWithLenKey returns the key with the following format: +// bytePrefix | len(chainId) | chainId +// This is similar to Solidity's ABI encoding. +func ChainIdWithLenKey(chainId string) []byte { + chainIdL := len(chainId) + return AppendMany( + // Append the chainId length + sdk.Uint64ToBigEndian(uint64(chainIdL)), + // Append the chainId + []byte(chainId), + ) +} + +// TMCryptoPublicKeyToConsAddr converts a TM public key to an SDK public key +// and returns the associated consensus address +func TMCryptoPublicKeyToConsAddr(k tmprotocrypto.PublicKey) (sdk.ConsAddress, error) { + sdkK, err := cryptocodec.FromTmProtoPublicKey(k) + if err != nil { + return nil, err + } + return sdk.GetConsAddress(sdkK), nil +} diff --git a/x/operator/types/codec.go b/x/operator/types/codec.go index d85fe3101..71e40f49e 100644 --- a/x/operator/types/codec.go +++ b/x/operator/types/codec.go @@ -37,6 +37,8 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &RegisterOperatorReq{}, + &OptInToChainIdRequest{}, + &InitiateOptOutFromChainIdRequest{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } @@ -45,5 +47,5 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { // concrete types on the provided LegacyAmino codec. These types are used for // Amino JSON serialization and EIP-712 compatibility. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&RegisterOperatorReq{}, registerOperator, nil) + //cdc.RegisterConcrete(&RegisterOperatorReq{}, registerOperator, nil) } diff --git a/x/operator/types/errors.go b/x/operator/types/errors.go index 830c705f9..d7e4ed12a 100644 --- a/x/operator/types/errors.go +++ b/x/operator/types/errors.go @@ -22,4 +22,14 @@ var ( ErrSlashContractNotMatch = errorsmod.Register(ModuleName, 8, "the slash contract isn't the slash contract address saved in the opted-in info") ErrSlashOccurredHeight = errorsmod.Register(ModuleName, 9, "the occurred height of slash event is error") + + // add for dogfood + ErrConsKeyAlreadyInUse = errorsmod.Register( + ModuleName, + 10, + "consensus key already in use by another operator", + ) + ErrAlreadyOptingOut = errorsmod.Register( + ModuleName, 11, "operator already opting out", + ) ) diff --git a/x/operator/types/expected_for_dogfood.go b/x/operator/types/expected_for_dogfood.go new file mode 100644 index 000000000..fc9d88171 --- /dev/null +++ b/x/operator/types/expected_for_dogfood.go @@ -0,0 +1,40 @@ +package types + +import ( + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type SlashKeeper interface { + IsOperatorFrozen(ctx sdk.Context, addr sdk.AccAddress) bool +} + +type RedelegationKeeper interface { + AppChainInfoIsExist(ctx sdk.Context, chainId string) bool +} + +type OperatorConsentHooks interface { + // This hook is called when an operator opts in to a chain. + AfterOperatorOptIn( + ctx sdk.Context, + addr sdk.AccAddress, + chainId string, + pubKey tmprotocrypto.PublicKey, + ) + // This hook is called when an operator's consensus key is replaced for + // a chain. + AfterOperatorKeyReplacement( + ctx sdk.Context, + addr sdk.AccAddress, + oldKey tmprotocrypto.PublicKey, + newKey tmprotocrypto.PublicKey, + chainId string, + ) + // This hook is called when an operator opts out of a chain. + AfterOperatorOptOutInitiated( + ctx sdk.Context, + addr sdk.AccAddress, + chainId string, + key tmprotocrypto.PublicKey, + ) +} diff --git a/x/operator/types/hooks_for_dogfood.go b/x/operator/types/hooks_for_dogfood.go new file mode 100644 index 000000000..66a6465b2 --- /dev/null +++ b/x/operator/types/hooks_for_dogfood.go @@ -0,0 +1,45 @@ +package types + +import ( + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ OperatorConsentHooks = &MultiOperatorConsentHooks{} + +type MultiOperatorConsentHooks []OperatorConsentHooks + +func NewMultiOperatorConsentHooks(hooks ...OperatorConsentHooks) MultiOperatorConsentHooks { + return hooks +} + +func (hooks MultiOperatorConsentHooks) AfterOperatorOptIn( + ctx sdk.Context, + addr sdk.AccAddress, + chainId string, + pubKey tmprotocrypto.PublicKey, +) { + for _, hook := range hooks { + hook.AfterOperatorOptIn(ctx, addr, chainId, pubKey) + } +} + +func (hooks MultiOperatorConsentHooks) AfterOperatorKeyReplacement( + ctx sdk.Context, + addr sdk.AccAddress, + oldKey tmprotocrypto.PublicKey, + newAddr tmprotocrypto.PublicKey, + chainId string, +) { + for _, hook := range hooks { + hook.AfterOperatorKeyReplacement(ctx, addr, oldKey, newAddr, chainId) + } +} + +func (hooks MultiOperatorConsentHooks) AfterOperatorOptOutInitiated( + ctx sdk.Context, addr sdk.AccAddress, chainId string, key tmprotocrypto.PublicKey, +) { + for _, hook := range hooks { + hook.AfterOperatorOptOutInitiated(ctx, addr, chainId, key) + } +} diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 5789ce891..79105ea26 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -1,6 +1,7 @@ package types import ( + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "math" @@ -47,6 +48,13 @@ const ( prefixOperatorSlashInfo prefixSlashAssetsState + + //add keys for dogfood + BytePrefixForOperatorAndChainIdToConsKey = iota + BytePrefixForOperatorAndChainIdToPrevConsKey + BytePrefixForChainIdAndOperatorToConsKey + BytePrefixForChainIdAndConsKeyToOperator + BytePrefixForOperatorOptOutFromChainId ) var ( @@ -81,3 +89,68 @@ var ( // completeSlashHeight + '/' + assetId + '/' + operatorAddr -> SlashAmount KeyPrefixSlashAssetsState = []byte{prefixSlashAssetsState} ) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +func AddrAndChainIdKey(prefix byte, addr sdk.AccAddress, chainId string) []byte { + partialKey := ChainIdWithLenKey(chainId) + return AppendMany( + // Append the prefix + []byte{prefix}, + // Append the addr bytes first so we can iterate over all chain ids + // belonging to an operator easily. + addr, + // Append the partialKey + partialKey, + ) +} + +func ChainIdAndAddrKey(prefix byte, chainId string, addr sdk.AccAddress) []byte { + partialKey := ChainIdWithLenKey(chainId) + return AppendMany( + // Append the prefix + []byte{prefix}, + // Append the partialKey so that we can look for any operator keys + // corresponding to this chainId easily. + partialKey, + addr, + ) +} + +func KeyForOperatorAndChainIdToConsKey(addr sdk.AccAddress, chainId string) []byte { + return AddrAndChainIdKey( + BytePrefixForOperatorAndChainIdToConsKey, + addr, chainId, + ) +} + +func KeyForOperatorAndChainIdToPrevConsKey(addr sdk.AccAddress, chainId string) []byte { + return AddrAndChainIdKey( + BytePrefixForOperatorAndChainIdToPrevConsKey, + addr, chainId, + ) +} + +func KeyForChainIdAndOperatorToConsKey(chainId string, addr sdk.AccAddress) []byte { + return ChainIdAndAddrKey( + BytePrefixForChainIdAndOperatorToConsKey, + chainId, addr, + ) +} + +func KeyForChainIdAndConsKeyToOperator(chainId string, addr sdk.ConsAddress) []byte { + return AppendMany( + []byte{BytePrefixForChainIdAndConsKeyToOperator}, + ChainIdWithLenKey(chainId), + addr, + ) +} + +func KeyForOperatorOptOutFromChainId(addr sdk.AccAddress, chainId string) []byte { + return AppendMany( + []byte{BytePrefixForOperatorOptOutFromChainId}, addr, + ChainIdWithLenKey(chainId), + ) +} diff --git a/x/operator/types/msg.go b/x/operator/types/msg.go index 1cf00daad..52cfd2738 100644 --- a/x/operator/types/msg.go +++ b/x/operator/types/msg.go @@ -7,6 +7,10 @@ import ( var ( _ sdk.Msg = &RegisterOperatorReq{} + + // add for dogfood + _ sdk.Msg = &OptInToChainIdRequest{} + _ sdk.Msg = &InitiateOptOutFromChainIdRequest{} ) // GetSigners returns the expected signers for a MsgUpdateParams message. @@ -27,3 +31,27 @@ func (m *RegisterOperatorReq) ValidateBasic() error { func (m *RegisterOperatorReq) GetSignBytes() []byte { return nil } + +func (m *OptInToChainIdRequest) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.Address) + return []sdk.AccAddress{addr} +} + +func (m *OptInToChainIdRequest) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { + return errorsmod.Wrap(err, "invalid from address") + } + return nil +} + +func (m *InitiateOptOutFromChainIdRequest) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.Address) + return []sdk.AccAddress{addr} +} + +func (m *InitiateOptOutFromChainIdRequest) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { + return errorsmod.Wrap(err, "invalid from address") + } + return nil +} diff --git a/x/operator/types/query.pb.go b/x/operator/types/query.pb.go index d34d0a592..0cc75c5ff 100644 --- a/x/operator/types/query.pb.go +++ b/x/operator/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" @@ -75,33 +76,145 @@ func (m *GetOperatorInfoReq) GetOperatorAddr() string { return "" } +type QueryOperatorConsKeyForChainIdRequest struct { + Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *QueryOperatorConsKeyForChainIdRequest) Reset() { *m = QueryOperatorConsKeyForChainIdRequest{} } +func (m *QueryOperatorConsKeyForChainIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorConsKeyForChainIdRequest) ProtoMessage() {} +func (*QueryOperatorConsKeyForChainIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f91e795a3cecbdbf, []int{1} +} +func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest.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 *QueryOperatorConsKeyForChainIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest.Merge(m, src) +} +func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOperatorConsKeyForChainIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest proto.InternalMessageInfo + +func (m *QueryOperatorConsKeyForChainIdRequest) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *QueryOperatorConsKeyForChainIdRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +type QueryOperatorConsKeyForChainIdResponse struct { + PublicKey crypto.PublicKey `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key"` +} + +func (m *QueryOperatorConsKeyForChainIdResponse) Reset() { + *m = QueryOperatorConsKeyForChainIdResponse{} +} +func (m *QueryOperatorConsKeyForChainIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorConsKeyForChainIdResponse) ProtoMessage() {} +func (*QueryOperatorConsKeyForChainIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f91e795a3cecbdbf, []int{2} +} +func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse.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 *QueryOperatorConsKeyForChainIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse.Merge(m, src) +} +func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOperatorConsKeyForChainIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse proto.InternalMessageInfo + +func (m *QueryOperatorConsKeyForChainIdResponse) GetPublicKey() crypto.PublicKey { + if m != nil { + return m.PublicKey + } + return crypto.PublicKey{} +} + func init() { proto.RegisterType((*GetOperatorInfoReq)(nil), "exocore.operator.v1.GetOperatorInfoReq") + proto.RegisterType((*QueryOperatorConsKeyForChainIdRequest)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIdRequest") + proto.RegisterType((*QueryOperatorConsKeyForChainIdResponse)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIdResponse") } func init() { proto.RegisterFile("exocore/operator/v1/query.proto", fileDescriptor_f91e795a3cecbdbf) } var fileDescriptor_f91e795a3cecbdbf = []byte{ - // 301 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xad, 0xc8, 0x4f, - 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x48, 0x2d, 0x4a, 0x2c, 0xc9, 0x2f, 0xd2, 0x2f, 0x33, 0xd4, - 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x2a, 0xd0, - 0x83, 0x29, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, - 0x10, 0xa5, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, - 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0xe9, 0xe4, 0xfc, 0xe2, - 0xdc, 0xfc, 0x62, 0x88, 0xe1, 0x68, 0xb6, 0x48, 0x49, 0x42, 0x24, 0xe3, 0x21, 0x66, 0x42, 0x38, - 0x30, 0x53, 0xb1, 0xb9, 0xb0, 0xa4, 0x02, 0x22, 0xab, 0x14, 0xc4, 0x25, 0xe4, 0x9e, 0x5a, 0xe2, - 0x0f, 0x95, 0xf2, 0xcc, 0x4b, 0xcb, 0x0f, 0x4a, 0x2d, 0x14, 0xb2, 0xe1, 0xe2, 0x81, 0x09, 0x39, - 0xa6, 0xa4, 0x14, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0x49, 0x5c, 0xda, 0xa2, 0x2b, 0x02, - 0x35, 0x1b, 0x24, 0x9c, 0x5a, 0x5c, 0x1c, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x1e, 0x84, 0xa2, 0xda, - 0x68, 0x3a, 0x23, 0x17, 0x6b, 0x20, 0xc8, 0x71, 0x42, 0xbd, 0x8c, 0x5c, 0xfc, 0x68, 0xc6, 0x0b, - 0xa9, 0xeb, 0x61, 0x09, 0x11, 0x3d, 0x4c, 0x47, 0x48, 0x29, 0x62, 0x55, 0x88, 0xac, 0x4a, 0x49, - 0xaf, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0x1a, 0x42, 0x6a, 0xfa, 0x30, 0x4f, 0xa6, 0xa4, 0xe6, 0xa4, - 0xa6, 0x83, 0xc3, 0x0d, 0xe4, 0x4d, 0x34, 0x53, 0x9d, 0x6c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, - 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, - 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x39, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, - 0x6e, 0x56, 0x05, 0x22, 0xc8, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x61, 0x66, 0x0c, - 0x08, 0x00, 0x00, 0xff, 0xff, 0x59, 0x84, 0xe9, 0xcc, 0xf5, 0x01, 0x00, 0x00, + // 490 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0xa3, 0xf2, 0xd1, 0x05, 0x09, 0x69, 0xe9, 0x21, 0x0d, 0x95, 0x0b, 0x96, 0x28, 0xbd, + 0xb0, 0xab, 0x86, 0x1b, 0x70, 0x49, 0x22, 0x40, 0x51, 0x11, 0x1f, 0x46, 0xe2, 0xc0, 0x25, 0x72, + 0xec, 0xc1, 0xb5, 0x92, 0xec, 0x38, 0xbb, 0x9b, 0x12, 0xab, 0xea, 0x85, 0x3b, 0x12, 0x12, 0x7f, + 0x85, 0x1f, 0xd1, 0x63, 0x05, 0x17, 0x4e, 0x08, 0x25, 0xfd, 0x1d, 0x08, 0x79, 0xd7, 0x6e, 0xc1, + 0x44, 0x80, 0xb8, 0xad, 0x67, 0xde, 0xbc, 0xb7, 0xfb, 0xde, 0x98, 0x6c, 0xc2, 0x0c, 0x43, 0x94, + 0xc0, 0x31, 0x05, 0x19, 0x68, 0x94, 0x7c, 0x7f, 0x87, 0x4f, 0xa6, 0x20, 0x33, 0x96, 0x4a, 0xd4, + 0x48, 0xaf, 0x16, 0x00, 0x56, 0x02, 0xd8, 0xfe, 0x4e, 0x73, 0x2d, 0xc6, 0x18, 0x4d, 0x9f, 0xe7, + 0x27, 0x0b, 0x6d, 0x6e, 0xc4, 0x88, 0xf1, 0x08, 0x78, 0x90, 0x26, 0x3c, 0x10, 0x02, 0x75, 0xa0, + 0x13, 0x14, 0xaa, 0xe8, 0x5e, 0x0b, 0x51, 0x8d, 0x51, 0x59, 0xf2, 0x8a, 0x4a, 0x73, 0xdd, 0x36, + 0xfb, 0x96, 0xd3, 0x7e, 0x94, 0xac, 0xcb, 0x6e, 0xa8, 0x67, 0x65, 0x57, 0x83, 0x88, 0x40, 0x8e, + 0x13, 0xa1, 0x79, 0x28, 0xb3, 0x54, 0x23, 0x1f, 0x42, 0x56, 0xcc, 0x7a, 0x3e, 0xa1, 0x8f, 0x40, + 0x3f, 0x2d, 0x06, 0x7b, 0xe2, 0x35, 0xfa, 0x30, 0xa1, 0xf7, 0xc9, 0xe5, 0xb2, 0xd4, 0x8e, 0x22, + 0xd9, 0x70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x6b, 0x8d, 0xf7, 0x7a, 0xe6, 0x2d, 0x5d, 0xda, 0xe6, + 0xd5, 0x9d, 0xec, 0x87, 0x39, 0x40, 0xe8, 0xca, 0x8b, 0x0a, 0x2a, 0x7e, 0x90, 0x87, 0x7f, 0xc8, + 0x0f, 0xca, 0xec, 0x0f, 0x3b, 0x8f, 0x8f, 0xe6, 0xae, 0x73, 0x3c, 0x77, 0x9d, 0x6f, 0x73, 0xd7, + 0x79, 0xbf, 0x70, 0x6b, 0xc7, 0x0b, 0xb7, 0xf6, 0x65, 0xe1, 0xd6, 0x5e, 0xb5, 0xe2, 0x44, 0xef, + 0x4d, 0x07, 0x2c, 0xc4, 0x31, 0x7f, 0x60, 0x65, 0x9e, 0x80, 0x7e, 0x83, 0x72, 0x78, 0xaa, 0x3a, + 0x3b, 0xfb, 0x17, 0x74, 0x96, 0x82, 0x1a, 0x9c, 0x37, 0xeb, 0x7e, 0xe7, 0x47, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x60, 0x37, 0x18, 0x68, 0xce, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -117,6 +230,8 @@ const _ = grpc.SupportPackageIsVersion4 // 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 { GetOperatorInfo(ctx context.Context, in *GetOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) + // add services for dogfood + QueryOperatorConsKeyForChainId(ctx context.Context, in *QueryOperatorConsKeyForChainIdRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIdResponse, error) } type queryClient struct { @@ -136,9 +251,20 @@ func (c *queryClient) GetOperatorInfo(ctx context.Context, in *GetOperatorInfoRe return out, nil } +func (c *queryClient) QueryOperatorConsKeyForChainId(ctx context.Context, in *QueryOperatorConsKeyForChainIdRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIdResponse, error) { + out := new(QueryOperatorConsKeyForChainIdResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainId", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { GetOperatorInfo(context.Context, *GetOperatorInfoReq) (*OperatorInfo, error) + // add services for dogfood + QueryOperatorConsKeyForChainId(context.Context, *QueryOperatorConsKeyForChainIdRequest) (*QueryOperatorConsKeyForChainIdResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -148,6 +274,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) GetOperatorInfo(ctx context.Context, req *GetOperatorInfoReq) (*OperatorInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetOperatorInfo not implemented") } +func (*UnimplementedQueryServer) QueryOperatorConsKeyForChainId(ctx context.Context, req *QueryOperatorConsKeyForChainIdRequest) (*QueryOperatorConsKeyForChainIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorConsKeyForChainId not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -171,6 +300,24 @@ func _Query_GetOperatorInfo_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_QueryOperatorConsKeyForChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOperatorConsKeyForChainIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryOperatorConsKeyForChainId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryOperatorConsKeyForChainId(ctx, req.(*QueryOperatorConsKeyForChainIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.operator.v1.Query", HandlerType: (*QueryServer)(nil), @@ -179,6 +326,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetOperatorInfo", Handler: _Query_GetOperatorInfo_Handler, }, + { + MethodName: "QueryOperatorConsKeyForChainId", + Handler: _Query_QueryOperatorConsKeyForChainId_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "exocore/operator/v1/query.proto", @@ -214,6 +365,76 @@ func (m *GetOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryOperatorConsKeyForChainIdRequest) 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 *QueryOperatorConsKeyForChainIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOperatorConsKeyForChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryOperatorConsKeyForChainIdResponse) 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 *QueryOperatorConsKeyForChainIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOperatorConsKeyForChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PublicKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -238,6 +459,34 @@ func (m *GetOperatorInfoReq) Size() (n int) { return n } +func (m *QueryOperatorConsKeyForChainIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryOperatorConsKeyForChainIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PublicKey.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -326,6 +575,203 @@ func (m *GetOperatorInfoReq) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryOperatorConsKeyForChainIdRequest) 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: QueryOperatorConsKeyForChainIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOperatorConsKeyForChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addr", 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.Addr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 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.ChainId = 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 *QueryOperatorConsKeyForChainIdResponse) 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: QueryOperatorConsKeyForChainIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOperatorConsKeyForChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", 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 err := m.PublicKey.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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/operator/types/query.pb.gw.go b/x/operator/types/query.pb.gw.go index e5adaf034..f5076602c 100644 --- a/x/operator/types/query.pb.gw.go +++ b/x/operator/types/query.pb.gw.go @@ -69,6 +69,82 @@ func local_request_Query_GetOperatorInfo_0(ctx context.Context, marshaler runtim } +func request_Query_QueryOperatorConsKeyForChainId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOperatorConsKeyForChainIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["addr"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "addr") + } + + protoReq.Addr, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "addr", err) + } + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + msg, err := client.QueryOperatorConsKeyForChainId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryOperatorConsKeyForChainId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOperatorConsKeyForChainIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["addr"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "addr") + } + + protoReq.Addr, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "addr", err) + } + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + msg, err := server.QueryOperatorConsKeyForChainId(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. @@ -98,6 +174,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainId_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_QueryOperatorConsKeyForChainId_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_QueryOperatorConsKeyForChainId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -159,13 +258,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainId_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_QueryOperatorConsKeyForChainId_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_QueryOperatorConsKeyForChainId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_GetOperatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetOperatorInfo"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryOperatorConsKeyForChainId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"exocore", "operator_consent", "v1", "GetOperatorConsKey", "addr", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_GetOperatorInfo_0 = runtime.ForwardResponseMessage + + forward_Query_QueryOperatorConsKeyForChainId_0 = runtime.ForwardResponseMessage ) diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index bcc356eba..174cb21bc 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -482,6 +482,198 @@ func (m *RegisterOperatorResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo +// OptInToChainIdRequest defines the OptInToChainId request. +type OptInToChainIdRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` + // there is no need to check for knowledge of the corresponding private key since this is ED25519 + // and not BLS key, where a rogue key attack can take place. however, we should still check for + // overlap with another operator's key. + PublicKey string `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` +} + +func (m *OptInToChainIdRequest) Reset() { *m = OptInToChainIdRequest{} } +func (m *OptInToChainIdRequest) String() string { return proto.CompactTextString(m) } +func (*OptInToChainIdRequest) ProtoMessage() {} +func (*OptInToChainIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{9} +} +func (m *OptInToChainIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OptInToChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OptInToChainIdRequest.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 *OptInToChainIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToChainIdRequest.Merge(m, src) +} +func (m *OptInToChainIdRequest) XXX_Size() int { + return m.Size() +} +func (m *OptInToChainIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToChainIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_OptInToChainIdRequest proto.InternalMessageInfo + +func (m *OptInToChainIdRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *OptInToChainIdRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *OptInToChainIdRequest) GetPublicKey() string { + if m != nil { + return m.PublicKey + } + return "" +} + +// OptInToChainIdResponse defines the OptInToChainId response. +type OptInToChainIdResponse struct { +} + +func (m *OptInToChainIdResponse) Reset() { *m = OptInToChainIdResponse{} } +func (m *OptInToChainIdResponse) String() string { return proto.CompactTextString(m) } +func (*OptInToChainIdResponse) ProtoMessage() {} +func (*OptInToChainIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{10} +} +func (m *OptInToChainIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OptInToChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OptInToChainIdResponse.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 *OptInToChainIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToChainIdResponse.Merge(m, src) +} +func (m *OptInToChainIdResponse) XXX_Size() int { + return m.Size() +} +func (m *OptInToChainIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToChainIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_OptInToChainIdResponse proto.InternalMessageInfo + +// InitiateOptOutFromChainIdRequest defines the InitiateOptOutFromChainId request. +type InitiateOptOutFromChainIdRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *InitiateOptOutFromChainIdRequest) Reset() { *m = InitiateOptOutFromChainIdRequest{} } +func (m *InitiateOptOutFromChainIdRequest) String() string { return proto.CompactTextString(m) } +func (*InitiateOptOutFromChainIdRequest) ProtoMessage() {} +func (*InitiateOptOutFromChainIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{11} +} +func (m *InitiateOptOutFromChainIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InitiateOptOutFromChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InitiateOptOutFromChainIdRequest.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 *InitiateOptOutFromChainIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitiateOptOutFromChainIdRequest.Merge(m, src) +} +func (m *InitiateOptOutFromChainIdRequest) XXX_Size() int { + return m.Size() +} +func (m *InitiateOptOutFromChainIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_InitiateOptOutFromChainIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_InitiateOptOutFromChainIdRequest proto.InternalMessageInfo + +func (m *InitiateOptOutFromChainIdRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *InitiateOptOutFromChainIdRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +// InitiateOptOutFromChainIdResponse defines the InitiateOptOutFromChainId response. +type InitiateOptOutFromChainIdResponse struct { +} + +func (m *InitiateOptOutFromChainIdResponse) Reset() { *m = InitiateOptOutFromChainIdResponse{} } +func (m *InitiateOptOutFromChainIdResponse) String() string { return proto.CompactTextString(m) } +func (*InitiateOptOutFromChainIdResponse) ProtoMessage() {} +func (*InitiateOptOutFromChainIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{12} +} +func (m *InitiateOptOutFromChainIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InitiateOptOutFromChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InitiateOptOutFromChainIdResponse.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 *InitiateOptOutFromChainIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitiateOptOutFromChainIdResponse.Merge(m, src) +} +func (m *InitiateOptOutFromChainIdResponse) XXX_Size() int { + return m.Size() +} +func (m *InitiateOptOutFromChainIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_InitiateOptOutFromChainIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_InitiateOptOutFromChainIdResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*ClientChainEarningAddrList)(nil), "exocore.operator.v1.clientChainEarningAddrList") proto.RegisterType((*ClientChainEarningAddrInfo)(nil), "exocore.operator.v1.clientChainEarningAddrInfo") @@ -492,58 +684,72 @@ func init() { proto.RegisterType((*OperatorSlashInfo)(nil), "exocore.operator.v1.OperatorSlashInfo") proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.operator.v1.RegisterOperatorReq") proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.operator.v1.RegisterOperatorResponse") + proto.RegisterType((*OptInToChainIdRequest)(nil), "exocore.operator.v1.OptInToChainIdRequest") + proto.RegisterType((*OptInToChainIdResponse)(nil), "exocore.operator.v1.OptInToChainIdResponse") + proto.RegisterType((*InitiateOptOutFromChainIdRequest)(nil), "exocore.operator.v1.InitiateOptOutFromChainIdRequest") + proto.RegisterType((*InitiateOptOutFromChainIdResponse)(nil), "exocore.operator.v1.InitiateOptOutFromChainIdResponse") } func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 734 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x4f, 0x13, 0x4f, - 0x14, 0xef, 0xd2, 0xd2, 0x7c, 0x79, 0xe5, 0x2b, 0x30, 0x10, 0x58, 0x1b, 0xd3, 0xd6, 0xd5, 0x90, - 0xa6, 0x49, 0xbb, 0x01, 0x7f, 0x1c, 0x88, 0x1e, 0x4a, 0x81, 0xd8, 0x44, 0x82, 0x19, 0x0c, 0x89, - 0x5e, 0xcc, 0xb2, 0x1d, 0xb6, 0x1b, 0xda, 0x9d, 0x75, 0x66, 0x8a, 0xc5, 0x83, 0x1a, 0x4f, 0xc6, - 0x93, 0x7f, 0x02, 0x57, 0x6f, 0x1c, 0xb8, 0xea, 0x99, 0x23, 0xe1, 0x64, 0x3c, 0x10, 0x03, 0x07, - 0x4c, 0xfc, 0x27, 0xcc, 0xce, 0x4e, 0xc3, 0xf6, 0x07, 0x89, 0x44, 0x2f, 0xb0, 0xf3, 0x79, 0x9f, - 0xf7, 0x79, 0x6f, 0xde, 0x67, 0xa6, 0x03, 0x37, 0x48, 0x9b, 0xda, 0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d0, 0x36, 0x8c, - 0xf7, 0x52, 0x50, 0x7e, 0x60, 0x57, 0x03, 0x26, 0x91, 0x2e, 0xfe, 0x21, 0x33, 0xac, 0x99, 0x1e, - 0x7e, 0x77, 0xbe, 0x5f, 0xd0, 0x16, 0x1f, 0x1e, 0x9e, 0x66, 0xb4, 0xa3, 0xd3, 0x8c, 0xf6, 0xe3, - 0x34, 0xa3, 0x7d, 0x3a, 0xcb, 0xc4, 0x8e, 0xce, 0x32, 0xb1, 0x6f, 0x67, 0x99, 0xd8, 0xf3, 0x5b, - 0x11, 0xe3, 0x3a, 0x8f, 0x58, 0xfb, 0xe2, 0x19, 0x93, 0xce, 0x6d, 0x26, 0xe5, 0xab, 0x72, 0xe7, - 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xf3, 0x0e, 0xcc, 0xe7, 0x06, 0x00, 0x00, + // 891 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0x5e, 0x67, 0x37, 0x69, 0xf3, 0x12, 0x48, 0x33, 0x2d, 0x89, 0x63, 0xc1, 0xc6, 0x35, 0xa8, + 0x5a, 0x2d, 0xca, 0x5a, 0x0d, 0xb4, 0x87, 0x88, 0x4b, 0x9a, 0xa6, 0x62, 0x45, 0xcb, 0xa2, 0x49, + 0x55, 0x09, 0x2e, 0x91, 0x63, 0x4f, 0x9d, 0xd1, 0xee, 0x7a, 0xdc, 0x99, 0x71, 0x9a, 0x70, 0x00, + 0xc4, 0x09, 0x21, 0x0e, 0xfc, 0x84, 0x5e, 0xb9, 0xe5, 0xd0, 0x2b, 0x9c, 0x7b, 0xac, 0x7a, 0x42, + 0x1c, 0x2a, 0x94, 0x1c, 0x82, 0xc4, 0x99, 0x3b, 0xf2, 0x78, 0xac, 0x3a, 0x8e, 0x17, 0xba, 0x6a, + 0x2e, 0xbb, 0x9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xf3, 0xa3, 0xa6, + 0xf1, 0xe7, 0x51, 0xd3, 0xf8, 0xf9, 0xb8, 0x59, 0x7b, 0x7e, 0xdc, 0xac, 0xfd, 0x7e, 0xdc, 0xac, + 0x7d, 0xb5, 0x5a, 0xb8, 0xd6, 0x9b, 0x59, 0x90, 0xcf, 0x89, 0x7c, 0xcc, 0x78, 0xdf, 0xcd, 0x5f, + 0x3c, 0xfb, 0xaf, 0xde, 0x3c, 0xea, 0x9a, 0xef, 0x4c, 0xa9, 0x27, 0xc8, 0x47, 0xff, 0x06, 0x00, + 0x00, 0xff, 0xff, 0xb2, 0xfc, 0xfd, 0xe6, 0x14, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -560,6 +766,17 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) + // add services for dogfood + // OptInToChainId acts as opt in method for an operator to + // start validatring on a chain. The operator must sign the request with + // the key with which they registered in the system. + OptInToChainId(ctx context.Context, in *OptInToChainIdRequest, opts ...grpc.CallOption) (*OptInToChainIdResponse, error) + // InitiateOptOutFromChainId is a method with which an operator can initiate + // the opt out process from a chain. The operator must sign the request with + // the key with which they registered in the system. The opt-out process takes + // as long as the chain's unbonding period to complete, plus some loose change + // for message relaying across chains. + InitiateOptOutFromChainId(ctx context.Context, in *InitiateOptOutFromChainIdRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIdResponse, error) } type msgClient struct { @@ -579,10 +796,39 @@ func (c *msgClient) RegisterOperator(ctx context.Context, in *RegisterOperatorRe return out, nil } +func (c *msgClient) OptInToChainId(ctx context.Context, in *OptInToChainIdRequest, opts ...grpc.CallOption) (*OptInToChainIdResponse, error) { + out := new(OptInToChainIdResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/OptInToChainId", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) InitiateOptOutFromChainId(ctx context.Context, in *InitiateOptOutFromChainIdRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIdResponse, error) { + out := new(InitiateOptOutFromChainIdResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitiateOptOutFromChainId", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) + // add services for dogfood + // OptInToChainId acts as opt in method for an operator to + // start validatring on a chain. The operator must sign the request with + // the key with which they registered in the system. + OptInToChainId(context.Context, *OptInToChainIdRequest) (*OptInToChainIdResponse, error) + // InitiateOptOutFromChainId is a method with which an operator can initiate + // the opt out process from a chain. The operator must sign the request with + // the key with which they registered in the system. The opt-out process takes + // as long as the chain's unbonding period to complete, plus some loose change + // for message relaying across chains. + InitiateOptOutFromChainId(context.Context, *InitiateOptOutFromChainIdRequest) (*InitiateOptOutFromChainIdResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -592,6 +838,12 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *RegisterOperatorReq) (*RegisterOperatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterOperator not implemented") } +func (*UnimplementedMsgServer) OptInToChainId(ctx context.Context, req *OptInToChainIdRequest) (*OptInToChainIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OptInToChainId not implemented") +} +func (*UnimplementedMsgServer) InitiateOptOutFromChainId(ctx context.Context, req *InitiateOptOutFromChainIdRequest) (*InitiateOptOutFromChainIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InitiateOptOutFromChainId not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -615,6 +867,42 @@ func _Msg_RegisterOperator_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Msg_OptInToChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OptInToChainIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).OptInToChainId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Msg/OptInToChainId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).OptInToChainId(ctx, req.(*OptInToChainIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_InitiateOptOutFromChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InitiateOptOutFromChainIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).InitiateOptOutFromChainId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Msg/InitiateOptOutFromChainId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).InitiateOptOutFromChainId(ctx, req.(*InitiateOptOutFromChainIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.operator.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -623,6 +911,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RegisterOperator", Handler: _Msg_RegisterOperator_Handler, }, + { + MethodName: "OptInToChainId", + Handler: _Msg_OptInToChainId_Handler, + }, + { + MethodName: "InitiateOptOutFromChainId", + Handler: _Msg_InitiateOptOutFromChainId_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "exocore/operator/v1/tx.proto", @@ -1002,6 +1298,133 @@ func (m *RegisterOperatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *OptInToChainIdRequest) 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 *OptInToChainIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptInToChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintTx(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OptInToChainIdResponse) 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 *OptInToChainIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptInToChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *InitiateOptOutFromChainIdRequest) 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 *InitiateOptOutFromChainIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InitiateOptOutFromChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *InitiateOptOutFromChainIdResponse) 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 *InitiateOptOutFromChainIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InitiateOptOutFromChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1165,17 +1588,73 @@ func (m *RegisterOperatorResponse) Size() (n int) { return n } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ClientChainEarningAddrList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx +func (m *OptInToChainIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *OptInToChainIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *InitiateOptOutFromChainIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *InitiateOptOutFromChainIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ClientChainEarningAddrList) 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 { @@ -2221,6 +2700,366 @@ func (m *RegisterOperatorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *OptInToChainIdRequest) 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 ErrIntOverflowTx + } + 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: OptInToChainIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptInToChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PublicKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OptInToChainIdResponse) 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 ErrIntOverflowTx + } + 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: OptInToChainIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptInToChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InitiateOptOutFromChainIdRequest) 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 ErrIntOverflowTx + } + 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: InitiateOptOutFromChainIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InitiateOptOutFromChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InitiateOptOutFromChainIdResponse) 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 ErrIntOverflowTx + } + 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: InitiateOptOutFromChainIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InitiateOptOutFromChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/restaking_assets_manage/keeper/app_chain.go b/x/restaking_assets_manage/keeper/app_chain.go new file mode 100644 index 000000000..915c9fe35 --- /dev/null +++ b/x/restaking_assets_manage/keeper/app_chain.go @@ -0,0 +1,58 @@ +package keeper + +import ( + restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetAppChainInfo stores the info for the app chain to the db. At the moment, it is called by +// the +// genesis process. In the future, it should be called by governance. +func (k Keeper) SetAppChainInfo( + ctx sdk.Context, + info restakingtype.AppChainInfo, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) + bz := k.cdc.MustMarshal(&info) + store.Set([]byte(info.ChainId), bz) +} + +// AppChainInfoIsExist returns whether the app chain info for the specified chainId exists +func (k Keeper) AppChainInfoIsExist(ctx sdk.Context, chainId string) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) + return store.Has([]byte(chainId)) +} + +// GetAppChainInfoByChainId gets the app chain info for the specified chainId, if it exists +func (k Keeper) GetAppChainInfoByChainId( + ctx sdk.Context, + chainId string, +) (info restakingtype.AppChainInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) + ifExist := store.Has([]byte(chainId)) + if !ifExist { + return restakingtype.AppChainInfo{}, restakingtype.ErrNoAppChainKey + } + value := store.Get([]byte(chainId)) + ret := restakingtype.AppChainInfo{} + k.cdc.MustUnmarshal(value, &ret) + return ret, nil +} + +// GetAllAppChainInfo gets all the app chain info, indexed by chainId +func (k Keeper) GetAllAppChainInfo( + ctx sdk.Context, +) (infos map[string]restakingtype.AppChainInfo) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, restakingtype.KeyPrefixAppChainInfo) + defer iterator.Close() + + ret := make(map[string]restakingtype.AppChainInfo, 0) + for ; iterator.Valid(); iterator.Next() { + var chainInfo restakingtype.AppChainInfo + k.cdc.MustUnmarshal(iterator.Value(), &chainInfo) + ret[chainInfo.ChainId] = chainInfo + } + return ret +} diff --git a/x/restaking_assets_manage/keeper/snapshot.go b/x/restaking_assets_manage/keeper/snapshot.go new file mode 100644 index 000000000..c2a8d041b --- /dev/null +++ b/x/restaking_assets_manage/keeper/snapshot.go @@ -0,0 +1,110 @@ +package keeper + +import ( + sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// we need to ensure that a snapshot exists for the block heights at which +// a delegation/undelegation happened. these are the heights at which +// the validator set update is broadcasted to the chain(s), and they +// therefore represent the mapped infraction heights. + +// updateOperatorLastSnapshotHeight stores the last snapshot height for an operator +// equal to the current block height. +func (k Keeper) updateOperatorLastSnapshotHeight( + ctx sdk.Context, operator sdk.AccAddress, +) { + store := ctx.KVStore(k.storeKey) + store.Set( + types.OperatorLastSnapshotHeightKey(operator), + sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight())), + ) +} + +// GetOperatorLastSnapshotHeight returns the last snapshot height for an operator +func (k Keeper) getOperatorLastSnapshotHeight( + ctx sdk.Context, operator sdk.AccAddress, +) uint64 { + store := ctx.KVStore(k.storeKey) + val := store.Get(types.OperatorLastSnapshotHeightKey(operator)) + return sdk.BigEndianToUint64(val) +} + +// GetOperatorLastSnapshot returns the last snapshot for an operator +func (k Keeper) getOperatorLastSnapshot( + ctx sdk.Context, operator sdk.AccAddress, +) (types.Snapshot, bool) { + lastHeight := k.getOperatorLastSnapshotHeight(ctx, operator) + if lastHeight == 0 { + return types.Snapshot{}, false + } + return k.GetOperatorSnapshotAtHeight(ctx, operator, lastHeight) +} + +// GetOperatorSnapshotAtHeight returns the snapshot for an operator at a given height. +// If no snapshot exists at that height, an empty snapshot is returned. +func (k Keeper) GetOperatorSnapshotAtHeight( + ctx sdk.Context, operator sdk.AccAddress, height uint64, +) (types.Snapshot, bool) { + store := ctx.KVStore(k.storeKey) + val := store.Get(types.OperatorSnapshotKey(operator, height)) + if val == nil { + return types.Snapshot{}, false + } + var snapshot types.Snapshot + k.cdc.MustUnmarshal(val, &snapshot) + return snapshot, true +} + +// SetOperatorSnapshot stores a snapshot for an operator at the current height +func (k Keeper) setOperatorSnapshot( + ctx sdk.Context, operator sdk.AccAddress, snapshot types.Snapshot, +) { + store := ctx.KVStore(k.storeKey) + store.Set( + types.OperatorSnapshotKey(operator, uint64(ctx.BlockHeight())), + k.cdc.MustMarshal(&snapshot), + ) + k.updateOperatorLastSnapshotHeight(ctx, operator) +} + +// How is a slashing request sent to the coordinator? +// The subscriber chain finds the id of the val set update +// corresponding to the infraction height on the subcriber. +// It then sends a slashing request to the coordinator with +// the val set update id and the infraction type. +// The coordinator then finds the Exocore height for which +// the val set update was broadcasted to the subscriber. +// It then loads the operator snapshot at that height and +// calculates the amount to slash. +// The amount that is liable to be slashed is the amount +// that was delegated to the operator at the infraction height. +// It will be burnt from either the current amount that is pending +// undelegation first (since we keep it pending for exactly situations +// like these), and then the delegation (which will happen if there +// were no undelegations). If the operator is slashed multiple times +// for the same infraction height, it may happen that both the +// amounts run out. + +func (k Keeper) UpdateAndStoreSnapshotForDelegation( + ctx sdk.Context, operator sdk.AccAddress, assetId string, + stakerId string, changeAmount sdkmath.Int, +) { + snapshot, _ := k.getOperatorLastSnapshot(ctx, operator) + snapshot.UpdateForDelegation(assetId, stakerId, changeAmount) + k.setOperatorSnapshot(ctx, operator, snapshot) +} + +func (k Keeper) UpdateAndStoreSnapshotForUndelegation( + ctx sdk.Context, operator sdk.AccAddress, assetId string, + stakerId string, changeAmount sdkmath.Int, +) { + snapshot, found := k.getOperatorLastSnapshot(ctx, operator) + if !found { + panic("snapshot not found, cnanot update for undelegation") + } + snapshot.UpdateForUndelegation(assetId, stakerId, changeAmount) + k.setOperatorSnapshot(ctx, operator, snapshot) +} diff --git a/x/restaking_assets_manage/types/errors.go b/x/restaking_assets_manage/types/errors.go index a06935983..9fabf86d2 100644 --- a/x/restaking_assets_manage/types/errors.go +++ b/x/restaking_assets_manage/types/errors.go @@ -23,5 +23,5 @@ var ( ErrOperatorAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid acc addr") - ErrNoKeyInTheStore = errorsmod.Register(ModuleName, 9, "there is not the key for in the store") + ErrNoAppChainKey = errorsmod.Register(ModuleName, 10, "there is no stored key for the input app chain id") ) diff --git a/x/restaking_assets_manage/types/genesis.pb.go b/x/restaking_assets_manage/types/genesis.pb.go index 5a1be6790..a5ba32306 100644 --- a/x/restaking_assets_manage/types/genesis.pb.go +++ b/x/restaking_assets_manage/types/genesis.pb.go @@ -85,7 +85,7 @@ func init() { } var fileDescriptor_554af23024865cd5 = []byte{ - // 257 bytes of a gzipped FileDescriptorProto + // 268 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x29, 0x8e, 0xcf, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, @@ -97,12 +97,12 @@ var fileDescriptor_554af23024865cd5 = []byte{ 0x53, 0xf3, 0x4a, 0x9c, 0x33, 0x12, 0x33, 0xf3, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x8c, 0xf5, 0x08, 0x3b, 0x4f, 0x0f, 0x49, 0x9f, 0x67, 0x5e, 0x5a, 0x7e, 0x10, 0x5e, 0x83, 0x85, 0xda, 0x18, 0xb9, 0x14, 0xf1, 0x28, 0x08, 0xc9, 0xcf, 0x4e, 0xcd, 0x2b, 0x96, 0x60, 0x02, 0x5b, - 0x6f, 0x41, 0xa2, 0xf5, 0x60, 0xcd, 0x60, 0x37, 0x10, 0xb6, 0xc2, 0xc9, 0xe7, 0xc4, 0x23, 0x39, + 0x6f, 0x41, 0xa2, 0xf5, 0x60, 0xcd, 0x60, 0x37, 0x10, 0xb6, 0xc2, 0x29, 0xfa, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, - 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x8c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, - 0xf3, 0x73, 0xf5, 0x61, 0x81, 0x5c, 0x81, 0x33, 0x98, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, - 0xc0, 0xe1, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x50, 0x80, 0xbc, 0x7a, 0x02, 0x02, 0x00, - 0x00, + 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x1c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, + 0xf3, 0x73, 0xf5, 0x5d, 0x21, 0x0e, 0xf0, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x87, 0x85, + 0x79, 0x05, 0xce, 0x50, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x07, 0xbb, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x4a, 0xb7, 0xc1, 0xb1, 0x11, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/restaking_assets_manage/types/keys.go b/x/restaking_assets_manage/types/keys.go index b00558220..0c85fedc5 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/restaking_assets_manage/types/keys.go @@ -2,6 +2,7 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "strings" errorsmod "cosmossdk.io/errors" @@ -31,6 +32,7 @@ func init() { // prefix bytes for the reStaking assets manage store const ( prefixClientChainInfo = iota + 1 + prefixAppChainInfo prefixRestakingAssetInfo prefixRestakerAssetInfo prefixOperatorAssetInfo @@ -43,6 +45,10 @@ const ( prefixReStakingAssetList prefixReStakerAssetList prefixOperatorAssetList + + // add for dogfood + prefixOperatorSnapshot + prefixOperatorLastSnapshotHeight ) // KVStore key prefixes @@ -81,6 +87,8 @@ var ( // KeyPrefixClientChainInfo key->value: chainIndex->ClientChainInfo KeyPrefixClientChainInfo = []byte{prefixClientChainInfo} + KeyPrefixAppChainInfo = []byte{prefixAppChainInfo} + // KeyPrefixReStakingAssetInfo AssetId = AssetAddr+'_'+chainIndex // KeyPrefixReStakingAssetInfo key->value: AssetId->ReStakingAssetInfo KeyPrefixReStakingAssetInfo = []byte{prefixRestakingAssetInfo} @@ -94,10 +102,18 @@ var ( // or operatorAddr->mapping(AssetId->OperatorSingleAssetInfo) ? 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} - // KeyPrefixReStakerExoCoreAddrReverse k->v: exocoreAddress -> map[clientChainIndex]clientChainAddress + // KeyPrefixReStakerExoCoreAddrReverse k->v: exocoreAddress -> + // map[clientChainIndex]clientChainAddress // used to retrieve all user assets based on their exoCore address KeyPrefixReStakerExoCoreAddrReverse = []byte{prefixRestakerExocoreAddrReverse} ) @@ -118,3 +134,17 @@ func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { } return stringList, nil } + +// add for dogfood +func OperatorSnapshotKey(operatorAddr sdk.AccAddress, height uint64) []byte { + base := []byte{prefixOperatorSnapshot} + base = append(base, operatorAddr.Bytes()...) + base = append(base, sdk.Uint64ToBigEndian(height)...) + return base +} + +func OperatorLastSnapshotHeightKey(operatorAddr sdk.AccAddress) []byte { + base := []byte{prefixOperatorLastSnapshotHeight} + base = append(base, operatorAddr.Bytes()...) + return base +} diff --git a/x/restaking_assets_manage/types/query.pb.go b/x/restaking_assets_manage/types/query.pb.go index bad8dd2db..b4947c222 100644 --- a/x/restaking_assets_manage/types/query.pb.go +++ b/x/restaking_assets_manage/types/query.pb.go @@ -673,68 +673,68 @@ func init() { } var fileDescriptor_6d13900d4f268106 = []byte{ - // 961 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4d, 0x4f, 0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x6e, 0x9d, 0xb4, - 0x8f, 0xa4, 0x1a, 0x69, 0x7a, 0x89, 0x3a, 0xb1, 0xa9, 0xac, 0x6e, 0x0b, 0xd3, 0xa3, 0x27, 0xd9, - 0x9f, 0xf3, 0xf5, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x6c, 0x77, 0x7b, 0x8b, 0x10, 0x00, - 0x00, + // 974 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xee, 0x64, 0x59, 0xd8, 0x9d, 0x45, 0x62, 0x35, 0x1b, 0x20, 0xf1, 0x2e, 0xa1, 0x58, 0x1c, + 0x2a, 0x10, 0xb6, 0x9a, 0x22, 0x48, 0x36, 0x54, 0x90, 0x9a, 0xa0, 0x6d, 0x0f, 0x5b, 0x9a, 0x20, + 0x55, 0x05, 0xa4, 0xc8, 0x4d, 0xa6, 0xae, 0x69, 0xe2, 0x49, 0x3d, 0x4e, 0x49, 0x54, 0x15, 0x55, + 0xbd, 0xc0, 0x09, 0x21, 0xf5, 0x06, 0x3f, 0x02, 0x0e, 0x1c, 0xf8, 0x09, 0x1c, 0x38, 0x14, 0x90, + 0x10, 0x47, 0x68, 0x11, 0x88, 0x3b, 0x3f, 0x00, 0x65, 0xc6, 0x5f, 0x71, 0xec, 0x74, 0xf2, 0x71, + 0xcb, 0xcc, 0xbc, 0x5f, 0xcf, 0xfb, 0x8c, 0xdf, 0x67, 0x02, 0x15, 0xdc, 0x23, 0x0d, 0x62, 0x63, + 0xd5, 0xc6, 0xd4, 0xd1, 0x0f, 0x4c, 0xcb, 0xa8, 0xeb, 0x94, 0x62, 0x87, 0xd6, 0xdb, 0xba, 0xa5, + 0x1b, 0x58, 0x3d, 0x5a, 0x56, 0x0f, 0xbb, 0xd8, 0xee, 0x2b, 0x1d, 0x9b, 0x38, 0x04, 0xc9, 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3, 0x8b, 0x13, 0x7e, 0xb2, 0x81, 0x0e, 0x8b, 0xdd, + 0xe6, 0xb1, 0x8f, 0x00, 0xf9, 0xfd, 0x00, 0x66, 0x05, 0x69, 0x13, 0xc1, 0x0c, 0x81, 0x50, 0x8f, + 0xbd, 0x67, 0xc7, 0xc9, 0xda, 0x47, 0x3f, 0x5e, 0xe6, 0xc0, 0xc5, 0x65, 0x0e, 0xfc, 0x71, 0x99, + 0x03, 0x5f, 0x5d, 0xe5, 0x16, 0x2e, 0xae, 0x72, 0x0b, 0xbf, 0x5f, 0xe5, 0x16, 0x3e, 0x2c, 0x1b, + 0xa6, 0xb3, 0xdf, 0xdd, 0x55, 0x1a, 0xa4, 0xad, 0x56, 0x78, 0xa2, 0xc7, 0xd8, 0xf9, 0x94, 0xd8, + 0x07, 0x7e, 0xde, 0x5e, 0x62, 0x66, 0xa7, 0xdf, 0xc1, 0x74, 0xf7, 0x49, 0xf6, 0x5f, 0x7d, 0xe5, + 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x28, 0x6e, 0xf4, 0xff, 0x9a, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/restaking_assets_manage/types/snapshot.go b/x/restaking_assets_manage/types/snapshot.go new file mode 100644 index 000000000..58d16d71a --- /dev/null +++ b/x/restaking_assets_manage/types/snapshot.go @@ -0,0 +1,45 @@ +package types + +import sdkmath "cosmossdk.io/math" + +func (m *Snapshot) UpdateForDelegation( + assetId string, + stakerId string, + changeAmount sdkmath.Int, +) { + // find the asset within the snapshot + perAssetId, ok := m.PerAssetId[assetId] + if !ok { + // if it doesn't exist, create one + perAssetId = SnapshotPerAssetId{} + } + perStaker, ok := perAssetId.PerStaker[stakerId] + if !ok { + // if it doesn't exist, create one + perStaker = SnapshotPerAssetIdPerStaker{} + } + perStaker.Delegated = perStaker.Delegated.Add(changeAmount) + // update the snapshot + perAssetId.PerStaker[stakerId] = perStaker + m.PerAssetId[assetId] = perAssetId +} + +// UpdateForUndelegation updates the snapshot for an undelegation +// it performs no error checking and assumes that the undelegation is valid +// and that the undelegation amount is not greater than the delegated amount +// if the amount undelegated is equal to the delegated amount, it performs clean up too +func (m *Snapshot) UpdateForUndelegation( + assetId string, stakerId string, + changeAmount sdkmath.Int, +) { + x := m.PerAssetId[assetId].PerStaker[stakerId] + x.Delegated = x.Delegated.Sub(changeAmount) + if x.Delegated.IsZero() { + delete(m.PerAssetId[assetId].PerStaker, stakerId) + if len(m.PerAssetId[assetId].PerStaker) == 0 { + delete(m.PerAssetId, assetId) + } + } else { + m.PerAssetId[assetId].PerStaker[stakerId] = x + } +} diff --git a/x/restaking_assets_manage/types/snapshot.pb.go b/x/restaking_assets_manage/types/snapshot.pb.go new file mode 100644 index 000000000..ac874bb87 --- /dev/null +++ b/x/restaking_assets_manage/types/snapshot.pb.go @@ -0,0 +1,913 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/restaking_assets_manage/v1/snapshot.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Snapshot stores the snapshot of an operator's delegations at a given height +type Snapshot struct { + // this is the value and the key is combination of operator address and height + PerAssetId map[string]SnapshotPerAssetId `protobuf:"bytes,1,rep,name=per_asset_id,json=perAssetId,proto3" json:"per_asset_id" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Snapshot) Reset() { *m = Snapshot{} } +func (m *Snapshot) String() string { return proto.CompactTextString(m) } +func (*Snapshot) ProtoMessage() {} +func (*Snapshot) Descriptor() ([]byte, []int) { + return fileDescriptor_6ea4a71796bc9de8, []int{0} +} +func (m *Snapshot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Snapshot.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 *Snapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_Snapshot.Merge(m, src) +} +func (m *Snapshot) XXX_Size() int { + return m.Size() +} +func (m *Snapshot) XXX_DiscardUnknown() { + xxx_messageInfo_Snapshot.DiscardUnknown(m) +} + +var xxx_messageInfo_Snapshot proto.InternalMessageInfo + +func (m *Snapshot) GetPerAssetId() map[string]SnapshotPerAssetId { + if m != nil { + return m.PerAssetId + } + return nil +} + +type SnapshotPerAssetId struct { + PerStaker map[string]SnapshotPerAssetIdPerStaker `protobuf:"bytes,1,rep,name=per_staker,json=perStaker,proto3" json:"per_staker" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *SnapshotPerAssetId) Reset() { *m = SnapshotPerAssetId{} } +func (m *SnapshotPerAssetId) String() string { return proto.CompactTextString(m) } +func (*SnapshotPerAssetId) ProtoMessage() {} +func (*SnapshotPerAssetId) Descriptor() ([]byte, []int) { + return fileDescriptor_6ea4a71796bc9de8, []int{1} +} +func (m *SnapshotPerAssetId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotPerAssetId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotPerAssetId.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 *SnapshotPerAssetId) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotPerAssetId.Merge(m, src) +} +func (m *SnapshotPerAssetId) XXX_Size() int { + return m.Size() +} +func (m *SnapshotPerAssetId) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotPerAssetId.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotPerAssetId proto.InternalMessageInfo + +func (m *SnapshotPerAssetId) GetPerStaker() map[string]SnapshotPerAssetIdPerStaker { + if m != nil { + return m.PerStaker + } + return nil +} + +type SnapshotPerAssetIdPerStaker struct { + Delegated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=delegated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"delegated"` +} + +func (m *SnapshotPerAssetIdPerStaker) Reset() { *m = SnapshotPerAssetIdPerStaker{} } +func (m *SnapshotPerAssetIdPerStaker) String() string { return proto.CompactTextString(m) } +func (*SnapshotPerAssetIdPerStaker) ProtoMessage() {} +func (*SnapshotPerAssetIdPerStaker) Descriptor() ([]byte, []int) { + return fileDescriptor_6ea4a71796bc9de8, []int{2} +} +func (m *SnapshotPerAssetIdPerStaker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotPerAssetIdPerStaker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotPerAssetIdPerStaker.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 *SnapshotPerAssetIdPerStaker) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotPerAssetIdPerStaker.Merge(m, src) +} +func (m *SnapshotPerAssetIdPerStaker) XXX_Size() int { + return m.Size() +} +func (m *SnapshotPerAssetIdPerStaker) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotPerAssetIdPerStaker.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotPerAssetIdPerStaker proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Snapshot)(nil), "exocore.restaking_assets_manage.v1.Snapshot") + proto.RegisterMapType((map[string]SnapshotPerAssetId)(nil), "exocore.restaking_assets_manage.v1.Snapshot.PerAssetIdEntry") + proto.RegisterType((*SnapshotPerAssetId)(nil), "exocore.restaking_assets_manage.v1.SnapshotPerAssetId") + proto.RegisterMapType((map[string]SnapshotPerAssetIdPerStaker)(nil), "exocore.restaking_assets_manage.v1.SnapshotPerAssetId.PerStakerEntry") + proto.RegisterType((*SnapshotPerAssetIdPerStaker)(nil), "exocore.restaking_assets_manage.v1.SnapshotPerAssetIdPerStaker") +} + +func init() { + proto.RegisterFile("exocore/restaking_assets_manage/v1/snapshot.proto", fileDescriptor_6ea4a71796bc9de8) +} + +var fileDescriptor_6ea4a71796bc9de8 = []byte{ + // 405 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4c, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x4f, 0x2c, + 0x2e, 0x4e, 0x2d, 0x29, 0x8e, 0xcf, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, + 0xce, 0x4b, 0x2c, 0x28, 0xce, 0xc8, 0x2f, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, + 0x6a, 0xd1, 0xc3, 0xa1, 0x45, 0xaf, 0xcc, 0x50, 0x4a, 0x32, 0x39, 0xbf, 0x38, 0x37, 0xbf, 0x38, + 0x1e, 0xac, 0x43, 0x1f, 0xc2, 0x81, 0x68, 0x97, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x87, 0x88, 0x83, + 0x58, 0x10, 0x51, 0xa5, 0xe7, 0x8c, 0x5c, 0x1c, 0xc1, 0x50, 0x7b, 0x84, 0x52, 0xb8, 0x78, 0x0a, + 0x52, 0x8b, 0x20, 0xa6, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xd9, 0xe8, + 0x11, 0xb6, 0x58, 0x0f, 0x66, 0x86, 0x5e, 0x40, 0x6a, 0x91, 0x23, 0x48, 0xd2, 0x33, 0xc5, 0x35, + 0xaf, 0xa4, 0xa8, 0xd2, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xae, 0x02, 0xb8, 0xb0, 0x54, + 0x29, 0x17, 0x3f, 0x9a, 0x22, 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0xce, 0x20, 0x10, 0x53, 0xc8, 0x87, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x49, + 0x81, 0x51, 0x83, 0xdb, 0xc8, 0x8c, 0x14, 0x37, 0x20, 0x4c, 0x0f, 0x82, 0x18, 0x62, 0xc5, 0x64, + 0xc1, 0xa8, 0xf4, 0x9f, 0x91, 0x4b, 0x08, 0x53, 0x85, 0x50, 0x16, 0x17, 0xc8, 0x6d, 0xf1, 0x20, + 0x43, 0x53, 0x8b, 0xa0, 0x3e, 0x76, 0x25, 0xcf, 0x36, 0x90, 0xdf, 0x83, 0xc1, 0xe6, 0x20, 0x7b, + 0x9d, 0xb3, 0x00, 0x26, 0x2a, 0x55, 0xcb, 0xc5, 0x87, 0xaa, 0x04, 0x8b, 0xc7, 0x43, 0x51, 0x3d, + 0x6e, 0x4f, 0x9e, 0x53, 0xe0, 0xd6, 0x20, 0x87, 0x40, 0x25, 0x97, 0x34, 0x1e, 0x95, 0x42, 0x51, + 0x5c, 0x9c, 0x29, 0xa9, 0x39, 0xa9, 0xe9, 0x89, 0x25, 0xa9, 0x29, 0x10, 0x17, 0x39, 0xd9, 0x80, + 0x7c, 0x70, 0xeb, 0x9e, 0xbc, 0x5a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, + 0x34, 0x51, 0x41, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0x3d, 0xcf, + 0xbc, 0x92, 0x4b, 0x5b, 0x74, 0xb9, 0xa0, 0x69, 0xce, 0x33, 0xaf, 0x24, 0x08, 0x61, 0x9c, 0x53, + 0xf4, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x39, 0x22, 0x19, 0xed, 0x0a, + 0xf1, 0xaa, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0x2c, 0x8b, 0x54, 0xe0, 0xcc, 0x24, + 0x60, 0x9b, 0x93, 0xd8, 0xc0, 0x49, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x84, 0x60, + 0x02, 0x54, 0x03, 0x00, 0x00, +} + +func (m *Snapshot) 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 *Snapshot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PerAssetId) > 0 { + for k := range m.PerAssetId { + v := m.PerAssetId[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintSnapshot(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintSnapshot(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *SnapshotPerAssetId) 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 *SnapshotPerAssetId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotPerAssetId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PerStaker) > 0 { + for k := range m.PerStaker { + v := m.PerStaker[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintSnapshot(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintSnapshot(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *SnapshotPerAssetIdPerStaker) 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 *SnapshotPerAssetIdPerStaker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotPerAssetIdPerStaker) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Delegated.Size() + i -= size + if _, err := m.Delegated.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { + offset -= sovSnapshot(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Snapshot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PerAssetId) > 0 { + for k, v := range m.PerAssetId { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovSnapshot(uint64(len(k))) + 1 + l + sovSnapshot(uint64(l)) + n += mapEntrySize + 1 + sovSnapshot(uint64(mapEntrySize)) + } + } + return n +} + +func (m *SnapshotPerAssetId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PerStaker) > 0 { + for k, v := range m.PerStaker { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovSnapshot(uint64(len(k))) + 1 + l + sovSnapshot(uint64(l)) + n += mapEntrySize + 1 + sovSnapshot(uint64(mapEntrySize)) + } + } + return n +} + +func (m *SnapshotPerAssetIdPerStaker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Delegated.Size() + n += 1 + l + sovSnapshot(uint64(l)) + return n +} + +func sovSnapshot(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSnapshot(x uint64) (n int) { + return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Snapshot) 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 ErrIntOverflowSnapshot + } + 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: Snapshot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PerAssetId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PerAssetId == nil { + m.PerAssetId = make(map[string]SnapshotPerAssetId) + } + var mapkey string + mapvalue := &SnapshotPerAssetId{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + 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 ErrIntOverflowSnapshot + } + 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 ErrInvalidLengthSnapshot + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthSnapshot + } + 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 ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthSnapshot + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &SnapshotPerAssetId{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.PerAssetId[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SnapshotPerAssetId) 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 ErrIntOverflowSnapshot + } + 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: SnapshotPerAssetId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotPerAssetId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PerStaker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PerStaker == nil { + m.PerStaker = make(map[string]SnapshotPerAssetIdPerStaker) + } + var mapkey string + mapvalue := &SnapshotPerAssetIdPerStaker{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + 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 ErrIntOverflowSnapshot + } + 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 ErrInvalidLengthSnapshot + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthSnapshot + } + 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 ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthSnapshot + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &SnapshotPerAssetIdPerStaker{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.PerStaker[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SnapshotPerAssetIdPerStaker) 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 ErrIntOverflowSnapshot + } + 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: SnapshotPerAssetIdPerStaker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotPerAssetIdPerStaker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Delegated", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + 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 ErrInvalidLengthSnapshot + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Delegated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSnapshot(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, ErrIntOverflowSnapshot + } + 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, ErrIntOverflowSnapshot + } + 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, ErrIntOverflowSnapshot + } + 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, ErrInvalidLengthSnapshot + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSnapshot + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSnapshot + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSnapshot = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index a937f5c46..6130ad0b4 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -169,6 +169,81 @@ func (m *ClientChainInfo) GetAddressLength() uint32 { return 0 } +// AppChainInfo is used to store information related to the subscriber app chains we validate. +// The information stored within this module consists only of the chain's identifiers. +// The validation-related information is stored in the coordinator module. +type AppChainInfo struct { + // the chain name, for example "ethereum" + ChainName string `protobuf:"bytes,1,opt,name=ChainName,proto3" json:"ChainName,omitempty"` + // any other meta info that is at Exocore's discretion to deter,ome + ChainMetaInfo string `protobuf:"bytes,2,opt,name=ChainMetaInfo,proto3" json:"ChainMetaInfo,omitempty"` + // the chain id which is used as the primary key + ChainId string `protobuf:"bytes,3,opt,name=ChainId,proto3" json:"ChainId,omitempty"` + // the index of the chain in exocore, so far unused + ExocoreChainIndex uint64 `protobuf:"varint,4,opt,name=ExocoreChainIndex,proto3" json:"ExocoreChainIndex,omitempty"` +} + +func (m *AppChainInfo) Reset() { *m = AppChainInfo{} } +func (m *AppChainInfo) String() string { return proto.CompactTextString(m) } +func (*AppChainInfo) ProtoMessage() {} +func (*AppChainInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b24e66e530cc30d1, []int{2} +} +func (m *AppChainInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AppChainInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AppChainInfo.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 *AppChainInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_AppChainInfo.Merge(m, src) +} +func (m *AppChainInfo) XXX_Size() int { + return m.Size() +} +func (m *AppChainInfo) XXX_DiscardUnknown() { + xxx_messageInfo_AppChainInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_AppChainInfo proto.InternalMessageInfo + +func (m *AppChainInfo) GetChainName() string { + if m != nil { + return m.ChainName + } + return "" +} + +func (m *AppChainInfo) GetChainMetaInfo() string { + if m != nil { + return m.ChainMetaInfo + } + return "" +} + +func (m *AppChainInfo) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *AppChainInfo) GetExocoreChainIndex() uint64 { + if m != nil { + return m.ExocoreChainIndex + } + return 0 +} + type ClientChainTokenInfo struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Symbol string `protobuf:"bytes,2,opt,name=Symbol,proto3" json:"Symbol,omitempty"` @@ -184,7 +259,7 @@ func (m *ClientChainTokenInfo) Reset() { *m = ClientChainTokenInfo{} } func (m *ClientChainTokenInfo) String() string { return proto.CompactTextString(m) } func (*ClientChainTokenInfo) ProtoMessage() {} func (*ClientChainTokenInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{2} + return fileDescriptor_b24e66e530cc30d1, []int{3} } func (m *ClientChainTokenInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -271,7 +346,7 @@ func (m *StakingAssetInfo) Reset() { *m = StakingAssetInfo{} } func (m *StakingAssetInfo) String() string { return proto.CompactTextString(m) } func (*StakingAssetInfo) ProtoMessage() {} func (*StakingAssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{3} + return fileDescriptor_b24e66e530cc30d1, []int{4} } func (m *StakingAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,7 +392,7 @@ func (m *StakerSingleAssetOrChangeInfo) Reset() { *m = StakerSingleAsset func (m *StakerSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } func (*StakerSingleAssetOrChangeInfo) ProtoMessage() {} func (*StakerSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{4} + return fileDescriptor_b24e66e530cc30d1, []int{5} } func (m *StakerSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -354,7 +429,7 @@ func (m *StakerAllAssetsInfo) Reset() { *m = StakerAllAssetsInfo{} } func (m *StakerAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*StakerAllAssetsInfo) ProtoMessage() {} func (*StakerAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{5} + return fileDescriptor_b24e66e530cc30d1, []int{6} } func (m *StakerAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -403,7 +478,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleA func (m *OperatorSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } func (*OperatorSingleAssetOrChangeInfo) ProtoMessage() {} func (*OperatorSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{6} + return fileDescriptor_b24e66e530cc30d1, []int{7} } func (m *OperatorSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -440,7 +515,7 @@ func (m *OperatorAllAssetsInfo) Reset() { *m = OperatorAllAssetsInfo{} } func (m *OperatorAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*OperatorAllAssetsInfo) ProtoMessage() {} func (*OperatorAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{7} + return fileDescriptor_b24e66e530cc30d1, []int{8} } func (m *OperatorAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -488,7 +563,7 @@ func (m *MsgSetExoCoreAddr) Reset() { *m = MsgSetExoCoreAddr{} } func (m *MsgSetExoCoreAddr) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddr) ProtoMessage() {} func (*MsgSetExoCoreAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{8} + return fileDescriptor_b24e66e530cc30d1, []int{9} } func (m *MsgSetExoCoreAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -524,7 +599,7 @@ func (m *MsgSetExoCoreAddrResponse) Reset() { *m = MsgSetExoCoreAddrResp func (m *MsgSetExoCoreAddrResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddrResponse) ProtoMessage() {} func (*MsgSetExoCoreAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{9} + return fileDescriptor_b24e66e530cc30d1, []int{10} } func (m *MsgSetExoCoreAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -556,6 +631,7 @@ var xxx_messageInfo_MsgSetExoCoreAddrResponse proto.InternalMessageInfo func init() { proto.RegisterType((*ValueField)(nil), "exocore.restaking_assets_manage.v1.ValueField") proto.RegisterType((*ClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainInfo") + proto.RegisterType((*AppChainInfo)(nil), "exocore.restaking_assets_manage.v1.AppChainInfo") proto.RegisterType((*ClientChainTokenInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainTokenInfo") proto.RegisterType((*StakingAssetInfo)(nil), "exocore.restaking_assets_manage.v1.StakingAssetInfo") proto.RegisterType((*StakerSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.StakerSingleAssetOrChangeInfo") @@ -573,74 +649,76 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1063 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0xcf, 0x6b, 0x1b, 0xc7, - 0x17, 0xd7, 0x4a, 0xfe, 0xf9, 0x8c, 0x13, 0x7b, 0xe2, 0x6f, 0xbe, 0xb2, 0x9a, 0xca, 0x66, 0x1b, - 0x8a, 0x71, 0x6b, 0x89, 0xa8, 0x34, 0x18, 0xd3, 0x16, 0x64, 0x39, 0x01, 0x53, 0x3b, 0x82, 0x5d, - 0xb7, 0xa6, 0x39, 0xd4, 0x1d, 0x49, 0xe3, 0xd5, 0xa2, 0xdd, 0x19, 0xb1, 0x33, 0x72, 0xa4, 0x5b, - 0x28, 0xa1, 0x94, 0x52, 0x4a, 0x7a, 0xea, 0xa1, 0x97, 0xfc, 0x09, 0x3e, 0xe4, 0x8f, 0xc8, 0x31, - 0xf8, 0xd2, 0xb4, 0x94, 0x50, 0xec, 0x83, 0xfb, 0x67, 0x94, 0x9d, 0xd9, 0xb5, 0x57, 0x96, 0x14, - 0x6f, 0x1a, 0x05, 0x7a, 0xb1, 0x77, 0xde, 0xef, 0xfd, 0xbc, 0xf7, 0x19, 0xbd, 0x85, 0x0f, 0x48, - 0x9b, 0x55, 0x99, 0x47, 0xf2, 0x1e, 0xe1, 0x02, 0x37, 0x6c, 0x6a, 0xed, 0x61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ed, 0x81, 0xdf, - 0x72, 0x92, 0xb2, 0x95, 0x31, 0xf9, 0x2d, 0xf5, 0xd1, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4a, - 0x0e, 0xe2, 0x5e, 0xfb, 0x0d, 0x00, 0x00, + // 1094 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0xda, 0xcd, 0xd7, 0x1b, 0xd2, 0x26, 0xd3, 0x50, 0x1c, 0x53, 0x9c, 0x68, 0xa9, 0x50, + 0x14, 0x88, 0xad, 0x06, 0x51, 0x45, 0x11, 0x20, 0x39, 0x4e, 0x2b, 0x45, 0x34, 0x89, 0xb4, 0x0e, + 0x44, 0x14, 0x89, 0x30, 0xb6, 0x27, 0xeb, 0x95, 0x77, 0x67, 0xac, 0x9d, 0x71, 0x12, 0xdf, 0x2a, + 0x54, 0x21, 0x84, 0x10, 0x2a, 0x27, 0x24, 0xb8, 0xf4, 0x27, 0xe4, 0xd0, 0x1f, 0xd1, 0x63, 0x95, + 0x0b, 0x05, 0xa1, 0x0a, 0x25, 0x87, 0xf0, 0x33, 0xd0, 0xce, 0x8c, 0x93, 0xdd, 0xd8, 0x6e, 0xb6, + 0xd4, 0x95, 0xb8, 0x24, 0x3b, 0xcf, 0xfb, 0xf5, 0xec, 0xfb, 0x31, 0x7e, 0x17, 0xde, 0x27, 0xfb, + 0xac, 0xc2, 0x7c, 0x92, 0xf7, 0x09, 0x17, 0xb8, 0xee, 0x50, 0x7b, 0x1b, 0x73, 0x4e, 0x04, 0xdf, + 0xf6, 0x30, 0xc5, 0x36, 0xc9, 0xef, 0xde, 0xcc, 0x8b, 0xfd, 0x5c, 0xc3, 0x67, 0x82, 0x21, 0x53, + 0x2b, 0xe7, 0x7a, 0x28, 0xe7, 0x76, 0x6f, 0x66, 0xde, 0xaa, 0x30, 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0xa8, 0x7b, 0x70, 0x05, 0x9c, 0x96, 0x68, 0x58, + 0x95, 0x28, 0x02, 0x9a, 0x47, 0x06, 0x8c, 0x97, 0xd4, 0x8d, 0x21, 0x05, 0x32, 0xad, 0xdf, 0xc0, + 0x65, 0x79, 0x58, 0xc6, 0xdc, 0xa9, 0x48, 0xdb, 0x20, 0xc1, 0xa3, 0x0b, 0x8b, 0xb9, 0x8b, 0xaf, + 0x99, 0x5c, 0xb7, 0x42, 0x59, 0xe7, 0xfc, 0x21, 0x17, 0x90, 0x8e, 0x2a, 0x93, 0xa1, 0x2f, 0x8b, + 0x64, 0x1f, 0xb2, 0xdb, 0xc5, 0xaf, 0x79, 0x98, 0x82, 0x77, 0x02, 0x98, 0xf8, 0x25, 0x87, 0xda, + 0x2e, 0x91, 0x64, 0x36, 0xfc, 0x62, 0x0d, 0x53, 0x9b, 0x48, 0x3e, 0x3f, 0x19, 0xf0, 0xae, 0xb4, + 0x58, 0x21, 0x0d, 0xc6, 0x1d, 0xa1, 0x0c, 0x37, 0xfc, 0x2d, 0x2c, 0x5f, 0x85, 0xda, 0x44, 0xde, + 0x6e, 0x7d, 0xb9, 0xce, 0xe2, 0x04, 0x42, 0x3f, 0x1a, 0x60, 0x16, 0x31, 0xdd, 0x72, 0x44, 0xad, + 0xea, 0xe3, 0xbd, 0x5e, 0x7c, 0xfa, 0x91, 0xb1, 0x18, 0x71, 0xd0, 0x43, 0x03, 0x6e, 0x6c, 0x61, + 0x47, 0x7c, 0x4e, 0xcb, 0x8c, 0x56, 0x83, 0x66, 0xe9, 0x41, 0x28, 0xd5, 0x07, 0x42, 0xb1, 0x22, + 0x99, 0x3f, 0x27, 0xe1, 0xaa, 0x2a, 0x6a, 0xc1, 0x75, 0x65, 0x45, 0xb9, 0x2c, 0x25, 0x87, 0xcb, + 0xb8, 0x0d, 0x94, 0x04, 0x16, 0x41, 0xd1, 0x52, 0xb3, 0xa3, 0x0b, 0x9f, 0xc5, 0x69, 0xde, 0x2e, +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0x9d, 0x89, 0xfd, 0x9e, 0xdf, 0x9d, + 0x72, 0x82, 0xcb, 0x83, 0xf2, 0xbb, 0xef, 0xc3, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x41, + 0x7b, 0x3b, 0xa7, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -825,6 +903,55 @@ func (m *ClientChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AppChainInfo) 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 *AppChainInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AppChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExocoreChainIndex != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExocoreChainIndex)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChainMetaInfo) > 0 { + i -= len(m.ChainMetaInfo) + copy(dAtA[i:], m.ChainMetaInfo) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainMetaInfo))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainName) > 0 { + i -= len(m.ChainName) + copy(dAtA[i:], m.ChainName) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ClientChainTokenInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1307,6 +1434,30 @@ func (m *ClientChainInfo) Size() (n int) { return n } +func (m *AppChainInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainMetaInfo) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ExocoreChainIndex != 0 { + n += 1 + sovTx(uint64(m.ExocoreChainIndex)) + } + return n +} + func (m *ClientChainTokenInfo) Size() (n int) { if m == nil { return 0 @@ -1804,6 +1955,171 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } return nil } +func (m *AppChainInfo) 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 ErrIntOverflowTx + } + 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: AppChainInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AppChainInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainMetaInfo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainMetaInfo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreChainIndex", wireType) + } + m.ExocoreChainIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExocoreChainIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ClientChainTokenInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/reward/types/genesis.pb.go b/x/reward/types/genesis.pb.go index 49541e125..0d0363ec8 100644 --- a/x/reward/types/genesis.pb.go +++ b/x/reward/types/genesis.pb.go @@ -75,7 +75,7 @@ func init() { func init() { proto.RegisterFile("exocore/reward/genesis.proto", fileDescriptor_4ccfae99a1ae8f42) } var fileDescriptor_4ccfae99a1ae8f42 = []byte{ - // 183 bytes of a gzipped FileDescriptorProto + // 195 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xea, 0x41, 0x64, 0xa5, @@ -83,11 +83,12 @@ var fileDescriptor_4ccfae99a1ae8f42 = []byte{ 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x23, 0x94, 0x5c, 0xb8, 0x78, 0xdc, 0x21, 0x66, 0x06, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x99, 0x70, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0xc4, 0xf4, 0x50, 0xed, 0xd0, 0x0b, 0x00, 0xcb, 0x3a, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, - 0x55, 0xeb, 0x64, 0x7d, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, - 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x8a, 0xe9, - 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x30, 0x77, 0x54, 0xc0, 0x5c, 0x52, - 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x89, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xaa, - 0x1c, 0x4a, 0x98, 0xec, 0x00, 0x00, 0x00, + 0x55, 0xeb, 0xe4, 0x75, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, + 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x06, 0xe9, + 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xae, 0x10, 0x93, 0xfc, 0x52, 0x4b, + 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x61, 0xce, 0xaa, 0x80, 0x39, 0xac, 0xa4, 0xb2, 0x20, 0xb5, 0x38, + 0x89, 0x0d, 0xec, 0x30, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x52, 0x1d, 0xec, 0xf9, 0xfb, + 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/reward/types/params.pb.go b/x/reward/types/params.pb.go index 97fd90153..7ce7c11a7 100644 --- a/x/reward/types/params.pb.go +++ b/x/reward/types/params.pb.go @@ -83,7 +83,7 @@ func init() { func init() { proto.RegisterFile("exocore/reward/params.proto", fileDescriptor_1a29ebcfb63d5930) } var fileDescriptor_1a29ebcfb63d5930 = []byte{ - // 190 bytes of a gzipped FileDescriptorProto + // 201 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xea, 0x41, 0x24, 0xa5, 0x44, @@ -91,11 +91,12 @@ var fileDescriptor_1a29ebcfb63d5930 = []byte{ 0x58, 0x97, 0x90, 0x01, 0x97, 0x70, 0x6a, 0x45, 0xbe, 0x73, 0x7e, 0x51, 0xaa, 0x4f, 0x95, 0x63, 0x41, 0x81, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x36, 0x29, 0x21, 0x33, 0x2e, 0x31, 0x64, 0x61, 0xd7, 0xb2, 0xd4, 0xbc, 0x92, 0x90, 0xfc, 0x82, - 0xcc, 0x64, 0x09, 0x26, 0xb0, 0x26, 0x1c, 0xb2, 0x4e, 0xd6, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, + 0xcc, 0x64, 0x09, 0x26, 0xb0, 0x26, 0x1c, 0xb2, 0x4e, 0x5e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, - 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x98, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, - 0x0f, 0xf3, 0x5b, 0x05, 0xcc, 0x77, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x77, 0x1b, - 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x14, 0x22, 0xd5, 0x83, 0xfc, 0x00, 0x00, 0x00, + 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, + 0xef, 0x0a, 0x71, 0xbe, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xcc, 0xab, 0x15, 0x30, + 0xcf, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xbd, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, + 0xff, 0x73, 0x5a, 0x65, 0xb8, 0x0b, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/reward/types/query.pb.go b/x/reward/types/query.pb.go index 757219ea9..4e81c4f0e 100644 --- a/x/reward/types/query.pb.go +++ b/x/reward/types/query.pb.go @@ -121,25 +121,26 @@ func init() { func init() { proto.RegisterFile("exocore/reward/query.proto", fileDescriptor_03321eafc9126bed) } var fileDescriptor_03321eafc9126bed = []byte{ - // 282 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x31, 0x4b, 0xc4, 0x30, - 0x14, 0xc7, 0xaf, 0x82, 0x1d, 0x22, 0x38, 0xc4, 0xe3, 0x38, 0xaa, 0x04, 0xad, 0x8b, 0x38, 0x24, - 0xdc, 0x39, 0xba, 0x09, 0xee, 0xea, 0xe8, 0x96, 0xd6, 0x47, 0x2c, 0xd8, 0xbe, 0x34, 0x49, 0xf5, - 0xce, 0xd1, 0x4f, 0x20, 0xf8, 0xa5, 0x1c, 0x0f, 0x5c, 0x1c, 0xa5, 0xf5, 0x83, 0xc8, 0x35, 0x51, - 0xb8, 0x53, 0xdc, 0xca, 0xfb, 0xff, 0x7e, 0xff, 0xbe, 0x17, 0x92, 0xc0, 0x0c, 0x73, 0x34, 0x20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0x6e, 0xae, 0xc1, 0x66, 0x71, 0xff, 0x38, 0x27, 0x5f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xbc, 0x0b, 0xc2, 0xc5, 0xc7, 0x01, 0x00, 0x00, + // 292 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x41, 0x4b, 0xc3, 0x30, + 0x14, 0xc7, 0x57, 0xc1, 0x1d, 0x22, 0x78, 0x88, 0x63, 0x8c, 0x2a, 0x41, 0xea, 0x45, 0x3c, 0x24, + 0x6e, 0x7e, 0x03, 0x61, 0x17, 0x0f, 0xa2, 0x1e, 0xbd, 0xa5, 0xf3, 0x11, 0x8b, 0xb6, 0x2f, 0x4d, + 0x52, 0xb7, 0x79, 0xf4, 0x13, 0x08, 0x7e, 0x29, 0x8f, 0x03, 0x2f, 0x1e, 0xa5, 0xf5, 0x83, 0xc8, + 0x9a, 0x28, 0x6c, 0x8a, 0xb7, 0xf2, 0xfe, 0xbf, 0xff, 0xaf, 0xef, 0x85, 0xc4, 0x30, 0xc3, 0x09, + 0x1a, 0x10, 0x06, 0xa6, 0xd2, 0xdc, 0x88, 0xb2, 0x02, 0x33, 0xe7, 0xda, 0xa0, 0x43, 0xba, 0x1d, + 0x32, 0xee, 0xb3, 0xb8, 0xa7, 0x50, 0x61, 0x1b, 0x89, 0xe5, 0x97, 0xa7, 0xe2, 0x3d, 0x85, 0xa8, + 0xee, 0x41, 0x48, 0x9d, 0x09, 0x59, 0x14, 0xe8, 0xa4, 0xcb, 0xb0, 0xb0, 0x21, 0x3d, 0x9a, 0xa0, + 0xcd, 0xd1, 0x8a, 0x54, 0x5a, 0xf0, 0x72, 0xf1, 0x30, 0x4c, 0xc1, 0xc9, 0xa1, 0xd0, 0x52, 0x65, + 0x45, 0x0b, 0x07, 0x76, 0x77, 0x6d, 0x17, 0x2d, 0x8d, 0xcc, 0x83, 0x28, 0xe9, 0x11, 0x7a, 0xb9, + 0xac, 0x5f, 0xb4, 0xc3, 0x2b, 0x28, 0x2b, 0xb0, 0x2e, 0x19, 0x93, 0x9d, 0x95, 0xa9, 0xd5, 0x58, + 0x58, 0xa0, 0x9c, 0x74, 0x7d, 0x79, 0x10, 0xed, 0x47, 0x87, 0x5b, 0xa3, 0x3e, 0x5f, 0x3d, 0x85, + 0x07, 0x3e, 0x50, 0xa3, 0x47, 0xb2, 0xd9, 0x6a, 0x68, 0x49, 0xba, 0x3e, 0xa2, 0xc9, 0x7a, 0xe5, + 0xf7, 0xdf, 0xe3, 0x83, 0x7f, 0x19, 0xbf, 0x4b, 0xc2, 0x9e, 0xde, 0x3e, 0x5f, 0x36, 0x06, 0xb4, + 0x2f, 0xfe, 0x3c, 0xef, 0xf4, 0xec, 0xb5, 0x66, 0xd1, 0xa2, 0x66, 0xd1, 0x47, 0xcd, 0xa2, 0xe7, + 0x86, 0x75, 0x16, 0x0d, 0xeb, 0xbc, 0x37, 0xac, 0x73, 0x7d, 0xac, 0x32, 0x77, 0x5b, 0xa5, 0x7c, + 0x82, 0xb9, 0x18, 0xfb, 0xee, 0x39, 0xb8, 0x29, 0x9a, 0xbb, 0x1f, 0xd5, 0xec, 0x5b, 0xe6, 0xe6, + 0x1a, 0x6c, 0xda, 0x6d, 0xdf, 0xea, 0xe4, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x6d, 0xb6, 0xc4, + 0xd6, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/reward/types/tx.pb.go b/x/reward/types/tx.pb.go index cad854ffe..d3a6bd2bd 100644 --- a/x/reward/types/tx.pb.go +++ b/x/reward/types/tx.pb.go @@ -135,7 +135,7 @@ func init() { func init() { proto.RegisterFile("exocore/reward/tx.proto", fileDescriptor_9cd4863caedb1c8f) } var fileDescriptor_9cd4863caedb1c8f = []byte{ - // 319 bytes of a gzipped FileDescriptorProto + // 330 bytes of a gzipped FileDescriptorProto 0x1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, 0x44, - 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x99, 0x5a, 0x2d, 0x17, 0xfe, 0x01, 0x00, 0x00, + 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x06, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, + 0xb9, 0xfa, 0xae, 0x10, 0xc3, 0xfc, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x61, 0xc1, 0x5b, + 0x01, 0x8f, 0xee, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x00, 0x1b, 0x03, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x2a, 0x46, 0x9e, 0xfc, 0x0d, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/reward/types/types.pb.go b/x/reward/types/types.pb.go index cd276c0f6..bf693dde9 100644 --- a/x/reward/types/types.pb.go +++ b/x/reward/types/types.pb.go @@ -109,27 +109,27 @@ func init() { func init() { proto.RegisterFile("exocore/reward/types.proto", fileDescriptor_620cd6dbeff3c5e2) } var fileDescriptor_620cd6dbeff3c5e2 = []byte{ - // 310 bytes of a gzipped FileDescriptorProto + // 319 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x3d, 0x4e, 0xc3, 0x30, - 0x18, 0x8d, 0x4b, 0x29, 0xaa, 0x41, 0x0c, 0x16, 0x43, 0x09, 0x92, 0x5b, 0x98, 0xba, 0xd4, 0xa6, - 0x30, 0x32, 0x20, 0xc2, 0x01, 0x40, 0x19, 0x18, 0xd8, 0x9c, 0xc4, 0x2a, 0x11, 0x4d, 0xbe, 0xca, - 0x0e, 0xa5, 0xdc, 0x82, 0x89, 0x43, 0x70, 0x06, 0x0e, 0x90, 0xb1, 0x23, 0x53, 0x81, 0xe4, 0x16, - 0x4c, 0xc8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00, } func (m *Pool) Marshal() (dAtA []byte, err error) { diff --git a/x/slash/types/genesis.pb.go b/x/slash/types/genesis.pb.go index 9a7a24c54..ab8531252 100644 --- a/x/slash/types/genesis.pb.go +++ b/x/slash/types/genesis.pb.go @@ -75,7 +75,7 @@ func init() { func init() { proto.RegisterFile("exocore/slash/genesis.proto", fileDescriptor_0800c20695e285d5) } var fileDescriptor_0800c20695e285d5 = []byte{ - // 182 bytes of a gzipped FileDescriptorProto + // 194 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xce, 0x49, 0x2c, 0xce, 0xd0, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0x4a, 0xea, 0x81, 0x25, 0xa5, 0x44, @@ -83,11 +83,12 @@ var fileDescriptor_0800c20695e285d5 = []byte{ 0x89, 0x45, 0x89, 0xb9, 0x50, 0x03, 0x94, 0x9c, 0xb9, 0x78, 0xdc, 0x21, 0x26, 0x06, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x19, 0x73, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf5, 0x50, 0x6c, 0xd0, 0x0b, 0x00, 0x4b, 0x3a, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, - 0xea, 0x64, 0x75, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, - 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x0a, 0xe9, 0x99, - 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x30, 0x57, 0x54, 0x40, 0xdd, 0x51, 0x52, - 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x87, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xed, 0x5d, - 0x06, 0xc1, 0xe7, 0x00, 0x00, 0x00, + 0xea, 0xe4, 0x79, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xfa, 0xe9, 0x99, + 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xae, 0x10, 0x83, 0xfc, 0x52, 0x4b, 0xca, + 0xf3, 0x8b, 0xb2, 0xf5, 0x61, 0x8e, 0xaa, 0x80, 0x3a, 0xab, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, + 0x0d, 0xec, 0x2c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xab, 0xe9, 0x4d, 0xf6, 0x00, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/slash/types/params.pb.go b/x/slash/types/params.pb.go index ae4924f09..dbded7051 100644 --- a/x/slash/types/params.pb.go +++ b/x/slash/types/params.pb.go @@ -83,7 +83,7 @@ func init() { func init() { proto.RegisterFile("exocore/slash/params.proto", fileDescriptor_a98d46ef8bcc0f8a) } var fileDescriptor_a98d46ef8bcc0f8a = []byte{ - // 189 bytes of a gzipped FileDescriptorProto + // 200 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xce, 0x49, 0x2c, 0xce, 0xd0, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0xca, 0xe9, 0x81, 0xe5, 0xa4, 0x44, 0xd2, @@ -91,11 +91,12 @@ var fileDescriptor_a98d46ef8bcc0f8a = []byte{ 0x93, 0x90, 0x01, 0x97, 0x70, 0x6a, 0x45, 0xbe, 0x73, 0x7e, 0x51, 0xaa, 0x4f, 0x95, 0x63, 0x41, 0x81, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x36, 0x29, 0x21, 0x33, 0x2e, 0x31, 0x64, 0x61, 0xd7, 0xb2, 0xd4, 0xbc, 0x92, 0x90, 0xfc, 0x82, 0xcc, - 0x64, 0x09, 0x26, 0xb0, 0x26, 0x1c, 0xb2, 0x4e, 0x56, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, + 0x64, 0x09, 0x26, 0xb0, 0x26, 0x1c, 0xb2, 0x4e, 0x9e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, - 0x2c, 0xc7, 0x10, 0xa5, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, - 0xf3, 0x59, 0x05, 0xd4, 0x6f, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x67, 0x1b, 0x03, - 0x02, 0x00, 0x00, 0xff, 0xff, 0xff, 0x5f, 0xa7, 0x41, 0xf9, 0x00, 0x00, 0x00, + 0x2c, 0xc7, 0x10, 0xa5, 0x9f, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, + 0x0a, 0x71, 0xbd, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xcc, 0xa3, 0x15, 0x50, 0xaf, + 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x7d, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0x6f, 0x99, 0x26, 0xee, 0x08, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/slash/types/query.pb.go b/x/slash/types/query.pb.go index 8dd02aeb5..b79a22056 100644 --- a/x/slash/types/query.pb.go +++ b/x/slash/types/query.pb.go @@ -121,7 +121,7 @@ func init() { func init() { proto.RegisterFile("exocore/slash/query.proto", fileDescriptor_8cd6399098c1a574) } var fileDescriptor_8cd6399098c1a574 = []byte{ - // 267 bytes of a gzipped FileDescriptorProto + // 278 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xce, 0x49, 0x2c, 0xce, 0xd0, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0x4a, 0xe9, 0x81, 0xa5, 0xa4, 0x44, 0xd2, 0xf3, @@ -134,11 +134,12 @@ var fileDescriptor_8cd6399098c1a574 = []byte{ 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf5, 0x50, 0x5c, 0xae, 0x07, 0x55, 0x0e, 0x55, 0x64, 0x54, 0xce, 0xc5, 0x0a, 0x36, 0x45, 0x28, 0x8f, 0x8b, 0x0d, 0x22, 0x25, 0xa4, 0x88, 0xa6, 0x03, 0xd3, 0x6e, 0x29, 0x25, 0x7c, 0x4a, 0x20, 0x0e, 0x51, 0x92, 0x6d, 0xba, 0xfc, 0x64, 0x32, 0x93, - 0xb8, 0x90, 0xa8, 0x3e, 0x36, 0xaf, 0x39, 0x59, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, + 0xb8, 0x90, 0xa8, 0x3e, 0x36, 0xaf, 0x39, 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, - 0x1c, 0x43, 0x94, 0x42, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0x5c, 0x6b, - 0x05, 0x54, 0x73, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x5c, 0x8c, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x0b, 0x83, 0x1e, 0xa4, 0xb0, 0x01, 0x00, 0x00, + 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0xbe, 0x2b, + 0x44, 0xab, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0x36, 0xdc, 0xa4, 0x0a, 0xa8, 0x59, 0x25, 0x95, + 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x60, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x61, 0xd5, + 0xbc, 0x52, 0xbf, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/slash/types/tx.pb.go b/x/slash/types/tx.pb.go index ff08bd24e..89c83dc28 100644 --- a/x/slash/types/tx.pb.go +++ b/x/slash/types/tx.pb.go @@ -134,7 +134,7 @@ func init() { func init() { proto.RegisterFile("exocore/slash/tx.proto", fileDescriptor_6ec062c35f00efd9) } var fileDescriptor_6ec062c35f00efd9 = []byte{ - // 300 bytes of a gzipped FileDescriptorProto + // 311 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xce, 0x49, 0x2c, 0xce, 0xd0, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0x8a, 0xeb, 0x81, 0xc5, 0xa5, 0xa4, 0x50, 0x95, 0x15, 0x24, 0x16, @@ -149,11 +149,12 @@ var fileDescriptor_6ec062c35f00efd9 = []byte{ 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x52, 0x2b, 0xbe, 0xa6, 0xe7, 0x1b, 0xb4, 0x10, 0x86, 0x28, 0x49, 0x72, 0x89, 0xa3, 0xb9, 0x27, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x96, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x8c, 0x8b, 0x07, 0xc5, 0xb9, 0x72, 0x68, 0xd6, 0xa0, 0x69, - 0x97, 0x52, 0xc3, 0x2f, 0x0f, 0x33, 0xde, 0xc9, 0xea, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, + 0x97, 0x52, 0xc3, 0x2f, 0x0f, 0x33, 0xde, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, - 0xe5, 0x18, 0xa2, 0x14, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x61, - 0xb1, 0x52, 0x01, 0x8b, 0xbe, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x68, 0x1a, 0x03, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x90, 0x0f, 0xfa, 0xd8, 0xdc, 0x01, 0x00, 0x00, + 0xe5, 0x18, 0xa2, 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x5d, + 0x21, 0x66, 0xf9, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0xc3, 0x22, 0xa9, 0x02, 0x16, 0x9b, + 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0xc0, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x0e, + 0x3b, 0x4b, 0x60, 0xeb, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/withdraw/types/query.pb.go b/x/withdraw/types/query.pb.go index 6612c2109..0f71e5881 100644 --- a/x/withdraw/types/query.pb.go +++ b/x/withdraw/types/query.pb.go @@ -6,11 +6,11 @@ package types import ( context "context" fmt "fmt" + types "github.com/ExocoreNetwork/exocore/x/deposit/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" - types "github.com/ExocoreNetwork/exocore/x/deposit/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -122,26 +122,27 @@ func init() { func init() { proto.RegisterFile("exocore/withdraw/query.proto", fileDescriptor_59bca5e59812c328) } var fileDescriptor_59bca5e59812c328 = []byte{ - // 300 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xb1, 0x4e, 0xc3, 0x30, - 0x18, 0x84, 0x6b,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, 0x21, 0xeb, 0x3c, 0x1d, 0x19, - 0x3d, 0x22, 0xbc, 0xdf, 0x66, 0x91, 0x0a, 0x0f, 0xbd, 0x46, 0x4e, 0xd8, 0xdf, 0x25, 0xd8, 0x6e, - 0x89, 0xe0, 0xf4, 0x1f, 0xca, 0x97, 0x9a, 0x4d, 0x9f, 0xde, 0x3e, 0x5f, 0xf6, 0x02, 0x32, 0xe6, - 0x3b, 0xe3, 0xfb, 0x0a, 0x57, 0x97, 0xaf, 0x35, 0x45, 0x9b, 0x9a, 0xa2, 0x8f, 0x9a, 0xa2, 0xe7, - 0x86, 0x0e, 0x36, 0x0d, 0x1d, 0xbc, 0x37, 0x74, 0x70, 0x7f, 0xac, 0xb4, 0x5b, 0x14, 0x31, 0x4b, - 0x20, 0xfd, 0x76, 0xaf, 0x7e, 0xfc, 0x6e, 0x6d, 0xa4, 0x8d, 0x87, 0xed, 0x52, 0x17, 0x5f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0xd4, 0x37, 0xe8, 0x06, 0xdd, 0x01, 0x00, 0x00, + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x31, 0x4b, 0x03, 0x31, + 0x14, 0xc7, 0x7b, 0x82, 0x1d, 0xe2, 0x22, 0xb1, 0x43, 0x39, 0x4a, 0x28, 0x45, 0x41, 0x1c, 0x12, + 0xee, 0xfc, 0x06, 0x82, 0x83, 0x20, 0xa2, 0x8e, 0x6e, 0xb9, 0xf6, 0x91, 0x06, 0xed, 0xbd, 0x34, + 0x49, 0x7b, 0xed, 0x26, 0x7e, 0x02, 0xc1, 0x2f, 0xe5, 0x58, 0x70, 0x71, 0x94, 0x9e, 0x1f, 0x44, + 0x7a, 0xb9, 0x53, 0xb4, 0x83, 0x5b, 0x78, 0xff, 0xdf, 0xfb, 0xf1, 0xcf, 0x23, 0x3d, 0x58, 0xe0, + 0x10, 0x2d, 0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 0x25, 0x6b, 0xdd, 0xa5, 0x4a, 0xfb, 0xf1, 0x2c, + 0xe3, 0x43, 0x9c, 0x88, 0xf3, 0xb0, 0x7d, 0x05, 0xbe, 0x40, 0x7b, 0xff, 0x2d, 0x5b, 0xfc, 0xe8, + 0xfc, 0xd2, 0x80, 0xcb, 0xda, 0xd5, 0xe1, 0x4e, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xea, 0xd2, + 0x25, 0x41, 0xec, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/withdraw/types/tx.pb.go b/x/withdraw/types/tx.pb.go index 552be4574..b7af85d30 100644 --- a/x/withdraw/types/tx.pb.go +++ b/x/withdraw/types/tx.pb.go @@ -6,13 +6,13 @@ package types import ( context "context" fmt "fmt" + types "github.com/ExocoreNetwork/exocore/x/deposit/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - types "github.com/ExocoreNetwork/exocore/x/deposit/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -136,7 +136,7 @@ func init() { func init() { proto.RegisterFile("exocore/withdraw/tx.proto", fileDescriptor_9fa45fb8759a8d92) } var fileDescriptor_9fa45fb8759a8d92 = []byte{ - // 337 bytes of a gzipped FileDescriptorProto + // 348 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xcf, 0x2c, 0xc9, 0x48, 0x29, 0x4a, 0x2c, 0xd7, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x4a, 0xe9, 0xc1, 0xa4, 0xa4, 0xc4, 0x93, 0xf3, @@ -153,12 +153,12 @@ var fileDescriptor_9fa45fb8759a8d92 = []byte{ 0xaa, 0xde, 0x8a, 0xaf, 0xe9, 0xf9, 0x06, 0x2d, 0x84, 0x49, 0x4a, 0x92, 0x5c, 0xe2, 0x68, 0x8e, 0x0a, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0xca, 0xe2, 0x62, 0xf6, 0x2d, 0x4e, 0x17, 0x8a, 0xe1, 0xe2, 0x41, 0x71, 0xb3, 0xa2, 0x1e, 0x7a, 0xc8, 0xea, 0xa1, 0x99, 0x20, 0xa5, 0x49, - 0x50, 0x09, 0xcc, 0x12, 0x29, 0xd6, 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0x6c, 0x4f, 0x3c, 0x92, + 0x50, 0x09, 0xcc, 0x12, 0x29, 0xd6, 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, - 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x39, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, - 0x39, 0x3f, 0x57, 0x1f, 0x16, 0xc6, 0x15, 0x48, 0xf1, 0x5d, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, - 0x0e, 0x62, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb3, 0xf5, 0xde, 0xf5, 0x10, 0x02, 0x00, - 0x00, + 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, + 0x39, 0x3f, 0x57, 0xdf, 0x15, 0x62, 0xaa, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0x2c, + 0xc8, 0x2b, 0x90, 0xa2, 0xbf, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0xe2, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xbb, 0x4a, 0x31, 0x2f, 0x1f, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From 3fd0dbf892bb76ae7ac4b41b3ff664e223a462be Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 27 Feb 2024 13:09:52 +0800 Subject: [PATCH 27/44] correct the dependency in x/operator/keeper/utils_test.go --- x/operator/keeper/utils_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x/operator/keeper/utils_test.go b/x/operator/keeper/utils_test.go index be31f2e10..f8b0243f7 100644 --- a/x/operator/keeper/utils_test.go +++ b/x/operator/keeper/utils_test.go @@ -6,9 +6,11 @@ import ( "golang.org/x/exp/rand" "time" - "github.com/exocore/testutil" - testutiltx "github.com/exocore/testutil/tx" + "github.com/ExocoreNetwork/exocore/testutil" + testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" + exocoreapp "github.com/ExocoreNetwork/exocore/app" + "github.com/ExocoreNetwork/exocore/utils" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/tmhash" tmtypes "github.com/cometbft/cometbft/types" @@ -28,8 +30,6 @@ import ( "github.com/evmos/evmos/v14/x/evm/statedb" evmtypes "github.com/evmos/evmos/v14/x/evm/types" inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" - evmosapp "github.com/exocore/app" - "github.com/exocore/utils" ) // SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts @@ -38,8 +38,8 @@ import ( // account. A Nop logger is set in SimApp. func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, &pruneOpts, false)() - app, ok := appI.(*evmosapp.ExocoreApp) + appI, genesisState := exocoreapp.SetupTestingApp(cmn.DefaultChainID, &pruneOpts, false)() + app, ok := appI.(*exocoreapp.ExocoreApp) suite.Require().True(ok) // set genesis accounts @@ -106,7 +106,7 @@ func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSe abci.RequestInitChain{ ChainId: cmn.DefaultChainID, Validators: []abci.ValidatorUpdate{}, - ConsensusParams: evmosapp.DefaultConsensusParams, + ConsensusParams: exocoreapp.DefaultConsensusParams, AppStateBytes: stateBytes, }, ) From 3da8cba888fa4c632ecf70c1388afa1b1cfe790e Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 27 Feb 2024 14:51:15 +0800 Subject: [PATCH 28/44] delete snapshot and refine some code about operator module --- .../restaking_assets_manage/v1/snapshot.proto | 26 - x/delegation/keeper/cross_chain_tx_process.go | 6 +- x/operator/types/expected_for_dogfood.go | 40 - x/operator/types/expected_keepers.go | 37 + .../types/{hooks_for_dogfood.go => hooks.go} | 0 x/restaking_assets_manage/keeper/snapshot.go | 110 --- x/restaking_assets_manage/types/snapshot.go | 45 - .../types/snapshot.pb.go | 913 ------------------ 8 files changed, 39 insertions(+), 1138 deletions(-) delete mode 100644 proto/exocore/restaking_assets_manage/v1/snapshot.proto delete mode 100644 x/operator/types/expected_for_dogfood.go rename x/operator/types/{hooks_for_dogfood.go => hooks.go} (100%) delete mode 100644 x/restaking_assets_manage/keeper/snapshot.go delete mode 100644 x/restaking_assets_manage/types/snapshot.go delete mode 100644 x/restaking_assets_manage/types/snapshot.pb.go diff --git a/proto/exocore/restaking_assets_manage/v1/snapshot.proto b/proto/exocore/restaking_assets_manage/v1/snapshot.proto deleted file mode 100644 index fecd369bc..000000000 --- a/proto/exocore/restaking_assets_manage/v1/snapshot.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package exocore.restaking_assets_manage.v1; - -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; - -// Snapshot stores the snapshot of an operator's delegations at a given height -message Snapshot { - // this is the value and the key is combination of operator address and height - map per_asset_id = 1 [ (gogoproto.nullable) = false ]; -} - -message SnapshotPerAssetId { - map per_staker = 1 [ (gogoproto.nullable) = false ]; -} - -message SnapshotPerAssetIdPerStaker { - string delegated = 1 - [ - (cosmos_proto.scalar) = "cosmos.Int", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} \ No newline at end of file diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 7f3834b71..d8a7be8ca 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -172,8 +172,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return err } - // update the snapshot and call the hooks registered by the other modules - k.restakingStateKeeper.UpdateAndStoreSnapshotForDelegation(ctx, params.OperatorAddress, assetId, stakerId, params.OpAmount) + // call the hooks registered by the other modules k.Hooks().AfterDelegation(ctx, params.OperatorAddress) return nil } @@ -254,8 +253,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio return err } - // update the snapshot and call the hooks registered by the other modules - k.restakingStateKeeper.UpdateAndStoreSnapshotForUndelegation(ctx, params.OperatorAddress, assetId, stakerId, params.OpAmount) + // call the hooks registered by the other modules k.Hooks().AfterUndelegationStarted(ctx, params.OperatorAddress, delegationtype.GetUndelegationRecordKey(r.LzTxNonce, r.TxHash, r.OperatorAddr)) return nil } diff --git a/x/operator/types/expected_for_dogfood.go b/x/operator/types/expected_for_dogfood.go deleted file mode 100644 index fc9d88171..000000000 --- a/x/operator/types/expected_for_dogfood.go +++ /dev/null @@ -1,40 +0,0 @@ -package types - -import ( - tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type SlashKeeper interface { - IsOperatorFrozen(ctx sdk.Context, addr sdk.AccAddress) bool -} - -type RedelegationKeeper interface { - AppChainInfoIsExist(ctx sdk.Context, chainId string) bool -} - -type OperatorConsentHooks interface { - // This hook is called when an operator opts in to a chain. - AfterOperatorOptIn( - ctx sdk.Context, - addr sdk.AccAddress, - chainId string, - pubKey tmprotocrypto.PublicKey, - ) - // This hook is called when an operator's consensus key is replaced for - // a chain. - AfterOperatorKeyReplacement( - ctx sdk.Context, - addr sdk.AccAddress, - oldKey tmprotocrypto.PublicKey, - newKey tmprotocrypto.PublicKey, - chainId string, - ) - // This hook is called when an operator opts out of a chain. - AfterOperatorOptOutInitiated( - ctx sdk.Context, - addr sdk.AccAddress, - chainId string, - key tmprotocrypto.PublicKey, - ) -} diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index ac938d377..571251880 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdkmath "cosmossdk.io/math" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -60,3 +61,39 @@ type ExpectAvsInterface interface { GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) } + +// add for dogfood + +type SlashKeeper interface { + IsOperatorFrozen(ctx sdk.Context, addr sdk.AccAddress) bool +} + +type RedelegationKeeper interface { + AppChainInfoIsExist(ctx sdk.Context, chainId string) bool +} + +type OperatorConsentHooks interface { + // This hook is called when an operator opts in to a chain. + AfterOperatorOptIn( + ctx sdk.Context, + addr sdk.AccAddress, + chainId string, + pubKey tmprotocrypto.PublicKey, + ) + // This hook is called when an operator's consensus key is replaced for + // a chain. + AfterOperatorKeyReplacement( + ctx sdk.Context, + addr sdk.AccAddress, + oldKey tmprotocrypto.PublicKey, + newKey tmprotocrypto.PublicKey, + chainId string, + ) + // This hook is called when an operator opts out of a chain. + AfterOperatorOptOutInitiated( + ctx sdk.Context, + addr sdk.AccAddress, + chainId string, + key tmprotocrypto.PublicKey, + ) +} diff --git a/x/operator/types/hooks_for_dogfood.go b/x/operator/types/hooks.go similarity index 100% rename from x/operator/types/hooks_for_dogfood.go rename to x/operator/types/hooks.go diff --git a/x/restaking_assets_manage/keeper/snapshot.go b/x/restaking_assets_manage/keeper/snapshot.go deleted file mode 100644 index c2a8d041b..000000000 --- a/x/restaking_assets_manage/keeper/snapshot.go +++ /dev/null @@ -1,110 +0,0 @@ -package keeper - -import ( - sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// we need to ensure that a snapshot exists for the block heights at which -// a delegation/undelegation happened. these are the heights at which -// the validator set update is broadcasted to the chain(s), and they -// therefore represent the mapped infraction heights. - -// updateOperatorLastSnapshotHeight stores the last snapshot height for an operator -// equal to the current block height. -func (k Keeper) updateOperatorLastSnapshotHeight( - ctx sdk.Context, operator sdk.AccAddress, -) { - store := ctx.KVStore(k.storeKey) - store.Set( - types.OperatorLastSnapshotHeightKey(operator), - sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight())), - ) -} - -// GetOperatorLastSnapshotHeight returns the last snapshot height for an operator -func (k Keeper) getOperatorLastSnapshotHeight( - ctx sdk.Context, operator sdk.AccAddress, -) uint64 { - store := ctx.KVStore(k.storeKey) - val := store.Get(types.OperatorLastSnapshotHeightKey(operator)) - return sdk.BigEndianToUint64(val) -} - -// GetOperatorLastSnapshot returns the last snapshot for an operator -func (k Keeper) getOperatorLastSnapshot( - ctx sdk.Context, operator sdk.AccAddress, -) (types.Snapshot, bool) { - lastHeight := k.getOperatorLastSnapshotHeight(ctx, operator) - if lastHeight == 0 { - return types.Snapshot{}, false - } - return k.GetOperatorSnapshotAtHeight(ctx, operator, lastHeight) -} - -// GetOperatorSnapshotAtHeight returns the snapshot for an operator at a given height. -// If no snapshot exists at that height, an empty snapshot is returned. -func (k Keeper) GetOperatorSnapshotAtHeight( - ctx sdk.Context, operator sdk.AccAddress, height uint64, -) (types.Snapshot, bool) { - store := ctx.KVStore(k.storeKey) - val := store.Get(types.OperatorSnapshotKey(operator, height)) - if val == nil { - return types.Snapshot{}, false - } - var snapshot types.Snapshot - k.cdc.MustUnmarshal(val, &snapshot) - return snapshot, true -} - -// SetOperatorSnapshot stores a snapshot for an operator at the current height -func (k Keeper) setOperatorSnapshot( - ctx sdk.Context, operator sdk.AccAddress, snapshot types.Snapshot, -) { - store := ctx.KVStore(k.storeKey) - store.Set( - types.OperatorSnapshotKey(operator, uint64(ctx.BlockHeight())), - k.cdc.MustMarshal(&snapshot), - ) - k.updateOperatorLastSnapshotHeight(ctx, operator) -} - -// How is a slashing request sent to the coordinator? -// The subscriber chain finds the id of the val set update -// corresponding to the infraction height on the subcriber. -// It then sends a slashing request to the coordinator with -// the val set update id and the infraction type. -// The coordinator then finds the Exocore height for which -// the val set update was broadcasted to the subscriber. -// It then loads the operator snapshot at that height and -// calculates the amount to slash. -// The amount that is liable to be slashed is the amount -// that was delegated to the operator at the infraction height. -// It will be burnt from either the current amount that is pending -// undelegation first (since we keep it pending for exactly situations -// like these), and then the delegation (which will happen if there -// were no undelegations). If the operator is slashed multiple times -// for the same infraction height, it may happen that both the -// amounts run out. - -func (k Keeper) UpdateAndStoreSnapshotForDelegation( - ctx sdk.Context, operator sdk.AccAddress, assetId string, - stakerId string, changeAmount sdkmath.Int, -) { - snapshot, _ := k.getOperatorLastSnapshot(ctx, operator) - snapshot.UpdateForDelegation(assetId, stakerId, changeAmount) - k.setOperatorSnapshot(ctx, operator, snapshot) -} - -func (k Keeper) UpdateAndStoreSnapshotForUndelegation( - ctx sdk.Context, operator sdk.AccAddress, assetId string, - stakerId string, changeAmount sdkmath.Int, -) { - snapshot, found := k.getOperatorLastSnapshot(ctx, operator) - if !found { - panic("snapshot not found, cnanot update for undelegation") - } - snapshot.UpdateForUndelegation(assetId, stakerId, changeAmount) - k.setOperatorSnapshot(ctx, operator, snapshot) -} diff --git a/x/restaking_assets_manage/types/snapshot.go b/x/restaking_assets_manage/types/snapshot.go deleted file mode 100644 index 58d16d71a..000000000 --- a/x/restaking_assets_manage/types/snapshot.go +++ /dev/null @@ -1,45 +0,0 @@ -package types - -import sdkmath "cosmossdk.io/math" - -func (m *Snapshot) UpdateForDelegation( - assetId string, - stakerId string, - changeAmount sdkmath.Int, -) { - // find the asset within the snapshot - perAssetId, ok := m.PerAssetId[assetId] - if !ok { - // if it doesn't exist, create one - perAssetId = SnapshotPerAssetId{} - } - perStaker, ok := perAssetId.PerStaker[stakerId] - if !ok { - // if it doesn't exist, create one - perStaker = SnapshotPerAssetIdPerStaker{} - } - perStaker.Delegated = perStaker.Delegated.Add(changeAmount) - // update the snapshot - perAssetId.PerStaker[stakerId] = perStaker - m.PerAssetId[assetId] = perAssetId -} - -// UpdateForUndelegation updates the snapshot for an undelegation -// it performs no error checking and assumes that the undelegation is valid -// and that the undelegation amount is not greater than the delegated amount -// if the amount undelegated is equal to the delegated amount, it performs clean up too -func (m *Snapshot) UpdateForUndelegation( - assetId string, stakerId string, - changeAmount sdkmath.Int, -) { - x := m.PerAssetId[assetId].PerStaker[stakerId] - x.Delegated = x.Delegated.Sub(changeAmount) - if x.Delegated.IsZero() { - delete(m.PerAssetId[assetId].PerStaker, stakerId) - if len(m.PerAssetId[assetId].PerStaker) == 0 { - delete(m.PerAssetId, assetId) - } - } else { - m.PerAssetId[assetId].PerStaker[stakerId] = x - } -} diff --git a/x/restaking_assets_manage/types/snapshot.pb.go b/x/restaking_assets_manage/types/snapshot.pb.go deleted file mode 100644 index ac874bb87..000000000 --- a/x/restaking_assets_manage/types/snapshot.pb.go +++ /dev/null @@ -1,913 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/restaking_assets_manage/v1/snapshot.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - 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 - -// Snapshot stores the snapshot of an operator's delegations at a given height -type Snapshot struct { - // this is the value and the key is combination of operator address and height - PerAssetId map[string]SnapshotPerAssetId `protobuf:"bytes,1,rep,name=per_asset_id,json=perAssetId,proto3" json:"per_asset_id" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *Snapshot) Reset() { *m = Snapshot{} } -func (m *Snapshot) String() string { return proto.CompactTextString(m) } -func (*Snapshot) ProtoMessage() {} -func (*Snapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_6ea4a71796bc9de8, []int{0} -} -func (m *Snapshot) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Snapshot.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 *Snapshot) XXX_Merge(src proto.Message) { - xxx_messageInfo_Snapshot.Merge(m, src) -} -func (m *Snapshot) XXX_Size() int { - return m.Size() -} -func (m *Snapshot) XXX_DiscardUnknown() { - xxx_messageInfo_Snapshot.DiscardUnknown(m) -} - -var xxx_messageInfo_Snapshot proto.InternalMessageInfo - -func (m *Snapshot) GetPerAssetId() map[string]SnapshotPerAssetId { - if m != nil { - return m.PerAssetId - } - return nil -} - -type SnapshotPerAssetId struct { - PerStaker map[string]SnapshotPerAssetIdPerStaker `protobuf:"bytes,1,rep,name=per_staker,json=perStaker,proto3" json:"per_staker" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *SnapshotPerAssetId) Reset() { *m = SnapshotPerAssetId{} } -func (m *SnapshotPerAssetId) String() string { return proto.CompactTextString(m) } -func (*SnapshotPerAssetId) ProtoMessage() {} -func (*SnapshotPerAssetId) Descriptor() ([]byte, []int) { - return fileDescriptor_6ea4a71796bc9de8, []int{1} -} -func (m *SnapshotPerAssetId) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotPerAssetId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotPerAssetId.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 *SnapshotPerAssetId) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotPerAssetId.Merge(m, src) -} -func (m *SnapshotPerAssetId) XXX_Size() int { - return m.Size() -} -func (m *SnapshotPerAssetId) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotPerAssetId.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotPerAssetId proto.InternalMessageInfo - -func (m *SnapshotPerAssetId) GetPerStaker() map[string]SnapshotPerAssetIdPerStaker { - if m != nil { - return m.PerStaker - } - return nil -} - -type SnapshotPerAssetIdPerStaker struct { - Delegated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=delegated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"delegated"` -} - -func (m *SnapshotPerAssetIdPerStaker) Reset() { *m = SnapshotPerAssetIdPerStaker{} } -func (m *SnapshotPerAssetIdPerStaker) String() string { return proto.CompactTextString(m) } -func (*SnapshotPerAssetIdPerStaker) ProtoMessage() {} -func (*SnapshotPerAssetIdPerStaker) Descriptor() ([]byte, []int) { - return fileDescriptor_6ea4a71796bc9de8, []int{2} -} -func (m *SnapshotPerAssetIdPerStaker) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotPerAssetIdPerStaker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotPerAssetIdPerStaker.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 *SnapshotPerAssetIdPerStaker) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotPerAssetIdPerStaker.Merge(m, src) -} -func (m *SnapshotPerAssetIdPerStaker) XXX_Size() int { - return m.Size() -} -func (m *SnapshotPerAssetIdPerStaker) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotPerAssetIdPerStaker.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotPerAssetIdPerStaker proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Snapshot)(nil), "exocore.restaking_assets_manage.v1.Snapshot") - proto.RegisterMapType((map[string]SnapshotPerAssetId)(nil), "exocore.restaking_assets_manage.v1.Snapshot.PerAssetIdEntry") - proto.RegisterType((*SnapshotPerAssetId)(nil), "exocore.restaking_assets_manage.v1.SnapshotPerAssetId") - proto.RegisterMapType((map[string]SnapshotPerAssetIdPerStaker)(nil), "exocore.restaking_assets_manage.v1.SnapshotPerAssetId.PerStakerEntry") - proto.RegisterType((*SnapshotPerAssetIdPerStaker)(nil), "exocore.restaking_assets_manage.v1.SnapshotPerAssetIdPerStaker") -} - -func init() { - proto.RegisterFile("exocore/restaking_assets_manage/v1/snapshot.proto", fileDescriptor_6ea4a71796bc9de8) -} - -var fileDescriptor_6ea4a71796bc9de8 = []byte{ - // 405 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4c, 0xad, 0xc8, 0x4f, - 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x4f, 0x2c, - 0x2e, 0x4e, 0x2d, 0x29, 0x8e, 0xcf, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, - 0xce, 0x4b, 0x2c, 0x28, 0xce, 0xc8, 0x2f, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, - 0x6a, 0xd1, 0xc3, 0xa1, 0x45, 0xaf, 0xcc, 0x50, 0x4a, 0x32, 0x39, 0xbf, 0x38, 0x37, 0xbf, 0x38, - 0x1e, 0xac, 0x43, 0x1f, 0xc2, 0x81, 0x68, 0x97, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x87, 0x88, 0x83, - 0x58, 0x10, 0x51, 0xa5, 0xe7, 0x8c, 0x5c, 0x1c, 0xc1, 0x50, 0x7b, 0x84, 0x52, 0xb8, 0x78, 0x0a, - 0x52, 0x8b, 0x20, 0xa6, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xd9, 0xe8, - 0x11, 0xb6, 0x58, 0x0f, 0x66, 0x86, 0x5e, 0x40, 0x6a, 0x91, 0x23, 0x48, 0xd2, 0x33, 0xc5, 0x35, - 0xaf, 0xa4, 0xa8, 0xd2, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xae, 0x02, 0xb8, 0xb0, 0x54, - 0x29, 0x17, 0x3f, 0x9a, 0x22, 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0x09, 0x46, 0x05, 0x46, - 0x0d, 0xce, 0x20, 0x10, 0x53, 0xc8, 0x87, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x49, - 0x81, 0x51, 0x83, 0xdb, 0xc8, 0x8c, 0x14, 0x37, 0x20, 0x4c, 0x0f, 0x82, 0x18, 0x62, 0xc5, 0x64, - 0xc1, 0xa8, 0xf4, 0x9f, 0x91, 0x4b, 0x08, 0x53, 0x85, 0x50, 0x16, 0x17, 0xc8, 0x6d, 0xf1, 0x20, - 0x43, 0x53, 0x8b, 0xa0, 0x3e, 0x76, 0x25, 0xcf, 0x36, 0x90, 0xdf, 0x83, 0xc1, 0xe6, 0x20, 0x7b, - 0x9d, 0xb3, 0x00, 0x26, 0x2a, 0x55, 0xcb, 0xc5, 0x87, 0xaa, 0x04, 0x8b, 0xc7, 0x43, 0x51, 0x3d, - 0x6e, 0x4f, 0x9e, 0x53, 0xe0, 0xd6, 0x20, 0x87, 0x40, 0x25, 0x97, 0x34, 0x1e, 0x95, 0x42, 0x51, - 0x5c, 0x9c, 0x29, 0xa9, 0x39, 0xa9, 0xe9, 0x89, 0x25, 0xa9, 0x29, 0x10, 0x17, 0x39, 0xd9, 0x80, - 0x7c, 0x70, 0xeb, 0x9e, 0xbc, 0x5a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, - 0x34, 0x51, 0x41, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0x3d, 0xcf, - 0xbc, 0x92, 0x4b, 0x5b, 0x74, 0xb9, 0xa0, 0x69, 0xce, 0x33, 0xaf, 0x24, 0x08, 0x61, 0x9c, 0x53, - 0xf4, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, - 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x39, 0x22, 0x19, 0xed, 0x0a, - 0xf1, 0xaa, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0x2c, 0x8b, 0x54, 0xe0, 0xcc, 0x24, - 0x60, 0x9b, 0x93, 0xd8, 0xc0, 0x49, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x84, 0x60, - 0x02, 0x54, 0x03, 0x00, 0x00, -} - -func (m *Snapshot) 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 *Snapshot) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PerAssetId) > 0 { - for k := range m.PerAssetId { - v := m.PerAssetId[k] - baseI := i - { - size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintSnapshot(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintSnapshot(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SnapshotPerAssetId) 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 *SnapshotPerAssetId) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotPerAssetId) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PerStaker) > 0 { - for k := range m.PerStaker { - v := m.PerStaker[k] - baseI := i - { - size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintSnapshot(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintSnapshot(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SnapshotPerAssetIdPerStaker) 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 *SnapshotPerAssetIdPerStaker) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotPerAssetIdPerStaker) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Delegated.Size() - i -= size - if _, err := m.Delegated.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { - offset -= sovSnapshot(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Snapshot) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PerAssetId) > 0 { - for k, v := range m.PerAssetId { - _ = k - _ = v - l = v.Size() - mapEntrySize := 1 + len(k) + sovSnapshot(uint64(len(k))) + 1 + l + sovSnapshot(uint64(l)) - n += mapEntrySize + 1 + sovSnapshot(uint64(mapEntrySize)) - } - } - return n -} - -func (m *SnapshotPerAssetId) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PerStaker) > 0 { - for k, v := range m.PerStaker { - _ = k - _ = v - l = v.Size() - mapEntrySize := 1 + len(k) + sovSnapshot(uint64(len(k))) + 1 + l + sovSnapshot(uint64(l)) - n += mapEntrySize + 1 + sovSnapshot(uint64(mapEntrySize)) - } - } - return n -} - -func (m *SnapshotPerAssetIdPerStaker) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Delegated.Size() - n += 1 + l + sovSnapshot(uint64(l)) - return n -} - -func sovSnapshot(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSnapshot(x uint64) (n int) { - return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Snapshot) 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 ErrIntOverflowSnapshot - } - 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: Snapshot: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PerAssetId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PerAssetId == nil { - m.PerAssetId = make(map[string]SnapshotPerAssetId) - } - var mapkey string - mapvalue := &SnapshotPerAssetId{} - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - 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 ErrIntOverflowSnapshot - } - 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 ErrInvalidLengthSnapshot - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthSnapshot - } - 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 ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthSnapshot - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &SnapshotPerAssetId{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.PerAssetId[mapkey] = *mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotPerAssetId) 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 ErrIntOverflowSnapshot - } - 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: SnapshotPerAssetId: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotPerAssetId: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PerStaker", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PerStaker == nil { - m.PerStaker = make(map[string]SnapshotPerAssetIdPerStaker) - } - var mapkey string - mapvalue := &SnapshotPerAssetIdPerStaker{} - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - 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 ErrIntOverflowSnapshot - } - 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 ErrInvalidLengthSnapshot - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthSnapshot - } - 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 ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthSnapshot - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &SnapshotPerAssetIdPerStaker{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.PerStaker[mapkey] = *mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotPerAssetIdPerStaker) 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 ErrIntOverflowSnapshot - } - 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: SnapshotPerAssetIdPerStaker: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotPerAssetIdPerStaker: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegated", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - 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 ErrInvalidLengthSnapshot - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Delegated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipSnapshot(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, ErrIntOverflowSnapshot - } - 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, ErrIntOverflowSnapshot - } - 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, ErrIntOverflowSnapshot - } - 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, ErrInvalidLengthSnapshot - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupSnapshot - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthSnapshot - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupSnapshot = fmt.Errorf("proto: unexpected end of group") -) From 383284974f5a7b5361e25a9fa769b2f302f37f15 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 28 Feb 2024 13:58:28 +0800 Subject: [PATCH 29/44] add unit test for slash in operator module --- go.mod | 2 +- go.sum | 2 -- x/operator/keeper/state_update_test.go | 13 ++++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8d69582df..4560dcb24 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e google.golang.org/grpc v1.57.0 + gopkg.in/yaml.v2 v2.4.0 sigs.k8s.io/yaml v1.3.0 ) @@ -204,7 +205,6 @@ require ( google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.7 // indirect pgregory.net/rapid v0.5.5 // indirect diff --git a/go.sum b/go.sum index d77fe7088..946fafbbc 100644 --- a/go.sum +++ b/go.sum @@ -809,8 +809,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= -github.com/evmos/cosmos-sdk v0.47.4-evmos.2 h1:bgKGJAeiTyEXLam+WCocIqOQk1pAJ1Bo3JPFG3FomX8= -github.com/evmos/cosmos-sdk v0.47.4-evmos.2/go.mod h1:R5n+uM7vguVPFap4pgkdvQCT1nVo/OtPwrlAU40rvok= github.com/evmos/go-ethereum v1.10.26-evmos-rc2 h1:tYghk1ZZ8X4/OQ4YI9hvtm8aSN8OSqO0g9vo/sCMdBo= github.com/evmos/go-ethereum v1.10.26-evmos-rc2/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index 7a96ae94c..906d029b5 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -216,10 +216,17 @@ func (suite *KeeperTestSuite) TestUpdateOptedInAssetsState() { suite.CheckState(expectedState) } -/*func (suite *KeeperTestSuite) TestSlash() { +func (suite *KeeperTestSuite) TestSlash() { suite.prepare() err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) optInHeight := suite.ctx.BlockHeight() - suite.NextBlock() -}*/ + + // run to the block at specified height + runToHeight := optInHeight + 10 + for i := optInHeight; i < runToHeight; i++ { + suite.NextBlock() + } + suite.Equal(runToHeight, suite.ctx.BlockHeight()) + +} From 7d8d25b61ea33ddcd48dcba48f46c978fbd12d05 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 28 Feb 2024 17:54:07 +0800 Subject: [PATCH 30/44] Test to see if the workflow for checking the PR will be activated. --- precompiles/deposit/deposit.go | 1 - 1 file changed, 1 deletion(-) diff --git a/precompiles/deposit/deposit.go b/precompiles/deposit/deposit.go index a178f1822..dc1272f0b 100644 --- a/precompiles/deposit/deposit.go +++ b/precompiles/deposit/deposit.go @@ -75,7 +75,6 @@ func (p Precompile) RequiredGas(input []byte) uint64 { // This should never happen since this method is going to fail during Run return 0 } - return p.Precompile.RequiredGas(input, p.IsTransaction(method.Name)) } From 97df83cb8e4f5ccd8a2c7c127be1b0119dbff12e Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Thu, 29 Feb 2024 17:44:35 +0800 Subject: [PATCH 31/44] refine the naming about stakerId assetId and clientChainId refine the test codes and make all unit tests pass delete the code related to setting ExoCoreLzAppAddress to fix the bug when set parameter use shared test utils to refine the test codes use shared test utils to refine the test codes fix the problem in tests caused by denom rename --- app/ethtest_helper.go | 2 +- app/export.go | 60 +- app/test_helpers.go | 8 +- go.mod | 2 + go.sum | 2 + precompiles/delegation/abi.json | 4 +- precompiles/delegation/delegation.sol | 8 +- precompiles/delegation/delegation_test.go | 134 ++-- precompiles/delegation/setup_test.go | 41 +- precompiles/delegation/types.go | 4 +- precompiles/delegation/utils_test.go | 197 ------ precompiles/deposit/abi.json | 2 +- precompiles/deposit/deposit.sol | 8 +- precompiles/deposit/deposit_integrate_test.go | 39 +- precompiles/deposit/deposit_test.go | 50 +- precompiles/deposit/setup_test.go | 38 +- precompiles/deposit/tx.go | 4 +- precompiles/deposit/types.go | 11 +- precompiles/deposit/utils_test.go | 220 ------- precompiles/reward/abi.json | 2 +- precompiles/reward/claimReward.sol | 4 +- precompiles/reward/methods.go | 4 +- precompiles/reward/parser.go | 4 +- precompiles/reward/reward_test.go | 50 +- precompiles/reward/setup_test.go | 39 +- precompiles/reward/utils_test.go | 231 ------- precompiles/slash/abi.json | 2 +- precompiles/slash/parser.go | 4 +- precompiles/slash/setup_test.go | 39 +- precompiles/slash/slash.sol | 4 +- precompiles/slash/slash_test.go | 50 +- precompiles/slash/utils_test.go | 231 ------- .../testutil/contracts/DepositCaller.json | 2 +- .../testutil/contracts/DepositCaller.sol | 20 +- precompiles/withdraw/abi.json | 2 +- precompiles/withdraw/methods.go | 4 +- precompiles/withdraw/parser.go | 4 +- precompiles/withdraw/setup_test.go | 39 +- precompiles/withdraw/utils_test.go | 232 ------- precompiles/withdraw/withdraw.sol | 4 +- .../withdraw/withdraw_integrate_test.go | 14 +- precompiles/withdraw/withdraw_test.go | 65 +- proto/exocore/delegation/v1/query.proto | 8 +- proto/exocore/delegation/v1/tx.proto | 6 +- proto/exocore/operator/v1/tx.proto | 2 +- .../restaking_assets_manage/v1/query.proto | 14 +- proto/exocore/withdraw/query.proto | 26 - proto/exocore/withdraw/tx.proto | 35 - testutil/abci.go | 32 +- testutil/ante.go | 2 +- testutil/contract.go | 16 +- testutil/fund.go | 6 +- testutil/integration.go | 12 +- testutil/network/network.go | 4 +- testutil/network/network_test.go | 4 +- testutil/staking-rewards.go | 10 +- testutil/tx/cosmos.go | 12 +- testutil/tx/eip712.go | 16 +- testutil/tx/eth.go | 16 +- .../keeper/utils_test.go => testutil/utils.go | 145 +++-- utils/utils.go | 6 +- utils/utils_test.go | 24 +- x/delegation/client/cli/query.go | 16 +- x/delegation/keeper/abci.go | 8 +- x/delegation/keeper/cross_chain_tx_process.go | 46 +- x/delegation/keeper/delegation_op_test.go | 124 ++-- x/delegation/keeper/delegation_state.go | 28 +- x/delegation/keeper/grpc_query.go | 4 +- x/delegation/keeper/keeper.go | 4 +- x/delegation/keeper/setup_test.go | 24 +- x/delegation/keeper/un_delegation_state.go | 14 +- x/delegation/keeper/utils_test.go | 44 -- x/delegation/types/expected_keepers.go | 6 +- x/delegation/types/keys.go | 22 +- x/delegation/types/query.pb.go | 156 ++--- x/delegation/types/tx.pb.go | 158 ++--- x/deposit/keeper/cross_chain_tx_process.go | 24 +- x/deposit/keeper/deposit_test.go | 20 +- x/deposit/keeper/params_test.go | 6 +- x/deposit/keeper/setup_test.go | 23 +- x/deposit/keeper/utils_test.go | 36 -- x/evm/types/params.go | 29 +- x/native_token/module.go | 6 +- x/native_token/types/keys.go | 4 +- x/operator/client/cli/tx.go | 4 +- x/operator/keeper/abci.go | 34 +- x/operator/keeper/avs_operator_shares.go | 30 +- x/operator/keeper/keeper.go | 2 +- x/operator/keeper/operator_info_test.go | 30 +- x/operator/keeper/operator_slash_state.go | 16 +- x/operator/keeper/setup_test.go | 48 +- x/operator/keeper/state_update.go | 102 +-- x/operator/keeper/state_update_test.go | 80 +-- x/operator/types/expected_keepers.go | 14 +- x/operator/types/keys.go | 10 +- x/operator/types/tx.pb.go | 120 ++-- x/restaking_assets_manage/client/cli/query.go | 40 +- .../keeper/client_chain_and_asset_test.go | 20 +- .../keeper/client_chain_asset.go | 22 +- .../keeper/exocore_addr.go | 2 +- .../keeper/grpc_query.go | 22 +- x/restaking_assets_manage/keeper/keeper.go | 16 +- .../keeper/operator_asset.go | 14 +- .../keeper/setup_test.go | 23 +- .../keeper/staker_asset.go | 16 +- .../keeper/staker_asset_test.go | 52 +- .../keeper/utils_test.go | 36 -- x/restaking_assets_manage/types/errors.go | 6 +- x/restaking_assets_manage/types/general.go | 24 +- x/restaking_assets_manage/types/keys.go | 22 +- x/restaking_assets_manage/types/query.pb.go | 240 +++---- .../types/query.pb.gw.go | 18 +- x/reward/keeper/claim_reward.go | 30 +- x/reward/keeper/claim_reward_test.go | 22 +- x/reward/keeper/params_test.go | 6 +- x/reward/keeper/setup_test.go | 23 +- x/reward/keeper/utils_test.go | 34 - x/slash/keeper/execute_slash.go | 34 +- x/slash/keeper/execute_slash_test.go | 30 +- x/slash/keeper/keeper.go | 2 +- x/slash/keeper/params_test.go | 6 +- x/slash/keeper/setup_test.go | 23 +- x/slash/keeper/utils_test.go | 34 - x/withdraw/client/cli/query.go | 2 +- x/withdraw/client/cli/query_params.go | 36 -- x/withdraw/client/cli/tx.go | 56 +- x/withdraw/keeper/claim_withdraw.go | 30 +- x/withdraw/keeper/claim_withdraw_test.go | 42 +- x/withdraw/keeper/msg_server.go | 20 - x/withdraw/keeper/params.go | 22 - x/withdraw/keeper/params_test.go | 18 - x/withdraw/keeper/query.go | 7 - x/withdraw/keeper/query_params.go | 19 - x/withdraw/keeper/setup_test.go | 24 +- x/withdraw/keeper/utils_test.go | 34 - x/withdraw/module.go | 32 +- x/withdraw/types/codec.go | 50 -- x/withdraw/types/genesis.go | 24 - x/withdraw/types/genesis.pb.go | 320 ---------- x/withdraw/types/genesis_test.go | 41 -- x/withdraw/types/msg.go | 27 - x/withdraw/types/params.go | 32 - x/withdraw/types/params.pb.go | 369 ----------- x/withdraw/types/query.pb.go | 546 ---------------- x/withdraw/types/query.pb.gw.go | 153 ----- x/withdraw/types/tx.pb.go | 596 ------------------ x/withdraw/types/types.go | 1 - 147 files changed, 1534 insertions(+), 5356 deletions(-) delete mode 100644 precompiles/delegation/utils_test.go delete mode 100644 precompiles/deposit/utils_test.go delete mode 100644 precompiles/reward/utils_test.go delete mode 100644 precompiles/slash/utils_test.go delete mode 100644 precompiles/withdraw/utils_test.go delete mode 100644 proto/exocore/withdraw/query.proto delete mode 100644 proto/exocore/withdraw/tx.proto rename x/operator/keeper/utils_test.go => testutil/utils.go (59%) delete mode 100644 x/delegation/keeper/utils_test.go delete mode 100644 x/deposit/keeper/utils_test.go delete mode 100644 x/restaking_assets_manage/keeper/utils_test.go delete mode 100644 x/reward/keeper/utils_test.go delete mode 100644 x/slash/keeper/utils_test.go delete mode 100644 x/withdraw/client/cli/query_params.go delete mode 100644 x/withdraw/keeper/msg_server.go delete mode 100644 x/withdraw/keeper/params_test.go delete mode 100644 x/withdraw/keeper/query.go delete mode 100644 x/withdraw/keeper/query_params.go delete mode 100644 x/withdraw/keeper/utils_test.go delete mode 100644 x/withdraw/types/codec.go delete mode 100644 x/withdraw/types/genesis.go delete mode 100644 x/withdraw/types/genesis.pb.go delete mode 100644 x/withdraw/types/genesis_test.go delete mode 100644 x/withdraw/types/msg.go delete mode 100644 x/withdraw/types/params.go delete mode 100644 x/withdraw/types/params.pb.go delete mode 100644 x/withdraw/types/query.pb.go delete mode 100644 x/withdraw/types/query.pb.gw.go delete mode 100644 x/withdraw/types/tx.pb.go delete mode 100644 x/withdraw/types/types.go diff --git a/app/ethtest_helper.go b/app/ethtest_helper.go index b0700ddf1..3c2599230 100644 --- a/app/ethtest_helper.go +++ b/app/ethtest_helper.go @@ -109,7 +109,7 @@ func NewTestGenesisState(codec codec.Codec) simapp.GenesisState { Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } - genesisState := NewDefaultGenesisState() + genesisState := NewDefaultGenesisState(codec) return genesisStateWithValSet(codec, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) } diff --git a/app/export.go b/app/export.go index 5cd4a8156..a31671f6a 100644 --- a/app/export.go +++ b/app/export.go @@ -1,25 +1,75 @@ package app import ( + "cosmossdk.io/simapp" "encoding/json" "fmt" - + "github.com/ExocoreNetwork/exocore/utils" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - - "cosmossdk.io/simapp" + "github.com/cosmos/cosmos-sdk/codec" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + claimstypes "github.com/evmos/evmos/v14/x/claims/types" + evmtypes "github.com/evmos/evmos/v14/x/evm/types" + inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" "github.com/evmos/evmos/v14/encoding" ) // NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState() simapp.GenesisState { +func NewDefaultGenesisState(cdc codec.Codec) simapp.GenesisState { encCfg := encoding.MakeConfig(ModuleBasics) - return ModuleBasics.DefaultGenesis(encCfg.Codec) + defaultGenesis := ModuleBasics.DefaultGenesis(encCfg.Codec) + + //staking module + stakingGenesis := stakingtypes.GenesisState{} + rawGenesis := defaultGenesis[stakingtypes.ModuleName] + cdc.MustUnmarshalJSON(rawGenesis, &stakingGenesis) + stakingGenesis.Params.BondDenom = utils.BaseDenom + defaultGenesis[stakingtypes.ModuleName] = cdc.MustMarshalJSON(&stakingGenesis) + + //crisis module + crisisGenesis := crisistypes.GenesisState{} + rawGenesis = defaultGenesis[crisistypes.ModuleName] + cdc.MustUnmarshalJSON(rawGenesis, &crisisGenesis) + crisisGenesis.ConstantFee.Denom = utils.BaseDenom + defaultGenesis[crisistypes.ModuleName] = cdc.MustMarshalJSON(&crisisGenesis) + + //gov module + govGenesis := govtypesv1.GenesisState{} + rawGenesis = defaultGenesis[govtypes.ModuleName] + cdc.MustUnmarshalJSON(rawGenesis, &govGenesis) + govGenesis.Params.MinDeposit[0].Denom = utils.BaseDenom + defaultGenesis[govtypes.ModuleName] = cdc.MustMarshalJSON(&govGenesis) + + //evm module + evmGenesis := evmtypes.GenesisState{} + rawGenesis = defaultGenesis[evmtypes.ModuleName] + cdc.MustUnmarshalJSON(rawGenesis, &evmGenesis) + evmGenesis.Params.EvmDenom = utils.BaseDenom + defaultGenesis[evmtypes.ModuleName] = cdc.MustMarshalJSON(&evmGenesis) + + //inflation module + inflationGenesis := inflationtypes.GenesisState{} + rawGenesis = defaultGenesis[inflationtypes.ModuleName] + cdc.MustUnmarshalJSON(rawGenesis, &inflationGenesis) + inflationGenesis.Params.MintDenom = utils.BaseDenom + defaultGenesis[inflationtypes.ModuleName] = cdc.MustMarshalJSON(&inflationGenesis) + + //claims module + claimsGenesis := claimstypes.GenesisState{} + rawGenesis = defaultGenesis[claimstypes.ModuleName] + cdc.MustUnmarshalJSON(rawGenesis, &claimsGenesis) + claimsGenesis.Params.ClaimsDenom = utils.BaseDenom + defaultGenesis[claimstypes.ModuleName] = cdc.MustMarshalJSON(&claimsGenesis) + + return defaultGenesis } // ExportAppStateAndValidators exports the state of the application for a genesis diff --git a/app/test_helpers.go b/app/test_helpers.go index 257b3b529..150ad9914 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -28,8 +28,8 @@ import ( "github.com/evmos/evmos/v14/encoding" feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/evmos/evmos/v14/cmd/config" - "github.com/evmos/evmos/v14/utils" + "github.com/ExocoreNetwork/exocore/cmd/config" + "github.com/ExocoreNetwork/exocore/utils" ) func init() { @@ -106,7 +106,7 @@ func Setup( ) if !isCheckTx { // init chain must be called to stop deliverState from being nil - genesisState := NewDefaultGenesisState() + genesisState := NewDefaultGenesisState(app.appCodec) genesisState = GenesisStateWithValSet(app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) // Verify feeMarket genesis @@ -223,6 +223,6 @@ func SetupTestingApp(chainID string, pruneOpts *pruningtypes.PruningOptions, isP simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), baseAppOptions[:]..., ) - return app, NewDefaultGenesisState() + return app, NewDefaultGenesisState(app.appCodec) } } diff --git a/go.mod b/go.mod index 4560dcb24..982337826 100644 --- a/go.mod +++ b/go.mod @@ -215,12 +215,14 @@ replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 // use Cosmos-SDK fork to enable Ledger functionality github.com/cosmos/cosmos-sdk => github.com/evmos/cosmos-sdk v0.47.4-evmos.2 + //github.com/cosmos/cosmos-sdk => ../cosmos-sdk //fix cosmos-sdk error github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10 // use Evmos geth fork github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 // use exocore fork of evmos github.com/evmos/evmos/v14 => github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240205024453-5e8090e42ef4 + //github.com/evmos/evmos/v14 => ../ExocoreNetwork/evmos // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 // replace broken goleveldb diff --git a/go.sum b/go.sum index 946fafbbc..d77fe7088 100644 --- a/go.sum +++ b/go.sum @@ -809,6 +809,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +github.com/evmos/cosmos-sdk v0.47.4-evmos.2 h1:bgKGJAeiTyEXLam+WCocIqOQk1pAJ1Bo3JPFG3FomX8= +github.com/evmos/cosmos-sdk v0.47.4-evmos.2/go.mod h1:R5n+uM7vguVPFap4pgkdvQCT1nVo/OtPwrlAU40rvok= github.com/evmos/go-ethereum v1.10.26-evmos-rc2 h1:tYghk1ZZ8X4/OQ4YI9hvtm8aSN8OSqO0g9vo/sCMdBo= github.com/evmos/go-ethereum v1.10.26-evmos-rc2/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= diff --git a/precompiles/delegation/abi.json b/precompiles/delegation/abi.json index 9231aef18..14575e108 100644 --- a/precompiles/delegation/abi.json +++ b/precompiles/delegation/abi.json @@ -4,7 +4,7 @@ [ { "internalType": "uint16", - "name": "clientChainLzId", + "name": "clientChainLzID", "type": "uint16" }, { @@ -50,7 +50,7 @@ [ { "internalType": "uint16", - "name": "clientChainLzId", + "name": "clientChainLzID", "type": "uint16" }, { diff --git a/precompiles/delegation/delegation.sol b/precompiles/delegation/delegation.sol index 08049d557..e15a99313 100644 --- a/precompiles/delegation/delegation.sol +++ b/precompiles/delegation/delegation.sol @@ -16,14 +16,14 @@ interface IDelegation { /// TRANSACTIONS /// @dev delegate the client chain assets to the operator through client chain, that will change the states in delegation and restaking_assets_manage module /// Note that this address cannot be a module account. -/// @param clientChainLzId The lzId of client chain +/// @param clientChainLzID The LzID of client chain /// @param lzNonce The cross chain tx layerZero nonce /// @param assetsAddress The client chain asset Address /// @param stakerAddress The staker address /// @param operatorAddr The operator address that wants to be delegated to /// @param opAmount The delegation amount function delegateToThroughClientChain( - uint16 clientChainLzId, + uint16 clientChainLzID, uint64 lzNonce, bytes memory assetsAddress, bytes memory stakerAddress, @@ -34,14 +34,14 @@ interface IDelegation { /// TRANSACTIONS /// @dev undelegate the client chain assets from the operator through client chain, that will change the states in delegation and restaking_assets_manage module /// Note that this address cannot be a module account. -/// @param clientChainLzId The lzId of client chain +/// @param clientChainLzID The LzID of client chain /// @param lzNonce The cross chain tx layerZero nonce /// @param assetsAddress The client chain asset Address /// @param stakerAddress The staker address /// @param operatorAddr The operator address that wants to unDelegate from /// @param opAmount The Undelegation amount function undelegateFromThroughClientChain( - uint16 clientChainLzId, + uint16 clientChainLzID, uint64 lzNonce, bytes memory assetsAddress, bytes memory stakerAddress, diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index e75dcb940..971941845 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -24,7 +24,7 @@ import ( evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) -func (s *PrecompileTestSuite) TestIsTransaction() { +func (s *DelegationPrecompileSuite) TestIsTransaction() { testCases := []struct { name string method string @@ -63,13 +63,13 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { } // TestRun tests DelegateToThroughClientChain method through calling Run function. -func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { +func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { // deposit params for test exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") - opAccAddr := "evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl" - clientChainLzId := 101 + opAccAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" + clientChainLzID := 101 lzNonce := 0 delegationAmount := big.NewInt(50) depositAmount := big.NewInt(100) @@ -78,13 +78,13 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for delegation test params := &keeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, } - err := s.app.DepositKeeper.Deposit(s.ctx, params) + err := s.App.DepositKeeper.Deposit(s.Ctx, params) s.Require().NoError(err) } registerOperator := func() { @@ -94,27 +94,27 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { EarningsAddr: opAccAddr, }, } - _, err := s.app.OperatorKeeper.RegisterOperator(s.ctx, registerReq) + _, err := s.App.OperatorKeeper.RegisterOperator(s.Ctx, registerReq) s.NoError(err) } commonMalleate := func() (common.Address, []byte) { // prepare the call input for delegation test - valAddr, err := sdk.ValAddressFromBech32(s.validators[0].OperatorAddress) + valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) s.Require().NoError(err) - val, _ := s.app.StakingKeeper.GetValidator(s.ctx, valAddr) + val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - s.app.DistrKeeper.AllocateTokensToValidator(s.ctx, val, sdk.NewDecCoinsFromCoins(coins...)) + s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( delegation.MethodDelegateToThroughClientChain, - uint16(clientChainLzId), + uint16(clientChainLzID), uint64(lzNonce), assetAddr, - paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), []byte(opAccAddr), delegationAmount, ) s.Require().NoError(err, "failed to pack input") - return s.address, input + return s.Address, input } successRet, err := s.precompile.Methods[delegation.MethodDelegateToThroughClientChain].Outputs.Pack(true) s.Require().NoError(err) @@ -143,7 +143,7 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { ExoCoreLzAppAddress: exoCoreLzAppAddress, ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -155,10 +155,10 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { name: "fail - delegateToThroughClientChain transaction will fail because the delegated operator hasn't been registered", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -170,10 +170,10 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { name: "fail - delegateToThroughClientChain transaction will fail because the delegated asset hasn't been deposited", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() return commonMalleate() @@ -186,13 +186,13 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { name: "fail - delegateToThroughClientChain transaction will fail because the delegation amount is bigger than the canWithdraw amount", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() - depositAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(smallDepositAmount)) + depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(smallDepositAmount)) return commonMalleate() }, readOnly: false, @@ -203,13 +203,13 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { name: "pass - delegateToThroughClientChain transaction", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() - depositAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) + depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) return commonMalleate() }, returnBytes: successRet, @@ -224,7 +224,7 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { // setup basic test suite s.SetupTest() - baseFee := s.app.FeeMarketKeeper.GetBaseFee(s.ctx) + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) // malleate testcase caller, input := tc.malleate() @@ -235,7 +235,7 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { contractAddr := contract.Address() // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ - ChainID: s.app.EvmKeeper.ChainID(), + ChainID: s.App.EvmKeeper.ChainID(), Nonce: 0, To: &contractAddr, Amount: nil, @@ -247,28 +247,28 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { } msgEthereumTx := evmtypes.NewTx(&txArgs) - msgEthereumTx.From = s.address.String() - err := msgEthereumTx.Sign(s.ethSigner, s.signer) + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) s.Require().NoError(err, "failed to sign Ethereum message") // Instantiate config - proposerAddress := s.ctx.BlockHeader().ProposerAddress - cfg, err := s.app.EvmKeeper.EVMConfig(s.ctx, proposerAddress, s.app.EvmKeeper.ChainID()) + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) s.Require().NoError(err, "failed to instantiate EVM config") - msg, err := msgEthereumTx.AsMessage(s.ethSigner, baseFee) + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) s.Require().NoError(err, "failed to instantiate Ethereum message") // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.StateDB = statedb.New(s.Ctx, s.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.Ctx.HeaderHash().Bytes()))) // Instantiate EVM - evm := s.app.EvmKeeper.NewEVM( - s.ctx, msg, cfg, nil, s.stateDB, + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, ) - params := s.app.EvmKeeper.GetParams(s.ctx) + params := s.App.EvmKeeper.GetParams(s.Ctx) activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := s.app.EvmKeeper.Precompiles(activePrecompiles...) + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) s.Require().NoError(err, "invalid precompiles", activePrecompiles) evm.WithPrecompiles(precompileMap, activePrecompiles) @@ -290,12 +290,12 @@ func (s *PrecompileTestSuite) TestRunDelegateToThroughClientChain() { } // TestRun tests DelegateToThroughClientChain method through calling Run function. -func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { +func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { // deposit params for test exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") - operatorAddr := "evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl" - clientChainLzId := 101 + operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" + clientChainLzID := 101 lzNonce := uint64(0) delegationAmount := big.NewInt(50) depositAmount := big.NewInt(100) @@ -303,20 +303,20 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for delegation test params := &keeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, } - err := s.app.DepositKeeper.Deposit(s.ctx, params) + err := s.App.DepositKeeper.Deposit(s.Ctx, params) s.Require().NoError(err) } delegateAsset := func(staker []byte, delegateAmount sdkmath.Int) { // deposit asset for delegation test delegateToParams := &keeper2.DelegationOrUndelegationParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.DelegateTo, StakerAddress: staker, AssetsAddress: usdtAddress, @@ -326,7 +326,7 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { opAccAddr, err := sdk.AccAddressFromBech32(operatorAddr) s.Require().NoError(err) delegateToParams.OperatorAddress = opAccAddr - err = s.app.DelegationKeeper.DelegateTo(s.ctx, delegateToParams) + err = s.App.DelegationKeeper.DelegateTo(s.Ctx, delegateToParams) s.Require().NoError(err) } registerOperator := func() { @@ -336,27 +336,27 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { EarningsAddr: operatorAddr, }, } - _, err := s.app.OperatorKeeper.RegisterOperator(s.ctx, registerReq) + _, err := s.App.OperatorKeeper.RegisterOperator(s.Ctx, registerReq) s.NoError(err) } commonMalleate := func() (common.Address, []byte) { // prepare the call input for delegation test - valAddr, err := sdk.ValAddressFromBech32(s.validators[0].OperatorAddress) + valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) s.Require().NoError(err) - val, _ := s.app.StakingKeeper.GetValidator(s.ctx, valAddr) + val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - s.app.DistrKeeper.AllocateTokensToValidator(s.ctx, val, sdk.NewDecCoinsFromCoins(coins...)) + s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( delegation.MethodUndelegateFromThroughClientChain, - uint16(clientChainLzId), + uint16(clientChainLzID), lzNonce+1, assetAddr, - paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), []byte(operatorAddr), delegationAmount, ) s.Require().NoError(err, "failed to pack input") - return s.address, input + return s.Address, input } successRet, err := s.precompile.Methods[delegation.MethodUndelegateFromThroughClientChain].Outputs.Pack(true) s.Require().NoError(err) @@ -373,14 +373,14 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { name: "pass - undelegateFromThroughClientChain transaction", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() - depositAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) - delegateAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(delegationAmount)) + depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) + delegateAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(delegationAmount)) return commonMalleate() }, returnBytes: successRet, @@ -394,7 +394,7 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { // setup basic test suite s.SetupTest() - baseFee := s.app.FeeMarketKeeper.GetBaseFee(s.ctx) + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) // malleate testcase caller, input := tc.malleate() @@ -405,7 +405,7 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { contractAddr := contract.Address() // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ - ChainID: s.app.EvmKeeper.ChainID(), + ChainID: s.App.EvmKeeper.ChainID(), Nonce: 0, To: &contractAddr, Amount: nil, @@ -417,29 +417,29 @@ func (s *PrecompileTestSuite) TestRunUnDelegateFromThroughClientChain() { } msgEthereumTx := evmtypes.NewTx(&txArgs) - msgEthereumTx.From = s.address.String() - err := msgEthereumTx.Sign(s.ethSigner, s.signer) + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) s.Require().NoError(err, "failed to sign Ethereum message") // Instantiate config - proposerAddress := s.ctx.BlockHeader().ProposerAddress - cfg, err := s.app.EvmKeeper.EVMConfig(s.ctx, proposerAddress, s.app.EvmKeeper.ChainID()) + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) s.Require().NoError(err, "failed to instantiate EVM config") - msg, err := msgEthereumTx.AsMessage(s.ethSigner, baseFee) + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) s.Require().NoError(err, "failed to instantiate Ethereum message") // set txHash for delegation module - s.ctx = s.ctx.WithValue(delegation.CtxKeyTxHash, common.HexToHash(msgEthereumTx.Hash)) + s.Ctx = s.Ctx.WithValue(delegation.CtxKeyTxHash, common.HexToHash(msgEthereumTx.Hash)) // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.StateDB = statedb.New(s.Ctx, s.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.Ctx.HeaderHash().Bytes()))) // Instantiate EVM - evm := s.app.EvmKeeper.NewEVM( - s.ctx, msg, cfg, nil, s.stateDB, + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, ) - params := s.app.EvmKeeper.GetParams(s.ctx) + params := s.App.EvmKeeper.GetParams(s.Ctx) activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := s.app.EvmKeeper.Precompiles(activePrecompiles...) + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) s.Require().NoError(err, "invalid precompiles", activePrecompiles) evm.WithPrecompiles(precompileMap, activePrecompiles) diff --git a/precompiles/delegation/setup_test.go b/precompiles/delegation/setup_test.go index 885171420..b5bec0e9b 100644 --- a/precompiles/delegation/setup_test.go +++ b/precompiles/delegation/setup_test.go @@ -1,50 +1,26 @@ package delegation_test import ( - "testing" - "github.com/ExocoreNetwork/exocore/precompiles/delegation" - - "github.com/evmos/evmos/v14/x/evm/statedb" + "github.com/ExocoreNetwork/exocore/testutil" + "testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - evmosapp "github.com/ExocoreNetwork/exocore/app" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" "github.com/stretchr/testify/suite" ) -var s *PrecompileTestSuite - -type PrecompileTestSuite struct { - suite.Suite +var s *DelegationPrecompileSuite - ctx sdk.Context - app *evmosapp.ExocoreApp - address common.Address - validators []stakingtypes.Validator - valSet *tmtypes.ValidatorSet - ethSigner ethtypes.Signer - privKey cryptotypes.PrivKey - signer keyring.Signer - bondDenom string +type DelegationPrecompileSuite struct { + testutil.BaseTestSuite precompile *delegation.Precompile - stateDB *statedb.StateDB - - queryClientEVM evmtypes.QueryClient } func TestPrecompileTestSuite(t *testing.T) { - s = new(PrecompileTestSuite) + s = new(DelegationPrecompileSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -52,6 +28,9 @@ func TestPrecompileTestSuite(t *testing.T) { RunSpecs(t, "Distribution Precompile Suite") } -func (s *PrecompileTestSuite) SetupTest() { +func (s *DelegationPrecompileSuite) SetupTest() { s.DoSetupTest() + precompile, err := delegation.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.DelegationKeeper, s.App.AuthzKeeper) + s.Require().NoError(err) + s.precompile = precompile } diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index c11559f59..b24010334 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -24,9 +24,9 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf if !ok { return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } - delegationParams.ClientChainLzId = uint64(clientChainLzID) + delegationParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, delegationParams.ClientChainLzId) + info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, delegationParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/delegation/utils_test.go b/precompiles/delegation/utils_test.go deleted file mode 100644 index a2151e074..000000000 --- a/precompiles/delegation/utils_test.go +++ /dev/null @@ -1,197 +0,0 @@ -package delegation_test - -import ( - "encoding/json" - "time" - - "github.com/ExocoreNetwork/exocore/precompiles/delegation" - "github.com/ExocoreNetwork/exocore/testutil" - testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" - - evmosapp "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/testutil/mock" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" - evmostypes "github.com/evmos/evmos/v14/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" -) - -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() - app, ok := appI.(*evmosapp.ExocoreApp) - s.Require().True(ok) - - // set genesis accounts - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) - delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - - bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) - - for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - s.Require().NoError(err) - pkAny, err := codectypes.NewAnyWithValue(pk) - s.Require().NoError(err) - validator := stakingtypes.Validator{ - OperatorAddress: sdk.ValAddress(val.Address).String(), - ConsensusPubkey: pkAny, - Jailed: false, - Status: stakingtypes.Bonded, - Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), - Description: stakingtypes.Description{}, - UnbondingHeight: int64(0), - UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), - } - validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - } - s.validators = validators - - // set validators and delegations - stakingParams := stakingtypes.DefaultParams() - // set bond demon to be aevmos - stakingParams.BondDenom = utils.BaseDenom - stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) - - totalBondAmt := bondAmt.Add(bondAmt) - totalSupply := sdk.NewCoins() - for _, b := range balances { - // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) - } - - // add bonded amount to bonded pool module account - balances = append(balances, banktypes.Balance{ - Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, - }) - - // update total supply - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) - - // init chain will set the validator set and initialize the genesis accounts - app.InitChain( - abci.RequestInitChain{ - ChainId: cmn.DefaultChainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: evmosapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - app.Commit() - - // instantiate new header - header := testutil.NewHeader( - 2, - time.Now().UTC(), - cmn.DefaultChainID, - sdk.ConsAddress(validators[0].GetOperator()), - tmhash.Sum([]byte("app")), - tmhash.Sum([]byte("validators")), - ) - - app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // create Context - s.ctx = app.BaseApp.NewContext(false, header) - s.app = app -} - -func (s *PrecompileTestSuite) DoSetupTest() { - // generate validator private/public key - privVal := mock.NewPV() - pubKey, err := privVal.GetPubKey() - s.Require().NoError(err) - - privVal2 := mock.NewPV() - pubKey2, err := privVal2.GetPubKey() - s.Require().NoError(err) - - // create validator set with two validators - validator := tmtypes.NewValidator(pubKey, 1) - validator2 := tmtypes.NewValidator(pubKey2, 2) - s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) - signers := make(map[string]tmtypes.PrivValidator) - signers[pubKey.Address().String()] = privVal - signers[pubKey2.Address().String()] = privVal2 - - // generate genesis account - addr, priv := testutiltx.NewAddrKey() - s.privKey = priv - s.address = addr - s.signer = testutiltx.NewSigner(priv) - - baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) - - acc := &evmostypes.EthAccount{ - BaseAccount: baseAcc, - CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), - } - - amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) - - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), - } - - s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) - - // bond denom - stakingParams := s.app.StakingKeeper.GetParams(s.ctx) - stakingParams.BondDenom = utils.BaseDenom - s.bondDenom = stakingParams.BondDenom - err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) - s.Require().NoError(err) - - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) - - precompile, err := delegation.NewPrecompile(s.app.StakingAssetsManageKeeper, s.app.DelegationKeeper, s.app.AuthzKeeper) - s.Require().NoError(err) - s.precompile = precompile - - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) - inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) - distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - s.Require().NoError(err) - - queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) - s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) -} diff --git a/precompiles/deposit/abi.json b/precompiles/deposit/abi.json index bf15e4d64..029092796 100644 --- a/precompiles/deposit/abi.json +++ b/precompiles/deposit/abi.json @@ -4,7 +4,7 @@ [ { "internalType": "uint16", - "name": "clientChainLzId", + "name": "clientChainLzID", "type": "uint16" }, { diff --git a/precompiles/deposit/deposit.sol b/precompiles/deposit/deposit.sol index f0d925add..3e6127166 100644 --- a/precompiles/deposit/deposit.sol +++ b/precompiles/deposit/deposit.sol @@ -1,6 +1,6 @@ pragma solidity >=0.8.17; -/// @dev The DEPOSIT contract's address. +/// @dev The DEPOSIT contract's.Address. address constant DEPOSIT_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000804; /// @dev The DEPOSIT contract's instance. @@ -15,13 +15,13 @@ IDeposit constant DEPOSIT_CONTRACT = IDeposit( interface IDeposit { /// TRANSACTIONS /// @dev deposit the client chain assets to the staker, that will change the state in deposit module -/// Note that this address cannot be a module account. -/// @param clientChainLzId The lzId of client chain +/// Note that this.Address cannot be a module account. +/// @param clientChainLzID The LzID of client chain /// @param assetsAddress The client chain asset Address /// @param stakerAddress The staker address /// @param opAmount The deposit amount function depositTo( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount diff --git a/precompiles/deposit/deposit_integrate_test.go b/precompiles/deposit/deposit_integrate_test.go index 41d29bee6..3515c5d84 100644 --- a/precompiles/deposit/deposit_integrate_test.go +++ b/precompiles/deposit/deposit_integrate_test.go @@ -26,7 +26,7 @@ var ( passCheck testutil.LogCheckArgs ) -func (s *PrecompileTestSuite) TestCallDepositToFromEOA() { +func (s *DepositPrecompileSuite) TestCallDepositToFromEOA() { // deposit params for test exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" @@ -35,8 +35,8 @@ func (s *PrecompileTestSuite) TestCallDepositToFromEOA() { ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) - clientChainLzId := 101 - stakerAddr := paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength) + clientChainLzID := 101 + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress method := "depositTo" @@ -47,7 +47,7 @@ func (s *PrecompileTestSuite) TestCallDepositToFromEOA() { defaultCallArgs = contracts.CallArgs{ ContractAddr: s.precompile.Address(), ContractABI: s.precompile.ABI, - PrivKey: s.privKey, + PrivKey: s.PrivKey, } defaultLogCheck = testutil.LogCheckArgs{ @@ -57,11 +57,11 @@ func (s *PrecompileTestSuite) TestCallDepositToFromEOA() { } prepareFunc := func(params *types3.Params, method string) contracts.CallArgs { - err := s.app.DepositKeeper.SetParams(s.ctx, params) + err := s.App.DepositKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) defaultDepositArgs := defaultCallArgs.WithMethodName(method) return defaultDepositArgs.WithArgs( - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, stakerAddr, opAmount) @@ -70,20 +70,20 @@ func (s *PrecompileTestSuite) TestCallDepositToFromEOA() { // test caller error beforeEach() setDepositToArgs := prepareFunc(&depositParams, method) - _, _, err := contracts.CallContractAndCheckLogs(s.ctx, s.app, setDepositToArgs, passCheck) + _, _, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) s.Require().ErrorContains(err, strings.Split(deposit.ErrContractCaller, ",")[0]) // test success beforeEach() - depositParams.ExoCoreLzAppAddress = s.address.String() + depositParams.ExoCoreLzAppAddress = s.Address.String() setDepositToArgs = prepareFunc(&depositParams, method) - _, ethRes, err := contracts.CallContractAndCheckLogs(s.ctx, s.app, setDepositToArgs, passCheck) + _, ethRes, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) successRet, err := s.precompile.Methods[deposit.MethodDepositTo].Outputs.Pack(true, opAmount) s.Require().NoError(err) s.Require().Equal(successRet, ethRes.Ret) } -func (s *PrecompileTestSuite) TestCallDepositToFromContract() { +func (s *DepositPrecompileSuite) TestCallDepositToFromContract() { // deposit params for test exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" @@ -92,8 +92,8 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) - clientChainLzId := 101 - stakerAddr := paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength) + clientChainLzID := 101 + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress @@ -107,8 +107,9 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { s.Require().NoError(err) // NextBlock the smart contract s.NextBlock() + // check contract was correctly deployed - cAcc := s.app.EvmKeeper.GetAccount(s.ctx, contractAddr) + cAcc := s.App.EvmKeeper.GetAccount(s.Ctx, contractAddr) s.Require().NotNil(cAcc) s.Require().True(cAcc.IsContract()) @@ -118,7 +119,7 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { defaultCallArgs = contracts.CallArgs{ ContractAddr: contractAddr, ContractABI: contracts.DepositCallerContract.ABI, - PrivKey: s.privKey, + PrivKey: s.PrivKey, } // default log check arguments @@ -127,11 +128,11 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { } prepareFunc := func(params *types3.Params, method string) contracts.CallArgs { - err := s.app.DepositKeeper.SetParams(s.ctx, params) + err := s.App.DepositKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) defaultDepositArgs := defaultCallArgs.WithMethodName(method) return defaultDepositArgs.WithArgs( - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, stakerAddr, opAmount) @@ -141,7 +142,7 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { beforeEach() depositParams.ExoCoreLzAppAddress = contractAddr.String() setDepositToArgs := prepareFunc(&depositParams, "testDepositTo") - _, _, err = contracts.CallContractAndCheckLogs(s.ctx, s.app, setDepositToArgs, passCheck) + _, _, err = contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) s.Require().NoError(err) //todo: need to find why the ethRet is nil when called by contract /* successRet, err := contracts.DepositCallerContract.ABI.Methods["testDepositTo"].Outputs.Pack(true, opAmount) @@ -153,7 +154,7 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { setDepositToArgs = prepareFunc(&depositParams, "testCallDepositToAndEmitEvent") // todo: need to check why can't get the ethereum log // eventCheck := passCheck.WithExpEvents("callDepositToResult") - _, _, err = contracts.CallContractAndCheckLogs(s.ctx, s.app, setDepositToArgs, passCheck) + _, _, err = contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) s.Require().NoError(err) /* successRet, err = contracts.DepositCallerContract.ABI.Methods["testCallDepositToAndEmitEvent"].Outputs.Pack(true, opAmount) s.Require().NoError(err) @@ -165,7 +166,7 @@ func (s *PrecompileTestSuite) TestCallDepositToFromContract() { setDepositToArgs = prepareFunc(&depositParams, "testCallDepositToWithTryCatch") // eventCheck = passCheck.WithExpEvents("ErrorOccurred") // todo: need to check the ethereum log - _, _, err = contracts.CallContractAndCheckLogs(s.ctx, s.app, setDepositToArgs, passCheck) + _, _, err = contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) s.Require().NoError(err) /* successRet, err = contracts.DepositCallerContract.ABI.Methods["testCallDepositToWithTryCatch"].Outputs.Pack(false, big.NewInt(0)) s.Require().NoError(err) diff --git a/precompiles/deposit/deposit_test.go b/precompiles/deposit/deposit_test.go index 85449b5c1..afc4f3227 100644 --- a/precompiles/deposit/deposit_test.go +++ b/precompiles/deposit/deposit_test.go @@ -16,7 +16,7 @@ import ( evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) -func (s *PrecompileTestSuite) TestIsTransaction() { +func (s *DepositPrecompileSuite) TestIsTransaction() { testCases := []struct { name string method string @@ -50,31 +50,31 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { } // TestRunDepositTo tests DepositTo method through calling Run function.. -func (s *PrecompileTestSuite) TestRunDepositTo() { +func (s *DepositPrecompileSuite) TestRunDepositTo() { // deposit params for test exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) usdcAddress := paddingClientChainAddress(common.FromHex("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), types.GeneralClientChainAddrLength) - clientChainLzId := 101 - stakerAddr := paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength) + clientChainLzID := 101 + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress commonMalleate := func() (common.Address, []byte) { - valAddr, err := sdk.ValAddressFromBech32(s.validators[0].OperatorAddress) + valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) s.Require().NoError(err) - val, _ := s.app.StakingKeeper.GetValidator(s.ctx, valAddr) + val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - s.app.DistrKeeper.AllocateTokensToValidator(s.ctx, val, sdk.NewDecCoinsFromCoins(coins...)) + s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( deposit.MethodDepositTo, - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, stakerAddr, opAmount, ) s.Require().NoError(err, "failed to pack input") - return s.address, input + return s.Address, input } successRet, err := s.precompile.Methods[deposit.MethodDepositTo].Outputs.Pack(true, opAmount) s.Require().NoError(err) @@ -103,7 +103,7 @@ func (s *PrecompileTestSuite) TestRunDepositTo() { ExoCoreLzAppAddress: exoCoreLzAppAddress, ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -115,10 +115,10 @@ func (s *PrecompileTestSuite) TestRunDepositTo() { name: "fail - depositTo transaction will fail because the staked asset hasn't been registered", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) assetAddr = usdcAddress return commonMalleate() @@ -131,11 +131,11 @@ func (s *PrecompileTestSuite) TestRunDepositTo() { name: "pass - depositTo transaction", malleate: func() (common.Address, []byte) { depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } assetAddr = usdtAddress - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -151,7 +151,7 @@ func (s *PrecompileTestSuite) TestRunDepositTo() { // setup basic test suite s.SetupTest() - baseFee := s.app.FeeMarketKeeper.GetBaseFee(s.ctx) + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) // malleate testcase caller, input := tc.malleate() @@ -162,7 +162,7 @@ func (s *PrecompileTestSuite) TestRunDepositTo() { contractAddr := contract.Address() // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ - ChainID: s.app.EvmKeeper.ChainID(), + ChainID: s.App.EvmKeeper.ChainID(), Nonce: 0, To: &contractAddr, Amount: nil, @@ -174,26 +174,26 @@ func (s *PrecompileTestSuite) TestRunDepositTo() { } msgEthereumTx := evmtypes.NewTx(&txArgs) - msgEthereumTx.From = s.address.String() - err := msgEthereumTx.Sign(s.ethSigner, s.signer) + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) s.Require().NoError(err, "failed to sign Ethereum message") // Instantiate config - proposerAddress := s.ctx.BlockHeader().ProposerAddress - cfg, err := s.app.EvmKeeper.EVMConfig(s.ctx, proposerAddress, s.app.EvmKeeper.ChainID()) + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) s.Require().NoError(err, "failed to instantiate EVM config") - msg, err := msgEthereumTx.AsMessage(s.ethSigner, baseFee) + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) s.Require().NoError(err, "failed to instantiate Ethereum message") // Instantiate EVM - evm := s.app.EvmKeeper.NewEVM( - s.ctx, msg, cfg, nil, s.stateDB, + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, ) - params := s.app.EvmKeeper.GetParams(s.ctx) + params := s.App.EvmKeeper.GetParams(s.Ctx) activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := s.app.EvmKeeper.Precompiles(activePrecompiles...) + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) s.Require().NoError(err, "invalid precompiles", activePrecompiles) evm.WithPrecompiles(precompileMap, activePrecompiles) diff --git a/precompiles/deposit/setup_test.go b/precompiles/deposit/setup_test.go index 7c0783634..a489fe03d 100644 --- a/precompiles/deposit/setup_test.go +++ b/precompiles/deposit/setup_test.go @@ -1,50 +1,27 @@ package deposit_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" "github.com/ExocoreNetwork/exocore/precompiles/deposit" - "github.com/evmos/evmos/v14/x/evm/statedb" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - evmosapp "github.com/ExocoreNetwork/exocore/app" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" "github.com/stretchr/testify/suite" ) -var s *PrecompileTestSuite - -type PrecompileTestSuite struct { - suite.Suite +var s *DepositPrecompileSuite - ctx sdk.Context - app *evmosapp.ExocoreApp - address common.Address - validators []stakingtypes.Validator - valSet *tmtypes.ValidatorSet - ethSigner ethtypes.Signer - privKey cryptotypes.PrivKey - signer keyring.Signer - bondDenom string +type DepositPrecompileSuite struct { + testutil.BaseTestSuite precompile *deposit.Precompile - stateDB *statedb.StateDB - - queryClientEVM evmtypes.QueryClient } func TestPrecompileTestSuite(t *testing.T) { - s = new(PrecompileTestSuite) + s = new(DepositPrecompileSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -52,6 +29,9 @@ func TestPrecompileTestSuite(t *testing.T) { RunSpecs(t, "Distribution Precompile Suite") } -func (s *PrecompileTestSuite) SetupTest() { +func (s *DepositPrecompileSuite) SetupTest() { s.DoSetupTest() + precompile, err := deposit.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.DepositKeeper, s.App.AuthzKeeper) + s.Require().NoError(err) + s.precompile = precompile } diff --git a/precompiles/deposit/tx.go b/precompiles/deposit/tx.go index a184dd704..cde6e55b3 100644 --- a/precompiles/deposit/tx.go +++ b/precompiles/deposit/tx.go @@ -48,8 +48,8 @@ func (p Precompile) DepositTo( } // get the latest asset state of staker to return. - stakerId, assetId := types.GetStakeIDAndAssetId(depositParams.ClientChainLzId, depositParams.StakerAddress, depositParams.AssetsAddress) - info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(depositParams.ClientChainLzID, depositParams.StakerAddress, depositParams.AssetsAddress) + info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/precompiles/deposit/types.go b/precompiles/deposit/types.go index 5ed048e27..ccea59735 100644 --- a/precompiles/deposit/types.go +++ b/precompiles/deposit/types.go @@ -1,15 +1,14 @@ package deposit import ( - "fmt" - "math/big" - "reflect" - sdkmath "cosmossdk.io/math" + "fmt" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" + "math/big" + "reflect" ) func (p Precompile) GetDepositToParamsFromInputs(ctx sdk.Context, args []interface{}) (*keeper.DepositParams, error) { @@ -21,9 +20,9 @@ func (p Precompile) GetDepositToParamsFromInputs(ctx sdk.Context, args []interfa if !ok { return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } - depositParams.ClientChainLzId = uint64(clientChainLzID) + depositParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, depositParams.ClientChainLzId) + info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, depositParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/deposit/utils_test.go b/precompiles/deposit/utils_test.go deleted file mode 100644 index 3c2abfeb1..000000000 --- a/precompiles/deposit/utils_test.go +++ /dev/null @@ -1,220 +0,0 @@ -package deposit_test - -import ( - "encoding/json" - "time" - - "github.com/ExocoreNetwork/exocore/precompiles/deposit" - "github.com/ExocoreNetwork/exocore/testutil" - testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" - - evmosapp "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/testutil/mock" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" -) - -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() - app, ok := appI.(*evmosapp.ExocoreApp) - s.Require().True(ok) - - // set genesis accounts - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) - delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - - bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) - - for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - s.Require().NoError(err) - pkAny, err := codectypes.NewAnyWithValue(pk) - s.Require().NoError(err) - validator := stakingtypes.Validator{ - OperatorAddress: sdk.ValAddress(val.Address).String(), - ConsensusPubkey: pkAny, - Jailed: false, - Status: stakingtypes.Bonded, - Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), - Description: stakingtypes.Description{}, - UnbondingHeight: int64(0), - UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), - } - validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - } - s.validators = validators - - // set validators and delegations - stakingParams := stakingtypes.DefaultParams() - // set bond demon to be aevmos - stakingParams.BondDenom = utils.BaseDenom - stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) - - totalBondAmt := bondAmt.Add(bondAmt) - totalSupply := sdk.NewCoins() - for _, b := range balances { - // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) - } - - // add bonded amount to bonded pool module account - balances = append(balances, banktypes.Balance{ - Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, - }) - - // update total supply - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) - - // init chain will set the validator set and initialize the genesis accounts - app.InitChain( - abci.RequestInitChain{ - ChainId: cmn.DefaultChainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: evmosapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - app.Commit() - - // instantiate new header - header := testutil.NewHeader( - 2, - time.Now().UTC(), - cmn.DefaultChainID, - sdk.ConsAddress(validators[0].GetOperator()), - tmhash.Sum([]byte("app")), - tmhash.Sum([]byte("validators")), - ) - - app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // create Context - s.ctx = app.BaseApp.NewContext(false, header) - s.app = app -} - -func (s *PrecompileTestSuite) DoSetupTest() { - // generate validator private/public key - privVal := mock.NewPV() - pubKey, err := privVal.GetPubKey() - s.Require().NoError(err) - - privVal2 := mock.NewPV() - pubKey2, err := privVal2.GetPubKey() - s.Require().NoError(err) - - // create validator set with two validators - validator := tmtypes.NewValidator(pubKey, 1) - validator2 := tmtypes.NewValidator(pubKey2, 2) - s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) - signers := make(map[string]tmtypes.PrivValidator) - signers[pubKey.Address().String()] = privVal - signers[pubKey2.Address().String()] = privVal2 - - // generate genesis account - addr, priv := testutiltx.NewAddrKey() - s.privKey = priv - s.address = addr - s.signer = testutiltx.NewSigner(priv) - - baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) - - acc := &evmostypes.EthAccount{ - BaseAccount: baseAcc, - CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), - } - - amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) - - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), - } - - s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) - - // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) - - // bond denom - stakingParams := s.app.StakingKeeper.GetParams(s.ctx) - stakingParams.BondDenom = utils.BaseDenom - s.bondDenom = stakingParams.BondDenom - err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) - s.Require().NoError(err) - - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) - - precompile, err := deposit.NewPrecompile(s.app.StakingAssetsManageKeeper, s.app.DepositKeeper, s.app.AuthzKeeper) - s.Require().NoError(err) - s.precompile = precompile - - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) - inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) - distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - s.Require().NoError(err) - - queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) - s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) -} - -// DeployContract deploys a contract that calls the deposit precompile's methods for testing purposes. -func (s *PrecompileTestSuite) DeployContract(contract evmtypes.CompiledContract) (addr common.Address, err error) { - addr, err = testutil.DeployContract( - s.ctx, - s.app, - s.privKey, - s.queryClientEVM, - contract, - ) - return -} - -// NextBlock commits the current block and sets up the next block. -func (s *PrecompileTestSuite) NextBlock() { - var err error - s.ctx, err = testutil.CommitAndCreateNewCtx(s.ctx, s.app, time.Second, s.valSet, false) - s.Require().NoError(err) -} diff --git a/precompiles/reward/abi.json b/precompiles/reward/abi.json index b956787e0..598f805fb 100644 --- a/precompiles/reward/abi.json +++ b/precompiles/reward/abi.json @@ -3,7 +3,7 @@ "inputs":[ { "internalType":"uint16", - "name":"clientChainLzId", + "name":"clientChainLzID", "type":"uint16" }, { diff --git a/precompiles/reward/claimReward.sol b/precompiles/reward/claimReward.sol index b6af178b3..4e17925f0 100644 --- a/precompiles/reward/claimReward.sol +++ b/precompiles/reward/claimReward.sol @@ -16,12 +16,12 @@ interface IClaimReward { /// TRANSACTIONS /// @dev ClaimReward To the staker, that will change the state in reward module /// Note that this address cannot be a module account. -/// @param clientChainLzId The lzId of client chain +/// @param clientChainLzID The LzID of client chain /// @param assetsAddress The client chain asset Address /// @param withdrawRewardAddress The claim reward address /// @param opAmount The reward amount function claimReward( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory withdrawRewardAddress, uint256 opAmount diff --git a/precompiles/reward/methods.go b/precompiles/reward/methods.go index cd5ec2baf..b75a9c8ed 100644 --- a/precompiles/reward/methods.go +++ b/precompiles/reward/methods.go @@ -45,8 +45,8 @@ func (p Precompile) Reward( return nil, err } // get the latest asset state of staker to return. - stakerId, assetId := types.GetStakeIDAndAssetId(rewardParam.ClientChainLzId, rewardParam.WithdrawRewardAddress, rewardParam.AssetsAddress) - info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(rewardParam.ClientChainLzID, rewardParam.WithdrawRewardAddress, rewardParam.AssetsAddress) + info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/precompiles/reward/parser.go b/precompiles/reward/parser.go index b4296c9a5..eb7f194ac 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -22,9 +22,9 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ if !ok { return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } - rewardParams.ClientChainLzId = uint64(clientChainLzID) + rewardParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, rewardParams.ClientChainLzId) + info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, rewardParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/reward/reward_test.go b/precompiles/reward/reward_test.go index 7190b14dc..ccc2f0483 100644 --- a/precompiles/reward/reward_test.go +++ b/precompiles/reward/reward_test.go @@ -17,7 +17,7 @@ import ( evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) -func (s *PrecompileTestSuite) TestIsTransaction() { +func (s *RewardPrecompileTestSuite) TestIsTransaction() { testCases := []struct { name string method string @@ -51,24 +51,24 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { } // TestRun tests the precompiled Run method reward. -func (s *PrecompileTestSuite) TestRunRewardThroughClientChain() { +func (s *RewardPrecompileTestSuite) TestRunRewardThroughClientChain() { // deposit params for test exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := 101 + clientChainLzID := 101 withdrawAmount := big.NewInt(10) depositAmount := big.NewInt(100) assetAddr := paddingClientChainAddress(usdtAddress, types.GeneralClientChainAddrLength) depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for reward test params := &keeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, } - err := s.app.DepositKeeper.Deposit(s.ctx, params) + err := s.App.DepositKeeper.Deposit(s.Ctx, params) s.Require().NoError(err) } @@ -76,13 +76,13 @@ func (s *PrecompileTestSuite) TestRunRewardThroughClientChain() { // Prepare the call input for reward test input, err := s.precompile.Pack( reward.MethodReward, - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, - paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), withdrawAmount, ) s.Require().NoError(err, "failed to pack input") - return s.address, input + return s.Address, input } successRet, err := s.precompile.Methods[reward.MethodReward].Outputs.Pack(true, new(big.Int).Add(depositAmount, withdrawAmount)) s.Require().NoError(err) @@ -98,17 +98,17 @@ func (s *PrecompileTestSuite) TestRunRewardThroughClientChain() { name: "pass - reward via pre-compiles", malleate: func() (common.Address, []byte) { depositModuleParam := &depositParams.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) - depositAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) + depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) rewardModuleParam := &rewardParams.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err = s.app.RewardKeeper.SetParams(s.ctx, rewardModuleParam) + err = s.App.RewardKeeper.SetParams(s.Ctx, rewardModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -123,7 +123,7 @@ func (s *PrecompileTestSuite) TestRunRewardThroughClientChain() { // setup basic test suite s.SetupTest() - baseFee := s.app.FeeMarketKeeper.GetBaseFee(s.ctx) + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) // malleate testcase caller, input := tc.malleate() @@ -134,7 +134,7 @@ func (s *PrecompileTestSuite) TestRunRewardThroughClientChain() { contractAddr := contract.Address() // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ - ChainID: s.app.EvmKeeper.ChainID(), + ChainID: s.App.EvmKeeper.ChainID(), Nonce: 0, To: &contractAddr, Amount: nil, @@ -146,27 +146,27 @@ func (s *PrecompileTestSuite) TestRunRewardThroughClientChain() { } msgEthereumTx := evmtypes.NewTx(&txArgs) - msgEthereumTx.From = s.address.String() - err := msgEthereumTx.Sign(s.ethSigner, s.signer) + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) s.Require().NoError(err, "failed to sign Ethereum message") // Instantiate config - proposerAddress := s.ctx.BlockHeader().ProposerAddress - cfg, err := s.app.EvmKeeper.EVMConfig(s.ctx, proposerAddress, s.app.EvmKeeper.ChainID()) + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) s.Require().NoError(err, "failed to instantiate EVM config") - msg, err := msgEthereumTx.AsMessage(s.ethSigner, baseFee) + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) s.Require().NoError(err, "failed to instantiate Ethereum message") // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.StateDB = statedb.New(s.Ctx, s.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.Ctx.HeaderHash().Bytes()))) // Instantiate EVM - evm := s.app.EvmKeeper.NewEVM( - s.ctx, msg, cfg, nil, s.stateDB, + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, ) - params := s.app.EvmKeeper.GetParams(s.ctx) + params := s.App.EvmKeeper.GetParams(s.Ctx) activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := s.app.EvmKeeper.Precompiles(activePrecompiles...) + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) s.Require().NoError(err, "invalid precompiles", activePrecompiles) evm.WithPrecompiles(precompileMap, activePrecompiles) diff --git a/precompiles/reward/setup_test.go b/precompiles/reward/setup_test.go index e8db9fdbb..9b444815e 100644 --- a/precompiles/reward/setup_test.go +++ b/precompiles/reward/setup_test.go @@ -1,50 +1,26 @@ package reward_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" "github.com/ExocoreNetwork/exocore/precompiles/reward" - "github.com/evmos/evmos/v14/x/evm/statedb" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - evmosapp "github.com/ExocoreNetwork/exocore/app" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" "github.com/stretchr/testify/suite" ) -var s *PrecompileTestSuite - -type PrecompileTestSuite struct { - suite.Suite - - ctx sdk.Context - app *evmosapp.ExocoreApp - address common.Address - validators []stakingtypes.Validator - valSet *tmtypes.ValidatorSet - ethSigner ethtypes.Signer - privKey cryptotypes.PrivKey - signer keyring.Signer - bondDenom string +var s *RewardPrecompileTestSuite +type RewardPrecompileTestSuite struct { + testutil.BaseTestSuite precompile *reward.Precompile - stateDB *statedb.StateDB - - queryClientEVM evmtypes.QueryClient } func TestPrecompileTestSuite(t *testing.T) { - s = new(PrecompileTestSuite) + s = new(RewardPrecompileTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -52,6 +28,9 @@ func TestPrecompileTestSuite(t *testing.T) { RunSpecs(t, "Reward Precompile Suite") } -func (s *PrecompileTestSuite) SetupTest() { +func (s *RewardPrecompileTestSuite) SetupTest() { s.DoSetupTest() + precompile, err := reward.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.RewardKeeper, s.App.AuthzKeeper) + s.Require().NoError(err) + s.precompile = precompile } diff --git a/precompiles/reward/utils_test.go b/precompiles/reward/utils_test.go deleted file mode 100644 index 2c1158319..000000000 --- a/precompiles/reward/utils_test.go +++ /dev/null @@ -1,231 +0,0 @@ -package reward_test - -import ( - "encoding/json" - "time" - - evmosapp "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/precompiles/reward" - "github.com/ExocoreNetwork/exocore/utils" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/testutil/mock" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" - "github.com/evmos/evmos/v14/precompiles/testutil/contracts" - "github.com/evmos/evmos/v14/precompiles/vesting/testdata" - evmosutil "github.com/evmos/evmos/v14/testutil" - evmosutiltx "github.com/evmos/evmos/v14/testutil/tx" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" -) - -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() - app, ok := appI.(*evmosapp.ExocoreApp) - s.Require().True(ok) - - // set genesis accounts - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) - delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - - bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) - - for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - s.Require().NoError(err) - pkAny, err := codectypes.NewAnyWithValue(pk) - s.Require().NoError(err) - validator := stakingtypes.Validator{ - OperatorAddress: sdk.ValAddress(val.Address).String(), - ConsensusPubkey: pkAny, - Jailed: false, - Status: stakingtypes.Bonded, - Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), - Description: stakingtypes.Description{}, - UnbondingHeight: int64(0), - UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), - } - validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - } - s.validators = validators - - // set validators and delegations - stakingParams := stakingtypes.DefaultParams() - // set bond demon to be aevmos - stakingParams.BondDenom = utils.BaseDenom - stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) - - totalBondAmt := bondAmt.Add(bondAmt) - totalSupply := sdk.NewCoins() - for _, b := range balances { - // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) - } - - // add bonded amount to bonded pool module account - balances = append(balances, banktypes.Balance{ - Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, - }) - - // update total supply - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) - - // init chain will set the validator set and initialize the genesis accounts - app.InitChain( - abci.RequestInitChain{ - ChainId: cmn.DefaultChainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: evmosapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - app.Commit() - - // instantiate new header - header := evmosutil.NewHeader( - 2, - time.Now().UTC(), - cmn.DefaultChainID, - sdk.ConsAddress(validators[0].GetOperator()), - tmhash.Sum([]byte("app")), - tmhash.Sum([]byte("validators")), - ) - - app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // create Context - s.ctx = app.BaseApp.NewContext(false, header) - s.app = app -} - -func (s *PrecompileTestSuite) DoSetupTest() { - // generate validator private/public key - privVal := mock.NewPV() - pubKey, err := privVal.GetPubKey() - s.Require().NoError(err) - - privVal2 := mock.NewPV() - pubKey2, err := privVal2.GetPubKey() - s.Require().NoError(err) - - // create validator set with two validators - validator := tmtypes.NewValidator(pubKey, 1) - validator2 := tmtypes.NewValidator(pubKey2, 2) - s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) - signers := make(map[string]tmtypes.PrivValidator) - signers[pubKey.Address().String()] = privVal - signers[pubKey2.Address().String()] = privVal2 - - // generate genesis account - addr, priv := evmosutiltx.NewAddrKey() - s.privKey = priv - s.address = addr - s.signer = evmosutiltx.NewSigner(priv) - - baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) - - acc := &evmostypes.EthAccount{ - BaseAccount: baseAcc, - CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), - } - - amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) - - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), - } - - s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) - - // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) - - // bond denom - stakingParams := s.app.StakingKeeper.GetParams(s.ctx) - stakingParams.BondDenom = utils.BaseDenom - s.bondDenom = stakingParams.BondDenom - err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) - s.Require().NoError(err) - - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) - - precompile, err := reward.NewPrecompile(s.app.StakingAssetsManageKeeper, s.app.RewardKeeper, s.app.AuthzKeeper) - s.Require().NoError(err) - s.precompile = precompile - - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) - inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) - distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - s.Require().NoError(err) - - queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) - s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) -} - -// CallType is a struct that represents the type of call to be made to -// precompile - either direct or through a smart contract. -type CallType struct { - // name is the name of the call type - name string - // directCall is true if the call is to be made directly to precompile - directCall bool -} - -// BuildCallArgs builds the call arguments for the integration test suite -// depending on the type of interaction. -func (s *PrecompileTestSuite) BuildCallArgs( - callType CallType, - contractAddr common.Address, -) contracts.CallArgs { - callArgs := contracts.CallArgs{ - PrivKey: s.privKey, - } - if callType.directCall { - callArgs.ContractABI = s.precompile.ABI - callArgs.ContractAddr = s.precompile.Address() - } else { - callArgs.ContractAddr = contractAddr - callArgs.ContractABI = testdata.VestingCallerContract.ABI - } - - return callArgs -} diff --git a/precompiles/slash/abi.json b/precompiles/slash/abi.json index 358f0fb61..9ae673bc0 100644 --- a/precompiles/slash/abi.json +++ b/precompiles/slash/abi.json @@ -3,7 +3,7 @@ "inputs":[ { "internalType":"uint16", - "name":"clientChainLzId", + "name":"clientChainLzID", "type":"uint16" }, { diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index ad29a726d..792b74c76 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -21,9 +21,9 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} if !ok { return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } - slashParams.ClientChainLzId = uint64(clientChainLzID) + slashParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, slashParams.ClientChainLzId) + info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, slashParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/slash/setup_test.go b/precompiles/slash/setup_test.go index bd7eaf1b3..dcae7c8ee 100644 --- a/precompiles/slash/setup_test.go +++ b/precompiles/slash/setup_test.go @@ -1,50 +1,26 @@ package slash_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" "github.com/ExocoreNetwork/exocore/precompiles/slash" - "github.com/evmos/evmos/v14/x/evm/statedb" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - evmosapp "github.com/ExocoreNetwork/exocore/app" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" "github.com/stretchr/testify/suite" ) -var s *PrecompileTestSuite - -type PrecompileTestSuite struct { - suite.Suite - - ctx sdk.Context - app *evmosapp.ExocoreApp - address common.Address - validators []stakingtypes.Validator - valSet *tmtypes.ValidatorSet - ethSigner ethtypes.Signer - privKey cryptotypes.PrivKey - signer keyring.Signer - bondDenom string +var s *SlashPrecompileTestSuite +type SlashPrecompileTestSuite struct { + testutil.BaseTestSuite precompile *slash.Precompile - stateDB *statedb.StateDB - - queryClientEVM evmtypes.QueryClient } func TestPrecompileTestSuite(t *testing.T) { - s = new(PrecompileTestSuite) + s = new(SlashPrecompileTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -52,6 +28,9 @@ func TestPrecompileTestSuite(t *testing.T) { RunSpecs(t, "Slash Precompile Suite") } -func (s *PrecompileTestSuite) SetupTest() { +func (s *SlashPrecompileTestSuite) SetupTest() { s.DoSetupTest() + precompile, err := slash.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.ExoSlashKeeper, s.App.AuthzKeeper) + s.Require().NoError(err) + s.precompile = precompile } diff --git a/precompiles/slash/slash.sol b/precompiles/slash/slash.sol index 87f63a834..001201ab1 100644 --- a/precompiles/slash/slash.sol +++ b/precompiles/slash/slash.sol @@ -16,7 +16,7 @@ interface ISlash { /// TRANSACTIONS /// @dev Slash the oprator, that will change the state in Slash module /// Note that this address cannot be a module account. -/// @param clientChainLzId The lzId of client chain +/// @param clientChainLzID The LzID of client chain /// @param assetsAddress The client chain asset Address /// @param opAmount The Slash amount /// @param operatorAddress The Slashed OperatorAddress @@ -25,7 +25,7 @@ interface ISlash { /// @param proof The Slash proof function submitSlash( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount, diff --git a/precompiles/slash/slash_test.go b/precompiles/slash/slash_test.go index 27f1e874a..2538a6a70 100644 --- a/precompiles/slash/slash_test.go +++ b/precompiles/slash/slash_test.go @@ -17,7 +17,7 @@ import ( evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) -func (s *PrecompileTestSuite) TestIsTransaction() { +func (s *SlashPrecompileTestSuite) TestIsTransaction() { testCases := []struct { name string method string @@ -51,24 +51,24 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { } // TestRun tests the precompiles Run method submitSlash. -func (s *PrecompileTestSuite) TestRunSlash() { +func (s *SlashPrecompileTestSuite) TestRunSlash() { // deposit params for test exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := 101 + clientChainLzID := 101 slashAmount := big.NewInt(10) depositAmount := big.NewInt(100) assetAddr := paddingClientChainAddress(usdtAddress, types.GeneralClientChainAddrLength) depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for slash test params := &keeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, } - err := s.app.DepositKeeper.Deposit(s.ctx, params) + err := s.App.DepositKeeper.Deposit(s.Ctx, params) s.Require().NoError(err) } @@ -76,9 +76,9 @@ func (s *PrecompileTestSuite) TestRunSlash() { // Prepare the call input for slash test input, err := s.precompile.Pack( slash.MethodSlash, - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, - paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), slashAmount, common.FromHex("0x2E756b8faBeA234b9900767b69D6387400CDC396"), common.FromHex("0xceb69f6342ece283b2f5c9088ff249b5d0ae66ea"), @@ -86,7 +86,7 @@ func (s *PrecompileTestSuite) TestRunSlash() { "slash", ) s.Require().NoError(err, "failed to pack input") - return s.address, input + return s.Address, input } successRet, err := s.precompile.Methods[slash.MethodSlash].Outputs.Pack(true) s.Require().NoError(err) @@ -102,17 +102,17 @@ func (s *PrecompileTestSuite) TestRunSlash() { name: "pass - slash via pre-compiles", malleate: func() (common.Address, []byte) { depositModuleParam := &depositParams.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) - depositAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) + depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) slashModuleParam := &slashParams.Params{ - ExoCoreLzAppAddress: s.address.String(), + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err = s.app.ExoSlashKeeper.SetParams(s.ctx, slashModuleParam) + err = s.App.ExoSlashKeeper.SetParams(s.Ctx, slashModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -127,7 +127,7 @@ func (s *PrecompileTestSuite) TestRunSlash() { // setup basic test suite s.SetupTest() - baseFee := s.app.FeeMarketKeeper.GetBaseFee(s.ctx) + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) // malleate testcase caller, input := tc.malleate() @@ -138,7 +138,7 @@ func (s *PrecompileTestSuite) TestRunSlash() { contractAddr := contract.Address() // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ - ChainID: s.app.EvmKeeper.ChainID(), + ChainID: s.App.EvmKeeper.ChainID(), Nonce: 0, To: &contractAddr, Amount: nil, @@ -150,27 +150,27 @@ func (s *PrecompileTestSuite) TestRunSlash() { } msgEthereumTx := evmtypes.NewTx(&txArgs) - msgEthereumTx.From = s.address.String() - err := msgEthereumTx.Sign(s.ethSigner, s.signer) + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) s.Require().NoError(err, "failed to sign Ethereum message") // Instantiate config - proposerAddress := s.ctx.BlockHeader().ProposerAddress - cfg, err := s.app.EvmKeeper.EVMConfig(s.ctx, proposerAddress, s.app.EvmKeeper.ChainID()) + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) s.Require().NoError(err, "failed to instantiate EVM config") - msg, err := msgEthereumTx.AsMessage(s.ethSigner, baseFee) + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) s.Require().NoError(err, "failed to instantiate Ethereum message") // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.StateDB = statedb.New(s.Ctx, s.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.Ctx.HeaderHash().Bytes()))) // Instantiate EVM - evm := s.app.EvmKeeper.NewEVM( - s.ctx, msg, cfg, nil, s.stateDB, + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, ) - params := s.app.EvmKeeper.GetParams(s.ctx) + params := s.App.EvmKeeper.GetParams(s.Ctx) activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := s.app.EvmKeeper.Precompiles(activePrecompiles...) + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) s.Require().NoError(err, "invalid precompiles", activePrecompiles) evm.WithPrecompiles(precompileMap, activePrecompiles) diff --git a/precompiles/slash/utils_test.go b/precompiles/slash/utils_test.go deleted file mode 100644 index b08e889d1..000000000 --- a/precompiles/slash/utils_test.go +++ /dev/null @@ -1,231 +0,0 @@ -package slash_test - -import ( - "encoding/json" - "time" - - evmosapp "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/precompiles/slash" - "github.com/ExocoreNetwork/exocore/utils" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/testutil/mock" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" - "github.com/evmos/evmos/v14/precompiles/testutil/contracts" - "github.com/evmos/evmos/v14/precompiles/vesting/testdata" - evmosutil "github.com/evmos/evmos/v14/testutil" - evmosutiltx "github.com/evmos/evmos/v14/testutil/tx" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" -) - -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() - app, ok := appI.(*evmosapp.ExocoreApp) - s.Require().True(ok) - - // set genesis accounts - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) - delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - - bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) - - for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - s.Require().NoError(err) - pkAny, err := codectypes.NewAnyWithValue(pk) - s.Require().NoError(err) - validator := stakingtypes.Validator{ - OperatorAddress: sdk.ValAddress(val.Address).String(), - ConsensusPubkey: pkAny, - Jailed: false, - Status: stakingtypes.Bonded, - Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), - Description: stakingtypes.Description{}, - UnbondingHeight: int64(0), - UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), - } - validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - } - s.validators = validators - - // set validators and delegations - stakingParams := stakingtypes.DefaultParams() - // set bond demon to be aevmos - stakingParams.BondDenom = utils.BaseDenom - stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) - - totalBondAmt := bondAmt.Add(bondAmt) - totalSupply := sdk.NewCoins() - for _, b := range balances { - // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) - } - - // add bonded amount to bonded pool module account - balances = append(balances, banktypes.Balance{ - Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, - }) - - // update total supply - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) - - // init chain will set the validator set and initialize the genesis accounts - app.InitChain( - abci.RequestInitChain{ - ChainId: cmn.DefaultChainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: evmosapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - app.Commit() - - // instantiate new header - header := evmosutil.NewHeader( - 2, - time.Now().UTC(), - cmn.DefaultChainID, - sdk.ConsAddress(validators[0].GetOperator()), - tmhash.Sum([]byte("app")), - tmhash.Sum([]byte("validators")), - ) - - app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // create Context - s.ctx = app.BaseApp.NewContext(false, header) - s.app = app -} - -func (s *PrecompileTestSuite) DoSetupTest() { - // generate validator private/public key - privVal := mock.NewPV() - pubKey, err := privVal.GetPubKey() - s.Require().NoError(err) - - privVal2 := mock.NewPV() - pubKey2, err := privVal2.GetPubKey() - s.Require().NoError(err) - - // create validator set with two validators - validator := tmtypes.NewValidator(pubKey, 1) - validator2 := tmtypes.NewValidator(pubKey2, 2) - s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) - signers := make(map[string]tmtypes.PrivValidator) - signers[pubKey.Address().String()] = privVal - signers[pubKey2.Address().String()] = privVal2 - - // generate genesis account - addr, priv := evmosutiltx.NewAddrKey() - s.privKey = priv - s.address = addr - s.signer = evmosutiltx.NewSigner(priv) - - baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) - - acc := &evmostypes.EthAccount{ - BaseAccount: baseAcc, - CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), - } - - amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) - - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), - } - - s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) - - // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) - - // bond denom - stakingParams := s.app.StakingKeeper.GetParams(s.ctx) - stakingParams.BondDenom = utils.BaseDenom - s.bondDenom = stakingParams.BondDenom - err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) - s.Require().NoError(err) - - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) - - precompile, err := slash.NewPrecompile(s.app.StakingAssetsManageKeeper, s.app.ExoSlashKeeper, s.app.AuthzKeeper) - s.Require().NoError(err) - s.precompile = precompile - - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) - inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) - distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - s.Require().NoError(err) - - queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) - s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) -} - -// CallType is a struct that represents the type of call to be made to -// precompile - either direct or through a smart contract. -type CallType struct { - // name is the name of the call type - name string - // directCall is true if the call is to be made directly to precompile - directCall bool -} - -// BuildCallArgs builds the call arguments for the integration test suite -// depending on the type of interaction. -func (s *PrecompileTestSuite) BuildCallArgs( - callType CallType, - contractAddr common.Address, -) contracts.CallArgs { - callArgs := contracts.CallArgs{ - PrivKey: s.privKey, - } - if callType.directCall { - callArgs.ContractABI = s.precompile.ABI - callArgs.ContractAddr = s.precompile.Address() - } else { - callArgs.ContractAddr = contractAddr - callArgs.ContractABI = testdata.VestingCallerContract.ABI - } - - return callArgs -} diff --git a/precompiles/testutil/contracts/DepositCaller.json b/precompiles/testutil/contracts/DepositCaller.json index 255c068c2..38bd8060c 100644 --- a/precompiles/testutil/contracts/DepositCaller.json +++ b/precompiles/testutil/contracts/DepositCaller.json @@ -1,4 +1,4 @@ { - "abi": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"errorMessage\",\"type\":\"string\"}],\"name\":\"ErrorOccurred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"latestAssetState\",\"type\":\"uint256\"}],\"name\":\"callDepositToResult\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"clientChainLzId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"assetsAddress\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"stakerAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"opAmount\",\"type\":\"uint256\"}],\"name\":\"testCallDepositToAndEmitEvent\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"clientChainLzId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"assetsAddress\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"stakerAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"opAmount\",\"type\":\"uint256\"}],\"name\":\"testCallDepositToWithTryCatch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"clientChainLzId\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"assetsAddress\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"stakerAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"opAmount\",\"type\":\"uint256\"}],\"name\":\"testDepositTo\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + "abi": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"errorMessage\",\"type\":\"string\"}],\"name\":\"ErrorOccurred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"latestAssetState\",\"type\":\"uint256\"}],\"name\":\"callDepositToResult\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"clientChainLzID\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"assetsAddress\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"stakerAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"opAmount\",\"type\":\"uint256\"}],\"name\":\"testCallDepositToAndEmitEvent\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"clientChainLzID\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"assetsAddress\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"stakerAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"opAmount\",\"type\":\"uint256\"}],\"name\":\"testCallDepositToWithTryCatch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"clientChainLzID\",\"type\":\"uint16\"},{\"internalType\":\"bytes\",\"name\":\"assetsAddress\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"stakerAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"opAmount\",\"type\":\"uint256\"}],\"name\":\"testDepositTo\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", "bin": "608060405234801561001057600080fd5b5061090a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632f0baf7314610046578063c39b2a2114610077578063e43f6bf3146100a8575b600080fd5b610060600480360381019061005b919061054a565b6100d9565b60405161006e929190610613565b60405180910390f35b610091600480360381019061008c919061054a565b61021f565b60405161009f929190610613565b60405180910390f35b6100c260048036038101906100bd919061054a565b6102ed565b6040516100d0929190610613565b60405180910390f35b60008061080473ffffffffffffffffffffffffffffffffffffffff166358bd9b81878787876040518563ffffffff1660e01b815260040161011d94939291906106ca565b60408051808303816000875af192505050801561015857506040513d601f19601f82011682018060405250810190610155919061075e565b60015b6101d1576101646107ab565b806308c379a0036101c057506101786107cd565b8061018357506101c2565b7fcc8610635659273962514cbb1e149386cc83625cb5595394a01869a0c3fbf7cb816040516101b291906108b2565b60405180910390a1506101cc565b505b3d6000803e3d6000fd5b61020e565b808215157f245dbff7400bcd2635c318abe587da5622f824ca5a373ef16c76c1a929eff0d260405160405180910390a38181935093505050610216565b600080915091505b94509492505050565b60008060008061080473ffffffffffffffffffffffffffffffffffffffff166358bd9b81898989896040518563ffffffff1660e01b815260040161026694939291906106ca565b60408051808303816000875af1158015610284573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a8919061075e565b91509150808215157f245dbff7400bcd2635c318abe587da5622f824ca5a373ef16c76c1a929eff0d260405160405180910390a3818193509350505094509492505050565b60008061080473ffffffffffffffffffffffffffffffffffffffff166358bd9b81878787876040518563ffffffff1660e01b815260040161033194939291906106ca565b60408051808303816000875af115801561034f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610373919061075e565b9150915094509492505050565b6000604051905090565b600080fd5b600080fd5b600061ffff82169050919050565b6103ab81610394565b81146103b657600080fd5b50565b6000813590506103c8816103a2565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610421826103d8565b810181811067ffffffffffffffff821117156104405761043f6103e9565b5b80604052505050565b6000610453610380565b905061045f8282610418565b919050565b600067ffffffffffffffff82111561047f5761047e6103e9565b5b610488826103d8565b9050602081019050919050565b82818337600083830152505050565b60006104b76104b284610464565b610449565b9050828152602081018484840111156104d3576104d26103d3565b5b6104de848285610495565b509392505050565b600082601f8301126104fb576104fa6103ce565b5b813561050b8482602086016104a4565b91505092915050565b6000819050919050565b61052781610514565b811461053257600080fd5b50565b6000813590506105448161051e565b92915050565b600080600080608085870312156105645761056361038a565b5b6000610572878288016103b9565b945050602085013567ffffffffffffffff8111156105935761059261038f565b5b61059f878288016104e6565b935050604085013567ffffffffffffffff8111156105c0576105bf61038f565b5b6105cc878288016104e6565b92505060606105dd87828801610535565b91505092959194509250565b60008115159050919050565b6105fe816105e9565b82525050565b61060d81610514565b82525050565b600060408201905061062860008301856105f5565b6106356020830184610604565b9392505050565b61064581610394565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561068557808201518184015260208101905061066a565b60008484015250505050565b600061069c8261064b565b6106a68185610656565b93506106b6818560208601610667565b6106bf816103d8565b840191505092915050565b60006080820190506106df600083018761063c565b81810360208301526106f18186610691565b905081810360408301526107058185610691565b90506107146060830184610604565b95945050505050565b610726816105e9565b811461073157600080fd5b50565b6000815190506107438161071d565b92915050565b6000815190506107588161051e565b92915050565b600080604083850312156107755761077461038a565b5b600061078385828601610734565b925050602061079485828601610749565b9150509250929050565b60008160e01c9050919050565b600060033d11156107ca5760046000803e6107c760005161079e565b90505b90565b600060443d1061085a576107df610380565b60043d036004823e80513d602482011167ffffffffffffffff8211171561080757505061085a565b808201805167ffffffffffffffff811115610825575050505061085a565b80602083010160043d03850181111561084257505050505061085a565b61085182602001850186610418565b82955050505050505b90565b600081519050919050565b600082825260208201905092915050565b60006108848261085d565b61088e8185610868565b935061089e818560208601610667565b6108a7816103d8565b840191505092915050565b600060208201905081810360008301526108cc8184610879565b90509291505056fea26469706673582212208f8e24c5ab27a724ba977f623ebc377db7fcae619d3f861bbf3d2e0c9284e2e864736f6c63430008150033" } \ No newline at end of file diff --git a/precompiles/testutil/contracts/DepositCaller.sol b/precompiles/testutil/contracts/DepositCaller.sol index a6e1dcc6f..f17d49a21 100644 --- a/precompiles/testutil/contracts/DepositCaller.sol +++ b/precompiles/testutil/contracts/DepositCaller.sol @@ -9,14 +9,14 @@ contract DepositCaller { event ErrorOccurred(string errorMessage); function testDepositTo( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount ) public returns (bool, uint256) { return deposit.DEPOSIT_CONTRACT.depositTo( - clientChainLzId, + clientChainLzID, assetsAddress, stakerAddress, opAmount @@ -24,13 +24,13 @@ contract DepositCaller { } function testCallDepositToAndEmitEvent( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount ) public returns (bool, uint256) { (bool success,uint256 latestAssetState) = deposit.DEPOSIT_CONTRACT.depositTo( - clientChainLzId, + clientChainLzID, assetsAddress, stakerAddress, opAmount @@ -41,13 +41,13 @@ contract DepositCaller { } function testCallDepositToWithTryCatch( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount ) public returns (bool, uint256) { try deposit.DEPOSIT_CONTRACT.depositTo( - clientChainLzId, + clientChainLzID, assetsAddress, stakerAddress, opAmount @@ -62,7 +62,7 @@ contract DepositCaller { return (false,0); } /* function testDelegateCallDepositTo( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount @@ -70,7 +70,7 @@ contract DepositCaller { (bool success,uint256 latestAssetState) = deposit.DEPOSIT_PRECOMPILE_ADDRESS.delegatecall( abi.encodeWithSignature( "depositTo(uint16,bytes,bytes,uint256)", - clientChainLzId, + clientChainLzID, assetsAddress, stakerAddress, opAmount @@ -81,7 +81,7 @@ contract DepositCaller { } function testStaticCallDepositTo( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory stakerAddress, uint256 opAmount @@ -91,7 +91,7 @@ contract DepositCaller { .staticcall( abi.encodeWithSignature( "depositTo(uint16,bytes,bytes,uint256)", - clientChainLzId, + clientChainLzID, assetsAddress, stakerAddress, opAmount diff --git a/precompiles/withdraw/abi.json b/precompiles/withdraw/abi.json index a425cd496..5ab9282c5 100644 --- a/precompiles/withdraw/abi.json +++ b/precompiles/withdraw/abi.json @@ -3,7 +3,7 @@ "inputs":[ { "internalType":"uint16", - "name":"clientChainLzId", + "name":"clientChainLzID", "type":"uint16" }, { diff --git a/precompiles/withdraw/methods.go b/precompiles/withdraw/methods.go index 60aebb7bc..c34739601 100644 --- a/precompiles/withdraw/methods.go +++ b/precompiles/withdraw/methods.go @@ -44,8 +44,8 @@ func (p Precompile) Withdraw( return nil, err } // get the latest asset state of staker to return. - stakerId, assetId := types.GetStakeIDAndAssetId(withdrawParam.ClientChainLzId, withdrawParam.WithdrawAddress, withdrawParam.AssetsAddress) - info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(withdrawParam.ClientChainLzID, withdrawParam.WithdrawAddress, withdrawParam.AssetsAddress) + info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/precompiles/withdraw/parser.go b/precompiles/withdraw/parser.go index 740610946..79595cef9 100644 --- a/precompiles/withdraw/parser.go +++ b/precompiles/withdraw/parser.go @@ -21,9 +21,9 @@ func (p Precompile) GetWithdrawParamsFromInputs(ctx sdk.Context, args []interfac if !ok { return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } - withdrawParams.ClientChainLzId = uint64(clientChainLzID) + withdrawParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, withdrawParams.ClientChainLzId) + info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, withdrawParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/withdraw/setup_test.go b/precompiles/withdraw/setup_test.go index 7465b97d7..259b6c0b5 100644 --- a/precompiles/withdraw/setup_test.go +++ b/precompiles/withdraw/setup_test.go @@ -1,50 +1,26 @@ package withdraw_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" "github.com/ExocoreNetwork/exocore/precompiles/withdraw" - "github.com/evmos/evmos/v14/x/evm/statedb" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - evmosapp "github.com/ExocoreNetwork/exocore/app" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" "github.com/stretchr/testify/suite" ) -var s *PrecompileTestSuite - -type PrecompileTestSuite struct { - suite.Suite - - ctx sdk.Context - app *evmosapp.ExocoreApp - address common.Address - validators []stakingtypes.Validator - valSet *tmtypes.ValidatorSet - ethSigner ethtypes.Signer - privKey cryptotypes.PrivKey - signer keyring.Signer - bondDenom string +var s *WithdrawPrecompileTestSuite +type WithdrawPrecompileTestSuite struct { + testutil.BaseTestSuite precompile *withdraw.Precompile - stateDB *statedb.StateDB - - queryClientEVM evmtypes.QueryClient } func TestPrecompileTestSuite(t *testing.T) { - s = new(PrecompileTestSuite) + s = new(WithdrawPrecompileTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -52,6 +28,9 @@ func TestPrecompileTestSuite(t *testing.T) { RunSpecs(t, "Withdraw Precompile Suite") } -func (s *PrecompileTestSuite) SetupTest() { +func (s *WithdrawPrecompileTestSuite) SetupTest() { s.DoSetupTest() + precompile, err := withdraw.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.WithdrawKeeper, s.App.AuthzKeeper) + s.Require().NoError(err) + s.precompile = precompile } diff --git a/precompiles/withdraw/utils_test.go b/precompiles/withdraw/utils_test.go deleted file mode 100644 index eb69c3131..000000000 --- a/precompiles/withdraw/utils_test.go +++ /dev/null @@ -1,232 +0,0 @@ -package withdraw_test - -import ( - "encoding/json" - "time" - - evmosapp "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/precompiles/withdraw" - testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" - "github.com/ExocoreNetwork/exocore/utils" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/testutil/mock" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" - "github.com/evmos/evmos/v14/precompiles/testutil/contracts" - "github.com/evmos/evmos/v14/precompiles/vesting/testdata" - evmosutil "github.com/evmos/evmos/v14/testutil" - evmosutiltx "github.com/evmos/evmos/v14/testutil/tx" - evmostypes "github.com/evmos/evmos/v14/types" - "github.com/evmos/evmos/v14/x/evm/statedb" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" -) - -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, false)() - app, ok := appI.(*evmosapp.ExocoreApp) - s.Require().True(ok) - - // set genesis accounts - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) - delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - - bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) - - for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - s.Require().NoError(err) - pkAny, err := codectypes.NewAnyWithValue(pk) - s.Require().NoError(err) - validator := stakingtypes.Validator{ - OperatorAddress: sdk.ValAddress(val.Address).String(), - ConsensusPubkey: pkAny, - Jailed: false, - Status: stakingtypes.Bonded, - Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), - Description: stakingtypes.Description{}, - UnbondingHeight: int64(0), - UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), - } - validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - } - s.validators = validators - - // set validators and delegations - stakingParams := stakingtypes.DefaultParams() - // set bond demon to be aevmos - stakingParams.BondDenom = utils.BaseDenom - stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) - - totalBondAmt := bondAmt.Add(bondAmt) - totalSupply := sdk.NewCoins() - for _, b := range balances { - // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) - } - - // add bonded amount to bonded pool module account - balances = append(balances, banktypes.Balance{ - Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, - }) - - // update total supply - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - s.Require().NoError(err) - - // init chain will set the validator set and initialize the genesis accounts - app.InitChain( - abci.RequestInitChain{ - ChainId: cmn.DefaultChainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: evmosapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - app.Commit() - - // instantiate new header - header := evmosutil.NewHeader( - 2, - time.Now().UTC(), - cmn.DefaultChainID, - sdk.ConsAddress(validators[0].GetOperator()), - tmhash.Sum([]byte("app")), - tmhash.Sum([]byte("validators")), - ) - - app.BeginBlock(abci.RequestBeginBlock{ - Header: header, - }) - - // create Context - s.ctx = app.BaseApp.NewContext(false, header) - s.app = app -} - -func (s *PrecompileTestSuite) DoSetupTest() { - // generate validator private/public key - privVal := mock.NewPV() - pubKey, err := privVal.GetPubKey() - s.Require().NoError(err) - - privVal2 := mock.NewPV() - pubKey2, err := privVal2.GetPubKey() - s.Require().NoError(err) - - // create validator set with two validators - validator := tmtypes.NewValidator(pubKey, 1) - validator2 := tmtypes.NewValidator(pubKey2, 2) - s.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) - signers := make(map[string]tmtypes.PrivValidator) - signers[pubKey.Address().String()] = privVal - signers[pubKey2.Address().String()] = privVal2 - - // generate genesis account - addr, priv := testutiltx.NewAddrKey() - s.privKey = priv - s.address = addr - s.signer = evmosutiltx.NewSigner(priv) - - baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) - - acc := &evmostypes.EthAccount{ - BaseAccount: baseAcc, - CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), - } - - amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) - - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), - } - - s.SetupWithGenesisValSet(s.valSet, []authtypes.GenesisAccount{acc}, balance) - - // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) - - // bond denom - stakingParams := s.app.StakingKeeper.GetParams(s.ctx) - stakingParams.BondDenom = utils.BaseDenom - s.bondDenom = stakingParams.BondDenom - err = s.app.StakingKeeper.SetParams(s.ctx, stakingParams) - s.Require().NoError(err) - - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) - - precompile, err := withdraw.NewPrecompile(s.app.StakingAssetsManageKeeper, s.app.WithdrawKeeper, s.app.AuthzKeeper) - s.Require().NoError(err) - s.precompile = precompile - - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) - inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) - distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = s.app.BankKeeper.MintCoins(s.ctx, inflationtypes.ModuleName, coins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToModule(s.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - s.Require().NoError(err) - - queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) - s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) -} - -// CallType is a struct that represents the type of call to be made to -// precompile - either direct or through a smart contract. -type CallType struct { - // name is the name of the call type - name string - // directCall is true if the call is to be made directly to precompile - directCall bool -} - -// BuildCallArgs builds the call arguments for the integration test suite -// depending on the type of interaction. -func (s *PrecompileTestSuite) BuildCallArgs( - callType CallType, - contractAddr common.Address, -) contracts.CallArgs { - callArgs := contracts.CallArgs{ - PrivKey: s.privKey, - } - if callType.directCall { - callArgs.ContractABI = s.precompile.ABI - callArgs.ContractAddr = s.precompile.Address() - } else { - callArgs.ContractAddr = contractAddr - callArgs.ContractABI = testdata.VestingCallerContract.ABI - } - - return callArgs -} diff --git a/precompiles/withdraw/withdraw.sol b/precompiles/withdraw/withdraw.sol index d531d9006..79e6c25b5 100644 --- a/precompiles/withdraw/withdraw.sol +++ b/precompiles/withdraw/withdraw.sol @@ -16,12 +16,12 @@ interface IWithdraw { /// TRANSACTIONS /// @dev withdraw To the staker, that will change the state in withdraw module /// Note that this address cannot be a module account. -/// @param clientChainLzId The lzId of client chain +/// @param clientChainLzID The LzID of client chain /// @param assetsAddress The client chain asset Address /// @param withdrawAddress The withdraw address /// @param opAmount The withdraw amount function withdrawPrinciple( - uint16 clientChainLzId, + uint16 clientChainLzID, bytes memory assetsAddress, bytes memory withdrawAddress, uint256 opAmount diff --git a/precompiles/withdraw/withdraw_integrate_test.go b/precompiles/withdraw/withdraw_integrate_test.go index 7e3cc61a9..239c9d0f9 100644 --- a/precompiles/withdraw/withdraw_integrate_test.go +++ b/precompiles/withdraw/withdraw_integrate_test.go @@ -26,7 +26,7 @@ var ( passCheck testutil.LogCheckArgs ) -func (s *PrecompileTestSuite) TestCallWithdrawFromEOA() { +func (s *WithdrawPrecompileTestSuite) TestCallWithdrawFromEOA() { // withdraw params for test exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" @@ -35,8 +35,8 @@ func (s *PrecompileTestSuite) TestCallWithdrawFromEOA() { ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) - clientChainLzId := 101 - stakerAddr := paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength) + clientChainLzID := 101 + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress method := "withdrawPrinciple" @@ -47,7 +47,7 @@ func (s *PrecompileTestSuite) TestCallWithdrawFromEOA() { defaultCallArgs = contracts.CallArgs{ ContractAddr: s.precompile.Address(), ContractABI: s.precompile.ABI, - PrivKey: s.privKey, + PrivKey: s.PrivKey, } defaultLogCheck = testutil.LogCheckArgs{ @@ -57,11 +57,11 @@ func (s *PrecompileTestSuite) TestCallWithdrawFromEOA() { } prepareFunc := func(params *deposittype.Params, method string) contracts.CallArgs { - err := s.app.DepositKeeper.SetParams(s.ctx, params) + err := s.App.DepositKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) defaultWithdrawArgs := defaultCallArgs.WithMethodName(method) return defaultWithdrawArgs.WithArgs( - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, stakerAddr, opAmount) @@ -69,6 +69,6 @@ func (s *PrecompileTestSuite) TestCallWithdrawFromEOA() { beforeEach() setWithdrawArgs := prepareFunc(¶ms, method) - _, _, err := contracts.CallContractAndCheckLogs(s.ctx, s.app, setWithdrawArgs, passCheck) + _, _, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setWithdrawArgs, passCheck) s.Require().ErrorContains(err, strings.Split(withdraw.ErrContractCaller, ",")[0]) } diff --git a/precompiles/withdraw/withdraw_test.go b/precompiles/withdraw/withdraw_test.go index ad3f27bfd..38545e324 100644 --- a/precompiles/withdraw/withdraw_test.go +++ b/precompiles/withdraw/withdraw_test.go @@ -7,9 +7,8 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/withdraw" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - depositParams "github.com/ExocoreNetwork/exocore/x/deposit/types" + depositparams "github.com/ExocoreNetwork/exocore/x/deposit/types" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" - withdrawParams "github.com/ExocoreNetwork/exocore/x/withdraw/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -17,7 +16,7 @@ import ( evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) -func (s *PrecompileTestSuite) TestIsTransaction() { +func (s *WithdrawPrecompileTestSuite) TestIsTransaction() { testCases := []struct { name string method string @@ -50,10 +49,10 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { return input } -func (s *PrecompileTestSuite) TestRequiredGas() { - clientChainLzId := 101 +func (s *WithdrawPrecompileTestSuite) TestRequiredGas() { + clientChainLzID := 101 usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) - withdrawAddr := paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength) + withdrawAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress @@ -67,7 +66,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { func() []byte { input, err := s.precompile.Pack( withdraw.MethodWithdraw, - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, withdrawAddr, opAmount, @@ -93,24 +92,24 @@ func (s *PrecompileTestSuite) TestRequiredGas() { } // TestRun tests the precompiled Run method withdraw. -func (s *PrecompileTestSuite) TestRunWithdrawThroughClientChain() { +func (s *WithdrawPrecompileTestSuite) TestRunWithdrawThroughClientChain() { // deposit params for test exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := 101 + clientChainLzID := 101 withdrawAmount := big.NewInt(10) depositAmount := big.NewInt(100) assetAddr := paddingClientChainAddress(usdtAddress, types.GeneralClientChainAddrLength) depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for withdraw test params := &keeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, } - err := s.app.DepositKeeper.Deposit(s.ctx, params) + err := s.App.DepositKeeper.Deposit(s.Ctx, params) s.Require().NoError(err) } @@ -118,13 +117,13 @@ func (s *PrecompileTestSuite) TestRunWithdrawThroughClientChain() { // Prepare the call input for withdraw test input, err := s.precompile.Pack( withdraw.MethodWithdraw, - uint16(clientChainLzId), + uint16(clientChainLzID), assetAddr, - paddingClientChainAddress(s.address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), withdrawAmount, ) s.Require().NoError(err, "failed to pack input") - return s.address, input + return s.Address, input } successRet, err := s.precompile.Methods[withdraw.MethodWithdraw].Outputs.Pack(true, new(big.Int).Sub(depositAmount, withdrawAmount)) s.Require().NoError(err) @@ -139,19 +138,13 @@ func (s *PrecompileTestSuite) TestRunWithdrawThroughClientChain() { { name: "pass - withdraw via pre-compiles", malleate: func() (common.Address, []byte) { - depositModuleParam := &depositParams.Params{ - ExoCoreLzAppAddress: s.address.String(), + depositModuleParam := &depositparams.Params{ + ExoCoreLzAppAddress: s.Address.String(), ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, } - err := s.app.DepositKeeper.SetParams(s.ctx, depositModuleParam) - s.Require().NoError(err) - depositAsset(s.address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) - withdrawModuleParam := &withdrawParams.Params{ - ExoCoreLzAppAddress: s.address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, - } - err = s.app.WithdrawKeeper.SetParams(s.ctx, withdrawModuleParam) + err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) + depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) return commonMalleate() }, returnBytes: successRet, @@ -165,7 +158,7 @@ func (s *PrecompileTestSuite) TestRunWithdrawThroughClientChain() { // setup basic test suite s.SetupTest() - baseFee := s.app.FeeMarketKeeper.GetBaseFee(s.ctx) + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) // malleate testcase caller, input := tc.malleate() @@ -176,7 +169,7 @@ func (s *PrecompileTestSuite) TestRunWithdrawThroughClientChain() { contractAddr := contract.Address() // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ - ChainID: s.app.EvmKeeper.ChainID(), + ChainID: s.App.EvmKeeper.ChainID(), Nonce: 0, To: &contractAddr, Amount: nil, @@ -188,27 +181,27 @@ func (s *PrecompileTestSuite) TestRunWithdrawThroughClientChain() { } msgEthereumTx := evmtypes.NewTx(&txArgs) - msgEthereumTx.From = s.address.String() - err := msgEthereumTx.Sign(s.ethSigner, s.signer) + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) s.Require().NoError(err, "failed to sign Ethereum message") // Instantiate config - proposerAddress := s.ctx.BlockHeader().ProposerAddress - cfg, err := s.app.EvmKeeper.EVMConfig(s.ctx, proposerAddress, s.app.EvmKeeper.ChainID()) + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) s.Require().NoError(err, "failed to instantiate EVM config") - msg, err := msgEthereumTx.AsMessage(s.ethSigner, baseFee) + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) s.Require().NoError(err, "failed to instantiate Ethereum message") // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.StateDB = statedb.New(s.Ctx, s.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.Ctx.HeaderHash().Bytes()))) // Instantiate EVM - evm := s.app.EvmKeeper.NewEVM( - s.ctx, msg, cfg, nil, s.stateDB, + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, ) - params := s.app.EvmKeeper.GetParams(s.ctx) + params := s.App.EvmKeeper.GetParams(s.Ctx) activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := s.app.EvmKeeper.Precompiles(activePrecompiles...) + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) s.Require().NoError(err, "invalid precompiles", activePrecompiles) evm.WithPrecompiles(precompileMap, activePrecompiles) diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index 2f998dd83..e549fe54e 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -10,8 +10,8 @@ import "exocore/delegation/v1/tx.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/delegation/types"; message DelegationInfoReq { - string stakerId = 1; - string assetId = 2; + string stakerID = 1; + string assetID = 2; } message DelegationAmounts{ @@ -46,9 +46,9 @@ message QueryDelegationInfoResponse{ } message SingleDelegationInfoReq { - string stakerId = 1; + string stakerID = 1; string operatorAddr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string assetId = 3; + string assetID = 3; } diff --git a/proto/exocore/delegation/v1/tx.proto b/proto/exocore/delegation/v1/tx.proto index 2cb9e2a2d..2935de760 100644 --- a/proto/exocore/delegation/v1/tx.proto +++ b/proto/exocore/delegation/v1/tx.proto @@ -19,7 +19,7 @@ message ValueField { } message DelegatedSingleAssetInfo { - string AssetId = 1; + string AssetID = 1; string TotalDelegatedAmount = 2 [ (cosmos_proto.scalar) = "cosmos.Int", @@ -52,8 +52,8 @@ message MsgDelegation{ } message UndelegationRecord{ - string stakerId = 1; - string assetId = 2; + string stakerID = 1; + string assetID = 2; string OperatorAddr = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; string txHash = 4; diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index ec5facdb2..3be495ba4 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -13,7 +13,7 @@ message clientChainEarningAddrList { } message clientChainEarningAddrInfo { - uint64 lzClientChainId = 1; + uint64 lzClientChainID = 1; string clientChainEarningAddr = 2; } diff --git a/proto/exocore/restaking_assets_manage/v1/query.proto b/proto/exocore/restaking_assets_manage/v1/query.proto index 00ee592db..c9ad6aca8 100644 --- a/proto/exocore/restaking_assets_manage/v1/query.proto +++ b/proto/exocore/restaking_assets_manage/v1/query.proto @@ -19,7 +19,7 @@ message QueryAllClientChainInfoResponse{ } message QueryStakingAssetInfo{ - string assetId = 1; + string assetID = 1; } message QueryAllStakingAssetsInfo{} @@ -28,15 +28,15 @@ message QueryAllStakingAssetsInfoResponse{ } message QueryStakerAssetInfo{ - string stakerId = 1; + string stakerID = 1; } message QueryAssetInfoResponse{ map assetInfos = 1; } message QuerySpecifiedAssetAmountReq{ - string stakerId = 1; - string assetId = 2; + string stakerID = 1; + string assetID = 2; } @@ -50,11 +50,11 @@ message QueryOperatorAssetInfosResponse{ message QueryOperatorSpecifiedAssetAmountReq{ string operatorAddr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string assetId = 2; + string assetID = 2; } message QueryStakerExCoreAddr { - string StakerId = 1; + string StakerID = 1; } message QueryStakerExCoreAddrResponse{ @@ -104,7 +104,7 @@ service Query { rpc QueStakerExoCoreAddr(QueryStakerExCoreAddr) returns (QueryStakerExCoreAddrResponse) { option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakerExoCoreAddr/{StakerId}"; + option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakerExoCoreAddr/{StakerID}"; } } diff --git a/proto/exocore/withdraw/query.proto b/proto/exocore/withdraw/query.proto deleted file mode 100644 index b8c03dcf8..000000000 --- a/proto/exocore/withdraw/query.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package exocore.withdraw; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "exocore/deposit/v1/deposit.proto"; - -option go_package = "github.com/ExocoreNetwork/exocore/x/withdraw/types"; - -// Query defines the gRPC querier service. -service Query { - // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/exocore/withdraw/params"; - } -} - -// QueryParamsRequest is request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is response type for the Query/Params RPC method. -message QueryParamsResponse { - // params holds all the parameters of this module. - exocore.deposit.v1.Params params = 1; -} \ No newline at end of file diff --git a/proto/exocore/withdraw/tx.proto b/proto/exocore/withdraw/tx.proto deleted file mode 100644 index c97b62031..000000000 --- a/proto/exocore/withdraw/tx.proto +++ /dev/null @@ -1,35 +0,0 @@ - -syntax = "proto3"; -package exocore.withdraw; - -import "cosmos/msg/v1/msg.proto"; -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; -import "amino/amino.proto"; -import "exocore/deposit/v1/deposit.proto"; -option go_package = "github.com/ExocoreNetwork/exocore/x/withdraw/types"; - -// MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 -message MsgUpdateParams { - // todo: temporarily not update configuration through gov module - option (cosmos.msg.v1.signer) = "authority"; - // authority is the address of the governance account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - - // params defines the x/evm parameters to update. - // NOTE: All parameters must be supplied. - exocore.deposit.v1.Params params = 2 [(gogoproto.nullable) = false]; -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// Since: cosmos-sdk 0.47 -message MsgUpdateParamsResponse {} - -service Msg { - - option (cosmos.msg.v1.service) = true; - - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); -} diff --git a/testutil/abci.go b/testutil/abci.go index 45a3a12e6..ca29b6566 100644 --- a/testutil/abci.go +++ b/testutil/abci.go @@ -32,7 +32,7 @@ func Commit(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.V return ctx.WithBlockHeader(header), nil } -// CommitAndCreateNewCtx commits a block at a given time creating a ctx with the current settings +// CommitAndCreateNewCtx commits a block at a given time creating a Ctx with the current settings // This is useful to keep test settings that could be affected by EndBlockers, e.g. // setting a baseFee == 0 and expecting this condition to continue after commit func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.ValidatorSet, isUncachedCtx bool) (sdk.Context, error) { @@ -51,7 +51,7 @@ func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration newCtx = app.BaseApp.NewContext(false, header) } - // set the reseted fields to keep the current ctx settings + // set the reseted fields to keep the current Ctx settings newCtx = newCtx.WithMinGasPrices(ctx.MinGasPrices()) newCtx = newCtx.WithEventManager(ctx.EventManager()) newCtx = newCtx.WithKVGasConfig(ctx.KVGasConfig()) @@ -63,7 +63,7 @@ func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration // DeliverTx delivers a cosmos tx for a given set of msgs func DeliverTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv cryptotypes.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg, @@ -71,7 +71,7 @@ func DeliverTx( txConfig := encoding.MakeConfig(app.ModuleBasics).TxConfig tx, err := tx.PrepareCosmosTx( ctx, - appEvmos, + appExocore, tx.CosmosTxArgs{ TxCfg: txConfig, Priv: priv, @@ -84,7 +84,7 @@ func DeliverTx( if err != nil { return abci.ResponseDeliverTx{}, err } - return BroadcastTxBytes(appEvmos, txConfig.TxEncoder(), tx) + return BroadcastTxBytes(appExocore, txConfig.TxEncoder(), tx) } // DeliverEthTx generates and broadcasts a Cosmos Tx populated with MsgEthereumTx messages. @@ -118,18 +118,18 @@ func DeliverEthTx( // otherwise, it will assume the messages have already been signed. It does not check if the Eth tx is // successful or not. func DeliverEthTxWithoutCheck( - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv cryptotypes.PrivKey, msgs ...sdk.Msg, ) (abci.ResponseDeliverTx, error) { txConfig := encoding.MakeConfig(app.ModuleBasics).TxConfig - tx, err := tx.PrepareEthTx(txConfig, appEvmos, priv, msgs...) + tx, err := tx.PrepareEthTx(txConfig, appExocore, priv, msgs...) if err != nil { return abci.ResponseDeliverTx{}, err } - res, err := BroadcastTxBytes(appEvmos, txConfig.TxEncoder(), tx) + res, err := BroadcastTxBytes(appExocore, txConfig.TxEncoder(), tx) if err != nil { return abci.ResponseDeliverTx{}, err } @@ -140,7 +140,7 @@ func DeliverEthTxWithoutCheck( // CheckTx checks a cosmos tx for a given set of msgs func CheckTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv cryptotypes.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg, @@ -149,7 +149,7 @@ func CheckTx( tx, err := tx.PrepareCosmosTx( ctx, - appEvmos, + appExocore, tx.CosmosTxArgs{ TxCfg: txConfig, Priv: priv, @@ -162,25 +162,25 @@ func CheckTx( if err != nil { return abci.ResponseCheckTx{}, err } - return checkTxBytes(appEvmos, txConfig.TxEncoder(), tx) + return checkTxBytes(appExocore, txConfig.TxEncoder(), tx) } // CheckEthTx checks a Ethereum tx for a given set of msgs func CheckEthTx( - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv cryptotypes.PrivKey, msgs ...sdk.Msg, ) (abci.ResponseCheckTx, error) { txConfig := encoding.MakeConfig(app.ModuleBasics).TxConfig - tx, err := tx.PrepareEthTx(txConfig, appEvmos, priv, msgs...) + tx, err := tx.PrepareEthTx(txConfig, appExocore, priv, msgs...) if err != nil { return abci.ResponseCheckTx{}, err } - return checkTxBytes(appEvmos, txConfig.TxEncoder(), tx) + return checkTxBytes(appExocore, txConfig.TxEncoder(), tx) } -// BroadcastTxBytes encodes a transaction and calls DeliverTx on the app. +// BroadcastTxBytes encodes a transaction and calls DeliverTx on the App. func BroadcastTxBytes(app *app.ExocoreApp, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.ResponseDeliverTx, error) { // bz are bytes to be broadcasted over the network bz, err := txEncoder(tx) @@ -228,7 +228,7 @@ func commit(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.V return header, nil } -// checkTxBytes encodes a transaction and calls checkTx on the app. +// checkTxBytes encodes a transaction and calls checkTx on the App. func checkTxBytes(app *app.ExocoreApp, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.ResponseCheckTx, error) { bz, err := txEncoder(tx) if err != nil { diff --git a/testutil/ante.go b/testutil/ante.go index 22032f884..f9fdfa990 100644 --- a/testutil/ante.go +++ b/testutil/ante.go @@ -10,7 +10,7 @@ import ( // the next function in the AnteHandler chain. // // It can be used in unit tests when calling a decorator's AnteHandle method, e.g. -// `dec.AnteHandle(ctx, tx, false, NextFn)` +// `dec.AnteHandle(Ctx, tx, false, NextFn)` func NextFn(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) { return ctx, nil } diff --git a/testutil/contract.go b/testutil/contract.go index 27ac88ba6..8ea51b668 100644 --- a/testutil/contract.go +++ b/testutil/contract.go @@ -23,7 +23,7 @@ import ( // ContractArgs are the params used for calling a smart contract. type ContractArgs struct { - // Addr is the address of the contract to call. + // Addr is the Address of the contract to call. Addr common.Address // ABI is the ABI of the contract to call. ABI abi.ABI @@ -39,7 +39,7 @@ type ContractCallArgs struct { Contract ContractArgs // Nonce is the nonce to use for the transaction. Nonce *big.Int - // Amount is the aevmos amount to send in the transaction. + // Amount is the aexo amount to send in the transaction. Amount *big.Int // GasLimit to use for the transaction GasLimit uint64 @@ -51,15 +51,15 @@ type ContractCallArgs struct { // compiled contract data and constructor arguments func DeployContract( ctx sdk.Context, - evmosApp *app.ExocoreApp, + exocoreApp *app.ExocoreApp, priv cryptotypes.PrivKey, queryClientEvm evm.QueryClient, contract evm.CompiledContract, constructorArgs ...interface{}, ) (common.Address, error) { - chainID := evmosApp.EvmKeeper.ChainID() + chainID := exocoreApp.EvmKeeper.ChainID() from := common.BytesToAddress(priv.PubKey().Address().Bytes()) - nonce := evmosApp.EvmKeeper.GetNonce(ctx, from) + nonce := exocoreApp.EvmKeeper.GetNonce(ctx, from) ctorArgs, err := contract.ABI.Pack("", constructorArgs...) if err != nil { @@ -76,19 +76,19 @@ func DeployContract( ChainID: chainID, Nonce: nonce, GasLimit: gas, - GasFeeCap: evmosApp.FeeMarketKeeper.GetBaseFee(ctx), + GasFeeCap: exocoreApp.FeeMarketKeeper.GetBaseFee(ctx), GasTipCap: big.NewInt(1), Input: data, Accesses: ðtypes.AccessList{}, }) msgEthereumTx.From = from.String() - res, err := DeliverEthTx(evmosApp, priv, msgEthereumTx) + res, err := DeliverEthTx(exocoreApp, priv, msgEthereumTx) if err != nil { return common.Address{}, err } - if _, err := CheckEthTxResponse(res, evmosApp.AppCodec()); err != nil { + if _, err := CheckEthTxResponse(res, exocoreApp.AppCodec()); err != nil { return common.Address{}, err } diff --git a/testutil/fund.go b/testutil/fund.go index dfc19878e..459bcde83 100644 --- a/testutil/fund.go +++ b/testutil/fund.go @@ -1,14 +1,14 @@ package testutil import ( + "github.com/ExocoreNetwork/exocore/utils" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/evmos/evmos/v14/utils" inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" ) // FundAccount is a utility function that funds an account by minting and -// sending the coins to the address. +// sending the coins to the Address. func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amounts sdk.Coins) error { if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil { return err @@ -27,7 +27,7 @@ func FundAccountWithBaseDenom(ctx sdk.Context, bankKeeper bankkeeper.Keeper, add } // FundModuleAccount is a utility function that funds a module account by -// minting and sending the coins to the address. +// minting and sending the coins to the Address. func FundModuleAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, recipientMod string, amounts sdk.Coins) error { if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil { return err diff --git a/testutil/integration.go b/testutil/integration.go index e795a1d13..dfaa91a96 100644 --- a/testutil/integration.go +++ b/testutil/integration.go @@ -18,7 +18,7 @@ import ( // event. func SubmitProposal( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, pk *ethsecp256k1.PrivKey, content govv1beta1.Content, eventNum int, @@ -31,7 +31,7 @@ func SubmitProposal( if err != nil { return id, err } - res, err := DeliverTx(ctx, appEvmos, pk, nil, msg) + res, err := DeliverTx(ctx, appExocore, pk, nil, msg) if err != nil { return id, err } @@ -47,7 +47,7 @@ func SubmitProposal( // Delegate delivers a delegate tx func Delegate( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv *ethsecp256k1.PrivKey, delegateAmount sdk.Coin, validator stakingtypes.Validator, @@ -60,13 +60,13 @@ func Delegate( } delegateMsg := stakingtypes.NewMsgDelegate(accountAddress, val, delegateAmount) - return DeliverTx(ctx, appEvmos, priv, nil, delegateMsg) + return DeliverTx(ctx, appExocore, priv, nil, delegateMsg) } // Vote delivers a vote tx with the VoteOption "yes" func Vote( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv *ethsecp256k1.PrivKey, proposalID uint64, voteOption govv1beta1.VoteOption, @@ -74,5 +74,5 @@ func Vote( accountAddress := sdk.AccAddress(priv.PubKey().Address().Bytes()) voteMsg := govv1beta1.NewMsgVote(accountAddress, proposalID, voteOption) - return DeliverTx(ctx, appEvmos, priv, nil, voteMsg) + return DeliverTx(ctx, appExocore, priv, nil, voteMsg) } diff --git a/testutil/network/network.go b/testutil/network/network.go index 85593918e..513e044d1 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -99,7 +99,7 @@ type Config struct { // testing requirements. func DefaultConfig() Config { encCfg := encoding.MakeConfig(app.ModuleBasics) - chainID := fmt.Sprintf("evmos_%d-1", tmrand.Int63n(9999999999999)+1) + chainID := fmt.Sprintf("exocore_%d-1", tmrand.Int63n(9999999999999)+1) return Config{ Codec: encCfg.Codec, TxConfig: encCfg.TxConfig, @@ -111,7 +111,7 @@ func DefaultConfig() Config { TimeoutCommit: 3 * time.Second, ChainID: chainID, NumValidators: 4, - BondDenom: "aevmos", + BondDenom: "aexo", MinGasPrices: fmt.Sprintf("0.000006%s", evmostypes.AttoEvmos), AccountTokens: sdk.TokensFromConsensusPower(1000000000000000000, evmostypes.PowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500000000000000000, evmostypes.PowerReduction), diff --git a/testutil/network/network_test.go b/testutil/network/network_test.go index 2844a9cc6..e412fef33 100644 --- a/testutil/network/network_test.go +++ b/testutil/network/network_test.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/evmos/evmos/v14/server/config" - evmosnetwork "github.com/ExocoreNetwork/exocore/testutil/network" + exocorenetwork "github.com/ExocoreNetwork/exocore/testutil/network" ) type IntegrationTestSuite struct { @@ -27,7 +27,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") var err error - cfg := evmosnetwork.DefaultConfig() + cfg := exocorenetwork.DefaultConfig() cfg.JSONRPCAddress = config.DefaultJSONRPCAddress cfg.NumValidators = 1 diff --git a/testutil/staking-rewards.go b/testutil/staking-rewards.go index 070ad7554..ac6cabefa 100644 --- a/testutil/staking-rewards.go +++ b/testutil/staking-rewards.go @@ -7,6 +7,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" + "github.com/ExocoreNetwork/exocore/utils" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +17,6 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" teststaking "github.com/cosmos/cosmos-sdk/x/staking/testutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/evmos/evmos/v14/utils" "github.com/stretchr/testify/require" ) @@ -44,7 +44,7 @@ func CreateValidator(ctx sdk.Context, t *testing.T, pubKey cryptotypes.PubKey, s // such that the given amount of tokens is outstanding as a staking reward for the account. // // The setup is done in the following way: -// - Fund the account with the given address with the given balance. +// - Fund the account with the given Address with the given balance. // - If the given balance is zero, the account will be created with zero balance. // // For every reward defined in the rewards argument, the following steps are executed: @@ -54,7 +54,7 @@ func CreateValidator(ctx sdk.Context, t *testing.T, pubKey cryptotypes.PubKey, s // The function returns the updated context along with a potential error. func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app *app.ExocoreApp, addr sdk.AccAddress, balance sdkmath.Int, rewards ...sdkmath.Int) (sdk.Context, error) { // Calculate the necessary amount of tokens to fund the account in order for the desired residual balance to - // be left after creating validators and delegating to them. + // be left after creating Validators and delegating to them. totalRewards := sdk.ZeroInt() for _, reward := range rewards { totalRewards = totalRewards.Add(reward) @@ -112,7 +112,7 @@ func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app *app stakingHelper.Denom = utils.BaseDenom valAddr := sdk.ValAddress(addr2.Bytes()) - // self-delegate the same amount of tokens as the delegate address also stakes + // self-delegate the same amount of tokens as the delegate Address also stakes // this ensures, that the delegation rewards are 50% of the total rewards stakingHelper.CreateValidator(valAddr, privKey.PubKey(), reward, true) stakingHelper.Delegate(addr, valAddr, reward) @@ -131,7 +131,7 @@ func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app *app } // GetTotalDelegationRewards returns the total delegation rewards that are currently -// outstanding for the given address. +// outstanding for the given Address. func GetTotalDelegationRewards(ctx sdk.Context, distributionKeeper distributionkeeper.Keeper, addr sdk.AccAddress) (sdk.DecCoins, error) { querier := distributionkeeper.NewQuerier(distributionKeeper) resp, err := querier.DelegationTotalRewards( diff --git a/testutil/tx/cosmos.go b/testutil/tx/cosmos.go index ee9dee3c3..9051dd01b 100644 --- a/testutil/tx/cosmos.go +++ b/testutil/tx/cosmos.go @@ -12,7 +12,7 @@ import ( authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/ExocoreNetwork/exocore/app" - "github.com/evmos/evmos/v14/utils" + "github.com/ExocoreNetwork/exocore/utils" ) var ( @@ -44,7 +44,7 @@ type CosmosTxArgs struct { // It returns the signed transaction and an error func PrepareCosmosTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, args CosmosTxArgs, ) (authsigning.Tx, error) { txBuilder := args.TxCfg.NewTxBuilder() @@ -67,7 +67,7 @@ func PrepareCosmosTx( return signCosmosTx( ctx, - appEvmos, + appExocore, args, txBuilder, ) @@ -77,12 +77,12 @@ func PrepareCosmosTx( // the provided private key func signCosmosTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, args CosmosTxArgs, txBuilder client.TxBuilder, ) (authsigning.Tx, error) { addr := sdk.AccAddress(args.Priv.PubKey().Address().Bytes()) - seq, err := appEvmos.AccountKeeper.GetSequence(ctx, addr) + seq, err := appExocore.AccountKeeper.GetSequence(ctx, addr) if err != nil { return nil, err } @@ -105,7 +105,7 @@ func signCosmosTx( } // Second round: all signer infos are set, so each signer can sign. - accNumber := appEvmos.AccountKeeper.GetAccount(ctx, addr).GetAccountNumber() + accNumber := appExocore.AccountKeeper.GetAccount(ctx, addr).GetAccountNumber() signerData := authsigning.SignerData{ ChainID: args.ChainID, AccountNumber: accNumber, diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index 65a6a37b3..e845453c3 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -50,12 +50,12 @@ type legacyWeb3ExtensionArgs struct { // It returns the signed transaction and an error func CreateEIP712CosmosTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, args EIP712TxArgs, ) (sdk.Tx, error) { builder, err := PrepareEIP712CosmosTx( ctx, - appEvmos, + appExocore, args, ) return builder.GetTx(), err @@ -66,7 +66,7 @@ func CreateEIP712CosmosTx( // It returns the tx builder with the signed transaction and an error func PrepareEIP712CosmosTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, args EIP712TxArgs, ) (client.TxBuilder, error) { txArgs := args.CosmosTxArgs @@ -78,9 +78,9 @@ func PrepareEIP712CosmosTx( chainIDNum := pc.Uint64() from := sdk.AccAddress(txArgs.Priv.PubKey().Address().Bytes()) - accNumber := appEvmos.AccountKeeper.GetAccount(ctx, from).GetAccountNumber() + accNumber := appExocore.AccountKeeper.GetAccount(ctx, from).GetAccountNumber() - nonce, err := appEvmos.AccountKeeper.GetSequence(ctx, from) + nonce, err := appExocore.AccountKeeper.GetSequence(ctx, from) if err != nil { return nil, err } @@ -117,7 +117,7 @@ func PrepareEIP712CosmosTx( return signCosmosEIP712Tx( ctx, - appEvmos, + appExocore, args, builder, chainIDNum, @@ -129,7 +129,7 @@ func PrepareEIP712CosmosTx( // the provided private key and the typed data func signCosmosEIP712Tx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, args EIP712TxArgs, builder authtx.ExtensionOptionsTxBuilder, chainID uint64, @@ -138,7 +138,7 @@ func signCosmosEIP712Tx( priv := args.CosmosTxArgs.Priv from := sdk.AccAddress(priv.PubKey().Address().Bytes()) - nonce, err := appEvmos.AccountKeeper.GetSequence(ctx, from) + nonce, err := appExocore.AccountKeeper.GetSequence(ctx, from) if err != nil { return nil, err } diff --git a/testutil/tx/eth.go b/testutil/tx/eth.go index e739a13c1..84aec52c2 100644 --- a/testutil/tx/eth.go +++ b/testutil/tx/eth.go @@ -17,8 +17,8 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ExocoreNetwork/exocore/app" + "github.com/ExocoreNetwork/exocore/utils" "github.com/evmos/evmos/v14/server/config" - "github.com/evmos/evmos/v14/utils" evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) @@ -26,13 +26,13 @@ import ( // It returns the signed transaction and an error func PrepareEthTx( txCfg client.TxConfig, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, priv cryptotypes.PrivKey, msgs ...sdk.Msg, ) (authsigning.Tx, error) { txBuilder := txCfg.NewTxBuilder() - signer := ethtypes.LatestSignerForChainID(appEvmos.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(appExocore.EvmKeeper.ChainID()) txFee := sdk.Coins{} txGasLimit := uint64(0) @@ -89,7 +89,7 @@ func PrepareEthTx( // Should this not be the case, just pass in zero. func CreateEthTx( ctx sdk.Context, - appEvmos *app.ExocoreApp, + appExocore *app.ExocoreApp, privKey cryptotypes.PrivKey, from sdk.AccAddress, dest sdk.AccAddress, @@ -98,17 +98,17 @@ func CreateEthTx( ) (*evmtypes.MsgEthereumTx, error) { toAddr := common.BytesToAddress(dest.Bytes()) fromAddr := common.BytesToAddress(from.Bytes()) - chainID := appEvmos.EvmKeeper.ChainID() + chainID := appExocore.EvmKeeper.ChainID() // When we send multiple Ethereum Tx's in one Cosmos Tx, we need to increment the nonce for each one. - nonce := appEvmos.EvmKeeper.GetNonce(ctx, fromAddr) + uint64(nonceIncrement) + nonce := appExocore.EvmKeeper.GetNonce(ctx, fromAddr) + uint64(nonceIncrement) evmTxParams := &evmtypes.EvmTxArgs{ ChainID: chainID, Nonce: nonce, To: &toAddr, Amount: amount, GasLimit: 100000, - GasFeeCap: appEvmos.FeeMarketKeeper.GetBaseFee(ctx), + GasFeeCap: appExocore.FeeMarketKeeper.GetBaseFee(ctx), GasTipCap: big.NewInt(1), Accesses: ðtypes.AccessList{}, } @@ -117,7 +117,7 @@ func CreateEthTx( // If we are creating multiple eth Tx's with different senders, we need to sign here rather than later. if privKey != nil { - signer := ethtypes.LatestSignerForChainID(appEvmos.EvmKeeper.ChainID()) + signer := ethtypes.LatestSignerForChainID(appExocore.EvmKeeper.ChainID()) err := msgEthereumTx.Sign(signer, NewSigner(privKey)) if err != nil { return nil, err diff --git a/x/operator/keeper/utils_test.go b/testutil/utils.go similarity index 59% rename from x/operator/keeper/utils_test.go rename to testutil/utils.go index f8b0243f7..1ddbf5e4a 100644 --- a/x/operator/keeper/utils_test.go +++ b/testutil/utils.go @@ -1,12 +1,16 @@ -package keeper_test +package testutil import ( "encoding/json" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" + "github.com/evmos/evmos/v14/testutil" + "github.com/stretchr/testify/suite" "golang.org/x/exp/rand" "time" - "github.com/ExocoreNetwork/exocore/testutil" testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" exocoreapp "github.com/ExocoreNetwork/exocore/app" @@ -21,24 +25,55 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - cmn "github.com/evmos/evmos/v14/precompiles/common" evmostypes "github.com/evmos/evmos/v14/types" "github.com/evmos/evmos/v14/x/evm/statedb" evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" ) +type BaseTestSuite struct { + suite.Suite + + Ctx sdk.Context + App *exocoreapp.ExocoreApp + Address common.Address + AccAddress sdk.AccAddress + + Validators []stakingtypes.Validator + ValSet *tmtypes.ValidatorSet + EthSigner ethtypes.Signer + PrivKey cryptotypes.PrivKey + Signer keyring.Signer + BondDenom string + StateDB *statedb.StateDB + QueryClientEVM evmtypes.QueryClient + + //needed by test + /* operatorAddr sdk.AccAddress + avsAddr string + assetID string + stakerID string + assetAddr common.Address + assetDecimal uint32 + clientChainLzID uint64 + depositAmount sdkmath.Int + delegationAmount sdkmath.Int + updatedAmountForOptIn sdkmath.Int*/ +} + +func (suite *BaseTestSuite) SetupTest() { + suite.DoSetupTest() +} + // SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. -func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { +func (suite *BaseTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) - appI, genesisState := exocoreapp.SetupTestingApp(cmn.DefaultChainID, &pruneOpts, false)() + appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, false)() app, ok := appI.(*exocoreapp.ExocoreApp) suite.Require().True(ok) @@ -72,9 +107,9 @@ func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSe validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) } - suite.validators = validators + suite.Validators = validators - // set validators and delegations + // set Validators and delegations stakingParams := stakingtypes.DefaultParams() // set bond demon to be aevmos stakingParams.BondDenom = utils.BaseDenom @@ -104,7 +139,7 @@ func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSe // init chain will set the validator set and initialize the genesis accounts app.InitChain( abci.RequestInitChain{ - ChainId: cmn.DefaultChainID, + ChainId: utils.DefaultChainID, Validators: []abci.ValidatorUpdate{}, ConsensusParams: exocoreapp.DefaultConsensusParams, AppStateBytes: stateBytes, @@ -116,10 +151,10 @@ func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSe header := testutil.NewHeader( 2, time.Now().UTC(), - cmn.DefaultChainID, + utils.DefaultChainID, sdk.ConsAddress(validators[0].GetOperator()), - tmhash.Sum([]byte("app")), - tmhash.Sum([]byte("validators")), + tmhash.Sum([]byte("App")), + tmhash.Sum([]byte("Validators")), ) app.BeginBlock(abci.RequestBeginBlock{ @@ -127,11 +162,11 @@ func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSe }) // need to create UncachedContext when retrieving historical state - suite.ctx = app.BaseApp.NewUncachedContext(false, header) - suite.app = app + suite.Ctx = app.BaseApp.NewUncachedContext(false, header) + suite.App = app } -func (suite *KeeperTestSuite) DoSetupTest() { +func (suite *BaseTestSuite) DoSetupTest() { // generate validator private/public key privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() @@ -141,69 +176,83 @@ func (suite *KeeperTestSuite) DoSetupTest() { pubKey2, err := privVal2.GetPubKey() suite.Require().NoError(err) - // create validator set with two validators + // create validator set with two Validators validator := tmtypes.NewValidator(pubKey, 1) validator2 := tmtypes.NewValidator(pubKey2, 2) - suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) + suite.ValSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) signers := make(map[string]tmtypes.PrivValidator) signers[pubKey.Address().String()] = privVal signers[pubKey2.Address().String()] = privVal2 - // accAddress + // create AccAddress for test pubBz := make([]byte, ed25519.PubKeySize) pub := &ed25519.PubKey{Key: pubBz} rand.Read(pub.Key) - suite.accAddress = sdk.AccAddress(pub.Address()) + suite.AccAddress = sdk.AccAddress(pub.Address()) // generate genesis account addr, priv := testutiltx.NewAddrKey() - suite.privKey = priv - suite.address = addr - suite.signer = testutiltx.NewSigner(priv) - + suite.PrivKey = priv + suite.Address = addr + suite.Signer = testutiltx.NewSigner(priv) baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) - acc := &evmostypes.EthAccount{ BaseAccount: baseAcc, CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), } - + // set amount for genesis account amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) - balance := banktypes.Balance{ Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), } - suite.SetupWithGenesisValSet(suite.valSet, []authtypes.GenesisAccount{acc}, balance) + // Initialize an ExocoreApp for test + suite.SetupWithGenesisValSet(suite.ValSet, []authtypes.GenesisAccount{acc}, balance) // Create StateDB - suite.stateDB = statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) + suite.StateDB = statedb.New(suite.Ctx, suite.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.Ctx.HeaderHash().Bytes()))) // bond denom - stakingParams := suite.app.StakingKeeper.GetParams(suite.ctx) - stakingParams.BondDenom = utils.BaseDenom - suite.bondDenom = stakingParams.BondDenom - err = suite.app.StakingKeeper.SetParams(suite.ctx, stakingParams) - suite.Require().NoError(err) - - suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) - - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) - inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) - distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) - err = suite.app.BankKeeper.MintCoins(suite.ctx, inflationtypes.ModuleName, coins) - suite.Require().NoError(err) - err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) - suite.Require().NoError(err) - err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) - suite.Require().NoError(err) + /* stakingParams := suite.App.StakingKeeper.GetParams(suite.Ctx) + stakingParams.BondDenom = utils.BaseDenom + suite.BondDenom = stakingParams.BondDenom + err = suite.App.StakingKeeper.SetParams(suite.Ctx, stakingParams) + suite.Require().NoError(err)*/ + + suite.BondDenom = utils.BaseDenom + suite.EthSigner = ethtypes.LatestSignerForChainID(suite.App.EvmKeeper.ChainID()) + + queryHelperEvm := baseapp.NewQueryServerTestHelper(suite.Ctx, suite.App.InterfaceRegistry()) + evmtypes.RegisterQueryServer(queryHelperEvm, suite.App.EvmKeeper) + suite.QueryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) + + /* coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) + inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) + distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) + err = suite.App.BankKeeper.MintCoins(suite.Ctx, inflationtypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.App.BankKeeper.SendCoinsFromModuleToModule(suite.Ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) + suite.Require().NoError(err) + err = suite.App.BankKeeper.SendCoinsFromModuleToModule(suite.Ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) + suite.Require().NoError(err)*/ +} +// DeployContract deploys a contract that calls the deposit precompile's methods for testing purposes. +func (suite *BaseTestSuite) DeployContract(contract evmtypes.CompiledContract) (addr common.Address, err error) { + addr, err = DeployContract( + suite.Ctx, + suite.App, + suite.PrivKey, + suite.QueryClientEVM, + contract, + ) + return } // NextBlock commits the current block and sets up the next block. -func (suite *KeeperTestSuite) NextBlock() { +func (suite *BaseTestSuite) NextBlock() { var err error - suite.ctx, err = testutil.CommitAndCreateNewCtx(suite.ctx, suite.app, time.Second, suite.valSet, true) + suite.Ctx, err = CommitAndCreateNewCtx(suite.Ctx, suite.App, time.Second, suite.ValSet, true) suite.Require().NoError(err) } diff --git a/utils/utils.go b/utils/utils.go index 121c91017..cbbc672ec 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -20,6 +20,8 @@ const ( // TestnetChainID defines the Evmos EIP155 chain ID for testnet // TODO: the testnet chainid is still under consideration and need to be finalized later TestnetChainID = "exocoretestnet_233" + // DefaultChainID is the standard chain id used for testing purposes + DefaultChainID = MainnetChainID + "-1" // BaseDenom defines the Evmos mainnet denomination BaseDenom = "aexo" ) @@ -62,11 +64,11 @@ func IsSupportedKey(pubkey cryptotypes.PubKey) bool { } } -// GetEvmosAddressFromBech32 returns the sdk.Account address of given address, +// 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`). // The function fails if the provided bech32 address is invalid. -func GetEvmosAddressFromBech32(address string) (sdk.AccAddress, error) { +func GetExocoreAddressFromBech32(address string) (sdk.AccAddress, error) { bech32Prefix := strings.SplitN(address, "1", 2)[0] if bech32Prefix == address { return nil, errorsmod.Wrapf(errortypes.ErrInvalidAddress, "invalid bech32 address: %s", address) diff --git a/utils/utils_test.go b/utils/utils_test.go index f3e547835..5240ce5a0 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -17,7 +17,7 @@ import ( func init() { cfg := sdk.GetConfig() - cfg.SetBech32PrefixForAccount("evmos", "evmospub") + cfg.SetBech32PrefixForAccount("exo", "exopub") } func TestIsSupportedKeys(t *testing.T) { @@ -73,7 +73,7 @@ func TestIsSupportedKeys(t *testing.T) { } } -func TestGetEvmosAddressFromBech32(t *testing.T) { +func TestGetExocoreAddressFromBech32(t *testing.T) { testCases := []struct { name string address string @@ -88,38 +88,38 @@ func TestGetEvmosAddressFromBech32(t *testing.T) { }, { "invalid bech32 address", - "evmos", + "exocore", "", true, }, { "invalid address bytes", - "evmos1123", + "exocore1123", "", true, }, { - "evmos address", - "evmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueuafmxps", - "evmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueuafmxps", + "exocore address", + "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", + "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", false, }, { "cosmos address", "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc", - "evmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueuafmxps", + "exo1qql8ag4cluz6r4dz28p3w00dnc9w8ueu83talg", false, }, { "osmosis address", "osmo1qql8ag4cluz6r4dz28p3w00dnc9w8ueuhnecd2", - "evmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueuafmxps", + "exo1qql8ag4cluz6r4dz28p3w00dnc9w8ueu83talg", false, }, } for _, tc := range testCases { - addr, err := GetEvmosAddressFromBech32(tc.address) + addr, err := GetExocoreAddressFromBech32(tc.address) if tc.expError { require.Error(t, err, tc.name) } else { @@ -129,7 +129,7 @@ func TestGetEvmosAddressFromBech32(t *testing.T) { } } -func TestEvmosCoinDenom(t *testing.T) { +func TestExocoreCoinDenom(t *testing.T) { testCases := []struct { name string denom string @@ -137,7 +137,7 @@ func TestEvmosCoinDenom(t *testing.T) { }{ { "valid denom - native coin", - "aevmos", + "aexo", false, }, { diff --git a/x/delegation/client/cli/query.go b/x/delegation/client/cli/query.go index ec77dab3f..305e37831 100644 --- a/x/delegation/client/cli/query.go +++ b/x/delegation/client/cli/query.go @@ -33,7 +33,7 @@ func GetQueryCmd() *cobra.Command { // QuerySingleDelegationInfo queries the single delegation info func QuerySingleDelegationInfo() *cobra.Command { cmd := &cobra.Command{ - Use: "QuerySingleDelegationInfo clientChainId stakerAddr assetAddr operatorAddr", + Use: "QuerySingleDelegationInfo clientChainID stakerAddr assetAddr operatorAddr", Short: "Get single delegation info", Long: "Get single delegation info", Args: cobra.ExactArgs(4), @@ -44,14 +44,14 @@ func QuerySingleDelegationInfo() *cobra.Command { } queryClient := delegationtype.NewQueryClient(clientCtx) - clientChainLzId, err := strconv.ParseUint(args[0], 10, 64) + clientChainLzID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) } - stakerId, assetId := types.GetStakeIDAndAssetIdFromStr(clientChainLzId, args[1], args[2]) + stakerID, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, args[1], args[2]) req := &delegationtype.SingleDelegationInfoReq{ - StakerId: stakerId, - AssetId: assetId, + StakerID: stakerID, + AssetID: assetID, OperatorAddr: args[3], } res, err := queryClient.QuerySingleDelegationInfo(context.Background(), req) @@ -69,7 +69,7 @@ func QuerySingleDelegationInfo() *cobra.Command { // QueryDelegationInfo queries delegation info func QueryDelegationInfo() *cobra.Command { cmd := &cobra.Command{ - Use: "QueryDelegationInfo stakerId assetId", + Use: "QueryDelegationInfo stakerID assetID", Short: "Get delegation info", Long: "Get delegation info", Args: cobra.ExactArgs(2), @@ -81,8 +81,8 @@ func QueryDelegationInfo() *cobra.Command { queryClient := delegationtype.NewQueryClient(clientCtx) req := &delegationtype.DelegationInfoReq{ - StakerId: args[0], - AssetId: args[1], + StakerID: args[0], + AssetID: args[1], } res, err := queryClient.QueryDelegationInfo(context.Background(), req) if err != nil { diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 2872d667c..d8251de40 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -56,7 +56,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // TODO(mike): ensure that operator is required to perform self delegation to match above. //calculate the actual canUndelegated asset amount - delegationInfo, err := k.GetSingleDelegationInfo(ctx, record.StakerId, record.AssetId, record.OperatorAddr) + delegationInfo, err := k.GetSingleDelegationInfo(ctx, record.StakerID, record.AssetID, record.OperatorAddr) if err != nil { panic(err) } @@ -73,13 +73,13 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida WaitUndelegationAmount: recordAmountNeg, UndelegatableAmountAfterSlash: record.ActualCompletedAmount.Neg(), } - err = k.UpdateDelegationState(ctx, record.StakerId, record.AssetId, delegatorAndAmount) + err = k.UpdateDelegationState(ctx, record.StakerID, record.AssetID, delegatorAndAmount) if err != nil { panic(err) } // update the staker state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerId, record.AssetId, types.StakerSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetOrChangeInfo{ CanWithdrawAmountOrWantChangeValue: record.ActualCompletedAmount, WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, }) @@ -88,7 +88,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } // update the operator state - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetId, types.OperatorSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetOrChangeInfo{ WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, }) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index d8a7be8ca..d373aee63 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -12,7 +12,7 @@ import ( ) type DelegationOrUndelegationParams struct { - ClientChainLzId uint64 + ClientChainLzID uint64 Action types.CrossChainOpType AssetsAddress []byte OperatorAddress sdk.AccAddress @@ -42,13 +42,13 @@ type DelegationOrUndelegationParams struct { return nil, nil } - var clientChainLzId uint64 - r = bytes.NewReader(log.Topics[types.ClientChainLzIdIndexInTopics][:]) - err = binary.Read(r, binary.BigEndian, &clientChainLzId) + var clientChainLzID uint64 + r = bytes.NewReader(log.Topics[types.ClientChainLzIDIndexInTopics][:]) + err = binary.Read(r, binary.BigEndian, &clientChainLzID) if err != nil { - return nil, errorsmod.Wrap(err, "error occurred when binary read ClientChainLzId from topic") + return nil, errorsmod.Wrap(err, "error occurred when binary read ClientChainLzID from topic") } - clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzId) + clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when get client chain info") } @@ -97,7 +97,7 @@ type DelegationOrUndelegationParams struct { amount := sdkmath.NewIntFromBigInt(big.NewInt(0).SetBytes(log.Data[readStart:readEnd])) return &DelegationOrUndelegationParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: action, AssetsAddress: assetsAddress, StakerAddress: stakerAddress, @@ -127,10 +127,10 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return delegationtype.ErrOpAmountIsNegative } - stakerId, assetId := types.GetStakeIDAndAssetId(params.ClientChainLzId, params.StakerAddress, params.AssetsAddress) + stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) //check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount - info, err := k.restakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerId, assetId) + info, err := k.restakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return err } @@ -140,14 +140,14 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar } //update staker asset state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types.StakerSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), }) if err != nil { return err } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetId, types.OperatorSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, types.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: params.OpAmount, }) if err != nil { @@ -158,16 +158,16 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ CanUndelegationAmount: params.OpAmount, } - err = k.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) + err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { return err } - err = k.UpdateStakerDelegationTotalAmount(ctx, stakerId, assetId, params.OpAmount) + err = k.UpdateStakerDelegationTotalAmount(ctx, stakerID, assetID, params.OpAmount) if err != nil { return err } // call operator module to bond the increased assets to the opted-in AVS - err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount) + err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount) if err != nil { return err } @@ -189,8 +189,8 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio return delegationtype.ErrOpAmountIsNegative } // get staker delegation state, then check the validation of Undelegation amount - stakerId, assetId := types.GetStakeIDAndAssetId(params.ClientChainLzId, params.StakerAddress, params.AssetsAddress) - delegationState, err := k.GetSingleDelegationInfo(ctx, stakerId, assetId, params.OperatorAddress.String()) + stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) + delegationState, err := k.GetSingleDelegationInfo(ctx, stakerID, assetID, params.OperatorAddress.String()) if err != nil { return err } @@ -200,8 +200,8 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio //record Undelegation event r := &delegationtype.UndelegationRecord{ - StakerId: stakerId, - AssetId: assetId, + StakerID: stakerID, + AssetID: assetID, OperatorAddr: params.OperatorAddress.String(), TxHash: params.TxHash.String(), IsPending: true, @@ -223,23 +223,23 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio WaitUndelegationAmount: params.OpAmount, UndelegatableAmountAfterSlash: params.OpAmount, } - err = k.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) + err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { return err } - err = k.UpdateStakerDelegationTotalAmount(ctx, stakerId, assetId, params.OpAmount.Neg()) + err = k.UpdateStakerDelegationTotalAmount(ctx, stakerID, assetID, params.OpAmount.Neg()) if err != nil { return err } //update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types.StakerSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ WaitUnbondingAmountOrWantChangeValue: params.OpAmount, }) if err != nil { return err } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetId, types.OperatorSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, types.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: params.OpAmount.Neg(), WaitUnbondingAmountOrWantChangeValue: params.OpAmount, }) @@ -248,7 +248,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio } // call operator module to decrease the state of opted-in assets - err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerId, assetId, params.OperatorAddress.String(), params.OpAmount.Neg()) + err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount.Neg()) if err != nil { return err } diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index d0d457c98..1fd155bff 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -14,33 +14,33 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (suite *KeeperTestSuite) TestDelegateTo() { +func (suite *DelegationTestSuite) TestDelegateTo() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := uint64(101) + clientChainLzID := uint64(101) depositEvent := &keeper.DepositParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: types.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(100), } depositEvent.AssetsAddress = usdtAddress[:] - err := suite.app.DepositKeeper.Deposit(suite.ctx, depositEvent) + err := suite.App.DepositKeeper.Deposit(suite.Ctx, depositEvent) suite.NoError(err) - opAccAddr, err := sdk.AccAddressFromBech32("evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl") + opAccAddr, err := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") suite.NoError(err) delegationParams := &keeper2.DelegationOrUndelegationParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: types.DelegateTo, AssetsAddress: usdtAddress[:], OperatorAddress: opAccAddr, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(50), LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParams) + err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationParams) suite.EqualError(err, errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", delegationParams.OperatorAddress)).Error()) registerReq := &types2.RegisterOperatorReq{ @@ -49,15 +49,15 @@ func (suite *KeeperTestSuite) TestDelegateTo() { EarningsAddr: opAccAddr.String(), }, } - _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.App.OperatorKeeper.RegisterOperator(suite.Ctx, registerReq) suite.NoError(err) - err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParams) + err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationParams) suite.NoError(err) // check delegation states - stakerId, assetId := types.GetStakeIDAndAssetId(delegationParams.ClientChainLzId, delegationParams.StakerAddress, delegationParams.AssetsAddress) - restakerState, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(delegationParams.ClientChainLzID, delegationParams.StakerAddress, delegationParams.AssetsAddress) + restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, @@ -65,7 +65,7 @@ func (suite *KeeperTestSuite) TestDelegateTo() { WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *restakerState) - operatorState, err := suite.app.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.ctx, opAccAddr, assetId) + operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) suite.Equal(types.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: delegationParams.OpAmount, @@ -75,7 +75,7 @@ func (suite *KeeperTestSuite) TestDelegateTo() { OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) - specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) + specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ CanUndelegationAmount: delegationParams.OpAmount, @@ -83,33 +83,33 @@ func (suite *KeeperTestSuite) TestDelegateTo() { UndelegatableAmountAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) - totalDelegationAmount, err := suite.app.DelegationKeeper.GetStakerDelegationTotalAmount(suite.ctx, stakerId, assetId) + totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(delegationParams.OpAmount, totalDelegationAmount) } -func (suite *KeeperTestSuite) TestUndelegateFrom() { +func (suite *DelegationTestSuite) TestUndelegateFrom() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := uint64(101) + clientChainLzID := uint64(101) depositEvent := &keeper.DepositParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: types.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(100), } depositEvent.AssetsAddress = usdtAddress[:] - err := suite.app.DepositKeeper.Deposit(suite.ctx, depositEvent) + err := suite.App.DepositKeeper.Deposit(suite.Ctx, depositEvent) suite.NoError(err) - opAccAddr, err := sdk.AccAddressFromBech32("evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl") + opAccAddr, err := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") suite.NoError(err) delegationEvent := &keeper2.DelegationOrUndelegationParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: types.DelegateTo, AssetsAddress: usdtAddress[:], OperatorAddress: opAccAddr, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(50), LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), @@ -120,20 +120,20 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { EarningsAddr: opAccAddr.String(), }, } - _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.App.OperatorKeeper.RegisterOperator(suite.Ctx, registerReq) suite.NoError(err) - err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationEvent) + err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationEvent) suite.NoError(err) // test Undelegation delegationEvent.LzNonce = 1 - err = suite.app.DelegationKeeper.UndelegateFrom(suite.ctx, delegationEvent) + err = suite.App.DelegationKeeper.UndelegateFrom(suite.Ctx, delegationEvent) suite.NoError(err) // check state - stakerId, assetId := types.GetStakeIDAndAssetId(delegationEvent.ClientChainLzId, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) - restakerState, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(delegationEvent.ClientChainLzID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) + restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, @@ -141,7 +141,7 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, }, *restakerState) - operatorState, err := suite.app.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.ctx, opAccAddr, assetId) + operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) suite.Equal(types.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: sdkmath.NewInt(0), @@ -151,7 +151,7 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) - specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) + specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ CanUndelegationAmount: sdkmath.NewInt(0), @@ -159,20 +159,20 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { UndelegatableAmountAfterSlash: delegationEvent.OpAmount, }, *specifiedDelegationAmount) - totalDelegationAmount, err := suite.app.DelegationKeeper.GetStakerDelegationTotalAmount(suite.ctx, stakerId, assetId) + totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(0), totalDelegationAmount) - records, err := suite.app.DelegationKeeper.GetStakerUndelegationRecords(suite.ctx, stakerId, assetId, keeper2.PendingRecords) + records, err := suite.App.DelegationKeeper.GetStakerUndelegationRecords(suite.Ctx, stakerID, assetID, keeper2.PendingRecords) suite.NoError(err) suite.Equal(1, len(records)) UndelegationRecord := &delegationtype.UndelegationRecord{ - StakerId: stakerId, - AssetId: assetId, + StakerID: stakerID, + AssetID: assetID, OperatorAddr: delegationEvent.OperatorAddress.String(), TxHash: delegationEvent.TxHash.String(), IsPending: true, - BlockNumber: uint64(suite.ctx.BlockHeight()), + BlockNumber: uint64(suite.Ctx.BlockHeight()), LzTxNonce: delegationEvent.LzNonce, Amount: delegationEvent.OpAmount, ActualCompletedAmount: sdkmath.NewInt(0), @@ -180,35 +180,35 @@ func (suite *KeeperTestSuite) TestUndelegateFrom() { UndelegationRecord.CompleteBlockNumber = UndelegationRecord.BlockNumber + delegationtype.CanUndelegationDelayHeight suite.Equal(UndelegationRecord, records[0]) - suite.ctx.Logger().Info("the complete block number is:", "height", UndelegationRecord.CompleteBlockNumber) - waitUndelegationRecords, err := suite.app.DelegationKeeper.GetWaitCompleteUndelegationRecords(suite.ctx, UndelegationRecord.CompleteBlockNumber) + suite.Ctx.Logger().Info("the complete block number is:", "height", UndelegationRecord.CompleteBlockNumber) + waitUndelegationRecords, err := suite.App.DelegationKeeper.GetWaitCompleteUndelegationRecords(suite.Ctx, UndelegationRecord.CompleteBlockNumber) suite.NoError(err) suite.Equal(1, len(waitUndelegationRecords)) suite.Equal(UndelegationRecord, waitUndelegationRecords[0]) } -func (suite *KeeperTestSuite) TestCompleteUndelegation() { +func (suite *DelegationTestSuite) TestCompleteUndelegation() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := uint64(101) + clientChainLzID := uint64(101) depositEvent := &keeper.DepositParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: types.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(100), } depositEvent.AssetsAddress = usdtAddress[:] - err := suite.app.DepositKeeper.Deposit(suite.ctx, depositEvent) + err := suite.App.DepositKeeper.Deposit(suite.Ctx, depositEvent) suite.NoError(err) - opAccAddr, err := sdk.AccAddressFromBech32("evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl") + opAccAddr, err := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") suite.NoError(err) delegationEvent := &keeper2.DelegationOrUndelegationParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: types.DelegateTo, AssetsAddress: usdtAddress[:], OperatorAddress: opAccAddr, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(50), LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), @@ -219,26 +219,26 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { EarningsAddr: opAccAddr.String(), }, } - _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.App.OperatorKeeper.RegisterOperator(suite.Ctx, registerReq) suite.NoError(err) - err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationEvent) + err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationEvent) suite.NoError(err) delegationEvent.LzNonce = 1 - err = suite.app.DelegationKeeper.UndelegateFrom(suite.ctx, delegationEvent) + err = suite.App.DelegationKeeper.UndelegateFrom(suite.Ctx, delegationEvent) suite.NoError(err) - UndelegateHeight := suite.ctx.BlockHeight() - suite.ctx.Logger().Info("the ctx block height is:", "height", UndelegateHeight) + UndelegateHeight := suite.Ctx.BlockHeight() + suite.Ctx.Logger().Info("the ctx block height is:", "height", UndelegateHeight) // test complete Undelegation completeBlockNumber := UndelegateHeight + int64(delegationtype.CanUndelegationDelayHeight) - suite.ctx = suite.ctx.WithBlockHeight(completeBlockNumber) - suite.app.DelegationKeeper.EndBlock(suite.ctx, abci.RequestEndBlock{}) + suite.Ctx = suite.Ctx.WithBlockHeight(completeBlockNumber) + suite.App.DelegationKeeper.EndBlock(suite.Ctx, abci.RequestEndBlock{}) // check state - stakerId, assetId := types.GetStakeIDAndAssetId(delegationEvent.ClientChainLzId, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) - restakerState, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(delegationEvent.ClientChainLzID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) + restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, @@ -246,7 +246,7 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *restakerState) - operatorState, err := suite.app.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.ctx, opAccAddr, assetId) + operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) suite.Equal(types.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: sdkmath.NewInt(0), @@ -256,7 +256,7 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) - specifiedDelegationAmount, err := suite.app.DelegationKeeper.GetSingleDelegationInfo(suite.ctx, stakerId, assetId, opAccAddr.String()) + specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ CanUndelegationAmount: sdkmath.NewInt(0), @@ -264,16 +264,16 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { UndelegatableAmountAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) - totalDelegationAmount, err := suite.app.DelegationKeeper.GetStakerDelegationTotalAmount(suite.ctx, stakerId, assetId) + totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(0), totalDelegationAmount) - records, err := suite.app.DelegationKeeper.GetStakerUndelegationRecords(suite.ctx, stakerId, assetId, keeper2.CompletedRecords) + records, err := suite.App.DelegationKeeper.GetStakerUndelegationRecords(suite.Ctx, stakerID, assetID, keeper2.CompletedRecords) suite.NoError(err) suite.Equal(1, len(records)) UndelegationRecord := &delegationtype.UndelegationRecord{ - StakerId: stakerId, - AssetId: assetId, + StakerID: stakerID, + AssetID: assetID, OperatorAddr: delegationEvent.OperatorAddress.String(), TxHash: delegationEvent.TxHash.String(), IsPending: false, @@ -285,7 +285,7 @@ func (suite *KeeperTestSuite) TestCompleteUndelegation() { } suite.Equal(UndelegationRecord, records[0]) - waitUndelegationRecords, err := suite.app.DelegationKeeper.GetWaitCompleteUndelegationRecords(suite.ctx, UndelegationRecord.CompleteBlockNumber) + waitUndelegationRecords, err := suite.App.DelegationKeeper.GetWaitCompleteUndelegationRecords(suite.Ctx, UndelegationRecord.CompleteBlockNumber) suite.NoError(err) suite.Equal(1, len(waitUndelegationRecords)) suite.Equal(UndelegationRecord, waitUndelegationRecords[0]) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 49be0c0a9..ba353d5b5 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -14,14 +14,14 @@ import ( // UpdateStakerDelegationTotalAmount The function is used to update the delegation total amount of the specified staker and asset. // The input `opAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is delegation or undelegation related to the specified staker and asset. -func (k *Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string, opAmount sdkmath.Int) error { +func (k *Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerID string, assetID string, opAmount sdkmath.Int) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } - // use stakerId+'/'+assetId as the key of total delegation amount + // use stakerID+'/'+assetID as the key of total delegation amount store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) amount := delegationtype.ValueField{Amount: sdkmath.NewInt(0)} - key := stakingtypes.GetJoinedStoreKey(stakerId, assetId) + key := stakingtypes.GetJoinedStoreKey(stakerID, assetID) if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &amount) @@ -38,10 +38,10 @@ func (k *Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId str } // GetStakerDelegationTotalAmount query the total delegation amount of the specified staker and asset. -func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string) (opAmount sdkmath.Int, err error) { +func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerID string, assetID string) (opAmount sdkmath.Int, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) var ret delegationtype.ValueField - prefixKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId) + prefixKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID) isExit := store.Has(prefixKey) if !isExit { return sdkmath.Int{}, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerDelegationTotalAmount: key is %s", prefixKey)) @@ -54,7 +54,7 @@ func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerId string // UpdateDelegationState The function is used to update the staker's asset amount that is delegated to a specified operator. // Compared to `UpdateStakerDelegationTotalAmount`,they use the same kv store, but in this function the store key needs to add the operator address as a suffix. -func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) { +func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) //todo: think about the difference between init and update in future @@ -70,7 +70,7 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId if err != nil { return delegationtype.OperatorAddrIsNotAccAddr } - singleStateKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId, opAddr) + singleStateKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID, opAddr) delegationState := delegationtype.DelegationAmounts{ CanUndelegationAmount: sdkmath.NewInt(0), WaitUndelegationAmount: sdkmath.NewInt(0), @@ -105,9 +105,9 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerId string, assetId } // GetSingleDelegationInfo query the staker's asset amount that has been delegated to the specified operator. -func (k *Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, operatorAddr string) (*delegationtype.DelegationAmounts, error) { +func (k *Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerID, assetID, operatorAddr string) (*delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) - singleStateKey := stakingtypes.GetJoinedStoreKey(stakerId, assetId, operatorAddr) + singleStateKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID, operatorAddr) isExit := store.Has(singleStateKey) delegationState := delegationtype.DelegationAmounts{} if isExit { @@ -120,23 +120,23 @@ func (k *Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, ope } // GetDelegationInfo query the staker's asset info that has been delegated. -func (k *Keeper) GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*delegationtype.QueryDelegationInfoResponse, error) { +func (k *Keeper) GetDelegationInfo(ctx sdk.Context, stakerID, assetID string) (*delegationtype.QueryDelegationInfoResponse, error) { var ret delegationtype.QueryDelegationInfoResponse - totalAmount, err := k.GetStakerDelegationTotalAmount(ctx, stakerId, assetId) + totalAmount, err := k.GetStakerDelegationTotalAmount(ctx, stakerID, assetID) if err != nil { return nil, err } ret.TotalDelegatedAmount = totalAmount store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) - iterator := sdk.KVStorePrefixIterator(store, delegationtype.GetDelegationStateIteratorPrefix(stakerId, assetId)) + iterator := sdk.KVStorePrefixIterator(store, delegationtype.GetDelegationStateIteratorPrefix(stakerID, assetID)) defer iterator.Close() ret.DelegationInfos = make(map[string]*delegationtype.DelegationAmounts, 0) for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := delegationtype.ParseStakerAssetIdAndOperatorAddrFromKey(iterator.Key()) + keys, err := delegationtype.ParseStakerAssetIDAndOperatorAddrFromKey(iterator.Key()) if err != nil { return nil, err } @@ -179,7 +179,7 @@ func (k *Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr s return ret, nil } -func (k *Keeper) IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { +func (k *Keeper) IterateDelegationState(ctx sdk.Context, f func(restakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() diff --git a/x/delegation/keeper/grpc_query.go b/x/delegation/keeper/grpc_query.go index 31c76ae8f..990479874 100644 --- a/x/delegation/keeper/grpc_query.go +++ b/x/delegation/keeper/grpc_query.go @@ -11,10 +11,10 @@ var _ delegationtype.QueryServer = &Keeper{} func (k *Keeper) QuerySingleDelegationInfo(ctx context.Context, req *delegationtype.SingleDelegationInfoReq) (*delegationtype.DelegationAmounts, error) { c := sdk.UnwrapSDKContext(ctx) - return k.GetSingleDelegationInfo(c, req.StakerId, req.AssetId, req.OperatorAddr) + return k.GetSingleDelegationInfo(c, req.StakerID, req.AssetID, req.OperatorAddr) } func (k *Keeper) QueryDelegationInfo(ctx context.Context, info *delegationtype.DelegationInfoReq) (*delegationtype.QueryDelegationInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) - return k.GetDelegationInfo(c, info.StakerId, info.AssetId) + return k.GetDelegationInfo(c, info.StakerID, info.AssetID) } diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 1b657617a..35eb12be1 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -80,7 +80,7 @@ type IDelegation interface { // UndelegateAssetFromOperator handle the UndelegateAssetFromOperator txs from msg service UndelegateAssetFromOperator(ctx context.Context, delegation *delegationtype.MsgUndelegation) (*delegationtype.UndelegationResponse, error) - GetSingleDelegationInfo(ctx sdk.Context, stakerId, assetId, operatorAddr string) (*delegationtype.DelegationAmounts, error) + GetSingleDelegationInfo(ctx sdk.Context, stakerID, assetID, operatorAddr string) (*delegationtype.DelegationAmounts, error) - GetDelegationInfo(ctx sdk.Context, stakerId, assetId string) (*delegationtype.QueryDelegationInfoResponse, error) + GetDelegationInfo(ctx sdk.Context, stakerID, assetID string) (*delegationtype.QueryDelegationInfoResponse, error) } diff --git a/x/delegation/keeper/setup_test.go b/x/delegation/keeper/setup_test.go index ce52efbcb..c139e4874 100644 --- a/x/delegation/keeper/setup_test.go +++ b/x/delegation/keeper/setup_test.go @@ -1,33 +1,23 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" - "github.com/ExocoreNetwork/exocore/app" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" ) -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.ExocoreApp - address common.Address - signer keyring.Signer - accAddress sdk.AccAddress +type DelegationTestSuite struct { + testutil.BaseTestSuite } -var s *KeeperTestSuite +var s *DelegationTestSuite func TestKeeperTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(DelegationTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -35,6 +25,6 @@ func TestKeeperTestSuite(t *testing.T) { RunSpecs(t, "Keeper Suite") } -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (suite *DelegationTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/delegation/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index 6aea7bfc6..b141b463c 100644 --- a/x/delegation/keeper/un_delegation_state.go +++ b/x/delegation/keeper/un_delegation_state.go @@ -35,7 +35,7 @@ func (k *Keeper) SetUndelegationRecords(ctx sdk.Context, records []*types.Undele singleRecKey := types.GetUndelegationRecordKey(record.LzTxNonce, record.TxHash, record.OperatorAddr) singleRecordStore.Set(singleRecKey, bz) - stakerKey := types.GetStakerUndelegationRecordKey(record.StakerId, record.AssetId, record.LzTxNonce) + stakerKey := types.GetStakerUndelegationRecordKey(record.StakerID, record.AssetID, record.LzTxNonce) stakerUndelegationStore.Set(stakerKey, singleRecKey) waitCompleteKey := types.GetWaitCompleteRecordKey(record.CompleteBlockNumber, record.LzTxNonce) @@ -91,16 +91,16 @@ func (k *Keeper) GetUndelegationRecords(ctx sdk.Context, singleRecordKeys []stri return ret, nil } -func (k *Keeper) SetStakerUndelegationInfo(ctx sdk.Context, stakerId, assetId string, recordKey []byte, lzNonce uint64) error { +func (k *Keeper) SetStakerUndelegationInfo(ctx sdk.Context, stakerID, assetID string, recordKey []byte, lzNonce uint64) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixStakerUndelegationInfo) - key := types.GetStakerUndelegationRecordKey(stakerId, assetId, lzNonce) + key := types.GetStakerUndelegationRecordKey(stakerID, assetID, lzNonce) store.Set(key, recordKey) return nil } -func (k *Keeper) GetStakerUndelegationRecKeys(ctx sdk.Context, stakerId, assetId string) (recordKeyList []string, err error) { +func (k *Keeper) GetStakerUndelegationRecKeys(ctx sdk.Context, stakerID, assetID string) (recordKeyList []string, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixStakerUndelegationInfo) - iterator := sdk.KVStorePrefixIterator(store, []byte(strings.Join([]string{stakerId, assetId}, "/"))) + iterator := sdk.KVStorePrefixIterator(store, []byte(strings.Join([]string{stakerID, assetID}, "/"))) defer iterator.Close() ret := make([]string, 0) @@ -110,8 +110,8 @@ func (k *Keeper) GetStakerUndelegationRecKeys(ctx sdk.Context, stakerId, assetId return ret, nil } -func (k *Keeper) GetStakerUndelegationRecords(ctx sdk.Context, stakerId, assetId string, getType GetUndelegationRecordType) (records []*types.UndelegationRecord, err error) { - recordKeys, err := k.GetStakerUndelegationRecKeys(ctx, stakerId, assetId) +func (k *Keeper) GetStakerUndelegationRecords(ctx sdk.Context, stakerID, assetID string, getType GetUndelegationRecordType) (records []*types.UndelegationRecord, err error) { + recordKeys, err := k.GetStakerUndelegationRecKeys(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/x/delegation/keeper/utils_test.go b/x/delegation/keeper/utils_test.go deleted file mode 100644 index 8abc9db4a..000000000 --- a/x/delegation/keeper/utils_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package keeper_test - -import ( - "time" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/stretchr/testify/require" - "golang.org/x/exp/rand" -) - -// Test helpers -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) - - // accAddress - pubBz := make([]byte, ed25519.PubKeySize) - pub := &ed25519.PubKey{Key: pubBz} - rand.Read(pub.Key) - suite.accAddress = sdk.AccAddress(pub.Address()) - - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) - - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, feemarkettypes.DefaultGenesisState(), chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) -} diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 4918e2450..9e2e978ed 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -9,7 +9,7 @@ var CanUndelegationDelayHeight = uint64(10) type ISlashKeeper interface { IsOperatorFrozen(ctx sdk.Context, opAddr sdk.AccAddress) bool - OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetId string, startHeight, endHeight uint64) sdkmath.LegacyDec + OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetID string, startHeight, endHeight uint64) sdkmath.LegacyDec } // VirtualISlashKeeper todo: When the actual keeper functionality has not been implemented yet, temporarily use the virtual keeper. @@ -19,7 +19,7 @@ func (VirtualISlashKeeper) IsOperatorFrozen(ctx sdk.Context, opAddr sdk.AccAddre return false } -func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetId string, startHeight, endHeight uint64) sdkmath.LegacyDec { +func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetID string, startHeight, endHeight uint64) sdkmath.LegacyDec { return sdkmath.LegacyNewDec(0) } @@ -41,5 +41,5 @@ type ExpectedOperatorInterface interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 - UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error + UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, operatorAddr string, opAmount sdkmath.Int) error } diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index 31457445a..262d9b75d 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -43,46 +43,46 @@ const ( ) var ( - // KeyPrefixRestakerDelegationInfo reStakerId = clientChainAddr+'_'+ExoCoreChainIndex + // KeyPrefixRestakerDelegationInfo reStakerID = clientChainAddr+'_'+ExoCoreChainIndex // KeyPrefixRestakerDelegationInfo // key-value: - // reStakerId +'/'+assetId -> totalDelegationAmount - // reStakerId +'/'+assetId+'/'+operatorAddr -> delegationAmounts + // reStakerID +'/'+assetID -> totalDelegationAmount + // reStakerID +'/'+assetID+'/'+operatorAddr -> delegationAmounts KeyPrefixRestakerDelegationInfo = []byte{prefixRestakerDelegationInfo} // KeyPrefixDelegationUsedSalt key->value: operatorApproveAddr->map[salt]{} KeyPrefixDelegationUsedSalt = []byte{prefixDelegationUsedSalt} - // KeyPrefixOperatorApprovedInfo key-value: operatorApproveAddr->map[reStakerId]{} + // KeyPrefixOperatorApprovedInfo key-value: operatorApproveAddr->map[reStakerID]{} KeyPrefixOperatorApprovedInfo = []byte{prefixOperatorApprovedInfo} // KeyPrefixUndelegationInfo singleRecordKey = lzNonce+'/'+txHash+'/'+operatorAddr // singleRecordKey -> UndelegateReqRecord KeyPrefixUndelegationInfo = []byte{prefixUndelegationInfo} - // KeyPrefixStakerUndelegationInfo reStakerId+'/'+assetId+'/'+lzNonce -> singleRecordKey + // KeyPrefixStakerUndelegationInfo reStakerID+'/'+assetID+'/'+lzNonce -> singleRecordKey KeyPrefixStakerUndelegationInfo = []byte{prefixStakerUndelegationInfo} // KeyPrefixWaitCompleteUndelegations completeHeight +'/'+lzNonce -> singleRecordKey KeyPrefixWaitCompleteUndelegations = []byte{prefixWaitCompleteUndelegations} ) -func GetDelegationStateIteratorPrefix(stakerId, assetId string) []byte { - tmp := []byte(strings.Join([]string{stakerId, assetId}, "/")) +func GetDelegationStateIteratorPrefix(stakerID, assetID string) []byte { + tmp := []byte(strings.Join([]string{stakerID, assetID}, "/")) tmp = append(tmp, '/') return tmp } -func ParseStakerAssetIdAndOperatorAddrFromKey(key []byte) (keys *SingleDelegationInfoReq, err error) { +func ParseStakerAssetIDAndOperatorAddrFromKey(key []byte) (keys *SingleDelegationInfoReq, err error) { stringList, err := types.ParseJoinedStoreKey(key, 3) if err != nil { return nil, err } - return &SingleDelegationInfoReq{StakerId: stringList[0], AssetId: stringList[1], OperatorAddr: stringList[2]}, nil + return &SingleDelegationInfoReq{StakerID: stringList[0], AssetID: stringList[1], OperatorAddr: stringList[2]}, nil } func GetUndelegationRecordKey(lzNonce uint64, txHash string, operatorAddr string) []byte { return []byte(strings.Join([]string{hexutil.EncodeUint64(lzNonce), txHash, operatorAddr}, "/")) } -func GetStakerUndelegationRecordKey(stakerId, assetId string, lzNonce uint64) []byte { - return []byte(strings.Join([]string{stakerId, assetId, hexutil.EncodeUint64(lzNonce)}, "/")) +func GetStakerUndelegationRecordKey(stakerID, assetID string, lzNonce uint64) []byte { + return []byte(strings.Join([]string{stakerID, assetID, hexutil.EncodeUint64(lzNonce)}, "/")) } func GetWaitCompleteRecordKey(height, lzNonce uint64) []byte { diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index e57acfd11..41a7f04fd 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -33,8 +33,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type DelegationInfoReq struct { - StakerId string `protobuf:"bytes,1,opt,name=stakerId,proto3" json:"stakerId,omitempty"` - AssetId string `protobuf:"bytes,2,opt,name=assetId,proto3" json:"assetId,omitempty"` + StakerID string `protobuf:"bytes,1,opt,name=stakerID,proto3" json:"stakerID,omitempty"` + AssetID string `protobuf:"bytes,2,opt,name=assetID,proto3" json:"assetID,omitempty"` } func (m *DelegationInfoReq) Reset() { *m = DelegationInfoReq{} } @@ -70,16 +70,16 @@ func (m *DelegationInfoReq) XXX_DiscardUnknown() { var xxx_messageInfo_DelegationInfoReq proto.InternalMessageInfo -func (m *DelegationInfoReq) GetStakerId() string { +func (m *DelegationInfoReq) GetStakerID() string { if m != nil { - return m.StakerId + return m.StakerID } return "" } -func (m *DelegationInfoReq) GetAssetId() string { +func (m *DelegationInfoReq) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } @@ -169,9 +169,9 @@ func (m *QueryDelegationInfoResponse) GetDelegationInfos() map[string]*Delegatio } type SingleDelegationInfoReq struct { - StakerId string `protobuf:"bytes,1,opt,name=stakerId,proto3" json:"stakerId,omitempty"` + StakerID string `protobuf:"bytes,1,opt,name=stakerID,proto3" json:"stakerID,omitempty"` OperatorAddr string `protobuf:"bytes,2,opt,name=operatorAddr,proto3" json:"operatorAddr,omitempty"` - AssetId string `protobuf:"bytes,3,opt,name=assetId,proto3" json:"assetId,omitempty"` + AssetID string `protobuf:"bytes,3,opt,name=assetID,proto3" json:"assetID,omitempty"` } func (m *SingleDelegationInfoReq) Reset() { *m = SingleDelegationInfoReq{} } @@ -207,9 +207,9 @@ func (m *SingleDelegationInfoReq) XXX_DiscardUnknown() { var xxx_messageInfo_SingleDelegationInfoReq proto.InternalMessageInfo -func (m *SingleDelegationInfoReq) GetStakerId() string { +func (m *SingleDelegationInfoReq) GetStakerID() string { if m != nil { - return m.StakerId + return m.StakerID } return "" } @@ -221,9 +221,9 @@ func (m *SingleDelegationInfoReq) GetOperatorAddr() string { return "" } -func (m *SingleDelegationInfoReq) GetAssetId() string { +func (m *SingleDelegationInfoReq) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } @@ -240,44 +240,44 @@ func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescri var fileDescriptor_aab345e1cf20490c = []byte{ // 605 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x4f, - 0x18, 0xce, 0x6e, 0xe8, 0xef, 0xa7, 0x53, 0x41, 0x1d, 0x53, 0xdd, 0x6e, 0x75, 0x5b, 0xf7, 0x20, - 0xa1, 0xd0, 0x5d, 0x1b, 0x15, 0x44, 0xaa, 0xd0, 0x6a, 0x29, 0x7b, 0x29, 0xb8, 0x51, 0x04, 0x2f, -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0x5f, 0x47, 0x9c, 0xd1, + 0x21, 0x86, 0xb4, 0x64, 0x97, 0xa2, 0x13, 0xe1, 0xba, 0x05, 0xae, 0x96, 0xc7, 0x88, 0x45, 0xf6, + 0xa8, 0x8d, 0x9b, 0x50, 0x05, 0x17, 0xb8, 0x40, 0x75, 0xcc, 0xac, 0xb2, 0x22, 0xad, 0x49, 0xf9, + 0x8b, 0xf6, 0xf8, 0x0c, 0x15, 0x70, 0x1e, 0x71, 0x8e, 0x85, 0x55, 0x56, 0xe4, 0x10, 0xfa, 0x73, + 0xd4, 0x7b, 0xd9, 0x49, 0xae, 0x52, 0x83, 0xb6, 0x88, 0xe0, 0x90, 0x81, 0xa5, 0xa7, 0x88, 0xbc, + 0x20, 0xce, 0x0c, 0x12, 0x11, 0x6f, 0x6d, 0x1e, 0x1c, 0xaf, 0x66, 0xbe, 0x1e, 0xaf, 0xde, 0x71, + 0x3d, 0xb1, 0xdf, 0xaa, 0x1a, 0x35, 0xda, 0x88, 0x2f, 0x10, 0xff, 0x14, 0xb8, 0x53, 0x37, 0x45, + 0x37, 0xc0, 0xdc, 0xb0, 0x88, 0x38, 0xea, 0x17, 0x40, 0x7c, 0x3f, 0x8b, 0x08, 0x3b, 0x99, 0x1a, + 0x0a, 0x70, 0xfd, 0x25, 0xf2, 0x44, 0x82, 0xa8, 0x3c, 0x07, 0xd1, 0x14, 0x6e, 0xd8, 0x93, 0xc0, + 0xad, 0x71, 0x18, 0x55, 0x7d, 0x1c, 0xc5, 0x4b, 0x7b, 0x02, 0xb3, 0x8a, 0x8f, 0xf8, 0xbe, 0x92, + 0x9d, 0x83, 0xfa, 0xe9, 0x12, 0xfa, 0x2f, 0x19, 0xac, 0x3c, 0x1b, 0x8d, 0xc6, 0x6c, 0x57, 0x79, + 0x40, 0x09, 0xc7, 0x30, 0x00, 0xb9, 0xe7, 0x54, 0x20, 0x3f, 0x86, 0xb1, 0x33, 0xc7, 0x6e, 0x24, + 0x32, 0xc3, 0x26, 0xb8,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, 0xbb, 0x29, 0x76, 0x53, 0x8d, 0x6d, 0xed, + 0x1e, 0x0c, 0x34, 0xe9, 0x70, 0xa0, 0x49, 0xdf, 0x06, 0x9a, 0xf4, 0x7e, 0xa8, 0x65, 0x0e, 0x87, + 0x5a, 0xe6, 0xcb, 0x50, 0xcb, 0xbc, 0xba, 0x3f, 0xb1, 0x44, 0xdb, 0x11, 0xeb, 0x2e, 0x16, 0x6f, + 0x28, 0xab, 0x8f, 0x45, 0x3a, 0x93, 0x32, 0xe1, 0x5a, 0x55, 0xcf, 0x85, 0xef, 0xf2, 0xbd, 0xdf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x28, 0x14, 0xf3, 0x72, 0x5f, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -418,17 +418,17 @@ func (m *DelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = 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))) + 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))) + 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 } @@ -567,10 +567,10 @@ func (m *SingleDelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = 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))) + 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 } @@ -581,10 +581,10 @@ func (m *SingleDelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) 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))) + 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 } @@ -608,11 +608,11 @@ func (m *DelegationInfoReq) Size() (n int) { } var l int _ = l - l = len(m.StakerId) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -664,7 +664,7 @@ func (m *SingleDelegationInfoReq) Size() (n int) { } var l int _ = l - l = len(m.StakerId) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -672,7 +672,7 @@ func (m *SingleDelegationInfoReq) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -716,7 +716,7 @@ func (m *DelegationInfoReq) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -744,11 +744,11 @@ func (m *DelegationInfoReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakerId = string(dAtA[iNdEx:postIndex]) + m.StakerID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -776,7 +776,7 @@ func (m *DelegationInfoReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1195,7 +1195,7 @@ func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1223,7 +1223,7 @@ func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakerId = string(dAtA[iNdEx:postIndex]) + m.StakerID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1259,7 +1259,7 @@ func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1287,7 +1287,7 @@ func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/delegation/types/tx.pb.go b/x/delegation/types/tx.pb.go index 3d6e60f77..0b9523132 100644 --- a/x/delegation/types/tx.pb.go +++ b/x/delegation/types/tx.pb.go @@ -70,7 +70,7 @@ func (m *ValueField) XXX_DiscardUnknown() { var xxx_messageInfo_ValueField proto.InternalMessageInfo type DelegatedSingleAssetInfo struct { - AssetId string `protobuf:"bytes,1,opt,name=AssetId,proto3" json:"AssetId,omitempty"` + AssetID string `protobuf:"bytes,1,opt,name=AssetID,proto3" json:"AssetID,omitempty"` TotalDelegatedAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=TotalDelegatedAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalDelegatedAmount"` PerOperatorAmounts map[string]*ValueField `protobuf:"bytes,3,rep,name=PerOperatorAmounts,proto3" json:"PerOperatorAmounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } @@ -108,9 +108,9 @@ func (m *DelegatedSingleAssetInfo) XXX_DiscardUnknown() { var xxx_messageInfo_DelegatedSingleAssetInfo proto.InternalMessageInfo -func (m *DelegatedSingleAssetInfo) GetAssetId() string { +func (m *DelegatedSingleAssetInfo) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } @@ -265,8 +265,8 @@ func (m *MsgDelegation) GetApprovedInfo() *DelegationApproveInfo { } type UndelegationRecord struct { - StakerId string `protobuf:"bytes,1,opt,name=stakerId,proto3" json:"stakerId,omitempty"` - AssetId string `protobuf:"bytes,2,opt,name=assetId,proto3" json:"assetId,omitempty"` + StakerID string `protobuf:"bytes,1,opt,name=stakerID,proto3" json:"stakerID,omitempty"` + AssetID string `protobuf:"bytes,2,opt,name=assetID,proto3" json:"assetID,omitempty"` OperatorAddr string `protobuf:"bytes,3,opt,name=OperatorAddr,proto3" json:"OperatorAddr,omitempty"` TxHash string `protobuf:"bytes,4,opt,name=txHash,proto3" json:"txHash,omitempty"` IsPending bool `protobuf:"varint,5,opt,name=isPending,proto3" json:"isPending,omitempty"` @@ -310,16 +310,16 @@ func (m *UndelegationRecord) XXX_DiscardUnknown() { var xxx_messageInfo_UndelegationRecord proto.InternalMessageInfo -func (m *UndelegationRecord) GetStakerId() string { +func (m *UndelegationRecord) GetStakerID() string { if m != nil { - return m.StakerId + return m.StakerID } return "" } -func (m *UndelegationRecord) GetAssetId() string { +func (m *UndelegationRecord) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } @@ -547,59 +547,59 @@ var fileDescriptor_16596a15a828f109 = []byte{ // 879 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x41, 0x6f, 0x1b, 0x45, 0x14, 0xf6, 0xc6, 0x49, 0x9a, 0x3c, 0x17, 0x01, 0x83, 0x93, 0x6c, 0x0d, 0x72, 0xcc, 0x0a, 0xaa, - 0x10, 0x88, 0x4d, 0x03, 0x08, 0x14, 0xf5, 0xe2, 0x90, 0x14, 0x2c, 0x9a, 0x34, 0xda, 0x06, 0x0e, + 0x10, 0x88, 0x4d, 0x03, 0x08, 0x14, 0xf5, 0xe2, 0xe0, 0x14, 0x2c, 0x9a, 0x34, 0xda, 0x06, 0x0e, 0x08, 0x09, 0x8d, 0x77, 0xa7, 0x9b, 0xc5, 0xbb, 0x33, 0xab, 0x99, 0x71, 0xea, 0x70, 0x42, 0x9c, 0x80, 0x13, 0x3f, 0xa1, 0x3f, 0x80, 0x43, 0x0e, 0xfd, 0x11, 0x3d, 0x56, 0x3d, 0x21, 0x0e, 0x11, - 0x4a, 0x0e, 0xe1, 0xc0, 0x1f, 0x80, 0x13, 0xda, 0x99, 0xf1, 0xee, 0x86, 0xd8, 0x44, 0x48, 0x96, - 0x7a, 0xb1, 0xe7, 0xbd, 0x79, 0xf3, 0x7d, 0xef, 0xcd, 0xf7, 0xf6, 0x69, 0xa0, 0x4e, 0x06, 0xcc, - 0x63, 0x9c, 0xb4, 0x7c, 0x12, 0x91, 0x00, 0xcb, 0x90, 0xd1, 0xd6, 0xe1, 0xad, 0x96, 0x1c, 0x34, - 0x13, 0xce, 0x24, 0x43, 0x0b, 0x66, 0xbf, 0x99, 0xef, 0x37, 0x0f, 0x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 0x9e, 0xd6, + 0x4b, 0xbf, 0x9e, 0xd6, 0x4b, 0x5f, 0xbe, 0x5f, 0x68, 0x8c, 0x2d, 0x8d, 0xbb, 0x43, 0xe4, 0x43, + 0xc6, 0xfb, 0xad, 0xd1, 0xe3, 0x66, 0x58, 0x7c, 0xde, 0xa8, 0x56, 0xe9, 0xcd, 0xaa, 0xb7, 0xc6, + 0x7b, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x12, 0x40, 0x79, 0x6b, 0x01, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -809,10 +809,10 @@ func (m *DelegatedSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error } i-- dAtA[i] = 0x12 - if len(m.AssetId) > 0 { - i -= len(m.AssetId) - copy(dAtA[i:], m.AssetId) - i = encodeVarintTx(dAtA, i, uint64(len(m.AssetId))) + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintTx(dAtA, i, uint64(len(m.AssetID))) i-- dAtA[i] = 0xa } @@ -1038,17 +1038,17 @@ func (m *UndelegationRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.AssetId) > 0 { - i -= len(m.AssetId) - copy(dAtA[i:], m.AssetId) - i = encodeVarintTx(dAtA, i, uint64(len(m.AssetId))) + if len(m.AssetID) > 0 { + i -= len(m.AssetID) + copy(dAtA[i:], m.AssetID) + i = encodeVarintTx(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 = encodeVarintTx(dAtA, i, uint64(len(m.StakerId))) + if len(m.StakerID) > 0 { + i -= len(m.StakerID) + copy(dAtA[i:], m.StakerID) + i = encodeVarintTx(dAtA, i, uint64(len(m.StakerID))) i-- dAtA[i] = 0xa } @@ -1196,7 +1196,7 @@ func (m *DelegatedSingleAssetInfo) Size() (n int) { } var l int _ = l - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1284,11 +1284,11 @@ func (m *UndelegationRecord) Size() (n int) { } var l int _ = l - l = len(m.StakerId) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1486,7 +1486,7 @@ func (m *DelegatedSingleAssetInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1514,7 +1514,7 @@ func (m *DelegatedSingleAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -2178,7 +2178,7 @@ func (m *UndelegationRecord) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2206,11 +2206,11 @@ func (m *UndelegationRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakerId = string(dAtA[iNdEx:postIndex]) + m.StakerID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2238,7 +2238,7 @@ func (m *UndelegationRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { diff --git a/x/deposit/keeper/cross_chain_tx_process.go b/x/deposit/keeper/cross_chain_tx_process.go index e09723582..6c16d55ec 100644 --- a/x/deposit/keeper/cross_chain_tx_process.go +++ b/x/deposit/keeper/cross_chain_tx_process.go @@ -11,7 +11,7 @@ import ( ) type DepositParams struct { - ClientChainLzId uint64 + ClientChainLzID uint64 // The action field might need to be removed,it will be used when called from event hook. Action types.CrossChainOpType AssetsAddress []byte @@ -36,14 +36,14 @@ type DepositParams struct { return nil, nil } - var clientChainLzId uint64 - r = bytes.NewReader(log.Topics[types.ClientChainLzIdIndexInTopics][:]) - err = binary.Read(r, binary.BigEndian, &clientChainLzId) + var clientChainLzID uint64 + r = bytes.NewReader(log.Topics[types.ClientChainLzIDIndexInTopics][:]) + err = binary.Read(r, binary.BigEndian, &clientChainLzID) if err != nil { - return nil, errorsmod.Wrap(err, "error occurred when binary read ClientChainLzId from topic") + return nil, errorsmod.Wrap(err, "error occurred when binary read ClientChainLzID from topic") } - clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzId) + clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when get client chain info") } @@ -72,7 +72,7 @@ type DepositParams struct { amount := sdkmath.NewIntFromBigInt(big.NewInt(0).SetBytes(log.Data[readStart:readEnd])) return &DepositParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: action, AssetsAddress: assetsAddress, StakerAddress: depositAddress, @@ -128,23 +128,23 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { if params.OpAmount.IsNegative() { return errorsmod.Wrap(despoittypes.ErrDepositAmountIsNegative, fmt.Sprintf("the amount is:%s", params.OpAmount)) } - stakeId, assetId := types.GetStakeIDAndAssetId(params.ClientChainLzId, params.StakerAddress, params.AssetsAddress) + stakeId, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) // check if asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetId) { - return errorsmod.Wrap(despoittypes.ErrDepositAssetNotExist, fmt.Sprintf("the assetId is:%s", assetId)) + if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + return errorsmod.Wrap(despoittypes.ErrDepositAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: params.OpAmount, CanWithdrawAmountOrWantChangeValue: params.OpAmount, } // update asset state of the specified staker - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetId, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) if err != nil { return err } // update total amount of the deposited asset - err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetId, params.OpAmount) + err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, params.OpAmount) if err != nil { return err } diff --git a/x/deposit/keeper/deposit_test.go b/x/deposit/keeper/deposit_test.go index 62e823760..84f2d17f9 100644 --- a/x/deposit/keeper/deposit_test.go +++ b/x/deposit/keeper/deposit_test.go @@ -8,33 +8,33 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (suite *KeeperTestSuite) TestDeposit() { +func (suite *DepositTestSuite) TestDeposit() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") usdcAddress := common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48") params := &keeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(100), } // test the case that the deposit asset hasn't registered params.AssetsAddress = usdcAddress[:] - err := suite.app.DepositKeeper.Deposit(suite.ctx, params) + err := suite.App.DepositKeeper.Deposit(suite.Ctx, params) suite.ErrorContains(err, deposittype.ErrDepositAssetNotExist.Error()) - assets, err := suite.app.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.ctx) + assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) - suite.app.Logger().Info("the assets is:", "assets", assets) + suite.App.Logger().Info("the assets is:", "assets", assets) // test the normal case params.AssetsAddress = usdtAddress[:] - err = suite.app.DepositKeeper.Deposit(suite.ctx, params) + err = suite.App.DepositKeeper.Deposit(suite.Ctx, params) suite.NoError(err) // check state after deposit - stakerId, assetId := types.GetStakeIDAndAssetId(params.ClientChainLzId, params.StakerAddress, params.AssetsAddress) - info, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) + info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: params.OpAmount, @@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestDeposit() { WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) + assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(params.OpAmount, assetInfo.StakingTotalAmount) } diff --git a/x/deposit/keeper/params_test.go b/x/deposit/keeper/params_test.go index f40415fff..016486003 100644 --- a/x/deposit/keeper/params_test.go +++ b/x/deposit/keeper/params_test.go @@ -4,15 +4,15 @@ import ( deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" ) -func (suite *KeeperTestSuite) TestParams() { +func (suite *DepositTestSuite) TestParams() { params := &deposittype.Params{ ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", } - err := suite.app.DepositKeeper.SetParams(suite.ctx, params) + err := suite.App.DepositKeeper.SetParams(suite.Ctx, params) suite.NoError(err) - getParams, err := suite.app.DepositKeeper.GetParams(suite.ctx) + getParams, err := suite.App.DepositKeeper.GetParams(suite.Ctx) suite.NoError(err) suite.Equal(*params, *getParams) } diff --git a/x/deposit/keeper/setup_test.go b/x/deposit/keeper/setup_test.go index 13bd11a79..c6b43ccc3 100644 --- a/x/deposit/keeper/setup_test.go +++ b/x/deposit/keeper/setup_test.go @@ -1,32 +1,23 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" - "github.com/ExocoreNetwork/exocore/app" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" ) -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.ExocoreApp - address common.Address - signer keyring.Signer +type DepositTestSuite struct { + testutil.BaseTestSuite } -var s *KeeperTestSuite +var s *DepositTestSuite func TestKeeperTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(DepositTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -34,6 +25,6 @@ func TestKeeperTestSuite(t *testing.T) { RunSpecs(t, "Keeper Suite") } -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (suite *DepositTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/deposit/keeper/utils_test.go b/x/deposit/keeper/utils_test.go deleted file mode 100644 index 8116e8070..000000000 --- a/x/deposit/keeper/utils_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package keeper_test - -import ( - "time" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/stretchr/testify/require" -) - -// Test helpers -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) - - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) - - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, feemarkettypes.DefaultGenesisState(), chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) -} diff --git a/x/evm/types/params.go b/x/evm/types/params.go index 92e972ae6..0dcacfceb 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -1,21 +1,26 @@ package types import ( + "github.com/ExocoreNetwork/exocore/utils" evmtype "github.com/evmos/evmos/v14/x/evm/types" ) // ExocoreAvailableEVMExtensions defines the default active precompiles -var ExocoreAvailableEVMExtensions = []string{ - "0x0000000000000000000000000000000000000800", // Staking precompile - "0x0000000000000000000000000000000000000801", // Distribution precompile - "0x0000000000000000000000000000000000000802", // ICS20 transfer precompile - "0x0000000000000000000000000000000000000803", // Vesting precompile - "0x0000000000000000000000000000000000000804", // deposit precompile - "0x0000000000000000000000000000000000000805", // delegation precompile - "0x0000000000000000000000000000000000000806", // reward precompile - "0x0000000000000000000000000000000000000807", // slash precompile - "0x0000000000000000000000000000000000000808", // withdraw precompile -} +var ( + // DefaultEVMDenom defines the default EVM denomination on Exocore + DefaultEVMDenom = utils.BaseDenom + ExocoreAvailableEVMExtensions = []string{ + "0x0000000000000000000000000000000000000800", // Staking precompile + "0x0000000000000000000000000000000000000801", // Distribution precompile + "0x0000000000000000000000000000000000000802", // ICS20 transfer precompile + "0x0000000000000000000000000000000000000803", // Vesting precompile + "0x0000000000000000000000000000000000000804", // deposit precompile + "0x0000000000000000000000000000000000000805", // delegation precompile + "0x0000000000000000000000000000000000000806", // reward precompile + "0x0000000000000000000000000000000000000807", // slash precompile + "0x0000000000000000000000000000000000000808", // withdraw precompile + } +) // ExocoreEvmDefaultParams returns default evm parameters // ExtraEIPs is empty to prevent overriding the latest hard fork instruction set @@ -23,7 +28,7 @@ var ExocoreAvailableEVMExtensions = []string{ // from the EVM configuration. func ExocoreEvmDefaultParams() evmtype.Params { return evmtype.Params{ - EvmDenom: evmtype.DefaultEVMDenom, + EvmDenom: DefaultEVMDenom, EnableCreate: evmtype.DefaultEnableCreate, EnableCall: evmtype.DefaultEnableCall, ChainConfig: evmtype.DefaultChainConfig(), diff --git a/x/native_token/module.go b/x/native_token/module.go index 00269d42e..3cdaa922a 100644 --- a/x/native_token/module.go +++ b/x/native_token/module.go @@ -84,9 +84,9 @@ type IDeposit interface { PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error // SetReStakerExoCoreAddr handle the SetReStakerExoCoreAddr txs from msg service - SetReStakerExoCoreAddr(ctx context.Context, reStakerId string) (err error) - GetReStakerExoCoreAddr(reStakerId string) (addr sdk.Address, err error) + SetReStakerExoCoreAddr(ctx context.Context, reStakerID string) (err error) + GetReStakerExoCoreAddr(reStakerID string) (addr sdk.Address, err error) // Deposit internal func for PostTxProcessing - Deposit(reStakerId string, assetsInfo map[string]math.Uint) error + Deposit(reStakerID string, assetsInfo map[string]math.Uint) error } diff --git a/x/native_token/types/keys.go b/x/native_token/types/keys.go index 5835491f9..bcc3947a5 100644 --- a/x/native_token/types/keys.go +++ b/x/native_token/types/keys.go @@ -28,6 +28,6 @@ const ( prefixReStakerExocoreAddr = iota + 1 ) -// KeyPrefixReStakerExoCoreAddr reStakerId = clientChainAddr+'_'+ExoCoreChainIndex -// KeyPrefixReStakerExoCoreAddr key-value: reStakerId->exoCoreAddr +// KeyPrefixReStakerExoCoreAddr reStakerID = clientChainAddr+'_'+ExoCoreChainIndex +// KeyPrefixReStakerExoCoreAddr key-value: reStakerID->exoCoreAddr var KeyPrefixReStakerExoCoreAddr = []byte{prefixReStakerExocoreAddr} diff --git a/x/operator/client/cli/tx.go b/x/operator/client/cli/tx.go index b6f7ec6da..752b701a3 100644 --- a/x/operator/client/cli/tx.go +++ b/x/operator/client/cli/tx.go @@ -59,13 +59,13 @@ func RegisterOperator() *cobra.Command { if len(strList) != 2 { return errorsmod.Wrap(operatortypes.ErrCliCmdInputArg, fmt.Sprintf("the error input arg is:%s", arg)) } - clientChainLzId, err := strconv.ParseUint(strList[0], 10, 64) + clientChainLzID, err := strconv.ParseUint(strList[0], 10, 64) if err != nil { return err } clientChainEarningAddress.EarningInfoList = append(clientChainEarningAddress.EarningInfoList, &operatortypes.ClientChainEarningAddrInfo{ - LzClientChainId: clientChainLzId, ClientChainEarningAddr: strList[1], + LzClientChainID: clientChainLzID, ClientChainEarningAddr: strList[1], }) } msg.Info.ClientChainEarningsAddr = clientChainEarningAddress diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 26078e9d7..f4fb6f1f3 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -16,12 +16,12 @@ type SharedParameter struct { stakerShare map[string]sdkmath.LegacyDec } -func UpdateShareOfStakerAndOperator(sharedParam *SharedParameter, assetId, stakerId, operatorAddr string, assetAmount sdkmath.Int) { - priceChange := sharedParam.priceChangeAssets[assetId] - assetDecimal := sharedParam.assetsDecimal[assetId] - if avsAddr, ok := sharedParam.assetsOperatorAVSInfo[assetId][operatorAddr]; ok { +func UpdateShareOfStakerAndOperator(sharedParam *SharedParameter, assetID, stakerID, operatorAddr string, assetAmount sdkmath.Int) { + priceChange := sharedParam.priceChangeAssets[assetID] + assetDecimal := sharedParam.assetsDecimal[assetID] + if avsAddr, ok := sharedParam.assetsOperatorAVSInfo[assetID][operatorAddr]; ok { newAssetUSDValue := CalculateShare(assetAmount, priceChange.NewPrice, assetDecimal, priceChange.Decimal) - key := string(types.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr)) + key := string(types.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr)) AddShareInMap(sharedParam.stakerShare, key, newAssetUSDValue) } } @@ -38,18 +38,18 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) assetsOperatorAVSInfo := make(map[string]map[string]string, 0) assetsDecimal := make(map[string]uint32) - for assetId, priceChange := range priceChangeAssets { + for assetID, priceChange := range priceChangeAssets { //get the decimal of asset - assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) + assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } - assetsDecimal[assetId] = assetInfo.AssetBasicInfo.Decimals - if _, ok := assetsOperatorAVSInfo[assetId]; !ok { - assetsOperatorAVSInfo[assetId] = make(map[string]string, 0) + assetsDecimal[assetID] = assetInfo.AssetBasicInfo.Decimals + if _, ok := assetsOperatorAVSInfo[assetID]; !ok { + assetsOperatorAVSInfo[assetID] = make(map[string]string, 0) } //UpdateStateForAsset - f := func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error { + f := func(assetID string, keys []string, state *operatortypes.AssetOptedInState) error { newAssetUSDValue := CalculateShare(state.Amount, priceChange.NewPrice, assetInfo.AssetBasicInfo.Decimals, priceChange.Decimal) changeValue := newAssetUSDValue.Sub(state.Value) state.Value = newAssetUSDValue @@ -58,10 +58,10 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) AddShareInMap(avsOperatorShareChange, avsAddr, changeValue) AddShareInMap(avsOperatorShareChange, avsOperator, changeValue) - assetsOperatorAVSInfo[assetId][keys[2]] = avsAddr + assetsOperatorAVSInfo[assetID][keys[2]] = avsAddr return nil } - err = k.IterateUpdateAssetState(ctx, assetId, f) + err = k.IterateUpdateAssetState(ctx, assetID, f) if err != nil { return err } @@ -79,8 +79,8 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { assetsOperatorAVSInfo: assetsOperatorAVSInfo, stakerShare: make(map[string]sdkmath.LegacyDec, 0), } - stakerShareHandleFunc := func(stakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error { - UpdateShareOfStakerAndOperator(sharedParameter, assetId, stakerId, operatorAddr, state.CanUndelegationAmount) + stakerShareHandleFunc := func(stakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error { + UpdateShareOfStakerAndOperator(sharedParameter, assetID, stakerID, operatorAddr, state.CanUndelegationAmount) return nil } err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) @@ -88,8 +88,8 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { return err } - operatorShareHandleFunc := func(operatorAddr, assetId string, state *types.OperatorSingleAssetOrChangeInfo) error { - UpdateShareOfStakerAndOperator(sharedParameter, assetId, "", operatorAddr, state.OperatorOwnAmountOrWantChangeValue) + operatorShareHandleFunc := func(operatorAddr, assetID string, state *types.OperatorSingleAssetOrChangeInfo) error { + UpdateShareOfStakerAndOperator(sharedParameter, assetID, "", operatorAddr, state.OperatorOwnAmountOrWantChangeValue) return nil } err = k.restakingStateKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index 56db14f1a..eb9f06e27 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -120,7 +120,7 @@ func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec return ret.Amount, nil } -func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetId, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { +func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) if changeState.Amount.IsNil() && changeState.Value.IsNil() { return nil @@ -130,7 +130,7 @@ func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetId, avsAddr, operator if err != nil { return restakingtype.ErrOperatorAddr } - stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) + stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) assetOptedInState := operatortypes.AssetOptedInState{ Amount: sdkmath.NewInt(0), Value: sdkmath.LegacyNewDec(0), @@ -157,21 +157,21 @@ func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetId, avsAddr, operator return nil } -func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) error { +func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) //check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { return restakingtype.ErrOperatorAddr } - stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) + stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) store.Delete(stateKey) return nil } -func (k *Keeper) GetAssetState(ctx sdk.Context, assetId, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { +func (k *Keeper) GetAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - stateKey := restakingtype.GetJoinedStoreKey(assetId, avsAddr, operatorAddr) + stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) isExit := store.Has(stateKey) assetOptedInState := operatortypes.AssetOptedInState{} if isExit { @@ -183,9 +183,9 @@ func (k *Keeper) GetAssetState(ctx sdk.Context, assetId, avsAddr, operatorAddr s return &assetOptedInState, nil } -func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetId string, f func(assetId string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { +func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func(assetID string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - iterator := sdk.KVStorePrefixIterator(store, []byte(assetId)) + iterator := sdk.KVStorePrefixIterator(store, []byte(assetID)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -195,7 +195,7 @@ func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetId string, f func } assetOptedInState := &operatortypes.AssetOptedInState{} k.cdc.MustUnmarshal(iterator.Value(), assetOptedInState) - err = f(assetId, keys, assetOptedInState) + err = f(assetID, keys, assetOptedInState) if err != nil { return err } @@ -205,12 +205,12 @@ func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetId string, f func return nil } -func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerId, operatorAddr string, opAmount sdkmath.LegacyDec) error { +func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) + key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) optedInValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { @@ -241,17 +241,17 @@ func (k *Keeper) BatchSetStakerShare(ctx sdk.Context, newValues map[string]sdkma return nil } -func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) error { +func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) + key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) store.Delete(key) return nil } -func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerId, operatorAddr string) (sdkmath.LegacyDec, error) { +func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) var ret operatortypes.ValueField - key := restakingtype.GetJoinedStoreKey(avsAddr, stakerId, operatorAddr) + key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) isExit := store.Has(key) if !isExit { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerShare: key is %s", key)) diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 114f00185..02739ea00 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -64,7 +64,7 @@ type OperatorKeeper interface { GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 - UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error + UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, operatorAddr string, opAmount sdkmath.Int) error OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index 4ae5d47b9..d7b3f720a 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -5,9 +5,9 @@ import ( "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" ) -func (suite *KeeperTestSuite) TestOperatorInfo() { +func (suite *OperatorTestSuite) TestOperatorInfo() { info := &operatortype.OperatorInfo{ - EarningsAddr: suite.accAddress.String(), + EarningsAddr: suite.AccAddress.String(), ApproveAddr: "", OperatorMetaInfo: "test operator", ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ @@ -16,45 +16,45 @@ func (suite *KeeperTestSuite) TestOperatorInfo() { }, }, } - err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) + err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), info) suite.NoError(err) - getOperatorInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: suite.accAddress.String()}) + getOperatorInfo, err := suite.App.OperatorKeeper.GetOperatorInfo(suite.Ctx, &operatortype.GetOperatorInfoReq{OperatorAddr: suite.AccAddress.String()}) suite.NoError(err) suite.Equal(*info, *getOperatorInfo) } -func (suite *KeeperTestSuite) TestHistoricalOperatorInfo() { - height := suite.ctx.BlockHeight() +func (suite *OperatorTestSuite) TestHistoricalOperatorInfo() { + height := suite.Ctx.BlockHeight() info := &operatortype.OperatorInfo{ - EarningsAddr: suite.accAddress.String(), + EarningsAddr: suite.AccAddress.String(), ApproveAddr: "", OperatorMetaInfo: "test operator", ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ EarningInfoList: nil, }, } - err := suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), info) + err := suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), info) suite.NoError(err) suite.NextBlock() - suite.Equal(height+1, suite.ctx.BlockHeight(), "nexBlock failed") + suite.Equal(height+1, suite.Ctx.BlockHeight(), "nexBlock failed") newInfo := *info newInfo.OperatorMetaInfo = "new operator" - err = suite.app.OperatorKeeper.SetOperatorInfo(suite.ctx, suite.accAddress.String(), &newInfo) + err = suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), &newInfo) suite.NoError(err) //get historical operator info - historicalQueryCtx, err := types.ContextForHistoricalState(suite.ctx, height) + historicalQueryCtx, err := types.ContextForHistoricalState(suite.Ctx, height) suite.NoError(err) - getInfo, err := suite.app.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ - OperatorAddr: suite.accAddress.String(), + getInfo, err := suite.App.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ + OperatorAddr: suite.AccAddress.String(), }) suite.NoError(err) suite.Equal(info.OperatorMetaInfo, getInfo.OperatorMetaInfo) - getInfo, err = suite.app.OperatorKeeper.GetOperatorInfo(suite.ctx, &operatortype.GetOperatorInfoReq{ - OperatorAddr: suite.accAddress.String(), + getInfo, err = suite.App.OperatorKeeper.GetOperatorInfo(suite.Ctx, &operatortype.GetOperatorInfoReq{ + OperatorAddr: suite.AccAddress.String(), }) suite.NoError(err) suite.Equal(newInfo.OperatorMetaInfo, getInfo.OperatorMetaInfo) diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 73c6c0ff9..c44e31d40 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -55,17 +55,17 @@ func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, sl return &operatorSlashInfo, nil } -func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64, opAmount sdkmath.Int) error { +func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator string, completeHeight uint64, opAmount sdkmath.Int) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte - if stakerOrOperator == "" || assetId == "" { - return errorsmod.Wrap(operatortypes.ErrParameterInvalid, fmt.Sprintf("assetId:%suite,stakerOrOperator:%suite", assetId, stakerOrOperator)) + if stakerOrOperator == "" || assetID == "" { + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, fmt.Sprintf("assetID:%suite,stakerOrOperator:%suite", assetID, stakerOrOperator)) } - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerOrOperator) + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID, stakerOrOperator) slashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} if store.Has(key) { value := store.Get(key) @@ -78,7 +78,7 @@ func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperat bz := k.cdc.MustMarshal(&slashAmount) store.Set(key, bz) - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID) totalSlashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} if store.Has(key) { value := store.Get(key) @@ -93,13 +93,13 @@ func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperat return nil } -func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetId, stakerOrOperator string, completeHeight uint64) (sdkmath.Int, error) { +func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator string, completeHeight uint64) (sdkmath.Int, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte if stakerOrOperator == "" { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId) + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID) } else { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetId, stakerOrOperator) + key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID, stakerOrOperator) } var ret restakingtype.ValueField isExit := store.Has(key) diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go index a13fa1ce8..9c20336be 100644 --- a/x/operator/keeper/setup_test.go +++ b/x/operator/keeper/setup_test.go @@ -2,57 +2,35 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" - "github.com/stretchr/testify/suite" - "testing" - - "github.com/evmos/evmos/v14/x/evm/statedb" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - evmosapp "github.com/ExocoreNetwork/exocore/app" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/ExocoreNetwork/exocore/testutil" sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/stretchr/testify/suite" + "testing" ) -var s *KeeperTestSuite - -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *evmosapp.ExocoreApp - address common.Address - accAddress sdk.AccAddress +var s *OperatorTestSuite - validators []stakingtypes.Validator - valSet *tmtypes.ValidatorSet - ethSigner ethtypes.Signer - privKey cryptotypes.PrivKey - signer keyring.Signer - bondDenom string - stateDB *statedb.StateDB +type OperatorTestSuite struct { + testutil.BaseTestSuite //needed by test operatorAddr sdk.AccAddress avsAddr string - assetId string - stakerId string + assetID string + stakerID string assetAddr common.Address assetDecimal uint32 - clientChainLzId uint64 + clientChainLzID uint64 depositAmount sdkmath.Int delegationAmount sdkmath.Int updatedAmountForOptIn sdkmath.Int } func TestOperatorTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(OperatorTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -60,6 +38,6 @@ func TestOperatorTestSuite(t *testing.T) { RunSpecs(t, "operator module Suite") } -func (suite *KeeperTestSuite) SetupTest() { +func (suite *OperatorTestSuite) SetupTest() { suite.DoSetupTest() } diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index afdc2fe12..0bf229c51 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -25,20 +25,20 @@ type SlashAssets struct { slashOperatorInfo map[string]*slashAmounts } -func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, operatorAddr string, opAmount sdkmath.Int) error { +func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, operatorAddr string, opAmount sdkmath.Int) error { //get the AVS opted-in by the operator avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) if err != nil { return err } //get price and priceDecimal from oracle - price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) + price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetID) if err != nil { return err } //get the decimal of asset - assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) + assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } @@ -50,9 +50,9 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, op return err } - if _, ok := avsSupportedAssets[assetId]; ok { + if _, ok := avsSupportedAssets[assetID]; ok { //UpdateStakerShare - err = k.UpdateStakerShare(ctx, avs, stakerId, operatorAddr, opUSDValue) + err = k.UpdateStakerShare(ctx, avs, stakerID, operatorAddr, opUSDValue) if err != nil { return err } @@ -62,7 +62,7 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerId, assetId, op Amount: opAmount, Value: opUSDValue, } - err = k.UpdateStateForAsset(ctx, assetId, avs, operatorAddr, changeState) + err = k.UpdateStateForAsset(ctx, assetID, avs, operatorAddr, changeState) if err != nil { return err } @@ -106,19 +106,19 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr assetFilter := make(map[string]interface{}) assetInfoRecord := make(map[string]*AssetPriceAndDecimal) - for assetId, operatorAssetState := range operatorAssets { + for assetID, operatorAssetState := range operatorAssets { //get price and priceDecimal from oracle - price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetId) + price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetID) if err != nil { return err } //get the decimal of asset - assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetId) + assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } - assetInfoRecord[assetId] = &AssetPriceAndDecimal{ + assetInfoRecord[assetID] = &AssetPriceAndDecimal{ Price: price, PriceDecimal: decimal, Decimal: assetInfo.AssetBasicInfo.Decimals, @@ -132,15 +132,15 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr Amount: operatorAssetState.TotalAmountOrWantChangeValue, Value: assetUSDValue, } - err = k.UpdateStateForAsset(ctx, assetId, AVSAddr, operatorAddress.String(), changeState) + err = k.UpdateStateForAsset(ctx, assetID, AVSAddr, operatorAddress.String(), changeState) if err != nil { return err } totalAssetUSDValue = totalAssetUSDValue.Add(assetUSDValue) - assetFilter[assetId] = nil + assetFilter[assetID] = nil } - //update the share value of operator itself, the input stakerId should be empty + //update the share value of operator itself, the input stakerID should be empty err = k.UpdateStakerShare(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUSDValue) if err != nil { return err @@ -163,14 +163,14 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return err } - for stakerId, assetState := range relatedAssetsState { + for stakerID, assetState := range relatedAssetsState { stakerAssetsUSDValue := sdkmath.LegacyNewDec(0) - for assetId, amount := range assetState { - singleAssetUSDValue := CalculateShare(amount.CanUndelegationAmount, assetInfoRecord[assetId].Price, assetInfoRecord[assetId].Decimal, assetInfoRecord[assetId].PriceDecimal) + for assetID, amount := range assetState { + singleAssetUSDValue := CalculateShare(amount.CanUndelegationAmount, assetInfoRecord[assetID].Price, assetInfoRecord[assetID].Decimal, assetInfoRecord[assetID].PriceDecimal) stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) } - err = k.UpdateStakerShare(ctx, AVSAddr, stakerId, operatorAddress.String(), stakerAssetsUSDValue) + err = k.UpdateStakerShare(ctx, AVSAddr, stakerID, operatorAddress.String(), stakerAssetsUSDValue) if err != nil { return err } @@ -213,12 +213,12 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr assetFilter := make(map[string]interface{}) - for assetId := range operatorAssets { - err = k.DeleteAssetState(ctx, assetId, AVSAddr, operatorAddress.String()) + for assetID := range operatorAssets { + err = k.DeleteAssetState(ctx, assetID, AVSAddr, operatorAddress.String()) if err != nil { return err } - assetFilter[assetId] = nil + assetFilter[assetID] = nil } avsOperatorTotalValue, err := k.GetOperatorShare(ctx, AVSAddr, operatorAddress.String()) @@ -229,7 +229,7 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return errorsmod.Wrap(types.ErrTheValueIsNegative, fmt.Sprintf("OptOut,avsOperatorTotalValue:%suite", avsOperatorTotalValue)) } - //delete the share value of operator itself, the input stakerId should be empty + //delete the share value of operator itself, the input stakerID should be empty err = k.DeleteStakerShare(ctx, AVSAddr, "", operatorAddress.String()) if err != nil { return err @@ -251,8 +251,8 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr if err != nil { return err } - for stakerId := range relatedAssetsState { - err = k.DeleteStakerShare(ctx, AVSAddr, stakerId, operatorAddress.String()) + for stakerID := range relatedAssetsState { + err = k.DeleteStakerShare(ctx, AVSAddr, stakerID, operatorAddress.String()) if err != nil { return err } @@ -311,24 +311,24 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc } //calculate the actual slash amount for staker - for stakerId, assetsState := range currentStakerAssets { - if historyAssetState, ok := historyStakerAssets[stakerId]; ok { - for assetId, curState := range assetsState { - if historyState, isExist := historyAssetState[assetId]; isExist { - if _, exist := ret.slashStakerInfo[stakerId]; !exist { - ret.slashStakerInfo[stakerId] = make(map[string]*slashAmounts, 0) + for stakerID, assetsState := range currentStakerAssets { + if historyAssetState, ok := historyStakerAssets[stakerID]; ok { + for assetID, curState := range assetsState { + if historyState, isExist := historyAssetState[assetID]; isExist { + if _, exist := ret.slashStakerInfo[stakerID]; !exist { + ret.slashStakerInfo[stakerID] = make(map[string]*slashAmounts, 0) } shouldSlashAmount := slashProportion.MulInt(historyState.CanUndelegationAmount).TruncateInt() if curState.CanUndelegationAmount.LT(shouldSlashAmount) { - ret.slashStakerInfo[stakerId][assetId].AmountFromOptedIn = curState.CanUndelegationAmount + ret.slashStakerInfo[stakerID][assetID].AmountFromOptedIn = curState.CanUndelegationAmount remainShouldSlash := shouldSlashAmount.Sub(curState.CanUndelegationAmount) if curState.UndelegatableAmountAfterSlash.LT(remainShouldSlash) { - ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = curState.UndelegatableAmountAfterSlash + ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = curState.UndelegatableAmountAfterSlash } else { - ret.slashStakerInfo[stakerId][assetId].AmountFromUnbonding = remainShouldSlash + ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = remainShouldSlash } } else { - ret.slashStakerInfo[stakerId][assetId].AmountFromOptedIn = shouldSlashAmount + ret.slashStakerInfo[stakerID][assetID].AmountFromOptedIn = shouldSlashAmount } } } @@ -336,19 +336,19 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc } //calculate the actual slash amount for operator - for assetId, curAssetState := range currentOperatorAssetsState { - if historyAssetState, ok := historyOperatorAssetsState[assetId]; ok { + for assetID, curAssetState := range currentOperatorAssetsState { + if historyAssetState, ok := historyOperatorAssetsState[assetID]; ok { shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorOwnAmountOrWantChangeValue).TruncateInt() if curAssetState.OperatorOwnAmountOrWantChangeValue.LT(shouldSlashAmount) { - ret.slashOperatorInfo[assetId].AmountFromOptedIn = curAssetState.OperatorOwnAmountOrWantChangeValue + ret.slashOperatorInfo[assetID].AmountFromOptedIn = curAssetState.OperatorOwnAmountOrWantChangeValue remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmountOrWantChangeValue) if curAssetState.OperatorUnbondableAmountAfterSlash.LT(remainShouldSlash) { - ret.slashOperatorInfo[assetId].AmountFromUnbonding = curAssetState.OperatorUnbondableAmountAfterSlash + ret.slashOperatorInfo[assetID].AmountFromUnbonding = curAssetState.OperatorUnbondableAmountAfterSlash } else { - ret.slashOperatorInfo[assetId].AmountFromUnbonding = remainShouldSlash + ret.slashOperatorInfo[assetID].AmountFromUnbonding = remainShouldSlash } } else { - ret.slashOperatorInfo[assetId].AmountFromOptedIn = shouldSlashAmount + ret.slashOperatorInfo[assetID].AmountFromOptedIn = shouldSlashAmount } } } @@ -356,8 +356,8 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc } func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, executeHeight uint64) error { - for stakerId, slashAssets := range slashStakerInfo { - for assetId, slashInfo := range slashAssets { + for stakerID, slashAssets := range slashStakerInfo { + for assetID, slashInfo := range slashAssets { //handle the state that needs to be updated when slashing both opted-in and unbonding assets //update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) @@ -365,18 +365,18 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl CanUndelegationAmount: slashInfo.AmountFromOptedIn.Neg(), UndelegatableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), } - err := k.delegationKeeper.UpdateDelegationState(ctx, stakerId, assetId, delegatorAndAmount) + err := k.delegationKeeper.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { return err } - err = k.delegationKeeper.UpdateStakerDelegationTotalAmount(ctx, stakerId, assetId, slashInfo.AmountFromOptedIn.Neg()) + err = k.delegationKeeper.UpdateStakerDelegationTotalAmount(ctx, stakerID, assetID, slashInfo.AmountFromOptedIn.Neg()) if err != nil { return err } slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) //update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerId, assetId, types2.StakerSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: slashSumValue.Neg(), }) if err != nil { @@ -384,20 +384,20 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl } //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetId, stakerId, executeHeight, slashSumValue) + err = k.UpdateSlashAssetsState(ctx, assetID, stakerID, executeHeight, slashSumValue) if err != nil { return err } //handle the state that needs to be updated when slashing opted-in assets - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), }) if err != nil { return err } //decrease the related share value - err = k.UpdateOptedInAssetsState(ctx, stakerId, assetId, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) + err = k.UpdateOptedInAssetsState(ctx, stakerID, assetID, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) if err != nil { return err } @@ -407,10 +407,10 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl } func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, executeHeight uint64) error { - for assetId, slashInfo := range slashOperatorInfo { + for assetID, slashInfo := range slashOperatorInfo { slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) //handle the state that needs to be updated when slashing both opted-in and unbonding assets - err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetId, types2.OperatorSingleAssetOrChangeInfo{ + err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: slashSumValue.Neg(), OperatorOwnAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), OperatorUnbondableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), @@ -419,14 +419,14 @@ func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, return err } //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetId, operatorAddress.String(), executeHeight, slashSumValue) + err = k.UpdateSlashAssetsState(ctx, assetID, operatorAddress.String(), executeHeight, slashSumValue) if err != nil { return err } //handle the state that needs to be updated when slashing opted-in assets //decrease the related share value - err = k.UpdateOptedInAssetsState(ctx, "", assetId, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) + err = k.UpdateOptedInAssetsState(ctx, "", assetID, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) if err != nil { return err } diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index 906d029b5..53f560b1f 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -21,31 +21,31 @@ type StateForCheck struct { StakerShare sdkmath.LegacyDec } -func (suite *KeeperTestSuite) prepare() { - opAccAddr, err := sdk.AccAddressFromBech32("evmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3h6cprl") +func (suite *OperatorTestSuite) prepare() { + opAccAddr, err := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") suite.NoError(err) usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") - clientChainLzId := uint64(101) + clientChainLzID := uint64(101) suite.avsAddr = "avsTestAddr" suite.operatorAddr = opAccAddr suite.assetAddr = usdtAddress suite.assetDecimal = 6 - suite.clientChainLzId = clientChainLzId + suite.clientChainLzID = clientChainLzID suite.depositAmount = sdkmath.NewInt(100) suite.delegationAmount = sdkmath.NewInt(50) suite.updatedAmountForOptIn = sdkmath.NewInt(20) - suite.stakerId, suite.assetId = restakingTypes.GetStakeIDAndAssetId(suite.clientChainLzId, suite.address[:], suite.assetAddr[:]) + suite.stakerID, suite.assetID = restakingTypes.GetStakeIDAndAssetID(suite.clientChainLzID, suite.Address[:], suite.assetAddr[:]) //staking assets depositParam := &keeper.DepositParams{ - ClientChainLzId: suite.clientChainLzId, + ClientChainLzID: suite.clientChainLzID, Action: restakingTypes.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: suite.depositAmount, } depositParam.AssetsAddress = suite.assetAddr[:] - err = suite.app.DepositKeeper.Deposit(suite.ctx, depositParam) + err = suite.App.DepositKeeper.Deposit(suite.Ctx, depositParam) suite.NoError(err) //register operator @@ -55,27 +55,27 @@ func (suite *KeeperTestSuite) prepare() { EarningsAddr: suite.operatorAddr.String(), }, } - _, err = suite.app.OperatorKeeper.RegisterOperator(suite.ctx, registerReq) + _, err = suite.App.OperatorKeeper.RegisterOperator(suite.Ctx, registerReq) suite.NoError(err) //delegate to operator delegationParam := &delegationKeeper.DelegationOrUndelegationParams{ - ClientChainLzId: suite.clientChainLzId, + ClientChainLzID: suite.clientChainLzID, Action: restakingTypes.DelegateTo, AssetsAddress: suite.assetAddr[:], OperatorAddress: suite.operatorAddr, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: suite.delegationAmount, LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - err = suite.app.DelegationKeeper.DelegateTo(suite.ctx, delegationParam) + err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationParam) suite.NoError(err) } -func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { +func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { //check opted info - optInfo, err := suite.app.OperatorKeeper.GetOptedInfo(suite.ctx, suite.operatorAddr.String(), suite.avsAddr) + optInfo, err := suite.App.OperatorKeeper.GetOptedInfo(suite.Ctx, suite.operatorAddr.String(), suite.avsAddr) if expectedState.OptedInfo == nil { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { @@ -83,7 +83,7 @@ func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { suite.Equal(*expectedState.OptedInfo, *optInfo) } //check total USD value for AVS and operator - value, err := suite.app.OperatorKeeper.GetAVSShare(suite.ctx, suite.avsAddr) + value, err := suite.App.OperatorKeeper.GetAVSShare(suite.Ctx, suite.avsAddr) if expectedState.AVSTotalShare.IsNil() { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { @@ -91,7 +91,7 @@ func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { suite.Equal(expectedState.AVSTotalShare, value) } - value, err = suite.app.OperatorKeeper.GetOperatorShare(suite.ctx, suite.avsAddr, suite.operatorAddr.String()) + value, err = suite.App.OperatorKeeper.GetOperatorShare(suite.Ctx, suite.avsAddr, suite.operatorAddr.String()) if expectedState.AVSOperatorShare.IsNil() { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { @@ -100,7 +100,7 @@ func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { } //check assets state for AVS and operator - assetState, err := suite.app.OperatorKeeper.GetAssetState(suite.ctx, suite.assetId, suite.avsAddr, suite.operatorAddr.String()) + assetState, err := suite.App.OperatorKeeper.GetAssetState(suite.Ctx, suite.assetID, suite.avsAddr, suite.operatorAddr.String()) if expectedState.AssetState == nil { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { @@ -109,14 +109,14 @@ func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { } //check asset USD share for staker and operator - operatorShare, err := suite.app.OperatorKeeper.GetStakerShare(suite.ctx, suite.avsAddr, "", suite.operatorAddr.String()) + operatorShare, err := suite.App.OperatorKeeper.GetStakerShare(suite.Ctx, suite.avsAddr, "", suite.operatorAddr.String()) if expectedState.OperatorShare.IsNil() { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { suite.NoError(err) suite.Equal(expectedState.OperatorShare, operatorShare) } - stakerShare, err := suite.app.OperatorKeeper.GetStakerShare(suite.ctx, suite.avsAddr, suite.stakerId, suite.operatorAddr.String()) + stakerShare, err := suite.App.OperatorKeeper.GetStakerShare(suite.Ctx, suite.avsAddr, suite.stakerID, suite.operatorAddr.String()) if expectedState.StakerShare.IsNil() { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) } else { @@ -125,16 +125,16 @@ func (suite *KeeperTestSuite) CheckState(expectedState *StateForCheck) { } } -func (suite *KeeperTestSuite) TestOptIn() { +func (suite *OperatorTestSuite) TestOptIn() { suite.prepare() - err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) //check if the related state is correct - price, decimal, err := suite.app.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.ctx, suite.assetId) + price, decimal, err := suite.App.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.Ctx, suite.assetID) share := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) expectedState := &StateForCheck{ OptedInfo: &operatorTypes.OptedInfo{ - OptedInHeight: uint64(suite.ctx.BlockHeight()), + OptedInHeight: uint64(suite.Ctx.BlockHeight()), OptedOutHeight: operatorTypes.DefaultOptedOutHeight, }, AVSTotalShare: share, @@ -149,23 +149,23 @@ func (suite *KeeperTestSuite) TestOptIn() { suite.CheckState(expectedState) } -func (suite *KeeperTestSuite) TestOptOut() { +func (suite *OperatorTestSuite) TestOptOut() { suite.prepare() - err := suite.app.OperatorKeeper.OptOut(suite.ctx, suite.operatorAddr, suite.avsAddr) + err := suite.App.OperatorKeeper.OptOut(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.EqualError(err, operatorTypes.ErrNotOptedIn.Error()) - err = suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + err = suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) - optInHeight := suite.ctx.BlockHeight() + optInHeight := suite.Ctx.BlockHeight() suite.NextBlock() - err = suite.app.OperatorKeeper.OptOut(suite.ctx, suite.operatorAddr, suite.avsAddr) + err = suite.App.OperatorKeeper.OptOut(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) expectedState := &StateForCheck{ OptedInfo: &operatorTypes.OptedInfo{ OptedInHeight: uint64(optInHeight), - OptedOutHeight: uint64(suite.ctx.BlockHeight()), + OptedOutHeight: uint64(suite.Ctx.BlockHeight()), }, AVSTotalShare: sdkmath.LegacyNewDec(0), AVSOperatorShare: sdkmath.LegacyDec{}, @@ -176,25 +176,25 @@ func (suite *KeeperTestSuite) TestOptOut() { suite.CheckState(expectedState) } -func (suite *KeeperTestSuite) TestCalculateShare() { +func (suite *OperatorTestSuite) TestCalculateShare() { suite.prepare() - price, decimal, err := suite.app.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.ctx, suite.assetId) + price, decimal, err := suite.App.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.Ctx, suite.assetID) suite.NoError(err) share := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) suite.Equal(sdkmath.LegacyNewDecWithPrec(5000, int64(operatorTypes.USDValueDefaultDecimal)), share) } -func (suite *KeeperTestSuite) TestUpdateOptedInAssetsState() { +func (suite *OperatorTestSuite) TestUpdateOptedInAssetsState() { suite.prepare() - err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) - optInHeight := suite.ctx.BlockHeight() + optInHeight := suite.Ctx.BlockHeight() suite.NextBlock() - err = suite.app.OperatorKeeper.UpdateOptedInAssetsState(suite.ctx, suite.stakerId, suite.assetId, suite.operatorAddr.String(), suite.updatedAmountForOptIn) + err = suite.App.OperatorKeeper.UpdateOptedInAssetsState(suite.Ctx, suite.stakerID, suite.assetID, suite.operatorAddr.String(), suite.updatedAmountForOptIn) suite.NoError(err) - price, decimal, err := suite.app.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.ctx, suite.assetId) + price, decimal, err := suite.App.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.Ctx, suite.assetID) oldShare := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) addShare := operatorKeeper.CalculateShare(suite.updatedAmountForOptIn, price, suite.assetDecimal, decimal) newShare := oldShare.Add(addShare) @@ -216,17 +216,17 @@ func (suite *KeeperTestSuite) TestUpdateOptedInAssetsState() { suite.CheckState(expectedState) } -func (suite *KeeperTestSuite) TestSlash() { +func (suite *OperatorTestSuite) TestSlash() { suite.prepare() - err := suite.app.OperatorKeeper.OptIn(suite.ctx, suite.operatorAddr, suite.avsAddr) + err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) - optInHeight := suite.ctx.BlockHeight() + optInHeight := suite.Ctx.BlockHeight() // run to the block at specified height runToHeight := optInHeight + 10 for i := optInHeight; i < runToHeight; i++ { suite.NextBlock() } - suite.Equal(runToHeight, suite.ctx.BlockHeight()) + suite.Equal(runToHeight, suite.Ctx.BlockHeight()) } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 571251880..ebd102cb9 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -9,10 +9,10 @@ import ( type ExpectDelegationInterface interface { DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) - IterateDelegationState(ctx sdk.Context, f func(restakerId, assetId, operatorAddr string, state *delegationtype.DelegationAmounts) error) error - UpdateDelegationState(ctx sdk.Context, stakerId string, assetId string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) + IterateDelegationState(ctx sdk.Context, f func(restakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error) error + UpdateDelegationState(ctx sdk.Context, stakerID string, assetID string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) - UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerId string, assetId string, opAmount sdkmath.Int) error + UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerID string, assetID string, opAmount sdkmath.Int) error } type PriceChange struct { @@ -34,8 +34,8 @@ func (MockOracle) GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdk func (MockOracle) GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) { //use USDT as the mock asset ret := make(map[string]*PriceChange, 0) - usdtAssetId := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" - ret[usdtAssetId] = &PriceChange{ + usdtAssetID := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" + ret[usdtAssetID] = &PriceChange{ NewPrice: sdkmath.NewInt(1), OriginalPrice: sdkmath.NewInt(1), Decimal: 0, @@ -48,8 +48,8 @@ type MockAVS struct{} func (MockAVS) GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) { //set USDT as the default asset supported by AVS ret := make(map[string]interface{}) - usdtAssetId := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" - ret[usdtAssetId] = nil + usdtAssetID := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" + ret[usdtAssetID] = nil return ret, nil } diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 79105ea26..e4130c014 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -71,12 +71,12 @@ var ( KeyPrefixAVSOperatorAssetsTotalValue = []byte{prefixAVSOperatorAssetsTotalValue} // KeyPrefixOperatorAVSSingleAssetState key-value: - // assetId + '/' + AVSAddr + '/' + operatorAddr -> AssetOptedInState + // assetID + '/' + AVSAddr + '/' + operatorAddr -> AssetOptedInState KeyPrefixOperatorAVSSingleAssetState = []byte{prefixOperatorAVSSingleAssetState} // KeyPrefixAVSOperatorStakerShareState key-value: // AVSAddr + '/' + '' + '/' + operatorAddr -> ownAssetsOptedInValue - // AVSAddr + '/' + stakerId + '/' + operatorAddr -> assetsOptedInValue + // AVSAddr + '/' + stakerID + '/' + operatorAddr -> assetsOptedInValue KeyPrefixAVSOperatorStakerShareState = []byte{prefixOperatorAVSStakerShareState} // KeyPrefixOperatorSlashInfo key-value: @@ -84,9 +84,9 @@ var ( KeyPrefixOperatorSlashInfo = []byte{prefixOperatorSlashInfo} // KeyPrefixSlashAssetsState key-value: - // completeSlashHeight + '/' + assetId -> SlashAmount - // completeSlashHeight + '/' + assetId + '/' + stakerId -> SlashAmount - // completeSlashHeight + '/' + assetId + '/' + operatorAddr -> SlashAmount + // completeSlashHeight + '/' + assetID -> SlashAmount + // completeSlashHeight + '/' + assetID + '/' + stakerID -> SlashAmount + // completeSlashHeight + '/' + assetID + '/' + operatorAddr -> SlashAmount KeyPrefixSlashAssetsState = []byte{prefixSlashAssetsState} ) diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 174cb21bc..4bae48d47 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -77,7 +77,7 @@ func (m *ClientChainEarningAddrList) GetEarningInfoList() []*ClientChainEarningA } type ClientChainEarningAddrInfo struct { - LzClientChainId uint64 `protobuf:"varint,1,opt,name=lzClientChainId,proto3" json:"lzClientChainId,omitempty"` + LzClientChainID uint64 `protobuf:"varint,1,opt,name=lzClientChainID,proto3" json:"lzClientChainID,omitempty"` ClientChainEarningAddr string `protobuf:"bytes,2,opt,name=clientChainEarningAddr,proto3" json:"clientChainEarningAddr,omitempty"` } @@ -114,9 +114,9 @@ func (m *ClientChainEarningAddrInfo) XXX_DiscardUnknown() { var xxx_messageInfo_ClientChainEarningAddrInfo proto.InternalMessageInfo -func (m *ClientChainEarningAddrInfo) GetLzClientChainId() uint64 { +func (m *ClientChainEarningAddrInfo) GetLzClientChainID() uint64 { if m != nil { - return m.LzClientChainId + return m.LzClientChainID } return 0 } @@ -693,63 +693,63 @@ func init() { func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 891 bytes of a gzipped FileDescriptorProto + // 892 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0xdc, 0x44, 0x14, 0x5e, 0x67, 0x37, 0x69, 0xf3, 0x12, 0x48, 0x33, 0x2d, 0x89, 0x63, 0xc1, 0xc6, 0x35, 0xa8, - 0x5a, 0x2d, 0xca, 0x5a, 0x0d, 0xb4, 0x87, 0x88, 0x4b, 0x9a, 0xa6, 0x62, 0x45, 0xcb, 0xa2, 0x49, + 0x5a, 0x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8d, 0xa8, 0xa4, 0x9e, 0x24, 0xbd, 0x58, + 0xf6, 0x12, 0x99, 0xee, 0xf4, 0x0d, 0xe4, 0x57, 0x4a, 0xe0, 0x7d, 0xb8, 0xfa, 0x1f, 0x61, 0xb2, + 0x5c, 0x56, 0xff, 0x99, 0x80, 0xfa, 0x5d, 0x11, 0xa2, 0x3e, 0x5c, 0x2a, 0x17, 0x11, 0xb5, 0x2a, + 0xfb, 0x56, 0x31, 0x2b, 0xd6, 0xca, 0x2b, 0x32, 0xb3, 0xa0, 0xa8, 0xaf, 0xae, 0xba, 0x42, 0x69, + 0x50, 0x7b, 0xc4, 0x88, 0x54, 0xb4, 0xce, 0xfa, 0xf0, 0x95, 0xb8, 0xba, 0xd6, 0x35, 0xf4, 0x93, + 0x01, 0x4b, 0x23, 0xeb, 0x80, 0x6e, 0x54, 0x8a, 0xfd, 0x5f, 0x7b, 0xac, 0x9b, 0xe3, 0xba, 0xe5, + 0xe9, 0x58, 0x93, 0xdf, 0x9d, 0x1e, 0xb5, 0x8d, 0x5b, 0x77, 0x9e, 0x1e, 0x37, 0x8d, 0x67, 0xc7, + 0x4d, 0xe3, 0xcf, 0xe3, 0xa6, 0xf1, 0xf3, 0x49, 0xb3, 0xf6, 0xec, 0xa4, 0x59, 0xfb, 0xfd, 0xa4, + 0x59, 0xfb, 0x6a, 0xb5, 0x70, 0xac, 0xb7, 0xb2, 0x20, 0x9f, 0x13, 0xf9, 0x88, 0xf1, 0xbe, 0x9b, + 0xbf, 0x78, 0x0e, 0x5e, 0xbe, 0x79, 0xd4, 0x31, 0xdf, 0x9d, 0x52, 0x4f, 0x90, 0x8f, 0xfe, 0x0d, + 0x00, 0x00, 0xff, 0xff, 0x7c, 0x63, 0xa1, 0xfe, 0x14, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -988,8 +988,8 @@ func (m *ClientChainEarningAddrInfo) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x12 } - if m.LzClientChainId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.LzClientChainId)) + if m.LzClientChainID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.LzClientChainID)) i-- dAtA[i] = 0x8 } @@ -1457,8 +1457,8 @@ func (m *ClientChainEarningAddrInfo) Size() (n int) { } var l int _ = l - if m.LzClientChainId != 0 { - n += 1 + sovTx(uint64(m.LzClientChainId)) + if m.LzClientChainID != 0 { + n += 1 + sovTx(uint64(m.LzClientChainID)) } l = len(m.ClientChainEarningAddr) if l > 0 { @@ -1765,9 +1765,9 @@ func (m *ClientChainEarningAddrInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LzClientChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LzClientChainID", wireType) } - m.LzClientChainId = 0 + m.LzClientChainID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1777,7 +1777,7 @@ func (m *ClientChainEarningAddrInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LzClientChainId |= uint64(b&0x7F) << shift + m.LzClientChainID |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/restaking_assets_manage/client/cli/query.go b/x/restaking_assets_manage/client/cli/query.go index 8626d71af..eac1485cb 100644 --- a/x/restaking_assets_manage/client/cli/query.go +++ b/x/restaking_assets_manage/client/cli/query.go @@ -40,7 +40,7 @@ func GetQueryCmd() *cobra.Command { // QueClientChainInfoByIndex queries the client chain info by index func QueClientChainInfoByIndex() *cobra.Command { cmd := &cobra.Command{ - Use: "QueClientChainInfoByIndex clientChainLzId", + Use: "QueClientChainInfoByIndex clientChainLzID", Short: "Get client chain info by layerZero Id", Long: "Get client chain info by layerZero Id", Args: cobra.ExactArgs(1), @@ -49,13 +49,13 @@ func QueClientChainInfoByIndex() *cobra.Command { if err != nil { return err } - clientChainLzId, err := strconv.ParseUint(args[0], 10, 64) + clientChainLzID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) } queryClient := types.NewQueryClient(clientCtx) req := &types.QueryClientChainInfo{ - ChainIndex: clientChainLzId, + ChainIndex: clientChainLzID, } res, err := queryClient.QueClientChainInfoByIndex(context.Background(), req) if err != nil { @@ -99,7 +99,7 @@ func QueAllClientChainInfo() *cobra.Command { // QueStakingAssetInfo queries staking asset info func QueStakingAssetInfo() *cobra.Command { cmd := &cobra.Command{ - Use: "QueStakingAssetInfo assetAddr clientChainLzId", + Use: "QueStakingAssetInfo assetAddr clientChainLzID", Short: "Get staking asset info", Long: "Get staking asset info", Args: cobra.ExactArgs(2), @@ -109,15 +109,15 @@ func QueStakingAssetInfo() *cobra.Command { return err } - clientChainLzId, err := strconv.ParseUint(args[1], 10, 64) + clientChainLzID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return errorsmod.Wrap(types.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[1])) } - _, assetId := types.GetStakeIDAndAssetIdFromStr(clientChainLzId, "", args[0]) + _, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, "", args[0]) queryClient := types.NewQueryClient(clientCtx) req := &types.QueryStakingAssetInfo{ - AssetId: assetId, + AssetID: assetID, } res, err := queryClient.QueStakingAssetInfo(context.Background(), req) if err != nil { @@ -161,7 +161,7 @@ func QueAllStakingAssetsInfo() *cobra.Command { // QueStakerAssetInfos queries staker asset info func QueStakerAssetInfos() *cobra.Command { cmd := &cobra.Command{ - Use: "QueStakerAssetInfos stakerId", + Use: "QueStakerAssetInfos stakerID", Short: "Get staker asset state", Long: "Get staker asset state", Args: cobra.ExactArgs(1), @@ -173,7 +173,7 @@ func QueStakerAssetInfos() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) req := &types.QueryStakerAssetInfo{ - StakerId: args[0], + StakerID: args[0], } res, err := queryClient.QueStakerAssetInfos(context.Background(), req) if err != nil { @@ -190,7 +190,7 @@ func QueStakerAssetInfos() *cobra.Command { // QueStakerSpecifiedAssetAmount queries staker specified asset info func QueStakerSpecifiedAssetAmount() *cobra.Command { cmd := &cobra.Command{ - Use: "QueStakerSpecifiedAssetAmount clientChainId stakerAddr assetAddr", + Use: "QueStakerSpecifiedAssetAmount clientChainID stakerAddr assetAddr", Short: "Get staker specified asset state", Long: "Get staker specified asset state", Args: cobra.ExactArgs(3), @@ -201,14 +201,14 @@ func QueStakerSpecifiedAssetAmount() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - clientChainLzId, err := strconv.ParseUint(args[0], 10, 64) + clientChainLzID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) } - stakerId, assetId := types.GetStakeIDAndAssetIdFromStr(clientChainLzId, args[1], args[2]) + stakerID, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, args[1], args[2]) req := &types.QuerySpecifiedAssetAmountReq{ - StakerId: stakerId, - AssetId: assetId, + StakerID: stakerID, + AssetID: assetID, } res, err := queryClient.QueStakerSpecifiedAssetAmount(context.Background(), req) if err != nil { @@ -254,7 +254,7 @@ func QueOperatorAssetInfos() *cobra.Command { // QueOperatorSpecifiedAssetAmount queries specified operator asset info func QueOperatorSpecifiedAssetAmount() *cobra.Command { cmd := &cobra.Command{ - Use: "QueOperatorSpecifiedAssetAmount operatorAddr clientChainId assetAddr", + Use: "QueOperatorSpecifiedAssetAmount operatorAddr clientChainID assetAddr", Short: "Get operator specified asset state", Long: "Get operator specified asset state", Args: cobra.ExactArgs(3), @@ -264,15 +264,15 @@ func QueOperatorSpecifiedAssetAmount() *cobra.Command { return err } - clientChainLzId, err := strconv.ParseUint(args[1], 10, 64) + clientChainLzID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) } - _, assetId := types.GetStakeIDAndAssetIdFromStr(clientChainLzId, "", args[2]) + _, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, "", args[2]) queryClient := types.NewQueryClient(clientCtx) req := &types.QueryOperatorSpecifiedAssetAmountReq{ OperatorAddr: args[0], - AssetId: assetId, + AssetID: assetID, } res, err := queryClient.QueOperatorSpecifiedAssetAmount(context.Background(), req) if err != nil { @@ -289,7 +289,7 @@ func QueOperatorSpecifiedAssetAmount() *cobra.Command { // QueStakerExoCoreAddr queries staker ExoCore address func QueStakerExoCoreAddr() *cobra.Command { cmd := &cobra.Command{ - Use: "QueStakerExoCoreAddr stakerId", + Use: "QueStakerExoCoreAddr stakerID", Short: "Get staker ExoCore address", Long: "Get staker ExoCore address", Args: cobra.ExactArgs(1), @@ -301,7 +301,7 @@ func QueStakerExoCoreAddr() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) req := &types.QueryStakerExCoreAddr{ - StakerId: args[0], + StakerID: args[0], } res, err := queryClient.QueStakerExoCoreAddr(context.Background(), req) if err != nil { diff --git a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go b/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go index dde9dda69..ae31b109d 100644 --- a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go +++ b/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go @@ -5,37 +5,37 @@ import ( "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" ) -func (suite *KeeperTestSuite) TestGenesisClientChainAndAssetInfo() { +func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { defaultGensisState := restaking_assets_manage.DefaultGenesisState() // test the client chains getting - clientChains, err := suite.app.StakingAssetsManageKeeper.GetAllClientChainInfo(suite.ctx) + clientChains, err := suite.App.StakingAssetsManageKeeper.GetAllClientChainInfo(suite.Ctx) suite.NoError(err) - suite.ctx.Logger().Info("the clientChains is:", "info", clientChains) + suite.Ctx.Logger().Info("the clientChains is:", "info", clientChains) for _, clientChain := range defaultGensisState.DefaultSupportedClientChains { info, ok := clientChains[clientChain.LayerZeroChainId] suite.True(ok) suite.Equal(info, clientChain) } - chainInfo, err := suite.app.StakingAssetsManageKeeper.GetClientChainInfoByIndex(suite.ctx, 101) + chainInfo, err := suite.App.StakingAssetsManageKeeper.GetClientChainInfoByIndex(suite.Ctx, 101) suite.NoError(err) suite.Equal(clientChains[101], chainInfo) // test the client chain assets getting - assets, err := suite.app.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.ctx) + assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) for _, asset := range defaultGensisState.DefaultSupportedClientChainTokens { - _, assetId := types.GetStakeIDAndAssetIdFromStr(asset.LayerZeroChainId, "", asset.Address) - suite.ctx.Logger().Info("the asset id is:", "assetId", assetId) - info, ok := assets[assetId] + _, assetID := types.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) } usdtAsset := defaultGensisState.DefaultSupportedClientChainTokens[0] - _, assetId := types.GetStakeIDAndAssetIdFromStr(usdtAsset.LayerZeroChainId, "", usdtAsset.Address) - assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) + _, assetID := types.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainId, "", usdtAsset.Address) + assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(usdtAsset, assetInfo.AssetBasicInfo) } diff --git a/x/restaking_assets_manage/keeper/client_chain_asset.go b/x/restaking_assets_manage/keeper/client_chain_asset.go index 19a5bb110..3d687ed81 100644 --- a/x/restaking_assets_manage/keeper/client_chain_asset.go +++ b/x/restaking_assets_manage/keeper/client_chain_asset.go @@ -9,12 +9,12 @@ import ( // UpdateStakingAssetTotalAmount updating the total deposited amount of a specified asset in exoCore chain // The function will be called when stakers deposit and withdraw their assets -func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetId string, changeAmount sdkmath.Int) (err error) { +func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetID string, changeAmount sdkmath.Int) (err error) { if changeAmount.IsNil() { return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) - key := []byte(assetId) + key := []byte(assetID) ifExist := store.Has(key) if !ifExist { return restakingtype.ErrNoClientChainAssetKey @@ -44,24 +44,24 @@ func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *restakingtype.Staking // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) - _, assetId := restakingtype.GetStakeIDAndAssetIdFromStr(info.AssetBasicInfo.LayerZeroChainId, "", info.AssetBasicInfo.Address) - store.Set([]byte(assetId), bz) + _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(info.AssetBasicInfo.LayerZeroChainId, "", info.AssetBasicInfo.Address) + store.Set([]byte(assetID), bz) return nil } -func (k Keeper) IsStakingAsset(ctx sdk.Context, assetId string) bool { +func (k Keeper) IsStakingAsset(ctx sdk.Context, assetID string) bool { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) - return store.Has([]byte(assetId)) + return store.Has([]byte(assetID)) } -func (k Keeper) GetStakingAssetInfo(ctx sdk.Context, assetId string) (info *restakingtype.StakingAssetInfo, err error) { +func (k Keeper) GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *restakingtype.StakingAssetInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) - ifExist := store.Has([]byte(assetId)) + ifExist := store.Has([]byte(assetID)) if !ifExist { return nil, restakingtype.ErrNoClientChainAssetKey } - value := store.Get([]byte(assetId)) + value := store.Get([]byte(assetID)) ret := restakingtype.StakingAssetInfo{} k.cdc.MustUnmarshal(value, &ret) @@ -77,8 +77,8 @@ func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]* for ; iterator.Valid(); iterator.Next() { var assetInfo restakingtype.StakingAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) - _, assetId := restakingtype.GetStakeIDAndAssetIdFromStr(assetInfo.AssetBasicInfo.LayerZeroChainId, "", assetInfo.AssetBasicInfo.Address) - ret[assetId] = &assetInfo + _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainId, "", assetInfo.AssetBasicInfo.Address) + ret[assetID] = &assetInfo } return ret, nil } diff --git a/x/restaking_assets_manage/keeper/exocore_addr.go b/x/restaking_assets_manage/keeper/exocore_addr.go index abd5b139e..b99feac39 100644 --- a/x/restaking_assets_manage/keeper/exocore_addr.go +++ b/x/restaking_assets_manage/keeper/exocore_addr.go @@ -5,7 +5,7 @@ import ( ) // GetStakerExoCoreAddr outdated, will be deprecated. -func (k Keeper) GetStakerExoCoreAddr(ctx sdk.Context, stakerId string) (string, error) { +func (k Keeper) GetStakerExoCoreAddr(ctx sdk.Context, stakerID string) (string, error) { // TODO implement me panic("implement me") } diff --git a/x/restaking_assets_manage/keeper/grpc_query.go b/x/restaking_assets_manage/keeper/grpc_query.go index 193d6c85d..ff4071c25 100644 --- a/x/restaking_assets_manage/keeper/grpc_query.go +++ b/x/restaking_assets_manage/keeper/grpc_query.go @@ -9,14 +9,14 @@ import ( "google.golang.org/grpc/status" ) -// QueClientChainInfoByIndex query client chain info by clientChainLzId +// QueClientChainInfoByIndex query client chain info by clientChainLzID func (k Keeper) QueClientChainInfoByIndex(ctx context.Context, info *restakingtype.QueryClientChainInfo) (*restakingtype.ClientChainInfo, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetClientChainInfoByIndex(c, info.ChainIndex) } // QueAllClientChainInfo query all client chain info that have been registered in exoCore -// the key of returned map is clientChainLzId, the value is the client chain info. +// the key of returned map is clientChainLzID, the value is the client chain info. func (k Keeper) QueAllClientChainInfo(ctx context.Context, info *restakingtype.QueryAllClientChainInfo) (*restakingtype.QueryAllClientChainInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) allInfo, err := k.GetAllClientChainInfo(c) @@ -26,10 +26,10 @@ func (k Keeper) QueAllClientChainInfo(ctx context.Context, info *restakingtype.Q return &restakingtype.QueryAllClientChainInfoResponse{AllClientChainInfos: allInfo}, nil } -// QueStakingAssetInfo query the specified client chain asset info by inputting assetId +// QueStakingAssetInfo query the specified client chain asset info by inputting assetID func (k Keeper) QueStakingAssetInfo(ctx context.Context, info *restakingtype.QueryStakingAssetInfo) (*restakingtype.StakingAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) - return k.GetStakingAssetInfo(c, info.AssetId) + return k.GetStakingAssetInfo(c, info.AssetID) } // QueAllStakingAssetsInfo query the info about all client chain assets that have been registered @@ -42,20 +42,20 @@ func (k Keeper) QueAllStakingAssetsInfo(ctx context.Context, info *restakingtype return &restakingtype.QueryAllStakingAssetsInfoResponse{AllStakingAssetsInfo: allInfo}, nil } -// QueStakerAssetInfos query th state of all assets for a staker specified by stakerId +// QueStakerAssetInfos query th state of all assets for a staker specified by stakerID func (k Keeper) QueStakerAssetInfos(ctx context.Context, info *restakingtype.QueryStakerAssetInfo) (*restakingtype.QueryAssetInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) - assetInfos, err := k.GetStakerAssetInfos(c, info.StakerId) + assetInfos, err := k.GetStakerAssetInfos(c, info.StakerID) if err != nil { return nil, err } return &restakingtype.QueryAssetInfoResponse{AssetInfos: assetInfos}, nil } -// QueStakerSpecifiedAssetAmount query the specified asset state of a staker, using stakerId and assetId as query parameters +// QueStakerSpecifiedAssetAmount query the specified asset state of a staker, using stakerID and assetID as query parameters func (k Keeper) QueStakerSpecifiedAssetAmount(ctx context.Context, req *restakingtype.QuerySpecifiedAssetAmountReq) (*restakingtype.StakerSingleAssetOrChangeInfo, error) { c := sdk.UnwrapSDKContext(ctx) - return k.GetStakerSpecifiedAssetInfo(c, req.StakerId, req.AssetId) + return k.GetStakerSpecifiedAssetInfo(c, req.StakerID, req.AssetID) } // QueOperatorAssetInfos query th state of all assets for an operator specified by operator address @@ -72,20 +72,20 @@ func (k Keeper) QueOperatorAssetInfos(ctx context.Context, infos *restakingtype. return &restakingtype.QueryOperatorAssetInfosResponse{AssetInfos: assetInfos}, nil } -// QueOperatorSpecifiedAssetAmount query the specified asset state of an operator, using operator address and assetId as query parameters +// QueOperatorSpecifiedAssetAmount query the specified asset state of an operator, using operator address and assetID as query parameters func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *restakingtype.QueryOperatorSpecifiedAssetAmountReq) (*restakingtype.OperatorSingleAssetOrChangeInfo, error) { c := sdk.UnwrapSDKContext(ctx) addr, err := sdk.AccAddressFromBech32(req.OperatorAddr) if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - return k.GetOperatorSpecifiedAssetInfo(c, addr, req.AssetId) + return k.GetOperatorSpecifiedAssetInfo(c, addr, req.AssetID) } // QueStakerExoCoreAddr outdated,will be deprecated func (k Keeper) QueStakerExoCoreAddr(ctx context.Context, req *restakingtype.QueryStakerExCoreAddr) (*restakingtype.QueryStakerExCoreAddrResponse, error) { c := sdk.UnwrapSDKContext(ctx) - exoCoreAddr, err := k.GetStakerExoCoreAddr(c, req.StakerId) + exoCoreAddr, err := k.GetStakerExoCoreAddr(c, req.StakerID) if err != nil { return nil, err } diff --git a/x/restaking_assets_manage/keeper/keeper.go b/x/restaking_assets_manage/keeper/keeper.go index 1918c4b27..d08886a2b 100644 --- a/x/restaking_assets_manage/keeper/keeper.go +++ b/x/restaking_assets_manage/keeper/keeper.go @@ -43,23 +43,23 @@ type IRestakingAssetsManage interface { GetAllClientChainInfo(ctx sdk.Context) (infos map[uint64]*restakingtype.ClientChainInfo, err error) SetStakingAssetInfo(ctx sdk.Context, info *restakingtype.StakingAssetInfo) (err error) - GetStakingAssetInfo(ctx sdk.Context, assetId string) (info *restakingtype.StakingAssetInfo, err error) + GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *restakingtype.StakingAssetInfo, err error) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*restakingtype.StakingAssetInfo, err error) - GetStakerAssetInfos(ctx sdk.Context, stakerId string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) - GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerId string, assetId string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) - UpdateStakerAssetState(ctx sdk.Context, stakerId string, assetId string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) + GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) + GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) + UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) (assetsInfo map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) - GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetId string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) - UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetId string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) + GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) + UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) // SetStakerExoCoreAddr handle the SetStakerExoCoreAddr txs from msg service SetStakerExoCoreAddr(ctx context.Context, addr *restakingtype.MsgSetExoCoreAddr) (*restakingtype.MsgSetExoCoreAddrResponse, error) - GetStakerExoCoreAddr(ctx sdk.Context, stakerId string) (string, error) + GetStakerExoCoreAddr(ctx sdk.Context, stakerID string) (string, error) // GetOperatorAssetOptedInMiddleWare :the following three interfaces should be implemented in operator opt-in module - GetOperatorAssetOptedInMiddleWare(operatorAddr sdk.Address, assetId string) (middleWares []sdk.Address, err error) + GetOperatorAssetOptedInMiddleWare(operatorAddr sdk.Address, assetID string) (middleWares []sdk.Address, err error) GetAllOperatorAssetOptedInMiddleWare(operatorAddr sdk.Address) (optedInInfos map[string][]sdk.Address, err error) SetOperatorAssetOptedInMiddleWare(operatorAddr sdk.Address, setInfo map[string]sdk.Address) (middleWares []sdk.Address, err error) } diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index 5e72ceb84..d46fc5ca6 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -25,15 +25,15 @@ func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, if err != nil { return nil, err } - assetId := keyList[1] - ret[assetId] = &stateInfo + assetID := keyList[1] + ret[assetID] = &stateInfo } return ret, nil } -func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetId string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) { +func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) + key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetID) ifExist := store.Has(key) if !ifExist { return nil, restakingtype.ErrNoOperatorAssetKey @@ -50,10 +50,10 @@ func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk. // The input `changeAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is delegation or undelegation related to the operator. In the future,it will also be called when the operator deposit their own assets. -func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetId string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) { +func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) { //get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetId) + key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetID) assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: math.NewInt(0), OperatorOwnAmountOrWantChangeValue: math.NewInt(0), @@ -94,7 +94,7 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre return nil } -func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetId string, state *restakingtype.OperatorSingleAssetOrChangeInfo) error) error { +func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *restakingtype.OperatorSingleAssetOrChangeInfo) error) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() diff --git a/x/restaking_assets_manage/keeper/setup_test.go b/x/restaking_assets_manage/keeper/setup_test.go index 13bd11a79..21d80f32f 100644 --- a/x/restaking_assets_manage/keeper/setup_test.go +++ b/x/restaking_assets_manage/keeper/setup_test.go @@ -1,32 +1,23 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" - "github.com/ExocoreNetwork/exocore/app" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" ) -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.ExocoreApp - address common.Address - signer keyring.Signer +type StakingAssetsTestSuite struct { + testutil.BaseTestSuite } -var s *KeeperTestSuite +var s *StakingAssetsTestSuite func TestKeeperTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(StakingAssetsTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -34,6 +25,6 @@ func TestKeeperTestSuite(t *testing.T) { RunSpecs(t, "Keeper Suite") } -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (suite *StakingAssetsTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/restaking_assets_manage/keeper/staker_asset.go b/x/restaking_assets_manage/keeper/staker_asset.go index 60f3fc1f0..9991e5601 100644 --- a/x/restaking_assets_manage/keeper/staker_asset.go +++ b/x/restaking_assets_manage/keeper/staker_asset.go @@ -10,9 +10,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerId string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) { +func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - iterator := sdk.KVStorePrefixIterator(store, []byte(stakerId)) + iterator := sdk.KVStorePrefixIterator(store, []byte(stakerID)) defer iterator.Close() ret := make(map[string]*restakingtype.StakerSingleAssetOrChangeInfo, 0) @@ -23,15 +23,15 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerId string) (assetsInf if err != nil { return nil, err } - assetId := keyList[1] - ret[assetId] = &stateInfo + assetID := keyList[1] + ret[assetID] = &stateInfo } return ret, nil } -func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerId string, assetId string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) { +func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetJoinedStoreKey(stakerId, assetId) + key := restakingtype.GetJoinedStoreKey(stakerID, assetID) ifExist := store.Has(key) if !ifExist { return nil, errorsmod.Wrap(restakingtype.ErrNoStakerAssetKey, fmt.Sprintf("the key is:%s", key)) @@ -47,10 +47,10 @@ func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerId string, as // UpdateStakerAssetState It's used to update the staker asset state // The input `changeAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is deposit or withdraw related to the specified staker. -func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerId string, assetId string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) { +func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) { //get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetJoinedStoreKey(stakerId, assetId) + key := restakingtype.GetJoinedStoreKey(stakerID, assetID) assetState := restakingtype.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: math.NewInt(0), CanWithdrawAmountOrWantChangeValue: math.NewInt(0), diff --git a/x/restaking_assets_manage/keeper/staker_asset_test.go b/x/restaking_assets_manage/keeper/staker_asset_test.go index 664433da5..c5eed7479 100644 --- a/x/restaking_assets_manage/keeper/staker_asset_test.go +++ b/x/restaking_assets_manage/keeper/staker_asset_test.go @@ -8,20 +8,20 @@ import ( restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" ) -func (suite *KeeperTestSuite) TestUpdateStakerAssetsState() { - stakerId := fmt.Sprintf("%s_%s", suite.address, "0") - ethUniAssetId := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") +func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { + stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") + ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") ethUniInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: math.NewInt(1000), CanWithdrawAmountOrWantChangeValue: math.NewInt(1000), } // test the initial storage of statker assets state - err := suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) // test that the retrieved value is correct - getInfo, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, ethUniAssetId) + getInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue.Equal(getInfo.TotalDepositAmountOrWantChangeValue)) suite.Require().True(ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue.Equal(getInfo.CanWithdrawAmountOrWantChangeValue)) @@ -29,16 +29,16 @@ func (suite *KeeperTestSuite) TestUpdateStakerAssetsState() { //test ErrInputUpdateStateIsZero /* ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(0) ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(0) - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, restakingtype.ErrInputUpdateStateIsZero)*/ // test valid increase of staker asset state ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(500) ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(500) - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) - getInfo, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, ethUniAssetId) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1500))) suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1500))) @@ -46,9 +46,9 @@ func (suite *KeeperTestSuite) TestUpdateStakerAssetsState() { // test valid decrease of staker asset state ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(-500) ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(-500) - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) - getInfo, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, ethUniAssetId) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) @@ -56,40 +56,40 @@ func (suite *KeeperTestSuite) TestUpdateStakerAssetsState() { // test the decreased amount is bigger than original state ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(-2000) ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(-500) - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, restakingtype.ErrSubAmountIsMoreThanOrigin) - getInfo, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, ethUniAssetId) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(-500) ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(-2000) - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, restakingtype.ErrSubAmountIsMoreThanOrigin) - getInfo, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, ethUniAssetId) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) // test the storage of multiple assets state - ethUsdtAssetId := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") + ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUsdtInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: math.NewInt(2000), CanWithdrawAmountOrWantChangeValue: math.NewInt(2000), } - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUsdtAssetId, ethUsdtInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) suite.Require().NoError(err) - getInfo, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, ethUsdtAssetId) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUsdtAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(2000))) suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(2000))) } -func (suite *KeeperTestSuite) TestGetStakerAssetInfos() { - stakerId := fmt.Sprintf("%s_%s", suite.address, "0") - ethUniAssetId := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") - ethUsdtAssetId := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") +func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { + stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") + ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") + ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUniInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: math.NewInt(1000), CanWithdrawAmountOrWantChangeValue: math.NewInt(1000), @@ -98,20 +98,20 @@ func (suite *KeeperTestSuite) TestGetStakerAssetInfos() { TotalDepositAmountOrWantChangeValue: math.NewInt(2000), CanWithdrawAmountOrWantChangeValue: math.NewInt(2000), } - err := suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUniAssetId, ethUniInitialChangeValue) + err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) - err = suite.app.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.ctx, stakerId, ethUsdtAssetId, ethUsdtInitialChangeValue) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) suite.Require().NoError(err) // test get all assets state of staker - assetsInfo, err := suite.app.StakingAssetsManageKeeper.GetStakerAssetInfos(suite.ctx, stakerId) + assetsInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) suite.Require().NoError(err) - uniState, isExist := assetsInfo[ethUniAssetId] + uniState, isExist := assetsInfo[ethUniAssetID] suite.Require().True(isExist) suite.Require().True(uniState.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) suite.Require().True(uniState.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) - usdtState, isExist := assetsInfo[ethUsdtAssetId] + usdtState, isExist := assetsInfo[ethUsdtAssetID] suite.Require().True(isExist) suite.Require().True(usdtState.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(2000))) suite.Require().True(usdtState.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(2000))) diff --git a/x/restaking_assets_manage/keeper/utils_test.go b/x/restaking_assets_manage/keeper/utils_test.go deleted file mode 100644 index 8116e8070..000000000 --- a/x/restaking_assets_manage/keeper/utils_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package keeper_test - -import ( - "time" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/stretchr/testify/require" -) - -// Test helpers -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) - - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) - - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, feemarkettypes.DefaultGenesisState(), chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) -} diff --git a/x/restaking_assets_manage/types/errors.go b/x/restaking_assets_manage/types/errors.go index 9fabf86d2..562b0232b 100644 --- a/x/restaking_assets_manage/types/errors.go +++ b/x/restaking_assets_manage/types/errors.go @@ -7,13 +7,13 @@ import ( // errors var ( ErrNoClientChainKey = errorsmod.Register(ModuleName, 0, "there is no stored key for the input chain index") - ErrNoClientChainAssetKey = errorsmod.Register(ModuleName, 1, "there is no stored key for the input assetId") + ErrNoClientChainAssetKey = errorsmod.Register(ModuleName, 1, "there is no stored key for the input assetID") - ErrNoStakerAssetKey = errorsmod.Register(ModuleName, 2, "there is no stored key for the input staker and assetId") + ErrNoStakerAssetKey = errorsmod.Register(ModuleName, 2, "there is no stored key for the input staker and assetID") ErrSubAmountIsMoreThanOrigin = errorsmod.Register(ModuleName, 3, "the amount that want to decrease is more than the original state amount") - ErrNoOperatorAssetKey = errorsmod.Register(ModuleName, 4, "there is no stored key for the input operator address and assetId") + ErrNoOperatorAssetKey = errorsmod.Register(ModuleName, 4, "there is no stored key for the input operator address and assetID") ErrParseAssetsStateKey = errorsmod.Register(ModuleName, 5, "assets state key can't be parsed") diff --git a/x/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go index dc478dcbe..70477bee8 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/restaking_assets_manage/types/general.go @@ -18,10 +18,10 @@ const ( GeneralAssetsAddrLength = 32 GeneralClientChainAddrLength = 32 - ClientChainLzIdIndexInTopics = 0 + ClientChainLzIDIndexInTopics = 0 LzNonceIndexInTopics = 2 - ExoCoreOperatorAddrLength = 44 + ExoCoreOperatorAddrLength = 42 ) type GeneralAssetsAddr [32]byte @@ -41,28 +41,28 @@ const ( Slash ) -// GetStakeIDAndAssetId stakerId = stakerAddress+'_'+clientChainLzId,assetId = assetAddress+'_'+clientChainLzId -func GetStakeIDAndAssetId(clientChainLzId uint64, stakerAddress []byte, assetsAddress []byte) (stakeId string, assetId string) { - clientChainLzIdStr := hexutil.EncodeUint64(clientChainLzId) +// GetStakeIDAndAssetID stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID +func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAddress []byte) (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}, "_") } if assetsAddress != nil { - assetId = strings.Join([]string{hexutil.Encode(assetsAddress), clientChainLzIdStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(assetsAddress), clientChainLzIDStr}, "_") } return } -// GetStakeIDAndAssetIdFromStr stakerId = stakerAddress+'_'+clientChainLzId,assetId = assetAddress+'_'+clientChainLzId -func GetStakeIDAndAssetIdFromStr(clientChainLzId uint64, stakerAddress string, assetsAddress string) (stakeId string, assetId string) { - clientChainLzIdStr := hexutil.EncodeUint64(clientChainLzId) +// GetStakeIDAndAssetIDFromStr stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID +func GetStakeIDAndAssetIDFromStr(clientChainLzID uint64, stakerAddress string, assetsAddress string) (stakeId string, assetID string) { + clientChainLzIDStr := hexutil.EncodeUint64(clientChainLzID) if stakerAddress != "" { - stakeId = strings.Join([]string{strings.ToLower(stakerAddress), clientChainLzIdStr}, "_") + stakeId = strings.Join([]string{strings.ToLower(stakerAddress), clientChainLzIDStr}, "_") } if assetsAddress != "" { - assetId = strings.Join([]string{strings.ToLower(assetsAddress), clientChainLzIdStr}, "_") + assetID = strings.Join([]string{strings.ToLower(assetsAddress), clientChainLzIDStr}, "_") } return } diff --git a/x/restaking_assets_manage/types/keys.go b/x/restaking_assets_manage/types/keys.go index 0c85fedc5..564ec3d8f 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/restaking_assets_manage/types/keys.go @@ -89,28 +89,28 @@ var ( KeyPrefixAppChainInfo = []byte{prefixAppChainInfo} - // KeyPrefixReStakingAssetInfo AssetId = AssetAddr+'_'+chainIndex - // KeyPrefixReStakingAssetInfo key->value: AssetId->ReStakingAssetInfo + // KeyPrefixReStakingAssetInfo AssetID = AssetAddr+'_'+chainIndex + // KeyPrefixReStakingAssetInfo key->value: AssetID->ReStakingAssetInfo KeyPrefixReStakingAssetInfo = []byte{prefixRestakingAssetInfo} - // KeyPrefixReStakerAssetInfos reStakerId = clientChainAddr+'_'+ExoCoreChainIndex - // KeyPrefixReStakerAssetInfos key->value: reStakerId+'_'+AssetId->ReStakerSingleAssetInfo - // or reStakerId->mapping(AssetId->ReStakerSingleAssetInfo)? + // KeyPrefixReStakerAssetInfos reStakerID = clientChainAddr+'_'+ExoCoreChainIndex + // KeyPrefixReStakerAssetInfos key->value: reStakerID+'_'+AssetID->ReStakerSingleAssetInfo + // or reStakerID->mapping(AssetID->ReStakerSingleAssetInfo)? KeyPrefixReStakerAssetInfos = []byte{prefixRestakerAssetInfo} - // KeyPrefixOperatorAssetInfos key->value: operatorAddr+'_'+AssetId->OperatorSingleAssetInfo - // or operatorAddr->mapping(AssetId->OperatorSingleAssetInfo) ? + // KeyPrefixOperatorAssetInfos key->value: operatorAddr+'_'+AssetID->OperatorSingleAssetInfo + // or operatorAddr->mapping(AssetID->OperatorSingleAssetInfo) ? KeyPrefixOperatorAssetInfos = []byte{prefixOperatorAssetInfo} // KeyPrefixOperatorOptedInMiddleWareAssetInfos key->value: - // operatorAddr+'_'+AssetId->mapping(middleWareAddr->struct{}) - // or operatorAddr->mapping(AssetId->mapping(middleWareAddr->struct{})) ? + // 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 reStakerID = clientChainAddr+'_'+ExoCoreChainIndex + // KeyPrefixReStakerExoCoreAddr key-value: reStakerID->exoCoreAddr KeyPrefixReStakerExoCoreAddr = []byte{prefixRestakerExocoreAddr} // KeyPrefixReStakerExoCoreAddrReverse k->v: exocoreAddress -> // map[clientChainIndex]clientChainAddress diff --git a/x/restaking_assets_manage/types/query.pb.go b/x/restaking_assets_manage/types/query.pb.go index b4947c222..b95e30b2a 100644 --- a/x/restaking_assets_manage/types/query.pb.go +++ b/x/restaking_assets_manage/types/query.pb.go @@ -156,7 +156,7 @@ func (m *QueryAllClientChainInfoResponse) GetAllClientChainInfos() map[uint64]*C } type QueryStakingAssetInfo struct { - AssetId string `protobuf:"bytes,1,opt,name=assetId,proto3" json:"assetId,omitempty"` + AssetID string `protobuf:"bytes,1,opt,name=assetID,proto3" json:"assetID,omitempty"` } func (m *QueryStakingAssetInfo) Reset() { *m = QueryStakingAssetInfo{} } @@ -192,9 +192,9 @@ func (m *QueryStakingAssetInfo) XXX_DiscardUnknown() { var xxx_messageInfo_QueryStakingAssetInfo proto.InternalMessageInfo -func (m *QueryStakingAssetInfo) GetAssetId() string { +func (m *QueryStakingAssetInfo) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } @@ -280,7 +280,7 @@ func (m *QueryAllStakingAssetsInfoResponse) GetAllStakingAssetsInfo() map[string } type QueryStakerAssetInfo struct { - StakerId string `protobuf:"bytes,1,opt,name=stakerId,proto3" json:"stakerId,omitempty"` + StakerID string `protobuf:"bytes,1,opt,name=stakerID,proto3" json:"stakerID,omitempty"` } func (m *QueryStakerAssetInfo) Reset() { *m = QueryStakerAssetInfo{} } @@ -316,9 +316,9 @@ func (m *QueryStakerAssetInfo) XXX_DiscardUnknown() { var xxx_messageInfo_QueryStakerAssetInfo proto.InternalMessageInfo -func (m *QueryStakerAssetInfo) GetStakerId() string { +func (m *QueryStakerAssetInfo) GetStakerID() string { if m != nil { - return m.StakerId + return m.StakerID } return "" } @@ -368,8 +368,8 @@ func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerSingleAssetOr } type QuerySpecifiedAssetAmountReq struct { - StakerId string `protobuf:"bytes,1,opt,name=stakerId,proto3" json:"stakerId,omitempty"` - AssetId string `protobuf:"bytes,2,opt,name=assetId,proto3" json:"assetId,omitempty"` + StakerID string `protobuf:"bytes,1,opt,name=stakerID,proto3" json:"stakerID,omitempty"` + AssetID string `protobuf:"bytes,2,opt,name=assetID,proto3" json:"assetID,omitempty"` } func (m *QuerySpecifiedAssetAmountReq) Reset() { *m = QuerySpecifiedAssetAmountReq{} } @@ -405,16 +405,16 @@ func (m *QuerySpecifiedAssetAmountReq) XXX_DiscardUnknown() { var xxx_messageInfo_QuerySpecifiedAssetAmountReq proto.InternalMessageInfo -func (m *QuerySpecifiedAssetAmountReq) GetStakerId() string { +func (m *QuerySpecifiedAssetAmountReq) GetStakerID() string { if m != nil { - return m.StakerId + return m.StakerID } return "" } -func (m *QuerySpecifiedAssetAmountReq) GetAssetId() string { +func (m *QuerySpecifiedAssetAmountReq) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } @@ -509,7 +509,7 @@ func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorSi type QueryOperatorSpecifiedAssetAmountReq struct { OperatorAddr string `protobuf:"bytes,1,opt,name=operatorAddr,proto3" json:"operatorAddr,omitempty"` - AssetId string `protobuf:"bytes,2,opt,name=assetId,proto3" json:"assetId,omitempty"` + AssetID string `protobuf:"bytes,2,opt,name=assetID,proto3" json:"assetID,omitempty"` } func (m *QueryOperatorSpecifiedAssetAmountReq) Reset() { *m = QueryOperatorSpecifiedAssetAmountReq{} } @@ -552,15 +552,15 @@ func (m *QueryOperatorSpecifiedAssetAmountReq) GetOperatorAddr() string { return "" } -func (m *QueryOperatorSpecifiedAssetAmountReq) GetAssetId() string { +func (m *QueryOperatorSpecifiedAssetAmountReq) GetAssetID() string { if m != nil { - return m.AssetId + return m.AssetID } return "" } type QueryStakerExCoreAddr struct { - StakerId string `protobuf:"bytes,1,opt,name=StakerId,proto3" json:"StakerId,omitempty"` + StakerID string `protobuf:"bytes,1,opt,name=StakerID,proto3" json:"StakerID,omitempty"` } func (m *QueryStakerExCoreAddr) Reset() { *m = QueryStakerExCoreAddr{} } @@ -596,9 +596,9 @@ func (m *QueryStakerExCoreAddr) XXX_DiscardUnknown() { var xxx_messageInfo_QueryStakerExCoreAddr proto.InternalMessageInfo -func (m *QueryStakerExCoreAddr) GetStakerId() string { +func (m *QueryStakerExCoreAddr) GetStakerID() string { if m != nil { - return m.StakerId + return m.StakerID } return "" } @@ -673,68 +673,68 @@ func init() { } var fileDescriptor_6d13900d4f268106 = []byte{ - // 974 bytes of a gzipped FileDescriptorProto + // 975 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4d, 0x6f, 0xe3, 0x44, 0x18, 0xee, 0x64, 0x59, 0xd8, 0x9d, 0x45, 0x62, 0x35, 0x1b, 0x20, 0xf1, 0x2e, 0xa1, 0x58, 0x1c, - 0x2a, 0x10, 0xb6, 0x9a, 0x22, 0x48, 0x36, 0x54, 0x90, 0x9a, 0xa0, 0x6d, 0x0f, 0x5b, 0x9a, 0x20, - 0x55, 0x05, 0xa4, 0xc8, 0x4d, 0xa6, 0xae, 0x69, 0xe2, 0x49, 0x3d, 0x4e, 0x49, 0x54, 0x15, 0x55, - 0xbd, 0xc0, 0x09, 0x21, 0xf5, 0x06, 0x3f, 0x02, 0x0e, 0x1c, 0xf8, 0x09, 0x1c, 0x38, 0x14, 0x90, - 0x10, 0x47, 0x68, 0x11, 0x88, 0x3b, 0x3f, 0x00, 0x65, 0xc6, 0x5f, 0x71, 0xec, 0x74, 0xf2, 0x71, - 0xcb, 0xcc, 0xbc, 0x5f, 0xcf, 0xfb, 0x8c, 0xdf, 0x67, 0x02, 0x15, 0xdc, 0x23, 0x0d, 0x62, 0x63, - 0xd5, 0xc6, 0xd4, 0xd1, 0x0f, 0x4c, 0xcb, 0xa8, 0xeb, 0x94, 0x62, 0x87, 0xd6, 0xdb, 0xba, 0xa5, - 0x1b, 0x58, 0x3d, 0x5a, 0x56, 0x0f, 0xbb, 0xd8, 0xee, 0x2b, 0x1d, 0x9b, 0x38, 0x04, 0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0xdf, 0xc8, 0x44, 0x5f, 0xeb, 0x33, 0x69, 0x44, 0x05, 0xe1, 0xdb, 0x11, 0x09, 0x20, + 0x4d, 0xa3, 0x23, 0xf2, 0xc6, 0x97, 0xff, 0x7e, 0xff, 0x1a, 0x38, 0xfd, 0xed, 0xef, 0xb3, 0xd4, + 0xbb, 0x68, 0x55, 0x15, 0x10, 0xff, 0xe4, 0xd2, 0xff, 0x02, 0xac, 0xe7, 0xa3, 0x4a, 0x88, 0x4a, + 0x33, 0x48, 0xb2, 0xa4, 0xcd, 0x41, 0xcf, 0xe5, 0xf7, 0x03, 0x9c, 0x25, 0x54, 0x14, 0xc4, 0x19, + 0x83, 0xe4, 0x67, 0x00, 0xef, 0x6c, 0x76, 0xf1, 0x88, 0xd6, 0x16, 0x85, 0x8b, 0x8c, 0xba, 0x4a, + 0x53, 0xa9, 0x8e, 0xfc, 0x20, 0x00, 0x54, 0x44, 0x6f, 0x0b, 0x02, 0x1a, 0x29, 0xfb, 0x3f, 0xc0, + 0xa6, 0x63, 0x9c, 0x66, 0xa2, 0xd5, 0x99, 0x24, 0x5c, 0xaa, 0xcc, 0xe5, 0x05, 0x20, 0x3f, 0x0c, + 0x70, 0xae, 0xa2, 0x92, 0x38, 0x71, 0xa3, 0x78, 0x7e, 0x09, 0xa8, 0xc3, 0x61, 0x15, 0x28, 0x4c, + 0x44, 0x5d, 0xc8, 0x55, 0xba, 0x3f, 0xbd, 0x16, 0x4f, 0xcf, 0xdf, 0x50, 0xed, 0xff, 0x03, 0x36, + 0xb1, 0x5c, 0x89, 0x8d, 0x19, 0xb1, 0xe8, 0x3d, 0x71, 0x74, 0xf1, 0x13, 0x5a, 0x9a, 0x5d, 0xe4, + 0xe5, 0x47, 0x01, 0x58, 0x0d, 0x95, 0x27, 0x02, 0x1b, 0x0b, 0xca, 0x9d, 0x34, 0x31, 0x92, 0x5e, + 0x9a, 0x41, 0x5c, 0x27, 0x98, 0x34, 0xc9, 0xca, 0x3c, 0xdd, 0xa4, 0x89, 0x41, 0x72, 0xc2, 0x9f, + 0x17, 0xe3, 0xf4, 0x13, 0x3d, 0x9c, 0xb8, 0xe0, 0x24, 0x92, 0xe7, 0x21, 0xff, 0x73, 0xa7, 0xf9, + 0x1f, 0xc0, 0xde, 0xd3, 0x9e, 0x1a, 0x13, 0x5f, 0xc3, 0x8b, 0x13, 0x7e, 0xb2, 0x81, 0x0e, 0x8b, + 0xdd, 0xe6, 0xb1, 0x8f, 0x00, 0xf9, 0x83, 0x00, 0x66, 0x05, 0x69, 0x13, 0xc1, 0x0c, 0x81, 0x50, + 0x8f, 0xbc, 0x67, 0xc7, 0xf1, 0xda, 0xc7, 0x3f, 0x5d, 0xe4, 0xc0, 0xf9, 0x45, 0x0e, 0xfc, 0x79, + 0x91, 0x03, 0x5f, 0x5f, 0xe6, 0x16, 0xce, 0x2f, 0x73, 0x0b, 0x7f, 0x5c, 0xe6, 0x16, 0x3e, 0x2a, + 0x1b, 0xa6, 0xb3, 0xd7, 0xdd, 0x51, 0x1a, 0xa4, 0xad, 0x56, 0x78, 0xa2, 0x47, 0xd8, 0xf9, 0x8c, + 0xd8, 0xfb, 0x7e, 0xde, 0x5e, 0x62, 0x66, 0xa7, 0xdf, 0xc1, 0x74, 0xe7, 0x69, 0xf6, 0x5f, 0x7d, + 0xe5, 0x49, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x2b, 0xcf, 0xb5, 0x9a, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1225,10 +1225,10 @@ func (m *QueryStakingAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = 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))) + 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] = 0xa } @@ -1327,10 +1327,10 @@ func (m *QueryStakerAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.StakerId) > 0 { - i -= len(m.StakerId) - copy(dAtA[i:], m.StakerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerId))) + 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 } @@ -1406,17 +1406,17 @@ func (m *QuerySpecifiedAssetAmountReq) MarshalToSizedBuffer(dAtA []byte) (int, e _ = 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))) + 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))) + 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 } @@ -1522,10 +1522,10 @@ func (m *QueryOperatorSpecifiedAssetAmountReq) MarshalToSizedBuffer(dAtA []byte) _ = 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))) + 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 } @@ -1559,10 +1559,10 @@ func (m *QueryStakerExCoreAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.StakerId) > 0 { - i -= len(m.StakerId) - copy(dAtA[i:], m.StakerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerId))) + 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 } @@ -1659,7 +1659,7 @@ func (m *QueryStakingAssetInfo) Size() (n int) { } var l int _ = l - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1703,7 +1703,7 @@ func (m *QueryStakerAssetInfo) Size() (n int) { } var l int _ = l - l = len(m.StakerId) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1738,11 +1738,11 @@ func (m *QuerySpecifiedAssetAmountReq) Size() (n int) { } var l int _ = l - l = len(m.StakerId) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1794,7 +1794,7 @@ func (m *QueryOperatorSpecifiedAssetAmountReq) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.AssetId) + l = len(m.AssetID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1807,7 +1807,7 @@ func (m *QueryStakerExCoreAddr) Size() (n int) { } var l int _ = l - l = len(m.StakerId) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -2148,7 +2148,7 @@ func (m *QueryStakingAssetInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2176,7 +2176,7 @@ func (m *QueryStakingAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2459,7 +2459,7 @@ func (m *QueryStakerAssetInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2487,7 +2487,7 @@ func (m *QueryStakerAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakerId = string(dAtA[iNdEx:postIndex]) + m.StakerID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2720,7 +2720,7 @@ func (m *QuerySpecifiedAssetAmountReq) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2748,11 +2748,11 @@ func (m *QuerySpecifiedAssetAmountReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakerId = string(dAtA[iNdEx:postIndex]) + m.StakerID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2780,7 +2780,7 @@ func (m *QuerySpecifiedAssetAmountReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3127,7 +3127,7 @@ func (m *QueryOperatorSpecifiedAssetAmountReq) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3155,7 +3155,7 @@ func (m *QueryOperatorSpecifiedAssetAmountReq) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetId = string(dAtA[iNdEx:postIndex]) + m.AssetID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3209,7 +3209,7 @@ func (m *QueryStakerExCoreAddr) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3237,7 +3237,7 @@ func (m *QueryStakerExCoreAddr) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakerId = string(dAtA[iNdEx:postIndex]) + m.StakerID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/restaking_assets_manage/types/query.pb.gw.go b/x/restaking_assets_manage/types/query.pb.gw.go index 1aa9d1b60..0dbf2efec 100644 --- a/x/restaking_assets_manage/types/query.pb.gw.go +++ b/x/restaking_assets_manage/types/query.pb.gw.go @@ -296,15 +296,15 @@ func request_Query_QueStakerExoCoreAddr_0(ctx context.Context, marshaler runtime _ = err ) - val, ok = pathParams["StakerId"] + val, ok = pathParams["StakerID"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "StakerId") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "StakerID") } - protoReq.StakerId, err = runtime.String(val) + protoReq.StakerID, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "StakerId", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "StakerID", err) } msg, err := client.QueStakerExoCoreAddr(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -323,15 +323,15 @@ func local_request_Query_QueStakerExoCoreAddr_0(ctx context.Context, marshaler r _ = err ) - val, ok = pathParams["StakerId"] + val, ok = pathParams["StakerID"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "StakerId") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "StakerID") } - protoReq.StakerId, err = runtime.String(val) + protoReq.StakerID, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "StakerId", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "StakerID", err) } msg, err := server.QueStakerExoCoreAddr(ctx, &protoReq) @@ -793,7 +793,7 @@ var ( pattern_Query_QueOperatorSpecifiedAssetAmount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerSpecifiedAssetAmount"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueStakerExoCoreAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerExoCoreAddr", "StakerId"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueStakerExoCoreAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerExoCoreAddr", "StakerID"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index 483a6de98..34b98061e 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -21,7 +21,7 @@ import ( ) type RewardParams struct { - ClientChainLzId uint64 + ClientChainLzID uint64 Action types.CrossChainOpType AssetsAddress []byte WithdrawRewardAddress []byte @@ -67,15 +67,15 @@ func getRewardParamsFromEventLog(log *ethtypes.Log) (*RewardParams, error) { readEnd += types.CrossChainOpAmountLength amount := sdkmath.NewIntFromBigInt(big.NewInt(0).SetBytes(log.Data[readStart:readEnd])) - var clientChainLzId uint64 - r = bytes.NewReader(log.Topics[types.ClientChainLzIdIndexInTopics][:]) - err = binary.Read(r, binary.BigEndian, &clientChainLzId) + var clientChainLzID uint64 + r = bytes.NewReader(log.Topics[types.ClientChainLzIDIndexInTopics][:]) + err = binary.Read(r, binary.BigEndian, &clientChainLzID) if err != nil { - return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzId from topic") + return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzID from topic") } return &RewardParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: action, AssetsAddress: assetsAddress, WithdrawRewardAddress: rewardAddr, @@ -83,10 +83,10 @@ func getRewardParamsFromEventLog(log *ethtypes.Log) (*RewardParams, error) { }, nil } -func getStakeIDAndAssetId(params *RewardParams) (stakeId string, assetId string) { - clientChainLzIdStr := hexutil.EncodeUint64(params.ClientChainLzId) - stakeId = strings.Join([]string{hexutil.Encode(params.WithdrawRewardAddress[:]), clientChainLzIdStr}, "_") - assetId = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIdStr}, "_") +func getStakeIDAndAssetID(params *RewardParams) (stakeId string, assetID string) { + clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) + stakeId = strings.Join([]string{hexutil.Encode(params.WithdrawRewardAddress[:]), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") return } @@ -129,10 +129,10 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { if event.OpAmount.IsNegative() { return errorsmod.Wrap(rtypes.ErrRewardAmountIsNegative, fmt.Sprintf("the amount is:%s", event.OpAmount)) } - stakeId, assetId := getStakeIDAndAssetId(event) + stakeId, assetID := getStakeIDAndAssetID(event) // check is asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetId) { - return errorsmod.Wrap(rtypes.ErrRewardAssetNotExist, fmt.Sprintf("the assetId is:%s", assetId)) + if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + return errorsmod.Wrap(rtypes.ErrRewardAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } // TODO @@ -140,11 +140,11 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { TotalDepositAmountOrWantChangeValue: event.OpAmount, CanWithdrawAmountOrWantChangeValue: event.OpAmount, } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetId, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) if err != nil { return err } - if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetId, event.OpAmount); err != nil { + if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount); err != nil { return err } return nil diff --git a/x/reward/keeper/claim_reward_test.go b/x/reward/keeper/claim_reward_test.go index 1d5ac332a..ec6bf8a70 100644 --- a/x/reward/keeper/claim_reward_test.go +++ b/x/reward/keeper/claim_reward_test.go @@ -8,37 +8,37 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (suite *KeeperTestSuite) TestClaimWithdrawRequest() { +func (suite *RewardTestSuite) TestClaimWithdrawRequest() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") usdcAddress := common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48") event := &keeper.RewardParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.WithDrawReward, - WithdrawRewardAddress: suite.address[:], + WithdrawRewardAddress: suite.Address[:], OpAmount: sdkmath.NewInt(10), } // test the case that the deposit asset hasn't registered event.AssetsAddress = usdcAddress[:] - err := suite.app.RewardKeeper.RewardForWithdraw(suite.ctx, event) + err := suite.App.RewardKeeper.RewardForWithdraw(suite.Ctx, event) suite.ErrorContains(err, rewardtype.ErrRewardAssetNotExist.Error()) // test the normal case event.AssetsAddress = usdtAddress[:] - err = suite.app.RewardKeeper.RewardForWithdraw(suite.ctx, event) + err = suite.App.RewardKeeper.RewardForWithdraw(suite.Ctx, event) suite.NoError(err) // check state after reward - stakerId, assetId := types.GetStakeIDAndAssetId(event.ClientChainLzId, event.WithdrawRewardAddress, event.AssetsAddress) - info, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(event.ClientChainLzID, event.WithdrawRewardAddress, event.AssetsAddress) + info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), + CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) + assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(10), assetInfo.StakingTotalAmount) } diff --git a/x/reward/keeper/params_test.go b/x/reward/keeper/params_test.go index 5de13d449..3dfa1fd9e 100644 --- a/x/reward/keeper/params_test.go +++ b/x/reward/keeper/params_test.go @@ -4,15 +4,15 @@ import ( rewardtype "github.com/ExocoreNetwork/exocore/x/reward/types" ) -func (suite *KeeperTestSuite) TestParams() { +func (suite *RewardTestSuite) TestParams() { params := &rewardtype.Params{ ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", } - err := suite.app.RewardKeeper.SetParams(suite.ctx, params) + err := suite.App.RewardKeeper.SetParams(suite.Ctx, params) suite.NoError(err) - getParams, err := suite.app.RewardKeeper.GetParams(suite.ctx) + getParams, err := suite.App.RewardKeeper.GetParams(suite.Ctx) suite.NoError(err) suite.Equal(*params, *getParams) } diff --git a/x/reward/keeper/setup_test.go b/x/reward/keeper/setup_test.go index f8d0365c3..1927a5b17 100644 --- a/x/reward/keeper/setup_test.go +++ b/x/reward/keeper/setup_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" //nolint:revive // dot imports are fine for Ginkgo @@ -8,27 +9,17 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - "github.com/ExocoreNetwork/exocore/app" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/suite" ) -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.ExocoreApp - address common.Address - - signer keyring.Signer +type RewardTestSuite struct { + testutil.BaseTestSuite } -var s *KeeperTestSuite +var s *RewardTestSuite func TestKeeperTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(RewardTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -37,6 +28,6 @@ func TestKeeperTestSuite(t *testing.T) { } // SetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (suite *RewardTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/reward/keeper/utils_test.go b/x/reward/keeper/utils_test.go deleted file mode 100644 index 8dcb23033..000000000 --- a/x/reward/keeper/utils_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package keeper_test - -import ( - "time" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/stretchr/testify/require" -) - -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) - - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) - - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, nil, chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) -} diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index a8e2c8273..d36ef63df 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -21,7 +21,7 @@ import ( ) type SlashParams struct { - ClientChainLzId uint64 + ClientChainLzID uint64 Action types.CrossChainOpType AssetsAddress []byte OperatorAddress sdk.AccAddress @@ -52,13 +52,13 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas return nil, nil } - var clientChainLzId uint64 - r = bytes.NewReader(log.Topics[types.ClientChainLzIdIndexInTopics][:]) - err = binary.Read(r, binary.BigEndian, &clientChainLzId) + var clientChainLzID uint64 + r = bytes.NewReader(log.Topics[types.ClientChainLzIDIndexInTopics][:]) + err = binary.Read(r, binary.BigEndian, &clientChainLzID) if err != nil { - return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzId from topic") + return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzID from topic") } - clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzId) + clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when get client chain info") } @@ -100,7 +100,7 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas amount := sdkmath.NewIntFromBigInt(big.NewInt(0).SetBytes(log.Data[readStart:readEnd])) return &SlashParams{ - ClientChainLzId: clientChainLzId, + ClientChainLzID: clientChainLzID, Action: action, AssetsAddress: assetsAddress, StakerAddress: stakerAddress, @@ -109,10 +109,10 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas }, nil } -func getStakeIDAndAssetId(params *SlashParams) (stakeId string, assetId string) { - clientChainLzIdStr := hexutil.EncodeUint64(params.ClientChainLzId) - stakeId = strings.Join([]string{hexutil.Encode(params.StakerAddress[:]), clientChainLzIdStr}, "_") - assetId = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIdStr}, "_") +func getStakeIDAndAssetID(params *SlashParams) (stakeId string, assetID string) { + clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) + stakeId = strings.Join([]string{hexutil.Encode(params.StakerAddress[:]), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") return } @@ -179,21 +179,21 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { if event.OpAmount.IsNegative() { return errorsmod.Wrap(rtypes.ErrSlashAmountIsNegative, fmt.Sprintf("the amount is:%s", event.OpAmount)) } - stakeId, assetId := getStakeIDAndAssetId(event) + stakeId, assetID := getStakeIDAndAssetID(event) // check is asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetId) { - return errorsmod.Wrap(rtypes.ErrSlashAssetNotExist, fmt.Sprintf("the assetId is:%s", assetId)) + if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + return errorsmod.Wrap(rtypes.ErrSlashAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: event.OpAmount.Neg(), CanWithdrawAmountOrWantChangeValue: event.OpAmount.Neg(), } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetId, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) if err != nil { return err } - if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetId, event.OpAmount.Neg()); err != nil { + if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount.Neg()); err != nil { return err } return nil @@ -212,7 +212,7 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { // return k.GetFrozenStatus(ctx, string(event.OperatorAddress)) // } -// func (k Keeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetId string, startHeight, endHeight uint64) sdkmath.LegacyDec { +// func (k Keeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetID string, startHeight, endHeight uint64) sdkmath.LegacyDec { // //TODO // return sdkmath.LegacyNewDec(3) // } diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index 77298d9e1..02aa73ed6 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -9,39 +9,39 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (suite *KeeperTestSuite) TestSlash() { +func (suite *SlashTestSuite) TestSlash() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") usdcAddress := common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48") event := &keeper.SlashParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Slash, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(90), } depositEvent := &depositKeeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(100), } // deposit firstly depositEvent.AssetsAddress = usdtAddress[:] - err := suite.app.DepositKeeper.Deposit(suite.ctx, depositEvent) + err := suite.App.DepositKeeper.Deposit(suite.Ctx, depositEvent) suite.NoError(err) // test the case that the slash hasn't registered event.AssetsAddress = usdcAddress[:] - err = suite.app.ExoSlashKeeper.Slash(suite.ctx, event) + err = suite.App.ExoSlashKeeper.Slash(suite.Ctx, event) suite.ErrorContains(err, slashtype.ErrSlashAssetNotExist.Error()) - assets, err := suite.app.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.ctx) + assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) - suite.app.Logger().Info("the assets is:", "assets", assets) + suite.App.Logger().Info("the assets is:", "assets", assets) - stakerId, assetId := types.GetStakeIDAndAssetId(depositEvent.ClientChainLzId, depositEvent.StakerAddress, depositEvent.AssetsAddress) - info, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(depositEvent.ClientChainLzID, depositEvent.StakerAddress, depositEvent.AssetsAddress) + info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, @@ -51,12 +51,12 @@ func (suite *KeeperTestSuite) TestSlash() { // test the normal case event.AssetsAddress = usdtAddress[:] - err = suite.app.ExoSlashKeeper.Slash(suite.ctx, event) + err = suite.App.ExoSlashKeeper.Slash(suite.Ctx, event) suite.NoError(err) // check state after slash - stakerId, assetId = types.GetStakeIDAndAssetId(event.ClientChainLzId, event.StakerAddress, event.AssetsAddress) - info, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID = types.GetStakeIDAndAssetID(event.ClientChainLzID, event.StakerAddress, event.AssetsAddress) + info, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), @@ -64,7 +64,7 @@ func (suite *KeeperTestSuite) TestSlash() { WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) + assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(10), assetInfo.StakingTotalAmount) } diff --git a/x/slash/keeper/keeper.go b/x/slash/keeper/keeper.go index cda9177c8..fedfe1286 100644 --- a/x/slash/keeper/keeper.go +++ b/x/slash/keeper/keeper.go @@ -48,5 +48,5 @@ type IEXOSlash interface { IsOperatorFrozen(ctx sdk.Context, event *SlashParams) (bool, error) SetParams(ctx sdk.Context, params *types.Params) error GetParams(ctx sdk.Context) (*types.Params, error) - OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetId string, startHeight, endHeight uint64) sdkmath.LegacyDec + OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetID string, startHeight, endHeight uint64) sdkmath.LegacyDec } diff --git a/x/slash/keeper/params_test.go b/x/slash/keeper/params_test.go index c89f832aa..4d4342717 100644 --- a/x/slash/keeper/params_test.go +++ b/x/slash/keeper/params_test.go @@ -4,15 +4,15 @@ import ( slashtype "github.com/ExocoreNetwork/exocore/x/slash/types" ) -func (suite *KeeperTestSuite) TestParams() { +func (suite *SlashTestSuite) TestParams() { params := &slashtype.Params{ ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", } - err := suite.app.ExoSlashKeeper.SetParams(suite.ctx, params) + err := suite.App.ExoSlashKeeper.SetParams(suite.Ctx, params) suite.NoError(err) - getParams, err := suite.app.ExoSlashKeeper.GetParams(suite.ctx) + getParams, err := suite.App.ExoSlashKeeper.GetParams(suite.Ctx) suite.NoError(err) suite.Equal(*params, *getParams) } diff --git a/x/slash/keeper/setup_test.go b/x/slash/keeper/setup_test.go index f8d0365c3..cf45470b0 100644 --- a/x/slash/keeper/setup_test.go +++ b/x/slash/keeper/setup_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" //nolint:revive // dot imports are fine for Ginkgo @@ -8,27 +9,17 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - "github.com/ExocoreNetwork/exocore/app" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/suite" ) -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.ExocoreApp - address common.Address - - signer keyring.Signer +type SlashTestSuite struct { + testutil.BaseTestSuite } -var s *KeeperTestSuite +var s *SlashTestSuite func TestKeeperTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(SlashTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -37,6 +28,6 @@ func TestKeeperTestSuite(t *testing.T) { } // SetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (suite *SlashTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/slash/keeper/utils_test.go b/x/slash/keeper/utils_test.go deleted file mode 100644 index 8dcb23033..000000000 --- a/x/slash/keeper/utils_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package keeper_test - -import ( - "time" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/stretchr/testify/require" -) - -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) - - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) - - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, nil, chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) -} diff --git a/x/withdraw/client/cli/query.go b/x/withdraw/client/cli/query.go index 35f0a6bf3..5525f0032 100644 --- a/x/withdraw/client/cli/query.go +++ b/x/withdraw/client/cli/query.go @@ -24,7 +24,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand() // this line is used by starport scaffolding # 1 return cmd diff --git a/x/withdraw/client/cli/query_params.go b/x/withdraw/client/cli/query_params.go deleted file mode 100644 index c60b32bfe..000000000 --- a/x/withdraw/client/cli/query_params.go +++ /dev/null @@ -1,36 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/ExocoreNetwork/exocore/x/withdraw/types" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/withdraw/client/cli/tx.go b/x/withdraw/client/cli/tx.go index 7fe7d3b3c..cca9df077 100644 --- a/x/withdraw/client/cli/tx.go +++ b/x/withdraw/client/cli/tx.go @@ -2,71 +2,23 @@ package cli import ( "fmt" - "time" + "github.com/ExocoreNetwork/exocore/x/withdraw/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - - // "github.com/cosmos/cosmos-sdk/client/flags" - paramstypes "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/withdraw/types" -) - -var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) - -const ( - flagPacketTimeoutTimestamp = "packet-timeout-timestamp" - listSeparator = "," ) // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ - Use: paramstypes.ModuleName, - Short: fmt.Sprintf("%s transactions subcommands", paramstypes.ModuleName), + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } - cmd.AddCommand( - UpdateParams(), - ) - - return cmd -} - -// UpdateParams todo: it should be a gov proposal command in future. -func UpdateParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "UpdateParams ExoCoreLZAppAddr ExoCoreLzAppEventTopic", - Short: "set ExoCoreLZAppAddr and ExoCoreLzAppEventTopic params to withdraw module", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := cliCtx.GetFromAddress() - msg := &types.MsgUpdateParams{ - Authority: sender.String(), - Params: paramstypes.Params{ - ExoCoreLzAppAddress: args[0], - ExoCoreLzAppEventTopic: args[1], - }, - } - - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) + cmd.AddCommand() return cmd } diff --git a/x/withdraw/keeper/claim_withdraw.go b/x/withdraw/keeper/claim_withdraw.go index 35c7e9b32..80c8ed770 100644 --- a/x/withdraw/keeper/claim_withdraw.go +++ b/x/withdraw/keeper/claim_withdraw.go @@ -13,7 +13,7 @@ import ( ) type WithdrawParams struct { - ClientChainLzId uint64 + ClientChainLzID uint64 Action types.CrossChainOpType AssetsAddress []byte WithdrawAddress []byte @@ -59,15 +59,15 @@ type WithdrawParams struct { // readEnd += types.CrossChainOpAmountLength // amount := sdkmath.NewIntFromBigInt(big.NewInt(0).SetBytes(log.Data[readStart:readEnd])) -// var clientChainLzId uint64 -// r = bytes.NewReader(log.Topics[types.ClientChainLzIdIndexInTopics][:]) -// err = binary.Read(r, binary.BigEndian, &clientChainLzId) +// var clientChainLzID uint64 +// r = bytes.NewReader(log.Topics[types.ClientChainLzIDIndexInTopics][:]) +// err = binary.Read(r, binary.BigEndian, &clientChainLzID) // if err != nil { -// return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzId from topic") +// return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzID from topic") // } // return &WithdrawParams{ -// ClientChainLzId: clientChainLzId, +// ClientChainLzID: clientChainLzID, // Action: action, // AssetsAddress: assetsAddress, // WithdrawAddress: withdrawAddress, @@ -75,10 +75,10 @@ type WithdrawParams struct { // }, nil // } -func getStakeIDAndAssetId(params *WithdrawParams) (stakeId string, assetId string) { - clientChainLzIdStr := hexutil.EncodeUint64(params.ClientChainLzId) - stakeId = strings.Join([]string{hexutil.Encode(params.WithdrawAddress[:]), clientChainLzIdStr}, "_") - assetId = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIdStr}, "_") +func getStakeIDAndAssetID(params *WithdrawParams) (stakeId string, assetID string) { + clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) + stakeId = strings.Join([]string{hexutil.Encode(params.WithdrawAddress[:]), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") return } @@ -122,21 +122,21 @@ func (k Keeper) Withdraw(ctx sdk.Context, params *WithdrawParams) error { if params.OpAmount.IsNegative() { return errorsmod.Wrap(withdrawtype.ErrWithdrawAmountIsNegative, fmt.Sprintf("the amount is:%s", params.OpAmount)) } - stakeId, assetId := getStakeIDAndAssetId(params) + stakeId, assetID := getStakeIDAndAssetID(params) // check if asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetId) { - return errorsmod.Wrap(withdrawtype.ErrWithdrawAssetNotExist, fmt.Sprintf("the assetId is:%s", assetId)) + if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + return errorsmod.Wrap(withdrawtype.ErrWithdrawAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: params.OpAmount.Neg(), CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetId, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) if err != nil { return err } - if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetId, params.OpAmount.Neg()); err != nil { + if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, params.OpAmount.Neg()); err != nil { return err } return nil diff --git a/x/withdraw/keeper/claim_withdraw_test.go b/x/withdraw/keeper/claim_withdraw_test.go index 4bb4250a6..670a832b1 100644 --- a/x/withdraw/keeper/claim_withdraw_test.go +++ b/x/withdraw/keeper/claim_withdraw_test.go @@ -9,61 +9,61 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (suite *KeeperTestSuite) TestClaimWithdrawRequest() { +func (suite *WithdrawTestSuite) TestClaimWithdrawRequest() { usdtAddress := common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7") usdcAddress := common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48") event := &keeper.WithdrawParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.WithdrawPrinciple, - WithdrawAddress: suite.address[:], + WithdrawAddress: suite.Address[:], OpAmount: sdkmath.NewInt(90), } depositEvent := &depositKeeper.DepositParams{ - ClientChainLzId: 101, + ClientChainLzID: 101, Action: types.Deposit, - StakerAddress: suite.address[:], + StakerAddress: suite.Address[:], OpAmount: sdkmath.NewInt(100), } // deposit firstly depositEvent.AssetsAddress = usdtAddress[:] - err := suite.app.DepositKeeper.Deposit(suite.ctx, depositEvent) + err := suite.App.DepositKeeper.Deposit(suite.Ctx, depositEvent) suite.NoError(err) // test the case that the withdraw asset hasn't registered event.AssetsAddress = usdcAddress[:] - err = suite.app.WithdrawKeeper.Withdraw(suite.ctx, event) + err = suite.App.WithdrawKeeper.Withdraw(suite.Ctx, event) suite.ErrorContains(err, withdrawtype.ErrWithdrawAssetNotExist.Error()) - assets, err := suite.app.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.ctx) + assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) - suite.app.Logger().Info("the assets is:", "assets", assets) + suite.App.Logger().Info("the assets is:", "assets", assets) - stakerId, assetId := types.GetStakeIDAndAssetId(depositEvent.ClientChainLzId, depositEvent.StakerAddress, depositEvent.AssetsAddress) - info, err := suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID := types.GetStakeIDAndAssetID(depositEvent.ClientChainLzID, depositEvent.StakerAddress, depositEvent.AssetsAddress) + info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, + CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) // test the normal case event.AssetsAddress = usdtAddress[:] - err = suite.app.WithdrawKeeper.Withdraw(suite.ctx, event) + err = suite.App.WithdrawKeeper.Withdraw(suite.Ctx, event) suite.NoError(err) // check state after withdraw - stakerId, assetId = types.GetStakeIDAndAssetId(event.ClientChainLzId, event.WithdrawAddress, event.AssetsAddress) - info, err = suite.app.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.ctx, stakerId, assetId) + stakerID, assetID = types.GetStakeIDAndAssetID(event.ClientChainLzID, event.WithdrawAddress, event.AssetsAddress) + info, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), + CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), + WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.app.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.ctx, assetId) + assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(10), assetInfo.StakingTotalAmount) } diff --git a/x/withdraw/keeper/msg_server.go b/x/withdraw/keeper/msg_server.go deleted file mode 100644 index 71fd4b521..000000000 --- a/x/withdraw/keeper/msg_server.go +++ /dev/null @@ -1,20 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/ExocoreNetwork/exocore/x/withdraw/types" -) - -type msgServer struct { - Keeper -} - -func (k Keeper) UpdateParams(ctx context.Context, params *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - // c := sdk.UnwrapSDKContext(ctx) - // err := k.SetParams(c, ¶ms.Params) - // if err != nil { - // return nil, err - // } - return nil, nil -} diff --git a/x/withdraw/keeper/params.go b/x/withdraw/keeper/params.go index f366860c1..6c6537003 100644 --- a/x/withdraw/keeper/params.go +++ b/x/withdraw/keeper/params.go @@ -1,13 +1,8 @@ package keeper import ( - "strings" - paramstypes "github.com/ExocoreNetwork/exocore/x/deposit/types" - types "github.com/ExocoreNetwork/exocore/x/withdraw/types" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) // GetParams get all parameters as types.Params @@ -26,20 +21,3 @@ func (k Keeper) GetParams(ctx sdk.Context) (*paramstypes.Params, error) { // Uify the way to obtain Params from deposit keeper return k.depositKeeper.GetParams(ctx) } - -// SetParams set the params -func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { - // check if addr is evm address - if !common.IsHexAddress(params.ExoCoreLzAppAddress) { - return types.ErrInvalidEvmAddressFormat - } - if len(common.FromHex(params.ExoCoreLzAppEventTopic)) != common.HashLength { - return types.ErrInvalidLzUaTopicIdLength - } - params.ExoCoreLzAppAddress = strings.ToLower(params.ExoCoreLzAppAddress) - params.ExoCoreLzAppEventTopic = strings.ToLower(params.ExoCoreLzAppEventTopic) - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixParams) - bz := k.cdc.MustMarshal(params) - store.Set(types.ParamsKey, bz) - return nil -} diff --git a/x/withdraw/keeper/params_test.go b/x/withdraw/keeper/params_test.go deleted file mode 100644 index ee8bf7ab1..000000000 --- a/x/withdraw/keeper/params_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper_test - -import ( - withdrawtype "github.com/ExocoreNetwork/exocore/x/withdraw/types" -) - -func (suite *KeeperTestSuite) TestParams() { - params := &withdrawtype.Params{ - ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", - ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", - } - err := suite.app.WithdrawKeeper.SetParams(suite.ctx, params) - suite.NoError(err) - - getParams, err := suite.app.WithdrawKeeper.GetParams(suite.ctx) - suite.NoError(err) - suite.Equal(*params, *getParams) -} diff --git a/x/withdraw/keeper/query.go b/x/withdraw/keeper/query.go deleted file mode 100644 index f6e51ad1c..000000000 --- a/x/withdraw/keeper/query.go +++ /dev/null @@ -1,7 +0,0 @@ -package keeper - -import ( - "github.com/ExocoreNetwork/exocore/x/withdraw/types" -) - -var _ types.QueryServer = Keeper{} diff --git a/x/withdraw/keeper/query_params.go b/x/withdraw/keeper/query_params.go deleted file mode 100644 index b2654597e..000000000 --- a/x/withdraw/keeper/query_params.go +++ /dev/null @@ -1,19 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/ExocoreNetwork/exocore/x/withdraw/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - c := sdk.UnwrapSDKContext(goCtx) - params, err := k.GetParams(c) - if err != nil { - return nil, err - } - return &types.QueryParamsResponse{ - Params: params, - }, nil -} diff --git a/x/withdraw/keeper/setup_test.go b/x/withdraw/keeper/setup_test.go index f8d0365c3..9dd0c641a 100644 --- a/x/withdraw/keeper/setup_test.go +++ b/x/withdraw/keeper/setup_test.go @@ -1,34 +1,24 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/testutil" "testing" //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/ginkgo/v2" //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/suite" ) -type KeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.ExocoreApp - address common.Address - - signer keyring.Signer +type WithdrawTestSuite struct { + testutil.BaseTestSuite } -var s *KeeperTestSuite +var s *WithdrawTestSuite func TestKeeperTestSuite(t *testing.T) { - s = new(KeeperTestSuite) + s = new(WithdrawTestSuite) suite.Run(t, s) // Run Ginkgo integration tests @@ -37,6 +27,6 @@ func TestKeeperTestSuite(t *testing.T) { } // SetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`. -func (suite *KeeperTestSuite) SetupTest() { - suite.DoSetupTest(suite.T()) +func (suite *WithdrawTestSuite) SetupTest() { + suite.DoSetupTest() } diff --git a/x/withdraw/keeper/utils_test.go b/x/withdraw/keeper/utils_test.go deleted file mode 100644 index 8dcb23033..000000000 --- a/x/withdraw/keeper/utils_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package keeper_test - -import ( - "time" - - "github.com/ExocoreNetwork/exocore/app" - "github.com/ExocoreNetwork/exocore/utils" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v14/crypto/ethsecp256k1" - "github.com/evmos/evmos/v14/testutil" - utiltx "github.com/evmos/evmos/v14/testutil/tx" - "github.com/stretchr/testify/require" -) - -func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) { - // account key - priv, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes()) - suite.signer = utiltx.NewSigner(priv) - - // consensus key - privCons, err := ethsecp256k1.GenerateKey() - require.NoError(t, err) - consAddress := sdk.ConsAddress(privCons.PubKey().Address()) - - chainID := utils.TestnetChainID + "-1" - suite.app = app.Setup(false, nil, chainID, false) - header := testutil.NewHeader( - 1, time.Now().UTC(), chainID, consAddress, nil, nil, - ) - suite.ctx = suite.app.BaseApp.NewContext(false, header) -} diff --git a/x/withdraw/module.go b/x/withdraw/module.go index 61f2fb4b4..0a0b3c92e 100644 --- a/x/withdraw/module.go +++ b/x/withdraw/module.go @@ -1,10 +1,6 @@ package withdraw import ( - "context" - "encoding/json" - "fmt" - // this line is used by starport scaffolding # 1 "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -49,33 +45,13 @@ func (AppModuleBasic) Name() string { } // RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(cdc) -} +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message -func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { - types.RegisterInterfaces(reg) -} - -// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) -} - -// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var genState types.GenesisState - if err := cdc.UnmarshalJSON(bz, &genState); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - return genState.Validate() -} +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) -} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module func (a AppModuleBasic) GetTxCmd() *cobra.Command { @@ -111,7 +87,7 @@ func NewAppModule( // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + //types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) diff --git a/x/withdraw/types/codec.go b/x/withdraw/types/codec.go deleted file mode 100644 index 021ff6751..000000000 --- a/x/withdraw/types/codec.go +++ /dev/null @@ -1,50 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global erc20 module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding. - // - // The actual codec used for serialization should be provided to modules/erc20 and - // defined at the application level. - ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) - - // AminoCdc is a amino codec created to support amino JSON compatible msgs. - AminoCdc = codec.NewAminoCodec(amino) -) - -const ( - // Amino names - updateParamsName = "exocore/MsgUpdateParamsForWithdraw" -) - -// NOTE: This is required for the GetSignBytes function -func init() { - RegisterLegacyAminoCodec(amino) - amino.Seal() -} - -// RegisterInterfaces register implementations -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgUpdateParams{}, - ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -// RegisterLegacyAminoCodec registers the necessary x/revenue interfaces and -// concrete types on the provided LegacyAmino codec. These types are used for -// Amino JSON serialization and EIP-712 compatibility. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgUpdateParams{}, updateParamsName, nil) -} diff --git a/x/withdraw/types/genesis.go b/x/withdraw/types/genesis.go deleted file mode 100644 index 0af9b4416..000000000 --- a/x/withdraw/types/genesis.go +++ /dev/null @@ -1,24 +0,0 @@ -package types - -import ( -// this line is used by starport scaffolding # genesis/types/import -) - -// DefaultIndex is the default global index -const DefaultIndex uint64 = 1 - -// DefaultGenesis returns the default genesis state -func DefaultGenesis() *GenesisState { - return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), - } -} - -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate - - return gs.Params.Validate() -} diff --git a/x/withdraw/types/genesis.pb.go b/x/withdraw/types/genesis.pb.go deleted file mode 100644 index 59fbfa94b..000000000 --- a/x/withdraw/types/genesis.pb.go +++ /dev/null @@ -1,320 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/withdraw/genesis.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - 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 - -// GenesisState defines the withdraw module's genesis state. -type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_a840e4e75e554053, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "exocore.withdraw.GenesisState") -} - -func init() { proto.RegisterFile("exocore/withdraw/genesis.proto", fileDescriptor_a840e4e75e554053) } - -var fileDescriptor_a840e4e75e554053 = []byte{ - // 185 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xad, 0xc8, 0x4f, - 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xcf, 0x2c, 0xc9, 0x48, 0x29, 0x4a, 0x2c, 0xd7, 0x4f, 0x4f, 0xcd, - 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0xca, 0xeb, 0xc1, - 0xe4, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x94, 0x2c, - 0x86, 0x39, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x63, 0x94, 0xdc, 0xb8, 0x78, 0xdc, 0x21, 0xe6, - 0x06, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x99, 0x71, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, - 0xb8, 0x8d, 0x24, 0xf4, 0xd0, 0xed, 0xd1, 0x0b, 0x00, 0xcb, 0x3b, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, - 0x10, 0x04, 0x55, 0xed, 0x64, 0x7b, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, - 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, - 0xca, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x30, 0xb7, 0x54, 0x20, - 0x5c, 0x53, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x8d, 0x31, 0x20, 0x00, 0x00, 0xff, - 0xff, 0xdc, 0x77, 0x24, 0x66, 0xf6, 0x00, 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 - { - size, err := m.Params.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 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 - l = m.Params.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 Params", 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.Params.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 skipGenesis(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, ErrIntOverflowGenesis - } - 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, ErrIntOverflowGenesis - } - 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, ErrIntOverflowGenesis - } - 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, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/withdraw/types/genesis_test.go b/x/withdraw/types/genesis_test.go deleted file mode 100644 index 05b369d81..000000000 --- a/x/withdraw/types/genesis_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/ExocoreNetwork/exocore/x/withdraw/types" - "github.com/stretchr/testify/require" -) - -func TestGenesisState_Validate(t *testing.T) { - tests := []struct { - desc string - genState *types.GenesisState - valid bool - }{ - { - desc: "default is valid", - genState: types.DefaultGenesis(), - valid: true, - }, - { - desc: "valid genesis state", - genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, - }, - // this line is used by starport scaffolding # types/genesis/testcase - } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} diff --git a/x/withdraw/types/msg.go b/x/withdraw/types/msg.go deleted file mode 100644 index bc29c4af4..000000000 --- a/x/withdraw/types/msg.go +++ /dev/null @@ -1,27 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ sdk.Msg = &MsgUpdateParams{} - -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { - addr := sdk.MustAccAddressFromBech32(m.Authority) - return []sdk.AccAddress{addr} -} - -// ValidateBasic does a sanity check of the provided data -func (m *MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { - return errorsmod.Wrap(err, "invalid from address") - } - return nil -} - -// GetSignBytes implements the LegacyMsg interface. -func (m *MsgUpdateParams) GetSignBytes() []byte { - return nil -} diff --git a/x/withdraw/types/params.go b/x/withdraw/types/params.go deleted file mode 100644 index 4f3215e35..000000000 --- a/x/withdraw/types/params.go +++ /dev/null @@ -1,32 +0,0 @@ -package types - -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// NewParams creates a new Params instance -func NewParams() Params { - return Params{} -} - -// DefaultParams returns a default set of parameters -func DefaultParams() Params { - return NewParams() -} - -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - -// Validate validates the set of params -func (p Params) Validate() error { - return nil -} diff --git a/x/withdraw/types/params.pb.go b/x/withdraw/types/params.pb.go deleted file mode 100644 index d57539549..000000000 --- a/x/withdraw/types/params.pb.go +++ /dev/null @@ -1,369 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/withdraw/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - 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 - -// Params defines the parameters for the module. -type Params struct { - ExoCoreLzAppAddress string `protobuf:"bytes,1,opt,name=exoCoreLzAppAddress,proto3" json:"exoCoreLzAppAddress,omitempty"` - ExoCoreLzAppEventTopic string `protobuf:"bytes,2,opt,name=exoCoreLzAppEventTopic,proto3" json:"exoCoreLzAppEventTopic,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_35a6d42797266547, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetExoCoreLzAppAddress() string { - if m != nil { - return m.ExoCoreLzAppAddress - } - return "" -} - -func (m *Params) GetExoCoreLzAppEventTopic() string { - if m != nil { - return m.ExoCoreLzAppEventTopic - } - return "" -} - -func init() { - proto.RegisterType((*Params)(nil), "exocore.withdraw.Params") -} - -func init() { proto.RegisterFile("exocore/withdraw/params.proto", fileDescriptor_35a6d42797266547) } - -var fileDescriptor_35a6d42797266547 = []byte{ - // 192 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xad, 0xc8, 0x4f, - 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xcf, 0x2c, 0xc9, 0x48, 0x29, 0x4a, 0x2c, 0xd7, 0x2f, 0x48, 0x2c, - 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x4a, 0xeb, 0xc1, 0xa4, - 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x52, 0x11, 0x17, - 0x5b, 0x00, 0x58, 0x9f, 0x90, 0x01, 0x97, 0x70, 0x6a, 0x45, 0xbe, 0x73, 0x7e, 0x51, 0xaa, 0x4f, - 0x95, 0x63, 0x41, 0x81, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, 0x04, 0xa3, 0x02, 0xa3, 0x06, - 0x67, 0x10, 0x36, 0x29, 0x21, 0x33, 0x2e, 0x31, 0x64, 0x61, 0xd7, 0xb2, 0xd4, 0xbc, 0x92, 0x90, - 0xfc, 0x82, 0xcc, 0x64, 0x09, 0x26, 0xb0, 0x26, 0x1c, 0xb2, 0x4e, 0xb6, 0x27, 0x1e, 0xc9, 0x31, - 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, - 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9c, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, - 0x9f, 0xab, 0x0f, 0xf3, 0x5f, 0x05, 0xc2, 0x87, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, - 0x97, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x56, 0x86, 0xd8, 0xa9, 0x02, 0x01, 0x00, 0x00, -} - -func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ExoCoreLzAppEventTopic) > 0 { - i -= len(m.ExoCoreLzAppEventTopic) - copy(dAtA[i:], m.ExoCoreLzAppEventTopic) - i = encodeVarintParams(dAtA, i, uint64(len(m.ExoCoreLzAppEventTopic))) - i-- - dAtA[i] = 0x12 - } - if len(m.ExoCoreLzAppAddress) > 0 { - i -= len(m.ExoCoreLzAppAddress) - copy(dAtA[i:], m.ExoCoreLzAppAddress) - i = encodeVarintParams(dAtA, i, uint64(len(m.ExoCoreLzAppAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ExoCoreLzAppAddress) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.ExoCoreLzAppEventTopic) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) 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 ErrIntOverflowParams - } - 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: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppEventTopic", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppEventTopic = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(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, ErrIntOverflowParams - } - 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, ErrIntOverflowParams - } - 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, ErrIntOverflowParams - } - 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, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/withdraw/types/query.pb.go b/x/withdraw/types/query.pb.go deleted file mode 100644 index 0f71e5881..000000000 --- a/x/withdraw/types/query.pb.go +++ /dev/null @@ -1,546 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/withdraw/query.proto - -package types - -import ( - context "context" - fmt "fmt" - types "github.com/ExocoreNetwork/exocore/x/deposit/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 - -// QueryParamsRequest is request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_59bca5e59812c328, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params holds all the parameters of this module. - Params *types.Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59bca5e59812c328, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() *types.Params { - if m != nil { - return m.Params - } - return nil -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "exocore.withdraw.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "exocore.withdraw.QueryParamsResponse") -} - -func init() { proto.RegisterFile("exocore/withdraw/query.proto", fileDescriptor_59bca5e59812c328) } - -var fileDescriptor_59bca5e59812c328 = []byte{ - // 310 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x31, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x7b, 0x82, 0x1d, 0xe2, 0x22, 0xb1, 0x43, 0x39, 0x4a, 0x28, 0x45, 0x41, 0x1c, 0x12, - 0xee, 0xfc, 0x06, 0x82, 0x83, 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43, 0xfe, 0xf7, 0x12, 0x7c, - 0xbb, 0x44, 0x7c, 0xf4, 0x0f, 0x15, 0x4a, 0x0d, 0xfa, 0x4f, 0x6f, 0x9f, 0x2f, 0x3b, 0x31, 0xed, - 0x8a, 0xad, 0xe3, 0x87, 0x0a, 0x67, 0x97, 0xaf, 0x6b, 0x16, 0xad, 0xd6, 0x2c, 0xfa, 0x58, 0xb3, - 0xe8, 0xb9, 0x64, 0xad, 0x55, 0xc9, 0x5a, 0xef, 0x25, 0x6b, 0xdd, 0xa5, 0x4a, 0xfb, 0xf1, 0x2c, - 0xe3, 0x43, 0x9c, 0x88, 0xf3, 0xb0, 0x7d, 0x05, 0xbe, 0x40, 0x7b, 0xff, 0x2d, 0x5b, 0xfc, 0xe8, - 0xfc, 0xd2, 0x80, 0xcb, 0xda, 0xd5, 0xe1, 0x4e, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xea, 0xd2, - 0x25, 0x41, 0xec, 0x01, 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 { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/exocore.withdraw.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.withdraw.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "exocore.withdraw.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "exocore/withdraw/query.proto", -} - -func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Params != nil { - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - 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 *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Params != nil { - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - } - 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 *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params == nil { - m.Params = &types.Params{} - } - if err := m.Params.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 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/withdraw/types/query.pb.gw.go b/x/withdraw/types/query.pb.gw.go deleted file mode 100644 index 5b7cd856b..000000000 --- a/x/withdraw/types/query.pb.gw.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: exocore/withdraw/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 - -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(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_Params_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_Params_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_Params_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_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"exocore", "withdraw", "params"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage -) diff --git a/x/withdraw/types/tx.pb.go b/x/withdraw/types/tx.pb.go deleted file mode 100644 index b7af85d30..000000000 --- a/x/withdraw/types/tx.pb.go +++ /dev/null @@ -1,596 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/withdraw/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - types "github.com/ExocoreNetwork/exocore/x/deposit/types" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - 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 - -// MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 -type MsgUpdateParams struct { - // authority is the address of the governance account. - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the x/evm parameters to update. - // NOTE: All parameters must be supplied. - Params types.Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_9fa45fb8759a8d92, []int{0} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() types.Params { - if m != nil { - return m.Params - } - return types.Params{} -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// Since: cosmos-sdk 0.47 -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9fa45fb8759a8d92, []int{1} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgUpdateParams)(nil), "exocore.withdraw.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "exocore.withdraw.MsgUpdateParamsResponse") -} - -func init() { proto.RegisterFile("exocore/withdraw/tx.proto", fileDescriptor_9fa45fb8759a8d92) } - -var fileDescriptor_9fa45fb8759a8d92 = []byte{ - // 348 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xad, 0xc8, 0x4f, - 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xcf, 0x2c, 0xc9, 0x48, 0x29, 0x4a, 0x2c, 0xd7, 0x2f, 0xa9, 0xd0, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x4a, 0xe9, 0xc1, 0xa4, 0xa4, 0xc4, 0x93, 0xf3, - 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0xa9, 0x94, - 0x24, 0x44, 0x22, 0x1e, 0xcc, 0xd3, 0x87, 0x70, 0xa0, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x10, - 0x71, 0x10, 0x0b, 0x2a, 0x2a, 0x98, 0x98, 0x9b, 0x99, 0x97, 0xaf, 0x0f, 0x26, 0xa1, 0x42, 0x0a, - 0x30, 0x97, 0xa4, 0xa4, 0x16, 0xe4, 0x17, 0x67, 0x96, 0x80, 0x6c, 0x80, 0x32, 0x21, 0x2a, 0x94, - 0x26, 0x33, 0x72, 0xf1, 0xfb, 0x16, 0xa7, 0x87, 0x16, 0xa4, 0x24, 0x96, 0xa4, 0x06, 0x24, 0x16, - 0x25, 0xe6, 0x16, 0x0b, 0x99, 0x71, 0x71, 0x26, 0x96, 0x96, 0x64, 0xe4, 0x17, 0x65, 0x96, 0x54, - 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0x49, 0x5c, 0xda, 0xa2, 0x2b, 0x02, 0x75, 0x83, 0x63, - 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0x71, 0x70, 0x49, 0x51, 0x66, 0x5e, 0x7a, 0x10, 0x42, 0xa9, 0x90, - 0x05, 0x17, 0x5b, 0x01, 0xd8, 0x04, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x29, 0x3d, 0x98, - 0x6f, 0x61, 0x76, 0x96, 0x19, 0xea, 0x41, 0xec, 0x70, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, - 0xaa, 0xde, 0x8a, 0xaf, 0xe9, 0xf9, 0x06, 0x2d, 0x84, 0x49, 0x4a, 0x92, 0x5c, 0xe2, 0x68, 0x8e, - 0x0a, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0xca, 0xe2, 0x62, 0xf6, 0x2d, 0x4e, 0x17, - 0x8a, 0xe1, 0xe2, 0x41, 0x71, 0xb3, 0xa2, 0x1e, 0x7a, 0xc8, 0xea, 0xa1, 0x99, 0x20, 0xa5, 0x49, - 0x50, 0x09, 0xcc, 0x12, 0x29, 0xd6, 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0x7c, 0x4e, 0x3c, 0x92, - 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, - 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, - 0x39, 0x3f, 0x57, 0xdf, 0x15, 0x62, 0xaa, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0x2c, - 0xc8, 0x2b, 0x90, 0xa2, 0xbf, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0xe2, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xbb, 0x4a, 0x31, 0x2f, 0x1f, 0x02, 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 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/exocore.withdraw.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.withdraw.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "exocore.withdraw.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "exocore/withdraw/tx.proto", -} - -func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgUpdateParams) 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 ErrIntOverflowTx - } - 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: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx - } - 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: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(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, ErrIntOverflowTx - } - 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, ErrIntOverflowTx - } - 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, ErrIntOverflowTx - } - 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, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/withdraw/types/types.go b/x/withdraw/types/types.go deleted file mode 100644 index ab1254f4c..000000000 --- a/x/withdraw/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types From 9fd1543dfc744050c5b6509d49025a508cc70c48 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 6 Mar 2024 16:45:16 +0800 Subject: [PATCH 32/44] change LayerZeroChainId to LayerZeroChainID --- .../restaking_assets_manage/v1/tx.proto | 4 +- x/restaking_assets_manage/genesis.go | 4 +- .../keeper/client_chain.go | 8 +- .../keeper/client_chain_and_asset_test.go | 6 +- .../keeper/client_chain_asset.go | 6 +- x/restaking_assets_manage/types/tx.pb.go | 134 +++++++++--------- 6 files changed, 81 insertions(+), 81 deletions(-) diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index f3773fb8f..4e22e95fc 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -23,7 +23,7 @@ message ClientChainInfo { uint64 OriginChainId = 3; uint64 ExoCoreChainIndex = 4; uint64 FinalityNeedBlockDelay = 5; - uint64 LayerZeroChainId = 6; + uint64 LayerZeroChainID = 6; string SignatureType = 7; uint32 AddressLength = 8; } @@ -53,7 +53,7 @@ message ClientChainTokenInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - uint64 LayerZeroChainId = 6; + uint64 LayerZeroChainID = 6; uint64 ExoCoreChainIndex = 7; string AssetMetaInfo = 8; } diff --git a/x/restaking_assets_manage/genesis.go b/x/restaking_assets_manage/genesis.go index ecafcfdc6..6cc658807 100644 --- a/x/restaking_assets_manage/genesis.go +++ b/x/restaking_assets_manage/genesis.go @@ -26,7 +26,7 @@ func DefaultGenesisState() *restakingtype.GenesisState { ChainMetaInfo: "ethereum blockchain", OriginChainId: 1, FinalityNeedBlockDelay: 10, - LayerZeroChainId: 101, + LayerZeroChainID: 101, AddressLength: 20, } usdtClientChainAsset := &restakingtype.ClientChainTokenInfo{ @@ -34,7 +34,7 @@ func DefaultGenesisState() *restakingtype.GenesisState { Symbol: "USDT", Address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", Decimals: 6, - LayerZeroChainId: ethClientChain.LayerZeroChainId, + LayerZeroChainID: ethClientChain.LayerZeroChainID, AssetMetaInfo: "Tether USD token", } totalSupply, _ := sdk.NewIntFromString("40022689732746729") diff --git a/x/restaking_assets_manage/keeper/client_chain.go b/x/restaking_assets_manage/keeper/client_chain.go index c106bcf64..bc24df2c4 100644 --- a/x/restaking_assets_manage/keeper/client_chain.go +++ b/x/restaking_assets_manage/keeper/client_chain.go @@ -7,14 +7,14 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) -// SetClientChainInfo todo: Temporarily use layerZeroChainId as key. +// SetClientChainInfo todo: Temporarily use LayerZeroChainID as key. // It provides a function to register the client chains supported by exoCore.It's called by genesis configuration now,however it will be called by the governance in the future func (k Keeper) SetClientChainInfo(ctx sdk.Context, info *restakingtype.ClientChainInfo) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixClientChainInfo) //key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) - store.Set([]byte(hexutil.EncodeUint64(info.LayerZeroChainId)), bz) + store.Set([]byte(hexutil.EncodeUint64(info.LayerZeroChainID)), bz) return nil } @@ -23,7 +23,7 @@ func (k Keeper) ClientChainInfoIsExist(ctx sdk.Context, index uint64) bool { return store.Has([]byte(hexutil.EncodeUint64(index))) } -// GetClientChainInfoByIndex using layerZeroChainId as the query index. +// GetClientChainInfoByIndex using LayerZeroChainID as the query index. func (k Keeper) GetClientChainInfoByIndex(ctx sdk.Context, index uint64) (info *restakingtype.ClientChainInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixClientChainInfo) ifExist := store.Has([]byte(hexutil.EncodeUint64(index))) @@ -47,7 +47,7 @@ func (k Keeper) GetAllClientChainInfo(ctx sdk.Context) (infos map[uint64]*restak for ; iterator.Valid(); iterator.Next() { var chainInfo restakingtype.ClientChainInfo k.cdc.MustUnmarshal(iterator.Value(), &chainInfo) - ret[chainInfo.LayerZeroChainId] = &chainInfo + ret[chainInfo.LayerZeroChainID] = &chainInfo } return ret, nil } diff --git a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go b/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go index ae31b109d..83e1b2e30 100644 --- a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go +++ b/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go @@ -13,7 +13,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { suite.NoError(err) suite.Ctx.Logger().Info("the clientChains is:", "info", clientChains) for _, clientChain := range defaultGensisState.DefaultSupportedClientChains { - info, ok := clientChains[clientChain.LayerZeroChainId] + info, ok := clientChains[clientChain.LayerZeroChainID] suite.True(ok) suite.Equal(info, clientChain) } @@ -26,7 +26,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) for _, asset := range defaultGensisState.DefaultSupportedClientChainTokens { - _, assetID := types.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainId, "", asset.Address) + _, assetID := types.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) suite.Ctx.Logger().Info("the asset id is:", "assetID", assetID) info, ok := assets[assetID] suite.True(ok) @@ -34,7 +34,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { } usdtAsset := defaultGensisState.DefaultSupportedClientChainTokens[0] - _, assetID := types.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainId, "", usdtAsset.Address) + _, assetID := types.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainID, "", usdtAsset.Address) assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(usdtAsset, assetInfo.AssetBasicInfo) diff --git a/x/restaking_assets_manage/keeper/client_chain_asset.go b/x/restaking_assets_manage/keeper/client_chain_asset.go index 3d687ed81..9074fad73 100644 --- a/x/restaking_assets_manage/keeper/client_chain_asset.go +++ b/x/restaking_assets_manage/keeper/client_chain_asset.go @@ -37,14 +37,14 @@ func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetID string, c return nil } -// SetStakingAssetInfo todo: Temporarily use clientChainAssetAddr+'_'+layerZeroChainId as the key. +// SetStakingAssetInfo todo: Temporarily use clientChainAssetAddr+'_'+LayerZeroChainID as the key. // It provides a function to register the client chain assets supported by exoCore.It's called by genesis configuration now,however it will be called by the governance in the future func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *restakingtype.StakingAssetInfo) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) - _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(info.AssetBasicInfo.LayerZeroChainId, "", info.AssetBasicInfo.Address) + _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(info.AssetBasicInfo.LayerZeroChainID, "", info.AssetBasicInfo.Address) store.Set([]byte(assetID), bz) return nil } @@ -77,7 +77,7 @@ func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]* for ; iterator.Valid(); iterator.Next() { var assetInfo restakingtype.StakingAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) - _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainId, "", assetInfo.AssetBasicInfo.Address) + _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainID, "", assetInfo.AssetBasicInfo.Address) ret[assetID] = &assetInfo } return ret, nil diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index 6130ad0b4..22aa10ec4 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -75,7 +75,7 @@ type ClientChainInfo struct { OriginChainId uint64 `protobuf:"varint,3,opt,name=OriginChainId,proto3" json:"OriginChainId,omitempty"` ExoCoreChainIndex uint64 `protobuf:"varint,4,opt,name=ExoCoreChainIndex,proto3" json:"ExoCoreChainIndex,omitempty"` FinalityNeedBlockDelay uint64 `protobuf:"varint,5,opt,name=FinalityNeedBlockDelay,proto3" json:"FinalityNeedBlockDelay,omitempty"` - LayerZeroChainId uint64 `protobuf:"varint,6,opt,name=LayerZeroChainId,proto3" json:"LayerZeroChainId,omitempty"` + LayerZeroChainID uint64 `protobuf:"varint,6,opt,name=LayerZeroChainID,proto3" json:"LayerZeroChainID,omitempty"` SignatureType string `protobuf:"bytes,7,opt,name=SignatureType,proto3" json:"SignatureType,omitempty"` AddressLength uint32 `protobuf:"varint,8,opt,name=AddressLength,proto3" json:"AddressLength,omitempty"` } @@ -148,9 +148,9 @@ func (m *ClientChainInfo) GetFinalityNeedBlockDelay() uint64 { return 0 } -func (m *ClientChainInfo) GetLayerZeroChainId() uint64 { +func (m *ClientChainInfo) GetLayerZeroChainID() uint64 { if m != nil { - return m.LayerZeroChainId + return m.LayerZeroChainID } return 0 } @@ -250,7 +250,7 @@ type ClientChainTokenInfo struct { Address string `protobuf:"bytes,3,opt,name=Address,proto3" json:"Address,omitempty"` Decimals uint32 `protobuf:"varint,4,opt,name=Decimals,proto3" json:"Decimals,omitempty"` TotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=TotalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"TotalSupply"` - LayerZeroChainId uint64 `protobuf:"varint,6,opt,name=LayerZeroChainId,proto3" json:"LayerZeroChainId,omitempty"` + LayerZeroChainID uint64 `protobuf:"varint,6,opt,name=LayerZeroChainID,proto3" json:"LayerZeroChainID,omitempty"` ExoCoreChainIndex uint64 `protobuf:"varint,7,opt,name=ExoCoreChainIndex,proto3" json:"ExoCoreChainIndex,omitempty"` AssetMetaInfo string `protobuf:"bytes,8,opt,name=AssetMetaInfo,proto3" json:"AssetMetaInfo,omitempty"` } @@ -316,9 +316,9 @@ func (m *ClientChainTokenInfo) GetDecimals() uint32 { return 0 } -func (m *ClientChainTokenInfo) GetLayerZeroChainId() uint64 { +func (m *ClientChainTokenInfo) GetLayerZeroChainID() uint64 { if m != nil { - return m.LayerZeroChainId + return m.LayerZeroChainID } return 0 } @@ -649,7 +649,7 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1094 bytes of a gzipped FileDescriptorProto + // 1096 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, 0x18, 0xf6, 0xda, 0xcd, 0xd7, 0x1b, 0xd2, 0x26, 0xd3, 0x50, 0x1c, 0x53, 0x9c, 0x68, 0xa9, 0x50, 0x14, 0x88, 0xad, 0x06, 0x51, 0x45, 0x11, 0x20, 0x39, 0x4e, 0x2b, 0x45, 0x34, 0x89, 0xb4, 0x0e, @@ -673,52 +673,52 @@ var fileDescriptor_b24e66e530cc30d1 = []byte{ 0x00, 0x26, 0x6e, 0xef, 0xb3, 0x22, 0xf3, 0x89, 0x8e, 0x5e, 0x25, 0xfb, 0xe9, 0x4b, 0x52, 0xb3, 0x53, 0x80, 0x6e, 0xc1, 0xb5, 0x3b, 0x0e, 0xc5, 0xae, 0x23, 0x5a, 0xeb, 0x84, 0x54, 0x97, 0x5d, 0x56, 0xa9, 0xaf, 0x10, 0x17, 0xb7, 0xd2, 0x03, 0xd2, 0xa4, 0x87, 0x14, 0xcd, 0xc1, 0xf8, 0x5d, - 0xdc, 0x22, 0xfe, 0x3d, 0xe2, 0xb3, 0x36, 0x9d, 0x41, 0x69, 0xd1, 0x81, 0x07, 0xbc, 0x4b, 0x8e, - 0x4d, 0xb1, 0x68, 0xfa, 0x64, 0xb3, 0xd5, 0x20, 0xe9, 0x21, 0xf5, 0x76, 0x11, 0x30, 0xd0, 0x2a, - 0x54, 0xab, 0x3e, 0xe1, 0xfc, 0x2e, 0xa1, 0xb6, 0xa8, 0xa5, 0x87, 0x67, 0x8c, 0xd9, 0x31, 0x2b, - 0x0a, 0x9a, 0xbf, 0x1a, 0xf0, 0x46, 0xa1, 0xd1, 0xe8, 0x6f, 0x62, 0xd3, 0x30, 0x14, 0x4e, 0xe9, - 0x88, 0x35, 0x14, 0x4d, 0x66, 0xa5, 0x57, 0x32, 0xa3, 0x02, 0xf3, 0x59, 0x12, 0x26, 0x43, 0x85, - 0xdf, 0x64, 0x75, 0xa2, 0x48, 0x22, 0xb8, 0x14, 0xe2, 0x27, 0x9f, 0xd1, 0x35, 0x18, 0x2c, 0xb5, - 0xbc, 0x32, 0x73, 0x35, 0x27, 0x7d, 0x0a, 0xc8, 0xe8, 0x57, 0x6e, 0x93, 0xd1, 0x47, 0x94, 0x81, - 0xe1, 0x15, 0x52, 0x71, 0x3c, 0xec, 0x72, 0xc9, 0x61, 0xcc, 0x3a, 0x3d, 0xa3, 0xaf, 0x61, 0x74, - 0x93, 0x09, 0xec, 0x96, 0x9a, 0x8d, 0x86, 0xab, 0x8a, 0xf7, 0xaa, 0xed, 0x1c, 0x76, 0xf8, 0x52, - 0xf5, 0xee, 0xda, 0x81, 0x43, 0xbd, 0x3a, 0x30, 0xa8, 0x7b, 0x70, 0x05, 0x9c, 0x96, 0x68, 0x58, - 0x95, 0x28, 0x02, 0x9a, 0x47, 0x06, 0x8c, 0x97, 0xd4, 0x8d, 0x21, 0x05, 0x32, 0xad, 0xdf, 0xc0, - 0x65, 0x79, 0x58, 0xc6, 0xdc, 0xa9, 0x48, 0xdb, 0x20, 0xc1, 0xa3, 0x0b, 0x8b, 0xb9, 0x8b, 0xaf, - 0x99, 0x5c, 0xb7, 0x42, 0x59, 0xe7, 0xfc, 0x21, 0x17, 0x90, 0x8e, 0x2a, 0x93, 0xa1, 0x2f, 0x8b, - 0x64, 0x1f, 0xb2, 0xdb, 0xc5, 0xaf, 0x79, 0x98, 0x82, 0x77, 0x02, 0x98, 0xf8, 0x25, 0x87, 0xda, - 0x2e, 0x91, 0x64, 0x36, 0xfc, 0x62, 0x0d, 0x53, 0x9b, 0x48, 0x3e, 0x3f, 0x19, 0xf0, 0xae, 0xb4, - 0x58, 0x21, 0x0d, 0xc6, 0x1d, 0xa1, 0x0c, 0x37, 0xfc, 0x2d, 0x2c, 0x5f, 0x85, 0xda, 0x44, 0xde, - 0x6e, 0x7d, 0xb9, 0xce, 0xe2, 0x04, 0x42, 0x3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 0x9b, 0xac, 0x4e, 0x14, 0x49, 0x04, 0x97, 0x42, 0xfc, 0xe4, 0x33, 0xba, 0x06, 0x83, + 0xa5, 0x96, 0x57, 0x66, 0xae, 0xe6, 0xa4, 0x4f, 0x01, 0x19, 0xfd, 0xca, 0x6d, 0x32, 0xfa, 0x88, + 0x32, 0x30, 0xbc, 0x42, 0x2a, 0x8e, 0x87, 0x5d, 0x2e, 0x39, 0x8c, 0x59, 0xa7, 0x67, 0xf4, 0x35, + 0x8c, 0x6e, 0x32, 0x81, 0xdd, 0x52, 0xb3, 0xd1, 0x70, 0x55, 0xf1, 0x5e, 0xb5, 0x9d, 0xc3, 0x0e, + 0x5f, 0xaa, 0xde, 0x5d, 0x3b, 0x70, 0xa8, 0x57, 0x07, 0x06, 0x75, 0x0f, 0xae, 0x80, 0xd3, 0x12, + 0x0d, 0xab, 0x12, 0x45, 0x40, 0xf3, 0xc8, 0x80, 0xf1, 0x92, 0xba, 0x31, 0xa4, 0x40, 0xa6, 0xf5, + 0x1b, 0xb8, 0x2c, 0x0f, 0xcb, 0x98, 0x3b, 0x15, 0x69, 0x1b, 0x24, 0x78, 0x74, 0x61, 0x31, 0x77, + 0xf1, 0x35, 0x93, 0xeb, 0x56, 0x28, 0xeb, 0x9c, 0x3f, 0xe4, 0x02, 0xd2, 0x51, 0x65, 0x32, 0xf4, + 0x65, 0x91, 0xec, 0x43, 0x76, 0xbb, 0xf8, 0x35, 0x0f, 0x53, 0xf0, 0x4e, 0x00, 0x13, 0xbf, 0xe4, + 0x50, 0xdb, 0x25, 0x92, 0xcc, 0x86, 0x5f, 0xac, 0x61, 0x6a, 0x13, 0xc9, 0xe7, 0x27, 0x03, 0xde, + 0x95, 0x16, 0x2b, 0xa4, 0xc1, 0xb8, 0x23, 0x94, 0xe1, 0x86, 0xbf, 0x85, 0xe5, 0xab, 0x50, 0x9b, + 0xc8, 0xdb, 0xad, 0x2f, 0xd7, 0x59, 0x9c, 0x40, 0xe8, 0x47, 0x03, 0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7, 0x83, 0x39, 0x99, 0x2c, 0x11, 0xa1, 0xc2, 0x87, + 0x2b, 0xf0, 0x51, 0x9c, 0x3a, 0x77, 0xf8, 0xcf, 0x7c, 0xf2, 0x9f, 0xcc, 0xda, 0xb4, 0x32, 0x03, + 0xf7, 0x4f, 0x0e, 0xe6, 0x8c, 0xe5, 0xaf, 0x9e, 0x1c, 0x65, 0x8d, 0xa7, 0x47, 0x59, 0xe3, 0xef, + 0xa3, 0xac, 0xf1, 0xf0, 0x38, 0x9b, 0x78, 0x7a, 0x9c, 0x4d, 0x3c, 0x3b, 0xce, 0x26, 0xee, 0x15, + 0x42, 0x23, 0xaa, 0xd7, 0xed, 0x75, 0x22, 0xf6, 0x98, 0x5f, 0xcf, 0xb7, 0x33, 0xb1, 0xdf, 0xf3, + 0xbb, 0x53, 0x4e, 0x70, 0x79, 0x50, 0x7e, 0xf7, 0x7d, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xe6, 0x8e, 0xd0, 0xcb, 0xa7, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -866,8 +866,8 @@ func (m *ClientChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - if m.LayerZeroChainId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.LayerZeroChainId)) + if m.LayerZeroChainID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.LayerZeroChainID)) i-- dAtA[i] = 0x30 } @@ -984,8 +984,8 @@ func (m *ClientChainTokenInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x38 } - if m.LayerZeroChainId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.LayerZeroChainId)) + if m.LayerZeroChainID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.LayerZeroChainID)) i-- dAtA[i] = 0x30 } @@ -1421,8 +1421,8 @@ func (m *ClientChainInfo) Size() (n int) { if m.FinalityNeedBlockDelay != 0 { n += 1 + sovTx(uint64(m.FinalityNeedBlockDelay)) } - if m.LayerZeroChainId != 0 { - n += 1 + sovTx(uint64(m.LayerZeroChainId)) + if m.LayerZeroChainID != 0 { + n += 1 + sovTx(uint64(m.LayerZeroChainID)) } l = len(m.SignatureType) if l > 0 { @@ -1481,8 +1481,8 @@ func (m *ClientChainTokenInfo) Size() (n int) { } l = m.TotalSupply.Size() n += 1 + l + sovTx(uint64(l)) - if m.LayerZeroChainId != 0 { - n += 1 + sovTx(uint64(m.LayerZeroChainId)) + if m.LayerZeroChainID != 0 { + n += 1 + sovTx(uint64(m.LayerZeroChainID)) } if m.ExoCoreChainIndex != 0 { n += 1 + sovTx(uint64(m.ExoCoreChainIndex)) @@ -1866,9 +1866,9 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LayerZeroChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LayerZeroChainID", wireType) } - m.LayerZeroChainId = 0 + m.LayerZeroChainID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1878,7 +1878,7 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LayerZeroChainId |= uint64(b&0x7F) << shift + m.LayerZeroChainID |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2300,9 +2300,9 @@ func (m *ClientChainTokenInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LayerZeroChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LayerZeroChainID", wireType) } - m.LayerZeroChainId = 0 + m.LayerZeroChainID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2312,7 +2312,7 @@ func (m *ClientChainTokenInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LayerZeroChainId |= uint64(b&0x7F) << shift + m.LayerZeroChainID |= uint64(b&0x7F) << shift if b < 0x80 { break } From d30c84f31e9b737d75825c68dbfadd44c40f91d8 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 6 Mar 2024 17:03:20 +0800 Subject: [PATCH 33/44] change recordId to recordID --- x/delegation/keeper/abci.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index d8251de40..b9f38fbdb 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -34,8 +34,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida continue }*/ - recordId := delegationtype.GetUndelegationRecordKey(record.LzTxNonce, record.TxHash, record.OperatorAddr) - if k.GetUndelegationHoldCount(ctx, recordId) > 0 { + recordID := delegationtype.GetUndelegationRecordKey(record.LzTxNonce, record.TxHash, record.OperatorAddr) + if k.GetUndelegationHoldCount(ctx, recordID) > 0 { // store it again with the next block and move on record.CompleteBlockNumber = uint64(ctx.BlockHeight()) + 1 // we need to store two things here: one is the updated record in itself From 79876188e30c864ed2ee89ae59dfbf2aeaaacb1c Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 6 Mar 2024 17:16:48 +0800 Subject: [PATCH 34/44] change stakeId to stakeID --- x/deposit/keeper/cross_chain_tx_process.go | 4 ++-- x/restaking_assets_manage/types/general.go | 8 ++++---- x/reward/keeper/claim_reward.go | 8 ++++---- x/slash/keeper/execute_slash.go | 8 ++++---- x/withdraw/keeper/claim_withdraw.go | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/x/deposit/keeper/cross_chain_tx_process.go b/x/deposit/keeper/cross_chain_tx_process.go index 6c16d55ec..67c3960c3 100644 --- a/x/deposit/keeper/cross_chain_tx_process.go +++ b/x/deposit/keeper/cross_chain_tx_process.go @@ -128,7 +128,7 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { if params.OpAmount.IsNegative() { return errorsmod.Wrap(despoittypes.ErrDepositAmountIsNegative, fmt.Sprintf("the amount is:%s", params.OpAmount)) } - stakeId, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) + stakeID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) // check if asset exist if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(despoittypes.ErrDepositAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) @@ -138,7 +138,7 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { CanWithdrawAmountOrWantChangeValue: params.OpAmount, } // update asset state of the specified staker - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } diff --git a/x/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go index 70477bee8..a9f6ea5a4 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/restaking_assets_manage/types/general.go @@ -42,10 +42,10 @@ const ( ) // GetStakeIDAndAssetID stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID -func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAddress []byte) (stakeId string, assetID string) { +func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAddress []byte) (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}, "_") } if assetsAddress != nil { @@ -55,10 +55,10 @@ func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAd } // GetStakeIDAndAssetIDFromStr stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID -func GetStakeIDAndAssetIDFromStr(clientChainLzID uint64, stakerAddress string, assetsAddress string) (stakeId string, assetID string) { +func GetStakeIDAndAssetIDFromStr(clientChainLzID uint64, stakerAddress string, assetsAddress string) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(clientChainLzID) if stakerAddress != "" { - stakeId = strings.Join([]string{strings.ToLower(stakerAddress), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{strings.ToLower(stakerAddress), clientChainLzIDStr}, "_") } if assetsAddress != "" { diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index 34b98061e..71867efbc 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -83,9 +83,9 @@ func getRewardParamsFromEventLog(log *ethtypes.Log) (*RewardParams, error) { }, nil } -func getStakeIDAndAssetID(params *RewardParams) (stakeId string, assetID string) { +func getStakeIDAndAssetID(params *RewardParams) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) - stakeId = strings.Join([]string{hexutil.Encode(params.WithdrawRewardAddress[:]), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(params.WithdrawRewardAddress[:]), clientChainLzIDStr}, "_") assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") return } @@ -129,7 +129,7 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { if event.OpAmount.IsNegative() { return errorsmod.Wrap(rtypes.ErrRewardAmountIsNegative, fmt.Sprintf("the amount is:%s", event.OpAmount)) } - stakeId, assetID := getStakeIDAndAssetID(event) + stakeID, assetID := getStakeIDAndAssetID(event) // check is asset exist if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(rtypes.ErrRewardAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) @@ -140,7 +140,7 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { TotalDepositAmountOrWantChangeValue: event.OpAmount, CanWithdrawAmountOrWantChangeValue: event.OpAmount, } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index d36ef63df..f125848e0 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -109,9 +109,9 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas }, nil } -func getStakeIDAndAssetID(params *SlashParams) (stakeId string, assetID string) { +func getStakeIDAndAssetID(params *SlashParams) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) - stakeId = strings.Join([]string{hexutil.Encode(params.StakerAddress[:]), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(params.StakerAddress[:]), clientChainLzIDStr}, "_") assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") return } @@ -179,7 +179,7 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { if event.OpAmount.IsNegative() { return errorsmod.Wrap(rtypes.ErrSlashAmountIsNegative, fmt.Sprintf("the amount is:%s", event.OpAmount)) } - stakeId, assetID := getStakeIDAndAssetID(event) + stakeID, assetID := getStakeIDAndAssetID(event) // check is asset exist if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(rtypes.ErrSlashAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) @@ -189,7 +189,7 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { TotalDepositAmountOrWantChangeValue: event.OpAmount.Neg(), CanWithdrawAmountOrWantChangeValue: event.OpAmount.Neg(), } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } diff --git a/x/withdraw/keeper/claim_withdraw.go b/x/withdraw/keeper/claim_withdraw.go index 80c8ed770..2c59da081 100644 --- a/x/withdraw/keeper/claim_withdraw.go +++ b/x/withdraw/keeper/claim_withdraw.go @@ -75,9 +75,9 @@ type WithdrawParams struct { // }, nil // } -func getStakeIDAndAssetID(params *WithdrawParams) (stakeId string, assetID string) { +func getStakeIDAndAssetID(params *WithdrawParams) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) - stakeId = strings.Join([]string{hexutil.Encode(params.WithdrawAddress[:]), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(params.WithdrawAddress[:]), clientChainLzIDStr}, "_") assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") return } @@ -122,7 +122,7 @@ func (k Keeper) Withdraw(ctx sdk.Context, params *WithdrawParams) error { if params.OpAmount.IsNegative() { return errorsmod.Wrap(withdrawtype.ErrWithdrawAmountIsNegative, fmt.Sprintf("the amount is:%s", params.OpAmount)) } - stakeId, assetID := getStakeIDAndAssetID(params) + stakeID, assetID := getStakeIDAndAssetID(params) // check if asset exist if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { @@ -132,7 +132,7 @@ func (k Keeper) Withdraw(ctx sdk.Context, params *WithdrawParams) error { TotalDepositAmountOrWantChangeValue: params.OpAmount.Neg(), CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeId, assetID, changeAmount) + err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } From 99522407704d35ded3f2739c09376029680c9b60 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 6 Mar 2024 17:53:33 +0800 Subject: [PATCH 35/44] fix super lint error update the dependency version of protobuf to eliminate vulnerability fix the lint error about gosec and vulncheck fix the lint error about proto-lint --- .github/workflows/security.yml | 4 +- app/app.go | 5 +- app/test_helpers.go | 5 +- go.mod | 34 +- go.sum | 65 +- local_node.sh | 4 +- precompiles/delegation/delegation_test.go | 3 +- precompiles/delegation/setup_test.go | 3 +- precompiles/deposit/setup_test.go | 3 +- precompiles/reward/setup_test.go | 3 +- precompiles/slash/setup_test.go | 3 +- precompiles/withdraw/setup_test.go | 3 +- proto/exocore/delegation/v1/query.proto | 16 +- proto/exocore/delegation/v1/tx.proto | 2 - proto/exocore/operator/v1/query.proto | 24 +- proto/exocore/operator/v1/tx.proto | 129 ++- .../restaking_assets_manage/v1/tx.proto | 52 +- testutil/utils.go | 8 +- x/delegation/client/cli/tx.go | 2 +- x/delegation/keeper/abci.go | 18 +- x/delegation/keeper/cross_chain_tx_process.go | 28 +- x/delegation/keeper/delegation_op_test.go | 28 +- x/delegation/keeper/delegation_state.go | 26 +- x/delegation/keeper/keeper.go | 2 +- x/delegation/keeper/msg_server.go | 4 +- x/delegation/keeper/setup_test.go | 3 +- x/delegation/types/expected_keepers.go | 10 +- x/delegation/types/keys.go | 3 +- x/delegation/types/query.pb.go | 187 ++-- x/delegation/types/tx.pb.go | 187 ++-- x/deposit/keeper/setup_test.go | 3 +- x/operator/keeper/abci.go | 20 +- x/operator/keeper/avs_operator_shares.go | 94 +- x/operator/keeper/common_func.go | 2 + x/operator/keeper/dogfood.go | 186 ++-- x/operator/keeper/grpc_query.go | 12 +- x/operator/keeper/keeper.go | 7 +- x/operator/keeper/msg_server.go | 23 +- x/operator/keeper/operator.go | 12 +- x/operator/keeper/operator_info_test.go | 2 +- x/operator/keeper/operator_slash_state.go | 22 +- x/operator/keeper/setup_test.go | 5 +- x/operator/keeper/state_update.go | 190 ++-- x/operator/keeper/state_update_test.go | 26 +- x/operator/module.go | 11 +- x/operator/types/app_chain_utils.go | 15 +- x/operator/types/codec.go | 13 +- x/operator/types/expected_keepers.go | 22 +- x/operator/types/hooks.go | 12 +- x/operator/types/keys.go | 63 +- x/operator/types/msg.go | 12 +- x/operator/types/query.pb.go | 206 +++-- x/operator/types/query.pb.gw.go | 28 +- x/operator/types/tx.pb.go | 848 +++++++++-------- x/restaking_assets_manage/keeper/app_chain.go | 14 +- .../keeper/grpc_query.go | 4 +- .../keeper/operator_asset.go | 10 +- .../keeper/setup_test.go | 3 +- .../keeper/staker_asset.go | 2 +- x/restaking_assets_manage/types/general.go | 10 +- x/restaking_assets_manage/types/keys.go | 3 +- x/restaking_assets_manage/types/tx.pb.go | 867 +++++++++++++++--- x/reward/keeper/claim_reward.go | 6 +- x/reward/keeper/setup_test.go | 3 +- x/slash/keeper/execute_slash.go | 4 +- x/slash/keeper/setup_test.go | 3 +- x/withdraw/keeper/claim_withdraw.go | 4 +- x/withdraw/keeper/setup_test.go | 3 +- 68 files changed, 2177 insertions(+), 1457 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 54ceec5c7..59d3adebd 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -29,7 +29,9 @@ jobs: uses: cosmos/gosec@master with: # we let the report trigger content trigger a failure using the GitHub Security features. - args: "-no-fail -fmt sarif -out results.sarif ./..." + # exclude G705 as it is almost always a false positive, it is removed from gosec master + # but the action has not been updated to reflect the change. + args: "-exclude G705 -no-fail -fmt sarif -out results.sarif ./..." if: "env.GIT_DIFF_FILTERED != ''" - name: Upload SARIF file uses: github/codeql-action/upload-sarif@v2 diff --git a/app/app.go b/app/app.go index f97ce2999..e91c77e0f 100644 --- a/app/app.go +++ b/app/app.go @@ -4,14 +4,15 @@ import ( "context" "encoding/json" "fmt" - "github.com/ExocoreNetwork/exocore/x/operator" - operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" "io" "net/http" "os" "path/filepath" "sort" + "github.com/ExocoreNetwork/exocore/x/operator" + operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" + exoslash "github.com/ExocoreNetwork/exocore/x/slash" slashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" diff --git a/app/test_helpers.go b/app/test_helpers.go index 150ad9914..54de19660 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -2,10 +2,11 @@ package app import ( "encoding/json" - pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "os" "time" + pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" + "cosmossdk.io/simapp" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" @@ -221,7 +222,7 @@ func SetupTestingApp(chainID string, pruneOpts *pruningtypes.PruningOptions, isP map[int64]bool{}, DefaultNodeHome, 5, cfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), - baseAppOptions[:]..., + baseAppOptions..., ) return app, NewDefaultGenesisState(app.appCodec) } diff --git a/go.mod b/go.mod index be0eb43af..ff463418a 100644 --- a/go.mod +++ b/go.mod @@ -17,11 +17,11 @@ require ( github.com/cosmos/ibc-go/v7 v7.2.1-0.20230829085526-4d114bd09096 github.com/ethereum/go-ethereum v1.11.5 github.com/evmos/evmos/v14 v14.0.0-rc4 - github.com/golang/protobuf v1.5.3 + github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/onsi/ginkgo/v2 v2.11.0 - github.com/onsi/gomega v1.27.10 + github.com/onsi/ginkgo/v2 v2.15.0 + github.com/onsi/gomega v1.31.1 github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.5.1 @@ -29,10 +29,13 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 - golang.org/x/crypto v0.12.0 + golang.org/x/crypto v0.21.0 golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e google.golang.org/grpc v1.57.1 + google.golang.org/protobuf v1.33.0 + gopkg.in/yaml.v2 v2.4.0 sigs.k8s.io/yaml v1.3.0 ) @@ -49,7 +52,7 @@ require ( github.com/rs/cors v1.9.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/zondax/hid v0.9.1 // indirect - golang.org/x/net v0.14.0 // indirect + golang.org/x/net v0.22.0 // indirect ) require ( @@ -105,7 +108,7 @@ require ( github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.3.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-stack/stack v1.8.1 // indirect @@ -116,11 +119,11 @@ require ( github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect @@ -144,7 +147,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.16.7 // indirect - github.com/lib/pq v1.10.7 // indirect + github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/linxGnu/grocksdb v1.7.16 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -191,20 +194,17 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.10.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.19.0 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 // indirect - google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.7 // indirect pgregory.net/rapid v0.5.5 // indirect diff --git a/go.sum b/go.sum index d33d5c4a7..bb081e135 100644 --- a/go.sum +++ b/go.sum @@ -786,8 +786,6 @@ github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:Htrtb github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= -github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/dvsekhvalnov/jose2go v1.5.1-0.20231206184617-48ba0b76bc88 h1:y87odSHhV8WSSnjuFYC+K2V6LpZtEVcjmVWxtUkXZiQ= github.com/dvsekhvalnov/jose2go v1.5.1-0.20231206184617-48ba0b76bc88/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= @@ -862,8 +860,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -949,8 +947,9 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -975,8 +974,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -1012,8 +1012,9 @@ github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -1188,8 +1189,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -1283,14 +1284,14 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= +github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -1579,8 +1580,8 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= @@ -1620,8 +1621,8 @@ golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1695,8 +1696,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1744,8 +1745,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1857,8 +1858,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1869,8 +1870,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1887,8 +1888,8 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1964,8 +1965,8 @@ golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= -golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2232,8 +2233,6 @@ google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsA google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= -google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg= google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2253,8 +2252,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/local_node.sh b/local_node.sh index e8e7ed2c7..7b3848b75 100755 --- a/local_node.sh +++ b/local_node.sh @@ -141,8 +141,8 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # set custom pruning settings sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML" - sed -i.bak 's/pruning-keep-recent = "0"/pruning-keep-recent = "100"/g' "$APP_TOML" - sed -i.bak 's/pruning-interval = "0"/pruning-interval = "500"/g' "$APP_TOML" + sed -i.bak 's/pruning-keep-recent = "0"/pruning-keep-recent = "2"/g' "$APP_TOML" + sed -i.bak 's/pruning-interval = "0"/pruning-interval = "10"/g' "$APP_TOML" # make sure the localhost IP is 0.0.0.0 sed -i.bak 's/localhost/0.0.0.0/g' "$CONFIG" diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 971941845..4b8254ef8 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -1,10 +1,11 @@ package delegation_test import ( - operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "math/big" "strings" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" diff --git a/precompiles/delegation/setup_test.go b/precompiles/delegation/setup_test.go index b5bec0e9b..4f6fe37f2 100644 --- a/precompiles/delegation/setup_test.go +++ b/precompiles/delegation/setup_test.go @@ -1,9 +1,10 @@ package delegation_test import ( + "testing" + "github.com/ExocoreNetwork/exocore/precompiles/delegation" "github.com/ExocoreNetwork/exocore/testutil" - "testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/precompiles/deposit/setup_test.go b/precompiles/deposit/setup_test.go index a489fe03d..4880ccdc5 100644 --- a/precompiles/deposit/setup_test.go +++ b/precompiles/deposit/setup_test.go @@ -1,9 +1,10 @@ package deposit_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + "github.com/ExocoreNetwork/exocore/precompiles/deposit" . "github.com/onsi/ginkgo/v2" diff --git a/precompiles/reward/setup_test.go b/precompiles/reward/setup_test.go index 9b444815e..74e70a08b 100644 --- a/precompiles/reward/setup_test.go +++ b/precompiles/reward/setup_test.go @@ -1,9 +1,10 @@ package reward_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + "github.com/ExocoreNetwork/exocore/precompiles/reward" . "github.com/onsi/ginkgo/v2" diff --git a/precompiles/slash/setup_test.go b/precompiles/slash/setup_test.go index dcae7c8ee..8ddec306f 100644 --- a/precompiles/slash/setup_test.go +++ b/precompiles/slash/setup_test.go @@ -1,9 +1,10 @@ package slash_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + "github.com/ExocoreNetwork/exocore/precompiles/slash" . "github.com/onsi/ginkgo/v2" diff --git a/precompiles/withdraw/setup_test.go b/precompiles/withdraw/setup_test.go index 259b6c0b5..5a79fd128 100644 --- a/precompiles/withdraw/setup_test.go +++ b/precompiles/withdraw/setup_test.go @@ -1,9 +1,10 @@ package withdraw_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + "github.com/ExocoreNetwork/exocore/precompiles/withdraw" . "github.com/onsi/ginkgo/v2" diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index 4d4316f8d..67b285795 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -3,7 +3,6 @@ package exocore.delegation.v1; import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; -import "exocore/delegation/v1/tx.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; @@ -20,8 +19,8 @@ message DelegationInfoReq { // DelegationAmounts is the delegation amount response for a single delegation. message DelegationAmounts { - // can_undelegation_amount is the amount that can be undelegated. - string can_undelegation_amount = 1 + // can_be_undelegated_amount is the amount that can be undelegated. + string can_be_undelegated_amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -34,6 +33,13 @@ message DelegationAmounts { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; + // can_be_undelegated_after_slash is the amount that can be undelegated after slash + string can_be_undelegated_after_slash = 3 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } // QueryDelegationInfoResponse is the response for delegations by staker id and @@ -69,10 +75,6 @@ message QueryOperatorInfoReq { // Query is the service API for the delegation module. service Query { - // OperatorInfo queries the operator information. - rpc QueryOperatorInfo(QueryOperatorInfoReq) returns (OperatorInfo) { - option (google.api.http).get = "/exocore/delegation/v1/GetOperatorInfo"; - } // DelegationInfo queries the delegation information for {stakerID, assetID}. rpc QueryDelegationInfo(DelegationInfoReq) returns (QueryDelegationInfoResponse) { option (cosmos.query.v1.module_query_safe) = true; diff --git a/proto/exocore/delegation/v1/tx.proto b/proto/exocore/delegation/v1/tx.proto index d5b6c4e2a..b4cdb98c9 100644 --- a/proto/exocore/delegation/v1/tx.proto +++ b/proto/exocore/delegation/v1/tx.proto @@ -166,8 +166,6 @@ message UndelegationResponse {} // Msg defines the delegation Msg service. service Msg { option (cosmos.msg.v1.service) = true; - // RegisterOperator registers a new operator. - rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); // DelegateAssetToOperator delegates asset to operator. rpc DelegateAssetToOperator(MsgDelegation) returns (DelegationResponse); // UndelegateAssetFromOperator undelegates asset from operator. diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index a638aafda..02003a85b 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -1,36 +1,44 @@ syntax = "proto3"; package exocore.operator.v1; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; import "exocore/operator/v1/tx.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; import "tendermint/crypto/keys.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; +// QueryOperatorInfoReq is the request to obtain the operator information. message GetOperatorInfoReq { - string OperatorAddr = 1 + // operator_addr is the operator address. + string operator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -message QueryOperatorConsKeyForChainIdRequest { +// QueryOperatorConsKeyRequest is the request to obtain the consensus public key of the operator +message QueryOperatorConsKeyRequest { + // addr is the ACC address of operator string addr = 1; + // chain_id is the id of the chain served by the operator string chain_id = 2; } -message QueryOperatorConsKeyForChainIdResponse { +// QueryOperatorConsKeyResponse is the response for QueryOperatorConsKeyForChainID +message QueryOperatorConsKeyResponse { + // public_key is the consensus public key of the operator tendermint.crypto.PublicKey public_key = 1 [ (gogoproto.nullable) = false ]; } +// Query defines the gRPC querier service. service Query { + // OperatorInfo queries the operator information. rpc GetOperatorInfo(GetOperatorInfoReq) returns(OperatorInfo){ option (google.api.http).get = "/exocore/delegation/v1/GetOperatorInfo"; } - // add services for dogfood - rpc QueryOperatorConsKeyForChainId(QueryOperatorConsKeyForChainIdRequest) returns (QueryOperatorConsKeyForChainIdResponse) { + // QueryOperatorConsKeyForChainID queries the consensus public key for the operator + rpc QueryOperatorConsKeyForChainID(QueryOperatorConsKeyRequest) returns (QueryOperatorConsKeyResponse) { option (google.api.http) = { get: "/exocore/operator_consent/v1/GetOperatorConsKey/{addr}/{chain_id}" }; diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 3be495ba4..3b05cfb00 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -1,53 +1,71 @@ syntax = "proto3"; package exocore.operator.v1; +import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "amino/amino.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; -message clientChainEarningAddrList { - repeated clientChainEarningAddrInfo EarningInfoList = 1; +// DecValueField is a field that holds a value of sdk.LegacyDec type. +message DecValueField { + // amount is the USD value of the asset, as an sdk.LegacyDec. + string amount = 1 + [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// ClientChainEarningAddrList is the list of client chain earning addresses. +message ClientChainEarningAddrList { + // earning_info_list is the contents of ClientChainEarningAddrList. + repeated ClientChainEarningAddrInfo earning_info_list = 1; } -message clientChainEarningAddrInfo { - uint64 lzClientChainID = 1; - string clientChainEarningAddr = 2; +// ClientChainEarningAddrInfo is the client chain earning address info. +message ClientChainEarningAddrInfo { + // lz_client_chain_id is the layer0 client chain id. + uint64 lz_client_chain_id = 1 [(gogoproto.customname) = "LzClientChainID"]; + // client_chain_earning_addr is the client chain earning address. + string client_chain_earning_addr = 2; } -message OperatorInfo{ - string EarningsAddr = 1; - string ApproveAddr = 2; - string OperatorMetaInfo = 3; - clientChainEarningAddrList ClientChainEarningsAddr = 4; +// OperatorInfo is the operator info. +message OperatorInfo { + // earnings_addr is the earnings address. + string earnings_addr = 1; + // approve_addr is the approve address. + string approve_addr = 2; + // operator_meta_info is the operator meta info. + string operator_meta_info = 3; + // client_chain_earning_addr_list is the client chain earning address list. + ClientChainEarningAddrList client_chain_earnings_addr = 4; } +// OptedInfo is the opted information about operator message OptedInfo { - string SlashContract = 1; - uint64 OptedInHeight = 2; - uint64 OptedOutHeight = 3; + // slash_contract is the slash contract address of AVS opted-in by the operator + string slash_contract = 1; + // opted_in_height is the height at which the operator opted in + uint64 opted_in_height = 2; + // opted_out_height is the height at which the operator opted out + uint64 opted_out_height = 3; } -message AssetOptedInState{ - string Amount = 1 +// OptedInAssetState is the state of opted-in asset +message OptedInAssetState{ + // amount of the opted-in asset + string amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - - string Value = 2 - [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -message ValueField { - string Amount = 1 + // value is the USD value of the opted-in asset + string value = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", @@ -55,13 +73,20 @@ message ValueField { ]; } +// OperatorSlashInfo is the slash info of operator message OperatorSlashInfo { - string SlashContract = 1; - int64 SlashHeight = 2; - int64 OccurredHeight = 3; - int64 ExecuteHeight = 4; - bool IsVeto = 5; - string SlashProportion = 6 + // slash_contract is the address of slash contract + string slash_contract = 1; + // slash_height is the height at which the slash event is submitted + int64 slash_height = 2; + // occurred_height is the height at which the slash event occurs + int64 occurred_height = 3; + // execute_height is the height at which the slash event is executed + int64 execute_height = 4; + // is_veto is a flag to indicate if this slash is vetoed + bool is_veto = 5; + // slash_proportion is the proportion of assets that need to be slashed + string slash_proportion = 6 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", @@ -69,23 +94,29 @@ message OperatorSlashInfo { ]; } +// RegisterOperatorReq is the request to register a new operator. message RegisterOperatorReq { option (cosmos.msg.v1.signer) = "FromAddress"; option (amino.name) = "cosmos-sdk/OperatorInfo"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string FromAddress = 1 + // from_address is the address of the operator (sdk.AccAddress). + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // info is the operator info. OperatorInfo info = 2; } +// RegisterOperatorResponse is the response to a register operator request. message RegisterOperatorResponse{} -// OptInToChainIdRequest defines the OptInToChainId request. -message OptInToChainIdRequest { +// OptInToChainIDRequest defines the OptInToChainID request. +message OptInToChainIDRequest { option (cosmos.msg.v1.signer) = "address"; + // address is the operator address string address = 1; + // chain_id is the identifier for the chain that wants to opt in. string chain_id = 2; // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` // there is no need to check for knowledge of the corresponding private key since this is ED25519 @@ -94,38 +125,40 @@ message OptInToChainIdRequest { string public_key = 3; } -// OptInToChainIdResponse defines the OptInToChainId response. -message OptInToChainIdResponse { +// OptInToChainIDResponse defines the OptInToChainID response. +message OptInToChainIDResponse { } -// InitiateOptOutFromChainIdRequest defines the InitiateOptOutFromChainId request. -message InitiateOptOutFromChainIdRequest { +// InitiateOptOutFromChainIDRequest defines the InitiateOptOutFromChainID request. +message InitiateOptOutFromChainIDRequest { option (cosmos.msg.v1.signer) = "address"; + // address is the operator address string address = 1; + // chain_id is the identifier for the chain that wants to opt out. string chain_id = 2; } -// InitiateOptOutFromChainIdResponse defines the InitiateOptOutFromChainId response. -message InitiateOptOutFromChainIdResponse { +// InitiateOptOutFromChainIDResponse defines the InitiateOptOutFromChainID response. +message InitiateOptOutFromChainIDResponse { } -// Msg defines the delegation Msg service. +// Msg defines the operator Msg service. service Msg { option (cosmos.msg.v1.service) = true; - // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. + // RegisterOperator registers a new operator. rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); // add services for dogfood - // OptInToChainId acts as opt in method for an operator to + // OptInToChainID acts as opt in method for an operator to // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. - rpc OptInToChainId(OptInToChainIdRequest) returns (OptInToChainIdResponse) {}; - // InitiateOptOutFromChainId is a method with which an operator can initiate + rpc OptInToChainID(OptInToChainIDRequest) returns (OptInToChainIDResponse) {}; + // InitiateOptOutFromChainID is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - rpc InitiateOptOutFromChainId(InitiateOptOutFromChainIdRequest) returns (InitiateOptOutFromChainIdResponse) {}; + rpc InitiateOptOutFromChainID(InitiateOptOutFromChainIDRequest) returns (InitiateOptOutFromChainIDResponse) {}; } diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/restaking_assets_manage/v1/tx.proto index 49eb87d8f..c32404809 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/restaking_assets_manage/v1/tx.proto @@ -8,6 +8,17 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; +// ValueField is a field that holds a value of sdk.Int type. +message ValueField { + // amount is the amount of the asset, as an sdk.Int. + string amount = 1 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + // ClientChainInfo defines the client chain information. message ClientChainInfo { // name of the client chain, like "Ethereum". @@ -29,6 +40,20 @@ message ClientChainInfo { uint32 address_length = 8; } +// AppChainInfo is used to store information related to the subscriber app chains we validate. +// The information stored within this module consists only of the chain's identifiers. +// The validation-related information is stored in the coordinator module. +message AppChainInfo { + // name of the chain, for example "ethereum" + string name = 1; + // meta_info is at Exocore's discretion to deter,ome + string meta_info = 2; + // chain_id is used as the primary key + string chain_id = 3; + // exo_core_chain_index is the index of the chain in exocore, so far unused + uint64 exo_core_chain_index = 4; +} + // AssetInfo defines the information for an asset to be used in staking. message AssetInfo { // name of the asset, like "Tether USD" @@ -88,9 +113,9 @@ message StakerSingleAssetOrChangeInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // wait_undelegation_amount_or_want_change_value is the amount that is waiting for undelegation + // wait_unbonding_amount_or_want_change_value is the amount that is waiting for undelegation // or the amount by which it can change. - string wait_undelegation_amount_or_want_change_value = 3 + string wait_unbonding_amount_or_want_change_value = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -116,6 +141,7 @@ message OperatorSingleAssetOrChangeInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; + // operator_own_amount_or_want_change_value is the amount that the operator owns // or the amount by which it can change. //todo: the field is used to mark operator's own assets and is not temporarily used now @@ -125,9 +151,27 @@ message OperatorSingleAssetOrChangeInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // wait_undelegation_amount_or_want_change_value is the amount that is waiting for undelegation + // wait_unbonding_amount_or_want_change_value is the amount that is waiting for unbonding // or the amount by which it can change. - string wait_undelegation_amount_or_want_change_value = 3 + string wait_unbonding_amount_or_want_change_value = 3 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // operator_own_wait_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding + // or the amount by which it can change + string operator_own_wait_unbonding_amount = 4 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + + // operator_can_unbond_after_slash is the amount that is owned by operator itself and can be unbonded after slash + // or the amount by which it can change + string operator_can_unbond_after_slash = 5 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/testutil/utils.go b/testutil/utils.go index 1ddbf5e4a..02ab7135e 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -2,6 +2,8 @@ package testutil import ( "encoding/json" + "time" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -9,7 +11,6 @@ import ( "github.com/evmos/evmos/v14/testutil" "github.com/stretchr/testify/suite" "golang.org/x/exp/rand" - "time" testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" @@ -50,7 +51,7 @@ type BaseTestSuite struct { StateDB *statedb.StateDB QueryClientEVM evmtypes.QueryClient - //needed by test + // needed by test /* operatorAddr sdk.AccAddress avsAddr string assetID string @@ -187,7 +188,8 @@ func (suite *BaseTestSuite) DoSetupTest() { // create AccAddress for test pubBz := make([]byte, ed25519.PubKeySize) pub := &ed25519.PubKey{Key: pubBz} - rand.Read(pub.Key) + _, err = rand.Read(pub.Key) + suite.Require().NoError(err) suite.AccAddress = sdk.AccAddress(pub.Address()) // generate genesis account diff --git a/x/delegation/client/cli/tx.go b/x/delegation/client/cli/tx.go index 951a4341b..3e8854a55 100644 --- a/x/delegation/client/cli/tx.go +++ b/x/delegation/client/cli/tx.go @@ -18,7 +18,7 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - //add tx commands + // add tx commands ) return txCmd } diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index b9f38fbdb..95f006d92 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -20,7 +20,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida for _, record := range records { // check if the operator has been slashed or frozen operatorAccAddress := sdk.MustAccAddressFromBech32(record.OperatorAddr) - //todo: don't think about freezing the operator in current implementation + // todo: don't think about freezing the operator in current implementation /* if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { // reSet the completed height if the operator is frozen record.CompleteBlockNumber = k.expectedOperatorInterface.GetUnbondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) @@ -37,6 +37,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida recordID := delegationtype.GetUndelegationRecordKey(record.LzTxNonce, record.TxHash, record.OperatorAddr) if k.GetUndelegationHoldCount(ctx, recordID) > 0 { // store it again with the next block and move on + // #nosec G701 record.CompleteBlockNumber = uint64(ctx.BlockHeight()) + 1 // we need to store two things here: one is the updated record in itself recordKey, err := k.SetSingleUndelegationRecord(ctx, record) @@ -44,7 +45,10 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida panic(err) } // and the other is the fact that it matures at the next block - k.StoreWaitCompleteRecord(ctx, recordKey, record) + err = k.StoreWaitCompleteRecord(ctx, recordKey, record) + if err != nil { + panic(err) + } continue } // operator opt out: since operators can not immediately withdraw their funds, that is, @@ -55,13 +59,13 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // the operator is still active on. the same applies to delegators too. // TODO(mike): ensure that operator is required to perform self delegation to match above. - //calculate the actual canUndelegated asset amount + // calculate the actual canUndelegated asset amount delegationInfo, err := k.GetSingleDelegationInfo(ctx, record.StakerID, record.AssetID, record.OperatorAddr) if err != nil { panic(err) } - if record.Amount.GT(delegationInfo.UndelegatableAmountAfterSlash) { - record.ActualCompletedAmount = delegationInfo.UndelegatableAmountAfterSlash + if record.Amount.GT(delegationInfo.CanBeUndelegatedAfterSlash) { + record.ActualCompletedAmount = delegationInfo.CanBeUndelegatedAfterSlash } else { record.ActualCompletedAmount = record.Amount } @@ -70,8 +74,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[record.OperatorAddr] = &delegationtype.DelegationAmounts{ - WaitUndelegationAmount: recordAmountNeg, - UndelegatableAmountAfterSlash: record.ActualCompletedAmount.Neg(), + WaitUndelegationAmount: recordAmountNeg, + CanBeUndelegatedAfterSlash: record.ActualCompletedAmount.Neg(), } err = k.UpdateDelegationState(ctx, record.StakerID, record.AssetID, delegatorAndAmount) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index d373aee63..996ebda08 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -20,7 +20,7 @@ type DelegationOrUndelegationParams struct { OpAmount sdkmath.Int LzNonce uint64 TxHash common.Hash - //todo: The operator approved signature might be needed here in future + // todo: The operator approved signature might be needed here in future } // The event hook process has been deprecated, now we use precompile contract to trigger the calls. @@ -120,16 +120,16 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return delegationtype.ErrOperatorIsFrozen } - //todo: The operator approved signature might be needed here in future + // todo: The operator approved signature might be needed here in future - //update the related states + // update the related states if params.OpAmount.IsNegative() { return delegationtype.ErrOpAmountIsNegative } stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) - //check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount + // check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount info, err := k.restakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return err @@ -139,7 +139,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return errorsmod.Wrap(delegationtype.ErrDelegationAmountTooBig, fmt.Sprintf("the opAmount is:%s the canWithdraw amount is:%s", params.OpAmount, info.CanWithdrawAmountOrWantChangeValue)) } - //update staker asset state + // update staker asset state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), }) @@ -156,7 +156,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegationAmount: params.OpAmount, + CanBeUndelegatedAmount: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -194,11 +194,11 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio if err != nil { return err } - if params.OpAmount.GT(delegationState.CanUndelegationAmount) { - return errorsmod.Wrap(delegationtype.ErrUndelegationAmountTooBig, fmt.Sprintf("UndelegationAmount:%s,CanUndelegationAmount:%s", params.OpAmount, delegationState.CanUndelegationAmount)) + if params.OpAmount.GT(delegationState.CanBeUndelegatedAmount) { + return errorsmod.Wrap(delegationtype.ErrUndelegationAmountTooBig, fmt.Sprintf("UndelegationAmount:%s,CanBeUndelegatedAmount:%s", params.OpAmount, delegationState.CanBeUndelegatedAmount)) } - //record Undelegation event + // record Undelegation event r := &delegationtype.UndelegationRecord{ StakerID: stakerID, AssetID: assetID, @@ -216,12 +216,12 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio return err } - //update delegation state + // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegationAmount: params.OpAmount.Neg(), - WaitUndelegationAmount: params.OpAmount, - UndelegatableAmountAfterSlash: params.OpAmount, + CanBeUndelegatedAmount: params.OpAmount.Neg(), + WaitUndelegationAmount: params.OpAmount, + CanBeUndelegatedAfterSlash: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -232,7 +232,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio return err } - //update staker and operator assets state + // update staker and operator assets state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ WaitUnbondingAmountOrWantChangeValue: params.OpAmount, }) diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 1fd155bff..f0c9a5ace 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -1,9 +1,11 @@ package keeper_test import ( + "fmt" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "fmt" + keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" @@ -72,15 +74,15 @@ func (suite *DelegationTestSuite) TestDelegateTo() { OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), - OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), + OperatorCanUnbondAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanUndelegationAmount: delegationParams.OpAmount, - WaitUndelegationAmount: sdkmath.NewInt(0), - UndelegatableAmountAfterSlash: sdkmath.NewInt(0), + CanBeUndelegatedAmount: delegationParams.OpAmount, + WaitUndelegationAmount: sdkmath.NewInt(0), + CanBeUndelegatedAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) @@ -148,15 +150,15 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), - OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), + OperatorCanUnbondAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: delegationEvent.OpAmount, - UndelegatableAmountAfterSlash: delegationEvent.OpAmount, + CanBeUndelegatedAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: delegationEvent.OpAmount, + CanBeUndelegatedAfterSlash: delegationEvent.OpAmount, }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) @@ -253,15 +255,15 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), - OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), + OperatorCanUnbondAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), - UndelegatableAmountAfterSlash: sdkmath.NewInt(0), + CanBeUndelegatedAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + CanBeUndelegatedAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index ba353d5b5..964415386 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -45,10 +45,10 @@ func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerID string isExit := store.Has(prefixKey) if !isExit { return sdkmath.Int{}, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerDelegationTotalAmount: key is %s", prefixKey)) - } else { - value := store.Get(prefixKey) - k.cdc.MustUnmarshal(value, &ret) } + value := store.Get(prefixKey) + k.cdc.MustUnmarshal(value, &ret) + return ret.Amount, nil } @@ -56,25 +56,25 @@ func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerID string // Compared to `UpdateStakerDelegationTotalAmount`,they use the same kv store, but in this function the store key needs to add the operator address as a suffix. func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) - //todo: think about the difference between init and update in future + // todo: think about the difference between init and update in future for opAddr, amounts := range delegationAmounts { if amounts == nil { continue } - if amounts.CanUndelegationAmount.IsNil() && amounts.WaitUndelegationAmount.IsNil() { + if amounts.CanBeUndelegatedAmount.IsNil() && amounts.WaitUndelegationAmount.IsNil() { continue } - //check operator address validation + // check operator address validation _, err := sdk.AccAddressFromBech32(opAddr) if err != nil { return delegationtype.OperatorAddrIsNotAccAddr } singleStateKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID, opAddr) delegationState := delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), - UndelegatableAmountAfterSlash: sdkmath.NewInt(0), + CanBeUndelegatedAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + CanBeUndelegatedAfterSlash: sdkmath.NewInt(0), } if store.Has(singleStateKey) { @@ -82,9 +82,9 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID k.cdc.MustUnmarshal(value, &delegationState) } - err = stakingtypes.UpdateAssetValue(&delegationState.CanUndelegationAmount, &amounts.CanUndelegationAmount) + err = stakingtypes.UpdateAssetValue(&delegationState.CanBeUndelegatedAmount, &amounts.CanBeUndelegatedAmount) if err != nil { - return errorsmod.Wrap(err, "UpdateDelegationState CanUndelegationAmount error") + return errorsmod.Wrap(err, "UpdateDelegationState CanBeUndelegatedAmount error") } err = stakingtypes.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) @@ -92,12 +92,12 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } - err = stakingtypes.UpdateAssetValue(&delegationState.UndelegatableAmountAfterSlash, &amounts.UndelegatableAmountAfterSlash) + err = stakingtypes.UpdateAssetValue(&delegationState.CanBeUndelegatedAfterSlash, &amounts.CanBeUndelegatedAfterSlash) if err != nil { return errorsmod.Wrap(err, "UpdateDelegationState CanUsedToUndelegateAmount error") } - //save single operator delegation state + // save single operator delegation state bz := k.cdc.MustMarshal(&delegationState) store.Set(singleStateKey, bz) } diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 35eb12be1..46cfff188 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -18,7 +18,7 @@ type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec - //other keepers + // other keepers restakingStateKeeper keeper.Keeper depositKeeper depositkeeper.Keeper slashKeeper delegationtype.ISlashKeeper diff --git a/x/delegation/keeper/msg_server.go b/x/delegation/keeper/msg_server.go index e625c8ed6..f63ceca81 100644 --- a/x/delegation/keeper/msg_server.go +++ b/x/delegation/keeper/msg_server.go @@ -10,10 +10,10 @@ import ( var _ types.MsgServer = &Keeper{} // DelegateAssetToOperator todo: Delegation and Undelegation from exoCore chain directly will be implemented in future.At the moment,they are executed from client chain -func (k *Keeper) DelegateAssetToOperator(ctx context.Context, delegation *types.MsgDelegation) (*types.DelegationResponse, error) { +func (k *Keeper) DelegateAssetToOperator(_ context.Context, _ *types.MsgDelegation) (*types.DelegationResponse, error) { return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:DelegateAssetToOperator") } -func (k *Keeper) UndelegateAssetFromOperator(ctx context.Context, delegation *types.MsgUndelegation) (*types.UndelegationResponse, error) { +func (k *Keeper) UndelegateAssetFromOperator(_ context.Context, _ *types.MsgUndelegation) (*types.UndelegationResponse, error) { return nil, errorsmod.Wrap(types.ErrNotSupportYet, "func:UndelegateAssetFromOperator") } diff --git a/x/delegation/keeper/setup_test.go b/x/delegation/keeper/setup_test.go index c139e4874..ed6d4580e 100644 --- a/x/delegation/keeper/setup_test.go +++ b/x/delegation/keeper/setup_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 9e2e978ed..2062c7d3a 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -15,24 +15,24 @@ type ISlashKeeper interface { // VirtualISlashKeeper todo: When the actual keeper functionality has not been implemented yet, temporarily use the virtual keeper. type VirtualISlashKeeper struct{} -func (VirtualISlashKeeper) IsOperatorFrozen(ctx sdk.Context, opAddr sdk.AccAddress) bool { +func (VirtualISlashKeeper) IsOperatorFrozen(_ sdk.Context, _ sdk.AccAddress) bool { return false } -func (VirtualISlashKeeper) OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetID string, startHeight, endHeight uint64) sdkmath.LegacyDec { +func (VirtualISlashKeeper) OperatorAssetSlashedProportion(_ sdk.Context, _ sdk.AccAddress, _ string, _, _ uint64) sdkmath.LegacyDec { return sdkmath.LegacyNewDec(0) } // DelegationHooks add for dogfood type DelegationHooks interface { - //AfterDelegation we don't want the ability to cancel delegation or undelegation so no return type for + // AfterDelegation we don't want the ability to cancel delegation or undelegation so no return type for // either // for delegation, we only care about the address of the operator to cache the event AfterDelegation(ctx sdk.Context, operator sdk.AccAddress) - //AfterUndelegationStarted for undelegation, we use the address of the operator to figure out the list of impacted + // AfterUndelegationStarted for undelegation, we use the address of the operator to figure out the list of impacted // chains for that operator. and we need the identifier to hold it until confirmed by subscriber AfterUndelegationStarted(ctx sdk.Context, addr sdk.AccAddress, recordKey []byte) - //AfterUndelegationCompleted whenever an undelegation completes, we should update the vote power of the associated operator + // AfterUndelegationCompleted whenever an undelegation completes, we should update the vote power of the associated operator // on all of the chain ids that are impacted AfterUndelegationCompleted(ctx sdk.Context, addr sdk.AccAddress) } diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index 262d9b75d..4ce78ed44 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -1,11 +1,12 @@ package types import ( + "strings" + "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "strings" ) // constants diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index 55dd872d0..e184bec24 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -90,10 +90,12 @@ func (m *DelegationInfoReq) GetAssetID() string { // DelegationAmounts is the delegation amount response for a single delegation. type DelegationAmounts struct { - // can_undelegation_amount is the amount that can be undelegated. - CanUndelegationAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=can_undelegation_amount,json=canUndelegationAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_undelegation_amount"` + // can_be_undelegated_amount is the amount that can be undelegated. + CanBeUndelegatedAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=can_be_undelegated_amount,json=canBeUndelegatedAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_be_undelegated_amount"` // 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"` + // can_be_undelegated_after_slash is the amount that can be undelegated after slash + CanBeUndelegatedAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=can_be_undelegated_after_slash,json=canBeUndelegatedAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_be_undelegated_after_slash"` } func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } @@ -300,50 +302,49 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 676 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x4f, 0x13, 0x4f, - 0x18, 0xee, 0x96, 0x1f, 0x3f, 0x60, 0xc0, 0x08, 0x63, 0x81, 0x52, 0xcc, 0x16, 0xd7, 0x84, 0x54, - 0x0c, 0xbb, 0x52, 0x35, 0x31, 0x46, 0x4c, 0x20, 0x25, 0x64, 0x2f, 0x18, 0x97, 0x70, 0xf1, 0xd2, - 0x0c, 0xdd, 0x61, 0xdd, 0xb4, 0xcc, 0x94, 0x99, 0x69, 0xa1, 0x47, 0xf5, 0xe2, 0xd1, 0xc4, 0xf8, - 0x25, 0xf4, 0xe2, 0x81, 0x0f, 0xc1, 0x91, 0xe0, 0xc5, 0x78, 0x68, 0x4c, 0x31, 0xf1, 0x03, 0xf8, - 0x05, 0xcc, 0xce, 0x4e, 0xa1, 0x7f, 0x76, 0x51, 0x22, 0xa7, 0xee, 0xbe, 0x7f, 0x9e, 0xe7, 0x99, - 0xf7, 0x7d, 0x76, 0x0a, 0x6e, 0xe1, 0x03, 0x5a, 0xa2, 0x0c, 0x5b, 0x2e, 0xae, 0x60, 0x0f, 0x09, - 0x9f, 0x12, 0xab, 0xbe, 0x64, 0xed, 0xd5, 0x30, 0x6b, 0x98, 0x55, 0x46, 0x05, 0x85, 0x93, 0xaa, - 0xc4, 0x3c, 0x2f, 0x31, 0xeb, 0x4b, 0x99, 0xd9, 0x12, 0xe5, 0xbb, 0x94, 0x87, 0xa5, 0x3d, 0x3d, - 0x99, 0x99, 0x30, 0x59, 0x94, 0x6f, 0x56, 0xf8, 0xa2, 0x52, 0x7a, 0x34, 0xa3, 0x38, 0x50, 0xf9, - 0x94, 0x47, 0x3d, 0x1a, 0xf6, 0x05, 0x4f, 0x2a, 0x7a, 0xd3, 0xa3, 0xd4, 0xab, 0x60, 0x0b, 0x55, - 0x7d, 0x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- 0x07, 0xe7, 0xad, 0xe8, 0x5b, 0x6b, 0x1d, 0x8b, 0x2e, 0x05, 0x1f, 0x35, 0x70, 0x23, 0xc2, 0x5a, - 0xf0, 0xcf, 0x3b, 0x6f, 0xcb, 0xca, 0x5f, 0xde, 0xb0, 0xc6, 0xc3, 0xb7, 0x3f, 0x3f, 0x2f, 0x68, - 0x52, 0xea, 0x02, 0xcc, 0xc5, 0x4b, 0xed, 0x11, 0x75, 0xa8, 0x81, 0x19, 0x09, 0x1b, 0x65, 0x2c, - 0x68, 0xc6, 0x08, 0x89, 0x71, 0x61, 0xe6, 0xaf, 0x6d, 0x6d, 0x2c, 0x9f, 0xcb, 0xcd, 0xc3, 0x7b, - 0x31, 0x72, 0x63, 0x85, 0xad, 0x6e, 0x1c, 0xb5, 0x74, 0xed, 0xb8, 0xa5, 0x6b, 0xdf, 0x5b, 0xba, - 0xf6, 0xee, 0x54, 0x4f, 0x1c, 0x9f, 0xea, 0x89, 0xaf, 0xa7, 0x7a, 0xe2, 0xc5, 0x83, 0x8e, 0x2b, - 0x65, 0x2d, 0x44, 0xdd, 0xc0, 0x62, 0x9f, 0xb2, 0xf2, 0x19, 0xc9, 0x41, 0x27, 0x8d, 0xbc, 0x64, - 0xb6, 0xff, 0x97, 0xff, 0x21, 0xf7, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xde, 0x68, 0x9a, 0xc7, - 0x0b, 0x07, 0x00, 0x00, + // 671 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x4f, 0x13, 0x4f, + 0x1c, 0xee, 0x6e, 0xc3, 0x1f, 0x18, 0xf8, 0x47, 0x1c, 0x2b, 0x96, 0x62, 0xb6, 0xd8, 0x03, 0xa9, + 0x24, 0xec, 0x4a, 0xd5, 0xc4, 0x18, 0x31, 0x81, 0x94, 0x90, 0xbd, 0x60, 0xdc, 0x86, 0x8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 0xf0, 0x46, 0xcc, 0x0b, 0x2a, + 0x30, 0xcf, 0x9b, 0xf9, 0x1a, 0x11, 0xac, 0xe9, 0x5c, 0xf3, 0xce, 0x5b, 0x33, 0x21, 0x48, 0x0d, + 0x0a, 0x84, 0x53, 0x20, 0x59, 0xc5, 0xcd, 0xb8, 0x58, 0x27, 0x7a, 0x84, 0x4f, 0xc1, 0x48, 0x03, + 0x85, 0x75, 0x2c, 0x37, 0x63, 0xa2, 0x90, 0x1f, 0x22, 0xa9, 0x6f, 0xbd, 0x9d, 0x38, 0xed, 0xb1, + 0xfe, 0x48, 0xcb, 0x7d, 0xd0, 0xc0, 0xad, 0x52, 0x40, 0xfc, 0x10, 0xff, 0xd5, 0xb9, 0x2d, 0x83, + 0xff, 0x69, 0x0d, 0x33, 0x24, 0x28, 0x73, 0x91, 0xe7, 0x31, 0xb5, 0xac, 0xe9, 0xe3, 0x83, 0xc5, + 0x94, 0xea, 0xf2, 0x8a, 0xe7, 0x31, 0xcc, 0x79, 0x49, 0xb0, 0x80, 0xf8, 0xce, 0xe4, 0x69, 0x78, + 0x64, 0x3e, 0x77, 0xad, 0xc9, 0x0b, 0xae, 0x75, 0x13, 0xa4, 0x64, 0x83, 0x9f, 0xa9, 0xe4, 0x53, + 0xa5, 0x7d, 0xf4, 0xda, 0x65, 0xe8, 0x0b, 0x3f, 0x74, 0x30, 0x22, 0x71, 0xe1, 0x7b, 0x0d, 0xdc, + 0x18, 0x30, 0x42, 0xf8, 0xfb, 0xde, 0x2a, 0x29, 0x99, 0xc2, 0xe5, 0x17, 0x23, 0xf7, 0xf0, 0xcd, + 0xf7, 0x8f, 0x0b, 0xda, 0xab, 0x4f, 0xdf, 0xde, 0xe9, 0x0b, 0x30, 0x6f, 0x0d, 0xfe, 0x83, 0x5e, + 0xc7, 0xa2, 0x47, 0xd4, 0x81, 0x06, 0x66, 0x24, 0xec, 0xa0, 0x01, 0x42, 0x73, 0x88, 0x90, 0x21, + 0xd3, 0xce, 0xfc, 0xf1, 0xfa, 0xe4, 0x96, 0x3b, 0x72, 0x0b, 0xf0, 0xde, 0x10, 0xb9, 0x43, 0x85, + 0xad, 0x6e, 0x1c, 0xb6, 0x0d, 0xed, 0xa8, 0x6d, 0x68, 0x5f, 0xdb, 0x86, 0xf6, 0xf6, 0xc4, 0x48, + 0x1c, 0x9d, 0x18, 0x89, 0xcf, 0x27, 0x46, 0xe2, 0xc5, 0x83, 0xae, 0xd3, 0x5d, 0x8b, 0x51, 0x37, + 0xb0, 0xd8, 0xa3, 0xac, 0x7a, 0x46, 0xb2, 0xdf, 0x4d, 0x23, 0x8f, 0x79, 0xeb, 0x3f, 0xf9, 0xc5, + 0xb8, 0xff, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x37, 0x8b, 0x23, 0x15, 0xd9, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -358,8 +359,6 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - // OperatorInfo queries the operator information. - QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) // 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 @@ -375,15 +374,6 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) QueryOperatorInfo(ctx context.Context, in *QueryOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) { - out := new(OperatorInfo) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Query/QueryOperatorInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - 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...) @@ -404,8 +394,6 @@ func (c *queryClient) QuerySingleDelegationInfo(ctx context.Context, in *SingleD // QueryServer is the server API for Query service. type QueryServer interface { - // OperatorInfo queries the operator information. - QueryOperatorInfo(context.Context, *QueryOperatorInfoReq) (*OperatorInfo, error) // DelegationInfo queries the delegation information for {stakerID, assetID}. QueryDelegationInfo(context.Context, *DelegationInfoReq) (*QueryDelegationInfoResponse, error) // SingleDelegationInfo queries the single delegation information for @@ -417,9 +405,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) QueryOperatorInfo(ctx context.Context, req *QueryOperatorInfoReq) (*OperatorInfo, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorInfo not implemented") -} func (*UnimplementedQueryServer) QueryDelegationInfo(ctx context.Context, req *DelegationInfoReq) (*QueryDelegationInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryDelegationInfo not implemented") } @@ -431,24 +416,6 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_QueryOperatorInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOperatorInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryOperatorInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Query/QueryOperatorInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryOperatorInfo(ctx, req.(*QueryOperatorInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - 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 { @@ -489,10 +456,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.delegation.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "QueryOperatorInfo", - Handler: _Query_QueryOperatorInfo_Handler, - }, { MethodName: "QueryDelegationInfo", Handler: _Query_QueryDelegationInfo_Handler, @@ -563,6 +526,16 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.CanBeUndelegatedAfterSlash.Size() + i -= size + if _, err := m.CanBeUndelegatedAfterSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size := m.WaitUndelegationAmount.Size() i -= size @@ -574,9 +547,9 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 { - size := m.CanUndelegationAmount.Size() + size := m.CanBeUndelegatedAmount.Size() i -= size - if _, err := m.CanUndelegationAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.CanBeUndelegatedAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) @@ -753,10 +726,12 @@ func (m *DelegationAmounts) Size() (n int) { } var l int _ = l - l = m.CanUndelegationAmount.Size() + l = m.CanBeUndelegatedAmount.Size() n += 1 + l + sovQuery(uint64(l)) l = m.WaitUndelegationAmount.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.CanBeUndelegatedAfterSlash.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -969,7 +944,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CanUndelegationAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CanBeUndelegatedAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -997,7 +972,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CanUndelegationAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.CanBeUndelegatedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1035,6 +1010,40 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CanBeUndelegatedAfterSlash", 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.CanBeUndelegatedAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/delegation/types/tx.pb.go b/x/delegation/types/tx.pb.go index 82266f9cf..030d187a4 100644 --- a/x/delegation/types/tx.pb.go +++ b/x/delegation/types/tx.pb.go @@ -835,83 +835,82 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/tx.proto", fileDescriptor_16596a15a828f109) } var fileDescriptor_16596a15a828f109 = []byte{ - // 1207 bytes of a gzipped FileDescriptorProto + // 1187 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0x69, 0x62, 0x3f, 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, 0x21, 0x50, - 0xe5, 0x6d, 0x6a, 0x53, 0x29, 0xf7, 0x7f, 0x49, 0xa9, 0xda, 0x04, 0xf8, 0xcc, 0x70, 0x7b, 0xf8, - 0x9a, 0x83, 0x5d, 0x0b, 0xdd, 0x86, 0x59, 0xa3, 0x43, 0x7b, 0x84, 0x17, 0x95, 0x53, 0xca, 0xb9, - 0xcc, 0xc6, 0xbb, 0x0f, 0xf7, 0x2b, 0x89, 0xdf, 0xf6, 0x2b, 0x67, 0x6d, 0x87, 0xb7, 0x7a, 0xcd, - 0xaa, 0x49, 0x3b, 0x01, 0x68, 0xf0, 0x6f, 0x95, 0x59, 0xed, 0x1a, 0x1f, 0x74, 0x31, 0xab, 0x36, - 0x08, 0x7f, 0xfc, 0x60, 0x15, 0x02, 0xce, 0x06, 0xe1, 0x5a, 0x80, 0xa5, 0xfe, 0x98, 0x82, 0x62, - 0x5d, 0xa6, 0x84, 0xad, 0x5b, 0x0e, 0xb1, 0x5d, 0xbc, 0xce, 0x18, 0xe6, 0x0d, 0xb2, 0x43, 0xd1, - 0x59, 0x48, 0x1b, 0xfe, 0x83, 0xee, 0x58, 0x01, 0x69, 0x76, 0xb8, 0x5f, 0x99, 0x93, 0x06, 0x75, - 0x6d, 0x4e, 0x28, 0x1b, 0x16, 0xf2, 0x60, 0x89, 0x53, 0x6e, 0xb8, 0xba, 0x15, 0x22, 0xe9, 0x41, - 0xa8, 0xc9, 0x23, 0x08, 0x35, 0x2f, 0xb0, 0x47, 0x41, 0xae, 0x0b, 0x64, 0x34, 0x80, 0x7c, 0x17, - 0x7b, 0x3a, 0xed, 0x62, 0xcf, 0xe0, 0xd4, 0x0b, 0x08, 0x59, 0x31, 0x75, 0x2a, 0x75, 0x2e, 0xbb, - 0xf6, 0x41, 0x75, 0x62, 0xbf, 0xaa, 0xd3, 0x52, 0xad, 0xde, 0xc4, 0xde, 0x8d, 0x00, 0x4a, 0x12, - 0xb0, 0x4d, 0xc2, 0xbd, 0x81, 0x86, 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d4, 0x1c, 0xa0, 0x5a, 0x4c, 0x2b, 0xd8, + 0x50, 0x0f, 0x60, 0x76, 0x9d, 0xd9, 0x71, 0x83, 0xa7, 0x39, 0x23, 0xea, 0x3c, 0xe4, 0x46, 0x9d, + 0x95, 0xb0, 0x4b, 0x7f, 0x2a, 0x90, 0x5c, 0x67, 0x36, 0xfa, 0x02, 0xf2, 0xe1, 0x6b, 0x48, 0xb4, + 0xe8, 0x16, 0x0d, 0x77, 0x0b, 0x7a, 0x75, 0x0c, 0xe6, 0xc8, 0x40, 0x17, 0xaf, 0x9e, 0xe8, 0x59, + 0x88, 0x89, 0x3c, 0x78, 0x69, 0xe8, 0x8b, 0x44, 0xf3, 0x6f, 0x8b, 0x21, 0xde, 0xe5, 0xf1, 0x78, + 0xf1, 0x10, 0x8a, 0xaf, 0x8f, 0x91, 0x3b, 0x2e, 0xce, 0xe2, 0x99, 0xaf, 0x0f, 0xf7, 0xae, 0x29, + 0x2b, 0x1b, 0x4f, 0x06, 0x25, 0xe5, 0xe9, 0xa0, 0xa4, 0xfc, 0x3e, 0x28, 0x29, 0xdf, 0x1f, 0x94, + 0x12, 0x4f, 0x0f, 0x4a, 0x89, 0x5f, 0x0f, 0x4a, 0x89, 0xcf, 0x6f, 0xc6, 0x5a, 0x63, 0x4d, 0xda, + 0xdd, 0xc0, 0xfc, 0x21, 0xf5, 0x5a, 0xd5, 0xf0, 0xc7, 0x40, 0x2f, 0xfe, 0x73, 0x40, 0x34, 0x4b, + 0x63, 0x4a, 0xbc, 0xcd, 0xdf, 0xf8, 0x27, 0x00, 0x00, 0xff, 0xff, 0x48, 0x50, 0x09, 0xb1, 0x31, + 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -926,8 +925,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // RegisterOperator registers a new operator. - RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) // DelegateAssetToOperator delegates asset to operator. DelegateAssetToOperator(ctx context.Context, in *MsgDelegation, opts ...grpc.CallOption) (*DelegationResponse, error) // UndelegateAssetFromOperator undelegates asset from operator. @@ -942,15 +939,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) { - out := new(RegisterOperatorResponse) - err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Msg/RegisterOperator", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) DelegateAssetToOperator(ctx context.Context, in *MsgDelegation, opts ...grpc.CallOption) (*DelegationResponse, error) { out := new(DelegationResponse) err := c.cc.Invoke(ctx, "/exocore.delegation.v1.Msg/DelegateAssetToOperator", in, out, opts...) @@ -971,8 +959,6 @@ func (c *msgClient) UndelegateAssetFromOperator(ctx context.Context, in *MsgUnde // MsgServer is the server API for Msg service. type MsgServer interface { - // RegisterOperator registers a new operator. - RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) // DelegateAssetToOperator delegates asset to operator. DelegateAssetToOperator(context.Context, *MsgDelegation) (*DelegationResponse, error) // UndelegateAssetFromOperator undelegates asset from operator. @@ -983,9 +969,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *RegisterOperatorReq) (*RegisterOperatorResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterOperator not implemented") -} func (*UnimplementedMsgServer) DelegateAssetToOperator(ctx context.Context, req *MsgDelegation) (*DelegationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DelegateAssetToOperator not implemented") } @@ -997,24 +980,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_RegisterOperator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterOperatorReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterOperator(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/exocore.delegation.v1.Msg/RegisterOperator", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterOperator(ctx, req.(*RegisterOperatorReq)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_DelegateAssetToOperator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgDelegation) if err := dec(in); err != nil { @@ -1055,10 +1020,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.delegation.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "RegisterOperator", - Handler: _Msg_RegisterOperator_Handler, - }, { MethodName: "DelegateAssetToOperator", Handler: _Msg_DelegateAssetToOperator_Handler, diff --git a/x/deposit/keeper/setup_test.go b/x/deposit/keeper/setup_test.go index c6b43ccc3..67a7734cd 100644 --- a/x/deposit/keeper/setup_test.go +++ b/x/deposit/keeper/setup_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index f4fb6f1f3..36ab35301 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -32,14 +32,14 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { if err != nil { return err } - if priceChangeAssets == nil || len(priceChangeAssets) == 0 { + if len(priceChangeAssets) == 0 { return nil } avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) assetsOperatorAVSInfo := make(map[string]map[string]string, 0) assetsDecimal := make(map[string]uint32) for assetID, priceChange := range priceChangeAssets { - //get the decimal of asset + // get the decimal of asset assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err @@ -48,8 +48,8 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { if _, ok := assetsOperatorAVSInfo[assetID]; !ok { assetsOperatorAVSInfo[assetID] = make(map[string]string, 0) } - //UpdateStateForAsset - f := func(assetID string, keys []string, state *operatortypes.AssetOptedInState) error { + // UpdateStateForAsset + f := func(assetID string, keys []string, state *operatortypes.OptedInAssetState) error { newAssetUSDValue := CalculateShare(state.Amount, priceChange.NewPrice, assetInfo.AssetBasicInfo.Decimals, priceChange.Decimal) changeValue := newAssetUSDValue.Sub(state.Value) state.Value = newAssetUSDValue @@ -66,13 +66,13 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { return err } } - //BatchUpdateShareForAVSAndOperator + // BatchUpdateShareForAVSAndOperator err = k.BatchUpdateShareForAVSAndOperator(ctx, avsOperatorShareChange) if err != nil { return err } - //update staker'suite share + // update staker'suite share sharedParameter := &SharedParameter{ priceChangeAssets: priceChangeAssets, assetsDecimal: assetsDecimal, @@ -80,7 +80,7 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { stakerShare: make(map[string]sdkmath.LegacyDec, 0), } stakerShareHandleFunc := func(stakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error { - UpdateShareOfStakerAndOperator(sharedParameter, assetID, stakerID, operatorAddr, state.CanUndelegationAmount) + UpdateShareOfStakerAndOperator(sharedParameter, assetID, stakerID, operatorAddr, state.CanBeUndelegatedAmount) return nil } err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) @@ -96,7 +96,7 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { if err != nil { return err } - //BatchSetStakerShare + // BatchSetStakerShare err = k.BatchSetStakerShare(ctx, sharedParameter.stakerShare) if err != nil { return err @@ -109,7 +109,7 @@ func (k *Keeper) ClearPreConsensusPK(ctx sdk.Context) error { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator( store, - []byte{operatortypes.BytePrefixForOperatorAndChainIdToPrevConsKey}, + []byte{operatortypes.BytePrefixForOperatorAndChainIDToPrevConsKey}, ) defer iterator.Close() @@ -121,7 +121,7 @@ func (k *Keeper) ClearPreConsensusPK(ctx sdk.Context) error { // EndBlock : update the assets' share when their prices change func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - //todo: need to consider the calling order + // todo: need to consider the calling order err := k.PriceChangeHandle(ctx) if err != nil { panic(err) diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index eb9f06e27..6aed677c9 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -1,9 +1,11 @@ package keeper import ( + "fmt" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "fmt" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -18,11 +20,10 @@ func (k *Keeper) UpdateOperatorShare(ctx sdk.Context, avsAddr, operatorAddr stri var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") - } else { - key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } + key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) - totalValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} + totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &totalValue) @@ -41,29 +42,29 @@ func (k *Keeper) DeleteOperatorShare(ctx sdk.Context, avsAddr, operatorAddr stri var key []byte if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") - } else { - key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } + key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + store.Delete(key) return nil } func (k *Keeper) GetOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) - var ret operatortypes.ValueField + var ret operatortypes.DecValueField var key []byte if operatorAddr == "" { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetOperatorShare the operatorAddr is empty") - } else { - key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) } + key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + isExist := store.Has(key) if !isExist { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorShare: key is %suite", key)) - } else { - value := store.Get(key) - k.cdc.MustUnmarshal(value, &ret) } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + return ret.Amount, nil } @@ -73,7 +74,7 @@ func (k *Keeper) UpdateAVSShare(ctx sdk.Context, avsAddr string, opAmount sdkmat } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) key := []byte(avsAddr) - totalValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} + totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &totalValue) @@ -91,12 +92,13 @@ func (k *Keeper) BatchUpdateShareForAVSAndOperator(ctx sdk.Context, avsOperatorC store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) for avs, opAmount := range avsOperatorChange { key := []byte(avs) - totalValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} + totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &totalValue) } - err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + tmpOpAmount := opAmount + err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &tmpOpAmount) if err != nil { return err } @@ -108,58 +110,58 @@ func (k *Keeper) BatchUpdateShareForAVSAndOperator(ctx sdk.Context, avsOperatorC func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) - var ret operatortypes.ValueField + var ret operatortypes.DecValueField key := []byte(avsAddr) isExit := store.Has(key) if !isExit { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSShare: key is %suite", key)) - } else { - value := store.Get(key) - k.cdc.MustUnmarshal(value, &ret) } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + return ret.Amount, nil } -func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.AssetOptedInState) error { +func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.OptedInAssetState) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) if changeState.Amount.IsNil() && changeState.Value.IsNil() { return nil } - //check operator address validation + // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { return restakingtype.ErrOperatorAddr } stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) - assetOptedInState := operatortypes.AssetOptedInState{ + optedInAssetState := operatortypes.OptedInAssetState{ Amount: sdkmath.NewInt(0), Value: sdkmath.LegacyNewDec(0), } if store.Has(stateKey) { value := store.Get(stateKey) - k.cdc.MustUnmarshal(value, &assetOptedInState) + k.cdc.MustUnmarshal(value, &optedInAssetState) } - err = restakingtype.UpdateAssetValue(&assetOptedInState.Amount, &changeState.Amount) + err = restakingtype.UpdateAssetValue(&optedInAssetState.Amount, &changeState.Amount) if err != nil { - return errorsmod.Wrap(err, "UpdateStateForAsset assetOptedInState.Amount error") + return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Amount error") } - err = restakingtype.UpdateAssetDecValue(&assetOptedInState.Value, &changeState.Value) + err = restakingtype.UpdateAssetDecValue(&optedInAssetState.Value, &changeState.Value) if err != nil { - return errorsmod.Wrap(err, "UpdateStateForAsset assetOptedInState.Value error") + return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Value error") } - //save single operator delegation state - bz := k.cdc.MustMarshal(&assetOptedInState) + // save single operator delegation state + bz := k.cdc.MustMarshal(&optedInAssetState) store.Set(stateKey, bz) return nil } func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - //check operator address validation + // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { return restakingtype.ErrOperatorAddr @@ -169,21 +171,21 @@ func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAdd return nil } -func (k *Keeper) GetAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) (changeState *operatortypes.AssetOptedInState, err error) { +func (k *Keeper) GetAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) (changeState *operatortypes.OptedInAssetState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) isExit := store.Has(stateKey) - assetOptedInState := operatortypes.AssetOptedInState{} + optedInAssetState := operatortypes.OptedInAssetState{} if isExit { value := store.Get(stateKey) - k.cdc.MustUnmarshal(value, &assetOptedInState) + k.cdc.MustUnmarshal(value, &optedInAssetState) } else { return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAssetState: key is %suite", stateKey)) } - return &assetOptedInState, nil + return &optedInAssetState, nil } -func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func(assetID string, keys []string, state *operatortypes.AssetOptedInState) error) (err error) { +func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func(assetID string, keys []string, state *operatortypes.OptedInAssetState) error) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) iterator := sdk.KVStorePrefixIterator(store, []byte(assetID)) defer iterator.Close() @@ -193,13 +195,13 @@ func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func if err != nil { return err } - assetOptedInState := &operatortypes.AssetOptedInState{} - k.cdc.MustUnmarshal(iterator.Value(), assetOptedInState) - err = f(assetID, keys, assetOptedInState) + optedInAssetState := &operatortypes.OptedInAssetState{} + k.cdc.MustUnmarshal(iterator.Value(), optedInAssetState) + err = f(assetID, keys, optedInAssetState) if err != nil { return err } - bz := k.cdc.MustMarshal(assetOptedInState) + bz := k.cdc.MustMarshal(optedInAssetState) store.Set(iterator.Key(), bz) } return nil @@ -212,7 +214,7 @@ func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) - optedInValue := operatortypes.ValueField{Amount: sdkmath.LegacyNewDec(0)} + optedInValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &optedInValue) @@ -229,7 +231,7 @@ func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA func (k *Keeper) BatchSetStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) for key, value := range newValues { - optedInValue := operatortypes.ValueField{Amount: value} + optedInValue := operatortypes.DecValueField{Amount: value} if store.Has([]byte(key)) { value := store.Get([]byte(key)) k.cdc.MustUnmarshal(value, &optedInValue) @@ -250,19 +252,19 @@ func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - var ret operatortypes.ValueField + var ret operatortypes.DecValueField key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) isExit := store.Has(key) if !isExit { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerShare: key is %s", key)) - } else { - value := store.Get(key) - k.cdc.MustUnmarshal(value, &ret) } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + return ret.Amount, nil } -func (k *Keeper) GetStakerByAVSOperator(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]interface{}, error) { +func (k *Keeper) GetStakerByAVSOperator(ctx sdk.Context, _, _ string) (map[string]interface{}, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) stakers := make(map[string]interface{}, 0) iterator := sdk.KVStorePrefixIterator(store, nil) diff --git a/x/operator/keeper/common_func.go b/x/operator/keeper/common_func.go index 677318a17..35a437276 100644 --- a/x/operator/keeper/common_func.go +++ b/x/operator/keeper/common_func.go @@ -17,7 +17,9 @@ func AddShareInMap(shareMap map[string]sdkmath.LegacyDec, key string, addValue s // CalculateShare assetUSDValue = (assetAmount*price*10^USDValueDefaultDecimal)/(10^(asset.decimal+priceDecimal)) func CalculateShare(assetAmount sdkmath.Int, price sdkmath.Int, assetDecimal uint32, priceDecimal uint8) sdkmath.LegacyDec { + // #nosec G701 assetValue := assetAmount.Mul(price).Mul(sdkmath.NewIntWithDecimal(1, int(operatortypes.USDValueDefaultDecimal))).Quo(sdkmath.NewIntWithDecimal(1, int(assetDecimal)+int(priceDecimal))) + // #nosec G701 assetUSDValue := sdkmath.LegacyNewDecFromBigIntWithPrec(assetValue.BigInt(), int64(operatortypes.USDValueDefaultDecimal)) return assetUSDValue } diff --git a/x/operator/keeper/dogfood.go b/x/operator/keeper/dogfood.go index 5b5efa0df..ed49c657a 100644 --- a/x/operator/keeper/dogfood.go +++ b/x/operator/keeper/dogfood.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "github.com/ExocoreNetwork/exocore/x/operator/types" errorsmod "cosmossdk.io/errors" @@ -19,14 +20,14 @@ func (k *Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// SetOperatorConsKeyForChainId sets the (consensus) public key for the given operator address +// SetOperatorConsKeyForChainID sets the (consensus) public key for the given operator address // and chain id. By doing this, an operator is consenting to be an operator on the given chain. // If a key already exists, it will be overwritten and the change in voting power will flow // through to the validator set. -func (k *Keeper) SetOperatorConsKeyForChainId( +func (k *Keeper) SetOperatorConsKeyForChainID( ctx sdk.Context, opAccAddr sdk.AccAddress, - chainId string, + chainID string, // should be tm-ed25519 consKey tmprotocrypto.PublicKey, ) error { @@ -39,11 +40,11 @@ func (k *Keeper) SetOperatorConsKeyForChainId( return delegationtypes.ErrOperatorIsFrozen } // check if the chain id is valid - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { return restakingtypes.ErrNoAppChainKey } // if opting out, do not allow key replacement - if k.IsOperatorOptingOutFromChainId(ctx, opAccAddr, chainId) { + if k.IsOperatorOptingOutFromChainID(ctx, opAccAddr, chainID) { return types.ErrAlreadyOptingOut } // convert to bytes @@ -51,7 +52,7 @@ func (k *Keeper) SetOperatorConsKeyForChainId( if err != nil { return errorsmod.Wrap( err, - "SetOperatorConsKeyForChainId: error occurred when marshal public key", + "SetOperatorConsKeyForChainID: error occurred when marshal public key", ) } // convert to address for reverse lookup @@ -59,20 +60,20 @@ func (k *Keeper) SetOperatorConsKeyForChainId( if err != nil { return errorsmod.Wrap( err, - "SetOperatorConsKeyForChainId: error occurred when convert public key to consensus address", + "SetOperatorConsKeyForChainID: error occurred when convert public key to consensus address", ) } // check if the key is already in use by another operator // operators may call this function with their own key // to unjail themselves, so we will allow that. - keyInUse, existingAddr := k.GetOperatorAddressForChainIdAndConsAddr(ctx, chainId, consAddr) + keyInUse, existingAddr := k.GetOperatorAddressForChainIDAndConsAddr(ctx, chainID, consAddr) if keyInUse { if !existingAddr.Equals(opAccAddr) { return types.ErrConsKeyAlreadyInUse } } // check that such a key is already set. if yes, we will consider it as key replacement. - found, prevKey, err := k.getOperatorConsKeyForChainId(ctx, opAccAddr, chainId) + found, prevKey, err := k.getOperatorConsKeyForChainID(ctx, opAccAddr, chainID) if err != nil { // this should not happen panic(err) @@ -87,28 +88,28 @@ func (k *Keeper) SetOperatorConsKeyForChainId( // if this key is different, we will set the vote power of the old key to 0 // in the validator update. but, we must only do so once in a block, since the // first existing key is the one to replace with 0 vote power and not any others. - alreadyRecorded, _, err = k.getOperatorPrevConsKeyForChainId(ctx, opAccAddr, chainId) + alreadyRecorded, _, err = k.getOperatorPrevConsKeyForChainID(ctx, opAccAddr, chainID) if err != nil { // this should not happen panic(err) } if !alreadyRecorded { - if err := k.setOperatorPrevConsKeyForChainId(ctx, opAccAddr, chainId, prevKey); err != nil { + if err := k.setOperatorPrevConsKeyForChainID(ctx, opAccAddr, chainID, prevKey); err != nil { // this should not happen panic(err) } } } - // k.setOperatorConsKeyForChainId(ctx, opAccAddr, chainId, bz) + // k.setOperatorConsKeyForChainID(ctx, opAccAddr, chainID, bz) // return nil // } - // // setOperatorConsKeyForChainId is the internal private version. It performs + // // setOperatorConsKeyForChainID is the internal private version. It performs // // no error checking of the input. - // func (k Keeper) setOperatorConsKeyForChainId( + // func (k Keeper) setOperatorConsKeyForChainID( // ctx sdk.Context, // opAccAddr sdk.AccAddress, - // chainId string, + // chainID string, // bz []byte, // ) { store := ctx.KVStore(k.storeKey) @@ -117,12 +118,12 @@ func (k *Keeper) SetOperatorConsKeyForChainId( // since it is sorted by operator address, it helps for faster indexing by operator // for example, when an operator is delegated to, we can find all impacted // chain ids and their respective consensus keys - store.Set(types.KeyForOperatorAndChainIdToConsKey(opAccAddr, chainId), bz) + store.Set(types.KeyForOperatorAndChainIDToConsKey(opAccAddr, chainID), bz) // reverse lookups // 1. given chain id and operator address, find the consensus key, // at initial onboarding of an app chain, it will allow us to find all // operators that have opted in and their consensus keys - store.Set(types.KeyForChainIdAndOperatorToConsKey(chainId, opAccAddr), bz) + store.Set(types.KeyForChainIDAndOperatorToConsKey(chainID, opAccAddr), bz) // 2. given a chain id and a consensus addr, find the operator address, // the slashing module asks for an operator to be slashed by their consensus // address, so this will allow us to find the operator address to slash. @@ -130,69 +131,69 @@ func (k *Keeper) SetOperatorConsKeyForChainId( // prune it once the validator set update id matures (if key replacement). // this pruning will be triggered by the app chain module and will not be // recorded here. - store.Set(types.KeyForChainIdAndConsKeyToOperator(chainId, consAddr), opAccAddr.Bytes()) + store.Set(types.KeyForChainIDAndConsKeyToOperator(chainID, consAddr), opAccAddr.Bytes()) if found { if !alreadyRecorded { - k.Hooks().AfterOperatorKeyReplacement(ctx, opAccAddr, prevKey, consKey, chainId) + k.Hooks().AfterOperatorKeyReplacement(ctx, opAccAddr, prevKey, consKey, chainID) } } else { - k.Hooks().AfterOperatorOptIn(ctx, opAccAddr, chainId, consKey) + k.Hooks().AfterOperatorOptIn(ctx, opAccAddr, chainID, consKey) } return nil } -// setOperatorPrevConsKeyForChainId sets the previous (consensus) public key for the given +// setOperatorPrevConsKeyForChainID sets the previous (consensus) public key for the given // operator address and chain id. This is used to track the previous key when a key is replaced. // It is internal-only because such a key must only be set upon key replacement. So it does // not perform any meaningful error checking of the input. -func (k *Keeper) setOperatorPrevConsKeyForChainId( +func (k *Keeper) setOperatorPrevConsKeyForChainID( ctx sdk.Context, opAccAddr sdk.AccAddress, - chainId string, + chainID string, prevKey tmprotocrypto.PublicKey, ) error { bz, err := prevKey.Marshal() if err != nil { return errorsmod.Wrap( err, - "SetOperatorPrevConsKeyForChainId: error occurred when marshal public key", + "SetOperatorPrevConsKeyForChainID: error occurred when marshal public key", ) } store := ctx.KVStore(k.storeKey) - store.Set(types.KeyForOperatorAndChainIdToPrevConsKey(opAccAddr, chainId), bz) + store.Set(types.KeyForOperatorAndChainIDToPrevConsKey(opAccAddr, chainID), bz) return nil } -// GetOperatorPrevConsKeyForChainId gets the previous (consensus) public key for the given +// GetOperatorPrevConsKeyForChainID gets the previous (consensus) public key for the given // operator address and chain id. When such a key is returned, callers should set its vote power // to 0 in the validator update. -func (k *Keeper) GetOperatorPrevConsKeyForChainId( - ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +func (k *Keeper) GetOperatorPrevConsKeyForChainID( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainID string, ) (found bool, key tmprotocrypto.PublicKey, err error) { // check if we are an operator if !k.IsOperator(ctx, opAccAddr) { err = delegationtypes.ErrOperatorNotExist return } - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { err = restakingtypes.ErrNoAppChainKey return } // do not check for slashing here - found, key, err = k.getOperatorPrevConsKeyForChainId(ctx, opAccAddr, chainId) + found, key, err = k.getOperatorPrevConsKeyForChainID(ctx, opAccAddr, chainID) return } -// getOperatorPrevConsKeyForChainId is the internal version of -// GetOperatorPrevConsKeyForChainId. +// getOperatorPrevConsKeyForChainID is the internal version of +// GetOperatorPrevConsKeyForChainID. // It performs no error checking of the input. -func (k *Keeper) getOperatorPrevConsKeyForChainId( +func (k *Keeper) getOperatorPrevConsKeyForChainID( ctx sdk.Context, opAccAddr sdk.AccAddress, - chainId string, + chainID string, ) (found bool, key tmprotocrypto.PublicKey, err error) { store := ctx.KVStore(k.storeKey) - res := store.Get(types.KeyForOperatorAndChainIdToPrevConsKey(opAccAddr, chainId)) + res := store.Get(types.KeyForOperatorAndChainIDToPrevConsKey(opAccAddr, chainID)) if res == nil { return } @@ -203,37 +204,37 @@ func (k *Keeper) getOperatorPrevConsKeyForChainId( return } -// GetOperatorConsKeyForChainId gets the (consensus) public key for the given operator address +// GetOperatorConsKeyForChainID gets the (consensus) public key for the given operator address // and chain id. This should be exposed via the query surface. -func (k *Keeper) GetOperatorConsKeyForChainId( +func (k *Keeper) GetOperatorConsKeyForChainID( ctx sdk.Context, opAccAddr sdk.AccAddress, - chainId string, + chainID string, ) (found bool, key tmprotocrypto.PublicKey, err error) { // check if we are an operator if !k.IsOperator(ctx, opAccAddr) { err = delegationtypes.ErrOperatorNotExist return } - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { err = restakingtypes.ErrNoAppChainKey return } // do not check for slashing, since this function will be used to update voting power even // when slashed - found, key, err = k.getOperatorConsKeyForChainId(ctx, opAccAddr, chainId) + found, key, err = k.getOperatorConsKeyForChainID(ctx, opAccAddr, chainID) return } -// getOperatorConsKeyForChainId is the internal version of GetOperatorConsKeyForChainId. It +// getOperatorConsKeyForChainID is the internal version of GetOperatorConsKeyForChainID. It // performs no error checking of the input. -func (k *Keeper) getOperatorConsKeyForChainId( +func (k *Keeper) getOperatorConsKeyForChainID( ctx sdk.Context, opAccAddr sdk.AccAddress, - chainId string, + chainID string, ) (found bool, key tmprotocrypto.PublicKey, err error) { store := ctx.KVStore(k.storeKey) - res := store.Get(types.KeyForOperatorAndChainIdToConsKey(opAccAddr, chainId)) + res := store.Get(types.KeyForOperatorAndChainIDToConsKey(opAccAddr, chainID)) if res == nil { return } @@ -243,20 +244,20 @@ func (k *Keeper) getOperatorConsKeyForChainId( return true, key, nil } -// GetChainIdsAndKeysForOperator gets the chain ids for which the given operator address has set a +// GetChainIDsAndKeysForOperator gets the chain ids for which the given operator address has set a // (consensus) public key. TODO: would it be better to make this a key per operator? // This is intentionally an array of strings because I don't see the utility for the vote power // or the public key here. If we need it, we can add it later. -func (k *Keeper) GetChainIdsAndKeysForOperator( +func (k *Keeper) GetChainIDsAndKeysForOperator( ctx sdk.Context, opAccAddr sdk.AccAddress, -) (chainIds []string, consKeys []tmprotocrypto.PublicKey) { +) (chainIDs []string, consKeys []tmprotocrypto.PublicKey) { // check if we are an operator if !k.IsOperator(ctx, opAccAddr) { return } // do not check for slashing here prefix := types.AppendMany( - []byte{types.BytePrefixForOperatorAndChainIdToConsKey}, + []byte{types.BytePrefixForOperatorAndChainIDToConsKey}, opAccAddr.Bytes(), ) store := ctx.KVStore(k.storeKey) @@ -266,32 +267,32 @@ func (k *Keeper) GetChainIdsAndKeysForOperator( defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // the key returned is the full key, with the prefix. drop the prefix and the length. - chainId := string(iterator.Key()[len(prefix)+8:]) + chainID := string(iterator.Key()[len(prefix)+8:]) var key tmprotocrypto.PublicKey if err := key.Unmarshal(iterator.Value()); err != nil { // grave error because we are the ones who stored this information in the first // place panic(err) } - chainIds = append(chainIds, chainId) + chainIDs = append(chainIDs, chainID) consKeys = append(consKeys, key) } return } -// GetOperatorsForChainId returns a list of {operatorAddr, pubKey} for the given -// chainId. This is used to create or update the validator set. It skips +// GetOperatorsForChainID returns a list of {operatorAddr, pubKey} for the given +// chainID. This is used to create or update the validator set. It skips // jailed or frozen operators. -func (k *Keeper) GetOperatorsForChainId( - ctx sdk.Context, chainId string, +func (k *Keeper) GetOperatorsForChainID( + ctx sdk.Context, chainID string, ) (addrs []sdk.AccAddress, pubKeys []tmprotocrypto.PublicKey) { - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { - return + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { + return nil, nil } - // prefix is the byte prefix and then chainId with length - prefix := types.ChainIdAndAddrKey( - types.BytePrefixForChainIdAndOperatorToConsKey, - chainId, + // prefix is the byte prefix and then chainID with length + prefix := types.ChainIDAndAddrKey( + types.BytePrefixForChainIDAndOperatorToConsKey, + chainID, nil, ) store := ctx.KVStore(k.storeKey) @@ -300,8 +301,8 @@ func (k *Keeper) GetOperatorsForChainId( ) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - // this key is of the format prefix | len | chainId | addr - // and our prefix is of the format prefix | len | chainId + // this key is of the format prefix | len | chainID | addr + // and our prefix is of the format prefix | len | chainID // so just drop it and convert to sdk.AccAddress addr := iterator.Key()[len(prefix):] res := iterator.Value() @@ -312,33 +313,32 @@ func (k *Keeper) GetOperatorsForChainId( } addrs = append(addrs, addr) pubKeys = append(pubKeys, ret) - } - return + return addrs, pubKeys } -func (k *Keeper) GetOperatorAddressForChainIdAndConsAddr( - ctx sdk.Context, chainId string, consAddr sdk.ConsAddress, +func (k *Keeper) GetOperatorAddressForChainIDAndConsAddr( + ctx sdk.Context, chainID string, consAddr sdk.ConsAddress, ) (found bool, addr sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - res := store.Get(types.KeyForChainIdAndConsKeyToOperator(chainId, consAddr)) + res := store.Get(types.KeyForChainIDAndConsKeyToOperator(chainID, consAddr)) if res == nil { return } found = true addr = sdk.AccAddress(res) - return + return found, addr } -// DeleteOperatorAddressForChainIdAndConsAddr is a pruning method used to delete the +// DeleteOperatorAddressForChainIDAndConsAddr is a pruning method used to delete the // mapping from chain id and consensus address to operator address. This mapping is used // to obtain the operator address from its consensus public key, which is sent to the // coordinator chain by a subscriber chain for slashing. -func (k *Keeper) DeleteOperatorAddressForChainIdAndConsAddr( - ctx sdk.Context, chainId string, consAddr sdk.ConsAddress, +func (k *Keeper) DeleteOperatorAddressForChainIDAndConsAddr( + ctx sdk.Context, chainID string, consAddr sdk.ConsAddress, ) { store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyForChainIdAndConsKeyToOperator(chainId, consAddr)) + store.Delete(types.KeyForChainIDAndConsKeyToOperator(chainID, consAddr)) } // SetHooks stores the given hooks implementations. @@ -361,11 +361,11 @@ func (k *Keeper) Hooks() types.OperatorConsentHooks { return k.hooks } -// InitiateOperatorOptOutFromChainId initiates an operator opting out from the given chain id. +// InitiateOperatorOptOutFromChainID initiates an operator opting out from the given chain id. // It validates whether the operator is registered, and that it is not frozen, and that the // chain is present within the system. It also checks if the operator is already opting out. -func (k *Keeper) InitiateOperatorOptOutFromChainId( - ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +func (k *Keeper) InitiateOperatorOptOutFromChainID( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainID string, ) error { // check if we are an operator if !k.IsOperator(ctx, opAccAddr) { @@ -376,52 +376,50 @@ func (k *Keeper) InitiateOperatorOptOutFromChainId( return delegationtypes.ErrOperatorIsFrozen } // check if the chain id is valid - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainId) { + if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { return restakingtypes.ErrNoAppChainKey } - found, key, err := k.getOperatorConsKeyForChainId(ctx, opAccAddr, chainId) + found, key, err := k.getOperatorConsKeyForChainID(ctx, opAccAddr, chainID) if err != nil { return err } if !found { return types.ErrNotOptedIn } - isAlreadyOptingOut := k.IsOperatorOptingOutFromChainId(ctx, opAccAddr, chainId) + isAlreadyOptingOut := k.IsOperatorOptingOutFromChainID(ctx, opAccAddr, chainID) if isAlreadyOptingOut { return types.ErrAlreadyOptingOut } store := ctx.KVStore(k.storeKey) - store.Set(types.KeyForOperatorOptOutFromChainId(opAccAddr, chainId), []byte{}) - k.Hooks().AfterOperatorOptOutInitiated(ctx, opAccAddr, chainId, key) + store.Set(types.KeyForOperatorOptOutFromChainID(opAccAddr, chainID), []byte{}) + k.Hooks().AfterOperatorOptOutInitiated(ctx, opAccAddr, chainID, key) return nil } -// IsOperatorOptingOutFromChainId returns true if the operator is opting out from the given +// IsOperatorOptingOutFromChainID returns true if the operator is opting out from the given // chain id. -func (k *Keeper) IsOperatorOptingOutFromChainId( - ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +func (k *Keeper) IsOperatorOptingOutFromChainID( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainID string, ) bool { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyForOperatorOptOutFromChainId(opAccAddr, chainId)) + bz := store.Get(types.KeyForOperatorOptOutFromChainID(opAccAddr, chainID)) return bz != nil } -// CompleteOperatorOptOutFromChainId completes the operator opting out from the given chain id. +// CompleteOperatorOptOutFromChainID completes the operator opting out from the given chain id. // TODO(mm): would it be better to store as 3 states? (opted in, opting out, opted out) -func (k *Keeper) CompleteOperatorOptOutFromChainId( - ctx sdk.Context, opAccAddr sdk.AccAddress, chainId string, +func (k *Keeper) CompleteOperatorOptOutFromChainID( + ctx sdk.Context, opAccAddr sdk.AccAddress, chainID string, ) { - if !k.IsOperatorOptingOutFromChainId(ctx, opAccAddr, chainId) { + if !k.IsOperatorOptingOutFromChainID(ctx, opAccAddr, chainID) { panic("operator is not opting out") } store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyForOperatorOptOutFromChainId(opAccAddr, chainId)) + store.Delete(types.KeyForOperatorOptOutFromChainID(opAccAddr, chainID)) } -// IsOperatorJailedForChainId add for dogfood -func (k *Keeper) IsOperatorJailedForChainId(sdk.Context, sdk.AccAddress, string) bool { +// IsOperatorJailedForChainID add for dogfood +func (k *Keeper) IsOperatorJailedForChainID(sdk.Context, sdk.AccAddress, string) bool { return false } -func (k *Keeper) Jail(sdk.Context, sdk.ConsAddress, string) { - return -} +func (k *Keeper) Jail(sdk.Context, sdk.ConsAddress, string) {} diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index 5856c70ea..a1ec38314 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -15,17 +15,17 @@ func (k *Keeper) GetOperatorInfo(ctx context.Context, req *operatortypes.GetOper return k.OperatorInfo(c, req.OperatorAddr) } -// QueryOperatorConsKeyForChainId add for dogfood -func (k *Keeper) QueryOperatorConsKeyForChainId( +// QueryOperatorConsKeyForChainID add for dogfood +func (k *Keeper) QueryOperatorConsKeyForChainID( goCtx context.Context, - req *operatortypes.QueryOperatorConsKeyForChainIdRequest, -) (*operatortypes.QueryOperatorConsKeyForChainIdResponse, error) { + req *operatortypes.QueryOperatorConsKeyForChainIDRequest, +) (*operatortypes.QueryOperatorConsKeyForChainIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Addr) if err != nil { return nil, err } - found, key, err := k.GetOperatorConsKeyForChainId( + found, key, err := k.GetOperatorConsKeyForChainID( ctx, addr, req.ChainId, ) if err != nil { @@ -34,7 +34,7 @@ func (k *Keeper) QueryOperatorConsKeyForChainId( if !found { return nil, errors.New("no key assigned") } - return &operatortypes.QueryOperatorConsKeyForChainIdResponse{ + return &operatortypes.QueryOperatorConsKeyForChainIDResponse{ PublicKey: key, }, nil } diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 02739ea00..8319f8c52 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdkmath "cosmossdk.io/math" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" @@ -14,7 +15,7 @@ type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec - //other keepers + // other keepers restakingStateKeeper keeper.Keeper delegationKeeper operatortypes.ExpectDelegationInterface oracleKeeper operatortypes.ExpectOracleInterface @@ -51,7 +52,7 @@ func (k *Keeper) OracleInterface() operatortypes.ExpectOracleInterface { return k.oracleKeeper } -func (k *Keeper) GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 { +func (k *Keeper) GetUnbondingExpirationBlockNumber(_ sdk.Context, _ sdk.AccAddress, startHeight uint64) uint64 { return startHeight + operatortypes.UnbondingExpiration } @@ -70,5 +71,5 @@ type OperatorKeeper interface { OptOut(ctx sdk.Context, OperatorAddress sdk.AccAddress, AVSAddr string) error - Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error + Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashID string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error } diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go index cafef0564..26b76052b 100644 --- a/x/operator/keeper/msg_server.go +++ b/x/operator/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( context "context" "encoding/base64" + tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "github.com/ExocoreNetwork/exocore/x/operator/types" @@ -20,11 +21,11 @@ func (k *Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperat return nil, nil } -// OptInToChainId add for dogfood -func (k *Keeper) OptInToChainId( +// OptInToChainID add for dogfood +func (k *Keeper) OptInToChainID( goCtx context.Context, - req *types.OptInToChainIdRequest, -) (*types.OptInToChainIdResponse, error) { + req *types.OptInToChainIDRequest, +) (*types.OptInToChainIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { @@ -34,30 +35,30 @@ func (k *Keeper) OptInToChainId( if err != nil { return nil, err } - err = k.SetOperatorConsKeyForChainId( + err = k.SetOperatorConsKeyForChainID( ctx, addr, req.ChainId, key, ) if err != nil { return nil, err } - return &types.OptInToChainIdResponse{}, nil + return &types.OptInToChainIDResponse{}, nil } -func (k *Keeper) InitiateOptOutFromChainId( +func (k *Keeper) InitiateOptOutFromChainID( goCtx context.Context, - req *types.InitiateOptOutFromChainIdRequest, -) (*types.InitiateOptOutFromChainIdResponse, error) { + req *types.InitiateOptOutFromChainIDRequest, +) (*types.InitiateOptOutFromChainIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { return nil, err } - if err := k.InitiateOperatorOptOutFromChainId( + if err := k.InitiateOperatorOptOutFromChainID( ctx, addr, req.ChainId, ); err != nil { return nil, err } - return &types.InitiateOptOutFromChainIdResponse{}, nil + return &types.InitiateOptOutFromChainIDResponse{}, nil } func stringToPubKey(pubKey string) (key tmprotocrypto.PublicKey, err error) { diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 6f6add31f..338312d28 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -1,8 +1,10 @@ package keeper import ( - errorsmod "cosmossdk.io/errors" "fmt" + + errorsmod "cosmossdk.io/errors" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -21,7 +23,7 @@ func (k *Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortyp store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) // todo: think about the difference between init and update in future - //key := common.HexToAddress(incentive.Contract) + // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) store.Set(opAccAddr, bz) @@ -34,7 +36,7 @@ func (k *Keeper) OperatorInfo(ctx sdk.Context, addr string) (info *operatortypes return nil, errorsmod.Wrap(err, "GetOperatorInfo: error occurred when parse acc address from Bech32") } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) - //key := common.HexToAddress(incentive.Contract) + // key := common.HexToAddress(incentive.Contract) isExist := store.Has(opAccAddr) if !isExist { return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %suite", opAccAddr)) @@ -55,7 +57,7 @@ func (k *Keeper) IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool { func (k *Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, info *operatortypes.OptedInfo) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) - //check operator address validation + // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { return restakingtype.ErrOperatorAddr @@ -98,7 +100,7 @@ func (k *Keeper) IsOptedIn(ctx sdk.Context, operatorAddr, avsAddr string) bool { } func (k *Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) ([]string, error) { - //get all opted-in info + // get all opted-in info store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) iterator := sdk.KVStorePrefixIterator(store, []byte(operatorAddr)) defer iterator.Close() diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index d7b3f720a..d3609e773 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -44,7 +44,7 @@ func (suite *OperatorTestSuite) TestHistoricalOperatorInfo() { err = suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), &newInfo) suite.NoError(err) - //get historical operator info + // get historical operator info historicalQueryCtx, err := types.ContextForHistoricalState(suite.Ctx, height) suite.NoError(err) getInfo, err := suite.App.OperatorKeeper.GetOperatorInfo(historicalQueryCtx, &operatortype.GetOperatorInfoReq{ diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index c44e31d40..8c5fdf5ae 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -1,9 +1,11 @@ package keeper import ( + "fmt" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "fmt" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -11,15 +13,15 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ) -func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashId string, slashInfo operatortypes.OperatorSlashInfo) error { +func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashID string, slashInfo operatortypes.OperatorSlashInfo) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) - //check operator address validation + // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { return restakingtype.ErrOperatorAddr } - slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashId) + slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) if store.Has(slashInfoKey) { return errorsmod.Wrap(operatortypes.ErrSlashInfoExist, fmt.Sprintf("slashInfoKey:%suite", slashInfoKey)) } @@ -35,15 +37,15 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashProportion:%v", slashInfo.SlashProportion)) } - //save single operator delegation state + // save single operator delegation state bz := k.cdc.MustMarshal(&slashInfo) store.Set(slashInfoKey, bz) return nil } -func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashId string) (changeState *operatortypes.OperatorSlashInfo, err error) { +func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashID string) (changeState *operatortypes.OperatorSlashInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) - slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashId) + slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) isExit := store.Has(slashInfoKey) operatorSlashInfo := operatortypes.OperatorSlashInfo{} if isExit { @@ -105,9 +107,9 @@ func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator isExit := store.Has(key) if !isExit { return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetSlashAssetsState: key is %suite", key)) - } else { - value := store.Get(key) - k.cdc.MustUnmarshal(value, &ret) } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + return ret.Amount, nil } diff --git a/x/operator/keeper/setup_test.go b/x/operator/keeper/setup_test.go index 9c20336be..efb6ca9d3 100644 --- a/x/operator/keeper/setup_test.go +++ b/x/operator/keeper/setup_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "testing" + sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -8,7 +10,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/stretchr/testify/suite" - "testing" ) var s *OperatorTestSuite @@ -16,7 +17,7 @@ var s *OperatorTestSuite type OperatorTestSuite struct { testutil.BaseTestSuite - //needed by test + // needed by test operatorAddr sdk.AccAddress avsAddr string assetID string diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index 0bf229c51..185cb82ad 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -1,9 +1,11 @@ package keeper import ( + "fmt" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "fmt" + delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/operator/types" types2 "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" @@ -26,39 +28,39 @@ type SlashAssets struct { } func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, operatorAddr string, opAmount sdkmath.Int) error { - //get the AVS opted-in by the operator + // get the AVS opted-in by the operator avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) if err != nil { return err } - //get price and priceDecimal from oracle + // get price and priceDecimal from oracle price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetID) if err != nil { return err } - //get the decimal of asset + // get the decimal of asset assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } opUSDValue := CalculateShare(opAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) for _, avs := range avsList { - //get the assets supported by the AVS + // get the assets supported by the AVS avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avs) if err != nil { return err } if _, ok := avsSupportedAssets[assetID]; ok { - //UpdateStakerShare + // UpdateStakerShare err = k.UpdateStakerShare(ctx, avs, stakerID, operatorAddr, opUSDValue) if err != nil { return err } - //UpdateStateForAsset - changeState := types.AssetOptedInState{ + // UpdateStateForAsset + changeState := types.OptedInAssetState{ Amount: opAmount, Value: opUSDValue, } @@ -67,13 +69,13 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, op return err } - //UpdateOperatorShare + // UpdateOperatorShare err = k.UpdateOperatorShare(ctx, avs, operatorAddr, opUSDValue) if err != nil { return err } - //UpdateAVSShare + // UpdateAVSShare err = k.UpdateAVSShare(ctx, avs, opUSDValue) if err != nil { return err @@ -84,18 +86,18 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, op } // OptIn call this function to opt in AVS -func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { - //check optedIn info - if k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { +func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string) error { + // check optedIn info + if k.IsOptedIn(ctx, operatorAddress.String(), avsAddr) { return types.ErrAlreadyOptedIn } - //get the assets supported by the AVS - avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + // get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avsAddr) if err != nil { return err } - //get the Assets opted in the operator + // get the Assets opted in the operator operatorAssets, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) if err != nil { return err @@ -107,13 +109,13 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr assetInfoRecord := make(map[string]*AssetPriceAndDecimal) for assetID, operatorAssetState := range operatorAssets { - //get price and priceDecimal from oracle + // get price and priceDecimal from oracle price, decimal, err := k.oracleKeeper.GetSpecifiedAssetsPrice(ctx, assetID) if err != nil { return err } - //get the decimal of asset + // get the decimal of asset assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err @@ -127,12 +129,12 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr operatorUSDValue := CalculateShare(operatorAssetState.OperatorOwnAmountOrWantChangeValue, price, assetInfo.AssetBasicInfo.Decimals, decimal) operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(operatorUSDValue) - //UpdateStateForAsset - changeState := types.AssetOptedInState{ + // UpdateStateForAsset + changeState := types.OptedInAssetState{ Amount: operatorAssetState.TotalAmountOrWantChangeValue, Value: assetUSDValue, } - err = k.UpdateStateForAsset(ctx, assetID, AVSAddr, operatorAddress.String(), changeState) + err = k.UpdateStateForAsset(ctx, assetID, avsAddr, operatorAddress.String(), changeState) if err != nil { return err } @@ -140,24 +142,24 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr assetFilter[assetID] = nil } - //update the share value of operator itself, the input stakerID should be empty - err = k.UpdateStakerShare(ctx, AVSAddr, "", operatorAddress.String(), operatorOwnAssetUSDValue) + // update the share value of operator itself, the input stakerID should be empty + err = k.UpdateStakerShare(ctx, avsAddr, "", operatorAddress.String(), operatorOwnAssetUSDValue) if err != nil { return err } - //UpdateAVSShare - err = k.UpdateAVSShare(ctx, AVSAddr, totalAssetUSDValue) + // UpdateAVSShare + err = k.UpdateAVSShare(ctx, avsAddr, totalAssetUSDValue) if err != nil { return err } - //UpdateOperatorShare - err = k.UpdateOperatorShare(ctx, AVSAddr, operatorAddress.String(), totalAssetUSDValue) + // UpdateOperatorShare + err = k.UpdateOperatorShare(ctx, avsAddr, operatorAddress.String(), totalAssetUSDValue) if err != nil { return err } - //UpdateStakerShare + // UpdateStakerShare relatedAssetsState, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetFilter) if err != nil { return err @@ -166,27 +168,28 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr for stakerID, assetState := range relatedAssetsState { stakerAssetsUSDValue := sdkmath.LegacyNewDec(0) for assetID, amount := range assetState { - singleAssetUSDValue := CalculateShare(amount.CanUndelegationAmount, assetInfoRecord[assetID].Price, assetInfoRecord[assetID].Decimal, assetInfoRecord[assetID].PriceDecimal) + singleAssetUSDValue := CalculateShare(amount.CanBeUndelegatedAmount, assetInfoRecord[assetID].Price, assetInfoRecord[assetID].Decimal, assetInfoRecord[assetID].PriceDecimal) stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) } - err = k.UpdateStakerShare(ctx, AVSAddr, stakerID, operatorAddress.String(), stakerAssetsUSDValue) + err = k.UpdateStakerShare(ctx, avsAddr, stakerID, operatorAddress.String(), stakerAssetsUSDValue) if err != nil { return err } } - //update opted-in info - slashContract, err := k.avsKeeper.GetAvsSlashContract(ctx, AVSAddr) + // update opted-in info + slashContract, err := k.avsKeeper.GetAvsSlashContract(ctx, avsAddr) if err != nil { return err } optedInfo := &types.OptedInfo{ - SlashContract: slashContract, + SlashContract: slashContract, + // #nosec G701 OptedInHeight: uint64(ctx.BlockHeight()), OptedOutHeight: types.DefaultOptedOutHeight, } - err = k.UpdateOptedInfo(ctx, operatorAddress.String(), AVSAddr, optedInfo) + err = k.UpdateOptedInfo(ctx, operatorAddress.String(), avsAddr, optedInfo) if err != nil { return err } @@ -194,18 +197,18 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } // OptOut call this function to opt out of AVS -func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error { - //check optedIn info - if !k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { +func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string) error { + // check optedIn info + if !k.IsOptedIn(ctx, operatorAddress.String(), avsAddr) { return types.ErrNotOptedIn } - //get the assets supported by the AVS - avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, AVSAddr) + // get the assets supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avsAddr) if err != nil { return err } - //get the Assets opted in the operator + // get the Assets opted in the operator operatorAssets, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) if err != nil { return err @@ -214,14 +217,14 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr assetFilter := make(map[string]interface{}) for assetID := range operatorAssets { - err = k.DeleteAssetState(ctx, assetID, AVSAddr, operatorAddress.String()) + err = k.DeleteAssetState(ctx, assetID, avsAddr, operatorAddress.String()) if err != nil { return err } assetFilter[assetID] = nil } - avsOperatorTotalValue, err := k.GetOperatorShare(ctx, AVSAddr, operatorAddress.String()) + avsOperatorTotalValue, err := k.GetOperatorShare(ctx, avsAddr, operatorAddress.String()) if err != nil { return err } @@ -229,42 +232,43 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr return errorsmod.Wrap(types.ErrTheValueIsNegative, fmt.Sprintf("OptOut,avsOperatorTotalValue:%suite", avsOperatorTotalValue)) } - //delete the share value of operator itself, the input stakerID should be empty - err = k.DeleteStakerShare(ctx, AVSAddr, "", operatorAddress.String()) + // delete the share value of operator itself, the input stakerID should be empty + err = k.DeleteStakerShare(ctx, avsAddr, "", operatorAddress.String()) if err != nil { return err } - //UpdateAVSShare - err = k.UpdateAVSShare(ctx, AVSAddr, avsOperatorTotalValue.Neg()) + // UpdateAVSShare + err = k.UpdateAVSShare(ctx, avsAddr, avsOperatorTotalValue.Neg()) if err != nil { return err } - //DeleteOperatorShare - err = k.DeleteOperatorShare(ctx, AVSAddr, operatorAddress.String()) + // DeleteOperatorShare + err = k.DeleteOperatorShare(ctx, avsAddr, operatorAddress.String()) if err != nil { return err } - //DeleteStakerShare + // DeleteStakerShare relatedAssetsState, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetFilter) if err != nil { return err } for stakerID := range relatedAssetsState { - err = k.DeleteStakerShare(ctx, AVSAddr, stakerID, operatorAddress.String()) + err = k.DeleteStakerShare(ctx, avsAddr, stakerID, operatorAddress.String()) if err != nil { return err } } - //set opted-out height - optedInfo, err := k.GetOptedInfo(ctx, operatorAddress.String(), AVSAddr) + // set opted-out height + optedInfo, err := k.GetOptedInfo(ctx, operatorAddress.String(), avsAddr) if err != nil { return err } + // #nosec G701 optedInfo.OptedOutHeight = uint64(ctx.BlockHeight()) - err = k.UpdateOptedInfo(ctx, operatorAddress.String(), AVSAddr, optedInfo) + err = k.UpdateOptedInfo(ctx, operatorAddress.String(), avsAddr, optedInfo) if err != nil { return err } @@ -272,19 +276,19 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr } // GetAssetsAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. -func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssets, error) { +func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssets, error) { ret := &SlashAssets{ slashStakerInfo: make(map[string]map[string]*slashAmounts, 0), slashOperatorInfo: make(map[string]*slashAmounts, 0), } - //get the state when the slash occurred + // get the state when the slash occurred historicalSateCtx, err := types2.ContextForHistoricalState(ctx, occurredSateHeight) if err != nil { return nil, err } - //get assetsInfo supported by AVS - assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(historicalSateCtx, AVSAddr) + // get assetsInfo supported by AVS + assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(historicalSateCtx, avsAddr) if err != nil { return nil, err } @@ -293,24 +297,24 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc return nil, err } - //get the Assets opted in the operator + // get the Assets opted in the operator historyOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(historicalSateCtx, operatorAddress, assetsFilter) if err != nil { return nil, err } - //calculate the actual slash amount according to the history and current state + // calculate the actual slash amount according to the history and current state currentStakerAssets, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } - //get the Assets opted in the operator + // get the Assets opted in the operator currentOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, assetsFilter) if err != nil { return nil, err } - //calculate the actual slash amount for staker + // calculate the actual slash amount for staker for stakerID, assetsState := range currentStakerAssets { if historyAssetState, ok := historyStakerAssets[stakerID]; ok { for assetID, curState := range assetsState { @@ -318,12 +322,12 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc if _, exist := ret.slashStakerInfo[stakerID]; !exist { ret.slashStakerInfo[stakerID] = make(map[string]*slashAmounts, 0) } - shouldSlashAmount := slashProportion.MulInt(historyState.CanUndelegationAmount).TruncateInt() - if curState.CanUndelegationAmount.LT(shouldSlashAmount) { - ret.slashStakerInfo[stakerID][assetID].AmountFromOptedIn = curState.CanUndelegationAmount - remainShouldSlash := shouldSlashAmount.Sub(curState.CanUndelegationAmount) - if curState.UndelegatableAmountAfterSlash.LT(remainShouldSlash) { - ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = curState.UndelegatableAmountAfterSlash + shouldSlashAmount := slashProportion.MulInt(historyState.CanBeUndelegatedAmount).TruncateInt() + if curState.CanBeUndelegatedAmount.LT(shouldSlashAmount) { + ret.slashStakerInfo[stakerID][assetID].AmountFromOptedIn = curState.CanBeUndelegatedAmount + remainShouldSlash := shouldSlashAmount.Sub(curState.CanBeUndelegatedAmount) + if curState.CanBeUndelegatedAfterSlash.LT(remainShouldSlash) { + ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = curState.CanBeUndelegatedAfterSlash } else { ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = remainShouldSlash } @@ -335,15 +339,15 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc } } - //calculate the actual slash amount for operator + // calculate the actual slash amount for operator for assetID, curAssetState := range currentOperatorAssetsState { if historyAssetState, ok := historyOperatorAssetsState[assetID]; ok { shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorOwnAmountOrWantChangeValue).TruncateInt() if curAssetState.OperatorOwnAmountOrWantChangeValue.LT(shouldSlashAmount) { ret.slashOperatorInfo[assetID].AmountFromOptedIn = curAssetState.OperatorOwnAmountOrWantChangeValue remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmountOrWantChangeValue) - if curAssetState.OperatorUnbondableAmountAfterSlash.LT(remainShouldSlash) { - ret.slashOperatorInfo[assetID].AmountFromUnbonding = curAssetState.OperatorUnbondableAmountAfterSlash + if curAssetState.OperatorCanUnbondAfterSlash.LT(remainShouldSlash) { + ret.slashOperatorInfo[assetID].AmountFromUnbonding = curAssetState.OperatorCanUnbondAfterSlash } else { ret.slashOperatorInfo[assetID].AmountFromUnbonding = remainShouldSlash } @@ -358,12 +362,12 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, executeHeight uint64) error { for stakerID, slashAssets := range slashStakerInfo { for assetID, slashInfo := range slashAssets { - //handle the state that needs to be updated when slashing both opted-in and unbonding assets - //update delegation state + // handle the state that needs to be updated when slashing both opted-in and unbonding assets + // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegationAmount: slashInfo.AmountFromOptedIn.Neg(), - UndelegatableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + CanBeUndelegatedAmount: slashInfo.AmountFromOptedIn.Neg(), + CanBeUndelegatedAfterSlash: slashInfo.AmountFromUnbonding.Neg(), } err := k.delegationKeeper.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -375,7 +379,7 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl } slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) - //update staker and operator assets state + // update staker and operator assets state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetOrChangeInfo{ TotalDepositAmountOrWantChangeValue: slashSumValue.Neg(), }) @@ -383,20 +387,20 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl return err } - //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + // Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. err = k.UpdateSlashAssetsState(ctx, assetID, stakerID, executeHeight, slashSumValue) if err != nil { return err } - //handle the state that needs to be updated when slashing opted-in assets + // handle the state that needs to be updated when slashing opted-in assets err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), }) if err != nil { return err } - //decrease the related share value + // decrease the related share value err = k.UpdateOptedInAssetsState(ctx, stakerID, assetID, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) if err != nil { return err @@ -409,23 +413,23 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, executeHeight uint64) error { for assetID, slashInfo := range slashOperatorInfo { slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) - //handle the state that needs to be updated when slashing both opted-in and unbonding assets + // handle the state that needs to be updated when slashing both opted-in and unbonding assets err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetOrChangeInfo{ TotalAmountOrWantChangeValue: slashSumValue.Neg(), OperatorOwnAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), - OperatorUnbondableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + OperatorCanUnbondAfterSlash: slashInfo.AmountFromUnbonding.Neg(), }) if err != nil { return err } - //Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. + // Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. err = k.UpdateSlashAssetsState(ctx, assetID, operatorAddress.String(), executeHeight, slashSumValue) if err != nil { return err } - //handle the state that needs to be updated when slashing opted-in assets - //decrease the related share value + // handle the state that needs to be updated when slashing opted-in assets + // decrease the related share value err = k.UpdateOptedInAssetsState(ctx, "", assetID, operatorAddress.String(), slashInfo.AmountFromOptedIn.Neg()) if err != nil { return err @@ -435,22 +439,22 @@ func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, } // Slash The occurredSateHeight should be the height that has the latest stable state. -func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, slashContract, slashId string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error { +func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, slashContract, slashID string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error { height := ctx.BlockHeight() if occurredSateHeight > height { return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("occurredSateHeight:%d,curHeight:%d", occurredSateHeight, height)) } - //get the state when the slash occurred - //get the opted-in info + // get the state when the slash occurred + // get the opted-in info historicalSateCtx, err := types2.ContextForHistoricalState(ctx, occurredSateHeight) if err != nil { return err } - if !k.IsOptedIn(ctx, operatorAddress.String(), AVSAddr) { + if !k.IsOptedIn(ctx, operatorAddress.String(), avsAddr) { return types.ErrNotOptedIn } - optedInfo, err := k.GetOptedInfo(historicalSateCtx, operatorAddress.String(), AVSAddr) + optedInfo, err := k.GetOptedInfo(historicalSateCtx, operatorAddress.String(), avsAddr) if err != nil { return err } @@ -458,7 +462,7 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, return errorsmod.Wrap(types.ErrSlashContractNotMatch, fmt.Sprintf("input slashContract:%suite, opted-in slash contract:%suite", slashContract, optedInfo.SlashContract)) } - //todo: recording the slash event might be moved to the slash module + // todo: recording the slash event might be moved to the slash module slashInfo := types.OperatorSlashInfo{ SlashContract: slashContract, SlashHeight: height, @@ -466,22 +470,22 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr, SlashProportion: slashProportion, ExecuteHeight: height + types.SlashVetoDuration, } - err = k.UpdateOperatorSlashInfo(ctx, operatorAddress.String(), AVSAddr, slashId, slashInfo) + err = k.UpdateOperatorSlashInfo(ctx, operatorAddress.String(), avsAddr, slashID, slashInfo) if err != nil { return err } // get the assets and amounts that should be slashed - assetsSlashInfo, err := k.GetAssetsAmountToSlash(ctx, operatorAddress, AVSAddr, occurredSateHeight, slashProportion) + assetsSlashInfo, err := k.GetAssetsAmountToSlash(ctx, operatorAddress, avsAddr, occurredSateHeight, slashProportion) if err != nil { return err } - + // #nosec G701 err = k.SlashStaker(ctx, operatorAddress, assetsSlashInfo.slashStakerInfo, uint64(slashInfo.ExecuteHeight)) if err != nil { return err } - + // #nosec G701 err = k.SlashOperator(ctx, operatorAddress, assetsSlashInfo.slashOperatorInfo, uint64(slashInfo.ExecuteHeight)) if err != nil { return err diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index 53f560b1f..09e68b4b1 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "strings" + sdkmath "cosmossdk.io/math" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" @@ -9,14 +11,13 @@ import ( restakingTypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "strings" ) type StateForCheck struct { OptedInfo *operatorTypes.OptedInfo AVSTotalShare sdkmath.LegacyDec AVSOperatorShare sdkmath.LegacyDec - AssetState *operatorTypes.AssetOptedInState + AssetState *operatorTypes.OptedInAssetState OperatorShare sdkmath.LegacyDec StakerShare sdkmath.LegacyDec } @@ -37,7 +38,7 @@ func (suite *OperatorTestSuite) prepare() { suite.updatedAmountForOptIn = sdkmath.NewInt(20) suite.stakerID, suite.assetID = restakingTypes.GetStakeIDAndAssetID(suite.clientChainLzID, suite.Address[:], suite.assetAddr[:]) - //staking assets + // staking assets depositParam := &keeper.DepositParams{ ClientChainLzID: suite.clientChainLzID, Action: restakingTypes.Deposit, @@ -48,7 +49,7 @@ func (suite *OperatorTestSuite) prepare() { err = suite.App.DepositKeeper.Deposit(suite.Ctx, depositParam) suite.NoError(err) - //register operator + // register operator registerReq := &operatorTypes.RegisterOperatorReq{ FromAddress: suite.operatorAddr.String(), Info: &operatorTypes.OperatorInfo{ @@ -58,7 +59,7 @@ func (suite *OperatorTestSuite) prepare() { _, err = suite.App.OperatorKeeper.RegisterOperator(suite.Ctx, registerReq) suite.NoError(err) - //delegate to operator + // delegate to operator delegationParam := &delegationKeeper.DelegationOrUndelegationParams{ ClientChainLzID: suite.clientChainLzID, Action: restakingTypes.DelegateTo, @@ -74,7 +75,7 @@ func (suite *OperatorTestSuite) prepare() { } func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { - //check opted info + // check opted info optInfo, err := suite.App.OperatorKeeper.GetOptedInfo(suite.Ctx, suite.operatorAddr.String(), suite.avsAddr) if expectedState.OptedInfo == nil { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) @@ -82,7 +83,7 @@ func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { suite.NoError(err) suite.Equal(*expectedState.OptedInfo, *optInfo) } - //check total USD value for AVS and operator + // check total USD value for AVS and operator value, err := suite.App.OperatorKeeper.GetAVSShare(suite.Ctx, suite.avsAddr) if expectedState.AVSTotalShare.IsNil() { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) @@ -99,7 +100,7 @@ func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { suite.Equal(expectedState.AVSOperatorShare, value) } - //check assets state for AVS and operator + // check assets state for AVS and operator assetState, err := suite.App.OperatorKeeper.GetAssetState(suite.Ctx, suite.assetID, suite.avsAddr, suite.operatorAddr.String()) if expectedState.AssetState == nil { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) @@ -108,7 +109,7 @@ func (suite *OperatorTestSuite) CheckState(expectedState *StateForCheck) { suite.Equal(*expectedState.AssetState, *assetState) } - //check asset USD share for staker and operator + // check asset USD share for staker and operator operatorShare, err := suite.App.OperatorKeeper.GetStakerShare(suite.Ctx, suite.avsAddr, "", suite.operatorAddr.String()) if expectedState.OperatorShare.IsNil() { suite.True(strings.Contains(err.Error(), operatorTypes.ErrNoKeyInTheStore.Error())) @@ -129,7 +130,7 @@ func (suite *OperatorTestSuite) TestOptIn() { suite.prepare() err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, suite.avsAddr) suite.NoError(err) - //check if the related state is correct + // check if the related state is correct price, decimal, err := suite.App.OperatorKeeper.OracleInterface().GetSpecifiedAssetsPrice(suite.Ctx, suite.assetID) share := operatorKeeper.CalculateShare(suite.delegationAmount, price, suite.assetDecimal, decimal) expectedState := &StateForCheck{ @@ -139,7 +140,7 @@ func (suite *OperatorTestSuite) TestOptIn() { }, AVSTotalShare: share, AVSOperatorShare: share, - AssetState: &operatorTypes.AssetOptedInState{ + AssetState: &operatorTypes.OptedInAssetState{ Amount: suite.delegationAmount, Value: share, }, @@ -206,7 +207,7 @@ func (suite *OperatorTestSuite) TestUpdateOptedInAssetsState() { }, AVSTotalShare: newShare, AVSOperatorShare: newShare, - AssetState: &operatorTypes.AssetOptedInState{ + AssetState: &operatorTypes.OptedInAssetState{ Amount: suite.delegationAmount.Add(suite.updatedAmountForOptIn), Value: newShare, }, @@ -228,5 +229,4 @@ func (suite *OperatorTestSuite) TestSlash() { suite.NextBlock() } suite.Equal(runToHeight, suite.Ctx.BlockHeight()) - } diff --git a/x/operator/module.go b/x/operator/module.go index f14f48755..cf870c535 100644 --- a/x/operator/module.go +++ b/x/operator/module.go @@ -2,6 +2,7 @@ package operator import ( "context" + "github.com/ExocoreNetwork/exocore/x/operator/client/cli" "github.com/ExocoreNetwork/exocore/x/operator/keeper" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" @@ -16,8 +17,6 @@ import ( "github.com/spf13/cobra" ) -const consensusVersion = 0 - // type check to ensure the interface is properly implemented var ( _ module.AppModule = AppModule{} @@ -58,7 +57,7 @@ type AppModule struct { keeper keeper.Keeper } -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { +func NewAppModule(_ codec.Codec, keeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: keeper, @@ -77,13 +76,13 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { operatortypes.RegisterQueryServer(cfg.QueryServer(), &am.keeper) } -func (am AppModule) GenerateGenesisState(input *module.SimulationState) { +func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { } -func (am AppModule) RegisterStoreDecoder(registry sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return []simtypes.WeightedOperation{} } diff --git a/x/operator/types/app_chain_utils.go b/x/operator/types/app_chain_utils.go index 9c3a96e9c..d776a976b 100644 --- a/x/operator/types/app_chain_utils.go +++ b/x/operator/types/app_chain_utils.go @@ -16,16 +16,17 @@ func AppendMany(byteses ...[]byte) (out []byte) { return out } -// ChainIdWithLenKey returns the key with the following format: +// ChainIDWithLenKey returns the key with the following format: // bytePrefix | len(chainId) | chainId // This is similar to Solidity's ABI encoding. -func ChainIdWithLenKey(chainId string) []byte { - chainIdL := len(chainId) +func ChainIDWithLenKey(chainID string) []byte { + chainIDL := len(chainID) return AppendMany( - // Append the chainId length - sdk.Uint64ToBigEndian(uint64(chainIdL)), - // Append the chainId - []byte(chainId), + // Append the chainID length + // #nosec G701 + sdk.Uint64ToBigEndian(uint64(chainIDL)), + // Append the chainID + []byte(chainID), ) } diff --git a/x/operator/types/codec.go b/x/operator/types/codec.go index 71e40f49e..89bd73c1a 100644 --- a/x/operator/types/codec.go +++ b/x/operator/types/codec.go @@ -21,11 +21,6 @@ var ( AminoCdc = codec.NewAminoCodec(amino) ) -const ( - // Amino names - registerOperator = "exocore/RegisterOperatorReq" -) - // NOTE: This is required for the GetSignBytes function func init() { RegisterLegacyAminoCodec(amino) @@ -37,8 +32,8 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &RegisterOperatorReq{}, - &OptInToChainIdRequest{}, - &InitiateOptOutFromChainIdRequest{}, + &OptInToChainIDRequest{}, + &InitiateOptOutFromChainIDRequest{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } @@ -46,6 +41,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { // RegisterLegacyAminoCodec registers the necessary x/revenue interfaces and // concrete types on the provided LegacyAmino codec. These types are used for // Amino JSON serialization and EIP-712 compatibility. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - //cdc.RegisterConcrete(&RegisterOperatorReq{}, registerOperator, nil) +func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { + // cdc.RegisterConcrete(&RegisterOperatorReq{}, registerOperator, nil) } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index ebd102cb9..21099becf 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -21,18 +21,18 @@ type PriceChange struct { Decimal uint8 } type ExpectOracleInterface interface { - GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdkmath.Int, uint8, error) + GetSpecifiedAssetsPrice(ctx sdk.Context, assetsID string) (sdkmath.Int, uint8, error) GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) } type MockOracle struct{} -func (MockOracle) GetSpecifiedAssetsPrice(ctx sdk.Context, assetsId string) (sdkmath.Int, uint8, error) { +func (MockOracle) GetSpecifiedAssetsPrice(_ sdk.Context, _ string) (sdkmath.Int, uint8, error) { return sdkmath.NewInt(1), 0, nil } -func (MockOracle) GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) { - //use USDT as the mock asset +func (MockOracle) GetPriceChangeAssets(_ sdk.Context) (map[string]*PriceChange, error) { + // use USDT as the mock asset ret := make(map[string]*PriceChange, 0) usdtAssetID := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" ret[usdtAssetID] = &PriceChange{ @@ -45,15 +45,15 @@ func (MockOracle) GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange type MockAVS struct{} -func (MockAVS) GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) { - //set USDT as the default asset supported by AVS +func (MockAVS) GetAvsSupportedAssets(_ sdk.Context, _ string) (map[string]interface{}, error) { + // set USDT as the default asset supported by AVS ret := make(map[string]interface{}) usdtAssetID := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" ret[usdtAssetID] = nil return ret, nil } -func (MockAVS) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) { +func (MockAVS) GetAvsSlashContract(_ sdk.Context, _ string) (string, error) { return "", nil } @@ -69,7 +69,7 @@ type SlashKeeper interface { } type RedelegationKeeper interface { - AppChainInfoIsExist(ctx sdk.Context, chainId string) bool + AppChainInfoIsExist(ctx sdk.Context, chainID string) bool } type OperatorConsentHooks interface { @@ -77,7 +77,7 @@ type OperatorConsentHooks interface { AfterOperatorOptIn( ctx sdk.Context, addr sdk.AccAddress, - chainId string, + chainID string, pubKey tmprotocrypto.PublicKey, ) // This hook is called when an operator's consensus key is replaced for @@ -87,13 +87,13 @@ type OperatorConsentHooks interface { addr sdk.AccAddress, oldKey tmprotocrypto.PublicKey, newKey tmprotocrypto.PublicKey, - chainId string, + chainID string, ) // This hook is called when an operator opts out of a chain. AfterOperatorOptOutInitiated( ctx sdk.Context, addr sdk.AccAddress, - chainId string, + chainID string, key tmprotocrypto.PublicKey, ) } diff --git a/x/operator/types/hooks.go b/x/operator/types/hooks.go index 66a6465b2..0c3441ab6 100644 --- a/x/operator/types/hooks.go +++ b/x/operator/types/hooks.go @@ -16,11 +16,11 @@ func NewMultiOperatorConsentHooks(hooks ...OperatorConsentHooks) MultiOperatorCo func (hooks MultiOperatorConsentHooks) AfterOperatorOptIn( ctx sdk.Context, addr sdk.AccAddress, - chainId string, + chainID string, pubKey tmprotocrypto.PublicKey, ) { for _, hook := range hooks { - hook.AfterOperatorOptIn(ctx, addr, chainId, pubKey) + hook.AfterOperatorOptIn(ctx, addr, chainID, pubKey) } } @@ -29,17 +29,17 @@ func (hooks MultiOperatorConsentHooks) AfterOperatorKeyReplacement( addr sdk.AccAddress, oldKey tmprotocrypto.PublicKey, newAddr tmprotocrypto.PublicKey, - chainId string, + chainID string, ) { for _, hook := range hooks { - hook.AfterOperatorKeyReplacement(ctx, addr, oldKey, newAddr, chainId) + hook.AfterOperatorKeyReplacement(ctx, addr, oldKey, newAddr, chainID) } } func (hooks MultiOperatorConsentHooks) AfterOperatorOptOutInitiated( - ctx sdk.Context, addr sdk.AccAddress, chainId string, key tmprotocrypto.PublicKey, + ctx sdk.Context, addr sdk.AccAddress, chainID string, key tmprotocrypto.PublicKey, ) { for _, hook := range hooks { - hook.AfterOperatorOptOutInitiated(ctx, addr, chainId, key) + hook.AfterOperatorOptOutInitiated(ctx, addr, chainID, key) } } diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index e4130c014..e83781e8f 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -1,10 +1,11 @@ package types import ( + "math" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" - "math" ) // constants @@ -49,12 +50,12 @@ const ( prefixSlashAssetsState - //add keys for dogfood - BytePrefixForOperatorAndChainIdToConsKey = iota - BytePrefixForOperatorAndChainIdToPrevConsKey - BytePrefixForChainIdAndOperatorToConsKey - BytePrefixForChainIdAndConsKeyToOperator - BytePrefixForOperatorOptOutFromChainId + // add keys for dogfood + BytePrefixForOperatorAndChainIDToConsKey = iota + BytePrefixForOperatorAndChainIDToPrevConsKey + BytePrefixForChainIDAndOperatorToConsKey + BytePrefixForChainIDAndConsKeyToOperator + BytePrefixForOperatorOptOutFromChainID ) var ( @@ -71,7 +72,7 @@ var ( KeyPrefixAVSOperatorAssetsTotalValue = []byte{prefixAVSOperatorAssetsTotalValue} // KeyPrefixOperatorAVSSingleAssetState key-value: - // assetID + '/' + AVSAddr + '/' + operatorAddr -> AssetOptedInState + // assetID + '/' + AVSAddr + '/' + operatorAddr -> OptedInAssetState KeyPrefixOperatorAVSSingleAssetState = []byte{prefixOperatorAVSSingleAssetState} // KeyPrefixAVSOperatorStakerShareState key-value: @@ -94,8 +95,8 @@ func KeyPrefix(p string) []byte { return []byte(p) } -func AddrAndChainIdKey(prefix byte, addr sdk.AccAddress, chainId string) []byte { - partialKey := ChainIdWithLenKey(chainId) +func AddrAndChainIDKey(prefix byte, addr sdk.AccAddress, chainID string) []byte { + partialKey := ChainIDWithLenKey(chainID) return AppendMany( // Append the prefix []byte{prefix}, @@ -107,50 +108,50 @@ func AddrAndChainIdKey(prefix byte, addr sdk.AccAddress, chainId string) []byte ) } -func ChainIdAndAddrKey(prefix byte, chainId string, addr sdk.AccAddress) []byte { - partialKey := ChainIdWithLenKey(chainId) +func ChainIDAndAddrKey(prefix byte, chainID string, addr sdk.AccAddress) []byte { + partialKey := ChainIDWithLenKey(chainID) return AppendMany( // Append the prefix []byte{prefix}, // Append the partialKey so that we can look for any operator keys - // corresponding to this chainId easily. + // corresponding to this chainID easily. partialKey, addr, ) } -func KeyForOperatorAndChainIdToConsKey(addr sdk.AccAddress, chainId string) []byte { - return AddrAndChainIdKey( - BytePrefixForOperatorAndChainIdToConsKey, - addr, chainId, +func KeyForOperatorAndChainIDToConsKey(addr sdk.AccAddress, chainID string) []byte { + return AddrAndChainIDKey( + BytePrefixForOperatorAndChainIDToConsKey, + addr, chainID, ) } -func KeyForOperatorAndChainIdToPrevConsKey(addr sdk.AccAddress, chainId string) []byte { - return AddrAndChainIdKey( - BytePrefixForOperatorAndChainIdToPrevConsKey, - addr, chainId, +func KeyForOperatorAndChainIDToPrevConsKey(addr sdk.AccAddress, chainID string) []byte { + return AddrAndChainIDKey( + BytePrefixForOperatorAndChainIDToPrevConsKey, + addr, chainID, ) } -func KeyForChainIdAndOperatorToConsKey(chainId string, addr sdk.AccAddress) []byte { - return ChainIdAndAddrKey( - BytePrefixForChainIdAndOperatorToConsKey, - chainId, addr, +func KeyForChainIDAndOperatorToConsKey(chainID string, addr sdk.AccAddress) []byte { + return ChainIDAndAddrKey( + BytePrefixForChainIDAndOperatorToConsKey, + chainID, addr, ) } -func KeyForChainIdAndConsKeyToOperator(chainId string, addr sdk.ConsAddress) []byte { +func KeyForChainIDAndConsKeyToOperator(chainID string, addr sdk.ConsAddress) []byte { return AppendMany( - []byte{BytePrefixForChainIdAndConsKeyToOperator}, - ChainIdWithLenKey(chainId), + []byte{BytePrefixForChainIDAndConsKeyToOperator}, + ChainIDWithLenKey(chainID), addr, ) } -func KeyForOperatorOptOutFromChainId(addr sdk.AccAddress, chainId string) []byte { +func KeyForOperatorOptOutFromChainID(addr sdk.AccAddress, chainID string) []byte { return AppendMany( - []byte{BytePrefixForOperatorOptOutFromChainId}, addr, - ChainIdWithLenKey(chainId), + []byte{BytePrefixForOperatorOptOutFromChainID}, addr, + ChainIDWithLenKey(chainID), ) } diff --git a/x/operator/types/msg.go b/x/operator/types/msg.go index 52cfd2738..8d2bb19e5 100644 --- a/x/operator/types/msg.go +++ b/x/operator/types/msg.go @@ -9,8 +9,8 @@ var ( _ sdk.Msg = &RegisterOperatorReq{} // add for dogfood - _ sdk.Msg = &OptInToChainIdRequest{} - _ sdk.Msg = &InitiateOptOutFromChainIdRequest{} + _ sdk.Msg = &OptInToChainIDRequest{} + _ sdk.Msg = &InitiateOptOutFromChainIDRequest{} ) // GetSigners returns the expected signers for a MsgUpdateParams message. @@ -32,24 +32,24 @@ func (m *RegisterOperatorReq) GetSignBytes() []byte { return nil } -func (m *OptInToChainIdRequest) GetSigners() []sdk.AccAddress { +func (m *OptInToChainIDRequest) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.Address) return []sdk.AccAddress{addr} } -func (m *OptInToChainIdRequest) ValidateBasic() error { +func (m *OptInToChainIDRequest) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { return errorsmod.Wrap(err, "invalid from address") } return nil } -func (m *InitiateOptOutFromChainIdRequest) GetSigners() []sdk.AccAddress { +func (m *InitiateOptOutFromChainIDRequest) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.Address) return []sdk.AccAddress{addr} } -func (m *InitiateOptOutFromChainIdRequest) ValidateBasic() error { +func (m *InitiateOptOutFromChainIDRequest) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { return errorsmod.Wrap(err, "invalid from address") } diff --git a/x/operator/types/query.pb.go b/x/operator/types/query.pb.go index 0cc75c5ff..af21b9d31 100644 --- a/x/operator/types/query.pb.go +++ b/x/operator/types/query.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -32,8 +31,10 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryOperatorInfoReq is the request to obtain the operator information. type GetOperatorInfoReq struct { - OperatorAddr string `protobuf:"bytes,1,opt,name=OperatorAddr,proto3" json:"OperatorAddr,omitempty"` + // operator_addr is the operator address. + OperatorAddr string `protobuf:"bytes,1,opt,name=operator_addr,json=operatorAddr,proto3" json:"operator_addr,omitempty"` } func (m *GetOperatorInfoReq) Reset() { *m = GetOperatorInfoReq{} } @@ -76,23 +77,26 @@ func (m *GetOperatorInfoReq) GetOperatorAddr() string { return "" } -type QueryOperatorConsKeyForChainIdRequest struct { - Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` +// QueryOperatorConsKeyForChainIDRequest is the request to obtain the consensus public key of the operator +type QueryOperatorConsKeyForChainIDRequest struct { + // addr is the ACC address of operator + Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` + // chain_id is the id of the chain served by the operator ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (m *QueryOperatorConsKeyForChainIdRequest) Reset() { *m = QueryOperatorConsKeyForChainIdRequest{} } -func (m *QueryOperatorConsKeyForChainIdRequest) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorConsKeyForChainIdRequest) ProtoMessage() {} -func (*QueryOperatorConsKeyForChainIdRequest) Descriptor() ([]byte, []int) { +func (m *QueryOperatorConsKeyForChainIDRequest) Reset() { *m = QueryOperatorConsKeyForChainIDRequest{} } +func (m *QueryOperatorConsKeyForChainIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorConsKeyForChainIDRequest) ProtoMessage() {} +func (*QueryOperatorConsKeyForChainIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f91e795a3cecbdbf, []int{1} } -func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -102,50 +106,52 @@ func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Marshal(b []byte, determinis return b[:n], nil } } -func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest.Merge(m, src) +func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest.Merge(m, src) } -func (m *QueryOperatorConsKeyForChainIdRequest) XXX_Size() int { +func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Size() int { return m.Size() } -func (m *QueryOperatorConsKeyForChainIdRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest.DiscardUnknown(m) +func (m *QueryOperatorConsKeyForChainIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryOperatorConsKeyForChainIdRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest proto.InternalMessageInfo -func (m *QueryOperatorConsKeyForChainIdRequest) GetAddr() string { +func (m *QueryOperatorConsKeyForChainIDRequest) GetAddr() string { if m != nil { return m.Addr } return "" } -func (m *QueryOperatorConsKeyForChainIdRequest) GetChainId() string { +func (m *QueryOperatorConsKeyForChainIDRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -type QueryOperatorConsKeyForChainIdResponse struct { +// QueryOperatorConsKeyForChainIDResponse is the response for QueryOperatorConsKeyForChainId +type QueryOperatorConsKeyForChainIDResponse struct { + // public_key is the consensus public key of the operator PublicKey crypto.PublicKey `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key"` } -func (m *QueryOperatorConsKeyForChainIdResponse) Reset() { - *m = QueryOperatorConsKeyForChainIdResponse{} +func (m *QueryOperatorConsKeyForChainIDResponse) Reset() { + *m = QueryOperatorConsKeyForChainIDResponse{} } -func (m *QueryOperatorConsKeyForChainIdResponse) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorConsKeyForChainIdResponse) ProtoMessage() {} -func (*QueryOperatorConsKeyForChainIdResponse) Descriptor() ([]byte, []int) { +func (m *QueryOperatorConsKeyForChainIDResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorConsKeyForChainIDResponse) ProtoMessage() {} +func (*QueryOperatorConsKeyForChainIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f91e795a3cecbdbf, []int{2} } -func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -155,19 +161,19 @@ func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Marshal(b []byte, determini return b[:n], nil } } -func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse.Merge(m, src) +func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse.Merge(m, src) } -func (m *QueryOperatorConsKeyForChainIdResponse) XXX_Size() int { +func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Size() int { return m.Size() } -func (m *QueryOperatorConsKeyForChainIdResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse.DiscardUnknown(m) +func (m *QueryOperatorConsKeyForChainIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryOperatorConsKeyForChainIdResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse proto.InternalMessageInfo -func (m *QueryOperatorConsKeyForChainIdResponse) GetPublicKey() crypto.PublicKey { +func (m *QueryOperatorConsKeyForChainIDResponse) GetPublicKey() crypto.PublicKey { if m != nil { return m.PublicKey } @@ -176,45 +182,45 @@ func (m *QueryOperatorConsKeyForChainIdResponse) GetPublicKey() crypto.PublicKey func init() { proto.RegisterType((*GetOperatorInfoReq)(nil), "exocore.operator.v1.GetOperatorInfoReq") - proto.RegisterType((*QueryOperatorConsKeyForChainIdRequest)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIdRequest") - proto.RegisterType((*QueryOperatorConsKeyForChainIdResponse)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIdResponse") + proto.RegisterType((*QueryOperatorConsKeyForChainIDRequest)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIDRequest") + proto.RegisterType((*QueryOperatorConsKeyForChainIDResponse)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIDResponse") } func init() { proto.RegisterFile("exocore/operator/v1/query.proto", fileDescriptor_f91e795a3cecbdbf) } var fileDescriptor_f91e795a3cecbdbf = []byte{ - // 490 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0x8d, 0xa3, 0xf2, 0xd1, 0x05, 0x09, 0x69, 0xe9, 0x21, 0x0d, 0x95, 0x0b, 0x96, 0x28, 0xbd, - 0xb0, 0xab, 0x86, 0x1b, 0x70, 0x49, 0x22, 0x40, 0x51, 0x11, 0x1f, 0x46, 0xe2, 0xc0, 0x25, 0x72, - 0xec, 0xc1, 0xb5, 0x92, 0xec, 0x38, 0xbb, 0x9b, 0x12, 0xab, 0xea, 0x85, 0x3b, 0x12, 0x12, 0x7f, - 0x85, 0x1f, 0xd1, 0x63, 0x05, 0x17, 0x4e, 0x08, 0x25, 0xfd, 0x1d, 0x08, 0x79, 0xd7, 0x6e, 0xc1, - 0x44, 0x80, 0xb8, 0xad, 0x67, 0xde, 0xbc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 0x2c, 0xc4, 0x31, 0x7f, 0x60, 0x65, 0x9e, 0x80, 0x7e, 0x83, 0x72, 0x78, 0xaa, 0x3a, - 0x3b, 0xfb, 0x17, 0x74, 0x96, 0x82, 0x1a, 0x9c, 0x37, 0xeb, 0x7e, 0xe7, 0x47, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x60, 0x37, 0x18, 0x68, 0xce, 0x03, 0x00, 0x00, + // 486 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x6e, 0xa6, 0xf1, 0x31, 0x03, 0x42, 0x32, 0x3b, 0x74, 0xd5, 0x94, 0x41, 0x24, 0xc6, 0x2e, + 0xd8, 0x5a, 0xb9, 0x81, 0x38, 0xb4, 0xe5, 0x43, 0xd5, 0x10, 0x1f, 0x99, 0xc4, 0x81, 0x4b, 0x94, + 0x26, 0x2f, 0x59, 0xd4, 0xd6, 0x6f, 0x6a, 0xbb, 0xa3, 0xd1, 0xb4, 0x0b, 0x77, 0x24, 0x24, 0xfe, + 0x0a, 0x3f, 0x62, 0xc7, 0x09, 0x2e, 0x9c, 0x10, 0x6a, 0xf7, 0x3b, 0x10, 0x8a, 0x13, 0x53, 0x54, + 0x2a, 0x40, 0xdc, 0x6c, 0xbf, 0xcf, 0x47, 0xfc, 0x3c, 0x0e, 0xd9, 0x82, 0x09, 0x46, 0x28, 0x81, + 0x63, 0x06, 0x32, 0xd4, 0x28, 0xf9, 0xe1, 0x2e, 0x1f, 0x8d, 0x41, 0xe6, 0x2c, 0x93, 0xa8, 0x91, + 0x5e, 0xab, 0x00, 0xcc, 0x02, 0xd8, 0xe1, 0x6e, 0x63, 0x3d, 0xc1, 0x04, 0xcd, 0x9c, 0x17, 0xab, + 0x12, 0xda, 0xd8, 0x4c, 0x10, 0x93, 0x01, 0xf0, 0x30, 0x4b, 0x79, 0x28, 0x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, 0xf3, 0xfb, 0x0a, 0x39, 0x67, 0xdc, 0xe8, 0x3b, 0x87, 0x5c, 0x5d, 0x08, 0x89, + 0xde, 0x62, 0x4b, 0x8a, 0x65, 0xbf, 0x47, 0xd9, 0xb8, 0xb1, 0x14, 0xf8, 0x2b, 0xca, 0x63, 0x6f, + 0x3f, 0x9f, 0x7d, 0x58, 0xd9, 0xa1, 0xdb, 0xdc, 0x16, 0x19, 0xc3, 0x00, 0x12, 0x53, 0x7f, 0x51, + 0xe5, 0xa2, 0xf7, 0x99, 0x43, 0xdc, 0x3f, 0xe7, 0x40, 0xef, 0x2e, 0x75, 0xfd, 0xa7, 0x52, 0x1a, + 0xf7, 0xfe, 0x8b, 0x5b, 0x06, 0xef, 0x75, 0xcd, 0x5d, 0x3a, 0xb4, 0xc5, 0x17, 0x1f, 0x65, 0x10, + 0x15, 0x00, 0xa1, 0x17, 0x6e, 0x54, 0x49, 0xf1, 0xa3, 0xa2, 0xfc, 0x63, 0x7e, 0x64, 0xbb, 0x3f, + 0x6e, 0x3f, 0x39, 0x99, 0xba, 0xce, 0xe9, 0xd4, 0x75, 0xbe, 0x4d, 0x5d, 0xe7, 0xfd, 0xcc, 0xad, + 0x9d, 0xce, 0xdc, 0xda, 0x97, 0x99, 0x5b, 0x7b, 0xd5, 0x4c, 0x52, 0x7d, 0x30, 0xee, 0xb1, 0x08, + 0x87, 0xfc, 0x61, 0x69, 0xf3, 0x14, 0xf4, 0x1b, 0x94, 0xfd, 0x9f, 0xae, 0x93, 0xf9, 0xcf, 0xa0, + 0xf3, 0x0c, 0x54, 0xef, 0xbc, 0x79, 0xef, 0x77, 0x7e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x83, 0xaa, + 0x6f, 0x9a, 0xb2, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -229,9 +235,10 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { + // OperatorInfo queries the operator information. GetOperatorInfo(ctx context.Context, in *GetOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) - // add services for dogfood - QueryOperatorConsKeyForChainId(ctx context.Context, in *QueryOperatorConsKeyForChainIdRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIdResponse, error) + // QueryOperatorConsKeyForChainID queries the consensus public key for the operator + QueryOperatorConsKeyForChainID(ctx context.Context, in *QueryOperatorConsKeyForChainIDRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIDResponse, error) } type queryClient struct { @@ -251,9 +258,9 @@ func (c *queryClient) GetOperatorInfo(ctx context.Context, in *GetOperatorInfoRe return out, nil } -func (c *queryClient) QueryOperatorConsKeyForChainId(ctx context.Context, in *QueryOperatorConsKeyForChainIdRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIdResponse, error) { - out := new(QueryOperatorConsKeyForChainIdResponse) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainId", in, out, opts...) +func (c *queryClient) QueryOperatorConsKeyForChainID(ctx context.Context, in *QueryOperatorConsKeyForChainIDRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIDResponse, error) { + out := new(QueryOperatorConsKeyForChainIDResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainID", in, out, opts...) if err != nil { return nil, err } @@ -262,9 +269,10 @@ func (c *queryClient) QueryOperatorConsKeyForChainId(ctx context.Context, in *Qu // QueryServer is the server API for Query service. type QueryServer interface { + // OperatorInfo queries the operator information. GetOperatorInfo(context.Context, *GetOperatorInfoReq) (*OperatorInfo, error) - // add services for dogfood - QueryOperatorConsKeyForChainId(context.Context, *QueryOperatorConsKeyForChainIdRequest) (*QueryOperatorConsKeyForChainIdResponse, error) + // QueryOperatorConsKeyForChainID queries the consensus public key for the operator + QueryOperatorConsKeyForChainID(context.Context, *QueryOperatorConsKeyForChainIDRequest) (*QueryOperatorConsKeyForChainIDResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -274,8 +282,8 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) GetOperatorInfo(ctx context.Context, req *GetOperatorInfoReq) (*OperatorInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetOperatorInfo not implemented") } -func (*UnimplementedQueryServer) QueryOperatorConsKeyForChainId(ctx context.Context, req *QueryOperatorConsKeyForChainIdRequest) (*QueryOperatorConsKeyForChainIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorConsKeyForChainId not implemented") +func (*UnimplementedQueryServer) QueryOperatorConsKeyForChainID(ctx context.Context, req *QueryOperatorConsKeyForChainIDRequest) (*QueryOperatorConsKeyForChainIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorConsKeyForChainID not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -300,20 +308,20 @@ func _Query_GetOperatorInfo_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } -func _Query_QueryOperatorConsKeyForChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOperatorConsKeyForChainIdRequest) +func _Query_QueryOperatorConsKeyForChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOperatorConsKeyForChainIDRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryOperatorConsKeyForChainId(ctx, in) + return srv.(QueryServer).QueryOperatorConsKeyForChainID(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainId", + FullMethod: "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryOperatorConsKeyForChainId(ctx, req.(*QueryOperatorConsKeyForChainIdRequest)) + return srv.(QueryServer).QueryOperatorConsKeyForChainID(ctx, req.(*QueryOperatorConsKeyForChainIDRequest)) } return interceptor(ctx, in, info, handler) } @@ -327,8 +335,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_GetOperatorInfo_Handler, }, { - MethodName: "QueryOperatorConsKeyForChainId", - Handler: _Query_QueryOperatorConsKeyForChainId_Handler, + MethodName: "QueryOperatorConsKeyForChainID", + Handler: _Query_QueryOperatorConsKeyForChainID_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -365,7 +373,7 @@ func (m *GetOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryOperatorConsKeyForChainIdRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryOperatorConsKeyForChainIDRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -375,12 +383,12 @@ func (m *QueryOperatorConsKeyForChainIdRequest) Marshal() (dAtA []byte, err erro return dAtA[:n], nil } -func (m *QueryOperatorConsKeyForChainIdRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyForChainIDRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOperatorConsKeyForChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyForChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -402,7 +410,7 @@ func (m *QueryOperatorConsKeyForChainIdRequest) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } -func (m *QueryOperatorConsKeyForChainIdResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryOperatorConsKeyForChainIDResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -412,12 +420,12 @@ func (m *QueryOperatorConsKeyForChainIdResponse) Marshal() (dAtA []byte, err err return dAtA[:n], nil } -func (m *QueryOperatorConsKeyForChainIdResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyForChainIDResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOperatorConsKeyForChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyForChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -459,7 +467,7 @@ func (m *GetOperatorInfoReq) Size() (n int) { return n } -func (m *QueryOperatorConsKeyForChainIdRequest) Size() (n int) { +func (m *QueryOperatorConsKeyForChainIDRequest) Size() (n int) { if m == nil { return 0 } @@ -476,7 +484,7 @@ func (m *QueryOperatorConsKeyForChainIdRequest) Size() (n int) { return n } -func (m *QueryOperatorConsKeyForChainIdResponse) Size() (n int) { +func (m *QueryOperatorConsKeyForChainIDResponse) Size() (n int) { if m == nil { return 0 } @@ -575,7 +583,7 @@ func (m *GetOperatorInfoReq) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOperatorConsKeyForChainIdRequest) Unmarshal(dAtA []byte) error { +func (m *QueryOperatorConsKeyForChainIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -598,10 +606,10 @@ func (m *QueryOperatorConsKeyForChainIdRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIdRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -689,7 +697,7 @@ func (m *QueryOperatorConsKeyForChainIdRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOperatorConsKeyForChainIdResponse) Unmarshal(dAtA []byte) error { +func (m *QueryOperatorConsKeyForChainIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -712,10 +720,10 @@ func (m *QueryOperatorConsKeyForChainIdResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIdResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/operator/types/query.pb.gw.go b/x/operator/types/query.pb.gw.go index f5076602c..87ca8026e 100644 --- a/x/operator/types/query.pb.gw.go +++ b/x/operator/types/query.pb.gw.go @@ -69,8 +69,8 @@ func local_request_Query_GetOperatorInfo_0(ctx context.Context, marshaler runtim } -func request_Query_QueryOperatorConsKeyForChainId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorConsKeyForChainIdRequest +func request_Query_QueryOperatorConsKeyForChainID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOperatorConsKeyForChainIDRequest var metadata runtime.ServerMetadata var ( @@ -102,13 +102,13 @@ func request_Query_QueryOperatorConsKeyForChainId_0(ctx context.Context, marshal return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } - msg, err := client.QueryOperatorConsKeyForChainId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryOperatorConsKeyForChainID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryOperatorConsKeyForChainId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorConsKeyForChainIdRequest +func local_request_Query_QueryOperatorConsKeyForChainID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOperatorConsKeyForChainIDRequest var metadata runtime.ServerMetadata var ( @@ -140,7 +140,7 @@ func local_request_Query_QueryOperatorConsKeyForChainId_0(ctx context.Context, m return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } - msg, err := server.QueryOperatorConsKeyForChainId(ctx, &protoReq) + msg, err := server.QueryOperatorConsKeyForChainID(ctx, &protoReq) return msg, metadata, err } @@ -174,7 +174,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -185,7 +185,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryOperatorConsKeyForChainId_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryOperatorConsKeyForChainID_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 { @@ -193,7 +193,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryOperatorConsKeyForChainId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryOperatorConsKeyForChainID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -258,7 +258,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainID_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) @@ -267,14 +267,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryOperatorConsKeyForChainId_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryOperatorConsKeyForChainID_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_QueryOperatorConsKeyForChainId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryOperatorConsKeyForChainID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -284,11 +284,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_GetOperatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "delegation", "v1", "GetOperatorInfo"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryOperatorConsKeyForChainId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"exocore", "operator_consent", "v1", "GetOperatorConsKey", "addr", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryOperatorConsKeyForChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"exocore", "operator_consent", "v1", "GetOperatorConsKey", "addr", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_GetOperatorInfo_0 = runtime.ForwardResponseMessage - forward_Query_QueryOperatorConsKeyForChainId_0 = runtime.ForwardResponseMessage + forward_Query_QueryOperatorConsKeyForChainID_0 = runtime.ForwardResponseMessage ) diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 4bae48d47..c4531c05e 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -32,15 +32,56 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// DecValueField is a field that holds a value of sdk.LegacyDec type. +type DecValueField struct { + // amount is the USD value of the asset, as an sdk.LegacyDec. + Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"amount"` +} + +func (m *DecValueField) Reset() { *m = DecValueField{} } +func (m *DecValueField) String() string { return proto.CompactTextString(m) } +func (*DecValueField) ProtoMessage() {} +func (*DecValueField) Descriptor() ([]byte, []int) { + return fileDescriptor_b229d5663e4df167, []int{0} +} +func (m *DecValueField) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DecValueField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DecValueField.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 *DecValueField) XXX_Merge(src proto.Message) { + xxx_messageInfo_DecValueField.Merge(m, src) +} +func (m *DecValueField) XXX_Size() int { + return m.Size() +} +func (m *DecValueField) XXX_DiscardUnknown() { + xxx_messageInfo_DecValueField.DiscardUnknown(m) +} + +var xxx_messageInfo_DecValueField proto.InternalMessageInfo + +// ClientChainEarningAddrList is the list of client chain earning addresses. type ClientChainEarningAddrList struct { - EarningInfoList []*ClientChainEarningAddrInfo `protobuf:"bytes,1,rep,name=EarningInfoList,proto3" json:"EarningInfoList,omitempty"` + // earning_info_list is the contents of ClientChainEarningAddrList. + EarningInfoList []*ClientChainEarningAddrInfo `protobuf:"bytes,1,rep,name=earning_info_list,json=earningInfoList,proto3" json:"earning_info_list,omitempty"` } func (m *ClientChainEarningAddrList) Reset() { *m = ClientChainEarningAddrList{} } func (m *ClientChainEarningAddrList) String() string { return proto.CompactTextString(m) } func (*ClientChainEarningAddrList) ProtoMessage() {} func (*ClientChainEarningAddrList) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{0} + return fileDescriptor_b229d5663e4df167, []int{1} } func (m *ClientChainEarningAddrList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,16 +117,19 @@ func (m *ClientChainEarningAddrList) GetEarningInfoList() []*ClientChainEarningA return nil } +// ClientChainEarningAddrInfo is the client chain earning address info. type ClientChainEarningAddrInfo struct { - LzClientChainID uint64 `protobuf:"varint,1,opt,name=lzClientChainID,proto3" json:"lzClientChainID,omitempty"` - ClientChainEarningAddr string `protobuf:"bytes,2,opt,name=clientChainEarningAddr,proto3" json:"clientChainEarningAddr,omitempty"` + // lz_client_chain_id is the layer0 client chain id. + LzClientChainID uint64 `protobuf:"varint,1,opt,name=lz_client_chain_id,json=lzClientChainId,proto3" json:"lz_client_chain_id,omitempty"` + // client_chain_earning_addr is the client chain earning address. + ClientChainEarningAddr string `protobuf:"bytes,2,opt,name=client_chain_earning_addr,json=clientChainEarningAddr,proto3" json:"client_chain_earning_addr,omitempty"` } func (m *ClientChainEarningAddrInfo) Reset() { *m = ClientChainEarningAddrInfo{} } func (m *ClientChainEarningAddrInfo) String() string { return proto.CompactTextString(m) } func (*ClientChainEarningAddrInfo) ProtoMessage() {} func (*ClientChainEarningAddrInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{1} + return fileDescriptor_b229d5663e4df167, []int{2} } func (m *ClientChainEarningAddrInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -128,18 +172,23 @@ func (m *ClientChainEarningAddrInfo) GetClientChainEarningAddr() string { return "" } +// OperatorInfo is the operator info. type OperatorInfo struct { - EarningsAddr string `protobuf:"bytes,1,opt,name=EarningsAddr,proto3" json:"EarningsAddr,omitempty"` - ApproveAddr string `protobuf:"bytes,2,opt,name=ApproveAddr,proto3" json:"ApproveAddr,omitempty"` - OperatorMetaInfo string `protobuf:"bytes,3,opt,name=OperatorMetaInfo,proto3" json:"OperatorMetaInfo,omitempty"` - ClientChainEarningsAddr *ClientChainEarningAddrList `protobuf:"bytes,4,opt,name=ClientChainEarningsAddr,proto3" json:"ClientChainEarningsAddr,omitempty"` + // earnings_addr is the earnings address. + EarningsAddr string `protobuf:"bytes,1,opt,name=earnings_addr,json=earningsAddr,proto3" json:"earnings_addr,omitempty"` + // approve_addr is the approve address. + ApproveAddr string `protobuf:"bytes,2,opt,name=approve_addr,json=approveAddr,proto3" json:"approve_addr,omitempty"` + // operator_meta_info is the operator meta info. + OperatorMetaInfo string `protobuf:"bytes,3,opt,name=operator_meta_info,json=operatorMetaInfo,proto3" json:"operator_meta_info,omitempty"` + // client_chain_earning_addr_list is the client chain earning address list. + ClientChainEarningsAddr *ClientChainEarningAddrList `protobuf:"bytes,4,opt,name=client_chain_earnings_addr,json=clientChainEarningsAddr,proto3" json:"client_chain_earnings_addr,omitempty"` } func (m *OperatorInfo) Reset() { *m = OperatorInfo{} } func (m *OperatorInfo) String() string { return proto.CompactTextString(m) } func (*OperatorInfo) ProtoMessage() {} func (*OperatorInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{2} + return fileDescriptor_b229d5663e4df167, []int{3} } func (m *OperatorInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -196,17 +245,21 @@ func (m *OperatorInfo) GetClientChainEarningsAddr() *ClientChainEarningAddrList return nil } +// OptedInfo is the opted information about operator type OptedInfo struct { - SlashContract string `protobuf:"bytes,1,opt,name=SlashContract,proto3" json:"SlashContract,omitempty"` - OptedInHeight uint64 `protobuf:"varint,2,opt,name=OptedInHeight,proto3" json:"OptedInHeight,omitempty"` - OptedOutHeight uint64 `protobuf:"varint,3,opt,name=OptedOutHeight,proto3" json:"OptedOutHeight,omitempty"` + // slash_contract is the slash contract address of AVS opted-in by the operator + SlashContract string `protobuf:"bytes,1,opt,name=slash_contract,json=slashContract,proto3" json:"slash_contract,omitempty"` + // opted_in_height is the height at which the operator opted in + OptedInHeight uint64 `protobuf:"varint,2,opt,name=opted_in_height,json=optedInHeight,proto3" json:"opted_in_height,omitempty"` + // opted_out_height is the height at which the operator opted out + OptedOutHeight uint64 `protobuf:"varint,3,opt,name=opted_out_height,json=optedOutHeight,proto3" json:"opted_out_height,omitempty"` } func (m *OptedInfo) Reset() { *m = OptedInfo{} } func (m *OptedInfo) String() string { return proto.CompactTextString(m) } func (*OptedInfo) ProtoMessage() {} func (*OptedInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{3} + return fileDescriptor_b229d5663e4df167, []int{4} } func (m *OptedInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -256,60 +309,26 @@ func (m *OptedInfo) GetOptedOutHeight() uint64 { return 0 } -type AssetOptedInState struct { - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=Amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"Amount"` - Value github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=Value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"Value"` -} - -func (m *AssetOptedInState) Reset() { *m = AssetOptedInState{} } -func (m *AssetOptedInState) String() string { return proto.CompactTextString(m) } -func (*AssetOptedInState) ProtoMessage() {} -func (*AssetOptedInState) Descriptor() ([]byte, []int) { - return fileDescriptor_b229d5663e4df167, []int{4} -} -func (m *AssetOptedInState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AssetOptedInState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AssetOptedInState.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 *AssetOptedInState) XXX_Merge(src proto.Message) { - xxx_messageInfo_AssetOptedInState.Merge(m, src) -} -func (m *AssetOptedInState) XXX_Size() int { - return m.Size() -} -func (m *AssetOptedInState) XXX_DiscardUnknown() { - xxx_messageInfo_AssetOptedInState.DiscardUnknown(m) -} - -var xxx_messageInfo_AssetOptedInState proto.InternalMessageInfo - -type ValueField struct { - Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=Amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"Amount"` +// OptedInAssetState is the state of opted-in asset +type OptedInAssetState struct { + // amount of the opted-in asset + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + // value is the USD value of the opted-in asset + Value github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"value"` } -func (m *ValueField) Reset() { *m = ValueField{} } -func (m *ValueField) String() string { return proto.CompactTextString(m) } -func (*ValueField) ProtoMessage() {} -func (*ValueField) Descriptor() ([]byte, []int) { +func (m *OptedInAssetState) Reset() { *m = OptedInAssetState{} } +func (m *OptedInAssetState) String() string { return proto.CompactTextString(m) } +func (*OptedInAssetState) ProtoMessage() {} +func (*OptedInAssetState) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{5} } -func (m *ValueField) XXX_Unmarshal(b []byte) error { +func (m *OptedInAssetState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ValueField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptedInAssetState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ValueField.Marshal(b, m, deterministic) + return xxx_messageInfo_OptedInAssetState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -319,25 +338,32 @@ func (m *ValueField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *ValueField) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValueField.Merge(m, src) +func (m *OptedInAssetState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptedInAssetState.Merge(m, src) } -func (m *ValueField) XXX_Size() int { +func (m *OptedInAssetState) XXX_Size() int { return m.Size() } -func (m *ValueField) XXX_DiscardUnknown() { - xxx_messageInfo_ValueField.DiscardUnknown(m) +func (m *OptedInAssetState) XXX_DiscardUnknown() { + xxx_messageInfo_OptedInAssetState.DiscardUnknown(m) } -var xxx_messageInfo_ValueField proto.InternalMessageInfo +var xxx_messageInfo_OptedInAssetState proto.InternalMessageInfo +// OperatorSlashInfo is the slash info of operator type OperatorSlashInfo struct { - SlashContract string `protobuf:"bytes,1,opt,name=SlashContract,proto3" json:"SlashContract,omitempty"` - SlashHeight int64 `protobuf:"varint,2,opt,name=SlashHeight,proto3" json:"SlashHeight,omitempty"` - OccurredHeight int64 `protobuf:"varint,3,opt,name=OccurredHeight,proto3" json:"OccurredHeight,omitempty"` - ExecuteHeight int64 `protobuf:"varint,4,opt,name=ExecuteHeight,proto3" json:"ExecuteHeight,omitempty"` - IsVeto bool `protobuf:"varint,5,opt,name=IsVeto,proto3" json:"IsVeto,omitempty"` - SlashProportion github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=SlashProportion,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"SlashProportion"` + // slash_contract is the address of slash contract + SlashContract string `protobuf:"bytes,1,opt,name=slash_contract,json=slashContract,proto3" json:"slash_contract,omitempty"` + // slash_height is the height at which the slash event is submitted + SlashHeight int64 `protobuf:"varint,2,opt,name=slash_height,json=slashHeight,proto3" json:"slash_height,omitempty"` + // occurred_height is the height at which the slash event occurs + OccurredHeight int64 `protobuf:"varint,3,opt,name=occurred_height,json=occurredHeight,proto3" json:"occurred_height,omitempty"` + // execute_height is the height at which the slash event is executed + ExecuteHeight int64 `protobuf:"varint,4,opt,name=execute_height,json=executeHeight,proto3" json:"execute_height,omitempty"` + // is_veto is a flag to indicate if this slash is vetoed + IsVeto bool `protobuf:"varint,5,opt,name=is_veto,json=isVeto,proto3" json:"is_veto,omitempty"` + // slash_proportion is the proportion of assets that need to be slashed + SlashProportion github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slash_proportion,json=slashProportion,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_proportion"` } func (m *OperatorSlashInfo) Reset() { *m = OperatorSlashInfo{} } @@ -408,9 +434,12 @@ func (m *OperatorSlashInfo) GetIsVeto() bool { return false } +// RegisterOperatorReq is the request to register a new operator. type RegisterOperatorReq struct { - FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` - Info *OperatorInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + // from_address is the address of the operator (sdk.AccAddress). + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` + // info is the operator info. + Info *OperatorInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` } func (m *RegisterOperatorReq) Reset() { *m = RegisterOperatorReq{} } @@ -446,6 +475,7 @@ func (m *RegisterOperatorReq) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterOperatorReq proto.InternalMessageInfo +// RegisterOperatorResponse is the response to a register operator request. type RegisterOperatorResponse struct { } @@ -482,8 +512,8 @@ func (m *RegisterOperatorResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo -// OptInToChainIdRequest defines the OptInToChainId request. -type OptInToChainIdRequest struct { +// OptInToChainIDRequest defines the OptInToChainID request. +type OptInToChainIDRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` @@ -493,18 +523,18 @@ type OptInToChainIdRequest struct { PublicKey string `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` } -func (m *OptInToChainIdRequest) Reset() { *m = OptInToChainIdRequest{} } -func (m *OptInToChainIdRequest) String() string { return proto.CompactTextString(m) } -func (*OptInToChainIdRequest) ProtoMessage() {} -func (*OptInToChainIdRequest) Descriptor() ([]byte, []int) { +func (m *OptInToChainIDRequest) Reset() { *m = OptInToChainIDRequest{} } +func (m *OptInToChainIDRequest) String() string { return proto.CompactTextString(m) } +func (*OptInToChainIDRequest) ProtoMessage() {} +func (*OptInToChainIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{9} } -func (m *OptInToChainIdRequest) XXX_Unmarshal(b []byte) error { +func (m *OptInToChainIDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OptInToChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptInToChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OptInToChainIdRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_OptInToChainIDRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -514,55 +544,55 @@ func (m *OptInToChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *OptInToChainIdRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_OptInToChainIdRequest.Merge(m, src) +func (m *OptInToChainIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToChainIDRequest.Merge(m, src) } -func (m *OptInToChainIdRequest) XXX_Size() int { +func (m *OptInToChainIDRequest) XXX_Size() int { return m.Size() } -func (m *OptInToChainIdRequest) XXX_DiscardUnknown() { - xxx_messageInfo_OptInToChainIdRequest.DiscardUnknown(m) +func (m *OptInToChainIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToChainIDRequest.DiscardUnknown(m) } -var xxx_messageInfo_OptInToChainIdRequest proto.InternalMessageInfo +var xxx_messageInfo_OptInToChainIDRequest proto.InternalMessageInfo -func (m *OptInToChainIdRequest) GetAddress() string { +func (m *OptInToChainIDRequest) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *OptInToChainIdRequest) GetChainId() string { +func (m *OptInToChainIDRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -func (m *OptInToChainIdRequest) GetPublicKey() string { +func (m *OptInToChainIDRequest) GetPublicKey() string { if m != nil { return m.PublicKey } return "" } -// OptInToChainIdResponse defines the OptInToChainId response. -type OptInToChainIdResponse struct { +// OptInToChainIDResponse defines the OptInToChainID response. +type OptInToChainIDResponse struct { } -func (m *OptInToChainIdResponse) Reset() { *m = OptInToChainIdResponse{} } -func (m *OptInToChainIdResponse) String() string { return proto.CompactTextString(m) } -func (*OptInToChainIdResponse) ProtoMessage() {} -func (*OptInToChainIdResponse) Descriptor() ([]byte, []int) { +func (m *OptInToChainIDResponse) Reset() { *m = OptInToChainIDResponse{} } +func (m *OptInToChainIDResponse) String() string { return proto.CompactTextString(m) } +func (*OptInToChainIDResponse) ProtoMessage() {} +func (*OptInToChainIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{10} } -func (m *OptInToChainIdResponse) XXX_Unmarshal(b []byte) error { +func (m *OptInToChainIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OptInToChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptInToChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OptInToChainIdResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_OptInToChainIDResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -572,36 +602,36 @@ func (m *OptInToChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *OptInToChainIdResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_OptInToChainIdResponse.Merge(m, src) +func (m *OptInToChainIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToChainIDResponse.Merge(m, src) } -func (m *OptInToChainIdResponse) XXX_Size() int { +func (m *OptInToChainIDResponse) XXX_Size() int { return m.Size() } -func (m *OptInToChainIdResponse) XXX_DiscardUnknown() { - xxx_messageInfo_OptInToChainIdResponse.DiscardUnknown(m) +func (m *OptInToChainIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToChainIDResponse.DiscardUnknown(m) } -var xxx_messageInfo_OptInToChainIdResponse proto.InternalMessageInfo +var xxx_messageInfo_OptInToChainIDResponse proto.InternalMessageInfo -// InitiateOptOutFromChainIdRequest defines the InitiateOptOutFromChainId request. -type InitiateOptOutFromChainIdRequest struct { +// InitiateOptOutFromChainIDRequest defines the InitiateOptOutFromChainID request. +type InitiateOptOutFromChainIDRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (m *InitiateOptOutFromChainIdRequest) Reset() { *m = InitiateOptOutFromChainIdRequest{} } -func (m *InitiateOptOutFromChainIdRequest) String() string { return proto.CompactTextString(m) } -func (*InitiateOptOutFromChainIdRequest) ProtoMessage() {} -func (*InitiateOptOutFromChainIdRequest) Descriptor() ([]byte, []int) { +func (m *InitiateOptOutFromChainIDRequest) Reset() { *m = InitiateOptOutFromChainIDRequest{} } +func (m *InitiateOptOutFromChainIDRequest) String() string { return proto.CompactTextString(m) } +func (*InitiateOptOutFromChainIDRequest) ProtoMessage() {} +func (*InitiateOptOutFromChainIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{11} } -func (m *InitiateOptOutFromChainIdRequest) XXX_Unmarshal(b []byte) error { +func (m *InitiateOptOutFromChainIDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InitiateOptOutFromChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InitiateOptOutFromChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InitiateOptOutFromChainIdRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_InitiateOptOutFromChainIDRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -611,48 +641,48 @@ func (m *InitiateOptOutFromChainIdRequest) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *InitiateOptOutFromChainIdRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitiateOptOutFromChainIdRequest.Merge(m, src) +func (m *InitiateOptOutFromChainIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitiateOptOutFromChainIDRequest.Merge(m, src) } -func (m *InitiateOptOutFromChainIdRequest) XXX_Size() int { +func (m *InitiateOptOutFromChainIDRequest) XXX_Size() int { return m.Size() } -func (m *InitiateOptOutFromChainIdRequest) XXX_DiscardUnknown() { - xxx_messageInfo_InitiateOptOutFromChainIdRequest.DiscardUnknown(m) +func (m *InitiateOptOutFromChainIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_InitiateOptOutFromChainIDRequest.DiscardUnknown(m) } -var xxx_messageInfo_InitiateOptOutFromChainIdRequest proto.InternalMessageInfo +var xxx_messageInfo_InitiateOptOutFromChainIDRequest proto.InternalMessageInfo -func (m *InitiateOptOutFromChainIdRequest) GetAddress() string { +func (m *InitiateOptOutFromChainIDRequest) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *InitiateOptOutFromChainIdRequest) GetChainId() string { +func (m *InitiateOptOutFromChainIDRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -// InitiateOptOutFromChainIdResponse defines the InitiateOptOutFromChainId response. -type InitiateOptOutFromChainIdResponse struct { +// InitiateOptOutFromChainIDResponse defines the InitiateOptOutFromChainID response. +type InitiateOptOutFromChainIDResponse struct { } -func (m *InitiateOptOutFromChainIdResponse) Reset() { *m = InitiateOptOutFromChainIdResponse{} } -func (m *InitiateOptOutFromChainIdResponse) String() string { return proto.CompactTextString(m) } -func (*InitiateOptOutFromChainIdResponse) ProtoMessage() {} -func (*InitiateOptOutFromChainIdResponse) Descriptor() ([]byte, []int) { +func (m *InitiateOptOutFromChainIDResponse) Reset() { *m = InitiateOptOutFromChainIDResponse{} } +func (m *InitiateOptOutFromChainIDResponse) String() string { return proto.CompactTextString(m) } +func (*InitiateOptOutFromChainIDResponse) ProtoMessage() {} +func (*InitiateOptOutFromChainIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{12} } -func (m *InitiateOptOutFromChainIdResponse) XXX_Unmarshal(b []byte) error { +func (m *InitiateOptOutFromChainIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InitiateOptOutFromChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InitiateOptOutFromChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InitiateOptOutFromChainIdResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_InitiateOptOutFromChainIDResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -662,94 +692,100 @@ func (m *InitiateOptOutFromChainIdResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *InitiateOptOutFromChainIdResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitiateOptOutFromChainIdResponse.Merge(m, src) +func (m *InitiateOptOutFromChainIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitiateOptOutFromChainIDResponse.Merge(m, src) } -func (m *InitiateOptOutFromChainIdResponse) XXX_Size() int { +func (m *InitiateOptOutFromChainIDResponse) XXX_Size() int { return m.Size() } -func (m *InitiateOptOutFromChainIdResponse) XXX_DiscardUnknown() { - xxx_messageInfo_InitiateOptOutFromChainIdResponse.DiscardUnknown(m) +func (m *InitiateOptOutFromChainIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_InitiateOptOutFromChainIDResponse.DiscardUnknown(m) } -var xxx_messageInfo_InitiateOptOutFromChainIdResponse proto.InternalMessageInfo +var xxx_messageInfo_InitiateOptOutFromChainIDResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*ClientChainEarningAddrList)(nil), "exocore.operator.v1.clientChainEarningAddrList") - proto.RegisterType((*ClientChainEarningAddrInfo)(nil), "exocore.operator.v1.clientChainEarningAddrInfo") + proto.RegisterType((*DecValueField)(nil), "exocore.operator.v1.DecValueField") + proto.RegisterType((*ClientChainEarningAddrList)(nil), "exocore.operator.v1.ClientChainEarningAddrList") + proto.RegisterType((*ClientChainEarningAddrInfo)(nil), "exocore.operator.v1.ClientChainEarningAddrInfo") proto.RegisterType((*OperatorInfo)(nil), "exocore.operator.v1.OperatorInfo") proto.RegisterType((*OptedInfo)(nil), "exocore.operator.v1.OptedInfo") - proto.RegisterType((*AssetOptedInState)(nil), "exocore.operator.v1.AssetOptedInState") - proto.RegisterType((*ValueField)(nil), "exocore.operator.v1.ValueField") + proto.RegisterType((*OptedInAssetState)(nil), "exocore.operator.v1.OptedInAssetState") proto.RegisterType((*OperatorSlashInfo)(nil), "exocore.operator.v1.OperatorSlashInfo") proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.operator.v1.RegisterOperatorReq") proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.operator.v1.RegisterOperatorResponse") - proto.RegisterType((*OptInToChainIdRequest)(nil), "exocore.operator.v1.OptInToChainIdRequest") - proto.RegisterType((*OptInToChainIdResponse)(nil), "exocore.operator.v1.OptInToChainIdResponse") - proto.RegisterType((*InitiateOptOutFromChainIdRequest)(nil), "exocore.operator.v1.InitiateOptOutFromChainIdRequest") - proto.RegisterType((*InitiateOptOutFromChainIdResponse)(nil), "exocore.operator.v1.InitiateOptOutFromChainIdResponse") + proto.RegisterType((*OptInToChainIDRequest)(nil), "exocore.operator.v1.OptInToChainIDRequest") + proto.RegisterType((*OptInToChainIDResponse)(nil), "exocore.operator.v1.OptInToChainIDResponse") + proto.RegisterType((*InitiateOptOutFromChainIDRequest)(nil), "exocore.operator.v1.InitiateOptOutFromChainIDRequest") + proto.RegisterType((*InitiateOptOutFromChainIDResponse)(nil), "exocore.operator.v1.InitiateOptOutFromChainIDResponse") } func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 892 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0xdc, 0x44, - 0x14, 0x5e, 0x67, 0x37, 0x69, 0xf3, 0x12, 0x48, 0x33, 0x2d, 0x89, 0x63, 0xc1, 0xc6, 0x35, 0xa8, - 0x5a, 0x2d, 0xca, 0x5a, 0x0d, 0xb4, 0x87, 0x88, 0x4b, 0x9a, 0xa4, 0x62, 0x45, 0xcb, 0xa2, 0x49, - 0x55, 0x09, 0x2e, 0x91, 0x63, 0x4f, 0x9d, 0xd1, 0xee, 0x7a, 0xdc, 0x99, 0x71, 0x9a, 0x70, 0x00, - 0xc4, 0x09, 0x21, 0x0e, 0xfc, 0x84, 0x5e, 0xb9, 0xe5, 0xd0, 0x2b, 0x9c, 0x7b, 0xac, 0x7a, 0x42, - 0x1c, 0x2a, 0x94, 0x1c, 0x82, 0xc4, 0x99, 0x3b, 0xf2, 0x78, 0xac, 0x3a, 0x8e, 0x17, 0xba, 0x6a, - 0x2f, 0xbb, 0x9e, 0xef, 0x7d, 0xef, 0x7b, 0x6f, 0xde, 0x7b, 0x33, 0x1a, 0x78, 0x97, 0x1c, 0x30, - 0x9f, 0x71, 0xe2, 0xb2, 0x98, 0x70, 0x4f, 0x32, 0xee, 0xee, 0x5f, 0x77, 0xe5, 0x41, 0x27, 0xe6, - 0x4c, 0x32, 0x74, 0x59, 0x5b, 0x3b, 0xb9, 0xb5, 0xb3, 0x7f, 0xdd, 0x5a, 0xf4, 0x99, 0x18, 0x32, - 0xe1, 0x0e, 0x45, 0x98, 0x92, 0x87, 0x22, 0xcc, 0xd8, 0xd6, 0x52, 0x66, 0xd8, 0x51, 0x2b, 0x37, - 0x5b, 0x68, 0xd3, 0x95, 0x90, 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0x00, + // 978 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xc6, 0x69, 0xd2, 0xbc, 0xf8, 0x23, 0x99, 0x94, 0xc6, 0xb1, 0xc0, 0x4e, 0xb6, 0x6a, + 0xb1, 0x02, 0xb1, 0xd5, 0x40, 0x91, 0x28, 0x1c, 0xc8, 0x47, 0x2b, 0x2c, 0x52, 0x8c, 0x36, 0x55, + 0x0f, 0x70, 0x58, 0x6d, 0x76, 0x5f, 0xd6, 0x23, 0xdb, 0x3b, 0xdb, 0x9d, 0x59, 0x13, 0xf7, 0x84, + 0x10, 0x07, 0x84, 0x38, 0x70, 0xe5, 0xd6, 0xff, 0x80, 0x1c, 0x7a, 0x45, 0x5c, 0x7b, 0xac, 0x7a, + 0x42, 0x1c, 0x22, 0x94, 0x1c, 0xc2, 0x19, 0x89, 0x3b, 0xda, 0x99, 0xd9, 0xd6, 0x49, 0x1d, 0x68, + 0xd4, 0x5e, 0x12, 0xcf, 0x6f, 0x7e, 0xef, 0xeb, 0xf7, 0xde, 0x1b, 0x2d, 0xbc, 0x89, 0x7b, 0xcc, + 0x65, 0x11, 0x36, 0x58, 0x88, 0x91, 0x23, 0x58, 0xd4, 0xe8, 0x5f, 0x6f, 0x88, 0xbd, 0x7a, 0x18, + 0x31, 0xc1, 0xc8, 0x9c, 0xbe, 0xad, 0xa7, 0xb7, 0xf5, 0xfe, 0xf5, 0xf2, 0xbc, 0xcb, 0x78, 0x8f, + 0xf1, 0x46, 0x8f, 0xfb, 0x09, 0xb9, 0xc7, 0x7d, 0xc5, 0x2e, 0x2f, 0xa8, 0x0b, 0x5b, 0x9e, 0x1a, + 0xea, 0xa0, 0xaf, 0x2e, 0xf9, 0xcc, 0x67, 0x0a, 0x4f, 0x7e, 0x69, 0x74, 0xd6, 0xe9, 0xd1, 0x80, + 0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34, 0x96, 0x88, 0x68, 0x5d, 0x76, 0x47, 0x26, 0x60, 0xfe, 0x6d, + 0x40, 0xae, 0xa5, 0xeb, 0x92, 0xd9, 0x5c, 0x81, 0xbc, 0x36, 0xe7, 0xca, 0x5e, 0x36, 0xc1, 0xca, + 0xa5, 0x60, 0x62, 0x45, 0x96, 0x20, 0xe7, 0x84, 0x61, 0xc4, 0xfa, 0x38, 0x1c, 0x63, 0x5a, 0x63, + 0x92, 0xf2, 0x2e, 0x90, 0x54, 0x2f, 0xbb, 0x87, 0xc2, 0x91, 0xba, 0x96, 0xb2, 0x92, 0x38, 0x93, + 0xde, 0xdc, 0x41, 0xe1, 0xc8, 0xa8, 0x5d, 0x28, 0x8f, 0xaa, 0x40, 0xa7, 0x30, 0xbe, 0x68, 0x9c, + 0xb3, 0x11, 0x89, 0xee, 0xd6, 0xfc, 0x8b, 0x35, 0xcb, 0xf4, 0xcd, 0xef, 0x0c, 0x98, 0x6a, 0x85, + 0x02, 0x3d, 0x19, 0xfb, 0x2a, 0x14, 0x78, 0xd7, 0xe1, 0x6d, 0xdb, 0x65, 0x81, 0x88, 0x1c, 0x57, + 0xcf, 0x9d, 0x95, 0x97, 0xe8, 0x86, 0x06, 0xc9, 0x35, 0x28, 0xb2, 0xc4, 0xc6, 0xa6, 0x81, 0xdd, + 0x46, 0xea, 0xb7, 0x85, 0x2c, 0x7b, 0xdc, 0xca, 0x33, 0xe5, 0xea, 0x53, 0x09, 0x92, 0x1a, 0xcc, + 0x28, 0x1e, 0x8b, 0x45, 0x4a, 0xcc, 0x4a, 0x62, 0x41, 0xe2, 0xad, 0x58, 0x28, 0xa6, 0xf9, 0xab, + 0x01, 0xb3, 0x3a, 0x8d, 0x35, 0xce, 0x51, 0x6c, 0x0b, 0x47, 0xe0, 0x2b, 0x8d, 0x7f, 0x33, 0x10, + 0x43, 0xe3, 0xdf, 0x0c, 0x44, 0x3a, 0xfe, 0xc4, 0x82, 0x0b, 0xfd, 0x64, 0xc5, 0x54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39, 0xde, 0x5f, 0x36, 0xd6, 0xb7, 0x1e, + 0x1f, 0x56, 0x8c, 0x27, 0x87, 0x15, 0xe3, 0xcf, 0xc3, 0x8a, 0xf1, 0xd3, 0x51, 0x25, 0xf3, 0xe4, + 0xa8, 0x92, 0xf9, 0xfd, 0xa8, 0x92, 0xf9, 0x72, 0x75, 0x68, 0xaf, 0x6f, 0xa9, 0x20, 0x9f, 0xa3, + 0xf8, 0x9a, 0x45, 0x9d, 0x46, 0xfa, 0x99, 0xb4, 0xf7, 0xfc, 0x43, 0x49, 0xee, 0xf9, 0xce, 0x84, + 0xfc, 0x6e, 0x79, 0xef, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xa3, 0x9f, 0x77, 0x49, 0x09, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -764,19 +800,19 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. + // RegisterOperator registers a new operator. RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) // add services for dogfood - // OptInToChainId acts as opt in method for an operator to + // OptInToChainID acts as opt in method for an operator to // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. - OptInToChainId(ctx context.Context, in *OptInToChainIdRequest, opts ...grpc.CallOption) (*OptInToChainIdResponse, error) - // InitiateOptOutFromChainId is a method with which an operator can initiate + OptInToChainID(ctx context.Context, in *OptInToChainIDRequest, opts ...grpc.CallOption) (*OptInToChainIDResponse, error) + // InitiateOptOutFromChainID is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - InitiateOptOutFromChainId(ctx context.Context, in *InitiateOptOutFromChainIdRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIdResponse, error) + InitiateOptOutFromChainID(ctx context.Context, in *InitiateOptOutFromChainIDRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIDResponse, error) } type msgClient struct { @@ -796,18 +832,18 @@ func (c *msgClient) RegisterOperator(ctx context.Context, in *RegisterOperatorRe return out, nil } -func (c *msgClient) OptInToChainId(ctx context.Context, in *OptInToChainIdRequest, opts ...grpc.CallOption) (*OptInToChainIdResponse, error) { - out := new(OptInToChainIdResponse) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/OptInToChainId", in, out, opts...) +func (c *msgClient) OptInToChainID(ctx context.Context, in *OptInToChainIDRequest, opts ...grpc.CallOption) (*OptInToChainIDResponse, error) { + out := new(OptInToChainIDResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/OptInToChainID", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) InitiateOptOutFromChainId(ctx context.Context, in *InitiateOptOutFromChainIdRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIdResponse, error) { - out := new(InitiateOptOutFromChainIdResponse) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitiateOptOutFromChainId", in, out, opts...) +func (c *msgClient) InitiateOptOutFromChainID(ctx context.Context, in *InitiateOptOutFromChainIDRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIDResponse, error) { + out := new(InitiateOptOutFromChainIDResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitiateOptOutFromChainID", in, out, opts...) if err != nil { return nil, err } @@ -816,19 +852,19 @@ func (c *msgClient) InitiateOptOutFromChainId(ctx context.Context, in *InitiateO // MsgServer is the server API for Msg service. type MsgServer interface { - // CreateClawbackVestingAccount creats a vesting account that is subject to clawback. + // RegisterOperator registers a new operator. RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) // add services for dogfood - // OptInToChainId acts as opt in method for an operator to + // OptInToChainID acts as opt in method for an operator to // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. - OptInToChainId(context.Context, *OptInToChainIdRequest) (*OptInToChainIdResponse, error) - // InitiateOptOutFromChainId is a method with which an operator can initiate + OptInToChainID(context.Context, *OptInToChainIDRequest) (*OptInToChainIDResponse, error) + // InitiateOptOutFromChainID is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - InitiateOptOutFromChainId(context.Context, *InitiateOptOutFromChainIdRequest) (*InitiateOptOutFromChainIdResponse, error) + InitiateOptOutFromChainID(context.Context, *InitiateOptOutFromChainIDRequest) (*InitiateOptOutFromChainIDResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -838,11 +874,11 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *RegisterOperatorReq) (*RegisterOperatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterOperator not implemented") } -func (*UnimplementedMsgServer) OptInToChainId(ctx context.Context, req *OptInToChainIdRequest) (*OptInToChainIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method OptInToChainId not implemented") +func (*UnimplementedMsgServer) OptInToChainID(ctx context.Context, req *OptInToChainIDRequest) (*OptInToChainIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OptInToChainID not implemented") } -func (*UnimplementedMsgServer) InitiateOptOutFromChainId(ctx context.Context, req *InitiateOptOutFromChainIdRequest) (*InitiateOptOutFromChainIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method InitiateOptOutFromChainId not implemented") +func (*UnimplementedMsgServer) InitiateOptOutFromChainID(ctx context.Context, req *InitiateOptOutFromChainIDRequest) (*InitiateOptOutFromChainIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InitiateOptOutFromChainID not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -867,38 +903,38 @@ func _Msg_RegisterOperator_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Msg_OptInToChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(OptInToChainIdRequest) +func _Msg_OptInToChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OptInToChainIDRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).OptInToChainId(ctx, in) + return srv.(MsgServer).OptInToChainID(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Msg/OptInToChainId", + FullMethod: "/exocore.operator.v1.Msg/OptInToChainID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).OptInToChainId(ctx, req.(*OptInToChainIdRequest)) + return srv.(MsgServer).OptInToChainID(ctx, req.(*OptInToChainIDRequest)) } return interceptor(ctx, in, info, handler) } -func _Msg_InitiateOptOutFromChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InitiateOptOutFromChainIdRequest) +func _Msg_InitiateOptOutFromChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InitiateOptOutFromChainIDRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).InitiateOptOutFromChainId(ctx, in) + return srv.(MsgServer).InitiateOptOutFromChainID(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Msg/InitiateOptOutFromChainId", + FullMethod: "/exocore.operator.v1.Msg/InitiateOptOutFromChainID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).InitiateOptOutFromChainId(ctx, req.(*InitiateOptOutFromChainIdRequest)) + return srv.(MsgServer).InitiateOptOutFromChainID(ctx, req.(*InitiateOptOutFromChainIDRequest)) } return interceptor(ctx, in, info, handler) } @@ -912,18 +948,51 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RegisterOperator_Handler, }, { - MethodName: "OptInToChainId", - Handler: _Msg_OptInToChainId_Handler, + MethodName: "OptInToChainID", + Handler: _Msg_OptInToChainID_Handler, }, { - MethodName: "InitiateOptOutFromChainId", - Handler: _Msg_InitiateOptOutFromChainId_Handler, + MethodName: "InitiateOptOutFromChainID", + Handler: _Msg_InitiateOptOutFromChainID_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "exocore/operator/v1/tx.proto", } +func (m *DecValueField) 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 *DecValueField) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DecValueField) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *ClientChainEarningAddrList) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1092,7 +1161,7 @@ func (m *OptedInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *AssetOptedInState) Marshal() (dAtA []byte, err error) { +func (m *OptedInAssetState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1102,12 +1171,12 @@ func (m *AssetOptedInState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AssetOptedInState) MarshalTo(dAtA []byte) (int, error) { +func (m *OptedInAssetState) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AssetOptedInState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OptedInAssetState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1135,39 +1204,6 @@ func (m *AssetOptedInState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ValueField) 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 *ValueField) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValueField) 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 = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *OperatorSlashInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1298,7 +1334,7 @@ func (m *RegisterOperatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *OptInToChainIdRequest) Marshal() (dAtA []byte, err error) { +func (m *OptInToChainIDRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1308,12 +1344,12 @@ func (m *OptInToChainIdRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OptInToChainIdRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *OptInToChainIDRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OptInToChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OptInToChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1342,7 +1378,7 @@ func (m *OptInToChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *OptInToChainIdResponse) Marshal() (dAtA []byte, err error) { +func (m *OptInToChainIDResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1352,12 +1388,12 @@ func (m *OptInToChainIdResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OptInToChainIdResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *OptInToChainIDResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OptInToChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OptInToChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1365,7 +1401,7 @@ func (m *OptInToChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *InitiateOptOutFromChainIdRequest) Marshal() (dAtA []byte, err error) { +func (m *InitiateOptOutFromChainIDRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1375,12 +1411,12 @@ func (m *InitiateOptOutFromChainIdRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *InitiateOptOutFromChainIdRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromChainIDRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InitiateOptOutFromChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1402,7 +1438,7 @@ func (m *InitiateOptOutFromChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } -func (m *InitiateOptOutFromChainIdResponse) Marshal() (dAtA []byte, err error) { +func (m *InitiateOptOutFromChainIDResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1412,12 +1448,12 @@ func (m *InitiateOptOutFromChainIdResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *InitiateOptOutFromChainIdResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromChainIDResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InitiateOptOutFromChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1436,6 +1472,17 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *DecValueField) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + func (m *ClientChainEarningAddrList) Size() (n int) { if m == nil { return 0 @@ -1511,7 +1558,7 @@ func (m *OptedInfo) Size() (n int) { return n } -func (m *AssetOptedInState) Size() (n int) { +func (m *OptedInAssetState) Size() (n int) { if m == nil { return 0 } @@ -1524,17 +1571,6 @@ func (m *AssetOptedInState) Size() (n int) { return n } -func (m *ValueField) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - func (m *OperatorSlashInfo) Size() (n int) { if m == nil { return 0 @@ -1588,7 +1624,7 @@ func (m *RegisterOperatorResponse) Size() (n int) { return n } -func (m *OptInToChainIdRequest) Size() (n int) { +func (m *OptInToChainIDRequest) Size() (n int) { if m == nil { return 0 } @@ -1609,7 +1645,7 @@ func (m *OptInToChainIdRequest) Size() (n int) { return n } -func (m *OptInToChainIdResponse) Size() (n int) { +func (m *OptInToChainIDResponse) Size() (n int) { if m == nil { return 0 } @@ -1618,7 +1654,7 @@ func (m *OptInToChainIdResponse) Size() (n int) { return n } -func (m *InitiateOptOutFromChainIdRequest) Size() (n int) { +func (m *InitiateOptOutFromChainIDRequest) Size() (n int) { if m == nil { return 0 } @@ -1635,7 +1671,7 @@ func (m *InitiateOptOutFromChainIdRequest) Size() (n int) { return n } -func (m *InitiateOptOutFromChainIdResponse) Size() (n int) { +func (m *InitiateOptOutFromChainIDResponse) Size() (n int) { if m == nil { return 0 } @@ -1650,6 +1686,90 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *DecValueField) 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 ErrIntOverflowTx + } + 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: DecValueField: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecValueField: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ClientChainEarningAddrList) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1673,10 +1793,10 @@ func (m *ClientChainEarningAddrList) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: clientChainEarningAddrList: wiretype end group for non-group") + return fmt.Errorf("proto: ClientChainEarningAddrList: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: clientChainEarningAddrList: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ClientChainEarningAddrList: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1757,10 +1877,10 @@ func (m *ClientChainEarningAddrInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: clientChainEarningAddrInfo: wiretype end group for non-group") + return fmt.Errorf("proto: ClientChainEarningAddrInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: clientChainEarningAddrInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ClientChainEarningAddrInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2137,7 +2257,7 @@ func (m *OptedInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *AssetOptedInState) Unmarshal(dAtA []byte) error { +func (m *OptedInAssetState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2160,10 +2280,10 @@ func (m *AssetOptedInState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: AssetOptedInState: wiretype end group for non-group") + return fmt.Errorf("proto: OptedInAssetState: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: AssetOptedInState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OptedInAssetState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2255,90 +2375,6 @@ func (m *AssetOptedInState) Unmarshal(dAtA []byte) error { } return nil } -func (m *ValueField) 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 ErrIntOverflowTx - } - 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: ValueField: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValueField: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2700,7 +2736,7 @@ func (m *RegisterOperatorResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *OptInToChainIdRequest) Unmarshal(dAtA []byte) error { +func (m *OptInToChainIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2723,10 +2759,10 @@ func (m *OptInToChainIdRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OptInToChainIdRequest: wiretype end group for non-group") + return fmt.Errorf("proto: OptInToChainIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OptInToChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OptInToChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2846,7 +2882,7 @@ func (m *OptInToChainIdRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *OptInToChainIdResponse) Unmarshal(dAtA []byte) error { +func (m *OptInToChainIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2869,10 +2905,10 @@ func (m *OptInToChainIdResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OptInToChainIdResponse: wiretype end group for non-group") + return fmt.Errorf("proto: OptInToChainIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OptInToChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OptInToChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2896,7 +2932,7 @@ func (m *OptInToChainIdResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *InitiateOptOutFromChainIdRequest) Unmarshal(dAtA []byte) error { +func (m *InitiateOptOutFromChainIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2919,10 +2955,10 @@ func (m *InitiateOptOutFromChainIdRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InitiateOptOutFromChainIdRequest: wiretype end group for non-group") + return fmt.Errorf("proto: InitiateOptOutFromChainIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InitiateOptOutFromChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InitiateOptOutFromChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3010,7 +3046,7 @@ func (m *InitiateOptOutFromChainIdRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *InitiateOptOutFromChainIdResponse) Unmarshal(dAtA []byte) error { +func (m *InitiateOptOutFromChainIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3033,10 +3069,10 @@ func (m *InitiateOptOutFromChainIdResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InitiateOptOutFromChainIdResponse: wiretype end group for non-group") + return fmt.Errorf("proto: InitiateOptOutFromChainIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InitiateOptOutFromChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InitiateOptOutFromChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/restaking_assets_manage/keeper/app_chain.go b/x/restaking_assets_manage/keeper/app_chain.go index 915c9fe35..ea26b3e04 100644 --- a/x/restaking_assets_manage/keeper/app_chain.go +++ b/x/restaking_assets_manage/keeper/app_chain.go @@ -19,22 +19,22 @@ func (k Keeper) SetAppChainInfo( } // AppChainInfoIsExist returns whether the app chain info for the specified chainId exists -func (k Keeper) AppChainInfoIsExist(ctx sdk.Context, chainId string) bool { +func (k Keeper) AppChainInfoIsExist(ctx sdk.Context, chainID string) bool { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) - return store.Has([]byte(chainId)) + return store.Has([]byte(chainID)) } -// GetAppChainInfoByChainId gets the app chain info for the specified chainId, if it exists -func (k Keeper) GetAppChainInfoByChainId( +// GetAppChainInfoByChainID gets the app chain info for the specified chainId, if it exists +func (k Keeper) GetAppChainInfoByChainID( ctx sdk.Context, - chainId string, + chainID string, ) (info restakingtype.AppChainInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) - ifExist := store.Has([]byte(chainId)) + ifExist := store.Has([]byte(chainID)) if !ifExist { return restakingtype.AppChainInfo{}, restakingtype.ErrNoAppChainKey } - value := store.Get([]byte(chainId)) + value := store.Get([]byte(chainID)) ret := restakingtype.AppChainInfo{} k.cdc.MustUnmarshal(value, &ret) return ret, nil diff --git a/x/restaking_assets_manage/keeper/grpc_query.go b/x/restaking_assets_manage/keeper/grpc_query.go index e82ab10ff..c4dde8f0e 100644 --- a/x/restaking_assets_manage/keeper/grpc_query.go +++ b/x/restaking_assets_manage/keeper/grpc_query.go @@ -85,9 +85,9 @@ func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *restak // QueStakerExoCoreAddr outdated,will be deprecated func (k Keeper) QueStakerExoCoreAddr(ctx context.Context, req *restakingtype.QueryStakerExCoreAddr) (*restakingtype.QueryStakerExCoreAddrResponse, error) { c := sdk.UnwrapSDKContext(ctx) - exoCoreAddr, err := k.GetStakerExoCoreAddr(c, req.StakerID) + exoCoreAddr, err := k.GetStakerExoCoreAddr(c, req.Staker) if err != nil { return nil, err } - return &restakingtype.QueryStakerExCoreAddrResponse{ExCoreAddr: exoCoreAddr}, nil + return &restakingtype.QueryStakerExCoreAddrResponse{ExoCoreAddr: exoCoreAddr}, nil } diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go index d46fc5ca6..a48f83c9c 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/restaking_assets_manage/keeper/operator_asset.go @@ -10,7 +10,7 @@ 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]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) { +func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, _ map[string]interface{}) (assetsInfo map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) // the key is the operator address in the bech32 format key := []byte(operatorAddr.String()) @@ -51,7 +51,7 @@ func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk. // The function will be called when there is delegation or undelegation related to the operator. In the future,it will also be called when the operator deposit their own assets. func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) { - //get the latest state,use the default initial state if the state hasn't been stored + // get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetID) assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ @@ -59,7 +59,7 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre OperatorOwnAmountOrWantChangeValue: math.NewInt(0), WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), OperatorOwnWaitUnbondingAmount: math.NewInt(0), - OperatorUnbondableAmountAfterSlash: math.NewInt(0), + OperatorCanUnbondAfterSlash: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -83,12 +83,12 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") } - err = restakingtype.UpdateAssetValue(&assetState.OperatorUnbondableAmountAfterSlash, &changeAmount.OperatorUnbondableAmountAfterSlash) + err = restakingtype.UpdateAssetValue(&assetState.OperatorCanUnbondAfterSlash, &changeAmount.OperatorCanUnbondAfterSlash) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") } - //store the updated state + // store the updated state bz := k.cdc.MustMarshal(&assetState) store.Set(key, bz) return nil diff --git a/x/restaking_assets_manage/keeper/setup_test.go b/x/restaking_assets_manage/keeper/setup_test.go index 21d80f32f..51349b55c 100644 --- a/x/restaking_assets_manage/keeper/setup_test.go +++ b/x/restaking_assets_manage/keeper/setup_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/x/restaking_assets_manage/keeper/staker_asset.go b/x/restaking_assets_manage/keeper/staker_asset.go index 9991e5601..b79e2ea2c 100644 --- a/x/restaking_assets_manage/keeper/staker_asset.go +++ b/x/restaking_assets_manage/keeper/staker_asset.go @@ -48,7 +48,7 @@ func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, as // The input `changeAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is deposit or withdraw related to the specified staker. func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) { - //get the latest state,use the default initial state if the state hasn't been stored + // get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) key := restakingtype.GetJoinedStoreKey(stakerID, assetID) assetState := restakingtype.StakerSingleAssetOrChangeInfo{ diff --git a/x/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go index a9f6ea5a4..98fad4821 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/restaking_assets_manage/types/general.go @@ -1,13 +1,15 @@ package types import ( + "fmt" + "strings" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - "fmt" + "github.com/cosmos/cosmos-sdk/store/rootmulti" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "strings" "github.com/ethereum/go-ethereum/common/hexutil" ) @@ -131,7 +133,7 @@ func ContextForHistoricalState(ctx sdk.Context, height int64) (sdk.Context, erro cacheMS, err := cms.CacheMultiStoreWithVersion(height) if err != nil { return sdk.Context{}, - sdkerrors.Wrapf( + errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "failed to load state at height %d; %s (latest height: %d)", height, err, lastBlockHeight, ) @@ -146,7 +148,7 @@ func ContextForHistoricalState(ctx sdk.Context, height int64) (sdk.Context, erro if ok { cInfo, err := rms.GetCommitInfo(height) if cInfo != nil && err == nil { - ctx = ctx.WithBlockTime(cInfo.Timestamp) + historicalStateCtx = historicalStateCtx.WithBlockTime(cInfo.Timestamp) } } } diff --git a/x/restaking_assets_manage/types/keys.go b/x/restaking_assets_manage/types/keys.go index 83df033b1..205c5e8ef 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/restaking_assets_manage/types/keys.go @@ -2,9 +2,10 @@ package types import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "strings" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsmod "cosmossdk.io/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/restaking_assets_manage/types/tx.pb.go index b287edae2..ce9c34898 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/restaking_assets_manage/types/tx.pb.go @@ -32,6 +32,45 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// ValueField is a field that holds a value of sdk.Int type. +type ValueField struct { + // amount is the amount of the asset, as an sdk.Int. + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *ValueField) Reset() { *m = ValueField{} } +func (m *ValueField) String() string { return proto.CompactTextString(m) } +func (*ValueField) ProtoMessage() {} +func (*ValueField) Descriptor() ([]byte, []int) { + return fileDescriptor_b24e66e530cc30d1, []int{0} +} +func (m *ValueField) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValueField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValueField.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 *ValueField) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValueField.Merge(m, src) +} +func (m *ValueField) XXX_Size() int { + return m.Size() +} +func (m *ValueField) XXX_DiscardUnknown() { + xxx_messageInfo_ValueField.DiscardUnknown(m) +} + +var xxx_messageInfo_ValueField proto.InternalMessageInfo + // ClientChainInfo defines the client chain information. type ClientChainInfo struct { // name of the client chain, like "Ethereum". @@ -57,7 +96,7 @@ func (m *ClientChainInfo) Reset() { *m = ClientChainInfo{} } func (m *ClientChainInfo) String() string { return proto.CompactTextString(m) } func (*ClientChainInfo) ProtoMessage() {} func (*ClientChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{0} + return fileDescriptor_b24e66e530cc30d1, []int{1} } func (m *ClientChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -142,6 +181,81 @@ func (m *ClientChainInfo) GetAddressLength() uint32 { return 0 } +// AppChainInfo is used to store information related to the subscriber app chains we validate. +// The information stored within this module consists only of the chain's identifiers. +// The validation-related information is stored in the coordinator module. +type AppChainInfo struct { + // name of the chain, for example "ethereum" + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // meta_info is at Exocore's discretion to deter,ome + MetaInfo string `protobuf:"bytes,2,opt,name=meta_info,json=metaInfo,proto3" json:"meta_info,omitempty"` + // chain_id is used as the primary key + ChainId string `protobuf:"bytes,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // exo_core_chain_index is the index of the chain in exocore, so far unused + ExoCoreChainIndex uint64 `protobuf:"varint,4,opt,name=exo_core_chain_index,json=exoCoreChainIndex,proto3" json:"exo_core_chain_index,omitempty"` +} + +func (m *AppChainInfo) Reset() { *m = AppChainInfo{} } +func (m *AppChainInfo) String() string { return proto.CompactTextString(m) } +func (*AppChainInfo) ProtoMessage() {} +func (*AppChainInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b24e66e530cc30d1, []int{2} +} +func (m *AppChainInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AppChainInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AppChainInfo.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 *AppChainInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_AppChainInfo.Merge(m, src) +} +func (m *AppChainInfo) XXX_Size() int { + return m.Size() +} +func (m *AppChainInfo) XXX_DiscardUnknown() { + xxx_messageInfo_AppChainInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_AppChainInfo proto.InternalMessageInfo + +func (m *AppChainInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *AppChainInfo) GetMetaInfo() string { + if m != nil { + return m.MetaInfo + } + return "" +} + +func (m *AppChainInfo) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *AppChainInfo) GetExoCoreChainIndex() uint64 { + if m != nil { + return m.ExoCoreChainIndex + } + return 0 +} + // AssetInfo defines the information for an asset to be used in staking. type AssetInfo struct { // name of the asset, like "Tether USD" @@ -166,7 +280,7 @@ func (m *AssetInfo) Reset() { *m = AssetInfo{} } func (m *AssetInfo) String() string { return proto.CompactTextString(m) } func (*AssetInfo) ProtoMessage() {} func (*AssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{1} + return fileDescriptor_b24e66e530cc30d1, []int{3} } func (m *AssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -256,7 +370,7 @@ func (m *StakingAssetInfo) Reset() { *m = StakingAssetInfo{} } func (m *StakingAssetInfo) String() string { return proto.CompactTextString(m) } func (*StakingAssetInfo) ProtoMessage() {} func (*StakingAssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{2} + return fileDescriptor_b24e66e530cc30d1, []int{4} } func (m *StakingAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -303,16 +417,16 @@ type StakerSingleAssetOrChangeInfo struct { // can_withdraw_amount_or_want_change_value is the amount that can be withdrawn // or the amount by which it can change. CanWithdrawAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=can_withdraw_amount_or_want_change_value,json=canWithdrawAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_withdraw_amount_or_want_change_value"` - // wait_undelegation_amount_or_want_change_value is the amount that is waiting for undelegation + // wait_unbonding_amount_or_want_change_value is the amount that is waiting for undelegation // or the amount by which it can change. - WaitUndelegationAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_undelegation_amount_or_want_change_value,json=waitUndelegationAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_undelegation_amount_or_want_change_value"` + WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount_or_want_change_value,json=waitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount_or_want_change_value"` } func (m *StakerSingleAssetOrChangeInfo) Reset() { *m = StakerSingleAssetOrChangeInfo{} } func (m *StakerSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } func (*StakerSingleAssetOrChangeInfo) ProtoMessage() {} func (*StakerSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{3} + return fileDescriptor_b24e66e530cc30d1, []int{5} } func (m *StakerSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -352,7 +466,7 @@ func (m *StakerAllAssetsInfo) Reset() { *m = StakerAllAssetsInfo{} } func (m *StakerAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*StakerAllAssetsInfo) ProtoMessage() {} func (*StakerAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{4} + return fileDescriptor_b24e66e530cc30d1, []int{6} } func (m *StakerAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -398,16 +512,22 @@ type OperatorSingleAssetOrChangeInfo struct { // or the amount by which it can change. // todo: the field is used to mark operator's own assets and is not temporarily used now OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=operator_own_amount_or_want_change_value,json=operatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_own_amount_or_want_change_value"` - // wait_undelegation_amount_or_want_change_value is the amount that is waiting for undelegation + // wait_unbonding_amount_or_want_change_value is the amount that is waiting for unbonding // or the amount by which it can change. - WaitUndelegationAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_undelegation_amount_or_want_change_value,json=waitUndelegationAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_undelegation_amount_or_want_change_value"` + WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount_or_want_change_value,json=waitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount_or_want_change_value"` + // operator_own_wait_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding + // or the amount by which it can change + OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=operator_own_wait_unbonding_amount,json=operatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_own_wait_unbonding_amount"` + // operator_can_unbond_after_slash is the amount that is owned by operator itself and can be unbonded after slash + // or the amount by which it can change + OperatorCanUnbondAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=operator_can_unbond_after_slash,json=operatorCanUnbondAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_can_unbond_after_slash"` } func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleAssetOrChangeInfo{} } func (m *OperatorSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } func (*OperatorSingleAssetOrChangeInfo) ProtoMessage() {} func (*OperatorSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{5} + return fileDescriptor_b24e66e530cc30d1, []int{7} } func (m *OperatorSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -447,7 +567,7 @@ func (m *OperatorAllAssetsInfo) Reset() { *m = OperatorAllAssetsInfo{} } func (m *OperatorAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*OperatorAllAssetsInfo) ProtoMessage() {} func (*OperatorAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{6} + return fileDescriptor_b24e66e530cc30d1, []int{8} } func (m *OperatorAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -503,7 +623,7 @@ func (m *MsgSetExoCoreAddr) Reset() { *m = MsgSetExoCoreAddr{} } func (m *MsgSetExoCoreAddr) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddr) ProtoMessage() {} func (*MsgSetExoCoreAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{7} + return fileDescriptor_b24e66e530cc30d1, []int{9} } func (m *MsgSetExoCoreAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -541,7 +661,7 @@ func (m *MsgSetExoCoreAddrResponse) Reset() { *m = MsgSetExoCoreAddrResp func (m *MsgSetExoCoreAddrResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddrResponse) ProtoMessage() {} func (*MsgSetExoCoreAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{8} + return fileDescriptor_b24e66e530cc30d1, []int{10} } func (m *MsgSetExoCoreAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -582,7 +702,7 @@ func (m *RegisterClientChainReq) Reset() { *m = RegisterClientChainReq{} func (m *RegisterClientChainReq) String() string { return proto.CompactTextString(m) } func (*RegisterClientChainReq) ProtoMessage() {} func (*RegisterClientChainReq) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{9} + return fileDescriptor_b24e66e530cc30d1, []int{11} } func (m *RegisterClientChainReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -619,7 +739,7 @@ func (m *RegisterClientChainResponse) Reset() { *m = RegisterClientChain func (m *RegisterClientChainResponse) String() string { return proto.CompactTextString(m) } func (*RegisterClientChainResponse) ProtoMessage() {} func (*RegisterClientChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{10} + return fileDescriptor_b24e66e530cc30d1, []int{12} } func (m *RegisterClientChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -661,7 +781,7 @@ func (m *RegisterAssetReq) Reset() { *m = RegisterAssetReq{} } func (m *RegisterAssetReq) String() string { return proto.CompactTextString(m) } func (*RegisterAssetReq) ProtoMessage() {} func (*RegisterAssetReq) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{11} + return fileDescriptor_b24e66e530cc30d1, []int{13} } func (m *RegisterAssetReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -698,7 +818,7 @@ func (m *RegisterAssetResponse) Reset() { *m = RegisterAssetResponse{} } func (m *RegisterAssetResponse) String() string { return proto.CompactTextString(m) } func (*RegisterAssetResponse) ProtoMessage() {} func (*RegisterAssetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{12} + return fileDescriptor_b24e66e530cc30d1, []int{14} } func (m *RegisterAssetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -728,7 +848,9 @@ func (m *RegisterAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterAssetResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*ValueField)(nil), "exocore.restaking_assets_manage.v1.ValueField") proto.RegisterType((*ClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainInfo") + proto.RegisterType((*AppChainInfo)(nil), "exocore.restaking_assets_manage.v1.AppChainInfo") proto.RegisterType((*AssetInfo)(nil), "exocore.restaking_assets_manage.v1.AssetInfo") proto.RegisterType((*StakingAssetInfo)(nil), "exocore.restaking_assets_manage.v1.StakingAssetInfo") proto.RegisterType((*StakerSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.StakerSingleAssetOrChangeInfo") @@ -750,86 +872,91 @@ func init() { } var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1251 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0x69, 0x93, 0x8c, 0x9b, 0xd6, 0xd9, 0xb8, 0xad, 0xe3, 0x52, 0xbb, 0x18, 0x01, - 0x21, 0x10, 0x5b, 0x4d, 0x29, 0xa2, 0x29, 0x08, 0x39, 0x6e, 0x40, 0x11, 0x0d, 0x91, 0xd6, 0x85, - 0x88, 0x72, 0x58, 0x4d, 0x76, 0x27, 0x9b, 0x55, 0x76, 0x67, 0xcc, 0xce, 0x38, 0xb6, 0x7b, 0xaa, - 0x10, 0x20, 0x84, 0x38, 0x20, 0xe0, 0x82, 0xc4, 0xa1, 0x1f, 0x21, 0x12, 0xfd, 0x10, 0xe5, 0x56, - 0xe5, 0x84, 0x40, 0x44, 0x25, 0x39, 0x04, 0xf1, 0x29, 0xd0, 0xfc, 0x59, 0xc7, 0xdb, 0xd8, 0xa9, - 0xf3, 0xa7, 0x07, 0x2e, 0xc9, 0xce, 0xbc, 0x7f, 0xbf, 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 0x3d, 0xde, 0xc9, 0xc5, 0x7e, 0xdf, 0xc9, 0xc5, 0xee, 0x96, 0x3b, 0x1e, 0xab, 0x39, 0x19, 0xe5, - 0x23, 0xc4, 0x1a, 0x24, 0x58, 0x2b, 0x85, 0x77, 0x40, 0xb3, 0xe7, 0x2f, 0x72, 0xf1, 0x96, 0x2d, - 0x9f, 0x16, 0xbf, 0x88, 0xaf, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x33, 0xb6, 0xf5, 0xc1, - 0x0f, 0x00, 0x00, + // 1338 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x5b, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0xda, 0xb9, 0x1e, 0x37, 0xad, 0xb3, 0x49, 0x5b, 0xc7, 0xf9, 0xd7, 0xee, 0x7f, 0xb9, + 0x28, 0x04, 0x62, 0xab, 0x29, 0x45, 0x34, 0x05, 0x21, 0xc7, 0x6d, 0x51, 0x44, 0x4b, 0xa4, 0x75, + 0x21, 0xa2, 0x3c, 0xac, 0xc6, 0xde, 0xc9, 0x66, 0x95, 0xf5, 0x8c, 0xd9, 0x19, 0xd7, 0x76, 0x9f, + 0xaa, 0x0a, 0x50, 0x05, 0x3c, 0x20, 0x40, 0x48, 0xbc, 0xf5, 0x23, 0x54, 0xa2, 0x1f, 0xa2, 0xbc, + 0x55, 0x7d, 0x42, 0x20, 0x55, 0x25, 0x45, 0x0a, 0x1f, 0x03, 0xcd, 0xcc, 0xae, 0xe3, 0x6d, 0xec, + 0xd6, 0x49, 0xdc, 0x07, 0x5e, 0x12, 0xcf, 0xb9, 0xfe, 0xce, 0x65, 0xce, 0x1c, 0x1b, 0xde, 0xc4, + 0x4d, 0x5a, 0xa1, 0x3e, 0xce, 0xfb, 0x98, 0x71, 0xb4, 0xe5, 0x12, 0xc7, 0x42, 0x8c, 0x61, 0xce, + 0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2c, 0xf1, 0xa4, 0x4e, 0x77, 0xa9, 0x8d, 0xbe, 0xdc, + 0x8f, 0xd9, 0xee, 0x1d, 0x9b, 0xfe, 0xe0, 0xc0, 0xba, 0x01, 0xa8, 0x5b, 0x1a, 0x4c, 0x46, 0xb2, + 0xa8, 0xbf, 0xbd, 0x1f, 0x93, 0x61, 0x0f, 0xa5, 0xcf, 0x1f, 0x40, 0x4b, 0x41, 0x48, 0x8f, 0xdc, + 0xda, 0xb9, 0xb7, 0xa0, 0xad, 0x7c, 0xfe, 0x60, 0x3b, 0xa3, 0x3d, 0xdc, 0xce, 0x68, 0x4f, 0xb6, + 0x33, 0xda, 0xf7, 0x4f, 0x33, 0x43, 0x0f, 0x9f, 0x66, 0x86, 0x7e, 0x7f, 0x9a, 0x19, 0xba, 0x5e, + 0xe8, 0x78, 0xa0, 0x2e, 0x29, 0x2f, 0x1f, 0x63, 0xde, 0xa0, 0xfe, 0x56, 0x3e, 0x9c, 0x01, 0xcd, + 0x9e, 0xbf, 0xc3, 0xc8, 0xf7, 0xab, 0x3c, 0x2a, 0x7f, 0x07, 0x39, 0xfb, 0x6f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x6b, 0x10, 0x0d, 0x13, 0xb7, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -990,6 +1117,39 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "exocore/restaking_assets_manage/v1/tx.proto", } +func (m *ValueField) 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 *ValueField) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValueField) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *ClientChainInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1059,6 +1219,55 @@ func (m *ClientChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AppChainInfo) 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 *AppChainInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AppChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExoCoreChainIndex != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExoCoreChainIndex)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x1a + } + if len(m.MetaInfo) > 0 { + i -= len(m.MetaInfo) + copy(dAtA[i:], m.MetaInfo) + i = encodeVarintTx(dAtA, i, uint64(len(m.MetaInfo))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *AssetInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1201,9 +1410,9 @@ func (m *StakerSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l { - size := m.WaitUndelegationAmountOrWantChangeValue.Size() + size := m.WaitUnbondingAmountOrWantChangeValue.Size() i -= size - if _, err := m.WaitUndelegationAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1303,9 +1512,29 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int var l int _ = l { - size := m.WaitUndelegationAmountOrWantChangeValue.Size() + size := m.OperatorCanUnbondAfterSlash.Size() + i -= size + if _, err := m.OperatorCanUnbondAfterSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.OperatorOwnWaitUnbondingAmount.Size() + i -= size + if _, err := m.OperatorOwnWaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.WaitUnbondingAmountOrWantChangeValue.Size() i -= size - if _, err := m.WaitUndelegationAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1604,6 +1833,17 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *ValueField) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + func (m *ClientChainInfo) Size() (n int) { if m == nil { return 0 @@ -1640,6 +1880,30 @@ func (m *ClientChainInfo) Size() (n int) { return n } +func (m *AppChainInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MetaInfo) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ExoCoreChainIndex != 0 { + n += 1 + sovTx(uint64(m.ExoCoreChainIndex)) + } + return n +} + func (m *AssetInfo) Size() (n int) { if m == nil { return 0 @@ -1701,7 +1965,7 @@ func (m *StakerSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.CanWithdrawAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUndelegationAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1738,7 +2002,11 @@ func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.OperatorOwnAmountOrWantChangeValue.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUndelegationAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmountOrWantChangeValue.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.OperatorOwnWaitUnbondingAmount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.OperatorCanUnbondAfterSlash.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1860,7 +2128,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { +func (m *ValueField) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1883,15 +2151,15 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ClientChainInfo: wiretype end group for non-group") + return fmt.Errorf("proto: ValueField: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ClientChainInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ValueField: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1919,42 +2187,126 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MetaInfo", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.MetaInfo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ClientChainInfo) 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 ErrIntOverflowTx + } + 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: ClientChainInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ClientChainInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MetaInfo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MetaInfo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } m.ChainId = 0 @@ -2101,6 +2453,171 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } return nil } +func (m *AppChainInfo) 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 ErrIntOverflowTx + } + 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: AppChainInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AppChainInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MetaInfo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MetaInfo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreChainIndex", wireType) + } + m.ExoCoreChainIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExoCoreChainIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *AssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2589,7 +3106,7 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUndelegationAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmountOrWantChangeValue", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2617,7 +3134,7 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUndelegationAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.WaitUnbondingAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2920,7 +3437,75 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUndelegationAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmountOrWantChangeValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WaitUnbondingAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnWaitUnbondingAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OperatorOwnWaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorCanUnbondAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2948,7 +3533,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUndelegationAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OperatorCanUnbondAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index 71867efbc..ff7a64529 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -85,12 +85,12 @@ func getRewardParamsFromEventLog(log *ethtypes.Log) (*RewardParams, error) { func getStakeIDAndAssetID(params *RewardParams) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) - stakeID = strings.Join([]string{hexutil.Encode(params.WithdrawRewardAddress[:]), clientChainLzIDStr}, "_") - assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(params.WithdrawRewardAddress), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress), clientChainLzIDStr}, "_") return } -func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { +func (k Keeper) PostTxProcessing(ctx sdk.Context, _ core.Message, receipt *ethtypes.Receipt) error { // TODO check if contract address is valid layerZero relayer address // check if log address and topicId is valid params, err := k.GetParams(ctx) diff --git a/x/reward/keeper/setup_test.go b/x/reward/keeper/setup_test.go index 1927a5b17..4cb58894d 100644 --- a/x/reward/keeper/setup_test.go +++ b/x/reward/keeper/setup_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/ginkgo/v2" //nolint:revive // dot imports are fine for Ginkgo diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index eacc1fb33..d6c238791 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -115,8 +115,8 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas func getStakeIDAndAssetID(params *SlashParams) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) - stakeID = strings.Join([]string{hexutil.Encode(params.StakerAddress[:]), clientChainLzIDStr}, "_") - assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(params.StakerAddress), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress), clientChainLzIDStr}, "_") return } diff --git a/x/slash/keeper/setup_test.go b/x/slash/keeper/setup_test.go index cf45470b0..70c6d6239 100644 --- a/x/slash/keeper/setup_test.go +++ b/x/slash/keeper/setup_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/ginkgo/v2" //nolint:revive // dot imports are fine for Ginkgo diff --git a/x/withdraw/keeper/claim_withdraw.go b/x/withdraw/keeper/claim_withdraw.go index 2c59da081..1b4275352 100644 --- a/x/withdraw/keeper/claim_withdraw.go +++ b/x/withdraw/keeper/claim_withdraw.go @@ -77,8 +77,8 @@ type WithdrawParams struct { func getStakeIDAndAssetID(params *WithdrawParams) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(params.ClientChainLzID) - stakeID = strings.Join([]string{hexutil.Encode(params.WithdrawAddress[:]), clientChainLzIDStr}, "_") - assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress[:]), clientChainLzIDStr}, "_") + stakeID = strings.Join([]string{hexutil.Encode(params.WithdrawAddress), clientChainLzIDStr}, "_") + assetID = strings.Join([]string{hexutil.Encode(params.AssetsAddress), clientChainLzIDStr}, "_") return } diff --git a/x/withdraw/keeper/setup_test.go b/x/withdraw/keeper/setup_test.go index 9dd0c641a..f2304a2b8 100644 --- a/x/withdraw/keeper/setup_test.go +++ b/x/withdraw/keeper/setup_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/testutil" "testing" + "github.com/ExocoreNetwork/exocore/testutil" + //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/ginkgo/v2" //nolint:revive // dot imports are fine for Ginkgo From 30159432c57d63933e5017be8aa6a851bdaf7981 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 11 Mar 2024 15:05:26 +0800 Subject: [PATCH 36/44] refine the code related to updating state rename package restaking_assets_manage to assets refine some code related to naming and comments --- app/app.go | 12 +- precompiles/delegation/delegation.go | 2 +- precompiles/delegation/delegation.sol | 4 +- precompiles/delegation/delegation_test.go | 2 +- precompiles/delegation/tx.go | 4 +- precompiles/delegation/types.go | 2 +- precompiles/deposit/deposit.go | 2 +- precompiles/deposit/deposit.sol | 6 +- precompiles/deposit/deposit_integrate_test.go | 2 +- precompiles/deposit/deposit_test.go | 2 +- precompiles/deposit/tx.go | 4 +- precompiles/deposit/types.go | 2 +- precompiles/reward/methods.go | 4 +- precompiles/reward/parser.go | 2 +- precompiles/reward/reward.go | 2 +- precompiles/reward/reward_test.go | 2 +- precompiles/slash/parser.go | 2 +- precompiles/slash/slash.go | 2 +- precompiles/slash/slash_test.go | 2 +- precompiles/withdraw/methods.go | 4 +- precompiles/withdraw/parser.go | 2 +- precompiles/withdraw/withdraw.go | 2 +- .../withdraw/withdraw_integrate_test.go | 2 +- precompiles/withdraw/withdraw_test.go | 2 +- .../v1/genesis.proto | 8 +- .../v1/query.proto | 34 +- .../v1/tx.proto | 77 ++- proto/exocore/delegation/v1/query.proto | 8 +- proto/exocore/deposit/v1/deposit.proto | 2 +- proto/exocore/operator/v1/query.proto | 2 +- proto/exocore/operator/v1/tx.proto | 24 +- testutil/tx/eip712.go | 3 +- .../client/cli/query.go | 4 +- .../client/cli/tx.go | 23 +- .../genesis.go | 45 +- .../keeper/app_chain.go | 24 +- .../keeper/client_chain.go | 24 +- .../keeper/client_chain_and_asset_test.go | 10 +- .../keeper/client_chain_asset.go | 36 +- .../keeper/exocore_addr.go | 0 .../keeper/grpc_query.go | 31 +- .../keeper/keeper.go | 30 +- .../keeper/msg_server.go | 17 +- .../keeper/operator_asset.go | 62 +- .../keeper/setup_test.go | 0 .../keeper/staker_asset.go | 43 +- x/assets/keeper/staker_asset_test.go | 112 ++++ .../module.go | 27 +- .../types/codec.go | 2 +- .../types/errors.go | 0 .../types/expected_keepers.go | 0 .../types/general.go | 32 +- .../types/genesis.pb.go | 50 +- .../types/keys.go | 4 +- .../types/msg.go | 0 .../types/query.pb.go | 289 +++++---- .../types/query.pb.gw.go | 20 +- .../types/tx.pb.go | 572 +++++++++--------- x/delegation/client/cli/query.go | 2 +- x/delegation/keeper/abci.go | 20 +- x/delegation/keeper/cross_chain_tx_process.go | 42 +- x/delegation/keeper/delegation_op_test.go | 80 +-- x/delegation/keeper/delegation_state.go | 34 +- x/delegation/keeper/keeper.go | 4 +- x/delegation/types/keys.go | 2 +- x/delegation/types/query.pb.go | 112 ++-- x/deposit/keeper/cross_chain_tx_process.go | 8 +- x/deposit/keeper/deposit_test.go | 10 +- x/deposit/keeper/keeper.go | 2 +- x/deposit/keeper/msg_server.go | 2 +- x/deposit/types/deposit.pb.go | 2 +- x/evm/keeper/precompiles.go | 2 +- x/operator/client/cli/query.go | 2 +- x/operator/client/cli/tx.go | 2 +- x/operator/keeper/abci.go | 8 +- x/operator/keeper/avs_operator_shares.go | 45 +- x/operator/keeper/dogfood.go | 10 +- x/operator/keeper/grpc_query.go | 6 +- x/operator/keeper/keeper.go | 2 +- x/operator/keeper/operator.go | 11 +- x/operator/keeper/operator_info_test.go | 2 +- x/operator/keeper/operator_slash_state.go | 55 +- x/operator/keeper/state_update.go | 82 +-- x/operator/keeper/state_update_test.go | 8 +- x/operator/types/general.go | 9 + x/operator/types/keys.go | 23 +- x/operator/types/query.pb.go | 178 +++--- x/operator/types/query.pb.gw.go | 4 +- x/operator/types/tx.pb.go | 220 +++---- .../keeper/staker_asset_test.go | 118 ---- x/reward/keeper/claim_reward.go | 8 +- x/reward/keeper/claim_reward_test.go | 10 +- x/reward/keeper/keeper.go | 2 +- x/slash/keeper/execute_slash.go | 8 +- x/slash/keeper/execute_slash_test.go | 18 +- x/slash/keeper/keeper.go | 2 +- x/todo.md | 2 +- x/withdraw/keeper/claim_withdraw.go | 8 +- x/withdraw/keeper/claim_withdraw_test.go | 18 +- x/withdraw/keeper/keeper.go | 2 +- 100 files changed, 1444 insertions(+), 1428 deletions(-) rename proto/exocore/{restaking_assets_manage => assets}/v1/genesis.proto (64%) rename proto/exocore/{restaking_assets_manage => assets}/v1/query.proto (80%) rename proto/exocore/{restaking_assets_manage => assets}/v1/tx.proto (74%) rename x/{restaking_assets_manage => assets}/client/cli/query.go (98%) rename x/{restaking_assets_manage => assets}/client/cli/tx.go (78%) rename x/{restaking_assets_manage => assets}/genesis.go (60%) rename x/{restaking_assets_manage => assets}/keeper/app_chain.go (62%) rename x/{restaking_assets_manage => assets}/keeper/client_chain.go (59%) rename x/{restaking_assets_manage => assets}/keeper/client_chain_and_asset_test.go (76%) rename x/{restaking_assets_manage => assets}/keeper/client_chain_asset.go (55%) rename x/{restaking_assets_manage => assets}/keeper/exocore_addr.go (100%) rename x/{restaking_assets_manage => assets}/keeper/grpc_query.go (62%) rename x/{restaking_assets_manage => assets}/keeper/keeper.go (62%) rename x/{restaking_assets_manage => assets}/keeper/msg_server.go (61%) rename x/{restaking_assets_manage => assets}/keeper/operator_asset.go (50%) rename x/{restaking_assets_manage => assets}/keeper/setup_test.go (100%) rename x/{restaking_assets_manage => assets}/keeper/staker_asset.go (51%) create mode 100644 x/assets/keeper/staker_asset_test.go rename x/{restaking_assets_manage => assets}/module.go (79%) rename x/{restaking_assets_manage => assets}/types/codec.go (94%) rename x/{restaking_assets_manage => assets}/types/errors.go (100%) rename x/{restaking_assets_manage => assets}/types/expected_keepers.go (100%) rename x/{restaking_assets_manage => assets}/types/general.go (88%) rename x/{restaking_assets_manage => assets}/types/genesis.pb.go (81%) rename x/{restaking_assets_manage => assets}/types/keys.go (98%) rename x/{restaking_assets_manage => assets}/types/msg.go (100%) rename x/{restaking_assets_manage => assets}/types/query.pb.go (87%) rename x/{restaking_assets_manage => assets}/types/query.pb.gw.go (96%) rename x/{restaking_assets_manage => assets}/types/tx.pb.go (80%) create mode 100644 x/operator/types/general.go delete mode 100644 x/restaking_assets_manage/keeper/staker_asset_test.go diff --git a/app/app.go b/app/app.go index e91c77e0f..764fae26c 100644 --- a/app/app.go +++ b/app/app.go @@ -26,6 +26,9 @@ import ( ethante "github.com/evmos/evmos/v14/app/ante/evm" "github.com/evmos/evmos/v14/ethereum/eip712" + "github.com/ExocoreNetwork/exocore/x/assets" + stakingAssetsManageKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + stakingAssetsManageTypes "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/delegation" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationTypes "github.com/ExocoreNetwork/exocore/x/delegation/types" @@ -33,9 +36,6 @@ import ( depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositTypes "github.com/ExocoreNetwork/exocore/x/deposit/types" operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage" - stakingAssetsManageKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" - stakingAssetsManageTypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ExocoreNetwork/exocore/x/reward" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types" @@ -260,7 +260,7 @@ var ( revenue.AppModuleBasic{}, consensus.AppModuleBasic{}, // Exocore modules - restaking_assets_manage.AppModuleBasic{}, + assets.AppModuleBasic{}, deposit.AppModuleBasic{}, operator.AppModuleBasic{}, delegation.AppModuleBasic{}, @@ -797,7 +797,7 @@ func NewExocoreApp( revenue.NewAppModule(app.RevenueKeeper, app.AccountKeeper, app.GetSubspace(revenuetypes.ModuleName)), // exoCore app modules - restaking_assets_manage.NewAppModule(appCodec, app.StakingAssetsManageKeeper), + assets.NewAppModule(appCodec, app.StakingAssetsManageKeeper), deposit.NewAppModule(appCodec, app.DepositKeeper), operator.NewAppModule(appCodec, app.OperatorKeeper), delegation.NewAppModule(appCodec, app.DelegationKeeper), @@ -1269,7 +1269,7 @@ func initParamsKeeper( paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) // ethermint subspaces - paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck return paramsKeeper } diff --git a/precompiles/delegation/delegation.go b/precompiles/delegation/delegation.go index 1bb972cb2..9fde2d1b6 100644 --- a/precompiles/delegation/delegation.go +++ b/precompiles/delegation/delegation.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" + stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" storetypes "github.com/cosmos/cosmos-sdk/store/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" diff --git a/precompiles/delegation/delegation.sol b/precompiles/delegation/delegation.sol index e15a99313..a67cecf55 100644 --- a/precompiles/delegation/delegation.sol +++ b/precompiles/delegation/delegation.sol @@ -14,7 +14,7 @@ IDelegation constant DELEGATION_CONTRACT = IDelegation( /// @custom:address 0x0000000000000000000000000000000000000805 interface IDelegation { /// TRANSACTIONS -/// @dev delegate the client chain assets to the operator through client chain, that will change the states in delegation and restaking_assets_manage module +/// @dev delegate the client chain assets to the operator through client chain, that will change the states in delegation and assets module /// Note that this address cannot be a module account. /// @param clientChainLzID The LzID of client chain /// @param lzNonce The cross chain tx layerZero nonce @@ -32,7 +32,7 @@ interface IDelegation { ) external returns (bool success); /// TRANSACTIONS -/// @dev undelegate the client chain assets from the operator through client chain, that will change the states in delegation and restaking_assets_manage module +/// @dev undelegate the client chain assets from the operator through client chain, that will change the states in delegation and assets module /// Note that this address cannot be a module account. /// @param clientChainLzID The LzID of client chain /// @param lzNonce The cross chain tx layerZero nonce diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 4b8254ef8..f7489f8d0 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -11,11 +11,11 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/delegation" "github.com/ExocoreNetwork/exocore/precompiles/deposit" + "github.com/ExocoreNetwork/exocore/x/assets/types" keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" diff --git a/precompiles/delegation/tx.go b/precompiles/delegation/tx.go index 2c9e8cb21..a254e502a 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -22,7 +22,7 @@ const ( CtxKeyTxHash = "TxHash" ) -// DelegateToThroughClientChain delegate the client chain assets to the operator through client chain, that will change the states in delegation and restaking_assets_manage module +// DelegateToThroughClientChain delegate the client chain assets to the operator through client chain, that will change the states in delegation and assets module func (p Precompile) DelegateToThroughClientChain( ctx sdk.Context, _ common.Address, @@ -52,7 +52,7 @@ func (p Precompile) DelegateToThroughClientChain( return method.Outputs.Pack(true) } -// UndelegateFromThroughClientChain Undelegation the client chain assets from the operator through client chain, that will change the states in delegation and restaking_assets_manage module +// UndelegateFromThroughClientChain Undelegation the client chain assets from the operator through client chain, that will change the states in delegation and assets module func (p Precompile) UndelegateFromThroughClientChain( ctx sdk.Context, _ common.Address, diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index 864aa292e..09e2c0f6d 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -9,8 +9,8 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/precompiles/deposit" + "github.com/ExocoreNetwork/exocore/x/assets/types" keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" ) diff --git a/precompiles/deposit/deposit.go b/precompiles/deposit/deposit.go index e4ef74e08..969a11b6b 100644 --- a/precompiles/deposit/deposit.go +++ b/precompiles/deposit/deposit.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" + stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" storetypes "github.com/cosmos/cosmos-sdk/store/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" "github.com/ethereum/go-ethereum/accounts/abi" diff --git a/precompiles/deposit/deposit.sol b/precompiles/deposit/deposit.sol index 3e6127166..ba540a253 100644 --- a/precompiles/deposit/deposit.sol +++ b/precompiles/deposit/deposit.sol @@ -1,6 +1,6 @@ pragma solidity >=0.8.17; -/// @dev The DEPOSIT contract's.Address. +/// @dev The DEPOSIT contract's address. address constant DEPOSIT_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000804; /// @dev The DEPOSIT contract's instance. @@ -15,9 +15,9 @@ IDeposit constant DEPOSIT_CONTRACT = IDeposit( interface IDeposit { /// TRANSACTIONS /// @dev deposit the client chain assets to the staker, that will change the state in deposit module -/// Note that this.Address cannot be a module account. +/// Note that this address cannot be a module account. /// @param clientChainLzID The LzID of client chain -/// @param assetsAddress The client chain asset Address +/// @param assetsAddress The client chain asset address /// @param stakerAddress The staker address /// @param opAmount The deposit amount function depositTo( diff --git a/precompiles/deposit/deposit_integrate_test.go b/precompiles/deposit/deposit_integrate_test.go index 99ca68f2a..276be10b6 100644 --- a/precompiles/deposit/deposit_integrate_test.go +++ b/precompiles/deposit/deposit_integrate_test.go @@ -7,8 +7,8 @@ import ( "github.com/ExocoreNetwork/exocore/precompiles/deposit" "github.com/ExocoreNetwork/exocore/precompiles/testutil" "github.com/ExocoreNetwork/exocore/precompiles/testutil/contracts" + "github.com/ExocoreNetwork/exocore/x/assets/types" types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ethereum/go-ethereum/common" ) diff --git a/precompiles/deposit/deposit_test.go b/precompiles/deposit/deposit_test.go index afc4f3227..f042397bb 100644 --- a/precompiles/deposit/deposit_test.go +++ b/precompiles/deposit/deposit_test.go @@ -6,8 +6,8 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/deposit" + "github.com/ExocoreNetwork/exocore/x/assets/types" types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" diff --git a/precompiles/deposit/tx.go b/precompiles/deposit/tx.go index 3ab5fe006..5d60ab8fc 100644 --- a/precompiles/deposit/tx.go +++ b/precompiles/deposit/tx.go @@ -3,7 +3,7 @@ package deposit import ( "fmt" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -54,5 +54,5 @@ func (p Precompile) DepositTo( return nil, err } - return method.Outputs.Pack(true, info.TotalDepositAmountOrWantChangeValue.BigInt()) + return method.Outputs.Pack(true, info.TotalDepositAmount.BigInt()) } diff --git a/precompiles/deposit/types.go b/precompiles/deposit/types.go index 140677bfd..e38f7b875 100644 --- a/precompiles/deposit/types.go +++ b/precompiles/deposit/types.go @@ -4,8 +4,8 @@ import ( "math/big" sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" "golang.org/x/xerrors" diff --git a/precompiles/reward/methods.go b/precompiles/reward/methods.go index ba56ed3a2..6e1dac2e9 100644 --- a/precompiles/reward/methods.go +++ b/precompiles/reward/methods.go @@ -3,7 +3,7 @@ package reward import ( "fmt" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -50,5 +50,5 @@ func (p Precompile) Reward( if err != nil { return nil, err } - return method.Outputs.Pack(true, info.TotalDepositAmountOrWantChangeValue.BigInt()) + return method.Outputs.Pack(true, info.TotalDepositAmount.BigInt()) } diff --git a/precompiles/reward/parser.go b/precompiles/reward/parser.go index eb7f194ac..4b7f792fe 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -7,7 +7,7 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/reward/keeper" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" diff --git a/precompiles/reward/reward.go b/precompiles/reward/reward.go index b2e9888db..7684372c7 100644 --- a/precompiles/reward/reward.go +++ b/precompiles/reward/reward.go @@ -5,7 +5,7 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" + stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/precompiles/reward/reward_test.go b/precompiles/reward/reward_test.go index ccc2f0483..0b4a0d678 100644 --- a/precompiles/reward/reward_test.go +++ b/precompiles/reward/reward_test.go @@ -6,9 +6,9 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/reward" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositParams "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" rewardParams "github.com/ExocoreNetwork/exocore/x/reward/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index 792b74c76..d76696199 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -6,7 +6,7 @@ import ( "reflect" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/slash/keeper" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" diff --git a/precompiles/slash/slash.go b/precompiles/slash/slash.go index 5e0135c19..9d857e8b4 100644 --- a/precompiles/slash/slash.go +++ b/precompiles/slash/slash.go @@ -5,7 +5,7 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" + stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" slashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/precompiles/slash/slash_test.go b/precompiles/slash/slash_test.go index 2538a6a70..c26806f4f 100644 --- a/precompiles/slash/slash_test.go +++ b/precompiles/slash/slash_test.go @@ -6,9 +6,9 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/slash" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositParams "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" slashParams "github.com/ExocoreNetwork/exocore/x/slash/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" diff --git a/precompiles/withdraw/methods.go b/precompiles/withdraw/methods.go index 0a59b01d3..dcff36bf7 100644 --- a/precompiles/withdraw/methods.go +++ b/precompiles/withdraw/methods.go @@ -3,7 +3,7 @@ package withdraw import ( "fmt" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -49,5 +49,5 @@ func (p Precompile) Withdraw( if err != nil { return nil, err } - return method.Outputs.Pack(true, info.TotalDepositAmountOrWantChangeValue.BigInt()) + return method.Outputs.Pack(true, info.TotalDepositAmount.BigInt()) } diff --git a/precompiles/withdraw/parser.go b/precompiles/withdraw/parser.go index 79595cef9..d1462083b 100644 --- a/precompiles/withdraw/parser.go +++ b/precompiles/withdraw/parser.go @@ -6,7 +6,7 @@ import ( "reflect" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" diff --git a/precompiles/withdraw/withdraw.go b/precompiles/withdraw/withdraw.go index a85532fd7..6ee973c9e 100644 --- a/precompiles/withdraw/withdraw.go +++ b/precompiles/withdraw/withdraw.go @@ -5,7 +5,7 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" + stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" withdrawKeeper "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/precompiles/withdraw/withdraw_integrate_test.go b/precompiles/withdraw/withdraw_integrate_test.go index 239c9d0f9..e1dbd10a4 100644 --- a/precompiles/withdraw/withdraw_integrate_test.go +++ b/precompiles/withdraw/withdraw_integrate_test.go @@ -7,8 +7,8 @@ import ( "github.com/ExocoreNetwork/exocore/precompiles/testutil" "github.com/ExocoreNetwork/exocore/precompiles/testutil/contracts" "github.com/ExocoreNetwork/exocore/precompiles/withdraw" + "github.com/ExocoreNetwork/exocore/x/assets/types" deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ethereum/go-ethereum/common" ) diff --git a/precompiles/withdraw/withdraw_test.go b/precompiles/withdraw/withdraw_test.go index 38545e324..4bcee8a88 100644 --- a/precompiles/withdraw/withdraw_test.go +++ b/precompiles/withdraw/withdraw_test.go @@ -6,9 +6,9 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/withdraw" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositparams "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" diff --git a/proto/exocore/restaking_assets_manage/v1/genesis.proto b/proto/exocore/assets/v1/genesis.proto similarity index 64% rename from proto/exocore/restaking_assets_manage/v1/genesis.proto rename to proto/exocore/assets/v1/genesis.proto index d5069548e..01a750f66 100644 --- a/proto/exocore/restaking_assets_manage/v1/genesis.proto +++ b/proto/exocore/assets/v1/genesis.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package exocore.restaking_assets_manage.v1; +package exocore.assets.v1; -import "exocore/restaking_assets_manage/v1/tx.proto"; +import "exocore/assets/v1/tx.proto"; -option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; +option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; -// GenesisState defines the restaking_assets_manage module's genesis state. +// GenesisState defines the assets module's genesis state. // TODO: make this state exportable for the case of chain restarts. message GenesisState { // default_supported_client_chains is the list of supported client chains, diff --git a/proto/exocore/restaking_assets_manage/v1/query.proto b/proto/exocore/assets/v1/query.proto similarity index 80% rename from proto/exocore/restaking_assets_manage/v1/query.proto rename to proto/exocore/assets/v1/query.proto index bdde829e1..cb74ef137 100644 --- a/proto/exocore/restaking_assets_manage/v1/query.proto +++ b/proto/exocore/assets/v1/query.proto @@ -1,13 +1,13 @@ syntax = "proto3"; -package exocore.restaking_assets_manage.v1; +package exocore.assets.v1; import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; -import "exocore/restaking_assets_manage/v1/tx.proto"; +import "exocore/assets/v1/tx.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; +option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; // QueryClientChainInfo is the query for getting the client chain info by index. message QueryClientChainInfo { @@ -49,7 +49,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; + map asset_infos = 1; } // QuerySpecifiedAssetAmountReq is the query for getting the staker specified asset amount. @@ -69,7 +69,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; + map asset_infos = 1; } // QueryOperatorSpecifiedAssetAmountReq is the query for getting the operator @@ -97,52 +97,52 @@ message QueryStakerExCoreAddrResponse { ]; } -// Query defines the gRPC query service for the restaking_assets_manage module. +// Query defines the gRPC query service for the assets module. service Query { // ClientChainInfoByIndex queries the client chain info by index. rpc QueClientChainInfoByIndex(QueryClientChainInfo) returns (ClientChainInfo) { option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueClientChainInfoByIndex"; + option (google.api.http).get = "/exocore/assets/v1/QueClientChainInfoByIndex"; } // AllClientChainInfo queries all client chain info. rpc QueAllClientChainInfo(QueryAllClientChainInfo) returns (QueryAllClientChainInfoResponse){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueAllClientChainInfo"; + option (google.api.http).get = "/exocore/assets/v1/QueAllClientChainInfo"; } // StakingAssetInfo queries the staking asset info. rpc QueStakingAssetInfo(QueryStakingAssetInfo)returns(StakingAssetInfo){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakingAssetInfo"; + option (google.api.http).get = "/exocore/assets/v1/QueStakingAssetInfo"; } // AllStakingAssetsInfo queries all staking assets info. rpc QueAllStakingAssetsInfo(QueryAllStakingAssetsInfo)returns(QueryAllStakingAssetsInfoResponse){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueAllStakingAssetsInfo"; + option (google.api.http).get = "/exocore/assets/v1/QueAllStakingAssetsInfo"; } // StakerAssetInfos queries the staker asset info. rpc QueStakerAssetInfos(QueryStakerAssetInfo)returns(QueryAssetInfoResponse){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakerAssetInfos"; + option (google.api.http).get = "/exocore/assets/v1/QueStakerAssetInfos"; } // StakerSpecifiedAssetAmount queries the staker specified asset amount. - rpc QueStakerSpecifiedAssetAmount(QuerySpecifiedAssetAmountReq)returns(StakerSingleAssetOrChangeInfo){ + rpc QueStakerSpecifiedAssetAmount(QuerySpecifiedAssetAmountReq)returns(StakerSingleAssetInfo){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakerSpecifiedAssetAmount"; + option (google.api.http).get = "/exocore/assets/v1/QueStakerSpecifiedAssetAmount"; } // OperatorAssetInfos queries the operator asset info. rpc QueOperatorAssetInfos(QueryOperatorAssetInfos)returns(QueryOperatorAssetInfosResponse){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueOperatorAssetInfos"; + option (google.api.http).get = "/exocore/assets/v1/QueOperatorAssetInfos"; } // OperatorSpecifiedAssetAmount queries the operator specified asset amount. - rpc QueOperatorSpecifiedAssetAmount(QueryOperatorSpecifiedAssetAmountReq) returns(OperatorSingleAssetOrChangeInfo){ + rpc QueOperatorSpecifiedAssetAmount(QueryOperatorSpecifiedAssetAmountReq) returns(OperatorSingleAssetInfo){ option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakerSpecifiedAssetAmount"; + option (google.api.http).get = "/exocore/assets/v1/QueStakerSpecifiedAssetAmount"; } // StakerExCoreAddr queries the staker exocore address. rpc QueStakerExoCoreAddr(QueryStakerExCoreAddr) returns (QueryStakerExCoreAddrResponse) { option (cosmos.query.v1.module_query_safe) = true; - option (google.api.http).get = "/exocore/restaking_assets_manage/v1/QueStakerExoCoreAddr/{staker}"; + option (google.api.http).get = "/exocore/assets/v1/QueStakerExoCoreAddr/{staker}"; } } diff --git a/proto/exocore/restaking_assets_manage/v1/tx.proto b/proto/exocore/assets/v1/tx.proto similarity index 74% rename from proto/exocore/restaking_assets_manage/v1/tx.proto rename to proto/exocore/assets/v1/tx.proto index c32404809..9f0fd3a69 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package exocore.restaking_assets_manage.v1; +package exocore.assets.v1; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"; +option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; // ValueField is a field that holds a value of sdk.Int type. message ValueField { @@ -27,8 +27,8 @@ message ClientChainInfo { string meta_info = 2; // chain_id of the client chain. Not necessarily the EVM chain id. uint64 chain_id = 3; - // exo_core_chain_index is the index of the client chain within the exosystem. - uint64 exo_core_chain_index = 4; + // exocore_chain_index is the index of the client chain within the exosystem. + uint64 exocore_chain_index = 4; // finalization_blocks is the number of blocks to wait for finalization. uint64 finalization_blocks = 5; // layer_zero_chain_id is the chain id of the client chain, according to L0. @@ -50,8 +50,8 @@ message AppChainInfo { string meta_info = 2; // chain_id is used as the primary key string chain_id = 3; - // exo_core_chain_index is the index of the chain in exocore, so far unused - uint64 exo_core_chain_index = 4; + // exocore_chain_index is the index of the chain in exocore, so far unused + uint64 exocore_chain_index = 4; } // AssetInfo defines the information for an asset to be used in staking. @@ -73,8 +73,8 @@ message AssetInfo { ]; // layer_zero_chain_id is the chain id of the asset, according to L0. uint64 layer_zero_chain_id = 6 [(gogoproto.customname) = "LayerZeroChainID"]; - // exo_core_chain_index is the index of the client chain within the exosystem. - uint64 exo_core_chain_index = 7; + // exocore_chain_index is the index of the client chain within the exosystem. + uint64 exocore_chain_index = 7; // meta_info about the asset, like "Tether USD on Ethereum blockchain". string meta_info = 8; } @@ -92,30 +92,26 @@ message StakingAssetInfo { ]; } -// StakerSingleAssetOrChangeInfo defines the information for a single asset or its change. -// The type is an overloaded type and is used in two contexts: -// 1. A staker's deposited, withdrawable, and currently unbonding amount. -// 2. The values by which #1 is to be changed / has been changed. -message StakerSingleAssetOrChangeInfo { - // total_deposit_amount_or_want_change_value is the total amount of the asset deposited - // or the amount by which it can change. - string total_deposit_amount_or_want_change_value = 1 +// StakerSingleAssetInfo defines the information for a single asset. +// The type include three states: +// staker's deposited, withdrawable, and currently unbonding amount. +message StakerSingleAssetInfo { + // total_deposit_amount is the total amount of the asset deposited. + string total_deposit_amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // can_withdraw_amount_or_want_change_value is the amount that can be withdrawn - // or the amount by which it can change. - string can_withdraw_amount_or_want_change_value = 2 + // withdrawable_amount is the amount that can be withdrawn. + string withdrawable_amount = 2 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // wait_unbonding_amount_or_want_change_value is the amount that is waiting for undelegation - // or the amount by which it can change. - string wait_unbonding_amount_or_want_change_value = 3 + // wait_unbonding_amount is the amount that is waiting for undelegation. + string wait_unbonding_amount = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -127,51 +123,46 @@ message StakerSingleAssetOrChangeInfo { // It is indexed by the asset_id. message StakerAllAssetsInfo { // all_assets_state is the state of all assets of the staker. - map all_assets_state = 1; + map all_assets_state = 1; } -// OperatorSingleAssetOrChangeInfo defines the information for a single asset or its change, -// for an operator. It is also overloaded like StakerSingleAssetOrChangeInfo. -message OperatorSingleAssetOrChangeInfo { - // total_amount_or_want_change_value is the total amount of the asset deposited - // or the amount by which it can change. - string total_amount_or_want_change_value = 1 +// OperatorSingleAssetInfo defines the information for a single asset, +// for an operator. It is also overloaded like StakerSingleAssetInfo. +message OperatorSingleAssetInfo { + // total_amount is the total amount of the asset deposited. + string total_amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // operator_own_amount_or_want_change_value is the amount that the operator owns - // or the amount by which it can change. + // operator_own_amount is the amount that the operator owns. //todo: the field is used to mark operator's own assets and is not temporarily used now - string operator_own_amount_or_want_change_value = 2 + string operator_own_amount = 2 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // wait_unbonding_amount_or_want_change_value is the amount that is waiting for unbonding - // or the amount by which it can change. - string wait_unbonding_amount_or_want_change_value = 3 + // wait_unbonding_amount is the amount that is waiting for unbonding. + string wait_unbonding_amount = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // operator_own_wait_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding - // or the amount by which it can change - string operator_own_wait_unbonding_amount = 4 + // operator_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding. + string operator_unbonding_amount = 4 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // operator_can_unbond_after_slash is the amount that is owned by operator itself and can be unbonded after slash - // or the amount by which it can change - string operator_can_unbond_after_slash = 5 + // operator_unbondable_amount_after_slash is the amount that is owned by operator itself and can be unbonded after slash. + string operator_unbondable_amount_after_slash = 5 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -183,7 +174,7 @@ message OperatorSingleAssetOrChangeInfo { // indexed by the asset_id. message OperatorAllAssetsInfo { // all_assets_state is the state of all assets of the operator. - map all_assets_state = 1; + map all_assets_state = 1; } // MsgSetExoCoreAddr defines the MsgSetExoCoreAddr message used to set the @@ -247,7 +238,7 @@ message RegisterAssetReq { // RegisterAssetResponse is the response to the RegisterAssetReq message. message RegisterAssetResponse {} -// Msg defines the restaking_assets_manage Msg service +// Msg defines the assets Msg service service Msg { option (cosmos.msg.v1.service) = true; // SetStakerExoCoreAddr sets the exocore address of the staker diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index 67b285795..4f671a764 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -19,8 +19,8 @@ message DelegationInfoReq { // DelegationAmounts is the delegation amount response for a single delegation. message DelegationAmounts { - // can_be_undelegated_amount is the amount that can be undelegated. - string can_be_undelegated_amount = 1 + // undelegatable_amount is the amount that can be undelegated. + string undelegatable_amount = 1 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -33,8 +33,8 @@ message DelegationAmounts { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - // can_be_undelegated_after_slash is the amount that can be undelegated after slash - string can_be_undelegated_after_slash = 3 + // undelegatable_after_slash is the amount that can be undelegated after slash + string undelegatable_after_slash = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/proto/exocore/deposit/v1/deposit.proto b/proto/exocore/deposit/v1/deposit.proto index df2652407..6aee9dd16 100644 --- a/proto/exocore/deposit/v1/deposit.proto +++ b/proto/exocore/deposit/v1/deposit.proto @@ -7,7 +7,7 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/deposit/types"; -// GenesisState defines the restaking_assets_manage module's genesis state. +// GenesisState defines the deposit module's genesis state. message Params { // exocore_lz_app_address is the address of the exocore lz app. string exocore_lz_app_address = 1 diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index 02003a85b..633f0a2c3 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -24,7 +24,7 @@ message QueryOperatorConsKeyRequest { string chain_id = 2; } -// QueryOperatorConsKeyResponse is the response for QueryOperatorConsKeyForChainID +// QueryOperatorConsKeyResponse is the response for QueryOperatorConsKeyRequest message QueryOperatorConsKeyResponse { // public_key is the consensus public key of the operator tendermint.crypto.PublicKey public_key = 1 [ (gogoproto.nullable) = false ]; diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 3b05cfb00..2a684ed12 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -20,6 +20,8 @@ message DecValueField { } // ClientChainEarningAddrList is the list of client chain earning addresses. +// Because the reward token provide by the AVS might be located at different client chain, the operator need to +// provide the different client chain address to receive the token rewards. message ClientChainEarningAddrList { // earning_info_list is the contents of ClientChainEarningAddrList. repeated ClientChainEarningAddrInfo earning_info_list = 1; @@ -49,14 +51,14 @@ message OperatorInfo { message OptedInfo { // slash_contract is the slash contract address of AVS opted-in by the operator string slash_contract = 1; - // opted_in_height is the height at which the operator opted in + // opted_in_height is the exocore block height at which the operator opted in uint64 opted_in_height = 2; - // opted_out_height is the height at which the operator opted out + // opted_out_height is the exocore block height at which the operator opted out uint64 opted_out_height = 3; } // OptedInAssetState is the state of opted-in asset -message OptedInAssetState{ +message OptedInAssetState { // amount of the opted-in asset string amount = 1 [ @@ -77,14 +79,14 @@ message OptedInAssetState{ message OperatorSlashInfo { // slash_contract is the address of slash contract string slash_contract = 1; - // slash_height is the height at which the slash event is submitted - int64 slash_height = 2; - // occurred_height is the height at which the slash event occurs - int64 occurred_height = 3; - // execute_height is the height at which the slash event is executed - int64 execute_height = 4; - // is_veto is a flag to indicate if this slash is vetoed - bool is_veto = 5; + // submitted_height is the exocore block height at which the slash event is submitted + int64 submitted_height = 2; + // event_height is the exocore block height at which the slash event occurs + int64 event_height = 3; + // processed_height is the exocore block height at which the slash event is processed + int64 processed_height = 4; + // is_vetoed is a flag to indicate if this slash is vetoed + bool is_vetoed = 5; // slash_proportion is the proportion of assets that need to be slashed string slash_proportion = 6 [ diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index e845453c3..041e94cff 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -84,8 +84,7 @@ func PrepareEIP712CosmosTx( if err != nil { return nil, err } - - fee := legacytx.NewStdFee(txArgs.Gas, txArgs.Fees) //nolint:staticcheck + fee := legacytx.NewStdFee(txArgs.Gas, txArgs.Fees) //nolint: staticcheck msgs := txArgs.Msgs data := legacytx.StdSignBytes(ctx.ChainID(), accNumber, nonce, 0, fee, msgs, "", nil) diff --git a/x/restaking_assets_manage/client/cli/query.go b/x/assets/client/cli/query.go similarity index 98% rename from x/restaking_assets_manage/client/cli/query.go rename to x/assets/client/cli/query.go index a3d0e1a0f..98d32fee8 100644 --- a/x/restaking_assets_manage/client/cli/query.go +++ b/x/assets/client/cli/query.go @@ -6,7 +6,7 @@ import ( "strconv" errorsmod "cosmossdk.io/errors" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -17,7 +17,7 @@ import ( func GetQueryCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the restaking_assets_manage module", + Short: "Querying commands for the assets module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/x/restaking_assets_manage/client/cli/tx.go b/x/assets/client/cli/tx.go similarity index 78% rename from x/restaking_assets_manage/client/cli/tx.go rename to x/assets/client/cli/tx.go index 7b55345a0..8c2fd8ea2 100644 --- a/x/restaking_assets_manage/client/cli/tx.go +++ b/x/assets/client/cli/tx.go @@ -5,9 +5,10 @@ import ( "strconv" "strings" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -17,7 +18,7 @@ import ( // NewTxCmd returns a root CLI command handler for deposit commands func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ - Use: restakingtype.ModuleName, + Use: assetstype.ModuleName, Short: "restaking subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, @@ -45,20 +46,20 @@ func RegisterClientChain() *cobra.Command { } sender := cliCtx.GetFromAddress() - msg := &restakingtype.RegisterClientChainReq{ + msg := &assetstype.RegisterClientChainReq{ FromAddress: sender.String(), - Info: &restakingtype.ClientChainInfo{ + Info: &assetstype.ClientChainInfo{ Name: args[0], MetaInfo: args[1], }, } lzChainID, err := strconv.ParseUint(args[2], 10, 64) if err != nil { - return errorsmod.Wrap(restakingtype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[2])) + return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[2])) } addressLength, err := strconv.ParseUint(args[3], 10, 64) if err != nil { - return errorsmod.Wrap(restakingtype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[3])) + return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[3])) } msg.Info.LayerZeroChainID = lzChainID msg.Info.AddressLength = uint32(addressLength) @@ -87,9 +88,9 @@ func RegisterAsset() *cobra.Command { } sender := cliCtx.GetFromAddress() - msg := &restakingtype.RegisterAssetReq{ + msg := &assetstype.RegisterAssetReq{ FromAddress: sender.String(), - Info: &restakingtype.AssetInfo{ + Info: &assetstype.AssetInfo{ Name: args[0], Symbol: args[1], Address: strings.ToLower(args[2]), @@ -98,16 +99,16 @@ func RegisterAsset() *cobra.Command { } totalSupply, ok := sdkmath.NewIntFromString(args[4]) if !ok { - return errorsmod.Wrap(restakingtype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[4])) + return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[4])) } lzChainID, err := strconv.ParseUint(args[5], 10, 64) if err != nil { - return errorsmod.Wrap(restakingtype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[5])) + return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[5])) } decimal, err := strconv.ParseUint(args[6], 10, 64) if err != nil { - return errorsmod.Wrap(restakingtype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[6])) + return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[6])) } msg.Info.TotalSupply = totalSupply diff --git a/x/restaking_assets_manage/genesis.go b/x/assets/genesis.go similarity index 60% rename from x/restaking_assets_manage/genesis.go rename to x/assets/genesis.go index 2f1322ad7..fead080fe 100644 --- a/x/restaking_assets_manage/genesis.go +++ b/x/assets/genesis.go @@ -1,27 +1,28 @@ -package restaking_assets_manage // nolint: revive,stylecheck // Package naming to be fixed later. +package assets import ( "encoding/json" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/keeper" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) // NewGenesisState - Create a new genesis state -func NewGenesisState(chain []*restakingtype.ClientChainInfo, token []*restakingtype.AssetInfo) *restakingtype.GenesisState { - return &restakingtype.GenesisState{ +func NewGenesisState(chain []*assetstype.ClientChainInfo, token []*assetstype.AssetInfo) *assetstype.GenesisState { + return &assetstype.GenesisState{ DefaultSupportedClientChains: chain, DefaultSupportedClientChainTokens: token, } } // DefaultGenesisState - Return a default genesis state -func DefaultGenesisState() *restakingtype.GenesisState { +func DefaultGenesisState() *assetstype.GenesisState { // todo: set eth as client chain and usdt as asset in the genesis state - ethClientChain := &restakingtype.ClientChainInfo{ + ethClientChain := &assetstype.ClientChainInfo{ Name: "ethereum", MetaInfo: "ethereum blockchain", ChainId: 1, @@ -29,7 +30,7 @@ func DefaultGenesisState() *restakingtype.GenesisState { LayerZeroChainID: 101, AddressLength: 20, } - usdtClientChainAsset := &restakingtype.AssetInfo{ + usdtClientChainAsset := &assetstype.AssetInfo{ Name: "Tether USD", Symbol: "USDT", Address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", @@ -39,24 +40,24 @@ func DefaultGenesisState() *restakingtype.GenesisState { } totalSupply, _ := sdk.NewIntFromString("40022689732746729") usdtClientChainAsset.TotalSupply = totalSupply - return NewGenesisState([]*restakingtype.ClientChainInfo{ethClientChain}, []*restakingtype.AssetInfo{usdtClientChainAsset}) + return NewGenesisState([]*assetstype.ClientChainInfo{ethClientChain}, []*assetstype.AssetInfo{usdtClientChainAsset}) } -// GetGenesisStateFromAppState returns x/restaking_assets_manage GenesisState given raw application +// GetGenesisStateFromAppState returns x/assets GenesisState given raw application // genesis state. -func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) restakingtype.GenesisState { - var genesisState restakingtype.GenesisState +func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) assetstype.GenesisState { + var genesisState assetstype.GenesisState - if appState[restakingtype.ModuleName] != nil { - cdc.MustUnmarshalJSON(appState[restakingtype.ModuleName], &genesisState) + if appState[assetstype.ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[assetstype.ModuleName], &genesisState) } return genesisState } -// ValidateGenesis performs basic validation of restaking_assets_manage genesis data returning an +// ValidateGenesis performs basic validation of assets genesis data returning an // error for any failed validation criteria. -func ValidateGenesis(restakingtype.GenesisState) error { +func ValidateGenesis(assetstype.GenesisState) error { // todo: check the validation of client chain and token info return nil } @@ -65,7 +66,7 @@ func ValidateGenesis(restakingtype.GenesisState) error { func InitGenesis( ctx sdk.Context, k keeper.Keeper, - data restakingtype.GenesisState, + data assetstype.GenesisState, ) { // todo: might need to sort the clientChains and tokens before handling. @@ -80,7 +81,7 @@ func InitGenesis( } // save default supported client chain assets for _, asset := range data.DefaultSupportedClientChainTokens { - err = k.SetStakingAssetInfo(c, &restakingtype.StakingAssetInfo{ + err = k.SetStakingAssetInfo(c, &assetstype.StakingAssetInfo{ AssetBasicInfo: asset, StakingTotalAmount: math.NewInt(0), }) @@ -91,20 +92,20 @@ func InitGenesis( } // ExportGenesis export module status -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *restakingtype.GenesisState { - clientChainList := make([]*restakingtype.ClientChainInfo, 0) +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *assetstype.GenesisState { + clientChainList := make([]*assetstype.ClientChainInfo, 0) c := sdk.UnwrapSDKContext(ctx) clientChainInfo, _ := k.GetAllClientChainInfo(c) for _, v := range clientChainInfo { clientChainList = append(clientChainList, v) } - clientChainAssetsList := make([]*restakingtype.AssetInfo, 0) + clientChainAssetsList := make([]*assetstype.AssetInfo, 0) clientChainAssets, _ := k.GetAllStakingAssetsInfo(c) for _, v := range clientChainAssets { clientChainAssetsList = append(clientChainAssetsList, v.AssetBasicInfo) } - return &restakingtype.GenesisState{ + return &assetstype.GenesisState{ DefaultSupportedClientChains: clientChainList, DefaultSupportedClientChainTokens: clientChainAssetsList, } diff --git a/x/restaking_assets_manage/keeper/app_chain.go b/x/assets/keeper/app_chain.go similarity index 62% rename from x/restaking_assets_manage/keeper/app_chain.go rename to x/assets/keeper/app_chain.go index ea26b3e04..ceec86c58 100644 --- a/x/restaking_assets_manage/keeper/app_chain.go +++ b/x/assets/keeper/app_chain.go @@ -1,7 +1,7 @@ package keeper import ( - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -11,16 +11,16 @@ import ( // genesis process. In the future, it should be called by governance. func (k Keeper) SetAppChainInfo( ctx sdk.Context, - info restakingtype.AppChainInfo, + info assetstype.AppChainInfo, ) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixAppChainInfo) bz := k.cdc.MustMarshal(&info) store.Set([]byte(info.ChainId), bz) } // AppChainInfoIsExist returns whether the app chain info for the specified chainId exists func (k Keeper) AppChainInfoIsExist(ctx sdk.Context, chainID string) bool { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixAppChainInfo) return store.Has([]byte(chainID)) } @@ -28,14 +28,14 @@ func (k Keeper) AppChainInfoIsExist(ctx sdk.Context, chainID string) bool { func (k Keeper) GetAppChainInfoByChainID( ctx sdk.Context, chainID string, -) (info restakingtype.AppChainInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixAppChainInfo) +) (info assetstype.AppChainInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixAppChainInfo) ifExist := store.Has([]byte(chainID)) if !ifExist { - return restakingtype.AppChainInfo{}, restakingtype.ErrNoAppChainKey + return assetstype.AppChainInfo{}, assetstype.ErrNoAppChainKey } value := store.Get([]byte(chainID)) - ret := restakingtype.AppChainInfo{} + ret := assetstype.AppChainInfo{} k.cdc.MustUnmarshal(value, &ret) return ret, nil } @@ -43,14 +43,14 @@ func (k Keeper) GetAppChainInfoByChainID( // GetAllAppChainInfo gets all the app chain info, indexed by chainId func (k Keeper) GetAllAppChainInfo( ctx sdk.Context, -) (infos map[string]restakingtype.AppChainInfo) { +) (infos map[string]assetstype.AppChainInfo) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, restakingtype.KeyPrefixAppChainInfo) + iterator := sdk.KVStorePrefixIterator(store, assetstype.KeyPrefixAppChainInfo) defer iterator.Close() - ret := make(map[string]restakingtype.AppChainInfo, 0) + ret := make(map[string]assetstype.AppChainInfo, 0) for ; iterator.Valid(); iterator.Next() { - var chainInfo restakingtype.AppChainInfo + var chainInfo assetstype.AppChainInfo k.cdc.MustUnmarshal(iterator.Value(), &chainInfo) ret[chainInfo.ChainId] = chainInfo } diff --git a/x/restaking_assets_manage/keeper/client_chain.go b/x/assets/keeper/client_chain.go similarity index 59% rename from x/restaking_assets_manage/keeper/client_chain.go rename to x/assets/keeper/client_chain.go index 69ed89012..0a93c72c0 100644 --- a/x/restaking_assets_manage/keeper/client_chain.go +++ b/x/assets/keeper/client_chain.go @@ -1,7 +1,7 @@ package keeper import ( - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" @@ -9,8 +9,8 @@ import ( // SetClientChainInfo todo: Temporarily use LayerZeroChainID as key. // It provides a function to register the client chains supported by exoCore.It's called by genesis configuration now,however it will be called by the governance in the future -func (k Keeper) SetClientChainInfo(ctx sdk.Context, info *restakingtype.ClientChainInfo) (err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixClientChainInfo) +func (k Keeper) SetClientChainInfo(ctx sdk.Context, info *assetstype.ClientChainInfo) (err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixClientChainInfo) bz := k.cdc.MustMarshal(info) @@ -19,33 +19,33 @@ func (k Keeper) SetClientChainInfo(ctx sdk.Context, info *restakingtype.ClientCh } func (k Keeper) IsExistedClientChain(ctx sdk.Context, index uint64) bool { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixClientChainInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixClientChainInfo) return store.Has([]byte(hexutil.EncodeUint64(index))) } // GetClientChainInfoByIndex using LayerZeroChainID as the query index. -func (k Keeper) GetClientChainInfoByIndex(ctx sdk.Context, index uint64) (info *restakingtype.ClientChainInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixClientChainInfo) +func (k Keeper) GetClientChainInfoByIndex(ctx sdk.Context, index uint64) (info *assetstype.ClientChainInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixClientChainInfo) ifExist := store.Has([]byte(hexutil.EncodeUint64(index))) if !ifExist { - return nil, restakingtype.ErrNoClientChainKey + return nil, assetstype.ErrNoClientChainKey } value := store.Get([]byte(hexutil.EncodeUint64(index))) - ret := restakingtype.ClientChainInfo{} + ret := assetstype.ClientChainInfo{} k.cdc.MustUnmarshal(value, &ret) return &ret, nil } -func (k Keeper) GetAllClientChainInfo(ctx sdk.Context) (infos map[uint64]*restakingtype.ClientChainInfo, err error) { +func (k Keeper) GetAllClientChainInfo(ctx sdk.Context) (infos map[uint64]*assetstype.ClientChainInfo, err error) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, restakingtype.KeyPrefixClientChainInfo) + iterator := sdk.KVStorePrefixIterator(store, assetstype.KeyPrefixClientChainInfo) defer iterator.Close() - ret := make(map[uint64]*restakingtype.ClientChainInfo, 0) + ret := make(map[uint64]*assetstype.ClientChainInfo, 0) for ; iterator.Valid(); iterator.Next() { - var chainInfo restakingtype.ClientChainInfo + var chainInfo assetstype.ClientChainInfo k.cdc.MustUnmarshal(iterator.Value(), &chainInfo) ret[chainInfo.LayerZeroChainID] = &chainInfo } diff --git a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go b/x/assets/keeper/client_chain_and_asset_test.go similarity index 76% rename from x/restaking_assets_manage/keeper/client_chain_and_asset_test.go rename to x/assets/keeper/client_chain_and_asset_test.go index 83e1b2e30..ca24c1d86 100644 --- a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go +++ b/x/assets/keeper/client_chain_and_asset_test.go @@ -1,12 +1,12 @@ package keeper_test import ( - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" ) func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { - defaultGensisState := restaking_assets_manage.DefaultGenesisState() + defaultGensisState := assets.DefaultGenesisState() // test the client chains getting clientChains, err := suite.App.StakingAssetsManageKeeper.GetAllClientChainInfo(suite.Ctx) @@ -26,7 +26,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) for _, asset := range defaultGensisState.DefaultSupportedClientChainTokens { - _, assetID := types.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) + _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) suite.Ctx.Logger().Info("the asset id is:", "assetID", assetID) info, ok := assets[assetID] suite.True(ok) @@ -34,7 +34,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { } usdtAsset := defaultGensisState.DefaultSupportedClientChainTokens[0] - _, assetID := types.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainID, "", usdtAsset.Address) + _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainID, "", usdtAsset.Address) assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(usdtAsset, assetInfo.AssetBasicInfo) diff --git a/x/restaking_assets_manage/keeper/client_chain_asset.go b/x/assets/keeper/client_chain_asset.go similarity index 55% rename from x/restaking_assets_manage/keeper/client_chain_asset.go rename to x/assets/keeper/client_chain_asset.go index 9074fad73..5e0c2f617 100644 --- a/x/restaking_assets_manage/keeper/client_chain_asset.go +++ b/x/assets/keeper/client_chain_asset.go @@ -2,7 +2,7 @@ package keeper import ( sdkmath "cosmossdk.io/math" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -13,20 +13,20 @@ func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetID string, c if changeAmount.IsNil() { return nil } - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakingAssetInfo) key := []byte(assetID) ifExist := store.Has(key) if !ifExist { - return restakingtype.ErrNoClientChainAssetKey + return assetstype.ErrNoClientChainAssetKey } value := store.Get(key) - ret := restakingtype.StakingAssetInfo{} + ret := assetstype.StakingAssetInfo{} k.cdc.MustUnmarshal(value, &ret) // calculate and set new amount - err = restakingtype.UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) + err = assetstype.UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) if err != nil { return err } @@ -39,45 +39,45 @@ func (k Keeper) UpdateStakingAssetTotalAmount(ctx sdk.Context, assetID string, c // SetStakingAssetInfo todo: Temporarily use clientChainAssetAddr+'_'+LayerZeroChainID as the key. // It provides a function to register the client chain assets supported by exoCore.It's called by genesis configuration now,however it will be called by the governance in the future -func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *restakingtype.StakingAssetInfo) (err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) +func (k Keeper) SetStakingAssetInfo(ctx sdk.Context, info *assetstype.StakingAssetInfo) (err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakingAssetInfo) // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(info) - _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(info.AssetBasicInfo.LayerZeroChainID, "", info.AssetBasicInfo.Address) + _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(info.AssetBasicInfo.LayerZeroChainID, "", info.AssetBasicInfo.Address) store.Set([]byte(assetID), bz) return nil } func (k Keeper) IsStakingAsset(ctx sdk.Context, assetID string) bool { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakingAssetInfo) return store.Has([]byte(assetID)) } -func (k Keeper) GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *restakingtype.StakingAssetInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakingAssetInfo) +func (k Keeper) GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *assetstype.StakingAssetInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakingAssetInfo) ifExist := store.Has([]byte(assetID)) if !ifExist { - return nil, restakingtype.ErrNoClientChainAssetKey + return nil, assetstype.ErrNoClientChainAssetKey } value := store.Get([]byte(assetID)) - ret := restakingtype.StakingAssetInfo{} + ret := assetstype.StakingAssetInfo{} k.cdc.MustUnmarshal(value, &ret) return &ret, nil } -func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*restakingtype.StakingAssetInfo, err error) { +func (k Keeper) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, restakingtype.KeyPrefixReStakingAssetInfo) + iterator := sdk.KVStorePrefixIterator(store, assetstype.KeyPrefixReStakingAssetInfo) defer iterator.Close() - ret := make(map[string]*restakingtype.StakingAssetInfo, 0) + ret := make(map[string]*assetstype.StakingAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { - var assetInfo restakingtype.StakingAssetInfo + var assetInfo assetstype.StakingAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &assetInfo) - _, assetID := restakingtype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainID, "", assetInfo.AssetBasicInfo.Address) + _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(assetInfo.AssetBasicInfo.LayerZeroChainID, "", assetInfo.AssetBasicInfo.Address) ret[assetID] = &assetInfo } return ret, nil diff --git a/x/restaking_assets_manage/keeper/exocore_addr.go b/x/assets/keeper/exocore_addr.go similarity index 100% rename from x/restaking_assets_manage/keeper/exocore_addr.go rename to x/assets/keeper/exocore_addr.go diff --git a/x/restaking_assets_manage/keeper/grpc_query.go b/x/assets/keeper/grpc_query.go similarity index 62% rename from x/restaking_assets_manage/keeper/grpc_query.go rename to x/assets/keeper/grpc_query.go index c4dde8f0e..3a77991bd 100644 --- a/x/restaking_assets_manage/keeper/grpc_query.go +++ b/x/assets/keeper/grpc_query.go @@ -3,63 +3,64 @@ package keeper import ( "context" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) // QueClientChainInfoByIndex query client chain info by clientChainLzID -func (k Keeper) QueClientChainInfoByIndex(ctx context.Context, info *restakingtype.QueryClientChainInfo) (*restakingtype.ClientChainInfo, error) { +func (k Keeper) QueClientChainInfoByIndex(ctx context.Context, info *assetstype.QueryClientChainInfo) (*assetstype.ClientChainInfo, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetClientChainInfoByIndex(c, info.ChainIndex) } // QueAllClientChainInfo query all client chain info that have been registered in exoCore // the key of returned map is clientChainLzID, the value is the client chain info. -func (k Keeper) QueAllClientChainInfo(ctx context.Context, _ *restakingtype.QueryAllClientChainInfo) (*restakingtype.QueryAllClientChainInfoResponse, error) { +func (k Keeper) QueAllClientChainInfo(ctx context.Context, _ *assetstype.QueryAllClientChainInfo) (*assetstype.QueryAllClientChainInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) allInfo, err := k.GetAllClientChainInfo(c) if err != nil { return nil, err } - return &restakingtype.QueryAllClientChainInfoResponse{AllClientChainInfos: allInfo}, nil + return &assetstype.QueryAllClientChainInfoResponse{AllClientChainInfos: allInfo}, nil } // QueStakingAssetInfo query the specified client chain asset info by inputting assetID -func (k Keeper) QueStakingAssetInfo(ctx context.Context, info *restakingtype.QueryStakingAssetInfo) (*restakingtype.StakingAssetInfo, error) { +func (k Keeper) QueStakingAssetInfo(ctx context.Context, info *assetstype.QueryStakingAssetInfo) (*assetstype.StakingAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetStakingAssetInfo(c, info.AssetID) } // QueAllStakingAssetsInfo query the info about all client chain assets that have been registered -func (k Keeper) QueAllStakingAssetsInfo(ctx context.Context, _ *restakingtype.QueryAllStakingAssetsInfo) (*restakingtype.QueryAllStakingAssetsInfoResponse, error) { +func (k Keeper) QueAllStakingAssetsInfo(ctx context.Context, _ *assetstype.QueryAllStakingAssetsInfo) (*assetstype.QueryAllStakingAssetsInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) allInfo, err := k.GetAllStakingAssetsInfo(c) if err != nil { return nil, err } - return &restakingtype.QueryAllStakingAssetsInfoResponse{AllStakingAssetsInfo: allInfo}, nil + return &assetstype.QueryAllStakingAssetsInfoResponse{AllStakingAssetsInfo: allInfo}, nil } // QueStakerAssetInfos query th state of all assets for a staker specified by stakerID -func (k Keeper) QueStakerAssetInfos(ctx context.Context, info *restakingtype.QueryStakerAssetInfo) (*restakingtype.QueryAssetInfoResponse, error) { +func (k Keeper) QueStakerAssetInfos(ctx context.Context, info *assetstype.QueryStakerAssetInfo) (*assetstype.QueryAssetInfoResponse, error) { c := sdk.UnwrapSDKContext(ctx) assetInfos, err := k.GetStakerAssetInfos(c, info.StakerID) if err != nil { return nil, err } - return &restakingtype.QueryAssetInfoResponse{AssetInfos: assetInfos}, nil + return &assetstype.QueryAssetInfoResponse{AssetInfos: assetInfos}, nil } // QueStakerSpecifiedAssetAmount query the specified asset state of a staker, using stakerID and assetID as query parameters -func (k Keeper) QueStakerSpecifiedAssetAmount(ctx context.Context, req *restakingtype.QuerySpecifiedAssetAmountReq) (*restakingtype.StakerSingleAssetOrChangeInfo, error) { +func (k Keeper) QueStakerSpecifiedAssetAmount(ctx context.Context, req *assetstype.QuerySpecifiedAssetAmountReq) (*assetstype.StakerSingleAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetStakerSpecifiedAssetInfo(c, req.StakerID, req.AssetID) } // QueOperatorAssetInfos query th state of all assets for an operator specified by operator address -func (k Keeper) QueOperatorAssetInfos(ctx context.Context, infos *restakingtype.QueryOperatorAssetInfos) (*restakingtype.QueryOperatorAssetInfosResponse, error) { +func (k Keeper) QueOperatorAssetInfos(ctx context.Context, infos *assetstype.QueryOperatorAssetInfos) (*assetstype.QueryOperatorAssetInfosResponse, error) { c := sdk.UnwrapSDKContext(ctx) addr, err := sdk.AccAddressFromBech32(infos.OperatorAddr) if err != nil { @@ -69,11 +70,11 @@ func (k Keeper) QueOperatorAssetInfos(ctx context.Context, infos *restakingtype. if err != nil { return nil, err } - return &restakingtype.QueryOperatorAssetInfosResponse{AssetInfos: assetInfos}, nil + return &assetstype.QueryOperatorAssetInfosResponse{AssetInfos: assetInfos}, nil } // QueOperatorSpecifiedAssetAmount query the specified asset state of an operator, using operator address and assetID as query parameters -func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *restakingtype.QueryOperatorSpecifiedAssetAmountReq) (*restakingtype.OperatorSingleAssetOrChangeInfo, error) { +func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *assetstype.QueryOperatorSpecifiedAssetAmountReq) (*assetstype.OperatorSingleAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) addr, err := sdk.AccAddressFromBech32(req.OperatorAddr) if err != nil { @@ -83,11 +84,11 @@ func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *restak } // QueStakerExoCoreAddr outdated,will be deprecated -func (k Keeper) QueStakerExoCoreAddr(ctx context.Context, req *restakingtype.QueryStakerExCoreAddr) (*restakingtype.QueryStakerExCoreAddrResponse, error) { +func (k Keeper) QueStakerExoCoreAddr(ctx context.Context, req *assetstype.QueryStakerExCoreAddr) (*assetstype.QueryStakerExCoreAddrResponse, error) { c := sdk.UnwrapSDKContext(ctx) exoCoreAddr, err := k.GetStakerExoCoreAddr(c, req.Staker) if err != nil { return nil, err } - return &restakingtype.QueryStakerExCoreAddrResponse{ExoCoreAddr: exoCoreAddr}, nil + return &assetstype.QueryStakerExCoreAddrResponse{ExoCoreAddr: exoCoreAddr}, nil } diff --git a/x/restaking_assets_manage/keeper/keeper.go b/x/assets/keeper/keeper.go similarity index 62% rename from x/restaking_assets_manage/keeper/keeper.go rename to x/assets/keeper/keeper.go index 4a727500d..73398c4a7 100644 --- a/x/restaking_assets_manage/keeper/keeper.go +++ b/x/assets/keeper/keeper.go @@ -3,7 +3,7 @@ package keeper import ( "context" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -36,26 +36,26 @@ func (k Keeper) SetOperatorAssetOptedInMiddleWare(sdk.Address, map[string]sdk.Ad panic("implement me") } -// IRestakingAssetsManage interface will be implemented by restaking_assets_manage keeper +// IRestakingAssetsManage interface will be implemented by assets keeper type IRestakingAssetsManage interface { - SetClientChainInfo(ctx sdk.Context, info *restakingtype.ClientChainInfo) (err error) - GetClientChainInfoByIndex(ctx sdk.Context, index uint64) (info *restakingtype.ClientChainInfo, err error) - GetAllClientChainInfo(ctx sdk.Context) (infos map[uint64]*restakingtype.ClientChainInfo, err error) + SetClientChainInfo(ctx sdk.Context, info *assetstype.ClientChainInfo) (err error) + GetClientChainInfoByIndex(ctx sdk.Context, index uint64) (info *assetstype.ClientChainInfo, err error) + GetAllClientChainInfo(ctx sdk.Context) (infos map[uint64]*assetstype.ClientChainInfo, err error) - SetStakingAssetInfo(ctx sdk.Context, info *restakingtype.StakingAssetInfo) (err error) - GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *restakingtype.StakingAssetInfo, err error) - GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*restakingtype.StakingAssetInfo, err error) + 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) - GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) - GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) - UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) + GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerSingleAssetInfo, err error) + GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerSingleAssetInfo, err error) + UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount assetstype.StakerSingleAssetChangeInfo) (err error) - GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) (assetsInfo map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) - GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) - UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) + GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) (assetsInfo map[string]*assetstype.OperatorSingleAssetInfo, err error) + GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorSingleAssetInfo, err error) + UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.OperatorSingleAssetChangeInfo) (err error) // SetStakerExoCoreAddr handle the SetStakerExoCoreAddr txs from msg service - SetStakerExoCoreAddr(ctx context.Context, addr *restakingtype.MsgSetExoCoreAddr) (*restakingtype.MsgSetExoCoreAddrResponse, error) + SetStakerExoCoreAddr(ctx context.Context, addr *assetstype.MsgSetExoCoreAddr) (*assetstype.MsgSetExoCoreAddrResponse, error) GetStakerExoCoreAddr(ctx sdk.Context, stakerID string) (string, error) // GetOperatorAssetOptedInMiddleWare :the following three interfaces should be implemented in operator opt-in module diff --git a/x/restaking_assets_manage/keeper/msg_server.go b/x/assets/keeper/msg_server.go similarity index 61% rename from x/restaking_assets_manage/keeper/msg_server.go rename to x/assets/keeper/msg_server.go index 715134df8..cf5ab7822 100644 --- a/x/restaking_assets_manage/keeper/msg_server.go +++ b/x/assets/keeper/msg_server.go @@ -5,24 +5,23 @@ import ( "strings" "cosmossdk.io/math" - - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" ) -var _ restakingtype.MsgServer = &Keeper{} +var _ assetstype.MsgServer = &Keeper{} // SetStakerExoCoreAddr outdated, will be deprecated. // don't check if the staker has existed temporarily,so users can set their ExoCoreAddr multiple times. // It may be modified later to allow setting only once -func (k Keeper) SetStakerExoCoreAddr(ctx context.Context, addrInfo *restakingtype.MsgSetExoCoreAddr) (*restakingtype.MsgSetExoCoreAddrResponse, error) { +func (k Keeper) SetStakerExoCoreAddr(ctx context.Context, addrInfo *assetstype.MsgSetExoCoreAddr) (*assetstype.MsgSetExoCoreAddrResponse, error) { // todo: verify client chain signature according to the client chain signature algorithm type. c := sdk.UnwrapSDKContext(ctx) - store := prefix.NewStore(c.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerExoCoreAddr) + store := prefix.NewStore(c.KVStore(k.storeKey), assetstype.KeyPrefixReStakerExoCoreAddr) bz := k.cdc.MustMarshal(addrInfo) @@ -31,10 +30,10 @@ func (k Keeper) SetStakerExoCoreAddr(ctx context.Context, addrInfo *restakingtyp // todo: save to KeyPrefixReStakerExoCoreAddrReverse - return &restakingtype.MsgSetExoCoreAddrResponse{}, nil + return &assetstype.MsgSetExoCoreAddrResponse{}, nil } -func (k Keeper) RegisterClientChain(ctx context.Context, req *restakingtype.RegisterClientChainReq) (*restakingtype.RegisterClientChainResponse, error) { +func (k Keeper) RegisterClientChain(ctx context.Context, req *assetstype.RegisterClientChainReq) (*assetstype.RegisterClientChainResponse, error) { c := sdk.UnwrapSDKContext(ctx) err := k.SetClientChainInfo(c, req.Info) if err != nil { @@ -43,9 +42,9 @@ func (k Keeper) RegisterClientChain(ctx context.Context, req *restakingtype.Regi return nil, nil } -func (k Keeper) RegisterAsset(ctx context.Context, req *restakingtype.RegisterAssetReq) (*restakingtype.RegisterAssetResponse, error) { +func (k Keeper) RegisterAsset(ctx context.Context, req *assetstype.RegisterAssetReq) (*assetstype.RegisterAssetResponse, error) { c := sdk.UnwrapSDKContext(ctx) - err := k.SetStakingAssetInfo(c, &restakingtype.StakingAssetInfo{ + err := k.SetStakingAssetInfo(c, &assetstype.StakingAssetInfo{ AssetBasicInfo: req.Info, StakingTotalAmount: math.NewInt(0), }) diff --git a/x/restaking_assets_manage/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go similarity index 50% rename from x/restaking_assets_manage/keeper/operator_asset.go rename to x/assets/keeper/operator_asset.go index a48f83c9c..512d9896c 100644 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -3,25 +3,25 @@ package keeper import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) // This file provides all functions about operator assets state management. -func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, _ map[string]interface{}) (assetsInfo map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) +func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, _ map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorSingleAssetInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) // the key is the operator address in the bech32 format key := []byte(operatorAddr.String()) iterator := sdk.KVStorePrefixIterator(store, key) defer iterator.Close() - ret := make(map[string]*restakingtype.OperatorSingleAssetOrChangeInfo, 0) + ret := make(map[string]*assetstype.OperatorSingleAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { - var stateInfo restakingtype.OperatorSingleAssetOrChangeInfo + var stateInfo assetstype.OperatorSingleAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) - keyList, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 2) + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { return nil, err } @@ -31,17 +31,17 @@ func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, return ret, nil } -func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *restakingtype.OperatorSingleAssetOrChangeInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetID) +func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorSingleAssetInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) + key := assetstype.GetJoinedStoreKey(operatorAddr.String(), assetID) ifExist := store.Has(key) if !ifExist { - return nil, restakingtype.ErrNoOperatorAssetKey + return nil, assetstype.ErrNoOperatorAssetKey } value := store.Get(key) - ret := restakingtype.OperatorSingleAssetOrChangeInfo{} + ret := assetstype.OperatorSingleAssetInfo{} k.cdc.MustUnmarshal(value, &ret) return &ret, nil } @@ -50,16 +50,16 @@ func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk. // The input `changeAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is delegation or undelegation related to the operator. In the future,it will also be called when the operator deposit their own assets. -func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) { +func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.OperatorSingleAssetChangeInfo) (err error) { // get the latest state,use the default initial state if the state hasn't been stored - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetJoinedStoreKey(operatorAddr.String(), assetID) - assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnAmountOrWantChangeValue: math.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnWaitUnbondingAmount: math.NewInt(0), - OperatorCanUnbondAfterSlash: math.NewInt(0), + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) + key := assetstype.GetJoinedStoreKey(operatorAddr.String(), assetID) + assetState := assetstype.OperatorSingleAssetInfo{ + TotalAmount: math.NewInt(0), + OperatorOwnAmount: math.NewInt(0), + WaitUnbondingAmount: math.NewInt(0), + OperatorUnbondingAmount: math.NewInt(0), + OperatorUnbondableAmountAfterSlash: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -67,25 +67,25 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre } // update all states of the specified operator asset - err = restakingtype.UpdateAssetValue(&assetState.TotalAmountOrWantChangeValue, &changeAmount.TotalAmountOrWantChangeValue) + err = assetstype.UpdateAssetValue(&assetState.TotalAmount, &changeAmount.ChangeForTotalAmount) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.OperatorOwnAmountOrWantChangeValue, &changeAmount.OperatorOwnAmountOrWantChangeValue) + err = assetstype.UpdateAssetValue(&assetState.OperatorOwnAmount, &changeAmount.ChangeForOperatorOwn) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.WaitUnbondingAmountOrWantChangeValue, &changeAmount.WaitUnbondingAmountOrWantChangeValue) + err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.ChangeForWaitUnbonding) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.OperatorOwnWaitUnbondingAmount, &changeAmount.OperatorOwnWaitUnbondingAmount) + err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondingAmount, &changeAmount.ChangeForOperatorUnbonding) if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorUnbondingAmount error") } - err = restakingtype.UpdateAssetValue(&assetState.OperatorCanUnbondAfterSlash, &changeAmount.OperatorCanUnbondAfterSlash) + err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondableAmountAfterSlash, &changeAmount.ChangeForUnbondableAfterSlash) if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnWaitUnbondingAmount error") + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorUnbondingAmount error") } // store the updated state @@ -94,15 +94,15 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre return nil } -func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *restakingtype.OperatorSingleAssetOrChangeInfo) error) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) +func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *assetstype.OperatorSingleAssetInfo) error) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amounts restakingtype.OperatorSingleAssetOrChangeInfo + var amounts assetstype.OperatorSingleAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := restakingtype.ParseJoinedKey(iterator.Key()) + keys, err := assetstype.ParseJoinedKey(iterator.Key()) if err != nil { return err } diff --git a/x/restaking_assets_manage/keeper/setup_test.go b/x/assets/keeper/setup_test.go similarity index 100% rename from x/restaking_assets_manage/keeper/setup_test.go rename to x/assets/keeper/setup_test.go diff --git a/x/restaking_assets_manage/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go similarity index 51% rename from x/restaking_assets_manage/keeper/staker_asset.go rename to x/assets/keeper/staker_asset.go index b79e2ea2c..61808108c 100644 --- a/x/restaking_assets_manage/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -3,23 +3,24 @@ package keeper import ( "fmt" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*restakingtype.StakerSingleAssetOrChangeInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) +func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerSingleAssetInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) iterator := sdk.KVStorePrefixIterator(store, []byte(stakerID)) defer iterator.Close() - ret := make(map[string]*restakingtype.StakerSingleAssetOrChangeInfo, 0) + ret := make(map[string]*assetstype.StakerSingleAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { - var stateInfo restakingtype.StakerSingleAssetOrChangeInfo + var stateInfo assetstype.StakerSingleAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) - keyList, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 2) + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { return nil, err } @@ -29,17 +30,17 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInf return ret, nil } -func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *restakingtype.StakerSingleAssetOrChangeInfo, err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetJoinedStoreKey(stakerID, assetID) +func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerSingleAssetInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) + key := assetstype.GetJoinedStoreKey(stakerID, assetID) ifExist := store.Has(key) if !ifExist { - return nil, errorsmod.Wrap(restakingtype.ErrNoStakerAssetKey, fmt.Sprintf("the key is:%s", key)) + return nil, errorsmod.Wrap(assetstype.ErrNoStakerAssetKey, fmt.Sprintf("the key is:%s", key)) } value := store.Get(key) - ret := restakingtype.StakerSingleAssetOrChangeInfo{} + ret := assetstype.StakerSingleAssetInfo{} k.cdc.MustUnmarshal(value, &ret) return &ret, nil } @@ -47,14 +48,14 @@ func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, as // UpdateStakerAssetState It's used to update the staker asset state // The input `changeAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is deposit or withdraw related to the specified staker. -func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount restakingtype.StakerSingleAssetOrChangeInfo) (err error) { +func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount assetstype.StakerSingleAssetChangeInfo) (err error) { // get the latest state,use the default initial state if the state hasn't been stored - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetJoinedStoreKey(stakerID, assetID) - assetState := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(0), - CanWithdrawAmountOrWantChangeValue: math.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: math.NewInt(0), + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) + key := assetstype.GetJoinedStoreKey(stakerID, assetID) + assetState := assetstype.StakerSingleAssetInfo{ + TotalDepositAmount: math.NewInt(0), + WithdrawableAmount: math.NewInt(0), + WaitUnbondingAmount: math.NewInt(0), } if store.Has(key) { value := store.Get(key) @@ -62,15 +63,15 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID } // update all states of the specified restaker asset - err = restakingtype.UpdateAssetValue(&assetState.TotalDepositAmountOrWantChangeValue, &changeAmount.TotalDepositAmountOrWantChangeValue) + err = assetstype.UpdateAssetValue(&assetState.TotalDepositAmount, &changeAmount.ChangeForTotalDeposit) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState TotalDepositAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.CanWithdrawAmountOrWantChangeValue, &changeAmount.CanWithdrawAmountOrWantChangeValue) + err = assetstype.UpdateAssetValue(&assetState.WithdrawableAmount, &changeAmount.ChangeForWithdrawable) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") } - err = restakingtype.UpdateAssetValue(&assetState.WaitUnbondingAmountOrWantChangeValue, &changeAmount.WaitUnbondingAmountOrWantChangeValue) + err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.ChangeForWaitUnbonding) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go new file mode 100644 index 000000000..89e8e477b --- /dev/null +++ b/x/assets/keeper/staker_asset_test.go @@ -0,0 +1,112 @@ +package keeper_test + +import ( + "fmt" + + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + + "cosmossdk.io/math" +) + +func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { + stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") + ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") + ethUniInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: math.NewInt(1000), + ChangeForWithdrawable: math.NewInt(1000), + } + + // test the initial storage of statker assets state + err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + + // test that the retrieved value is correct + getInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + suite.Require().NoError(err) + suite.Require().True(ethUniInitialChangeValue.ChangeForTotalDeposit.Equal(getInfo.TotalDepositAmount)) + suite.Require().True(ethUniInitialChangeValue.ChangeForWithdrawable.Equal(getInfo.WithdrawableAmount)) + + // test valid increase of staker asset state + ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(500) + ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(500) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + suite.Require().NoError(err) + suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1500))) + suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1500))) + + // test valid decrease of staker asset state + ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(-500) + ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(-500) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + suite.Require().NoError(err) + suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) + suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) + + // test the decreased amount is bigger than original state + ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(-2000) + ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(-500) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + suite.Require().NoError(err) + suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) + suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) + + ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(-500) + ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(-2000) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + suite.Require().NoError(err) + suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) + suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) + + // test the storage of multiple assets state + ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") + ethUsdtInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: math.NewInt(2000), + ChangeForWithdrawable: math.NewInt(2000), + } + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) + suite.Require().NoError(err) + getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUsdtAssetID) + suite.Require().NoError(err) + suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(2000))) + suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(2000))) +} + +func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { + stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") + ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") + ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") + ethUniInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: math.NewInt(1000), + ChangeForWithdrawable: math.NewInt(1000), + } + ethUsdtInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: math.NewInt(2000), + ChangeForWithdrawable: math.NewInt(2000), + } + err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) + suite.Require().NoError(err) + + // test get all assets state of staker + assetsInfo, err := suite.App.StakingAssetsManageKeeper.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))) +} diff --git a/x/restaking_assets_manage/module.go b/x/assets/module.go similarity index 79% rename from x/restaking_assets_manage/module.go rename to x/assets/module.go index c1c8988c4..c5b7128ab 100644 --- a/x/restaking_assets_manage/module.go +++ b/x/assets/module.go @@ -1,13 +1,14 @@ -package restaking_assets_manage // nolint: revive,stylecheck // Package naming to be fixed later. +package assets import ( "context" "encoding/json" "fmt" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/client/cli" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + + "github.com/ExocoreNetwork/exocore/x/assets/client/cli" + "github.com/ExocoreNetwork/exocore/x/assets/keeper" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -29,11 +30,11 @@ var ( type AppModuleBasic struct{} func (b AppModuleBasic) Name() string { - return restakingtype.ModuleName + return assetstype.ModuleName } func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { - restakingtype.RegisterLegacyAminoCodec(amino) + assetstype.RegisterLegacyAminoCodec(amino) } // DefaultGenesis returns default genesis state as raw bytes for the auth @@ -44,20 +45,20 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { // ValidateGenesis performs genesis state validation for the auth module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { - var data restakingtype.GenesisState + var data assetstype.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", restakingtype.ModuleName, err) + return fmt.Errorf("failed to unmarshal %s genesis state: %w", assetstype.ModuleName, err) } return ValidateGenesis(data) } func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - restakingtype.RegisterInterfaces(registry) + assetstype.RegisterInterfaces(registry) } func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { - if err := restakingtype.RegisterQueryHandlerClient(context.Background(), serveMux, restakingtype.NewQueryClient(c)); err != nil { + if err := assetstype.RegisterQueryHandlerClient(context.Background(), serveMux, assetstype.NewQueryClient(c)); err != nil { panic(err) } } @@ -90,12 +91,12 @@ func (am AppModule) IsAppModule() {} // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - restakingtype.RegisterMsgServer(cfg.MsgServer(), &am.keeper) - restakingtype.RegisterQueryServer(cfg.QueryServer(), am.keeper) + assetstype.RegisterMsgServer(cfg.MsgServer(), &am.keeper) + assetstype.RegisterQueryServer(cfg.QueryServer(), am.keeper) } func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - var genesisState restakingtype.GenesisState + var genesisState assetstype.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) InitGenesis(ctx, am.keeper, genesisState) return []abci.ValidatorUpdate{} diff --git a/x/restaking_assets_manage/types/codec.go b/x/assets/types/codec.go similarity index 94% rename from x/restaking_assets_manage/types/codec.go rename to x/assets/types/codec.go index faf229824..7900dd893 100644 --- a/x/restaking_assets_manage/types/codec.go +++ b/x/assets/types/codec.go @@ -44,7 +44,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -// RegisterLegacyAminoCodec registers the necessary x/restaking_assets_manage interfaces and +// RegisterLegacyAminoCodec registers the necessary x/assets interfaces and // concrete types on the provided LegacyAmino codec. These types are used for // Amino JSON serialization and EIP-712 compatibility. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { diff --git a/x/restaking_assets_manage/types/errors.go b/x/assets/types/errors.go similarity index 100% rename from x/restaking_assets_manage/types/errors.go rename to x/assets/types/errors.go diff --git a/x/restaking_assets_manage/types/expected_keepers.go b/x/assets/types/expected_keepers.go similarity index 100% rename from x/restaking_assets_manage/types/expected_keepers.go rename to x/assets/types/expected_keepers.go diff --git a/x/restaking_assets_manage/types/general.go b/x/assets/types/general.go similarity index 88% rename from x/restaking_assets_manage/types/general.go rename to x/assets/types/general.go index 98fad4821..62c205a75 100644 --- a/x/restaking_assets_manage/types/general.go +++ b/x/assets/types/general.go @@ -26,14 +26,6 @@ const ( ExoCoreOperatorAddrLength = 42 ) -type GeneralAssetsAddr [32]byte - -type GeneralClientChainAddr [32]byte - -type CrossChainOpType uint8 - -type WithdrawerAddress [32]byte - const ( Deposit CrossChainOpType = iota WithdrawPrinciple @@ -43,6 +35,30 @@ const ( Slash ) +type GeneralAssetsAddr [32]byte + +type GeneralClientChainAddr [32]byte + +type CrossChainOpType uint8 + +type WithdrawerAddress [32]byte + +// StakerSingleAssetChangeInfo This is a struct to describe the desired change that matches with the StakerSingleAssetInfo +type StakerSingleAssetChangeInfo struct { + ChangeForTotalDeposit math.Int + ChangeForWithdrawable math.Int + ChangeForWaitUnbonding math.Int +} + +// OperatorSingleAssetChangeInfo This is a struct to describe the desired change that matches with the OperatorSingleAssetInfo +type OperatorSingleAssetChangeInfo struct { + ChangeForTotalAmount math.Int + ChangeForOperatorOwn math.Int + ChangeForWaitUnbonding math.Int + ChangeForOperatorUnbonding math.Int + ChangeForUnbondableAfterSlash math.Int +} + // GetStakeIDAndAssetID stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAddress []byte) (stakeID string, assetID string) { clientChainLzIDStr := hexutil.EncodeUint64(clientChainLzID) diff --git a/x/restaking_assets_manage/types/genesis.pb.go b/x/assets/types/genesis.pb.go similarity index 81% rename from x/restaking_assets_manage/types/genesis.pb.go rename to x/assets/types/genesis.pb.go index 818735621..ca7566cb1 100644 --- a/x/restaking_assets_manage/types/genesis.pb.go +++ b/x/assets/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/restaking_assets_manage/v1/genesis.proto +// source: exocore/assets/v1/genesis.proto package types @@ -22,7 +22,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the restaking_assets_manage module's genesis state. +// GenesisState defines the assets module's genesis state. // TODO: make this state exportable for the case of chain restarts. type GenesisState struct { // default_supported_client_chains is the list of supported client chains, @@ -37,7 +37,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_554af23024865cd5, []int{0} + return fileDescriptor_caf4f124d39d82ce, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -81,33 +81,29 @@ func (m *GenesisState) GetDefaultSupportedClientChainTokens() []*AssetInfo { } func init() { - proto.RegisterType((*GenesisState)(nil), "exocore.restaking_assets_manage.v1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "exocore.assets.v1.GenesisState") } -func init() { - proto.RegisterFile("exocore/restaking_assets_manage/v1/genesis.proto", fileDescriptor_554af23024865cd5) -} +func init() { proto.RegisterFile("exocore/assets/v1/genesis.proto", fileDescriptor_caf4f124d39d82ce) } -var fileDescriptor_554af23024865cd5 = []byte{ - // 275 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0xad, 0xc8, 0x4f, - 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x4f, 0x2c, - 0x2e, 0x4e, 0x2d, 0x29, 0x8e, 0xcf, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, - 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0xea, - 0xd0, 0xc3, 0xa1, 0x43, 0xaf, 0xcc, 0x50, 0x4a, 0x9b, 0x08, 0x53, 0x4b, 0x2a, 0x20, 0x06, 0x2a, - 0x75, 0x33, 0x71, 0xf1, 0xb8, 0x43, 0xac, 0x08, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xaa, 0xe2, 0x92, - 0x4f, 0x49, 0x4d, 0x4b, 0x2c, 0xcd, 0x29, 0x89, 0x2f, 0x2e, 0x2d, 0x28, 0xc8, 0x2f, 0x2a, 0x49, - 0x4d, 0x89, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0x89, 0x4f, 0xce, 0x48, 0xcc, 0xcc, 0x2b, 0x96, - 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x32, 0xd6, 0x23, 0xec, 0x16, 0x3d, 0x67, 0xb0, 0x46, 0x67, - 0x90, 0x3e, 0xcf, 0xbc, 0xb4, 0xfc, 0x20, 0x19, 0xa8, 0xd9, 0xc1, 0x30, 0xa3, 0x91, 0x14, 0x14, - 0x0b, 0xd5, 0x73, 0xa9, 0xe2, 0xb7, 0x3b, 0xbe, 0x24, 0x3f, 0x3b, 0x35, 0xaf, 0x58, 0x82, 0x09, - 0xec, 0x02, 0x5d, 0x62, 0x5c, 0xe0, 0x08, 0x12, 0x00, 0xdb, 0xad, 0x88, 0xc7, 0xee, 0x10, 0xb0, - 0xb9, 0x4e, 0xd1, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, - 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xe5, 0x98, 0x9e, - 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x0a, 0xb1, 0xd5, 0x2f, 0xb5, 0xa4, - 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0x16, 0xdc, 0x15, 0x38, 0x03, 0xbc, 0xa4, 0xb2, 0x20, 0xb5, 0x38, - 0x89, 0x0d, 0x1c, 0xe2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x38, 0x87, 0xab, 0xf6, - 0x01, 0x00, 0x00, +var fileDescriptor_caf4f124d39d82ce = []byte{ + // 256 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, + 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x2a, 0xd0, + 0x83, 0x28, 0xd0, 0x2b, 0x33, 0x94, 0x92, 0xc2, 0xd4, 0x53, 0x52, 0x01, 0x51, 0xae, 0xf4, 0x92, + 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x40, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x50, 0x26, 0x97, 0x7c, 0x4a, + 0x6a, 0x5a, 0x62, 0x69, 0x4e, 0x49, 0x7c, 0x71, 0x69, 0x41, 0x41, 0x7e, 0x51, 0x49, 0x6a, 0x4a, + 0x7c, 0x72, 0x4e, 0x66, 0x6a, 0x5e, 0x49, 0x7c, 0x72, 0x46, 0x62, 0x66, 0x5e, 0xb1, 0x04, 0xa3, + 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x92, 0x1e, 0x86, 0x4d, 0x7a, 0xce, 0x60, 0x75, 0xce, 0x20, 0x65, + 0x9e, 0x79, 0x69, 0xf9, 0x41, 0x32, 0x50, 0xa3, 0x82, 0x61, 0x26, 0x21, 0x29, 0x28, 0x16, 0xca, + 0xe3, 0x52, 0xc5, 0x6f, 0x55, 0x7c, 0x49, 0x7e, 0x76, 0x6a, 0x5e, 0xb1, 0x04, 0x13, 0xd8, 0x42, + 0x19, 0x2c, 0x16, 0x3a, 0x82, 0x58, 0x60, 0xab, 0x14, 0xf1, 0x58, 0x15, 0x02, 0x36, 0xc6, 0xc9, + 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x5d, 0x21, 0x96, 0xf8, 0xa5, 0x96, 0x94, 0xe7, 0x17, + 0x65, 0xeb, 0xc3, 0xc2, 0xae, 0x02, 0x16, 0x7a, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, + 0xe0, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x57, 0xfb, 0x5e, 0x22, 0x90, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/restaking_assets_manage/types/keys.go b/x/assets/types/keys.go similarity index 98% rename from x/restaking_assets_manage/types/keys.go rename to x/assets/types/keys.go index 205c5e8ef..cb9f2e5e9 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/assets/types/keys.go @@ -14,7 +14,7 @@ import ( // constants const ( // ModuleName module name - ModuleName = "restaking_assets_manage" + ModuleName = "assets" // StoreKey to be used when creating the KVStore StoreKey = ModuleName @@ -57,7 +57,7 @@ var ( /* exoCore stored info: - //stored info in restaking_assets_manage module + //stored info in assets module //used to record supported client chain and reStaking token info chainIndex->ChainInfo tokenIndex->tokenInfo diff --git a/x/restaking_assets_manage/types/msg.go b/x/assets/types/msg.go similarity index 100% rename from x/restaking_assets_manage/types/msg.go rename to x/assets/types/msg.go diff --git a/x/restaking_assets_manage/types/query.pb.go b/x/assets/types/query.pb.go similarity index 87% rename from x/restaking_assets_manage/types/query.pb.go rename to x/assets/types/query.pb.go index 48d348813..1020500f2 100644 --- a/x/restaking_assets_manage/types/query.pb.go +++ b/x/assets/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/restaking_assets_manage/v1/query.proto +// source: exocore/assets/v1/query.proto package types @@ -41,7 +41,7 @@ func (m *QueryClientChainInfo) Reset() { *m = QueryClientChainInfo{} } func (m *QueryClientChainInfo) String() string { return proto.CompactTextString(m) } func (*QueryClientChainInfo) ProtoMessage() {} func (*QueryClientChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{0} + return fileDescriptor_1de33a8cf38ccb9d, []int{0} } func (m *QueryClientChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -85,7 +85,7 @@ func (m *QueryAllClientChainInfo) Reset() { *m = QueryAllClientChainInfo func (m *QueryAllClientChainInfo) String() string { return proto.CompactTextString(m) } func (*QueryAllClientChainInfo) ProtoMessage() {} func (*QueryAllClientChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{1} + return fileDescriptor_1de33a8cf38ccb9d, []int{1} } func (m *QueryAllClientChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -124,7 +124,7 @@ func (m *QueryAllClientChainInfoResponse) Reset() { *m = QueryAllClientC func (m *QueryAllClientChainInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllClientChainInfoResponse) ProtoMessage() {} func (*QueryAllClientChainInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{2} + return fileDescriptor_1de33a8cf38ccb9d, []int{2} } func (m *QueryAllClientChainInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -170,7 +170,7 @@ func (m *QueryStakingAssetInfo) Reset() { *m = QueryStakingAssetInfo{} } func (m *QueryStakingAssetInfo) String() string { return proto.CompactTextString(m) } func (*QueryStakingAssetInfo) ProtoMessage() {} func (*QueryStakingAssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{3} + return fileDescriptor_1de33a8cf38ccb9d, []int{3} } func (m *QueryStakingAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -214,7 +214,7 @@ func (m *QueryAllStakingAssetsInfo) Reset() { *m = QueryAllStakingAssets func (m *QueryAllStakingAssetsInfo) String() string { return proto.CompactTextString(m) } func (*QueryAllStakingAssetsInfo) ProtoMessage() {} func (*QueryAllStakingAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{4} + return fileDescriptor_1de33a8cf38ccb9d, []int{4} } func (m *QueryAllStakingAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -254,7 +254,7 @@ func (m *QueryAllStakingAssetsInfoResponse) Reset() { *m = QueryAllStaki func (m *QueryAllStakingAssetsInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllStakingAssetsInfoResponse) ProtoMessage() {} func (*QueryAllStakingAssetsInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{5} + return fileDescriptor_1de33a8cf38ccb9d, []int{5} } func (m *QueryAllStakingAssetsInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -300,7 +300,7 @@ func (m *QueryStakerAssetInfo) Reset() { *m = QueryStakerAssetInfo{} } func (m *QueryStakerAssetInfo) String() string { return proto.CompactTextString(m) } func (*QueryStakerAssetInfo) ProtoMessage() {} func (*QueryStakerAssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{6} + return fileDescriptor_1de33a8cf38ccb9d, []int{6} } func (m *QueryStakerAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -339,14 +339,14 @@ 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]*StakerSingleAssetOrChangeInfo `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 map[string]*StakerSingleAssetInfo `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"` } func (m *QueryAssetInfoResponse) Reset() { *m = QueryAssetInfoResponse{} } func (m *QueryAssetInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryAssetInfoResponse) ProtoMessage() {} func (*QueryAssetInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{7} + return fileDescriptor_1de33a8cf38ccb9d, []int{7} } func (m *QueryAssetInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -375,7 +375,7 @@ func (m *QueryAssetInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAssetInfoResponse proto.InternalMessageInfo -func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerSingleAssetOrChangeInfo { +func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerSingleAssetInfo { if m != nil { return m.AssetInfos } @@ -394,7 +394,7 @@ func (m *QuerySpecifiedAssetAmountReq) Reset() { *m = QuerySpecifiedAsse func (m *QuerySpecifiedAssetAmountReq) String() string { return proto.CompactTextString(m) } func (*QuerySpecifiedAssetAmountReq) ProtoMessage() {} func (*QuerySpecifiedAssetAmountReq) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{8} + return fileDescriptor_1de33a8cf38ccb9d, []int{8} } func (m *QuerySpecifiedAssetAmountReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -447,7 +447,7 @@ func (m *QueryOperatorAssetInfos) Reset() { *m = QueryOperatorAssetInfos func (m *QueryOperatorAssetInfos) String() string { return proto.CompactTextString(m) } func (*QueryOperatorAssetInfos) ProtoMessage() {} func (*QueryOperatorAssetInfos) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{9} + return fileDescriptor_1de33a8cf38ccb9d, []int{9} } func (m *QueryOperatorAssetInfos) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -486,14 +486,14 @@ 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]*OperatorSingleAssetOrChangeInfo `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 map[string]*OperatorSingleAssetInfo `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"` } func (m *QueryOperatorAssetInfosResponse) Reset() { *m = QueryOperatorAssetInfosResponse{} } func (m *QueryOperatorAssetInfosResponse) String() string { return proto.CompactTextString(m) } func (*QueryOperatorAssetInfosResponse) ProtoMessage() {} func (*QueryOperatorAssetInfosResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{10} + return fileDescriptor_1de33a8cf38ccb9d, []int{10} } func (m *QueryOperatorAssetInfosResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -522,7 +522,7 @@ func (m *QueryOperatorAssetInfosResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryOperatorAssetInfosResponse proto.InternalMessageInfo -func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorSingleAssetOrChangeInfo { +func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorSingleAssetInfo { if m != nil { return m.AssetInfos } @@ -542,7 +542,7 @@ func (m *QueryOperatorSpecifiedAssetAmountReq) Reset() { *m = QueryOpera func (m *QueryOperatorSpecifiedAssetAmountReq) String() string { return proto.CompactTextString(m) } func (*QueryOperatorSpecifiedAssetAmountReq) ProtoMessage() {} func (*QueryOperatorSpecifiedAssetAmountReq) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{11} + return fileDescriptor_1de33a8cf38ccb9d, []int{11} } func (m *QueryOperatorSpecifiedAssetAmountReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -596,7 +596,7 @@ func (m *QueryStakerExCoreAddr) Reset() { *m = QueryStakerExCoreAddr{} } func (m *QueryStakerExCoreAddr) String() string { return proto.CompactTextString(m) } func (*QueryStakerExCoreAddr) ProtoMessage() {} func (*QueryStakerExCoreAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{12} + return fileDescriptor_1de33a8cf38ccb9d, []int{12} } func (m *QueryStakerExCoreAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -642,7 +642,7 @@ func (m *QueryStakerExCoreAddrResponse) Reset() { *m = QueryStakerExCore func (m *QueryStakerExCoreAddrResponse) String() string { return proto.CompactTextString(m) } func (*QueryStakerExCoreAddrResponse) ProtoMessage() {} func (*QueryStakerExCoreAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6d13900d4f268106, []int{13} + return fileDescriptor_1de33a8cf38ccb9d, []int{13} } func (m *QueryStakerExCoreAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -679,97 +679,94 @@ func (m *QueryStakerExCoreAddrResponse) GetExoCoreAddr() string { } func init() { - proto.RegisterType((*QueryClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.QueryClientChainInfo") - proto.RegisterType((*QueryAllClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.QueryAllClientChainInfo") - proto.RegisterType((*QueryAllClientChainInfoResponse)(nil), "exocore.restaking_assets_manage.v1.QueryAllClientChainInfoResponse") - proto.RegisterMapType((map[uint64]*ClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.QueryAllClientChainInfoResponse.AllClientChainInfosEntry") - proto.RegisterType((*QueryStakingAssetInfo)(nil), "exocore.restaking_assets_manage.v1.QueryStakingAssetInfo") - proto.RegisterType((*QueryAllStakingAssetsInfo)(nil), "exocore.restaking_assets_manage.v1.QueryAllStakingAssetsInfo") - proto.RegisterType((*QueryAllStakingAssetsInfoResponse)(nil), "exocore.restaking_assets_manage.v1.QueryAllStakingAssetsInfoResponse") - proto.RegisterMapType((map[string]*StakingAssetInfo)(nil), "exocore.restaking_assets_manage.v1.QueryAllStakingAssetsInfoResponse.AllStakingAssetsInfoEntry") - proto.RegisterType((*QueryStakerAssetInfo)(nil), "exocore.restaking_assets_manage.v1.QueryStakerAssetInfo") - proto.RegisterType((*QueryAssetInfoResponse)(nil), "exocore.restaking_assets_manage.v1.QueryAssetInfoResponse") - proto.RegisterMapType((map[string]*StakerSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.QueryAssetInfoResponse.AssetInfosEntry") - proto.RegisterType((*QuerySpecifiedAssetAmountReq)(nil), "exocore.restaking_assets_manage.v1.QuerySpecifiedAssetAmountReq") - proto.RegisterType((*QueryOperatorAssetInfos)(nil), "exocore.restaking_assets_manage.v1.QueryOperatorAssetInfos") - proto.RegisterType((*QueryOperatorAssetInfosResponse)(nil), "exocore.restaking_assets_manage.v1.QueryOperatorAssetInfosResponse") - proto.RegisterMapType((map[string]*OperatorSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.QueryOperatorAssetInfosResponse.AssetInfosEntry") - proto.RegisterType((*QueryOperatorSpecifiedAssetAmountReq)(nil), "exocore.restaking_assets_manage.v1.QueryOperatorSpecifiedAssetAmountReq") - proto.RegisterType((*QueryStakerExCoreAddr)(nil), "exocore.restaking_assets_manage.v1.QueryStakerExCoreAddr") - proto.RegisterType((*QueryStakerExCoreAddrResponse)(nil), "exocore.restaking_assets_manage.v1.QueryStakerExCoreAddrResponse") -} - -func init() { - proto.RegisterFile("exocore/restaking_assets_manage/v1/query.proto", fileDescriptor_6d13900d4f268106) -} - -var fileDescriptor_6d13900d4f268106 = []byte{ - // 1038 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xce, 0xb8, 0xb4, 0x4d, 0xc6, 0x41, 0x54, 0xd3, 0x90, 0x3a, 0xdb, 0x62, 0x87, 0x15, 0x82, - 0x00, 0x62, 0x57, 0x4d, 0x91, 0x9a, 0x34, 0x8a, 0x8a, 0xe3, 0x18, 0xd5, 0x39, 0xb4, 0xaa, 0x73, - 0xe0, 0x53, 0x5a, 0x6d, 0xbd, 0x93, 0xcd, 0xca, 0xce, 0x8e, 0xb3, 0xb3, 0x0e, 0xb6, 0xaa, 0x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xdc, 0x56, 0x97, 0xe0, 0x15, 0x66, 0x58, 0x6c, 0x34, 0x62, - 0xb6, 0xea, 0x8f, 0x19, 0x58, 0x48, 0x91, 0x55, 0x31, 0x6d, 0x12, 0x97, 0x62, 0xf4, 0x35, 0x80, - 0x8b, 0x66, 0xa3, 0x61, 0xd4, 0x98, 0xdc, 0xe8, 0xc5, 0xda, 0x23, 0x34, 0x07, 0x96, 0xcf, 0xad, - 0x64, 0x57, 0x3f, 0xd7, 0xce, 0x6e, 0xab, 0x76, 0x46, 0x14, 0x6d, 0x58, 0x44, 0xcb, 0xae, 0xef, - 0x75, 0xaa, 0x97, 0xcd, 0x61, 0x89, 0xf2, 0x10, 0xe6, 0xd2, 0x0c, 0xd0, 0x25, 0x78, 0xae, 0x8e, - 0x3b, 0xa2, 0x0f, 0xc1, 0x4f, 0x54, 0x81, 0xe7, 0x8f, 0xcc, 0x46, 0x0b, 0xe7, 0x32, 0xcb, 0x60, - 0x25, 0xbb, 0x7a, 0x43, 0x26, 0xdf, 0x78, 0x9e, 0xdc, 0xc3, 0xad, 0xcc, 0x1a, 0x50, 0x6f, 0xc3, - 0x57, 0x59, 0x35, 0xbb, 0xdc, 0xb6, 0x18, 0x98, 0x32, 0x24, 0xde, 0x84, 0xb3, 0xcc, 0x8f, 0xe1, - 0x58, 0x2c, 0xfc, 0xdc, 0x56, 0xb6, 0x7b, 0x5c, 0xb8, 0xc8, 0x15, 0xb6, 0xab, 0x17, 0x99, 0xb0, - 0x62, 0xa9, 0x57, 0xe1, 0x52, 0xaf, 0x1d, 0x51, 0x1f, 0x94, 0x41, 0xf2, 0x73, 0x06, 0xbe, 0x9e, - 0x2a, 0xed, 0x83, 0xf2, 0x2d, 0x80, 0x57, 0x02, 0x50, 0x62, 0xf9, 0x07, 0xb0, 0x08, 0x54, 0x8c, - 0x51, 0x50, 0x49, 0x0d, 0xa4, 0x25, 0x09, 0x39, 0x30, 0x0b, 0x66, 0x82, 0x48, 0x79, 0x04, 0x97, - 0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 0xc1, 0x57, 0x27, 0xf9, 0x99, 0x67, 0x27, 0xf9, 0x99, 0xbf, 0x4e, 0xf2, 0x33, 0x9f, 0x16, 0x6d, - 0xc7, 0xdf, 0x6f, 0x3d, 0xd0, 0x6a, 0xe4, 0x40, 0x2f, 0xf3, 0x30, 0x77, 0xb1, 0xff, 0x05, 0xf1, - 0xea, 0xfd, 0xa8, 0xed, 0xd4, 0xb8, 0x7e, 0xa7, 0x89, 0xe9, 0x83, 0x0b, 0xec, 0xbf, 0x80, 0x1b, - 0x2f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x87, 0x86, 0xe8, 0xfa, 0x10, 0x00, 0x00, + proto.RegisterType((*QueryClientChainInfo)(nil), "exocore.assets.v1.QueryClientChainInfo") + proto.RegisterType((*QueryAllClientChainInfo)(nil), "exocore.assets.v1.QueryAllClientChainInfo") + proto.RegisterType((*QueryAllClientChainInfoResponse)(nil), "exocore.assets.v1.QueryAllClientChainInfoResponse") + proto.RegisterMapType((map[uint64]*ClientChainInfo)(nil), "exocore.assets.v1.QueryAllClientChainInfoResponse.AllClientChainInfosEntry") + 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]*StakerSingleAssetInfo)(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]*OperatorSingleAssetInfo)(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") +} + +func init() { proto.RegisterFile("exocore/assets/v1/query.proto", fileDescriptor_1de33a8cf38ccb9d) } + +var fileDescriptor_1de33a8cf38ccb9d = []byte{ + // 1010 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x97, 0xc1, 0x6f, 0xdc, 0x44, + 0x14, 0xc6, 0x33, 0x5b, 0xda, 0x26, 0xb3, 0x41, 0xc0, 0x34, 0xa4, 0x1b, 0xb7, 0xdd, 0x0d, 0x06, + 0x35, 0xdb, 0x55, 0xb0, 0xd3, 0x2d, 0x28, 0x0d, 0x52, 0x81, 0x4d, 0x9a, 0x43, 0x8a, 0x54, 0xd4, + 0xcd, 0x05, 0xf5, 0xb2, 0x72, 0xd7, 0x13, 0xd7, 0xc4, 0xf1, 0x6c, 0x3c, 0xde, 0xb0, 0x2b, 0x84, + 0x84, 0x90, 0x90, 0xb8, 0x20, 0x55, 0xe2, 0xd4, 0x0b, 0x17, 0xee, 0x08, 0x24, 0x84, 0xc4, 0x81, + 0x23, 0x12, 0xc7, 0x0a, 0x2e, 0x5c, 0x88, 0xd0, 0x06, 0x89, 0x33,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, 0xff, 0xff, 0x3a, 0x12, 0x72, 0x31, 0x41, 0x0e, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -795,11 +792,11 @@ type QueryClient interface { // StakerAssetInfos queries the staker asset info. QueStakerAssetInfos(ctx context.Context, in *QueryStakerAssetInfo, opts ...grpc.CallOption) (*QueryAssetInfoResponse, error) // StakerSpecifiedAssetAmount queries the staker specified asset amount. - QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerSingleAssetOrChangeInfo, error) + QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerSingleAssetInfo, error) // OperatorAssetInfos queries the operator asset info. QueOperatorAssetInfos(ctx context.Context, in *QueryOperatorAssetInfos, opts ...grpc.CallOption) (*QueryOperatorAssetInfosResponse, error) // OperatorSpecifiedAssetAmount queries the operator specified asset amount. - QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorSingleAssetOrChangeInfo, error) + QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorSingleAssetInfo, error) // StakerExCoreAddr queries the staker exocore address. QueStakerExoCoreAddr(ctx context.Context, in *QueryStakerExCoreAddr, opts ...grpc.CallOption) (*QueryStakerExCoreAddrResponse, error) } @@ -814,7 +811,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) QueClientChainInfoByIndex(ctx context.Context, in *QueryClientChainInfo, opts ...grpc.CallOption) (*ClientChainInfo, error) { out := new(ClientChainInfo) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueClientChainInfoByIndex", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueClientChainInfoByIndex", in, out, opts...) if err != nil { return nil, err } @@ -823,7 +820,7 @@ func (c *queryClient) QueClientChainInfoByIndex(ctx context.Context, in *QueryCl func (c *queryClient) QueAllClientChainInfo(ctx context.Context, in *QueryAllClientChainInfo, opts ...grpc.CallOption) (*QueryAllClientChainInfoResponse, error) { out := new(QueryAllClientChainInfoResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueAllClientChainInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueAllClientChainInfo", in, out, opts...) if err != nil { return nil, err } @@ -832,7 +829,7 @@ func (c *queryClient) QueAllClientChainInfo(ctx context.Context, in *QueryAllCli func (c *queryClient) QueStakingAssetInfo(ctx context.Context, in *QueryStakingAssetInfo, opts ...grpc.CallOption) (*StakingAssetInfo, error) { out := new(StakingAssetInfo) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueStakingAssetInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueStakingAssetInfo", in, out, opts...) if err != nil { return nil, err } @@ -841,7 +838,7 @@ func (c *queryClient) QueStakingAssetInfo(ctx context.Context, in *QueryStakingA func (c *queryClient) QueAllStakingAssetsInfo(ctx context.Context, in *QueryAllStakingAssetsInfo, opts ...grpc.CallOption) (*QueryAllStakingAssetsInfoResponse, error) { out := new(QueryAllStakingAssetsInfoResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueAllStakingAssetsInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueAllStakingAssetsInfo", in, out, opts...) if err != nil { return nil, err } @@ -850,16 +847,16 @@ func (c *queryClient) QueAllStakingAssetsInfo(ctx context.Context, in *QueryAllS func (c *queryClient) QueStakerAssetInfos(ctx context.Context, in *QueryStakerAssetInfo, opts ...grpc.CallOption) (*QueryAssetInfoResponse, error) { out := new(QueryAssetInfoResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueStakerAssetInfos", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueStakerAssetInfos", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerSingleAssetOrChangeInfo, error) { - out := new(StakerSingleAssetOrChangeInfo) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueStakerSpecifiedAssetAmount", in, out, opts...) +func (c *queryClient) QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerSingleAssetInfo, error) { + out := new(StakerSingleAssetInfo) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueStakerSpecifiedAssetAmount", in, out, opts...) if err != nil { return nil, err } @@ -868,16 +865,16 @@ func (c *queryClient) QueStakerSpecifiedAssetAmount(ctx context.Context, in *Que func (c *queryClient) QueOperatorAssetInfos(ctx context.Context, in *QueryOperatorAssetInfos, opts ...grpc.CallOption) (*QueryOperatorAssetInfosResponse, error) { out := new(QueryOperatorAssetInfosResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueOperatorAssetInfos", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueOperatorAssetInfos", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorSingleAssetOrChangeInfo, error) { - out := new(OperatorSingleAssetOrChangeInfo) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueOperatorSpecifiedAssetAmount", in, out, opts...) +func (c *queryClient) QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorSingleAssetInfo, error) { + out := new(OperatorSingleAssetInfo) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueOperatorSpecifiedAssetAmount", in, out, opts...) if err != nil { return nil, err } @@ -886,7 +883,7 @@ func (c *queryClient) QueOperatorSpecifiedAssetAmount(ctx context.Context, in *Q func (c *queryClient) QueStakerExoCoreAddr(ctx context.Context, in *QueryStakerExCoreAddr, opts ...grpc.CallOption) (*QueryStakerExCoreAddrResponse, error) { out := new(QueryStakerExCoreAddrResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Query/QueStakerExoCoreAddr", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueStakerExoCoreAddr", in, out, opts...) if err != nil { return nil, err } @@ -906,11 +903,11 @@ type QueryServer interface { // StakerAssetInfos queries the staker asset info. QueStakerAssetInfos(context.Context, *QueryStakerAssetInfo) (*QueryAssetInfoResponse, error) // StakerSpecifiedAssetAmount queries the staker specified asset amount. - QueStakerSpecifiedAssetAmount(context.Context, *QuerySpecifiedAssetAmountReq) (*StakerSingleAssetOrChangeInfo, error) + QueStakerSpecifiedAssetAmount(context.Context, *QuerySpecifiedAssetAmountReq) (*StakerSingleAssetInfo, error) // OperatorAssetInfos queries the operator asset info. QueOperatorAssetInfos(context.Context, *QueryOperatorAssetInfos) (*QueryOperatorAssetInfosResponse, error) // OperatorSpecifiedAssetAmount queries the operator specified asset amount. - QueOperatorSpecifiedAssetAmount(context.Context, *QueryOperatorSpecifiedAssetAmountReq) (*OperatorSingleAssetOrChangeInfo, error) + QueOperatorSpecifiedAssetAmount(context.Context, *QueryOperatorSpecifiedAssetAmountReq) (*OperatorSingleAssetInfo, error) // StakerExCoreAddr queries the staker exocore address. QueStakerExoCoreAddr(context.Context, *QueryStakerExCoreAddr) (*QueryStakerExCoreAddrResponse, error) } @@ -934,13 +931,13 @@ func (*UnimplementedQueryServer) QueAllStakingAssetsInfo(ctx context.Context, re func (*UnimplementedQueryServer) QueStakerAssetInfos(ctx context.Context, req *QueryStakerAssetInfo) (*QueryAssetInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueStakerAssetInfos not implemented") } -func (*UnimplementedQueryServer) QueStakerSpecifiedAssetAmount(ctx context.Context, req *QuerySpecifiedAssetAmountReq) (*StakerSingleAssetOrChangeInfo, error) { +func (*UnimplementedQueryServer) QueStakerSpecifiedAssetAmount(ctx context.Context, req *QuerySpecifiedAssetAmountReq) (*StakerSingleAssetInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method QueStakerSpecifiedAssetAmount not implemented") } func (*UnimplementedQueryServer) QueOperatorAssetInfos(ctx context.Context, req *QueryOperatorAssetInfos) (*QueryOperatorAssetInfosResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueOperatorAssetInfos not implemented") } -func (*UnimplementedQueryServer) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *QueryOperatorSpecifiedAssetAmountReq) (*OperatorSingleAssetOrChangeInfo, error) { +func (*UnimplementedQueryServer) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *QueryOperatorSpecifiedAssetAmountReq) (*OperatorSingleAssetInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method QueOperatorSpecifiedAssetAmount not implemented") } func (*UnimplementedQueryServer) QueStakerExoCoreAddr(ctx context.Context, req *QueryStakerExCoreAddr) (*QueryStakerExCoreAddrResponse, error) { @@ -961,7 +958,7 @@ func _Query_QueClientChainInfoByIndex_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueClientChainInfoByIndex", + FullMethod: "/exocore.assets.v1.Query/QueClientChainInfoByIndex", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueClientChainInfoByIndex(ctx, req.(*QueryClientChainInfo)) @@ -979,7 +976,7 @@ func _Query_QueAllClientChainInfo_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueAllClientChainInfo", + FullMethod: "/exocore.assets.v1.Query/QueAllClientChainInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueAllClientChainInfo(ctx, req.(*QueryAllClientChainInfo)) @@ -997,7 +994,7 @@ func _Query_QueStakingAssetInfo_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueStakingAssetInfo", + FullMethod: "/exocore.assets.v1.Query/QueStakingAssetInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueStakingAssetInfo(ctx, req.(*QueryStakingAssetInfo)) @@ -1015,7 +1012,7 @@ func _Query_QueAllStakingAssetsInfo_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueAllStakingAssetsInfo", + FullMethod: "/exocore.assets.v1.Query/QueAllStakingAssetsInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueAllStakingAssetsInfo(ctx, req.(*QueryAllStakingAssetsInfo)) @@ -1033,7 +1030,7 @@ func _Query_QueStakerAssetInfos_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueStakerAssetInfos", + FullMethod: "/exocore.assets.v1.Query/QueStakerAssetInfos", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueStakerAssetInfos(ctx, req.(*QueryStakerAssetInfo)) @@ -1051,7 +1048,7 @@ func _Query_QueStakerSpecifiedAssetAmount_Handler(srv interface{}, ctx context.C } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueStakerSpecifiedAssetAmount", + FullMethod: "/exocore.assets.v1.Query/QueStakerSpecifiedAssetAmount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueStakerSpecifiedAssetAmount(ctx, req.(*QuerySpecifiedAssetAmountReq)) @@ -1069,7 +1066,7 @@ func _Query_QueOperatorAssetInfos_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueOperatorAssetInfos", + FullMethod: "/exocore.assets.v1.Query/QueOperatorAssetInfos", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueOperatorAssetInfos(ctx, req.(*QueryOperatorAssetInfos)) @@ -1087,7 +1084,7 @@ func _Query_QueOperatorSpecifiedAssetAmount_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueOperatorSpecifiedAssetAmount", + FullMethod: "/exocore.assets.v1.Query/QueOperatorSpecifiedAssetAmount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueOperatorSpecifiedAssetAmount(ctx, req.(*QueryOperatorSpecifiedAssetAmountReq)) @@ -1105,7 +1102,7 @@ func _Query_QueStakerExoCoreAddr_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Query/QueStakerExoCoreAddr", + FullMethod: "/exocore.assets.v1.Query/QueStakerExoCoreAddr", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueStakerExoCoreAddr(ctx, req.(*QueryStakerExCoreAddr)) @@ -1114,7 +1111,7 @@ func _Query_QueStakerExoCoreAddr_Handler(srv interface{}, ctx context.Context, d } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "exocore.restaking_assets_manage.v1.Query", + ServiceName: "exocore.assets.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -1155,7 +1152,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "exocore/restaking_assets_manage/v1/query.proto", + Metadata: "exocore/assets/v1/query.proto", } func (m *QueryClientChainInfo) Marshal() (dAtA []byte, err error) { @@ -2620,10 +2617,10 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*StakerSingleAssetOrChangeInfo) + m.AssetInfos = make(map[string]*StakerSingleAssetInfo) } var mapkey string - var mapvalue *StakerSingleAssetOrChangeInfo + var mapvalue *StakerSingleAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -2697,7 +2694,7 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &StakerSingleAssetOrChangeInfo{} + mapvalue = &StakerSingleAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -2995,10 +2992,10 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*OperatorSingleAssetOrChangeInfo) + m.AssetInfos = make(map[string]*OperatorSingleAssetInfo) } var mapkey string - var mapvalue *OperatorSingleAssetOrChangeInfo + var mapvalue *OperatorSingleAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3072,7 +3069,7 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &OperatorSingleAssetOrChangeInfo{} + mapvalue = &OperatorSingleAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } diff --git a/x/restaking_assets_manage/types/query.pb.gw.go b/x/assets/types/query.pb.gw.go similarity index 96% rename from x/restaking_assets_manage/types/query.pb.gw.go rename to x/assets/types/query.pb.gw.go index 8d90490fe..57629d753 100644 --- a/x/restaking_assets_manage/types/query.pb.gw.go +++ b/x/assets/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: exocore/restaking_assets_manage/v1/query.proto +// source: exocore/assets/v1/query.proto /* Package types is a reverse proxy. @@ -777,23 +777,23 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_QueClientChainInfoByIndex_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueClientChainInfoByIndex"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueClientChainInfoByIndex_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueClientChainInfoByIndex"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueAllClientChainInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueAllClientChainInfo"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueAllClientChainInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueAllClientChainInfo"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueStakingAssetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakingAssetInfo"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueStakingAssetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueStakingAssetInfo"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueAllStakingAssetsInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueAllStakingAssetsInfo"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueAllStakingAssetsInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueAllStakingAssetsInfo"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueStakerAssetInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerAssetInfos"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueStakerAssetInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueStakerAssetInfos"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueStakerSpecifiedAssetAmount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerSpecifiedAssetAmount"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueStakerSpecifiedAssetAmount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueStakerSpecifiedAssetAmount"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueOperatorAssetInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueOperatorAssetInfos"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueOperatorAssetInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueOperatorAssetInfos"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueOperatorSpecifiedAssetAmount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerSpecifiedAssetAmount"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueOperatorSpecifiedAssetAmount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueStakerSpecifiedAssetAmount"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueStakerExoCoreAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"exocore", "restaking_assets_manage", "v1", "QueStakerExoCoreAddr", "staker"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueStakerExoCoreAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"exocore", "assets", "v1", "QueStakerExoCoreAddr", "staker"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/assets/types/tx.pb.go similarity index 80% rename from x/restaking_assets_manage/types/tx.pb.go rename to x/assets/types/tx.pb.go index ce9c34898..a4704e735 100644 --- a/x/restaking_assets_manage/types/tx.pb.go +++ b/x/assets/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: exocore/restaking_assets_manage/v1/tx.proto +// source: exocore/assets/v1/tx.proto package types @@ -42,7 +42,7 @@ func (m *ValueField) Reset() { *m = ValueField{} } func (m *ValueField) String() string { return proto.CompactTextString(m) } func (*ValueField) ProtoMessage() {} func (*ValueField) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{0} + return fileDescriptor_adb6ebd423a2c426, []int{0} } func (m *ValueField) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,8 +79,8 @@ type ClientChainInfo struct { MetaInfo string `protobuf:"bytes,2,opt,name=meta_info,json=metaInfo,proto3" json:"meta_info,omitempty"` // chain_id of the client chain. Not necessarily the EVM chain id. ChainId uint64 `protobuf:"varint,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // exo_core_chain_index is the index of the client chain within the exosystem. - ExoCoreChainIndex uint64 `protobuf:"varint,4,opt,name=exo_core_chain_index,json=exoCoreChainIndex,proto3" json:"exo_core_chain_index,omitempty"` + // exocore_chain_index is the index of the client chain within the exosystem. + ExocoreChainIndex uint64 `protobuf:"varint,4,opt,name=exocore_chain_index,json=exocoreChainIndex,proto3" json:"exocore_chain_index,omitempty"` // finalization_blocks is the number of blocks to wait for finalization. FinalizationBlocks uint64 `protobuf:"varint,5,opt,name=finalization_blocks,json=finalizationBlocks,proto3" json:"finalization_blocks,omitempty"` // layer_zero_chain_id is the chain id of the client chain, according to L0. @@ -96,7 +96,7 @@ func (m *ClientChainInfo) Reset() { *m = ClientChainInfo{} } func (m *ClientChainInfo) String() string { return proto.CompactTextString(m) } func (*ClientChainInfo) ProtoMessage() {} func (*ClientChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{1} + return fileDescriptor_adb6ebd423a2c426, []int{1} } func (m *ClientChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -146,9 +146,9 @@ func (m *ClientChainInfo) GetChainId() uint64 { return 0 } -func (m *ClientChainInfo) GetExoCoreChainIndex() uint64 { +func (m *ClientChainInfo) GetExocoreChainIndex() uint64 { if m != nil { - return m.ExoCoreChainIndex + return m.ExocoreChainIndex } return 0 } @@ -191,15 +191,15 @@ type AppChainInfo struct { MetaInfo string `protobuf:"bytes,2,opt,name=meta_info,json=metaInfo,proto3" json:"meta_info,omitempty"` // chain_id is used as the primary key ChainId string `protobuf:"bytes,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // exo_core_chain_index is the index of the chain in exocore, so far unused - ExoCoreChainIndex uint64 `protobuf:"varint,4,opt,name=exo_core_chain_index,json=exoCoreChainIndex,proto3" json:"exo_core_chain_index,omitempty"` + // exocore_chain_index is the index of the chain in exocore, so far unused + ExocoreChainIndex uint64 `protobuf:"varint,4,opt,name=exocore_chain_index,json=exocoreChainIndex,proto3" json:"exocore_chain_index,omitempty"` } func (m *AppChainInfo) Reset() { *m = AppChainInfo{} } func (m *AppChainInfo) String() string { return proto.CompactTextString(m) } func (*AppChainInfo) ProtoMessage() {} func (*AppChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{2} + return fileDescriptor_adb6ebd423a2c426, []int{2} } func (m *AppChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -249,9 +249,9 @@ func (m *AppChainInfo) GetChainId() string { return "" } -func (m *AppChainInfo) GetExoCoreChainIndex() uint64 { +func (m *AppChainInfo) GetExocoreChainIndex() uint64 { if m != nil { - return m.ExoCoreChainIndex + return m.ExocoreChainIndex } return 0 } @@ -270,8 +270,8 @@ type AssetInfo struct { TotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=total_supply,json=totalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_supply"` // layer_zero_chain_id is the chain id of the asset, according to L0. LayerZeroChainID uint64 `protobuf:"varint,6,opt,name=layer_zero_chain_id,json=layerZeroChainId,proto3" json:"layer_zero_chain_id,omitempty"` - // exo_core_chain_index is the index of the client chain within the exosystem. - ExoCoreChainIndex uint64 `protobuf:"varint,7,opt,name=exo_core_chain_index,json=exoCoreChainIndex,proto3" json:"exo_core_chain_index,omitempty"` + // exocore_chain_index is the index of the client chain within the exosystem. + ExocoreChainIndex uint64 `protobuf:"varint,7,opt,name=exocore_chain_index,json=exocoreChainIndex,proto3" json:"exocore_chain_index,omitempty"` // meta_info about the asset, like "Tether USD on Ethereum blockchain". MetaInfo string `protobuf:"bytes,8,opt,name=meta_info,json=metaInfo,proto3" json:"meta_info,omitempty"` } @@ -280,7 +280,7 @@ func (m *AssetInfo) Reset() { *m = AssetInfo{} } func (m *AssetInfo) String() string { return proto.CompactTextString(m) } func (*AssetInfo) ProtoMessage() {} func (*AssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{3} + return fileDescriptor_adb6ebd423a2c426, []int{3} } func (m *AssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -344,9 +344,9 @@ func (m *AssetInfo) GetLayerZeroChainID() uint64 { return 0 } -func (m *AssetInfo) GetExoCoreChainIndex() uint64 { +func (m *AssetInfo) GetExocoreChainIndex() uint64 { if m != nil { - return m.ExoCoreChainIndex + return m.ExocoreChainIndex } return 0 } @@ -370,7 +370,7 @@ func (m *StakingAssetInfo) Reset() { *m = StakingAssetInfo{} } func (m *StakingAssetInfo) String() string { return proto.CompactTextString(m) } func (*StakingAssetInfo) ProtoMessage() {} func (*StakingAssetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{4} + return fileDescriptor_adb6ebd423a2c426, []int{4} } func (m *StakingAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -406,34 +406,30 @@ func (m *StakingAssetInfo) GetAssetBasicInfo() *AssetInfo { return nil } -// StakerSingleAssetOrChangeInfo defines the information for a single asset or its change. -// The type is an overloaded type and is used in two contexts: -// 1. A staker's deposited, withdrawable, and currently unbonding amount. -// 2. The values by which #1 is to be changed / has been changed. -type StakerSingleAssetOrChangeInfo struct { - // total_deposit_amount_or_want_change_value is the total amount of the asset deposited - // or the amount by which it can change. - TotalDepositAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_deposit_amount_or_want_change_value,json=totalDepositAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_deposit_amount_or_want_change_value"` - // can_withdraw_amount_or_want_change_value is the amount that can be withdrawn - // or the amount by which it can change. - CanWithdrawAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=can_withdraw_amount_or_want_change_value,json=canWithdrawAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_withdraw_amount_or_want_change_value"` - // wait_unbonding_amount_or_want_change_value is the amount that is waiting for undelegation - // or the amount by which it can change. - WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount_or_want_change_value,json=waitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount_or_want_change_value"` -} - -func (m *StakerSingleAssetOrChangeInfo) Reset() { *m = StakerSingleAssetOrChangeInfo{} } -func (m *StakerSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } -func (*StakerSingleAssetOrChangeInfo) ProtoMessage() {} -func (*StakerSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{5} -} -func (m *StakerSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { +// StakerSingleAssetInfo defines the information for a single asset. +// The type include three states: +// staker's deposited, withdrawable, and currently unbonding amount. +type StakerSingleAssetInfo struct { + // total_deposit_amount is the total amount of the asset deposited. + TotalDepositAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_deposit_amount,json=totalDepositAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_deposit_amount"` + // withdrawable_amount is the amount that can be withdrawn. + WithdrawableAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=withdrawable_amount,json=withdrawableAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"withdrawable_amount"` + // wait_unbonding_amount is the amount that is waiting for undelegation. + WaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount,json=waitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount"` +} + +func (m *StakerSingleAssetInfo) Reset() { *m = StakerSingleAssetInfo{} } +func (m *StakerSingleAssetInfo) String() string { return proto.CompactTextString(m) } +func (*StakerSingleAssetInfo) ProtoMessage() {} +func (*StakerSingleAssetInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_adb6ebd423a2c426, []int{5} +} +func (m *StakerSingleAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerSingleAssetOrChangeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *StakerSingleAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerSingleAssetOrChangeInfo.Marshal(b, m, deterministic) + return xxx_messageInfo_StakerSingleAssetInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -443,30 +439,30 @@ func (m *StakerSingleAssetOrChangeInfo) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *StakerSingleAssetOrChangeInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerSingleAssetOrChangeInfo.Merge(m, src) +func (m *StakerSingleAssetInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerSingleAssetInfo.Merge(m, src) } -func (m *StakerSingleAssetOrChangeInfo) XXX_Size() int { +func (m *StakerSingleAssetInfo) XXX_Size() int { return m.Size() } -func (m *StakerSingleAssetOrChangeInfo) XXX_DiscardUnknown() { - xxx_messageInfo_StakerSingleAssetOrChangeInfo.DiscardUnknown(m) +func (m *StakerSingleAssetInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StakerSingleAssetInfo.DiscardUnknown(m) } -var xxx_messageInfo_StakerSingleAssetOrChangeInfo proto.InternalMessageInfo +var xxx_messageInfo_StakerSingleAssetInfo proto.InternalMessageInfo // StakerAllAssetsInfo defines the information for all assets of a staker. // It is indexed by the asset_id. type StakerAllAssetsInfo struct { // all_assets_state is the state of all assets of the staker. - AllAssetsState map[string]*StakerSingleAssetOrChangeInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AllAssetsState map[string]*StakerSingleAssetInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *StakerAllAssetsInfo) Reset() { *m = StakerAllAssetsInfo{} } func (m *StakerAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*StakerAllAssetsInfo) ProtoMessage() {} func (*StakerAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{6} + return fileDescriptor_adb6ebd423a2c426, []int{6} } func (m *StakerAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -495,46 +491,41 @@ func (m *StakerAllAssetsInfo) XXX_DiscardUnknown() { var xxx_messageInfo_StakerAllAssetsInfo proto.InternalMessageInfo -func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetOrChangeInfo { +func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetInfo { if m != nil { return m.AllAssetsState } return nil } -// OperatorSingleAssetOrChangeInfo defines the information for a single asset or its change, -// for an operator. It is also overloaded like StakerSingleAssetOrChangeInfo. -type OperatorSingleAssetOrChangeInfo struct { - // total_amount_or_want_change_value is the total amount of the asset deposited - // or the amount by which it can change. - TotalAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_amount_or_want_change_value,json=totalAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amount_or_want_change_value"` - // operator_own_amount_or_want_change_value is the amount that the operator owns - // or the amount by which it can change. +// OperatorSingleAssetInfo defines the information for a single asset, +// for an operator. It is also overloaded like StakerSingleAssetInfo. +type OperatorSingleAssetInfo struct { + // total_amount is the total amount of the asset deposited. + 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"` + // operator_own_amount is the amount that the operator owns. // todo: the field is used to mark operator's own assets and is not temporarily used now - OperatorOwnAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=operator_own_amount_or_want_change_value,json=operatorOwnAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_own_amount_or_want_change_value"` - // wait_unbonding_amount_or_want_change_value is the amount that is waiting for unbonding - // or the amount by which it can change. - WaitUnbondingAmountOrWantChangeValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount_or_want_change_value,json=waitUnbondingAmountOrWantChangeValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount_or_want_change_value"` - // operator_own_wait_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding - // or the amount by which it can change - OperatorOwnWaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=operator_own_wait_unbonding_amount,json=operatorOwnWaitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_own_wait_unbonding_amount"` - // operator_can_unbond_after_slash is the amount that is owned by operator itself and can be unbonded after slash - // or the amount by which it can change - OperatorCanUnbondAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=operator_can_unbond_after_slash,json=operatorCanUnbondAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_can_unbond_after_slash"` -} - -func (m *OperatorSingleAssetOrChangeInfo) Reset() { *m = OperatorSingleAssetOrChangeInfo{} } -func (m *OperatorSingleAssetOrChangeInfo) String() string { return proto.CompactTextString(m) } -func (*OperatorSingleAssetOrChangeInfo) ProtoMessage() {} -func (*OperatorSingleAssetOrChangeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{7} -} -func (m *OperatorSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { + OperatorOwnAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=operator_own_amount,json=operatorOwnAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_own_amount"` + // wait_unbonding_amount is the amount that is waiting for unbonding. + WaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount,json=waitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount"` + // operator_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding. + OperatorUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=operator_unbonding_amount,json=operatorUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_unbonding_amount"` + // operator_unbondable_amount_after_slash is the amount that is owned by operator itself and can be unbonded after slash. + OperatorUnbondableAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=operator_unbondable_amount_after_slash,json=operatorUnbondableAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_unbondable_amount_after_slash"` +} + +func (m *OperatorSingleAssetInfo) Reset() { *m = OperatorSingleAssetInfo{} } +func (m *OperatorSingleAssetInfo) String() string { return proto.CompactTextString(m) } +func (*OperatorSingleAssetInfo) ProtoMessage() {} +func (*OperatorSingleAssetInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_adb6ebd423a2c426, []int{7} +} +func (m *OperatorSingleAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OperatorSingleAssetOrChangeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OperatorSingleAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OperatorSingleAssetOrChangeInfo.Marshal(b, m, deterministic) + return xxx_messageInfo_OperatorSingleAssetInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -544,30 +535,30 @@ func (m *OperatorSingleAssetOrChangeInfo) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } -func (m *OperatorSingleAssetOrChangeInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_OperatorSingleAssetOrChangeInfo.Merge(m, src) +func (m *OperatorSingleAssetInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorSingleAssetInfo.Merge(m, src) } -func (m *OperatorSingleAssetOrChangeInfo) XXX_Size() int { +func (m *OperatorSingleAssetInfo) XXX_Size() int { return m.Size() } -func (m *OperatorSingleAssetOrChangeInfo) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorSingleAssetOrChangeInfo.DiscardUnknown(m) +func (m *OperatorSingleAssetInfo) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorSingleAssetInfo.DiscardUnknown(m) } -var xxx_messageInfo_OperatorSingleAssetOrChangeInfo proto.InternalMessageInfo +var xxx_messageInfo_OperatorSingleAssetInfo proto.InternalMessageInfo // OperatorAllAssetsInfo defines the information for all assets of an operator, // indexed by the asset_id. type OperatorAllAssetsInfo struct { // all_assets_state is the state of all assets of the operator. - AllAssetsState map[string]*OperatorSingleAssetOrChangeInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AllAssetsState map[string]*OperatorSingleAssetInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *OperatorAllAssetsInfo) Reset() { *m = OperatorAllAssetsInfo{} } func (m *OperatorAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*OperatorAllAssetsInfo) ProtoMessage() {} func (*OperatorAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{8} + return fileDescriptor_adb6ebd423a2c426, []int{8} } func (m *OperatorAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -596,7 +587,7 @@ func (m *OperatorAllAssetsInfo) XXX_DiscardUnknown() { var xxx_messageInfo_OperatorAllAssetsInfo proto.InternalMessageInfo -func (m *OperatorAllAssetsInfo) GetAllAssetsState() map[string]*OperatorSingleAssetOrChangeInfo { +func (m *OperatorAllAssetsInfo) GetAllAssetsState() map[string]*OperatorSingleAssetInfo { if m != nil { return m.AllAssetsState } @@ -623,7 +614,7 @@ func (m *MsgSetExoCoreAddr) Reset() { *m = MsgSetExoCoreAddr{} } func (m *MsgSetExoCoreAddr) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddr) ProtoMessage() {} func (*MsgSetExoCoreAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{9} + return fileDescriptor_adb6ebd423a2c426, []int{9} } func (m *MsgSetExoCoreAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -661,7 +652,7 @@ func (m *MsgSetExoCoreAddrResponse) Reset() { *m = MsgSetExoCoreAddrResp func (m *MsgSetExoCoreAddrResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetExoCoreAddrResponse) ProtoMessage() {} func (*MsgSetExoCoreAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{10} + return fileDescriptor_adb6ebd423a2c426, []int{10} } func (m *MsgSetExoCoreAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -702,7 +693,7 @@ func (m *RegisterClientChainReq) Reset() { *m = RegisterClientChainReq{} func (m *RegisterClientChainReq) String() string { return proto.CompactTextString(m) } func (*RegisterClientChainReq) ProtoMessage() {} func (*RegisterClientChainReq) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{11} + return fileDescriptor_adb6ebd423a2c426, []int{11} } func (m *RegisterClientChainReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -739,7 +730,7 @@ func (m *RegisterClientChainResponse) Reset() { *m = RegisterClientChain func (m *RegisterClientChainResponse) String() string { return proto.CompactTextString(m) } func (*RegisterClientChainResponse) ProtoMessage() {} func (*RegisterClientChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{12} + return fileDescriptor_adb6ebd423a2c426, []int{12} } func (m *RegisterClientChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -781,7 +772,7 @@ func (m *RegisterAssetReq) Reset() { *m = RegisterAssetReq{} } func (m *RegisterAssetReq) String() string { return proto.CompactTextString(m) } func (*RegisterAssetReq) ProtoMessage() {} func (*RegisterAssetReq) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{13} + return fileDescriptor_adb6ebd423a2c426, []int{13} } func (m *RegisterAssetReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -818,7 +809,7 @@ func (m *RegisterAssetResponse) Reset() { *m = RegisterAssetResponse{} } func (m *RegisterAssetResponse) String() string { return proto.CompactTextString(m) } func (*RegisterAssetResponse) ProtoMessage() {} func (*RegisterAssetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{14} + return fileDescriptor_adb6ebd423a2c426, []int{14} } func (m *RegisterAssetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -848,115 +839,108 @@ func (m *RegisterAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterAssetResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*ValueField)(nil), "exocore.restaking_assets_manage.v1.ValueField") - proto.RegisterType((*ClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainInfo") - proto.RegisterType((*AppChainInfo)(nil), "exocore.restaking_assets_manage.v1.AppChainInfo") - proto.RegisterType((*AssetInfo)(nil), "exocore.restaking_assets_manage.v1.AssetInfo") - proto.RegisterType((*StakingAssetInfo)(nil), "exocore.restaking_assets_manage.v1.StakingAssetInfo") - proto.RegisterType((*StakerSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.StakerSingleAssetOrChangeInfo") - proto.RegisterType((*StakerAllAssetsInfo)(nil), "exocore.restaking_assets_manage.v1.StakerAllAssetsInfo") - proto.RegisterMapType((map[string]*StakerSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.StakerAllAssetsInfo.AllAssetsStateEntry") - proto.RegisterType((*OperatorSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.OperatorSingleAssetOrChangeInfo") - proto.RegisterType((*OperatorAllAssetsInfo)(nil), "exocore.restaking_assets_manage.v1.OperatorAllAssetsInfo") - proto.RegisterMapType((map[string]*OperatorSingleAssetOrChangeInfo)(nil), "exocore.restaking_assets_manage.v1.OperatorAllAssetsInfo.AllAssetsStateEntry") - proto.RegisterType((*MsgSetExoCoreAddr)(nil), "exocore.restaking_assets_manage.v1.MsgSetExoCoreAddr") - proto.RegisterType((*MsgSetExoCoreAddrResponse)(nil), "exocore.restaking_assets_manage.v1.MsgSetExoCoreAddrResponse") - proto.RegisterType((*RegisterClientChainReq)(nil), "exocore.restaking_assets_manage.v1.RegisterClientChainReq") - proto.RegisterType((*RegisterClientChainResponse)(nil), "exocore.restaking_assets_manage.v1.RegisterClientChainResponse") - proto.RegisterType((*RegisterAssetReq)(nil), "exocore.restaking_assets_manage.v1.RegisterAssetReq") - proto.RegisterType((*RegisterAssetResponse)(nil), "exocore.restaking_assets_manage.v1.RegisterAssetResponse") -} - -func init() { - proto.RegisterFile("exocore/restaking_assets_manage/v1/tx.proto", fileDescriptor_b24e66e530cc30d1) -} - -var fileDescriptor_b24e66e530cc30d1 = []byte{ - // 1338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x5b, 0x6f, 0x1b, 0xc5, - 0x17, 0xcf, 0xda, 0xb9, 0x1e, 0x37, 0xad, 0xb3, 0x49, 0x5b, 0xc7, 0xf9, 0xd7, 0xee, 0x7f, 0xb9, - 0x28, 0x04, 0x62, 0xab, 0x29, 0x45, 0x34, 0x05, 0x21, 0xc7, 0x6d, 0x51, 0x44, 0x4b, 0xa4, 0x75, - 0x21, 0xa2, 0x3c, 0xac, 0xc6, 0xde, 0xc9, 0x66, 0x95, 0xf5, 0x8c, 0xd9, 0x19, 0xd7, 0x76, 0x9f, - 0xaa, 0x0a, 0x50, 0x05, 0x3c, 0x20, 0x40, 0x48, 0xbc, 0xf5, 0x23, 0x54, 0xa2, 0x1f, 0xa2, 0xbc, - 0x55, 0x7d, 0x42, 0x20, 0x55, 0x25, 0x45, 0x0a, 0x1f, 0x03, 0xcd, 0xcc, 0xae, 0xe3, 0x6d, 0xec, - 0xd6, 0x49, 0xdc, 0x07, 0x5e, 0x12, 0xcf, 0xb9, 0xfe, 0xce, 0x65, 0xce, 0x1c, 0x1b, 0xde, 0xc4, - 0x4d, 0x5a, 0xa1, 0x3e, 0xce, 0xfb, 0x98, 0x71, 0xb4, 0xe5, 0x12, 0xc7, 0x42, 0x8c, 0x61, 0xce, - 0xac, 0x2a, 0x22, 0xc8, 0xc1, 0xf9, 0x1b, 0x67, 0xf2, 0xbc, 0x99, 0xab, 0xf9, 0x94, 0x53, 0xdd, - 0x08, 0x84, 0x73, 0x3d, 0x84, 0x73, 0x37, 0xce, 0xa4, 0xa7, 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, - 0xa8, 0xbf, 0xbd, 0x1f, 0x93, 0x61, 0x0f, 0xa5, 0xcf, 0x1f, 0x40, 0x4b, 0x41, 0x48, 0x8f, 0xdc, - 0xda, 0xb9, 0xb7, 0xa0, 0xad, 0x7c, 0xfe, 0x60, 0x3b, 0xa3, 0x3d, 0xdc, 0xce, 0x68, 0x4f, 0xb6, - 0x33, 0xda, 0xf7, 0x4f, 0x33, 0x43, 0x0f, 0x9f, 0x66, 0x86, 0x7e, 0x7f, 0x9a, 0x19, 0xba, 0x5e, - 0xe8, 0x78, 0xa0, 0x2e, 0x29, 0x2f, 0x1f, 0x63, 0xde, 0xa0, 0xfe, 0x56, 0x3e, 0x9c, 0x01, 0xcd, - 0x9e, 0xbf, 0xc3, 0xc8, 0xf7, 0xab, 0x3c, 0x2a, 0x7f, 0x07, 0x39, 0xfb, 0x6f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x6b, 0x10, 0x0d, 0x13, 0xb7, 0x11, 0x00, 0x00, + proto.RegisterType((*ValueField)(nil), "exocore.assets.v1.ValueField") + proto.RegisterType((*ClientChainInfo)(nil), "exocore.assets.v1.ClientChainInfo") + proto.RegisterType((*AppChainInfo)(nil), "exocore.assets.v1.AppChainInfo") + proto.RegisterType((*AssetInfo)(nil), "exocore.assets.v1.AssetInfo") + proto.RegisterType((*StakingAssetInfo)(nil), "exocore.assets.v1.StakingAssetInfo") + proto.RegisterType((*StakerSingleAssetInfo)(nil), "exocore.assets.v1.StakerSingleAssetInfo") + proto.RegisterType((*StakerAllAssetsInfo)(nil), "exocore.assets.v1.StakerAllAssetsInfo") + proto.RegisterMapType((map[string]*StakerSingleAssetInfo)(nil), "exocore.assets.v1.StakerAllAssetsInfo.AllAssetsStateEntry") + proto.RegisterType((*OperatorSingleAssetInfo)(nil), "exocore.assets.v1.OperatorSingleAssetInfo") + proto.RegisterType((*OperatorAllAssetsInfo)(nil), "exocore.assets.v1.OperatorAllAssetsInfo") + proto.RegisterMapType((map[string]*OperatorSingleAssetInfo)(nil), "exocore.assets.v1.OperatorAllAssetsInfo.AllAssetsStateEntry") + proto.RegisterType((*MsgSetExoCoreAddr)(nil), "exocore.assets.v1.MsgSetExoCoreAddr") + proto.RegisterType((*MsgSetExoCoreAddrResponse)(nil), "exocore.assets.v1.MsgSetExoCoreAddrResponse") + proto.RegisterType((*RegisterClientChainReq)(nil), "exocore.assets.v1.RegisterClientChainReq") + proto.RegisterType((*RegisterClientChainResponse)(nil), "exocore.assets.v1.RegisterClientChainResponse") + proto.RegisterType((*RegisterAssetReq)(nil), "exocore.assets.v1.RegisterAssetReq") + proto.RegisterType((*RegisterAssetResponse)(nil), "exocore.assets.v1.RegisterAssetResponse") +} + +func init() { proto.RegisterFile("exocore/assets/v1/tx.proto", fileDescriptor_adb6ebd423a2c426) } + +var fileDescriptor_adb6ebd423a2c426 = []byte{ + // 1254 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x4d, 0x6f, 0x13, 0xc7, + 0x1b, 0xcf, 0x3a, 0x21, 0x2f, 0x8f, 0x09, 0x38, 0xe3, 0x84, 0x38, 0xe6, 0x8f, 0x83, 0xfc, 0x6f, + 0x51, 0x1a, 0x81, 0x0d, 0xa9, 0x8a, 0xda, 0x80, 0xaa, 0x3a, 0x01, 0xa4, 0x54, 0x50, 0xa4, 0x35, + 0xed, 0x81, 0x43, 0x57, 0x63, 0xef, 0x64, 0xb3, 0xcd, 0xee, 0xcc, 0x76, 0x67, 0x42, 0x6c, 0x4e, + 0x55, 0x4f, 0x15, 0x27, 0x3e, 0x02, 0x1f, 0x81, 0x03, 0x87, 0x7e, 0x04, 0xc4, 0x89, 0x72, 0xaa, + 0x7a, 0x40, 0x28, 0x1c, 0xc2, 0xa9, 0x9f, 0xa1, 0x9a, 0x97, 0x75, 0xbc, 0xc9, 0x26, 0x44, 0x8d, + 0xa5, 0x5e, 0x92, 0x9d, 0xe7, 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68, 0x8b, 0x51, 0x57, 0xe6, 0xdb, 0x18, 0x1c, + 0x1e, 0x80, 0xc1, 0xa2, 0x84, 0xfe, 0x3e, 0x41, 0x4e, 0x52, 0x6d, 0x41, 0x51, 0xa7, 0xba, 0x11, + 0x04, 0x2a, 0xcf, 0x5c, 0x25, 0xda, 0x85, 0x02, 0x0e, 0x02, 0x47, 0x57, 0x87, 0xc3, 0x05, 0x16, + 0xb2, 0x61, 0x87, 0x17, 0xf2, 0x4b, 0xcb, 0x19, 0xa5, 0x93, 0x81, 0x50, 0xeb, 0x9d, 0x9a, 0x52, + 0xf9, 0x36, 0x15, 0x71, 0xd7, 0x3e, 0x83, 0x53, 0xc4, 0xf2, 0x26, 0x14, 0x33, 0xc4, 0x50, 0x01, + 0x86, 0x37, 0x49, 0xd7, 0x0c, 0x08, 0xf9, 0x89, 0xbe, 0x86, 0x53, 0x8f, 0xe4, 0x33, 0xa4, 0x32, + 0x9f, 0x5f, 0x5a, 0x38, 0xd4, 0x87, 0x7d, 0x05, 0x63, 0x6b, 0xb5, 0xe5, 0xdc, 0x97, 0x56, 0x75, + 0x77, 0x04, 0x66, 0xef, 0x47, 0x24, 0xc6, 0x82, 0x1d, 0xa8, 0xab, 0xde, 0xc4, 0x18, 0x60, 0x3d, + 0xe9, 0x89, 0x61, 0x6e, 0x36, 0x80, 0x22, 0x33, 0xb6, 0x1d, 0xb6, 0x4d, 0x07, 0x59, 0x48, 0x53, + 0x09, 0xf0, 0xfd, 0x6d, 0xfa, 0x5f, 0xd5, 0x11, 0xea, 0xc0, 0x5c, 0x2f, 0xbe, 0x03, 0x56, 0x47, + 0x06, 0x60, 0x75, 0x36, 0x81, 0xdf, 0x6f, 0xf9, 0xa9, 0x05, 0x97, 0xf6, 0x99, 0xee, 0x6b, 0x55, + 0x07, 0xaf, 0x0b, 0x12, 0x3b, 0x3c, 0xc0, 0x7c, 0x63, 0x20, 0xef, 0x40, 0x35, 0xed, 0xc7, 0x5e, + 0xf3, 0x36, 0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2a, 0xd6, 0xbb, 0x9d, 0x8a, 0xf5, 0xf4, + 0x7d, 0x65, 0xe8, 0xf5, 0xfb, 0xca, 0xd0, 0x9f, 0xef, 0x2b, 0x43, 0x0f, 0xaf, 0xf6, 0x4d, 0xfc, + 0xdb, 0x1a, 0xf4, 0x3b, 0x22, 0xb6, 0x59, 0xbc, 0x59, 0x4f, 0x1a, 0xaf, 0x93, 0xfc, 0xe8, 0x56, + 0xf3, 0xbf, 0x35, 0xaa, 0x7e, 0x05, 0x7f, 0xfe, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x4f, + 0x65, 0x11, 0x93, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -989,7 +973,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) SetStakerExoCoreAddr(ctx context.Context, in *MsgSetExoCoreAddr, opts ...grpc.CallOption) (*MsgSetExoCoreAddrResponse, error) { out := new(MsgSetExoCoreAddrResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Msg/SetStakerExoCoreAddr", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Msg/SetStakerExoCoreAddr", in, out, opts...) if err != nil { return nil, err } @@ -998,7 +982,7 @@ func (c *msgClient) SetStakerExoCoreAddr(ctx context.Context, in *MsgSetExoCoreA func (c *msgClient) RegisterClientChain(ctx context.Context, in *RegisterClientChainReq, opts ...grpc.CallOption) (*RegisterClientChainResponse, error) { out := new(RegisterClientChainResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Msg/RegisterClientChain", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Msg/RegisterClientChain", in, out, opts...) if err != nil { return nil, err } @@ -1007,7 +991,7 @@ func (c *msgClient) RegisterClientChain(ctx context.Context, in *RegisterClientC func (c *msgClient) RegisterAsset(ctx context.Context, in *RegisterAssetReq, opts ...grpc.CallOption) (*RegisterAssetResponse, error) { out := new(RegisterAssetResponse) - err := c.cc.Invoke(ctx, "/exocore.restaking_assets_manage.v1.Msg/RegisterAsset", in, out, opts...) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Msg/RegisterAsset", in, out, opts...) if err != nil { return nil, err } @@ -1052,7 +1036,7 @@ func _Msg_SetStakerExoCoreAddr_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Msg/SetStakerExoCoreAddr", + FullMethod: "/exocore.assets.v1.Msg/SetStakerExoCoreAddr", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SetStakerExoCoreAddr(ctx, req.(*MsgSetExoCoreAddr)) @@ -1070,7 +1054,7 @@ func _Msg_RegisterClientChain_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Msg/RegisterClientChain", + FullMethod: "/exocore.assets.v1.Msg/RegisterClientChain", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).RegisterClientChain(ctx, req.(*RegisterClientChainReq)) @@ -1088,7 +1072,7 @@ func _Msg_RegisterAsset_Handler(srv interface{}, ctx context.Context, dec func(i } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.restaking_assets_manage.v1.Msg/RegisterAsset", + FullMethod: "/exocore.assets.v1.Msg/RegisterAsset", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).RegisterAsset(ctx, req.(*RegisterAssetReq)) @@ -1097,7 +1081,7 @@ func _Msg_RegisterAsset_Handler(srv interface{}, ctx context.Context, dec func(i } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "exocore.restaking_assets_manage.v1.Msg", + ServiceName: "exocore.assets.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -1114,7 +1098,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "exocore/restaking_assets_manage/v1/tx.proto", + Metadata: "exocore/assets/v1/tx.proto", } func (m *ValueField) Marshal() (dAtA []byte, err error) { @@ -1192,8 +1176,8 @@ func (m *ClientChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.ExoCoreChainIndex != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ExoCoreChainIndex)) + if m.ExocoreChainIndex != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExocoreChainIndex)) i-- dAtA[i] = 0x20 } @@ -1239,8 +1223,8 @@ func (m *AppChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ExoCoreChainIndex != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ExoCoreChainIndex)) + if m.ExocoreChainIndex != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExocoreChainIndex)) i-- dAtA[i] = 0x20 } @@ -1295,8 +1279,8 @@ func (m *AssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x42 } - if m.ExoCoreChainIndex != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ExoCoreChainIndex)) + if m.ExocoreChainIndex != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExocoreChainIndex)) i-- dAtA[i] = 0x38 } @@ -1389,7 +1373,7 @@ func (m *StakingAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *StakerSingleAssetOrChangeInfo) Marshal() (dAtA []byte, err error) { +func (m *StakerSingleAssetInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1399,20 +1383,20 @@ func (m *StakerSingleAssetOrChangeInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *StakerSingleAssetOrChangeInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *StakerSingleAssetInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *StakerSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *StakerSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.WaitUnbondingAmountOrWantChangeValue.Size() + size := m.WaitUnbondingAmount.Size() i -= size - if _, err := m.WaitUnbondingAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1420,9 +1404,9 @@ func (m *StakerSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x1a { - size := m.CanWithdrawAmountOrWantChangeValue.Size() + size := m.WithdrawableAmount.Size() i -= size - if _, err := m.CanWithdrawAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WithdrawableAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1430,9 +1414,9 @@ func (m *StakerSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 { - size := m.TotalDepositAmountOrWantChangeValue.Size() + size := m.TotalDepositAmount.Size() i -= size - if _, err := m.TotalDepositAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.TotalDepositAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1491,7 +1475,7 @@ func (m *StakerAllAssetsInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *OperatorSingleAssetOrChangeInfo) Marshal() (dAtA []byte, err error) { +func (m *OperatorSingleAssetInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1501,20 +1485,20 @@ func (m *OperatorSingleAssetOrChangeInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorSingleAssetOrChangeInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *OperatorSingleAssetInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OperatorSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.OperatorCanUnbondAfterSlash.Size() + size := m.OperatorUnbondableAmountAfterSlash.Size() i -= size - if _, err := m.OperatorCanUnbondAfterSlash.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.OperatorUnbondableAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1522,9 +1506,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x2a { - size := m.OperatorOwnWaitUnbondingAmount.Size() + size := m.OperatorUnbondingAmount.Size() i -= size - if _, err := m.OperatorOwnWaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.OperatorUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1532,9 +1516,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x22 { - size := m.WaitUnbondingAmountOrWantChangeValue.Size() + size := m.WaitUnbondingAmount.Size() i -= size - if _, err := m.WaitUnbondingAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1542,9 +1526,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x1a { - size := m.OperatorOwnAmountOrWantChangeValue.Size() + size := m.OperatorOwnAmount.Size() i -= size - if _, err := m.OperatorOwnAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.OperatorOwnAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1552,9 +1536,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x12 { - size := m.TotalAmountOrWantChangeValue.Size() + size := m.TotalAmount.Size() i -= size - if _, err := m.TotalAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.TotalAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1861,8 +1845,8 @@ func (m *ClientChainInfo) Size() (n int) { if m.ChainId != 0 { n += 1 + sovTx(uint64(m.ChainId)) } - if m.ExoCoreChainIndex != 0 { - n += 1 + sovTx(uint64(m.ExoCoreChainIndex)) + if m.ExocoreChainIndex != 0 { + n += 1 + sovTx(uint64(m.ExocoreChainIndex)) } if m.FinalizationBlocks != 0 { n += 1 + sovTx(uint64(m.FinalizationBlocks)) @@ -1898,8 +1882,8 @@ func (m *AppChainInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.ExoCoreChainIndex != 0 { - n += 1 + sovTx(uint64(m.ExoCoreChainIndex)) + if m.ExocoreChainIndex != 0 { + n += 1 + sovTx(uint64(m.ExocoreChainIndex)) } return n } @@ -1930,8 +1914,8 @@ func (m *AssetInfo) Size() (n int) { if m.LayerZeroChainID != 0 { n += 1 + sovTx(uint64(m.LayerZeroChainID)) } - if m.ExoCoreChainIndex != 0 { - n += 1 + sovTx(uint64(m.ExoCoreChainIndex)) + if m.ExocoreChainIndex != 0 { + n += 1 + sovTx(uint64(m.ExocoreChainIndex)) } l = len(m.MetaInfo) if l > 0 { @@ -1955,17 +1939,17 @@ func (m *StakingAssetInfo) Size() (n int) { return n } -func (m *StakerSingleAssetOrChangeInfo) Size() (n int) { +func (m *StakerSingleAssetInfo) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.TotalDepositAmountOrWantChangeValue.Size() + l = m.TotalDepositAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.CanWithdrawAmountOrWantChangeValue.Size() + l = m.WithdrawableAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUnbondingAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1992,21 +1976,21 @@ func (m *StakerAllAssetsInfo) Size() (n int) { return n } -func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { +func (m *OperatorSingleAssetInfo) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.TotalAmountOrWantChangeValue.Size() + l = m.TotalAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.OperatorOwnAmountOrWantChangeValue.Size() + l = m.OperatorOwnAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUnbondingAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.OperatorOwnWaitUnbondingAmount.Size() + l = m.OperatorUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.OperatorCanUnbondAfterSlash.Size() + l = m.OperatorUnbondableAmountAfterSlash.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -2326,9 +2310,9 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreChainIndex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreChainIndex", wireType) } - m.ExoCoreChainIndex = 0 + m.ExocoreChainIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2338,7 +2322,7 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExoCoreChainIndex |= uint64(b&0x7F) << shift + m.ExocoreChainIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2580,9 +2564,9 @@ func (m *AppChainInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreChainIndex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreChainIndex", wireType) } - m.ExoCoreChainIndex = 0 + m.ExocoreChainIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2592,7 +2576,7 @@ func (m *AppChainInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExoCoreChainIndex |= uint64(b&0x7F) << shift + m.ExocoreChainIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2817,9 +2801,9 @@ func (m *AssetInfo) Unmarshal(dAtA []byte) error { } case 7: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreChainIndex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreChainIndex", wireType) } - m.ExoCoreChainIndex = 0 + m.ExocoreChainIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2829,7 +2813,7 @@ func (m *AssetInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExoCoreChainIndex |= uint64(b&0x7F) << shift + m.ExocoreChainIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -3007,7 +2991,7 @@ func (m *StakingAssetInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { +func (m *StakerSingleAssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3030,15 +3014,15 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StakerSingleAssetOrChangeInfo: wiretype end group for non-group") + return fmt.Errorf("proto: StakerSingleAssetInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StakerSingleAssetOrChangeInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StakerSingleAssetInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalDepositAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalDepositAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3066,13 +3050,13 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalDepositAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalDepositAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CanWithdrawAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawableAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3100,13 +3084,13 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CanWithdrawAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.WithdrawableAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3134,7 +3118,7 @@ func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUnbondingAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.WaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3218,10 +3202,10 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AllAssetsState == nil { - m.AllAssetsState = make(map[string]*StakerSingleAssetOrChangeInfo) + m.AllAssetsState = make(map[string]*StakerSingleAssetInfo) } var mapkey string - var mapvalue *StakerSingleAssetOrChangeInfo + var mapvalue *StakerSingleAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3295,7 +3279,7 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &StakerSingleAssetOrChangeInfo{} + mapvalue = &StakerSingleAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -3338,7 +3322,7 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { +func (m *OperatorSingleAssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3361,15 +3345,15 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OperatorSingleAssetOrChangeInfo: wiretype end group for non-group") + return fmt.Errorf("proto: OperatorSingleAssetInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OperatorSingleAssetOrChangeInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OperatorSingleAssetInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3397,13 +3381,13 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3431,13 +3415,13 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OperatorOwnAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OperatorOwnAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3465,13 +3449,13 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WaitUnbondingAmountOrWantChangeValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.WaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnWaitUnbondingAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorUnbondingAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3499,13 +3483,13 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OperatorOwnWaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OperatorUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorCanUnbondAfterSlash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorUnbondableAmountAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3533,7 +3517,7 @@ func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OperatorCanUnbondAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OperatorUnbondableAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3617,10 +3601,10 @@ func (m *OperatorAllAssetsInfo) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AllAssetsState == nil { - m.AllAssetsState = make(map[string]*OperatorSingleAssetOrChangeInfo) + m.AllAssetsState = make(map[string]*OperatorSingleAssetInfo) } var mapkey string - var mapvalue *OperatorSingleAssetOrChangeInfo + var mapvalue *OperatorSingleAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3694,7 +3678,7 @@ func (m *OperatorAllAssetsInfo) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &OperatorSingleAssetOrChangeInfo{} + mapvalue = &OperatorSingleAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } diff --git a/x/delegation/client/cli/query.go b/x/delegation/client/cli/query.go index 305e37831..1e29298c7 100644 --- a/x/delegation/client/cli/query.go +++ b/x/delegation/client/cli/query.go @@ -5,8 +5,8 @@ import ( "strconv" errorsmod "cosmossdk.io/errors" + "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 95f006d92..a1b61a324 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -1,8 +1,8 @@ package keeper import ( + "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -64,8 +64,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida if err != nil { panic(err) } - if record.Amount.GT(delegationInfo.CanBeUndelegatedAfterSlash) { - record.ActualCompletedAmount = delegationInfo.CanBeUndelegatedAfterSlash + if record.Amount.GT(delegationInfo.UndelegatableAfterSlash) { + record.ActualCompletedAmount = delegationInfo.UndelegatableAfterSlash } else { record.ActualCompletedAmount = record.Amount } @@ -74,8 +74,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[record.OperatorAddr] = &delegationtype.DelegationAmounts{ - WaitUndelegationAmount: recordAmountNeg, - CanBeUndelegatedAfterSlash: record.ActualCompletedAmount.Neg(), + WaitUndelegationAmount: recordAmountNeg, + UndelegatableAfterSlash: record.ActualCompletedAmount.Neg(), } err = k.UpdateDelegationState(ctx, record.StakerID, record.AssetID, delegatorAndAmount) if err != nil { @@ -83,17 +83,17 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } // update the staker state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetOrChangeInfo{ - CanWithdrawAmountOrWantChangeValue: record.ActualCompletedAmount, - WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetChangeInfo{ + ChangeForWithdrawable: record.ActualCompletedAmount, + ChangeForWaitUnbonding: recordAmountNeg, }) if err != nil { panic(err) } // update the operator state - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetOrChangeInfo{ - WaitUnbondingAmountOrWantChangeValue: recordAmountNeg, + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetChangeInfo{ + ChangeForWaitUnbonding: recordAmountNeg, }) if err != nil { panic(err) diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 996ebda08..97160a041 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -5,15 +5,15 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) type DelegationOrUndelegationParams struct { ClientChainLzID uint64 - Action types.CrossChainOpType + Action assetstype.CrossChainOpType AssetsAddress []byte OperatorAddress sdk.AccAddress StakerAddress []byte @@ -127,7 +127,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return delegationtype.ErrOpAmountIsNegative } - stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) + stakerID, assetID := assetstype.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) // check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount info, err := k.restakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) @@ -135,20 +135,20 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return err } - if info.CanWithdrawAmountOrWantChangeValue.LT(params.OpAmount) { - return errorsmod.Wrap(delegationtype.ErrDelegationAmountTooBig, fmt.Sprintf("the opAmount is:%s the canWithdraw amount is:%s", params.OpAmount, info.CanWithdrawAmountOrWantChangeValue)) + if info.WithdrawableAmount.LT(params.OpAmount) { + return errorsmod.Wrap(delegationtype.ErrDelegationAmountTooBig, fmt.Sprintf("the opAmount is:%s the WithdrawableAmount amount is:%s", params.OpAmount, info.WithdrawableAmount)) } // update staker asset state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ - CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ + ChangeForWithdrawable: params.OpAmount.Neg(), }) if err != nil { return err } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: params.OpAmount, + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ + ChangeForTotalAmount: params.OpAmount, }) if err != nil { return err @@ -156,7 +156,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: params.OpAmount, + UndelegatableAmount: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -189,13 +189,13 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio return delegationtype.ErrOpAmountIsNegative } // get staker delegation state, then check the validation of Undelegation amount - stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) + stakerID, assetID := assetstype.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) delegationState, err := k.GetSingleDelegationInfo(ctx, stakerID, assetID, params.OperatorAddress.String()) if err != nil { return err } - if params.OpAmount.GT(delegationState.CanBeUndelegatedAmount) { - return errorsmod.Wrap(delegationtype.ErrUndelegationAmountTooBig, fmt.Sprintf("UndelegationAmount:%s,CanBeUndelegatedAmount:%s", params.OpAmount, delegationState.CanBeUndelegatedAmount)) + if params.OpAmount.GT(delegationState.UndelegatableAmount) { + return errorsmod.Wrap(delegationtype.ErrUndelegationAmountTooBig, fmt.Sprintf("UndelegationAmount:%s,UndelegatableAmount:%s", params.OpAmount, delegationState.UndelegatableAmount)) } // record Undelegation event @@ -219,9 +219,9 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: params.OpAmount.Neg(), - WaitUndelegationAmount: params.OpAmount, - CanBeUndelegatedAfterSlash: params.OpAmount, + UndelegatableAmount: params.OpAmount.Neg(), + WaitUndelegationAmount: params.OpAmount, + UndelegatableAfterSlash: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -233,15 +233,15 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio } // update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ - WaitUnbondingAmountOrWantChangeValue: params.OpAmount, + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ + ChangeForWaitUnbonding: params.OpAmount, }) if err != nil { return err } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: params.OpAmount.Neg(), - WaitUnbondingAmountOrWantChangeValue: params.OpAmount, + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ + ChangeForTotalAmount: params.OpAmount.Neg(), + ChangeForWaitUnbonding: params.OpAmount, }) if err != nil { return err diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index f0c9a5ace..b028f64c6 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -6,11 +6,11 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" types2 "github.com/ExocoreNetwork/exocore/x/operator/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -61,28 +61,28 @@ func (suite *DelegationTestSuite) TestDelegateTo() { stakerID, assetID := types.GetStakeIDAndAssetID(delegationParams.ClientChainLzID, delegationParams.StakerAddress, delegationParams.AssetsAddress) restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationParams.OpAmount), - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount.Sub(delegationParams.OpAmount), + WaitUnbondingAmount: sdkmath.NewInt(0), }, *restakerState) operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) - suite.Equal(types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: delegationParams.OpAmount, - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), - OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), - OperatorCanUnbondAfterSlash: sdkmath.NewInt(0), + suite.Equal(types.OperatorSingleAssetInfo{ + TotalAmount: delegationParams.OpAmount, + OperatorOwnAmount: sdkmath.NewInt(0), + WaitUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: delegationParams.OpAmount, - WaitUndelegationAmount: sdkmath.NewInt(0), - CanBeUndelegatedAfterSlash: sdkmath.NewInt(0), + UndelegatableAmount: delegationParams.OpAmount, + WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) @@ -137,28 +137,28 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { stakerID, assetID := types.GetStakeIDAndAssetID(delegationEvent.ClientChainLzID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationEvent.OpAmount), - WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount.Sub(delegationEvent.OpAmount), + WaitUnbondingAmount: delegationEvent.OpAmount, }, *restakerState) operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) - suite.Equal(types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: sdkmath.NewInt(0), - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: delegationEvent.OpAmount, - OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), - OperatorCanUnbondAfterSlash: sdkmath.NewInt(0), + suite.Equal(types.OperatorSingleAssetInfo{ + TotalAmount: sdkmath.NewInt(0), + OperatorOwnAmount: sdkmath.NewInt(0), + WaitUnbondingAmount: delegationEvent.OpAmount, + OperatorUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: delegationEvent.OpAmount, - CanBeUndelegatedAfterSlash: delegationEvent.OpAmount, + UndelegatableAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: delegationEvent.OpAmount, + UndelegatableAfterSlash: delegationEvent.OpAmount, }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) @@ -242,28 +242,28 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { stakerID, assetID := types.GetStakeIDAndAssetID(delegationEvent.ClientChainLzID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount, + WaitUnbondingAmount: sdkmath.NewInt(0), }, *restakerState) operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) - suite.Equal(types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: sdkmath.NewInt(0), - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), - OperatorOwnWaitUnbondingAmount: sdkmath.NewInt(0), - OperatorCanUnbondAfterSlash: sdkmath.NewInt(0), + suite.Equal(types.OperatorSingleAssetInfo{ + TotalAmount: sdkmath.NewInt(0), + OperatorOwnAmount: sdkmath.NewInt(0), + WaitUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondingAmount: sdkmath.NewInt(0), + OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), }, *operatorState) specifiedDelegationAmount, err := suite.App.DelegationKeeper.GetSingleDelegationInfo(suite.Ctx, stakerID, assetID, opAccAddr.String()) suite.NoError(err) suite.Equal(delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), - CanBeUndelegatedAfterSlash: sdkmath.NewInt(0), + UndelegatableAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAfterSlash: sdkmath.NewInt(0), }, *specifiedDelegationAmount) totalDelegationAmount, err := suite.App.DelegationKeeper.GetStakerDelegationTotalAmount(suite.Ctx, stakerID, assetID) diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 964415386..b4d975422 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -5,8 +5,8 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - stakingtypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -21,13 +21,13 @@ func (k *Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerID str // use stakerID+'/'+assetID as the key of total delegation amount store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) amount := delegationtype.ValueField{Amount: sdkmath.NewInt(0)} - key := stakingtypes.GetJoinedStoreKey(stakerID, assetID) + key := assetstype.GetJoinedStoreKey(stakerID, assetID) if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &amount) } - err := stakingtypes.UpdateAssetValue(&amount.Amount, &opAmount) + err := assetstype.UpdateAssetValue(&amount.Amount, &opAmount) if err != nil { return err } @@ -41,7 +41,7 @@ func (k *Keeper) UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerID str func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerID string, assetID string) (opAmount sdkmath.Int, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) var ret delegationtype.ValueField - prefixKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID) + prefixKey := assetstype.GetJoinedStoreKey(stakerID, assetID) isExit := store.Has(prefixKey) if !isExit { return sdkmath.Int{}, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerDelegationTotalAmount: key is %s", prefixKey)) @@ -62,7 +62,7 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID if amounts == nil { continue } - if amounts.CanBeUndelegatedAmount.IsNil() && amounts.WaitUndelegationAmount.IsNil() { + if amounts.UndelegatableAmount.IsNil() && amounts.WaitUndelegationAmount.IsNil() { continue } // check operator address validation @@ -70,11 +70,11 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID if err != nil { return delegationtype.OperatorAddrIsNotAccAddr } - singleStateKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID, opAddr) + singleStateKey := assetstype.GetJoinedStoreKey(stakerID, assetID, opAddr) delegationState := delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), - CanBeUndelegatedAfterSlash: sdkmath.NewInt(0), + UndelegatableAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAfterSlash: sdkmath.NewInt(0), } if store.Has(singleStateKey) { @@ -82,19 +82,19 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID k.cdc.MustUnmarshal(value, &delegationState) } - err = stakingtypes.UpdateAssetValue(&delegationState.CanBeUndelegatedAmount, &amounts.CanBeUndelegatedAmount) + err = assetstype.UpdateAssetValue(&delegationState.UndelegatableAmount, &amounts.UndelegatableAmount) if err != nil { - return errorsmod.Wrap(err, "UpdateDelegationState CanBeUndelegatedAmount error") + return errorsmod.Wrap(err, "UpdateDelegationState UndelegatableAmount error") } - err = stakingtypes.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) + err = assetstype.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) if err != nil { return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } - err = stakingtypes.UpdateAssetValue(&delegationState.CanBeUndelegatedAfterSlash, &amounts.CanBeUndelegatedAfterSlash) + err = assetstype.UpdateAssetValue(&delegationState.UndelegatableAfterSlash, &amounts.UndelegatableAfterSlash) if err != nil { - return errorsmod.Wrap(err, "UpdateDelegationState CanUsedToUndelegateAmount error") + return errorsmod.Wrap(err, "UpdateDelegationState UndelegatableAfterSlash error") } // save single operator delegation state @@ -107,7 +107,7 @@ func (k *Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID // GetSingleDelegationInfo query the staker's asset amount that has been delegated to the specified operator. func (k *Keeper) GetSingleDelegationInfo(ctx sdk.Context, stakerID, assetID, operatorAddr string) (*delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) - singleStateKey := stakingtypes.GetJoinedStoreKey(stakerID, assetID, operatorAddr) + singleStateKey := assetstype.GetJoinedStoreKey(stakerID, assetID, operatorAddr) isExit := store.Has(singleStateKey) delegationState := delegationtype.DelegationAmounts{} if isExit { @@ -156,7 +156,7 @@ func (k *Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr s for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := stakingtypes.ParseJoinedKey(iterator.Key()) + keys, err := assetstype.ParseJoinedKey(iterator.Key()) if err != nil { return nil, err } @@ -187,7 +187,7 @@ func (k *Keeper) IterateDelegationState(ctx sdk.Context, f func(restakerID, asse for ; iterator.Valid(); iterator.Next() { var amounts delegationtype.DelegationAmounts k.cdc.MustUnmarshal(iterator.Value(), &amounts) - keys, err := stakingtypes.ParseJoinedKey(iterator.Key()) + keys, err := assetstype.ParseJoinedKey(iterator.Key()) if err != nil { return err } diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 46cfff188..04f6cd0f1 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -3,9 +3,9 @@ package keeper import ( "context" + "github.com/ExocoreNetwork/exocore/x/assets/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" depositkeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -45,7 +45,7 @@ func NewKeeper( } // GetExoCoreLzAppAddress Get exoCoreLzAppAddr from deposit keeper,it will be used when check the caller of precompile contract. -// This function needs to be moved to `restaking_assets_manage` module,which will facilitate its use for the other modules +// This function needs to be moved to `assets` module,which will facilitate its use for the other modules func (k *Keeper) GetExoCoreLzAppAddress(ctx sdk.Context) (common.Address, error) { return k.depositKeeper.GetExoCoreLzAppAddress(ctx) } diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index 4ce78ed44..fbf1466b1 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -3,7 +3,7 @@ package types import ( "strings" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index e184bec24..cd6a93b26 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -90,12 +90,12 @@ func (m *DelegationInfoReq) GetAssetID() string { // DelegationAmounts is the delegation amount response for a single delegation. type DelegationAmounts struct { - // can_be_undelegated_amount is the amount that can be undelegated. - CanBeUndelegatedAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=can_be_undelegated_amount,json=canBeUndelegatedAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_be_undelegated_amount"` + // undelegatable_amount is the amount that can be undelegated. + UndelegatableAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=undelegatable_amount,json=undelegatableAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"undelegatable_amount"` // 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"` - // can_be_undelegated_after_slash is the amount that can be undelegated after slash - CanBeUndelegatedAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=can_be_undelegated_after_slash,json=canBeUndelegatedAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"can_be_undelegated_after_slash"` + // undelegatable_after_slash is the amount that can be undelegated after slash + UndelegatableAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=undelegatable_after_slash,json=undelegatableAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"undelegatable_after_slash"` } func (m *DelegationAmounts) Reset() { *m = DelegationAmounts{} } @@ -302,49 +302,49 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 671 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x4f, 0x13, 0x4f, - 0x1c, 0xee, 0x6e, 0xc3, 0x1f, 0x18, 0xf8, 0x47, 0x1c, 0x2b, 0x96, 0x62, 0xb6, 0xd8, 0x03, 0xa9, + // 667 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x4f, 0x13, 0x4f, + 0x1c, 0xee, 0x6e, 0xc3, 0x1f, 0x18, 0xf8, 0x47, 0x1c, 0x2a, 0x94, 0x62, 0x5a, 0xdc, 0x03, 0xa9, 0x24, 0xec, 0x4a, 0xd5, 0xc4, 0x18, 0x31, 0x81, 0x94, 0x90, 0xbd, 0x60, 0xdc, 0x86, 0x8b, 0x97, - 0xcd, 0xd0, 0x9d, 0x2e, 0x9b, 0x2e, 0x33, 0x65, 0x66, 0x5a, 0xe8, 0xcd, 0x78, 0xd1, 0xa3, 0x89, - 0xdf, 0x42, 0x2f, 0x1e, 0xf8, 0x10, 0x1c, 0x09, 0x5e, 0x8c, 0x87, 0xc6, 0x14, 0x13, 0x0f, 0x1e, - 0xfd, 0x02, 0x66, 0x67, 0x07, 0x5a, 0xfa, 0x82, 0x12, 0xf1, 0xd4, 0xdd, 0xdf, 0xcb, 0xf3, 0x3c, - 0xbf, 0xb7, 0x2e, 0xb8, 0x83, 0xf7, 0x69, 0x99, 0x32, 0x6c, 0x79, 0x38, 0xc4, 0x3e, 0x12, 0x01, - 0x25, 0x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 0x5f, 0xaf, 0x8f, + 0xb1, 0x7a, 0x29, 0xb7, 0x00, 0x1f, 0x0c, 0x90, 0x3b, 0x50, 0xd8, 0xfa, 0xd6, 0x49, 0x2b, 0xab, + 0x9d, 0xb6, 0xb2, 0xda, 0xd7, 0x56, 0x56, 0x7b, 0x7b, 0x9e, 0x4d, 0x9c, 0x9e, 0x67, 0x13, 0x9f, + 0xcf, 0xb3, 0x89, 0x57, 0x8f, 0x3a, 0x4e, 0x77, 0x23, 0x46, 0xdd, 0xc2, 0xe2, 0x90, 0xb2, 0xca, + 0x05, 0xc9, 0x51, 0x27, 0x8d, 0x3c, 0xe6, 0x9d, 0xff, 0xe4, 0x07, 0xe2, 0xe1, 0xef, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xa3, 0xe7, 0x09, 0xae, 0xc8, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -527,9 +527,9 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.CanBeUndelegatedAfterSlash.Size() + size := m.UndelegatableAfterSlash.Size() i -= size - if _, err := m.CanBeUndelegatedAfterSlash.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.UndelegatableAfterSlash.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) @@ -547,9 +547,9 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 { - size := m.CanBeUndelegatedAmount.Size() + size := m.UndelegatableAmount.Size() i -= size - if _, err := m.CanBeUndelegatedAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.UndelegatableAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) @@ -726,11 +726,11 @@ func (m *DelegationAmounts) Size() (n int) { } var l int _ = l - l = m.CanBeUndelegatedAmount.Size() + l = m.UndelegatableAmount.Size() n += 1 + l + sovQuery(uint64(l)) l = m.WaitUndelegationAmount.Size() n += 1 + l + sovQuery(uint64(l)) - l = m.CanBeUndelegatedAfterSlash.Size() + l = m.UndelegatableAfterSlash.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -944,7 +944,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CanBeUndelegatedAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UndelegatableAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -972,7 +972,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CanBeUndelegatedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.UndelegatableAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1012,7 +1012,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CanBeUndelegatedAfterSlash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UndelegatableAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1040,7 +1040,7 @@ func (m *DelegationAmounts) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CanBeUndelegatedAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.UndelegatableAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/deposit/keeper/cross_chain_tx_process.go b/x/deposit/keeper/cross_chain_tx_process.go index 67c3960c3..2b43285fa 100644 --- a/x/deposit/keeper/cross_chain_tx_process.go +++ b/x/deposit/keeper/cross_chain_tx_process.go @@ -5,8 +5,8 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" despoittypes "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -133,9 +133,9 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(despoittypes.ErrDepositAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } - changeAmount := types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount, - CanWithdrawAmountOrWantChangeValue: params.OpAmount, + changeAmount := types.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: params.OpAmount, + ChangeForWithdrawable: params.OpAmount, } // update asset state of the specified staker err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) diff --git a/x/deposit/keeper/deposit_test.go b/x/deposit/keeper/deposit_test.go index 84f2d17f9..eda1de67f 100644 --- a/x/deposit/keeper/deposit_test.go +++ b/x/deposit/keeper/deposit_test.go @@ -2,9 +2,9 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ethereum/go-ethereum/common" ) @@ -36,10 +36,10 @@ func (suite *DepositTestSuite) TestDeposit() { stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount, - CanWithdrawAmountOrWantChangeValue: params.OpAmount, - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: params.OpAmount, + WithdrawableAmount: params.OpAmount, + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) diff --git a/x/deposit/keeper/keeper.go b/x/deposit/keeper/keeper.go index d2b23dce1..93a3efe68 100644 --- a/x/deposit/keeper/keeper.go +++ b/x/deposit/keeper/keeper.go @@ -1,8 +1,8 @@ package keeper import ( + "github.com/ExocoreNetwork/exocore/x/assets/keeper" deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/deposit/keeper/msg_server.go b/x/deposit/keeper/msg_server.go index 4cf9e312c..3bf9523e2 100644 --- a/x/deposit/keeper/msg_server.go +++ b/x/deposit/keeper/msg_server.go @@ -10,7 +10,7 @@ import ( var _ deposittype.MsgServer = &Keeper{} // UpdateParams set `exoCoreLzAppAddress` in the parameters of the deposit module, it can be used to verify whether the caller of precompile contracts is the `exoCoreLzApp` contract. -// This function should be triggered by the governance in the future,and we need to move this function to the `restaking_assets_manage` module to facilitate the query by other modules. +// This function should be triggered by the governance in the future,and we need to move this function to the `assets` module to facilitate the query by other modules. func (k Keeper) UpdateParams(ctx context.Context, params *deposittype.MsgUpdateParams) (*deposittype.MsgUpdateParamsResponse, error) { c := sdk.UnwrapSDKContext(ctx) err := k.SetParams(c, ¶ms.Params) diff --git a/x/deposit/types/deposit.pb.go b/x/deposit/types/deposit.pb.go index 7b6c68395..4ba9caff9 100644 --- a/x/deposit/types/deposit.pb.go +++ b/x/deposit/types/deposit.pb.go @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the restaking_assets_manage module's genesis state. +// GenesisState defines the deposit module's genesis state. type Params struct { // exocore_lz_app_address is the address of the exocore lz app. ExoCoreLzAppAddress string `protobuf:"bytes,1,opt,name=exocore_lz_app_address,json=exocoreLzAppAddress,proto3" json:"exocore_lz_app_address,omitempty"` diff --git a/x/evm/keeper/precompiles.go b/x/evm/keeper/precompiles.go index 995470233..a26d157bc 100644 --- a/x/evm/keeper/precompiles.go +++ b/x/evm/keeper/precompiles.go @@ -3,7 +3,7 @@ package keeper import ( "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" + stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" withdrawKeeper "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" diff --git a/x/operator/client/cli/query.go b/x/operator/client/cli/query.go index 2e4ad5e2d..6f41f7055 100644 --- a/x/operator/client/cli/query.go +++ b/x/operator/client/cli/query.go @@ -14,7 +14,7 @@ import ( func GetQueryCmd() *cobra.Command { cmd := &cobra.Command{ Use: operatortypes.ModuleName, - Short: "Querying commands for the delegation module", + Short: "Querying commands for the operator module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/x/operator/client/cli/tx.go b/x/operator/client/cli/tx.go index 752b701a3..31caa4171 100644 --- a/x/operator/client/cli/tx.go +++ b/x/operator/client/cli/tx.go @@ -18,7 +18,7 @@ import ( func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ Use: operatortypes.ModuleName, - Short: "delegation subcommands", + Short: "operator subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 36ab35301..f146a733e 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -2,9 +2,9 @@ package keeper import ( sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -80,7 +80,7 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { stakerShare: make(map[string]sdkmath.LegacyDec, 0), } stakerShareHandleFunc := func(stakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error { - UpdateShareOfStakerAndOperator(sharedParameter, assetID, stakerID, operatorAddr, state.CanBeUndelegatedAmount) + UpdateShareOfStakerAndOperator(sharedParameter, assetID, stakerID, operatorAddr, state.UndelegatableAmount) return nil } err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) @@ -88,8 +88,8 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { return err } - operatorShareHandleFunc := func(operatorAddr, assetID string, state *types.OperatorSingleAssetOrChangeInfo) error { - UpdateShareOfStakerAndOperator(sharedParameter, assetID, "", operatorAddr, state.OperatorOwnAmountOrWantChangeValue) + operatorShareHandleFunc := func(operatorAddr, assetID string, state *types.OperatorSingleAssetInfo) error { + UpdateShareOfStakerAndOperator(sharedParameter, assetID, "", operatorAddr, state.OperatorOwnAmount) return nil } err = k.restakingStateKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index 6aed677c9..037c559b4 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -3,11 +3,12 @@ package keeper import ( "fmt" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -21,14 +22,14 @@ func (k *Keeper) UpdateOperatorShare(ctx sdk.Context, avsAddr, operatorAddr stri if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") } - key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &totalValue) } - err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + err := assetstype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) if err != nil { return err } @@ -43,7 +44,7 @@ func (k *Keeper) DeleteOperatorShare(ctx sdk.Context, avsAddr, operatorAddr stri if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") } - key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) store.Delete(key) return nil @@ -56,7 +57,7 @@ func (k *Keeper) GetOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) if operatorAddr == "" { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetOperatorShare the operatorAddr is empty") } - key = restakingtype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) isExist := store.Has(key) if !isExist { @@ -79,7 +80,7 @@ func (k *Keeper) UpdateAVSShare(ctx sdk.Context, avsAddr string, opAmount sdkmat value := store.Get(key) k.cdc.MustUnmarshal(value, &totalValue) } - err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + err := assetstype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) if err != nil { return err } @@ -98,7 +99,7 @@ func (k *Keeper) BatchUpdateShareForAVSAndOperator(ctx sdk.Context, avsOperatorC k.cdc.MustUnmarshal(value, &totalValue) } tmpOpAmount := opAmount - err := restakingtype.UpdateAssetDecValue(&totalValue.Amount, &tmpOpAmount) + err := assetstype.UpdateAssetDecValue(&totalValue.Amount, &tmpOpAmount) if err != nil { return err } @@ -122,17 +123,17 @@ func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec return ret.Amount, nil } -func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.OptedInAssetState) error { +func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.OptedInAssetStateChange) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - if changeState.Amount.IsNil() && changeState.Value.IsNil() { + if changeState.ChangeForAmount.IsNil() && changeState.ChangeForValue.IsNil() { return nil } // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.ErrOperatorAddr + return assetstype.ErrOperatorAddr } - stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) + stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) optedInAssetState := operatortypes.OptedInAssetState{ Amount: sdkmath.NewInt(0), Value: sdkmath.LegacyNewDec(0), @@ -143,12 +144,12 @@ func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operator k.cdc.MustUnmarshal(value, &optedInAssetState) } - err = restakingtype.UpdateAssetValue(&optedInAssetState.Amount, &changeState.Amount) + err = assetstype.UpdateAssetValue(&optedInAssetState.Amount, &changeState.ChangeForAmount) if err != nil { return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Amount error") } - err = restakingtype.UpdateAssetDecValue(&optedInAssetState.Value, &changeState.Value) + err = assetstype.UpdateAssetDecValue(&optedInAssetState.Value, &changeState.ChangeForValue) if err != nil { return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Value error") } @@ -164,16 +165,16 @@ func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAdd // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.ErrOperatorAddr + return assetstype.ErrOperatorAddr } - stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) + stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) store.Delete(stateKey) return nil } func (k *Keeper) GetAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) (changeState *operatortypes.OptedInAssetState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - stateKey := restakingtype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) + stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) isExit := store.Has(stateKey) optedInAssetState := operatortypes.OptedInAssetState{} if isExit { @@ -191,7 +192,7 @@ func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - keys, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 3) + keys, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 3) if err != nil { return err } @@ -212,14 +213,14 @@ func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA return nil } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) + key := assetstype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) optedInValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &optedInValue) } - err := restakingtype.UpdateAssetDecValue(&optedInValue.Amount, &opAmount) + err := assetstype.UpdateAssetDecValue(&optedInValue.Amount, &opAmount) if err != nil { return err } @@ -245,7 +246,7 @@ func (k *Keeper) BatchSetStakerShare(ctx sdk.Context, newValues map[string]sdkma func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) + key := assetstype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) store.Delete(key) return nil } @@ -253,7 +254,7 @@ func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) var ret operatortypes.DecValueField - key := restakingtype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) + key := assetstype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) isExit := store.Has(key) if !isExit { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerShare: key is %s", key)) @@ -270,7 +271,7 @@ func (k *Keeper) GetStakerByAVSOperator(ctx sdk.Context, _, _ string) (map[strin iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - keys, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 3) + keys, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 3) if err != nil { return nil, err } diff --git a/x/operator/keeper/dogfood.go b/x/operator/keeper/dogfood.go index ed49c657a..ab2dc63eb 100644 --- a/x/operator/keeper/dogfood.go +++ b/x/operator/keeper/dogfood.go @@ -10,8 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" - restakingtypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" ) @@ -41,7 +41,7 @@ func (k *Keeper) SetOperatorConsKeyForChainID( } // check if the chain id is valid if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - return restakingtypes.ErrNoAppChainKey + return assetstypes.ErrNoAppChainKey } // if opting out, do not allow key replacement if k.IsOperatorOptingOutFromChainID(ctx, opAccAddr, chainID) { @@ -176,7 +176,7 @@ func (k *Keeper) GetOperatorPrevConsKeyForChainID( return } if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - err = restakingtypes.ErrNoAppChainKey + err = assetstypes.ErrNoAppChainKey return } // do not check for slashing here @@ -217,7 +217,7 @@ func (k *Keeper) GetOperatorConsKeyForChainID( return } if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - err = restakingtypes.ErrNoAppChainKey + err = assetstypes.ErrNoAppChainKey return } // do not check for slashing, since this function will be used to update voting power even @@ -377,7 +377,7 @@ func (k *Keeper) InitiateOperatorOptOutFromChainID( } // check if the chain id is valid if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - return restakingtypes.ErrNoAppChainKey + return assetstypes.ErrNoAppChainKey } found, key, err := k.getOperatorConsKeyForChainID(ctx, opAccAddr, chainID) if err != nil { diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index a1ec38314..d86edeb0a 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -18,8 +18,8 @@ func (k *Keeper) GetOperatorInfo(ctx context.Context, req *operatortypes.GetOper // QueryOperatorConsKeyForChainID add for dogfood func (k *Keeper) QueryOperatorConsKeyForChainID( goCtx context.Context, - req *operatortypes.QueryOperatorConsKeyForChainIDRequest, -) (*operatortypes.QueryOperatorConsKeyForChainIDResponse, error) { + req *operatortypes.QueryOperatorConsKeyRequest, +) (*operatortypes.QueryOperatorConsKeyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Addr) if err != nil { @@ -34,7 +34,7 @@ func (k *Keeper) QueryOperatorConsKeyForChainID( if !found { return nil, errors.New("no key assigned") } - return &operatortypes.QueryOperatorConsKeyForChainIDResponse{ + return &operatortypes.QueryOperatorConsKeyResponse{ PublicKey: key, }, nil } diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 8319f8c52..2f30d64fa 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -4,8 +4,8 @@ import ( "context" sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/keeper" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 338312d28..cd8cd9858 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -3,10 +3,11 @@ package keeper import ( "fmt" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + errorsmod "cosmossdk.io/errors" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -60,9 +61,9 @@ func (k *Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.ErrOperatorAddr + return assetstype.ErrOperatorAddr } - infoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr) + infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) bz := k.cdc.MustMarshal(info) store.Set(infoKey, bz) @@ -75,7 +76,7 @@ func (k *Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (in return nil, errorsmod.Wrap(err, "GetOptedInfo: error occurred when parse acc address from Bech32") } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) - infoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr) + infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) ifExist := store.Has(infoKey) if !ifExist { return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %suite", opAccAddr)) @@ -107,7 +108,7 @@ func (k *Keeper) GetOptedInAVSForOperator(ctx sdk.Context, operatorAddr string) avsList := make([]string, 0) for ; iterator.Valid(); iterator.Next() { - keys, err := restakingtype.ParseJoinedStoreKey(iterator.Key(), 2) + keys, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { return nil, err } diff --git a/x/operator/keeper/operator_info_test.go b/x/operator/keeper/operator_info_test.go index d3609e773..6c4109d35 100644 --- a/x/operator/keeper/operator_info_test.go +++ b/x/operator/keeper/operator_info_test.go @@ -1,8 +1,8 @@ package keeper_test import ( + "github.com/ExocoreNetwork/exocore/x/assets/types" operatortype "github.com/ExocoreNetwork/exocore/x/operator/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" ) func (suite *OperatorTestSuite) TestOperatorInfo() { diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 8c5fdf5ae..d3630931d 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -3,25 +3,29 @@ package keeper import ( "fmt" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" ) +// UpdateOperatorSlashInfo This is a function to store the slash info related to an operator +// The stored state is: operator + '/' + AVSAddr + '/' + slashId -> OperatorSlashInfo +// Now this function will be called by `slash` function implemented in 'state_update.go' when there is a slash event occurs. func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, slashID string, slashInfo operatortypes.OperatorSlashInfo) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return restakingtype.ErrOperatorAddr + return assetstype.ErrOperatorAddr } - slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) + slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) if store.Has(slashInfoKey) { return errorsmod.Wrap(operatortypes.ErrSlashInfoExist, fmt.Sprintf("slashInfoKey:%suite", slashInfoKey)) } @@ -29,8 +33,8 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, if slashInfo.SlashContract == "" { return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err slashContract:%suite", slashInfo.SlashContract)) } - if slashInfo.OccurredHeight > slashInfo.SlashHeight { - return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SlashHeight:%v,OccurredHeight:%v", slashInfo.SlashHeight, slashInfo.OccurredHeight)) + if slashInfo.EventHeight > slashInfo.SubmittedHeight { + return errorsmod.Wrap(operatortypes.ErrSlashInfo, fmt.Sprintf("err SubmittedHeight:%v,EventHeight:%v", slashInfo.SubmittedHeight, slashInfo.EventHeight)) } if slashInfo.SlashProportion.IsNil() || slashInfo.SlashProportion.IsNegative() || slashInfo.SlashProportion.GT(sdkmath.LegacyNewDec(1)) { @@ -43,9 +47,12 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, return nil } +// GetOperatorSlashInfo This is a function to retrieve the slash info related to an operator +// Now this function hasn't been called. In the future, it might be called by the grpc query. +// Additionally, it might be used when implementing the veto function func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashID string) (changeState *operatortypes.OperatorSlashInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) - slashInfoKey := restakingtype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) + slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) isExit := store.Has(slashInfoKey) operatorSlashInfo := operatortypes.OperatorSlashInfo{} if isExit { @@ -57,7 +64,17 @@ func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, sl return &operatorSlashInfo, nil } -func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator string, completeHeight uint64, opAmount sdkmath.Int) error { +// UpdateSlashAssetsState This is a function to update the assets amount that need to be slashed +// The stored state is: +// KeyPrefixSlashAssetsState key-value: +// processedSlashHeight + '/' + assetID -> SlashAmount +// processedSlashHeight + '/' + assetID + '/' + stakerID -> SlashAmount +// processedSlashHeight + '/' + assetID + '/' + operatorAddr -> SlashAmount +// The slashed assets info won't be sent to the client chain immediately after the slash event being processed, env if +// the asset amounts of related operator and staker have been decreased. This is because we need to wait a veto period. +// The state updated by this function will be sent to the client chain once the veto period has expired. +// This function will be called by `SlashStaker` and `SlashOperator` implemented in the 'state_update.go' file. +func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator string, processedHeight uint64, opAmount sdkmath.Int) error { if opAmount.IsNil() || opAmount.IsZero() { return nil } @@ -67,26 +84,26 @@ func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperat return errorsmod.Wrap(operatortypes.ErrParameterInvalid, fmt.Sprintf("assetID:%suite,stakerOrOperator:%suite", assetID, stakerOrOperator)) } - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID, stakerOrOperator) - slashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + key = assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(processedHeight), assetID, stakerOrOperator) + slashAmount := assetstype.ValueField{Amount: sdkmath.NewInt(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &slashAmount) } - err := restakingtype.UpdateAssetValue(&slashAmount.Amount, &opAmount) + err := assetstype.UpdateAssetValue(&slashAmount.Amount, &opAmount) if err != nil { return err } bz := k.cdc.MustMarshal(&slashAmount) store.Set(key, bz) - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID) - totalSlashAmount := restakingtype.ValueField{Amount: sdkmath.NewInt(0)} + key = assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(processedHeight), assetID) + totalSlashAmount := assetstype.ValueField{Amount: sdkmath.NewInt(0)} if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &totalSlashAmount) } - err = restakingtype.UpdateAssetValue(&totalSlashAmount.Amount, &opAmount) + err = assetstype.UpdateAssetValue(&totalSlashAmount.Amount, &opAmount) if err != nil { return err } @@ -95,15 +112,19 @@ func (k *Keeper) UpdateSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperat return nil } -func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator string, completeHeight uint64) (sdkmath.Int, error) { +// GetSlashAssetsState This is a function to retrieve the assets awaiting transfer to the client chain for slashing. +// Now this function hasn't been called, it might be called by the grpc query in the future. +// Additionally, this function might be called in the schedule function `EndBlock` to send the slash info to client chain. +// todo: It's to be determined about how to send the slash info to client chain. If we send them in `EndBlock`, then the native code needs to call the gateway contract deployed in exocore. This seems a little bit odd. +func (k *Keeper) GetSlashAssetsState(ctx sdk.Context, assetID, stakerOrOperator string, processedHeight uint64) (sdkmath.Int, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixSlashAssetsState) var key []byte if stakerOrOperator == "" { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID) + key = assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(processedHeight), assetID) } else { - key = restakingtype.GetJoinedStoreKey(hexutil.EncodeUint64(completeHeight), assetID, stakerOrOperator) + key = assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(processedHeight), assetID, stakerOrOperator) } - var ret restakingtype.ValueField + var ret assetstype.ValueField isExit := store.Has(key) if !isExit { return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetSlashAssetsState: key is %suite", key)) diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index 185cb82ad..06fc12d93 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -6,9 +6,9 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" + types2 "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/operator/types" - types2 "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -60,9 +60,9 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, op } // UpdateStateForAsset - changeState := types.OptedInAssetState{ - Amount: opAmount, - Value: opUSDValue, + changeState := types.OptedInAssetStateChange{ + ChangeForAmount: opAmount, + ChangeForValue: opUSDValue, } err = k.UpdateStateForAsset(ctx, assetID, avs, operatorAddr, changeState) if err != nil { @@ -125,14 +125,14 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr PriceDecimal: decimal, Decimal: assetInfo.AssetBasicInfo.Decimals, } - assetUSDValue := CalculateShare(operatorAssetState.TotalAmountOrWantChangeValue, price, assetInfo.AssetBasicInfo.Decimals, decimal) - operatorUSDValue := CalculateShare(operatorAssetState.OperatorOwnAmountOrWantChangeValue, price, assetInfo.AssetBasicInfo.Decimals, decimal) + assetUSDValue := CalculateShare(operatorAssetState.TotalAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) + operatorUSDValue := CalculateShare(operatorAssetState.OperatorOwnAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(operatorUSDValue) // UpdateStateForAsset - changeState := types.OptedInAssetState{ - Amount: operatorAssetState.TotalAmountOrWantChangeValue, - Value: assetUSDValue, + changeState := types.OptedInAssetStateChange{ + ChangeForAmount: operatorAssetState.TotalAmount, + ChangeForValue: assetUSDValue, } err = k.UpdateStateForAsset(ctx, assetID, avsAddr, operatorAddress.String(), changeState) if err != nil { @@ -168,7 +168,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr for stakerID, assetState := range relatedAssetsState { stakerAssetsUSDValue := sdkmath.LegacyNewDec(0) for assetID, amount := range assetState { - singleAssetUSDValue := CalculateShare(amount.CanBeUndelegatedAmount, assetInfoRecord[assetID].Price, assetInfoRecord[assetID].Decimal, assetInfoRecord[assetID].PriceDecimal) + singleAssetUSDValue := CalculateShare(amount.UndelegatableAmount, assetInfoRecord[assetID].Price, assetInfoRecord[assetID].Decimal, assetInfoRecord[assetID].PriceDecimal) stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) } @@ -322,12 +322,12 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc if _, exist := ret.slashStakerInfo[stakerID]; !exist { ret.slashStakerInfo[stakerID] = make(map[string]*slashAmounts, 0) } - shouldSlashAmount := slashProportion.MulInt(historyState.CanBeUndelegatedAmount).TruncateInt() - if curState.CanBeUndelegatedAmount.LT(shouldSlashAmount) { - ret.slashStakerInfo[stakerID][assetID].AmountFromOptedIn = curState.CanBeUndelegatedAmount - remainShouldSlash := shouldSlashAmount.Sub(curState.CanBeUndelegatedAmount) - if curState.CanBeUndelegatedAfterSlash.LT(remainShouldSlash) { - ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = curState.CanBeUndelegatedAfterSlash + shouldSlashAmount := slashProportion.MulInt(historyState.UndelegatableAmount).TruncateInt() + if curState.UndelegatableAmount.LT(shouldSlashAmount) { + ret.slashStakerInfo[stakerID][assetID].AmountFromOptedIn = curState.UndelegatableAmount + remainShouldSlash := shouldSlashAmount.Sub(curState.UndelegatableAmount) + if curState.UndelegatableAfterSlash.LT(remainShouldSlash) { + ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = curState.UndelegatableAfterSlash } else { ret.slashStakerInfo[stakerID][assetID].AmountFromUnbonding = remainShouldSlash } @@ -342,12 +342,12 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc // calculate the actual slash amount for operator for assetID, curAssetState := range currentOperatorAssetsState { if historyAssetState, ok := historyOperatorAssetsState[assetID]; ok { - shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorOwnAmountOrWantChangeValue).TruncateInt() - if curAssetState.OperatorOwnAmountOrWantChangeValue.LT(shouldSlashAmount) { - ret.slashOperatorInfo[assetID].AmountFromOptedIn = curAssetState.OperatorOwnAmountOrWantChangeValue - remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmountOrWantChangeValue) - if curAssetState.OperatorCanUnbondAfterSlash.LT(remainShouldSlash) { - ret.slashOperatorInfo[assetID].AmountFromUnbonding = curAssetState.OperatorCanUnbondAfterSlash + shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorOwnAmount).TruncateInt() + if curAssetState.OperatorOwnAmount.LT(shouldSlashAmount) { + ret.slashOperatorInfo[assetID].AmountFromOptedIn = curAssetState.OperatorOwnAmount + remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmount) + if curAssetState.OperatorUnbondableAmountAfterSlash.LT(remainShouldSlash) { + ret.slashOperatorInfo[assetID].AmountFromUnbonding = curAssetState.OperatorUnbondableAmountAfterSlash } else { ret.slashOperatorInfo[assetID].AmountFromUnbonding = remainShouldSlash } @@ -359,15 +359,15 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc return ret, nil } -func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, executeHeight uint64) error { +func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, slashStakerInfo map[string]map[string]*slashAmounts, processedHeight uint64) error { for stakerID, slashAssets := range slashStakerInfo { for assetID, slashInfo := range slashAssets { // handle the state that needs to be updated when slashing both opted-in and unbonding assets // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[operatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanBeUndelegatedAmount: slashInfo.AmountFromOptedIn.Neg(), - CanBeUndelegatedAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + UndelegatableAmount: slashInfo.AmountFromOptedIn.Neg(), + UndelegatableAfterSlash: slashInfo.AmountFromUnbonding.Neg(), } err := k.delegationKeeper.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -380,22 +380,22 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) // update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: slashSumValue.Neg(), + err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: slashSumValue.Neg(), }) if err != nil { return err } // Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetID, stakerID, executeHeight, slashSumValue) + err = k.UpdateSlashAssetsState(ctx, assetID, stakerID, processedHeight, slashSumValue) if err != nil { return err } // handle the state that needs to be updated when slashing opted-in assets - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), + err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ + ChangeForTotalAmount: slashInfo.AmountFromOptedIn.Neg(), }) if err != nil { return err @@ -410,20 +410,20 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl return nil } -func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, executeHeight uint64) error { +func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashOperatorInfo map[string]*slashAmounts, processedHeight uint64) error { for assetID, slashInfo := range slashOperatorInfo { slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) // handle the state that needs to be updated when slashing both opted-in and unbonding assets - err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: slashSumValue.Neg(), - OperatorOwnAmountOrWantChangeValue: slashInfo.AmountFromOptedIn.Neg(), - OperatorCanUnbondAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ + ChangeForTotalAmount: slashSumValue.Neg(), + ChangeForOperatorOwn: slashInfo.AmountFromOptedIn.Neg(), + ChangeForUnbondableAfterSlash: slashInfo.AmountFromUnbonding.Neg(), }) if err != nil { return err } // Record the slash information for scheduled tasks and send it to the client chain once the veto duration expires. - err = k.UpdateSlashAssetsState(ctx, assetID, operatorAddress.String(), executeHeight, slashSumValue) + err = k.UpdateSlashAssetsState(ctx, assetID, operatorAddress.String(), processedHeight, slashSumValue) if err != nil { return err } @@ -465,10 +465,10 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, // todo: recording the slash event might be moved to the slash module slashInfo := types.OperatorSlashInfo{ SlashContract: slashContract, - SlashHeight: height, - OccurredHeight: occurredSateHeight, + SubmittedHeight: height, + EventHeight: occurredSateHeight, SlashProportion: slashProportion, - ExecuteHeight: height + types.SlashVetoDuration, + ProcessedHeight: height + types.SlashVetoDuration, } err = k.UpdateOperatorSlashInfo(ctx, operatorAddress.String(), avsAddr, slashID, slashInfo) if err != nil { @@ -481,12 +481,12 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, return err } // #nosec G701 - err = k.SlashStaker(ctx, operatorAddress, assetsSlashInfo.slashStakerInfo, uint64(slashInfo.ExecuteHeight)) + err = k.SlashStaker(ctx, operatorAddress, assetsSlashInfo.slashStakerInfo, uint64(slashInfo.ProcessedHeight)) if err != nil { return err } // #nosec G701 - err = k.SlashOperator(ctx, operatorAddress, assetsSlashInfo.slashOperatorInfo, uint64(slashInfo.ExecuteHeight)) + err = k.SlashOperator(ctx, operatorAddress, assetsSlashInfo.slashOperatorInfo, uint64(slashInfo.ProcessedHeight)) if err != nil { return err } diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go index 09e68b4b1..10be7bf59 100644 --- a/x/operator/keeper/state_update_test.go +++ b/x/operator/keeper/state_update_test.go @@ -4,11 +4,11 @@ import ( "strings" sdkmath "cosmossdk.io/math" + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" - restakingTypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) @@ -36,12 +36,12 @@ func (suite *OperatorTestSuite) prepare() { suite.depositAmount = sdkmath.NewInt(100) suite.delegationAmount = sdkmath.NewInt(50) suite.updatedAmountForOptIn = sdkmath.NewInt(20) - suite.stakerID, suite.assetID = restakingTypes.GetStakeIDAndAssetID(suite.clientChainLzID, suite.Address[:], suite.assetAddr[:]) + suite.stakerID, suite.assetID = assetstypes.GetStakeIDAndAssetID(suite.clientChainLzID, suite.Address[:], suite.assetAddr[:]) // staking assets depositParam := &keeper.DepositParams{ ClientChainLzID: suite.clientChainLzID, - Action: restakingTypes.Deposit, + Action: assetstypes.Deposit, StakerAddress: suite.Address[:], OpAmount: suite.depositAmount, } @@ -62,7 +62,7 @@ func (suite *OperatorTestSuite) prepare() { // delegate to operator delegationParam := &delegationKeeper.DelegationOrUndelegationParams{ ClientChainLzID: suite.clientChainLzID, - Action: restakingTypes.DelegateTo, + Action: assetstypes.DelegateTo, AssetsAddress: suite.assetAddr[:], OperatorAddress: suite.operatorAddr, StakerAddress: suite.Address[:], diff --git a/x/operator/types/general.go b/x/operator/types/general.go new file mode 100644 index 000000000..b6a0c3dd0 --- /dev/null +++ b/x/operator/types/general.go @@ -0,0 +1,9 @@ +package types + +import "cosmossdk.io/math" + +// OptedInAssetStateChange This is a struct to describe the desired change that matches with the OptedInAssetState +type OptedInAssetStateChange struct { + ChangeForAmount math.Int + ChangeForValue math.LegacyDec +} diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index e83781e8f..5cc396660 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -3,9 +3,10 @@ package types import ( "math" - sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // constants @@ -28,13 +29,6 @@ const ( UnbondingExpiration = 10 ) -// ModuleAddress is the native module address for EVM -var ModuleAddress common.Address - -func init() { - ModuleAddress = common.BytesToAddress(authtypes.NewModuleAddress(ModuleName).Bytes()) -} - const ( prefixOperatorInfo = iota + 1 @@ -85,14 +79,17 @@ var ( KeyPrefixOperatorSlashInfo = []byte{prefixOperatorSlashInfo} // KeyPrefixSlashAssetsState key-value: - // completeSlashHeight + '/' + assetID -> SlashAmount - // completeSlashHeight + '/' + assetID + '/' + stakerID -> SlashAmount - // completeSlashHeight + '/' + assetID + '/' + operatorAddr -> SlashAmount + // processedSlashHeight + '/' + assetID -> SlashAmount + // processedSlashHeight + '/' + assetID + '/' + stakerID -> SlashAmount + // processedSlashHeight + '/' + assetID + '/' + operatorAddr -> SlashAmount KeyPrefixSlashAssetsState = []byte{prefixSlashAssetsState} ) -func KeyPrefix(p string) []byte { - return []byte(p) +// ModuleAddress is the native module address for EVM +var ModuleAddress common.Address + +func init() { + ModuleAddress = common.BytesToAddress(authtypes.NewModuleAddress(ModuleName).Bytes()) } func AddrAndChainIDKey(prefix byte, addr sdk.AccAddress, chainID string) []byte { diff --git a/x/operator/types/query.pb.go b/x/operator/types/query.pb.go index af21b9d31..df6dd2716 100644 --- a/x/operator/types/query.pb.go +++ b/x/operator/types/query.pb.go @@ -77,26 +77,26 @@ func (m *GetOperatorInfoReq) GetOperatorAddr() string { return "" } -// QueryOperatorConsKeyForChainIDRequest is the request to obtain the consensus public key of the operator -type QueryOperatorConsKeyForChainIDRequest struct { +// QueryOperatorConsKeyRequest is the request to obtain the consensus public key of the operator +type QueryOperatorConsKeyRequest struct { // addr is the ACC address of operator Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` // chain_id is the id of the chain served by the operator ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (m *QueryOperatorConsKeyForChainIDRequest) Reset() { *m = QueryOperatorConsKeyForChainIDRequest{} } -func (m *QueryOperatorConsKeyForChainIDRequest) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorConsKeyForChainIDRequest) ProtoMessage() {} -func (*QueryOperatorConsKeyForChainIDRequest) Descriptor() ([]byte, []int) { +func (m *QueryOperatorConsKeyRequest) Reset() { *m = QueryOperatorConsKeyRequest{} } +func (m *QueryOperatorConsKeyRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorConsKeyRequest) ProtoMessage() {} +func (*QueryOperatorConsKeyRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f91e795a3cecbdbf, []int{1} } -func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryOperatorConsKeyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOperatorConsKeyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOperatorConsKeyRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -106,52 +106,50 @@ func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Marshal(b []byte, determinis return b[:n], nil } } -func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest.Merge(m, src) +func (m *QueryOperatorConsKeyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyRequest.Merge(m, src) } -func (m *QueryOperatorConsKeyForChainIDRequest) XXX_Size() int { +func (m *QueryOperatorConsKeyRequest) XXX_Size() int { return m.Size() } -func (m *QueryOperatorConsKeyForChainIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest.DiscardUnknown(m) +func (m *QueryOperatorConsKeyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryOperatorConsKeyForChainIDRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryOperatorConsKeyRequest proto.InternalMessageInfo -func (m *QueryOperatorConsKeyForChainIDRequest) GetAddr() string { +func (m *QueryOperatorConsKeyRequest) GetAddr() string { if m != nil { return m.Addr } return "" } -func (m *QueryOperatorConsKeyForChainIDRequest) GetChainId() string { +func (m *QueryOperatorConsKeyRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -// QueryOperatorConsKeyForChainIDResponse is the response for QueryOperatorConsKeyForChainId -type QueryOperatorConsKeyForChainIDResponse struct { +// QueryOperatorConsKeyResponse is the response for QueryOperatorConsKeyRequest +type QueryOperatorConsKeyResponse struct { // public_key is the consensus public key of the operator PublicKey crypto.PublicKey `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key"` } -func (m *QueryOperatorConsKeyForChainIDResponse) Reset() { - *m = QueryOperatorConsKeyForChainIDResponse{} -} -func (m *QueryOperatorConsKeyForChainIDResponse) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorConsKeyForChainIDResponse) ProtoMessage() {} -func (*QueryOperatorConsKeyForChainIDResponse) Descriptor() ([]byte, []int) { +func (m *QueryOperatorConsKeyResponse) Reset() { *m = QueryOperatorConsKeyResponse{} } +func (m *QueryOperatorConsKeyResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOperatorConsKeyResponse) ProtoMessage() {} +func (*QueryOperatorConsKeyResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f91e795a3cecbdbf, []int{2} } -func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryOperatorConsKeyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryOperatorConsKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryOperatorConsKeyResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -161,19 +159,19 @@ func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Marshal(b []byte, determini return b[:n], nil } } -func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse.Merge(m, src) +func (m *QueryOperatorConsKeyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyResponse.Merge(m, src) } -func (m *QueryOperatorConsKeyForChainIDResponse) XXX_Size() int { +func (m *QueryOperatorConsKeyResponse) XXX_Size() int { return m.Size() } -func (m *QueryOperatorConsKeyForChainIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse.DiscardUnknown(m) +func (m *QueryOperatorConsKeyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryOperatorConsKeyForChainIDResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryOperatorConsKeyResponse proto.InternalMessageInfo -func (m *QueryOperatorConsKeyForChainIDResponse) GetPublicKey() crypto.PublicKey { +func (m *QueryOperatorConsKeyResponse) GetPublicKey() crypto.PublicKey { if m != nil { return m.PublicKey } @@ -182,45 +180,45 @@ func (m *QueryOperatorConsKeyForChainIDResponse) GetPublicKey() crypto.PublicKey func init() { proto.RegisterType((*GetOperatorInfoReq)(nil), "exocore.operator.v1.GetOperatorInfoReq") - proto.RegisterType((*QueryOperatorConsKeyForChainIDRequest)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIDRequest") - proto.RegisterType((*QueryOperatorConsKeyForChainIDResponse)(nil), "exocore.operator.v1.QueryOperatorConsKeyForChainIDResponse") + proto.RegisterType((*QueryOperatorConsKeyRequest)(nil), "exocore.operator.v1.QueryOperatorConsKeyRequest") + proto.RegisterType((*QueryOperatorConsKeyResponse)(nil), "exocore.operator.v1.QueryOperatorConsKeyResponse") } func init() { proto.RegisterFile("exocore/operator/v1/query.proto", fileDescriptor_f91e795a3cecbdbf) } var fileDescriptor_f91e795a3cecbdbf = []byte{ - // 486 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x30, - 0x18, 0x6e, 0xa6, 0xf1, 0x31, 0x03, 0x42, 0x32, 0x3b, 0x74, 0xd5, 0x94, 0x41, 0x24, 0xc6, 0x2e, - 0xd8, 0x5a, 0xb9, 0x81, 0x38, 0xb4, 0xe5, 0x43, 0xd5, 0x10, 0x1f, 0x99, 0xc4, 0x81, 0x4b, 0x94, - 0x26, 0x2f, 0x59, 0xd4, 0xd6, 0x6f, 0x6a, 0xbb, 0xa3, 0xd1, 0xb4, 0x0b, 0x77, 0x24, 0x24, 0xfe, - 0x0a, 0x3f, 0x62, 0xc7, 0x09, 0x2e, 0x9c, 0x10, 0x6a, 0xf7, 0x3b, 0x10, 0x8a, 0x13, 0x53, 0x54, - 0x2a, 0x40, 0xdc, 0x6c, 0xbf, 0xcf, 0x47, 0xfc, 0x3c, 0x0e, 0xd9, 0x82, 0x09, 0x46, 0x28, 0x81, - 0x63, 0x06, 0x32, 0xd4, 0x28, 0xf9, 0xe1, 0x2e, 0x1f, 0x8d, 0x41, 0xe6, 0x2c, 0x93, 0xa8, 0x91, - 0x5e, 0xab, 0x00, 0xcc, 0x02, 0xd8, 0xe1, 0x6e, 0x63, 0x3d, 0xc1, 0x04, 0xcd, 0x9c, 0x17, 0xab, - 0x12, 0xda, 0xd8, 0x4c, 0x10, 0x93, 0x01, 0xf0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cd, 0x5f, - 0xcb, 0xec, 0x41, 0xf3, 0xfb, 0x0a, 0x39, 0x67, 0xdc, 0xe8, 0x3b, 0x87, 0x5c, 0x5d, 0x08, 0x89, - 0xde, 0x62, 0x4b, 0x8a, 0x65, 0xbf, 0x47, 0xd9, 0xb8, 0xb1, 0x14, 0xf8, 0x2b, 0xca, 0x63, 0x6f, - 0x3f, 0x9f, 0x7d, 0x58, 0xd9, 0xa1, 0xdb, 0xdc, 0x16, 0x19, 0xc3, 0x00, 0x12, 0x53, 0x7f, 0x51, - 0xe5, 0xa2, 0xf7, 0x99, 0x43, 0xdc, 0x3f, 0xe7, 0x40, 0xef, 0x2e, 0x75, 0xfd, 0xa7, 0x52, 0x1a, - 0xf7, 0xfe, 0x8b, 0x5b, 0x06, 0xef, 0x75, 0xcd, 0x5d, 0x3a, 0xb4, 0xc5, 0x17, 0x1f, 0x65, 0x10, - 0x15, 0x00, 0xa1, 0x17, 0x6e, 0x54, 0x49, 0xf1, 0xa3, 0xa2, 0xfc, 0x63, 0x7e, 0x64, 0xbb, 0x3f, - 0x6e, 0x3f, 0x39, 0x99, 0xba, 0xce, 0xe9, 0xd4, 0x75, 0xbe, 0x4d, 0x5d, 0xe7, 0xfd, 0xcc, 0xad, - 0x9d, 0xce, 0xdc, 0xda, 0x97, 0x99, 0x5b, 0x7b, 0xd5, 0x4c, 0x52, 0x7d, 0x30, 0xee, 0xb1, 0x08, - 0x87, 0xfc, 0x61, 0x69, 0xf3, 0x14, 0xf4, 0x1b, 0x94, 0xfd, 0x9f, 0xae, 0x93, 0xf9, 0xcf, 0xa0, - 0xf3, 0x0c, 0x54, 0xef, 0xbc, 0x79, 0xef, 0x77, 0x7e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x83, 0xaa, - 0x6f, 0x9a, 0xb2, 0x03, 0x00, 0x00, + // 483 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0xa3, 0xf2, 0xd1, 0x05, 0x84, 0xb4, 0xf4, 0x90, 0x86, 0xc8, 0x05, 0x1f, 0xa0, 0x17, + 0x76, 0x49, 0x38, 0x73, 0x48, 0xc2, 0x87, 0xa2, 0x56, 0x7c, 0xb8, 0x37, 0x2e, 0x96, 0x63, 0x0f, + 0xae, 0x95, 0x64, 0xc7, 0xd9, 0xdd, 0x94, 0x58, 0x55, 0x2f, 0xdc, 0x91, 0x90, 0xf8, 0x2b, 0xfc, + 0x88, 0x1e, 0x23, 0xb8, 0x70, 0x42, 0x28, 0xe1, 0xc4, 0xaf, 0x40, 0x5e, 0xdb, 0x0d, 0x0a, 0x16, + 0x12, 0x37, 0xef, 0xec, 0x9b, 0xf7, 0x66, 0xde, 0x5b, 0x93, 0x3d, 0x98, 0x63, 0x80, 0x12, 0x38, + 0x26, 0x20, 0x7d, 0x8d, 0x92, 0x9f, 0xb4, 0xf9, 0x74, 0x06, 0x32, 0x65, 0x89, 0x44, 0x8d, 0xf4, + 0x56, 0x01, 0x60, 0x25, 0x80, 0x9d, 0xb4, 0x9b, 0xbb, 0x01, 0xaa, 0x09, 0x2a, 0xcf, 0x40, 0x78, + 0x7e, 0xc8, 0xf1, 0xcd, 0x56, 0x15, 0xa1, 0x9e, 0x17, 0xb7, 0x3b, 0x11, 0x46, 0x98, 0x77, 0x65, + 0x5f, 0x65, 0x4f, 0x84, 0x18, 0x8d, 0x81, 0xfb, 0x49, 0xcc, 0x7d, 0x21, 0x50, 0xfb, 0x3a, 0x46, + 0x71, 0xc1, 0xa8, 0x41, 0x84, 0x20, 0x27, 0xb1, 0xd0, 0x3c, 0x90, 0x69, 0xa2, 0x91, 0x8f, 0x20, + 0x2d, 0x6e, 0x9d, 0x23, 0x42, 0x9f, 0x83, 0x7e, 0x59, 0x88, 0x0d, 0xc4, 0x5b, 0x74, 0x61, 0x4a, + 0x1f, 0x93, 0x1b, 0xa5, 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0x4a, 0xd5, 0x7f, 0x04, 0xd0, 0x6c, 0xff, 0x47, + 0x47, 0x6e, 0xb2, 0x33, 0x30, 0x73, 0xf7, 0x69, 0x97, 0x6f, 0x3e, 0x50, 0x2f, 0xc8, 0x00, 0x42, + 0x6f, 0x4c, 0x5f, 0x10, 0xf0, 0xd3, 0x2c, 0xde, 0x33, 0x7e, 0x5a, 0xa6, 0x7b, 0xd6, 0x3b, 0x3c, + 0x5f, 0xda, 0xd6, 0x62, 0x69, 0x5b, 0x3f, 0x96, 0xb6, 0xf5, 0x71, 0x65, 0xd7, 0x16, 0x2b, 0xbb, + 0xf6, 0x6d, 0x65, 0xd7, 0xde, 0x74, 0xa2, 0x58, 0x1f, 0xcf, 0x86, 0x2c, 0xc0, 0x09, 0x7f, 0x9a, + 0xcb, 0xbc, 0x00, 0xfd, 0x0e, 0xe5, 0xe8, 0x42, 0x75, 0xbe, 0xfe, 0x31, 0x74, 0x9a, 0x80, 0x1a, + 0x5e, 0x36, 0xef, 0xf8, 0xd1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x78, 0x5d, 0x1f, 0xfe, 0x8a, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -238,7 +236,7 @@ type QueryClient interface { // OperatorInfo queries the operator information. GetOperatorInfo(ctx context.Context, in *GetOperatorInfoReq, opts ...grpc.CallOption) (*OperatorInfo, error) // QueryOperatorConsKeyForChainID queries the consensus public key for the operator - QueryOperatorConsKeyForChainID(ctx context.Context, in *QueryOperatorConsKeyForChainIDRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIDResponse, error) + QueryOperatorConsKeyForChainID(ctx context.Context, in *QueryOperatorConsKeyRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyResponse, error) } type queryClient struct { @@ -258,8 +256,8 @@ func (c *queryClient) GetOperatorInfo(ctx context.Context, in *GetOperatorInfoRe return out, nil } -func (c *queryClient) QueryOperatorConsKeyForChainID(ctx context.Context, in *QueryOperatorConsKeyForChainIDRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyForChainIDResponse, error) { - out := new(QueryOperatorConsKeyForChainIDResponse) +func (c *queryClient) QueryOperatorConsKeyForChainID(ctx context.Context, in *QueryOperatorConsKeyRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyResponse, error) { + out := new(QueryOperatorConsKeyResponse) err := c.cc.Invoke(ctx, "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainID", in, out, opts...) if err != nil { return nil, err @@ -272,7 +270,7 @@ type QueryServer interface { // OperatorInfo queries the operator information. GetOperatorInfo(context.Context, *GetOperatorInfoReq) (*OperatorInfo, error) // QueryOperatorConsKeyForChainID queries the consensus public key for the operator - QueryOperatorConsKeyForChainID(context.Context, *QueryOperatorConsKeyForChainIDRequest) (*QueryOperatorConsKeyForChainIDResponse, error) + QueryOperatorConsKeyForChainID(context.Context, *QueryOperatorConsKeyRequest) (*QueryOperatorConsKeyResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -282,7 +280,7 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) GetOperatorInfo(ctx context.Context, req *GetOperatorInfoReq) (*OperatorInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetOperatorInfo not implemented") } -func (*UnimplementedQueryServer) QueryOperatorConsKeyForChainID(ctx context.Context, req *QueryOperatorConsKeyForChainIDRequest) (*QueryOperatorConsKeyForChainIDResponse, error) { +func (*UnimplementedQueryServer) QueryOperatorConsKeyForChainID(ctx context.Context, req *QueryOperatorConsKeyRequest) (*QueryOperatorConsKeyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorConsKeyForChainID not implemented") } @@ -309,7 +307,7 @@ func _Query_GetOperatorInfo_Handler(srv interface{}, ctx context.Context, dec fu } func _Query_QueryOperatorConsKeyForChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOperatorConsKeyForChainIDRequest) + in := new(QueryOperatorConsKeyRequest) if err := dec(in); err != nil { return nil, err } @@ -321,7 +319,7 @@ func _Query_QueryOperatorConsKeyForChainID_Handler(srv interface{}, ctx context. FullMethod: "/exocore.operator.v1.Query/QueryOperatorConsKeyForChainID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryOperatorConsKeyForChainID(ctx, req.(*QueryOperatorConsKeyForChainIDRequest)) + return srv.(QueryServer).QueryOperatorConsKeyForChainID(ctx, req.(*QueryOperatorConsKeyRequest)) } return interceptor(ctx, in, info, handler) } @@ -373,7 +371,7 @@ func (m *GetOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryOperatorConsKeyForChainIDRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryOperatorConsKeyRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -383,12 +381,12 @@ func (m *QueryOperatorConsKeyForChainIDRequest) Marshal() (dAtA []byte, err erro return dAtA[:n], nil } -func (m *QueryOperatorConsKeyForChainIDRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOperatorConsKeyForChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -410,7 +408,7 @@ func (m *QueryOperatorConsKeyForChainIDRequest) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } -func (m *QueryOperatorConsKeyForChainIDResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryOperatorConsKeyResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -420,12 +418,12 @@ func (m *QueryOperatorConsKeyForChainIDResponse) Marshal() (dAtA []byte, err err return dAtA[:n], nil } -func (m *QueryOperatorConsKeyForChainIDResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOperatorConsKeyForChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryOperatorConsKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -467,7 +465,7 @@ func (m *GetOperatorInfoReq) Size() (n int) { return n } -func (m *QueryOperatorConsKeyForChainIDRequest) Size() (n int) { +func (m *QueryOperatorConsKeyRequest) Size() (n int) { if m == nil { return 0 } @@ -484,7 +482,7 @@ func (m *QueryOperatorConsKeyForChainIDRequest) Size() (n int) { return n } -func (m *QueryOperatorConsKeyForChainIDResponse) Size() (n int) { +func (m *QueryOperatorConsKeyResponse) Size() (n int) { if m == nil { return 0 } @@ -583,7 +581,7 @@ func (m *GetOperatorInfoReq) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOperatorConsKeyForChainIDRequest) Unmarshal(dAtA []byte) error { +func (m *QueryOperatorConsKeyRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -606,10 +604,10 @@ func (m *QueryOperatorConsKeyForChainIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOperatorConsKeyRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOperatorConsKeyRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -697,7 +695,7 @@ func (m *QueryOperatorConsKeyForChainIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOperatorConsKeyForChainIDResponse) Unmarshal(dAtA []byte) error { +func (m *QueryOperatorConsKeyResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -720,10 +718,10 @@ func (m *QueryOperatorConsKeyForChainIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOperatorConsKeyResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorConsKeyForChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOperatorConsKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/operator/types/query.pb.gw.go b/x/operator/types/query.pb.gw.go index 87ca8026e..df260f313 100644 --- a/x/operator/types/query.pb.gw.go +++ b/x/operator/types/query.pb.gw.go @@ -70,7 +70,7 @@ func local_request_Query_GetOperatorInfo_0(ctx context.Context, marshaler runtim } func request_Query_QueryOperatorConsKeyForChainID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorConsKeyForChainIDRequest + var protoReq QueryOperatorConsKeyRequest var metadata runtime.ServerMetadata var ( @@ -108,7 +108,7 @@ func request_Query_QueryOperatorConsKeyForChainID_0(ctx context.Context, marshal } func local_request_Query_QueryOperatorConsKeyForChainID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOperatorConsKeyForChainIDRequest + var protoReq QueryOperatorConsKeyRequest var metadata runtime.ServerMetadata var ( diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index c4531c05e..2d21736dc 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -72,6 +72,8 @@ func (m *DecValueField) XXX_DiscardUnknown() { var xxx_messageInfo_DecValueField proto.InternalMessageInfo // ClientChainEarningAddrList is the list of client chain earning addresses. +// Because the reward token provide by the AVS might be located at different client chain, the operator need to +// provide the different client chain address to receive the token rewards. type ClientChainEarningAddrList struct { // earning_info_list is the contents of ClientChainEarningAddrList. EarningInfoList []*ClientChainEarningAddrInfo `protobuf:"bytes,1,rep,name=earning_info_list,json=earningInfoList,proto3" json:"earning_info_list,omitempty"` @@ -249,9 +251,9 @@ func (m *OperatorInfo) GetClientChainEarningsAddr() *ClientChainEarningAddrList type OptedInfo struct { // slash_contract is the slash contract address of AVS opted-in by the operator SlashContract string `protobuf:"bytes,1,opt,name=slash_contract,json=slashContract,proto3" json:"slash_contract,omitempty"` - // opted_in_height is the height at which the operator opted in + // opted_in_height is the exocore block height at which the operator opted in OptedInHeight uint64 `protobuf:"varint,2,opt,name=opted_in_height,json=optedInHeight,proto3" json:"opted_in_height,omitempty"` - // opted_out_height is the height at which the operator opted out + // opted_out_height is the exocore block height at which the operator opted out OptedOutHeight uint64 `protobuf:"varint,3,opt,name=opted_out_height,json=optedOutHeight,proto3" json:"opted_out_height,omitempty"` } @@ -354,14 +356,14 @@ var xxx_messageInfo_OptedInAssetState proto.InternalMessageInfo type OperatorSlashInfo struct { // slash_contract is the address of slash contract SlashContract string `protobuf:"bytes,1,opt,name=slash_contract,json=slashContract,proto3" json:"slash_contract,omitempty"` - // slash_height is the height at which the slash event is submitted - SlashHeight int64 `protobuf:"varint,2,opt,name=slash_height,json=slashHeight,proto3" json:"slash_height,omitempty"` - // occurred_height is the height at which the slash event occurs - OccurredHeight int64 `protobuf:"varint,3,opt,name=occurred_height,json=occurredHeight,proto3" json:"occurred_height,omitempty"` - // execute_height is the height at which the slash event is executed - ExecuteHeight int64 `protobuf:"varint,4,opt,name=execute_height,json=executeHeight,proto3" json:"execute_height,omitempty"` - // is_veto is a flag to indicate if this slash is vetoed - IsVeto bool `protobuf:"varint,5,opt,name=is_veto,json=isVeto,proto3" json:"is_veto,omitempty"` + // submitted_height is the exocore block height at which the slash event is submitted + SubmittedHeight int64 `protobuf:"varint,2,opt,name=submitted_height,json=submittedHeight,proto3" json:"submitted_height,omitempty"` + // event_height is the exocore block height at which the slash event occurs + EventHeight int64 `protobuf:"varint,3,opt,name=event_height,json=eventHeight,proto3" json:"event_height,omitempty"` + // processed_height is the exocore block height at which the slash event is processed + ProcessedHeight int64 `protobuf:"varint,4,opt,name=processed_height,json=processedHeight,proto3" json:"processed_height,omitempty"` + // is_vetoed is a flag to indicate if this slash is vetoed + IsVetoed bool `protobuf:"varint,5,opt,name=is_vetoed,json=isVetoed,proto3" json:"is_vetoed,omitempty"` // slash_proportion is the proportion of assets that need to be slashed SlashProportion github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slash_proportion,json=slashProportion,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_proportion"` } @@ -406,30 +408,30 @@ func (m *OperatorSlashInfo) GetSlashContract() string { return "" } -func (m *OperatorSlashInfo) GetSlashHeight() int64 { +func (m *OperatorSlashInfo) GetSubmittedHeight() int64 { if m != nil { - return m.SlashHeight + return m.SubmittedHeight } return 0 } -func (m *OperatorSlashInfo) GetOccurredHeight() int64 { +func (m *OperatorSlashInfo) GetEventHeight() int64 { if m != nil { - return m.OccurredHeight + return m.EventHeight } return 0 } -func (m *OperatorSlashInfo) GetExecuteHeight() int64 { +func (m *OperatorSlashInfo) GetProcessedHeight() int64 { if m != nil { - return m.ExecuteHeight + return m.ProcessedHeight } return 0 } -func (m *OperatorSlashInfo) GetIsVeto() bool { +func (m *OperatorSlashInfo) GetIsVetoed() bool { if m != nil { - return m.IsVeto + return m.IsVetoed } return false } @@ -514,7 +516,9 @@ var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo // OptInToChainIDRequest defines the OptInToChainID request. type OptInToChainIDRequest struct { + // address is the operator address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // chain_id is the identifier for the chain that wants to opt in. ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` // there is no need to check for knowledge of the corresponding private key since this is ED25519 @@ -616,7 +620,9 @@ var xxx_messageInfo_OptInToChainIDResponse proto.InternalMessageInfo // InitiateOptOutFromChainIDRequest defines the InitiateOptOutFromChainID request. type InitiateOptOutFromChainIDRequest struct { + // address is the operator address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // chain_id is the identifier for the chain that wants to opt out. ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } @@ -723,69 +729,69 @@ func init() { func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 978 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xc6, 0x69, 0xd2, 0xbc, 0xf8, 0x23, 0x99, 0x94, 0xc6, 0xb1, 0xc0, 0x4e, 0xb6, 0x6a, - 0xb1, 0x02, 0xb1, 0xd5, 0x40, 0x91, 0x28, 0x1c, 0xc8, 0x47, 0x2b, 0x2c, 0x52, 0x8c, 0x36, 0x55, - 0x0f, 0x70, 0x58, 0x6d, 0x76, 0x5f, 0xd6, 0x23, 0xdb, 0x3b, 0xdb, 0x9d, 0x59, 0x13, 0xf7, 0x84, - 0x10, 0x07, 0x84, 0x38, 0x70, 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2, 0x19, 0x0e, 0x6e, 0xe6, - 0x92, 0xb4, 0x53, 0x3f, 0x66, 0x09, 0x2e, 0x9f, 0x0e, 0xad, 0x93, 0x42, 0x58, 0x6c, 0x06, 0x54, - 0x50, 0x47, 0x60, 0x2b, 0x14, 0xad, 0x58, 0x24, 0x95, 0xbe, 0x86, 0xfc, 0x4e, 0x25, 0x70, 0x05, - 0x96, 0xfe, 0x23, 0x8c, 0xca, 0x65, 0xf5, 0x9f, 0x31, 0xc8, 0xde, 0xe1, 0x3e, 0xe9, 0xc0, 0xcc, - 0x69, 0x11, 0x49, 0x6d, 0x64, 0xdf, 0x46, 0x0c, 0x4b, 0x79, 0xe5, 0x25, 0x99, 0x2a, 0x28, 0xe9, - 0x40, 0xe1, 0xa4, 0x34, 0x64, 0xf9, 0x8c, 0x11, 0x19, 0xd1, 0xba, 0xf2, 0x3b, 0x2f, 0xc5, 0xd5, - 0x5a, 0x67, 0xc8, 0x8f, 0x06, 0x2c, 0x9c, 0xa9, 0x03, 0xb9, 0x31, 0xd2, 0xd9, 0xff, 0xb5, 0xa7, - 0xfc, 0xc1, 0x79, 0xcd, 0xd2, 0x74, 0xca, 0x17, 0xbe, 0x39, 0xde, 0x5f, 0x36, 0xd6, 0xb7, 0x1e, - 0x1f, 0x56, 0x8c, 0x27, 0x87, 0x15, 0xe3, 0xcf, 0xc3, 0x8a, 0xf1, 0xd3, 0x51, 0x25, 0xf3, 0xe4, - 0xa8, 0x92, 0xf9, 0xfd, 0xa8, 0x92, 0xf9, 0x72, 0x75, 0x68, 0xaf, 0x6f, 0xa9, 0x20, 0x9f, 0xa3, - 0xf8, 0x9a, 0x45, 0x9d, 0x46, 0xfa, 0x99, 0xb4, 0xf7, 0xfc, 0x43, 0x49, 0xee, 0xf9, 0xce, 0x84, - 0xfc, 0x6e, 0x79, 0xef, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xa3, 0x9f, 0x77, 0x49, 0x09, - 0x00, 0x00, + // 984 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xc6, 0x49, 0x9a, 0x3c, 0x3b, 0xb1, 0x33, 0x29, 0x8d, 0x63, 0xc0, 0x4e, 0xb6, 0xa2, + 0x72, 0x03, 0xb1, 0xd5, 0x40, 0x91, 0x28, 0x1c, 0xc8, 0x8f, 0x56, 0x58, 0xa4, 0x18, 0x6d, 0xaa, + 0x1e, 0xe0, 0xb0, 0xda, 0xec, 0x4e, 0xd6, 0x23, 0xdb, 0x3b, 0xdb, 0x9d, 0xb1, 0x89, 0x7b, 0x42, + 0x88, 0x03, 0x42, 0x1c, 0xb8, 0x72, 0xeb, 0x9f, 0x90, 0x43, 0x2f, 0x1c, 0x10, 0xd7, 0x1e, 0xab, + 0x9e, 0x10, 0x87, 0x08, 0x25, 0x87, 0x70, 0x46, 0xe2, 0x8e, 0xe6, 0xc7, 0x26, 0x9b, 0x74, 0x43, + 0x1b, 0xb5, 0x97, 0xc4, 0xf3, 0xcd, 0xf7, 0xbe, 0xf7, 0xde, 0x37, 0x6f, 0x46, 0x0b, 0x6f, 0xe1, + 0x5d, 0xea, 0xd2, 0x08, 0x37, 0x68, 0x88, 0x23, 0x87, 0xd3, 0xa8, 0x31, 0xb8, 0xd1, 0xe0, 0xbb, + 0xf5, 0x30, 0xa2, 0x9c, 0xa2, 0x59, 0xbd, 0x5b, 0x8f, 0x77, 0xeb, 0x83, 0x1b, 0xe5, 0x19, 0xa7, + 0x47, 0x02, 0xda, 0x90, 0x7f, 0x15, 0xaf, 0x3c, 0xe7, 0x52, 0xd6, 0xa3, 0xac, 0xd1, 0x63, 0xbe, + 0x88, 0xef, 0x31, 0x5f, 0x6f, 0xcc, 0xab, 0x0d, 0x5b, 0xae, 0x1a, 0x6a, 0xa1, 0xb7, 0x2e, 0xfb, + 0xd4, 0xa7, 0x0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36, 0x10, 0x57, 0x4c, + 0x1d, 0xd5, 0x2b, 0xde, 0x29, 0x25, 0x65, 0xfe, 0x3a, 0x22, 0xea, 0x57, 0x47, 0xb1, 0x25, 0xbc, + 0xba, 0x88, 0x9d, 0xd7, 0xa1, 0xc8, 0xfa, 0xdb, 0x3d, 0xc2, 0x85, 0x55, 0x09, 0x3f, 0xb3, 0x56, + 0xe1, 0x18, 0xd7, 0x8e, 0x2e, 0x42, 0x1e, 0x0f, 0xc4, 0x6c, 0x24, 0xdc, 0xcc, 0x5a, 0x39, 0x89, + 0x69, 0xca, 0x75, 0x28, 0x86, 0x11, 0x75, 0x31, 0x63, 0x27, 0x6a, 0xa3, 0x4a, 0xed, 0x18, 0xd7, + 0xd4, 0x37, 0x61, 0x92, 0x30, 0x7b, 0x80, 0x39, 0xc5, 0x5e, 0x69, 0x6c, 0xc1, 0xa8, 0x4d, 0x58, + 0x13, 0x84, 0xdd, 0x97, 0x6b, 0xe4, 0x43, 0x51, 0x15, 0x1f, 0x46, 0x34, 0xa4, 0x11, 0x27, 0x34, + 0x28, 0x8d, 0xbf, 0x06, 0xc7, 0x0a, 0x52, 0xf5, 0xcb, 0x63, 0x51, 0xf3, 0x77, 0x03, 0x66, 0x2d, + 0xec, 0x13, 0xc6, 0x71, 0x14, 0x7b, 0x68, 0xe1, 0x07, 0xe8, 0x63, 0xc8, 0xef, 0x44, 0xb4, 0x27, + 0xe7, 0x1e, 0x33, 0xa6, 0x67, 0xa0, 0xf4, 0xec, 0xf1, 0xf2, 0x65, 0x2d, 0xb7, 0xaa, 0x76, 0xb6, + 0x78, 0x44, 0x02, 0xdf, 0xca, 0x09, 0xb6, 0x86, 0xd0, 0x4d, 0x18, 0x95, 0xb7, 0x6c, 0x44, 0xde, + 0x97, 0xc5, 0xd4, 0xfb, 0x92, 0xbc, 0xec, 0x96, 0xa4, 0xdf, 0xfa, 0xe0, 0x87, 0x47, 0xd5, 0xcc, + 0xdf, 0x8f, 0xaa, 0x99, 0xef,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, 0x2e, 0xa7, 0x3c, 0xf6, 0xed, + 0xd1, 0xde, 0x92, 0xb1, 0xb6, 0xf9, 0xe4, 0xa0, 0x62, 0x3c, 0x3d, 0xa8, 0x18, 0x7f, 0x1d, 0x54, + 0x8c, 0x9f, 0x0f, 0x2b, 0x99, 0xa7, 0x87, 0x95, 0xcc, 0x1f, 0x87, 0x95, 0xcc, 0x57, 0x2b, 0x89, + 0x7b, 0x7d, 0x5b, 0x25, 0xf9, 0x02, 0xf3, 0x6f, 0x68, 0xd4, 0x69, 0xc4, 0x1f, 0x4c, 0xbb, 0x27, + 0x9f, 0x4c, 0xf2, 0x9e, 0x6f, 0x8f, 0xcb, 0x2f, 0x98, 0xf7, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, + 0x22, 0x62, 0xdc, 0x98, 0x53, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1234,9 +1240,9 @@ func (m *OperatorSlashInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x32 - if m.IsVeto { + if m.IsVetoed { i-- - if m.IsVeto { + if m.IsVetoed { dAtA[i] = 1 } else { dAtA[i] = 0 @@ -1244,18 +1250,18 @@ func (m *OperatorSlashInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.ExecuteHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ExecuteHeight)) + if m.ProcessedHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProcessedHeight)) i-- dAtA[i] = 0x20 } - if m.OccurredHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.OccurredHeight)) + if m.EventHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.EventHeight)) i-- dAtA[i] = 0x18 } - if m.SlashHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SlashHeight)) + if m.SubmittedHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.SubmittedHeight)) i-- dAtA[i] = 0x10 } @@ -1581,16 +1587,16 @@ func (m *OperatorSlashInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.SlashHeight != 0 { - n += 1 + sovTx(uint64(m.SlashHeight)) + if m.SubmittedHeight != 0 { + n += 1 + sovTx(uint64(m.SubmittedHeight)) } - if m.OccurredHeight != 0 { - n += 1 + sovTx(uint64(m.OccurredHeight)) + if m.EventHeight != 0 { + n += 1 + sovTx(uint64(m.EventHeight)) } - if m.ExecuteHeight != 0 { - n += 1 + sovTx(uint64(m.ExecuteHeight)) + if m.ProcessedHeight != 0 { + n += 1 + sovTx(uint64(m.ProcessedHeight)) } - if m.IsVeto { + if m.IsVetoed { n += 2 } l = m.SlashProportion.Size() @@ -2438,9 +2444,9 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SubmittedHeight", wireType) } - m.SlashHeight = 0 + m.SubmittedHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2450,16 +2456,16 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashHeight |= int64(b&0x7F) << shift + m.SubmittedHeight |= int64(b&0x7F) << shift if b < 0x80 { break } } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OccurredHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EventHeight", wireType) } - m.OccurredHeight = 0 + m.EventHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2469,16 +2475,16 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OccurredHeight |= int64(b&0x7F) << shift + m.EventHeight |= int64(b&0x7F) << shift if b < 0x80 { break } } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecuteHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProcessedHeight", wireType) } - m.ExecuteHeight = 0 + m.ProcessedHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2488,14 +2494,14 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExecuteHeight |= int64(b&0x7F) << shift + m.ProcessedHeight |= int64(b&0x7F) << shift if b < 0x80 { break } } case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsVeto", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IsVetoed", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -2512,7 +2518,7 @@ func (m *OperatorSlashInfo) Unmarshal(dAtA []byte) error { break } } - m.IsVeto = bool(v != 0) + m.IsVetoed = bool(v != 0) case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashProportion", wireType) diff --git a/x/restaking_assets_manage/keeper/staker_asset_test.go b/x/restaking_assets_manage/keeper/staker_asset_test.go deleted file mode 100644 index 563166d72..000000000 --- a/x/restaking_assets_manage/keeper/staker_asset_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package keeper_test - -import ( - "fmt" - - "cosmossdk.io/math" - - restakingtype "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" -) - -func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { - stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") - ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") - ethUniInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(1000), - CanWithdrawAmountOrWantChangeValue: math.NewInt(1000), - } - - // test the initial storage of statker assets state - err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().NoError(err) - - // test that the retrieved value is correct - getInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) - suite.Require().NoError(err) - suite.Require().True(ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue.Equal(getInfo.TotalDepositAmountOrWantChangeValue)) - suite.Require().True(ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue.Equal(getInfo.CanWithdrawAmountOrWantChangeValue)) - - // test ErrInputUpdateStateIsZero - /* ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(0) - ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(0) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().Error(err, restakingtype.ErrInputUpdateStateIsZero)*/ - - // test valid increase of staker asset state - ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(500) - ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(500) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().NoError(err) - - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) - suite.Require().NoError(err) - suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1500))) - suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1500))) - - // test valid decrease of staker asset state - ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(-500) - ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(-500) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().NoError(err) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) - suite.Require().NoError(err) - suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) - suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) - - // test the decreased amount is bigger than original state - ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(-2000) - ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(-500) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().Error(err, restakingtype.ErrSubAmountIsMoreThanOrigin) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) - suite.Require().NoError(err) - suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) - suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) - - ethUniInitialChangeValue.TotalDepositAmountOrWantChangeValue = math.NewInt(-500) - ethUniInitialChangeValue.CanWithdrawAmountOrWantChangeValue = math.NewInt(-2000) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().Error(err, restakingtype.ErrSubAmountIsMoreThanOrigin) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) - suite.Require().NoError(err) - suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) - suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) - - // test the storage of multiple assets state - ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") - ethUsdtInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(2000), - CanWithdrawAmountOrWantChangeValue: math.NewInt(2000), - } - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) - suite.Require().NoError(err) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUsdtAssetID) - suite.Require().NoError(err) - suite.Require().True(getInfo.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(2000))) - suite.Require().True(getInfo.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(2000))) -} - -func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { - stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") - ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") - ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") - ethUniInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(1000), - CanWithdrawAmountOrWantChangeValue: math.NewInt(1000), - } - ethUsdtInitialChangeValue := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(2000), - CanWithdrawAmountOrWantChangeValue: math.NewInt(2000), - } - err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) - suite.Require().NoError(err) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) - suite.Require().NoError(err) - - // test get all assets state of staker - assetsInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) - suite.Require().NoError(err) - uniState, isExist := assetsInfo[ethUniAssetID] - suite.Require().True(isExist) - suite.Require().True(uniState.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(1000))) - suite.Require().True(uniState.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(1000))) - - usdtState, isExist := assetsInfo[ethUsdtAssetID] - suite.Require().True(isExist) - suite.Require().True(usdtState.TotalDepositAmountOrWantChangeValue.Equal(math.NewInt(2000))) - suite.Require().True(usdtState.CanWithdrawAmountOrWantChangeValue.Equal(math.NewInt(2000))) -} diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index ff7a64529..3d181bc41 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -10,7 +10,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" rtypes "github.com/ExocoreNetwork/exocore/x/reward/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -136,9 +136,9 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { } // TODO - changeAmount := types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: event.OpAmount, - CanWithdrawAmountOrWantChangeValue: event.OpAmount, + changeAmount := types.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: event.OpAmount, + ChangeForWithdrawable: event.OpAmount, } err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { diff --git a/x/reward/keeper/claim_reward_test.go b/x/reward/keeper/claim_reward_test.go index ec6bf8a70..4ceed1256 100644 --- a/x/reward/keeper/claim_reward_test.go +++ b/x/reward/keeper/claim_reward_test.go @@ -2,7 +2,7 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/reward/keeper" rewardtype "github.com/ExocoreNetwork/exocore/x/reward/types" "github.com/ethereum/go-ethereum/common" @@ -32,10 +32,10 @@ func (suite *RewardTestSuite) TestClaimWithdrawRequest() { stakerID, assetID := types.GetStakeIDAndAssetID(event.ClientChainLzID, event.WithdrawRewardAddress, event.AssetsAddress) info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: sdkmath.NewInt(10), + WithdrawableAmount: sdkmath.NewInt(10), + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) diff --git a/x/reward/keeper/keeper.go b/x/reward/keeper/keeper.go index cfbe7c064..5320bb94d 100644 --- a/x/reward/keeper/keeper.go +++ b/x/reward/keeper/keeper.go @@ -8,7 +8,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" + "github.com/ExocoreNetwork/exocore/x/assets/keeper" "github.com/ExocoreNetwork/exocore/x/reward/types" ) diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index d6c238791..fad342ac6 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -10,7 +10,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" rtypes "github.com/ExocoreNetwork/exocore/x/slash/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -189,9 +189,9 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { return errorsmod.Wrap(rtypes.ErrSlashAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } - changeAmount := types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: event.OpAmount.Neg(), - CanWithdrawAmountOrWantChangeValue: event.OpAmount.Neg(), + changeAmount := types.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: event.OpAmount.Neg(), + ChangeForWithdrawable: event.OpAmount.Neg(), } err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index 02aa73ed6..9b06e3efc 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -2,8 +2,8 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ExocoreNetwork/exocore/x/slash/keeper" slashtype "github.com/ExocoreNetwork/exocore/x/slash/types" "github.com/ethereum/go-ethereum/common" @@ -43,10 +43,10 @@ func (suite *SlashTestSuite) TestSlash() { stakerID, assetID := types.GetStakeIDAndAssetID(depositEvent.ClientChainLzID, depositEvent.StakerAddress, depositEvent.AssetsAddress) info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount, + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) // test the normal case @@ -58,10 +58,10 @@ func (suite *SlashTestSuite) TestSlash() { stakerID, assetID = types.GetStakeIDAndAssetID(event.ClientChainLzID, event.StakerAddress, event.AssetsAddress) info, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: sdkmath.NewInt(10), + WithdrawableAmount: sdkmath.NewInt(10), + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) diff --git a/x/slash/keeper/keeper.go b/x/slash/keeper/keeper.go index fedfe1286..3a214df9e 100644 --- a/x/slash/keeper/keeper.go +++ b/x/slash/keeper/keeper.go @@ -4,7 +4,7 @@ import ( "fmt" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" + "github.com/ExocoreNetwork/exocore/x/assets/keeper" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/x/todo.md b/x/todo.md index dc3254fc0..663628e4f 100644 --- a/x/todo.md +++ b/x/todo.md @@ -17,7 +17,7 @@ * the operator can only be registered once * delegateTo might require the approval of operator to grant the operator permission for selecting a staking user -## restaking_assets_manage +## assets * implement the registration of client chain and assets through the governance proposal instead of setting in the genesis diff --git a/x/withdraw/keeper/claim_withdraw.go b/x/withdraw/keeper/claim_withdraw.go index 1b4275352..cfdb0a31e 100644 --- a/x/withdraw/keeper/claim_withdraw.go +++ b/x/withdraw/keeper/claim_withdraw.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + "github.com/ExocoreNetwork/exocore/x/assets/types" withdrawtype "github.com/ExocoreNetwork/exocore/x/withdraw/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" @@ -128,9 +128,9 @@ func (k Keeper) Withdraw(ctx sdk.Context, params *WithdrawParams) error { if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(withdrawtype.ErrWithdrawAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } - changeAmount := types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount.Neg(), - CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), + changeAmount := types.StakerSingleAssetChangeInfo{ + ChangeForTotalDeposit: params.OpAmount.Neg(), + ChangeForWithdrawable: params.OpAmount.Neg(), } err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { diff --git a/x/withdraw/keeper/claim_withdraw_test.go b/x/withdraw/keeper/claim_withdraw_test.go index 670a832b1..1680aa9d1 100644 --- a/x/withdraw/keeper/claim_withdraw_test.go +++ b/x/withdraw/keeper/claim_withdraw_test.go @@ -2,8 +2,8 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/assets/types" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" withdrawtype "github.com/ExocoreNetwork/exocore/x/withdraw/types" "github.com/ethereum/go-ethereum/common" @@ -43,10 +43,10 @@ func (suite *WithdrawTestSuite) TestClaimWithdrawRequest() { stakerID, assetID := types.GetStakeIDAndAssetID(depositEvent.ClientChainLzID, depositEvent.StakerAddress, depositEvent.AssetsAddress) info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount, + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) // test the normal case event.AssetsAddress = usdtAddress[:] @@ -57,10 +57,10 @@ func (suite *WithdrawTestSuite) TestClaimWithdrawRequest() { stakerID, assetID = types.GetStakeIDAndAssetID(event.ClientChainLzID, event.WithdrawAddress, event.AssetsAddress) info, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUnbondingAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerSingleAssetInfo{ + TotalDepositAmount: sdkmath.NewInt(10), + WithdrawableAmount: sdkmath.NewInt(10), + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) diff --git a/x/withdraw/keeper/keeper.go b/x/withdraw/keeper/keeper.go index c08f2e2ee..8e0f4f0d4 100644 --- a/x/withdraw/keeper/keeper.go +++ b/x/withdraw/keeper/keeper.go @@ -3,8 +3,8 @@ package keeper import ( "fmt" + restakingkeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" depositkeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - restakingkeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" "github.com/ExocoreNetwork/exocore/x/withdraw/types" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" From 16dce4f892f918c4518473fd2fa5fe5e8396f977 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 12 Mar 2024 12:00:55 +0800 Subject: [PATCH 37/44] redefine change info struct and fix some lint problems --- proto/exocore/assets/v1/tx.proto | 3 +- x/assets/client/cli/tx.go | 4 +-- x/assets/keeper/operator_asset.go | 10 +++--- x/assets/keeper/staker_asset.go | 6 ++-- x/assets/keeper/staker_asset_test.go | 36 +++++++++---------- x/assets/types/general.go | 14 ++------ x/delegation/keeper/abci.go | 6 ++-- x/delegation/keeper/cross_chain_tx_process.go | 10 +++--- x/delegation/keeper/delegation_op_test.go | 14 ++++---- x/deposit/keeper/cross_chain_tx_process.go | 4 +-- x/operator/keeper/avs_operator_shares.go | 6 ++-- x/operator/keeper/state_update.go | 18 +++++----- x/operator/types/general.go | 7 +--- x/reward/keeper/claim_reward.go | 4 +-- x/slash/keeper/execute_slash.go | 4 +-- x/withdraw/keeper/claim_withdraw.go | 4 +-- 16 files changed, 68 insertions(+), 82 deletions(-) diff --git a/proto/exocore/assets/v1/tx.proto b/proto/exocore/assets/v1/tx.proto index 9f0fd3a69..dc831ab42 100644 --- a/proto/exocore/assets/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -161,7 +161,8 @@ message OperatorSingleAssetInfo { (gogoproto.nullable) = false ]; - // operator_unbondable_amount_after_slash is the amount that is owned by operator itself and can be unbonded after slash. + // operator_unbondable_amount_after_slash is the amount that is owned by operator itself + // and can be unbonded after slash. string operator_unbondable_amount_after_slash = 5 [ (cosmos_proto.scalar) = "cosmos.Int", diff --git a/x/assets/client/cli/tx.go b/x/assets/client/cli/tx.go index 8c2fd8ea2..aba570c42 100644 --- a/x/assets/client/cli/tx.go +++ b/x/assets/client/cli/tx.go @@ -57,7 +57,7 @@ func RegisterClientChain() *cobra.Command { if err != nil { return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[2])) } - addressLength, err := strconv.ParseUint(args[3], 10, 64) + addressLength, err := strconv.ParseUint(args[3], 10, 32) if err != nil { return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[3])) } @@ -106,7 +106,7 @@ func RegisterAsset() *cobra.Command { if err != nil { return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[5])) } - decimal, err := strconv.ParseUint(args[6], 10, 64) + decimal, err := strconv.ParseUint(args[6], 10, 32) if err != nil { return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[6])) } diff --git a/x/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go index 512d9896c..355dad5fc 100644 --- a/x/assets/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -67,23 +67,23 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre } // update all states of the specified operator asset - err = assetstype.UpdateAssetValue(&assetState.TotalAmount, &changeAmount.ChangeForTotalAmount) + err = assetstype.UpdateAssetValue(&assetState.TotalAmount, &changeAmount.TotalAmount) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.OperatorOwnAmount, &changeAmount.ChangeForOperatorOwn) + err = assetstype.UpdateAssetValue(&assetState.OperatorOwnAmount, &changeAmount.OperatorOwnAmount) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.ChangeForWaitUnbonding) + err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondingAmount, &changeAmount.ChangeForOperatorUnbonding) + err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondingAmount, &changeAmount.OperatorUnbondingAmount) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorUnbondingAmount error") } - err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondableAmountAfterSlash, &changeAmount.ChangeForUnbondableAfterSlash) + err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondableAmountAfterSlash, &changeAmount.OperatorUnbondableAmountAfterSlash) if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorUnbondingAmount error") } diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index 61808108c..5ac4ff36a 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -63,15 +63,15 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID } // update all states of the specified restaker asset - err = assetstype.UpdateAssetValue(&assetState.TotalDepositAmount, &changeAmount.ChangeForTotalDeposit) + err = assetstype.UpdateAssetValue(&assetState.TotalDepositAmount, &changeAmount.TotalDepositAmount) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState TotalDepositAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.WithdrawableAmount, &changeAmount.ChangeForWithdrawable) + err = assetstype.UpdateAssetValue(&assetState.WithdrawableAmount, &changeAmount.WithdrawableAmount) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.ChangeForWaitUnbonding) + err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) if err != nil { return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") } diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go index 89e8e477b..41fac44b5 100644 --- a/x/assets/keeper/staker_asset_test.go +++ b/x/assets/keeper/staker_asset_test.go @@ -12,8 +12,8 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { stakerID := fmt.Sprintf("%s_%s", suite.Address, "0") ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") ethUniInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: math.NewInt(1000), - ChangeForWithdrawable: math.NewInt(1000), + TotalDepositAmount: math.NewInt(1000), + WithdrawableAmount: math.NewInt(1000), } // test the initial storage of statker assets state @@ -23,12 +23,12 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { // test that the retrieved value is correct getInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) - suite.Require().True(ethUniInitialChangeValue.ChangeForTotalDeposit.Equal(getInfo.TotalDepositAmount)) - suite.Require().True(ethUniInitialChangeValue.ChangeForWithdrawable.Equal(getInfo.WithdrawableAmount)) + suite.Require().True(ethUniInitialChangeValue.TotalDepositAmount.Equal(getInfo.TotalDepositAmount)) + suite.Require().True(ethUniInitialChangeValue.WithdrawableAmount.Equal(getInfo.WithdrawableAmount)) // test valid increase of staker asset state - ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(500) - ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(500) + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(500) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(500) err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) @@ -38,8 +38,8 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1500))) // test valid decrease of staker asset state - ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(-500) - ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(-500) + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-500) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-500) err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) @@ -48,8 +48,8 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) // test the decreased amount is bigger than original state - ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(-2000) - ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(-500) + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-2000) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-500) err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) @@ -57,8 +57,8 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) - ethUniInitialChangeValue.ChangeForTotalDeposit = math.NewInt(-500) - ethUniInitialChangeValue.ChangeForWithdrawable = math.NewInt(-2000) + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-500) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-2000) err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) @@ -69,8 +69,8 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { // test the storage of multiple assets state ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUsdtInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: math.NewInt(2000), - ChangeForWithdrawable: math.NewInt(2000), + TotalDepositAmount: math.NewInt(2000), + WithdrawableAmount: math.NewInt(2000), } err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) suite.Require().NoError(err) @@ -85,12 +85,12 @@ func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { ethUniAssetID := fmt.Sprintf("%s_%s", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "101") ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") ethUniInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: math.NewInt(1000), - ChangeForWithdrawable: math.NewInt(1000), + TotalDepositAmount: math.NewInt(1000), + WithdrawableAmount: math.NewInt(1000), } ethUsdtInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: math.NewInt(2000), - ChangeForWithdrawable: math.NewInt(2000), + TotalDepositAmount: math.NewInt(2000), + WithdrawableAmount: math.NewInt(2000), } err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) diff --git a/x/assets/types/general.go b/x/assets/types/general.go index 62c205a75..a15f16ce6 100644 --- a/x/assets/types/general.go +++ b/x/assets/types/general.go @@ -44,20 +44,10 @@ type CrossChainOpType uint8 type WithdrawerAddress [32]byte // StakerSingleAssetChangeInfo This is a struct to describe the desired change that matches with the StakerSingleAssetInfo -type StakerSingleAssetChangeInfo struct { - ChangeForTotalDeposit math.Int - ChangeForWithdrawable math.Int - ChangeForWaitUnbonding math.Int -} +type StakerSingleAssetChangeInfo StakerSingleAssetInfo // OperatorSingleAssetChangeInfo This is a struct to describe the desired change that matches with the OperatorSingleAssetInfo -type OperatorSingleAssetChangeInfo struct { - ChangeForTotalAmount math.Int - ChangeForOperatorOwn math.Int - ChangeForWaitUnbonding math.Int - ChangeForOperatorUnbonding math.Int - ChangeForUnbondableAfterSlash math.Int -} +type OperatorSingleAssetChangeInfo OperatorSingleAssetInfo // GetStakeIDAndAssetID stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAddress []byte) (stakeID string, assetID string) { diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index a1b61a324..0a7e44780 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -84,8 +84,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // update the staker state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetChangeInfo{ - ChangeForWithdrawable: record.ActualCompletedAmount, - ChangeForWaitUnbonding: recordAmountNeg, + WithdrawableAmount: record.ActualCompletedAmount, + WaitUnbondingAmount: recordAmountNeg, }) if err != nil { panic(err) @@ -93,7 +93,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // update the operator state err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetChangeInfo{ - ChangeForWaitUnbonding: recordAmountNeg, + WaitUnbondingAmount: recordAmountNeg, }) if err != nil { panic(err) diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 97160a041..7c1cff7a5 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -141,14 +141,14 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar // update staker asset state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ - ChangeForWithdrawable: params.OpAmount.Neg(), + WithdrawableAmount: params.OpAmount.Neg(), }) if err != nil { return err } err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ - ChangeForTotalAmount: params.OpAmount, + TotalAmount: params.OpAmount, }) if err != nil { return err @@ -234,14 +234,14 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio // update staker and operator assets state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ - ChangeForWaitUnbonding: params.OpAmount, + WaitUnbondingAmount: params.OpAmount, }) if err != nil { return err } err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ - ChangeForTotalAmount: params.OpAmount.Neg(), - ChangeForWaitUnbonding: params.OpAmount, + TotalAmount: params.OpAmount.Neg(), + WaitUnbondingAmount: params.OpAmount, }) if err != nil { return err diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index b028f64c6..c98fac5eb 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -10,7 +10,7 @@ import ( keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - types2 "github.com/ExocoreNetwork/exocore/x/operator/types" + operatortype "github.com/ExocoreNetwork/exocore/x/operator/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -45,9 +45,9 @@ func (suite *DelegationTestSuite) TestDelegateTo() { err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationParams) suite.EqualError(err, errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", delegationParams.OperatorAddress)).Error()) - registerReq := &types2.RegisterOperatorReq{ + registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &types2.OperatorInfo{ + Info: &operatortype.OperatorInfo{ EarningsAddr: opAccAddr.String(), }, } @@ -116,9 +116,9 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - registerReq := &types2.RegisterOperatorReq{ + registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &types2.OperatorInfo{ + Info: &operatortype.OperatorInfo{ EarningsAddr: opAccAddr.String(), }, } @@ -215,9 +215,9 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - registerReq := &types2.RegisterOperatorReq{ + registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &types2.OperatorInfo{ + Info: &operatortype.OperatorInfo{ EarningsAddr: opAccAddr.String(), }, } diff --git a/x/deposit/keeper/cross_chain_tx_process.go b/x/deposit/keeper/cross_chain_tx_process.go index 2b43285fa..7803913f6 100644 --- a/x/deposit/keeper/cross_chain_tx_process.go +++ b/x/deposit/keeper/cross_chain_tx_process.go @@ -134,8 +134,8 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { return errorsmod.Wrap(despoittypes.ErrDepositAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: params.OpAmount, - ChangeForWithdrawable: params.OpAmount, + TotalDepositAmount: params.OpAmount, + WithdrawableAmount: params.OpAmount, } // update asset state of the specified staker err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index 037c559b4..ba978454e 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -125,7 +125,7 @@ func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.OptedInAssetStateChange) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) - if changeState.ChangeForAmount.IsNil() && changeState.ChangeForValue.IsNil() { + if changeState.Amount.IsNil() && changeState.Value.IsNil() { return nil } // check operator address validation @@ -144,12 +144,12 @@ func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operator k.cdc.MustUnmarshal(value, &optedInAssetState) } - err = assetstype.UpdateAssetValue(&optedInAssetState.Amount, &changeState.ChangeForAmount) + err = assetstype.UpdateAssetValue(&optedInAssetState.Amount, &changeState.Amount) if err != nil { return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Amount error") } - err = assetstype.UpdateAssetDecValue(&optedInAssetState.Value, &changeState.ChangeForValue) + err = assetstype.UpdateAssetDecValue(&optedInAssetState.Value, &changeState.Value) if err != nil { return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Value error") } diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index 06fc12d93..3395cd04d 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -61,8 +61,8 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, op // UpdateStateForAsset changeState := types.OptedInAssetStateChange{ - ChangeForAmount: opAmount, - ChangeForValue: opUSDValue, + Amount: opAmount, + Value: opUSDValue, } err = k.UpdateStateForAsset(ctx, assetID, avs, operatorAddr, changeState) if err != nil { @@ -131,8 +131,8 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr // UpdateStateForAsset changeState := types.OptedInAssetStateChange{ - ChangeForAmount: operatorAssetState.TotalAmount, - ChangeForValue: assetUSDValue, + Amount: operatorAssetState.TotalAmount, + Value: assetUSDValue, } err = k.UpdateStateForAsset(ctx, assetID, avsAddr, operatorAddress.String(), changeState) if err != nil { @@ -381,7 +381,7 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) // update staker and operator assets state err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: slashSumValue.Neg(), + TotalDepositAmount: slashSumValue.Neg(), }) if err != nil { return err @@ -395,7 +395,7 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl // handle the state that needs to be updated when slashing opted-in assets err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ - ChangeForTotalAmount: slashInfo.AmountFromOptedIn.Neg(), + TotalAmount: slashInfo.AmountFromOptedIn.Neg(), }) if err != nil { return err @@ -415,9 +415,9 @@ func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) // handle the state that needs to be updated when slashing both opted-in and unbonding assets err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ - ChangeForTotalAmount: slashSumValue.Neg(), - ChangeForOperatorOwn: slashInfo.AmountFromOptedIn.Neg(), - ChangeForUnbondableAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + TotalAmount: slashSumValue.Neg(), + OperatorOwnAmount: slashInfo.AmountFromOptedIn.Neg(), + OperatorUnbondableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), }) if err != nil { return err diff --git a/x/operator/types/general.go b/x/operator/types/general.go index b6a0c3dd0..bb2573483 100644 --- a/x/operator/types/general.go +++ b/x/operator/types/general.go @@ -1,9 +1,4 @@ package types -import "cosmossdk.io/math" - // OptedInAssetStateChange This is a struct to describe the desired change that matches with the OptedInAssetState -type OptedInAssetStateChange struct { - ChangeForAmount math.Int - ChangeForValue math.LegacyDec -} +type OptedInAssetStateChange OptedInAssetState diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index 3d181bc41..a7f062a48 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -137,8 +137,8 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { // TODO changeAmount := types.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: event.OpAmount, - ChangeForWithdrawable: event.OpAmount, + TotalDepositAmount: event.OpAmount, + WithdrawableAmount: event.OpAmount, } err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index fad342ac6..901f515f4 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -190,8 +190,8 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { } changeAmount := types.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: event.OpAmount.Neg(), - ChangeForWithdrawable: event.OpAmount.Neg(), + TotalDepositAmount: event.OpAmount.Neg(), + WithdrawableAmount: event.OpAmount.Neg(), } err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { diff --git a/x/withdraw/keeper/claim_withdraw.go b/x/withdraw/keeper/claim_withdraw.go index cfdb0a31e..a93d8d2d3 100644 --- a/x/withdraw/keeper/claim_withdraw.go +++ b/x/withdraw/keeper/claim_withdraw.go @@ -129,8 +129,8 @@ func (k Keeper) Withdraw(ctx sdk.Context, params *WithdrawParams) error { return errorsmod.Wrap(withdrawtype.ErrWithdrawAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetChangeInfo{ - ChangeForTotalDeposit: params.OpAmount.Neg(), - ChangeForWithdrawable: params.OpAmount.Neg(), + TotalDepositAmount: params.OpAmount.Neg(), + WithdrawableAmount: params.OpAmount.Neg(), } err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { From fa2a36af8c1ba6e65f17ab85f33dc02395142348 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Tue, 12 Mar 2024 12:30:37 +0800 Subject: [PATCH 38/44] mv the function related to setting ExocoreLzAppAddress to assets module and delete redudant code rename chainId to chainID in dogfood module rename restakingKeeper to assetsKeeper --- app/app.go | 44 +- precompiles/delegation/delegation.go | 12 +- precompiles/delegation/delegation_test.go | 64 +- precompiles/delegation/error.go | 2 +- precompiles/delegation/setup_test.go | 2 +- precompiles/delegation/tx.go | 16 +- precompiles/delegation/types.go | 2 +- precompiles/deposit/deposit.go | 12 +- precompiles/deposit/deposit_integrate_test.go | 44 +- precompiles/deposit/deposit_test.go | 47 +- precompiles/deposit/error.go | 2 +- precompiles/deposit/setup_test.go | 2 +- precompiles/deposit/tx.go | 14 +- precompiles/deposit/types.go | 2 +- precompiles/reward/error.go | 2 +- precompiles/reward/methods.go | 13 +- precompiles/reward/parser.go | 2 +- precompiles/reward/reward.go | 16 +- precompiles/reward/reward_test.go | 26 +- precompiles/reward/setup_test.go | 2 +- precompiles/slash/error.go | 2 +- precompiles/slash/methods.go | 11 +- precompiles/slash/parser.go | 2 +- precompiles/slash/setup_test.go | 2 +- precompiles/slash/slash.go | 10 +- precompiles/slash/slash_test.go | 26 +- precompiles/withdraw/error.go | 2 +- precompiles/withdraw/methods.go | 13 +- precompiles/withdraw/parser.go | 2 +- precompiles/withdraw/setup_test.go | 2 +- precompiles/withdraw/withdraw.go | 16 +- .../withdraw/withdraw_integrate_test.go | 24 +- precompiles/withdraw/withdraw_test.go | 23 +- proto/exocore/assets/v1/params.proto | 16 + proto/exocore/assets/v1/query.proto | 24 +- proto/exocore/assets/v1/tx.proto | 39 +- proto/exocore/deposit/v1/deposit.proto | 9 +- proto/exocore/reward/params.proto | 7 +- proto/exocore/slash/params.proto | 8 +- x/assets/client/cli/query.go | 8 +- x/assets/client/cli/tx.go | 43 +- x/assets/keeper/app_chain.go | 2 +- .../keeper/client_chain_and_asset_test.go | 8 +- x/assets/keeper/grpc_query.go | 15 +- x/assets/keeper/keeper.go | 8 +- x/assets/keeper/msg_server.go | 10 + x/assets/keeper/operator_asset.go | 24 +- x/assets/keeper/params.go | 62 ++ x/assets/keeper/params_test.go | 18 + x/assets/keeper/staker_asset.go | 12 +- x/assets/keeper/staker_asset_test.go | 30 +- x/assets/types/errors.go | 14 +- x/assets/types/general.go | 8 +- x/assets/types/keys.go | 19 +- x/assets/types/msg.go | 20 + x/assets/types/params.pb.go | 375 ++++++++++ x/assets/types/query.pb.go | 517 ++++++++++--- x/assets/types/query.pb.gw.go | 65 ++ x/assets/types/tx.pb.go | 687 ++++++++++++++---- x/delegation/client/cli/query.go | 2 +- x/delegation/keeper/abci.go | 4 +- x/delegation/keeper/cross_chain_tx_process.go | 12 +- x/delegation/keeper/delegation_op_test.go | 30 +- x/delegation/keeper/keeper.go | 13 +- x/delegation/types/keys.go | 10 +- x/deposit/client/cli/tx.go | 38 +- x/deposit/keeper/cross_chain_tx_process.go | 8 +- x/deposit/keeper/deposit_test.go | 8 +- x/deposit/keeper/keeper.go | 10 +- x/deposit/keeper/msg_server.go | 3 +- x/deposit/keeper/params.go | 46 +- x/deposit/keeper/params_test.go | 5 +- x/deposit/types/deposit.pb.go | 126 +--- x/deposit/types/errors.go | 8 +- x/deposit/types/keys.go | 5 +- x/dogfood/keeper/abci.go | 6 +- x/dogfood/keeper/impl_delegation_hooks.go | 2 +- x/dogfood/keeper/impl_sdk.go | 10 +- x/dogfood/keeper/keeper.go | 4 +- x/dogfood/types/expected_keepers.go | 20 +- x/native_token/module.go | 6 +- x/native_token/types/keys.go | 4 +- x/operator/keeper/abci.go | 8 +- x/operator/keeper/avs_operator_shares.go | 4 +- x/operator/keeper/dogfood.go | 24 +- x/operator/keeper/keeper.go | 22 +- x/operator/keeper/operator.go | 2 +- x/operator/keeper/operator_slash_state.go | 2 +- x/operator/keeper/state_update.go | 30 +- x/reward/client/cli/tx.go | 39 +- x/reward/keeper/claim_reward.go | 12 +- x/reward/keeper/claim_reward_test.go | 6 +- x/reward/keeper/keeper.go | 10 +- x/reward/keeper/params.go | 11 +- x/reward/keeper/params_test.go | 5 +- x/reward/types/params.pb.go | 125 +--- x/slash/client/cli/tx.go | 38 +- x/slash/keeper/execute_slash.go | 20 +- x/slash/keeper/execute_slash_test.go | 12 +- x/slash/keeper/keeper.go | 10 +- x/slash/keeper/params.go | 15 +- x/slash/keeper/params_test.go | 5 +- x/slash/types/params.pb.go | 125 +--- x/withdraw/keeper/claim_withdraw.go | 6 +- x/withdraw/keeper/claim_withdraw_test.go | 12 +- x/withdraw/keeper/keeper.go | 14 +- x/withdraw/keeper/params.go | 23 - 107 files changed, 2145 insertions(+), 1324 deletions(-) create mode 100644 proto/exocore/assets/v1/params.proto create mode 100644 x/assets/keeper/params.go create mode 100644 x/assets/keeper/params_test.go create mode 100644 x/assets/types/params.pb.go delete mode 100644 x/withdraw/keeper/params.go diff --git a/app/app.go b/app/app.go index 764fae26c..26fbbd141 100644 --- a/app/app.go +++ b/app/app.go @@ -27,8 +27,8 @@ import ( "github.com/evmos/evmos/v14/ethereum/eip712" "github.com/ExocoreNetwork/exocore/x/assets" - stakingAssetsManageKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" - stakingAssetsManageTypes "github.com/ExocoreNetwork/exocore/x/assets/types" + assetsKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + assetsTypes "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/delegation" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationTypes "github.com/ExocoreNetwork/exocore/x/delegation/types" @@ -351,13 +351,13 @@ type ExocoreApp struct { RecoveryKeeper *recoverykeeper.Keeper RevenueKeeper revenuekeeper.Keeper - // exocore staking module keepers - StakingAssetsManageKeeper stakingAssetsManageKeeper.Keeper - DepositKeeper depositKeeper.Keeper - DelegationKeeper delegationKeeper.Keeper - WithdrawKeeper withdrawKeeper.Keeper - RewardKeeper rewardKeeper.Keeper - OperatorKeeper operatorKeeper.Keeper + // exocore assets module keepers + AssetsKeeper assetsKeeper.Keeper + DepositKeeper depositKeeper.Keeper + DelegationKeeper delegationKeeper.Keeper + WithdrawKeeper withdrawKeeper.Keeper + RewardKeeper rewardKeeper.Keeper + OperatorKeeper operatorKeeper.Keeper ExoSlashKeeper slashKeeper.Keeper // the module manager @@ -434,7 +434,7 @@ func NewExocoreApp( epochstypes.StoreKey, claimstypes.StoreKey, vestingtypes.StoreKey, revenuetypes.StoreKey, recoverytypes.StoreKey, // exoCore module keys - stakingAssetsManageTypes.StoreKey, + assetsTypes.StoreKey, delegationTypes.StoreKey, depositTypes.StoreKey, withdrawTypes.StoreKey, @@ -620,16 +620,16 @@ func NewExocoreApp( ) // set exoCore staking keepers - app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec) - app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper) - app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}, delegationTypes.VirtualISlashKeeper{}) + app.AssetsKeeper = assetsKeeper.NewKeeper(keys[assetsTypes.StoreKey], appCodec) + app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper) + app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.AssetsKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}, delegationTypes.VirtualISlashKeeper{}) // todo: need to replace the virtual keepers with actual keepers after they have been implemented - app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper) + app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper) app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper) - app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.StakingAssetsManageKeeper, app.DepositKeeper) - app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.StakingAssetsManageKeeper) - app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.StakingAssetsManageKeeper) + app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.AssetsKeeper, app.DepositKeeper) + app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.AssetsKeeper) + app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.AssetsKeeper) // We call this after setting the hooks to ensure that the hooks are set on the keeper evmKeeper.WithPrecompiles( evmkeeper.AvailablePrecompiles( @@ -641,7 +641,7 @@ func NewExocoreApp( app.IBCKeeper.ChannelKeeper, app.DepositKeeper, app.DelegationKeeper, - app.StakingAssetsManageKeeper, + app.AssetsKeeper, app.WithdrawKeeper, app.ExoSlashKeeper, app.RewardKeeper, @@ -797,7 +797,7 @@ func NewExocoreApp( revenue.NewAppModule(app.RevenueKeeper, app.AccountKeeper, app.GetSubspace(revenuetypes.ModuleName)), // exoCore app modules - assets.NewAppModule(appCodec, app.StakingAssetsManageKeeper), + assets.NewAppModule(appCodec, app.AssetsKeeper), deposit.NewAppModule(appCodec, app.DepositKeeper), operator.NewAppModule(appCodec, app.OperatorKeeper), delegation.NewAppModule(appCodec, app.DelegationKeeper), @@ -844,7 +844,7 @@ func NewExocoreApp( revenuetypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules - stakingAssetsManageTypes.ModuleName, + assetsTypes.ModuleName, depositTypes.ModuleName, operatorTypes.ModuleName, delegationTypes.ModuleName, @@ -887,7 +887,7 @@ func NewExocoreApp( revenuetypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules - stakingAssetsManageTypes.ModuleName, + assetsTypes.ModuleName, depositTypes.ModuleName, operatorTypes.ModuleName, delegationTypes.ModuleName, @@ -928,7 +928,7 @@ func NewExocoreApp( paramstypes.ModuleName, upgradetypes.ModuleName, // ExoCore modules - stakingAssetsManageTypes.ModuleName, + assetsTypes.ModuleName, depositTypes.ModuleName, operatorTypes.ModuleName, delegationTypes.ModuleName, diff --git a/precompiles/delegation/delegation.go b/precompiles/delegation/delegation.go index 9fde2d1b6..0181d8c1a 100644 --- a/precompiles/delegation/delegation.go +++ b/precompiles/delegation/delegation.go @@ -5,7 +5,7 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -26,14 +26,14 @@ var f embed.FS // Precompile defines the precompiled contract for deposit. type Precompile struct { cmn.Precompile - stakingStateKeeper stakingStateKeeper.Keeper - delegationKeeper delegationKeeper.Keeper + assetsKeeper assetskeeper.Keeper + delegationKeeper delegationKeeper.Keeper } // NewPrecompile creates a new deposit Precompile instance as a // PrecompiledContract interface. func NewPrecompile( - stakingStateKeeper stakingStateKeeper.Keeper, + stakingStateKeeper assetskeeper.Keeper, delegationKeeper delegationKeeper.Keeper, authzKeeper authzkeeper.Keeper, ) (*Precompile, error) { @@ -55,8 +55,8 @@ func NewPrecompile( TransientKVGasConfig: storetypes.TransientGasConfig(), ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. }, - delegationKeeper: delegationKeeper, - stakingStateKeeper: stakingStateKeeper, + delegationKeeper: delegationKeeper, + assetsKeeper: stakingStateKeeper, }, nil } diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index f7489f8d0..9ba6eb67e 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -2,7 +2,6 @@ package delegation_test import ( "math/big" - "strings" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" @@ -10,12 +9,11 @@ import ( "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/delegation" - "github.com/ExocoreNetwork/exocore/precompiles/deposit" "github.com/ExocoreNetwork/exocore/x/assets/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -66,8 +64,8 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { // TestRun tests DelegateToThroughClientChain method through calling Run function. func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { // deposit params for test - exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + ExocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" + ExocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") opAccAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" clientChainLzID := 101 @@ -129,37 +127,37 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { returnBytes []byte }{ { - name: "fail - delegateToThroughClientChain transaction will fail because the exoCoreLzAppAddress haven't been stored", + name: "fail - delegateToThroughClientChain transaction will fail because the ExocoreLzAppAddress haven't been stored", malleate: func() (common.Address, []byte) { return commonMalleate() }, readOnly: false, expPass: false, - errContains: types3.ErrNoParamsKey.Error(), + errContains: assetstype.ErrNoParamsKey.Error(), }, { name: "fail - delegateToThroughClientChain transaction will fail because the contract caller isn't the exoCoreLzAppAddr", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: exoCoreLzAppAddress, - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: ExocoreLzAppAddress, + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, readOnly: false, expPass: false, - errContains: strings.Split(deposit.ErrContractCaller, ",")[0], + errContains: types.ErrNotEqualToLzAppAddr.Error(), }, { name: "fail - delegateToThroughClientChain transaction will fail because the delegated operator hasn't been registered", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, @@ -170,11 +168,11 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { { name: "fail - delegateToThroughClientChain transaction will fail because the delegated asset hasn't been deposited", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() return commonMalleate() @@ -186,11 +184,11 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { { name: "fail - delegateToThroughClientChain transaction will fail because the delegation amount is bigger than the canWithdraw amount", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(smallDepositAmount)) @@ -203,11 +201,11 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { { name: "pass - delegateToThroughClientChain transaction", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) @@ -293,7 +291,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { // TestRun tests DelegateToThroughClientChain method through calling Run function. func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { // deposit params for test - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + ExocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" clientChainLzID := 101 @@ -373,11 +371,11 @@ func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { { name: "pass - undelegateFromThroughClientChain transaction", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) registerOperator() depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) diff --git a/precompiles/delegation/error.go b/precompiles/delegation/error.go index b2208847b..81623485d 100644 --- a/precompiles/delegation/error.go +++ b/precompiles/delegation/error.go @@ -2,7 +2,7 @@ package delegation const ( ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function,caller:%s,need:%s" + ErrContractCaller = "the caller doesn't have the permission to call this function" ErrCtxTxHash = "ctx TxHash type error or is nil,type is:%v,value:%v" ErrInputOperatorAddrLength = "mismatched length of the input operator address,actual is:%d,expect:%v" diff --git a/precompiles/delegation/setup_test.go b/precompiles/delegation/setup_test.go index 4f6fe37f2..abb0d1dfd 100644 --- a/precompiles/delegation/setup_test.go +++ b/precompiles/delegation/setup_test.go @@ -31,7 +31,7 @@ func TestPrecompileTestSuite(t *testing.T) { func (s *DelegationPrecompileSuite) SetupTest() { s.DoSetupTest() - precompile, err := delegation.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.DelegationKeeper, s.App.AuthzKeeper) + precompile, err := delegation.NewPrecompile(s.App.AssetsKeeper, s.App.DelegationKeeper, s.App.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile } diff --git a/precompiles/delegation/tx.go b/precompiles/delegation/tx.go index a254e502a..1e629818d 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -4,6 +4,8 @@ import ( "fmt" "reflect" + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -32,12 +34,9 @@ func (p Precompile) DelegateToThroughClientChain( args []interface{}, ) ([]byte, error) { // check the invalidation of caller contract - exoCoreLzAppAddr, err := p.delegationKeeper.GetExoCoreLzAppAddress(ctx) + err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, err - } - if contract.CallerAddress != exoCoreLzAppAddr { - return nil, fmt.Errorf(ErrContractCaller, contract.CallerAddress, exoCoreLzAppAddr) + return nil, errorsmod.Wrap(err, ErrContractCaller) } delegationParams, err := p.GetDelegationParamsFromInputs(ctx, args) @@ -62,12 +61,9 @@ func (p Precompile) UndelegateFromThroughClientChain( args []interface{}, ) ([]byte, error) { // check the invalidation of caller contract - exoCoreLzAppAddr, err := p.delegationKeeper.GetExoCoreLzAppAddress(ctx) + err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, err - } - if contract.CallerAddress != exoCoreLzAppAddr { - return nil, fmt.Errorf(ErrContractCaller, contract.CallerAddress, exoCoreLzAppAddr) + return nil, errorsmod.Wrap(err, ErrContractCaller) } UndelegationParams, err := p.GetDelegationParamsFromInputs(ctx, args) diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index 09e2c0f6d..a1ebb1b01 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -26,7 +26,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf } delegationParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, delegationParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, delegationParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/deposit/deposit.go b/precompiles/deposit/deposit.go index 969a11b6b..b0877130f 100644 --- a/precompiles/deposit/deposit.go +++ b/precompiles/deposit/deposit.go @@ -5,7 +5,7 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" storetypes "github.com/cosmos/cosmos-sdk/store/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" @@ -26,14 +26,14 @@ var f embed.FS // Precompile defines the precompiled contract for deposit. type Precompile struct { cmn.Precompile - stakingStateKeeper stakingStateKeeper.Keeper - depositKeeper depositKeeper.Keeper + assetsKeeper assetskeeper.Keeper + depositKeeper depositKeeper.Keeper } // NewPrecompile creates a new deposit Precompile instance as a // PrecompiledContract interface. func NewPrecompile( - stakingStateKeeper stakingStateKeeper.Keeper, + stakingStateKeeper assetskeeper.Keeper, depositKeeper depositKeeper.Keeper, authzKeeper authzkeeper.Keeper, ) (*Precompile, error) { @@ -55,8 +55,8 @@ func NewPrecompile( TransientKVGasConfig: storetypes.TransientGasConfig(), ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. }, - depositKeeper: depositKeeper, - stakingStateKeeper: stakingStateKeeper, + depositKeeper: depositKeeper, + assetsKeeper: stakingStateKeeper, }, nil } diff --git a/precompiles/deposit/deposit_integrate_test.go b/precompiles/deposit/deposit_integrate_test.go index 276be10b6..52e53b866 100644 --- a/precompiles/deposit/deposit_integrate_test.go +++ b/precompiles/deposit/deposit_integrate_test.go @@ -2,13 +2,11 @@ package deposit_test import ( "math/big" - "strings" "github.com/ExocoreNetwork/exocore/precompiles/deposit" "github.com/ExocoreNetwork/exocore/precompiles/testutil" "github.com/ExocoreNetwork/exocore/precompiles/testutil/contracts" - "github.com/ExocoreNetwork/exocore/x/assets/types" - types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ethereum/go-ethereum/common" ) @@ -28,15 +26,15 @@ var ( func (s *DepositPrecompileSuite) TestCallDepositToFromEOA() { // deposit params for test - exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" - depositParams := types3.Params{ - ExoCoreLzAppAddress: exoCoreLzAppAddress, - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + exocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + depositParams := assetstype.Params{ + ExocoreLzAppAddress: exocoreLzAppAddress, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } - usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) + usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), assetstype.GeneralClientChainAddrLength) clientChainLzID := 101 - stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress method := "depositTo" @@ -56,8 +54,8 @@ func (s *DepositPrecompileSuite) TestCallDepositToFromEOA() { passCheck = defaultLogCheck.WithExpPass(true) } - prepareFunc := func(params *types3.Params, method string) contracts.CallArgs { - err := s.App.DepositKeeper.SetParams(s.Ctx, params) + prepareFunc := func(params *assetstype.Params, method string) contracts.CallArgs { + err := s.App.AssetsKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) defaultDepositArgs := defaultCallArgs.WithMethodName(method) return defaultDepositArgs.WithArgs( @@ -71,11 +69,11 @@ func (s *DepositPrecompileSuite) TestCallDepositToFromEOA() { beforeEach() setDepositToArgs := prepareFunc(&depositParams, method) _, _, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) - s.Require().ErrorContains(err, strings.Split(deposit.ErrContractCaller, ",")[0]) + s.Require().ErrorContains(err, assetstype.ErrNotEqualToLzAppAddr.Error()) // test success beforeEach() - depositParams.ExoCoreLzAppAddress = s.Address.String() + depositParams.ExocoreLzAppAddress = s.Address.String() setDepositToArgs = prepareFunc(&depositParams, method) _, ethRes, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) successRet, err := s.precompile.Methods[deposit.MethodDepositTo].Outputs.Pack(true, opAmount) @@ -87,13 +85,13 @@ func (s *DepositPrecompileSuite) TestCallDepositToFromContract() { // deposit params for test exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" - depositParams := types3.Params{ - ExoCoreLzAppAddress: exoCoreLzAppAddress, - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositParams := assetstype.Params{ + ExocoreLzAppAddress: exoCoreLzAppAddress, + ExocoreLzAppEventTopic: exoCoreLzAppEventTopic, } - usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) + usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), assetstype.GeneralClientChainAddrLength) clientChainLzID := 101 - stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress @@ -127,8 +125,8 @@ func (s *DepositPrecompileSuite) TestCallDepositToFromContract() { passCheck = defaultLogCheck.WithExpPass(true) } - prepareFunc := func(params *types3.Params, method string) contracts.CallArgs { - err := s.App.DepositKeeper.SetParams(s.Ctx, params) + prepareFunc := func(params *assetstype.Params, method string) contracts.CallArgs { + err := s.App.AssetsKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) defaultDepositArgs := defaultCallArgs.WithMethodName(method) return defaultDepositArgs.WithArgs( @@ -140,7 +138,7 @@ func (s *DepositPrecompileSuite) TestCallDepositToFromContract() { // testDepositTo beforeEach() - depositParams.ExoCoreLzAppAddress = contractAddr.String() + depositParams.ExocoreLzAppAddress = contractAddr.String() setDepositToArgs := prepareFunc(&depositParams, "testDepositTo") _, _, err = contracts.CallContractAndCheckLogs(s.Ctx, s.App, setDepositToArgs, passCheck) s.Require().NoError(err) @@ -162,7 +160,7 @@ func (s *DepositPrecompileSuite) TestCallDepositToFromContract() { // testCallDepositToWithTryCatch beforeEach() - depositParams.ExoCoreLzAppAddress = exoCoreLzAppAddress + depositParams.ExocoreLzAppAddress = exoCoreLzAppAddress setDepositToArgs = prepareFunc(&depositParams, "testCallDepositToWithTryCatch") // eventCheck = passCheck.WithExpEvents("ErrorOccurred") // todo: need to check the ethereum log diff --git a/precompiles/deposit/deposit_test.go b/precompiles/deposit/deposit_test.go index f042397bb..31dce39e1 100644 --- a/precompiles/deposit/deposit_test.go +++ b/precompiles/deposit/deposit_test.go @@ -2,12 +2,11 @@ package deposit_test import ( "math/big" - "strings" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/deposit" - "github.com/ExocoreNetwork/exocore/x/assets/types" - types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -52,12 +51,12 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { // TestRunDepositTo tests DepositTo method through calling Run function.. func (s *DepositPrecompileSuite) TestRunDepositTo() { // deposit params for test - exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" - usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) - usdcAddress := paddingClientChainAddress(common.FromHex("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), types.GeneralClientChainAddrLength) + ExocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" + ExocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), assetstype.GeneralClientChainAddrLength) + usdcAddress := paddingClientChainAddress(common.FromHex("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), assetstype.GeneralClientChainAddrLength) clientChainLzID := 101 - stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress commonMalleate := func() (common.Address, []byte) { @@ -88,54 +87,54 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { returnBytes []byte }{ { - name: "fail - depositTo transaction will fail because the exoCoreLzAppAddress haven't been stored", + name: "fail - depositTo transaction will fail because the ExocoreLzAppAddress haven't been stored", malleate: func() (common.Address, []byte) { return commonMalleate() }, readOnly: false, expPass: false, - errContains: types3.ErrNoParamsKey.Error(), + errContains: assetstype.ErrNoParamsKey.Error(), }, { name: "fail - depositTo transaction will fail because the contract caller isn't the exoCoreLzAppAddr", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: exoCoreLzAppAddress, - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: ExocoreLzAppAddress, + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, readOnly: false, expPass: false, - errContains: strings.Split(deposit.ErrContractCaller, ",")[0], + errContains: assetstype.ErrNotEqualToLzAppAddr.Error(), }, { name: "fail - depositTo transaction will fail because the staked asset hasn't been registered", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) assetAddr = usdcAddress return commonMalleate() }, readOnly: false, expPass: false, - errContains: types3.ErrDepositAssetNotExist.Error(), + errContains: deposittype.ErrDepositAssetNotExist.Error(), }, { name: "pass - depositTo transaction", malleate: func() (common.Address, []byte) { - depositModuleParam := &types3.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, } assetAddr = usdtAddress - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) return commonMalleate() }, diff --git a/precompiles/deposit/error.go b/precompiles/deposit/error.go index 3bce6ea7e..79d51d573 100644 --- a/precompiles/deposit/error.go +++ b/precompiles/deposit/error.go @@ -2,6 +2,6 @@ package deposit const ( ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, expected type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function,caller:%s,need:%s" + ErrContractCaller = "the caller doesn't have the permission to call this function" ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" ) diff --git a/precompiles/deposit/setup_test.go b/precompiles/deposit/setup_test.go index 4880ccdc5..df09c3a8a 100644 --- a/precompiles/deposit/setup_test.go +++ b/precompiles/deposit/setup_test.go @@ -32,7 +32,7 @@ func TestPrecompileTestSuite(t *testing.T) { func (s *DepositPrecompileSuite) SetupTest() { s.DoSetupTest() - precompile, err := deposit.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.DepositKeeper, s.App.AuthzKeeper) + precompile, err := deposit.NewPrecompile(s.App.AssetsKeeper, s.App.DepositKeeper, s.App.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile } diff --git a/precompiles/deposit/tx.go b/precompiles/deposit/tx.go index 5d60ab8fc..23bb0d234 100644 --- a/precompiles/deposit/tx.go +++ b/precompiles/deposit/tx.go @@ -1,8 +1,7 @@ package deposit import ( - "fmt" - + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -26,15 +25,10 @@ func (p Precompile) DepositTo( args []interface{}, ) ([]byte, error) { // check the invalidation of caller contract,the caller must be exoCore LzApp contract - depositModuleParam, err := p.depositKeeper.GetParams(ctx) + err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, err + return nil, errorsmod.Wrap(err, ErrContractCaller) } - exoCoreLzAppAddr := common.HexToAddress(depositModuleParam.ExoCoreLzAppAddress) - if contract.CallerAddress != exoCoreLzAppAddr { - return nil, fmt.Errorf(ErrContractCaller, contract.CallerAddress, exoCoreLzAppAddr) - } - // parse the depositTo input params depositParams, err := p.GetDepositToParamsFromInputs(ctx, args) if err != nil { @@ -49,7 +43,7 @@ func (p Precompile) DepositTo( // get the latest asset state of staker to return. stakerID, assetID := types.GetStakeIDAndAssetID(depositParams.ClientChainLzID, depositParams.StakerAddress, depositParams.AssetsAddress) - info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) + info, err := p.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/precompiles/deposit/types.go b/precompiles/deposit/types.go index e38f7b875..55e951bf6 100644 --- a/precompiles/deposit/types.go +++ b/precompiles/deposit/types.go @@ -22,7 +22,7 @@ func (p Precompile) GetDepositToParamsFromInputs(ctx sdk.Context, args []interfa } depositParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, depositParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, depositParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/reward/error.go b/precompiles/reward/error.go index 69d5c160d..bfc0851f4 100644 --- a/precompiles/reward/error.go +++ b/precompiles/reward/error.go @@ -2,6 +2,6 @@ package reward const ( ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function,caller:%s,need:%s" + ErrContractCaller = "the caller doesn't have the permission to call this function" ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" ) diff --git a/precompiles/reward/methods.go b/precompiles/reward/methods.go index 6e1dac2e9..e47321171 100644 --- a/precompiles/reward/methods.go +++ b/precompiles/reward/methods.go @@ -1,8 +1,7 @@ package reward import ( - "fmt" - + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -26,13 +25,9 @@ func (p Precompile) Reward( args []interface{}, ) ([]byte, error) { // check the invalidation of caller contract - rewardModuleParam, err := p.rewardKeeper.GetParams(ctx) + err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, err - } - exoCoreLzAppAddr := common.HexToAddress(rewardModuleParam.ExoCoreLzAppAddress) - if contract.CallerAddress != exoCoreLzAppAddr { - return nil, fmt.Errorf(ErrContractCaller, contract.CallerAddress, exoCoreLzAppAddr) + return nil, errorsmod.Wrap(err, ErrContractCaller) } rewardParam, err := p.GetRewardParamsFromInputs(ctx, args) @@ -46,7 +41,7 @@ func (p Precompile) Reward( } // get the latest asset state of staker to return. stakerID, assetID := types.GetStakeIDAndAssetID(rewardParam.ClientChainLzID, rewardParam.WithdrawRewardAddress, rewardParam.AssetsAddress) - info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) + info, err := p.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/precompiles/reward/parser.go b/precompiles/reward/parser.go index 4b7f792fe..cac0bdbfc 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -24,7 +24,7 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ } rewardParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, rewardParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, rewardParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/reward/reward.go b/precompiles/reward/reward.go index 7684372c7..aa04c1e59 100644 --- a/precompiles/reward/reward.go +++ b/precompiles/reward/reward.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" - rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" + assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + rewardkeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,15 +27,15 @@ var f embed.FS // Precompile defines the precompiled contract for reward. type Precompile struct { cmn.Precompile - stakingStateKeeper stakingStateKeeper.Keeper - rewardKeeper rewardKeeper.Keeper + assetsKeeper assetskeeper.Keeper + rewardKeeper rewardkeeper.Keeper } // NewPrecompile creates a new reward Precompile instance as a // PrecompiledContract interface. func NewPrecompile( - stakingStateKeeper stakingStateKeeper.Keeper, - rewardKeeper rewardKeeper.Keeper, + stakingStateKeeper assetskeeper.Keeper, + rewardKeeper rewardkeeper.Keeper, authzKeeper authzkeeper.Keeper, ) (*Precompile, error) { abiBz, err := f.ReadFile("abi.json") @@ -56,8 +56,8 @@ func NewPrecompile( TransientKVGasConfig: storetypes.TransientGasConfig(), ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. }, - rewardKeeper: rewardKeeper, - stakingStateKeeper: stakingStateKeeper, + rewardKeeper: rewardKeeper, + assetsKeeper: stakingStateKeeper, }, nil } diff --git a/precompiles/reward/reward_test.go b/precompiles/reward/reward_test.go index 0b4a0d678..5980615a7 100644 --- a/precompiles/reward/reward_test.go +++ b/precompiles/reward/reward_test.go @@ -6,10 +6,8 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/reward" - "github.com/ExocoreNetwork/exocore/x/assets/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - depositParams "github.com/ExocoreNetwork/exocore/x/deposit/types" - rewardParams "github.com/ExocoreNetwork/exocore/x/reward/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -53,17 +51,17 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { // TestRun tests the precompiled Run method reward. func (s *RewardPrecompileTestSuite) TestRunRewardThroughClientChain() { // deposit params for test - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") clientChainLzID := 101 withdrawAmount := big.NewInt(10) depositAmount := big.NewInt(100) - assetAddr := paddingClientChainAddress(usdtAddress, types.GeneralClientChainAddrLength) + assetAddr := paddingClientChainAddress(usdtAddress, assetstype.GeneralClientChainAddrLength) depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for reward test params := &keeper.DepositParams{ ClientChainLzID: 101, - Action: types.Deposit, + Action: assetstype.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, @@ -78,7 +76,7 @@ func (s *RewardPrecompileTestSuite) TestRunRewardThroughClientChain() { reward.MethodReward, uint16(clientChainLzID), assetAddr, - paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength), withdrawAmount, ) s.Require().NoError(err, "failed to pack input") @@ -97,19 +95,13 @@ func (s *RewardPrecompileTestSuite) TestRunRewardThroughClientChain() { { name: "pass - reward via pre-compiles", malleate: func() (common.Address, []byte) { - depositModuleParam := &depositParams.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) - rewardModuleParam := &rewardParams.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, - } - err = s.App.RewardKeeper.SetParams(s.Ctx, rewardModuleParam) - s.Require().NoError(err) return commonMalleate() }, returnBytes: successRet, diff --git a/precompiles/reward/setup_test.go b/precompiles/reward/setup_test.go index 74e70a08b..9d49781de 100644 --- a/precompiles/reward/setup_test.go +++ b/precompiles/reward/setup_test.go @@ -31,7 +31,7 @@ func TestPrecompileTestSuite(t *testing.T) { func (s *RewardPrecompileTestSuite) SetupTest() { s.DoSetupTest() - precompile, err := reward.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.RewardKeeper, s.App.AuthzKeeper) + precompile, err := reward.NewPrecompile(s.App.AssetsKeeper, s.App.RewardKeeper, s.App.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile } diff --git a/precompiles/slash/error.go b/precompiles/slash/error.go index 3125b51ee..a5fc7bddc 100644 --- a/precompiles/slash/error.go +++ b/precompiles/slash/error.go @@ -2,6 +2,6 @@ package slash const ( ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function,caller:%s,need:%s" + ErrContractCaller = "the caller doesn't have the permission to call this function" ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" ) diff --git a/precompiles/slash/methods.go b/precompiles/slash/methods.go index 0c35af83a..6ddba8239 100644 --- a/precompiles/slash/methods.go +++ b/precompiles/slash/methods.go @@ -1,8 +1,7 @@ package slash import ( - "fmt" - + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -25,13 +24,9 @@ func (p Precompile) SubmitSlash( args []interface{}, ) ([]byte, error) { // check the invalidation of caller contract - slashModuleParam, err := p.slashKeeper.GetParams(ctx) + err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, err - } - exoCoreLzAppAddr := common.HexToAddress(slashModuleParam.ExoCoreLzAppAddress) - if contract.CallerAddress != exoCoreLzAppAddr { - return nil, fmt.Errorf(ErrContractCaller, contract.CallerAddress, exoCoreLzAppAddr) + return nil, errorsmod.Wrap(err, ErrContractCaller) } slashParam, err := p.GetSlashParamsFromInputs(ctx, args) diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index d76696199..c390f44d2 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -23,7 +23,7 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} } slashParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, slashParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, slashParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/slash/setup_test.go b/precompiles/slash/setup_test.go index 8ddec306f..8aa802170 100644 --- a/precompiles/slash/setup_test.go +++ b/precompiles/slash/setup_test.go @@ -31,7 +31,7 @@ func TestPrecompileTestSuite(t *testing.T) { func (s *SlashPrecompileTestSuite) SetupTest() { s.DoSetupTest() - precompile, err := slash.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.ExoSlashKeeper, s.App.AuthzKeeper) + precompile, err := slash.NewPrecompile(s.App.AssetsKeeper, s.App.ExoSlashKeeper, s.App.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile } diff --git a/precompiles/slash/slash.go b/precompiles/slash/slash.go index 9d857e8b4..eb9203f1f 100644 --- a/precompiles/slash/slash.go +++ b/precompiles/slash/slash.go @@ -5,7 +5,7 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" slashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -26,7 +26,7 @@ var f embed.FS // Precompile defines the precompiled contract for slash. type Precompile struct { - stakingStateKeeper stakingStateKeeper.Keeper + assetsKeeper assetskeeper.Keeper cmn.Precompile slashKeeper slashKeeper.Keeper } @@ -34,7 +34,7 @@ type Precompile struct { // NewPrecompile creates a new slash Precompile instance as a // PrecompiledContract interface. func NewPrecompile( - stakingStateKeeper stakingStateKeeper.Keeper, + stakingStateKeeper assetskeeper.Keeper, slashKeeper slashKeeper.Keeper, authzKeeper authzkeeper.Keeper, ) (*Precompile, error) { @@ -56,8 +56,8 @@ func NewPrecompile( TransientKVGasConfig: storetypes.TransientGasConfig(), ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. }, - stakingStateKeeper: stakingStateKeeper, - slashKeeper: slashKeeper, + assetsKeeper: stakingStateKeeper, + slashKeeper: slashKeeper, }, nil } diff --git a/precompiles/slash/slash_test.go b/precompiles/slash/slash_test.go index c26806f4f..24323690a 100644 --- a/precompiles/slash/slash_test.go +++ b/precompiles/slash/slash_test.go @@ -6,10 +6,8 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/slash" - "github.com/ExocoreNetwork/exocore/x/assets/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - depositParams "github.com/ExocoreNetwork/exocore/x/deposit/types" - slashParams "github.com/ExocoreNetwork/exocore/x/slash/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -53,17 +51,17 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { // TestRun tests the precompiles Run method submitSlash. func (s *SlashPrecompileTestSuite) TestRunSlash() { // deposit params for test - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") clientChainLzID := 101 slashAmount := big.NewInt(10) depositAmount := big.NewInt(100) - assetAddr := paddingClientChainAddress(usdtAddress, types.GeneralClientChainAddrLength) + assetAddr := paddingClientChainAddress(usdtAddress, assetstype.GeneralClientChainAddrLength) depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for slash test params := &keeper.DepositParams{ ClientChainLzID: 101, - Action: types.Deposit, + Action: assetstype.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, @@ -78,7 +76,7 @@ func (s *SlashPrecompileTestSuite) TestRunSlash() { slash.MethodSlash, uint16(clientChainLzID), assetAddr, - paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength), slashAmount, common.FromHex("0x2E756b8faBeA234b9900767b69D6387400CDC396"), common.FromHex("0xceb69f6342ece283b2f5c9088ff249b5d0ae66ea"), @@ -101,19 +99,13 @@ func (s *SlashPrecompileTestSuite) TestRunSlash() { { name: "pass - slash via pre-compiles", malleate: func() (common.Address, []byte) { - depositModuleParam := &depositParams.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) - slashModuleParam := &slashParams.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, - } - err = s.App.ExoSlashKeeper.SetParams(s.Ctx, slashModuleParam) - s.Require().NoError(err) return commonMalleate() }, returnBytes: successRet, diff --git a/precompiles/withdraw/error.go b/precompiles/withdraw/error.go index ebf6cb249..8c51c1984 100644 --- a/precompiles/withdraw/error.go +++ b/precompiles/withdraw/error.go @@ -2,6 +2,6 @@ package withdraw const ( ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function,caller:%s,need:%s" + ErrContractCaller = "the caller doesn't have the permission to call this function" ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" ) diff --git a/precompiles/withdraw/methods.go b/precompiles/withdraw/methods.go index dcff36bf7..8a577ae10 100644 --- a/precompiles/withdraw/methods.go +++ b/precompiles/withdraw/methods.go @@ -1,8 +1,7 @@ package withdraw import ( - "fmt" - + errorsmod "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -25,13 +24,9 @@ func (p Precompile) Withdraw( args []interface{}, ) ([]byte, error) { // check the invalidation of caller contract - withdrawModuleParam, err := p.withdrawKeeper.GetParams(ctx) + err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, err - } - exoCoreLzAppAddr := common.HexToAddress(withdrawModuleParam.ExoCoreLzAppAddress) - if contract.CallerAddress != exoCoreLzAppAddr { - return nil, fmt.Errorf(ErrContractCaller, contract.CallerAddress, exoCoreLzAppAddr) + return nil, errorsmod.Wrap(err, ErrContractCaller) } withdrawParam, err := p.GetWithdrawParamsFromInputs(ctx, args) @@ -45,7 +40,7 @@ func (p Precompile) Withdraw( } // get the latest asset state of staker to return. stakerID, assetID := types.GetStakeIDAndAssetID(withdrawParam.ClientChainLzID, withdrawParam.WithdrawAddress, withdrawParam.AssetsAddress) - info, err := p.stakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) + info, err := p.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return nil, err } diff --git a/precompiles/withdraw/parser.go b/precompiles/withdraw/parser.go index d1462083b..e84a4a8ea 100644 --- a/precompiles/withdraw/parser.go +++ b/precompiles/withdraw/parser.go @@ -23,7 +23,7 @@ func (p Precompile) GetWithdrawParamsFromInputs(ctx sdk.Context, args []interfac } withdrawParams.ClientChainLzID = uint64(clientChainLzID) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, withdrawParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, withdrawParams.ClientChainLzID) if err != nil { return nil, err } diff --git a/precompiles/withdraw/setup_test.go b/precompiles/withdraw/setup_test.go index 5a79fd128..befb1fc66 100644 --- a/precompiles/withdraw/setup_test.go +++ b/precompiles/withdraw/setup_test.go @@ -31,7 +31,7 @@ func TestPrecompileTestSuite(t *testing.T) { func (s *WithdrawPrecompileTestSuite) SetupTest() { s.DoSetupTest() - precompile, err := withdraw.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.WithdrawKeeper, s.App.AuthzKeeper) + precompile, err := withdraw.NewPrecompile(s.App.AssetsKeeper, s.App.WithdrawKeeper, s.App.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile } diff --git a/precompiles/withdraw/withdraw.go b/precompiles/withdraw/withdraw.go index 6ee973c9e..2e55b7121 100644 --- a/precompiles/withdraw/withdraw.go +++ b/precompiles/withdraw/withdraw.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" - stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" - withdrawKeeper "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" + assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" + withdrawkeeper "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,15 +27,15 @@ var f embed.FS // Precompile defines the precompiled contract for Withdraw. type Precompile struct { cmn.Precompile - stakingStateKeeper stakingStateKeeper.Keeper - withdrawKeeper withdrawKeeper.Keeper + assetsKeeper assetskeeper.Keeper + withdrawKeeper withdrawkeeper.Keeper } // NewPrecompile creates a new Withdraw Precompile instance as a // PrecompiledContract interface. func NewPrecompile( - stakingStateKeeper stakingStateKeeper.Keeper, - withdrawKeeper withdrawKeeper.Keeper, + stakingStateKeeper assetskeeper.Keeper, + withdrawKeeper withdrawkeeper.Keeper, authzKeeper authzkeeper.Keeper, ) (*Precompile, error) { abiBz, err := f.ReadFile("abi.json") @@ -56,8 +56,8 @@ func NewPrecompile( TransientKVGasConfig: storetypes.TransientGasConfig(), ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. }, - withdrawKeeper: withdrawKeeper, - stakingStateKeeper: stakingStateKeeper, + withdrawKeeper: withdrawKeeper, + assetsKeeper: stakingStateKeeper, }, nil } diff --git a/precompiles/withdraw/withdraw_integrate_test.go b/precompiles/withdraw/withdraw_integrate_test.go index e1dbd10a4..6e9f32d8c 100644 --- a/precompiles/withdraw/withdraw_integrate_test.go +++ b/precompiles/withdraw/withdraw_integrate_test.go @@ -2,13 +2,11 @@ package withdraw_test import ( "math/big" - "strings" "github.com/ExocoreNetwork/exocore/precompiles/testutil" "github.com/ExocoreNetwork/exocore/precompiles/testutil/contracts" "github.com/ExocoreNetwork/exocore/precompiles/withdraw" - "github.com/ExocoreNetwork/exocore/x/assets/types" - deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ethereum/go-ethereum/common" ) @@ -28,15 +26,15 @@ var ( func (s *WithdrawPrecompileTestSuite) TestCallWithdrawFromEOA() { // withdraw params for test - exoCoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" - params := deposittype.Params{ - ExoCoreLzAppAddress: exoCoreLzAppAddress, - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + exocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + params := assetstype.Params{ + ExocoreLzAppAddress: exocoreLzAppAddress, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } - usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) + usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), assetstype.GeneralClientChainAddrLength) clientChainLzID := 101 - stakerAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) + stakerAddr := paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress method := "withdrawPrinciple" @@ -56,8 +54,8 @@ func (s *WithdrawPrecompileTestSuite) TestCallWithdrawFromEOA() { passCheck = defaultLogCheck.WithExpPass(true) } - prepareFunc := func(params *deposittype.Params, method string) contracts.CallArgs { - err := s.App.DepositKeeper.SetParams(s.Ctx, params) + prepareFunc := func(params *assetstype.Params, method string) contracts.CallArgs { + err := s.App.AssetsKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) defaultWithdrawArgs := defaultCallArgs.WithMethodName(method) return defaultWithdrawArgs.WithArgs( @@ -70,5 +68,5 @@ func (s *WithdrawPrecompileTestSuite) TestCallWithdrawFromEOA() { beforeEach() setWithdrawArgs := prepareFunc(¶ms, method) _, _, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setWithdrawArgs, passCheck) - s.Require().ErrorContains(err, strings.Split(withdraw.ErrContractCaller, ",")[0]) + s.Require().ErrorContains(err, withdraw.ErrContractCaller) } diff --git a/precompiles/withdraw/withdraw_test.go b/precompiles/withdraw/withdraw_test.go index 4bcee8a88..19a0bd313 100644 --- a/precompiles/withdraw/withdraw_test.go +++ b/precompiles/withdraw/withdraw_test.go @@ -6,9 +6,8 @@ import ( sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/precompiles/withdraw" - "github.com/ExocoreNetwork/exocore/x/assets/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" - depositparams "github.com/ExocoreNetwork/exocore/x/deposit/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -51,8 +50,8 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { func (s *WithdrawPrecompileTestSuite) TestRequiredGas() { clientChainLzID := 101 - usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), types.GeneralClientChainAddrLength) - withdrawAddr := paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength) + usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), assetstype.GeneralClientChainAddrLength) + withdrawAddr := paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength) opAmount := big.NewInt(100) assetAddr := usdtAddress @@ -94,17 +93,17 @@ func (s *WithdrawPrecompileTestSuite) TestRequiredGas() { // TestRun tests the precompiled Run method withdraw. func (s *WithdrawPrecompileTestSuite) TestRunWithdrawThroughClientChain() { // deposit params for test - exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") clientChainLzID := 101 withdrawAmount := big.NewInt(10) depositAmount := big.NewInt(100) - assetAddr := paddingClientChainAddress(usdtAddress, types.GeneralClientChainAddrLength) + assetAddr := paddingClientChainAddress(usdtAddress, assetstype.GeneralClientChainAddrLength) depositAsset := func(staker []byte, depositAmount sdkmath.Int) { // deposit asset for withdraw test params := &keeper.DepositParams{ ClientChainLzID: 101, - Action: types.Deposit, + Action: assetstype.Deposit, StakerAddress: staker, AssetsAddress: usdtAddress, OpAmount: depositAmount, @@ -119,7 +118,7 @@ func (s *WithdrawPrecompileTestSuite) TestRunWithdrawThroughClientChain() { withdraw.MethodWithdraw, uint16(clientChainLzID), assetAddr, - paddingClientChainAddress(s.Address.Bytes(), types.GeneralClientChainAddrLength), + paddingClientChainAddress(s.Address.Bytes(), assetstype.GeneralClientChainAddrLength), withdrawAmount, ) s.Require().NoError(err, "failed to pack input") @@ -138,11 +137,11 @@ func (s *WithdrawPrecompileTestSuite) TestRunWithdrawThroughClientChain() { { name: "pass - withdraw via pre-compiles", malleate: func() (common.Address, []byte) { - depositModuleParam := &depositparams.Params{ - ExoCoreLzAppAddress: s.Address.String(), - ExoCoreLzAppEventTopic: exoCoreLzAppEventTopic, + depositModuleParam := &assetstype.Params{ + ExocoreLzAppAddress: s.Address.String(), + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } - err := s.App.DepositKeeper.SetParams(s.Ctx, depositModuleParam) + err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) depositAsset(s.Address.Bytes(), sdkmath.NewIntFromBigInt(depositAmount)) return commonMalleate() diff --git a/proto/exocore/assets/v1/params.proto b/proto/exocore/assets/v1/params.proto new file mode 100644 index 000000000..2c3aeea5c --- /dev/null +++ b/proto/exocore/assets/v1/params.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package exocore.assets.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; + +// GenesisState defines the deposit module's genesis state. +message Params { + // exocore_lz_app_address is the address of the exocore lz app. + string exocore_lz_app_address = 1 + [(gogoproto.customname) = "ExocoreLzAppAddress"]; + // exocore_lz_app_event_topic is the topic of the exocore lz app event. + string exocore_lz_app_event_topic = 2 + [(gogoproto.customname) = "ExocoreLzAppEventTopic"]; +} \ No newline at end of file diff --git a/proto/exocore/assets/v1/query.proto b/proto/exocore/assets/v1/query.proto index cb74ef137..18a22a7b7 100644 --- a/proto/exocore/assets/v1/query.proto +++ b/proto/exocore/assets/v1/query.proto @@ -3,6 +3,7 @@ package exocore.assets.v1; import "cosmos/query/v1/query.proto"; import "cosmos_proto/cosmos.proto"; +import "exocore/assets/v1/params.proto"; import "exocore/assets/v1/tx.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; @@ -49,7 +50,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; + map asset_infos = 1; } // QuerySpecifiedAssetAmountReq is the query for getting the staker specified asset amount. @@ -69,7 +70,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; + map asset_infos = 1; } // QueryOperatorSpecifiedAssetAmountReq is the query for getting the operator @@ -97,8 +98,23 @@ message QueryStakerExCoreAddrResponse { ]; } +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC +// method. +message QueryParamsResponse { + // params defines the parameters for this module. + Params params = 1 ; +} + // Query defines the gRPC query service for the assets module. service Query { + // Params retrieves the assets module params + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/exocore/assets/v1/Params"; + } + // ClientChainInfoByIndex queries the client chain info by index. rpc QueClientChainInfoByIndex(QueryClientChainInfo) returns (ClientChainInfo) { option (cosmos.query.v1.module_query_safe) = true; @@ -125,7 +141,7 @@ service Query { option (google.api.http).get = "/exocore/assets/v1/QueStakerAssetInfos"; } // StakerSpecifiedAssetAmount queries the staker specified asset amount. - rpc QueStakerSpecifiedAssetAmount(QuerySpecifiedAssetAmountReq)returns(StakerSingleAssetInfo){ + rpc QueStakerSpecifiedAssetAmount(QuerySpecifiedAssetAmountReq)returns(StakerAssetInfo){ option (cosmos.query.v1.module_query_safe) = true; option (google.api.http).get = "/exocore/assets/v1/QueStakerSpecifiedAssetAmount"; } @@ -135,7 +151,7 @@ service Query { option (google.api.http).get = "/exocore/assets/v1/QueOperatorAssetInfos"; } // OperatorSpecifiedAssetAmount queries the operator specified asset amount. - rpc QueOperatorSpecifiedAssetAmount(QueryOperatorSpecifiedAssetAmountReq) returns(OperatorSingleAssetInfo){ + rpc QueOperatorSpecifiedAssetAmount(QueryOperatorSpecifiedAssetAmountReq) returns(OperatorAssetInfo){ option (cosmos.query.v1.module_query_safe) = true; option (google.api.http).get = "/exocore/assets/v1/QueStakerSpecifiedAssetAmount"; } diff --git a/proto/exocore/assets/v1/tx.proto b/proto/exocore/assets/v1/tx.proto index dc831ab42..68f8fa50c 100644 --- a/proto/exocore/assets/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -4,6 +4,7 @@ package exocore.assets.v1; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; +import "exocore/assets/v1/params.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/assets/types"; @@ -92,10 +93,10 @@ message StakingAssetInfo { ]; } -// StakerSingleAssetInfo defines the information for a single asset. +// StakerAssetInfo defines the information for a single asset. // The type include three states: // staker's deposited, withdrawable, and currently unbonding amount. -message StakerSingleAssetInfo { +message StakerAssetInfo { // total_deposit_amount is the total amount of the asset deposited. string total_deposit_amount = 1 [ @@ -123,12 +124,12 @@ message StakerSingleAssetInfo { // It is indexed by the asset_id. message StakerAllAssetsInfo { // all_assets_state is the state of all assets of the staker. - map all_assets_state = 1; + map all_assets_state = 1; } -// OperatorSingleAssetInfo defines the information for a single asset, -// for an operator. It is also overloaded like StakerSingleAssetInfo. -message OperatorSingleAssetInfo { +// OperatorAssetInfo defines the information for a single asset, +// for an operator. +message OperatorAssetInfo { // total_amount is the total amount of the asset deposited. string total_amount = 1 [ @@ -137,9 +138,9 @@ message OperatorSingleAssetInfo { (gogoproto.nullable) = false ]; - // operator_own_amount is the amount that the operator owns. + // operator_amount is the amount that the operator owns. //todo: the field is used to mark operator's own assets and is not temporarily used now - string operator_own_amount = 2 + string operator_amount = 2 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -175,7 +176,7 @@ message OperatorSingleAssetInfo { // indexed by the asset_id. message OperatorAllAssetsInfo { // all_assets_state is the state of all assets of the operator. - map all_assets_state = 1; + map all_assets_state = 1; } // MsgSetExoCoreAddr defines the MsgSetExoCoreAddr message used to set the @@ -239,9 +240,29 @@ message RegisterAssetReq { // RegisterAssetResponse is the response to the RegisterAssetReq message. message RegisterAssetResponse {} +// MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. +// Since: cosmos-sdk 0.47 +message MsgUpdateParams { + // todo: temporarily not update configuration through gov module + option (cosmos.msg.v1.signer) = "authority"; + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/evm parameters to update. + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsResponse {} + // Msg defines the assets Msg service service Msg { option (cosmos.msg.v1.service) = true; + // UpdateParams updates the parameters of the assets module. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); // SetStakerExoCoreAddr sets the exocore address of the staker rpc SetStakerExoCoreAddr(MsgSetExoCoreAddr) returns (MsgSetExoCoreAddrResponse); // RegisterClientChain registers the client chain diff --git a/proto/exocore/deposit/v1/deposit.proto b/proto/exocore/deposit/v1/deposit.proto index 6aee9dd16..32a336552 100644 --- a/proto/exocore/deposit/v1/deposit.proto +++ b/proto/exocore/deposit/v1/deposit.proto @@ -8,11 +8,4 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/deposit/types"; // GenesisState defines the deposit module's genesis state. -message Params { - // exocore_lz_app_address is the address of the exocore lz app. - string exocore_lz_app_address = 1 - [(gogoproto.customname) = "ExoCoreLzAppAddress"]; - // exocore_lz_app_event_topic is the topic of the exocore lz app event. - string exocore_lz_app_event_topic = 2 - [(gogoproto.customname) = "ExoCoreLzAppEventTopic"]; -} +message Params {} diff --git a/proto/exocore/reward/params.proto b/proto/exocore/reward/params.proto index fe12aa2d0..a3bd73a15 100644 --- a/proto/exocore/reward/params.proto +++ b/proto/exocore/reward/params.proto @@ -4,9 +4,4 @@ package exocore.reward; option go_package = "github.com/ExocoreNetwork/exocore/x/reward/types"; // Params defines the parameters for the module. -message Params { - // exo_core_lz_app_address is the address of the L0 app. - string exo_core_lz_app_address = 1; - // exo_core_lz_app_event_topic is the topic of the L0 app. - string exo_core_lz_app_event_topic =2; -} +message Params {} diff --git a/proto/exocore/slash/params.proto b/proto/exocore/slash/params.proto index 977d42f20..7f50c4509 100644 --- a/proto/exocore/slash/params.proto +++ b/proto/exocore/slash/params.proto @@ -4,10 +4,4 @@ package exocore.slash; option go_package = "github.com/ExocoreNetwork/exocore/x/slash/types"; // Params defines the parameters for the module. -message Params { - // exo_core_lz_app_address defines the address of the lz app - string exo_core_lz_app_address = 1; - // exo_core_lz_app_event_topic defines the topic of the lz app - string exo_core_lz_app_event_topic = 2; - -} +message Params {} diff --git a/x/assets/client/cli/query.go b/x/assets/client/cli/query.go index 98d32fee8..aeac1286c 100644 --- a/x/assets/client/cli/query.go +++ b/x/assets/client/cli/query.go @@ -51,7 +51,7 @@ func QueClientChainInfoByIndex() *cobra.Command { } clientChainLzID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { - return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) + return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error()) } queryClient := types.NewQueryClient(clientCtx) req := &types.QueryClientChainInfo{ @@ -111,7 +111,7 @@ func QueStakingAssetInfo() *cobra.Command { clientChainLzID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { - return errorsmod.Wrap(types.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[1])) + return errorsmod.Wrap(types.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[1])) } _, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, "", args[0]) @@ -203,7 +203,7 @@ func QueStakerSpecifiedAssetAmount() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) clientChainLzID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { - return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) + return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error()) } stakerID, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, args[1], args[2]) req := &types.QuerySpecifiedAssetAmountReq{ @@ -266,7 +266,7 @@ func QueOperatorSpecifiedAssetAmount() *cobra.Command { clientChainLzID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { - return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) + return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error()) } _, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, "", args[2]) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/assets/client/cli/tx.go b/x/assets/client/cli/tx.go index aba570c42..09a3766da 100644 --- a/x/assets/client/cli/tx.go +++ b/x/assets/client/cli/tx.go @@ -28,10 +28,43 @@ func NewTxCmd() *cobra.Command { txCmd.AddCommand( RegisterClientChain(), RegisterAsset(), + UpdateParams(), ) return txCmd } +// UpdateParams todo: it should be a gov proposal command in future. +func UpdateParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "UpdateParams ExoCoreLZAppAddr ExoCoreLzAppEventTopic", + Short: "Set ExoCoreLZAppAddr and ExoCoreLzAppEventTopic params to assets module", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + sender := cliCtx.GetFromAddress() + msg := &assetstype.MsgUpdateParams{ + Authority: sender.String(), + Params: assetstype.Params{ + ExocoreLzAppAddress: args[0], + ExocoreLzAppEventTopic: args[1], + }, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + // RegisterClientChain register client chain // todo: this function should be controlled by governance in the future func RegisterClientChain() *cobra.Command { @@ -55,11 +88,11 @@ func RegisterClientChain() *cobra.Command { } lzChainID, err := strconv.ParseUint(args[2], 10, 64) if err != nil { - return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[2])) + return errorsmod.Wrap(assetstype.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[2])) } addressLength, err := strconv.ParseUint(args[3], 10, 32) if err != nil { - return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[3])) + return errorsmod.Wrap(assetstype.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[3])) } msg.Info.LayerZeroChainID = lzChainID msg.Info.AddressLength = uint32(addressLength) @@ -99,16 +132,16 @@ func RegisterAsset() *cobra.Command { } totalSupply, ok := sdkmath.NewIntFromString(args[4]) if !ok { - return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[4])) + return errorsmod.Wrap(assetstype.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[4])) } lzChainID, err := strconv.ParseUint(args[5], 10, 64) if err != nil { - return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[5])) + return errorsmod.Wrap(assetstype.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[5])) } decimal, err := strconv.ParseUint(args[6], 10, 32) if err != nil { - return errorsmod.Wrap(assetstype.ErrCliCmdInputArg, fmt.Sprintf("error arg is:%v", args[6])) + return errorsmod.Wrap(assetstype.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[6])) } msg.Info.TotalSupply = totalSupply diff --git a/x/assets/keeper/app_chain.go b/x/assets/keeper/app_chain.go index ceec86c58..7a70ebd92 100644 --- a/x/assets/keeper/app_chain.go +++ b/x/assets/keeper/app_chain.go @@ -32,7 +32,7 @@ func (k Keeper) GetAppChainInfoByChainID( store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixAppChainInfo) ifExist := store.Has([]byte(chainID)) if !ifExist { - return assetstype.AppChainInfo{}, assetstype.ErrNoAppChainKey + return assetstype.AppChainInfo{}, assetstype.ErrUnknownAppChainID } value := store.Get([]byte(chainID)) ret := assetstype.AppChainInfo{} diff --git a/x/assets/keeper/client_chain_and_asset_test.go b/x/assets/keeper/client_chain_and_asset_test.go index ca24c1d86..9feb73a1b 100644 --- a/x/assets/keeper/client_chain_and_asset_test.go +++ b/x/assets/keeper/client_chain_and_asset_test.go @@ -9,7 +9,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { defaultGensisState := assets.DefaultGenesisState() // test the client chains getting - clientChains, err := suite.App.StakingAssetsManageKeeper.GetAllClientChainInfo(suite.Ctx) + clientChains, err := suite.App.AssetsKeeper.GetAllClientChainInfo(suite.Ctx) suite.NoError(err) suite.Ctx.Logger().Info("the clientChains is:", "info", clientChains) for _, clientChain := range defaultGensisState.DefaultSupportedClientChains { @@ -18,12 +18,12 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { suite.Equal(info, clientChain) } - chainInfo, err := suite.App.StakingAssetsManageKeeper.GetClientChainInfoByIndex(suite.Ctx, 101) + chainInfo, err := suite.App.AssetsKeeper.GetClientChainInfoByIndex(suite.Ctx, 101) suite.NoError(err) suite.Equal(clientChains[101], chainInfo) // test the client chain assets getting - assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) + assets, err := suite.App.AssetsKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) for _, asset := range defaultGensisState.DefaultSupportedClientChainTokens { _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) @@ -35,7 +35,7 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { usdtAsset := defaultGensisState.DefaultSupportedClientChainTokens[0] _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainID, "", usdtAsset.Address) - assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) + assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(usdtAsset, assetInfo.AssetBasicInfo) } diff --git a/x/assets/keeper/grpc_query.go b/x/assets/keeper/grpc_query.go index 3a77991bd..40b20fb87 100644 --- a/x/assets/keeper/grpc_query.go +++ b/x/assets/keeper/grpc_query.go @@ -10,6 +10,17 @@ import ( "google.golang.org/grpc/status" ) +func (k Keeper) Params(ctx context.Context, _ *assetstype.QueryParamsRequest) (*assetstype.QueryParamsResponse, error) { + c := sdk.UnwrapSDKContext(ctx) + params, err := k.GetParams(c) + if err != nil { + return nil, err + } + return &assetstype.QueryParamsResponse{ + Params: params, + }, nil +} + // QueClientChainInfoByIndex query client chain info by clientChainLzID func (k Keeper) QueClientChainInfoByIndex(ctx context.Context, info *assetstype.QueryClientChainInfo) (*assetstype.ClientChainInfo, error) { c := sdk.UnwrapSDKContext(ctx) @@ -54,7 +65,7 @@ func (k Keeper) QueStakerAssetInfos(ctx context.Context, info *assetstype.QueryS } // QueStakerSpecifiedAssetAmount query the specified asset state of a staker, using stakerID and assetID as query parameters -func (k Keeper) QueStakerSpecifiedAssetAmount(ctx context.Context, req *assetstype.QuerySpecifiedAssetAmountReq) (*assetstype.StakerSingleAssetInfo, error) { +func (k Keeper) QueStakerSpecifiedAssetAmount(ctx context.Context, req *assetstype.QuerySpecifiedAssetAmountReq) (*assetstype.StakerAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) return k.GetStakerSpecifiedAssetInfo(c, req.StakerID, req.AssetID) } @@ -74,7 +85,7 @@ func (k Keeper) QueOperatorAssetInfos(ctx context.Context, infos *assetstype.Que } // QueOperatorSpecifiedAssetAmount query the specified asset state of an operator, using operator address and assetID as query parameters -func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *assetstype.QueryOperatorSpecifiedAssetAmountReq) (*assetstype.OperatorSingleAssetInfo, error) { +func (k Keeper) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *assetstype.QueryOperatorSpecifiedAssetAmountReq) (*assetstype.OperatorAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) addr, err := sdk.AccAddressFromBech32(req.OperatorAddr) if err != nil { diff --git a/x/assets/keeper/keeper.go b/x/assets/keeper/keeper.go index 73398c4a7..ec7bf8e14 100644 --- a/x/assets/keeper/keeper.go +++ b/x/assets/keeper/keeper.go @@ -46,12 +46,12 @@ type IRestakingAssetsManage interface { GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *assetstype.StakingAssetInfo, err error) GetAllStakingAssetsInfo(ctx sdk.Context) (allAssets map[string]*assetstype.StakingAssetInfo, err error) - GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerSingleAssetInfo, err error) - GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerSingleAssetInfo, err error) + GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerAssetInfo, 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.StakerSingleAssetChangeInfo) (err error) - GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) (assetsInfo map[string]*assetstype.OperatorSingleAssetInfo, err error) - GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorSingleAssetInfo, err error) + GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address) (assetsInfo map[string]*assetstype.OperatorAssetInfo, 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.OperatorSingleAssetChangeInfo) (err error) // SetStakerExoCoreAddr handle the SetStakerExoCoreAddr txs from msg service diff --git a/x/assets/keeper/msg_server.go b/x/assets/keeper/msg_server.go index cf5ab7822..d89d9591b 100644 --- a/x/assets/keeper/msg_server.go +++ b/x/assets/keeper/msg_server.go @@ -13,6 +13,16 @@ import ( var _ assetstype.MsgServer = &Keeper{} +// UpdateParams This function should be triggered by the governance in the future +func (k Keeper) UpdateParams(ctx context.Context, params *assetstype.MsgUpdateParams) (*assetstype.MsgUpdateParamsResponse, error) { + c := sdk.UnwrapSDKContext(ctx) + err := k.SetParams(c, ¶ms.Params) + if err != nil { + return nil, err + } + return nil, nil +} + // SetStakerExoCoreAddr outdated, will be deprecated. // don't check if the staker has existed temporarily,so users can set their ExoCoreAddr multiple times. // It may be modified later to allow setting only once diff --git a/x/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go index 355dad5fc..1b575b895 100644 --- a/x/assets/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -10,16 +10,16 @@ import ( // This file provides all functions about operator assets state management. -func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, _ map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorSingleAssetInfo, err error) { +func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, _ map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorAssetInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) // the key is the operator address in the bech32 format key := []byte(operatorAddr.String()) iterator := sdk.KVStorePrefixIterator(store, key) defer iterator.Close() - ret := make(map[string]*assetstype.OperatorSingleAssetInfo, 0) + ret := make(map[string]*assetstype.OperatorAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { - var stateInfo assetstype.OperatorSingleAssetInfo + var stateInfo assetstype.OperatorAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { @@ -31,7 +31,7 @@ func (k Keeper) GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, return ret, nil } -func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorSingleAssetInfo, err error) { +func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk.Address, assetID string) (info *assetstype.OperatorAssetInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) key := assetstype.GetJoinedStoreKey(operatorAddr.String(), assetID) ifExist := store.Has(key) @@ -41,12 +41,12 @@ func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk. value := store.Get(key) - ret := assetstype.OperatorSingleAssetInfo{} + ret := assetstype.OperatorAssetInfo{} k.cdc.MustUnmarshal(value, &ret) return &ret, nil } -// UpdateOperatorAssetState It's used to update the operator states that include TotalAmount OperatorOwnAmount and WaitUndelegationAmount +// UpdateOperatorAssetState It's used to update the operator states that include TotalAmount OperatorAmount and WaitUndelegationAmount // The input `changeAmount` represents the values that you want to add or decrease,using positive or negative values for increasing and decreasing,respectively. The function will calculate and update new state after a successful check. // The function will be called when there is delegation or undelegation related to the operator. In the future,it will also be called when the operator deposit their own assets. @@ -54,9 +54,9 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre // get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) key := assetstype.GetJoinedStoreKey(operatorAddr.String(), assetID) - assetState := assetstype.OperatorSingleAssetInfo{ + assetState := assetstype.OperatorAssetInfo{ TotalAmount: math.NewInt(0), - OperatorOwnAmount: math.NewInt(0), + OperatorAmount: math.NewInt(0), WaitUnbondingAmount: math.NewInt(0), OperatorUnbondingAmount: math.NewInt(0), OperatorUnbondableAmountAfterSlash: math.NewInt(0), @@ -71,9 +71,9 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre if err != nil { return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") } - err = assetstype.UpdateAssetValue(&assetState.OperatorOwnAmount, &changeAmount.OperatorOwnAmount) + err = assetstype.UpdateAssetValue(&assetState.OperatorAmount, &changeAmount.OperatorAmount) if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnAmountOrWantChangeValue error") + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorAmountOrWantChangeValue error") } err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) if err != nil { @@ -94,13 +94,13 @@ func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Addre return nil } -func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *assetstype.OperatorSingleAssetInfo) error) error { +func (k Keeper) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *assetstype.OperatorAssetInfo) error) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixOperatorAssetInfos) iterator := sdk.KVStorePrefixIterator(store, nil) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amounts assetstype.OperatorSingleAssetInfo + var amounts assetstype.OperatorAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &amounts) keys, err := assetstype.ParseJoinedKey(iterator.Key()) if err != nil { diff --git a/x/assets/keeper/params.go b/x/assets/keeper/params.go new file mode 100644 index 000000000..bd7b9ad81 --- /dev/null +++ b/x/assets/keeper/params.go @@ -0,0 +1,62 @@ +package keeper + +import ( + "strings" + + errorsmod "cosmossdk.io/errors" + + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +func (k Keeper) SetParams(ctx sdk.Context, params *assetstypes.Params) error { + // check if addr is evm address + if !common.IsHexAddress(params.ExocoreLzAppAddress) { + return assetstypes.ErrInvalidEvmAddressFormat + } + if len(common.FromHex(params.ExocoreLzAppEventTopic)) != common.HashLength { + return assetstypes.ErrInvalidLzUaTopicIDLength + } + params.ExocoreLzAppAddress = strings.ToLower(params.ExocoreLzAppAddress) + params.ExocoreLzAppEventTopic = strings.ToLower(params.ExocoreLzAppEventTopic) + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstypes.KeyPrefixParams) + bz := k.cdc.MustMarshal(params) + store.Set(assetstypes.ParamsKey, bz) + return nil +} + +func (k Keeper) GetParams(ctx sdk.Context) (*assetstypes.Params, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstypes.KeyPrefixParams) + isExist := store.Has(assetstypes.ParamsKey) + if !isExist { + return nil, assetstypes.ErrNoParamsKey + } + + value := store.Get(assetstypes.ParamsKey) + + ret := &assetstypes.Params{} + k.cdc.MustUnmarshal(value, ret) + return ret, nil +} + +func (k Keeper) GetExocoreLzAppAddress(ctx sdk.Context) (common.Address, error) { + depositModuleParam, err := k.GetParams(ctx) + if err != nil { + return common.Address{}, err + } + return common.HexToAddress(depositModuleParam.ExocoreLzAppAddress), nil +} + +func (k Keeper) CheckExocoreLzAppAddr(ctx sdk.Context, addr common.Address) error { + param, err := k.GetParams(ctx) + if err != nil { + return err + } + exoCoreLzAppAddr := common.HexToAddress(param.ExocoreLzAppAddress) + if addr != exoCoreLzAppAddr { + return errorsmod.Wrapf(assetstypes.ErrNotEqualToLzAppAddr, "addr:%s,param.ExocoreLzAppAddress:%s", addr, param.ExocoreLzAppAddress) + } + return nil +} diff --git a/x/assets/keeper/params_test.go b/x/assets/keeper/params_test.go new file mode 100644 index 000000000..b7d45dadb --- /dev/null +++ b/x/assets/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" +) + +func (suite *StakingAssetsTestSuite) TestParams() { + params := &assetstype.Params{ + ExocoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", + ExocoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", + } + err := suite.App.AssetsKeeper.SetParams(suite.Ctx, params) + suite.NoError(err) + + getParams, err := suite.App.AssetsKeeper.GetParams(suite.Ctx) + suite.NoError(err) + suite.Equal(*params, *getParams) +} diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index 5ac4ff36a..2051c84a5 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -11,14 +11,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerSingleAssetInfo, err error) { +func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInfo map[string]*assetstype.StakerAssetInfo, 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.StakerSingleAssetInfo, 0) + ret := make(map[string]*assetstype.StakerAssetInfo, 0) for ; iterator.Valid(); iterator.Next() { - var stateInfo assetstype.StakerSingleAssetInfo + var stateInfo assetstype.StakerAssetInfo k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) if err != nil { @@ -30,7 +30,7 @@ func (k Keeper) GetStakerAssetInfos(ctx sdk.Context, stakerID string) (assetsInf return ret, nil } -func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerSingleAssetInfo, err error) { +func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerAssetInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) key := assetstype.GetJoinedStoreKey(stakerID, assetID) ifExist := store.Has(key) @@ -40,7 +40,7 @@ func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, as value := store.Get(key) - ret := assetstype.StakerSingleAssetInfo{} + ret := assetstype.StakerAssetInfo{} k.cdc.MustUnmarshal(value, &ret) return &ret, nil } @@ -52,7 +52,7 @@ func (k Keeper) UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID // get the latest state,use the default initial state if the state hasn't been stored store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixReStakerAssetInfos) key := assetstype.GetJoinedStoreKey(stakerID, assetID) - assetState := assetstype.StakerSingleAssetInfo{ + assetState := assetstype.StakerAssetInfo{ TotalDepositAmount: math.NewInt(0), WithdrawableAmount: math.NewInt(0), WaitUnbondingAmount: math.NewInt(0), diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go index 41fac44b5..6459199f8 100644 --- a/x/assets/keeper/staker_asset_test.go +++ b/x/assets/keeper/staker_asset_test.go @@ -17,11 +17,11 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { } // test the initial storage of statker assets state - err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + err := suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) // test that the retrieved value is correct - getInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + getInfo, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(ethUniInitialChangeValue.TotalDepositAmount.Equal(getInfo.TotalDepositAmount)) suite.Require().True(ethUniInitialChangeValue.WithdrawableAmount.Equal(getInfo.WithdrawableAmount)) @@ -29,10 +29,10 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { // test valid increase of staker asset state ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(500) ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(500) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + getInfo, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1500))) suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1500))) @@ -40,9 +40,9 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { // test valid decrease of staker asset state ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-500) ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-500) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + getInfo, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) @@ -50,18 +50,18 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { // test the decreased amount is bigger than original state ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-2000) ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-500) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + getInfo, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-500) ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-2000) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) + getInfo, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUniAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(1000))) suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(1000))) @@ -72,9 +72,9 @@ func (suite *StakingAssetsTestSuite) TestUpdateStakerAssetsState() { TotalDepositAmount: math.NewInt(2000), WithdrawableAmount: math.NewInt(2000), } - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) suite.Require().NoError(err) - getInfo, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUsdtAssetID) + getInfo, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, ethUsdtAssetID) suite.Require().NoError(err) suite.Require().True(getInfo.TotalDepositAmount.Equal(math.NewInt(2000))) suite.Require().True(getInfo.WithdrawableAmount.Equal(math.NewInt(2000))) @@ -92,13 +92,13 @@ func (suite *StakingAssetsTestSuite) TestGetStakerAssetInfos() { TotalDepositAmount: math.NewInt(2000), WithdrawableAmount: math.NewInt(2000), } - err := suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + err := suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) suite.Require().NoError(err) - err = suite.App.StakingAssetsManageKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) suite.Require().NoError(err) // test get all assets state of staker - assetsInfo, err := suite.App.StakingAssetsManageKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) + assetsInfo, err := suite.App.AssetsKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) suite.Require().NoError(err) uniState, isExist := assetsInfo[ethUniAssetID] suite.Require().True(isExist) diff --git a/x/assets/types/errors.go b/x/assets/types/errors.go index 562b0232b..16929dec5 100644 --- a/x/assets/types/errors.go +++ b/x/assets/types/errors.go @@ -17,11 +17,19 @@ var ( ErrParseAssetsStateKey = errorsmod.Register(ModuleName, 5, "assets state key can't be parsed") - ErrCliCmdInputArg = errorsmod.Register(ModuleName, 6, "there is an error in the input client command args") + ErrInvalidCliCmdArg = errorsmod.Register(ModuleName, 6, "the input client command arguments are invalid") ErrInputPointerIsNil = errorsmod.Register(ModuleName, 7, "the input pointer is nil") - ErrOperatorAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid acc addr") + ErrInvalidOperatorAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid account address") - ErrNoAppChainKey = errorsmod.Register(ModuleName, 10, "there is no stored key for the input app chain id") + ErrUnknownAppChainID = errorsmod.Register(ModuleName, 9, "the app chain id is unknown or invalid") + + ErrInvalidEvmAddressFormat = errorsmod.Register(ModuleName, 10, "the evm address format is error") + + ErrInvalidLzUaTopicIDLength = errorsmod.Register(ModuleName, 11, "the LZUaTopicID length isn't equal to HashLength") + + ErrNoParamsKey = errorsmod.Register(ModuleName, 12, "there is no stored key for deposit module params") + + ErrNotEqualToLzAppAddr = errorsmod.Register(ModuleName, 13, "the address isn't equal to the layerZero gateway address") ) diff --git a/x/assets/types/general.go b/x/assets/types/general.go index a15f16ce6..7e93ceb81 100644 --- a/x/assets/types/general.go +++ b/x/assets/types/general.go @@ -43,11 +43,11 @@ type CrossChainOpType uint8 type WithdrawerAddress [32]byte -// StakerSingleAssetChangeInfo This is a struct to describe the desired change that matches with the StakerSingleAssetInfo -type StakerSingleAssetChangeInfo StakerSingleAssetInfo +// StakerSingleAssetChangeInfo This is a struct to describe the desired change that matches with the StakerAssetInfo +type StakerSingleAssetChangeInfo StakerAssetInfo -// OperatorSingleAssetChangeInfo This is a struct to describe the desired change that matches with the OperatorSingleAssetInfo -type OperatorSingleAssetChangeInfo OperatorSingleAssetInfo +// OperatorSingleAssetChangeInfo This is a struct to describe the desired change that matches with the OperatorAssetInfo +type OperatorSingleAssetChangeInfo OperatorAssetInfo // GetStakeIDAndAssetID stakerID = stakerAddress+'_'+clientChainLzID,assetID = assetAddress+'_'+clientChainLzID func GetStakeIDAndAssetID(clientChainLzID uint64, stakerAddress []byte, assetsAddress []byte) (stakeID string, assetID string) { diff --git a/x/assets/types/keys.go b/x/assets/types/keys.go index cb9f2e5e9..02c17b9d2 100644 --- a/x/assets/types/keys.go +++ b/x/assets/types/keys.go @@ -50,6 +50,7 @@ const ( // add for dogfood prefixOperatorSnapshot prefixOperatorLastSnapshotHeight + prefixParams ) // KVStore key prefixes @@ -94,13 +95,13 @@ var ( // KeyPrefixReStakingAssetInfo key->value: AssetID->ReStakingAssetInfo KeyPrefixReStakingAssetInfo = []byte{prefixRestakingAssetInfo} - // KeyPrefixReStakerAssetInfos reStakerID = clientChainAddr+'_'+ExoCoreChainIndex - // KeyPrefixReStakerAssetInfos key->value: reStakerID+'_'+AssetID->ReStakerSingleAssetInfo - // or reStakerID->mapping(AssetID->ReStakerSingleAssetInfo)? + // KeyPrefixReStakerAssetInfos restakerID = clientChainAddr+'_'+ExoCoreChainIndex + // KeyPrefixReStakerAssetInfos key->value: restakerID+'_'+AssetID->ReStakerAssetInfo + // or restakerID->mapping(AssetID->ReStakerAssetInfo)? KeyPrefixReStakerAssetInfos = []byte{prefixRestakerAssetInfo} - // KeyPrefixOperatorAssetInfos key->value: operatorAddr+'_'+AssetID->OperatorSingleAssetInfo - // or operatorAddr->mapping(AssetID->OperatorSingleAssetInfo) ? + // KeyPrefixOperatorAssetInfos key->value: operatorAddr+'_'+AssetID->OperatorAssetInfo + // or operatorAddr->mapping(AssetID->OperatorAssetInfo) ? KeyPrefixOperatorAssetInfos = []byte{prefixOperatorAssetInfo} // KeyPrefixOperatorOptedInMiddleWareAssetInfos key->value: @@ -110,13 +111,17 @@ var ( prefixOperatorOptedInMiddlewareAssetInfo, } - // KeyPrefixReStakerExoCoreAddr reStakerID = clientChainAddr+'_'+ExoCoreChainIndex - // KeyPrefixReStakerExoCoreAddr key-value: reStakerID->exoCoreAddr + // KeyPrefixReStakerExoCoreAddr restakerID = clientChainAddr+'_'+ExoCoreChainIndex + // KeyPrefixReStakerExoCoreAddr key-value: restakerID->exoCoreAddr KeyPrefixReStakerExoCoreAddr = []byte{prefixRestakerExocoreAddr} // KeyPrefixReStakerExoCoreAddrReverse k->v: exocoreAddress -> // map[clientChainIndex]clientChainAddress // used to retrieve all user assets based on their exoCore address KeyPrefixReStakerExoCoreAddrReverse = []byte{prefixRestakerExocoreAddrReverse} + + // KeyPrefixParams This is a key prefix for module parameter + KeyPrefixParams = []byte{prefixParams} + ParamsKey = []byte("Params") ) func GetJoinedStoreKey(keys ...string) []byte { diff --git a/x/assets/types/msg.go b/x/assets/types/msg.go index 8905d2b89..e64821400 100644 --- a/x/assets/types/msg.go +++ b/x/assets/types/msg.go @@ -6,11 +6,31 @@ import ( ) var ( + _ sdk.Msg = &MsgUpdateParams{} _ sdk.Msg = &MsgSetExoCoreAddr{} _ sdk.Msg = &RegisterClientChainReq{} _ sdk.Msg = &RegisterAssetReq{} ) +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.Authority) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check of the provided data +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errorsmod.Wrap(err, "invalid from address") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (m *MsgUpdateParams) GetSignBytes() []byte { + return nil +} + // GetSigners returns the expected signers for a MsgUpdateParams message. func (m *MsgSetExoCoreAddr) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.FromAddress) diff --git a/x/assets/types/params.pb.go b/x/assets/types/params.pb.go new file mode 100644 index 000000000..b06a93ed0 --- /dev/null +++ b/x/assets/types/params.pb.go @@ -0,0 +1,375 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/assets/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// GenesisState defines the deposit module's genesis state. +type Params struct { + // exocore_lz_app_address is the address of the exocore lz app. + ExocoreLzAppAddress string `protobuf:"bytes,1,opt,name=exocore_lz_app_address,json=exocoreLzAppAddress,proto3" json:"exocore_lz_app_address,omitempty"` + // exocore_lz_app_event_topic is the topic of the exocore lz app event. + ExocoreLzAppEventTopic string `protobuf:"bytes,2,opt,name=exocore_lz_app_event_topic,json=exocoreLzAppEventTopic,proto3" json:"exocore_lz_app_event_topic,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_cf4772c4d7b6d2f9, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetExocoreLzAppAddress() string { + if m != nil { + return m.ExocoreLzAppAddress + } + return "" +} + +func (m *Params) GetExocoreLzAppEventTopic() string { + if m != nil { + return m.ExocoreLzAppEventTopic + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "exocore.assets.v1.Params") +} + +func init() { proto.RegisterFile("exocore/assets/v1/params.proto", fileDescriptor_cf4772c4d7b6d2f9) } + +var fileDescriptor_cf4772c4d7b6d2f9 = []byte{ + // 242 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x48, + 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0xca, 0xeb, 0x41, + 0xe4, 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, + 0xa1, 0xd2, 0x3a, 0x46, 0x2e, 0xb6, 0x00, 0xb0, 0x4e, 0x21, 0x1f, 0x2e, 0x31, 0xa8, 0xae, 0xf8, + 0x9c, 0xaa, 0xf8, 0xc4, 0x82, 0x82, 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0x62, 0x09, 0x46, + 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xf1, 0x47, 0xf7, 0xe4, 0x85, 0x5d, 0x21, 0x2a, 0x7c, 0xaa, 0x1c, + 0x0b, 0x0a, 0x1c, 0x21, 0xd2, 0x41, 0xc2, 0xa9, 0x98, 0x82, 0x42, 0x61, 0x5c, 0x52, 0x68, 0xa6, + 0xa5, 0x96, 0xa5, 0xe6, 0x95, 0xc4, 0x97, 0xe4, 0x17, 0x64, 0x26, 0x4b, 0x30, 0x81, 0x4d, 0x94, + 0x7a, 0x74, 0x4f, 0x5e, 0x0c, 0xd9, 0x44, 0x57, 0x90, 0x92, 0x10, 0x90, 0x8a, 0x20, 0xb1, 0x54, + 0xac, 0xe2, 0x4e, 0x5e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, + 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x90, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x35, 0xd4, 0x2f, 0xb5, 0xa4, + 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0x16, 0x5a, 0x15, 0xb0, 0xf0, 0x2a, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0x87, 0x81, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xe2, 0xbd, 0x2e, 0x68, 0x4e, 0x01, + 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ExocoreLzAppEventTopic) > 0 { + i -= len(m.ExocoreLzAppEventTopic) + copy(dAtA[i:], m.ExocoreLzAppEventTopic) + i = encodeVarintParams(dAtA, i, uint64(len(m.ExocoreLzAppEventTopic))) + i-- + dAtA[i] = 0x12 + } + if len(m.ExocoreLzAppAddress) > 0 { + i -= len(m.ExocoreLzAppAddress) + copy(dAtA[i:], m.ExocoreLzAppAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.ExocoreLzAppAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ExocoreLzAppAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.ExocoreLzAppEventTopic) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreLzAppAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExocoreLzAppAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreLzAppEventTopic", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExocoreLzAppEventTopic = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/assets/types/query.pb.go b/x/assets/types/query.pb.go index 1020500f2..2ca380f32 100644 --- a/x/assets/types/query.pb.go +++ b/x/assets/types/query.pb.go @@ -339,7 +339,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]*StakerSingleAssetInfo `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 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"` } func (m *QueryAssetInfoResponse) Reset() { *m = QueryAssetInfoResponse{} } @@ -375,7 +375,7 @@ func (m *QueryAssetInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAssetInfoResponse proto.InternalMessageInfo -func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerSingleAssetInfo { +func (m *QueryAssetInfoResponse) GetAssetInfos() map[string]*StakerAssetInfo { if m != nil { return m.AssetInfos } @@ -486,7 +486,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]*OperatorSingleAssetInfo `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 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"` } func (m *QueryOperatorAssetInfosResponse) Reset() { *m = QueryOperatorAssetInfosResponse{} } @@ -522,7 +522,7 @@ func (m *QueryOperatorAssetInfosResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryOperatorAssetInfosResponse proto.InternalMessageInfo -func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorSingleAssetInfo { +func (m *QueryOperatorAssetInfosResponse) GetAssetInfos() map[string]*OperatorAssetInfo { if m != nil { return m.AssetInfos } @@ -678,6 +678,90 @@ func (m *QueryStakerExCoreAddrResponse) GetExoCoreAddr() string { return "" } +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1de33a8cf38ccb9d, []int{14} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC +// method. +type QueryParamsResponse struct { + // params defines the parameters for this module. + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1de33a8cf38ccb9d, []int{15} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + func init() { proto.RegisterType((*QueryClientChainInfo)(nil), "exocore.assets.v1.QueryClientChainInfo") proto.RegisterType((*QueryAllClientChainInfo)(nil), "exocore.assets.v1.QueryAllClientChainInfo") @@ -689,84 +773,89 @@ func init() { 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]*StakerSingleAssetInfo)(nil), "exocore.assets.v1.QueryAssetInfoResponse.AssetInfosEntry") + 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]*OperatorSingleAssetInfo)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse.AssetInfosEntry") + 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") + proto.RegisterType((*QueryParamsRequest)(nil), "exocore.assets.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "exocore.assets.v1.QueryParamsResponse") } func init() { proto.RegisterFile("exocore/assets/v1/query.proto", fileDescriptor_1de33a8cf38ccb9d) } var fileDescriptor_1de33a8cf38ccb9d = []byte{ - // 1010 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x97, 0xc1, 0x6f, 0xdc, 0x44, - 0x14, 0xc6, 0x33, 0x5b, 0xda, 0x26, 0xb3, 0x41, 0xc0, 0x34, 0xa4, 0x1b, 0xb7, 0xdd, 0x0d, 0x06, - 0x35, 0xdb, 0x55, 0xb0, 0xd3, 0x2d, 0x28, 0x0d, 0x52, 0x81, 0x4d, 0x9a, 0x43, 0x8a, 0x54, 0xd4, - 0xcd, 0x05, 0xf5, 0xb2, 0x72, 0xd7, 0x13, 0xd7, 0xc4, 0xf1, 0x6c, 0x3c, 0xde, 0xb0, 0x2b, 0x84, - 0x84, 0x90, 0x90, 0xb8, 0x20, 0x55, 0xe2, 0xd4, 0x0b, 0x17, 0xee, 0x08, 0x24, 0x84, 0xc4, 0x81, - 0x23, 0x12, 0xc7, 0x0a, 0x2e, 0x5c, 0x88, 0xd0, 0x06, 0x89, 0x33, 0xff, 0x01, 0xf2, 0xcc, 0xac, - 0xd7, 0x6b, 0xcf, 0xb8, 0x0e, 0xbd, 0xad, 0xe7, 0xbd, 0x99, 0xf7, 0xf9, 0xf7, 0xc6, 0xef, 0x4b, - 0xe0, 0x15, 0x3c, 0x20, 0x5d, 0x12, 0x60, 0xd3, 0xa2, 0x14, 0x87, 0xd4, 0x3c, 0xba, 0x6e, 0x1e, - 0xf6, 0x71, 0x30, 0x34, 0x7a, 0x01, 0x09, 0x09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0x9b, - 0x68, 0x2d, 0x4f, 0xb1, 0x54, 0x99, 0xf8, 0xc4, 0x24, 0x6e, 0xd4, 0x28, 0xee, 0x0a, 0xea, 0x4f, - 0x4c, 0xed, 0x20, 0x85, 0x3e, 0x31, 0x89, 0xac, 0x5f, 0xb8, 0xcb, 0xe5, 0xcd, 0x7b, 0xb4, 0xfe, - 0x34, 0x39, 0x2a, 0xec, 0xa7, 0x70, 0xa1, 0x67, 0x05, 0xff, 0x3d, 0x60, 0x7f, 0x9e, 0x8d, 0xe7, - 0x7e, 0x3c, 0xc9, 0xf3, 0x67, 0x45, 0xd2, 0x22, 0xb4, 0xb5, 0xa2, 0x99, 0x31, 0xf3, 0xe2, 0x9a, - 0x13, 0x8a, 0xcc, 0x8f, 0xb9, 0x57, 0x7d, 0xb2, 0x79, 0xe7, 0xd7, 0x51, 0x15, 0x3c, 0x19, 0x55, - 0xc1, 0x5f, 0xa3, 0x2a, 0x78, 0x74, 0x52, 0x9d, 0x79, 0x72, 0x52, 0x9d, 0xf9, 0xe3, 0xa4, 0x3a, - 0x73, 0x7f, 0xcd, 0x71, 0xc3, 0x87, 0xfd, 0x07, 0x46, 0x97, 0x1c, 0x98, 0xdb, 0xfc, 0xd4, 0xbb, - 0x38, 0xfc, 0x88, 0x04, 0xfb, 0x71, 0x91, 0xc1, 0xb8, 0x4c, 0x38, 0xec, 0x61, 0xfa, 0xe0, 0x1c, - 0xfb, 0x2f, 0xec, 0xc6, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x12, 0x72, 0x31, 0x41, 0x0e, - 0x00, 0x00, + // 1067 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xb8, 0x34, 0x4d, 0xc6, 0xa9, 0x80, 0xa9, 0x49, 0xed, 0x4d, 0x6b, 0xa7, 0x4b, 0x49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c, 0x6a, 0x47, 0x4c, 0xf5, 0x72, + 0x49, 0x68, 0xfd, 0xca, 0x5d, 0x7b, 0x92, 0x8b, 0xa1, 0xf5, 0x93, 0xe8, 0xa8, 0x04, 0x4f, 0xe5, + 0xaa, 0x67, 0x95, 0xfc, 0x47, 0xc0, 0x3e, 0x31, 0x87, 0x3e, 0x16, 0x3a, 0xd3, 0xe4, 0xfb, 0x21, + 0x6a, 0x79, 0xda, 0x6a, 0xda, 0xc8, 0x50, 0xed, 0xf4, 0x9c, 0x23, 0x8c, 0xcc, 0x4f, 0xb8, 0xf7, + 0x7e, 0xba, 0x79, 0xef, 0xb7, 0x7e, 0x11, 0x3c, 0xeb, 0x17, 0xc1, 0xdf, 0xfd, 0x22, 0x78, 0x72, + 0x5c, 0x9c, 0x7a, 0x76, 0x5c, 0x9c, 0xfa, 0xeb, 0xb8, 0x38, 0xf5, 0x70, 0xb5, 0xe9, 0x06, 0x8f, + 0x3b, 0x8f, 0x0c, 0x9b, 0xec, 0x9b, 0xdb, 0x3c, 0xeb, 0x7d, 0x1c, 0x7c, 0x44, 0xfc, 0xbd, 0xb0, + 0x48, 0x77, 0x58, 0x26, 0xe8, 0xb5, 0x31, 0x7d, 0x34, 0xcd, 0xfe, 0x49, 0xde, 0xfc, 0x3f, 0x00, + 0x00, 0xff, 0xff, 0xbc, 0x9b, 0x07, 0xd7, 0x25, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -781,6 +870,8 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { + // Params retrieves the assets module params + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // ClientChainInfoByIndex queries the client chain info by index. QueClientChainInfoByIndex(ctx context.Context, in *QueryClientChainInfo, opts ...grpc.CallOption) (*ClientChainInfo, error) // AllClientChainInfo queries all client chain info. @@ -792,11 +883,11 @@ type QueryClient interface { // StakerAssetInfos queries the staker asset info. QueStakerAssetInfos(ctx context.Context, in *QueryStakerAssetInfo, opts ...grpc.CallOption) (*QueryAssetInfoResponse, error) // StakerSpecifiedAssetAmount queries the staker specified asset amount. - QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerSingleAssetInfo, error) + QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerAssetInfo, error) // OperatorAssetInfos queries the operator asset info. QueOperatorAssetInfos(ctx context.Context, in *QueryOperatorAssetInfos, opts ...grpc.CallOption) (*QueryOperatorAssetInfosResponse, error) // OperatorSpecifiedAssetAmount queries the operator specified asset amount. - QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorSingleAssetInfo, error) + QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorAssetInfo, error) // StakerExCoreAddr queries the staker exocore address. QueStakerExoCoreAddr(ctx context.Context, in *QueryStakerExCoreAddr, opts ...grpc.CallOption) (*QueryStakerExCoreAddrResponse, error) } @@ -809,6 +900,15 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) QueClientChainInfoByIndex(ctx context.Context, in *QueryClientChainInfo, opts ...grpc.CallOption) (*ClientChainInfo, error) { out := new(ClientChainInfo) err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueClientChainInfoByIndex", in, out, opts...) @@ -854,8 +954,8 @@ func (c *queryClient) QueStakerAssetInfos(ctx context.Context, in *QueryStakerAs return out, nil } -func (c *queryClient) QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerSingleAssetInfo, error) { - out := new(StakerSingleAssetInfo) +func (c *queryClient) QueStakerSpecifiedAssetAmount(ctx context.Context, in *QuerySpecifiedAssetAmountReq, opts ...grpc.CallOption) (*StakerAssetInfo, error) { + out := new(StakerAssetInfo) err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueStakerSpecifiedAssetAmount", in, out, opts...) if err != nil { return nil, err @@ -872,8 +972,8 @@ func (c *queryClient) QueOperatorAssetInfos(ctx context.Context, in *QueryOperat return out, nil } -func (c *queryClient) QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorSingleAssetInfo, error) { - out := new(OperatorSingleAssetInfo) +func (c *queryClient) QueOperatorSpecifiedAssetAmount(ctx context.Context, in *QueryOperatorSpecifiedAssetAmountReq, opts ...grpc.CallOption) (*OperatorAssetInfo, error) { + out := new(OperatorAssetInfo) err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueOperatorSpecifiedAssetAmount", in, out, opts...) if err != nil { return nil, err @@ -892,6 +992,8 @@ func (c *queryClient) QueStakerExoCoreAddr(ctx context.Context, in *QueryStakerE // QueryServer is the server API for Query service. type QueryServer interface { + // Params retrieves the assets module params + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // ClientChainInfoByIndex queries the client chain info by index. QueClientChainInfoByIndex(context.Context, *QueryClientChainInfo) (*ClientChainInfo, error) // AllClientChainInfo queries all client chain info. @@ -903,11 +1005,11 @@ type QueryServer interface { // StakerAssetInfos queries the staker asset info. QueStakerAssetInfos(context.Context, *QueryStakerAssetInfo) (*QueryAssetInfoResponse, error) // StakerSpecifiedAssetAmount queries the staker specified asset amount. - QueStakerSpecifiedAssetAmount(context.Context, *QuerySpecifiedAssetAmountReq) (*StakerSingleAssetInfo, error) + QueStakerSpecifiedAssetAmount(context.Context, *QuerySpecifiedAssetAmountReq) (*StakerAssetInfo, error) // OperatorAssetInfos queries the operator asset info. QueOperatorAssetInfos(context.Context, *QueryOperatorAssetInfos) (*QueryOperatorAssetInfosResponse, error) // OperatorSpecifiedAssetAmount queries the operator specified asset amount. - QueOperatorSpecifiedAssetAmount(context.Context, *QueryOperatorSpecifiedAssetAmountReq) (*OperatorSingleAssetInfo, error) + QueOperatorSpecifiedAssetAmount(context.Context, *QueryOperatorSpecifiedAssetAmountReq) (*OperatorAssetInfo, error) // StakerExCoreAddr queries the staker exocore address. QueStakerExoCoreAddr(context.Context, *QueryStakerExCoreAddr) (*QueryStakerExCoreAddrResponse, error) } @@ -916,6 +1018,9 @@ type QueryServer interface { type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} func (*UnimplementedQueryServer) QueClientChainInfoByIndex(ctx context.Context, req *QueryClientChainInfo) (*ClientChainInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method QueClientChainInfoByIndex not implemented") } @@ -931,13 +1036,13 @@ func (*UnimplementedQueryServer) QueAllStakingAssetsInfo(ctx context.Context, re func (*UnimplementedQueryServer) QueStakerAssetInfos(ctx context.Context, req *QueryStakerAssetInfo) (*QueryAssetInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueStakerAssetInfos not implemented") } -func (*UnimplementedQueryServer) QueStakerSpecifiedAssetAmount(ctx context.Context, req *QuerySpecifiedAssetAmountReq) (*StakerSingleAssetInfo, error) { +func (*UnimplementedQueryServer) QueStakerSpecifiedAssetAmount(ctx context.Context, req *QuerySpecifiedAssetAmountReq) (*StakerAssetInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method QueStakerSpecifiedAssetAmount not implemented") } func (*UnimplementedQueryServer) QueOperatorAssetInfos(ctx context.Context, req *QueryOperatorAssetInfos) (*QueryOperatorAssetInfosResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueOperatorAssetInfos not implemented") } -func (*UnimplementedQueryServer) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *QueryOperatorSpecifiedAssetAmountReq) (*OperatorSingleAssetInfo, error) { +func (*UnimplementedQueryServer) QueOperatorSpecifiedAssetAmount(ctx context.Context, req *QueryOperatorSpecifiedAssetAmountReq) (*OperatorAssetInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method QueOperatorSpecifiedAssetAmount not implemented") } func (*UnimplementedQueryServer) QueStakerExoCoreAddr(ctx context.Context, req *QueryStakerExCoreAddr) (*QueryStakerExCoreAddrResponse, error) { @@ -948,6 +1053,24 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.assets.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_QueClientChainInfoByIndex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryClientChainInfo) if err := dec(in); err != nil { @@ -1114,6 +1237,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.assets.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, { MethodName: "QueClientChainInfoByIndex", Handler: _Query_QueClientChainInfoByIndex_Handler, @@ -1647,6 +1774,64 @@ func (m *QueryStakerExCoreAddrResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1875,6 +2060,28 @@ func (m *QueryStakerExCoreAddrResponse) Size() (n int) { return n } +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2617,10 +2824,10 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*StakerSingleAssetInfo) + m.AssetInfos = make(map[string]*StakerAssetInfo) } var mapkey string - var mapvalue *StakerSingleAssetInfo + var mapvalue *StakerAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -2694,7 +2901,7 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &StakerSingleAssetInfo{} + mapvalue = &StakerAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -2992,10 +3199,10 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AssetInfos == nil { - m.AssetInfos = make(map[string]*OperatorSingleAssetInfo) + m.AssetInfos = make(map[string]*OperatorAssetInfo) } var mapkey string - var mapvalue *OperatorSingleAssetInfo + var mapvalue *OperatorAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3069,7 +3276,7 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &OperatorSingleAssetInfo{} + mapvalue = &OperatorAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -3390,6 +3597,142 @@ func (m *QueryStakerExCoreAddrResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params == nil { + m.Params = &Params{} + } + if err := m.Params.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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/assets/types/query.pb.gw.go b/x/assets/types/query.pb.gw.go index 57629d753..4bc526699 100644 --- a/x/assets/types/query.pb.gw.go +++ b/x/assets/types/query.pb.gw.go @@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_QueClientChainInfoByIndex_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -345,6 +363,29 @@ func local_request_Query_QueStakerExoCoreAddr_0(ctx context.Context, marshaler r // 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_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueClientChainInfoByIndex_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -593,6 +634,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueClientChainInfoByIndex_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -777,6 +838,8 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "Params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueClientChainInfoByIndex_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueClientChainInfoByIndex"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueAllClientChainInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"exocore", "assets", "v1", "QueAllClientChainInfo"}, "", runtime.AssumeColonVerbOpt(false))) @@ -797,6 +860,8 @@ var ( ) var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_QueClientChainInfoByIndex_0 = runtime.ForwardResponseMessage forward_Query_QueAllClientChainInfo_0 = runtime.ForwardResponseMessage diff --git a/x/assets/types/tx.pb.go b/x/assets/types/tx.pb.go index a4704e735..6ad057798 100644 --- a/x/assets/types/tx.pb.go +++ b/x/assets/types/tx.pb.go @@ -406,10 +406,10 @@ func (m *StakingAssetInfo) GetAssetBasicInfo() *AssetInfo { return nil } -// StakerSingleAssetInfo defines the information for a single asset. +// StakerAssetInfo defines the information for a single asset. // The type include three states: // staker's deposited, withdrawable, and currently unbonding amount. -type StakerSingleAssetInfo struct { +type StakerAssetInfo struct { // total_deposit_amount is the total amount of the asset deposited. TotalDepositAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_deposit_amount,json=totalDepositAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_deposit_amount"` // withdrawable_amount is the amount that can be withdrawn. @@ -418,18 +418,18 @@ type StakerSingleAssetInfo struct { WaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount,json=waitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount"` } -func (m *StakerSingleAssetInfo) Reset() { *m = StakerSingleAssetInfo{} } -func (m *StakerSingleAssetInfo) String() string { return proto.CompactTextString(m) } -func (*StakerSingleAssetInfo) ProtoMessage() {} -func (*StakerSingleAssetInfo) Descriptor() ([]byte, []int) { +func (m *StakerAssetInfo) Reset() { *m = StakerAssetInfo{} } +func (m *StakerAssetInfo) String() string { return proto.CompactTextString(m) } +func (*StakerAssetInfo) ProtoMessage() {} +func (*StakerAssetInfo) Descriptor() ([]byte, []int) { return fileDescriptor_adb6ebd423a2c426, []int{5} } -func (m *StakerSingleAssetInfo) XXX_Unmarshal(b []byte) error { +func (m *StakerAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerSingleAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *StakerAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerSingleAssetInfo.Marshal(b, m, deterministic) + return xxx_messageInfo_StakerAssetInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -439,23 +439,23 @@ func (m *StakerSingleAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *StakerSingleAssetInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakerSingleAssetInfo.Merge(m, src) +func (m *StakerAssetInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerAssetInfo.Merge(m, src) } -func (m *StakerSingleAssetInfo) XXX_Size() int { +func (m *StakerAssetInfo) XXX_Size() int { return m.Size() } -func (m *StakerSingleAssetInfo) XXX_DiscardUnknown() { - xxx_messageInfo_StakerSingleAssetInfo.DiscardUnknown(m) +func (m *StakerAssetInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StakerAssetInfo.DiscardUnknown(m) } -var xxx_messageInfo_StakerSingleAssetInfo proto.InternalMessageInfo +var xxx_messageInfo_StakerAssetInfo proto.InternalMessageInfo // StakerAllAssetsInfo defines the information for all assets of a staker. // It is indexed by the asset_id. type StakerAllAssetsInfo struct { // all_assets_state is the state of all assets of the staker. - AllAssetsState map[string]*StakerSingleAssetInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AllAssetsState map[string]*StakerAssetInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *StakerAllAssetsInfo) Reset() { *m = StakerAllAssetsInfo{} } @@ -491,41 +491,42 @@ func (m *StakerAllAssetsInfo) XXX_DiscardUnknown() { var xxx_messageInfo_StakerAllAssetsInfo proto.InternalMessageInfo -func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetInfo { +func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerAssetInfo { if m != nil { return m.AllAssetsState } return nil } -// OperatorSingleAssetInfo defines the information for a single asset, -// for an operator. It is also overloaded like StakerSingleAssetInfo. -type OperatorSingleAssetInfo struct { +// OperatorAssetInfo defines the information for a single asset, +// for an operator. +type OperatorAssetInfo struct { // total_amount is the total amount of the asset deposited. 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"` - // operator_own_amount is the amount that the operator owns. + // operator_amount is the amount that the operator owns. // todo: the field is used to mark operator's own assets and is not temporarily used now - OperatorOwnAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=operator_own_amount,json=operatorOwnAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_own_amount"` + OperatorAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=operator_amount,json=operatorAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_amount"` // wait_unbonding_amount is the amount that is waiting for unbonding. WaitUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=wait_unbonding_amount,json=waitUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wait_unbonding_amount"` // operator_unbonding_amount is the amount that is owned by operator itself and waiting for unbonding. OperatorUnbondingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=operator_unbonding_amount,json=operatorUnbondingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_unbonding_amount"` - // operator_unbondable_amount_after_slash is the amount that is owned by operator itself and can be unbonded after slash. + // operator_unbondable_amount_after_slash is the amount that is owned by operator itself + // and can be unbonded after slash. OperatorUnbondableAmountAfterSlash github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=operator_unbondable_amount_after_slash,json=operatorUnbondableAmountAfterSlash,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"operator_unbondable_amount_after_slash"` } -func (m *OperatorSingleAssetInfo) Reset() { *m = OperatorSingleAssetInfo{} } -func (m *OperatorSingleAssetInfo) String() string { return proto.CompactTextString(m) } -func (*OperatorSingleAssetInfo) ProtoMessage() {} -func (*OperatorSingleAssetInfo) Descriptor() ([]byte, []int) { +func (m *OperatorAssetInfo) Reset() { *m = OperatorAssetInfo{} } +func (m *OperatorAssetInfo) String() string { return proto.CompactTextString(m) } +func (*OperatorAssetInfo) ProtoMessage() {} +func (*OperatorAssetInfo) Descriptor() ([]byte, []int) { return fileDescriptor_adb6ebd423a2c426, []int{7} } -func (m *OperatorSingleAssetInfo) XXX_Unmarshal(b []byte) error { +func (m *OperatorAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OperatorSingleAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OperatorAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OperatorSingleAssetInfo.Marshal(b, m, deterministic) + return xxx_messageInfo_OperatorAssetInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -535,23 +536,23 @@ func (m *OperatorSingleAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *OperatorSingleAssetInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_OperatorSingleAssetInfo.Merge(m, src) +func (m *OperatorAssetInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorAssetInfo.Merge(m, src) } -func (m *OperatorSingleAssetInfo) XXX_Size() int { +func (m *OperatorAssetInfo) XXX_Size() int { return m.Size() } -func (m *OperatorSingleAssetInfo) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorSingleAssetInfo.DiscardUnknown(m) +func (m *OperatorAssetInfo) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorAssetInfo.DiscardUnknown(m) } -var xxx_messageInfo_OperatorSingleAssetInfo proto.InternalMessageInfo +var xxx_messageInfo_OperatorAssetInfo proto.InternalMessageInfo // OperatorAllAssetsInfo defines the information for all assets of an operator, // indexed by the asset_id. type OperatorAllAssetsInfo struct { // all_assets_state is the state of all assets of the operator. - AllAssetsState map[string]*OperatorSingleAssetInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AllAssetsState map[string]*OperatorAssetInfo `protobuf:"bytes,1,rep,name=all_assets_state,json=allAssetsState,proto3" json:"all_assets_state,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *OperatorAllAssetsInfo) Reset() { *m = OperatorAllAssetsInfo{} } @@ -587,7 +588,7 @@ func (m *OperatorAllAssetsInfo) XXX_DiscardUnknown() { var xxx_messageInfo_OperatorAllAssetsInfo proto.InternalMessageInfo -func (m *OperatorAllAssetsInfo) GetAllAssetsState() map[string]*OperatorSingleAssetInfo { +func (m *OperatorAllAssetsInfo) GetAllAssetsState() map[string]*OperatorAssetInfo { if m != nil { return m.AllAssetsState } @@ -838,109 +839,211 @@ func (m *RegisterAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterAssetResponse proto.InternalMessageInfo +// MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. +// Since: cosmos-sdk 0.47 +type MsgUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/evm parameters to update. + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_adb6ebd423a2c426, []int{15} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// Since: cosmos-sdk 0.47 +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_adb6ebd423a2c426, []int{16} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*ValueField)(nil), "exocore.assets.v1.ValueField") proto.RegisterType((*ClientChainInfo)(nil), "exocore.assets.v1.ClientChainInfo") proto.RegisterType((*AppChainInfo)(nil), "exocore.assets.v1.AppChainInfo") proto.RegisterType((*AssetInfo)(nil), "exocore.assets.v1.AssetInfo") proto.RegisterType((*StakingAssetInfo)(nil), "exocore.assets.v1.StakingAssetInfo") - proto.RegisterType((*StakerSingleAssetInfo)(nil), "exocore.assets.v1.StakerSingleAssetInfo") + proto.RegisterType((*StakerAssetInfo)(nil), "exocore.assets.v1.StakerAssetInfo") proto.RegisterType((*StakerAllAssetsInfo)(nil), "exocore.assets.v1.StakerAllAssetsInfo") - proto.RegisterMapType((map[string]*StakerSingleAssetInfo)(nil), "exocore.assets.v1.StakerAllAssetsInfo.AllAssetsStateEntry") - proto.RegisterType((*OperatorSingleAssetInfo)(nil), "exocore.assets.v1.OperatorSingleAssetInfo") + proto.RegisterMapType((map[string]*StakerAssetInfo)(nil), "exocore.assets.v1.StakerAllAssetsInfo.AllAssetsStateEntry") + proto.RegisterType((*OperatorAssetInfo)(nil), "exocore.assets.v1.OperatorAssetInfo") proto.RegisterType((*OperatorAllAssetsInfo)(nil), "exocore.assets.v1.OperatorAllAssetsInfo") - proto.RegisterMapType((map[string]*OperatorSingleAssetInfo)(nil), "exocore.assets.v1.OperatorAllAssetsInfo.AllAssetsStateEntry") + proto.RegisterMapType((map[string]*OperatorAssetInfo)(nil), "exocore.assets.v1.OperatorAllAssetsInfo.AllAssetsStateEntry") proto.RegisterType((*MsgSetExoCoreAddr)(nil), "exocore.assets.v1.MsgSetExoCoreAddr") proto.RegisterType((*MsgSetExoCoreAddrResponse)(nil), "exocore.assets.v1.MsgSetExoCoreAddrResponse") proto.RegisterType((*RegisterClientChainReq)(nil), "exocore.assets.v1.RegisterClientChainReq") proto.RegisterType((*RegisterClientChainResponse)(nil), "exocore.assets.v1.RegisterClientChainResponse") proto.RegisterType((*RegisterAssetReq)(nil), "exocore.assets.v1.RegisterAssetReq") proto.RegisterType((*RegisterAssetResponse)(nil), "exocore.assets.v1.RegisterAssetResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "exocore.assets.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "exocore.assets.v1.MsgUpdateParamsResponse") } func init() { proto.RegisterFile("exocore/assets/v1/tx.proto", fileDescriptor_adb6ebd423a2c426) } var fileDescriptor_adb6ebd423a2c426 = []byte{ - // 1254 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x4d, 0x6f, 0x13, 0xc7, - 0x1b, 0xcf, 0x3a, 0x21, 0x2f, 0x8f, 0x09, 0x38, 0xe3, 0x84, 0x38, 0xe6, 0x8f, 0x83, 0xfc, 0x6f, - 0x51, 0x1a, 0x81, 0x0d, 0xa9, 0x8a, 0xda, 0x80, 0xaa, 0x3a, 0x01, 0xa4, 0x54, 0x50, 0xa4, 0x35, - 0xed, 0x81, 0x43, 0x57, 0x63, 0xef, 0x64, 0xb3, 0xcd, 0xee, 0xcc, 0x76, 0x67, 0x42, 0x6c, 0x4e, - 0x55, 0x4f, 0x15, 0x27, 0x3e, 0x02, 0x1f, 0x81, 0x03, 0x87, 0x7e, 0x04, 0xc4, 0x89, 0x72, 0xaa, - 0x7a, 0x40, 0x28, 0x1c, 0xc2, 0xa9, 0x9f, 0xa1, 0x9a, 0x97, 0x75, 0xbc, 0xc9, 0x26, 0x44, 0x8d, - 0xa5, 0x5e, 0x92, 0x9d, 0xe7, 0xe5, 0xf7, 0xbc, 0xcc, 0xf3, 0x3c, 0xf3, 0x18, 0xca, 0xa4, 0xc3, - 0xda, 0x2c, 0x26, 0x75, 0xcc, 0x39, 0x11, 0xbc, 0xfe, 0xe8, 0x5a, 0x5d, 0x74, 0x6a, 0x51, 0xcc, - 0x04, 0x43, 0x53, 0x86, 0x57, 0xd3, 0xbc, 0xda, 0xa3, 0x6b, 0xe5, 0x29, 0x1c, 0xfa, 0x94, 0xd5, - 0xd5, 0x5f, 0x2d, 0x55, 0x9e, 0x6d, 0x33, 0x1e, 0x32, 0x5e, 0x0f, 0xb9, 0x27, 0xb5, 0x43, 0xee, - 0x19, 0xc6, 0x9c, 0x66, 0x38, 0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b, 0x0a, 0x4d, 0x81, 0x37, 0x7d, 0xea, 0xed, 0x65, 0xfa, 0x0e, 0x14, 0xd4, 0x98, 0x70, - 0x5a, 0x98, 0xfb, 0x6d, 0xad, 0x28, 0xb3, 0x9e, 0x5f, 0xfa, 0x5f, 0xed, 0xc0, 0x1c, 0xa9, 0xf5, - 0xf4, 0xec, 0x33, 0x8a, 0xb8, 0x22, 0x95, 0x14, 0x0e, 0x85, 0x69, 0xae, 0xb1, 0x1d, 0x9d, 0x57, - 0x33, 0x04, 0x72, 0x03, 0xc8, 0x2b, 0x32, 0xc8, 0x0f, 0x24, 0x70, 0x43, 0x0f, 0x84, 0x0f, 0x39, - 0x98, 0x91, 0xc1, 0x90, 0xb8, 0xe9, 0x53, 0x2f, 0x20, 0x7b, 0x11, 0x51, 0x98, 0xd6, 0x1e, 0xb8, - 0x24, 0x62, 0xdc, 0x17, 0xce, 0x00, 0xc7, 0x11, 0x52, 0xc8, 0xb7, 0x34, 0xb0, 0xf6, 0x04, 0x85, - 0x50, 0xdc, 0xf6, 0xc5, 0x86, 0x1b, 0xe3, 0x6d, 0xdc, 0x0a, 0xc8, 0x40, 0x03, 0xef, 0x07, 0x36, - 0xe6, 0x22, 0x98, 0xd9, 0xc6, 0xbe, 0x70, 0xb6, 0x68, 0x8b, 0x51, 0x57, 0xe6, 0xdb, 0x18, 0x1c, - 0x1e, 0x80, 0xc1, 0xa2, 0x84, 0xfe, 0x3e, 0x41, 0x4e, 0x52, 0x6d, 0x41, 0x51, 0xa7, 0xba, 0x11, - 0x04, 0x2a, 0xcf, 0x5c, 0x25, 0xda, 0x85, 0x02, 0x0e, 0x02, 0x47, 0x57, 0x87, 0xc3, 0x05, 0x16, - 0xb2, 0x61, 0x87, 0x17, 0xf2, 0x4b, 0xcb, 0x19, 0xa5, 0x93, 0x81, 0x50, 0xeb, 0x9d, 0x9a, 0x52, - 0xf9, 0x36, 0x15, 0x71, 0xd7, 0x3e, 0x83, 0x53, 0xc4, 0xf2, 0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0xbf, 0x3f, + 0x94, 0x87, 0x1e, 0x5e, 0xe9, 0xbb, 0xfb, 0x6e, 0x2b, 0xd0, 0x6f, 0x09, 0xdf, 0xa6, 0xd1, 0x56, + 0x2d, 0x1e, 0x44, 0x9d, 0xf8, 0xef, 0x01, 0xf2, 0x26, 0x6c, 0x8e, 0xc8, 0xcf, 0xfe, 0x2f, 0xfe, + 0x09, 0x00, 0x00, 0xff, 0xff, 0xd7, 0x99, 0x04, 0xe0, 0xa4, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -955,6 +1058,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // UpdateParams updates the parameters of the assets module. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) // SetStakerExoCoreAddr sets the exocore address of the staker SetStakerExoCoreAddr(ctx context.Context, in *MsgSetExoCoreAddr, opts ...grpc.CallOption) (*MsgSetExoCoreAddrResponse, error) // RegisterClientChain registers the client chain @@ -971,6 +1076,15 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) SetStakerExoCoreAddr(ctx context.Context, in *MsgSetExoCoreAddr, opts ...grpc.CallOption) (*MsgSetExoCoreAddrResponse, error) { out := new(MsgSetExoCoreAddrResponse) err := c.cc.Invoke(ctx, "/exocore.assets.v1.Msg/SetStakerExoCoreAddr", in, out, opts...) @@ -1000,6 +1114,8 @@ func (c *msgClient) RegisterAsset(ctx context.Context, in *RegisterAssetReq, opt // MsgServer is the server API for Msg service. type MsgServer interface { + // UpdateParams updates the parameters of the assets module. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) // SetStakerExoCoreAddr sets the exocore address of the staker SetStakerExoCoreAddr(context.Context, *MsgSetExoCoreAddr) (*MsgSetExoCoreAddrResponse, error) // RegisterClientChain registers the client chain @@ -1012,6 +1128,9 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func (*UnimplementedMsgServer) SetStakerExoCoreAddr(ctx context.Context, req *MsgSetExoCoreAddr) (*MsgSetExoCoreAddrResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetStakerExoCoreAddr not implemented") } @@ -1026,6 +1145,24 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.assets.v1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_SetStakerExoCoreAddr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSetExoCoreAddr) if err := dec(in); err != nil { @@ -1084,6 +1221,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "exocore.assets.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, { MethodName: "SetStakerExoCoreAddr", Handler: _Msg_SetStakerExoCoreAddr_Handler, @@ -1373,7 +1514,7 @@ func (m *StakingAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *StakerSingleAssetInfo) Marshal() (dAtA []byte, err error) { +func (m *StakerAssetInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1383,12 +1524,12 @@ func (m *StakerSingleAssetInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *StakerSingleAssetInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *StakerAssetInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *StakerSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *StakerAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1475,7 +1616,7 @@ func (m *StakerAllAssetsInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *OperatorSingleAssetInfo) Marshal() (dAtA []byte, err error) { +func (m *OperatorAssetInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1485,12 +1626,12 @@ func (m *OperatorSingleAssetInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorSingleAssetInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *OperatorAssetInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OperatorAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1526,9 +1667,9 @@ func (m *OperatorSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x1a { - size := m.OperatorOwnAmount.Size() + size := m.OperatorAmount.Size() i -= size - if _, err := m.OperatorOwnAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.OperatorAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1806,6 +1947,69 @@ func (m *RegisterAssetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1939,7 +2143,7 @@ func (m *StakingAssetInfo) Size() (n int) { return n } -func (m *StakerSingleAssetInfo) Size() (n int) { +func (m *StakerAssetInfo) Size() (n int) { if m == nil { return 0 } @@ -1976,7 +2180,7 @@ func (m *StakerAllAssetsInfo) Size() (n int) { return n } -func (m *OperatorSingleAssetInfo) Size() (n int) { +func (m *OperatorAssetInfo) Size() (n int) { if m == nil { return 0 } @@ -1984,7 +2188,7 @@ func (m *OperatorSingleAssetInfo) Size() (n int) { _ = l l = m.TotalAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.OperatorOwnAmount.Size() + l = m.OperatorAmount.Size() n += 1 + l + sovTx(uint64(l)) l = m.WaitUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) @@ -2106,6 +2310,30 @@ func (m *RegisterAssetResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2991,7 +3219,7 @@ func (m *StakingAssetInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *StakerSingleAssetInfo) Unmarshal(dAtA []byte) error { +func (m *StakerAssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3014,10 +3242,10 @@ func (m *StakerSingleAssetInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StakerSingleAssetInfo: wiretype end group for non-group") + return fmt.Errorf("proto: StakerAssetInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StakerSingleAssetInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StakerAssetInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3202,10 +3430,10 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AllAssetsState == nil { - m.AllAssetsState = make(map[string]*StakerSingleAssetInfo) + m.AllAssetsState = make(map[string]*StakerAssetInfo) } var mapkey string - var mapvalue *StakerSingleAssetInfo + var mapvalue *StakerAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3279,7 +3507,7 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &StakerSingleAssetInfo{} + mapvalue = &StakerAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -3322,7 +3550,7 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *OperatorSingleAssetInfo) Unmarshal(dAtA []byte) error { +func (m *OperatorAssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3345,10 +3573,10 @@ func (m *OperatorSingleAssetInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OperatorSingleAssetInfo: wiretype end group for non-group") + return fmt.Errorf("proto: OperatorAssetInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OperatorSingleAssetInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OperatorAssetInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3387,7 +3615,7 @@ func (m *OperatorSingleAssetInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorOwnAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3415,7 +3643,7 @@ func (m *OperatorSingleAssetInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OperatorOwnAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OperatorAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3601,10 +3829,10 @@ func (m *OperatorAllAssetsInfo) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AllAssetsState == nil { - m.AllAssetsState = make(map[string]*OperatorSingleAssetInfo) + m.AllAssetsState = make(map[string]*OperatorAssetInfo) } var mapkey string - var mapvalue *OperatorSingleAssetInfo + var mapvalue *OperatorAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3678,7 +3906,7 @@ func (m *OperatorAllAssetsInfo) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &OperatorSingleAssetInfo{} + mapvalue = &OperatorAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -4304,6 +4532,171 @@ func (m *RegisterAssetResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/delegation/client/cli/query.go b/x/delegation/client/cli/query.go index 1e29298c7..8bece122d 100644 --- a/x/delegation/client/cli/query.go +++ b/x/delegation/client/cli/query.go @@ -46,7 +46,7 @@ func QuerySingleDelegationInfo() *cobra.Command { queryClient := delegationtype.NewQueryClient(clientCtx) clientChainLzID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { - return errorsmod.Wrap(types.ErrCliCmdInputArg, err.Error()) + return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error()) } stakerID, assetID := types.GetStakeIDAndAssetIDFromStr(clientChainLzID, args[1], args[2]) req := &delegationtype.SingleDelegationInfoReq{ diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 0a7e44780..f19a9fd3a 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -83,7 +83,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } // update the staker state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetChangeInfo{ WithdrawableAmount: record.ActualCompletedAmount, WaitUnbondingAmount: recordAmountNeg, }) @@ -92,7 +92,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } // update the operator state - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetChangeInfo{ WaitUnbondingAmount: recordAmountNeg, }) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 7c1cff7a5..1879be19f 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -48,7 +48,7 @@ type DelegationOrUndelegationParams struct { if err != nil { return nil, errorsmod.Wrap(err, "error occurred when binary read ClientChainLzID from topic") } - clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) + clientChainInfo, err := k.assetsKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when get client chain info") } @@ -130,7 +130,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar stakerID, assetID := assetstype.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) // check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount - info, err := k.restakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) + info, err := k.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return err } @@ -140,14 +140,14 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar } // update staker asset state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ WithdrawableAmount: params.OpAmount.Neg(), }) if err != nil { return err } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ TotalAmount: params.OpAmount, }) if err != nil { @@ -233,13 +233,13 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio } // update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, assetstype.StakerSingleAssetChangeInfo{ WaitUnbondingAmount: params.OpAmount, }) if err != nil { return err } - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ TotalAmount: params.OpAmount.Neg(), WaitUnbondingAmount: params.OpAmount, }) diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index c98fac5eb..5697bb9b9 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -59,19 +59,19 @@ func (suite *DelegationTestSuite) TestDelegateTo() { // check delegation states stakerID, assetID := types.GetStakeIDAndAssetID(delegationParams.ClientChainLzID, delegationParams.StakerAddress, delegationParams.AssetsAddress) - restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + restakerState, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: depositEvent.OpAmount, WithdrawableAmount: depositEvent.OpAmount.Sub(delegationParams.OpAmount), WaitUnbondingAmount: sdkmath.NewInt(0), }, *restakerState) - operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) + operatorState, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) - suite.Equal(types.OperatorSingleAssetInfo{ + suite.Equal(types.OperatorAssetInfo{ TotalAmount: delegationParams.OpAmount, - OperatorOwnAmount: sdkmath.NewInt(0), + OperatorAmount: sdkmath.NewInt(0), WaitUnbondingAmount: sdkmath.NewInt(0), OperatorUnbondingAmount: sdkmath.NewInt(0), OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), @@ -135,19 +135,19 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { // check state stakerID, assetID := types.GetStakeIDAndAssetID(delegationEvent.ClientChainLzID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) - restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + restakerState, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: depositEvent.OpAmount, WithdrawableAmount: depositEvent.OpAmount.Sub(delegationEvent.OpAmount), WaitUnbondingAmount: delegationEvent.OpAmount, }, *restakerState) - operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) + operatorState, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) - suite.Equal(types.OperatorSingleAssetInfo{ + suite.Equal(types.OperatorAssetInfo{ TotalAmount: sdkmath.NewInt(0), - OperatorOwnAmount: sdkmath.NewInt(0), + OperatorAmount: sdkmath.NewInt(0), WaitUnbondingAmount: delegationEvent.OpAmount, OperatorUnbondingAmount: sdkmath.NewInt(0), OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), @@ -240,19 +240,19 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { // check state stakerID, assetID := types.GetStakeIDAndAssetID(delegationEvent.ClientChainLzID, delegationEvent.StakerAddress, delegationEvent.AssetsAddress) - restakerState, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + restakerState, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: depositEvent.OpAmount, WithdrawableAmount: depositEvent.OpAmount, WaitUnbondingAmount: sdkmath.NewInt(0), }, *restakerState) - operatorState, err := suite.App.StakingAssetsManageKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) + operatorState, err := suite.App.AssetsKeeper.GetOperatorSpecifiedAssetInfo(suite.Ctx, opAccAddr, assetID) suite.NoError(err) - suite.Equal(types.OperatorSingleAssetInfo{ + suite.Equal(types.OperatorAssetInfo{ TotalAmount: sdkmath.NewInt(0), - OperatorOwnAmount: sdkmath.NewInt(0), + OperatorAmount: sdkmath.NewInt(0), WaitUnbondingAmount: sdkmath.NewInt(0), OperatorUnbondingAmount: sdkmath.NewInt(0), OperatorUnbondableAmountAfterSlash: sdkmath.NewInt(0), diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 04f6cd0f1..8bad0db43 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -19,7 +18,7 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers - restakingStateKeeper keeper.Keeper + assetsKeeper keeper.Keeper depositKeeper depositkeeper.Keeper slashKeeper delegationtype.ISlashKeeper expectedOperatorInterface delegationtype.ExpectedOperatorInterface @@ -29,7 +28,7 @@ type Keeper struct { func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - restakingStateKeeper keeper.Keeper, + assetsKeeper keeper.Keeper, depositKeeper depositkeeper.Keeper, slashKeeper delegationtype.ISlashKeeper, operatorKeeper delegationtype.ExpectedOperatorInterface, @@ -37,19 +36,13 @@ func NewKeeper( return Keeper{ storeKey: storeKey, cdc: cdc, - restakingStateKeeper: restakingStateKeeper, + assetsKeeper: assetsKeeper, depositKeeper: depositKeeper, slashKeeper: slashKeeper, expectedOperatorInterface: operatorKeeper, } } -// GetExoCoreLzAppAddress Get exoCoreLzAppAddr from deposit keeper,it will be used when check the caller of precompile contract. -// This function needs to be moved to `assets` module,which will facilitate its use for the other modules -func (k *Keeper) GetExoCoreLzAppAddress(ctx sdk.Context) (common.Address, error) { - return k.depositKeeper.GetExoCoreLzAppAddress(ctx) -} - // SetHooks stores the given hooks implementations. // Note that the Keeper is changed into a pointer to prevent an ineffective assignment. func (k *Keeper) SetHooks(hooks delegationtype.DelegationHooks) { diff --git a/x/delegation/types/keys.go b/x/delegation/types/keys.go index fbf1466b1..23bdccaf8 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -44,21 +44,21 @@ const ( ) var ( - // KeyPrefixRestakerDelegationInfo reStakerID = clientChainAddr+'_'+ExoCoreChainIndex + // KeyPrefixRestakerDelegationInfo restakerID = clientChainAddr+'_'+ExoCoreChainIndex // KeyPrefixRestakerDelegationInfo // key-value: - // reStakerID +'/'+assetID -> totalDelegationAmount - // reStakerID +'/'+assetID+'/'+operatorAddr -> delegationAmounts + // restakerID +'/'+assetID -> totalDelegationAmount + // restakerID +'/'+assetID+'/'+operatorAddr -> delegationAmounts KeyPrefixRestakerDelegationInfo = []byte{prefixRestakerDelegationInfo} // KeyPrefixDelegationUsedSalt key->value: operatorApproveAddr->map[salt]{} KeyPrefixDelegationUsedSalt = []byte{prefixDelegationUsedSalt} - // KeyPrefixOperatorApprovedInfo key-value: operatorApproveAddr->map[reStakerID]{} + // KeyPrefixOperatorApprovedInfo key-value: operatorApproveAddr->map[restakerID]{} KeyPrefixOperatorApprovedInfo = []byte{prefixOperatorApprovedInfo} // KeyPrefixUndelegationInfo singleRecordKey = lzNonce+'/'+txHash+'/'+operatorAddr // singleRecordKey -> UndelegateReqRecord KeyPrefixUndelegationInfo = []byte{prefixUndelegationInfo} - // KeyPrefixStakerUndelegationInfo reStakerID+'/'+assetID+'/'+lzNonce -> singleRecordKey + // KeyPrefixStakerUndelegationInfo restakerID+'/'+assetID+'/'+lzNonce -> singleRecordKey KeyPrefixStakerUndelegationInfo = []byte{prefixStakerUndelegationInfo} // KeyPrefixWaitCompleteUndelegations completeHeight +'/'+lzNonce -> singleRecordKey KeyPrefixWaitCompleteUndelegations = []byte{prefixWaitCompleteUndelegations} diff --git a/x/deposit/client/cli/tx.go b/x/deposit/client/cli/tx.go index ec86556da..b536ceb5a 100644 --- a/x/deposit/client/cli/tx.go +++ b/x/deposit/client/cli/tx.go @@ -2,11 +2,9 @@ package cli import ( deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" ) // NewTxCmd returns a root CLI command handler for deposit commands @@ -19,40 +17,6 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand( - UpdateParams(), - ) + txCmd.AddCommand() return txCmd } - -// UpdateParams todo: it should be a gov proposal command in future. -func UpdateParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "UpdateParams ExoCoreLZAppAddr ExoCoreLzAppEventTopic", - Short: "Set ExoCoreLZAppAddr and ExoCoreLzAppEventTopic params to deposit module", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := cliCtx.GetFromAddress() - msg := &deposittype.MsgUpdateParams{ - Authority: sender.String(), - Params: deposittype.Params{ - ExoCoreLzAppAddress: args[0], - ExoCoreLzAppEventTopic: args[1], - }, - } - - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} diff --git a/x/deposit/keeper/cross_chain_tx_process.go b/x/deposit/keeper/cross_chain_tx_process.go index 7803913f6..6d3422f73 100644 --- a/x/deposit/keeper/cross_chain_tx_process.go +++ b/x/deposit/keeper/cross_chain_tx_process.go @@ -43,7 +43,7 @@ type DepositParams struct { return nil, errorsmod.Wrap(err, "error occurred when binary read ClientChainLzID from topic") } - clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) + clientChainInfo, err := k.assetsKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when get client chain info") } @@ -130,7 +130,7 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { } stakeID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) // check if asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + if !k.assetsKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(despoittypes.ErrDepositAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetChangeInfo{ @@ -138,13 +138,13 @@ func (k Keeper) Deposit(ctx sdk.Context, params *DepositParams) error { WithdrawableAmount: params.OpAmount, } // update asset state of the specified staker - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } // update total amount of the deposited asset - err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, params.OpAmount) + err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, params.OpAmount) if err != nil { return err } diff --git a/x/deposit/keeper/deposit_test.go b/x/deposit/keeper/deposit_test.go index eda1de67f..230d70efe 100644 --- a/x/deposit/keeper/deposit_test.go +++ b/x/deposit/keeper/deposit_test.go @@ -23,7 +23,7 @@ func (suite *DepositTestSuite) TestDeposit() { err := suite.App.DepositKeeper.Deposit(suite.Ctx, params) suite.ErrorContains(err, deposittype.ErrDepositAssetNotExist.Error()) - assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) + assets, err := suite.App.AssetsKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) suite.App.Logger().Info("the assets is:", "assets", assets) @@ -34,15 +34,15 @@ func (suite *DepositTestSuite) TestDeposit() { // check state after deposit stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) - info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + info, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: params.OpAmount, WithdrawableAmount: params.OpAmount, WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) + assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(params.OpAmount, assetInfo.StakingTotalAmount) } diff --git a/x/deposit/keeper/keeper.go b/x/deposit/keeper/keeper.go index 93a3efe68..7caa6de57 100644 --- a/x/deposit/keeper/keeper.go +++ b/x/deposit/keeper/keeper.go @@ -13,18 +13,18 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers - restakingStateKeeper keeper.Keeper + assetsKeeper keeper.Keeper } func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - restakingStateKeeper keeper.Keeper, + assetsKeeper keeper.Keeper, ) Keeper { return Keeper{ - storeKey: storeKey, - cdc: cdc, - restakingStateKeeper: restakingStateKeeper, + storeKey: storeKey, + cdc: cdc, + assetsKeeper: assetsKeeper, } } diff --git a/x/deposit/keeper/msg_server.go b/x/deposit/keeper/msg_server.go index 3bf9523e2..3096a82af 100644 --- a/x/deposit/keeper/msg_server.go +++ b/x/deposit/keeper/msg_server.go @@ -9,8 +9,7 @@ import ( var _ deposittype.MsgServer = &Keeper{} -// UpdateParams set `exoCoreLzAppAddress` in the parameters of the deposit module, it can be used to verify whether the caller of precompile contracts is the `exoCoreLzApp` contract. -// This function should be triggered by the governance in the future,and we need to move this function to the `assets` module to facilitate the query by other modules. +// UpdateParams This function should be triggered by the governance in the future func (k Keeper) UpdateParams(ctx context.Context, params *deposittype.MsgUpdateParams) (*deposittype.MsgUpdateParamsResponse, error) { c := sdk.UnwrapSDKContext(ctx) err := k.SetParams(c, ¶ms.Params) diff --git a/x/deposit/keeper/params.go b/x/deposit/keeper/params.go index 42c755e91..05aadc232 100644 --- a/x/deposit/keeper/params.go +++ b/x/deposit/keeper/params.go @@ -1,50 +1,30 @@ package keeper import ( - "strings" - - deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" + "github.com/ExocoreNetwork/exocore/x/deposit/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) -var ParamsKey = []byte("Params") - -func (k Keeper) SetParams(ctx sdk.Context, params *deposittype.Params) error { - // check if addr is evm address - if !common.IsHexAddress(params.ExoCoreLzAppAddress) { - return deposittype.ErrInvalidEvmAddressFormat - } - if len(common.FromHex(params.ExoCoreLzAppEventTopic)) != common.HashLength { - return deposittype.ErrInvalidLzUaTopicIDLength - } - params.ExoCoreLzAppAddress = strings.ToLower(params.ExoCoreLzAppAddress) - params.ExoCoreLzAppEventTopic = strings.ToLower(params.ExoCoreLzAppEventTopic) - store := prefix.NewStore(ctx.KVStore(k.storeKey), deposittype.KeyPrefixParams) +// SetParams The function related to module parameter should be deleted +// if no parameters need to be stored in the future. +func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixParams) bz := k.cdc.MustMarshal(params) - store.Set(ParamsKey, bz) + store.Set(types.ParamsKey, bz) return nil } -func (k Keeper) GetParams(ctx sdk.Context) (*deposittype.Params, error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), deposittype.KeyPrefixParams) - isExist := store.Has(ParamsKey) - if !isExist { - return nil, deposittype.ErrNoParamsKey +func (k Keeper) GetParams(ctx sdk.Context) (*types.Params, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixParams) + ifExist := store.Has(types.ParamsKey) + if !ifExist { + return nil, types.ErrNoParamsKey } - value := store.Get(ParamsKey) + value := store.Get(types.ParamsKey) - ret := &deposittype.Params{} + ret := &types.Params{} k.cdc.MustUnmarshal(value, ret) return ret, nil } - -func (k Keeper) GetExoCoreLzAppAddress(ctx sdk.Context) (common.Address, error) { - depositModuleParam, err := k.GetParams(ctx) - if err != nil { - return common.Address{}, err - } - return common.HexToAddress(depositModuleParam.ExoCoreLzAppAddress), nil -} diff --git a/x/deposit/keeper/params_test.go b/x/deposit/keeper/params_test.go index 016486003..3d4560496 100644 --- a/x/deposit/keeper/params_test.go +++ b/x/deposit/keeper/params_test.go @@ -5,10 +5,7 @@ import ( ) func (suite *DepositTestSuite) TestParams() { - params := &deposittype.Params{ - ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", - ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", - } + params := &deposittype.Params{} err := suite.App.DepositKeeper.SetParams(suite.Ctx, params) suite.NoError(err) diff --git a/x/deposit/types/deposit.pb.go b/x/deposit/types/deposit.pb.go index 4ba9caff9..8eb5c7092 100644 --- a/x/deposit/types/deposit.pb.go +++ b/x/deposit/types/deposit.pb.go @@ -25,10 +25,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the deposit module's genesis state. type Params struct { - // exocore_lz_app_address is the address of the exocore lz app. - ExoCoreLzAppAddress string `protobuf:"bytes,1,opt,name=exocore_lz_app_address,json=exocoreLzAppAddress,proto3" json:"exocore_lz_app_address,omitempty"` - // exocore_lz_app_event_topic is the topic of the exocore lz app event. - ExoCoreLzAppEventTopic string `protobuf:"bytes,2,opt,name=exocore_lz_app_event_topic,json=exocoreLzAppEventTopic,proto3" json:"exocore_lz_app_event_topic,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -64,20 +60,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetExoCoreLzAppAddress() string { - if m != nil { - return m.ExoCoreLzAppAddress - } - return "" -} - -func (m *Params) GetExoCoreLzAppEventTopic() string { - if m != nil { - return m.ExoCoreLzAppEventTopic - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "exocore.deposit.v1.Params") } @@ -85,23 +67,17 @@ func init() { func init() { proto.RegisterFile("exocore/deposit/v1/deposit.proto", fileDescriptor_bb743e1548b62476) } var fileDescriptor_bb743e1548b62476 = []byte{ - // 247 bytes of a gzipped FileDescriptorProto + // 151 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x49, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, 0xd1, 0x2f, 0x33, 0x84, 0x31, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0xa0, 0x2a, 0xf4, 0x60, 0xc2, 0x65, 0x86, 0x52, - 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x69, 0x7d, 0x10, 0x0b, 0xa2, 0x52, 0x69, 0x1d, 0x23, 0x17, - 0x5b, 0x40, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x90, 0x0f, 0x97, 0x18, 0x54, 0x5b, 0x7c, 0x4e, 0x55, - 0x7c, 0x62, 0x41, 0x41, 0x7c, 0x62, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, 0x04, 0xa3, 0x02, 0xa3, - 0x06, 0xa7, 0x93, 0xf8, 0xa3, 0x7b, 0xf2, 0xc2, 0xae, 0x15, 0xf9, 0xce, 0xf9, 0x45, 0xa9, 0x3e, - 0x55, 0x8e, 0x05, 0x05, 0x8e, 0x10, 0xe9, 0x20, 0x61, 0xa8, 0x36, 0x64, 0x41, 0xa1, 0x30, 0x2e, - 0x29, 0x34, 0xd3, 0x52, 0xcb, 0x52, 0xf3, 0x4a, 0xe2, 0x4b, 0xf2, 0x0b, 0x32, 0x93, 0x25, 0x98, - 0xc0, 0x26, 0x4a, 0x3d, 0xba, 0x27, 0x2f, 0x86, 0x6c, 0xa2, 0x2b, 0x48, 0x49, 0x08, 0x48, 0x45, - 0x90, 0x18, 0xb2, 0xa1, 0x08, 0x71, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, - 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, - 0x63, 0x88, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0x85, - 0x68, 0xf6, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x87, 0x05, 0x58, 0x05, 0x3c, 0xc8, 0x4a, - 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x81, 0x60, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xfc, - 0x66, 0x03, 0x60, 0x52, 0x01, 0x00, 0x00, + 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x69, 0x7d, 0x10, 0x0b, 0xa2, 0x52, 0x89, 0x83, 0x8b, 0x2d, + 0x20, 0xb1, 0x28, 0x31, 0xb7, 0xd8, 0xc9, 0xfb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, + 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, + 0x18, 0xa2, 0x0c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x5d, 0x21, + 0x06, 0xfb, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0xc3, 0x5c, 0x52, 0x01, 0x77, 0x4b, 0x49, + 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x74, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, + 0x18, 0xb7, 0x57, 0xab, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -124,20 +100,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ExoCoreLzAppEventTopic) > 0 { - i -= len(m.ExoCoreLzAppEventTopic) - copy(dAtA[i:], m.ExoCoreLzAppEventTopic) - i = encodeVarintDeposit(dAtA, i, uint64(len(m.ExoCoreLzAppEventTopic))) - i-- - dAtA[i] = 0x12 - } - if len(m.ExoCoreLzAppAddress) > 0 { - i -= len(m.ExoCoreLzAppAddress) - copy(dAtA[i:], m.ExoCoreLzAppAddress) - i = encodeVarintDeposit(dAtA, i, uint64(len(m.ExoCoreLzAppAddress))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -158,14 +120,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = len(m.ExoCoreLzAppAddress) - if l > 0 { - n += 1 + l + sovDeposit(uint64(l)) - } - l = len(m.ExoCoreLzAppEventTopic) - if l > 0 { - n += 1 + l + sovDeposit(uint64(l)) - } return n } @@ -204,70 +158,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDeposit - } - 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 ErrInvalidLengthDeposit - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthDeposit - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppEventTopic", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDeposit - } - 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 ErrInvalidLengthDeposit - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthDeposit - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppEventTopic = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDeposit(dAtA[iNdEx:]) diff --git a/x/deposit/types/errors.go b/x/deposit/types/errors.go index 65f8acf75..3ae91144f 100644 --- a/x/deposit/types/errors.go +++ b/x/deposit/types/errors.go @@ -6,9 +6,7 @@ import ( // errors var ( - ErrInvalidEvmAddressFormat = errorsmod.Register(ModuleName, 0, "the evm address format is error") - ErrInvalidLzUaTopicIDLength = errorsmod.Register(ModuleName, 1, "the LZUaTopicID length isn't equal to HashLength") - ErrNoParamsKey = errorsmod.Register(ModuleName, 2, "there is no stored key for deposit module params") - ErrDepositAmountIsNegative = errorsmod.Register(ModuleName, 3, "the deposit amount is negative") - ErrDepositAssetNotExist = errorsmod.Register(ModuleName, 4, "the deposit asset doesn't exist") + ErrNoParamsKey = errorsmod.Register(ModuleName, 1, "there is no stored key for deposit module params") + ErrDepositAmountIsNegative = errorsmod.Register(ModuleName, 2, "the deposit amount is negative") + ErrDepositAssetNotExist = errorsmod.Register(ModuleName, 3, "the deposit asset doesn't exist") ) diff --git a/x/deposit/types/keys.go b/x/deposit/types/keys.go index 18063d232..97dde7be4 100644 --- a/x/deposit/types/keys.go +++ b/x/deposit/types/keys.go @@ -28,4 +28,7 @@ const ( prefixParams = iota + 1 ) -var KeyPrefixParams = []byte{prefixParams} +var ( + KeyPrefixParams = []byte{prefixParams} + ParamsKey = []byte("Params") +) diff --git a/x/dogfood/keeper/abci.go b/x/dogfood/keeper/abci.go index 040aabdf5..27f7fd132 100644 --- a/x/dogfood/keeper/abci.go +++ b/x/dogfood/keeper/abci.go @@ -25,7 +25,7 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { // then, let the operator module know that the opt out has finished. optOuts := k.GetPendingOptOuts(ctx) for _, addr := range optOuts.GetList() { - k.operatorKeeper.CompleteOperatorOptOutFromChainId(ctx, addr, ctx.ChainID()) + k.operatorKeeper.CompleteOperatorOptOutFromChainID(ctx, addr, ctx.ChainID()) } k.ClearPendingOptOuts(ctx) // for slashing, the operator module is required to store a mapping of chain id + cons addr @@ -33,7 +33,7 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { // complete. consensusAddrs := k.GetPendingConsensusAddrs(ctx) for _, consensusAddr := range consensusAddrs.GetList() { - k.operatorKeeper.DeleteOperatorAddressForChainIdAndConsAddr( + k.operatorKeeper.DeleteOperatorAddressForChainIDAndConsAddr( ctx, ctx.ChainID(), consensusAddr, ) } @@ -47,7 +47,7 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { // if it has, queue an update. prev := k.getKeyPowerMapping(ctx).List res := make([]abci.ValidatorUpdate, 0, len(prev)) - operators, keys := k.operatorKeeper.GetActiveOperatorsForChainId(ctx, ctx.ChainID()) + operators, keys := k.operatorKeeper.GetActiveOperatorsForChainID(ctx, ctx.ChainID()) powers, err := k.restakingKeeper.GetAvgDelegatedValue( ctx, operators, k.GetAssetIDs(ctx), k.GetEpochIdentifier(ctx), ) diff --git a/x/dogfood/keeper/impl_delegation_hooks.go b/x/dogfood/keeper/impl_delegation_hooks.go index adbdc021e..c23d6be34 100644 --- a/x/dogfood/keeper/impl_delegation_hooks.go +++ b/x/dogfood/keeper/impl_delegation_hooks.go @@ -34,7 +34,7 @@ func (wrapper DelegationHooksWrapper) AfterUndelegationStarted( ctx sdk.Context, operator sdk.AccAddress, recordKey []byte, ) { var unbondingCompletionEpoch int64 - if wrapper.keeper.operatorKeeper.IsOperatorOptingOutFromChainId( + if wrapper.keeper.operatorKeeper.IsOperatorOptingOutFromChainID( ctx, operator, ctx.ChainID(), ) { // if the operator is opting out, we need to use the finish epoch of the opt out. diff --git a/x/dogfood/keeper/impl_sdk.go b/x/dogfood/keeper/impl_sdk.go index 936e7c2cb..99e30d259 100644 --- a/x/dogfood/keeper/impl_sdk.go +++ b/x/dogfood/keeper/impl_sdk.go @@ -61,7 +61,7 @@ func (k Keeper) ValidatorByConsAddr( ctx sdk.Context, addr sdk.ConsAddress, ) stakingtypes.ValidatorI { - found, accAddr := k.operatorKeeper.GetOperatorAddressForChainIdAndConsAddr( + found, accAddr := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr( ctx, ctx.ChainID(), addr, ) if !found { @@ -69,7 +69,7 @@ func (k Keeper) ValidatorByConsAddr( return nil } return stakingtypes.Validator{ - Jailed: k.operatorKeeper.IsOperatorJailedForChainId(ctx, accAddr, ctx.ChainID()), + Jailed: k.operatorKeeper.IsOperatorJailedForChainID(ctx, accAddr, ctx.ChainID()), } } @@ -94,7 +94,7 @@ func (k Keeper) SlashWithInfractionReason( ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, infraction stakingtypes.Infraction, ) math.Int { - found, accAddress := k.operatorKeeper.GetOperatorAddressForChainIdAndConsAddr( + found, accAddress := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr( ctx, ctx.ChainID(), addr, ) if !found { @@ -154,14 +154,14 @@ func (k Keeper) GetAllValidators(sdk.Context) (validators []stakingtypes.Validat // slashing module. It is called by the slashing module to record validator signatures // for downtime tracking. We delegate the call to the operator keeper. func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { - found, accAddr := k.operatorKeeper.GetOperatorAddressForChainIdAndConsAddr( + found, accAddr := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr( ctx, ctx.ChainID(), addr, ) if !found { // replicate the behavior of the SDK's staking module return false } - return k.operatorKeeper.IsOperatorJailedForChainId(ctx, accAddr, ctx.ChainID()) + return k.operatorKeeper.IsOperatorJailedForChainID(ctx, accAddr, ctx.ChainID()) } // ApplyAndReturnValidatorSetUpdates is an implementation of the staking interface expected diff --git a/x/dogfood/keeper/keeper.go b/x/dogfood/keeper/keeper.go index a0ba33e63..4f10371eb 100644 --- a/x/dogfood/keeper/keeper.go +++ b/x/dogfood/keeper/keeper.go @@ -25,7 +25,7 @@ type ( epochsKeeper types.EpochsKeeper operatorKeeper types.OperatorKeeper delegationKeeper types.DelegationKeeper - restakingKeeper types.RestakingKeeper + restakingKeeper types.AssetsKeeper slashingKeeper types.SlashingKeeper } ) @@ -38,7 +38,7 @@ func NewKeeper( epochsKeeper types.EpochsKeeper, operatorKeeper types.OperatorKeeper, delegationKeeper types.DelegationKeeper, - restakingKeeper types.RestakingKeeper, + restakingKeeper types.AssetsKeeper, slashingKeeper types.SlashingKeeper, ) *Keeper { // set KeyTable if it has not already been set diff --git a/x/dogfood/types/expected_keepers.go b/x/dogfood/types/expected_keepers.go index 6c6862d9f..0fc1c154f 100644 --- a/x/dogfood/types/expected_keepers.go +++ b/x/dogfood/types/expected_keepers.go @@ -42,23 +42,23 @@ type DelegationHooks interface { // OperatorKeeper represents the expected keeper interface for the operator module. type OperatorKeeper interface { - GetOperatorConsKeyForChainId( + GetOperatorConsKeyForChainID( sdk.Context, sdk.AccAddress, string, ) (bool, tmprotocrypto.PublicKey, error) - IsOperatorOptingOutFromChainId( + IsOperatorOptingOutFromChainID( sdk.Context, sdk.AccAddress, string, ) bool - CompleteOperatorOptOutFromChainId(sdk.Context, sdk.AccAddress, string) - DeleteOperatorAddressForChainIdAndConsAddr(sdk.Context, string, sdk.ConsAddress) - GetOperatorAddressForChainIdAndConsAddr( + CompleteOperatorOptOutFromChainID(sdk.Context, sdk.AccAddress, string) + DeleteOperatorAddressForChainIDAndConsAddr(sdk.Context, string, sdk.ConsAddress) + GetOperatorAddressForChainIDAndConsAddr( sdk.Context, string, sdk.ConsAddress, ) (bool, sdk.AccAddress) - IsOperatorJailedForChainId(sdk.Context, sdk.AccAddress, string) bool + IsOperatorJailedForChainID(sdk.Context, sdk.AccAddress, string) bool Jail(sdk.Context, sdk.ConsAddress, string) - // GetActiveOperatorsForChainId should return a list of operators and their public keys. + // GetActiveOperatorsForChainID should return a list of operators and their public keys. // These operators should not be in the process of opting our, and should not be jailed // whether permanently or temporarily. - GetActiveOperatorsForChainId( + GetActiveOperatorsForChainID( sdk.Context, string, ) ([]sdk.AccAddress, []tmprotocrypto.PublicKey) } @@ -75,8 +75,8 @@ type EpochsHooks interface { BeforeEpochStart(sdk.Context, string, int64) } -// RestakingKeeper represents the expected keeper interface for the restaking module. -type RestakingKeeper interface { +// AssetsKeeper represents the expected keeper interface for the assets module. +type AssetsKeeper interface { GetOperatorAssetValue(sdk.Context, sdk.AccAddress) (int64, error) IsStakingAsset(sdk.Context, string) bool GetAvgDelegatedValue( diff --git a/x/native_token/module.go b/x/native_token/module.go index 08a16273a..8dff94c29 100644 --- a/x/native_token/module.go +++ b/x/native_token/module.go @@ -85,9 +85,9 @@ type IDeposit interface { PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error // SetReStakerExoCoreAddr handle the SetReStakerExoCoreAddr txs from msg service - SetReStakerExoCoreAddr(ctx context.Context, reStakerID string) (err error) - GetReStakerExoCoreAddr(reStakerID string) (addr sdk.Address, err error) + SetReStakerExoCoreAddr(ctx context.Context, restakerID string) (err error) + GetReStakerExoCoreAddr(restakerID string) (addr sdk.Address, err error) // Deposit internal func for PostTxProcessing - Deposit(reStakerID string, assetsInfo map[string]math.Uint) error + Deposit(restakerID string, assetsInfo map[string]math.Uint) error } diff --git a/x/native_token/types/keys.go b/x/native_token/types/keys.go index bcc3947a5..1a74b9734 100644 --- a/x/native_token/types/keys.go +++ b/x/native_token/types/keys.go @@ -28,6 +28,6 @@ const ( prefixReStakerExocoreAddr = iota + 1 ) -// KeyPrefixReStakerExoCoreAddr reStakerID = clientChainAddr+'_'+ExoCoreChainIndex -// KeyPrefixReStakerExoCoreAddr key-value: reStakerID->exoCoreAddr +// KeyPrefixReStakerExoCoreAddr restakerID = clientChainAddr+'_'+ExoCoreChainIndex +// KeyPrefixReStakerExoCoreAddr key-value: restakerID->exoCoreAddr var KeyPrefixReStakerExoCoreAddr = []byte{prefixReStakerExocoreAddr} diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index f146a733e..b7eb48311 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -40,7 +40,7 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { assetsDecimal := make(map[string]uint32) for assetID, priceChange := range priceChangeAssets { // get the decimal of asset - assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) + assetInfo, err := k.assetsKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } @@ -88,11 +88,11 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { return err } - operatorShareHandleFunc := func(operatorAddr, assetID string, state *types.OperatorSingleAssetInfo) error { - UpdateShareOfStakerAndOperator(sharedParameter, assetID, "", operatorAddr, state.OperatorOwnAmount) + operatorShareHandleFunc := func(operatorAddr, assetID string, state *types.OperatorAssetInfo) error { + UpdateShareOfStakerAndOperator(sharedParameter, assetID, "", operatorAddr, state.OperatorAmount) return nil } - err = k.restakingStateKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) + err = k.assetsKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) if err != nil { return err } diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index ba978454e..911423f5a 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -131,7 +131,7 @@ func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operator // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return assetstype.ErrOperatorAddr + return assetstype.ErrInvalidOperatorAddr } stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) optedInAssetState := operatortypes.OptedInAssetState{ @@ -165,7 +165,7 @@ func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAdd // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return assetstype.ErrOperatorAddr + return assetstype.ErrInvalidOperatorAddr } stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) store.Delete(stateKey) diff --git a/x/operator/keeper/dogfood.go b/x/operator/keeper/dogfood.go index ab2dc63eb..c6fd55434 100644 --- a/x/operator/keeper/dogfood.go +++ b/x/operator/keeper/dogfood.go @@ -40,8 +40,8 @@ func (k *Keeper) SetOperatorConsKeyForChainID( return delegationtypes.ErrOperatorIsFrozen } // check if the chain id is valid - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - return assetstypes.ErrNoAppChainKey + if !k.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + return assetstypes.ErrUnknownAppChainID } // if opting out, do not allow key replacement if k.IsOperatorOptingOutFromChainID(ctx, opAccAddr, chainID) { @@ -175,8 +175,8 @@ func (k *Keeper) GetOperatorPrevConsKeyForChainID( err = delegationtypes.ErrOperatorNotExist return } - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - err = assetstypes.ErrNoAppChainKey + if !k.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + err = assetstypes.ErrUnknownAppChainID return } // do not check for slashing here @@ -216,8 +216,8 @@ func (k *Keeper) GetOperatorConsKeyForChainID( err = delegationtypes.ErrOperatorNotExist return } - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - err = assetstypes.ErrNoAppChainKey + if !k.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + err = assetstypes.ErrUnknownAppChainID return } // do not check for slashing, since this function will be used to update voting power even @@ -286,7 +286,7 @@ func (k *Keeper) GetChainIDsAndKeysForOperator( func (k *Keeper) GetOperatorsForChainID( ctx sdk.Context, chainID string, ) (addrs []sdk.AccAddress, pubKeys []tmprotocrypto.PublicKey) { - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { + if !k.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { return nil, nil } // prefix is the byte prefix and then chainID with length @@ -376,8 +376,8 @@ func (k *Keeper) InitiateOperatorOptOutFromChainID( return delegationtypes.ErrOperatorIsFrozen } // check if the chain id is valid - if !k.restakingStateKeeper.AppChainInfoIsExist(ctx, chainID) { - return assetstypes.ErrNoAppChainKey + if !k.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + return assetstypes.ErrUnknownAppChainID } found, key, err := k.getOperatorConsKeyForChainID(ctx, opAccAddr, chainID) if err != nil { @@ -423,3 +423,9 @@ func (k *Keeper) IsOperatorJailedForChainID(sdk.Context, sdk.AccAddress, string) return false } func (k *Keeper) Jail(sdk.Context, sdk.ConsAddress, string) {} + +func (k *Keeper) GetActiveOperatorsForChainID( + sdk.Context, string, +) ([]sdk.AccAddress, []tmprotocrypto.PublicKey) { + return nil, nil +} diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 2f30d64fa..a11ae7acb 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -16,10 +16,10 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers - restakingStateKeeper keeper.Keeper - delegationKeeper operatortypes.ExpectDelegationInterface - oracleKeeper operatortypes.ExpectOracleInterface - avsKeeper operatortypes.ExpectAvsInterface + assetsKeeper keeper.Keeper + delegationKeeper operatortypes.ExpectDelegationInterface + oracleKeeper operatortypes.ExpectOracleInterface + avsKeeper operatortypes.ExpectAvsInterface // add for dogfood hooks operatortypes.OperatorConsentHooks // set separately via call to SetHooks @@ -29,18 +29,18 @@ type Keeper struct { func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - restakingStateKeeper keeper.Keeper, + assetsKeeper keeper.Keeper, oracleKeeper operatortypes.ExpectOracleInterface, avsKeeper operatortypes.ExpectAvsInterface, slashKeeper operatortypes.SlashKeeper, ) Keeper { return Keeper{ - storeKey: storeKey, - cdc: cdc, - restakingStateKeeper: restakingStateKeeper, - oracleKeeper: oracleKeeper, - avsKeeper: avsKeeper, - slashKeeper: slashKeeper, + storeKey: storeKey, + cdc: cdc, + assetsKeeper: assetsKeeper, + oracleKeeper: oracleKeeper, + avsKeeper: avsKeeper, + slashKeeper: slashKeeper, } } diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index cd8cd9858..eb1e748ed 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -61,7 +61,7 @@ func (k *Keeper) UpdateOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return assetstype.ErrOperatorAddr + return assetstype.ErrInvalidOperatorAddr } infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index d3630931d..cdc9878d5 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -23,7 +23,7 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, // check operator address validation _, err := sdk.AccAddressFromBech32(operatorAddr) if err != nil { - return assetstype.ErrOperatorAddr + return assetstype.ErrInvalidOperatorAddr } slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) if store.Has(slashInfoKey) { diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index 3395cd04d..8326be1ee 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -40,7 +40,7 @@ func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, op } // get the decimal of asset - assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) + assetInfo, err := k.assetsKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } @@ -98,7 +98,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr } // get the Assets opted in the operator - operatorAssets, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) + operatorAssets, err := k.assetsKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) if err != nil { return err } @@ -116,7 +116,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr } // get the decimal of asset - assetInfo, err := k.restakingStateKeeper.GetStakingAssetInfo(ctx, assetID) + assetInfo, err := k.assetsKeeper.GetStakingAssetInfo(ctx, assetID) if err != nil { return err } @@ -126,7 +126,7 @@ func (k *Keeper) OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr Decimal: assetInfo.AssetBasicInfo.Decimals, } assetUSDValue := CalculateShare(operatorAssetState.TotalAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) - operatorUSDValue := CalculateShare(operatorAssetState.OperatorOwnAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) + operatorUSDValue := CalculateShare(operatorAssetState.OperatorAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(operatorUSDValue) // UpdateStateForAsset @@ -209,7 +209,7 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr return err } // get the Assets opted in the operator - operatorAssets, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) + operatorAssets, err := k.assetsKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) if err != nil { return err } @@ -298,7 +298,7 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc } // get the Assets opted in the operator - historyOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(historicalSateCtx, operatorAddress, assetsFilter) + historyOperatorAssetsState, err := k.assetsKeeper.GetOperatorAssetInfos(historicalSateCtx, operatorAddress, assetsFilter) if err != nil { return nil, err } @@ -309,7 +309,7 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc return nil, err } // get the Assets opted in the operator - currentOperatorAssetsState, err := k.restakingStateKeeper.GetOperatorAssetInfos(ctx, operatorAddress, assetsFilter) + currentOperatorAssetsState, err := k.assetsKeeper.GetOperatorAssetInfos(ctx, operatorAddress, assetsFilter) if err != nil { return nil, err } @@ -342,10 +342,10 @@ func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.Acc // calculate the actual slash amount for operator for assetID, curAssetState := range currentOperatorAssetsState { if historyAssetState, ok := historyOperatorAssetsState[assetID]; ok { - shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorOwnAmount).TruncateInt() - if curAssetState.OperatorOwnAmount.LT(shouldSlashAmount) { - ret.slashOperatorInfo[assetID].AmountFromOptedIn = curAssetState.OperatorOwnAmount - remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorOwnAmount) + shouldSlashAmount := slashProportion.MulInt(historyAssetState.OperatorAmount).TruncateInt() + if curAssetState.OperatorAmount.LT(shouldSlashAmount) { + ret.slashOperatorInfo[assetID].AmountFromOptedIn = curAssetState.OperatorAmount + remainShouldSlash := shouldSlashAmount.Sub(curAssetState.OperatorAmount) if curAssetState.OperatorUnbondableAmountAfterSlash.LT(remainShouldSlash) { ret.slashOperatorInfo[assetID].AmountFromUnbonding = curAssetState.OperatorUnbondableAmountAfterSlash } else { @@ -380,7 +380,7 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) // update staker and operator assets state - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetChangeInfo{ TotalDepositAmount: slashSumValue.Neg(), }) if err != nil { @@ -394,7 +394,7 @@ func (k *Keeper) SlashStaker(ctx sdk.Context, operatorAddress sdk.AccAddress, sl } // handle the state that needs to be updated when slashing opted-in assets - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ TotalAmount: slashInfo.AmountFromOptedIn.Neg(), }) if err != nil { @@ -414,9 +414,9 @@ func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, for assetID, slashInfo := range slashOperatorInfo { slashSumValue := slashInfo.AmountFromUnbonding.Add(slashInfo.AmountFromOptedIn) // handle the state that needs to be updated when slashing both opted-in and unbonding assets - err := k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ + err := k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ TotalAmount: slashSumValue.Neg(), - OperatorOwnAmount: slashInfo.AmountFromOptedIn.Neg(), + OperatorAmount: slashInfo.AmountFromOptedIn.Neg(), OperatorUnbondableAmountAfterSlash: slashInfo.AmountFromUnbonding.Neg(), }) if err != nil { diff --git a/x/reward/client/cli/tx.go b/x/reward/client/cli/tx.go index 7a28d01b4..b6a7f187a 100644 --- a/x/reward/client/cli/tx.go +++ b/x/reward/client/cli/tx.go @@ -6,9 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/ExocoreNetwork/exocore/x/reward/types" ) @@ -23,41 +20,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand( - UpdateParams(), - ) - - return cmd -} - -// UpdateParams todo: it should be a gov proposal command in future. -func UpdateParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "UpdateParams ExoCoreLZAppAddr ExoCoreLzAppEventTopic", - Short: "set ExoCoreLZAppAddr and ExoCoreLzAppEventTopic params to reward module", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := cliCtx.GetFromAddress() - msg := &types.MsgUpdateParams{ - Authority: sender.String(), - Params: types.Params{ - ExoCoreLzAppAddress: args[0], - ExoCoreLzAppEventTopic: args[1], - }, - } - - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) - }, - } + cmd.AddCommand() - flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index a7f062a48..182b074f8 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -93,14 +93,14 @@ func getStakeIDAndAssetID(params *RewardParams) (stakeID string, assetID string) func (k Keeper) PostTxProcessing(ctx sdk.Context, _ core.Message, receipt *ethtypes.Receipt) error { // TODO check if contract address is valid layerZero relayer address // check if log address and topicId is valid - params, err := k.GetParams(ctx) + params, err := k.assetsKeeper.GetParams(ctx) if err != nil { return err } // filter needed logs - addresses := []common.Address{common.HexToAddress(params.ExoCoreLzAppAddress)} + addresses := []common.Address{common.HexToAddress(params.ExocoreLzAppAddress)} topics := [][]common.Hash{ - {common.HexToHash(params.ExoCoreLzAppEventTopic)}, + {common.HexToHash(params.ExocoreLzAppEventTopic)}, } needLogs := filters.FilterLogs(receipt.Logs, nil, nil, addresses, topics) if len(needLogs) == 0 { @@ -131,7 +131,7 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { } stakeID, assetID := getStakeIDAndAssetID(event) // check is asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + if !k.assetsKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(rtypes.ErrRewardAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } @@ -140,11 +140,11 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { TotalDepositAmount: event.OpAmount, WithdrawableAmount: event.OpAmount, } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } - if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount); err != nil { + if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount); err != nil { return err } return nil diff --git a/x/reward/keeper/claim_reward_test.go b/x/reward/keeper/claim_reward_test.go index 4ceed1256..a8d6b514b 100644 --- a/x/reward/keeper/claim_reward_test.go +++ b/x/reward/keeper/claim_reward_test.go @@ -30,15 +30,15 @@ func (suite *RewardTestSuite) TestClaimWithdrawRequest() { // check state after reward stakerID, assetID := types.GetStakeIDAndAssetID(event.ClientChainLzID, event.WithdrawRewardAddress, event.AssetsAddress) - info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + info, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: sdkmath.NewInt(10), WithdrawableAmount: sdkmath.NewInt(10), WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) + assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(10), assetInfo.StakingTotalAmount) } diff --git a/x/reward/keeper/keeper.go b/x/reward/keeper/keeper.go index 5320bb94d..30380c15f 100644 --- a/x/reward/keeper/keeper.go +++ b/x/reward/keeper/keeper.go @@ -17,18 +17,18 @@ type Keeper struct { storeKey storetypes.StoreKey // other keepers - restakingStateKeeper keeper.Keeper + assetsKeeper keeper.Keeper } func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - restakingStateKeeper keeper.Keeper, + assetsKeeper keeper.Keeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - restakingStateKeeper: restakingStateKeeper, + cdc: cdc, + storeKey: storeKey, + assetsKeeper: assetsKeeper, } } diff --git a/x/reward/keeper/params.go b/x/reward/keeper/params.go index 4d838582d..6932b8cf5 100644 --- a/x/reward/keeper/params.go +++ b/x/reward/keeper/params.go @@ -4,19 +4,12 @@ import ( "github.com/ExocoreNetwork/exocore/x/reward/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) +// SetParams The function related to module parameter should be deleted +// if no parameters need to be stored in the future. func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { - // check if addr is evm address - if !common.IsHexAddress(params.ExoCoreLzAppAddress) { - return types.ErrInvalidEvmAddressFormat - } - if len(common.FromHex(params.ExoCoreLzAppEventTopic)) != common.HashLength { - return types.ErrInvalidLzUaTopicIDLength - } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixParams) - // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(params) store.Set(types.ParamsKey, bz) return nil diff --git a/x/reward/keeper/params_test.go b/x/reward/keeper/params_test.go index 3dfa1fd9e..77034d250 100644 --- a/x/reward/keeper/params_test.go +++ b/x/reward/keeper/params_test.go @@ -5,10 +5,7 @@ import ( ) func (suite *RewardTestSuite) TestParams() { - params := &rewardtype.Params{ - ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", - ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", - } + params := &rewardtype.Params{} err := suite.App.RewardKeeper.SetParams(suite.Ctx, params) suite.NoError(err) diff --git a/x/reward/types/params.pb.go b/x/reward/types/params.pb.go index 05e43f3d2..9f1e3fe81 100644 --- a/x/reward/types/params.pb.go +++ b/x/reward/types/params.pb.go @@ -24,10 +24,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - // exo_core_lz_app_address is the address of the L0 app. - ExoCoreLzAppAddress string `protobuf:"bytes,1,opt,name=exo_core_lz_app_address,json=exoCoreLzAppAddress,proto3" json:"exo_core_lz_app_address,omitempty"` - // exo_core_lz_app_event_topic is the topic of the L0 app. - ExoCoreLzAppEventTopic string `protobuf:"bytes,2,opt,name=exo_core_lz_app_event_topic,json=exoCoreLzAppEventTopic,proto3" json:"exo_core_lz_app_event_topic,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -63,20 +59,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetExoCoreLzAppAddress() string { - if m != nil { - return m.ExoCoreLzAppAddress - } - return "" -} - -func (m *Params) GetExoCoreLzAppEventTopic() string { - if m != nil { - return m.ExoCoreLzAppEventTopic - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "exocore.reward.Params") } @@ -84,21 +66,16 @@ func init() { func init() { proto.RegisterFile("exocore/reward/params.proto", fileDescriptor_1a29ebcfb63d5930) } var fileDescriptor_1a29ebcfb63d5930 = []byte{ - // 212 bytes of a gzipped FileDescriptorProto + // 134 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0xd1, 0x2f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 0x00, 0x00, + 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xea, 0x41, 0x24, 0x95, 0x38, + 0xb8, 0xd8, 0x02, 0xc0, 0xf2, 0x4e, 0x5e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, + 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, + 0x10, 0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x0a, 0xd1, + 0xee, 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0xad, 0x0f, 0xb3, 0xaa, 0x02, 0x66, 0x59, 0x49, 0x65, + 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x32, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, 0xa7, + 0x13, 0x63, 0x8b, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -121,20 +98,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ExoCoreLzAppEventTopic) > 0 { - i -= len(m.ExoCoreLzAppEventTopic) - copy(dAtA[i:], m.ExoCoreLzAppEventTopic) - i = encodeVarintParams(dAtA, i, uint64(len(m.ExoCoreLzAppEventTopic))) - i-- - dAtA[i] = 0x12 - } - if len(m.ExoCoreLzAppAddress) > 0 { - i -= len(m.ExoCoreLzAppAddress) - copy(dAtA[i:], m.ExoCoreLzAppAddress) - i = encodeVarintParams(dAtA, i, uint64(len(m.ExoCoreLzAppAddress))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -155,14 +118,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = len(m.ExoCoreLzAppAddress) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.ExoCoreLzAppEventTopic) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } return n } @@ -201,70 +156,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppEventTopic", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppEventTopic = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/slash/client/cli/tx.go b/x/slash/client/cli/tx.go index 19235e4dc..fa0675d14 100644 --- a/x/slash/client/cli/tx.go +++ b/x/slash/client/cli/tx.go @@ -7,8 +7,6 @@ import ( "github.com/ExocoreNetwork/exocore/x/slash/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" ) // GetTxCmd returns the transaction commands for this module @@ -21,41 +19,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand( - UpdateParams(), - ) + cmd.AddCommand() return cmd } - -// UpdateParams todo: it should be a gov proposal command in future. -func UpdateParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "UpdateParams ExoCoreLZAppAddr ExoCoreLzAppEventTopic", - Short: "set ExoCoreLZAppAddr and ExoCoreLzAppEventTopic params to exoSlash module", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := cliCtx.GetFromAddress() - msg := &types.MsgUpdateParams{ - Authority: sender.String(), - Params: types.Params{ - ExoCoreLzAppAddress: args[0], - ExoCoreLzAppEventTopic: args[1], - }, - } - - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} diff --git a/x/slash/keeper/execute_slash.go b/x/slash/keeper/execute_slash.go index 901f515f4..54357dbff 100644 --- a/x/slash/keeper/execute_slash.go +++ b/x/slash/keeper/execute_slash.go @@ -62,7 +62,7 @@ func (k Keeper) getParamsFromEventLog(ctx sdk.Context, log *ethtypes.Log) (*Slas if err != nil { return nil, errorsmod.Wrap(err, "error occurred when binary read clientChainLzID from topic") } - clientChainInfo, err := k.restakingStateKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) + clientChainInfo, err := k.assetsKeeper.GetClientChainInfoByIndex(ctx, clientChainLzID) if err != nil { return nil, errorsmod.Wrap(err, "error occurred when get client chain info") } @@ -121,28 +121,28 @@ func getStakeIDAndAssetID(params *SlashParams) (stakeID string, assetID string) } func (k Keeper) FilterCrossChainEventLogs(ctx sdk.Context, _ core.Message, receipt *ethtypes.Receipt) ([]*ethtypes.Log, error) { - params, err := k.GetParams(ctx) + params, err := k.assetsKeeper.GetParams(ctx) if err != nil { return nil, err } // filter needed logs - addresses := []common.Address{common.HexToAddress(params.ExoCoreLzAppAddress)} + addresses := []common.Address{common.HexToAddress(params.ExocoreLzAppAddress)} topics := [][]common.Hash{ - {common.HexToHash(params.ExoCoreLzAppEventTopic)}, + {common.HexToHash(params.ExocoreLzAppEventTopic)}, } needLogs := filters.FilterLogs(receipt.Logs, nil, nil, addresses, topics) return needLogs, nil } func (k Keeper) PostTxProcessing(ctx sdk.Context, _ core.Message, receipt *ethtypes.Receipt) error { - params, err := k.GetParams(ctx) + params, err := k.assetsKeeper.GetParams(ctx) if err != nil { return err } // filter needed logs - addresses := []common.Address{common.HexToAddress(params.ExoCoreLzAppAddress)} + addresses := []common.Address{common.HexToAddress(params.ExocoreLzAppAddress)} topics := [][]common.Hash{ - {common.HexToHash(params.ExoCoreLzAppEventTopic)}, + {common.HexToHash(params.ExocoreLzAppEventTopic)}, } needLogs := filters.FilterLogs(receipt.Logs, nil, nil, addresses, topics) if err != nil { @@ -185,7 +185,7 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { } stakeID, assetID := getStakeIDAndAssetID(event) // check is asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + if !k.assetsKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(rtypes.ErrSlashAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } @@ -193,11 +193,11 @@ func (k Keeper) Slash(ctx sdk.Context, event *SlashParams) error { TotalDepositAmount: event.OpAmount.Neg(), WithdrawableAmount: event.OpAmount.Neg(), } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } - if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount.Neg()); err != nil { + if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, event.OpAmount.Neg()); err != nil { return err } return nil diff --git a/x/slash/keeper/execute_slash_test.go b/x/slash/keeper/execute_slash_test.go index 9b06e3efc..fe91997c8 100644 --- a/x/slash/keeper/execute_slash_test.go +++ b/x/slash/keeper/execute_slash_test.go @@ -36,14 +36,14 @@ func (suite *SlashTestSuite) TestSlash() { err = suite.App.ExoSlashKeeper.Slash(suite.Ctx, event) suite.ErrorContains(err, slashtype.ErrSlashAssetNotExist.Error()) - assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) + assets, err := suite.App.AssetsKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) suite.App.Logger().Info("the assets is:", "assets", assets) stakerID, assetID := types.GetStakeIDAndAssetID(depositEvent.ClientChainLzID, depositEvent.StakerAddress, depositEvent.AssetsAddress) - info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + info, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: depositEvent.OpAmount, WithdrawableAmount: depositEvent.OpAmount, WaitUnbondingAmount: sdkmath.NewInt(0), @@ -56,15 +56,15 @@ func (suite *SlashTestSuite) TestSlash() { // check state after slash stakerID, assetID = types.GetStakeIDAndAssetID(event.ClientChainLzID, event.StakerAddress, event.AssetsAddress) - info, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + info, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: sdkmath.NewInt(10), WithdrawableAmount: sdkmath.NewInt(10), WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) + assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(10), assetInfo.StakingTotalAmount) } diff --git a/x/slash/keeper/keeper.go b/x/slash/keeper/keeper.go index 3a214df9e..b4c167223 100644 --- a/x/slash/keeper/keeper.go +++ b/x/slash/keeper/keeper.go @@ -20,18 +20,18 @@ type Keeper struct { storeKey storetypes.StoreKey // other keepers - restakingStateKeeper keeper.Keeper + assetsKeeper keeper.Keeper } func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - restakingStateKeeper keeper.Keeper, + assetsKeeper keeper.Keeper, ) Keeper { return Keeper{ - cdc: cdc, - storeKey: storeKey, - restakingStateKeeper: restakingStateKeeper, + cdc: cdc, + storeKey: storeKey, + assetsKeeper: assetsKeeper, } } diff --git a/x/slash/keeper/params.go b/x/slash/keeper/params.go index a7a10d4d0..052b9a437 100644 --- a/x/slash/keeper/params.go +++ b/x/slash/keeper/params.go @@ -1,26 +1,15 @@ package keeper import ( - "strings" - "github.com/ExocoreNetwork/exocore/x/slash/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) +// SetParams The function related to module parameter should be deleted +// if no parameters need to be stored in the future. func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { - // check if addr is evm address - if !common.IsHexAddress(params.ExoCoreLzAppAddress) { - return types.ErrInvalidEvmAddressFormat - } - if len(common.FromHex(params.ExoCoreLzAppEventTopic)) != common.HashLength { - return types.ErrInvalidLzUaTopicIDLength - } - params.ExoCoreLzAppAddress = strings.ToLower(params.ExoCoreLzAppAddress) - params.ExoCoreLzAppEventTopic = strings.ToLower(params.ExoCoreLzAppEventTopic) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixParams) - // key := common.HexToAddress(incentive.Contract) bz := k.cdc.MustMarshal(params) store.Set(types.ParamsKey, bz) return nil diff --git a/x/slash/keeper/params_test.go b/x/slash/keeper/params_test.go index 4d4342717..3c2054289 100644 --- a/x/slash/keeper/params_test.go +++ b/x/slash/keeper/params_test.go @@ -5,10 +5,7 @@ import ( ) func (suite *SlashTestSuite) TestParams() { - params := &slashtype.Params{ - ExoCoreLzAppAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", - ExoCoreLzAppEventTopic: "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec", - } + params := &slashtype.Params{} err := suite.App.ExoSlashKeeper.SetParams(suite.Ctx, params) suite.NoError(err) diff --git a/x/slash/types/params.pb.go b/x/slash/types/params.pb.go index 065131cf0..23bcbd6d3 100644 --- a/x/slash/types/params.pb.go +++ b/x/slash/types/params.pb.go @@ -24,10 +24,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - // exo_core_lz_app_address defines the address of the lz app - ExoCoreLzAppAddress string `protobuf:"bytes,1,opt,name=exo_core_lz_app_address,json=exoCoreLzAppAddress,proto3" json:"exo_core_lz_app_address,omitempty"` - // exo_core_lz_app_event_topic defines the topic of the lz app - ExoCoreLzAppEventTopic string `protobuf:"bytes,2,opt,name=exo_core_lz_app_event_topic,json=exoCoreLzAppEventTopic,proto3" json:"exo_core_lz_app_event_topic,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -63,20 +59,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetExoCoreLzAppAddress() string { - if m != nil { - return m.ExoCoreLzAppAddress - } - return "" -} - -func (m *Params) GetExoCoreLzAppEventTopic() string { - if m != nil { - return m.ExoCoreLzAppEventTopic - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "exocore.slash.Params") } @@ -84,21 +66,16 @@ func init() { func init() { proto.RegisterFile("exocore/slash/params.proto", fileDescriptor_a98d46ef8bcc0f8a) } var fileDescriptor_a98d46ef8bcc0f8a = []byte{ - // 211 bytes of a gzipped FileDescriptorProto + // 133 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0xce, 0x49, 0x2c, 0xce, 0xd0, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, - 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0xca, 0xe9, 0x81, 0xe5, 0x94, 0xaa, 0xb9, - 0xd8, 0x02, 0xc0, 0xd2, 0x42, 0x26, 0x5c, 0xe2, 0xa9, 0x15, 0xf9, 0xf1, 0x20, 0xb9, 0xf8, 0x9c, - 0xaa, 0xf8, 0xc4, 0x82, 0x82, 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0x62, 0x09, 0x46, 0x05, - 0x46, 0x0d, 0xce, 0x20, 0xe1, 0xd4, 0x8a, 0x7c, 0xe7, 0xfc, 0xa2, 0x54, 0x9f, 0x2a, 0xc7, 0x82, - 0x02, 0x47, 0x88, 0x94, 0x90, 0x35, 0x97, 0x34, 0xba, 0xae, 0xd4, 0xb2, 0xd4, 0xbc, 0x92, 0xf8, - 0x92, 0xfc, 0x82, 0xcc, 0x64, 0x09, 0x26, 0xb0, 0x4e, 0x31, 0x64, 0x9d, 0xae, 0x20, 0xe9, 0x10, - 0x90, 0xac, 0x93, 0xe7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, - 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa7, - 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xbb, 0x42, 0x1c, 0xec, 0x97, 0x5a, - 0x52, 0x9e, 0x5f, 0x94, 0xad, 0x0f, 0xf3, 0x5b, 0x05, 0xd4, 0x77, 0x25, 0x95, 0x05, 0xa9, 0xc5, - 0x49, 0x6c, 0x60, 0xdf, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x74, 0xb3, 0x99, 0x42, 0xfb, - 0x00, 0x00, 0x00, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x85, 0xca, 0xe9, 0x81, 0xe5, 0x94, 0x38, 0xb8, + 0xd8, 0x02, 0xc0, 0xd2, 0x4e, 0x9e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, + 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, + 0xa5, 0x9f, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x0a, 0xd1, 0xed, + 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0xad, 0x0f, 0xb3, 0xa8, 0x02, 0x6a, 0x55, 0x49, 0x65, 0x41, + 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x2a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x51, 0x08, 0x77, + 0x28, 0x88, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -121,20 +98,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ExoCoreLzAppEventTopic) > 0 { - i -= len(m.ExoCoreLzAppEventTopic) - copy(dAtA[i:], m.ExoCoreLzAppEventTopic) - i = encodeVarintParams(dAtA, i, uint64(len(m.ExoCoreLzAppEventTopic))) - i-- - dAtA[i] = 0x12 - } - if len(m.ExoCoreLzAppAddress) > 0 { - i -= len(m.ExoCoreLzAppAddress) - copy(dAtA[i:], m.ExoCoreLzAppAddress) - i = encodeVarintParams(dAtA, i, uint64(len(m.ExoCoreLzAppAddress))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -155,14 +118,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = len(m.ExoCoreLzAppAddress) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.ExoCoreLzAppEventTopic) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } return n } @@ -201,70 +156,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExoCoreLzAppEventTopic", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExoCoreLzAppEventTopic = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/withdraw/keeper/claim_withdraw.go b/x/withdraw/keeper/claim_withdraw.go index a93d8d2d3..eb6a7fbb7 100644 --- a/x/withdraw/keeper/claim_withdraw.go +++ b/x/withdraw/keeper/claim_withdraw.go @@ -125,18 +125,18 @@ func (k Keeper) Withdraw(ctx sdk.Context, params *WithdrawParams) error { stakeID, assetID := getStakeIDAndAssetID(params) // check if asset exist - if !k.restakingStateKeeper.IsStakingAsset(ctx, assetID) { + if !k.assetsKeeper.IsStakingAsset(ctx, assetID) { return errorsmod.Wrap(withdrawtype.ErrWithdrawAssetNotExist, fmt.Sprintf("the assetID is:%s", assetID)) } changeAmount := types.StakerSingleAssetChangeInfo{ TotalDepositAmount: params.OpAmount.Neg(), WithdrawableAmount: params.OpAmount.Neg(), } - err := k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) + err := k.assetsKeeper.UpdateStakerAssetState(ctx, stakeID, assetID, changeAmount) if err != nil { return err } - if err = k.restakingStateKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, params.OpAmount.Neg()); err != nil { + if err = k.assetsKeeper.UpdateStakingAssetTotalAmount(ctx, assetID, params.OpAmount.Neg()); err != nil { return err } return nil diff --git a/x/withdraw/keeper/claim_withdraw_test.go b/x/withdraw/keeper/claim_withdraw_test.go index 1680aa9d1..e9f785714 100644 --- a/x/withdraw/keeper/claim_withdraw_test.go +++ b/x/withdraw/keeper/claim_withdraw_test.go @@ -36,14 +36,14 @@ func (suite *WithdrawTestSuite) TestClaimWithdrawRequest() { err = suite.App.WithdrawKeeper.Withdraw(suite.Ctx, event) suite.ErrorContains(err, withdrawtype.ErrWithdrawAssetNotExist.Error()) - assets, err := suite.App.StakingAssetsManageKeeper.GetAllStakingAssetsInfo(suite.Ctx) + assets, err := suite.App.AssetsKeeper.GetAllStakingAssetsInfo(suite.Ctx) suite.NoError(err) suite.App.Logger().Info("the assets is:", "assets", assets) stakerID, assetID := types.GetStakeIDAndAssetID(depositEvent.ClientChainLzID, depositEvent.StakerAddress, depositEvent.AssetsAddress) - info, err := suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + info, err := suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: depositEvent.OpAmount, WithdrawableAmount: depositEvent.OpAmount, WaitUnbondingAmount: sdkmath.NewInt(0), @@ -55,15 +55,15 @@ func (suite *WithdrawTestSuite) TestClaimWithdrawRequest() { // check state after withdraw stakerID, assetID = types.GetStakeIDAndAssetID(event.ClientChainLzID, event.WithdrawAddress, event.AssetsAddress) - info, err = suite.App.StakingAssetsManageKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) + info, err = suite.App.AssetsKeeper.GetStakerSpecifiedAssetInfo(suite.Ctx, stakerID, assetID) suite.NoError(err) - suite.Equal(types.StakerSingleAssetInfo{ + suite.Equal(types.StakerAssetInfo{ TotalDepositAmount: sdkmath.NewInt(10), WithdrawableAmount: sdkmath.NewInt(10), WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) - assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) + assetInfo, err := suite.App.AssetsKeeper.GetStakingAssetInfo(suite.Ctx, assetID) suite.NoError(err) suite.Equal(sdkmath.NewInt(10), assetInfo.StakingTotalAmount) } diff --git a/x/withdraw/keeper/keeper.go b/x/withdraw/keeper/keeper.go index 8e0f4f0d4..f0483d4a3 100644 --- a/x/withdraw/keeper/keeper.go +++ b/x/withdraw/keeper/keeper.go @@ -18,22 +18,22 @@ type ( storeKey storetypes.StoreKey // restaking keepers for asset status update - restakingStateKeeper restakingkeeper.Keeper - depositKeeper depositkeeper.Keeper + assetsKeeper restakingkeeper.Keeper + depositKeeper depositkeeper.Keeper } ) func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - restakingStateKeeper restakingkeeper.Keeper, + assetsKeeper restakingkeeper.Keeper, depositKeeper depositkeeper.Keeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - restakingStateKeeper: restakingStateKeeper, - depositKeeper: depositKeeper, + cdc: cdc, + storeKey: storeKey, + assetsKeeper: assetsKeeper, + depositKeeper: depositKeeper, } } diff --git a/x/withdraw/keeper/params.go b/x/withdraw/keeper/params.go deleted file mode 100644 index 6c6537003..000000000 --- a/x/withdraw/keeper/params.go +++ /dev/null @@ -1,23 +0,0 @@ -package keeper - -import ( - paramstypes "github.com/ExocoreNetwork/exocore/x/deposit/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) (*paramstypes.Params, error) { - // store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixParams) - // ifExist := store.Has(types.ParamsKey) - // if !ifExist { - // return nil, types.ErrNoParamsKey - // } - - // value := store.Get(types.ParamsKey) - - // ret := &types.Params{} - // k.cdc.MustUnmarshal(value, ret) - // return ret, nil - // Uify the way to obtain Params from deposit keeper - return k.depositKeeper.GetParams(ctx) -} From 032c5ebf438e2ca9763ddc73adb62118c9425372 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 13 Mar 2024 14:34:43 +0800 Subject: [PATCH 39/44] fix the proto-lint error --- proto/exocore/deposit/v1/deposit.proto | 4 ---- 1 file changed, 4 deletions(-) diff --git a/proto/exocore/deposit/v1/deposit.proto b/proto/exocore/deposit/v1/deposit.proto index 32a336552..e33809a06 100644 --- a/proto/exocore/deposit/v1/deposit.proto +++ b/proto/exocore/deposit/v1/deposit.proto @@ -1,10 +1,6 @@ - - syntax = "proto3"; package exocore.deposit.v1; -import "gogoproto/gogo.proto"; - option go_package = "github.com/ExocoreNetwork/exocore/x/deposit/types"; // GenesisState defines the deposit module's genesis state. From 03b5c9e41d987f89962183f8d0dd8563f2d376fe Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Thu, 14 Mar 2024 10:21:19 +0800 Subject: [PATCH 40/44] refine the unconvitional code identified by code review in the procompile --- precompiles/common/error.go | 10 +++++++++ precompiles/delegation/delegation_test.go | 22 +++++++++---------- precompiles/delegation/error.go | 6 +---- precompiles/delegation/tx.go | 6 +++-- precompiles/delegation/types.go | 20 ++++++++--------- precompiles/deposit/deposit_test.go | 14 ++++++------ precompiles/deposit/error.go | 7 ------ precompiles/deposit/tx.go | 3 ++- precompiles/deposit/types.go | 13 ++++++----- precompiles/reward/error.go | 7 ------ precompiles/reward/methods.go | 3 ++- precompiles/reward/parser.go | 14 +++++++----- precompiles/slash/error.go | 7 ------ precompiles/slash/methods.go | 3 ++- precompiles/slash/parser.go | 14 +++++++----- precompiles/withdraw/error.go | 7 ------ precompiles/withdraw/methods.go | 3 ++- precompiles/withdraw/parser.go | 14 +++++++----- .../withdraw/withdraw_integrate_test.go | 5 +++-- proto/exocore/assets/v1/tx.proto | 4 +--- proto/exocore/deposit/v1/tx.proto | 2 -- proto/exocore/reward/tx.proto | 2 -- proto/exocore/slash/tx.proto | 2 -- x/operator/keeper/keeper.go | 2 +- x/operator/types/expected_keepers.go | 10 +++++++++ 25 files changed, 97 insertions(+), 103 deletions(-) create mode 100644 precompiles/common/error.go delete mode 100644 precompiles/deposit/error.go delete mode 100644 precompiles/reward/error.go delete mode 100644 precompiles/slash/error.go delete mode 100644 precompiles/withdraw/error.go diff --git a/precompiles/common/error.go b/precompiles/common/error.go new file mode 100644 index 000000000..8765aac3a --- /dev/null +++ b/precompiles/common/error.go @@ -0,0 +1,10 @@ +package common + +const ( + ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" + ErrContractCaller = "the caller doesn't have the permission to call this function" + + ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" + + ErrInputOperatorAddrLength = "mismatched length of the input operator address,actual is:%d,expect:%v" +) diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 9ba6eb67e..430e320de 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -64,8 +64,8 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { // TestRun tests DelegateToThroughClientChain method through calling Run function. func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { // deposit params for test - ExocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" - ExocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + exocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") opAccAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" clientChainLzID := 101 @@ -127,7 +127,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { returnBytes []byte }{ { - name: "fail - delegateToThroughClientChain transaction will fail because the ExocoreLzAppAddress haven't been stored", + name: "fail - delegateToThroughClientChain transaction will fail because the exocoreLzAppAddress haven't been stored", malleate: func() (common.Address, []byte) { return commonMalleate() }, @@ -139,8 +139,8 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { name: "fail - delegateToThroughClientChain transaction will fail because the contract caller isn't the exoCoreLzAppAddr", malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ - ExocoreLzAppAddress: ExocoreLzAppAddress, - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppAddress: exocoreLzAppAddress, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -155,7 +155,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -170,7 +170,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -186,7 +186,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -203,7 +203,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -291,7 +291,7 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { // TestRun tests DelegateToThroughClientChain method through calling Run function. func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { // deposit params for test - ExocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" clientChainLzID := 101 @@ -373,7 +373,7 @@ func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) diff --git a/precompiles/delegation/error.go b/precompiles/delegation/error.go index 81623485d..fa5bfee23 100644 --- a/precompiles/delegation/error.go +++ b/precompiles/delegation/error.go @@ -1,9 +1,5 @@ package delegation const ( - ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function" - ErrCtxTxHash = "ctx TxHash type error or is nil,type is:%v,value:%v" - - ErrInputOperatorAddrLength = "mismatched length of the input operator address,actual is:%d,expect:%v" + ErrCtxTxHash = "ctx TxHash type error or is nil,type is:%v,value:%v" ) diff --git a/precompiles/delegation/tx.go b/precompiles/delegation/tx.go index 1e629818d..71df9f487 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -4,6 +4,8 @@ import ( "fmt" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -36,7 +38,7 @@ func (p Precompile) DelegateToThroughClientChain( // check the invalidation of caller contract err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, errorsmod.Wrap(err, ErrContractCaller) + return nil, errorsmod.Wrap(err, exocmn.ErrContractCaller) } delegationParams, err := p.GetDelegationParamsFromInputs(ctx, args) @@ -63,7 +65,7 @@ func (p Precompile) UndelegateFromThroughClientChain( // check the invalidation of caller contract err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, errorsmod.Wrap(err, ErrContractCaller) + return nil, errorsmod.Wrap(err, exocmn.ErrContractCaller) } UndelegationParams, err := p.GetDelegationParamsFromInputs(ctx, args) diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index a1ebb1b01..4dcbaed7c 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -8,7 +8,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/precompiles/deposit" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" "github.com/ExocoreNetwork/exocore/x/assets/types" keeper2 "github.com/ExocoreNetwork/exocore/x/delegation/keeper" sdk "github.com/cosmos/cosmos-sdk/types" @@ -22,7 +22,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf delegationParams := &keeper2.DelegationOrUndelegationParams{} clientChainLzID, ok := args[0].(uint16) if !ok { - return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } delegationParams.ClientChainLzID = uint64(clientChainLzID) @@ -34,36 +34,36 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf txLzNonce, ok := args[1].(uint64) if !ok { - return nil, fmt.Errorf(ErrContractInputParaOrType, 1, reflect.TypeOf(args[1]), txLzNonce) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, reflect.TypeOf(args[1]), txLzNonce) } delegationParams.LzNonce = txLzNonce // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[2].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 2, reflect.TypeOf(args[2]), assetAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, reflect.TypeOf(args[2]), assetAddr) } if len(assetAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(deposit.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } delegationParams.AssetsAddress = assetAddr[:clientChainAddrLength] stakerAddr, ok := args[3].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 3, reflect.TypeOf(args[3]), stakerAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, reflect.TypeOf(args[3]), stakerAddr) } if len(assetAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(deposit.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } delegationParams.StakerAddress = stakerAddr[:clientChainAddrLength] // the input operator address is cosmos accAddress type,so we need to check the length and decode it through Bench32 operatorAddr, ok := args[4].([]byte) if !ok || operatorAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 4, reflect.TypeOf(args[4]), operatorAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, reflect.TypeOf(args[4]), operatorAddr) } if len(operatorAddr) != types.ExoCoreOperatorAddrLength { - return nil, fmt.Errorf(ErrInputOperatorAddrLength, len(operatorAddr), types.ExoCoreOperatorAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputOperatorAddrLength, len(operatorAddr), types.ExoCoreOperatorAddrLength) } opAccAddr, err := sdk.AccAddressFromBech32(string(operatorAddr)) @@ -74,7 +74,7 @@ func (p Precompile) GetDelegationParamsFromInputs(ctx sdk.Context, args []interf opAmount, ok := args[5].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, fmt.Errorf(ErrContractInputParaOrType, 5, reflect.TypeOf(args[5]), opAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, reflect.TypeOf(args[5]), opAmount) } delegationParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) return delegationParams, nil diff --git a/precompiles/deposit/deposit_test.go b/precompiles/deposit/deposit_test.go index 31dce39e1..c806d39c8 100644 --- a/precompiles/deposit/deposit_test.go +++ b/precompiles/deposit/deposit_test.go @@ -51,8 +51,8 @@ func paddingClientChainAddress(input []byte, outputLength int) []byte { // TestRunDepositTo tests DepositTo method through calling Run function.. func (s *DepositPrecompileSuite) TestRunDepositTo() { // deposit params for test - ExocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" - ExocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + exocoreLzAppAddress := "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" + exocoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" usdtAddress := paddingClientChainAddress(common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7"), assetstype.GeneralClientChainAddrLength) usdcAddress := paddingClientChainAddress(common.FromHex("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), assetstype.GeneralClientChainAddrLength) clientChainLzID := 101 @@ -87,7 +87,7 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { returnBytes []byte }{ { - name: "fail - depositTo transaction will fail because the ExocoreLzAppAddress haven't been stored", + name: "fail - depositTo transaction will fail because the exocoreLzAppAddress haven't been stored", malleate: func() (common.Address, []byte) { return commonMalleate() }, @@ -99,8 +99,8 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { name: "fail - depositTo transaction will fail because the contract caller isn't the exoCoreLzAppAddr", malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ - ExocoreLzAppAddress: ExocoreLzAppAddress, - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppAddress: exocoreLzAppAddress, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -115,7 +115,7 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) s.Require().NoError(err) @@ -131,7 +131,7 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { malleate: func() (common.Address, []byte) { depositModuleParam := &assetstype.Params{ ExocoreLzAppAddress: s.Address.String(), - ExocoreLzAppEventTopic: ExocoreLzAppEventTopic, + ExocoreLzAppEventTopic: exocoreLzAppEventTopic, } assetAddr = usdtAddress err := s.App.AssetsKeeper.SetParams(s.Ctx, depositModuleParam) diff --git a/precompiles/deposit/error.go b/precompiles/deposit/error.go deleted file mode 100644 index 79d51d573..000000000 --- a/precompiles/deposit/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package deposit - -const ( - ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, expected type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function" - ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" -) diff --git a/precompiles/deposit/tx.go b/precompiles/deposit/tx.go index 23bb0d234..83a9fe114 100644 --- a/precompiles/deposit/tx.go +++ b/precompiles/deposit/tx.go @@ -2,6 +2,7 @@ package deposit import ( errorsmod "cosmossdk.io/errors" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -27,7 +28,7 @@ func (p Precompile) DepositTo( // check the invalidation of caller contract,the caller must be exoCore LzApp contract err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, errorsmod.Wrap(err, ErrContractCaller) + return nil, errorsmod.Wrap(err, exocmn.ErrContractCaller) } // parse the depositTo input params depositParams, err := p.GetDepositToParamsFromInputs(ctx, args) diff --git a/precompiles/deposit/types.go b/precompiles/deposit/types.go index 55e951bf6..e210d3cad 100644 --- a/precompiles/deposit/types.go +++ b/precompiles/deposit/types.go @@ -4,6 +4,7 @@ import ( "math/big" sdkmath "cosmossdk.io/math" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/deposit/keeper" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +19,7 @@ func (p Precompile) GetDepositToParamsFromInputs(ctx sdk.Context, args []interfa depositParams := &keeper.DepositParams{} clientChainLzID, ok := args[0].(uint16) if !ok { - return nil, xerrors.Errorf(ErrContractInputParaOrType, 0, "uint16", clientChainLzID) + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "uint16", clientChainLzID) } depositParams.ClientChainLzID = uint64(clientChainLzID) @@ -31,25 +32,25 @@ func (p Precompile) GetDepositToParamsFromInputs(ctx sdk.Context, args []interfa // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[1].([]byte) if !ok || assetAddr == nil { - return nil, xerrors.Errorf(ErrContractInputParaOrType, 1, "[]byte", assetAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", assetAddr) } if len(assetAddr) != types.GeneralAssetsAddrLength { - return nil, xerrors.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, xerrors.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } depositParams.AssetsAddress = assetAddr[:clientChainAddrLength] stakerAddr, ok := args[2].([]byte) if !ok || stakerAddr == nil { - return nil, xerrors.Errorf(ErrContractInputParaOrType, 2, "[]byte", stakerAddr) + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", stakerAddr) } if len(stakerAddr) != types.GeneralClientChainAddrLength { - return nil, xerrors.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, xerrors.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } depositParams.StakerAddress = stakerAddr[:clientChainAddrLength] opAmount, ok := args[3].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, xerrors.Errorf(ErrContractInputParaOrType, 3, "*big.Int", opAmount) + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 3, "*big.Int", opAmount) } depositParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) diff --git a/precompiles/reward/error.go b/precompiles/reward/error.go deleted file mode 100644 index bfc0851f4..000000000 --- a/precompiles/reward/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package reward - -const ( - ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function" - ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" -) diff --git a/precompiles/reward/methods.go b/precompiles/reward/methods.go index e47321171..876270b03 100644 --- a/precompiles/reward/methods.go +++ b/precompiles/reward/methods.go @@ -2,6 +2,7 @@ package reward import ( errorsmod "cosmossdk.io/errors" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -27,7 +28,7 @@ func (p Precompile) Reward( // check the invalidation of caller contract err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, errorsmod.Wrap(err, ErrContractCaller) + return nil, errorsmod.Wrap(err, exocmn.ErrContractCaller) } rewardParam, err := p.GetRewardParamsFromInputs(ctx, args) diff --git a/precompiles/reward/parser.go b/precompiles/reward/parser.go index cac0bdbfc..37d256ccf 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -5,6 +5,8 @@ import ( "math/big" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/x/assets/types" @@ -20,7 +22,7 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ rewardParams := &keeper.RewardParams{} clientChainLzID, ok := args[0].(uint16) if !ok { - return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } rewardParams.ClientChainLzID = uint64(clientChainLzID) @@ -33,25 +35,25 @@ func (p Precompile) GetRewardParamsFromInputs(ctx sdk.Context, args []interface{ // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[1].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 1, reflect.TypeOf(args[0]), assetAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, reflect.TypeOf(args[0]), assetAddr) } if len(assetAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } rewardParams.AssetsAddress = assetAddr[:clientChainAddrLength] stakerAddr, ok := args[2].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 2, reflect.TypeOf(args[0]), stakerAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, reflect.TypeOf(args[0]), stakerAddr) } if len(assetAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } rewardParams.WithdrawRewardAddress = stakerAddr[:clientChainAddrLength] opAmount, ok := args[3].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, fmt.Errorf(ErrContractInputParaOrType, 3, reflect.TypeOf(args[0]), opAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, reflect.TypeOf(args[0]), opAmount) } rewardParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) diff --git a/precompiles/slash/error.go b/precompiles/slash/error.go deleted file mode 100644 index a5fc7bddc..000000000 --- a/precompiles/slash/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package slash - -const ( - ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function" - ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" -) diff --git a/precompiles/slash/methods.go b/precompiles/slash/methods.go index 6ddba8239..d8bb5ebc6 100644 --- a/precompiles/slash/methods.go +++ b/precompiles/slash/methods.go @@ -2,6 +2,7 @@ package slash import ( errorsmod "cosmossdk.io/errors" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -26,7 +27,7 @@ func (p Precompile) SubmitSlash( // check the invalidation of caller contract err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, errorsmod.Wrap(err, ErrContractCaller) + return nil, errorsmod.Wrap(err, exocmn.ErrContractCaller) } slashParam, err := p.GetSlashParamsFromInputs(ctx, args) diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index c390f44d2..ac1e13973 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -5,6 +5,8 @@ import ( "math/big" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/slash/keeper" @@ -19,7 +21,7 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} slashParams := &keeper.SlashParams{} clientChainLzID, ok := args[0].(uint16) if !ok { - return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } slashParams.ClientChainLzID = uint64(clientChainLzID) @@ -32,25 +34,25 @@ func (p Precompile) GetSlashParamsFromInputs(ctx sdk.Context, args []interface{} // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[1].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 1, reflect.TypeOf(args[0]), assetAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, reflect.TypeOf(args[0]), assetAddr) } if len(assetAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } slashParams.AssetsAddress = assetAddr[:clientChainAddrLength] stakerAddr, ok := args[2].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 2, reflect.TypeOf(args[0]), stakerAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, reflect.TypeOf(args[0]), stakerAddr) } if len(assetAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } slashParams.StakerAddress = stakerAddr[:clientChainAddrLength] opAmount, ok := args[3].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, fmt.Errorf(ErrContractInputParaOrType, 3, reflect.TypeOf(args[0]), opAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, reflect.TypeOf(args[0]), opAmount) } slashParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) diff --git a/precompiles/withdraw/error.go b/precompiles/withdraw/error.go deleted file mode 100644 index 8c51c1984..000000000 --- a/precompiles/withdraw/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package withdraw - -const ( - ErrContractInputParaOrType = "the contract input parameter type or value error,arg index:%d, type is:%s,value:%v" - ErrContractCaller = "the caller doesn't have the permission to call this function" - ErrInputClientChainAddrLength = "the length of input client chain addr doesn't match,input:%d,need:%d" -) diff --git a/precompiles/withdraw/methods.go b/precompiles/withdraw/methods.go index 8a577ae10..d94970f2a 100644 --- a/precompiles/withdraw/methods.go +++ b/precompiles/withdraw/methods.go @@ -2,6 +2,7 @@ package withdraw import ( errorsmod "cosmossdk.io/errors" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -26,7 +27,7 @@ func (p Precompile) Withdraw( // check the invalidation of caller contract err := p.assetsKeeper.CheckExocoreLzAppAddr(ctx, contract.CallerAddress) if err != nil { - return nil, errorsmod.Wrap(err, ErrContractCaller) + return nil, errorsmod.Wrap(err, exocmn.ErrContractCaller) } withdrawParam, err := p.GetWithdrawParamsFromInputs(ctx, args) diff --git a/precompiles/withdraw/parser.go b/precompiles/withdraw/parser.go index e84a4a8ea..995c288ce 100644 --- a/precompiles/withdraw/parser.go +++ b/precompiles/withdraw/parser.go @@ -5,6 +5,8 @@ import ( "math/big" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + sdkmath "cosmossdk.io/math" "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" @@ -19,7 +21,7 @@ func (p Precompile) GetWithdrawParamsFromInputs(ctx sdk.Context, args []interfac withdrawParams := &keeper.WithdrawParams{} clientChainLzID, ok := args[0].(uint16) if !ok { - return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), clientChainLzID) } withdrawParams.ClientChainLzID = uint64(clientChainLzID) @@ -32,25 +34,25 @@ func (p Precompile) GetWithdrawParamsFromInputs(ctx sdk.Context, args []interfac // the length of client chain address inputted by caller is 32, so we need to check the length and remove the padding according to the actual length. assetAddr, ok := args[1].([]byte) if !ok || assetAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 1, reflect.TypeOf(args[0]), assetAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, reflect.TypeOf(args[0]), assetAddr) } if len(assetAddr) != types.GeneralAssetsAddrLength { - return nil, fmt.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } withdrawParams.AssetsAddress = assetAddr[:clientChainAddrLength] stakerAddr, ok := args[2].([]byte) if !ok || stakerAddr == nil { - return nil, fmt.Errorf(ErrContractInputParaOrType, 2, reflect.TypeOf(args[0]), stakerAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, reflect.TypeOf(args[0]), stakerAddr) } if len(stakerAddr) != types.GeneralClientChainAddrLength { - return nil, fmt.Errorf(ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) + return nil, fmt.Errorf(exocmn.ErrInputClientChainAddrLength, len(assetAddr), types.GeneralClientChainAddrLength) } withdrawParams.WithdrawAddress = stakerAddr[:clientChainAddrLength] opAmount, ok := args[3].(*big.Int) if !ok || opAmount == nil || opAmount.Cmp(big.NewInt(0)) == 0 { - return nil, fmt.Errorf(ErrContractInputParaOrType, 3, reflect.TypeOf(args[0]), opAmount) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, reflect.TypeOf(args[0]), opAmount) } withdrawParams.OpAmount = sdkmath.NewIntFromBigInt(opAmount) diff --git a/precompiles/withdraw/withdraw_integrate_test.go b/precompiles/withdraw/withdraw_integrate_test.go index 6e9f32d8c..b29727769 100644 --- a/precompiles/withdraw/withdraw_integrate_test.go +++ b/precompiles/withdraw/withdraw_integrate_test.go @@ -3,9 +3,10 @@ package withdraw_test import ( "math/big" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + "github.com/ExocoreNetwork/exocore/precompiles/testutil" "github.com/ExocoreNetwork/exocore/precompiles/testutil/contracts" - "github.com/ExocoreNetwork/exocore/precompiles/withdraw" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ethereum/go-ethereum/common" ) @@ -68,5 +69,5 @@ func (s *WithdrawPrecompileTestSuite) TestCallWithdrawFromEOA() { beforeEach() setWithdrawArgs := prepareFunc(¶ms, method) _, _, err := contracts.CallContractAndCheckLogs(s.Ctx, s.App, setWithdrawArgs, passCheck) - s.Require().ErrorContains(err, withdraw.ErrContractCaller) + s.Require().ErrorContains(err, exocmn.ErrContractCaller) } diff --git a/proto/exocore/assets/v1/tx.proto b/proto/exocore/assets/v1/tx.proto index 68f8fa50c..84e024586 100644 --- a/proto/exocore/assets/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -241,21 +241,19 @@ message RegisterAssetReq { message RegisterAssetResponse {} // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 message MsgUpdateParams { // todo: temporarily not update configuration through gov module option (cosmos.msg.v1.signer) = "authority"; // authority is the address of the governance account. string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // params defines the x/evm parameters to update. + // params defines the x/assets parameters to update. // NOTE: All parameters must be supplied. Params params = 2 [(gogoproto.nullable) = false]; } // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 message MsgUpdateParamsResponse {} // Msg defines the assets Msg service diff --git a/proto/exocore/deposit/v1/tx.proto b/proto/exocore/deposit/v1/tx.proto index 6758f22d8..ecb78738f 100644 --- a/proto/exocore/deposit/v1/tx.proto +++ b/proto/exocore/deposit/v1/tx.proto @@ -10,7 +10,6 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/ExocoreNetwork/exocore/x/deposit/types"; // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 message MsgUpdateParams { // todo: temporarily not update configuration through gov module option (cosmos.msg.v1.signer) = "authority"; @@ -24,7 +23,6 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 message MsgUpdateParamsResponse {} // Msg defines the deposit Msg service. diff --git a/proto/exocore/reward/tx.proto b/proto/exocore/reward/tx.proto index d0c74e531..2a94e1c5b 100644 --- a/proto/exocore/reward/tx.proto +++ b/proto/exocore/reward/tx.proto @@ -15,7 +15,6 @@ service Msg { } // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 message MsgUpdateParams { // todo: temporarily not update configuration through gov module option (cosmos.msg.v1.signer) = "authority"; @@ -29,5 +28,4 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 message MsgUpdateParamsResponse {} diff --git a/proto/exocore/slash/tx.proto b/proto/exocore/slash/tx.proto index b23736d4a..b6f8e5bd4 100644 --- a/proto/exocore/slash/tx.proto +++ b/proto/exocore/slash/tx.proto @@ -15,7 +15,6 @@ service Msg { } // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 message MsgUpdateParams { // todo: temporarily not update configuration through gov module option (cosmos.msg.v1.signer) = "authority"; @@ -29,6 +28,5 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 message MsgUpdateParamsResponse {} diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index a11ae7acb..78c1ce6bc 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -16,7 +16,7 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers - assetsKeeper keeper.Keeper + assetsKeeper operatortypes.ExpectAssetsInterface delegationKeeper operatortypes.ExpectDelegationInterface oracleKeeper operatortypes.ExpectOracleInterface avsKeeper operatortypes.ExpectAvsInterface diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index 21099becf..f11243006 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -2,11 +2,21 @@ package types import ( sdkmath "cosmossdk.io/math" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" sdk "github.com/cosmos/cosmos-sdk/types" ) +type ExpectAssetsInterface interface { + GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *assetstype.StakingAssetInfo, err error) + IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *assetstype.OperatorAssetInfo) error) error + AppChainInfoIsExist(ctx sdk.Context, chainID string) bool + GetOperatorAssetInfos(ctx sdk.Context, operatorAddr sdk.Address, _ map[string]interface{}) (assetsInfo map[string]*assetstype.OperatorAssetInfo, err error) + UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount assetstype.StakerSingleAssetChangeInfo) (err error) + UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.OperatorSingleAssetChangeInfo) (err error) +} + type ExpectDelegationInterface interface { DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) IterateDelegationState(ctx sdk.Context, f func(restakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error) error From 3c08c5e10c9821a259cbac064504ea4437182d6c Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Fri, 15 Mar 2024 09:23:16 +0800 Subject: [PATCH 41/44] add code comments for GetAvsSupportedAssets --- x/operator/types/expected_keepers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index f11243006..f1e08401a 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -68,6 +68,9 @@ func (MockAVS) GetAvsSlashContract(_ sdk.Context, _ string) (string, error) { } type ExpectAvsInterface interface { + // GetAvsSupportedAssets The ctx can be historical or current, depending on the state you wish to retrieve. + // If the caller want to retrieve a historical assets info supported by Avs, it needs to generate a historical + // context through calling `ContextForHistoricalState` implemented in x/assets/types/general.go GetAvsSupportedAssets(ctx sdk.Context, avsAddr string) (map[string]interface{}, error) GetAvsSlashContract(ctx sdk.Context, avsAddr string) (string, error) } From ddaf1a2001e5be4b3df522c3924a912af202225f Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 18 Mar 2024 12:02:44 +0800 Subject: [PATCH 42/44] resolve the missed issues identified by code review, such as adding some comments and refine the naming --- app/app.go | 4 +- proto/exocore/operator/v1/query.proto | 2 +- proto/exocore/operator/v1/tx.proto | 30 +- testutil/abci.go | 8 +- x/assets/types/keys.go | 16 - x/assets/types/tx.pb.go | 4 +- x/delegation/keeper/abci.go | 8 +- x/delegation/keeper/cross_chain_tx_process.go | 15 +- x/delegation/keeper/delegation_op_test.go | 2 +- x/delegation/keeper/delegation_state.go | 6 +- x/delegation/keeper/keeper.go | 29 +- x/delegation/keeper/un_delegation_state.go | 13 +- x/delegation/types/errors.go | 4 + x/delegation/types/expected_keepers.go | 25 +- x/delegation/types/hooks.go | 8 +- x/deposit/types/deposit.pb.go | 18 +- x/deposit/types/tx.pb.go | 2 - x/dogfood/keeper/abci.go | 5 +- x/dogfood/keeper/impl_delegation_hooks.go | 4 +- x/dogfood/types/expected_keepers.go | 6 +- x/operator/keeper/abci.go | 50 ++- x/operator/keeper/avs_operator_shares.go | 88 +++- .../keeper/{dogfood.go => consensus_keys.go} | 0 x/operator/keeper/keeper.go | 19 +- x/operator/keeper/msg_server.go | 23 +- x/operator/keeper/operator.go | 1 - x/operator/keeper/state_update.go | 24 +- x/operator/types/codec.go | 4 +- x/operator/types/expected_keepers.go | 33 +- x/operator/types/keys.go | 10 +- x/operator/types/msg.go | 12 +- x/operator/types/tx.pb.go | 382 +++++++++--------- x/reward/types/tx.pb.go | 2 - x/slash/types/tx.pb.go | 2 - 34 files changed, 462 insertions(+), 397 deletions(-) rename x/operator/keeper/{dogfood.go => consensus_keys.go} (100%) diff --git a/app/app.go b/app/app.go index 26fbbd141..1fa133918 100644 --- a/app/app.go +++ b/app/app.go @@ -622,9 +622,9 @@ func NewExocoreApp( // set exoCore staking keepers app.AssetsKeeper = assetsKeeper.NewKeeper(keys[assetsTypes.StoreKey], appCodec) app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper) - app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.AssetsKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}, delegationTypes.VirtualISlashKeeper{}) + app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.AssetsKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAvs{}, delegationTypes.VirtualSlashKeeper{}) // todo: need to replace the virtual keepers with actual keepers after they have been implemented - app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper) + app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper, delegationTypes.VirtualSlashKeeper{}, &app.OperatorKeeper) app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper) app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.AssetsKeeper, app.DepositKeeper) diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index 633f0a2c3..e9e53c643 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -11,7 +11,7 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; // QueryOperatorInfoReq is the request to obtain the operator information. message GetOperatorInfoReq { - // operator_addr is the operator address. + // operator_addr is the operator address,its type should be a sdk.AccAddress string operator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 2a684ed12..29199fdec 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -113,8 +113,8 @@ message RegisterOperatorReq { // RegisterOperatorResponse is the response to a register operator request. message RegisterOperatorResponse{} -// OptInToChainIDRequest defines the OptInToChainID request. -message OptInToChainIDRequest { +// OptInToCosmosChainRequest defines the OptInToCosmosChain request. +message OptInToCosmosChainRequest { option (cosmos.msg.v1.signer) = "address"; // address is the operator address string address = 1; @@ -127,12 +127,12 @@ message OptInToChainIDRequest { string public_key = 3; } -// OptInToChainIDResponse defines the OptInToChainID response. -message OptInToChainIDResponse { +// OptInToCosmosChainResponse defines the OptInToCosmosChain response. +message OptInToCosmosChainResponse { } -// InitiateOptOutFromChainIDRequest defines the InitiateOptOutFromChainID request. -message InitiateOptOutFromChainIDRequest { +// InitiateOptOutFromCosmosChainRequest defines the InitiateOptOutFromCosmosChain request. +message InitiateOptOutFromCosmosChainRequest { option (cosmos.msg.v1.signer) = "address"; // address is the operator address string address = 1; @@ -140,8 +140,8 @@ message InitiateOptOutFromChainIDRequest { string chain_id = 2; } -// InitiateOptOutFromChainIDResponse defines the InitiateOptOutFromChainID response. -message InitiateOptOutFromChainIDResponse { +// InitiateOptOutFromCosmosChainResponse defines the InitiateOptOutFromCosmosChain response. +message InitiateOptOutFromCosmosChainResponse { } // Msg defines the operator Msg service. @@ -151,18 +151,14 @@ service Msg { rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); // add services for dogfood - // OptInToChainID acts as opt in method for an operator to + // OptInToCosmosChain acts as opt in method for an operator to // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. - rpc OptInToChainID(OptInToChainIDRequest) returns (OptInToChainIDResponse) {}; - // InitiateOptOutFromChainID is a method with which an operator can initiate + rpc OptInToCosmosChain(OptInToCosmosChainRequest) returns (OptInToCosmosChainResponse) {}; + // InitiateOptOutFromCosmosChain is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - rpc InitiateOptOutFromChainID(InitiateOptOutFromChainIDRequest) returns (InitiateOptOutFromChainIDResponse) {}; -} - - - - + rpc InitiateOptOutFromCosmosChain(InitiateOptOutFromCosmosChainRequest) returns (InitiateOptOutFromCosmosChainResponse) {}; +} \ No newline at end of file diff --git a/testutil/abci.go b/testutil/abci.go index ca29b6566..368446e31 100644 --- a/testutil/abci.go +++ b/testutil/abci.go @@ -32,10 +32,10 @@ func Commit(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.V return ctx.WithBlockHeader(header), nil } -// CommitAndCreateNewCtx commits a block at a given time creating a Ctx with the current settings +// CommitAndCreateNewCtx commits a block at a given time creating a ctx with the current settings // This is useful to keep test settings that could be affected by EndBlockers, e.g. // setting a baseFee == 0 and expecting this condition to continue after commit -func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.ValidatorSet, isUncachedCtx bool) (sdk.Context, error) { +func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.ValidatorSet, useUncachedCtx bool) (sdk.Context, error) { header, err := commit(ctx, app, t, vs) if err != nil { return ctx, err @@ -45,7 +45,7 @@ func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration // but resets other context fields // GasMeter is set as InfiniteGasMeter var newCtx sdk.Context - if isUncachedCtx { + if useUncachedCtx { newCtx = app.BaseApp.NewUncachedContext(false, header) } else { newCtx = app.BaseApp.NewContext(false, header) @@ -228,7 +228,7 @@ func commit(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.V return header, nil } -// checkTxBytes encodes a transaction and calls checkTx on the App. +// checkTxBytes encodes a transaction and calls checkTx on the app. func checkTxBytes(app *app.ExocoreApp, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.ResponseCheckTx, error) { bz, err := txEncoder(tx) if err != nil { diff --git a/x/assets/types/keys.go b/x/assets/types/keys.go index 02c17b9d2..9f0d9c7a5 100644 --- a/x/assets/types/keys.go +++ b/x/assets/types/keys.go @@ -4,8 +4,6 @@ import ( "fmt" "strings" - sdk "github.com/cosmos/cosmos-sdk/types" - errorsmod "cosmossdk.io/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -140,17 +138,3 @@ func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) { } return stringList, nil } - -// add for dogfood -func OperatorSnapshotKey(operatorAddr sdk.AccAddress, height uint64) []byte { - base := []byte{prefixOperatorSnapshot} - base = append(base, operatorAddr.Bytes()...) - base = append(base, sdk.Uint64ToBigEndian(height)...) - return base -} - -func OperatorLastSnapshotHeightKey(operatorAddr sdk.AccAddress) []byte { - base := []byte{prefixOperatorLastSnapshotHeight} - base = append(base, operatorAddr.Bytes()...) - return base -} diff --git a/x/assets/types/tx.pb.go b/x/assets/types/tx.pb.go index 6ad057798..b5a1a7238 100644 --- a/x/assets/types/tx.pb.go +++ b/x/assets/types/tx.pb.go @@ -840,11 +840,10 @@ func (m *RegisterAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterAssetResponse proto.InternalMessageInfo // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 type MsgUpdateParams struct { // authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the x/evm parameters to update. + // params defines the x/assets parameters to update. // NOTE: All parameters must be supplied. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } @@ -898,7 +897,6 @@ func (m *MsgUpdateParams) GetParams() Params { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 type MsgUpdateParamsResponse struct { } diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index f19a9fd3a..047d911e0 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -23,7 +23,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida // todo: don't think about freezing the operator in current implementation /* if k.slashKeeper.IsOperatorFrozen(ctx, operatorAccAddress) { // reSet the completed height if the operator is frozen - record.CompleteBlockNumber = k.expectedOperatorInterface.GetUnbondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) + record.CompleteBlockNumber = k.operatorKeeper.GetUnbondingExpirationBlockNumber(ctx, operatorAccAddress, record.BlockNumber) if record.CompleteBlockNumber <= uint64(ctx.BlockHeight()) { panic(fmt.Sprintf("the reset completedHeight isn't in future,setHeight:%v,curHeight:%v", record.CompleteBlockNumber, ctx.BlockHeight())) } @@ -51,12 +51,6 @@ func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Valida } continue } - // operator opt out: since operators can not immediately withdraw their funds, that is, - // even operator funds are not immediately available, operator opt out does not require - // any special handling here. if an operator undelegates before they opt out, the undelegation - // will be processed normally. if they undelegate after they opt out, the undelegation will - // be released at the same time as opt out completion, provided there are no other chains that - // the operator is still active on. the same applies to delegators too. // TODO(mike): ensure that operator is required to perform self delegation to match above. // calculate the actual canUndelegated asset amount diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 1879be19f..53933714e 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -111,8 +111,8 @@ type DelegationOrUndelegationParams struct { // DelegateTo : It doesn't need to check the active status of the operator in middlewares when delegating assets to the operator. This is because it adds assets to the operator's amount. But it needs to check if operator has been slashed or frozen. func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the delegatedTo address is an operator - if !k.expectedOperatorInterface.IsOperator(ctx, params.OperatorAddress) { - return errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", params.OperatorAddress)) + if !k.operatorKeeper.IsOperator(ctx, params.OperatorAddress) { + return errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input operatorAddr is:%s", params.OperatorAddress)) } // check if the operator has been slashed or frozen @@ -167,7 +167,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return err } // call operator module to bond the increased assets to the opted-in AVS - err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount) + err = k.operatorKeeper.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount) if err != nil { return err } @@ -182,7 +182,7 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar // So we use two steps to handle the undelegation. Fist,record the undelegation request and the corresponding exit time which needs to be obtained from the operator opt-in module. Then,we handle the record when the exit time has expired. func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the UndelegatedFrom address is an operator - if !k.expectedOperatorInterface.IsOperator(ctx, params.OperatorAddress) { + if !k.operatorKeeper.IsOperator(ctx, params.OperatorAddress) { return delegationtype.ErrOperatorNotExist } if params.OpAmount.IsNegative() { @@ -210,7 +210,7 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio Amount: params.OpAmount, ActualCompletedAmount: sdkmath.NewInt(0), } - r.CompleteBlockNumber = k.expectedOperatorInterface.GetUnbondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) + r.CompleteBlockNumber = k.operatorKeeper.GetUnbondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) if err != nil { return err @@ -248,14 +248,13 @@ func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegatio } // call operator module to decrease the state of opted-in assets - err = k.expectedOperatorInterface.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount.Neg()) + err = k.operatorKeeper.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount.Neg()) if err != nil { return err } // call the hooks registered by the other modules - k.Hooks().AfterUndelegationStarted(ctx, params.OperatorAddress, delegationtype.GetUndelegationRecordKey(r.LzTxNonce, r.TxHash, r.OperatorAddr)) - return nil + return k.Hooks().AfterUndelegationStarted(ctx, params.OperatorAddress, delegationtype.GetUndelegationRecordKey(r.LzTxNonce, r.TxHash, r.OperatorAddr)) } /*func (k *Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { diff --git a/x/delegation/keeper/delegation_op_test.go b/x/delegation/keeper/delegation_op_test.go index 5697bb9b9..84edfabda 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -43,7 +43,7 @@ func (suite *DelegationTestSuite) TestDelegateTo() { TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } err = suite.App.DelegationKeeper.DelegateTo(suite.Ctx, delegationParams) - suite.EqualError(err, errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input opreatorAddr is:%s", delegationParams.OperatorAddress)).Error()) + suite.EqualError(err, errorsmod.Wrap(delegationtype.ErrOperatorNotExist, fmt.Sprintf("input operatorAddr is:%s", delegationParams.OperatorAddress)).Error()) registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index b4d975422..022c668b5 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -42,8 +42,7 @@ func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerID string store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) var ret delegationtype.ValueField prefixKey := assetstype.GetJoinedStoreKey(stakerID, assetID) - isExit := store.Has(prefixKey) - if !isExit { + if !store.Has(prefixKey) { return sdkmath.Int{}, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerDelegationTotalAmount: key is %s", prefixKey)) } value := store.Get(prefixKey) @@ -147,6 +146,9 @@ func (k *Keeper) GetDelegationInfo(ctx sdk.Context, stakerID, assetID string) (* } // DelegationStateByOperatorAssets get the specified assets state delegated to the specified operator +// assetsFilter: assetID->nil, it's used to filter the specified assets +// the first return value is a nested map, its type is: stakerID->assetID->DelegationAmounts +// It means all delegation information related to the specified operator and filtered by the specified asset IDs func (k *Keeper) DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) iterator := sdk.KVStorePrefixIterator(store, nil) diff --git a/x/delegation/keeper/keeper.go b/x/delegation/keeper/keeper.go index 8bad0db43..cb189d5a7 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -3,9 +3,7 @@ package keeper import ( "context" - "github.com/ExocoreNetwork/exocore/x/assets/keeper" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" - depositkeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,28 +16,25 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers - assetsKeeper keeper.Keeper - depositKeeper depositkeeper.Keeper - slashKeeper delegationtype.ISlashKeeper - expectedOperatorInterface delegationtype.ExpectedOperatorInterface - hooks delegationtype.DelegationHooks + assetsKeeper delegationtype.AssetsKeeper + slashKeeper delegationtype.SlashKeeper + operatorKeeper delegationtype.OperatorKeeper + hooks delegationtype.DelegationHooks } func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - assetsKeeper keeper.Keeper, - depositKeeper depositkeeper.Keeper, - slashKeeper delegationtype.ISlashKeeper, - operatorKeeper delegationtype.ExpectedOperatorInterface, + assetsKeeper delegationtype.AssetsKeeper, + slashKeeper delegationtype.SlashKeeper, + operatorKeeper delegationtype.OperatorKeeper, ) Keeper { return Keeper{ - storeKey: storeKey, - cdc: cdc, - assetsKeeper: assetsKeeper, - depositKeeper: depositKeeper, - slashKeeper: slashKeeper, - expectedOperatorInterface: operatorKeeper, + storeKey: storeKey, + cdc: cdc, + assetsKeeper: assetsKeeper, + slashKeeper: slashKeeper, + operatorKeeper: operatorKeeper, } } diff --git a/x/delegation/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index c5fb9c620..b4a315537 100644 --- a/x/delegation/keeper/un_delegation_state.go +++ b/x/delegation/keeper/un_delegation_state.go @@ -53,7 +53,8 @@ func (k *Keeper) SetSingleUndelegationRecord(ctx sdk.Context, record *types.Unde } // StoreWaitCompleteRecord add it to handle the delay of completing undelegation caused by onHoldCount -func (k Keeper) StoreWaitCompleteRecord(ctx sdk.Context, singleRecKey []byte, record *types.UndelegationRecord) error { +// In the event that the undelegation is held by another module, this function is used within the EndBlocker to increment the scheduled completion block number by 1. Then the completion time of the undelegation will be delayed to the next block. +func (k *Keeper) StoreWaitCompleteRecord(ctx sdk.Context, singleRecKey []byte, record *types.UndelegationRecord) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixWaitCompleteUndelegations) waitCompleteKey := types.GetWaitCompleteRecordKey(record.CompleteBlockNumber, record.LzTxNonce) store.Set(waitCompleteKey, singleRecKey) @@ -151,14 +152,15 @@ func (k *Keeper) GetWaitCompleteUndelegationRecords(ctx sdk.Context, height uint return k.GetUndelegationRecords(ctx, recordKeys, AllRecords) } -func (k *Keeper) IncrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) { +func (k *Keeper) IncrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) error { prev := k.GetUndelegationHoldCount(ctx, recordKey) if prev == math.MaxUint64 { - panic("cannot increment undelegation hold count above max uint64") + return types.ErrCannotIncHoldCount } now := prev + 1 store := ctx.KVStore(k.storeKey) store.Set(types.GetUndelegationOnHoldKey(recordKey), sdk.Uint64ToBigEndian(now)) + return nil } func (k *Keeper) GetUndelegationHoldCount(ctx sdk.Context, recordKey []byte) uint64 { @@ -167,12 +169,13 @@ func (k *Keeper) GetUndelegationHoldCount(ctx sdk.Context, recordKey []byte) uin return sdk.BigEndianToUint64(bz) } -func (k *Keeper) DecrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) { +func (k *Keeper) DecrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) error { prev := k.GetUndelegationHoldCount(ctx, recordKey) if prev == 0 { - panic("cannot decrement undelegation hold count below zero") + return types.ErrCannotDecHoldCount } now := prev - 1 store := ctx.KVStore(k.storeKey) store.Set(types.GetUndelegationOnHoldKey(recordKey), sdk.Uint64ToBigEndian(now)) + return nil } diff --git a/x/delegation/types/errors.go b/x/delegation/types/errors.go index 4e1e4811a..1bb6446c7 100644 --- a/x/delegation/types/errors.go +++ b/x/delegation/types/errors.go @@ -23,4 +23,8 @@ var ( ErrNotSupportYet = errorsmod.Register(ModuleName, 9, "don't have supported it yet") ErrDelegationAmountTooBig = errorsmod.Register(ModuleName, 10, "the delegation amount is bigger than the canWithdraw amount") + + ErrCannotIncHoldCount = errorsmod.Register(ModuleName, 11, "cannot increment undelegation hold count above max uint64") + + ErrCannotDecHoldCount = errorsmod.Register(ModuleName, 12, "cannot decrement undelegation hold count below zero") ) diff --git a/x/delegation/types/expected_keepers.go b/x/delegation/types/expected_keepers.go index 2062c7d3a..f2b7bb2f2 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -2,28 +2,31 @@ package types import ( sdkmath "cosmossdk.io/math" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" sdk "github.com/cosmos/cosmos-sdk/types" ) +var _ SlashKeeper = VirtualSlashKeeper{} + var CanUndelegationDelayHeight = uint64(10) -type ISlashKeeper interface { +type SlashKeeper interface { IsOperatorFrozen(ctx sdk.Context, opAddr sdk.AccAddress) bool OperatorAssetSlashedProportion(ctx sdk.Context, opAddr sdk.AccAddress, assetID string, startHeight, endHeight uint64) sdkmath.LegacyDec } -// VirtualISlashKeeper todo: When the actual keeper functionality has not been implemented yet, temporarily use the virtual keeper. -type VirtualISlashKeeper struct{} +// VirtualSlashKeeper todo: When the actual keeper functionality has not been implemented yet, temporarily use the virtual keeper. +type VirtualSlashKeeper struct{} -func (VirtualISlashKeeper) IsOperatorFrozen(_ sdk.Context, _ sdk.AccAddress) bool { +func (VirtualSlashKeeper) IsOperatorFrozen(_ sdk.Context, _ sdk.AccAddress) bool { return false } -func (VirtualISlashKeeper) OperatorAssetSlashedProportion(_ sdk.Context, _ sdk.AccAddress, _ string, _, _ uint64) sdkmath.LegacyDec { +func (VirtualSlashKeeper) OperatorAssetSlashedProportion(_ sdk.Context, _ sdk.AccAddress, _ string, _, _ uint64) sdkmath.LegacyDec { return sdkmath.LegacyNewDec(0) } -// DelegationHooks add for dogfood +// DelegationHooks are event hooks triggered by the delegation module type DelegationHooks interface { // AfterDelegation we don't want the ability to cancel delegation or undelegation so no return type for // either @@ -31,15 +34,21 @@ type DelegationHooks interface { AfterDelegation(ctx sdk.Context, operator sdk.AccAddress) // AfterUndelegationStarted for undelegation, we use the address of the operator to figure out the list of impacted // chains for that operator. and we need the identifier to hold it until confirmed by subscriber - AfterUndelegationStarted(ctx sdk.Context, addr sdk.AccAddress, recordKey []byte) + AfterUndelegationStarted(ctx sdk.Context, addr sdk.AccAddress, recordKey []byte) error // AfterUndelegationCompleted whenever an undelegation completes, we should update the vote power of the associated operator // on all of the chain ids that are impacted AfterUndelegationCompleted(ctx sdk.Context, addr sdk.AccAddress) } -type ExpectedOperatorInterface interface { +type OperatorKeeper interface { IsOperator(ctx sdk.Context, addr sdk.AccAddress) bool GetUnbondingExpirationBlockNumber(ctx sdk.Context, OperatorAddress sdk.AccAddress, startHeight uint64) uint64 UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, operatorAddr string, opAmount sdkmath.Int) error } + +type AssetsKeeper interface { + UpdateStakerAssetState(ctx sdk.Context, stakerID string, assetID string, changeAmount assetstype.StakerSingleAssetChangeInfo) (err error) + UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.OperatorSingleAssetChangeInfo) (err error) + GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, assetID string) (info *assetstype.StakerAssetInfo, err error) +} diff --git a/x/delegation/types/hooks.go b/x/delegation/types/hooks.go index 2fd215a96..d0ad3032a 100644 --- a/x/delegation/types/hooks.go +++ b/x/delegation/types/hooks.go @@ -20,10 +20,14 @@ func (hooks MultiDelegationHooks) AfterUndelegationStarted( ctx sdk.Context, addr sdk.AccAddress, recordKey []byte, -) { +) error { for _, hook := range hooks { - hook.AfterUndelegationStarted(ctx, addr, recordKey) + err := hook.AfterUndelegationStarted(ctx, addr, recordKey) + if err != nil { + return err + } } + return nil } func (hooks MultiDelegationHooks) AfterUndelegationCompleted(ctx sdk.Context, addr sdk.AccAddress) { diff --git a/x/deposit/types/deposit.pb.go b/x/deposit/types/deposit.pb.go index 8eb5c7092..67be1c029 100644 --- a/x/deposit/types/deposit.pb.go +++ b/x/deposit/types/deposit.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -67,17 +66,16 @@ func init() { func init() { proto.RegisterFile("exocore/deposit/v1/deposit.proto", fileDescriptor_bb743e1548b62476) } var fileDescriptor_bb743e1548b62476 = []byte{ - // 151 bytes of a gzipped FileDescriptorProto + // 138 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xad, 0xc8, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x49, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, 0xd1, 0x2f, 0x33, 0x84, 0x31, - 0xf5, 0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ef, 0x0a, 0x31, 0xc2, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0x66, 0x67, 0x05, + 0xdc, 0xd6, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x8d, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x16, 0x0b, 0x5f, 0x01, 0x95, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/deposit/types/tx.pb.go b/x/deposit/types/tx.pb.go index 1ea759566..43ba9bf7b 100644 --- a/x/deposit/types/tx.pb.go +++ b/x/deposit/types/tx.pb.go @@ -31,7 +31,6 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 type MsgUpdateParams struct { // authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` @@ -89,7 +88,6 @@ func (m *MsgUpdateParams) GetParams() Params { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 type MsgUpdateParamsResponse struct { } diff --git a/x/dogfood/keeper/abci.go b/x/dogfood/keeper/abci.go index 27f7fd132..7c7b517ea 100644 --- a/x/dogfood/keeper/abci.go +++ b/x/dogfood/keeper/abci.go @@ -19,7 +19,10 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { // start with clearing the hold on the undelegations. undelegations := k.GetPendingUndelegations(ctx) for _, undelegation := range undelegations.GetList() { - k.delegationKeeper.DecrementUndelegationHoldCount(ctx, undelegation) + err := k.delegationKeeper.DecrementUndelegationHoldCount(ctx, undelegation) + if err != nil { + panic(err) + } } k.ClearPendingUndelegations(ctx) // then, let the operator module know that the opt out has finished. diff --git a/x/dogfood/keeper/impl_delegation_hooks.go b/x/dogfood/keeper/impl_delegation_hooks.go index c23d6be34..bb876dc49 100644 --- a/x/dogfood/keeper/impl_delegation_hooks.go +++ b/x/dogfood/keeper/impl_delegation_hooks.go @@ -32,7 +32,7 @@ func (wrapper DelegationHooksWrapper) AfterDelegation( // AfterUndelegationStarted is called after an undelegation is started. func (wrapper DelegationHooksWrapper) AfterUndelegationStarted( ctx sdk.Context, operator sdk.AccAddress, recordKey []byte, -) { +) error { var unbondingCompletionEpoch int64 if wrapper.keeper.operatorKeeper.IsOperatorOptingOutFromChainID( ctx, operator, ctx.ChainID(), @@ -49,7 +49,7 @@ func (wrapper DelegationHooksWrapper) AfterUndelegationStarted( // so this is not a concern. } wrapper.keeper.AppendUndelegationToMature(ctx, unbondingCompletionEpoch, recordKey) - wrapper.keeper.delegationKeeper.IncrementUndelegationHoldCount(ctx, recordKey) + return wrapper.keeper.delegationKeeper.IncrementUndelegationHoldCount(ctx, recordKey) } // AfterUndelegationCompleted is called after an undelegation is completed. diff --git a/x/dogfood/types/expected_keepers.go b/x/dogfood/types/expected_keepers.go index 0fc1c154f..a14789775 100644 --- a/x/dogfood/types/expected_keepers.go +++ b/x/dogfood/types/expected_keepers.go @@ -36,7 +36,7 @@ type OperatorHooks interface { // DelegationHooks represent the event hooks for delegation module. type DelegationHooks interface { AfterDelegation(sdk.Context, sdk.AccAddress) - AfterUndelegationStarted(sdk.Context, sdk.AccAddress, []byte) + AfterUndelegationStarted(sdk.Context, sdk.AccAddress, []byte) error AfterUndelegationCompleted(sdk.Context, sdk.AccAddress, []byte) } @@ -65,8 +65,8 @@ type OperatorKeeper interface { // DelegationKeeper represents the expected keeper interface for the delegation module. type DelegationKeeper interface { - IncrementUndelegationHoldCount(sdk.Context, []byte) - DecrementUndelegationHoldCount(sdk.Context, []byte) + IncrementUndelegationHoldCount(sdk.Context, []byte) error + DecrementUndelegationHoldCount(sdk.Context, []byte) error } // EpochsHooks represents the event hooks for the epochs module. diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index b7eb48311..c39e46675 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -9,17 +9,31 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// SharedParameter is a shared parameter used to record and update the related +// USD share of staker and operators when the prices of assets change type SharedParameter struct { - priceChangeAssets map[string]*operatortypes.PriceChange - assetsDecimal map[string]uint32 - assetsOperatorAVSInfo map[string]map[string]string - stakerShare map[string]sdkmath.LegacyDec + // priceChangeAssets is the price change information of assets, + // which is gotten by the expected Oracle interface. + priceChangeAssets map[string]*operatortypes.PriceChange + // assetsDecimal is a map to record the decimals of the related assets + // It will be used when calculate the USD share of the assets. + assetsDecimal map[string]uint32 + // optedInAssetsInfo : assetID->operator->Avs + // For staker and operator, only the USD share of opted-in assets needs to be updated + // when the prices of assets change. But in the delegation and assets module, the opted-in + // information of assets haven't been stored, so we need this map as a filter when iterate + // the assets state of delegation and operator + // It will be set when calling `IterateUpdateAssetState`, because the information of opted-in assets + // has been stored in types.KeyPrefixOperatorAVSSingleAssetState + optedInAssetsInfo map[string]map[string]string + // stakerShare records the latest share for staker and operator after updating + stakerShare map[string]sdkmath.LegacyDec } func UpdateShareOfStakerAndOperator(sharedParam *SharedParameter, assetID, stakerID, operatorAddr string, assetAmount sdkmath.Int) { priceChange := sharedParam.priceChangeAssets[assetID] assetDecimal := sharedParam.assetsDecimal[assetID] - if avsAddr, ok := sharedParam.assetsOperatorAVSInfo[assetID][operatorAddr]; ok { + if avsAddr, ok := sharedParam.optedInAssetsInfo[assetID][operatorAddr]; ok { newAssetUSDValue := CalculateShare(assetAmount, priceChange.NewPrice, assetDecimal, priceChange.Decimal) key := string(types.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr)) AddShareInMap(sharedParam.stakerShare, key, newAssetUSDValue) @@ -35,8 +49,8 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { if len(priceChangeAssets) == 0 { return nil } - avsOperatorShareChange := make(map[string]sdkmath.LegacyDec, 0) - assetsOperatorAVSInfo := make(map[string]map[string]string, 0) + shareChangeForAvsOperator := make(map[string]sdkmath.LegacyDec, 0) + optedInAssetsInfo := make(map[string]map[string]string, 0) assetsDecimal := make(map[string]uint32) for assetID, priceChange := range priceChangeAssets { // get the decimal of asset @@ -45,8 +59,8 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { return err } assetsDecimal[assetID] = assetInfo.AssetBasicInfo.Decimals - if _, ok := assetsOperatorAVSInfo[assetID]; !ok { - assetsOperatorAVSInfo[assetID] = make(map[string]string, 0) + if _, ok := optedInAssetsInfo[assetID]; !ok { + optedInAssetsInfo[assetID] = make(map[string]string, 0) } // UpdateStateForAsset f := func(assetID string, keys []string, state *operatortypes.OptedInAssetState) error { @@ -56,9 +70,9 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { avsAddr := keys[1] avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) - AddShareInMap(avsOperatorShareChange, avsAddr, changeValue) - AddShareInMap(avsOperatorShareChange, avsOperator, changeValue) - assetsOperatorAVSInfo[assetID][keys[2]] = avsAddr + AddShareInMap(shareChangeForAvsOperator, avsAddr, changeValue) + AddShareInMap(shareChangeForAvsOperator, avsOperator, changeValue) + optedInAssetsInfo[assetID][keys[2]] = avsAddr return nil } err = k.IterateUpdateAssetState(ctx, assetID, f) @@ -67,17 +81,17 @@ func (k *Keeper) PriceChangeHandle(ctx sdk.Context) error { } } // BatchUpdateShareForAVSAndOperator - err = k.BatchUpdateShareForAVSAndOperator(ctx, avsOperatorShareChange) + err = k.BatchUpdateShareForAVSAndOperator(ctx, shareChangeForAvsOperator) if err != nil { return err } - // update staker'suite share + // update the USD share for staker and operator sharedParameter := &SharedParameter{ - priceChangeAssets: priceChangeAssets, - assetsDecimal: assetsDecimal, - assetsOperatorAVSInfo: assetsOperatorAVSInfo, - stakerShare: make(map[string]sdkmath.LegacyDec, 0), + priceChangeAssets: priceChangeAssets, + assetsDecimal: assetsDecimal, + optedInAssetsInfo: optedInAssetsInfo, + stakerShare: make(map[string]sdkmath.LegacyDec, 0), } stakerShareHandleFunc := func(stakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error { UpdateShareOfStakerAndOperator(sharedParameter, assetID, stakerID, operatorAddr, state.UndelegatableAmount) diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go index 911423f5a..a2ae08356 100644 --- a/x/operator/keeper/avs_operator_shares.go +++ b/x/operator/keeper/avs_operator_shares.go @@ -13,6 +13,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// UpdateOperatorShare is a function to update the USD share for specified operator and Avs, +// The key and value that will be changed is: +// AVSAddr + '/' + operatorAddr -> types.DecValueField (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) UpdateOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil @@ -38,6 +42,11 @@ func (k *Keeper) UpdateOperatorShare(ctx sdk.Context, avsAddr, operatorAddr stri return nil } +// DeleteOperatorShare is a function to delete the USD share related to specified operator and Avs, +// The key and value that will be deleted is: +// AVSAddr + '/' + operatorAddr -> types.DecValueField (the total USD share of specified operator and Avs) +// 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) DeleteOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var key []byte @@ -50,6 +59,12 @@ func (k *Keeper) DeleteOperatorShare(ctx sdk.Context, avsAddr, operatorAddr stri return nil } +// GetOperatorShare is a function to retrieve the USD share of specified operator and Avs, +// The key and value to retrieve is: +// AVSAddr + '/' + operatorAddr -> types.DecValueField (the total USD share of specified operator and Avs) +// This function will be called when the operator opts out of the AVS, because the total USD share +// of Avs should decrease the USD share of the opted-out operator +// This function can also serve as an RPC in the future. func (k *Keeper) GetOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.DecValueField @@ -69,6 +84,12 @@ func (k *Keeper) GetOperatorShare(ctx sdk.Context, avsAddr, operatorAddr string) return ret.Amount, nil } +// UpdateAVSShare is a function to update the total USD share of an Avs, +// The key and value that will be changed is: +// AVSAddr -> types.DecValueField(the total USD share of specified Avs) +// This function will be called when some assets of operator supported by the specified Avs +// are delegated/undelegated or slashed. Additionally, when an operator opts out of +// the Avs, this function also will be called. func (k *Keeper) UpdateAVSShare(ctx sdk.Context, avsAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil @@ -89,6 +110,11 @@ func (k *Keeper) UpdateAVSShare(ctx sdk.Context, avsAddr string, opAmount sdkmat return nil } +// BatchUpdateShareForAVSAndOperator is a function to update the USD share for operator and Avs in bulk, +// The key and value that will be changed is: +// AVSAddr -> types.DecValueField(the total USD share of specified Avs) +// AVSAddr + '/' + operatorAddr -> types.DecValueField (the total USD share of specified operator and Avs) +// This function will be called when the prices of assets supported by Avs are changed. func (k *Keeper) BatchUpdateShareForAVSAndOperator(ctx sdk.Context, avsOperatorChange map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) for avs, opAmount := range avsOperatorChange { @@ -109,6 +135,10 @@ func (k *Keeper) BatchUpdateShareForAVSAndOperator(ctx sdk.Context, avsOperatorC return nil } +// GetAVSShare is a function to retrieve the USD share of specified Avs, +// The key and value to retrieve is: +// AVSAddr -> types.DecValueField(the total USD share of specified Avs) +// It hasn't been used now. but it can serve as an RPC in the future. func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) var ret operatortypes.DecValueField @@ -123,6 +153,12 @@ func (k *Keeper) GetAVSShare(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec return ret.Amount, nil } +// UpdateStateForAsset is a function to update the opted-in amount and USD share for +// the specified asset +// The key and value that will be changed is: +// assetID + '/' + AVSAddr + '/' + operatorAddr -> types.OptedInAssetState +// This function will be called when the amount of a specified asset opted-in by the operator +// changes, such as: opt-in, delegation, undelegation and slash. func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operatorAddr string, changeState operatortypes.OptedInAssetStateChange) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) if changeState.Amount.IsNil() && changeState.Value.IsNil() { @@ -160,6 +196,11 @@ func (k *Keeper) UpdateStateForAsset(ctx sdk.Context, assetID, avsAddr, operator return nil } +// DeleteAssetState is a function to delete the opted-in amount and USD share for +// the specified asset +// The key and value that will be deleted is: +// assetID + '/' + AVSAddr + '/' + operatorAddr -> types.OptedInAssetState +// This function will be called when the specified operator opts out of the Avs. func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) // check operator address validation @@ -172,6 +213,10 @@ func (k *Keeper) DeleteAssetState(ctx sdk.Context, assetID, avsAddr, operatorAdd return nil } +// GetAssetState is a function to retrieve the opted-in amount and USD share for the specified asset +// The key and value to retrieve is: +// assetID + '/' + AVSAddr + '/' + operatorAddr -> types.OptedInAssetState +// It hasn't been used now. but it can serve as an RPC in the future. func (k *Keeper) GetAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr string) (changeState *operatortypes.OptedInAssetState, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) @@ -186,6 +231,11 @@ func (k *Keeper) GetAssetState(ctx sdk.Context, assetID, avsAddr, operatorAddr s return &optedInAssetState, nil } +// IterateUpdateAssetState is a function to iteratively update the opted-in amount and USD share for +// the specified asset +// The key and value that will be changed is: +// assetID + '/' + AVSAddr + '/' + operatorAddr -> types.OptedInAssetState +// This function will be called when the prices of opted-in assets are changed. func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func(assetID string, keys []string, state *operatortypes.OptedInAssetState) error) (err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorAVSSingleAssetState) iterator := sdk.KVStorePrefixIterator(store, []byte(assetID)) @@ -208,6 +258,12 @@ func (k *Keeper) IterateUpdateAssetState(ctx sdk.Context, assetID string, f func return nil } +// UpdateStakerShare is a function to update the opted-in USD share for the specified staker and operator , +// The key and value that will be changed is: +// AVSAddr + '/' + ” + '/' + operatorAddr -> types.DecValueField(the opted-in USD share owned by the operator itself) +// AVSAddr + '/' + stakerID + '/' + operatorAddr -> types.DecValueField (the opted-in USD share of the staker) +// This function will be called when the opted-in assets of operator and staker +// are delegated/undelegated or slashed. Additionally, when an operator opts in, this function also will be called. func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string, opAmount sdkmath.LegacyDec) error { if opAmount.IsNil() || opAmount.IsZero() { return nil @@ -229,6 +285,11 @@ func (k *Keeper) UpdateStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA return nil } +// BatchSetStakerShare is a function to set the opted-in USD share for the specified staker and operator in bulk, +// The key and value that will be set is: +// AVSAddr + '/' + ” + '/' + operatorAddr -> types.DecValueField(the opted-in USD share owned by the operator itself) +// AVSAddr + '/' + stakerID + '/' + operatorAddr -> types.DecValueField (the opted-in USD share of the staker) +// This function will be called when the prices of opted-in assets are changed. func (k *Keeper) BatchSetStakerShare(ctx sdk.Context, newValues map[string]sdkmath.LegacyDec) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) for key, value := range newValues { @@ -244,6 +305,11 @@ func (k *Keeper) BatchSetStakerShare(ctx sdk.Context, newValues map[string]sdkma return nil } +// DeleteStakerShare is a function to delete the opted-in USD share for the specified staker and operator, +// The key and value that will be set is: +// AVSAddr + '/' + ” + '/' + operatorAddr -> types.DecValueField(the opted-in USD share owned by the operator itself) +// AVSAddr + '/' + stakerID + '/' + operatorAddr -> types.DecValueField (the opted-in USD share of the staker) +// This function will be called when the operator opts out of the Avs. func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) key := assetstype.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr) @@ -251,6 +317,11 @@ func (k *Keeper) DeleteStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorA return nil } +// GetStakerShare is a function to retrieve the opted-in USD share for the specified staker and operator, +// The key and value that will be set is: +// AVSAddr + '/' + ” + '/' + operatorAddr -> types.DecValueField(the opted-in USD share owned by the operator itself) +// AVSAddr + '/' + stakerID + '/' + operatorAddr -> types.DecValueField (the opted-in USD share of the staker) +// It hasn't been used now. but it can serve as an RPC in the future. func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr string) (sdkmath.LegacyDec, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) var ret operatortypes.DecValueField @@ -264,20 +335,3 @@ func (k *Keeper) GetStakerShare(ctx sdk.Context, avsAddr, stakerID, operatorAddr return ret.Amount, nil } - -func (k *Keeper) GetStakerByAVSOperator(ctx sdk.Context, _, _ string) (map[string]interface{}, error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) - stakers := make(map[string]interface{}, 0) - iterator := sdk.KVStorePrefixIterator(store, nil) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - keys, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 3) - if err != nil { - return nil, err - } - if keys[1] != "" { - stakers[keys[1]] = nil - } - } - return stakers, nil -} diff --git a/x/operator/keeper/dogfood.go b/x/operator/keeper/consensus_keys.go similarity index 100% rename from x/operator/keeper/dogfood.go rename to x/operator/keeper/consensus_keys.go diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go index 78c1ce6bc..1a029d03d 100644 --- a/x/operator/keeper/keeper.go +++ b/x/operator/keeper/keeper.go @@ -4,7 +4,6 @@ import ( "context" sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/x/assets/keeper" operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -16,10 +15,10 @@ type Keeper struct { cdc codec.BinaryCodec // other keepers - assetsKeeper operatortypes.ExpectAssetsInterface - delegationKeeper operatortypes.ExpectDelegationInterface - oracleKeeper operatortypes.ExpectOracleInterface - avsKeeper operatortypes.ExpectAvsInterface + assetsKeeper operatortypes.AssetsKeeper + delegationKeeper operatortypes.DelegationKeeper + oracleKeeper operatortypes.OracleKeeper + avsKeeper operatortypes.AvsKeeper // add for dogfood hooks operatortypes.OperatorConsentHooks // set separately via call to SetHooks @@ -29,9 +28,9 @@ type Keeper struct { func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - assetsKeeper keeper.Keeper, - oracleKeeper operatortypes.ExpectOracleInterface, - avsKeeper operatortypes.ExpectAvsInterface, + assetsKeeper operatortypes.AssetsKeeper, + oracleKeeper operatortypes.OracleKeeper, + avsKeeper operatortypes.AvsKeeper, slashKeeper operatortypes.SlashKeeper, ) Keeper { return Keeper{ @@ -44,11 +43,11 @@ func NewKeeper( } } -func (k *Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes.ExpectDelegationInterface) { +func (k *Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes.DelegationKeeper) { k.delegationKeeper = delegationKeeper } -func (k *Keeper) OracleInterface() operatortypes.ExpectOracleInterface { +func (k *Keeper) OracleInterface() operatortypes.OracleKeeper { return k.oracleKeeper } diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go index 26b76052b..0d74ead53 100644 --- a/x/operator/keeper/msg_server.go +++ b/x/operator/keeper/msg_server.go @@ -21,11 +21,14 @@ func (k *Keeper) RegisterOperator(ctx context.Context, req *types.RegisterOperat return nil, nil } -// OptInToChainID add for dogfood -func (k *Keeper) OptInToChainID( +// OptInToCosmosChain this is an RPC for the operators +// that want to service as a validator for the app chain Avs +// The operator can opt in the cosmos app chain through this RPC +// In this function, the basic function `OptIn` need to be called +func (k *Keeper) OptInToCosmosChain( goCtx context.Context, - req *types.OptInToChainIDRequest, -) (*types.OptInToChainIDResponse, error) { + req *types.OptInToCosmosChainRequest, +) (*types.OptInToCosmosChainResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { @@ -41,13 +44,15 @@ func (k *Keeper) OptInToChainID( if err != nil { return nil, err } - return &types.OptInToChainIDResponse{}, nil + return &types.OptInToCosmosChainResponse{}, nil } -func (k *Keeper) InitiateOptOutFromChainID( +// InitiateOptOutFromCosmosChain is a method corresponding to OptInToCosmosChain +// It provides a function to opt out from the app chain Avs for the operators. +func (k *Keeper) InitiateOptOutFromCosmosChain( goCtx context.Context, - req *types.InitiateOptOutFromChainIDRequest, -) (*types.InitiateOptOutFromChainIDResponse, error) { + req *types.InitiateOptOutFromCosmosChainRequest, +) (*types.InitiateOptOutFromCosmosChainResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { @@ -58,7 +63,7 @@ func (k *Keeper) InitiateOptOutFromChainID( ); err != nil { return nil, err } - return &types.InitiateOptOutFromChainIDResponse{}, nil + return &types.InitiateOptOutFromCosmosChainResponse{}, nil } func stringToPubKey(pubKey string) (key tmprotocrypto.PublicKey, err error) { diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index eb1e748ed..9ef38595a 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -14,7 +14,6 @@ import ( // SetOperatorInfo This function is used to register to be an operator in exoCore, the provided info will be stored on the chain. // Once an address has become an operator,the operator can't return to a normal address.But the operator can update the info through this function -// As for the operator opt-in function,it needs to be implemented in operator opt-in or AVS module func (k *Keeper) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) { opAccAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go index 8326be1ee..e047ebb6e 100644 --- a/x/operator/keeper/state_update.go +++ b/x/operator/keeper/state_update.go @@ -27,6 +27,8 @@ type SlashAssets struct { slashOperatorInfo map[string]*slashAmounts } +// UpdateOptedInAssetsState will update the USD share state related to asset, operator and AVS when +// the asset amount changes caused by delegation, undelegation, slashStaker and slashOperator. func (k *Keeper) UpdateOptedInAssetsState(ctx sdk.Context, stakerID, assetID, operatorAddr string, opAmount sdkmath.Int) error { // get the AVS opted-in by the operator avsList, err := k.GetOptedInAVSForOperator(ctx, operatorAddr) @@ -276,29 +278,29 @@ func (k *Keeper) OptOut(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr } // GetAssetsAmountToSlash It will slash the assets that are opting into AVS first, and if there isn't enough to slash, then it will slash the assets that have requested to undelegate but still locked. -func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssets, error) { +func (k *Keeper) GetAssetsAmountToSlash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, slashEventHeight int64, slashProportion sdkmath.LegacyDec) (*SlashAssets, error) { ret := &SlashAssets{ slashStakerInfo: make(map[string]map[string]*slashAmounts, 0), slashOperatorInfo: make(map[string]*slashAmounts, 0), } // get the state when the slash occurred - historicalSateCtx, err := types2.ContextForHistoricalState(ctx, occurredSateHeight) + historicalStateCtx, err := types2.ContextForHistoricalState(ctx, slashEventHeight) if err != nil { return nil, err } // get assetsInfo supported by AVS - assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(historicalSateCtx, avsAddr) + assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(historicalStateCtx, avsAddr) if err != nil { return nil, err } - historyStakerAssets, err := k.delegationKeeper.DelegationStateByOperatorAssets(historicalSateCtx, operatorAddress.String(), assetsFilter) + historyStakerAssets, err := k.delegationKeeper.DelegationStateByOperatorAssets(historicalStateCtx, operatorAddress.String(), assetsFilter) if err != nil { return nil, err } // get the Assets opted in the operator - historyOperatorAssetsState, err := k.assetsKeeper.GetOperatorAssetInfos(historicalSateCtx, operatorAddress, assetsFilter) + historyOperatorAssetsState, err := k.assetsKeeper.GetOperatorAssetInfos(historicalStateCtx, operatorAddress, assetsFilter) if err != nil { return nil, err } @@ -439,15 +441,15 @@ func (k *Keeper) SlashOperator(ctx sdk.Context, operatorAddress sdk.AccAddress, } // Slash The occurredSateHeight should be the height that has the latest stable state. -func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, slashContract, slashID string, occurredSateHeight int64, slashProportion sdkmath.LegacyDec) error { +func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, slashContract, slashID string, slashEventHeight int64, slashProportion sdkmath.LegacyDec) error { height := ctx.BlockHeight() - if occurredSateHeight > height { - return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("occurredSateHeight:%d,curHeight:%d", occurredSateHeight, height)) + if slashEventHeight > height { + return errorsmod.Wrap(types.ErrSlashOccurredHeight, fmt.Sprintf("slashEventHeight:%d,curHeight:%d", slashEventHeight, height)) } // get the state when the slash occurred // get the opted-in info - historicalSateCtx, err := types2.ContextForHistoricalState(ctx, occurredSateHeight) + historicalSateCtx, err := types2.ContextForHistoricalState(ctx, slashEventHeight) if err != nil { return err } @@ -466,7 +468,7 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, slashInfo := types.OperatorSlashInfo{ SlashContract: slashContract, SubmittedHeight: height, - EventHeight: occurredSateHeight, + EventHeight: slashEventHeight, SlashProportion: slashProportion, ProcessedHeight: height + types.SlashVetoDuration, } @@ -476,7 +478,7 @@ func (k *Keeper) Slash(ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr, } // get the assets and amounts that should be slashed - assetsSlashInfo, err := k.GetAssetsAmountToSlash(ctx, operatorAddress, avsAddr, occurredSateHeight, slashProportion) + assetsSlashInfo, err := k.GetAssetsAmountToSlash(ctx, operatorAddress, avsAddr, slashEventHeight, slashProportion) if err != nil { return err } diff --git a/x/operator/types/codec.go b/x/operator/types/codec.go index 89bd73c1a..473377ac4 100644 --- a/x/operator/types/codec.go +++ b/x/operator/types/codec.go @@ -32,8 +32,8 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &RegisterOperatorReq{}, - &OptInToChainIDRequest{}, - &InitiateOptOutFromChainIDRequest{}, + &OptInToCosmosChainRequest{}, + &InitiateOptOutFromCosmosChainRequest{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/operator/types/expected_keepers.go b/x/operator/types/expected_keepers.go index f1e08401a..5377075f8 100644 --- a/x/operator/types/expected_keepers.go +++ b/x/operator/types/expected_keepers.go @@ -8,7 +8,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -type ExpectAssetsInterface interface { +var ( + _ OracleKeeper = MockOracle{} + _ AvsKeeper = MockAvs{} +) + +type AssetsKeeper interface { GetStakingAssetInfo(ctx sdk.Context, assetID string) (info *assetstype.StakingAssetInfo, err error) IteratorOperatorAssetState(ctx sdk.Context, f func(operatorAddr, assetID string, state *assetstype.OperatorAssetInfo) error) error AppChainInfoIsExist(ctx sdk.Context, chainID string) bool @@ -17,7 +22,7 @@ type ExpectAssetsInterface interface { UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount assetstype.OperatorSingleAssetChangeInfo) (err error) } -type ExpectDelegationInterface interface { +type DelegationKeeper interface { DelegationStateByOperatorAssets(ctx sdk.Context, operatorAddr string, assetsFilter map[string]interface{}) (map[string]map[string]delegationtype.DelegationAmounts, error) IterateDelegationState(ctx sdk.Context, f func(restakerID, assetID, operatorAddr string, state *delegationtype.DelegationAmounts) error) error UpdateDelegationState(ctx sdk.Context, stakerID string, assetID string, delegationAmounts map[string]*delegationtype.DelegationAmounts) (err error) @@ -30,8 +35,16 @@ type PriceChange struct { NewPrice sdkmath.Int Decimal uint8 } -type ExpectOracleInterface interface { - GetSpecifiedAssetsPrice(ctx sdk.Context, assetsID string) (sdkmath.Int, uint8, error) + +// OracleKeeper is the oracle interface expected by operator module +// These functions need to be implemented by the oracle module +type OracleKeeper interface { + // GetSpecifiedAssetsPrice is a function to retrieve the asset price according to the assetID + // the first return value is price, and the second return value is decimal of the price. + GetSpecifiedAssetsPrice(ctx sdk.Context, assetID string) (sdkmath.Int, uint8, error) + // GetPriceChangeAssets the operator module expect a function that can retrieve all information + // about assets price change. Then it can update the USD share state according to the change + // information. This function need to return a map, the key is assetID and the value is PriceChange GetPriceChangeAssets(ctx sdk.Context) (map[string]*PriceChange, error) } @@ -53,9 +66,9 @@ func (MockOracle) GetPriceChangeAssets(_ sdk.Context) (map[string]*PriceChange, return nil, nil } -type MockAVS struct{} +type MockAvs struct{} -func (MockAVS) GetAvsSupportedAssets(_ sdk.Context, _ string) (map[string]interface{}, error) { +func (MockAvs) GetAvsSupportedAssets(_ sdk.Context, _ string) (map[string]interface{}, error) { // set USDT as the default asset supported by AVS ret := make(map[string]interface{}) usdtAssetID := "0xdac17f958d2ee523a2206206994597c13d831ec7_0x65" @@ -63,11 +76,11 @@ func (MockAVS) GetAvsSupportedAssets(_ sdk.Context, _ string) (map[string]interf return ret, nil } -func (MockAVS) GetAvsSlashContract(_ sdk.Context, _ string) (string, error) { +func (MockAvs) GetAvsSlashContract(_ sdk.Context, _ string) (string, error) { return "", nil } -type ExpectAvsInterface interface { +type AvsKeeper interface { // GetAvsSupportedAssets The ctx can be historical or current, depending on the state you wish to retrieve. // If the caller want to retrieve a historical assets info supported by Avs, it needs to generate a historical // context through calling `ContextForHistoricalState` implemented in x/assets/types/general.go @@ -81,10 +94,6 @@ type SlashKeeper interface { IsOperatorFrozen(ctx sdk.Context, addr sdk.AccAddress) bool } -type RedelegationKeeper interface { - AppChainInfoIsExist(ctx sdk.Context, chainID string) bool -} - type OperatorConsentHooks interface { // This hook is called when an operator opts in to a chain. AfterOperatorOptIn( diff --git a/x/operator/types/keys.go b/x/operator/types/keys.go index 5cc396660..5e34cf953 100644 --- a/x/operator/types/keys.go +++ b/x/operator/types/keys.go @@ -53,7 +53,7 @@ const ( ) var ( - // KeyPrefixOperatorInfo key-value: operatorAddr->operatorInfo + // KeyPrefixOperatorInfo key-value: operatorAddr->types.OperatorInfo KeyPrefixOperatorInfo = []byte{prefixOperatorInfo} // KeyPrefixOperatorOptedAVSInfo key-value: @@ -61,8 +61,8 @@ var ( KeyPrefixOperatorOptedAVSInfo = []byte{prefixOperatorOptedAVSInfo} // KeyPrefixAVSOperatorAssetsTotalValue key-value: - // AVSAddr -> AVSTotalValue - // AVSAddr + '/' + operatorAddr -> AVSOperatorTotalValue + // AVSAddr -> types.DecValueField(the total USD share of specified Avs) + // AVSAddr + '/' + operatorAddr -> types.DecValueField (the total USD share of specified operator and Avs) KeyPrefixAVSOperatorAssetsTotalValue = []byte{prefixAVSOperatorAssetsTotalValue} // KeyPrefixOperatorAVSSingleAssetState key-value: @@ -70,8 +70,8 @@ var ( KeyPrefixOperatorAVSSingleAssetState = []byte{prefixOperatorAVSSingleAssetState} // KeyPrefixAVSOperatorStakerShareState key-value: - // AVSAddr + '/' + '' + '/' + operatorAddr -> ownAssetsOptedInValue - // AVSAddr + '/' + stakerID + '/' + operatorAddr -> assetsOptedInValue + // AVSAddr + '/' + '' + '/' + operatorAddr -> types.DecValueField(the opted-in USD share owned by the operator itself) + // AVSAddr + '/' + stakerID + '/' + operatorAddr -> types.DecValueField (the opted-in USD share of the staker) KeyPrefixAVSOperatorStakerShareState = []byte{prefixOperatorAVSStakerShareState} // KeyPrefixOperatorSlashInfo key-value: diff --git a/x/operator/types/msg.go b/x/operator/types/msg.go index 8d2bb19e5..b38f28299 100644 --- a/x/operator/types/msg.go +++ b/x/operator/types/msg.go @@ -9,8 +9,8 @@ var ( _ sdk.Msg = &RegisterOperatorReq{} // add for dogfood - _ sdk.Msg = &OptInToChainIDRequest{} - _ sdk.Msg = &InitiateOptOutFromChainIDRequest{} + _ sdk.Msg = &OptInToCosmosChainRequest{} + _ sdk.Msg = &InitiateOptOutFromCosmosChainRequest{} ) // GetSigners returns the expected signers for a MsgUpdateParams message. @@ -32,24 +32,24 @@ func (m *RegisterOperatorReq) GetSignBytes() []byte { return nil } -func (m *OptInToChainIDRequest) GetSigners() []sdk.AccAddress { +func (m *OptInToCosmosChainRequest) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.Address) return []sdk.AccAddress{addr} } -func (m *OptInToChainIDRequest) ValidateBasic() error { +func (m *OptInToCosmosChainRequest) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { return errorsmod.Wrap(err, "invalid from address") } return nil } -func (m *InitiateOptOutFromChainIDRequest) GetSigners() []sdk.AccAddress { +func (m *InitiateOptOutFromCosmosChainRequest) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.Address) return []sdk.AccAddress{addr} } -func (m *InitiateOptOutFromChainIDRequest) ValidateBasic() error { +func (m *InitiateOptOutFromCosmosChainRequest) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { return errorsmod.Wrap(err, "invalid from address") } diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 2d21736dc..6bd9a425a 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -514,8 +514,8 @@ func (m *RegisterOperatorResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo -// OptInToChainIDRequest defines the OptInToChainID request. -type OptInToChainIDRequest struct { +// OptInToCosmosChainRequest defines the OptInToCosmosChain request. +type OptInToCosmosChainRequest struct { // address is the operator address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // chain_id is the identifier for the chain that wants to opt in. @@ -527,18 +527,18 @@ type OptInToChainIDRequest struct { PublicKey string `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` } -func (m *OptInToChainIDRequest) Reset() { *m = OptInToChainIDRequest{} } -func (m *OptInToChainIDRequest) String() string { return proto.CompactTextString(m) } -func (*OptInToChainIDRequest) ProtoMessage() {} -func (*OptInToChainIDRequest) Descriptor() ([]byte, []int) { +func (m *OptInToCosmosChainRequest) Reset() { *m = OptInToCosmosChainRequest{} } +func (m *OptInToCosmosChainRequest) String() string { return proto.CompactTextString(m) } +func (*OptInToCosmosChainRequest) ProtoMessage() {} +func (*OptInToCosmosChainRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{9} } -func (m *OptInToChainIDRequest) XXX_Unmarshal(b []byte) error { +func (m *OptInToCosmosChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OptInToChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptInToCosmosChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OptInToChainIDRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_OptInToCosmosChainRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -548,55 +548,55 @@ func (m *OptInToChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *OptInToChainIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_OptInToChainIDRequest.Merge(m, src) +func (m *OptInToCosmosChainRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToCosmosChainRequest.Merge(m, src) } -func (m *OptInToChainIDRequest) XXX_Size() int { +func (m *OptInToCosmosChainRequest) XXX_Size() int { return m.Size() } -func (m *OptInToChainIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_OptInToChainIDRequest.DiscardUnknown(m) +func (m *OptInToCosmosChainRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToCosmosChainRequest.DiscardUnknown(m) } -var xxx_messageInfo_OptInToChainIDRequest proto.InternalMessageInfo +var xxx_messageInfo_OptInToCosmosChainRequest proto.InternalMessageInfo -func (m *OptInToChainIDRequest) GetAddress() string { +func (m *OptInToCosmosChainRequest) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *OptInToChainIDRequest) GetChainId() string { +func (m *OptInToCosmosChainRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -func (m *OptInToChainIDRequest) GetPublicKey() string { +func (m *OptInToCosmosChainRequest) GetPublicKey() string { if m != nil { return m.PublicKey } return "" } -// OptInToChainIDResponse defines the OptInToChainID response. -type OptInToChainIDResponse struct { +// OptInToCosmosChainResponse defines the OptInToCosmosChain response. +type OptInToCosmosChainResponse struct { } -func (m *OptInToChainIDResponse) Reset() { *m = OptInToChainIDResponse{} } -func (m *OptInToChainIDResponse) String() string { return proto.CompactTextString(m) } -func (*OptInToChainIDResponse) ProtoMessage() {} -func (*OptInToChainIDResponse) Descriptor() ([]byte, []int) { +func (m *OptInToCosmosChainResponse) Reset() { *m = OptInToCosmosChainResponse{} } +func (m *OptInToCosmosChainResponse) String() string { return proto.CompactTextString(m) } +func (*OptInToCosmosChainResponse) ProtoMessage() {} +func (*OptInToCosmosChainResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{10} } -func (m *OptInToChainIDResponse) XXX_Unmarshal(b []byte) error { +func (m *OptInToCosmosChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OptInToChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OptInToCosmosChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OptInToChainIDResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_OptInToCosmosChainResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -606,38 +606,38 @@ func (m *OptInToChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *OptInToChainIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_OptInToChainIDResponse.Merge(m, src) +func (m *OptInToCosmosChainResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToCosmosChainResponse.Merge(m, src) } -func (m *OptInToChainIDResponse) XXX_Size() int { +func (m *OptInToCosmosChainResponse) XXX_Size() int { return m.Size() } -func (m *OptInToChainIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_OptInToChainIDResponse.DiscardUnknown(m) +func (m *OptInToCosmosChainResponse) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToCosmosChainResponse.DiscardUnknown(m) } -var xxx_messageInfo_OptInToChainIDResponse proto.InternalMessageInfo +var xxx_messageInfo_OptInToCosmosChainResponse proto.InternalMessageInfo -// InitiateOptOutFromChainIDRequest defines the InitiateOptOutFromChainID request. -type InitiateOptOutFromChainIDRequest struct { +// InitiateOptOutFromCosmosChainRequest defines the InitiateOptOutFromCosmosChain request. +type InitiateOptOutFromCosmosChainRequest struct { // address is the operator address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // chain_id is the identifier for the chain that wants to opt out. ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (m *InitiateOptOutFromChainIDRequest) Reset() { *m = InitiateOptOutFromChainIDRequest{} } -func (m *InitiateOptOutFromChainIDRequest) String() string { return proto.CompactTextString(m) } -func (*InitiateOptOutFromChainIDRequest) ProtoMessage() {} -func (*InitiateOptOutFromChainIDRequest) Descriptor() ([]byte, []int) { +func (m *InitiateOptOutFromCosmosChainRequest) Reset() { *m = InitiateOptOutFromCosmosChainRequest{} } +func (m *InitiateOptOutFromCosmosChainRequest) String() string { return proto.CompactTextString(m) } +func (*InitiateOptOutFromCosmosChainRequest) ProtoMessage() {} +func (*InitiateOptOutFromCosmosChainRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{11} } -func (m *InitiateOptOutFromChainIDRequest) XXX_Unmarshal(b []byte) error { +func (m *InitiateOptOutFromCosmosChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InitiateOptOutFromChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InitiateOptOutFromCosmosChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InitiateOptOutFromChainIDRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_InitiateOptOutFromCosmosChainRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -647,48 +647,48 @@ func (m *InitiateOptOutFromChainIDRequest) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *InitiateOptOutFromChainIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitiateOptOutFromChainIDRequest.Merge(m, src) +func (m *InitiateOptOutFromCosmosChainRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitiateOptOutFromCosmosChainRequest.Merge(m, src) } -func (m *InitiateOptOutFromChainIDRequest) XXX_Size() int { +func (m *InitiateOptOutFromCosmosChainRequest) XXX_Size() int { return m.Size() } -func (m *InitiateOptOutFromChainIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_InitiateOptOutFromChainIDRequest.DiscardUnknown(m) +func (m *InitiateOptOutFromCosmosChainRequest) XXX_DiscardUnknown() { + xxx_messageInfo_InitiateOptOutFromCosmosChainRequest.DiscardUnknown(m) } -var xxx_messageInfo_InitiateOptOutFromChainIDRequest proto.InternalMessageInfo +var xxx_messageInfo_InitiateOptOutFromCosmosChainRequest proto.InternalMessageInfo -func (m *InitiateOptOutFromChainIDRequest) GetAddress() string { +func (m *InitiateOptOutFromCosmosChainRequest) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *InitiateOptOutFromChainIDRequest) GetChainId() string { +func (m *InitiateOptOutFromCosmosChainRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -// InitiateOptOutFromChainIDResponse defines the InitiateOptOutFromChainID response. -type InitiateOptOutFromChainIDResponse struct { +// InitiateOptOutFromCosmosChainResponse defines the InitiateOptOutFromCosmosChain response. +type InitiateOptOutFromCosmosChainResponse struct { } -func (m *InitiateOptOutFromChainIDResponse) Reset() { *m = InitiateOptOutFromChainIDResponse{} } -func (m *InitiateOptOutFromChainIDResponse) String() string { return proto.CompactTextString(m) } -func (*InitiateOptOutFromChainIDResponse) ProtoMessage() {} -func (*InitiateOptOutFromChainIDResponse) Descriptor() ([]byte, []int) { +func (m *InitiateOptOutFromCosmosChainResponse) Reset() { *m = InitiateOptOutFromCosmosChainResponse{} } +func (m *InitiateOptOutFromCosmosChainResponse) String() string { return proto.CompactTextString(m) } +func (*InitiateOptOutFromCosmosChainResponse) ProtoMessage() {} +func (*InitiateOptOutFromCosmosChainResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{12} } -func (m *InitiateOptOutFromChainIDResponse) XXX_Unmarshal(b []byte) error { +func (m *InitiateOptOutFromCosmosChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InitiateOptOutFromChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InitiateOptOutFromCosmosChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InitiateOptOutFromChainIDResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_InitiateOptOutFromCosmosChainResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -698,17 +698,17 @@ func (m *InitiateOptOutFromChainIDResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *InitiateOptOutFromChainIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitiateOptOutFromChainIDResponse.Merge(m, src) +func (m *InitiateOptOutFromCosmosChainResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitiateOptOutFromCosmosChainResponse.Merge(m, src) } -func (m *InitiateOptOutFromChainIDResponse) XXX_Size() int { +func (m *InitiateOptOutFromCosmosChainResponse) XXX_Size() int { return m.Size() } -func (m *InitiateOptOutFromChainIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_InitiateOptOutFromChainIDResponse.DiscardUnknown(m) +func (m *InitiateOptOutFromCosmosChainResponse) XXX_DiscardUnknown() { + xxx_messageInfo_InitiateOptOutFromCosmosChainResponse.DiscardUnknown(m) } -var xxx_messageInfo_InitiateOptOutFromChainIDResponse proto.InternalMessageInfo +var xxx_messageInfo_InitiateOptOutFromCosmosChainResponse proto.InternalMessageInfo func init() { proto.RegisterType((*DecValueField)(nil), "exocore.operator.v1.DecValueField") @@ -720,78 +720,78 @@ func init() { proto.RegisterType((*OperatorSlashInfo)(nil), "exocore.operator.v1.OperatorSlashInfo") proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.operator.v1.RegisterOperatorReq") proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.operator.v1.RegisterOperatorResponse") - proto.RegisterType((*OptInToChainIDRequest)(nil), "exocore.operator.v1.OptInToChainIDRequest") - proto.RegisterType((*OptInToChainIDResponse)(nil), "exocore.operator.v1.OptInToChainIDResponse") - proto.RegisterType((*InitiateOptOutFromChainIDRequest)(nil), "exocore.operator.v1.InitiateOptOutFromChainIDRequest") - proto.RegisterType((*InitiateOptOutFromChainIDResponse)(nil), "exocore.operator.v1.InitiateOptOutFromChainIDResponse") + proto.RegisterType((*OptInToCosmosChainRequest)(nil), "exocore.operator.v1.OptInToCosmosChainRequest") + proto.RegisterType((*OptInToCosmosChainResponse)(nil), "exocore.operator.v1.OptInToCosmosChainResponse") + proto.RegisterType((*InitiateOptOutFromCosmosChainRequest)(nil), "exocore.operator.v1.InitiateOptOutFromCosmosChainRequest") + proto.RegisterType((*InitiateOptOutFromCosmosChainResponse)(nil), "exocore.operator.v1.InitiateOptOutFromCosmosChainResponse") } func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 984 bytes of a gzipped FileDescriptorProto + // 989 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0xc6, 0x49, 0x9a, 0x3c, 0x3b, 0xb1, 0x33, 0x29, 0x8d, 0x63, 0xc0, 0x4e, 0xb6, 0xa2, - 0x72, 0x03, 0xb1, 0xd5, 0x40, 0x91, 0x28, 0x1c, 0xc8, 0x8f, 0x56, 0x58, 0xa4, 0x18, 0x6d, 0xaa, - 0x1e, 0xe0, 0xb0, 0xda, 0xec, 0x4e, 0xd6, 0x23, 0xdb, 0x3b, 0xdb, 0x9d, 0xb1, 0x89, 0x7b, 0x42, - 0x88, 0x03, 0x42, 0x1c, 0xb8, 0x72, 0xeb, 0x9f, 0x90, 0x43, 0x2f, 0x1c, 0x10, 0xd7, 0x1e, 0xab, - 0x9e, 0x10, 0x87, 0x08, 0x25, 0x87, 0x70, 0x46, 0xe2, 0x8e, 0xe6, 0xc7, 0x26, 0x9b, 0x74, 0x43, - 0x1b, 0xb5, 0x97, 0xc4, 0xf3, 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d1, 0x67, 0x98, 0x3f, 0xa2, 0xc9, 0x96, 0x9d, + 0x7e, 0x58, 0x6d, 0x1f, 0x7f, 0x5a, 0xc9, 0xf7, 0x60, 0x63, 0x44, 0x7e, 0xe9, 0xbc, 0xf7, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x06, 0xf5, 0xb5, 0x2e, 0x7b, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -809,16 +809,16 @@ type MsgClient interface { // RegisterOperator registers a new operator. RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) // add services for dogfood - // OptInToChainID acts as opt in method for an operator to + // OptInToCosmosChain acts as opt in method for an operator to // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. - OptInToChainID(ctx context.Context, in *OptInToChainIDRequest, opts ...grpc.CallOption) (*OptInToChainIDResponse, error) - // InitiateOptOutFromChainID is a method with which an operator can initiate + OptInToCosmosChain(ctx context.Context, in *OptInToCosmosChainRequest, opts ...grpc.CallOption) (*OptInToCosmosChainResponse, error) + // InitiateOptOutFromCosmosChain is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - InitiateOptOutFromChainID(ctx context.Context, in *InitiateOptOutFromChainIDRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIDResponse, error) + InitiateOptOutFromCosmosChain(ctx context.Context, in *InitiateOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitiateOptOutFromCosmosChainResponse, error) } type msgClient struct { @@ -838,18 +838,18 @@ func (c *msgClient) RegisterOperator(ctx context.Context, in *RegisterOperatorRe return out, nil } -func (c *msgClient) OptInToChainID(ctx context.Context, in *OptInToChainIDRequest, opts ...grpc.CallOption) (*OptInToChainIDResponse, error) { - out := new(OptInToChainIDResponse) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/OptInToChainID", in, out, opts...) +func (c *msgClient) OptInToCosmosChain(ctx context.Context, in *OptInToCosmosChainRequest, opts ...grpc.CallOption) (*OptInToCosmosChainResponse, error) { + out := new(OptInToCosmosChainResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/OptInToCosmosChain", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) InitiateOptOutFromChainID(ctx context.Context, in *InitiateOptOutFromChainIDRequest, opts ...grpc.CallOption) (*InitiateOptOutFromChainIDResponse, error) { - out := new(InitiateOptOutFromChainIDResponse) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitiateOptOutFromChainID", in, out, opts...) +func (c *msgClient) InitiateOptOutFromCosmosChain(ctx context.Context, in *InitiateOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitiateOptOutFromCosmosChainResponse, error) { + out := new(InitiateOptOutFromCosmosChainResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitiateOptOutFromCosmosChain", in, out, opts...) if err != nil { return nil, err } @@ -861,16 +861,16 @@ type MsgServer interface { // RegisterOperator registers a new operator. RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) // add services for dogfood - // OptInToChainID acts as opt in method for an operator to + // OptInToCosmosChain acts as opt in method for an operator to // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. - OptInToChainID(context.Context, *OptInToChainIDRequest) (*OptInToChainIDResponse, error) - // InitiateOptOutFromChainID is a method with which an operator can initiate + OptInToCosmosChain(context.Context, *OptInToCosmosChainRequest) (*OptInToCosmosChainResponse, error) + // InitiateOptOutFromCosmosChain is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - InitiateOptOutFromChainID(context.Context, *InitiateOptOutFromChainIDRequest) (*InitiateOptOutFromChainIDResponse, error) + InitiateOptOutFromCosmosChain(context.Context, *InitiateOptOutFromCosmosChainRequest) (*InitiateOptOutFromCosmosChainResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -880,11 +880,11 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *RegisterOperatorReq) (*RegisterOperatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterOperator not implemented") } -func (*UnimplementedMsgServer) OptInToChainID(ctx context.Context, req *OptInToChainIDRequest) (*OptInToChainIDResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method OptInToChainID not implemented") +func (*UnimplementedMsgServer) OptInToCosmosChain(ctx context.Context, req *OptInToCosmosChainRequest) (*OptInToCosmosChainResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OptInToCosmosChain not implemented") } -func (*UnimplementedMsgServer) InitiateOptOutFromChainID(ctx context.Context, req *InitiateOptOutFromChainIDRequest) (*InitiateOptOutFromChainIDResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method InitiateOptOutFromChainID not implemented") +func (*UnimplementedMsgServer) InitiateOptOutFromCosmosChain(ctx context.Context, req *InitiateOptOutFromCosmosChainRequest) (*InitiateOptOutFromCosmosChainResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InitiateOptOutFromCosmosChain not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -909,38 +909,38 @@ func _Msg_RegisterOperator_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Msg_OptInToChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(OptInToChainIDRequest) +func _Msg_OptInToCosmosChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OptInToCosmosChainRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).OptInToChainID(ctx, in) + return srv.(MsgServer).OptInToCosmosChain(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Msg/OptInToChainID", + FullMethod: "/exocore.operator.v1.Msg/OptInToCosmosChain", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).OptInToChainID(ctx, req.(*OptInToChainIDRequest)) + return srv.(MsgServer).OptInToCosmosChain(ctx, req.(*OptInToCosmosChainRequest)) } return interceptor(ctx, in, info, handler) } -func _Msg_InitiateOptOutFromChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InitiateOptOutFromChainIDRequest) +func _Msg_InitiateOptOutFromCosmosChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InitiateOptOutFromCosmosChainRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).InitiateOptOutFromChainID(ctx, in) + return srv.(MsgServer).InitiateOptOutFromCosmosChain(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Msg/InitiateOptOutFromChainID", + FullMethod: "/exocore.operator.v1.Msg/InitiateOptOutFromCosmosChain", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).InitiateOptOutFromChainID(ctx, req.(*InitiateOptOutFromChainIDRequest)) + return srv.(MsgServer).InitiateOptOutFromCosmosChain(ctx, req.(*InitiateOptOutFromCosmosChainRequest)) } return interceptor(ctx, in, info, handler) } @@ -954,12 +954,12 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RegisterOperator_Handler, }, { - MethodName: "OptInToChainID", - Handler: _Msg_OptInToChainID_Handler, + MethodName: "OptInToCosmosChain", + Handler: _Msg_OptInToCosmosChain_Handler, }, { - MethodName: "InitiateOptOutFromChainID", - Handler: _Msg_InitiateOptOutFromChainID_Handler, + MethodName: "InitiateOptOutFromCosmosChain", + Handler: _Msg_InitiateOptOutFromCosmosChain_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -1340,7 +1340,7 @@ func (m *RegisterOperatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *OptInToChainIDRequest) Marshal() (dAtA []byte, err error) { +func (m *OptInToCosmosChainRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1350,12 +1350,12 @@ func (m *OptInToChainIDRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OptInToChainIDRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *OptInToCosmosChainRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OptInToChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OptInToCosmosChainRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1384,7 +1384,7 @@ func (m *OptInToChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *OptInToChainIDResponse) Marshal() (dAtA []byte, err error) { +func (m *OptInToCosmosChainResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1394,12 +1394,12 @@ func (m *OptInToChainIDResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OptInToChainIDResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *OptInToCosmosChainResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OptInToChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OptInToCosmosChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1407,7 +1407,7 @@ func (m *OptInToChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *InitiateOptOutFromChainIDRequest) Marshal() (dAtA []byte, err error) { +func (m *InitiateOptOutFromCosmosChainRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1417,12 +1417,12 @@ func (m *InitiateOptOutFromChainIDRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *InitiateOptOutFromChainIDRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromCosmosChainRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InitiateOptOutFromChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromCosmosChainRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1444,7 +1444,7 @@ func (m *InitiateOptOutFromChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } -func (m *InitiateOptOutFromChainIDResponse) Marshal() (dAtA []byte, err error) { +func (m *InitiateOptOutFromCosmosChainResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1454,12 +1454,12 @@ func (m *InitiateOptOutFromChainIDResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *InitiateOptOutFromChainIDResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromCosmosChainResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InitiateOptOutFromChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InitiateOptOutFromCosmosChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1630,7 +1630,7 @@ func (m *RegisterOperatorResponse) Size() (n int) { return n } -func (m *OptInToChainIDRequest) Size() (n int) { +func (m *OptInToCosmosChainRequest) Size() (n int) { if m == nil { return 0 } @@ -1651,7 +1651,7 @@ func (m *OptInToChainIDRequest) Size() (n int) { return n } -func (m *OptInToChainIDResponse) Size() (n int) { +func (m *OptInToCosmosChainResponse) Size() (n int) { if m == nil { return 0 } @@ -1660,7 +1660,7 @@ func (m *OptInToChainIDResponse) Size() (n int) { return n } -func (m *InitiateOptOutFromChainIDRequest) Size() (n int) { +func (m *InitiateOptOutFromCosmosChainRequest) Size() (n int) { if m == nil { return 0 } @@ -1677,7 +1677,7 @@ func (m *InitiateOptOutFromChainIDRequest) Size() (n int) { return n } -func (m *InitiateOptOutFromChainIDResponse) Size() (n int) { +func (m *InitiateOptOutFromCosmosChainResponse) Size() (n int) { if m == nil { return 0 } @@ -2742,7 +2742,7 @@ func (m *RegisterOperatorResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *OptInToChainIDRequest) Unmarshal(dAtA []byte) error { +func (m *OptInToCosmosChainRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2765,10 +2765,10 @@ func (m *OptInToChainIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OptInToChainIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: OptInToCosmosChainRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OptInToChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OptInToCosmosChainRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2888,7 +2888,7 @@ func (m *OptInToChainIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *OptInToChainIDResponse) Unmarshal(dAtA []byte) error { +func (m *OptInToCosmosChainResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2911,10 +2911,10 @@ func (m *OptInToChainIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OptInToChainIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: OptInToCosmosChainResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OptInToChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OptInToCosmosChainResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2938,7 +2938,7 @@ func (m *OptInToChainIDResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *InitiateOptOutFromChainIDRequest) Unmarshal(dAtA []byte) error { +func (m *InitiateOptOutFromCosmosChainRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2961,10 +2961,10 @@ func (m *InitiateOptOutFromChainIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InitiateOptOutFromChainIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: InitiateOptOutFromCosmosChainRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InitiateOptOutFromChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InitiateOptOutFromCosmosChainRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3052,7 +3052,7 @@ func (m *InitiateOptOutFromChainIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *InitiateOptOutFromChainIDResponse) Unmarshal(dAtA []byte) error { +func (m *InitiateOptOutFromCosmosChainResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3075,10 +3075,10 @@ func (m *InitiateOptOutFromChainIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InitiateOptOutFromChainIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: InitiateOptOutFromCosmosChainResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InitiateOptOutFromChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InitiateOptOutFromCosmosChainResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/reward/types/tx.pb.go b/x/reward/types/tx.pb.go index 19052baa8..f94910aab 100644 --- a/x/reward/types/tx.pb.go +++ b/x/reward/types/tx.pb.go @@ -31,7 +31,6 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 type MsgUpdateParams struct { // authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` @@ -89,7 +88,6 @@ func (m *MsgUpdateParams) GetParams() Params { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 type MsgUpdateParamsResponse struct { } diff --git a/x/slash/types/tx.pb.go b/x/slash/types/tx.pb.go index 78a818b45..d22b7b022 100644 --- a/x/slash/types/tx.pb.go +++ b/x/slash/types/tx.pb.go @@ -31,7 +31,6 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. -// Since: cosmos-sdk 0.47 type MsgUpdateParams struct { // authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` @@ -89,7 +88,6 @@ func (m *MsgUpdateParams) GetParams() Params { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -// Since: cosmos-sdk 0.47 type MsgUpdateParamsResponse struct { } From e8f6c8c16f8a1f9e50c666e668156856f4bffa41 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Mon, 18 Mar 2024 14:33:54 +0800 Subject: [PATCH 43/44] fix the prtobuf lint error --- proto/exocore/operator/v1/tx.proto | 12 +- x/operator/keeper/msg_server.go | 10 +- x/operator/types/codec.go | 2 +- x/operator/types/msg.go | 6 +- x/operator/types/query.pb.go | 2 +- x/operator/types/tx.pb.go | 252 ++++++++++++++--------------- 6 files changed, 142 insertions(+), 142 deletions(-) diff --git a/proto/exocore/operator/v1/tx.proto b/proto/exocore/operator/v1/tx.proto index 29199fdec..ce386e4b0 100644 --- a/proto/exocore/operator/v1/tx.proto +++ b/proto/exocore/operator/v1/tx.proto @@ -131,8 +131,8 @@ message OptInToCosmosChainRequest { message OptInToCosmosChainResponse { } -// InitiateOptOutFromCosmosChainRequest defines the InitiateOptOutFromCosmosChain request. -message InitiateOptOutFromCosmosChainRequest { +// InitOptOutFromCosmosChainRequest defines the InitOptOutFromCosmosChain request. +message InitOptOutFromCosmosChainRequest { option (cosmos.msg.v1.signer) = "address"; // address is the operator address string address = 1; @@ -140,8 +140,8 @@ message InitiateOptOutFromCosmosChainRequest { string chain_id = 2; } -// InitiateOptOutFromCosmosChainResponse defines the InitiateOptOutFromCosmosChain response. -message InitiateOptOutFromCosmosChainResponse { +// InitOptOutFromCosmosChainResponse defines the InitOptOutFromCosmosChain response. +message InitOptOutFromCosmosChainResponse { } // Msg defines the operator Msg service. @@ -155,10 +155,10 @@ service Msg { // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. rpc OptInToCosmosChain(OptInToCosmosChainRequest) returns (OptInToCosmosChainResponse) {}; - // InitiateOptOutFromCosmosChain is a method with which an operator can initiate + // InitOptOutFromCosmosChain is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - rpc InitiateOptOutFromCosmosChain(InitiateOptOutFromCosmosChainRequest) returns (InitiateOptOutFromCosmosChainResponse) {}; + rpc InitOptOutFromCosmosChain(InitOptOutFromCosmosChainRequest) returns (InitOptOutFromCosmosChainResponse) {}; } \ No newline at end of file diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go index 0d74ead53..fcc018a67 100644 --- a/x/operator/keeper/msg_server.go +++ b/x/operator/keeper/msg_server.go @@ -47,12 +47,12 @@ func (k *Keeper) OptInToCosmosChain( return &types.OptInToCosmosChainResponse{}, nil } -// InitiateOptOutFromCosmosChain is a method corresponding to OptInToCosmosChain +// InitOptOutFromCosmosChain is a method corresponding to OptInToCosmosChain // It provides a function to opt out from the app chain Avs for the operators. -func (k *Keeper) InitiateOptOutFromCosmosChain( +func (k *Keeper) InitOptOutFromCosmosChain( goCtx context.Context, - req *types.InitiateOptOutFromCosmosChainRequest, -) (*types.InitiateOptOutFromCosmosChainResponse, error) { + req *types.InitOptOutFromCosmosChainRequest, +) (*types.InitOptOutFromCosmosChainResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { @@ -63,7 +63,7 @@ func (k *Keeper) InitiateOptOutFromCosmosChain( ); err != nil { return nil, err } - return &types.InitiateOptOutFromCosmosChainResponse{}, nil + return &types.InitOptOutFromCosmosChainResponse{}, nil } func stringToPubKey(pubKey string) (key tmprotocrypto.PublicKey, err error) { diff --git a/x/operator/types/codec.go b/x/operator/types/codec.go index 473377ac4..17edd4f33 100644 --- a/x/operator/types/codec.go +++ b/x/operator/types/codec.go @@ -33,7 +33,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*sdk.Msg)(nil), &RegisterOperatorReq{}, &OptInToCosmosChainRequest{}, - &InitiateOptOutFromCosmosChainRequest{}, + &InitOptOutFromCosmosChainRequest{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/operator/types/msg.go b/x/operator/types/msg.go index b38f28299..16612cd68 100644 --- a/x/operator/types/msg.go +++ b/x/operator/types/msg.go @@ -10,7 +10,7 @@ var ( // add for dogfood _ sdk.Msg = &OptInToCosmosChainRequest{} - _ sdk.Msg = &InitiateOptOutFromCosmosChainRequest{} + _ sdk.Msg = &InitOptOutFromCosmosChainRequest{} ) // GetSigners returns the expected signers for a MsgUpdateParams message. @@ -44,12 +44,12 @@ func (m *OptInToCosmosChainRequest) ValidateBasic() error { return nil } -func (m *InitiateOptOutFromCosmosChainRequest) GetSigners() []sdk.AccAddress { +func (m *InitOptOutFromCosmosChainRequest) GetSigners() []sdk.AccAddress { addr := sdk.MustAccAddressFromBech32(m.Address) return []sdk.AccAddress{addr} } -func (m *InitiateOptOutFromCosmosChainRequest) ValidateBasic() error { +func (m *InitOptOutFromCosmosChainRequest) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { return errorsmod.Wrap(err, "invalid from address") } diff --git a/x/operator/types/query.pb.go b/x/operator/types/query.pb.go index df6dd2716..737635e24 100644 --- a/x/operator/types/query.pb.go +++ b/x/operator/types/query.pb.go @@ -33,7 +33,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryOperatorInfoReq is the request to obtain the operator information. type GetOperatorInfoReq struct { - // operator_addr is the operator address. + // operator_addr is the operator address,its type should be a sdk.AccAddress OperatorAddr string `protobuf:"bytes,1,opt,name=operator_addr,json=operatorAddr,proto3" json:"operator_addr,omitempty"` } diff --git a/x/operator/types/tx.pb.go b/x/operator/types/tx.pb.go index 6bd9a425a..b162bfb3b 100644 --- a/x/operator/types/tx.pb.go +++ b/x/operator/types/tx.pb.go @@ -618,26 +618,26 @@ func (m *OptInToCosmosChainResponse) XXX_DiscardUnknown() { var xxx_messageInfo_OptInToCosmosChainResponse proto.InternalMessageInfo -// InitiateOptOutFromCosmosChainRequest defines the InitiateOptOutFromCosmosChain request. -type InitiateOptOutFromCosmosChainRequest struct { +// InitOptOutFromCosmosChainRequest defines the InitOptOutFromCosmosChain request. +type InitOptOutFromCosmosChainRequest struct { // address is the operator address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // chain_id is the identifier for the chain that wants to opt out. ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (m *InitiateOptOutFromCosmosChainRequest) Reset() { *m = InitiateOptOutFromCosmosChainRequest{} } -func (m *InitiateOptOutFromCosmosChainRequest) String() string { return proto.CompactTextString(m) } -func (*InitiateOptOutFromCosmosChainRequest) ProtoMessage() {} -func (*InitiateOptOutFromCosmosChainRequest) Descriptor() ([]byte, []int) { +func (m *InitOptOutFromCosmosChainRequest) Reset() { *m = InitOptOutFromCosmosChainRequest{} } +func (m *InitOptOutFromCosmosChainRequest) String() string { return proto.CompactTextString(m) } +func (*InitOptOutFromCosmosChainRequest) ProtoMessage() {} +func (*InitOptOutFromCosmosChainRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{11} } -func (m *InitiateOptOutFromCosmosChainRequest) XXX_Unmarshal(b []byte) error { +func (m *InitOptOutFromCosmosChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InitiateOptOutFromCosmosChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InitOptOutFromCosmosChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InitiateOptOutFromCosmosChainRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_InitOptOutFromCosmosChainRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -647,48 +647,48 @@ func (m *InitiateOptOutFromCosmosChainRequest) XXX_Marshal(b []byte, determinist return b[:n], nil } } -func (m *InitiateOptOutFromCosmosChainRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitiateOptOutFromCosmosChainRequest.Merge(m, src) +func (m *InitOptOutFromCosmosChainRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitOptOutFromCosmosChainRequest.Merge(m, src) } -func (m *InitiateOptOutFromCosmosChainRequest) XXX_Size() int { +func (m *InitOptOutFromCosmosChainRequest) XXX_Size() int { return m.Size() } -func (m *InitiateOptOutFromCosmosChainRequest) XXX_DiscardUnknown() { - xxx_messageInfo_InitiateOptOutFromCosmosChainRequest.DiscardUnknown(m) +func (m *InitOptOutFromCosmosChainRequest) XXX_DiscardUnknown() { + xxx_messageInfo_InitOptOutFromCosmosChainRequest.DiscardUnknown(m) } -var xxx_messageInfo_InitiateOptOutFromCosmosChainRequest proto.InternalMessageInfo +var xxx_messageInfo_InitOptOutFromCosmosChainRequest proto.InternalMessageInfo -func (m *InitiateOptOutFromCosmosChainRequest) GetAddress() string { +func (m *InitOptOutFromCosmosChainRequest) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *InitiateOptOutFromCosmosChainRequest) GetChainId() string { +func (m *InitOptOutFromCosmosChainRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -// InitiateOptOutFromCosmosChainResponse defines the InitiateOptOutFromCosmosChain response. -type InitiateOptOutFromCosmosChainResponse struct { +// InitOptOutFromCosmosChainResponse defines the InitOptOutFromCosmosChain response. +type InitOptOutFromCosmosChainResponse struct { } -func (m *InitiateOptOutFromCosmosChainResponse) Reset() { *m = InitiateOptOutFromCosmosChainResponse{} } -func (m *InitiateOptOutFromCosmosChainResponse) String() string { return proto.CompactTextString(m) } -func (*InitiateOptOutFromCosmosChainResponse) ProtoMessage() {} -func (*InitiateOptOutFromCosmosChainResponse) Descriptor() ([]byte, []int) { +func (m *InitOptOutFromCosmosChainResponse) Reset() { *m = InitOptOutFromCosmosChainResponse{} } +func (m *InitOptOutFromCosmosChainResponse) String() string { return proto.CompactTextString(m) } +func (*InitOptOutFromCosmosChainResponse) ProtoMessage() {} +func (*InitOptOutFromCosmosChainResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b229d5663e4df167, []int{12} } -func (m *InitiateOptOutFromCosmosChainResponse) XXX_Unmarshal(b []byte) error { +func (m *InitOptOutFromCosmosChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InitiateOptOutFromCosmosChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *InitOptOutFromCosmosChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InitiateOptOutFromCosmosChainResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_InitOptOutFromCosmosChainResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -698,17 +698,17 @@ func (m *InitiateOptOutFromCosmosChainResponse) XXX_Marshal(b []byte, determinis return b[:n], nil } } -func (m *InitiateOptOutFromCosmosChainResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_InitiateOptOutFromCosmosChainResponse.Merge(m, src) +func (m *InitOptOutFromCosmosChainResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitOptOutFromCosmosChainResponse.Merge(m, src) } -func (m *InitiateOptOutFromCosmosChainResponse) XXX_Size() int { +func (m *InitOptOutFromCosmosChainResponse) XXX_Size() int { return m.Size() } -func (m *InitiateOptOutFromCosmosChainResponse) XXX_DiscardUnknown() { - xxx_messageInfo_InitiateOptOutFromCosmosChainResponse.DiscardUnknown(m) +func (m *InitOptOutFromCosmosChainResponse) XXX_DiscardUnknown() { + xxx_messageInfo_InitOptOutFromCosmosChainResponse.DiscardUnknown(m) } -var xxx_messageInfo_InitiateOptOutFromCosmosChainResponse proto.InternalMessageInfo +var xxx_messageInfo_InitOptOutFromCosmosChainResponse proto.InternalMessageInfo func init() { proto.RegisterType((*DecValueField)(nil), "exocore.operator.v1.DecValueField") @@ -722,76 +722,76 @@ func init() { proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.operator.v1.RegisterOperatorResponse") proto.RegisterType((*OptInToCosmosChainRequest)(nil), "exocore.operator.v1.OptInToCosmosChainRequest") proto.RegisterType((*OptInToCosmosChainResponse)(nil), "exocore.operator.v1.OptInToCosmosChainResponse") - proto.RegisterType((*InitiateOptOutFromCosmosChainRequest)(nil), "exocore.operator.v1.InitiateOptOutFromCosmosChainRequest") - proto.RegisterType((*InitiateOptOutFromCosmosChainResponse)(nil), "exocore.operator.v1.InitiateOptOutFromCosmosChainResponse") + proto.RegisterType((*InitOptOutFromCosmosChainRequest)(nil), "exocore.operator.v1.InitOptOutFromCosmosChainRequest") + proto.RegisterType((*InitOptOutFromCosmosChainResponse)(nil), "exocore.operator.v1.InitOptOutFromCosmosChainResponse") } func init() { proto.RegisterFile("exocore/operator/v1/tx.proto", fileDescriptor_b229d5663e4df167) } var fileDescriptor_b229d5663e4df167 = []byte{ - // 989 bytes of a gzipped FileDescriptorProto + // 985 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0xc6, 0x4e, 0x9a, 0x3c, 0x3b, 0xb5, 0x33, 0xa9, 0x88, 0xb3, 0xb4, 0x76, 0xb2, 0xd0, - 0xe2, 0x46, 0xc4, 0xab, 0x06, 0x38, 0x34, 0x70, 0x20, 0x3f, 0x5a, 0x61, 0x91, 0x62, 0xb4, 0xa9, - 0x7a, 0x80, 0xc3, 0x6a, 0xb3, 0x3b, 0x59, 0x8f, 0x62, 0xef, 0x6c, 0x77, 0xc6, 0x6e, 0x52, 0x09, - 0x09, 0x21, 0x0e, 0x08, 0x09, 0x89, 0x23, 0xdc, 0xfa, 0x27, 0xe4, 0xd0, 0x0b, 0x07, 0xc4, 0xb5, - 0xc7, 0xaa, 0x27, 0xc4, 0x21, 0x42, 0xc9, 0x21, 0x9c, 0xf9, 0x0b, 0xd0, 0xfc, 0xd8, 0xc4, 0x69, - 0x1c, 0x48, 0x69, 0x2e, 0x89, 0xe7, 0x9b, 0xef, 0x7d, 0xef, 0xbd, 0x6f, 0xde, 0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5, 0x7d, + 0xfc, 0x19, 0x25, 0x77, 0x7f, 0x63, 0x4c, 0x7e, 0xd5, 0xbc, 0xff, 0x5f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xde, 0x35, 0xd8, 0x13, 0x67, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -813,12 +813,12 @@ type MsgClient interface { // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. OptInToCosmosChain(ctx context.Context, in *OptInToCosmosChainRequest, opts ...grpc.CallOption) (*OptInToCosmosChainResponse, error) - // InitiateOptOutFromCosmosChain is a method with which an operator can initiate + // InitOptOutFromCosmosChain is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - InitiateOptOutFromCosmosChain(ctx context.Context, in *InitiateOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitiateOptOutFromCosmosChainResponse, error) + InitOptOutFromCosmosChain(ctx context.Context, in *InitOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitOptOutFromCosmosChainResponse, error) } type msgClient struct { @@ -847,9 +847,9 @@ func (c *msgClient) OptInToCosmosChain(ctx context.Context, in *OptInToCosmosCha return out, nil } -func (c *msgClient) InitiateOptOutFromCosmosChain(ctx context.Context, in *InitiateOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitiateOptOutFromCosmosChainResponse, error) { - out := new(InitiateOptOutFromCosmosChainResponse) - err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitiateOptOutFromCosmosChain", in, out, opts...) +func (c *msgClient) InitOptOutFromCosmosChain(ctx context.Context, in *InitOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitOptOutFromCosmosChainResponse, error) { + out := new(InitOptOutFromCosmosChainResponse) + err := c.cc.Invoke(ctx, "/exocore.operator.v1.Msg/InitOptOutFromCosmosChain", in, out, opts...) if err != nil { return nil, err } @@ -865,12 +865,12 @@ type MsgServer interface { // start validatring on a chain. The operator must sign the request with // the key with which they registered in the system. OptInToCosmosChain(context.Context, *OptInToCosmosChainRequest) (*OptInToCosmosChainResponse, error) - // InitiateOptOutFromCosmosChain is a method with which an operator can initiate + // InitOptOutFromCosmosChain is a method with which an operator can initiate // the opt out process from a chain. The operator must sign the request with // the key with which they registered in the system. The opt-out process takes // as long as the chain's unbonding period to complete, plus some loose change // for message relaying across chains. - InitiateOptOutFromCosmosChain(context.Context, *InitiateOptOutFromCosmosChainRequest) (*InitiateOptOutFromCosmosChainResponse, error) + InitOptOutFromCosmosChain(context.Context, *InitOptOutFromCosmosChainRequest) (*InitOptOutFromCosmosChainResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -883,8 +883,8 @@ func (*UnimplementedMsgServer) RegisterOperator(ctx context.Context, req *Regist func (*UnimplementedMsgServer) OptInToCosmosChain(ctx context.Context, req *OptInToCosmosChainRequest) (*OptInToCosmosChainResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OptInToCosmosChain not implemented") } -func (*UnimplementedMsgServer) InitiateOptOutFromCosmosChain(ctx context.Context, req *InitiateOptOutFromCosmosChainRequest) (*InitiateOptOutFromCosmosChainResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method InitiateOptOutFromCosmosChain not implemented") +func (*UnimplementedMsgServer) InitOptOutFromCosmosChain(ctx context.Context, req *InitOptOutFromCosmosChainRequest) (*InitOptOutFromCosmosChainResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InitOptOutFromCosmosChain not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -927,20 +927,20 @@ func _Msg_OptInToCosmosChain_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Msg_InitiateOptOutFromCosmosChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InitiateOptOutFromCosmosChainRequest) +func _Msg_InitOptOutFromCosmosChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InitOptOutFromCosmosChainRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).InitiateOptOutFromCosmosChain(ctx, in) + return srv.(MsgServer).InitOptOutFromCosmosChain(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/exocore.operator.v1.Msg/InitiateOptOutFromCosmosChain", + FullMethod: "/exocore.operator.v1.Msg/InitOptOutFromCosmosChain", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).InitiateOptOutFromCosmosChain(ctx, req.(*InitiateOptOutFromCosmosChainRequest)) + return srv.(MsgServer).InitOptOutFromCosmosChain(ctx, req.(*InitOptOutFromCosmosChainRequest)) } return interceptor(ctx, in, info, handler) } @@ -958,8 +958,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_OptInToCosmosChain_Handler, }, { - MethodName: "InitiateOptOutFromCosmosChain", - Handler: _Msg_InitiateOptOutFromCosmosChain_Handler, + MethodName: "InitOptOutFromCosmosChain", + Handler: _Msg_InitOptOutFromCosmosChain_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -1407,7 +1407,7 @@ func (m *OptInToCosmosChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *InitiateOptOutFromCosmosChainRequest) Marshal() (dAtA []byte, err error) { +func (m *InitOptOutFromCosmosChainRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1417,12 +1417,12 @@ func (m *InitiateOptOutFromCosmosChainRequest) Marshal() (dAtA []byte, err error return dAtA[:n], nil } -func (m *InitiateOptOutFromCosmosChainRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *InitOptOutFromCosmosChainRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InitiateOptOutFromCosmosChainRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InitOptOutFromCosmosChainRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1444,7 +1444,7 @@ func (m *InitiateOptOutFromCosmosChainRequest) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *InitiateOptOutFromCosmosChainResponse) Marshal() (dAtA []byte, err error) { +func (m *InitOptOutFromCosmosChainResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1454,12 +1454,12 @@ func (m *InitiateOptOutFromCosmosChainResponse) Marshal() (dAtA []byte, err erro return dAtA[:n], nil } -func (m *InitiateOptOutFromCosmosChainResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *InitOptOutFromCosmosChainResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InitiateOptOutFromCosmosChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *InitOptOutFromCosmosChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1660,7 +1660,7 @@ func (m *OptInToCosmosChainResponse) Size() (n int) { return n } -func (m *InitiateOptOutFromCosmosChainRequest) Size() (n int) { +func (m *InitOptOutFromCosmosChainRequest) Size() (n int) { if m == nil { return 0 } @@ -1677,7 +1677,7 @@ func (m *InitiateOptOutFromCosmosChainRequest) Size() (n int) { return n } -func (m *InitiateOptOutFromCosmosChainResponse) Size() (n int) { +func (m *InitOptOutFromCosmosChainResponse) Size() (n int) { if m == nil { return 0 } @@ -2938,7 +2938,7 @@ func (m *OptInToCosmosChainResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *InitiateOptOutFromCosmosChainRequest) Unmarshal(dAtA []byte) error { +func (m *InitOptOutFromCosmosChainRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2961,10 +2961,10 @@ func (m *InitiateOptOutFromCosmosChainRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InitiateOptOutFromCosmosChainRequest: wiretype end group for non-group") + return fmt.Errorf("proto: InitOptOutFromCosmosChainRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InitiateOptOutFromCosmosChainRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InitOptOutFromCosmosChainRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3052,7 +3052,7 @@ func (m *InitiateOptOutFromCosmosChainRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *InitiateOptOutFromCosmosChainResponse) Unmarshal(dAtA []byte) error { +func (m *InitOptOutFromCosmosChainResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3075,10 +3075,10 @@ func (m *InitiateOptOutFromCosmosChainResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InitiateOptOutFromCosmosChainResponse: wiretype end group for non-group") + return fmt.Errorf("proto: InitOptOutFromCosmosChainResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InitiateOptOutFromCosmosChainResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: InitOptOutFromCosmosChainResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 4596ca682981c64ef36e5dae40811d0ae504ea47 Mon Sep 17 00:00:00 2001 From: TimmyExogenous Date: Wed, 20 Mar 2024 11:11:55 +0800 Subject: [PATCH 44/44] remove the unnecessary code related to operator from the delegation proto file --- proto/exocore/delegation/v1/query.proto | 7 - proto/exocore/delegation/v1/tx.proto | 43 - x/delegation/types/query.pb.go | 257 +---- x/delegation/types/tx.pb.go | 1364 +++-------------------- 4 files changed, 183 insertions(+), 1488 deletions(-) diff --git a/proto/exocore/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index 4f671a764..3a4632128 100644 --- a/proto/exocore/delegation/v1/query.proto +++ b/proto/exocore/delegation/v1/query.proto @@ -66,13 +66,6 @@ message SingleDelegationInfoReq { string asset_id = 3 [(gogoproto.customname) = "AssetID"]; } -// QueryOperatorInfoReq is the request to obtain the operator information. -message QueryOperatorInfoReq { - // operator_addr is the operator address. - string operator_addr = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; -} - // Query is the service API for the delegation module. service Query { // DelegationInfo queries the delegation information for {stakerID, assetID}. diff --git a/proto/exocore/delegation/v1/tx.proto b/proto/exocore/delegation/v1/tx.proto index b4cdb98c9..53bee0531 100644 --- a/proto/exocore/delegation/v1/tx.proto +++ b/proto/exocore/delegation/v1/tx.proto @@ -35,46 +35,6 @@ message DelegatedSingleAssetInfo { map per_operator_amounts = 3; } -// ClientChainEarningAddrList is the list of client chain earning addresses. -message ClientChainEarningAddrList { - // earning_info_list is the contents of ClientChainEarningAddrList. - repeated ClientChainEarningAddrInfo earning_info_list = 1; -} - -// ClientChainEarningAddrInfo is the client chain earning address info. -message ClientChainEarningAddrInfo { - // lz_client_chain_id is the layer0 client chain id. - uint64 lz_client_chain_id = 1 [(gogoproto.customname) = "LzClientChainID"]; - // client_chain_earning_addr is the client chain earning address. - string client_chain_earning_addr = 2; -} - -// OperatorInfo is the operator info. -message OperatorInfo { - // earnings_addr is the earnings address. - string earnings_addr = 1; - // approve_addr is the approve address. - string approve_addr = 2; - // operator_meta_info is the operator meta info. - string operator_meta_info = 3; - // client_chain_earning_addr_list is the client chain earning address list. - ClientChainEarningAddrList client_chain_earnings_addr = 4; -} - -// RegisterOperatorReq is the request to register a new operator. -message RegisterOperatorReq { - option (cosmos.msg.v1.signer) = "FromAddress"; - option (amino.name) = "cosmos-sdk/OperatorInfo"; - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // from_address is the address of the operator (sdk.AccAddress). - string from_address = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // info is the operator info. - OperatorInfo info = 2; -} - // DelegationApproveInfo is the delegation approve info. message DelegationApproveInfo { // signature of the delegation approve info. @@ -83,9 +43,6 @@ message DelegationApproveInfo { string salt = 2; } -// RegisterOperatorResponse is the response to a register operator request. -message RegisterOperatorResponse {} - // DelegationIncOrDecInfo is the delegation increase or decrease info. message DelegationIncOrDecInfo { option (cosmos.msg.v1.signer) = "fromAddress"; diff --git a/x/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index cd6a93b26..41d4982f9 100644 --- a/x/delegation/types/query.pb.go +++ b/x/delegation/types/query.pb.go @@ -244,107 +244,59 @@ func (m *SingleDelegationInfoReq) GetAssetID() string { return "" } -// QueryOperatorInfoReq is the request to obtain the operator information. -type QueryOperatorInfoReq struct { - // operator_addr is the operator address. - OperatorAddr string `protobuf:"bytes,1,opt,name=operator_addr,json=operatorAddr,proto3" json:"operator_addr,omitempty"` -} - -func (m *QueryOperatorInfoReq) Reset() { *m = QueryOperatorInfoReq{} } -func (m *QueryOperatorInfoReq) String() string { return proto.CompactTextString(m) } -func (*QueryOperatorInfoReq) ProtoMessage() {} -func (*QueryOperatorInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_aab345e1cf20490c, []int{4} -} -func (m *QueryOperatorInfoReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryOperatorInfoReq.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 *QueryOperatorInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOperatorInfoReq.Merge(m, src) -} -func (m *QueryOperatorInfoReq) XXX_Size() int { - return m.Size() -} -func (m *QueryOperatorInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOperatorInfoReq.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryOperatorInfoReq proto.InternalMessageInfo - -func (m *QueryOperatorInfoReq) GetOperatorAddr() string { - if m != nil { - return m.OperatorAddr - } - return "" -} - func init() { proto.RegisterType((*DelegationInfoReq)(nil), "exocore.delegation.v1.DelegationInfoReq") 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((*QueryOperatorInfoReq)(nil), "exocore.delegation.v1.QueryOperatorInfoReq") } func init() { proto.RegisterFile("exocore/delegation/v1/query.proto", fileDescriptor_aab345e1cf20490c) } var fileDescriptor_aab345e1cf20490c = []byte{ - // 667 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x4f, 0x13, 0x4f, - 0x1c, 0xee, 0x6e, 0xc3, 0x1f, 0x18, 0xf8, 0x47, 0x1c, 0x2a, 0x94, 0x62, 0x5a, 0xdc, 0x03, 0xa9, - 0x24, 0xec, 0x4a, 0xd5, 0xc4, 0x18, 0x31, 0x81, 0x94, 0x90, 0xbd, 0x60, 0xdc, 0x86, 0x8b, 0x97, - 0xcd, 0xc0, 0x4e, 0x97, 0x4d, 0x97, 0x99, 0x32, 0x33, 0x2d, 0xf4, 0xea, 0xc9, 0xa3, 0x89, 0xdf, - 0x42, 0x2f, 0x1e, 0xf8, 0x10, 0x1c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d, 0x9c, 0x9e, 0x67, 0x13, 0x9f, - 0xcf, 0xb3, 0x89, 0x57, 0x8f, 0x3a, 0x4e, 0x77, 0x23, 0x46, 0xdd, 0xc2, 0xe2, 0x90, 0xb2, 0xca, - 0x05, 0xc9, 0x51, 0x27, 0x8d, 0x3c, 0xe6, 0x9d, 0xff, 0xe4, 0x07, 0xe2, 0xe1, 0xef, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xa3, 0xe7, 0x09, 0xae, 0xc8, 0x06, 0x00, 0x00, + // 652 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0xee, 0x6e, 0x83, 0xc0, 0x80, 0x11, 0x87, 0x0a, 0xa5, 0x98, 0x2d, 0xee, 0x81, 0x54, 0x12, + 0x76, 0xa5, 0x6a, 0x62, 0x8c, 0x98, 0x40, 0x4a, 0xc8, 0x5e, 0x48, 0xdc, 0xc6, 0x8b, 0x97, 0xcd, + 0xc0, 0x4e, 0x97, 0x4d, 0x97, 0x99, 0x32, 0x33, 0x2d, 0xf4, 0xea, 0xc9, 0xa3, 0x89, 0xff, 0x85, + 0x5e, 0x3c, 0xf0, 0x47, 0x70, 0x24, 0x78, 0x31, 0x1e, 0x1a, 0x53, 0x4c, 0x3c, 0x78, 0x34, 0xf1, + 0x6c, 0x76, 0x76, 0x80, 0xb6, 0x76, 0xfd, 0x11, 0x39, 0xed, 0xee, 0xfb, 0xf1, 0x7d, 0xef, 0x7d, + 0xef, 0xbd, 0x05, 0x77, 0xf0, 0x21, 0xdd, 0xa1, 0x0c, 0xdb, 0x3e, 0x8e, 0x70, 0x80, 0x44, 0x48, + 0x89, 0xdd, 0x5a, 0xb1, 0xf7, 0x9b, 0x98, 0xb5, 0xad, 0x06, 0xa3, 0x82, 0xc2, 0x5b, 0x2a, 0xc4, + 0xba, 0x0c, 0xb1, 0x5a, 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x86, 0x39, 0xaf, 0x0a, 0x16, 0x92, 0xc0, 0x9d, 0x3c, 0x0f, 0x8f, 0xcd, 0x7d, 0xc7, 0x99, + 0x4d, 0x3f, 0xce, 0xf2, 0x37, 0x1d, 0x8c, 0x48, 0x85, 0xe1, 0x5b, 0x0d, 0x4c, 0x0f, 0xd1, 0x1a, + 0xfe, 0x59, 0x04, 0xd5, 0x5d, 0xa1, 0xfc, 0xef, 0x13, 0x34, 0x1f, 0xbe, 0xfa, 0xfa, 0x7e, 0x49, + 0x7b, 0xf9, 0xe1, 0xcb, 0x1b, 0x7d, 0x09, 0x96, 0xec, 0xe1, 0x3f, 0xce, 0x4d, 0x2c, 0x06, 0x8a, + 0x3a, 0xd2, 0xc0, 0x9c, 0x84, 0x1d, 0xa6, 0x34, 0xb4, 0x52, 0x0a, 0x49, 0x19, 0x4b, 0xe1, 0xaf, + 0xe7, 0x6c, 0xae, 0x5e, 0x96, 0x5b, 0x86, 0xf7, 0x52, 0xca, 0x4d, 0x2d, 0x6c, 0x7d, 0xeb, 0xb8, + 0x6b, 0x68, 0x27, 0x5d, 0x43, 0xfb, 0xdc, 0x35, 0xb4, 0xd7, 0x67, 0x46, 0xe6, 0xe4, 0xcc, 0xc8, + 0x7c, 0x3c, 0x33, 0x32, 0x2f, 0x1e, 0xf4, 0xdc, 0xd8, 0x46, 0x82, 0xba, 0x85, 0xc5, 0x01, 0x65, + 0xf5, 0x0b, 0x92, 0xc3, 0x5e, 0x1a, 0x79, 0x75, 0xdb, 0xd7, 0xe4, 0x9f, 0xfc, 0xfe, 0xcf, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xa7, 0x4f, 0x91, 0x6a, 0x71, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -662,36 +614,6 @@ func (m *SingleDelegationInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryOperatorInfoReq) 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 *QueryOperatorInfoReq) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryOperatorInfoReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - 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] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -780,19 +702,6 @@ func (m *SingleDelegationInfoReq) Size() (n int) { return n } -func (m *QueryOperatorInfoReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1424,88 +1333,6 @@ func (m *SingleDelegationInfoReq) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOperatorInfoReq) 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: QueryOperatorInfoReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOperatorInfoReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 - 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 diff --git a/x/delegation/types/tx.pb.go b/x/delegation/types/tx.pb.go index 030d187a4..d9d9b36a2 100644 --- a/x/delegation/types/tx.pb.go +++ b/x/delegation/types/tx.pb.go @@ -128,221 +128,6 @@ func (m *DelegatedSingleAssetInfo) GetPerOperatorAmounts() map[string]*ValueFiel return nil } -// ClientChainEarningAddrList is the list of client chain earning addresses. -type ClientChainEarningAddrList struct { - // earning_info_list is the contents of ClientChainEarningAddrList. - EarningInfoList []*ClientChainEarningAddrInfo `protobuf:"bytes,1,rep,name=earning_info_list,json=earningInfoList,proto3" json:"earning_info_list,omitempty"` -} - -func (m *ClientChainEarningAddrList) Reset() { *m = ClientChainEarningAddrList{} } -func (m *ClientChainEarningAddrList) String() string { return proto.CompactTextString(m) } -func (*ClientChainEarningAddrList) ProtoMessage() {} -func (*ClientChainEarningAddrList) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{2} -} -func (m *ClientChainEarningAddrList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ClientChainEarningAddrList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ClientChainEarningAddrList.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 *ClientChainEarningAddrList) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientChainEarningAddrList.Merge(m, src) -} -func (m *ClientChainEarningAddrList) XXX_Size() int { - return m.Size() -} -func (m *ClientChainEarningAddrList) XXX_DiscardUnknown() { - xxx_messageInfo_ClientChainEarningAddrList.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientChainEarningAddrList proto.InternalMessageInfo - -func (m *ClientChainEarningAddrList) GetEarningInfoList() []*ClientChainEarningAddrInfo { - if m != nil { - return m.EarningInfoList - } - return nil -} - -// ClientChainEarningAddrInfo is the client chain earning address info. -type ClientChainEarningAddrInfo struct { - // lz_client_chain_id is the layer0 client chain id. - LzClientChainID uint64 `protobuf:"varint,1,opt,name=lz_client_chain_id,json=lzClientChainId,proto3" json:"lz_client_chain_id,omitempty"` - // client_chain_earning_addr is the client chain earning address. - ClientChainEarningAddr string `protobuf:"bytes,2,opt,name=client_chain_earning_addr,json=clientChainEarningAddr,proto3" json:"client_chain_earning_addr,omitempty"` -} - -func (m *ClientChainEarningAddrInfo) Reset() { *m = ClientChainEarningAddrInfo{} } -func (m *ClientChainEarningAddrInfo) String() string { return proto.CompactTextString(m) } -func (*ClientChainEarningAddrInfo) ProtoMessage() {} -func (*ClientChainEarningAddrInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{3} -} -func (m *ClientChainEarningAddrInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ClientChainEarningAddrInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ClientChainEarningAddrInfo.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 *ClientChainEarningAddrInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientChainEarningAddrInfo.Merge(m, src) -} -func (m *ClientChainEarningAddrInfo) XXX_Size() int { - return m.Size() -} -func (m *ClientChainEarningAddrInfo) XXX_DiscardUnknown() { - xxx_messageInfo_ClientChainEarningAddrInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientChainEarningAddrInfo proto.InternalMessageInfo - -func (m *ClientChainEarningAddrInfo) GetLzClientChainID() uint64 { - if m != nil { - return m.LzClientChainID - } - return 0 -} - -func (m *ClientChainEarningAddrInfo) GetClientChainEarningAddr() string { - if m != nil { - return m.ClientChainEarningAddr - } - return "" -} - -// OperatorInfo is the operator info. -type OperatorInfo struct { - // earnings_addr is the earnings address. - EarningsAddr string `protobuf:"bytes,1,opt,name=earnings_addr,json=earningsAddr,proto3" json:"earnings_addr,omitempty"` - // approve_addr is the approve address. - ApproveAddr string `protobuf:"bytes,2,opt,name=approve_addr,json=approveAddr,proto3" json:"approve_addr,omitempty"` - // operator_meta_info is the operator meta info. - OperatorMetaInfo string `protobuf:"bytes,3,opt,name=operator_meta_info,json=operatorMetaInfo,proto3" json:"operator_meta_info,omitempty"` - // client_chain_earning_addr_list is the client chain earning address list. - ClientChainEarningsAddr *ClientChainEarningAddrList `protobuf:"bytes,4,opt,name=client_chain_earnings_addr,json=clientChainEarningsAddr,proto3" json:"client_chain_earnings_addr,omitempty"` -} - -func (m *OperatorInfo) Reset() { *m = OperatorInfo{} } -func (m *OperatorInfo) String() string { return proto.CompactTextString(m) } -func (*OperatorInfo) ProtoMessage() {} -func (*OperatorInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{4} -} -func (m *OperatorInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OperatorInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_OperatorInfo.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 *OperatorInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_OperatorInfo.Merge(m, src) -} -func (m *OperatorInfo) XXX_Size() int { - return m.Size() -} -func (m *OperatorInfo) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_OperatorInfo proto.InternalMessageInfo - -func (m *OperatorInfo) GetEarningsAddr() string { - if m != nil { - return m.EarningsAddr - } - return "" -} - -func (m *OperatorInfo) GetApproveAddr() string { - if m != nil { - return m.ApproveAddr - } - return "" -} - -func (m *OperatorInfo) GetOperatorMetaInfo() string { - if m != nil { - return m.OperatorMetaInfo - } - return "" -} - -func (m *OperatorInfo) GetClientChainEarningsAddr() *ClientChainEarningAddrList { - if m != nil { - return m.ClientChainEarningsAddr - } - return nil -} - -// RegisterOperatorReq is the request to register a new operator. -type RegisterOperatorReq struct { - // from_address is the address of the operator (sdk.AccAddress). - FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` - // info is the operator info. - Info *OperatorInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` -} - -func (m *RegisterOperatorReq) Reset() { *m = RegisterOperatorReq{} } -func (m *RegisterOperatorReq) String() string { return proto.CompactTextString(m) } -func (*RegisterOperatorReq) ProtoMessage() {} -func (*RegisterOperatorReq) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{5} -} -func (m *RegisterOperatorReq) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RegisterOperatorReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RegisterOperatorReq.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 *RegisterOperatorReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_RegisterOperatorReq.Merge(m, src) -} -func (m *RegisterOperatorReq) XXX_Size() int { - return m.Size() -} -func (m *RegisterOperatorReq) XXX_DiscardUnknown() { - xxx_messageInfo_RegisterOperatorReq.DiscardUnknown(m) -} - -var xxx_messageInfo_RegisterOperatorReq proto.InternalMessageInfo - // DelegationApproveInfo is the delegation approve info. type DelegationApproveInfo struct { // signature of the delegation approve info. @@ -355,7 +140,7 @@ func (m *DelegationApproveInfo) Reset() { *m = DelegationApproveInfo{} } func (m *DelegationApproveInfo) String() string { return proto.CompactTextString(m) } func (*DelegationApproveInfo) ProtoMessage() {} func (*DelegationApproveInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{6} + return fileDescriptor_16596a15a828f109, []int{2} } func (m *DelegationApproveInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -398,43 +183,6 @@ func (m *DelegationApproveInfo) GetSalt() string { return "" } -// RegisterOperatorResponse is the response to a register operator request. -type RegisterOperatorResponse struct { -} - -func (m *RegisterOperatorResponse) Reset() { *m = RegisterOperatorResponse{} } -func (m *RegisterOperatorResponse) String() string { return proto.CompactTextString(m) } -func (*RegisterOperatorResponse) ProtoMessage() {} -func (*RegisterOperatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{7} -} -func (m *RegisterOperatorResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RegisterOperatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RegisterOperatorResponse.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 *RegisterOperatorResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RegisterOperatorResponse.Merge(m, src) -} -func (m *RegisterOperatorResponse) XXX_Size() int { - return m.Size() -} -func (m *RegisterOperatorResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RegisterOperatorResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_RegisterOperatorResponse proto.InternalMessageInfo - // DelegationIncOrDecInfo is the delegation increase or decrease info. type DelegationIncOrDecInfo struct { // from_address is the staker address @@ -447,7 +195,7 @@ func (m *DelegationIncOrDecInfo) Reset() { *m = DelegationIncOrDecInfo{} func (m *DelegationIncOrDecInfo) String() string { return proto.CompactTextString(m) } func (*DelegationIncOrDecInfo) ProtoMessage() {} func (*DelegationIncOrDecInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{8} + return fileDescriptor_16596a15a828f109, []int{3} } func (m *DelegationIncOrDecInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -488,7 +236,7 @@ func (m *MsgDelegation) Reset() { *m = MsgDelegation{} } func (m *MsgDelegation) String() string { return proto.CompactTextString(m) } func (*MsgDelegation) ProtoMessage() {} func (*MsgDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{9} + return fileDescriptor_16596a15a828f109, []int{4} } func (m *MsgDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -561,7 +309,7 @@ func (m *UndelegationRecord) Reset() { *m = UndelegationRecord{} } func (m *UndelegationRecord) String() string { return proto.CompactTextString(m) } func (*UndelegationRecord) ProtoMessage() {} func (*UndelegationRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{10} + return fileDescriptor_16596a15a828f109, []int{5} } func (m *UndelegationRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -656,7 +404,7 @@ func (m *UndelegationRecordKeyList) Reset() { *m = UndelegationRecordKey func (m *UndelegationRecordKeyList) String() string { return proto.CompactTextString(m) } func (*UndelegationRecordKeyList) ProtoMessage() {} func (*UndelegationRecordKeyList) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{11} + return fileDescriptor_16596a15a828f109, []int{6} } func (m *UndelegationRecordKeyList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -700,7 +448,7 @@ func (m *DelegationResponse) Reset() { *m = DelegationResponse{} } func (m *DelegationResponse) String() string { return proto.CompactTextString(m) } func (*DelegationResponse) ProtoMessage() {} func (*DelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{12} + return fileDescriptor_16596a15a828f109, []int{7} } func (m *DelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -739,7 +487,7 @@ func (m *MsgUndelegation) Reset() { *m = MsgUndelegation{} } func (m *MsgUndelegation) String() string { return proto.CompactTextString(m) } func (*MsgUndelegation) ProtoMessage() {} func (*MsgUndelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{13} + return fileDescriptor_16596a15a828f109, []int{8} } func (m *MsgUndelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -783,7 +531,7 @@ func (m *UndelegationResponse) Reset() { *m = UndelegationResponse{} } func (m *UndelegationResponse) String() string { return proto.CompactTextString(m) } func (*UndelegationResponse) ProtoMessage() {} func (*UndelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_16596a15a828f109, []int{14} + return fileDescriptor_16596a15a828f109, []int{9} } func (m *UndelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -816,12 +564,7 @@ func init() { proto.RegisterType((*ValueField)(nil), "exocore.delegation.v1.ValueField") proto.RegisterType((*DelegatedSingleAssetInfo)(nil), "exocore.delegation.v1.DelegatedSingleAssetInfo") proto.RegisterMapType((map[string]*ValueField)(nil), "exocore.delegation.v1.DelegatedSingleAssetInfo.PerOperatorAmountsEntry") - proto.RegisterType((*ClientChainEarningAddrList)(nil), "exocore.delegation.v1.ClientChainEarningAddrList") - proto.RegisterType((*ClientChainEarningAddrInfo)(nil), "exocore.delegation.v1.ClientChainEarningAddrInfo") - proto.RegisterType((*OperatorInfo)(nil), "exocore.delegation.v1.OperatorInfo") - proto.RegisterType((*RegisterOperatorReq)(nil), "exocore.delegation.v1.RegisterOperatorReq") proto.RegisterType((*DelegationApproveInfo)(nil), "exocore.delegation.v1.DelegationApproveInfo") - proto.RegisterType((*RegisterOperatorResponse)(nil), "exocore.delegation.v1.RegisterOperatorResponse") proto.RegisterType((*DelegationIncOrDecInfo)(nil), "exocore.delegation.v1.DelegationIncOrDecInfo") proto.RegisterMapType((map[string]*ValueField)(nil), "exocore.delegation.v1.DelegationIncOrDecInfo.PerOperatorAmountsEntry") proto.RegisterType((*MsgDelegation)(nil), "exocore.delegation.v1.MsgDelegation") @@ -835,82 +578,67 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/tx.proto", fileDescriptor_16596a15a828f109) } var fileDescriptor_16596a15a828f109 = []byte{ - // 1187 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xc6, 0x69, 0x62, 0x3f, 0x3b, 0x4a, 0x3b, 0x75, 0x62, 0xc7, 0x80, 0xdd, 0x6e, 0xa1, - 0x6a, 0x4b, 0x63, 0xab, 0xa1, 0xa2, 0x50, 0x40, 0x22, 0x89, 0x53, 0x30, 0x34, 0x69, 0xd9, 0x04, - 0x0e, 0x48, 0xd5, 0x6a, 0xbd, 0x3b, 0x59, 0x2f, 0x5e, 0xcf, 0x98, 0x9d, 0x71, 0x6a, 0x87, 0x0b, - 0xe2, 0x84, 0x38, 0x71, 0x45, 0x5c, 0xca, 0x17, 0x40, 0x39, 0xf4, 0x0b, 0x70, 0xeb, 0xb1, 0xea, - 0x09, 0x71, 0x88, 0x90, 0x73, 0x08, 0x07, 0x8e, 0x1c,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 0xff, 0xff, 0x48, 0x50, 0x09, 0xb1, 0x31, - 0x0c, 0x00, 0x00, + // 959 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0x8e, 0x9b, 0xb6, 0x49, 0x5e, 0x52, 0x01, 0x43, 0xda, 0xa4, 0x01, 0x92, 0xae, 0x05, 0x55, + 0xb6, 0xd0, 0x44, 0x1b, 0x10, 0xa0, 0x05, 0x0e, 0x29, 0xe9, 0x42, 0x80, 0x76, 0x17, 0xb7, 0x70, + 0x40, 0x42, 0x96, 0x63, 0x4f, 0x1d, 0x13, 0xdb, 0x63, 0xcd, 0x4c, 0xba, 0xc9, 0x9e, 0x10, 0x27, + 0xc4, 0x89, 0x3b, 0x97, 0xe5, 0x0f, 0xa0, 0x1e, 0xf6, 0x47, 0xec, 0x71, 0xb5, 0x27, 0xc4, 0xa1, + 0x42, 0xe9, 0xa1, 0x1c, 0xf8, 0x09, 0x1c, 0x90, 0x67, 0xec, 0xc4, 0x65, 0x37, 0x5b, 0x21, 0xf5, + 0xb0, 0x97, 0xc4, 0xf3, 0xde, 0x9b, 0xef, 0x7b, 0x6f, 0xbe, 0xe7, 0xe7, 0x81, 0x2a, 0x1e, 0x11, + 0x93, 0x50, 0xdc, 0xb4, 0xb0, 0x8b, 0x6d, 0x83, 0x3b, 0xc4, 0x6f, 0x1e, 0xdf, 0x68, 0xf2, 0x51, + 0x23, 0xa0, 0x84, 0x13, 0xb4, 0x1a, 0xf9, 0x1b, 0x33, 0x7f, 0xe3, 0xf8, 0x46, 0xe5, 0x25, 0xc3, + 0x73, 0x7c, 0xd2, 0x14, 0xbf, 0x32, 0xb2, 0x52, 0x32, 0x09, 0xf3, 0x08, 0x6b, 0x7a, 0xcc, 0x0e, + 0x11, 0x3c, 0x66, 0x47, 0x8e, 0x75, 0xe9, 0xd0, 0xc5, 0xa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1, 0xa4, 0xaa, 0xfc, 0x39, 0xa9, 0x2a, 0x3f, 0x9f, 0x55, 0x53, 0x8f, 0xce, 0xaa, + 0xa9, 0xdf, 0xcf, 0xaa, 0xa9, 0x6f, 0xde, 0x49, 0xb4, 0xc6, 0xae, 0xc4, 0xdd, 0xc7, 0xfc, 0x2e, + 0xa1, 0x83, 0x66, 0x7c, 0x39, 0x1a, 0x25, 0xaf, 0x47, 0xa2, 0x59, 0x7a, 0xcb, 0xe2, 0xae, 0xf2, + 0xf6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xd3, 0x67, 0x2f, 0x41, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1132,7 +860,7 @@ func (m *DelegatedSingleAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *ClientChainEarningAddrList) Marshal() (dAtA []byte, err error) { +func (m *DelegationApproveInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1142,34 +870,34 @@ func (m *ClientChainEarningAddrList) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ClientChainEarningAddrList) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegationApproveInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ClientChainEarningAddrList) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegationApproveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.EarningInfoList) > 0 { - for iNdEx := len(m.EarningInfoList) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.EarningInfoList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if len(m.Salt) > 0 { + i -= len(m.Salt) + copy(dAtA[i:], m.Salt) + i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ClientChainEarningAddrInfo) Marshal() (dAtA []byte, err error) { +func (m *DelegationIncOrDecInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1179,32 +907,53 @@ func (m *ClientChainEarningAddrInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ClientChainEarningAddrInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegationIncOrDecInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ClientChainEarningAddrInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegationIncOrDecInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ClientChainEarningAddr) > 0 { - i -= len(m.ClientChainEarningAddr) - copy(dAtA[i:], m.ClientChainEarningAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientChainEarningAddr))) - i-- - dAtA[i] = 0x12 + if len(m.PerOperatorAmounts) > 0 { + for k := range m.PerOperatorAmounts { + v := m.PerOperatorAmounts[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintTx(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintTx(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } } - if m.LzClientChainID != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.LzClientChainID)) + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *OperatorInfo) Marshal() (dAtA []byte, err error) { +func (m *MsgDelegation) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1214,19 +963,19 @@ func (m *OperatorInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDelegation) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.ClientChainEarningsAddr != nil { + if m.ApprovedInfo != nil { { - size, err := m.ClientChainEarningsAddr.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ApprovedInfo.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1234,33 +983,24 @@ func (m *OperatorInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - } - if len(m.OperatorMetaInfo) > 0 { - i -= len(m.OperatorMetaInfo) - copy(dAtA[i:], m.OperatorMetaInfo) - i = encodeVarintTx(dAtA, i, uint64(len(m.OperatorMetaInfo))) - i-- - dAtA[i] = 0x1a - } - if len(m.ApproveAddr) > 0 { - i -= len(m.ApproveAddr) - copy(dAtA[i:], m.ApproveAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ApproveAddr))) - i-- dAtA[i] = 0x12 } - if len(m.EarningsAddr) > 0 { - i -= len(m.EarningsAddr) - copy(dAtA[i:], m.EarningsAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.EarningsAddr))) + if m.BaseInfo != nil { + { + size, err := m.BaseInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *RegisterOperatorReq) Marshal() (dAtA []byte, err error) { +func (m *UndelegationRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1270,228 +1010,23 @@ func (m *RegisterOperatorReq) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RegisterOperatorReq) MarshalTo(dAtA []byte) (int, error) { +func (m *UndelegationRecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *RegisterOperatorReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *UndelegationRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Info != nil { - { - size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + { + size := m.ActualCompletedAmount.Size() + i -= size + if _, err := m.ActualCompletedAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 - } - if len(m.FromAddress) > 0 { - i -= len(m.FromAddress) - copy(dAtA[i:], m.FromAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DelegationApproveInfo) 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 *DelegationApproveInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationApproveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Salt) > 0 { - i -= len(m.Salt) - copy(dAtA[i:], m.Salt) - i = encodeVarintTx(dAtA, i, uint64(len(m.Salt))) - i-- - dAtA[i] = 0x12 - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RegisterOperatorResponse) 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 *RegisterOperatorResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RegisterOperatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *DelegationIncOrDecInfo) 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 *DelegationIncOrDecInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationIncOrDecInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PerOperatorAmounts) > 0 { - for k := range m.PerOperatorAmounts { - v := m.PerOperatorAmounts[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintTx(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintTx(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x12 - } - } - if len(m.FromAddress) > 0 { - i -= len(m.FromAddress) - copy(dAtA[i:], m.FromAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgDelegation) 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 *MsgDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ApprovedInfo != nil { - { - size, err := m.ApprovedInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.BaseInfo != nil { - { - size, err := m.BaseInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UndelegationRecord) 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 *UndelegationRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UndelegationRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.ActualCompletedAmount.Size() - i -= size - if _, err := m.ActualCompletedAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x52 @@ -1724,79 +1259,6 @@ func (m *DelegatedSingleAssetInfo) Size() (n int) { return n } -func (m *ClientChainEarningAddrList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.EarningInfoList) > 0 { - for _, e := range m.EarningInfoList { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *ClientChainEarningAddrInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.LzClientChainID != 0 { - n += 1 + sovTx(uint64(m.LzClientChainID)) - } - l = len(m.ClientChainEarningAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *OperatorInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.EarningsAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ApproveAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.OperatorMetaInfo) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.ClientChainEarningsAddr != nil { - l = m.ClientChainEarningsAddr.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *RegisterOperatorReq) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FromAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Info != nil { - l = m.Info.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - func (m *DelegationApproveInfo) Size() (n int) { if m == nil { return 0 @@ -1814,15 +1276,6 @@ func (m *DelegationApproveInfo) Size() (n int) { return n } -func (m *RegisterOperatorResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *DelegationIncOrDecInfo) Size() (n int) { if m == nil { return 0 @@ -2288,491 +1741,6 @@ func (m *DelegatedSingleAssetInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *ClientChainEarningAddrList) 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 ErrIntOverflowTx - } - 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: ClientChainEarningAddrList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ClientChainEarningAddrList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EarningInfoList", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EarningInfoList = append(m.EarningInfoList, &ClientChainEarningAddrInfo{}) - if err := m.EarningInfoList[len(m.EarningInfoList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ClientChainEarningAddrInfo) 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 ErrIntOverflowTx - } - 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: ClientChainEarningAddrInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ClientChainEarningAddrInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LzClientChainID", wireType) - } - m.LzClientChainID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LzClientChainID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientChainEarningAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientChainEarningAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *OperatorInfo) 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 ErrIntOverflowTx - } - 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: OperatorInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: OperatorInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EarningsAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EarningsAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApproveAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ApproveAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorMetaInfo", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OperatorMetaInfo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientChainEarningsAddr", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ClientChainEarningsAddr == nil { - m.ClientChainEarningsAddr = &ClientChainEarningAddrList{} - } - if err := m.ClientChainEarningsAddr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RegisterOperatorReq) 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 ErrIntOverflowTx - } - 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: RegisterOperatorReq: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegisterOperatorReq: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FromAddress = 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Info == nil { - m.Info = &OperatorInfo{} - } - if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *DelegationApproveInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2887,56 +1855,6 @@ func (m *DelegationApproveInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *RegisterOperatorResponse) 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 ErrIntOverflowTx - } - 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: RegisterOperatorResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegisterOperatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *DelegationIncOrDecInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0