diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 8ceef65bc..56a561ef6 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -34,7 +34,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 641838a91..1fa133918 100644 --- a/app/app.go +++ b/app/app.go @@ -10,6 +10,9 @@ import ( "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" @@ -23,15 +26,16 @@ import ( ethante "github.com/evmos/evmos/v14/app/ante/evm" "github.com/evmos/evmos/v14/ethereum/eip712" + "github.com/ExocoreNetwork/exocore/x/assets" + 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" "github.com/ExocoreNetwork/exocore/x/deposit" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositTypes "github.com/ExocoreNetwork/exocore/x/deposit/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" + operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" "github.com/ExocoreNetwork/exocore/x/reward" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types" @@ -255,9 +259,10 @@ var ( recovery.AppModuleBasic{}, revenue.AppModuleBasic{}, consensus.AppModuleBasic{}, - // exoCore staking modules - restaking_assets_manage.AppModuleBasic{}, + // Exocore modules + assets.AppModuleBasic{}, deposit.AppModuleBasic{}, + operator.AppModuleBasic{}, delegation.AppModuleBasic{}, withdraw.AppModuleBasic{}, reward.AppModuleBasic{}, @@ -346,12 +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 + // 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 @@ -398,7 +404,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, @@ -429,12 +434,13 @@ 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, rewardTypes.StoreKey, exoslashTypes.StoreKey, + operatorTypes.StoreKey, ) // Add the EVM transient store key @@ -614,13 +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.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.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.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, delegationTypes.VirtualOperatorOptedInKeeper{}) - 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.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) + 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( @@ -632,13 +641,12 @@ func NewExocoreApp( app.IBCKeeper.ChannelKeeper, app.DepositKeeper, app.DelegationKeeper, - app.StakingAssetsManageKeeper, + app.AssetsKeeper, app.WithdrawKeeper, app.ExoSlashKeeper, app.RewardKeeper, ), ) - epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey]) app.EpochsKeeper = *epochsKeeper.SetHooks( epochskeeper.NewMultiEpochHooks( @@ -789,8 +797,9 @@ 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.AssetsKeeper), 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), @@ -835,8 +844,9 @@ func NewExocoreApp( revenuetypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules - stakingAssetsManageTypes.ModuleName, + assetsTypes.ModuleName, depositTypes.ModuleName, + operatorTypes.ModuleName, delegationTypes.ModuleName, withdrawTypes.ModuleName, rewardTypes.ModuleName, @@ -877,8 +887,9 @@ func NewExocoreApp( revenuetypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules - stakingAssetsManageTypes.ModuleName, + assetsTypes.ModuleName, depositTypes.ModuleName, + operatorTypes.ModuleName, delegationTypes.ModuleName, withdrawTypes.ModuleName, rewardTypes.ModuleName, @@ -917,8 +928,9 @@ func NewExocoreApp( paramstypes.ModuleName, upgradetypes.ModuleName, // ExoCore modules - stakingAssetsManageTypes.ModuleName, + assetsTypes.ModuleName, depositTypes.ModuleName, + operatorTypes.ModuleName, delegationTypes.ModuleName, withdrawTypes.ModuleName, rewardTypes.ModuleName, @@ -1257,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/app/test_helpers.go b/app/test_helpers.go index 5fca3c7be..54de19660 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -5,6 +5,8 @@ import ( "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" @@ -38,7 +40,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. @@ -95,7 +97,6 @@ func Setup( } else { logger = log.NewNopLogger() } - app := NewExocoreApp( logger, db, nil, true, map[int64]bool{}, @@ -202,7 +203,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) @@ -210,13 +211,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(app.appCodec) } diff --git a/go.mod b/go.mod index 6c12c8c97..ff463418a 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( 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.33.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 70be3e69c..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,7 +947,6 @@ 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= @@ -977,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= @@ -1014,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= @@ -1190,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= @@ -1285,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= @@ -1581,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= @@ -1622,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= @@ -1697,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= @@ -1746,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= @@ -1859,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= @@ -1871,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= @@ -1889,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= @@ -1966,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= @@ -2234,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= @@ -2255,8 +2252,6 @@ 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= 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.go b/precompiles/delegation/delegation.go index 1bb972cb2..0181d8c1a 100644 --- a/precompiles/delegation/delegation.go +++ b/precompiles/delegation/delegation.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" + assetskeeper "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" @@ -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.sol b/precompiles/delegation/delegation.sol index e2109ec25..a67cecf55 100644 --- a/precompiles/delegation/delegation.sol +++ b/precompiles/delegation/delegation.sol @@ -14,9 +14,9 @@ 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 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 @@ -32,9 +32,9 @@ 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 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 diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 7d6931b33..430e320de 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -2,18 +2,18 @@ package delegation_test import ( "math/big" - "strings" + + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" sdkmath "cosmossdk.io/math" "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" - "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" @@ -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 @@ -87,13 +87,13 @@ func (s *DelegationPrecompileSuite) 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) { @@ -127,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() }, @@ -168,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() @@ -184,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)) @@ -201,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)) @@ -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 @@ -329,13 +329,13 @@ func (s *DelegationPrecompileSuite) 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) { @@ -371,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..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,caller:%s,need:%s" - 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/setup_test.go b/precompiles/delegation/setup_test.go index b5bec0e9b..abb0d1dfd 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" @@ -30,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 2c9e8cb21..71df9f487 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -4,6 +4,10 @@ import ( "fmt" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -22,7 +26,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, @@ -32,12 +36,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, exocmn.ErrContractCaller) } delegationParams, err := p.GetDelegationParamsFromInputs(ctx, args) @@ -52,7 +53,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, @@ -62,12 +63,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, exocmn.ErrContractCaller) } UndelegationParams, err := p.GetDelegationParamsFromInputs(ctx, args) diff --git a/precompiles/delegation/types.go b/precompiles/delegation/types.go index 864aa292e..4dcbaed7c 100644 --- a/precompiles/delegation/types.go +++ b/precompiles/delegation/types.go @@ -8,9 +8,9 @@ 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" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" sdk "github.com/cosmos/cosmos-sdk/types" cmn "github.com/evmos/evmos/v14/precompiles/common" ) @@ -22,11 +22,11 @@ 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) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, delegationParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, delegationParams.ClientChainLzID) if err != nil { return nil, err } @@ -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.go b/precompiles/deposit/deposit.go index 56d9d2389..b0877130f 100644 --- a/precompiles/deposit/deposit.go +++ b/precompiles/deposit/deposit.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" + assetskeeper "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" @@ -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 } @@ -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)) } diff --git a/precompiles/deposit/deposit.sol b/precompiles/deposit/deposit.sol index 179a2f81a..ba540a253 100644 --- a/precompiles/deposit/deposit.sol +++ b/precompiles/deposit/deposit.sol @@ -16,8 +16,8 @@ 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 -/// @param assetsAddress The client chain asset Address +/// @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( diff --git a/precompiles/deposit/deposit_integrate_test.go b/precompiles/deposit/deposit_integrate_test.go index 99ca68f2a..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" - types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/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 afc4f3227..c806d39c8 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" - types3 "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/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 deleted file mode 100644 index 3bce6ea7e..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,caller:%s,need:%s" - 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 a489fe03d..df09c3a8a 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" @@ -31,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 3ab5fe006..83a9fe114 100644 --- a/precompiles/deposit/tx.go +++ b/precompiles/deposit/tx.go @@ -1,9 +1,9 @@ package deposit import ( - "fmt" - - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + 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" "github.com/ethereum/go-ethereum/common" @@ -26,15 +26,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, exocmn.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,10 +44,10 @@ 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 } - 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..e210d3cad 100644 --- a/precompiles/deposit/types.go +++ b/precompiles/deposit/types.go @@ -4,8 +4,9 @@ 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" - "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" @@ -18,11 +19,11 @@ 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) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, depositParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, depositParams.ClientChainLzID) if err != nil { return nil, err } @@ -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/claimReward.sol b/precompiles/reward/claimReward.sol index 80e0668bc..4e17925f0 100644 --- a/precompiles/reward/claimReward.sol +++ b/precompiles/reward/claimReward.sol @@ -16,7 +16,7 @@ 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 diff --git a/precompiles/reward/error.go b/precompiles/reward/error.go deleted file mode 100644 index 69d5c160d..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,caller:%s,need:%s" - 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 ba56ed3a2..876270b03 100644 --- a/precompiles/reward/methods.go +++ b/precompiles/reward/methods.go @@ -1,9 +1,9 @@ package reward import ( - "fmt" - - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + 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" "github.com/ethereum/go-ethereum/common" @@ -26,13 +26,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, exocmn.ErrContractCaller) } rewardParam, err := p.GetRewardParamsFromInputs(ctx, args) @@ -46,9 +42,9 @@ 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 } - 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..37d256ccf 100644 --- a/precompiles/reward/parser.go +++ b/precompiles/reward/parser.go @@ -5,9 +5,11 @@ import ( "math/big" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + 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" @@ -20,11 +22,11 @@ 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) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, rewardParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, rewardParams.ClientChainLzID) if err != nil { return nil, err } @@ -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/reward/reward.go b/precompiles/reward/reward.go index b2e9888db..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/restaking_assets_manage/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 ccc2f0483..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" + 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/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" "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 9b444815e..9d49781de 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" @@ -30,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 deleted file mode 100644 index 3125b51ee..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,caller:%s,need:%s" - 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..d8bb5ebc6 100644 --- a/precompiles/slash/methods.go +++ b/precompiles/slash/methods.go @@ -1,8 +1,8 @@ package slash import ( - "fmt" - + 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" @@ -25,13 +25,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, exocmn.ErrContractCaller) } slashParam, err := p.GetSlashParamsFromInputs(ctx, args) diff --git a/precompiles/slash/parser.go b/precompiles/slash/parser.go index 792b74c76..ac1e13973 100644 --- a/precompiles/slash/parser.go +++ b/precompiles/slash/parser.go @@ -5,8 +5,10 @@ import ( "math/big" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + 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" @@ -19,11 +21,11 @@ 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) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, slashParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, slashParams.ClientChainLzID) if err != nil { return nil, err } @@ -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/slash/setup_test.go b/precompiles/slash/setup_test.go index dcae7c8ee..8aa802170 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" @@ -30,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 5e0135c19..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/restaking_assets_manage/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 2538a6a70..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" + 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/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" "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 deleted file mode 100644 index ebf6cb249..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,caller:%s,need:%s" - 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 0a59b01d3..d94970f2a 100644 --- a/precompiles/withdraw/methods.go +++ b/precompiles/withdraw/methods.go @@ -1,9 +1,9 @@ package withdraw import ( - "fmt" - - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + 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" "github.com/ethereum/go-ethereum/common" @@ -25,13 +25,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, exocmn.ErrContractCaller) } withdrawParam, err := p.GetWithdrawParamsFromInputs(ctx, args) @@ -45,9 +41,9 @@ 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 } - 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..995c288ce 100644 --- a/precompiles/withdraw/parser.go +++ b/precompiles/withdraw/parser.go @@ -5,8 +5,10 @@ import ( "math/big" "reflect" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + 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" @@ -19,11 +21,11 @@ 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) - info, err := p.stakingStateKeeper.GetClientChainInfoByIndex(ctx, withdrawParams.ClientChainLzID) + info, err := p.assetsKeeper.GetClientChainInfoByIndex(ctx, withdrawParams.ClientChainLzID) if err != nil { return nil, err } @@ -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/setup_test.go b/precompiles/withdraw/setup_test.go index 259b6c0b5..befb1fc66 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" @@ -30,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 a85532fd7..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/restaking_assets_manage/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 239c9d0f9..b29727769 100644 --- a/precompiles/withdraw/withdraw_integrate_test.go +++ b/precompiles/withdraw/withdraw_integrate_test.go @@ -2,13 +2,12 @@ package withdraw_test import ( "math/big" - "strings" + + 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" - deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ethereum/go-ethereum/common" ) @@ -28,15 +27,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 +55,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 +69,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, exocmn.ErrContractCaller) } diff --git a/precompiles/withdraw/withdraw_test.go b/precompiles/withdraw/withdraw_test.go index 38545e324..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" + 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/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" @@ -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/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/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/restaking_assets_manage/v1/query.proto b/proto/exocore/assets/v1/query.proto similarity index 77% rename from proto/exocore/restaking_assets_manage/v1/query.proto rename to proto/exocore/assets/v1/query.proto index bdde829e1..18a22a7b7 100644 --- a/proto/exocore/restaking_assets_manage/v1/query.proto +++ b/proto/exocore/assets/v1/query.proto @@ -1,13 +1,14 @@ 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/params.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 +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,52 +98,67 @@ message QueryStakerExCoreAddrResponse { ]; } -// Query defines the gRPC query service for the restaking_assets_manage module. +// 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; - 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(StakerAssetInfo){ 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(OperatorAssetInfo){ 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 63% rename from proto/exocore/restaking_assets_manage/v1/tx.proto rename to proto/exocore/assets/v1/tx.proto index 49eb87d8f..84e024586 100644 --- a/proto/exocore/restaking_assets_manage/v1/tx.proto +++ b/proto/exocore/assets/v1/tx.proto @@ -1,12 +1,24 @@ 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 "exocore/assets/v1/params.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 { + // 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 { @@ -16,8 +28,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. @@ -29,6 +41,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; + // 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. message AssetInfo { // name of the asset, like "Tether USD" @@ -48,8 +74,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; } @@ -67,30 +93,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 +// StakerAssetInfo defines the information for a single asset. +// The type include three states: +// staker's deposited, withdrawable, and currently unbonding amount. +message StakerAssetInfo { + // 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_undelegation_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 + // 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", @@ -102,32 +124,47 @@ 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 +// 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 [ (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_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_amount = 2 + [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // 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_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 ]; - // wait_undelegation_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 + + // 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", @@ -139,7 +176,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 @@ -203,9 +240,27 @@ message RegisterAssetReq { // RegisterAssetResponse is the response to the RegisterAssetReq message. message RegisterAssetResponse {} -// Msg defines the restaking_assets_manage Msg service +// MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. +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/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. +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/delegation/v1/query.proto b/proto/exocore/delegation/v1/query.proto index 4d4316f8d..3a4632128 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 + // 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", @@ -34,6 +33,13 @@ message DelegationAmounts { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; + // 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", + (gogoproto.nullable) = false + ]; } // QueryDelegationInfoResponse is the response for delegations by staker id and @@ -60,19 +66,8 @@ 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 { - // 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..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"; @@ -166,8 +123,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/deposit/v1/deposit.proto b/proto/exocore/deposit/v1/deposit.proto index df2652407..e33809a06 100644 --- a/proto/exocore/deposit/v1/deposit.proto +++ b/proto/exocore/deposit/v1/deposit.proto @@ -1,18 +1,7 @@ - - syntax = "proto3"; package exocore.deposit.v1; -import "gogoproto/gogo.proto"; - option go_package = "github.com/ExocoreNetwork/exocore/x/deposit/types"; -// GenesisState defines the restaking_assets_manage 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"]; -} +// GenesisState defines the deposit module's genesis state. +message Params {} 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/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto new file mode 100644 index 000000000..e9e53c643 --- /dev/null +++ b/proto/exocore/operator/v1/query.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package exocore.operator.v1; + +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 { + // operator_addr is the operator address,its type should be a sdk.AccAddress + string operator_addr = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// 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; +} + +// 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 ]; +} + +// 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"; + } + + // 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 new file mode 100644 index 000000000..ce386e4b0 --- /dev/null +++ b/proto/exocore/operator/v1/tx.proto @@ -0,0 +1,164 @@ +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"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/operator/types"; + +// 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. +// 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; +} + +// 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; +} + +// OptedInfo is the opted information about operator +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 exocore block height at which the operator opted in + uint64 opted_in_height = 2; + // 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 { + // 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 + ]; + // 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", + (gogoproto.nullable) = false + ]; +} + +// OperatorSlashInfo is the slash info of operator +message OperatorSlashInfo { + // slash_contract is the address of slash contract + string slash_contract = 1; + // 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 + [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// 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; +} + +// RegisterOperatorResponse is the response to a register operator request. +message RegisterOperatorResponse{} + +// OptInToCosmosChainRequest defines the OptInToCosmosChain request. +message OptInToCosmosChainRequest { + 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 + // 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; +} + +// OptInToCosmosChainResponse defines the OptInToCosmosChain response. +message OptInToCosmosChainResponse { +} + +// InitOptOutFromCosmosChainRequest defines the InitOptOutFromCosmosChain request. +message InitOptOutFromCosmosChainRequest { + 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; +} + +// InitOptOutFromCosmosChainResponse defines the InitOptOutFromCosmosChain response. +message InitOptOutFromCosmosChainResponse { +} + +// Msg defines the operator Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // RegisterOperator registers a new operator. + rpc RegisterOperator(RegisterOperatorReq) returns (RegisterOperatorResponse); + + // add services for dogfood + // 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 OptInToCosmosChain(OptInToCosmosChainRequest) returns (OptInToCosmosChainResponse) {}; + // 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 InitOptOutFromCosmosChain(InitOptOutFromCosmosChainRequest) returns (InitOptOutFromCosmosChainResponse) {}; +} \ No newline at end of file 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/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/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/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/testutil/abci.go b/testutil/abci.go index 51061fd20..368446e31 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, useUncachedCtx bool) (sdk.Context, error) { header, err := commit(ctx, app, t, vs) if err != nil { return ctx, err @@ -44,8 +44,14 @@ 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) - // set the reseted fields to keep the current ctx settings + var newCtx sdk.Context + if useUncachedCtx { + 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()) newCtx = newCtx.WithKVGasConfig(ctx.KVGasConfig()) 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/testutil/utils.go b/testutil/utils.go index d7a973841..02ab7135e 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -7,6 +7,7 @@ import ( "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" @@ -72,7 +73,8 @@ func (suite *BaseTestSuite) SetupTest() { // 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 *BaseTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { - appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, false)() + pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) + appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, false)() app, ok := appI.(*exocoreapp.ExocoreApp) suite.Require().True(ok) @@ -253,6 +255,6 @@ func (suite *BaseTestSuite) DeployContract(contract evmtypes.CompiledContract) ( // NextBlock commits the current block and sets up the next block. func (suite *BaseTestSuite) NextBlock() { var err error - suite.Ctx, err = CommitAndCreateNewCtx(suite.Ctx, suite.App, time.Second, suite.ValSet) + suite.Ctx, err = CommitAndCreateNewCtx(suite.Ctx, suite.App, time.Second, suite.ValSet, true) suite.Require().NoError(err) } diff --git a/x/restaking_assets_manage/client/cli/query.go b/x/assets/client/cli/query.go similarity index 94% rename from x/restaking_assets_manage/client/cli/query.go rename to x/assets/client/cli/query.go index a3d0e1a0f..aeac1286c 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, @@ -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/restaking_assets_manage/client/cli/tx.go b/x/assets/client/cli/tx.go similarity index 63% rename from x/restaking_assets_manage/client/cli/tx.go rename to x/assets/client/cli/tx.go index bfd11b538..09a3766da 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, @@ -27,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 { @@ -45,20 +79,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.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[2])) } addressLength, err := strconv.ParseUint(args[3], 10, 32) if err != nil { - return errorsmod.Wrap(restakingtype.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) @@ -87,9 +121,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 +132,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.ErrInvalidCliCmdArg, 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.ErrInvalidCliCmdArg, fmt.Sprintf("error arg is:%v", args[5])) } decimal, err := strconv.ParseUint(args[6], 10, 32) if err != nil { - return errorsmod.Wrap(restakingtype.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/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/assets/keeper/app_chain.go b/x/assets/keeper/app_chain.go new file mode 100644 index 000000000..7a70ebd92 --- /dev/null +++ b/x/assets/keeper/app_chain.go @@ -0,0 +1,58 @@ +package keeper + +import ( + assetstype "github.com/ExocoreNetwork/exocore/x/assets/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 assetstype.AppChainInfo, +) { + 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), assetstype.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 assetstype.AppChainInfo, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), assetstype.KeyPrefixAppChainInfo) + ifExist := store.Has([]byte(chainID)) + if !ifExist { + return assetstype.AppChainInfo{}, assetstype.ErrUnknownAppChainID + } + value := store.Get([]byte(chainID)) + ret := assetstype.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]assetstype.AppChainInfo) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, assetstype.KeyPrefixAppChainInfo) + defer iterator.Close() + + ret := make(map[string]assetstype.AppChainInfo, 0) + for ; iterator.Valid(); iterator.Next() { + var chainInfo assetstype.AppChainInfo + k.cdc.MustUnmarshal(iterator.Value(), &chainInfo) + ret[chainInfo.ChainId] = chainInfo + } + return ret +} diff --git a/x/restaking_assets_manage/keeper/client_chain.go b/x/assets/keeper/client_chain.go similarity index 53% rename from x/restaking_assets_manage/keeper/client_chain.go rename to x/assets/keeper/client_chain.go index f0507ffc4..0a93c72c0 100644 --- a/x/restaking_assets_manage/keeper/client_chain.go +++ b/x/assets/keeper/client_chain.go @@ -1,16 +1,16 @@ 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" ) -// 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) +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) +// GetClientChainInfoByIndex using LayerZeroChainID as the query index. +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 54% 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..9feb73a1b 100644 --- a/x/restaking_assets_manage/keeper/client_chain_and_asset_test.go +++ b/x/assets/keeper/client_chain_and_asset_test.go @@ -1,15 +1,15 @@ 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) + 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,15 +18,15 @@ 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 := 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,8 +34,8 @@ func (suite *StakingAssetsTestSuite) TestGenesisClientChainAndAssetInfo() { } usdtAsset := defaultGensisState.DefaultSupportedClientChainTokens[0] - _, assetID := types.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainID, "", usdtAsset.Address) - assetInfo, err := suite.App.StakingAssetsManageKeeper.GetStakingAssetInfo(suite.Ctx, assetID) + _, assetID := assetstype.GetStakeIDAndAssetIDFromStr(usdtAsset.LayerZeroChainID, "", usdtAsset.Address) + assetInfo, err := suite.App.AssetsKeeper.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 50% rename from x/restaking_assets_manage/keeper/client_chain_asset.go rename to x/assets/keeper/client_chain_asset.go index 3af480696..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,19 +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) - err = UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) + // calculate and set new amount + err = assetstype.UpdateAssetValue(&ret.StakingTotalAmount, &changeAmount) if err != nil { return err } @@ -36,52 +37,47 @@ 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) { - // check if the client chain exist - if !k.IsExistedClientChain(ctx, info.AssetBasicInfo.LayerZeroChainID) { - return restakingtype.ErrNoClientChainKey - } - - 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 58% rename from x/restaking_assets_manage/keeper/grpc_query.go rename to x/assets/keeper/grpc_query.go index f5717a312..40b20fb87 100644 --- a/x/restaking_assets_manage/keeper/grpc_query.go +++ b/x/assets/keeper/grpc_query.go @@ -3,77 +3,89 @@ 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" ) +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 *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.StakerAssetInfo, 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 { 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 } - 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.OperatorAssetInfo, error) { c := sdk.UnwrapSDKContext(ctx) addr, err := sdk.AccAddressFromBech32(req.OperatorAddr) if err != nil { @@ -83,11 +95,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..ec7bf8e14 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.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]*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.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 - 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 53% rename from x/restaking_assets_manage/keeper/msg_server.go rename to x/assets/keeper/msg_server.go index 715134df8..d89d9591b 100644 --- a/x/restaking_assets_manage/keeper/msg_server.go +++ b/x/assets/keeper/msg_server.go @@ -5,24 +5,33 @@ 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{} + +// 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 -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 +40,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 +52,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/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go new file mode 100644 index 000000000..1b575b895 --- /dev/null +++ b/x/assets/keeper/operator_asset.go @@ -0,0 +1,117 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + 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]*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.OperatorAssetInfo, 0) + for ; iterator.Valid(); iterator.Next() { + var stateInfo assetstype.OperatorAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + assetID := keyList[1] + ret[assetID] = &stateInfo + } + return ret, nil +} + +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) + if !ifExist { + return nil, assetstype.ErrNoOperatorAssetKey + } + + value := store.Get(key) + + ret := assetstype.OperatorAssetInfo{} + k.cdc.MustUnmarshal(value, &ret) + return &ret, nil +} + +// 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. + +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), assetstype.KeyPrefixOperatorAssetInfos) + key := assetstype.GetJoinedStoreKey(operatorAddr.String(), assetID) + assetState := assetstype.OperatorAssetInfo{ + TotalAmount: math.NewInt(0), + OperatorAmount: math.NewInt(0), + WaitUnbondingAmount: math.NewInt(0), + OperatorUnbondingAmount: math.NewInt(0), + OperatorUnbondableAmountAfterSlash: math.NewInt(0), + } + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &assetState) + } + + // update all states of the specified operator asset + err = assetstype.UpdateAssetValue(&assetState.TotalAmount, &changeAmount.TotalAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") + } + err = assetstype.UpdateAssetValue(&assetState.OperatorAmount, &changeAmount.OperatorAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorAmountOrWantChangeValue error") + } + err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") + } + err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondingAmount, &changeAmount.OperatorUnbondingAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorUnbondingAmount error") + } + err = assetstype.UpdateAssetValue(&assetState.OperatorUnbondableAmountAfterSlash, &changeAmount.OperatorUnbondableAmountAfterSlash) + if err != nil { + return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorUnbondingAmount error") + } + + // store the updated state + bz := k.cdc.MustMarshal(&assetState) + store.Set(key, bz) + return nil +} + +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.OperatorAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &amounts) + keys, err := assetstype.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 +} 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/restaking_assets_manage/keeper/setup_test.go b/x/assets/keeper/setup_test.go similarity index 99% rename from x/restaking_assets_manage/keeper/setup_test.go rename to x/assets/keeper/setup_test.go index 21d80f32f..51349b55c 100644 --- a/x/restaking_assets_manage/keeper/setup_test.go +++ b/x/assets/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/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go new file mode 100644 index 000000000..2051c84a5 --- /dev/null +++ b/x/assets/keeper/staker_asset.go @@ -0,0 +1,84 @@ +package keeper + +import ( + "fmt" + + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "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]*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.StakerAssetInfo, 0) + for ; iterator.Valid(); iterator.Next() { + var stateInfo assetstype.StakerAssetInfo + k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) + keyList, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 2) + if err != nil { + return nil, err + } + assetID := keyList[1] + ret[assetID] = &stateInfo + } + return ret, nil +} + +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) + if !ifExist { + return nil, errorsmod.Wrap(assetstype.ErrNoStakerAssetKey, fmt.Sprintf("the key is:%s", key)) + } + + value := store.Get(key) + + ret := assetstype.StakerAssetInfo{} + k.cdc.MustUnmarshal(value, &ret) + return &ret, nil +} + +// 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 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), assetstype.KeyPrefixReStakerAssetInfos) + key := assetstype.GetJoinedStoreKey(stakerID, assetID) + assetState := assetstype.StakerAssetInfo{ + TotalDepositAmount: math.NewInt(0), + WithdrawableAmount: math.NewInt(0), + WaitUnbondingAmount: math.NewInt(0), + } + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &assetState) + } + + // update all states of the specified restaker asset + err = assetstype.UpdateAssetValue(&assetState.TotalDepositAmount, &changeAmount.TotalDepositAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateStakerAssetState TotalDepositAmountOrWantChangeValue error") + } + err = assetstype.UpdateAssetValue(&assetState.WithdrawableAmount, &changeAmount.WithdrawableAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") + } + err = assetstype.UpdateAssetValue(&assetState.WaitUnbondingAmount, &changeAmount.WaitUnbondingAmount) + if err != nil { + return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") + } + + // store the updated state + bz := k.cdc.MustMarshal(&assetState) + store.Set(key, bz) + + return nil +} diff --git a/x/assets/keeper/staker_asset_test.go b/x/assets/keeper/staker_asset_test.go new file mode 100644 index 000000000..6459199f8 --- /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{ + TotalDepositAmount: math.NewInt(1000), + WithdrawableAmount: math.NewInt(1000), + } + + // test the initial storage of statker assets state + 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.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)) + + // test valid increase of staker asset state + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(500) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(500) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + + 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))) + + // test valid decrease of staker asset state + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-500) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-500) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + 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))) + + // test the decreased amount is bigger than original state + ethUniInitialChangeValue.TotalDepositAmount = math.NewInt(-2000) + ethUniInitialChangeValue.WithdrawableAmount = math.NewInt(-500) + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) + 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.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().Error(err, assetstype.ErrSubAmountIsMoreThanOrigin) + 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))) + + // test the storage of multiple assets state + ethUsdtAssetID := fmt.Sprintf("%s_%s", "0xdac17f958d2ee523a2206206994597c13d831ec7", "101") + ethUsdtInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ + TotalDepositAmount: math.NewInt(2000), + WithdrawableAmount: math.NewInt(2000), + } + err = suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUsdtAssetID, ethUsdtInitialChangeValue) + suite.Require().NoError(err) + 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))) +} + +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{ + TotalDepositAmount: math.NewInt(1000), + WithdrawableAmount: math.NewInt(1000), + } + ethUsdtInitialChangeValue := assetstype.StakerSingleAssetChangeInfo{ + TotalDepositAmount: math.NewInt(2000), + WithdrawableAmount: math.NewInt(2000), + } + err := suite.App.AssetsKeeper.UpdateStakerAssetState(suite.Ctx, stakerID, ethUniAssetID, ethUniInitialChangeValue) + suite.Require().NoError(err) + 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.AssetsKeeper.GetStakerAssetInfos(suite.Ctx, stakerID) + suite.Require().NoError(err) + uniState, isExist := assetsInfo[ethUniAssetID] + suite.Require().True(isExist) + suite.Require().True(uniState.TotalDepositAmount.Equal(math.NewInt(1000))) + suite.Require().True(uniState.WithdrawableAmount.Equal(math.NewInt(1000))) + + usdtState, isExist := assetsInfo[ethUsdtAssetID] + suite.Require().True(isExist) + suite.Require().True(usdtState.TotalDepositAmount.Equal(math.NewInt(2000))) + suite.Require().True(usdtState.WithdrawableAmount.Equal(math.NewInt(2000))) +} 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 53% rename from x/restaking_assets_manage/types/errors.go rename to x/assets/types/errors.go index 683cf2c8b..16929dec5 100644 --- a/x/restaking_assets_manage/types/errors.go +++ b/x/assets/types/errors.go @@ -17,7 +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") + + ErrInvalidOperatorAddr = errorsmod.Register(ModuleName, 8, "the operator address isn't a valid account address") + + 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/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/assets/types/general.go b/x/assets/types/general.go new file mode 100644 index 000000000..7e93ceb81 --- /dev/null +++ b/x/assets/types/general.go @@ -0,0 +1,162 @@ +package types + +import ( + "fmt" + "strings" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/store/rootmulti" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +const ( + CrossChainActionLength = 1 + CrossChainOpAmountLength = 32 + GeneralAssetsAddrLength = 32 + GeneralClientChainAddrLength = 32 + + ClientChainLzIDIndexInTopics = 0 + LzNonceIndexInTopics = 2 + + ExoCoreOperatorAddrLength = 42 +) + +const ( + Deposit CrossChainOpType = iota + WithdrawPrinciple + WithDrawReward + DelegateTo + UndelegateFrom + 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 StakerAssetInfo +type StakerSingleAssetChangeInfo StakerAssetInfo + +// 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) { + clientChainLzIDStr := hexutil.EncodeUint64(clientChainLzID) + if stakerAddress != nil { + stakeID = strings.Join([]string{hexutil.Encode(stakerAddress), clientChainLzIDStr}, "_") + } + + if assetsAddress != nil { + 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) + if stakerAddress != "" { + stakeID = strings.Join([]string{strings.ToLower(stakerAddress), clientChainLzIDStr}, "_") + } + + if assetsAddress != "" { + assetID = strings.Join([]string{strings.ToLower(assetsAddress), clientChainLzIDStr}, "_") + } + 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 +} + +// 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 +} + +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{}, + errorsmod.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 { + historicalStateCtx = historicalStateCtx.WithBlockTime(cInfo.Timestamp) + } + } + } + return historicalStateCtx, nil +} 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 57% rename from x/restaking_assets_manage/types/keys.go rename to x/assets/types/keys.go index ca71d3d45..9f0d9c7a5 100644 --- a/x/restaking_assets_manage/types/keys.go +++ b/x/assets/types/keys.go @@ -12,7 +12,7 @@ import ( // constants const ( // ModuleName module name - ModuleName = "restaking_assets_manage" + ModuleName = "assets" // StoreKey to be used when creating the KVStore StoreKey = ModuleName @@ -31,6 +31,7 @@ func init() { // prefix bytes for the reStaking assets manage store const ( prefixClientChainInfo = iota + 1 + prefixAppChainInfo prefixRestakingAssetInfo prefixRestakerAssetInfo prefixOperatorAssetInfo @@ -43,6 +44,11 @@ const ( // prefixReStakingAssetList // prefixReStakerAssetList // prefixOperatorAssetList + + // add for dogfood + prefixOperatorSnapshot + prefixOperatorLastSnapshotHeight + prefixParams ) // KVStore key prefixes @@ -50,7 +56,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 @@ -81,40 +87,54 @@ var ( // KeyPrefixClientChainInfo key->value: chainIndex->ClientChainInfo KeyPrefixClientChainInfo = []byte{prefixClientChainInfo} - // KeyPrefixReStakingAssetInfo AssetId = AssetAddr+'_'+chainIndex - // KeyPrefixReStakingAssetInfo key->value: AssetId->ReStakingAssetInfo + KeyPrefixAppChainInfo = []byte{prefixAppChainInfo} + + // 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->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: operatorAddr+'_'+AssetId->mapping(middleWareAddr->struct{}) - // or operatorAddr->mapping(AssetId->mapping(middleWareAddr->struct{})) ? - KeyPrefixOperatorOptedInMiddleWareAssetInfos = []byte{prefixOperatorOptedInMiddlewareAssetInfo} + // 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 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} + + // KeyPrefixParams This is a key prefix for module parameter + KeyPrefixParams = []byte{prefixParams} + ParamsKey = []byte("Params") ) -// 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 ParseJoinedKey(key []byte) (keys []string, err error) { + stringList := strings.Split(string(key), "/") + return stringList, nil } -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/msg.go b/x/assets/types/msg.go similarity index 77% rename from x/restaking_assets_manage/types/msg.go rename to x/assets/types/msg.go index 8905d2b89..e64821400 100644 --- a/x/restaking_assets_manage/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/restaking_assets_manage/types/query.pb.go b/x/assets/types/query.pb.go similarity index 81% rename from x/restaking_assets_manage/types/query.pb.go rename to x/assets/types/query.pb.go index 48d348813..2ca380f32 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]*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{} } 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]*StakerAssetInfo { 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]*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{} } 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]*OperatorAssetInfo { 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) @@ -678,98 +678,184 @@ func (m *QueryStakerExCoreAddrResponse) GetExoCoreAddr() string { return "" } -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") +// 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.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, 0x4a, - 0x55, 0x4f, 0xbd, 0x20, 0x81, 0x90, 0x10, 0x07, 0x7e, 0x04, 0x42, 0xdc, 0xf8, 0x03, 0x1c, 0x38, - 0x14, 0x90, 0x10, 0xa7, 0x08, 0x9c, 0x4a, 0x88, 0x3b, 0x3f, 0xa0, 0xda, 0x99, 0xb1, 0x77, 0xbd, - 0xde, 0x4d, 0xc6, 0x1f, 0x37, 0xcf, 0xbc, 0xdf, 0xef, 0x33, 0xfb, 0x3e, 0xaf, 0x0c, 0x35, 0xdc, - 0x26, 0x35, 0xe2, 0x61, 0xdd, 0xc3, 0xd4, 0x37, 0xeb, 0x8e, 0x6b, 0x1b, 0x26, 0xa5, 0xd8, 0xa7, - 0xc6, 0x81, 0xe9, 0x9a, 0x36, 0xd6, 0x8f, 0xae, 0xeb, 0x87, 0x2d, 0xec, 0x75, 0xb4, 0xa6, 0x47, - 0x7c, 0x82, 0x54, 0xa1, 0xaf, 0xa5, 0xe8, 0x6b, 0x47, 0xd7, 0x95, 0xab, 0x35, 0x42, 0x0f, 0x08, - 0xe5, 0x76, 0x31, 0x07, 0xca, 0x12, 0x17, 0x1a, 0xec, 0xa4, 0xf3, 0x83, 0x10, 0xbd, 0x2b, 0x91, - 0x8b, 0xdf, 0x16, 0xca, 0x0b, 0x36, 0xb1, 0x09, 0x77, 0x12, 0xfc, 0x12, 0xb7, 0xd7, 0x6c, 0x42, - 0xec, 0x06, 0xd6, 0xcd, 0xa6, 0xa3, 0x9b, 0xae, 0x4b, 0x7c, 0xd3, 0x77, 0x88, 0x2b, 0x02, 0xa8, - 0x37, 0xe1, 0xc2, 0xfd, 0x20, 0x95, 0x52, 0xc3, 0xc1, 0xae, 0x5f, 0xda, 0x37, 0x1d, 0xb7, 0xe2, - 0xee, 0x11, 0x54, 0x80, 0xd9, 0x5a, 0x70, 0x30, 0x1c, 0xd7, 0xc2, 0xed, 0x1c, 0x58, 0x06, 0x2b, - 0x2f, 0x55, 0x61, 0x8d, 0xcb, 0x2d, 0xdc, 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, - 0x52, 0x4d, 0xa2, 0xd0, 0xcc, 0x71, 0x68, 0x76, 0x06, 0xa1, 0x79, 0x5f, 0x26, 0xe9, 0x78, 0xdf, - 0xa3, 0xd8, 0x14, 0xc5, 0x47, 0x12, 0xe8, 0x60, 0x2f, 0x84, 0xe6, 0x6d, 0x38, 0x47, 0xd9, 0x55, - 0x88, 0xcd, 0x7c, 0xf7, 0xb8, 0x30, 0xcb, 0xf5, 0x2a, 0xdb, 0xd5, 0x59, 0x2e, 0xae, 0x58, 0xea, - 0xd3, 0x0c, 0x5c, 0xe4, 0x7d, 0xe9, 0x07, 0xe8, 0x75, 0xbd, 0x0e, 0xb3, 0x02, 0xe0, 0xc8, 0xf3, - 0xdf, 0x91, 0x6f, 0x74, 0xdc, 0xa1, 0xd6, 0xbf, 0x11, 0x8f, 0x1d, 0x9a, 0xfd, 0x0b, 0xe5, 0x31, - 0x80, 0xaf, 0xc4, 0xe4, 0x09, 0x0d, 0xfc, 0x68, 0xb0, 0x81, 0x45, 0xd9, 0x06, 0x62, 0x6f, 0xd7, - 0x71, 0xed, 0x06, 0x66, 0x11, 0xee, 0x79, 0xa5, 0x7d, 0xd3, 0xb5, 0x71, 0xbc, 0x9b, 0x87, 0xf0, - 0x1a, 0xef, 0x66, 0x13, 0xd7, 0x9c, 0x3d, 0x07, 0x5b, 0x4c, 0xbb, 0x78, 0x40, 0x5a, 0xae, 0x5f, - 0xc5, 0x87, 0x23, 0x74, 0x75, 0xe0, 0xdb, 0xc8, 0x9c, 0xf2, 0x6d, 0x7c, 0x2c, 0x86, 0xd5, 0xbd, - 0x26, 0xf6, 0x4c, 0x9f, 0x84, 0x10, 0x52, 0xb4, 0x09, 0x5f, 0x26, 0xe2, 0xd6, 0x30, 0x2d, 0xcb, - 0x13, 0x11, 0x73, 0xbf, 0xff, 0xf4, 0xde, 0x82, 0x18, 0xc5, 0x45, 0xcb, 0xf2, 0x30, 0xa5, 0xbb, - 0xbe, 0xe7, 0xb8, 0x76, 0x75, 0xbe, 0xa7, 0x1e, 0x5c, 0xab, 0xdf, 0xf7, 0x66, 0xdd, 0xb0, 0xeb, - 0x3e, 0xc0, 0x7e, 0x12, 0xc0, 0xbb, 0xd2, 0x00, 0xa7, 0x7b, 0x3e, 0x15, 0xe9, 0x27, 0x52, 0x48, - 0x7f, 0x32, 0x88, 0x74, 0x49, 0x26, 0xab, 0x5e, 0x42, 0x12, 0x58, 0x7f, 0x09, 0xe0, 0x1b, 0x03, - 0x45, 0xa4, 0x81, 0x3e, 0x19, 0x0c, 0xd2, 0x0f, 0x41, 0x8f, 0x4c, 0x59, 0xec, 0x95, 0xdb, 0x25, - 0xe2, 0x61, 0xe6, 0x60, 0x11, 0x5e, 0xe0, 0xaf, 0x4a, 0x34, 0x47, 0x9c, 0xd4, 0x3a, 0x7c, 0x2d, - 0xd1, 0xa0, 0x0f, 0xee, 0x0e, 0x9c, 0x17, 0x2d, 0x8b, 0xe6, 0xfd, 0x56, 0xf7, 0xb8, 0x90, 0x2d, - 0xb7, 0x49, 0x4f, 0x3d, 0xb5, 0x8c, 0xac, 0x30, 0x0e, 0x6e, 0x57, 0xbf, 0xbb, 0x04, 0xcf, 0xb3, - 0x68, 0xe8, 0x4f, 0xc0, 0xa6, 0x79, 0x8c, 0x2f, 0xb6, 0x3a, 0x8c, 0x7b, 0xd1, 0x9a, 0xf4, 0xdb, - 0x89, 0x39, 0x50, 0xc6, 0x61, 0x29, 0x75, 0xe7, 0xe9, 0xbf, 0x3f, 0xbc, 0x03, 0x9e, 0xfc, 0xf1, - 0xfc, 0x9b, 0xcc, 0x6d, 0xb4, 0xa9, 0x4b, 0xac, 0x24, 0xe9, 0xa9, 0xff, 0x03, 0x18, 0x02, 0xc3, - 0x3c, 0x8b, 0x36, 0x26, 0x20, 0x7c, 0xa5, 0x34, 0x85, 0x6d, 0x41, 0xfd, 0x30, 0xac, 0x73, 0x03, - 0xad, 0x4b, 0xd6, 0x99, 0x50, 0xc9, 0xaf, 0x00, 0x5e, 0xbe, 0xdf, 0xc2, 0x43, 0x4c, 0xbe, 0x2e, - 0x9d, 0x64, 0xdc, 0x54, 0x19, 0x8b, 0xc2, 0xd4, 0xed, 0xb0, 0xa0, 0x75, 0x74, 0x53, 0xb2, 0xa0, - 0xa1, 0xb4, 0xff, 0x03, 0x6c, 0x7a, 0x26, 0x11, 0x30, 0xda, 0x9c, 0x68, 0x1f, 0x50, 0xca, 0x53, - 0x59, 0x27, 0xd4, 0x3b, 0x61, 0x9d, 0x9b, 0x68, 0x43, 0x1e, 0xb8, 0xe1, 0x7a, 0x7e, 0x0b, 0xa1, - 0xc3, 0x51, 0x96, 0x58, 0x1b, 0x09, 0xba, 0x88, 0xa9, 0x72, 0x6b, 0x7c, 0x22, 0x1f, 0x1f, 0xbf, - 0x81, 0xdc, 0xff, 0x07, 0x6c, 0x86, 0x09, 0x7e, 0x4e, 0x98, 0xbf, 0xe8, 0x03, 0xf9, 0xea, 0x92, - 0xc7, 0xb7, 0x32, 0xf9, 0x86, 0xa0, 0xde, 0x0d, 0x8b, 0x2d, 0xa1, 0xe2, 0x48, 0xc5, 0x26, 0x16, - 0x25, 0x26, 0x4d, 0x02, 0xe5, 0x6f, 0x4c, 0x40, 0xbd, 0x23, 0x4c, 0x9a, 0x74, 0xde, 0x1e, 0x6f, - 0xd2, 0x24, 0x54, 0xf2, 0x98, 0x6f, 0x1f, 0xa7, 0x91, 0x2b, 0xba, 0x33, 0x72, 0xc2, 0x69, 0x20, - 0x4f, 0x63, 0x39, 0x98, 0x3a, 0xcc, 0xcf, 0x01, 0x5b, 0xce, 0x7b, 0xfc, 0xdc, 0x67, 0xdc, 0x11, - 0xa7, 0x6d, 0x94, 0xdb, 0xe5, 0x5e, 0xf3, 0xa9, 0x6b, 0xc1, 0x24, 0x65, 0x46, 0x8a, 0xd0, 0x1f, - 0xf2, 0x35, 0xe4, 0xd1, 0xd6, 0x67, 0xbf, 0x74, 0xf3, 0xe0, 0x59, 0x37, 0x0f, 0xfe, 0xee, 0xe6, - 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]*StakerAssetInfo)(nil), "exocore.assets.v1.QueryAssetInfoResponse.AssetInfosEntry") + proto.RegisterType((*QuerySpecifiedAssetAmountReq)(nil), "exocore.assets.v1.QuerySpecifiedAssetAmountReq") + proto.RegisterType((*QueryOperatorAssetInfos)(nil), "exocore.assets.v1.QueryOperatorAssetInfos") + proto.RegisterType((*QueryOperatorAssetInfosResponse)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse") + proto.RegisterMapType((map[string]*OperatorAssetInfo)(nil), "exocore.assets.v1.QueryOperatorAssetInfosResponse.AssetInfosEntry") + proto.RegisterType((*QueryOperatorSpecifiedAssetAmountReq)(nil), "exocore.assets.v1.QueryOperatorSpecifiedAssetAmountReq") + proto.RegisterType((*QueryStakerExCoreAddr)(nil), "exocore.assets.v1.QueryStakerExCoreAddr") + proto.RegisterType((*QueryStakerExCoreAddrResponse)(nil), "exocore.assets.v1.QueryStakerExCoreAddrResponse") + 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{ + // 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, + 0x5c, 0x2b, 0xec, 0x26, 0x2e, 0x28, 0x4d, 0xa5, 0x0a, 0x39, 0x69, 0x24, 0x52, 0xa4, 0x02, 0xee, + 0x05, 0xf5, 0x62, 0x6d, 0x77, 0x27, 0xee, 0x12, 0x67, 0xc7, 0xd9, 0x59, 0x07, 0x1b, 0x84, 0x84, + 0x90, 0x90, 0xb8, 0x20, 0x55, 0xe2, 0xd4, 0x0b, 0x17, 0xce, 0x20, 0x10, 0x88, 0x2b, 0x57, 0x8e, + 0x15, 0x1c, 0xe0, 0x14, 0x21, 0x07, 0x89, 0x03, 0x7f, 0x02, 0x79, 0x66, 0xbc, 0x5e, 0xef, 0xce, + 0x38, 0x9b, 0xe6, 0xe6, 0x9d, 0xef, 0xcd, 0x7b, 0xdf, 0x7c, 0xef, 0xed, 0x7c, 0x6b, 0x78, 0x15, + 0x77, 0x89, 0x4d, 0x7c, 0x6c, 0x5a, 0x94, 0xe2, 0x80, 0x9a, 0x87, 0x6b, 0xe6, 0x41, 0x07, 0xfb, + 0x3d, 0xa3, 0xed, 0x93, 0x80, 0xa0, 0x97, 0x05, 0x6c, 0x70, 0xd8, 0x38, 0x5c, 0xd3, 0x16, 0x6c, + 0x42, 0xf7, 0x09, 0xe5, 0x61, 0xb1, 0x78, 0xad, 0xc0, 0xc1, 0x06, 0x7b, 0x32, 0xf9, 0x83, 0x80, + 0x8a, 0xc9, 0x4a, 0x6d, 0xcb, 0xb7, 0xf6, 0x87, 0xb8, 0x96, 0xc4, 0x83, 0xae, 0xc0, 0x72, 0x4d, + 0xd2, 0x24, 0x3c, 0xe7, 0xe0, 0x97, 0x58, 0xbd, 0xd2, 0x24, 0xa4, 0xd9, 0xc2, 0xa6, 0xd5, 0x76, + 0x4d, 0xcb, 0xf3, 0x48, 0x60, 0x05, 0x2e, 0xf1, 0x44, 0x3e, 0x7d, 0x1d, 0xe6, 0xde, 0x1f, 0x30, + 0xdb, 0x6a, 0xb9, 0xd8, 0x0b, 0xb6, 0x1e, 0x5b, 0xae, 0xb7, 0xe3, 0xed, 0x12, 0x54, 0x82, 0x59, + 0x7b, 0xf0, 0xd0, 0x70, 0x3d, 0x07, 0x77, 0xf3, 0x60, 0x11, 0x94, 0x5f, 0xa8, 0x43, 0x9b, 0xe3, + 0x0e, 0xee, 0xea, 0x05, 0x78, 0x99, 0x6d, 0xac, 0xb5, 0x5a, 0xb1, 0xbd, 0xfa, 0x93, 0x0c, 0x2c, + 0x29, 0xb0, 0x3a, 0xa6, 0x6d, 0xe2, 0x51, 0x8c, 0x3e, 0x03, 0x70, 0xde, 0x6a, 0xb5, 0x1a, 0x36, + 0xc3, 0x1b, 0xc3, 0x5a, 0xbb, 0x84, 0xe6, 0xc1, 0xe2, 0xb9, 0x72, 0xb6, 0xfa, 0x8e, 0x91, 0x10, + 0xd5, 0x38, 0x21, 0xa9, 0x91, 0x84, 0xe8, 0xb6, 0x17, 0xf8, 0xbd, 0xfa, 0x25, 0x2b, 0x89, 0x68, + 0x1f, 0xc2, 0xbc, 0x6a, 0x03, 0x7a, 0x09, 0x9e, 0xdb, 0xc3, 0x3d, 0x71, 0xec, 0xc1, 0x4f, 0x74, + 0x0b, 0x9e, 0x3f, 0xb4, 0x5a, 0x1d, 0x9c, 0xcf, 0x2c, 0x82, 0x72, 0xb6, 0xaa, 0x4b, 0xe8, 0xc5, + 0x69, 0xf1, 0x0d, 0xb7, 0x33, 0xb7, 0x80, 0xfe, 0x16, 0x7c, 0x85, 0x91, 0x7f, 0x10, 0x58, 0x7b, + 0xae, 0xd7, 0xac, 0x0d, 0xf6, 0x30, 0x9d, 0x97, 0xe0, 0x0c, 0x4b, 0xd0, 0x70, 0x1d, 0x56, 0x6d, + 0x76, 0x33, 0xdb, 0x3f, 0x2a, 0x5d, 0xe0, 0x01, 0x77, 0xeb, 0x17, 0x18, 0xb8, 0xe3, 0xe8, 0x0b, + 0xb0, 0x30, 0x3c, 0x7d, 0x34, 0x07, 0x65, 0x82, 0x3f, 0xcd, 0xc0, 0x6b, 0x4a, 0x34, 0x94, 0xfc, + 0x0b, 0x00, 0x2f, 0x0f, 0x24, 0xa7, 0x3c, 0xa2, 0xc1, 0x89, 0x33, 0xd1, 0x85, 0xe6, 0xf7, 0x27, + 0x68, 0xae, 0xcc, 0x6b, 0xc8, 0x40, 0x2e, 0x7b, 0xce, 0x92, 0x40, 0x5a, 0x0b, 0x16, 0x94, 0x5b, + 0xa2, 0xc2, 0xcf, 0x72, 0xe1, 0x37, 0xc6, 0x85, 0x7f, 0x55, 0xc2, 0x31, 0xae, 0x6a, 0x54, 0xf9, + 0x9a, 0x18, 0xf0, 0x41, 0x0c, 0xf6, 0x47, 0xc2, 0xdf, 0x80, 0xb3, 0x94, 0x2d, 0x8d, 0x94, 0x9f, + 0xeb, 0x1f, 0x95, 0x66, 0x78, 0xdc, 0xce, 0xdd, 0xfa, 0x0c, 0x87, 0x77, 0x1c, 0xfd, 0x4f, 0x00, + 0xe7, 0xb9, 0x0c, 0x61, 0x81, 0xa1, 0xa6, 0x0f, 0x61, 0x56, 0xb4, 0x2f, 0x32, 0xba, 0x1b, 0x4a, + 0x19, 0xe3, 0xfb, 0x8d, 0x70, 0x45, 0x0c, 0x2a, 0xb4, 0xc2, 0x05, 0xcd, 0x82, 0x2f, 0xc6, 0x60, + 0x89, 0x3a, 0x29, 0xc6, 0x32, 0x76, 0xf2, 0xa8, 0x38, 0x07, 0xf0, 0x0a, 0x17, 0xa7, 0x8d, 0x6d, + 0x77, 0xd7, 0xc5, 0x0e, 0x8b, 0xaa, 0xed, 0x93, 0x8e, 0x17, 0xd4, 0xf1, 0xc1, 0x29, 0x44, 0x1a, + 0x1b, 0xe4, 0xcc, 0x84, 0x41, 0xfe, 0x40, 0xdc, 0x1b, 0xef, 0xb6, 0xb1, 0x6f, 0x05, 0x64, 0xc4, + 0x8b, 0xa2, 0x3b, 0xf0, 0x22, 0x11, 0xab, 0x0d, 0xcb, 0x71, 0x7c, 0x51, 0x31, 0xff, 0xfb, 0xcf, + 0xaf, 0xe7, 0xc4, 0x25, 0x59, 0x73, 0x1c, 0x1f, 0x53, 0xfa, 0x20, 0xf0, 0x5d, 0xaf, 0x59, 0x9f, + 0x1b, 0x86, 0x0f, 0x96, 0xf5, 0xff, 0x80, 0xb8, 0x76, 0x92, 0xa9, 0xc3, 0x7e, 0xd9, 0xb2, 0x7e, + 0x6d, 0xaa, 0xfa, 0xa5, 0x4e, 0x34, 0xb1, 0x71, 0x76, 0x9a, 0xc6, 0xdd, 0x1e, 0x6f, 0xdc, 0x75, + 0x09, 0x87, 0x44, 0xf9, 0x68, 0xeb, 0xbe, 0x02, 0xf0, 0xfa, 0x18, 0x49, 0x55, 0x0f, 0xcf, 0xa6, + 0x6a, 0xea, 0xbe, 0x9a, 0x91, 0x1b, 0x0e, 0xfb, 0xdb, 0xdd, 0x2d, 0xe2, 0x63, 0x96, 0x60, 0x1e, + 0x4e, 0xf3, 0x21, 0x11, 0xa7, 0x17, 0x4f, 0xfa, 0x1e, 0xbc, 0x2a, 0xdd, 0x10, 0xf6, 0xea, 0x1e, + 0x9c, 0x13, 0x9a, 0x44, 0x79, 0x2f, 0xf7, 0x8f, 0x4a, 0xd9, 0xed, 0x2e, 0x19, 0x86, 0x2b, 0x8f, + 0x91, 0x15, 0x9b, 0xd9, 0x6c, 0xe4, 0x20, 0x62, 0xc5, 0xde, 0x63, 0x5e, 0x5a, 0xc7, 0x07, 0x1d, + 0x4c, 0x03, 0xfd, 0x6d, 0x78, 0x69, 0x6c, 0x55, 0x14, 0x5e, 0x83, 0xd3, 0xdc, 0x73, 0x59, 0xc9, + 0x6c, 0xb5, 0x20, 0xe9, 0x8d, 0xd8, 0x22, 0x02, 0xab, 0xdf, 0x5d, 0x84, 0xe7, 0x59, 0x2a, 0xf4, + 0x31, 0x9c, 0xe6, 0x18, 0x7a, 0x4d, 0x35, 0x56, 0x63, 0x24, 0xb4, 0xa5, 0x93, 0xc2, 0x38, 0x2b, + 0xfd, 0xda, 0xe7, 0x7f, 0xfc, 0xf3, 0x75, 0x66, 0x01, 0x15, 0xcc, 0xe4, 0x27, 0x80, 0xa8, 0xf8, + 0x2d, 0x60, 0x2e, 0x11, 0xf3, 0xa1, 0xcd, 0x1e, 0x73, 0x6c, 0xb4, 0xac, 0x2a, 0x14, 0x8b, 0xd7, + 0x52, 0x78, 0x9b, 0xbe, 0xf1, 0xe5, 0xbf, 0x3f, 0x54, 0x00, 0xa3, 0x64, 0xa0, 0x15, 0x09, 0x25, + 0x35, 0x8f, 0xef, 0x01, 0x1b, 0x95, 0xa4, 0xf7, 0xa2, 0x4a, 0x7a, 0xcf, 0xd7, 0xaa, 0xa7, 0xff, + 0x3e, 0xd0, 0xdf, 0x1c, 0x91, 0xae, 0xa0, 0xb2, 0x9c, 0xb4, 0x84, 0xd6, 0x53, 0xc0, 0xe6, 0x24, + 0xe1, 0xdd, 0x65, 0x15, 0x85, 0x78, 0xa4, 0x96, 0xc6, 0xb4, 0xf4, 0x9b, 0x23, 0x76, 0x65, 0xb4, + 0x24, 0x67, 0x97, 0xe0, 0xf0, 0x0b, 0x60, 0xf7, 0xa9, 0xcc, 0x50, 0xd1, 0xca, 0x69, 0xec, 0x5c, + 0x7b, 0xe3, 0x79, 0xcc, 0x5f, 0x5f, 0x1f, 0x91, 0x5e, 0x41, 0x15, 0xa5, 0xa4, 0x49, 0x72, 0xdf, + 0x8c, 0x44, 0xc5, 0x51, 0x13, 0x58, 0x9e, 0x24, 0x6a, 0x24, 0x52, 0xbb, 0x91, 0xda, 0x65, 0x53, + 0x2b, 0x3b, 0x46, 0xe4, 0x27, 0xc0, 0x2e, 0x28, 0xbe, 0x2e, 0xbb, 0x5c, 0x91, 0xa9, 0xa4, 0x2a, + 0xbf, 0x8a, 0xb5, 0x14, 0xee, 0xac, 0xdf, 0x19, 0x71, 0xad, 0xa2, 0xd5, 0x49, 0x5c, 0xa5, 0x9c, + 0xc4, 0xcb, 0x25, 0x71, 0xd7, 0x4a, 0x7a, 0x97, 0x53, 0xbf, 0x5c, 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. @@ -784,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. @@ -795,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) (*StakerSingleAssetOrChangeInfo, 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) (*OperatorSingleAssetOrChangeInfo, 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) } @@ -812,9 +900,18 @@ 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.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 +920,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 +929,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 +938,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 +947,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) (*StakerAssetInfo, error) { + out := new(StakerAssetInfo) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueStakerSpecifiedAssetAmount", in, out, opts...) if err != nil { return nil, err } @@ -868,16 +965,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) (*OperatorAssetInfo, error) { + out := new(OperatorAssetInfo) + err := c.cc.Invoke(ctx, "/exocore.assets.v1.Query/QueOperatorSpecifiedAssetAmount", in, out, opts...) if err != nil { return nil, err } @@ -886,7 +983,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 } @@ -895,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. @@ -906,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) (*StakerSingleAssetOrChangeInfo, 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) (*OperatorSingleAssetOrChangeInfo, error) + QueOperatorSpecifiedAssetAmount(context.Context, *QueryOperatorSpecifiedAssetAmountReq) (*OperatorAssetInfo, error) // StakerExCoreAddr queries the staker exocore address. QueStakerExoCoreAddr(context.Context, *QueryStakerExCoreAddr) (*QueryStakerExCoreAddrResponse, error) } @@ -919,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") } @@ -934,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) (*StakerSingleAssetOrChangeInfo, 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) (*OperatorSingleAssetOrChangeInfo, 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) { @@ -951,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 { @@ -961,7 +1081,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 +1099,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 +1117,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 +1135,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 +1153,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 +1171,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 +1189,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 +1207,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 +1225,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,9 +1234,13 @@ 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{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, { MethodName: "QueClientChainInfoByIndex", Handler: _Query_QueClientChainInfoByIndex_Handler, @@ -1155,7 +1279,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) { @@ -1650,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 @@ -1878,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 } @@ -2620,10 +2824,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]*StakerAssetInfo) } var mapkey string - var mapvalue *StakerSingleAssetOrChangeInfo + var mapvalue *StakerAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -2697,7 +2901,7 @@ func (m *QueryAssetInfoResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &StakerSingleAssetOrChangeInfo{} + mapvalue = &StakerAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -2995,10 +3199,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]*OperatorAssetInfo) } var mapkey string - var mapvalue *OperatorSingleAssetOrChangeInfo + var mapvalue *OperatorAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3072,7 +3276,7 @@ func (m *QueryOperatorAssetInfosResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &OperatorSingleAssetOrChangeInfo{} + mapvalue = &OperatorAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -3393,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/restaking_assets_manage/types/query.pb.gw.go b/x/assets/types/query.pb.gw.go similarity index 90% rename from x/restaking_assets_manage/types/query.pb.gw.go rename to x/assets/types/query.pb.gw.go index 8d90490fe..4bc526699 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. @@ -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,26 +838,30 @@ 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_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", "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 ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_QueClientChainInfoByIndex_0 = runtime.ForwardResponseMessage forward_Query_QueAllClientChainInfo_0 = runtime.ForwardResponseMessage diff --git a/x/restaking_assets_manage/types/tx.pb.go b/x/assets/types/tx.pb.go similarity index 66% rename from x/restaking_assets_manage/types/tx.pb.go rename to x/assets/types/tx.pb.go index b287edae2..b5a1a7238 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 @@ -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_adb6ebd423a2c426, []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". @@ -40,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. @@ -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_adb6ebd423a2c426, []int{1} } func (m *ClientChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -107,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 } @@ -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"` + // 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_adb6ebd423a2c426, []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" @@ -156,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"` } @@ -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_adb6ebd423a2c426, []int{3} } func (m *AssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -230,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 } @@ -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_adb6ebd423a2c426, []int{4} } func (m *StakingAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -292,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_undelegation_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"` -} - -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} -} -func (m *StakerSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { +// StakerAssetInfo defines the information for a single asset. +// The type include three states: +// staker's deposited, withdrawable, and currently unbonding amount. +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. + 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 *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 *StakerAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *StakerSingleAssetOrChangeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *StakerAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_StakerSingleAssetOrChangeInfo.Marshal(b, m, deterministic) + return xxx_messageInfo_StakerAssetInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -329,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 *StakerAssetInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakerAssetInfo.Merge(m, src) } -func (m *StakerSingleAssetOrChangeInfo) XXX_Size() int { +func (m *StakerAssetInfo) XXX_Size() int { return m.Size() } -func (m *StakerSingleAssetOrChangeInfo) XXX_DiscardUnknown() { - xxx_messageInfo_StakerSingleAssetOrChangeInfo.DiscardUnknown(m) +func (m *StakerAssetInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StakerAssetInfo.DiscardUnknown(m) } -var xxx_messageInfo_StakerSingleAssetOrChangeInfo 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]*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]*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{} } func (m *StakerAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*StakerAllAssetsInfo) ProtoMessage() {} func (*StakerAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{4} + return fileDescriptor_adb6ebd423a2c426, []int{6} } func (m *StakerAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -381,40 +491,42 @@ func (m *StakerAllAssetsInfo) XXX_DiscardUnknown() { var xxx_messageInfo_StakerAllAssetsInfo proto.InternalMessageInfo -func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerSingleAssetOrChangeInfo { +func (m *StakerAllAssetsInfo) GetAllAssetsState() map[string]*StakerAssetInfo { 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. +// 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_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_undelegation_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"` -} - -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} -} -func (m *OperatorSingleAssetOrChangeInfo) XXX_Unmarshal(b []byte) error { + 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. + 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 *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 *OperatorAssetInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OperatorSingleAssetOrChangeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *OperatorAssetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OperatorSingleAssetOrChangeInfo.Marshal(b, m, deterministic) + return xxx_messageInfo_OperatorAssetInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -424,30 +536,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 *OperatorAssetInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorAssetInfo.Merge(m, src) } -func (m *OperatorSingleAssetOrChangeInfo) XXX_Size() int { +func (m *OperatorAssetInfo) XXX_Size() int { return m.Size() } -func (m *OperatorSingleAssetOrChangeInfo) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorSingleAssetOrChangeInfo.DiscardUnknown(m) +func (m *OperatorAssetInfo) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorAssetInfo.DiscardUnknown(m) } -var xxx_messageInfo_OperatorSingleAssetOrChangeInfo 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]*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]*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{} } func (m *OperatorAllAssetsInfo) String() string { return proto.CompactTextString(m) } func (*OperatorAllAssetsInfo) ProtoMessage() {} func (*OperatorAllAssetsInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_b24e66e530cc30d1, []int{6} + return fileDescriptor_adb6ebd423a2c426, []int{8} } func (m *OperatorAllAssetsInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -476,7 +588,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]*OperatorAssetInfo { if m != nil { return m.AllAssetsState } @@ -503,7 +615,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_adb6ebd423a2c426, []int{9} } func (m *MsgSetExoCoreAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -541,7 +653,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_adb6ebd423a2c426, []int{10} } func (m *MsgSetExoCoreAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -582,7 +694,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_adb6ebd423a2c426, []int{11} } func (m *RegisterClientChainReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -619,7 +731,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_adb6ebd423a2c426, []int{12} } func (m *RegisterClientChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -661,7 +773,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_adb6ebd423a2c426, []int{13} } func (m *RegisterAssetReq) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -698,7 +810,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_adb6ebd423a2c426, []int{14} } func (m *RegisterAssetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -727,109 +839,209 @@ func (m *RegisterAssetResponse) XXX_DiscardUnknown() { var xxx_messageInfo_RegisterAssetResponse proto.InternalMessageInfo -func init() { - proto.RegisterType((*ClientChainInfo)(nil), "exocore.restaking_assets_manage.v1.ClientChainInfo") - 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") +// MsgUpdateParams is the Msg/UpdateParams request type for Erc20 parameters. +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/assets 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. +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.RegisterFile("exocore/restaking_assets_manage/v1/tx.proto", fileDescriptor_b24e66e530cc30d1) -} - -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, 0xf7, 0xde, 0x6f, 0x66, 0x9e, 0xc1, 0xeb, - 0xa8, 0x49, 0x2c, 0x12, 0xa0, 0x52, 0x80, 0x28, 0x83, 0x6b, 0x2e, 0x76, 0x4c, 0x48, 0x29, 0x62, - 0xd4, 0xf4, 0x21, 0x86, 0x0e, 0x2a, 0xad, 0x5f, 0x2d, 0xb1, 0x66, 0xb1, 0x16, 0x10, 0x46, 0xf4, - 0x82, 0x52, 0x2e, 0xf6, 0x50, 0x2e, 0xae, 0x5f, 0xcd, 0x8e, 0x42, 0xdf, 0xc5, 0xa4, 0x24, 0xfe, - 0x4a, 0xb3, 0xec, 0x45, 0x8b, 0x50, 0x9f, 0xd0, 0x92, 0x4f, 0x1d, 0xee, 0xce, 0xa7, 0x8e, 0x12, - 0x8c, 0x4b, 0x81, 0x29, 0x56, 0x25, 0xb9, 0x50, 0xa2, 0xb4, 0x43, 0x1c, 0x22, 0xf7, 0xf9, 0x97, - 0xdc, 0x2d, 0x6c, 0xc6, 0xc1, 0xb9, 0x8a, 0xe7, 0x22, 0xcc, 0x2a, 0xab, 0xd0, 0xc5, 0xf3, 0x78, - 0x85, 0xe8, 0x3a, 0x18, 0xc0, 0xd0, 0x47, 0x19, 0xed, 0x8a, 0x36, 0x31, 0x6c, 0x88, 0x6f, 0xfd, - 0x12, 0x18, 0xf6, 0x11, 0x83, 0xa6, 0x8b, 0x57, 0x48, 0x26, 0x2e, 0x04, 0x43, 0x7c, 0x43, 0x18, - 0x8c, 0x83, 0x21, 0x8b, 0x5b, 0x9b, 0xae, 0x9d, 0x49, 0x5c, 0xd1, 0x26, 0x06, 0x8c, 0x41, 0xb1, - 0x9e, 0xb7, 0xf5, 0x12, 0x48, 0xa3, 0x26, 0x31, 0x79, 0x8e, 0xa6, 0xd2, 0xc1, 0x36, 0x6a, 0x66, - 0x06, 0x84, 0xda, 0x28, 0x6a, 0x92, 0x0a, 0x09, 0x90, 0x8a, 0x6d, 0xa3, 0xa6, 0x5e, 0x02, 0x63, - 0x2b, 0x2e, 0x86, 0x9e, 0x7b, 0x0f, 0x32, 0x97, 0x60, 0x73, 0xd9, 0x23, 0xd6, 0x1a, 0xcd, 0x9c, - 0x12, 0xfa, 0x7a, 0xa7, 0x68, 0x56, 0x48, 0xf4, 0x0a, 0x18, 0xf3, 0x60, 0x0b, 0x05, 0xe6, 0x3d, - 0x14, 0x10, 0xb3, 0x8d, 0xe3, 0x34, 0x37, 0x98, 0x4d, 0x6f, 0x6f, 0xe5, 0x53, 0xb7, 0xb9, 0xf8, - 0x2e, 0x0a, 0x88, 0x0c, 0x73, 0xcb, 0x48, 0x79, 0xd1, 0x1d, 0x5b, 0x7f, 0x19, 0x9c, 0xa5, 0xae, - 0x83, 0x21, 0xab, 0x07, 0xc8, 0x64, 0xad, 0x1a, 0xca, 0x0c, 0x8a, 0x1c, 0x47, 0xda, 0xbb, 0x77, - 0x5a, 0x35, 0xc4, 0xd5, 0xa0, 0x6d, 0x07, 0x88, 0x52, 0xd3, 0x43, 0xd8, 0x61, 0xab, 0x99, 0xa1, - 0x2b, 0xda, 0xc4, 0x88, 0x31, 0xa2, 0x76, 0x6f, 0x8b, 0xcd, 0xc2, 0xdf, 0x71, 0x30, 0x5c, 0xe6, - 0x6d, 0xec, 0x59, 0xce, 0x0b, 0xe0, 0x34, 0x6d, 0xf9, 0xcb, 0xc4, 0x53, 0xb5, 0x54, 0x2b, 0x3d, - 0x03, 0x06, 0x95, 0x2b, 0x51, 0xc8, 0x61, 0x23, 0x5c, 0xea, 0x59, 0x30, 0x64, 0x23, 0xcb, 0xf5, - 0xa1, 0x47, 0x45, 0xf1, 0x46, 0x8c, 0xf6, 0x5a, 0x37, 0xc1, 0x19, 0x46, 0x18, 0xf4, 0x4c, 0x5a, - 0xaf, 0xd5, 0xbc, 0x96, 0x28, 0xd6, 0xf0, 0xec, 0x3b, 0x8f, 0xb6, 0xf2, 0xb1, 0x3f, 0xb6, 0xf2, - 0xaf, 0x38, 0x2e, 0x5b, 0xad, 0x2f, 0x17, 0x2d, 0xe2, 0x2b, 0x46, 0xa8, 0x7f, 0x53, 0xd4, 0x5e, - 0x2b, 0xf1, 0x64, 0x69, 0x71, 0x1e, 0xb3, 0xcd, 0x87, 0x53, 0x40, 0x11, 0x66, 0x1e, 0x33, 0x23, - 0x29, 0x3c, 0x56, 0x85, 0xc3, 0x93, 0xa9, 0x71, 0x2f, 0x2a, 0x0c, 0xf6, 0xa2, 0x42, 0x84, 0x73, - 0x43, 0x51, 0xce, 0x15, 0xfe, 0xd4, 0x40, 0xaa, 0x2a, 0x8f, 0xcc, 0x5e, 0xa9, 0x97, 0x40, 0x4a, - 0x1c, 0x1f, 0x73, 0x19, 0x52, 0xd7, 0x92, 0x86, 0xbc, 0xec, 0xc9, 0xe9, 0xa9, 0xe2, 0xb3, 0x4f, - 0x5a, 0xb1, 0xed, 0xc8, 0x38, 0x2b, 0x64, 0xb3, 0xdc, 0x8b, 0x70, 0x8c, 0x41, 0x3a, 0xb4, 0x92, - 0x95, 0x86, 0x3e, 0xa9, 0x63, 0x26, 0xbb, 0x77, 0xcc, 0x4a, 0xeb, 0xca, 0xf3, 0x1d, 0xee, 0xb8, - 0x2c, 0xfc, 0x16, 0xfe, 0x4d, 0x80, 0xcb, 0x3c, 0x3b, 0x14, 0x54, 0x5d, 0xec, 0x78, 0x48, 0x20, - 0x5b, 0x0c, 0x2a, 0xab, 0x10, 0x3b, 0x48, 0x20, 0xfa, 0x49, 0x03, 0xaf, 0x49, 0x28, 0x36, 0xaa, - 0x11, 0xea, 0x32, 0x05, 0xc9, 0x24, 0x81, 0xd9, 0x80, 0x98, 0xf1, 0x12, 0x63, 0x07, 0x99, 0xeb, - 0xd0, 0xab, 0x2b, 0xee, 0x1d, 0x13, 0xe7, 0x4b, 0x22, 0xdc, 0x2d, 0x19, 0x4d, 0xe2, 0x5c, 0x0c, - 0x96, 0xa0, 0xb8, 0x39, 0xb0, 0x83, 0x3e, 0xe1, 0x81, 0xf4, 0x1f, 0x34, 0x30, 0x61, 0x41, 0x6c, - 0x36, 0x5c, 0xb6, 0x6a, 0x07, 0xb0, 0x71, 0x20, 0xaa, 0x93, 0xa8, 0x5e, 0xc1, 0x82, 0x78, 0x49, - 0x05, 0xeb, 0x05, 0xea, 0x17, 0x0d, 0x4c, 0x35, 0xa0, 0xcb, 0xcc, 0x3a, 0xb6, 0x91, 0x87, 0x1c, - 0x79, 0xb3, 0x1c, 0x84, 0x2c, 0x71, 0x02, 0xc8, 0x5e, 0xe5, 0x21, 0x3f, 0xee, 0x88, 0xd8, 0x03, - 0x5e, 0xe1, 0xc7, 0x38, 0x18, 0x93, 0xcd, 0x2e, 0x7b, 0x9e, 0xe8, 0x34, 0x15, 0x2d, 0xae, 0x83, - 0x14, 0xf4, 0xbc, 0x90, 0xa6, 0x94, 0x41, 0xc6, 0x1b, 0x99, 0x98, 0x48, 0x4e, 0x7f, 0xd8, 0x0f, - 0x9b, 0xbb, 0xb8, 0x2c, 0xb6, 0x57, 0x55, 0xee, 0x6d, 0x0e, 0xb3, 0xa0, 0x65, 0x9c, 0x85, 0x91, - 0xcd, 0xec, 0x97, 0x1a, 0x18, 0xeb, 0xa2, 0xa7, 0xa7, 0x40, 0x62, 0x0d, 0xb5, 0xd4, 0x35, 0xc6, - 0x3f, 0xf5, 0x25, 0x70, 0x6a, 0xaf, 0x91, 0xc9, 0xe9, 0x72, 0xff, 0xa8, 0x7a, 0xb0, 0xda, 0x90, - 0xfe, 0x66, 0xe2, 0x6f, 0x6b, 0x85, 0xbf, 0x12, 0x20, 0xbf, 0x58, 0x43, 0x01, 0x64, 0xa4, 0xe7, - 0x21, 0xf8, 0x4a, 0x03, 0x2f, 0x76, 0x9e, 0xc7, 0xe7, 0x47, 0xfe, 0x17, 0xd8, 0xde, 0xe9, 0xec, - 0xce, 0x7a, 0xa2, 0xb0, 0x9a, 0xa4, 0x81, 0x9f, 0x3f, 0xeb, 0xc3, 0x68, 0x8b, 0x0d, 0xfc, 0x3f, - 0x65, 0xfd, 0xcf, 0x71, 0x70, 0x3e, 0xec, 0x6f, 0x94, 0xf7, 0x8d, 0x9e, 0xbc, 0x5f, 0xe8, 0x87, - 0x61, 0x5d, 0x9d, 0xf6, 0xc5, 0xfc, 0xaf, 0xfb, 0x66, 0xfe, 0xa7, 0x51, 0xe6, 0x57, 0x0e, 0x83, - 0xab, 0x0f, 0xee, 0x3f, 0x89, 0x83, 0xd1, 0x05, 0xea, 0x54, 0x11, 0x9b, 0x93, 0xaf, 0x62, 0xd9, - 0xb6, 0x03, 0xfd, 0x26, 0x38, 0xb3, 0x12, 0x10, 0xdf, 0x0c, 0x27, 0x04, 0xc9, 0xeb, 0xcc, 0xe6, - 0xc3, 0xa9, 0xb4, 0x6a, 0x40, 0x59, 0x4a, 0xaa, 0x2c, 0x70, 0xb1, 0x63, 0x24, 0xb9, 0xb6, 0xda, - 0xd2, 0x6f, 0x80, 0x24, 0x7f, 0x18, 0x43, 0xdb, 0xf8, 0x33, 0x6c, 0x01, 0x45, 0x2c, 0x34, 0x9d, - 0x04, 0xa3, 0x96, 0x18, 0x11, 0xd5, 0xb3, 0xcd, 0x7d, 0xa8, 0xf1, 0xe4, 0x9c, 0xb5, 0x37, 0x3b, - 0x0a, 0x8c, 0x6f, 0x00, 0x3d, 0xa2, 0xdb, 0x39, 0xed, 0xa5, 0xac, 0xce, 0x41, 0x93, 0xbf, 0xf0, - 0x65, 0x70, 0x99, 0x8a, 0xfb, 0xc0, 0x8c, 0x18, 0xb5, 0x87, 0x2e, 0x39, 0xc9, 0x18, 0x59, 0xa9, - 0xd4, 0x31, 0xa7, 0x56, 0x43, 0x8d, 0x99, 0xb7, 0xbe, 0x79, 0x90, 0x8f, 0xfd, 0xf3, 0x20, 0x1f, - 0xfb, 0x62, 0x77, 0x63, 0xb2, 0x33, 0xe3, 0x6f, 0x77, 0x37, 0x26, 0xc7, 0xc3, 0x59, 0x7c, 0x5f, - 0x31, 0x0b, 0x97, 0xc0, 0xf8, 0xbe, 0x4d, 0x03, 0xd1, 0x1a, 0xc1, 0x14, 0xf1, 0xe1, 0xe2, 0x82, - 0x81, 0x1c, 0x97, 0xb2, 0x48, 0x54, 0x03, 0x7d, 0x7e, 0xbc, 0x26, 0x7c, 0x00, 0x06, 0xda, 0x03, - 0x74, 0x72, 0xfa, 0x5a, 0x3f, 0xac, 0x79, 0x6a, 0x38, 0x37, 0x84, 0x83, 0x99, 0x9b, 0x91, 0xac, - 0xdf, 0x8f, 0x66, 0x9d, 0xeb, 0x38, 0xa6, 0x5d, 0xb2, 0x28, 0x5c, 0x06, 0x97, 0xba, 0x26, 0xa7, - 0x92, 0xff, 0x4d, 0x03, 0xa9, 0x50, 0x2e, 0x58, 0x7a, 0xec, 0xb4, 0xcb, 0x91, 0xb4, 0x0f, 0x39, - 0x8a, 0xc9, 0x84, 0xaf, 0x1f, 0x94, 0x70, 0xa6, 0x4b, 0xc2, 0xc2, 0x41, 0xe1, 0x22, 0x38, 0xff, - 0x54, 0x2a, 0x32, 0xc9, 0xe9, 0x5f, 0x13, 0x20, 0xb1, 0x40, 0x1d, 0xfd, 0x3b, 0x0d, 0xa4, 0xab, - 0x88, 0xc9, 0x57, 0xa9, 0xf3, 0xb0, 0x5d, 0xef, 0x07, 0xe5, 0x3e, 0x06, 0x65, 0xdf, 0x3d, 0x92, - 0x59, 0x08, 0x8b, 0x3f, 0x24, 0x63, 0x5d, 0x7a, 0xa3, 0xcf, 0xf4, 0xe3, 0xb6, 0x3b, 0x63, 0xb3, - 0xef, 0x1d, 0xd9, 0x56, 0x81, 0xba, 0xaf, 0x81, 0x91, 0x48, 0x15, 0xf5, 0x37, 0x0f, 0xe3, 0x32, - 0xe4, 0x50, 0xf6, 0xc6, 0x11, 0xac, 0x24, 0x84, 0xec, 0xa9, 0xfb, 0xbb, 0x1b, 0x93, 0xda, 0xec, - 0x67, 0x8f, 0xb6, 0x73, 0xda, 0xe3, 0xed, 0x9c, 0xf6, 0x64, 0x3b, 0xa7, 0x7d, 0xbf, 0x93, 0x8b, - 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, + 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((*StakerAssetInfo)(nil), "exocore.assets.v1.StakerAssetInfo") + proto.RegisterType((*StakerAllAssetsInfo)(nil), "exocore.assets.v1.StakerAllAssetsInfo") + 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]*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{ + // 1325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x4b, 0x73, 0x13, 0xc7, + 0x13, 0xf7, 0xca, 0xc2, 0x8f, 0xf6, 0x4b, 0x1e, 0x19, 0x2c, 0x89, 0x3f, 0x32, 0xa5, 0x3f, 0xa1, + 0x1c, 0x17, 0x48, 0xe0, 0x54, 0x08, 0x31, 0x5c, 0x64, 0x03, 0x55, 0x4e, 0x41, 0x92, 0x5a, 0x41, + 0x0e, 0x1c, 0xd8, 0x1a, 0x69, 0xc7, 0xeb, 0x8d, 0x77, 0x77, 0x36, 0x3b, 0x23, 0x2c, 0x71, 0x4a, + 0xe5, 0x94, 0xe2, 0x44, 0xe5, 0x13, 0x70, 0xce, 0x89, 0x03, 0x87, 0x7c, 0x04, 0x2a, 0x27, 0xc2, + 0x29, 0xc5, 0x81, 0xa2, 0xcc, 0x01, 0x3e, 0x46, 0x6a, 0x1e, 0x2b, 0x6b, 0xed, 0xf5, 0xa3, 0x62, + 0x55, 0xe5, 0x02, 0x9a, 0xe9, 0xee, 0x5f, 0xf7, 0xaf, 0xa7, 0xbb, 0x67, 0xd6, 0x50, 0x22, 0x1d, + 0xda, 0xa2, 0x11, 0xa9, 0x61, 0xc6, 0x08, 0x67, 0xb5, 0xc7, 0x57, 0x6b, 0xbc, 0x53, 0x0d, 0x23, + 0xca, 0x29, 0x9a, 0xd5, 0xb2, 0xaa, 0x92, 0x55, 0x1f, 0x5f, 0x2d, 0xcd, 0x62, 0xdf, 0x0d, 0x68, + 0x4d, 0xfe, 0xab, 0xb4, 0x4a, 0xf3, 0x2d, 0xca, 0x7c, 0xca, 0x6a, 0x3e, 0x73, 0x84, 0xb5, 0xcf, + 0x1c, 0x2d, 0x28, 0x2a, 0x81, 0x25, 0x57, 0x35, 0xb5, 0xd0, 0xa2, 0xf2, 0x7e, 0xaf, 0x21, 0x8e, + 0xb0, 0x1f, 0xcb, 0xe7, 0x1c, 0xea, 0x50, 0x65, 0x27, 0x7e, 0xa9, 0xdd, 0x4a, 0x13, 0xe0, 0x07, + 0xec, 0xb5, 0xc9, 0x1d, 0x97, 0x78, 0x36, 0xba, 0x0f, 0x23, 0xd8, 0xa7, 0xed, 0x80, 0x17, 0x8c, + 0xf3, 0xc6, 0xe2, 0xf8, 0xea, 0xcd, 0x57, 0xef, 0x16, 0x86, 0xde, 0xbe, 0x5b, 0xb8, 0xe8, 0xb8, + 0x7c, 0xb3, 0xdd, 0xac, 0xb6, 0xa8, 0xaf, 0x9d, 0xea, 0xff, 0x2e, 0x33, 0x7b, 0xab, 0xc6, 0xbb, + 0x21, 0x61, 0xd5, 0xf5, 0x80, 0xbf, 0x79, 0x79, 0x19, 0x74, 0x4c, 0xeb, 0x01, 0x37, 0x35, 0x56, + 0xe5, 0xaf, 0x0c, 0xcc, 0xac, 0x79, 0x2e, 0x09, 0xf8, 0xda, 0x26, 0x76, 0x83, 0xf5, 0x60, 0x83, + 0x22, 0x04, 0xd9, 0x00, 0xfb, 0x44, 0xf9, 0x31, 0xe5, 0x6f, 0x74, 0x16, 0xc6, 0x7d, 0xc2, 0xb1, + 0xe5, 0x06, 0x1b, 0xb4, 0x90, 0x91, 0x82, 0x31, 0xb1, 0x21, 0x0d, 0x8a, 0x30, 0xd6, 0x12, 0xd6, + 0x96, 0x6b, 0x17, 0x86, 0xcf, 0x1b, 0x8b, 0x59, 0x73, 0x54, 0xae, 0xd7, 0x6d, 0x54, 0x85, 0xbc, + 0xe6, 0x6e, 0x69, 0x95, 0xc0, 0x26, 0x9d, 0x42, 0x56, 0x6a, 0xc5, 0x09, 0xd7, 0xae, 0x6d, 0xd2, + 0x41, 0x35, 0xc8, 0x6f, 0xb8, 0x01, 0xf6, 0xdc, 0x27, 0x98, 0xbb, 0x34, 0xb0, 0x9a, 0x1e, 0x6d, + 0x6d, 0xb1, 0xc2, 0x29, 0xa9, 0x8f, 0xfa, 0x45, 0xab, 0x52, 0x82, 0xd6, 0x20, 0xef, 0xe1, 0x2e, + 0x89, 0xac, 0x27, 0x24, 0xa2, 0x56, 0x2f, 0x8c, 0x11, 0x61, 0xb0, 0x3a, 0xb7, 0xf3, 0x6e, 0x21, + 0x77, 0x57, 0x88, 0x1f, 0x92, 0x88, 0x2a, 0x37, 0xb7, 0xcc, 0x9c, 0x97, 0xdc, 0xb1, 0xd1, 0x67, + 0x30, 0xcd, 0x5c, 0x27, 0xc0, 0xbc, 0x1d, 0x11, 0x4b, 0xa4, 0xac, 0x30, 0x2a, 0x29, 0x4e, 0xf5, + 0x76, 0xef, 0x77, 0x43, 0x22, 0xd4, 0xb0, 0x6d, 0x47, 0x84, 0x31, 0xcb, 0x23, 0x81, 0xc3, 0x37, + 0x0b, 0x63, 0xe7, 0x8d, 0xc5, 0x29, 0x73, 0x4a, 0xef, 0xde, 0x95, 0x9b, 0x95, 0xa7, 0x06, 0x4c, + 0xd6, 0xc3, 0x70, 0x80, 0x09, 0x1d, 0xff, 0xd7, 0x09, 0xad, 0xbc, 0xcf, 0xc0, 0x78, 0x5d, 0x54, + 0xdd, 0x81, 0x91, 0x9c, 0x81, 0x11, 0xd6, 0xf5, 0x9b, 0xd4, 0xd3, 0x61, 0xe8, 0x15, 0x2a, 0xc0, + 0xa8, 0xe6, 0x15, 0xc7, 0xa0, 0x97, 0xa8, 0x04, 0x63, 0x36, 0x69, 0xb9, 0x3e, 0xf6, 0x98, 0x74, + 0x3c, 0x65, 0xf6, 0xd6, 0xc8, 0x82, 0x49, 0x4e, 0x39, 0xf6, 0x2c, 0xd6, 0x0e, 0x43, 0xaf, 0x2b, + 0x4f, 0xee, 0xa4, 0xc5, 0x3a, 0x21, 0x11, 0x1b, 0x12, 0x70, 0x30, 0x07, 0x7e, 0x40, 0x16, 0x47, + 0x0f, 0x2a, 0xcb, 0xc4, 0x69, 0x8d, 0x25, 0x4f, 0xab, 0xf2, 0xa7, 0x01, 0xb9, 0x06, 0xc7, 0x5b, + 0x6e, 0xe0, 0xec, 0x66, 0xfa, 0x0e, 0xe4, 0x64, 0xb3, 0x5b, 0x4d, 0xcc, 0xdc, 0x96, 0x32, 0x14, + 0x59, 0x9f, 0x58, 0xfe, 0x5f, 0x75, 0xdf, 0x9c, 0xa9, 0xf6, 0xec, 0xcc, 0x69, 0xb9, 0xb9, 0x2a, + 0x8c, 0x24, 0x4e, 0x00, 0x73, 0x4c, 0x61, 0x5b, 0x2a, 0xaf, 0x7a, 0x08, 0x64, 0x06, 0x90, 0x57, + 0xa4, 0x91, 0xef, 0x0b, 0xe0, 0xba, 0x1a, 0x08, 0x3b, 0x19, 0x98, 0x11, 0x64, 0x48, 0xb4, 0xcb, + 0x25, 0x80, 0x39, 0xe5, 0xdb, 0x26, 0x21, 0x65, 0x2e, 0xb7, 0x06, 0x38, 0x88, 0x90, 0x44, 0xbe, + 0xa5, 0x80, 0x55, 0x0c, 0xc8, 0x87, 0xfc, 0xb6, 0xcb, 0x37, 0xed, 0x08, 0x6f, 0xe3, 0xa6, 0x47, + 0x06, 0x4a, 0xb9, 0x1f, 0x58, 0xbb, 0x0b, 0xe1, 0xf4, 0x36, 0x76, 0xb9, 0xd5, 0x0e, 0x9a, 0x34, + 0xb0, 0x45, 0xa6, 0xb5, 0xc3, 0xe1, 0x01, 0x38, 0xcc, 0x0b, 0xe8, 0x07, 0x31, 0x72, 0x9c, 0x64, + 0x03, 0xf2, 0x3a, 0xc9, 0x9e, 0x27, 0xf3, 0xcc, 0x64, 0xa2, 0x6d, 0xc8, 0x61, 0xcf, 0xb3, 0x54, + 0x5d, 0x58, 0x8c, 0x63, 0x2e, 0x5a, 0x75, 0x78, 0x71, 0x62, 0x79, 0x25, 0xa5, 0x68, 0x52, 0x10, + 0xaa, 0xbd, 0x55, 0x43, 0x18, 0xdf, 0x0e, 0x78, 0xd4, 0x35, 0xa7, 0x71, 0x62, 0xb3, 0x44, 0x20, + 0x9f, 0xa2, 0x86, 0x72, 0x30, 0xbc, 0x45, 0xba, 0x7a, 0x34, 0x88, 0x9f, 0xe8, 0x3a, 0x9c, 0x7a, + 0x2c, 0x2e, 0x20, 0x99, 0xf9, 0x89, 0xe5, 0xca, 0xc1, 0x31, 0xf4, 0xca, 0x57, 0x19, 0xac, 0x64, + 0xae, 0x1b, 0x95, 0xb7, 0x59, 0x98, 0xfd, 0x2e, 0x24, 0x11, 0xe6, 0xb4, 0xaf, 0x96, 0x7a, 0xf3, + 0x61, 0x80, 0x35, 0xa4, 0xe6, 0x83, 0x3e, 0x4d, 0x02, 0x33, 0x54, 0x7b, 0x1d, 0x64, 0xe1, 0x4c, + 0xc7, 0xa0, 0xff, 0x55, 0xd1, 0xa0, 0x0e, 0x14, 0x7b, 0xc4, 0xf6, 0x79, 0xcd, 0x0e, 0xc0, 0xeb, + 0x7c, 0x0c, 0xbf, 0xd7, 0xf3, 0x33, 0x03, 0x2e, 0xee, 0x71, 0xdd, 0xd7, 0x97, 0x16, 0xde, 0xe0, + 0x24, 0xb2, 0x98, 0x87, 0xd9, 0xe6, 0x40, 0xc6, 0x7d, 0x25, 0x19, 0xc7, 0x6e, 0xa7, 0xd6, 0x85, + 0xa3, 0x86, 0xf0, 0x53, 0xf9, 0x64, 0xc0, 0xe9, 0x5e, 0x71, 0x25, 0x7a, 0x68, 0xe3, 0xc0, 0x1e, + 0xba, 0x99, 0x52, 0xbf, 0xa9, 0x18, 0xc7, 0xea, 0x22, 0xe7, 0xb8, 0x5d, 0xb4, 0x92, 0xec, 0xa2, + 0x0b, 0x87, 0x45, 0x91, 0xd6, 0x47, 0xef, 0x33, 0x30, 0x7b, 0x8f, 0x39, 0x0d, 0xc2, 0x6f, 0x77, + 0xe8, 0x1a, 0x8d, 0x48, 0xdd, 0xb6, 0x23, 0x74, 0x03, 0x26, 0x37, 0x22, 0xea, 0x5b, 0xf1, 0x15, + 0xad, 0xfa, 0xa8, 0xf0, 0xe6, 0xe5, 0xe5, 0x39, 0x9d, 0xca, 0xba, 0x92, 0x34, 0x78, 0xe4, 0x06, + 0x8e, 0x39, 0x21, 0xb4, 0xf5, 0x16, 0xfa, 0x1a, 0x26, 0xc4, 0xd5, 0x14, 0xdb, 0x66, 0x8e, 0xb0, + 0x05, 0x46, 0x78, 0x6c, 0xba, 0x04, 0xb3, 0x2d, 0xf9, 0x5e, 0xd4, 0x17, 0xa7, 0xc0, 0xd0, 0xef, + 0x83, 0x99, 0xd6, 0xee, 0x43, 0x52, 0xc6, 0x78, 0x09, 0x50, 0x42, 0xb7, 0xff, 0xa9, 0x92, 0x6b, + 0xf5, 0xbf, 0x3a, 0xc5, 0x1d, 0x5b, 0x87, 0x73, 0x4c, 0x4e, 0x13, 0x2b, 0x61, 0xd4, 0x7b, 0x82, + 0xa9, 0xda, 0x32, 0x4b, 0x4a, 0xa9, 0xef, 0xd1, 0xda, 0x88, 0x35, 0x56, 0xae, 0xfd, 0xfa, 0x7c, + 0x61, 0xe8, 0xd3, 0xf3, 0x85, 0xa1, 0x5f, 0x3e, 0xbe, 0x58, 0xea, 0x67, 0xfc, 0xf4, 0xe3, 0x8b, + 0xa5, 0x62, 0xfc, 0x08, 0xdf, 0x97, 0xcc, 0xca, 0x59, 0x28, 0xee, 0xdb, 0x34, 0x09, 0x0b, 0x69, + 0xc0, 0x88, 0xb8, 0xde, 0xcf, 0x98, 0xc4, 0x71, 0x19, 0x4f, 0x78, 0x35, 0xc9, 0x4f, 0x27, 0x3b, + 0x84, 0x6b, 0x90, 0xed, 0x3d, 0xfe, 0xd2, 0x87, 0xeb, 0x9e, 0x87, 0xb9, 0x29, 0xf5, 0x57, 0x6e, + 0x24, 0x48, 0xde, 0x49, 0x92, 0x2c, 0xf7, 0xf5, 0x57, 0x4a, 0xd0, 0x95, 0x73, 0x70, 0x36, 0x95, + 0x8b, 0xe6, 0xfa, 0x87, 0x01, 0xb9, 0x58, 0x2e, 0x8b, 0xf1, 0xc4, 0x2c, 0xaf, 0x24, 0x58, 0x1e, + 0xfe, 0xf6, 0x51, 0xfc, 0xbe, 0x3c, 0x8c, 0x5f, 0x21, 0x85, 0x9f, 0x04, 0xa8, 0xcc, 0xc3, 0xe9, + 0x3d, 0x91, 0x6b, 0x4e, 0xbf, 0x19, 0x30, 0x73, 0x8f, 0x39, 0x0f, 0x42, 0x1b, 0x73, 0xf2, 0xbd, + 0xfc, 0xec, 0x42, 0xd7, 0x60, 0x1c, 0xb7, 0xf9, 0x26, 0x8d, 0x5c, 0xde, 0x3d, 0x92, 0xcf, 0xae, + 0x2a, 0xfa, 0x0a, 0x46, 0xd4, 0x87, 0x9b, 0xe6, 0x53, 0x4c, 0xe1, 0xa3, 0x5c, 0xac, 0x66, 0xc5, + 0x0c, 0x34, 0xb5, 0xfa, 0xca, 0xb4, 0x20, 0xb3, 0x0b, 0x54, 0x29, 0xc2, 0xfc, 0x9e, 0x98, 0xe2, + 0x78, 0x97, 0x7f, 0x1f, 0x86, 0xe1, 0x7b, 0xcc, 0x41, 0x8f, 0x60, 0x32, 0x11, 0x73, 0x5a, 0x85, + 0xec, 0xc1, 0x28, 0x2d, 0x1d, 0xad, 0x13, 0xfb, 0x41, 0x3f, 0xc2, 0x5c, 0x83, 0x70, 0x75, 0x81, + 0xf7, 0x4f, 0x96, 0x0b, 0xe9, 0x18, 0xc9, 0xee, 0x28, 0x5d, 0x3a, 0x8e, 0x56, 0xcf, 0x57, 0x08, + 0xf9, 0x94, 0xb2, 0x43, 0x9f, 0xa7, 0x80, 0xa4, 0xb7, 0x5a, 0xa9, 0x7a, 0x5c, 0x55, 0xed, 0xf1, + 0x11, 0x4c, 0x25, 0xca, 0x01, 0xfd, 0xff, 0x10, 0x80, 0xb8, 0xd4, 0x4b, 0x8b, 0x47, 0x2b, 0x29, + 0xfc, 0xd2, 0xa9, 0x9f, 0x3f, 0xbe, 0x58, 0x32, 0x56, 0xbf, 0x79, 0xb5, 0x53, 0x36, 0x5e, 0xef, + 0x94, 0x8d, 0xf7, 0x3b, 0x65, 0xe3, 0xd9, 0x87, 0xf2, 0xd0, 0xeb, 0x0f, 0xe5, 0xa1, 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. @@ -844,6 +1056,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 @@ -860,9 +1074,18 @@ 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.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 } @@ -871,7 +1094,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 } @@ -880,7 +1103,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 } @@ -889,6 +1112,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 @@ -901,6 +1126,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") } @@ -915,6 +1143,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 { @@ -925,7 +1171,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)) @@ -943,7 +1189,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)) @@ -961,7 +1207,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)) @@ -970,9 +1216,13 @@ 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{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, { MethodName: "SetStakerExoCoreAddr", Handler: _Msg_SetStakerExoCoreAddr_Handler, @@ -987,7 +1237,40 @@ 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) { + 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) { @@ -1032,8 +1315,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 } @@ -1059,6 +1342,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) @@ -1086,8 +1418,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 } @@ -1180,7 +1512,7 @@ func (m *StakingAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *StakerSingleAssetOrChangeInfo) 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]) @@ -1190,20 +1522,20 @@ func (m *StakerSingleAssetOrChangeInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *StakerSingleAssetOrChangeInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *StakerAssetInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *StakerSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *StakerAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.WaitUndelegationAmountOrWantChangeValue.Size() + size := m.WaitUnbondingAmount.Size() i -= size - if _, err := m.WaitUndelegationAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1211,9 +1543,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)) @@ -1221,9 +1553,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)) @@ -1282,7 +1614,7 @@ func (m *StakerAllAssetsInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *OperatorSingleAssetOrChangeInfo) 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]) @@ -1292,20 +1624,40 @@ func (m *OperatorSingleAssetOrChangeInfo) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorSingleAssetOrChangeInfo) MarshalTo(dAtA []byte) (int, error) { +func (m *OperatorAssetInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *OperatorAssetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.WaitUndelegationAmountOrWantChangeValue.Size() + size := m.OperatorUnbondableAmountAfterSlash.Size() + i -= size + if _, err := m.OperatorUnbondableAmountAfterSlash.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.OperatorUnbondingAmount.Size() + i -= size + if _, err := m.OperatorUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.WaitUnbondingAmount.Size() i -= size - if _, err := m.WaitUndelegationAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.WaitUnbondingAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1313,9 +1665,9 @@ func (m *OperatorSingleAssetOrChangeInfo) MarshalToSizedBuffer(dAtA []byte) (int i-- dAtA[i] = 0x1a { - size := m.OperatorOwnAmountOrWantChangeValue.Size() + size := m.OperatorAmount.Size() i -= size - if _, err := m.OperatorOwnAmountOrWantChangeValue.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.OperatorAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1323,9 +1675,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)) @@ -1593,25 +1945,99 @@ func (m *RegisterAssetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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++ +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 } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *ClientChainInfo) Size() (n int) { - if m == nil { - return 0 - } + +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 - l = len(m.Name) - if l > 0 { + { + 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 *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 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { n += 1 + l + sovTx(uint64(l)) } l = len(m.MetaInfo) @@ -1621,8 +2047,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)) @@ -1640,6 +2066,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 @@ -1666,8 +2116,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 { @@ -1691,17 +2141,17 @@ func (m *StakingAssetInfo) Size() (n int) { return n } -func (m *StakerSingleAssetOrChangeInfo) Size() (n int) { +func (m *StakerAssetInfo) 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.WaitUndelegationAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmount.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1728,17 +2178,21 @@ func (m *StakerAllAssetsInfo) Size() (n int) { return n } -func (m *OperatorSingleAssetOrChangeInfo) Size() (n int) { +func (m *OperatorAssetInfo) 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.OperatorAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.WaitUndelegationAmountOrWantChangeValue.Size() + l = m.WaitUnbondingAmount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.OperatorUnbondingAmount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.OperatorUnbondableAmountAfterSlash.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1854,12 +2308,120 @@ 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 } 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 @@ -1974,9 +2536,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 @@ -1986,7 +2548,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 } @@ -2010,11 +2572,163 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { break } } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LayerZeroChainID", wireType) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LayerZeroChainID", wireType) + } + m.LayerZeroChainID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LayerZeroChainID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignatureType", 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.SignatureType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AddressLength", wireType) + } + m.AddressLength = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AddressLength |= uint32(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 *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) } - m.LayerZeroChainID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2024,14 +2738,27 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LayerZeroChainID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 7: + 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 SignatureType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2059,13 +2786,13 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SignatureType = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AddressLength", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExocoreChainIndex", wireType) } - m.AddressLength = 0 + m.ExocoreChainIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2075,7 +2802,7 @@ func (m *ClientChainInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AddressLength |= uint32(b&0x7F) << shift + m.ExocoreChainIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2300,9 +3027,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 @@ -2312,7 +3039,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 } @@ -2490,7 +3217,7 @@ func (m *StakingAssetInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *StakerSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { +func (m *StakerAssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2513,15 +3240,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: StakerAssetInfo: 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: StakerAssetInfo: 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 { @@ -2549,13 +3276,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 { @@ -2583,13 +3310,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 WaitUndelegationAmountOrWantChangeValue", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WaitUnbondingAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2617,7 +3344,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.WaitUnbondingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2701,10 +3428,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]*StakerAssetInfo) } var mapkey string - var mapvalue *StakerSingleAssetOrChangeInfo + var mapvalue *StakerAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -2778,7 +3505,7 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &StakerSingleAssetOrChangeInfo{} + mapvalue = &StakerAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -2821,7 +3548,7 @@ func (m *StakerAllAssetsInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *OperatorSingleAssetOrChangeInfo) Unmarshal(dAtA []byte) error { +func (m *OperatorAssetInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2844,15 +3571,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: OperatorAssetInfo: 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: OperatorAssetInfo: 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 { @@ -2880,13 +3607,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 OperatorAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2914,13 +3641,81 @@ 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.OperatorAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } 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 WaitUnbondingAmount", 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.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 OperatorUnbondingAmount", 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.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 OperatorUnbondableAmountAfterSlash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2948,7 +3743,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.OperatorUnbondableAmountAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3032,10 +3827,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]*OperatorAssetInfo) } var mapkey string - var mapvalue *OperatorSingleAssetOrChangeInfo + var mapvalue *OperatorAssetInfo for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3109,7 +3904,7 @@ func (m *OperatorAllAssetsInfo) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &OperatorSingleAssetOrChangeInfo{} + mapvalue = &OperatorAssetInfo{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -3735,6 +4530,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 ead51495b..8bece122d 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" @@ -26,7 +26,6 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand( QuerySingleDelegationInfo(), QueryDelegationInfo(), - QueryOperatorInfo(), ) return cmd } @@ -47,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{ @@ -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 2fddf42d6..3e8854a55 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 f54838680..047d911e0 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -1,19 +1,15 @@ package keeper import ( - "fmt" - - sdkmath "cosmossdk.io/math" + "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" ) // 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) @@ -24,58 +20,74 @@ 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.operatorOptedInKeeper.GetOperatorCanUndelegateHeight(ctx, record.AssetID, 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())) + // 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.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())) + } + _, err = k.SetSingleUndelegationRecord(ctx, record) + if err != nil { + panic(err) + } + 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 + // #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) + if err != nil { + panic(err) } - _, err = k.SetSingleUndelegationRecord(ctx, record) + // and the other is the fact that it matures at the next block + err = k.StoreWaitCompleteRecord(ctx, recordKey, record) if err != nil { panic(err) } continue } + // TODO(mike): ensure that operator is required to perform self delegation to match above. - // 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 err != nil { + panic(err) + } + if record.Amount.GT(delegationInfo.UndelegatableAfterSlash) { + record.ActualCompletedAmount = delegationInfo.UndelegatableAfterSlash + } 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, + UndelegatableAfterSlash: 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, - WaitUndelegationAmountOrWantChangeValue: recordAmountNeg, + err = k.assetsKeeper.UpdateStakerAssetState(ctx, record.StakerID, record.AssetID, types.StakerSingleAssetChangeInfo{ + WithdrawableAmount: record.ActualCompletedAmount, + WaitUnbondingAmount: recordAmountNeg, }) if err != nil { panic(err) } // update the operator state - err = k.restakingStateKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: actualCanUndelegateAmount.Neg(), - WaitUndelegationAmountOrWantChangeValue: recordAmountNeg, + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAccAddress, record.AssetID, types.OperatorSingleAssetChangeInfo{ + 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 a7eb69c73..53933714e 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 @@ -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 @@ -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") } @@ -109,10 +109,10 @@ 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.IsOperator(ctx, params.OperatorAddress) { - return delegationtype.ErrOperatorNotExist + 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 @@ -127,26 +127,28 @@ func (k Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPara return delegationtype.ErrOpAmountIsNegative } - stakerID, assetID := types.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) + stakerID, assetID := assetstype.GetStakeIDAndAssetID(params.ClientChainLzID, params.StakerAddress, params.AssetsAddress) - info, err := k.restakingStateKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) + // check if the staker asset has been deposited and the canWithdraw amount is bigger than the delegation amount + info, err := k.assetsKeeper.GetStakerSpecifiedAssetInfo(ctx, stakerID, assetID) if err != nil { return err } - if info.CanWithdrawAmountOrWantChangeValue.LT(params.OpAmount) { - return delegationtype.ErrDelegationAmountTooBig + 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)) } - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ - CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), + // update staker asset state + 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, types.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: params.OpAmount, + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ + TotalAmount: params.OpAmount, }) if err != nil { return err @@ -154,7 +156,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, + UndelegatableAmount: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { @@ -164,30 +166,39 @@ 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.operatorKeeper.UpdateOptedInAssetsState(ctx, stakerID, assetID, params.OperatorAddress.String(), params.OpAmount) + if err != nil { + return err + } + + // call the hooks registered by the other modules + 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.IsOperator(ctx, params.OperatorAddress) { + if !k.operatorKeeper.IsOperator(ctx, params.OperatorAddress) { return delegationtype.ErrOperatorNotExist } if params.OpAmount.IsNegative() { 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.CanUndelegationAmount) { - return errorsmod.Wrap(delegationtype.ErrUndelegationAmountTooBig, fmt.Sprintf("UndelegationAmount:%s,CanUndelegationAmount:%s", params.OpAmount, delegationState.CanUndelegationAmount)) + if params.OpAmount.GT(delegationState.UndelegatableAmount) { + return errorsmod.Wrap(delegationtype.ErrUndelegationAmountTooBig, fmt.Sprintf("UndelegationAmount:%s,UndelegatableAmount:%s", params.OpAmount, delegationState.UndelegatableAmount)) } + // record Undelegation event r := &delegationtype.UndelegationRecord{ StakerID: stakerID, AssetID: assetID, @@ -199,38 +210,54 @@ 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.operatorKeeper.GetUnbondingExpirationBlockNumber(ctx, params.OperatorAddress, r.BlockNumber) err = k.SetUndelegationRecords(ctx, []*delegationtype.UndelegationRecord{r}) if err != nil { return err } + // update delegation state delegatorAndAmount := make(map[string]*delegationtype.DelegationAmounts) delegatorAndAmount[params.OperatorAddress.String()] = &delegationtype.DelegationAmounts{ - CanUndelegationAmount: params.OpAmount.Neg(), - WaitUndelegationAmount: params.OpAmount, + UndelegatableAmount: params.OpAmount.Neg(), + WaitUndelegationAmount: params.OpAmount, + UndelegatableAfterSlash: params.OpAmount, } err = k.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) if err != nil { return err } + err = k.UpdateStakerDelegationTotalAmount(ctx, stakerID, assetID, params.OpAmount.Neg()) + if err != nil { + return err + } - err = k.restakingStateKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types.StakerSingleAssetOrChangeInfo{ - WaitUndelegationAmountOrWantChangeValue: params.OpAmount, + // update staker and operator assets state + 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, types.OperatorSingleAssetOrChangeInfo{ - WaitUndelegationAmountOrWantChangeValue: params.OpAmount, + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, params.OperatorAddress, assetID, assetstype.OperatorSingleAssetChangeInfo{ + TotalAmount: params.OpAmount.Neg(), + WaitUnbondingAmount: params.OpAmount, }) if err != nil { return err } - return nil + + // call operator module to decrease the state of opted-in assets + 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 + 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 { +/*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_op_test.go b/x/delegation/keeper/delegation_op_test.go index 33ed6d3e0..84edfabda 100644 --- a/x/delegation/keeper/delegation_op_test.go +++ b/x/delegation/keeper/delegation_op_test.go @@ -1,11 +1,16 @@ package keeper_test import ( + "fmt" + + 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" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/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" @@ -38,15 +43,15 @@ func (suite *DelegationTestSuite) TestDelegateTo() { 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 operatorAddr is:%s", delegationParams.OperatorAddress)).Error()) - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &delegationtype.OperatorInfo{ + Info: &operatortype.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) @@ -54,27 +59,30 @@ 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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationParams.OpAmount), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + 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.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: delegationParams.OpAmount, - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.OperatorAssetInfo{ + TotalAmount: delegationParams.OpAmount, + OperatorAmount: 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{ - CanUndelegationAmount: delegationParams.OpAmount, - WaitUndelegationAmount: 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) @@ -108,13 +116,13 @@ func (suite *DelegationTestSuite) TestUndelegateFrom() { LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &delegationtype.OperatorInfo{ + Info: &operatortype.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) @@ -127,32 +135,35 @@ 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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount.Sub(delegationEvent.OpAmount), - WaitUndelegationAmountOrWantChangeValue: delegationEvent.OpAmount, + 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.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: delegationEvent.OpAmount, - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: delegationEvent.OpAmount, + suite.Equal(types.OperatorAssetInfo{ + TotalAmount: sdkmath.NewInt(0), + OperatorAmount: 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{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: delegationEvent.OpAmount, + UndelegatableAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: delegationEvent.OpAmount, + UndelegatableAfterSlash: 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) @@ -204,13 +215,13 @@ func (suite *DelegationTestSuite) TestCompleteUndelegation() { LzNonce: 0, TxHash: common.HexToHash("0x24c4a315d757249c12a7a1d7b6fb96261d49deee26f06a3e1787d008b445c3ac"), } - registerReq := &delegationtype.RegisterOperatorReq{ + registerReq := &operatortype.RegisterOperatorReq{ FromAddress: opAccAddr.String(), - Info: &delegationtype.OperatorInfo{ + Info: &operatortype.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) @@ -229,27 +240,30 @@ 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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + 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.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: sdkmath.NewInt(0), - OperatorOwnAmountOrWantChangeValue: sdkmath.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.OperatorAssetInfo{ + TotalAmount: sdkmath.NewInt(0), + OperatorAmount: 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{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: 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 0e667cd3e..022c668b5 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -5,9 +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" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper" - "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -15,21 +14,20 @@ 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 } - 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 := assetstype.GetJoinedStoreKey(stakerID, assetID) if store.Has(key) { value := store.Get(key) k.cdc.MustUnmarshal(value, &amount) } - err := keeper.UpdateAssetValue(&amount.Amount, &opAmount) + err := assetstype.UpdateAssetValue(&amount.Amount, &opAmount) if err != nil { return err } @@ -40,22 +38,22 @@ 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) +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 := types.GetAssetStateKey(stakerID, assetID) + prefixKey := assetstype.GetJoinedStoreKey(stakerID, assetID) if !store.Has(prefixKey) { return sdkmath.Int{}, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetStakerDelegationTotalAmount: key is %s", prefixKey)) } value := store.Get(prefixKey) k.cdc.MustUnmarshal(value, &ret) + return ret.Amount, nil } // 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 @@ -63,18 +61,19 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID if amounts == nil { continue } - if amounts.CanUndelegationAmount.IsNil() && amounts.WaitUndelegationAmount.IsNil() { + if amounts.UndelegatableAmount.IsNil() && amounts.WaitUndelegationAmount.IsNil() { continue } - + // check operator address validation _, err := sdk.AccAddressFromBech32(opAddr) if err != nil { return delegationtype.OperatorAddrIsNotAccAddr } - singleStateKey := delegationtype.GetDelegationStateKey(stakerID, assetID, opAddr) + singleStateKey := assetstype.GetJoinedStoreKey(stakerID, assetID, opAddr) delegationState := delegationtype.DelegationAmounts{ - CanUndelegationAmount: sdkmath.NewInt(0), - WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAmount: sdkmath.NewInt(0), + WaitUndelegationAmount: sdkmath.NewInt(0), + UndelegatableAfterSlash: sdkmath.NewInt(0), } if store.Has(singleStateKey) { @@ -82,16 +81,22 @@ func (k Keeper) UpdateDelegationState(ctx sdk.Context, stakerID string, assetID k.cdc.MustUnmarshal(value, &delegationState) } - err = keeper.UpdateAssetValue(&delegationState.CanUndelegationAmount, &amounts.CanUndelegationAmount) + err = assetstype.UpdateAssetValue(&delegationState.UndelegatableAmount, &amounts.UndelegatableAmount) if err != nil { - return errorsmod.Wrap(err, "UpdateDelegationState CanUndelegationAmount error") + return errorsmod.Wrap(err, "UpdateDelegationState UndelegatableAmount error") } - err = keeper.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) + err = assetstype.UpdateAssetValue(&delegationState.WaitUndelegationAmount, &amounts.WaitUndelegationAmount) if err != nil { return errorsmod.Wrap(err, "UpdateDelegationState WaitUndelegationAmount error") } + err = assetstype.UpdateAssetValue(&delegationState.UndelegatableAfterSlash, &amounts.UndelegatableAfterSlash) + if err != nil { + return errorsmod.Wrap(err, "UpdateDelegationState UndelegatableAfterSlash error") + } + + // save single operator delegation state bz := k.cdc.MustMarshal(&delegationState) store.Set(singleStateKey, bz) } @@ -99,9 +104,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 := delegationtype.GetDelegationStateKey(stakerID, assetID, operatorAddr) + singleStateKey := assetstype.GetJoinedStoreKey(stakerID, assetID, operatorAddr) isExit := store.Has(singleStateKey) delegationState := delegationtype.DelegationAmounts{} if isExit { @@ -114,9 +119,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) { - c := sdk.UnwrapSDKContext(ctx) - +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 { @@ -124,7 +127,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() @@ -141,3 +144,61 @@ func (k Keeper) GetDelegationInfo(ctx sdk.Context, stakerID, assetID string) (*d return &ret, nil } + +// 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) + defer iterator.Close() + + ret := make(map[string]map[string]delegationtype.DelegationAmounts, 0) + for ; iterator.Valid(); iterator.Next() { + var amounts delegationtype.DelegationAmounts + k.cdc.MustUnmarshal(iterator.Value(), &amounts) + keys, err := assetstype.ParseJoinedKey(iterator.Key()) + if err != nil { + return nil, err + } + 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 +} + +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() + + for ; iterator.Valid(); iterator.Next() { + var amounts delegationtype.DelegationAmounts + k.cdc.MustUnmarshal(iterator.Value(), &amounts) + keys, err := assetstype.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/delegation/keeper/grpc_query.go b/x/delegation/keeper/grpc_query.go index 98fdfa2b2..990479874 100644 --- a/x/delegation/keeper/grpc_query.go +++ b/x/delegation/keeper/grpc_query.go @@ -7,19 +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) } - -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 332b8b154..cb189d5a7 100644 --- a/x/delegation/keeper/keeper.go +++ b/x/delegation/keeper/keeper.go @@ -2,17 +2,11 @@ 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" "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" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -21,76 +15,47 @@ type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec - restakingStateKeeper keeper.Keeper - depositKeeper depositkeeper.Keeper - slashKeeper delegationtype.ISlashKeeper - operatorOptedInKeeper delegationtype.OperatorOptedInMiddlewareKeeper + // other keepers + assetsKeeper delegationtype.AssetsKeeper + slashKeeper delegationtype.SlashKeeper + operatorKeeper delegationtype.OperatorKeeper + hooks delegationtype.DelegationHooks } func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, - restakingStateKeeper keeper.Keeper, - depositKeeper depositkeeper.Keeper, - slashKeeper delegationtype.ISlashKeeper, - operatorOptedInKeeper delegationtype.OperatorOptedInMiddlewareKeeper, + assetsKeeper delegationtype.AssetsKeeper, + slashKeeper delegationtype.SlashKeeper, + operatorKeeper delegationtype.OperatorKeeper, ) Keeper { return Keeper{ - storeKey: storeKey, - cdc: cdc, - restakingStateKeeper: restakingStateKeeper, - depositKeeper: depositKeeper, - slashKeeper: slashKeeper, - operatorOptedInKeeper: operatorOptedInKeeper, + storeKey: storeKey, + cdc: cdc, + assetsKeeper: assetsKeeper, + slashKeeper: slashKeeper, + operatorKeeper: 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") +// 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") } - // 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 - - 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) - - ifExist := store.Has(opAccAddr) - if !ifExist { - return nil, errorsmod.Wrap(delegationtype.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %s", opAccAddr)) + if k.hooks != nil { + panic("cannot set hooks twice") } - - value := store.Get(opAccAddr) - - ret := delegationtype.OperatorInfo{} - k.cdc.MustUnmarshal(value, &ret) - return &ret, nil + k.hooks = hooks } -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) { - return k.depositKeeper.GetExoCoreLzAppAddress(ctx) +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 @@ -98,8 +63,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 0b1d739ed..f63ceca81 100644 --- a/x/delegation/keeper/msg_server.go +++ b/x/delegation/keeper/msg_server.go @@ -5,25 +5,15 @@ 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(context.Context, *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(context.Context, *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/operator_info_test.go b/x/delegation/keeper/operator_info_test.go deleted file mode 100644 index d0b3b1df6..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 *DelegationTestSuite) 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/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/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index c104dba24..b4a315537 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,16 @@ 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 +// 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) + 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 { @@ -83,14 +93,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() @@ -102,7 +112,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 @@ -111,14 +121,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() @@ -130,7 +140,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 @@ -141,3 +151,31 @@ 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) error { + prev := k.GetUndelegationHoldCount(ctx, recordKey) + if prev == math.MaxUint64 { + 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 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetUndelegationOnHoldKey(recordKey)) + return sdk.BigEndianToUint64(bz) +} + +func (k *Keeper) DecrementUndelegationHoldCount(ctx sdk.Context, recordKey []byte) error { + prev := k.GetUndelegationHoldCount(ctx, recordKey) + if prev == 0 { + 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/module.go b/x/delegation/module.go index 89b3af93d..b93a5ea35 100644 --- a/x/delegation/module.go +++ b/x/delegation/module.go @@ -73,7 +73,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(*module.SimulationState) { diff --git a/x/delegation/types/codec.go b/x/delegation/types/codec.go index 80b292929..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" ) @@ -38,7 +37,6 @@ func init() { func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), - &RegisterOperatorReq{}, &MsgDelegation{}, &MsgUndelegation{}, ) @@ -49,7 +47,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/errors.go b/x/delegation/types/errors.go index 5b15c2eab..1bb6446c7 100644 --- a/x/delegation/types/errors.go +++ b/x/delegation/types/errors.go @@ -22,7 +22,9 @@ 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, 10, "the delegation amount is bigger than the canWithdraw amount") - ErrDelegationAmountTooBig = errorsmod.Register(ModuleName, 11, "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 24069e093..f2b7bb2f2 100644 --- a/x/delegation/types/expected_keepers.go +++ b/x/delegation/types/expected_keepers.go @@ -2,33 +2,53 @@ 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, uint64) sdkmath.LegacyDec { +func (VirtualSlashKeeper) OperatorAssetSlashedProportion(_ sdk.Context, _ sdk.AccAddress, _ string, _, _ uint64) sdkmath.LegacyDec { return sdkmath.LegacyNewDec(0) } -type OperatorOptedInMiddlewareKeeper interface { - GetOperatorCanUndelegateHeight(ctx sdk.Context, assetID string, opAddr sdk.AccAddress, startHeight uint64) uint64 +// 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 + // 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) 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 VirtualOperatorOptedInKeeper struct{} +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 +} -func (VirtualOperatorOptedInKeeper) GetOperatorCanUndelegateHeight(_ sdk.Context, _ string, _ sdk.AccAddress, startHeight uint64) uint64 { - return startHeight + CanUndelegationDelayHeight +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 new file mode 100644 index 000000000..d0ad3032a --- /dev/null +++ b/x/delegation/types/hooks.go @@ -0,0 +1,37 @@ +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, +) error { + for _, hook := range hooks { + err := hook.AfterUndelegationStarted(ctx, addr, recordKey) + if err != nil { + return err + } + } + return nil +} + +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 0f52b90ec..23bdccaf8 100644 --- a/x/delegation/types/keys.go +++ b/x/delegation/types/keys.go @@ -1,11 +1,9 @@ package types import ( - "fmt" "strings" - errorsmod "cosmossdk.io/errors" - + "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" @@ -31,8 +29,7 @@ func init() { } const ( - prefixOperatorInfo = iota + 1 - prefixRestakerDelegationInfo + prefixRestakerDelegationInfo = iota + 1 prefixDelegationUsedSalt prefixOperatorApprovedInfo @@ -41,36 +38,32 @@ const ( prefixStakerUndelegationInfo prefixWaitCompleteUndelegations + + // add for dogfood + prefixUndelegationOnHold ) var ( - // KeyPrefixOperatorInfo key-value: operatorAddr->operatorInfo - KeyPrefixOperatorInfo = []byte{prefixOperatorInfo} - // 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 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, '/') @@ -78,9 +71,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 } @@ -96,3 +89,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/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/delegation/types/query.pb.go b/x/delegation/types/query.pb.go index 55dd872d0..41d4982f9 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"` + // 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"` + // 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{} } @@ -242,108 +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{ - // 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, 0x0b, 0x11, 0x42, 0x85, 0x6c, 0x54, 0x98, 0xc6, 0x0e, 0x98, 0x28, 0x9c, 0xa1, 0xd9, 0x64, - 0x87, 0x3a, 0x78, 0x0f, 0xde, 0x01, 0x23, 0x5c, 0xa0, 0x32, 0x66, 0x45, 0xdf, 0x4d, 0x6b, 0x73, - 0x5a, 0x6e, 0x64, 0x75, 0xac, 0xd5, 0xcc, 0x0e, 0x6f, 0xca, 0xa0, 0x5d, 0x70, 0x86, 0xc3, 0xb4, - 0xed, 0xc2, 0x79, 0x30, 0x8c, 0x38, 0xc7, 0x22, 0xa8, 0x4c, 0xca, 0xca, 0xd1, 0x56, 0x33, 0x3b, - 0xb4, 0x12, 0xc4, 0xec, 0x82, 0x33, 0x24, 0x93, 0xb6, 0x6b, 0xbc, 0x4a, 0x76, 0x12, 0xad, 0xec, - 0xd2, 0x1a, 0x11, 0x1c, 0x0a, 0x30, 0x5d, 0x42, 0xa4, 0x58, 0x23, 0xe7, 0x27, 0x2a, 0x22, 0x99, - 0x53, 0xb4, 0x4f, 0x8e, 0x9a, 0xd9, 0xc4, 0xb7, 0x66, 0x76, 0xde, 0xf3, 0xc5, 0xcb, 0xda, 0xb6, - 0x59, 0xa2, 0xbb, 0x6a, 0x26, 0xea, 0x67, 0x91, 0xbb, 0x65, 0x4b, 0x34, 0xaa, 0x98, 0x9b, 0x36, - 0x11, 0x27, 0x87, 0x8b, 0x40, 0x8d, 0xcc, 0x26, 0xc2, 0x99, 0x2c, 0x21, 0xb2, 0xd5, 0x81, 0x1d, - 0xd2, 0xc2, 0x3a, 0x48, 0xef, 0x23, 0x5f, 0x44, 0xd2, 0x26, 0xaf, 0x80, 0x76, 0x2a, 0x40, 0xef, - 0xe7, 0x35, 0x7e, 0x25, 0xc1, 0xec, 0xf3, 0x60, 0xd5, 0xbd, 0x13, 0xe7, 0x55, 0x4a, 0x38, 0x86, - 0x0c, 0x4c, 0x09, 0x2a, 0x50, 0xa5, 0xa8, 0x3a, 0xb1, 0x7b, 0x95, 0xc3, 0x48, 0x49, 0xec, 0x42, - 0x1b, 0x5a, 0xcd, 0x82, 0x81, 0xf1, 0x8e, 0x21, 0xf8, 0x64, 0x87, 0xf2, 0x74, 0x72, 0x6e, 0x20, - 0x37, 0x9a, 0x5f, 0x37, 0x23, 0xdd, 0x6b, 0x5e, 0x70, 0x02, 0xb3, 0x3b, 0xcc, 0xd7, 0x88, 0x60, - 0x0d, 0xe7, 0xba, 0xdb, 0x1d, 0xcd, 0x54, 0x40, 0x2a, 0xaa, 0x10, 0x8e, 0x83, 0x81, 0x32, 0x6e, - 0x84, 0x87, 0x75, 0x82, 0x47, 0xf8, 0x14, 0x0c, 0xd6, 0x51, 0xa5, 0x86, 0xe5, 0x5a, 0x46, 0xf3, - 0xb9, 0x18, 0x49, 0x7d, 0xc6, 0x72, 0xc2, 0xb6, 0xc7, 0xc9, 0x47, 0x9a, 0xf1, 0x49, 0x03, 0xd3, - 0x9b, 0x3e, 0xf1, 0x2a, 0xf8, 0x9f, 0x8c, 0xbe, 0x0c, 0xae, 0xd1, 0x2a, 0x66, 0x48, 0x50, 0x56, - 0x44, 0xae, 0xcb, 0x94, 0x53, 0xd2, 0x27, 0x87, 0x8b, 0x29, 0x35, 0xe5, 0x15, 0xd7, 0x65, 0x98, - 0xf3, 0x4d, 0xc1, 0x7c, 0xe2, 0x39, 0x63, 0xed, 0xf2, 0x20, 0xdc, 0xf5, 0x9d, 0x0c, 0x5c, 0xf0, - 0x9d, 0x6c, 0x81, 0x94, 0x1c, 0xf0, 0x33, 0xd5, 0xdc, 0x56, 0xda, 0x47, 0xaf, 0x5d, 0x86, 0x3e, - 0xff, 0xe6, 0x3f, 0x30, 0x28, 0x71, 0xe1, 0x07, 0x0d, 0x4c, 0xf4, 0x31, 0xc0, 0xbb, 0x17, 0x2d, - 0xbb, 0x47, 0x4b, 0xe6, 0x76, 0x4c, 0x71, 0x67, 0x9d, 0x61, 0xbe, 0xfe, 0xf2, 0xe3, 0x7d, 0x32, - 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, + // 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, 0x2b, 0x85, 0xf9, 0x1d, 0xca, 0xf7, 0x28, 0x4f, 0x42, 0x07, 0x72, 0x0a, + 0x73, 0x89, 0xd3, 0x93, 0x5f, 0x76, 0xf2, 0xa1, 0x5c, 0xb9, 0x80, 0x06, 0x34, 0xb1, 0xc7, 0x6f, + 0xca, 0x7a, 0x3b, 0xa0, 0x34, 0x88, 0xb0, 0x8d, 0x1a, 0xa1, 0x8d, 0x08, 0xa1, 0x42, 0xf2, 0xa8, + 0x1c, 0xb3, 0x06, 0x6e, 0x56, 0x2e, 0xc8, 0x1d, 0x52, 0xa3, 0x2e, 0xde, 0x87, 0x77, 0xc1, 0x38, + 0x17, 0xa8, 0x8e, 0x99, 0x17, 0xfa, 0x79, 0x6d, 0x41, 0x2b, 0x8d, 0xaf, 0x4f, 0x76, 0x3b, 0xc5, + 0xb1, 0xaa, 0x34, 0x3a, 0x15, 0x77, 0x2c, 0x71, 0x3b, 0x3e, 0x5c, 0x04, 0x63, 0x88, 0x73, 0x2c, + 0xe2, 0x48, 0x5d, 0x46, 0x4e, 0x74, 0x3b, 0xc5, 0xd1, 0xb5, 0xd8, 0xe6, 0x54, 0xdc, 0x51, 0xe9, + 0x74, 0x7c, 0xf3, 0x87, 0xde, 0x4b, 0xb4, 0xb6, 0x47, 0x9b, 0x44, 0x70, 0x48, 0x41, 0xae, 0x49, + 0x54, 0xf3, 0x68, 0x3b, 0xc2, 0x1e, 0x92, 0x0e, 0xc5, 0xf9, 0xe4, 0xb8, 0x53, 0xcc, 0x7c, 0xea, + 0x14, 0x17, 0x83, 0x50, 0xec, 0x36, 0xb7, 0xad, 0x1d, 0xba, 0xa7, 0x1a, 0x56, 0x8f, 0x65, 0xee, + 0xd7, 0x6d, 0xd1, 0x6e, 0x60, 0x6e, 0x39, 0x44, 0x9c, 0x1e, 0x2d, 0x03, 0xa5, 0x87, 0x43, 0x84, + 0x3b, 0xdd, 0x87, 0x9c, 0x30, 0xc2, 0x16, 0xc8, 0x1f, 0xa0, 0x50, 0x78, 0x17, 0xbe, 0x90, 0x92, + 0x73, 0x52, 0xfd, 0x0a, 0x48, 0x67, 0x62, 0xf4, 0xe7, 0x3d, 0xe0, 0x8a, 0xf7, 0x10, 0xcc, 0x0d, + 0x34, 0x5a, 0x13, 0x98, 0x79, 0x3c, 0x42, 0x7c, 0x37, 0x9f, 0xbd, 0x02, 0xe2, 0xd9, 0xfe, 0x6e, + 0x63, 0xf4, 0x6a, 0x0c, 0x6e, 0x7e, 0xd7, 0xc1, 0xfc, 0xb3, 0x78, 0x7f, 0x06, 0xc7, 0xcc, 0x1b, + 0x94, 0x70, 0x0c, 0x19, 0x98, 0x11, 0x54, 0xa0, 0xc8, 0x53, 0xe9, 0xd8, 0xbf, 0xca, 0x21, 0xe4, + 0x24, 0x76, 0xe5, 0x1c, 0x5a, 0xa9, 0xc1, 0xc0, 0x54, 0x8f, 0xfc, 0x21, 0xa9, 0x51, 0x9e, 0xd7, + 0x17, 0xb2, 0xa5, 0x89, 0xf2, 0xa6, 0x35, 0xf4, 0x24, 0xac, 0xdf, 0x74, 0x60, 0xf5, 0x9b, 0xf9, + 0x06, 0x11, 0xac, 0xed, 0xde, 0xf0, 0xfb, 0xad, 0x85, 0x08, 0xe4, 0x86, 0x05, 0xc2, 0x29, 0x90, + 0xad, 0xe3, 0x76, 0xd2, 0xac, 0x1b, 0xbf, 0xc2, 0xa7, 0x60, 0xa4, 0x85, 0xa2, 0x26, 0x96, 0x0b, + 0x31, 0x51, 0x2e, 0xa5, 0x94, 0xf4, 0xcb, 0x36, 0xbb, 0x49, 0xda, 0x63, 0xfd, 0x91, 0x66, 0xbe, + 0xd3, 0xc0, 0x6c, 0x35, 0x24, 0x41, 0x84, 0xff, 0xeb, 0xba, 0x56, 0xc1, 0x75, 0xda, 0xc0, 0x0c, + 0x09, 0xca, 0x3c, 0xe4, 0xfb, 0x4c, 0xed, 0x68, 0xfe, 0xf4, 0x68, 0x39, 0xa7, 0x54, 0x5e, 0xf3, + 0x7d, 0x86, 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. @@ -358,8 +311,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 +326,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 +346,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 +357,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 +368,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 +408,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 +478,16 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.UndelegatableAfterSlash.Size() + i -= size + if _, err := m.UndelegatableAfterSlash.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 +499,9 @@ func (m *DelegationAmounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 { - size := m.CanUndelegationAmount.Size() + size := m.UndelegatableAmount.Size() i -= size - if _, err := m.CanUndelegationAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.UndelegatableAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintQuery(dAtA, i, uint64(size)) @@ -689,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 @@ -753,10 +648,12 @@ func (m *DelegationAmounts) Size() (n int) { } var l int _ = l - l = m.CanUndelegationAmount.Size() + l = m.UndelegatableAmount.Size() n += 1 + l + sovQuery(uint64(l)) l = m.WaitUndelegationAmount.Size() n += 1 + l + sovQuery(uint64(l)) + l = m.UndelegatableAfterSlash.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -805,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 } @@ -969,7 +853,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 UndelegatableAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -997,7 +881,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.UndelegatableAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1035,6 +919,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 UndelegatableAfterSlash", 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.UndelegatableAfterSlash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1415,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/query.pb.gw.go b/x/delegation/types/query.pb.gw.go index 052e2eee7..cbf25a404 100644 --- a/x/delegation/types/query.pb.gw.go +++ b/x/delegation/types/query.pb.gw.go @@ -33,42 +33,6 @@ 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 - -} - var ( filter_Query_QueryDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -147,29 +111,6 @@ func local_request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marsha // 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()...) - - }) - 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() @@ -257,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() @@ -321,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 82266f9cf..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,83 +578,67 @@ func init() { func init() { proto.RegisterFile("exocore/delegation/v1/tx.proto", fileDescriptor_16596a15a828f109) } var fileDescriptor_16596a15a828f109 = []byte{ - // 1207 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, 0x3b, 0x4a, 0x3b, 0x75, 0x62, 0xc7, 0x80, 0xdd, 0x6e, 0xa1, - 0x6a, 0x43, 0x63, 0xab, 0xa1, 0xa2, 0x50, 0x40, 0x22, 0xa9, 0x53, 0x30, 0x34, 0x69, 0xd9, 0x16, - 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, 0x3d, 0xf4, 0x0b, 0x70, 0xeb, 0xb1, 0xea, - 0x09, 0x21, 0x11, 0x21, 0xf7, 0x50, 0x3e, 0x00, 0x47, 0x0e, 0x68, 0x67, 0x76, 0xbd, 0xeb, 0xc6, - 0x6e, 0xa8, 0xc8, 0x81, 0x4b, 0xe2, 0x7d, 0x7f, 0x7e, 0xbf, 0xf7, 0x6f, 0xde, 0xec, 0x42, 0x19, - 0xf7, 0xa9, 0x49, 0x3d, 0x5c, 0xb3, 0xb0, 0x8b, 0x6d, 0x83, 0x3b, 0x94, 0xd4, 0x76, 0x2f, 0xd6, - 0x78, 0xbf, 0xda, 0xf5, 0x28, 0xa7, 0x68, 0x31, 0xd0, 0x57, 0x23, 0x7d, 0x75, 0xf7, 0x62, 0xe9, - 0x84, 0xd1, 0x71, 0x08, 0xad, 0x89, 0xbf, 0xd2, 0xb2, 0x54, 0x30, 0x29, 0xeb, 0x50, 0x56, 0xeb, - 0x30, 0xdb, 0x47, 0xe8, 0x30, 0x3b, 0x50, 0x2c, 0x4b, 0x85, 0x2e, 0x9e, 0x6a, 0xf2, 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, 0xba, 0x07, 0x14, 0xa5, 0x16, 0x14, 0xa6, 0x98, 0xa3, 0xe3, - 0x90, 0x6a, 0xe3, 0x81, 0x2c, 0x96, 0xe6, 0xff, 0x44, 0x97, 0xe1, 0xd8, 0xae, 0xdf, 0x44, 0x51, - 0x8a, 0xec, 0xda, 0xe9, 0x29, 0x81, 0x45, 0x8d, 0xd6, 0xa4, 0xfd, 0x95, 0xe4, 0x5b, 0x8a, 0xfa, - 0x15, 0x94, 0xae, 0xba, 0x0e, 0x26, 0xfc, 0x6a, 0xcb, 0x70, 0xc8, 0xa6, 0xe1, 0x11, 0x87, 0xd8, - 0xeb, 0x96, 0xe5, 0x5d, 0x77, 0x18, 0x47, 0x77, 0xe0, 0x04, 0x96, 0x22, 0xdd, 0x21, 0x3b, 0x54, - 0x77, 0x1d, 0xe6, 0x0f, 0x87, 0x9f, 0xff, 0xc5, 0x29, 0x34, 0x93, 0xd1, 0xfc, 0x0a, 0x68, 0x0b, - 0x01, 0x96, 0xff, 0xe0, 0xc3, 0xab, 0x3f, 0x28, 0xd3, 0xd8, 0xc5, 0x70, 0xbc, 0x0f, 0xc8, 0xdd, - 0xd3, 0x4d, 0x61, 0xa0, 0x9b, 0xbe, 0x45, 0x38, 0x26, 0x33, 0x1b, 0x27, 0x87, 0xfb, 0x95, 0x85, - 0xeb, 0x7b, 0x31, 0xef, 0x46, 0x5d, 0x5b, 0x70, 0xc7, 0x04, 0x16, 0x7a, 0x1b, 0x96, 0xc7, 0xdc, - 0xc3, 0x64, 0x0c, 0xcb, 0xf2, 0xe4, 0xe4, 0x68, 0x4b, 0xe6, 0xc4, 0x00, 0xd4, 0xbf, 0x14, 0xc8, - 0x85, 0x0d, 0x10, 0xd1, 0x9c, 0x81, 0xf9, 0xc0, 0x9d, 0x49, 0x7f, 0xd9, 0x82, 0x5c, 0x28, 0xf4, - 0xbd, 0xd0, 0x69, 0xc8, 0x19, 0xdd, 0xae, 0x47, 0x77, 0x71, 0x9c, 0x23, 0x1b, 0xc8, 0x84, 0xc9, - 0x05, 0x40, 0xa3, 0x91, 0xea, 0x60, 0x6e, 0x88, 0xca, 0x16, 0x53, 0xc2, 0xf0, 0x78, 0xa8, 0xd9, - 0xc2, 0xdc, 0x10, 0xac, 0x04, 0x4a, 0x93, 0x32, 0x08, 0x42, 0x98, 0x11, 0x1d, 0x7f, 0xb1, 0x56, - 0xf8, 0x95, 0xd7, 0x0a, 0x07, 0xb3, 0x16, 0x09, 0xa8, 0xbf, 0x28, 0x70, 0x52, 0xc3, 0xb6, 0xc3, - 0x78, 0x34, 0x7f, 0x1a, 0xfe, 0x12, 0xbd, 0x03, 0xb9, 0x1d, 0x8f, 0x76, 0x04, 0x2d, 0x66, 0x2c, - 0x38, 0xac, 0xc5, 0xc7, 0x0f, 0x56, 0xf3, 0xc1, 0x41, 0x5a, 0x97, 0x9a, 0x5b, 0xdc, 0x73, 0x88, - 0xad, 0x65, 0x7d, 0xeb, 0x40, 0x84, 0x2e, 0xc3, 0x8c, 0x48, 0x52, 0x0e, 0xe8, 0x99, 0x29, 0xe1, - 0xc6, 0xab, 0xad, 0x09, 0x87, 0x2b, 0x97, 0xbe, 0xbd, 0x57, 0x49, 0xfc, 0x79, 0xaf, 0x92, 0xf8, - 0xe6, 0xe9, 0xfd, 0x95, 0xec, 0xb5, 0x08, 0xf2, 0xbb, 0xa7, 0xf7, 0x57, 0x0a, 0xb1, 0x93, 0x1d, - 0xf7, 0x55, 0x1b, 0xb0, 0x58, 0x1f, 0x21, 0xaf, 0xcb, 0xd2, 0x8b, 0x62, 0xbe, 0x0c, 0x19, 0xe6, - 0xd8, 0xc4, 0xe0, 0x3d, 0x0f, 0x07, 0xed, 0x8b, 0x04, 0x08, 0xc1, 0x0c, 0x33, 0xdc, 0x60, 0xa3, - 0x68, 0xe2, 0xb7, 0x5a, 0x82, 0xe2, 0xc1, 0x6a, 0xb0, 0x2e, 0x25, 0x0c, 0xab, 0x7f, 0x27, 0x61, - 0x29, 0xe2, 0x69, 0x10, 0xf3, 0x86, 0x57, 0xc7, 0xa6, 0x20, 0xfa, 0x4f, 0xd5, 0xba, 0x3b, 0x65, - 0xef, 0x24, 0xc5, 0xb9, 0xdb, 0x7c, 0xfe, 0xde, 0x79, 0x26, 0x92, 0xff, 0xe7, 0xd6, 0xb9, 0xb2, - 0x31, 0xd6, 0xd7, 0x9d, 0xf1, 0xbe, 0xbe, 0x16, 0xeb, 0xeb, 0x16, 0xf3, 0x67, 0x56, 0xa4, 0xe3, - 0x61, 0x83, 0xe1, 0x28, 0x4b, 0xf5, 0x67, 0x05, 0xe6, 0xb7, 0x98, 0x1d, 0x49, 0xd0, 0x47, 0x90, - 0x69, 0x1a, 0x0c, 0xcb, 0x03, 0xa5, 0x88, 0xb0, 0x56, 0x5f, 0xa8, 0x5a, 0x5a, 0xda, 0xf7, 0x17, - 0x1d, 0xfc, 0x04, 0xe6, 0x83, 0x43, 0x6b, 0xe9, 0xb1, 0xd9, 0xbd, 0x70, 0x28, 0x5e, 0x6c, 0xde, - 0xb4, 0x70, 0x17, 0x58, 0x62, 0x2c, 0x7f, 0x9a, 0x01, 0xf4, 0x29, 0x89, 0xfc, 0x34, 0x6c, 0x52, - 0xcf, 0x42, 0xe7, 0x21, 0xc3, 0xb8, 0xd1, 0xc6, 0x5e, 0x74, 0x07, 0xe6, 0x86, 0xfb, 0x95, 0xf4, - 0x2d, 0x21, 0x6c, 0xd4, 0xb5, 0xb4, 0x54, 0x37, 0xac, 0xb1, 0xdb, 0x32, 0xf9, 0x9c, 0xdb, 0xf2, - 0x3d, 0x98, 0x8f, 0xa6, 0xc7, 0xdf, 0x13, 0xa9, 0x43, 0xe6, 0x2f, 0x17, 0x9a, 0x8b, 0x0d, 0x55, - 0x80, 0x39, 0xde, 0xd7, 0x5b, 0x06, 0x6b, 0x89, 0x05, 0x93, 0xd1, 0x66, 0x79, 0xff, 0x43, 0x83, - 0xb5, 0xd0, 0x2b, 0x00, 0x0e, 0xd3, 0xbb, 0x98, 0x58, 0x0e, 0xb1, 0x8b, 0xc7, 0x4e, 0x29, 0xe7, - 0xd2, 0x5a, 0xc6, 0x61, 0x37, 0xa5, 0xc0, 0x5f, 0x7e, 0x4d, 0x97, 0x9a, 0x6d, 0x9d, 0xf4, 0x3a, - 0x4d, 0xec, 0x15, 0x67, 0xfd, 0x4d, 0xad, 0x65, 0x85, 0x6c, 0x5b, 0x88, 0xd0, 0x1a, 0x2c, 0x9a, - 0xb4, 0xd3, 0x75, 0x31, 0xc7, 0xfa, 0x98, 0xed, 0x9c, 0xb0, 0x3d, 0x19, 0x2a, 0x37, 0x62, 0x3e, - 0x65, 0xc8, 0xba, 0x7b, 0x3a, 0xef, 0xeb, 0x84, 0x12, 0x13, 0x17, 0xd3, 0xc2, 0x32, 0xe3, 0xee, - 0xdd, 0xee, 0x6f, 0xfb, 0x82, 0xd8, 0x6b, 0x4b, 0xe6, 0xe8, 0x5e, 0x5b, 0x10, 0x87, 0x82, 0x61, - 0xf2, 0x9e, 0xe1, 0xea, 0x61, 0x4c, 0xa3, 0x57, 0x0e, 0x38, 0x02, 0x9a, 0x45, 0x09, 0x7e, 0x35, - 0xc4, 0x96, 0xa7, 0x4d, 0x7d, 0x13, 0x96, 0x0f, 0x8e, 0xc8, 0xc7, 0x78, 0x20, 0x6e, 0xe3, 0x65, - 0x48, 0xb7, 0xf1, 0x20, 0xba, 0x84, 0x33, 0xda, 0x5c, 0x5b, 0xaa, 0xd4, 0x3c, 0xa0, 0x7a, 0xcc, - 0x2b, 0xd8, 0x50, 0x77, 0x60, 0x61, 0x8b, 0xd9, 0x71, 0xc0, 0xa3, 0x3c, 0x23, 0xea, 0x12, 0xe4, - 0xc7, 0x83, 0x95, 0xb4, 0x6b, 0xbf, 0x27, 0x21, 0xb5, 0xc5, 0x6c, 0x44, 0xe1, 0xf8, 0xb3, 0xcb, - 0x13, 0xad, 0x4c, 0x21, 0x9b, 0x70, 0xe7, 0x94, 0x6a, 0xff, 0xda, 0x56, 0x12, 0xa3, 0x2f, 0xa0, - 0x10, 0xbe, 0x7e, 0x89, 0x33, 0x71, 0x9b, 0x8e, 0x78, 0x5f, 0x9d, 0x82, 0x35, 0xb6, 0x41, 0x4a, - 0xe7, 0x0f, 0x2d, 0xc5, 0x88, 0xcb, 0x83, 0x97, 0x46, 0xc9, 0x4b, 0x36, 0xff, 0x7a, 0x1a, 0xf1, - 0x9d, 0x9d, 0xce, 0x17, 0xaf, 0x59, 0xe9, 0xf5, 0x29, 0x76, 0x93, 0x0a, 0x5b, 0x3a, 0xf6, 0xf5, - 0xd3, 0xfb, 0x2b, 0xca, 0xc6, 0xf6, 0xc3, 0x61, 0x59, 0x79, 0x34, 0x2c, 0x2b, 0x7f, 0x0c, 0xcb, - 0xca, 0xf7, 0x4f, 0xca, 0x89, 0x47, 0x4f, 0xca, 0x89, 0x5f, 0x9f, 0x94, 0x13, 0x9f, 0x5f, 0x8a, - 0xcd, 0xe2, 0xa6, 0xc4, 0xdd, 0xc6, 0xfc, 0x2e, 0xf5, 0xda, 0xb5, 0xf0, 0xeb, 0xa3, 0x1f, 0xff, - 0xfe, 0x10, 0xd3, 0xd9, 0x9c, 0x15, 0x1f, 0x03, 0x6f, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x26, - 0x9a, 0x38, 0xa1, 0xa2, 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, 0xaa, 0x29, 0x17, 0x91, 0xab, 0x68, 0x13, + 0x9b, 0x48, 0x7b, 0xf8, 0x24, 0xad, 0x6a, 0x0f, 0xe0, 0x6b, 0xc3, 0x1d, 0xe2, 0x5b, 0x0e, 0x76, + 0x2d, 0x74, 0x08, 0xcb, 0x86, 0x47, 0x86, 0x3e, 0x2f, 0x2b, 0x1b, 0x4a, 0x3d, 0xb7, 0xf3, 0xe1, + 0xc3, 0xd3, 0x5a, 0xea, 0x8f, 0xd3, 0xda, 0xa6, 0xed, 0xf0, 0xfe, 0xb0, 0xd7, 0x30, 0x89, 0x17, + 0x81, 0x46, 0x7f, 0xdb, 0xcc, 0x1a, 0x34, 0xf9, 0x38, 0xc0, 0xac, 0xd1, 0xf5, 0xf9, 0xe3, 0x07, + 0xdb, 0x10, 0x71, 0x76, 0x7d, 0xae, 0x45, 0x58, 0xea, 0x2f, 0x69, 0x28, 0x77, 0x64, 0x49, 0xd8, + 0x3a, 0x70, 0x7c, 0xdb, 0xc5, 0x6d, 0xc6, 0x30, 0xef, 0xfa, 0x47, 0x04, 0x6d, 0x42, 0xd6, 0x08, + 0x17, 0xba, 0x63, 0x45, 0xa4, 0xf9, 0xc9, 0x69, 0x2d, 0x23, 0x03, 0x3a, 0x5a, 0x46, 0x38, 0xbb, + 0x16, 0xa2, 0xb0, 0xc6, 0x09, 0x37, 0x5c, 0xdd, 0x8a, 0x91, 0xf4, 0x28, 0xd5, 0x85, 0x2b, 0x48, + 0xb5, 0x28, 0xb0, 0xa7, 0x49, 0xb6, 0x05, 0x32, 0x1a, 0x43, 0x31, 0xc0, 0x54, 0x27, 0x01, 0xa6, + 0x06, 0x27, 0x34, 0x22, 0x64, 0xe5, 0xf4, 0x46, 0xba, 0x9e, 0x6f, 0x7d, 0xd2, 0x78, 0xaa, 0x5e, + 0x8d, 0x79, 0xa5, 0x36, 0xee, 0x60, 0x7a, 0x3b, 0x82, 0x92, 0x04, 0x6c, 0xd7, 0xe7, 0x74, 0xac, + 0xa1, 0xe0, 0x09, 0x47, 0xa5, 0x0f, 0xa5, 0x39, 0xe1, 0xe8, 0x45, 0x48, 0x0f, 0xf0, 0x58, 0x1e, + 0x96, 0x16, 0x3e, 0xa2, 0xf7, 0x60, 0xe9, 0x38, 0x14, 0x51, 0x1c, 0x45, 0xbe, 0x75, 0x6d, 0x4e, + 0x62, 0x33, 0xa1, 0x35, 0x19, 0x7f, 0x73, 0xe1, 0x7d, 0x45, 0xed, 0xc2, 0x6a, 0x67, 0x1a, 0xd6, + 0x0e, 0x02, 0x4a, 0x8e, 0xb1, 0x50, 0xe6, 0x55, 0xc8, 0x31, 0xc7, 0xf6, 0x0d, 0x3e, 0xa4, 0x38, + 0x62, 0x9b, 0x19, 0x10, 0x82, 0x45, 0x66, 0xb8, 0xd1, 0xe9, 0x6b, 0xe2, 0x59, 0xfd, 0x67, 0x01, + 0xd6, 0x66, 0x58, 0x5d, 0xdf, 0xbc, 0x4d, 0x3b, 0xd8, 0x14, 0x60, 0x1f, 0x40, 0xe1, 0x88, 0x12, + 0x4f, 0x37, 0x2c, 0x8b, 0x62, 0xc6, 0x22, 0xa9, 0xcb, 0x8f, 0x1f, 0x6c, 0x17, 0x23, 0x19, 0xda, + 0xd2, 0x73, 0xc0, 0xa9, 0xe3, 0xdb, 0x5a, 0x3e, 0x8c, 0x8e, 0x4c, 0xe8, 0xee, 0x1c, 0x1d, 0x16, + 0x84, 0x0e, 0xbb, 0xcf, 0xd6, 0xe1, 0x3f, 0x99, 0x3c, 0x9f, 0x2a, 0xdc, 0xdc, 0xf9, 0xf1, 0x7e, + 0x2d, 0xf5, 0xd7, 0xfd, 0x5a, 0xea, 0x87, 0xf3, 0x93, 0xad, 0x64, 0xf1, 0x3f, 0x9d, 0x9f, 0x6c, + 0xbd, 0x91, 0xe8, 0xe0, 0x3d, 0x66, 0xb7, 0x2d, 0x4b, 0x94, 0x43, 0xb1, 0xc1, 0xf0, 0xac, 0x4a, + 0xf5, 0x37, 0x05, 0x56, 0xf6, 0x98, 0x3d, 0xb3, 0xa0, 0xcf, 0x20, 0xd7, 0x33, 0x18, 0xd6, 0x1d, + 0xff, 0x88, 0x88, 0x54, 0xf3, 0xad, 0xed, 0xff, 0x75, 0x5a, 0x5a, 0x36, 0xdc, 0x2f, 0x14, 0xfc, + 0x12, 0x56, 0x0c, 0xd9, 0x1d, 0x96, 0xc4, 0x93, 0x65, 0xbe, 0x75, 0x29, 0x5e, 0xa2, 0xa7, 0xb4, + 0x42, 0x0c, 0x11, 0xae, 0xd4, 0x5f, 0x17, 0x01, 0x7d, 0xe5, 0xcf, 0xf6, 0x69, 0xd8, 0x24, 0xd4, + 0x42, 0xd7, 0x21, 0xc7, 0xb8, 0x31, 0xc0, 0x74, 0x36, 0x13, 0x0a, 0x93, 0xd3, 0x5a, 0xf6, 0x40, + 0x18, 0xbb, 0x1d, 0x2d, 0x2b, 0xdd, 0x5d, 0xeb, 0xc2, 0xf4, 0x58, 0x78, 0xc6, 0xf4, 0xf8, 0x08, + 0x56, 0x66, 0xdd, 0x63, 0x59, 0xb4, 0x9c, 0xbe, 0xa4, 0xff, 0x0a, 0x71, 0x78, 0x68, 0x46, 0x25, + 0xc8, 0xf0, 0x91, 0xde, 0x37, 0x58, 0xbf, 0xbc, 0x28, 0x04, 0x5f, 0xe6, 0xa3, 0x4f, 0x0d, 0xd6, + 0x47, 0xaf, 0x01, 0x38, 0x4c, 0x0f, 0xb0, 0x6f, 0x39, 0xbe, 0x5d, 0x5e, 0xda, 0x50, 0xea, 0x59, + 0x2d, 0xe7, 0xb0, 0x3b, 0xd2, 0x80, 0xae, 0x41, 0xa1, 0xe7, 0x12, 0x73, 0xa0, 0xfb, 0x43, 0xaf, + 0x87, 0x69, 0x79, 0x79, 0x43, 0xa9, 0x2f, 0x6a, 0x79, 0x61, 0xdb, 0x17, 0x26, 0xd4, 0x82, 0x55, + 0x93, 0x78, 0x81, 0x8b, 0x39, 0xd6, 0x2f, 0xc4, 0x66, 0x44, 0xec, 0xcb, 0xb1, 0x73, 0x27, 0xb1, + 0xa7, 0x0a, 0x79, 0xf7, 0x9e, 0xce, 0x47, 0xba, 0x4f, 0x7c, 0x13, 0x97, 0xb3, 0x22, 0x32, 0xe7, + 0xde, 0x3b, 0x1c, 0xed, 0x87, 0x86, 0xc4, 0x18, 0xcf, 0x5d, 0xdd, 0x18, 0x47, 0x1c, 0x4a, 0x86, + 0xc9, 0x87, 0x86, 0xab, 0xc7, 0x39, 0x4d, 0x47, 0x30, 0x5c, 0x01, 0xcd, 0xaa, 0x04, 0xff, 0x38, + 0xc6, 0x96, 0x6f, 0x9b, 0xfa, 0x2e, 0xac, 0x3f, 0xd9, 0x22, 0x9f, 0xe3, 0xf1, 0x17, 0x0e, 0xe3, + 0x68, 0x1d, 0xb2, 0x03, 0x3c, 0xd6, 0x5d, 0x87, 0x85, 0x5f, 0xac, 0x74, 0x3d, 0xa7, 0x65, 0x06, + 0xd2, 0xa5, 0x16, 0x01, 0x75, 0x12, 0xbb, 0x58, 0x40, 0x7c, 0x86, 0xd5, 0x6f, 0xe1, 0x85, 0x3d, + 0x66, 0x27, 0x01, 0xaf, 0xf2, 0x1d, 0x51, 0xd7, 0xa0, 0x78, 0x31, 0x59, 0x49, 0xdb, 0xfa, 0x5b, + 0x81, 0xf4, 0x1e, 0xb3, 0xd1, 0x77, 0x50, 0x8a, 0xbf, 0x0e, 0xa2, 0x45, 0x0f, 0x49, 0x3c, 0x5b, + 0xd0, 0xeb, 0x73, 0x38, 0x2f, 0xbc, 0xd0, 0x95, 0xeb, 0x97, 0x66, 0x16, 0x73, 0x22, 0x0a, 0xaf, + 0x4c, 0x73, 0x91, 0x6c, 0xb7, 0x28, 0xf1, 0xa6, 0x7c, 0x9b, 0xf3, 0xf9, 0x92, 0x25, 0x54, 0xde, + 0x9c, 0x13, 0xf7, 0xb4, 0x3a, 0x2b, 0x4b, 0xdf, 0x9f, 0x9f, 0x6c, 0x29, 0x3b, 0xfb, 0x0f, 0x27, + 0x55, 0xe5, 0xd1, 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. @@ -926,8 +653,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 +667,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 +687,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 +697,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 +708,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 +748,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, @@ -1171,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]) @@ -1181,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]) @@ -1218,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]) @@ -1253,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 } @@ -1273,238 +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) { - 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 *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) { +func (m *UndelegationRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1763,165 +1259,83 @@ 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) { +func (m *DelegationApproveInfo) 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.Signature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - l = len(m.ClientChainEarningAddr) + l = len(m.Salt) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *OperatorInfo) Size() (n int) { +func (m *DelegationIncOrDecInfo) 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) + l = len(m.FromAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.ClientChainEarningsAddr != nil { - l = m.ClientChainEarningsAddr.Size() - 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 *RegisterOperatorReq) Size() (n int) { +func (m *MsgDelegation) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.FromAddress) - if l > 0 { + if m.BaseInfo != nil { + l = m.BaseInfo.Size() n += 1 + l + sovTx(uint64(l)) } - if m.Info != nil { - l = m.Info.Size() + if m.ApprovedInfo != nil { + l = m.ApprovedInfo.Size() n += 1 + l + sovTx(uint64(l)) } return n } -func (m *DelegationApproveInfo) Size() (n int) { +func (m *UndelegationRecord) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Signature) + l = len(m.StakerID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Salt) + l = len(m.AssetID) 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.OperatorAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } l = len(m.TxHash) if l > 0 { @@ -2327,192 +1741,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 { @@ -2535,15 +1764,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 { @@ -2571,11 +1800,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 { @@ -2603,358 +1832,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/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 67c3960c3..6d3422f73 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" ) @@ -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,21 +130,21 @@ 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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount, - CanWithdrawAmountOrWantChangeValue: params.OpAmount, + changeAmount := types.StakerSingleAssetChangeInfo{ + TotalDepositAmount: params.OpAmount, + 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 41c87e024..230d70efe 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" ) @@ -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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount, - CanWithdrawAmountOrWantChangeValue: params.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + 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 d2b23dce1..7caa6de57 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" @@ -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 4cf9e312c..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 `restaking_assets_manage` 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/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/deposit/types/deposit.pb.go b/x/deposit/types/deposit.pb.go index 7b6c68395..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" @@ -23,12 +22,8 @@ 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"` - // 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 +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.deposit.v1.Params") } @@ -85,23 +66,16 @@ func init() { func init() { proto.RegisterFile("exocore/deposit/v1/deposit.proto", fileDescriptor_bb743e1548b62476) } var fileDescriptor_bb743e1548b62476 = []byte{ - // 247 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, 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, + 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0xa0, 0x2a, 0xf4, 0x60, 0xc2, 0x65, 0x86, 0x4a, + 0x1c, 0x5c, 0x6c, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 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, 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) { @@ -124,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 = 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 +118,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 +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 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/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 040aabdf5..7c7b517ea 100644 --- a/x/dogfood/keeper/abci.go +++ b/x/dogfood/keeper/abci.go @@ -19,13 +19,16 @@ 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. 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 +36,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 +50,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..bb876dc49 100644 --- a/x/dogfood/keeper/impl_delegation_hooks.go +++ b/x/dogfood/keeper/impl_delegation_hooks.go @@ -32,9 +32,9 @@ 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( + 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. @@ -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/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..a14789775 100644 --- a/x/dogfood/types/expected_keepers.go +++ b/x/dogfood/types/expected_keepers.go @@ -36,37 +36,37 @@ 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) } // 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) } // 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. @@ -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/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/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/client/cli/query.go b/x/operator/client/cli/query.go new file mode 100644 index 000000000..6f41f7055 --- /dev/null +++ b/x/operator/client/cli/query.go @@ -0,0 +1,56 @@ +package cli + +import ( + "context" + + operatortypes "github.com/ExocoreNetwork/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 operator module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetOperatorInfo(), + ) + return cmd +} + +// GetOperatorInfo queries operator info +func GetOperatorInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "GetOperatorInfo 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.GetOperatorInfoReq{ + OperatorAddr: args[0], + } + res, err := queryClient.GetOperatorInfo(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..31caa4171 --- /dev/null +++ b/x/operator/client/cli/tx.go @@ -0,0 +1,81 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + errorsmod "cosmossdk.io/errors" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/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 +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: operatortypes.ModuleName, + Short: "operator 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..c39e46675 --- /dev/null +++ b/x/operator/keeper/abci.go @@ -0,0 +1,149 @@ +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" + abci "github.com/cometbft/cometbft/abci/types" + 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 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.optedInAssetsInfo[assetID][operatorAddr]; ok { + newAssetUSDValue := CalculateShare(assetAmount, priceChange.NewPrice, assetDecimal, priceChange.Decimal) + key := string(types.GetJoinedStoreKey(avsAddr, stakerID, operatorAddr)) + AddShareInMap(sharedParam.stakerShare, key, newAssetUSDValue) + } +} + +// 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 { + return err + } + if len(priceChangeAssets) == 0 { + return nil + } + 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 + assetInfo, err := k.assetsKeeper.GetStakingAssetInfo(ctx, assetID) + if err != nil { + return err + } + assetsDecimal[assetID] = assetInfo.AssetBasicInfo.Decimals + if _, ok := optedInAssetsInfo[assetID]; !ok { + optedInAssetsInfo[assetID] = make(map[string]string, 0) + } + // 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 + + avsAddr := keys[1] + avsOperator := string(types.GetJoinedStoreKey(keys[1], keys[2])) + AddShareInMap(shareChangeForAvsOperator, avsAddr, changeValue) + AddShareInMap(shareChangeForAvsOperator, avsOperator, changeValue) + optedInAssetsInfo[assetID][keys[2]] = avsAddr + return nil + } + err = k.IterateUpdateAssetState(ctx, assetID, f) + if err != nil { + return err + } + } + // BatchUpdateShareForAVSAndOperator + err = k.BatchUpdateShareForAVSAndOperator(ctx, shareChangeForAvsOperator) + if err != nil { + return err + } + + // update the USD share for staker and operator + sharedParameter := &SharedParameter{ + 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) + return nil + } + err = k.delegationKeeper.IterateDelegationState(ctx, stakerShareHandleFunc) + if err != nil { + return err + } + + operatorShareHandleFunc := func(operatorAddr, assetID string, state *types.OperatorAssetInfo) error { + UpdateShareOfStakerAndOperator(sharedParameter, assetID, "", operatorAddr, state.OperatorAmount) + return nil + } + err = k.assetsKeeper.IteratorOperatorAssetState(ctx, operatorShareHandleFunc) + if err != nil { + 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) + } + return []abci.ValidatorUpdate{} +} diff --git a/x/operator/keeper/avs_operator_shares.go b/x/operator/keeper/avs_operator_shares.go new file mode 100644 index 000000000..a2ae08356 --- /dev/null +++ b/x/operator/keeper/avs_operator_shares.go @@ -0,0 +1,337 @@ +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" + "github.com/cosmos/cosmos-sdk/store/prefix" + 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 + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + var key []byte + if operatorAddr == "" { + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") + } + 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 := assetstype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&totalValue) + store.Set(key, bz) + 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 + if operatorAddr == "" { + return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorShare the operatorAddr is empty") + } + key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) + + store.Delete(key) + 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 + var key []byte + if operatorAddr == "" { + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetOperatorShare the operatorAddr is empty") + } + key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) + + isExist := store.Has(key) + if !isExist { + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorShare: key is %suite", key)) + } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + + 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 + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorAssetsTotalValue) + key := []byte(avsAddr) + totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &totalValue) + } + err := assetstype.UpdateAssetDecValue(&totalValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&totalValue) + store.Set(key, bz) + 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 { + key := []byte(avs) + totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} + if store.Has(key) { + value := store.Get(key) + k.cdc.MustUnmarshal(value, &totalValue) + } + tmpOpAmount := opAmount + err := assetstype.UpdateAssetDecValue(&totalValue.Amount, &tmpOpAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&totalValue) + store.Set(key, bz) + } + 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 + key := []byte(avsAddr) + isExit := store.Has(key) + if !isExit { + return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSShare: key is %suite", key)) + } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + + 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() { + return nil + } + // check operator address validation + _, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return assetstype.ErrInvalidOperatorAddr + } + stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) + optedInAssetState := operatortypes.OptedInAssetState{ + Amount: sdkmath.NewInt(0), + Value: sdkmath.LegacyNewDec(0), + } + + if store.Has(stateKey) { + value := store.Get(stateKey) + k.cdc.MustUnmarshal(value, &optedInAssetState) + } + + err = assetstype.UpdateAssetValue(&optedInAssetState.Amount, &changeState.Amount) + if err != nil { + return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Amount error") + } + + err = assetstype.UpdateAssetDecValue(&optedInAssetState.Value, &changeState.Value) + if err != nil { + return errorsmod.Wrap(err, "UpdateStateForAsset OptedInAssetState.Value error") + } + + // save single operator delegation state + bz := k.cdc.MustMarshal(&optedInAssetState) + store.Set(stateKey, bz) + 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 + _, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return assetstype.ErrInvalidOperatorAddr + } + stateKey := assetstype.GetJoinedStoreKey(assetID, avsAddr, operatorAddr) + store.Delete(stateKey) + 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) + isExit := store.Has(stateKey) + optedInAssetState := operatortypes.OptedInAssetState{} + if isExit { + value := store.Get(stateKey) + k.cdc.MustUnmarshal(value, &optedInAssetState) + } else { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAssetState: key is %suite", stateKey)) + } + 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)) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + keys, err := assetstype.ParseJoinedStoreKey(iterator.Key(), 3) + if err != nil { + return err + } + optedInAssetState := &operatortypes.OptedInAssetState{} + k.cdc.MustUnmarshal(iterator.Value(), optedInAssetState) + err = f(assetID, keys, optedInAssetState) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(optedInAssetState) + store.Set(iterator.Key(), bz) + } + 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 + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixAVSOperatorStakerShareState) + 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 := assetstype.UpdateAssetDecValue(&optedInValue.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&optedInValue) + store.Set(key, bz) + 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 { + optedInValue := operatortypes.DecValueField{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 +} + +// 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) + store.Delete(key) + 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 + 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)) + } + value := store.Get(key) + k.cdc.MustUnmarshal(value, &ret) + + return ret.Amount, nil +} diff --git a/x/operator/keeper/common_func.go b/x/operator/keeper/common_func.go new file mode 100644 index 000000000..35a437276 --- /dev/null +++ b/x/operator/keeper/common_func.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdkmath "cosmossdk.io/math" + operatortypes "github.com/ExocoreNetwork/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 { + // #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/consensus_keys.go b/x/operator/keeper/consensus_keys.go new file mode 100644 index 000000000..c6fd55434 --- /dev/null +++ b/x/operator/keeper/consensus_keys.go @@ -0,0 +1,431 @@ +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" + + assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" + delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/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.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + return assetstypes.ErrUnknownAppChainID + } + // 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.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + err = assetstypes.ErrUnknownAppChainID + 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.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + err = assetstypes.ErrUnknownAppChainID + 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.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + return nil, nil + } + // 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 addrs, pubKeys +} + +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 found, addr +} + +// 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.assetsKeeper.AppChainInfoIsExist(ctx, chainID) { + return assetstypes.ErrUnknownAppChainID + } + 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) {} + +func (k *Keeper) GetActiveOperatorsForChainID( + sdk.Context, string, +) ([]sdk.AccAddress, []tmprotocrypto.PublicKey) { + return nil, nil +} diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go new file mode 100644 index 000000000..d86edeb0a --- /dev/null +++ b/x/operator/keeper/grpc_query.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "context" + "errors" + + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ operatortypes.QueryServer = &Keeper{} + +func (k *Keeper) GetOperatorInfo(ctx context.Context, req *operatortypes.GetOperatorInfoReq) (*operatortypes.OperatorInfo, error) { + c := sdk.UnwrapSDKContext(ctx) + return k.OperatorInfo(c, req.OperatorAddr) +} + +// QueryOperatorConsKeyForChainID add for dogfood +func (k *Keeper) QueryOperatorConsKeyForChainID( + goCtx context.Context, + req *operatortypes.QueryOperatorConsKeyRequest, +) (*operatortypes.QueryOperatorConsKeyResponse, 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.QueryOperatorConsKeyResponse{ + PublicKey: key, + }, nil +} diff --git a/x/operator/keeper/keeper.go b/x/operator/keeper/keeper.go new file mode 100644 index 000000000..1a029d03d --- /dev/null +++ b/x/operator/keeper/keeper.go @@ -0,0 +1,74 @@ +package keeper + +import ( + "context" + + sdkmath "cosmossdk.io/math" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + + // other keepers + assetsKeeper operatortypes.AssetsKeeper + delegationKeeper operatortypes.DelegationKeeper + oracleKeeper operatortypes.OracleKeeper + avsKeeper operatortypes.AvsKeeper + + // add for dogfood + hooks operatortypes.OperatorConsentHooks // set separately via call to SetHooks + slashKeeper operatortypes.SlashKeeper // for jailing and unjailing check TODO(mm) +} + +func NewKeeper( + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + assetsKeeper operatortypes.AssetsKeeper, + oracleKeeper operatortypes.OracleKeeper, + avsKeeper operatortypes.AvsKeeper, + slashKeeper operatortypes.SlashKeeper, +) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + assetsKeeper: assetsKeeper, + oracleKeeper: oracleKeeper, + avsKeeper: avsKeeper, + slashKeeper: slashKeeper, + } +} + +func (k *Keeper) RegisterExpectDelegationInterface(delegationKeeper operatortypes.DelegationKeeper) { + k.delegationKeeper = delegationKeeper +} + +func (k *Keeper) OracleInterface() operatortypes.OracleKeeper { + return k.oracleKeeper +} + +func (k *Keeper) GetUnbondingExpirationBlockNumber(_ sdk.Context, _ sdk.AccAddress, startHeight uint64) uint64 { + return startHeight + operatortypes.UnbondingExpiration +} + +// 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) + + 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 + + OptIn(ctx sdk.Context, operatorAddress sdk.AccAddress, AVSAddr string) error + + 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 +} diff --git a/x/operator/keeper/msg_server.go b/x/operator/keeper/msg_server.go new file mode 100644 index 000000000..fcc018a67 --- /dev/null +++ b/x/operator/keeper/msg_server.go @@ -0,0 +1,80 @@ +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" +) + +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 +} + +// 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.OptInToCosmosChainRequest, +) (*types.OptInToCosmosChainResponse, 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.OptInToCosmosChainResponse{}, nil +} + +// 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) InitOptOutFromCosmosChain( + goCtx context.Context, + req *types.InitOptOutFromCosmosChainRequest, +) (*types.InitOptOutFromCosmosChainResponse, 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.InitOptOutFromCosmosChainResponse{}, 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/keeper/operator.go b/x/operator/keeper/operator.go new file mode 100644 index 000000000..9ef38595a --- /dev/null +++ b/x/operator/keeper/operator.go @@ -0,0 +1,117 @@ +package keeper + +import ( + "fmt" + + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + + errorsmod "cosmossdk.io/errors" + + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/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 +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) 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") + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorInfo) + // key := common.HexToAddress(incentive.Contract) + isExist := store.Has(opAccAddr) + if !isExist { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %suite", 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 assetstype.ErrInvalidOperatorAddr + } + infoKey := assetstype.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 := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) + ifExist := store.Has(infoKey) + if !ifExist { + return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: key is %suite", 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 false + } + return true +} + +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 := assetstype.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..6c4109d35 --- /dev/null +++ b/x/operator/keeper/operator_info_test.go @@ -0,0 +1,61 @@ +package keeper_test + +import ( + "github.com/ExocoreNetwork/exocore/x/assets/types" + operatortype "github.com/ExocoreNetwork/exocore/x/operator/types" +) + +func (suite *OperatorTestSuite) 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, &operatortype.GetOperatorInfoReq{OperatorAddr: suite.AccAddress.String()}) + suite.NoError(err) + suite.Equal(*info, *getOperatorInfo) +} + +func (suite *OperatorTestSuite) TestHistoricalOperatorInfo() { + height := suite.Ctx.BlockHeight() + info := &operatortype.OperatorInfo{ + EarningsAddr: suite.AccAddress.String(), + ApproveAddr: "", + OperatorMetaInfo: "test operator", + ClientChainEarningsAddr: &operatortype.ClientChainEarningAddrList{ + EarningInfoList: nil, + }, + } + 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 = suite.App.OperatorKeeper.SetOperatorInfo(suite.Ctx, suite.AccAddress.String(), &newInfo) + suite.NoError(err) + + // get historical operator info + historicalQueryCtx, err := types.ContextForHistoricalState(suite.Ctx, height) + suite.NoError(err) + 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(), + }) + 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 new file mode 100644 index 000000000..cdc9878d5 --- /dev/null +++ b/x/operator/keeper/operator_slash_state.go @@ -0,0 +1,136 @@ +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" + "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 assetstype.ErrInvalidOperatorAddr + } + slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) + if store.Has(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:%suite", slashInfo.SlashContract)) + } + 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)) { + 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 +} + +// 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 := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) + 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 %suite", slashInfoKey)) + } + return &operatorSlashInfo, nil +} + +// 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 + } + 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)) + } + + 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 := assetstype.UpdateAssetValue(&slashAmount.Amount, &opAmount) + if err != nil { + return err + } + bz := k.cdc.MustMarshal(&slashAmount) + store.Set(key, bz) + + 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 = assetstype.UpdateAssetValue(&totalSlashAmount.Amount, &opAmount) + if err != nil { + return err + } + bz = k.cdc.MustMarshal(&slashAmount) + store.Set(key, bz) + return nil +} + +// 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 = assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(processedHeight), assetID) + } else { + key = assetstype.GetJoinedStoreKey(hexutil.EncodeUint64(processedHeight), assetID, stakerOrOperator) + } + var ret assetstype.ValueField + isExit := store.Has(key) + if !isExit { + return sdkmath.Int{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetSlashAssetsState: key is %suite", key)) + } + 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 new file mode 100644 index 000000000..efb6ca9d3 --- /dev/null +++ b/x/operator/keeper/setup_test.go @@ -0,0 +1,44 @@ +package keeper_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/stretchr/testify/suite" +) + +var s *OperatorTestSuite + +type OperatorTestSuite struct { + testutil.BaseTestSuite + + // 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 TestOperatorTestSuite(t *testing.T) { + s = new(OperatorTestSuite) + suite.Run(t, s) + + // Run Ginkgo integration tests + RegisterFailHandler(Fail) + RunSpecs(t, "operator module Suite") +} + +func (suite *OperatorTestSuite) SetupTest() { + suite.DoSetupTest() +} diff --git a/x/operator/keeper/state_update.go b/x/operator/keeper/state_update.go new file mode 100644 index 000000000..e047ebb6e --- /dev/null +++ b/x/operator/keeper/state_update.go @@ -0,0 +1,496 @@ +package keeper + +import ( + "fmt" + + 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" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type AssetPriceAndDecimal struct { + Price sdkmath.Int + PriceDecimal uint8 + Decimal uint32 +} + +type slashAmounts struct { + AmountFromUnbonding sdkmath.Int + AmountFromOptedIn sdkmath.Int +} +type SlashAssets struct { + slashStakerInfo map[string]map[string]*slashAmounts + 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) + if err != nil { + return err + } + // 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.assetsKeeper.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 + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avs) + if err != nil { + return err + } + + if _, ok := avsSupportedAssets[assetID]; ok { + // UpdateStakerShare + err = k.UpdateStakerShare(ctx, avs, stakerID, operatorAddr, opUSDValue) + if err != nil { + return err + } + + // UpdateStateForAsset + changeState := types.OptedInAssetStateChange{ + Amount: opAmount, + Value: opUSDValue, + } + err = k.UpdateStateForAsset(ctx, assetID, avs, operatorAddr, changeState) + if err != nil { + return err + } + + // UpdateOperatorShare + err = k.UpdateOperatorShare(ctx, avs, operatorAddr, opUSDValue) + if err != nil { + return err + } + + // UpdateAVSShare + err = k.UpdateAVSShare(ctx, avs, opUSDValue) + if err != nil { + return err + } + } + } + return nil +} + +// 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 supported by the AVS + avsSupportedAssets, err := k.avsKeeper.GetAvsSupportedAssets(ctx, avsAddr) + if err != nil { + return err + } + + // get the Assets opted in the operator + operatorAssets, err := k.assetsKeeper.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, operatorAssetState := range operatorAssets { + // 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.assetsKeeper.GetStakingAssetInfo(ctx, assetID) + if err != nil { + return err + } + assetInfoRecord[assetID] = &AssetPriceAndDecimal{ + Price: price, + PriceDecimal: decimal, + Decimal: assetInfo.AssetBasicInfo.Decimals, + } + assetUSDValue := CalculateShare(operatorAssetState.TotalAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) + operatorUSDValue := CalculateShare(operatorAssetState.OperatorAmount, price, assetInfo.AssetBasicInfo.Decimals, decimal) + operatorOwnAssetUSDValue = operatorOwnAssetUSDValue.Add(operatorUSDValue) + + // UpdateStateForAsset + changeState := types.OptedInAssetStateChange{ + Amount: operatorAssetState.TotalAmount, + Value: assetUSDValue, + } + err = k.UpdateStateForAsset(ctx, assetID, avsAddr, operatorAddress.String(), changeState) + if err != nil { + return err + } + totalAssetUSDValue = totalAssetUSDValue.Add(assetUSDValue) + assetFilter[assetID] = nil + } + + // 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) + if err != nil { + return err + } + // UpdateOperatorShare + err = k.UpdateOperatorShare(ctx, avsAddr, operatorAddress.String(), totalAssetUSDValue) + if err != nil { + return err + } + + // UpdateStakerShare + relatedAssetsState, err := k.delegationKeeper.DelegationStateByOperatorAssets(ctx, operatorAddress.String(), assetFilter) + if err != nil { + return err + } + + for stakerID, assetState := range relatedAssetsState { + stakerAssetsUSDValue := sdkmath.LegacyNewDec(0) + for assetID, amount := range assetState { + singleAssetUSDValue := CalculateShare(amount.UndelegatableAmount, assetInfoRecord[assetID].Price, assetInfoRecord[assetID].Decimal, assetInfoRecord[assetID].PriceDecimal) + stakerAssetsUSDValue = stakerAssetsUSDValue.Add(singleAssetUSDValue) + } + + 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) + if err != nil { + return err + } + optedInfo := &types.OptedInfo{ + SlashContract: slashContract, + // #nosec G701 + 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 { + // 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) + if err != nil { + return err + } + // get the Assets opted in the operator + operatorAssets, err := k.assetsKeeper.GetOperatorAssetInfos(ctx, operatorAddress, avsSupportedAssets) + if err != nil { + return err + } + + assetFilter := make(map[string]interface{}) + + for assetID := range operatorAssets { + err = k.DeleteAssetState(ctx, assetID, avsAddr, operatorAddress.String()) + if err != nil { + return err + } + assetFilter[assetID] = nil + } + + 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:%suite", avsOperatorTotalValue)) + } + + // 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()) + if err != nil { + return err + } + // DeleteOperatorShare + err = k.DeleteOperatorShare(ctx, avsAddr, operatorAddress.String()) + if err != nil { + return err + } + + // 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()) + if err != nil { + return err + } + } + + // 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) + if err != nil { + return err + } + return nil +} + +// 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, 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 + historicalStateCtx, err := types2.ContextForHistoricalState(ctx, slashEventHeight) + if err != nil { + return nil, err + } + // get assetsInfo supported by AVS + assetsFilter, err := k.avsKeeper.GetAvsSupportedAssets(historicalStateCtx, avsAddr) + if err != nil { + return nil, err + } + 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(historicalStateCtx, operatorAddress, assetsFilter) + if err != nil { + return nil, err + } + + // 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 + currentOperatorAssetsState, err := k.assetsKeeper.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, isExist := historyAssetState[assetID]; isExist { + if _, exist := ret.slashStakerInfo[stakerID]; !exist { + ret.slashStakerInfo[stakerID] = make(map[string]*slashAmounts, 0) + } + 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 + } + } 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.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 { + 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, 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{ + UndelegatableAmount: slashInfo.AmountFromOptedIn.Neg(), + UndelegatableAfterSlash: slashInfo.AmountFromUnbonding.Neg(), + } + err := k.delegationKeeper.UpdateDelegationState(ctx, stakerID, assetID, delegatorAndAmount) + 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 + err = k.assetsKeeper.UpdateStakerAssetState(ctx, stakerID, assetID, types2.StakerSingleAssetChangeInfo{ + TotalDepositAmount: 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, processedHeight, slashSumValue) + if err != nil { + return err + } + + // handle the state that needs to be updated when slashing opted-in assets + err = k.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ + TotalAmount: 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, 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.assetsKeeper.UpdateOperatorAssetState(ctx, operatorAddress, assetID, types2.OperatorSingleAssetChangeInfo{ + TotalAmount: slashSumValue.Neg(), + OperatorAmount: slashInfo.AmountFromOptedIn.Neg(), + OperatorUnbondableAmountAfterSlash: 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(), processedHeight, 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 +} + +// 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, slashEventHeight int64, slashProportion sdkmath.LegacyDec) error { + height := ctx.BlockHeight() + 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, slashEventHeight) + if err != nil { + return err + } + if !k.IsOptedIn(ctx, operatorAddress.String(), avsAddr) { + return types.ErrNotOptedIn + } + 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:%suite, opted-in slash contract:%suite", slashContract, optedInfo.SlashContract)) + } + + // todo: recording the slash event might be moved to the slash module + slashInfo := types.OperatorSlashInfo{ + SlashContract: slashContract, + SubmittedHeight: height, + EventHeight: slashEventHeight, + SlashProportion: slashProportion, + ProcessedHeight: 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.GetAssetsAmountToSlash(ctx, operatorAddress, avsAddr, slashEventHeight, slashProportion) + if err != nil { + return err + } + // #nosec G701 + 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.ProcessedHeight)) + if err != nil { + return err + } + return nil +} diff --git a/x/operator/keeper/state_update_test.go b/x/operator/keeper/state_update_test.go new file mode 100644 index 000000000..10be7bf59 --- /dev/null +++ b/x/operator/keeper/state_update_test.go @@ -0,0 +1,232 @@ +package keeper_test + +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" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +type StateForCheck struct { + OptedInfo *operatorTypes.OptedInfo + AVSTotalShare sdkmath.LegacyDec + AVSOperatorShare sdkmath.LegacyDec + AssetState *operatorTypes.OptedInAssetState + OperatorShare sdkmath.LegacyDec + StakerShare sdkmath.LegacyDec +} + +func (suite *OperatorTestSuite) prepare() { + opAccAddr, err := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") + 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 = assetstypes.GetStakeIDAndAssetID(suite.clientChainLzID, suite.Address[:], suite.assetAddr[:]) + + // staking assets + depositParam := &keeper.DepositParams{ + ClientChainLzID: suite.clientChainLzID, + Action: assetstypes.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: assetstypes.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 *OperatorTestSuite) 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 (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 + 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.OptedInAssetState{ + Amount: suite.delegationAmount, + Value: share, + }, + OperatorShare: sdkmath.LegacyDec{}, + StakerShare: share, + } + suite.CheckState(expectedState) +} + +func (suite *OperatorTestSuite) 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 (suite *OperatorTestSuite) 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 *OperatorTestSuite) 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.OptedInAssetState{ + Amount: suite.delegationAmount.Add(suite.updatedAmountForOptIn), + Value: newShare, + }, + OperatorShare: sdkmath.LegacyDec{}, + StakerShare: newShare, + } + suite.CheckState(expectedState) +} + +func (suite *OperatorTestSuite) TestSlash() { + suite.prepare() + err := suite.App.OperatorKeeper.OptIn(suite.Ctx, suite.operatorAddr, suite.avsAddr) + suite.NoError(err) + 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()) +} diff --git a/x/operator/module.go b/x/operator/module.go new file mode 100644 index 000000000..cf870c535 --- /dev/null +++ b/x/operator/module.go @@ -0,0 +1,94 @@ +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" + 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/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" +) + +// 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(_ 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(_ *module.SimulationState) { +} + +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +} + +func (am AppModule) WeightedOperations(_ 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/app_chain_utils.go b/x/operator/types/app_chain_utils.go new file mode 100644 index 000000000..d776a976b --- /dev/null +++ b/x/operator/types/app_chain_utils.go @@ -0,0 +1,41 @@ +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 + // #nosec G701 + 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 new file mode 100644 index 000000000..17edd4f33 --- /dev/null +++ b/x/operator/types/codec.go @@ -0,0 +1,46 @@ +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) +) + +// 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{}, + &OptInToCosmosChainRequest{}, + &InitOptOutFromCosmosChainRequest{}, + ) + 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(_ *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..d7e4ed12a --- /dev/null +++ b/x/operator/types/errors.go @@ -0,0 +1,35 @@ +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") + + 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") + + 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") + + // 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_keepers.go b/x/operator/types/expected_keepers.go new file mode 100644 index 000000000..5377075f8 --- /dev/null +++ b/x/operator/types/expected_keepers.go @@ -0,0 +1,121 @@ +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" +) + +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 + 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 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) + + UpdateStakerDelegationTotalAmount(ctx sdk.Context, stakerID string, assetID string, opAmount sdkmath.Int) error +} + +type PriceChange struct { + OriginalPrice sdkmath.Int + NewPrice sdkmath.Int + Decimal uint8 +} + +// 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) +} + +type MockOracle struct{} + +func (MockOracle) GetSpecifiedAssetsPrice(_ sdk.Context, _ string) (sdkmath.Int, uint8, error) { + return sdkmath.NewInt(1), 0, nil +} + +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{ + NewPrice: sdkmath.NewInt(1), + OriginalPrice: sdkmath.NewInt(1), + Decimal: 0, + } + return nil, nil +} + +type MockAvs struct{} + +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(_ sdk.Context, _ string) (string, error) { + return "", nil +} + +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 + 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 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/general.go b/x/operator/types/general.go new file mode 100644 index 000000000..bb2573483 --- /dev/null +++ b/x/operator/types/general.go @@ -0,0 +1,4 @@ +package types + +// OptedInAssetStateChange This is a struct to describe the desired change that matches with the OptedInAssetState +type OptedInAssetStateChange OptedInAssetState diff --git a/x/operator/types/hooks.go b/x/operator/types/hooks.go new file mode 100644 index 000000000..0c3441ab6 --- /dev/null +++ b/x/operator/types/hooks.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 new file mode 100644 index 000000000..5e34cf953 --- /dev/null +++ b/x/operator/types/keys.go @@ -0,0 +1,154 @@ +package types + +import ( + "math" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/ethereum/go-ethereum/common" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// 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) + + USDValueDefaultDecimal = uint8(8) + + SlashVetoDuration = int64(1000) + + UnbondingExpiration = 10 +) + +const ( + prefixOperatorInfo = iota + 1 + + prefixOperatorOptedAVSInfo + + prefixAVSOperatorAssetsTotalValue + + prefixOperatorAVSSingleAssetState + + prefixOperatorAVSStakerShareState + + prefixOperatorSlashInfo + + prefixSlashAssetsState + + // add keys for dogfood + BytePrefixForOperatorAndChainIDToConsKey = iota + BytePrefixForOperatorAndChainIDToPrevConsKey + BytePrefixForChainIDAndOperatorToConsKey + BytePrefixForChainIDAndConsKeyToOperator + BytePrefixForOperatorOptOutFromChainID +) + +var ( + // KeyPrefixOperatorInfo key-value: operatorAddr->types.OperatorInfo + KeyPrefixOperatorInfo = []byte{prefixOperatorInfo} + + // KeyPrefixOperatorOptedAVSInfo key-value: + // operatorAddr + '/' + AVSAddr -> OptedInfo + KeyPrefixOperatorOptedAVSInfo = []byte{prefixOperatorOptedAVSInfo} + + // KeyPrefixAVSOperatorAssetsTotalValue key-value: + // 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: + // assetID + '/' + AVSAddr + '/' + operatorAddr -> OptedInAssetState + KeyPrefixOperatorAVSSingleAssetState = []byte{prefixOperatorAVSSingleAssetState} + + // KeyPrefixAVSOperatorStakerShareState key-value: + // 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: + // operator + '/' + AVSAddr + '/' + slashId -> OperatorSlashInfo + KeyPrefixOperatorSlashInfo = []byte{prefixOperatorSlashInfo} + + // KeyPrefixSlashAssetsState key-value: + // processedSlashHeight + '/' + assetID -> SlashAmount + // processedSlashHeight + '/' + assetID + '/' + stakerID -> SlashAmount + // processedSlashHeight + '/' + assetID + '/' + operatorAddr -> SlashAmount + KeyPrefixSlashAssetsState = []byte{prefixSlashAssetsState} +) + +// 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 { + 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 new file mode 100644 index 000000000..16612cd68 --- /dev/null +++ b/x/operator/types/msg.go @@ -0,0 +1,57 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = &RegisterOperatorReq{} + + // add for dogfood + _ sdk.Msg = &OptInToCosmosChainRequest{} + _ sdk.Msg = &InitOptOutFromCosmosChainRequest{} +) + +// 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 +} + +func (m *OptInToCosmosChainRequest) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.Address) + return []sdk.AccAddress{addr} +} + +func (m *OptInToCosmosChainRequest) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Address); err != nil { + return errorsmod.Wrap(err, "invalid from address") + } + return nil +} + +func (m *InitOptOutFromCosmosChainRequest) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.Address) + return []sdk.AccAddress{addr} +} + +func (m *InitOptOutFromCosmosChainRequest) 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 new file mode 100644 index 000000000..737635e24 --- /dev/null +++ b/x/operator/types/query.pb.go @@ -0,0 +1,864 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/operator/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + _ "github.com/cosmos/cosmos-proto" + _ "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 + +// QueryOperatorInfoReq is the request to obtain the operator information. +type GetOperatorInfoReq struct { + // 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"` +} + +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 *GetOperatorInfoReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetOperatorInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetOperatorInfoReq.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 *GetOperatorInfoReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetOperatorInfoReq.Merge(m, src) +} +func (m *GetOperatorInfoReq) XXX_Size() int { + return m.Size() +} +func (m *GetOperatorInfoReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetOperatorInfoReq.DiscardUnknown(m) +} + +var xxx_messageInfo_GetOperatorInfoReq proto.InternalMessageInfo + +func (m *GetOperatorInfoReq) GetOperatorAddr() string { + if m != nil { + return m.OperatorAddr + } + return "" +} + +// 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 *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 *QueryOperatorConsKeyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOperatorConsKeyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOperatorConsKeyRequest.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 *QueryOperatorConsKeyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyRequest.Merge(m, src) +} +func (m *QueryOperatorConsKeyRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOperatorConsKeyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOperatorConsKeyRequest proto.InternalMessageInfo + +func (m *QueryOperatorConsKeyRequest) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *QueryOperatorConsKeyRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +// 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 *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 *QueryOperatorConsKeyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOperatorConsKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOperatorConsKeyResponse.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 *QueryOperatorConsKeyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOperatorConsKeyResponse.Merge(m, src) +} +func (m *QueryOperatorConsKeyResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOperatorConsKeyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOperatorConsKeyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOperatorConsKeyResponse proto.InternalMessageInfo + +func (m *QueryOperatorConsKeyResponse) GetPublicKey() crypto.PublicKey { + if m != nil { + return m.PublicKey + } + return crypto.PublicKey{} +} + +func init() { + proto.RegisterType((*GetOperatorInfoReq)(nil), "exocore.operator.v1.GetOperatorInfoReq") + 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{ + // 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, 0xbe, 0xe7, 0x87, 0xa1, 0x6c, 0x58, 0x77, 0xac, 0xfd, 0xed, 0x5e, 0xe3, + 0xcb, 0xe7, 0x07, 0x3b, 0xc5, 0xb8, 0xdd, 0x30, 0x94, 0xa0, 0xd4, 0x91, 0x96, 0xb1, 0x88, 0xdc, + 0xeb, 0x25, 0x3c, 0x2b, 0x3b, 0x87, 0xe4, 0xf6, 0xeb, 0xcc, 0x83, 0x92, 0xb6, 0x8f, 0x42, 0x1d, + 0x40, 0xea, 0xc2, 0x74, 0x06, 0x4a, 0x53, 0x4a, 0xb6, 0xd6, 0xa4, 0xae, 0xf9, 0xa6, 0xbb, 0xe4, + 0x6a, 0x70, 0xec, 0xc7, 0xc2, 0x8b, 0xc3, 0x46, 0xdd, 0xd4, 0xaf, 0x98, 0xf3, 0x20, 0x74, 0x7c, + 0xd2, 0xaa, 0x66, 0x53, 0x09, 0x0a, 0x05, 0xb4, 0x4b, 0x48, 0x32, 0x1b, 0x8e, 0xe3, 0xc0, 0x1b, + 0x41, 0x6a, 0x48, 0xaf, 0x75, 0x5a, 0x6c, 0xbd, 0x35, 0xcb, 0xb7, 0x66, 0xaf, 0x0c, 0xe8, 0x00, + 0xd2, 0xde, 0xd6, 0xf9, 0xf7, 0xbd, 0x9a, 0xbb, 0x9d, 0x94, 0x85, 0xce, 0xaf, 0x3a, 0xb9, 0x64, + 0x34, 0xe8, 0x07, 0x8b, 0xdc, 0xdc, 0x30, 0x84, 0xde, 0x67, 0x15, 0x21, 0xb2, 0xbf, 0x6d, 0x6b, + 0xde, 0xad, 0x04, 0xfe, 0x89, 0x72, 0xd8, 0xfb, 0xaf, 0x3f, 0x3f, 0xd5, 0xf7, 0xe9, 0x3d, 0x5e, + 0x06, 0x1d, 0xc2, 0x18, 0x22, 0x93, 0x58, 0x16, 0xf5, 0xa6, 0xf6, 0xc2, 0x22, 0x76, 0xd5, 0xf6, + 0xcf, 0x50, 0xf6, 0x8d, 0x3f, 0x4f, 0xe8, 0xc3, 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. +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 { + // 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 *QueryOperatorConsKeyRequest, opts ...grpc.CallOption) (*QueryOperatorConsKeyResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +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/GetOperatorInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +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 + } + return out, nil +} + +// QueryServer is the server API for Query service. +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, *QueryOperatorConsKeyRequest) (*QueryOperatorConsKeyResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +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 *QueryOperatorConsKeyRequest) (*QueryOperatorConsKeyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryOperatorConsKeyForChainID not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +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).GetOperatorInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Query/GetOperatorInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetOperatorInfo(ctx, req.(*GetOperatorInfoReq)) + } + 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(QueryOperatorConsKeyRequest) + 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.(*QueryOperatorConsKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.operator.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetOperatorInfo", + Handler: _Query_GetOperatorInfo_Handler, + }, + { + MethodName: "QueryOperatorConsKeyForChainID", + Handler: _Query_QueryOperatorConsKeyForChainID_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/operator/v1/query.proto", +} + +func (m *GetOperatorInfoReq) 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 *GetOperatorInfoReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetOperatorInfoReq) 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 (m *QueryOperatorConsKeyRequest) 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 *QueryOperatorConsKeyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOperatorConsKeyRequest) 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 *QueryOperatorConsKeyResponse) 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 *QueryOperatorConsKeyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOperatorConsKeyResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GetOperatorInfoReq) 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 (m *QueryOperatorConsKeyRequest) 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 *QueryOperatorConsKeyResponse) 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 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GetOperatorInfoReq) 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: GetOperatorInfoReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetOperatorInfoReq: 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 (m *QueryOperatorConsKeyRequest) 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: QueryOperatorConsKeyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOperatorConsKeyRequest: 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 *QueryOperatorConsKeyResponse) 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: QueryOperatorConsKeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOperatorConsKeyResponse: 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 + 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..df260f313 --- /dev/null +++ b/x/operator/types/query.pb.gw.go @@ -0,0 +1,294 @@ +// 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_GetOperatorInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +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_GetOperatorInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetOperatorInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +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_GetOperatorInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetOperatorInfo(ctx, &protoReq) + return msg, metadata, err + +} + +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 QueryOperatorConsKeyRequest + 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 QueryOperatorConsKeyRequest + 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. +// 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_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 + 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_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 { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + 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 +} + +// 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_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + 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_GetOperatorInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + 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 new file mode 100644 index 000000000..b162bfb3b --- /dev/null +++ b/x/operator/types/tx.pb.go @@ -0,0 +1,3188 @@ +// 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 + +// 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. +// 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"` +} + +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{1} +} +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_b229d5663e4df167, []int{2} +} +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_b229d5663e4df167, []int{3} +} +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 +} + +// OptedInfo is the opted information about operator +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 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 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"` +} + +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{4} +} +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 +} + +// 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 *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 *OptedInAssetState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OptedInAssetState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OptedInAssetState.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 *OptedInAssetState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptedInAssetState.Merge(m, src) +} +func (m *OptedInAssetState) XXX_Size() int { + return m.Size() +} +func (m *OptedInAssetState) XXX_DiscardUnknown() { + xxx_messageInfo_OptedInAssetState.DiscardUnknown(m) +} + +var xxx_messageInfo_OptedInAssetState proto.InternalMessageInfo + +// OperatorSlashInfo is the slash info of operator +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"` + // 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"` +} + +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{6} +} +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) GetSubmittedHeight() int64 { + if m != nil { + return m.SubmittedHeight + } + return 0 +} + +func (m *OperatorSlashInfo) GetEventHeight() int64 { + if m != nil { + return m.EventHeight + } + return 0 +} + +func (m *OperatorSlashInfo) GetProcessedHeight() int64 { + if m != nil { + return m.ProcessedHeight + } + return 0 +} + +func (m *OperatorSlashInfo) GetIsVetoed() bool { + if m != nil { + return m.IsVetoed + } + return false +} + +// 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_b229d5663e4df167, []int{7} +} +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 + +// 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_b229d5663e4df167, []int{8} +} +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 + +// 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. + 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 *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 *OptInToCosmosChainRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OptInToCosmosChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OptInToCosmosChainRequest.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 *OptInToCosmosChainRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToCosmosChainRequest.Merge(m, src) +} +func (m *OptInToCosmosChainRequest) XXX_Size() int { + return m.Size() +} +func (m *OptInToCosmosChainRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToCosmosChainRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_OptInToCosmosChainRequest proto.InternalMessageInfo + +func (m *OptInToCosmosChainRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *OptInToCosmosChainRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *OptInToCosmosChainRequest) GetPublicKey() string { + if m != nil { + return m.PublicKey + } + return "" +} + +// OptInToCosmosChainResponse defines the OptInToCosmosChain response. +type OptInToCosmosChainResponse struct { +} + +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 *OptInToCosmosChainResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OptInToCosmosChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OptInToCosmosChainResponse.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 *OptInToCosmosChainResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_OptInToCosmosChainResponse.Merge(m, src) +} +func (m *OptInToCosmosChainResponse) XXX_Size() int { + return m.Size() +} +func (m *OptInToCosmosChainResponse) XXX_DiscardUnknown() { + xxx_messageInfo_OptInToCosmosChainResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_OptInToCosmosChainResponse proto.InternalMessageInfo + +// 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 *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 *InitOptOutFromCosmosChainRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InitOptOutFromCosmosChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InitOptOutFromCosmosChainRequest.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 *InitOptOutFromCosmosChainRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitOptOutFromCosmosChainRequest.Merge(m, src) +} +func (m *InitOptOutFromCosmosChainRequest) XXX_Size() int { + return m.Size() +} +func (m *InitOptOutFromCosmosChainRequest) XXX_DiscardUnknown() { + xxx_messageInfo_InitOptOutFromCosmosChainRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_InitOptOutFromCosmosChainRequest proto.InternalMessageInfo + +func (m *InitOptOutFromCosmosChainRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *InitOptOutFromCosmosChainRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +// InitOptOutFromCosmosChainResponse defines the InitOptOutFromCosmosChain response. +type InitOptOutFromCosmosChainResponse struct { +} + +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 *InitOptOutFromCosmosChainResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InitOptOutFromCosmosChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InitOptOutFromCosmosChainResponse.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 *InitOptOutFromCosmosChainResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitOptOutFromCosmosChainResponse.Merge(m, src) +} +func (m *InitOptOutFromCosmosChainResponse) XXX_Size() int { + return m.Size() +} +func (m *InitOptOutFromCosmosChainResponse) XXX_DiscardUnknown() { + xxx_messageInfo_InitOptOutFromCosmosChainResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_InitOptOutFromCosmosChainResponse proto.InternalMessageInfo + +func init() { + 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((*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((*OptInToCosmosChainRequest)(nil), "exocore.operator.v1.OptInToCosmosChainRequest") + proto.RegisterType((*OptInToCosmosChainResponse)(nil), "exocore.operator.v1.OptInToCosmosChainResponse") + 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{ + // 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, 0xbd, 0x14, 0x3b, 0xd9, 0x8a, + 0xca, 0x8d, 0x88, 0x57, 0x0d, 0x14, 0x89, 0xc2, 0x81, 0xfc, 0x68, 0x85, 0x45, 0x8a, 0xd1, 0xa6, + 0xea, 0x01, 0x0e, 0xab, 0xcd, 0xee, 0x64, 0x3d, 0x8a, 0xbd, 0xb3, 0xdd, 0x19, 0xbb, 0x49, 0x25, + 0x24, 0x40, 0x1c, 0x10, 0xe2, 0xc0, 0x95, 0x5b, 0xff, 0x84, 0x1c, 0x7a, 0xe1, 0x80, 0xb8, 0xf6, + 0x58, 0xf5, 0x84, 0x38, 0x44, 0x28, 0x39, 0x84, 0x33, 0x7f, 0x01, 0x9a, 0x1f, 0x9b, 0x38, 0x8d, + 0x43, 0x1b, 0x35, 0x97, 0xc4, 0xf3, 0xe6, 0x7b, 0xdf, 0x7b, 0xef, 0x7b, 0xef, 0x8d, 0x16, 0xae, + 0xe2, 0x6d, 0xea, 0xd3, 0x04, 0xdb, 0x34, 0xc6, 0x89, 0xc7, 0x69, 0x62, 0xf7, 0x6f, 0xda, 0x7c, + 0xbb, 0x11, 0x27, 0x94, 0x53, 0x34, 0xad, 0x6f, 0x1b, 0xe9, 0x6d, 0xa3, 0x7f, 0xd3, 0x9c, 0xf2, + 0xba, 0x24, 0xa2, 0xb6, 0xfc, 0xab, 0x70, 0xe6, 0x8c, 0x4f, 0x59, 0x97, 0x32, 0xbb, 0xcb, 0x42, + 0xe1, 0xdf, 0x65, 0xa1, 0xbe, 0xa8, 0xa8, 0x0b, 0x57, 0x9e, 0x6c, 0x75, 0xd0, 0x57, 0x57, 0x42, + 0x1a, 0x52, 0x65, 0x17, 0xbf, 0x94, 0xd5, 0xc2, 0x30, 0xb9, 0x8a, 0xfd, 0x07, 0x5e, 0xa7, 0x87, + 0xef, 0x12, 0xdc, 0x09, 0xd0, 0x7d, 0x18, 0xf3, 0xba, 0xb4, 0x17, 0xf1, 0xb2, 0x31, 0x6b, 0xd4, + 0x27, 0x96, 0x3f, 0x79, 0xb6, 0x57, 0xcb, 0xfc, 0xb5, 0x57, 0xbb, 0x1e, 0x12, 0xde, 0xee, 0x6d, + 0x34, 0x7c, 0xda, 0xd5, 0xbc, 0xfa, 0xdf, 0x02, 0x0b, 0xb6, 0x6c, 0xbe, 0x13, 0x63, 0xd6, 0x58, + 0xc5, 0xfe, 0x8b, 0xa7, 0x0b, 0xa0, 0xc3, 0xae, 0x62, 0xdf, 0xd1, 0x5c, 0xd6, 0x0e, 0x98, 0x2b, + 0x1d, 0x82, 0x23, 0xbe, 0xd2, 0xf6, 0x48, 0x74, 0xc7, 0x4b, 0x22, 0x12, 0x85, 0x4b, 0x41, 0x90, + 0xac, 0x11, 0xc6, 0xd1, 0xd7, 0x30, 0x85, 0x95, 0xc9, 0x25, 0xd1, 0x26, 0x75, 0x3b, 0x84, 0x89, + 0xf0, 0xd9, 0x7a, 0x7e, 0xd1, 0x6e, 0x0c, 0x91, 0xa4, 0x31, 0x9c, 0xab, 0x19, 0x6d, 0x52, 0xa7, + 0xa8, 0x99, 0xc4, 0x41, 0x90, 0x5b, 0xbf, 0x1a, 0x67, 0xc5, 0x16, 0x10, 0xf4, 0x29, 0xa0, 0xce, + 0x63, 0xd7, 0x97, 0x00, 0xd7, 0x17, 0x08, 0x97, 0x04, 0xb2, 0xf6, 0xdc, 0xf2, 0xf4, 0xfe, 0x5e, + 0xad, 0xb8, 0xf6, 0x78, 0xc0, 0xbb, 0xb9, 0xea, 0x14, 0x3b, 0x27, 0x0c, 0x01, 0xfa, 0x08, 0x2a, + 0x27, 0xdc, 0xd3, 0x52, 0xbc, 0x20, 0x48, 0xca, 0x23, 0x42, 0x44, 0xe7, 0x2d, 0x7f, 0x68, 0x02, + 0xd6, 0xbf, 0x06, 0x14, 0x5a, 0xba, 0x2e, 0x99, 0xcd, 0x35, 0x98, 0xd4, 0xee, 0x4c, 0xf9, 0xcb, + 0x26, 0x38, 0x85, 0xd4, 0x28, 0xbc, 0xd0, 0x1c, 0x14, 0xbc, 0x38, 0x4e, 0x68, 0x1f, 0x0f, 0xc6, + 0xc8, 0x6b, 0x9b, 0x84, 0xbc, 0x07, 0x28, 0xd5, 0xcb, 0xed, 0x62, 0xee, 0x49, 0x5d, 0xcb, 0x59, + 0x09, 0x2c, 0xa5, 0x37, 0xf7, 0x30, 0xf7, 0x64, 0xd4, 0x0e, 0x98, 0xc3, 0x2a, 0xd0, 0x29, 0xe4, + 0x66, 0x8d, 0x73, 0x36, 0x42, 0xe8, 0xee, 0xcc, 0x9c, 0xae, 0x59, 0xa6, 0x6f, 0xfd, 0x60, 0xc0, + 0x44, 0x2b, 0xe6, 0x38, 0x90, 0xb1, 0xdf, 0x85, 0xcb, 0xac, 0xe3, 0xb1, 0xb6, 0xeb, 0xd3, 0x88, + 0x27, 0x9e, 0xaf, 0xe7, 0xce, 0x99, 0x94, 0xd6, 0x15, 0x6d, 0x44, 0xd7, 0xa1, 0x48, 0x85, 0x8f, + 0x4b, 0x22, 0xb7, 0x8d, 0x49, 0xd8, 0xe6, 0xb2, 0xec, 0x9c, 0x33, 0x49, 0x15, 0xd5, 0x67, 0xd2, + 0x88, 0xea, 0x50, 0x52, 0x38, 0xda, 0xe3, 0x29, 0x30, 0x2b, 0x81, 0x97, 0xa5, 0xbd, 0xd5, 0xe3, + 0x0a, 0x69, 0xfd, 0x6e, 0xc0, 0x94, 0x4e, 0x63, 0x89, 0x31, 0xcc, 0xd7, 0xb9, 0xc7, 0xf1, 0x1b, + 0x8d, 0x7f, 0x33, 0xe2, 0x03, 0xe3, 0xdf, 0x8c, 0x78, 0x3a, 0xfe, 0xc8, 0x81, 0xd1, 0xbe, 0x58, + 0x31, 0xd5, 0xaa, 0x37, 0xdc, 0x29, 0x45, 0x65, 0xfd, 0x36, 0x22, 0xf2, 0x57, 0xad, 0x58, 0x17, + 0x5a, 0x9d, 0x47, 0xce, 0x1b, 0x50, 0x62, 0xbd, 0x8d, 0x2e, 0xe1, 0x42, 0xaa, 0x01, 0x3d, 0xb3, + 0x4e, 0xf1, 0xc8, 0xae, 0x15, 0x9d, 0x83, 0x02, 0xee, 0x8b, 0xd9, 0x18, 0x50, 0x33, 0xeb, 0xe4, + 0xa5, 0x4d, 0x43, 0x6e, 0x40, 0x29, 0x4e, 0xa8, 0x8f, 0x19, 0x3b, 0x66, 0xcb, 0x29, 0xb6, 0x23, + 0xbb, 0x86, 0xbe, 0x0d, 0x13, 0x84, 0xb9, 0x7d, 0xcc, 0x29, 0x0e, 0xca, 0xa3, 0xb3, 0x46, 0x7d, + 0xdc, 0x19, 0x27, 0xec, 0x81, 0x3c, 0xa3, 0x10, 0x4a, 0x2a, 0xf9, 0x38, 0xa1, 0x31, 0x4d, 0x38, + 0xa1, 0x51, 0x79, 0xec, 0x02, 0x14, 0x2b, 0x4a, 0xd6, 0x2f, 0x8f, 0x48, 0xad, 0x3f, 0x0c, 0x98, + 0x76, 0x70, 0x48, 0x18, 0xc7, 0x49, 0xaa, 0xa1, 0x83, 0x1f, 0xa2, 0x8f, 0xa1, 0xb0, 0x99, 0xd0, + 0xae, 0x9c, 0x7b, 0xcc, 0x98, 0x9e, 0x81, 0xf2, 0x8b, 0xa7, 0x0b, 0x57, 0x34, 0xdd, 0x92, 0xba, + 0x59, 0xe7, 0x09, 0x89, 0x42, 0x27, 0x2f, 0xd0, 0xda, 0x84, 0x6e, 0x41, 0x4e, 0x6e, 0xd9, 0x88, + 0xdc, 0x97, 0xb9, 0xa1, 0xfb, 0x32, 0xb8, 0xec, 0x8e, 0x84, 0xdf, 0xfe, 0xe0, 0xc7, 0x27, 0xb5, + 0xcc, 0x3f, 0x4f, 0x6a, 0x99, 0xef, 0x0f, 0x77, 0xe7, 0xf3, 0x77, 0x8f, 0x09, 0x7f, 0x3a, 0xdc, + 0x9d, 0x9f, 0x19, 0xa8, 0x6e, 0xd0, 0xd7, 0x32, 0xa1, 0x7c, 0xba, 0x00, 0x16, 0xd3, 0x88, 0x61, + 0xeb, 0x1b, 0xa8, 0xb4, 0x62, 0xde, 0x8c, 0xee, 0xd3, 0x15, 0xe9, 0x2d, 0x57, 0xd0, 0xc1, 0x0f, + 0x7b, 0x98, 0x71, 0x54, 0x86, 0x4b, 0x27, 0xaa, 0x73, 0xd2, 0x23, 0xaa, 0xc0, 0xf8, 0xd1, 0xfb, + 0xa7, 0x9e, 0x94, 0x4b, 0xbe, 0x7e, 0xe2, 0xde, 0x01, 0x88, 0x7b, 0x1b, 0x1d, 0xe2, 0xbb, 0x5b, + 0x78, 0x47, 0x3f, 0x23, 0x13, 0xca, 0xf2, 0x39, 0xde, 0xb9, 0x5d, 0x10, 0xa9, 0xa7, 0x3c, 0xd6, + 0x55, 0x30, 0x87, 0x85, 0xd7, 0xc9, 0x61, 0x98, 0x6d, 0x46, 0x84, 0xb7, 0x62, 0xde, 0xea, 0x71, + 0x51, 0xed, 0x05, 0xe5, 0xf8, 0x52, 0x12, 0xd7, 0x60, 0xee, 0x7f, 0xc2, 0xa8, 0x5c, 0x16, 0xbf, + 0xcb, 0x42, 0xf6, 0x1e, 0x0b, 0xd1, 0x16, 0x94, 0x5e, 0x16, 0x13, 0xd5, 0x87, 0xf6, 0x6f, 0xc8, + 0xd0, 0x98, 0x0b, 0xaf, 0x89, 0x54, 0x41, 0xd1, 0x23, 0x40, 0xa7, 0xe5, 0x41, 0x8d, 0x33, 0xc6, + 0xe5, 0x8c, 0x36, 0x9a, 0xf6, 0x6b, 0xe3, 0xb5, 0xee, 0x19, 0xf4, 0xb3, 0x01, 0x95, 0x33, 0x35, + 0x41, 0xb7, 0x86, 0x12, 0xbe, 0xaa, 0x55, 0xe6, 0x87, 0xe7, 0x75, 0x4b, 0xd3, 0x31, 0x47, 0xbf, + 0x3d, 0xdc, 0x9d, 0x37, 0x96, 0xd7, 0x9e, 0xed, 0x57, 0x8d, 0xe7, 0xfb, 0x55, 0xe3, 0xef, 0xfd, + 0xaa, 0xf1, 0xcb, 0x41, 0x35, 0xf3, 0xfc, 0xa0, 0x9a, 0xf9, 0xf3, 0xa0, 0x9a, 0xf9, 0x6a, 0x71, + 0x60, 0xd7, 0xef, 0xa8, 0x20, 0x5f, 0x60, 0xfe, 0x88, 0x26, 0x5b, 0x76, 0xfa, 0x11, 0xb5, 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. +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 { + // RegisterOperator registers a new operator. + RegisterOperator(ctx context.Context, in *RegisterOperatorReq, opts ...grpc.CallOption) (*RegisterOperatorResponse, error) + // add services for dogfood + // 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. + OptInToCosmosChain(ctx context.Context, in *OptInToCosmosChainRequest, opts ...grpc.CallOption) (*OptInToCosmosChainResponse, error) + // 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. + InitOptOutFromCosmosChain(ctx context.Context, in *InitOptOutFromCosmosChainRequest, opts ...grpc.CallOption) (*InitOptOutFromCosmosChainResponse, 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 +} + +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) 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 + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // RegisterOperator registers a new operator. + RegisterOperator(context.Context, *RegisterOperatorReq) (*RegisterOperatorResponse, error) + // add services for dogfood + // 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. + OptInToCosmosChain(context.Context, *OptInToCosmosChainRequest) (*OptInToCosmosChainResponse, error) + // 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. + InitOptOutFromCosmosChain(context.Context, *InitOptOutFromCosmosChainRequest) (*InitOptOutFromCosmosChainResponse, 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 (*UnimplementedMsgServer) OptInToCosmosChain(ctx context.Context, req *OptInToCosmosChainRequest) (*OptInToCosmosChainResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OptInToCosmosChain 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) { + 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) +} + +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).OptInToCosmosChain(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Msg/OptInToCosmosChain", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).OptInToCosmosChain(ctx, req.(*OptInToCosmosChainRequest)) + } + return interceptor(ctx, in, info, handler) +} + +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).InitOptOutFromCosmosChain(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.operator.v1.Msg/InitOptOutFromCosmosChain", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).InitOptOutFromCosmosChain(ctx, req.(*InitOptOutFromCosmosChainRequest)) + } + 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, + }, + { + MethodName: "OptInToCosmosChain", + Handler: _Msg_OptInToCosmosChain_Handler, + }, + { + MethodName: "InitOptOutFromCosmosChain", + Handler: _Msg_InitOptOutFromCosmosChain_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) + 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 *OptedInAssetState) 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 *OptedInAssetState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptedInAssetState) 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] = 0x32 + if m.IsVetoed { + i-- + if m.IsVetoed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.ProcessedHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProcessedHeight)) + i-- + dAtA[i] = 0x20 + } + if m.EventHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.EventHeight)) + i-- + dAtA[i] = 0x18 + } + if m.SubmittedHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.SubmittedHeight)) + 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 (m *OptInToCosmosChainRequest) 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 *OptInToCosmosChainRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptInToCosmosChainRequest) 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 *OptInToCosmosChainResponse) 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 *OptInToCosmosChainResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OptInToCosmosChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *InitOptOutFromCosmosChainRequest) 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 *InitOptOutFromCosmosChainRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InitOptOutFromCosmosChainRequest) 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 *InitOptOutFromCosmosChainResponse) 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 *InitOptOutFromCosmosChainResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InitOptOutFromCosmosChainResponse) 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 *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 + } + 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 *OptedInAssetState) 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.SubmittedHeight != 0 { + n += 1 + sovTx(uint64(m.SubmittedHeight)) + } + if m.EventHeight != 0 { + n += 1 + sovTx(uint64(m.EventHeight)) + } + if m.ProcessedHeight != 0 { + n += 1 + sovTx(uint64(m.ProcessedHeight)) + } + if m.IsVetoed { + n += 2 + } + 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 (m *OptInToCosmosChainRequest) 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 *OptInToCosmosChainResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *InitOptOutFromCosmosChainRequest) 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 *InitOptOutFromCosmosChainResponse) 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 *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 + 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 *OptedInAssetState) 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: OptedInAssetState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptedInAssetState: 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 SubmittedHeight", wireType) + } + m.SubmittedHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubmittedHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EventHeight", wireType) + } + m.EventHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EventHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProcessedHeight", wireType) + } + m.ProcessedHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProcessedHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsVetoed", 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.IsVetoed = bool(v != 0) + case 6: + 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 (m *OptInToCosmosChainRequest) 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: OptInToCosmosChainRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptInToCosmosChainRequest: 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 *OptInToCosmosChainResponse) 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: OptInToCosmosChainResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OptInToCosmosChainResponse: 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 *InitOptOutFromCosmosChainRequest) 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: InitOptOutFromCosmosChainRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InitOptOutFromCosmosChainRequest: 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 *InitOptOutFromCosmosChainResponse) 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: InitOptOutFromCosmosChainResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InitOptOutFromCosmosChainResponse: 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/operator_asset.go b/x/restaking_assets_manage/keeper/operator_asset.go deleted file mode 100644 index 1a9e3cde8..000000000 --- a/x/restaking_assets_manage/keeper/operator_asset.go +++ /dev/null @@ -1,87 +0,0 @@ -package keeper - -import ( - 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" -) - -// 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) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.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) - for ; iterator.Valid(); iterator.Next() { - var stateInfo restakingtype.OperatorSingleAssetOrChangeInfo - k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) - _, assetID, err := restakingtype.ParseStakerAndAssetIDFromKey(iterator.Key()) - if err != nil { - return nil, err - } - ret[assetID] = &stateInfo - } - 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.GetAssetStateKey(operatorAddr.String(), assetID) - ifExist := store.Has(key) - if !ifExist { - return nil, restakingtype.ErrNoOperatorAssetKey - } - - value := store.Get(key) - - ret := restakingtype.OperatorSingleAssetOrChangeInfo{} - k.cdc.MustUnmarshal(value, &ret) - return &ret, nil -} - -// UpdateOperatorAssetState It's used to update the operator states that include TotalAmount OperatorOwnAmount 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. - -func (k Keeper) UpdateOperatorAssetState(ctx sdk.Context, operatorAddr sdk.Address, assetID string, changeAmount restakingtype.OperatorSingleAssetOrChangeInfo) (err error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixOperatorAssetInfos) - key := restakingtype.GetAssetStateKey(operatorAddr.String(), assetID) - assetState := restakingtype.OperatorSingleAssetOrChangeInfo{ - TotalAmountOrWantChangeValue: math.NewInt(0), - OperatorOwnAmountOrWantChangeValue: math.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: math.NewInt(0), - } - if store.Has(key) { - value := store.Get(key) - k.cdc.MustUnmarshal(value, &assetState) - } - - // update all states of the specified operator asset - err = UpdateAssetValue(&assetState.TotalAmountOrWantChangeValue, &changeAmount.TotalAmountOrWantChangeValue) - if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAssetState TotalAmountOrWantChangeValue error") - } - err = UpdateAssetValue(&assetState.OperatorOwnAmountOrWantChangeValue, &changeAmount.OperatorOwnAmountOrWantChangeValue) - if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAssetState OperatorOwnAmountOrWantChangeValue error") - } - err = UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) - if err != nil { - return errorsmod.Wrap(err, "UpdateOperatorAssetState WaitUndelegationAmountOrWantChangeValue error") - } - - bz := k.cdc.MustMarshal(&assetState) - store.Set(key, bz) - return nil -} - -// GetOperatorAssetOptedInMiddleWare This function should be implemented in the operator opt-in module -func (k Keeper) GetOperatorAssetOptedInMiddleWare(sdk.Address, string) (middleWares []sdk.Address, err error) { - panic("implement me") -} diff --git a/x/restaking_assets_manage/keeper/staker_asset.go b/x/restaking_assets_manage/keeper/staker_asset.go deleted file mode 100644 index 7ddecd348..000000000 --- a/x/restaking_assets_manage/keeper/staker_asset.go +++ /dev/null @@ -1,101 +0,0 @@ -package keeper - -import ( - "fmt" - - 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" -) - -// 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)) - defer iterator.Close() - - ret := make(map[string]*restakingtype.StakerSingleAssetOrChangeInfo, 0) - for ; iterator.Valid(); iterator.Next() { - var stateInfo restakingtype.StakerSingleAssetOrChangeInfo - k.cdc.MustUnmarshal(iterator.Value(), &stateInfo) - _, assetID, err := restakingtype.ParseStakerAndAssetIDFromKey(iterator.Key()) - if err != nil { - return nil, err - } - ret[assetID] = &stateInfo - } - 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.GetAssetStateKey(stakerID, assetID) - ifExist := store.Has(key) - if !ifExist { - return nil, errorsmod.Wrap(restakingtype.ErrNoStakerAssetKey, fmt.Sprintf("the key is:%s", key)) - } - - value := store.Get(key) - - ret := restakingtype.StakerSingleAssetOrChangeInfo{} - k.cdc.MustUnmarshal(value, &ret) - return &ret, nil -} - -// 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) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), restakingtype.KeyPrefixReStakerAssetInfos) - key := restakingtype.GetAssetStateKey(stakerID, assetID) - assetState := restakingtype.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: math.NewInt(0), - CanWithdrawAmountOrWantChangeValue: math.NewInt(0), - WaitUndelegationAmountOrWantChangeValue: math.NewInt(0), - } - if store.Has(key) { - value := store.Get(key) - k.cdc.MustUnmarshal(value, &assetState) - } - - // update all states of the specified restaker asset - err = UpdateAssetValue(&assetState.TotalDepositAmountOrWantChangeValue, &changeAmount.TotalDepositAmountOrWantChangeValue) - if err != nil { - return errorsmod.Wrap(err, "UpdateStakerAssetState TotalDepositAmountOrWantChangeValue error") - } - err = UpdateAssetValue(&assetState.CanWithdrawAmountOrWantChangeValue, &changeAmount.CanWithdrawAmountOrWantChangeValue) - if err != nil { - return errorsmod.Wrap(err, "UpdateStakerAssetState CanWithdrawAmountOrWantChangeValue error") - } - err = UpdateAssetValue(&assetState.WaitUndelegationAmountOrWantChangeValue, &changeAmount.WaitUndelegationAmountOrWantChangeValue) - if err != nil { - return errorsmod.Wrap(err, "UpdateStakerAssetState WaitUndelegationAmountOrWantChangeValue error") - } - - // store the updated state - bz := k.cdc.MustMarshal(&assetState) - store.Set(key, bz) - - return nil -} 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/restaking_assets_manage/types/general.go b/x/restaking_assets_manage/types/general.go deleted file mode 100644 index 1d2e39dd2..000000000 --- a/x/restaking_assets_manage/types/general.go +++ /dev/null @@ -1,62 +0,0 @@ -package types - -import ( - "strings" - - "github.com/ethereum/go-ethereum/common/hexutil" -) - -const ( - CrossChainActionLength = 1 - CrossChainOpAmountLength = 32 - GeneralAssetsAddrLength = 32 - GeneralClientChainAddrLength = 32 - - ClientChainLzIDIndexInTopics = 0 - LzNonceIndexInTopics = 2 - - ExoCoreOperatorAddrLength = 42 -) - -type GeneralAssetsAddr [32]byte - -type GeneralClientChainAddr [32]byte - -type CrossChainOpType uint8 - -type WithdrawerAddress [32]byte - -const ( - Deposit CrossChainOpType = iota - WithdrawPrinciple - WithDrawReward - DelegateTo - UndelegateFrom - Slash -) - -// 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}, "_") - } - - if assetsAddress != nil { - 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) - if stakerAddress != "" { - stakeID = strings.Join([]string{strings.ToLower(stakerAddress), clientChainLzIDStr}, "_") - } - - if assetsAddress != "" { - assetID = strings.Join([]string{strings.ToLower(assetsAddress), clientChainLzIDStr}, "_") - } - return -} 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 ff7a64529..182b074f8 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" @@ -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,20 +131,20 @@ 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)) } // TODO - changeAmount := types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: event.OpAmount, - CanWithdrawAmountOrWantChangeValue: event.OpAmount, + changeAmount := types.StakerSingleAssetChangeInfo{ + 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 c2bda596b..a8d6b514b 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" @@ -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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + 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 cfbe7c064..30380c15f 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" ) @@ -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/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/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, 0x48, 0x2c, 0x4a, 0xcc, - 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xea, 0x41, 0x24, 0x95, 0xaa, - 0xb9, 0xd8, 0x02, 0xc0, 0xf2, 0x42, 0x26, 0x5c, 0xe2, 0xa9, 0x15, 0xf9, 0xf1, 0x20, 0xc9, 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, 0xd8, 0x3a, 0x14, 0x5d, 0xa9, 0x65, 0xa9, 0x79, 0x25, - 0xf1, 0x25, 0xf9, 0x05, 0x99, 0xc9, 0x12, 0x4c, 0x60, 0x9d, 0x62, 0xc8, 0x3a, 0x5d, 0x41, 0xd2, - 0x21, 0x20, 0x59, 0x27, 0xaf, 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, - 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0x85, 0xb8, 0xd8, 0x2f, - 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0xe6, 0xbb, 0x0a, 0x98, 0xff, 0x4a, 0x2a, 0x0b, 0x52, - 0x8b, 0x93, 0xd8, 0xc0, 0xfe, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xf4, 0x7a, 0x66, - 0xfe, 0x00, 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/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/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 d6c238791..54357dbff 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" @@ -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,19 +185,19 @@ 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)) } - changeAmount := types.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: event.OpAmount.Neg(), - CanWithdrawAmountOrWantChangeValue: event.OpAmount.Neg(), + changeAmount := types.StakerSingleAssetChangeInfo{ + 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 a222f02b0..fe91997c8 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" @@ -36,17 +36,17 @@ 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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount, + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) // test the normal case @@ -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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + 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 fedfe1286..b4c167223 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" @@ -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/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/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/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 { } diff --git a/x/todo.md b/x/todo.md index e26721607..c0f878761 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..eb6a7fbb7 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" @@ -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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: params.OpAmount.Neg(), - CanWithdrawAmountOrWantChangeValue: params.OpAmount.Neg(), + 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 f40e3a31c..e9f785714 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" @@ -36,17 +36,17 @@ 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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: depositEvent.OpAmount, - CanWithdrawAmountOrWantChangeValue: depositEvent.OpAmount, - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + suite.Equal(types.StakerAssetInfo{ + TotalDepositAmount: depositEvent.OpAmount, + WithdrawableAmount: depositEvent.OpAmount, + WaitUnbondingAmount: sdkmath.NewInt(0), }, *info) // test the normal case event.AssetsAddress = usdtAddress[:] @@ -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.StakerSingleAssetOrChangeInfo{ - TotalDepositAmountOrWantChangeValue: sdkmath.NewInt(10), - CanWithdrawAmountOrWantChangeValue: sdkmath.NewInt(10), - WaitUndelegationAmountOrWantChangeValue: sdkmath.NewInt(0), + 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 c08f2e2ee..f0483d4a3 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" @@ -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) -} 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