diff --git a/app/app.go b/app/app.go index 1fa133918..6850b34f2 100644 --- a/app/app.go +++ b/app/app.go @@ -39,6 +39,8 @@ import ( "github.com/ExocoreNetwork/exocore/x/reward" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types" + taskKeeper "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" "github.com/ExocoreNetwork/exocore/x/withdraw" withdrawKeeper "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" withdrawTypes "github.com/ExocoreNetwork/exocore/x/withdraw/types" @@ -358,6 +360,7 @@ type ExocoreApp struct { WithdrawKeeper withdrawKeeper.Keeper RewardKeeper rewardKeeper.Keeper OperatorKeeper operatorKeeper.Keeper + TaskKeeper taskKeeper.Keeper ExoSlashKeeper slashKeeper.Keeper // the module manager @@ -630,6 +633,8 @@ func NewExocoreApp( 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) + app.TaskKeeper = taskKeeper.NewKeeper(appCodec, keys[tasktype.StoreKey], tasktype.AvsKeeper{}) + // We call this after setting the hooks to ensure that the hooks are set on the keeper evmKeeper.WithPrecompiles( evmkeeper.AvailablePrecompiles( @@ -645,6 +650,7 @@ func NewExocoreApp( app.WithdrawKeeper, app.ExoSlashKeeper, app.RewardKeeper, + app.TaskKeeper, ), ) epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey]) diff --git a/go.mod b/go.mod index ff463418a..e3b50a4af 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/ethereum/go-ethereum v1.11.5 github.com/evmos/evmos/v14 v14.0.0-rc4 github.com/golang/protobuf v1.5.4 + github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/onsi/ginkgo/v2 v2.15.0 @@ -123,7 +124,6 @@ require ( 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.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 diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json new file mode 100644 index 000000000..82afbc291 --- /dev/null +++ b/precompiles/avs/abi.json @@ -0,0 +1,36 @@ +[ + { + "inputs": [ + { + "internalType": "string", + "name": "avsName", + "type": "string" + }, + { + "internalType": "bytes", + "name": "avsAddress", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "operatorAddress", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "action", + "type": "uint64" + } + ], + "name": "AVSInfoRegisterOrDeregister", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go new file mode 100644 index 000000000..0d37bfc8a --- /dev/null +++ b/precompiles/avs/avs.go @@ -0,0 +1,116 @@ +package avs + +import ( + "bytes" + "embed" + "fmt" + + avsKeeper "github.com/ExocoreNetwork/exocore/x/avs/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" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +var _ vm.PrecompiledContract = &Precompile{} + +// Embed abi json file to the executable binary. Needed when importing as dependency. +// +//go:embed abi.json +var f embed.FS + +// Precompile defines the precompiled contract for avs. +type Precompile struct { + cmn.Precompile + avsKeeper avsKeeper.Keeper +} + +// NewPrecompile creates a new avs Precompile instance as a +// PrecompiledContract interface. +func NewPrecompile( + avsKeeper avsKeeper.Keeper, + authzKeeper authzkeeper.Keeper, +) (*Precompile, error) { + abiBz, err := f.ReadFile("abi.json") + if err != nil { + return nil, fmt.Errorf("error loading the avs ABI %s", err) + } + + newAbi, err := abi.JSON(bytes.NewReader(abiBz)) + if err != nil { + return nil, fmt.Errorf(cmn.ErrInvalidABI, err) + } + + return &Precompile{ + Precompile: cmn.Precompile{ + ABI: newAbi, + AuthzKeeper: authzKeeper, + KvGasConfig: storetypes.KVGasConfig(), + TransientKVGasConfig: storetypes.TransientGasConfig(), + ApprovalExpiration: cmn.DefaultExpirationDuration, + }, + avsKeeper: avsKeeper, + }, nil +} + +// Address defines the address of the avs compile contract. +// address: 0x0000000000000000000000000000000000000902 +func (p Precompile) Address() common.Address { + return common.HexToAddress("0x0000000000000000000000000000000000000902") +} + +// RequiredGas calculates the precompiled contract's base gas rate. +func (p Precompile) RequiredGas(input []byte) uint64 { + methodID := input[:4] + + method, err := p.MethodById(methodID) + if err != nil { + // This should never happen since this method is going to fail during Run + return 0 + } + return p.Precompile.RequiredGas(input, p.IsTransaction(method.Name)) +} + +// Run executes the precompiled contract AVSInfoRegisterOrDeregister methods defined in the ABI. +func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error) { + ctx, stateDB, method, initialGas, args, err := p.RunSetup(evm, contract, readOnly, p.IsTransaction) + if err != nil { + return nil, err + } + + // This handles any out of gas errors that may occur during the execution of a precompile tx or query. + // It avoids panics and returns the out of gas error so the EVM can continue gracefully. + defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + + if method.Name == MethodAVSAction { + bz, err = p.AVSInfoRegisterOrDeregister(ctx, evm.Origin, contract, stateDB, method, args) + } + + if err != nil { + ctx.Logger().Error("call avs precompile error", "module", "avs precompile", "err", err) + return nil, err + } + + cost := ctx.GasMeter().GasConsumed() - initialGas + + if !contract.UseGas(cost) { + return nil, vm.ErrOutOfGas + } + + return bz, nil +} + +// IsTransaction checks if the given methodID corresponds to a transaction or query. +// +// Available avs transactions are: +// - AVSRegister +func (Precompile) IsTransaction(methodID string) bool { + switch methodID { + case MethodAVSAction: + return true + default: + return false + } +} diff --git a/precompiles/avs/avs.sol b/precompiles/avs/avs.sol new file mode 100644 index 000000000..4f8453b05 --- /dev/null +++ b/precompiles/avs/avs.sol @@ -0,0 +1,24 @@ +pragma solidity >=0.8.17; + +/// @dev The avs-manager contract's address. +address constant AVSMANAGER_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000902; + +/// @dev The avs-manager contract's instance. +IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager( + AVSMANAGER_PRECOMPILE_ADDRESS +); + +/// @author Exocore Team +/// @title AVS-Manager Precompile Contract +/// @dev The interface through which solidity contracts will interact with AVS-Manager +/// @custom:address 0x0000000000000000000000000000000000000902 +interface IAVSManager { + function AVSInfoRegisterOrDeregister( + string memory avsName, + bytes memory avsAddress, + bytes memory operatorAddress, + uint64 action + + ) external returns (bool success); + +} \ No newline at end of file diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go new file mode 100644 index 000000000..e4174ca4f --- /dev/null +++ b/precompiles/avs/tx.go @@ -0,0 +1,35 @@ +package avs + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" +) + +const ( + // AVSRegister defines the ABI method name for the avs + // related transaction. + MethodAVSAction = "avsAction" +) + +// AVSInfoRegister register the avs related information and change the state in avs keeper module. +func (p Precompile) AVSInfoRegisterOrDeregister( + ctx sdk.Context, + _ common.Address, + contract *vm.Contract, + _ vm.StateDB, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + // parse the avs input params first. + avsParams, err := p.GetAVSParamsFromInputs(ctx, args) + if err != nil { + return nil, err + } + err = p.avsKeeper.AVSInfoUpdate(ctx, avsParams) + if err != nil { + return nil, err + } + return method.Outputs.Pack(true) +} diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go new file mode 100644 index 000000000..870f9f707 --- /dev/null +++ b/precompiles/avs/types.go @@ -0,0 +1,40 @@ +package avs + +import ( + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + "github.com/ExocoreNetwork/exocore/x/avs/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + cmn "github.com/evmos/evmos/v14/precompiles/common" + "golang.org/x/xerrors" +) + +func (p Precompile) GetAVSParamsFromInputs(ctx sdk.Context, args []interface{}) (*keeper.AVSParams, error) { + if len(args) != 4 { + return nil, xerrors.Errorf(cmn.ErrInvalidNumberOfArgs, 4, len(args)) + } + avsParams := &keeper.AVSParams{} + avsName, ok := args[0].(string) + if !ok { + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", avsName) + } + avsParams.AVSName = avsName + + avsAddress, ok := args[1].([]byte) + if !ok || avsAddress == nil { + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", avsAddress) + } + avsParams.AVSAddress = avsAddress + + operatorAddress, ok := args[2].([]byte) + if !ok || operatorAddress == nil { + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", operatorAddress) + } + avsParams.OperatorAddress = operatorAddress + + action, ok := args[3].(uint64) + if !ok || action != keeper.RegisterAction || action != keeper.DeRegisterAction { + return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 3, "uint64", action) + } + avsParams.Action = action + return avsParams, nil +} diff --git a/precompiles/avsTask/abi.json b/precompiles/avsTask/abi.json new file mode 100644 index 000000000..08e4a9e1d --- /dev/null +++ b/precompiles/avsTask/abi.json @@ -0,0 +1,31 @@ +[ + { + "inputs":[ + { + "internalType":"uint256", + "name":"numberToBeSquared", + "type":"uint256" + }, + { + "internalType":"bytes", + "name":"quorumThresholdPercentage", + "type":"bytes" + }, + { + "internalType":"bytes", + "name":"quorumNumbers", + "type":"bytes" + } + ], + "name":"createNewTask", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"nonpayable", + "type":"function" + } +] \ No newline at end of file diff --git a/precompiles/avsTask/avsTask.sol b/precompiles/avsTask/avsTask.sol new file mode 100644 index 000000000..801bf03ca --- /dev/null +++ b/precompiles/avsTask/avsTask.sol @@ -0,0 +1,90 @@ +pragma solidity >=0.8.17 .0; + +/// @dev The AVSTask contract's address. +address constant AVSTASK_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000901; + +/// @dev The AVSTask contract's instance. +IAVSTask constant AVSTASK_CONTRACT = IAVSTask( + AVSTASK_PRECOMPILE_ADDRESS +); + +/// @author Exocore Team +/// @title AVSTask Precompile Contract +/// @dev The interface through which solidity contracts will interact with AVSTask +/// @custom:address 0x0000000000000000000000000000000000000901 + struct Task { + uint256 numberToBeSquared; + uint32 taskCreatedBlock; + // task submitter decides on the criteria for a task to be completed + // note that this does not mean the task was "correctly" answered (i.e. the number was squared correctly) + // this is for the challenge logic to verify + // task is completed (and contract will accept its TaskResponse) when each quorumNumbers specified here + // are signed by at least quorumThresholdPercentage of the operators + // note that we set the quorumThresholdPercentage to be the same for all quorumNumbers, but this could be changed + bytes quorumNumbers; + uint32 quorumThresholdPercentage; + } + + struct TaskResponse { + // Can be obtained by the operator from the event NewTaskCreated. + uint32 referenceTaskIndex; + // This is just the response that the operator has to compute by itself. + uint256 numberSquared; + } + +// Extra information related to taskResponse, which is filled inside the contract. +// It thus cannot be signed by operators, so we keep it in a separate struct than TaskResponse +// This metadata is needed by the challenger, so we emit it in the TaskResponded event + struct TaskResponseMetadata { + uint32 taskResponsedBlock; + bytes32 hashOfNonSigners; + } +/// @dev Represents a operator in the avs module. + struct Operator { + string earningsAddr; + string approveAddr; + string operatorMetaInfo; + } +interface IAVSTask { +/// TRANSACTIONS +/// @dev IAVSTask the oprator, that will change the state in AVSTask module +/// @param numberToBeSquared The Numbers that need to be squared +/// @param quorumThresholdPercentage The Quorum threshold +/// @param quorumNumbers The Quorum numbers + function createNewTask( + uint256 numberToBeSquared, + uint32 quorumThresholdPercentage, + bytes calldata quorumNumbers + ) external returns (bool success); + + /// TRANSACTIONS +/// @dev this function responds to existing tasks. +/// @param Task The task of avs already created +/// @param TaskResponse The Task response parameters + function respondToTask( + Task calldata task, + TaskResponse calldata taskResponse + ) external returns (bool success); + + /// TRANSACTIONS +/// @dev Get the count of the current task + function taskNumber() external view returns (uint32); + + /// TRANSACTIONS +/// @dev Get the task window block for the current response + function getTaskResponseWindowBlock() external view returns (uint32); + + /// TRANSACTIONS +/// @dev Get the task window block for the current response + function queryOptinOperatorList(address avsAddress) external view returns (bool success,Operator[] calldata operators); + /// @dev This event is emitted when a task created. + + /// TRANSACTIONS +/// @dev Get the task window block for the current response + function queryOperatorInfoByAddr(address operatorAddress) external view returns (bool success,Operator calldata operator); + + function isOperatorOptin(address operatorAddress) external view returns (bool success); + + event NewTaskCreated(uint32 indexed taskIndex, Task task); + +} diff --git a/precompiles/avsTask/error.go b/precompiles/avsTask/error.go new file mode 100644 index 000000000..1cbd69db8 --- /dev/null +++ b/precompiles/avsTask/error.go @@ -0,0 +1,8 @@ +package task + +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" + ErrNotYetRegistered = "this AVS has not been registered yet,input:%d" +) diff --git a/precompiles/avsTask/events.go b/precompiles/avsTask/events.go new file mode 100644 index 000000000..63da761ac --- /dev/null +++ b/precompiles/avsTask/events.go @@ -0,0 +1,54 @@ +package task + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +const ( + // EventTypeNewTaskCreated defines the event type for the task create transaction. + EventTypeNewTaskCreated = "NewTaskCreated" +) + +// EmitNewTaskCreatedEvent creates a new task transaction. +func (p Precompile) EmitNewTaskCreatedEvent( + ctx sdk.Context, + stateDB vm.StateDB, + taskIndex uint32, + numberToBeSquared uint64, + quorumNumbers []byte, + quorumThresholdPercentage uint32, +) error { + event := p.ABI.Events[EventTypeNewTaskCreated] + topics := make([]common.Hash, 3) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + // sender and receiver are indexed + topics[1], err = cmn.MakeTopic(taskIndex) + if err != nil { + return err + } + + // Prepare the event data: denom, amount, memo + arguments := abi.Arguments{event.Inputs[2], event.Inputs[3], event.Inputs[4]} + packed, err := arguments.Pack(numberToBeSquared, quorumNumbers, quorumThresholdPercentage) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} diff --git a/precompiles/avsTask/methods.go b/precompiles/avsTask/methods.go new file mode 100644 index 000000000..6dc49169c --- /dev/null +++ b/precompiles/avsTask/methods.go @@ -0,0 +1,70 @@ +package task + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" +) + +const ( + // MethodCreateNewTask defines the ABI method name for the task + // transaction. + MethodCreateNewTask = "createNewTask" + MethodIsOperatorOptin = "isOperatorOptin" +) + +// CreateNewTask Middleware uses exocore's default task template to create tasks in task module. +func (p Precompile) CreateNewTask( + ctx sdk.Context, + _ common.Address, + contract *vm.Contract, + stateDB vm.StateDB, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + // check the invalidation of caller contract + flag := p.avsKeeper.IsAVS(ctx, sdk.AccAddress(contract.CallerAddress.String())) + if !flag { + return nil, fmt.Errorf(ErrNotYetRegistered, contract.CallerAddress) + } + + createNewTaskParams, err := p.GetTaskParamsFromInputs(ctx, args) + if err != nil { + return nil, err + } + createNewTaskParams.ContractAddr = contract.CallerAddress.String() + createNewTaskParams.TaskCreatedBlock = ctx.BlockHeight() + _, err = p.taskKeeper.CreateNewTask(ctx, createNewTaskParams) + if err != nil { + return nil, err + } + if err = p.EmitNewTaskCreatedEvent( + ctx, + stateDB, + createNewTaskParams.TaskIndex, + createNewTaskParams.NumberToBeSquared, + createNewTaskParams.QuorumNumbers, + createNewTaskParams.QuorumThresholdPercentage, + ); err != nil { + return nil, err + } + return method.Outputs.Pack(true) +} + +// IsOperatorOptin Middleware uses exocore's default task template to create tasks in task module. +func (p Precompile) IsOperatorOptin( + ctx sdk.Context, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + // check the invalidation of caller contract + flag := p.avsKeeper.IsAVS(ctx, sdk.AccAddress(contract.CallerAddress.String())) + if !flag { + return nil, fmt.Errorf(ErrNotYetRegistered, contract.CallerAddress) + } + + return method.Outputs.Pack(true) +} diff --git a/precompiles/avsTask/parser.go b/precompiles/avsTask/parser.go new file mode 100644 index 000000000..a8ac62a65 --- /dev/null +++ b/precompiles/avsTask/parser.go @@ -0,0 +1,27 @@ +package task + +import ( + "fmt" + "reflect" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +func (p Precompile) GetTaskParamsFromInputs(ctx sdk.Context, args []interface{}) (*keeper.CreateNewTaskParams, error) { + if len(args) != 8 { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, 4, len(args)) + } + taskParams := &keeper.CreateNewTaskParams{} + numberToBeSquared, ok := args[0].(uint16) + if !ok { + return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), numberToBeSquared) + } + taskParams.NumberToBeSquared = uint64(numberToBeSquared) + taskParams.QuorumThresholdPercentage = args[1].(uint32) + qnums, ok := args[2].([]byte) + taskParams.QuorumNumbers = qnums + + return taskParams, nil +} diff --git a/precompiles/avsTask/setup_test.go b/precompiles/avsTask/setup_test.go new file mode 100644 index 000000000..87fd1d210 --- /dev/null +++ b/precompiles/avsTask/setup_test.go @@ -0,0 +1,37 @@ +package task_test + +import ( + "github.com/ExocoreNetwork/exocore/testutil" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "testing" + + "github.com/ExocoreNetwork/exocore/precompiles/avsTask" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/stretchr/testify/suite" +) + +var s *TaskPrecompileTestSuite + +type TaskPrecompileTestSuite struct { + testutil.BaseTestSuite + precompile *task.Precompile +} + +func TestPrecompileTestSuite(t *testing.T) { + s = new(TaskPrecompileTestSuite) + suite.Run(t, s) + + // Run Ginkgo integration tests + RegisterFailHandler(Fail) + RunSpecs(t, "Task Precompile Suite") +} + +func (s *TaskPrecompileTestSuite) SetupTest() { + s.DoSetupTest() + precompile, err := task.NewPrecompile(s.App.AuthzKeeper, s.App.TaskKeeper, tasktype.AvsKeeper{}) + s.Require().NoError(err) + s.precompile = precompile +} diff --git a/precompiles/avsTask/task.go b/precompiles/avsTask/task.go new file mode 100644 index 000000000..d3927ef51 --- /dev/null +++ b/precompiles/avsTask/task.go @@ -0,0 +1,128 @@ +package task + +import ( + "bytes" + "embed" + "fmt" + taskKeeper "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/cometbft/cometbft/libs/log" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +var _ vm.PrecompiledContract = &Precompile{} + +// Embed abi json file to the executable binary. Needed when importing as dependency. +// +//go:embed abi.json +var f embed.FS + +// Precompile defines the precompiled contract for task. +type Precompile struct { + cmn.Precompile + taskKeeper taskKeeper.Keeper + avsKeeper tasktype.AvsKeeper +} + +// NewPrecompile creates a new task Precompile instance as a +// PrecompiledContract interface. +func NewPrecompile( + authzKeeper authzkeeper.Keeper, + taskKeeper taskKeeper.Keeper, + avsKeeper tasktype.AvsKeeper, +) (*Precompile, error) { + abiBz, err := f.ReadFile("abi.json") + if err != nil { + return nil, fmt.Errorf("error loading the task ABI %s", err) + } + + newAbi, err := abi.JSON(bytes.NewReader(abiBz)) + if err != nil { + return nil, fmt.Errorf(cmn.ErrInvalidABI, err) + } + + return &Precompile{ + Precompile: cmn.Precompile{ + ABI: newAbi, + AuthzKeeper: authzKeeper, + KvGasConfig: storetypes.KVGasConfig(), + TransientKVGasConfig: storetypes.TransientGasConfig(), + ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. + }, + taskKeeper: taskKeeper, + avsKeeper: avsKeeper, + }, nil +} + +// Address defines the address of the task compile contract. +// address: 0x0000000000000000000000000000000000000901 +func (p Precompile) Address() common.Address { + return common.HexToAddress("0x0000000000000000000000000000000000000901") +} + +// RequiredGas calculates the precompiled contract's base gas rate. +func (p Precompile) RequiredGas(input []byte) uint64 { + methodID := input[:4] + + method, err := p.MethodById(methodID) + if err != nil { + // This should never happen since this method is going to fail during Run + return 0 + } + + return p.Precompile.RequiredGas(input, p.IsTransaction(method.Name)) +} + +// Run executes the precompiled contract task methods defined in the ABI. +func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error) { + ctx, stateDB, method, initialGas, args, err := p.RunSetup(evm, contract, readOnly, p.IsTransaction) + if err != nil { + return nil, err + } + + // This handles any out of gas errors that may occur during the execution of a precompile tx or query. + // It avoids panics and returns the out of gas error so the EVM can continue gracefully. + defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + + switch method.Name { + case MethodCreateNewTask: + bz, err = p.CreateNewTask(ctx, evm.Origin, contract, stateDB, method, args) + case MethodIsOperatorOptin: + bz, err = p.IsOperatorOptin(ctx, contract, method, args) + } + + if err != nil { + return nil, err + } + + cost := ctx.GasMeter().GasConsumed() - initialGas + + if !contract.UseGas(cost) { + return nil, vm.ErrOutOfGas + } + + return bz, nil +} + +// IsTransaction checks if the given methodID corresponds to a transaction or query. +// +// Available task transactions are: +func (Precompile) IsTransaction(methodID string) bool { + switch methodID { + case MethodCreateNewTask: + return true + default: + return false + } +} + +// Logger returns a precompile-specific logger. +func (p Precompile) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("ExoCore module", "task") +} diff --git a/precompiles/avsTask/task_test.go b/precompiles/avsTask/task_test.go new file mode 100644 index 000000000..ba7e203d2 --- /dev/null +++ b/precompiles/avsTask/task_test.go @@ -0,0 +1,150 @@ +package task_test + +import ( + "github.com/ExocoreNetwork/exocore/app" + "github.com/ExocoreNetwork/exocore/precompiles/avsTask" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/evmos/evmos/v14/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v14/x/evm/types" + "math/big" +) + +func (s *TaskPrecompileTestSuite) TestIsTransaction() { + testCases := []struct { + name string + method string + isTx bool + }{ + { + task.MethodCreateNewTask, + s.precompile.Methods[task.MethodCreateNewTask].Name, + true, + }, + { + "invalid", + "invalid", + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + s.Require().Equal(s.precompile.IsTransaction(tc.method), tc.isTx) + }) + } +} + +func paddingClientChainAddress(input []byte, outputLength int) []byte { + if len(input) < outputLength { + padding := make([]byte, outputLength-len(input)) + return append(input, padding...) + } + return input +} + +// TestRun tests the precompiles Run method createTask. +func (s *TaskPrecompileTestSuite) TestRunCreateTask() { + // deposit params for test + //exoCoreLzAppEventTopic := "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec" + // usdtAddress := common.FromHex("0xdAC17F958D2ee523a2206206994597C13D831ec7") + + successRet, err := s.precompile.Methods[task.MethodCreateNewTask].Outputs.Pack(true) + s.Require().NoError(err) + testcases := []struct { + name string + malleate func() (common.Address, []byte) + readOnly bool + expPass bool + errContains string + returnBytes []byte + }{ + { + name: "pass - task via pre-compiles", + malleate: func() (common.Address, []byte) { + taskParam := &keeper.CreateNewTaskParams{ + + NumberToBeSquared: 3, + QuorumThresholdPercentage: 3, + QuorumNumbers: nil, + } + _, err = s.App.AvsTaskKeeper.CreateNewTask(s.Ctx, taskParam) + s.Require().NoError(err) + return [20]byte{}, nil + }, + returnBytes: successRet, + readOnly: false, + expPass: true, + }, + } + for _, tc := range testcases { + tc := tc + s.Run(tc.name, func() { + // setup basic test suite + s.SetupTest() + + baseFee := s.App.FeeMarketKeeper.GetBaseFee(s.Ctx) + + // malleate testcase + caller, input := tc.malleate() + + contract := vm.NewPrecompile(vm.AccountRef(caller), s.precompile, big.NewInt(0), uint64(1e6)) + contract.Input = input + + contractAddr := contract.Address() + // Build and sign Ethereum transaction + txArgs := evmtypes.EvmTxArgs{ + ChainID: s.App.EvmKeeper.ChainID(), + Nonce: 0, + To: &contractAddr, + Amount: nil, + GasLimit: 100000, + GasPrice: app.MainnetMinGasPrices.BigInt(), + GasFeeCap: baseFee, + GasTipCap: big.NewInt(1), + Accesses: ðtypes.AccessList{}, + } + msgEthereumTx := evmtypes.NewTx(&txArgs) + + msgEthereumTx.From = s.Address.String() + err := msgEthereumTx.Sign(s.EthSigner, s.Signer) + s.Require().NoError(err, "failed to sign Ethereum message") + + // Instantiate config + proposerAddress := s.Ctx.BlockHeader().ProposerAddress + cfg, err := s.App.EvmKeeper.EVMConfig(s.Ctx, proposerAddress, s.App.EvmKeeper.ChainID()) + s.Require().NoError(err, "failed to instantiate EVM config") + + msg, err := msgEthereumTx.AsMessage(s.EthSigner, baseFee) + s.Require().NoError(err, "failed to instantiate Ethereum message") + + // Create StateDB + s.StateDB = statedb.New(s.Ctx, s.App.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.Ctx.HeaderHash().Bytes()))) + // Instantiate EVM + evm := s.App.EvmKeeper.NewEVM( + s.Ctx, msg, cfg, nil, s.StateDB, + ) + params := s.App.EvmKeeper.GetParams(s.Ctx) + activePrecompiles := params.GetActivePrecompilesAddrs() + precompileMap := s.App.EvmKeeper.Precompiles(activePrecompiles...) + err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) + s.Require().NoError(err, "invalid precompiles", activePrecompiles) + evm.WithPrecompiles(precompileMap, activePrecompiles) + + // Run precompiled contract + bz, err := s.precompile.Run(evm, contract, tc.readOnly) + + // Check results + if tc.expPass { + s.Require().NoError(err, "expected no error when running the precompile") + s.Require().Equal(tc.returnBytes, bz, "the return doesn't match the expected result") + } else { + s.Require().Error(err, "expected error to be returned when running the precompile") + s.Require().Nil(bz, "expected returned bytes to be nil") + s.Require().ErrorContains(err, tc.errContains) + } + }) + } +} diff --git a/precompiles/bls/abi.json b/precompiles/bls/abi.json new file mode 100644 index 000000000..d361d604a --- /dev/null +++ b/precompiles/bls/abi.json @@ -0,0 +1,163 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "pubkeyG1", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "pubkeyG2", + "type": "bytes" + } + ], + "name": "NewPubkeyRegistration", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "msgHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "quorumNumbers", + "type": "bytes" + }, + { + "internalType": "uint32", + "name": "referenceBlockNumber", + "type": "uint32" + }, + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "checkSignatures", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "getRegisteredPubkey", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bytes", + "name": "pubKeyRegistrationParams", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "pubKeyRegistrationMessageHash", + "type": "bytes" + } + ], + "name": "registerBLSPublicKey", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes32", + "name": "operatorId", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "msgHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "apk", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "apkG2", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "sigma", + "type": "bytes" + } + ], + "name": "trySignatureAndApkVerification", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/precompiles/bls/bls.go b/precompiles/bls/bls.go new file mode 100644 index 000000000..56ae604c9 --- /dev/null +++ b/precompiles/bls/bls.go @@ -0,0 +1,128 @@ +package task + +import ( + "bytes" + "embed" + "fmt" + taskKeeper "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/cometbft/cometbft/libs/log" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +var _ vm.PrecompiledContract = &Precompile{} + +// Embed abi json file to the executable binary. Needed when importing as dependency. +// +//go:embed abi.json +var f embed.FS + +// Precompile defines the precompiled contract for task. +type Precompile struct { + cmn.Precompile + taskKeeper taskKeeper.Keeper + avsKeeper tasktype.AvsKeeper +} + +// NewPrecompile creates a new task Precompile instance as a +// PrecompiledContract interface. +func NewPrecompile( + authzKeeper authzkeeper.Keeper, + taskKeeper taskKeeper.Keeper, + avsKeeper tasktype.AvsKeeper, +) (*Precompile, error) { + abiBz, err := f.ReadFile("abi.json") + if err != nil { + return nil, fmt.Errorf("error loading the task ABI %s", err) + } + + newAbi, err := abi.JSON(bytes.NewReader(abiBz)) + if err != nil { + return nil, fmt.Errorf(cmn.ErrInvalidABI, err) + } + + return &Precompile{ + Precompile: cmn.Precompile{ + ABI: newAbi, + AuthzKeeper: authzKeeper, + KvGasConfig: storetypes.KVGasConfig(), + TransientKVGasConfig: storetypes.TransientGasConfig(), + ApprovalExpiration: cmn.DefaultExpirationDuration, // should be configurable in the future. + }, + taskKeeper: taskKeeper, + avsKeeper: avsKeeper, + }, nil +} + +// Address defines the address of the task compile contract. +// address: 0x0000000000000000000000000000000000000901 +func (p Precompile) Address() common.Address { + return common.HexToAddress("0x0000000000000000000000000000000000000901") +} + +// RequiredGas calculates the precompiled contract's base gas rate. +func (p Precompile) RequiredGas(input []byte) uint64 { + methodID := input[:4] + + method, err := p.MethodById(methodID) + if err != nil { + // This should never happen since this method is going to fail during Run + return 0 + } + + return p.Precompile.RequiredGas(input, p.IsTransaction(method.Name)) +} + +// Run executes the precompiled contract task methods defined in the ABI. +func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error) { + ctx, stateDB, method, initialGas, args, err := p.RunSetup(evm, contract, readOnly, p.IsTransaction) + if err != nil { + return nil, err + } + + // This handles any out of gas errors that may occur during the execution of a precompile tx or query. + // It avoids panics and returns the out of gas error so the EVM can continue gracefully. + defer cmn.HandleGasError(ctx, contract, initialGas, &err)() + + switch method.Name { + case MethodRegisterBLSPublicKey: + bz, err = p.RegisterBLSPublicKey(ctx, evm.Origin, contract, stateDB, method, args) + case MethodIGetRegisteredPubkey: + bz, err = p.GetRegisteredPubkey(ctx, contract, method, args) + } + + if err != nil { + return nil, err + } + + cost := ctx.GasMeter().GasConsumed() - initialGas + + if !contract.UseGas(cost) { + return nil, vm.ErrOutOfGas + } + + return bz, nil +} + +// IsTransaction checks if the given methodID corresponds to a transaction or query. +// +// Available task transactions are: +func (Precompile) IsTransaction(methodID string) bool { + switch methodID { + case MethodRegisterBLSPublicKey: + return true + default: + return false + } +} + +// Logger returns a precompile-specific logger. +func (p Precompile) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("ExoCore module", "task") +} diff --git a/precompiles/bls/bls.sol b/precompiles/bls/bls.sol new file mode 100644 index 000000000..c564c99d5 --- /dev/null +++ b/precompiles/bls/bls.sol @@ -0,0 +1,55 @@ +pragma solidity >=0.8.17 .0; + +/// @dev The BLS contract's address. +address constant BLS_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000902; + +/// @dev The BLS contract's instance. +IBLS constant BLS_CONTRACT = IBLS( + BLS_PRECOMPILE_ADDRESS +); + +/// @author Exocore Team +/// @title BLS Precompile Contract +/// @dev The interface through which solidity contracts will interact with BLS +/// @custom:address 0x0000000000000000000000000000000000000902 + +interface IBLS { +/// TRANSACTIONS +/// @dev Called by the avs manager service register an operator as the owner of a BLS public key. +/// @param operator is the operator for whom the key is being registered +/// @param pubKeyRegistrationParams contains the G1 & G2 public keys of the operator, and a signature proving their ownership +/// @param pubKeyRegistrationMessageHash is a hash that the operator must sign to prove key ownership + function registerBLSPublicKey( + address operator, + bytes calldata pubKeyRegistrationParams, + bytes calldata pubKeyRegistrationMessageHash + ) external returns (bool success,bytes32 operatorId); + + /// TRANSACTIONS +/// @dev Returns the pubkey and pubkey hash of an operator,Reverts if the operator has not registered a valid pubkey +/// @param operator is the operator for whom the key is being registered + function getRegisteredPubkey(address operator) external returns (bytes32,bytes32); + + /// TRANSACTIONS +/// @dev Get the count of the current task + function checkSignatures( + bytes32 msgHash, + bytes calldata quorumNumbers, + uint32 referenceBlockNumber, + bytes memory params + ) external view returns (bytes32,bytes32); + + /// TRANSACTIONS +/// @dev Get the task window block for the current response + function trySignatureAndApkVerification( + bytes32 msgHash, + bytes calldata apk, + bytes calldata apkG2, + bytes calldata sigma + ) external view returns (bool,bool); + + + // EVENTS + /// @notice Emitted when `operator` registers with the public keys `pubkeyG1` and `pubkeyG2`. + event NewPubkeyRegistration(address indexed operator, bytes pubkeyG1, bytes pubkeyG2); +} diff --git a/precompiles/bls/error.go b/precompiles/bls/error.go new file mode 100644 index 000000000..1cbd69db8 --- /dev/null +++ b/precompiles/bls/error.go @@ -0,0 +1,8 @@ +package task + +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" + ErrNotYetRegistered = "this AVS has not been registered yet,input:%d" +) diff --git a/precompiles/bls/events.go b/precompiles/bls/events.go new file mode 100644 index 000000000..8816c8ec7 --- /dev/null +++ b/precompiles/bls/events.go @@ -0,0 +1,53 @@ +package task + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +const ( + // EventTypeNewTaskCreated defines the event type for the task create transaction. + EventTypeNewPubkeyRegistration = "NewPubkeyRegistration" +) + +// EmitEventTypeNewPubkeyRegistration new bls pubkey reg +func (p Precompile) EmitEventTypeNewPubkeyRegistration( + ctx sdk.Context, + stateDB vm.StateDB, + operator sdk.Address, + pubkeyG1 []byte, + pubkeyG2 []byte, +) error { + event := p.ABI.Events[EventTypeNewPubkeyRegistration] + topics := make([]common.Hash, 3) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + // sender and receiver are indexed + topics[1], err = cmn.MakeTopic(operator) + if err != nil { + return err + } + + // Prepare the event data: denom, amount, memo + arguments := abi.Arguments{event.Inputs[2], event.Inputs[3]} + packed, err := arguments.Pack(pubkeyG1, pubkeyG2) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} diff --git a/precompiles/bls/methods.go b/precompiles/bls/methods.go new file mode 100644 index 000000000..1a15745e8 --- /dev/null +++ b/precompiles/bls/methods.go @@ -0,0 +1,69 @@ +package task + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" +) + +const ( + // MethodRegisterBLSPublicKey defines the ABI method name for the task + // transaction. + MethodRegisterBLSPublicKey = "registerBLSPublicKey" + MethodIGetRegisteredPubkey = "getRegisteredPubkey" +) + +// RegisterBLSPublicKey Middleware uses exocore's default task template to create tasks in task module. +func (p Precompile) RegisterBLSPublicKey( + ctx sdk.Context, + _ common.Address, + contract *vm.Contract, + stateDB vm.StateDB, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + // check the invalidation of caller contract + flag := p.avsKeeper.IsAVS(ctx, sdk.AccAddress(contract.CallerAddress.String())) + if !flag { + return nil, fmt.Errorf(ErrNotYetRegistered, contract.CallerAddress) + } + + createNewTaskParams, err := p.GetTaskParamsFromInputs(ctx, args) + if err != nil { + return nil, err + } + createNewTaskParams.ContractAddr = contract.CallerAddress.String() + createNewTaskParams.TaskCreatedBlock = ctx.BlockHeight() + _, err = p.taskKeeper.CreateNewTask(ctx, createNewTaskParams) + if err != nil { + return nil, err + } + if err = p.EmitEventTypeNewPubkeyRegistration( + ctx, + stateDB, + nil, + nil, + nil, + ); err != nil { + return nil, err + } + return method.Outputs.Pack(true) +} + +// GetRegisteredPubkey Middleware uses exocore's default task template to create tasks in task module. +func (p Precompile) GetRegisteredPubkey( + ctx sdk.Context, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + // check the invalidation of caller contract + flag := p.avsKeeper.IsAVS(ctx, sdk.AccAddress(contract.CallerAddress.String())) + if !flag { + return nil, fmt.Errorf(ErrNotYetRegistered, contract.CallerAddress) + } + + return method.Outputs.Pack(true) +} diff --git a/precompiles/bls/parser.go b/precompiles/bls/parser.go new file mode 100644 index 000000000..a8ac62a65 --- /dev/null +++ b/precompiles/bls/parser.go @@ -0,0 +1,27 @@ +package task + +import ( + "fmt" + "reflect" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + cmn "github.com/evmos/evmos/v14/precompiles/common" +) + +func (p Precompile) GetTaskParamsFromInputs(ctx sdk.Context, args []interface{}) (*keeper.CreateNewTaskParams, error) { + if len(args) != 8 { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, 4, len(args)) + } + taskParams := &keeper.CreateNewTaskParams{} + numberToBeSquared, ok := args[0].(uint16) + if !ok { + return nil, fmt.Errorf(ErrContractInputParaOrType, 0, reflect.TypeOf(args[0]), numberToBeSquared) + } + taskParams.NumberToBeSquared = uint64(numberToBeSquared) + taskParams.QuorumThresholdPercentage = args[1].(uint32) + qnums, ok := args[2].([]byte) + taskParams.QuorumNumbers = qnums + + return taskParams, nil +} diff --git a/precompiles/bls/setup_test.go b/precompiles/bls/setup_test.go new file mode 100644 index 000000000..87fd1d210 --- /dev/null +++ b/precompiles/bls/setup_test.go @@ -0,0 +1,37 @@ +package task_test + +import ( + "github.com/ExocoreNetwork/exocore/testutil" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "testing" + + "github.com/ExocoreNetwork/exocore/precompiles/avsTask" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/stretchr/testify/suite" +) + +var s *TaskPrecompileTestSuite + +type TaskPrecompileTestSuite struct { + testutil.BaseTestSuite + precompile *task.Precompile +} + +func TestPrecompileTestSuite(t *testing.T) { + s = new(TaskPrecompileTestSuite) + suite.Run(t, s) + + // Run Ginkgo integration tests + RegisterFailHandler(Fail) + RunSpecs(t, "Task Precompile Suite") +} + +func (s *TaskPrecompileTestSuite) SetupTest() { + s.DoSetupTest() + precompile, err := task.NewPrecompile(s.App.AuthzKeeper, s.App.TaskKeeper, tasktype.AvsKeeper{}) + s.Require().NoError(err) + s.precompile = precompile +} diff --git a/proto/exocore/avs/genesis.proto b/proto/exocore/avs/genesis.proto new file mode 100644 index 000000000..0231fb278 --- /dev/null +++ b/proto/exocore/avs/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package exocore.avs; + +import "gogoproto/gogo.proto"; +import "exocore/avs/params.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/avs/types"; + +// GenesisState defines the avs module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/exocore/avs/params.proto b/proto/exocore/avs/params.proto new file mode 100644 index 000000000..bbc7d1796 --- /dev/null +++ b/proto/exocore/avs/params.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package exocore.avs; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/avs/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + +} diff --git a/proto/exocore/avs/query.proto b/proto/exocore/avs/query.proto new file mode 100644 index 000000000..8803a1699 --- /dev/null +++ b/proto/exocore/avs/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package exocore.avs; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "exocore/avs/params.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/avs/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/avs/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/exocore/avs/tx.proto b/proto/exocore/avs/tx.proto new file mode 100644 index 000000000..a43bf6132 --- /dev/null +++ b/proto/exocore/avs/tx.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package exocore.avs; +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "exocore/delegation/v1/tx.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/avs/types"; + +message AVSInfo { + string name = 1; + string AVSAddress = 2; + repeated string operatorAddress = 3; + +} + +message AVSManager { + map AVSOperatorRelation = 1; +} + +message RegisterAVSReq { + option (cosmos.msg.v1.signer) = "FromAddress"; + string FromAddress = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + AVSInfo info = 2; +} + +message RegisterAVSResponse { + option (cosmos.msg.v1.signer) = "FromAddress"; + string FromAddress = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + AVSInfo info = 2; +} + +message DeRegisterAVSReq { + option (cosmos.msg.v1.signer) = "FromAddress"; + string FromAddress = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + AVSInfo info = 2; +} + +message DeRegisterAVSResponse { + option (cosmos.msg.v1.signer) = "FromAddress"; + string FromAddress = 1 + [(cosmos_proto.scalar) = "cosmos.AddressString"]; + AVSInfo info = 2; +} + +// Msg defines the AVS related Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // RegisterAVS registers a new AVS with corresponding operator. + rpc RegisterAVS (RegisterAVSReq) returns (RegisterAVSResponse); + // DelegateAssetToOperator delegates asset to operator. + rpc DeRegisterAVS (DeRegisterAVSReq) returns (DeRegisterAVSResponse); +} + \ No newline at end of file diff --git a/proto/exocore/taskmanageravs/genesis.proto b/proto/exocore/taskmanageravs/genesis.proto new file mode 100644 index 000000000..aeaa3034e --- /dev/null +++ b/proto/exocore/taskmanageravs/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package exocore.taskmanageravs; + +import "gogoproto/gogo.proto"; +import "exocore/taskmanageravs/params.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types"; + +// GenesisState defines the taskmanageravs module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/exocore/taskmanageravs/params.proto b/proto/exocore/taskmanageravs/params.proto new file mode 100644 index 000000000..af6ca4e72 --- /dev/null +++ b/proto/exocore/taskmanageravs/params.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package exocore.taskmanageravs; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + +} diff --git a/proto/exocore/taskmanageravs/query.proto b/proto/exocore/taskmanageravs/query.proto new file mode 100644 index 000000000..1df79afb0 --- /dev/null +++ b/proto/exocore/taskmanageravs/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package exocore.taskmanageravs; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "exocore/taskmanageravs/params.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/taskmanageravs/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/exocore/taskmanageravs/tx.proto b/proto/exocore/taskmanageravs/tx.proto new file mode 100644 index 000000000..8077e4394 --- /dev/null +++ b/proto/exocore/taskmanageravs/tx.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +package exocore.taskmanageravs; + +option go_package = "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types"; + +message TaskContractInfo { + uint64 TaskContractId = 1; + string Name = 2; + string MetaInfo = 3; + string TaskContractAddress = 4; + string Status = 5; + string sourceCode = 6; +} +message TaskInstance { + string TaskId = 1; + uint64 numberToBeSquared = 2; + uint64 taskCreatedBlock = 3; + string quorumNumbers = 4; + // each task needs to reach at least thresholdPercentage of operator signatures. + uint64 quorumThresholdPercentage = 5; + string ContractAddr =6; +} + +message TaskManagerInfo { + map TaskManager = 1; +} + +message RegisterAVSTaskReq { + string AVSAddress = 1; + TaskContractInfo task = 2; +} + +message RegisterAVSTaskResponse {} + + +// Msg defines the Msg service. +service Msg { + rpc RegisterAVSTask(RegisterAVSTaskReq) returns (RegisterAVSTaskResponse); +} \ No newline at end of file diff --git a/testutil/abci.go b/testutil/abci.go index 368446e31..51061fd20 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, useUncachedCtx bool) (sdk.Context, error) { +func CommitAndCreateNewCtx(ctx sdk.Context, app *app.ExocoreApp, t time.Duration, vs *tmtypes.ValidatorSet) (sdk.Context, error) { header, err := commit(ctx, app, t, vs) if err != nil { return ctx, err @@ -44,14 +44,8 @@ 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 - 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 := 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/keeper/avs.go b/testutil/keeper/avs.go new file mode 100644 index 000000000..a6e704191 --- /dev/null +++ b/testutil/keeper/avs.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "testing" + + "github.com/ExocoreNetwork/exocore/x/avs/keeper" + "github.com/ExocoreNetwork/exocore/x/avs/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmdb "github.com/cometbft/cometbft-db" +) + +func AvsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "AvsParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/testutil/keeper/taskmanageravs.go b/testutil/keeper/taskmanageravs.go new file mode 100644 index 000000000..c8431b8cb --- /dev/null +++ b/testutil/keeper/taskmanageravs.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "testing" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + "github.com/stretchr/testify/require" +) + +func TaskmanageravsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + k := keeper.NewKeeper( + cdc, + storeKey, + tasktype.AvsKeeper{}, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return &k, ctx +} diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index 041e94cff..e845453c3 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -84,7 +84,8 @@ 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 02ab7135e..d7a973841 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -7,7 +7,6 @@ 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" @@ -73,8 +72,7 @@ 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) { - pruneOpts := pruningtypes.NewPruningOptionsFromString(pruningtypes.PruningOptionDefault) - appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, &pruneOpts, false)() + appI, genesisState := exocoreapp.SetupTestingApp(utils.DefaultChainID, false)() app, ok := appI.(*exocoreapp.ExocoreApp) suite.Require().True(ok) @@ -255,6 +253,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, true) + suite.Ctx, err = CommitAndCreateNewCtx(suite.Ctx, suite.App, time.Second, suite.ValSet) suite.Require().NoError(err) } diff --git a/x/assets/keeper/operator_asset.go b/x/assets/keeper/operator_asset.go index 1b575b895..f972b759d 100644 --- a/x/assets/keeper/operator_asset.go +++ b/x/assets/keeper/operator_asset.go @@ -46,10 +46,9 @@ func (k Keeper) GetOperatorSpecifiedAssetInfo(ctx sdk.Context, operatorAddr sdk. return &ret, nil } -// UpdateOperatorAssetState It's used to update the operator states that include TotalAmount OperatorAmount and WaitUndelegationAmount +// UpdateOperatorAssetState is 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) diff --git a/x/assets/keeper/staker_asset.go b/x/assets/keeper/staker_asset.go index 2051c84a5..257dfa258 100644 --- a/x/assets/keeper/staker_asset.go +++ b/x/assets/keeper/staker_asset.go @@ -45,11 +45,11 @@ func (k Keeper) GetStakerSpecifiedAssetInfo(ctx sdk.Context, stakerID string, as return &ret, nil } -// UpdateStakerAssetState It's used to update the staker asset state +// UpdateStakerAssetState is 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 + // 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{ diff --git a/x/assets/types/general.go b/x/assets/types/general.go index 7e93ceb81..ae23e79ad 100644 --- a/x/assets/types/general.go +++ b/x/assets/types/general.go @@ -75,7 +75,7 @@ func GetStakeIDAndAssetIDFromStr(clientChainLzID uint64, stakerAddress string, a return } -// UpdateAssetValue It's used to update asset state,negative or positive `changeValue` represents a decrease or increase in the asset state +// UpdateAssetValue is 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 { diff --git a/x/assets/types/query.pb.gw.go b/x/assets/types/query.pb.gw.go index 4bc526699..507e99040 100644 --- a/x/assets/types/query.pb.gw.go +++ b/x/assets/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -360,14 +358,12 @@ func local_request_Query_QueStakerExoCoreAddr_0(ctx context.Context, marshaler r // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -375,7 +371,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -389,8 +384,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueClientChainInfoByIndex_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -398,7 +391,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueClientChainInfoByIndex_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -412,8 +404,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueAllClientChainInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -421,7 +411,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueAllClientChainInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -435,8 +424,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakingAssetInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -444,7 +431,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakingAssetInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -458,8 +444,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueAllStakingAssetsInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -467,7 +451,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueAllStakingAssetsInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -481,8 +464,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakerAssetInfos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -490,7 +471,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakerAssetInfos_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -504,8 +484,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakerSpecifiedAssetAmount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -513,7 +491,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakerSpecifiedAssetAmount_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -527,8 +504,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueOperatorAssetInfos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -536,7 +511,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueOperatorAssetInfos_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -550,8 +524,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueOperatorSpecifiedAssetAmount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -559,7 +531,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueOperatorSpecifiedAssetAmount_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -573,8 +544,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueStakerExoCoreAddr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -582,7 +551,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueStakerExoCoreAddr_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/avs/client/cli/query.go b/x/avs/client/cli/query.go new file mode 100644 index 000000000..bdf0577b8 --- /dev/null +++ b/x/avs/client/cli/query.go @@ -0,0 +1,32 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group avs queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} + diff --git a/x/avs/client/cli/query_params.go b/x/avs/client/cli/query_params.go new file mode 100644 index 000000000..91d3ce7f1 --- /dev/null +++ b/x/avs/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/avs/client/cli/tx.go b/x/avs/client/cli/tx.go new file mode 100644 index 000000000..8e7985870 --- /dev/null +++ b/x/avs/client/cli/tx.go @@ -0,0 +1,69 @@ +package cli + +import ( + "fmt" + "time" + + "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/avs/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} + +func RegisterAVS() *cobra.Command { + cmd := &cobra.Command{ + Use: "RegisterAVS: AVSName, AVSAddress, OperatorAddress", + Short: "register to be an avs", + 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() + fromAddress := sender.String() + msg := &types.RegisterAVSReq{ + FromAddress: fromAddress, + Info: &types.AVSInfo{ + Name: args[0], + AVSAddress: args[1], + OperatorAddress: args[2], + }, + } + + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/avs/genesis.go b/x/avs/genesis.go new file mode 100644 index 000000000..5cf1bc578 --- /dev/null +++ b/x/avs/genesis.go @@ -0,0 +1,23 @@ +package avs + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ExocoreNetwork/exocore/x/avs/keeper" + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/avs/genesis_test.go b/x/avs/genesis_test.go new file mode 100644 index 000000000..497681a15 --- /dev/null +++ b/x/avs/genesis_test.go @@ -0,0 +1,31 @@ +package avs_test + +import ( + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/avs" + "github.com/ExocoreNetwork/exocore/x/avs/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.AvsKeeper(t) + avs.InitGenesis(ctx, *k, genesisState) + got := avs.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go new file mode 100644 index 000000000..7c363e166 --- /dev/null +++ b/x/avs/keeper/keeper.go @@ -0,0 +1,117 @@ +package keeper + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" + "github.com/cometbft/cometbft/libs/log" + "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" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + operatorKeeper delegationtypes.OperatorKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) AVSInfoUpdate(ctx sdk.Context, params *AVSParams) error { + operatorAddress := params.OperatorAddress + opAccAddr, err := sdk.AccAddressFromBech32(string(operatorAddress)) + if err != nil { + return errorsmod.Wrap(err, fmt.Sprintf("error occurred when parse acc address from Bech32,the addr is:%s", operatorAddress)) + } + if !k.operatorKeeper.IsOperator(ctx, opAccAddr) { + return errorsmod.Wrap(delegationtypes.ErrOperatorNotExist, "AVSInfoUpdate: invalid operator address") + } + action := params.Action + + if action == RegisterAction { + return k.SetAVSInfo(ctx, params.AVSName, string(params.AVSAddress), string(operatorAddress)) + } else { + return k.DeleteAVSInfo(ctx, string(params.AVSAddress)) + } +} + +func (k Keeper) SetAVSInfo(ctx sdk.Context, AVSName string, AVSAddress string, OperatorAddress string) (err error) { + avsAddr, err := sdk.AccAddressFromBech32(AVSAddress) + if err != nil { + return errorsmod.Wrap(err, "GetAVSInfo: error occurred when parse acc address from Bech32") + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSInfo) + if !store.Has(avsAddr) { + AVSInfo := &types.AVSInfo{Name: AVSName, AVSAddress: AVSAddress, OperatorAddress: []string{OperatorAddress}} + bz := k.cdc.MustMarshal(AVSInfo) + store.Set(avsAddr, bz) + return nil + } else { + value := store.Get(avsAddr) + ret := &types.AVSInfo{} + k.cdc.MustUnmarshal(value, ret) + ret.OperatorAddress = append(ret.OperatorAddress, OperatorAddress) + return nil + } +} + +func (k Keeper) GetAVSInfo(ctx sdk.Context, addr string) (*types.AVSInfo, error) { + avsAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return nil, errorsmod.Wrap(err, "GetAVSInfo: error occurred when parse acc address from Bech32") + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSInfo) + if !store.Has(avsAddr) { + return nil, errorsmod.Wrap(types.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSInfo: key is %s", avsAddr)) + } + + value := store.Get(avsAddr) + ret := types.AVSInfo{} + k.cdc.MustUnmarshal(value, &ret) + return &ret, nil +} + +func (k Keeper) DeleteAVSInfo(ctx sdk.Context, addr string) error { + avsAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return errorsmod.Wrap(err, "AVSInfo: error occurred when parse acc address from Bech32") + } + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSInfo) + if !store.Has(avsAddr) { + return errorsmod.Wrap(types.ErrNoKeyInTheStore, fmt.Sprintf("AVSInfo didn't exist: key is %s", avsAddr)) + } + store.Delete(avsAddr) + return nil +} diff --git a/x/avs/keeper/msg_server.go b/x/avs/keeper/msg_server.go new file mode 100644 index 000000000..8bc3313fa --- /dev/null +++ b/x/avs/keeper/msg_server.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +var _ types.MsgServer = &Keeper{} + +func (k Keeper) RegisterAVS(ctx context.Context, req *types.RegisterAVSReq) (*types.RegisterAVSResponse, error) { + // Disable cosmos transaction temporarily + // c := sdk.UnwrapSDKContext(ctx) + // fromAddress := req.FromAddress + // operatorAddress := req.Info.OperatorAddress + // for _, opAddr := range operatorAddress { + // if fromAddress == opAddr { + // // Set purely for AVS itself information. + // if err := k.SetAVSInfo(c, req.Info); err != nil { + // return nil, err + // } + // } + // } + return nil, nil +} + +func (k Keeper) DeRegisterAVS(ctx context.Context, req *types.DeRegisterAVSReq) (*types.DeRegisterAVSResponse, error) { + // Disable cosmos transaction temporarily + // c := sdk.UnwrapSDKContext(ctx) + // if err := k.DeleteAVSInfo(c, req.Info); err != nil { + // return nil, err + // } + + return nil, nil +} diff --git a/x/avs/keeper/params.go b/x/avs/keeper/params.go new file mode 100644 index 000000000..5cb190464 --- /dev/null +++ b/x/avs/keeper/params.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/avs/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} + +type AVSParams struct { + AVSName string + AVSAddress []byte + OperatorAddress []byte + Action uint64 +} + +const ( + RegisterAction = iota + 1 + DeRegisterAction +) diff --git a/x/avs/keeper/params_test.go b/x/avs/keeper/params_test.go new file mode 100644 index 000000000..abe54c450 --- /dev/null +++ b/x/avs/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + testkeeper "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.AvsKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/avs/keeper/query.go b/x/avs/keeper/query.go new file mode 100644 index 000000000..f6f9fd320 --- /dev/null +++ b/x/avs/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/avs/keeper/query_params.go b/x/avs/keeper/query_params.go new file mode 100644 index 000000000..437c0aa3a --- /dev/null +++ b/x/avs/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ExocoreNetwork/exocore/x/avs/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/avs/keeper/query_params_test.go b/x/avs/keeper/query_params_test.go new file mode 100644 index 000000000..84338c827 --- /dev/null +++ b/x/avs/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.AvsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/avs/module.go b/x/avs/module.go new file mode 100644 index 000000000..52c1f6d29 --- /dev/null +++ b/x/avs/module.go @@ -0,0 +1,150 @@ +package avs + +import ( + "context" + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/ExocoreNetwork/exocore/x/avs/keeper" + "github.com/ExocoreNetwork/exocore/x/avs/types" + "github.com/ExocoreNetwork/exocore/x/avs/client/cli" + +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/avs/simulation/helpers.go b/x/avs/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/avs/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/avs/types/codec.go b/x/avs/types/codec.go new file mode 100644 index 000000000..fb6871d22 --- /dev/null +++ b/x/avs/types/codec.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/avs/types/errors.go b/x/avs/types/errors.go new file mode 100644 index 000000000..925153146 --- /dev/null +++ b/x/avs/types/errors.go @@ -0,0 +1,14 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/avs module sentinel errors +var ( + ErrNoKeyInTheStore = errorsmod.Register(ModuleName, 0, "there is not the key for in the store") + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/avs/types/expected_keepers.go b/x/avs/types/expected_keepers.go new file mode 100644 index 000000000..6aa6e9778 --- /dev/null +++ b/x/avs/types/expected_keepers.go @@ -0,0 +1,18 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/avs/types/genesis.go b/x/avs/types/genesis.go new file mode 100644 index 000000000..c41be0742 --- /dev/null +++ b/x/avs/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/avs/types/genesis.pb.go b/x/avs/types/genesis.pb.go new file mode 100644 index 000000000..1742a7a05 --- /dev/null +++ b/x/avs/types/genesis.pb.go @@ -0,0 +1,320 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/avs/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the avs module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_6f7a9069172c0bef, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "exocore.avs.GenesisState") +} + +func init() { proto.RegisterFile("exocore/avs/genesis.proto", fileDescriptor_6f7a9069172c0bef) } + +var fileDescriptor_6f7a9069172c0bef = []byte{ + // 192 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x2b, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x4a, 0xe9, 0x25, 0x96, 0x15, 0x4b, 0x89, 0xa4, + 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf5, 0x41, 0x2c, 0x88, 0x12, 0x29, 0x09, 0x64, 0xdd, 0x05, 0x89, + 0x45, 0x89, 0xb9, 0x50, 0xcd, 0x4a, 0x8e, 0x5c, 0x3c, 0xee, 0x10, 0xd3, 0x82, 0x4b, 0x12, 0x4b, + 0x52, 0x85, 0x0c, 0xb9, 0xd8, 0x20, 0xf2, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xc2, 0x7a, + 0x48, 0xa6, 0xeb, 0x05, 0x80, 0xa5, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0x2a, 0x74, + 0x72, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, + 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, + 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x57, 0x88, 0x31, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, + 0x45, 0xd9, 0xfa, 0x30, 0x07, 0x55, 0x80, 0x9d, 0x54, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0x76, 0x92, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x79, 0xb0, 0x7f, 0x59, 0xec, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/avs/types/genesis_test.go b/x/avs/types/genesis_test.go new file mode 100644 index 000000000..deb949fe6 --- /dev/null +++ b/x/avs/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/ExocoreNetwork/exocore/x/avs/types" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + } { + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} \ No newline at end of file diff --git a/x/avs/types/keys.go b/x/avs/types/keys.go new file mode 100644 index 000000000..bf062a701 --- /dev/null +++ b/x/avs/types/keys.go @@ -0,0 +1,34 @@ +package types + +import ( + "github.com/ethereum/go-ethereum/common" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +const ( + // ModuleName defines the module name + ModuleName = "avs" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_avs" + prefixAVSInfo = iota + 1 + prefixAVSOperatorInfo +) + +// ModuleAddress is the native module address for EVM +var ( + ModuleAddress common.Address + KeyPrefixAVSInfo = []byte{prefixAVSInfo} + KeyPrefixAVSOperatorInfo = []byte{prefixAVSOperatorInfo} +) + +func init() { + ModuleAddress = common.BytesToAddress(authtypes.NewModuleAddress(ModuleName).Bytes()) +} diff --git a/x/avs/types/msg.go b/x/avs/types/msg.go new file mode 100644 index 000000000..4dc3e633f --- /dev/null +++ b/x/avs/types/msg.go @@ -0,0 +1,49 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = &RegisterAVSReq{} + _ sdk.Msg = &DeRegisterAVSReq{} +) + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *RegisterAVSReq) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.FromAddress) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check of the provided data +func (m *RegisterAVSReq) 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 *RegisterAVSReq) GetSignBytes() []byte { + return nil +} + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *DeRegisterAVSReq) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.FromAddress) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check of the provided data +func (m *DeRegisterAVSReq) 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 *DeRegisterAVSReq) GetSignBytes() []byte { + return nil +} diff --git a/x/avs/types/params.go b/x/avs/types/params.go new file mode 100644 index 000000000..52a8a059f --- /dev/null +++ b/x/avs/types/params.go @@ -0,0 +1,47 @@ +package types + +import ( + + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + + + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams( +) Params { + return Params{ + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + ) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/avs/types/params.pb.go b/x/avs/types/params.pb.go new file mode 100644 index 000000000..6a30802d5 --- /dev/null +++ b/x/avs/types/params.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/avs/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_774593bd3020038f, []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 init() { + proto.RegisterType((*Params)(nil), "exocore.avs.Params") +} + +func init() { proto.RegisterFile("exocore/avs/params.proto", fileDescriptor_774593bd3020038f) } + +var fileDescriptor_774593bd3020038f = []byte{ + // 151 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x48, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x2b, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0xca, 0xe8, 0x25, 0x96, 0x15, 0x4b, 0x89, 0xa4, 0xe7, + 0xa7, 0xe7, 0x83, 0xc5, 0xf5, 0x41, 0x2c, 0x88, 0x12, 0x25, 0x3e, 0x2e, 0xb6, 0x00, 0xb0, 0x16, + 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0xdc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, + 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, + 0x8e, 0x21, 0x4a, 0x37, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x15, + 0x62, 0xae, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xcc, 0x01, 0x15, 0x60, 0x27, 0x94, + 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xcd, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x57, + 0x8f, 0xf6, 0xe8, 0x9e, 0x00, 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 + 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 + 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 { + 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/avs/types/query.pb.go b/x/avs/types/query.pb.go new file mode 100644 index 000000000..1e76f2c7b --- /dev/null +++ b/x/avs/types/query.pb.go @@ -0,0 +1,537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/avs/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d9df5f5965203ddc, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_d9df5f5965203ddc, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "exocore.avs.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "exocore.avs.QueryParamsResponse") +} + +func init() { proto.RegisterFile("exocore/avs/query.proto", fileDescriptor_d9df5f5965203ddc) } + +var fileDescriptor_d9df5f5965203ddc = []byte{ + // 300 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x41, 0x4b, 0xf3, 0x30, + 0x18, 0xc7, 0x9b, 0x97, 0xd7, 0x1d, 0xb2, 0x5b, 0x36, 0x70, 0x14, 0xc9, 0x46, 0xf1, 0x20, 0x03, + 0x1b, 0x3a, 0xbf, 0xc1, 0x40, 0xf4, 0x24, 0xba, 0xa3, 0xb7, 0xb4, 0x84, 0x58, 0xb4, 0x7d, 0xb2, + 0x26, 0xed, 0xb6, 0x9b, 0xf8, 0x09, 0x04, 0xbf, 0xd4, 0x8e, 0x03, 0x2f, 0x9e, 0x44, 0x5a, 0x3f, + 0x88, 0x2c, 0xe9, 0x61, 0x63, 0xec, 0x56, 0xfe, 0xcf, 0xef, 0xff, 0xeb, 0xf3, 0x04, 0x9f, 0x8a, + 0x25, 0x24, 0x50, 0x08, 0xc6, 0x2b, 0xcd, 0xe6, 0xa5, 0x28, 0x56, 0xa1, 0x2a, 0xc0, 0x00, 0xe9, + 0xb6, 0x83, 0x90, 0x57, 0xda, 0xef, 0x4b, 0x90, 0x60, 0x73, 0xb6, 0xfd, 0x72, 0x88, 0x7f, 0x26, + 0x01, 0xe4, 0x8b, 0x60, 0x5c, 0xa5, 0x8c, 0xe7, 0x39, 0x18, 0x6e, 0x52, 0xc8, 0x75, 0x3b, 0x1d, + 0x27, 0xa0, 0x33, 0xd0, 0x2c, 0xe6, 0x5a, 0x38, 0x33, 0xab, 0xa2, 0x58, 0x18, 0x1e, 0x31, 0xc5, + 0x65, 0x9a, 0x5b, 0xb8, 0x65, 0x07, 0xbb, 0x5b, 0x28, 0x5e, 0xf0, 0xac, 0xb5, 0x04, 0x7d, 0x4c, + 0x1e, 0xb6, 0xdd, 0x7b, 0x1b, 0xce, 0xc4, 0xbc, 0x14, 0xda, 0x04, 0xb7, 0xb8, 0xb7, 0x97, 0x6a, + 0x05, 0xb9, 0x16, 0x24, 0xc2, 0x1d, 0x57, 0x1e, 0xa0, 0x11, 0xba, 0xe8, 0x4e, 0x7a, 0xe1, 0xce, + 0x11, 0xa1, 0x83, 0xa7, 0xff, 0xd7, 0xdf, 0x43, 0x6f, 0xd6, 0x82, 0x93, 0x57, 0x84, 0x4f, 0xac, + 0x8a, 0x2c, 0x70, 0xc7, 0x11, 0x64, 0xb8, 0x57, 0x3b, 0xfc, 0xbd, 0x3f, 0x3a, 0x0e, 0xb8, 0x4d, + 0x82, 0xf1, 0xdb, 0xe7, 0xef, 0xc7, 0xbf, 0x73, 0x12, 0xb0, 0x6b, 0x47, 0xde, 0x09, 0xb3, 0x80, + 0xe2, 0x99, 0x1d, 0x1e, 0x3a, 0xbd, 0x59, 0xd7, 0x14, 0x6d, 0x6a, 0x8a, 0x7e, 0x6a, 0x8a, 0xde, + 0x1b, 0xea, 0x6d, 0x1a, 0xea, 0x7d, 0x35, 0xd4, 0x7b, 0xbc, 0x94, 0xa9, 0x79, 0x2a, 0xe3, 0x30, + 0x81, 0xec, 0x98, 0x67, 0x69, 0x4d, 0x66, 0xa5, 0x84, 0x8e, 0x3b, 0xf6, 0xc9, 0xae, 0xfe, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x78, 0xe2, 0x4e, 0x16, 0xd4, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.avs.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.avs.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.avs.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/avs/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/avs/types/query.pb.gw.go b/x/avs/types/query.pb.gw.go new file mode 100644 index 000000000..47246d466 --- /dev/null +++ b/x/avs/types/query.pb.gw.go @@ -0,0 +1,148 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: exocore/avs/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/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 + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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() + 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) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "avs", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/avs/types/tx.pb.go b/x/avs/types/tx.pb.go new file mode 100644 index 000000000..621140951 --- /dev/null +++ b/x/avs/types/tx.pb.go @@ -0,0 +1,1772 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/avs/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/ExocoreNetwork/exocore/x/delegation/types" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AVSInfo struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + AVSAddress string `protobuf:"bytes,2,opt,name=AVSAddress,proto3" json:"AVSAddress,omitempty"` + OperatorAddress []string `protobuf:"bytes,3,rep,name=operatorAddress,proto3" json:"operatorAddress,omitempty"` +} + +func (m *AVSInfo) Reset() { *m = AVSInfo{} } +func (m *AVSInfo) String() string { return proto.CompactTextString(m) } +func (*AVSInfo) ProtoMessage() {} +func (*AVSInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c92b5dfe90086a66, []int{0} +} +func (m *AVSInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AVSInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AVSInfo.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 *AVSInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_AVSInfo.Merge(m, src) +} +func (m *AVSInfo) XXX_Size() int { + return m.Size() +} +func (m *AVSInfo) XXX_DiscardUnknown() { + xxx_messageInfo_AVSInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_AVSInfo proto.InternalMessageInfo + +func (m *AVSInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *AVSInfo) GetAVSAddress() string { + if m != nil { + return m.AVSAddress + } + return "" +} + +func (m *AVSInfo) GetOperatorAddress() []string { + if m != nil { + return m.OperatorAddress + } + return nil +} + +type AVSManager struct { + AVSOperatorRelation map[string]string `protobuf:"bytes,1,rep,name=AVSOperatorRelation,proto3" json:"AVSOperatorRelation,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *AVSManager) Reset() { *m = AVSManager{} } +func (m *AVSManager) String() string { return proto.CompactTextString(m) } +func (*AVSManager) ProtoMessage() {} +func (*AVSManager) Descriptor() ([]byte, []int) { + return fileDescriptor_c92b5dfe90086a66, []int{1} +} +func (m *AVSManager) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AVSManager) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AVSManager.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 *AVSManager) XXX_Merge(src proto.Message) { + xxx_messageInfo_AVSManager.Merge(m, src) +} +func (m *AVSManager) XXX_Size() int { + return m.Size() +} +func (m *AVSManager) XXX_DiscardUnknown() { + xxx_messageInfo_AVSManager.DiscardUnknown(m) +} + +var xxx_messageInfo_AVSManager proto.InternalMessageInfo + +func (m *AVSManager) GetAVSOperatorRelation() map[string]string { + if m != nil { + return m.AVSOperatorRelation + } + return nil +} + +type RegisterAVSReq struct { + FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` + Info *AVSInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *RegisterAVSReq) Reset() { *m = RegisterAVSReq{} } +func (m *RegisterAVSReq) String() string { return proto.CompactTextString(m) } +func (*RegisterAVSReq) ProtoMessage() {} +func (*RegisterAVSReq) Descriptor() ([]byte, []int) { + return fileDescriptor_c92b5dfe90086a66, []int{2} +} +func (m *RegisterAVSReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterAVSReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterAVSReq.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 *RegisterAVSReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterAVSReq.Merge(m, src) +} +func (m *RegisterAVSReq) XXX_Size() int { + return m.Size() +} +func (m *RegisterAVSReq) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterAVSReq.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterAVSReq proto.InternalMessageInfo + +func (m *RegisterAVSReq) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *RegisterAVSReq) GetInfo() *AVSInfo { + if m != nil { + return m.Info + } + return nil +} + +type RegisterAVSResponse struct { + FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` + Info *AVSInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *RegisterAVSResponse) Reset() { *m = RegisterAVSResponse{} } +func (m *RegisterAVSResponse) String() string { return proto.CompactTextString(m) } +func (*RegisterAVSResponse) ProtoMessage() {} +func (*RegisterAVSResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c92b5dfe90086a66, []int{3} +} +func (m *RegisterAVSResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterAVSResponse.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 *RegisterAVSResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterAVSResponse.Merge(m, src) +} +func (m *RegisterAVSResponse) XXX_Size() int { + return m.Size() +} +func (m *RegisterAVSResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterAVSResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterAVSResponse proto.InternalMessageInfo + +func (m *RegisterAVSResponse) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *RegisterAVSResponse) GetInfo() *AVSInfo { + if m != nil { + return m.Info + } + return nil +} + +type DeRegisterAVSReq struct { + FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` + Info *AVSInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *DeRegisterAVSReq) Reset() { *m = DeRegisterAVSReq{} } +func (m *DeRegisterAVSReq) String() string { return proto.CompactTextString(m) } +func (*DeRegisterAVSReq) ProtoMessage() {} +func (*DeRegisterAVSReq) Descriptor() ([]byte, []int) { + return fileDescriptor_c92b5dfe90086a66, []int{4} +} +func (m *DeRegisterAVSReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeRegisterAVSReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeRegisterAVSReq.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 *DeRegisterAVSReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeRegisterAVSReq.Merge(m, src) +} +func (m *DeRegisterAVSReq) XXX_Size() int { + return m.Size() +} +func (m *DeRegisterAVSReq) XXX_DiscardUnknown() { + xxx_messageInfo_DeRegisterAVSReq.DiscardUnknown(m) +} + +var xxx_messageInfo_DeRegisterAVSReq proto.InternalMessageInfo + +func (m *DeRegisterAVSReq) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *DeRegisterAVSReq) GetInfo() *AVSInfo { + if m != nil { + return m.Info + } + return nil +} + +type DeRegisterAVSResponse struct { + FromAddress string `protobuf:"bytes,1,opt,name=FromAddress,proto3" json:"FromAddress,omitempty"` + Info *AVSInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *DeRegisterAVSResponse) Reset() { *m = DeRegisterAVSResponse{} } +func (m *DeRegisterAVSResponse) String() string { return proto.CompactTextString(m) } +func (*DeRegisterAVSResponse) ProtoMessage() {} +func (*DeRegisterAVSResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c92b5dfe90086a66, []int{5} +} +func (m *DeRegisterAVSResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeRegisterAVSResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeRegisterAVSResponse.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 *DeRegisterAVSResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeRegisterAVSResponse.Merge(m, src) +} +func (m *DeRegisterAVSResponse) XXX_Size() int { + return m.Size() +} +func (m *DeRegisterAVSResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DeRegisterAVSResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DeRegisterAVSResponse proto.InternalMessageInfo + +func (m *DeRegisterAVSResponse) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *DeRegisterAVSResponse) GetInfo() *AVSInfo { + if m != nil { + return m.Info + } + return nil +} + +func init() { + proto.RegisterType((*AVSInfo)(nil), "exocore.avs.AVSInfo") + proto.RegisterType((*AVSManager)(nil), "exocore.avs.AVSManager") + proto.RegisterMapType((map[string]string)(nil), "exocore.avs.AVSManager.AVSOperatorRelationEntry") + proto.RegisterType((*RegisterAVSReq)(nil), "exocore.avs.RegisterAVSReq") + proto.RegisterType((*RegisterAVSResponse)(nil), "exocore.avs.RegisterAVSResponse") + proto.RegisterType((*DeRegisterAVSReq)(nil), "exocore.avs.DeRegisterAVSReq") + proto.RegisterType((*DeRegisterAVSResponse)(nil), "exocore.avs.DeRegisterAVSResponse") +} + +func init() { proto.RegisterFile("exocore/avs/tx.proto", fileDescriptor_c92b5dfe90086a66) } + +var fileDescriptor_c92b5dfe90086a66 = []byte{ + // 495 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0xd5, 0x2d, 0xa8, 0xcf, 0x02, 0xc2, 0x35, 0x08, 0x63, 0x84, 0x15, 0x79, 0xb2, 0x2a, + 0xd5, 0x86, 0xb0, 0xa0, 0x6c, 0xae, 0x68, 0x11, 0x12, 0x05, 0xc9, 0x96, 0x32, 0xb0, 0x20, 0x27, + 0x79, 0x35, 0x56, 0x63, 0x5f, 0xb8, 0x73, 0x43, 0xb2, 0x21, 0x26, 0x84, 0x84, 0xe0, 0x97, 0xa0, + 0x0e, 0x0c, 0xfc, 0x04, 0xc6, 0x8a, 0x89, 0x11, 0x25, 0x43, 0xff, 0x06, 0xca, 0xf9, 0x2c, 0xec, + 0xa8, 0x65, 0x2d, 0x8b, 0x7d, 0xf7, 0xbe, 0xf7, 0x7d, 0xef, 0x7d, 0xef, 0xa4, 0x07, 0x2d, 0x9c, + 0xb2, 0x01, 0xe3, 0xe8, 0x45, 0x13, 0xe1, 0xe5, 0x53, 0x77, 0xcc, 0x59, 0xce, 0xa8, 0xae, 0xa2, + 0x6e, 0x34, 0x11, 0xe6, 0xcd, 0x28, 0x4d, 0x32, 0xe6, 0xc9, 0x6f, 0x81, 0x9b, 0xb7, 0x07, 0x4c, + 0xa4, 0x4c, 0x78, 0xa9, 0x88, 0xbd, 0xc9, 0x83, 0xe5, 0x4f, 0x01, 0x77, 0x0a, 0xe0, 0x95, 0xbc, + 0x79, 0xc5, 0x45, 0x41, 0x56, 0x59, 0x69, 0x88, 0x23, 0x8c, 0xa3, 0x3c, 0x61, 0xd9, 0x92, 0x5b, + 0xd6, 0xb4, 0x63, 0xb8, 0xea, 0xf7, 0xc2, 0xa7, 0xd9, 0x21, 0xa3, 0x14, 0xd6, 0xb3, 0x28, 0x45, + 0x83, 0xb4, 0x89, 0xb3, 0x19, 0xc8, 0x33, 0xb5, 0x00, 0xfc, 0x5e, 0xe8, 0x0f, 0x87, 0x1c, 0x85, + 0x30, 0xd6, 0x24, 0x52, 0x89, 0x50, 0x07, 0x6e, 0xb0, 0x31, 0xf2, 0x28, 0x67, 0xbc, 0x4c, 0xd2, + 0xda, 0x9a, 0xb3, 0x19, 0xac, 0x86, 0xed, 0xef, 0x44, 0x4a, 0x1d, 0x44, 0x59, 0x14, 0x23, 0xa7, + 0x7d, 0xd8, 0xf2, 0x7b, 0xe1, 0x0b, 0x95, 0x14, 0xe0, 0x48, 0xb6, 0x66, 0x90, 0xb6, 0xe6, 0xe8, + 0x9d, 0xfb, 0x6e, 0x65, 0x12, 0xee, 0x5f, 0x96, 0x7b, 0x0e, 0x65, 0x2f, 0xcb, 0xf9, 0x2c, 0x38, + 0x4f, 0xcc, 0xdc, 0x07, 0xe3, 0x22, 0x02, 0x6d, 0x82, 0x76, 0x84, 0x33, 0xe5, 0x75, 0x79, 0xa4, + 0x2d, 0xd8, 0x98, 0x44, 0xa3, 0x63, 0x54, 0x2e, 0x8b, 0x4b, 0x77, 0xed, 0x11, 0xb1, 0x3f, 0x10, + 0xb8, 0x1e, 0x60, 0x9c, 0x88, 0x1c, 0xb9, 0xdf, 0x0b, 0x03, 0x7c, 0x43, 0xbb, 0xa0, 0xef, 0x73, + 0x96, 0x96, 0x9e, 0xa5, 0xcc, 0xae, 0xf1, 0xf3, 0xdb, 0x4e, 0x4b, 0x4d, 0x5f, 0x21, 0x61, 0xce, + 0x93, 0x2c, 0x0e, 0xaa, 0xc9, 0xd4, 0x81, 0xf5, 0x24, 0x3b, 0x64, 0xb2, 0x8e, 0xde, 0x69, 0xad, + 0x7a, 0x5d, 0xbe, 0x45, 0x20, 0x33, 0xba, 0xcd, 0xf7, 0x67, 0x27, 0xdb, 0x55, 0xae, 0xfd, 0x89, + 0xc0, 0x56, 0xad, 0x15, 0x31, 0x66, 0x99, 0xc0, 0x4b, 0xeb, 0xe7, 0x23, 0x81, 0xe6, 0x63, 0xfc, + 0x4f, 0x86, 0xf3, 0x99, 0xc0, 0xad, 0x95, 0x66, 0x2e, 0x77, 0x3c, 0x9d, 0xaf, 0x04, 0xb4, 0x03, + 0x11, 0xd3, 0x67, 0xa0, 0x57, 0xda, 0xa2, 0x77, 0x6b, 0x22, 0xf5, 0xe9, 0x99, 0xed, 0x8b, 0x41, + 0xe5, 0x26, 0x80, 0x6b, 0x35, 0x9b, 0xf4, 0x5e, 0x8d, 0xb2, 0xfa, 0x1e, 0xa6, 0xfd, 0x2f, 0xb8, + 0xd0, 0x34, 0x37, 0xde, 0x9d, 0x9d, 0x6c, 0x93, 0xdd, 0x27, 0x3f, 0xe6, 0x16, 0x39, 0x9d, 0x5b, + 0xe4, 0xf7, 0xdc, 0x22, 0x5f, 0x16, 0x56, 0xe3, 0x74, 0x61, 0x35, 0x7e, 0x2d, 0xac, 0xc6, 0xcb, + 0x9d, 0x38, 0xc9, 0x5f, 0x1f, 0xf7, 0xdd, 0x01, 0x4b, 0xbd, 0xbd, 0x42, 0xee, 0x39, 0xe6, 0x6f, + 0x19, 0x3f, 0xf2, 0xca, 0x15, 0x33, 0x2d, 0xd6, 0xd9, 0x6c, 0x8c, 0xa2, 0x7f, 0x45, 0xae, 0x97, + 0x87, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x5e, 0xa4, 0x50, 0xea, 0x04, 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 { + // RegisterAVS registers a new AVS with corresponding operator. + RegisterAVS(ctx context.Context, in *RegisterAVSReq, opts ...grpc.CallOption) (*RegisterAVSResponse, error) + // DelegateAssetToOperator delegates asset to operator. + DeRegisterAVS(ctx context.Context, in *DeRegisterAVSReq, opts ...grpc.CallOption) (*DeRegisterAVSResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterAVS(ctx context.Context, in *RegisterAVSReq, opts ...grpc.CallOption) (*RegisterAVSResponse, error) { + out := new(RegisterAVSResponse) + err := c.cc.Invoke(ctx, "/exocore.avs.Msg/RegisterAVS", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeRegisterAVS(ctx context.Context, in *DeRegisterAVSReq, opts ...grpc.CallOption) (*DeRegisterAVSResponse, error) { + out := new(DeRegisterAVSResponse) + err := c.cc.Invoke(ctx, "/exocore.avs.Msg/DeRegisterAVS", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // RegisterAVS registers a new AVS with corresponding operator. + RegisterAVS(context.Context, *RegisterAVSReq) (*RegisterAVSResponse, error) + // DelegateAssetToOperator delegates asset to operator. + DeRegisterAVS(context.Context, *DeRegisterAVSReq) (*DeRegisterAVSResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterAVS(ctx context.Context, req *RegisterAVSReq) (*RegisterAVSResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterAVS not implemented") +} +func (*UnimplementedMsgServer) DeRegisterAVS(ctx context.Context, req *DeRegisterAVSReq) (*DeRegisterAVSResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeRegisterAVS not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterAVSReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterAVS(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.avs.Msg/RegisterAVS", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterAVS(ctx, req.(*RegisterAVSReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeRegisterAVS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeRegisterAVSReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeRegisterAVS(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.avs.Msg/DeRegisterAVS", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeRegisterAVS(ctx, req.(*DeRegisterAVSReq)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.avs.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterAVS", + Handler: _Msg_RegisterAVS_Handler, + }, + { + MethodName: "DeRegisterAVS", + Handler: _Msg_DeRegisterAVS_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/avs/tx.proto", +} + +func (m *AVSInfo) 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 *AVSInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AVSInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OperatorAddress) > 0 { + for iNdEx := len(m.OperatorAddress) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.OperatorAddress[iNdEx]) + copy(dAtA[i:], m.OperatorAddress[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.OperatorAddress[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.AVSAddress) > 0 { + i -= len(m.AVSAddress) + copy(dAtA[i:], m.AVSAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.AVSAddress))) + 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 *AVSManager) 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 *AVSManager) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AVSManager) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AVSOperatorRelation) > 0 { + for k := range m.AVSOperatorRelation { + v := m.AVSOperatorRelation[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintTx(dAtA, i, uint64(len(v))) + 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] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RegisterAVSReq) 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 *RegisterAVSReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterAVSReq) 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 *RegisterAVSResponse) 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 *RegisterAVSResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterAVSResponse) 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 *DeRegisterAVSReq) 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 *DeRegisterAVSReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeRegisterAVSReq) 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 *DeRegisterAVSResponse) 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 *DeRegisterAVSResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeRegisterAVSResponse) 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 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 *AVSInfo) 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.AVSAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.OperatorAddress) > 0 { + for _, s := range m.OperatorAddress { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *AVSManager) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AVSOperatorRelation) > 0 { + for k, v := range m.AVSOperatorRelation { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovTx(uint64(len(k))) + 1 + len(v) + sovTx(uint64(len(v))) + n += mapEntrySize + 1 + sovTx(uint64(mapEntrySize)) + } + } + return n +} + +func (m *RegisterAVSReq) 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 *RegisterAVSResponse) 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 *DeRegisterAVSReq) 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 *DeRegisterAVSResponse) 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 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 *AVSInfo) 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: AVSInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AVSInfo: 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 AVSAddress", 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.AVSAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.OperatorAddress = append(m.OperatorAddress, 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 *AVSManager) 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: AVSManager: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AVSManager: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSOperatorRelation", 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.AVSOperatorRelation == nil { + m.AVSOperatorRelation = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthTx + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthTx + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthTx + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthTx + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.AVSOperatorRelation[mapkey] = mapvalue + 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 *RegisterAVSReq) 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: RegisterAVSReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterAVSReq: 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 = &AVSInfo{} + } + 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 *RegisterAVSResponse) 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: RegisterAVSResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterAVSResponse: 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 = &AVSInfo{} + } + 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 *DeRegisterAVSReq) 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: DeRegisterAVSReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeRegisterAVSReq: 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 = &AVSInfo{} + } + 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 *DeRegisterAVSResponse) 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: DeRegisterAVSResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeRegisterAVSResponse: 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 = &AVSInfo{} + } + 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 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/avs/types/types.go b/x/avs/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/avs/types/types.go @@ -0,0 +1 @@ +package types diff --git a/x/delegation/keeper/abci.go b/x/delegation/keeper/abci.go index 047d911e0..eaf8cbfdf 100644 --- a/x/delegation/keeper/abci.go +++ b/x/delegation/keeper/abci.go @@ -8,7 +8,7 @@ import ( ) // 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. +// 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 { records, err := k.GetWaitCompleteUndelegationRecords(ctx, uint64(ctx.BlockHeight())) if err != nil { diff --git a/x/delegation/keeper/cross_chain_tx_process.go b/x/delegation/keeper/cross_chain_tx_process.go index 53933714e..93f670174 100644 --- a/x/delegation/keeper/cross_chain_tx_process.go +++ b/x/delegation/keeper/cross_chain_tx_process.go @@ -177,9 +177,10 @@ func (k *Keeper) DelegateTo(ctx sdk.Context, params *DelegationOrUndelegationPar return nil } -// UndelegateFrom The undelegation needs to consider whether the operator's opted-in assets can exit from the AVS. +// 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. +// So we use two steps to handle the undelegation. Fist, record the undelegation request and the corresponding exit time which needs to be obtained from the operator opt-in module. +// Then we handle the record when the exit time has expired. func (k *Keeper) UndelegateFrom(ctx sdk.Context, params *DelegationOrUndelegationParams) error { // check if the UndelegatedFrom address is an operator if !k.operatorKeeper.IsOperator(ctx, params.OperatorAddress) { diff --git a/x/delegation/keeper/delegation_state.go b/x/delegation/keeper/delegation_state.go index 022c668b5..f49f55dc3 100644 --- a/x/delegation/keeper/delegation_state.go +++ b/x/delegation/keeper/delegation_state.go @@ -11,8 +11,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// 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. +// UpdateStakerDelegationTotalAmount 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 { if opAmount.IsNil() || opAmount.IsZero() { @@ -51,7 +52,7 @@ func (k *Keeper) GetStakerDelegationTotalAmount(ctx sdk.Context, stakerID string return ret.Amount, nil } -// UpdateDelegationState The function is used to update the staker's asset amount that is delegated to a specified operator. +// UpdateDelegationState 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) { store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixRestakerDelegationInfo) diff --git a/x/delegation/keeper/un_delegation_state.go b/x/delegation/keeper/un_delegation_state.go index b4a315537..02e124cb3 100644 --- a/x/delegation/keeper/un_delegation_state.go +++ b/x/delegation/keeper/un_delegation_state.go @@ -21,8 +21,8 @@ const ( AllRecords ) -// 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` +// SetUndelegationRecords function saves the undelegation records to be handled when the handle time expires. +// When we save the undelegation records, we save them in three kv stores which are `KeyPrefixUndelegationInfo` `KeyPrefixStakerUndelegationInfo` and `KeyPrefixWaitCompleteUndelegations`. 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) @@ -53,7 +53,8 @@ func (k *Keeper) SetSingleUndelegationRecord(ctx sdk.Context, record *types.Unde } // StoreWaitCompleteRecord add it to handle the delay of completing undelegation caused by onHoldCount -// 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. +// 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) diff --git a/x/delegation/types/query.pb.gw.go b/x/delegation/types/query.pb.gw.go index cbf25a404..75a9fcb45 100644 --- a/x/delegation/types/query.pb.gw.go +++ b/x/delegation/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join var ( filter_Query_QueryDelegationInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} @@ -108,14 +106,12 @@ func local_request_Query_QuerySingleDelegationInfo_0(ctx context.Context, marsha // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_QueryDelegationInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -123,7 +119,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QueryDelegationInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -137,8 +132,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QuerySingleDelegationInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -146,7 +139,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_QuerySingleDelegationInfo_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/deposit/types/query.pb.gw.go b/x/deposit/types/query.pb.gw.go index 4e143091e..2c727832e 100644 --- a/x/deposit/types/query.pb.gw.go +++ b/x/deposit/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -54,14 +52,12 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -69,7 +65,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/dogfood/types/query.pb.gw.go b/x/dogfood/types/query.pb.gw.go index f078ad093..cbec494da 100644 --- a/x/dogfood/types/query.pb.gw.go +++ b/x/dogfood/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -54,14 +52,12 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -69,7 +65,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/evm/keeper/precompiles.go b/x/evm/keeper/precompiles.go index a26d157bc..e36d778ad 100644 --- a/x/evm/keeper/precompiles.go +++ b/x/evm/keeper/precompiles.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + taskKeeper "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" stakingStateKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" @@ -12,12 +13,14 @@ import ( "golang.org/x/exp/maps" + taskPrecompile "github.com/ExocoreNetwork/exocore/precompiles/avsTask" delegationprecompile "github.com/ExocoreNetwork/exocore/precompiles/delegation" depositprecompile "github.com/ExocoreNetwork/exocore/precompiles/deposit" rewardPrecompile "github.com/ExocoreNetwork/exocore/precompiles/reward" slashPrecompile "github.com/ExocoreNetwork/exocore/precompiles/slash" withdrawPrecompile "github.com/ExocoreNetwork/exocore/precompiles/withdraw" exoslashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -47,6 +50,7 @@ func AvailablePrecompiles( withdrawKeeper withdrawKeeper.Keeper, slashKeeper exoslashKeeper.Keeper, rewardKeeper rewardKeeper.Keeper, + taskKeeper taskKeeper.Keeper, ) map[common.Address]vm.PrecompiledContract { // Clone the mapping from the latest EVM fork. precompiles := maps.Clone(vm.PrecompiledContractsBerlin) @@ -92,11 +96,16 @@ func AvailablePrecompiles( if err != nil { panic(fmt.Errorf("failed to load reward precompile: %w", err)) } + taskPrecompile, err := taskPrecompile.NewPrecompile(authzKeeper, taskKeeper, tasktype.AvsKeeper{}) + if err != nil { + panic(fmt.Errorf("failed to load reward precompile: %w", err)) + } precompiles[slashPrecompile.Address()] = slashPrecompile precompiles[rewardPrecompile.Address()] = rewardPrecompile precompiles[withdrawPrecompile.Address()] = withdrawPrecompile precompiles[depositPrecompile.Address()] = depositPrecompile precompiles[delegationPrecompile.Address()] = delegationPrecompile + precompiles[taskPrecompile.Address()] = taskPrecompile precompiles[stakingPrecompile.Address()] = stakingPrecompile precompiles[distributionPrecompile.Address()] = distributionPrecompile diff --git a/x/operator/types/query.pb.gw.go b/x/operator/types/query.pb.gw.go index df260f313..145ebcd2e 100644 --- a/x/operator/types/query.pb.gw.go +++ b/x/operator/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ 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)} @@ -148,14 +146,12 @@ func local_request_Query_QueryOperatorConsKeyForChainID_0(ctx context.Context, m // 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. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -163,7 +159,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) @@ -177,8 +172,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_QueryOperatorConsKeyForChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -186,7 +179,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) diff --git a/x/reward/types/query.pb.gw.go b/x/reward/types/query.pb.gw.go index 67784ea28..17252797c 100644 --- a/x/reward/types/query.pb.gw.go +++ b/x/reward/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -54,14 +52,12 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -69,7 +65,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/slash/types/query.pb.gw.go b/x/slash/types/query.pb.gw.go index 82bdc46cb..9edbdedb6 100644 --- a/x/slash/types/query.pb.gw.go +++ b/x/slash/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -54,14 +52,12 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -69,7 +65,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/taskmanageravs/client/cli/query.go b/x/taskmanageravs/client/cli/query.go new file mode 100644 index 000000000..5fe839231 --- /dev/null +++ b/x/taskmanageravs/client/cli/query.go @@ -0,0 +1,31 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" +) + +// GetQueryCmd returns the cli query commands for this module + +func GetQueryCmd() *cobra.Command { + // Group taskmanageravs queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + return cmd +} diff --git a/x/taskmanageravs/client/cli/query_params.go b/x/taskmanageravs/client/cli/query_params.go new file mode 100644 index 000000000..eb0f5b7b3 --- /dev/null +++ b/x/taskmanageravs/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/taskmanageravs/client/cli/tx.go b/x/taskmanageravs/client/cli/tx.go new file mode 100644 index 000000000..214f8f934 --- /dev/null +++ b/x/taskmanageravs/client/cli/tx.go @@ -0,0 +1,82 @@ +package cli + +import ( + "fmt" + "strconv" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + taskTypes "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/cosmos/cosmos-sdk/client/tx" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + cmd.AddCommand( + RegisterAVSTask(), + ) + return cmd +} + +func RegisterAVSTask() *cobra.Command { + cmd := &cobra.Command{ + Use: "Set task params to taskManager module", + Short: "Set task params to taskManager module", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + taskId, err := strconv.Atoi(args[2]) + if err != nil { + return err + } + + if err != nil { + return err + } + sender := cliCtx.GetFromAddress().String() + + msg := &taskTypes.RegisterAVSTaskReq{ + AVSAddress: sender, + Task: &taskTypes.TaskContractInfo{ + Name: args[0], + MetaInfo: args[1], + TaskContractId: uint64(taskId), + TaskContractAddress: args[3]}, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/taskmanageravs/genesis.go b/x/taskmanageravs/genesis.go new file mode 100644 index 000000000..3c3a1e300 --- /dev/null +++ b/x/taskmanageravs/genesis.go @@ -0,0 +1,23 @@ +package taskmanageravs + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/taskmanageravs/genesis_test.go b/x/taskmanageravs/genesis_test.go new file mode 100644 index 000000000..7862ccff3 --- /dev/null +++ b/x/taskmanageravs/genesis_test.go @@ -0,0 +1,25 @@ +package taskmanageravs_test + +import ( + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.TaskmanageravsKeeper(t) + taskmanageravs.InitGenesis(ctx, *k, genesisState) + got := taskmanageravs.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/taskmanageravs/keeper/abci.go b/x/taskmanageravs/keeper/abci.go new file mode 100644 index 000000000..3a92afd0a --- /dev/null +++ b/x/taskmanageravs/keeper/abci.go @@ -0,0 +1,22 @@ +package keeper + +import ( + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// EndBlock : completed task create events according to the canCompleted blockHeight +func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + ctx.Logger().Info("the blockHeight is:", "height", ctx.BlockHeight()) + task := CreateNewTaskParams{ + TaskCreatedBlock: ctx.BlockHeight(), + } + records, err := k.SetTaskforAvs(ctx, &task) + if err != nil { + panic(err) + } + if len(records) == 0 { + return []abci.ValidatorUpdate{} + } + return []abci.ValidatorUpdate{} +} diff --git a/x/taskmanageravs/keeper/keeper.go b/x/taskmanageravs/keeper/keeper.go new file mode 100644 index 000000000..644a6b8dc --- /dev/null +++ b/x/taskmanageravs/keeper/keeper.go @@ -0,0 +1,45 @@ +package keeper + +import ( + "context" + "fmt" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + avsKeeper tasktype.AvsKeeper + } +) + +func (k Keeper) RegisterAVSTask(ctx context.Context, req *types.RegisterAVSTaskReq) (*types.RegisterAVSTaskResponse, error) { + //TODO implement me + panic("implement me") +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + avsKeeper tasktype.AvsKeeper, +) Keeper { + return Keeper{ + cdc: cdc, + storeKey: storeKey, + avsKeeper: avsKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +type TaskKeeper interface { + RegisterAVSTask(ctx context.Context, req *types.RegisterAVSTaskReq) (*types.RegisterAVSTaskResponse, error) +} diff --git a/x/taskmanageravs/keeper/msg_server.go b/x/taskmanageravs/keeper/msg_server.go new file mode 100644 index 000000000..095b1e519 --- /dev/null +++ b/x/taskmanageravs/keeper/msg_server.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "context" + errorsmod "cosmossdk.io/errors" + "fmt" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type msgServer struct { + Keeper +} + +func (m msgServer) RegisterAVSTask(ctx context.Context, req *types.RegisterAVSTaskReq) (*types.RegisterAVSTaskResponse, error) { + c := sdk.UnwrapSDKContext(ctx) + avs := m.avsKeeper.IsAVS(c, sdk.AccAddress(req.AVSAddress)) + if !avs { + return nil, errorsmod.Wrap(types.ErrNotYetRegistered, fmt.Sprintf("RegisterAVSTask: avs address is %s", req.GetAVSAddress())) + + } + _, err := m.Keeper.SetAvsTaskInfo(c, req) + if err != nil { + return nil, err + } + return nil, nil +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/taskmanageravs/keeper/msg_server_test.go b/x/taskmanageravs/keeper/msg_server_test.go new file mode 100644 index 000000000..7a00923e2 --- /dev/null +++ b/x/taskmanageravs/keeper/msg_server_test.go @@ -0,0 +1,23 @@ +package keeper_test + +import ( + "context" + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.TaskmanageravsKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} + +func TestMsgServer(t *testing.T) { + ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} diff --git a/x/taskmanageravs/keeper/params.go b/x/taskmanageravs/keeper/params.go new file mode 100644 index 000000000..1f44b895b --- /dev/null +++ b/x/taskmanageravs/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + +} diff --git a/x/taskmanageravs/keeper/params_test.go b/x/taskmanageravs/keeper/params_test.go new file mode 100644 index 000000000..8793d3461 --- /dev/null +++ b/x/taskmanageravs/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.TaskmanageravsKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/taskmanageravs/keeper/query.go b/x/taskmanageravs/keeper/query.go new file mode 100644 index 000000000..202ea9ba7 --- /dev/null +++ b/x/taskmanageravs/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/taskmanageravs/keeper/query_params.go b/x/taskmanageravs/keeper/query_params.go new file mode 100644 index 000000000..7a036555f --- /dev/null +++ b/x/taskmanageravs/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/taskmanageravs/keeper/query_params_test.go b/x/taskmanageravs/keeper/query_params_test.go new file mode 100644 index 000000000..89df53f8a --- /dev/null +++ b/x/taskmanageravs/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.TaskmanageravsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/taskmanageravs/keeper/setup_test.go b/x/taskmanageravs/keeper/setup_test.go new file mode 100644 index 000000000..a13fa1ce8 --- /dev/null +++ b/x/taskmanageravs/keeper/setup_test.go @@ -0,0 +1,65 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/suite" + "testing" + + "github.com/evmos/evmos/v14/x/evm/statedb" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + evmosapp "github.com/ExocoreNetwork/exocore/app" + tmtypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" +) + +var s *KeeperTestSuite + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + app *evmosapp.ExocoreApp + address common.Address + accAddress sdk.AccAddress + + validators []stakingtypes.Validator + valSet *tmtypes.ValidatorSet + ethSigner ethtypes.Signer + privKey cryptotypes.PrivKey + signer keyring.Signer + bondDenom string + stateDB *statedb.StateDB + + //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(KeeperTestSuite) + suite.Run(t, s) + + // Run Ginkgo integration tests + RegisterFailHandler(Fail) + RunSpecs(t, "operator module Suite") +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.DoSetupTest() +} diff --git a/x/taskmanageravs/keeper/task.go b/x/taskmanageravs/keeper/task.go new file mode 100644 index 000000000..7c4429b25 --- /dev/null +++ b/x/taskmanageravs/keeper/task.go @@ -0,0 +1,85 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + "fmt" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/google/uuid" + "strings" +) + +func (k *Keeper) SetAvsTaskInfo(ctx sdk.Context, info *types.RegisterAVSTaskReq) (res string, err error) { + + key := strings.Join([]string{strings.ToLower(info.AVSAddress), uuid.NewString()}, "_") + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskInfo) + + bz := k.cdc.MustMarshal(info) + + store.Set([]byte(key), bz) + return key, nil +} + +func (k *Keeper) GetAvsTaskInfo(ctx sdk.Context, index string) (info *types.TaskContractInfo, err error) { + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskInfo) + //key := common.HexToAddress(incentive.Contract) + isExist := store.Has([]byte(index)) + if !isExist { + return nil, errorsmod.Wrap(types.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorInfo: key is %suite", index)) + } + + value := store.Get([]byte(index)) + + ret := types.RegisterAVSTaskReq{} + k.cdc.MustUnmarshal(value, &ret) + return ret.Task, nil +} + +func (k *Keeper) IsExistTask(ctx sdk.Context, index string) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskInfo) + return store.Has([]byte(index)) +} + +func (k Keeper) GetTaskIndex(ctx sdk.Context, addr string) []byte { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAvsTaskIdMap) + return store.Get([]byte(addr)) +} + +func (k Keeper) SetTaskIndex(ctx sdk.Context, addr string, id string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAvsTaskIdMap) + store.Set([]byte(addr), []byte(id)) +} + +func (k Keeper) SetTaskforAvs(ctx sdk.Context, params *CreateNewTaskParams) (recordKey string, err error) { + key := strings.Join([]string{strings.ToLower(params.ContractAddr), uuid.NewString()}, "_") + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskMap) + + task := types.TaskInstance{ + NumberToBeSquared: params.NumberToBeSquared, + QuorumThresholdPercentage: uint64(params.QuorumThresholdPercentage), + TaskCreatedBlock: uint64(params.TaskCreatedBlock), + } + bz := k.cdc.MustMarshal(&task) + + store.Set([]byte(key), bz) + return key, nil +} + +func (k *Keeper) CreateNewTask(ctx sdk.Context, params *CreateNewTaskParams) (bool, error) { + // create a new task struct + k.SetTaskforAvs(ctx, params) + return true, nil +} + +type CreateNewTaskParams struct { + TaskIndex uint32 + NumberToBeSquared uint64 + QuorumThresholdPercentage uint32 + QuorumNumbers []byte + ContractAddr string + TaskCreatedBlock int64 +} diff --git a/x/taskmanageravs/keeper/task_test.go b/x/taskmanageravs/keeper/task_test.go new file mode 100644 index 000000000..b50564166 --- /dev/null +++ b/x/taskmanageravs/keeper/task_test.go @@ -0,0 +1,22 @@ +package keeper_test + +import tasktype "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" + +func (suite *KeeperTestSuite) TestTaskInfo() { + info := &tasktype.RegisterAVSTaskReq{ + AVSAddress: suite.accAddress.String(), + Task: &tasktype.TaskContractInfo{ + Name: "test-task-01", + MetaInfo: "task up", + TaskContractAddress: "0x0000000000000000000000000000000000000901", + TaskContractId: 99, + Status: "active", + }, + } + index, err := suite.app.TaskKeeper.SetAvsTaskInfo(suite.ctx, info) + suite.NoError(err) + + getOperatorInfo, err := suite.app.TaskKeeper.GetAvsTaskInfo(suite.ctx, index) + suite.NoError(err) + suite.Equal(*info.Task, *getOperatorInfo) +} diff --git a/x/taskmanageravs/keeper/utils_test.go b/x/taskmanageravs/keeper/utils_test.go new file mode 100644 index 000000000..7d4ccf445 --- /dev/null +++ b/x/taskmanageravs/keeper/utils_test.go @@ -0,0 +1,207 @@ +package keeper_test + +import ( + "encoding/json" + "golang.org/x/exp/rand" + "time" + + "github.com/ExocoreNetwork/exocore/testutil" + testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" + + evmosapp "github.com/ExocoreNetwork/exocore/app" + "github.com/ExocoreNetwork/exocore/utils" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/crypto/tmhash" + tmtypes "github.com/cometbft/cometbft/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/testutil/mock" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + cmn "github.com/evmos/evmos/v14/precompiles/common" + evmostypes "github.com/evmos/evmos/v14/types" + "github.com/evmos/evmos/v14/x/evm/statedb" + evmtypes "github.com/evmos/evmos/v14/x/evm/types" + inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" +) + +// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts +// that also act as delegators. For simplicity, each validator is bonded with a delegation +// of one consensus engine unit (10^6) in the default token of the simapp from first genesis +// account. A Nop logger is set in SimApp. +func (suite *KeeperTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { + appI, genesisState := evmosapp.SetupTestingApp(cmn.DefaultChainID, nil, true)() + app, ok := appI.(*evmosapp.ExocoreApp) + suite.Require().True(ok) + + // set genesis accounts + authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) + genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) + + validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) + delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) + + bondAmt := sdk.TokensFromConsensusPower(1, evmostypes.PowerReduction) + + for _, val := range valSet.Validators { + pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) + suite.Require().NoError(err) + pkAny, err := codectypes.NewAnyWithValue(pk) + suite.Require().NoError(err) + validator := stakingtypes.Validator{ + OperatorAddress: sdk.ValAddress(val.Address).String(), + ConsensusPubkey: pkAny, + Jailed: false, + Status: stakingtypes.Bonded, + Tokens: bondAmt, + DelegatorShares: sdk.OneDec(), + Description: stakingtypes.Description{}, + UnbondingHeight: int64(0), + UnbondingTime: time.Unix(0, 0).UTC(), + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + MinSelfDelegation: sdk.ZeroInt(), + } + validators = append(validators, validator) + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) + } + suite.validators = validators + + // set validators and delegations + stakingParams := stakingtypes.DefaultParams() + // set bond demon to be aevmos + stakingParams.BondDenom = utils.BaseDenom + stakingGenesis := stakingtypes.NewGenesisState(stakingParams, validators, delegations) + genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) + + totalBondAmt := bondAmt.Add(bondAmt) + totalSupply := sdk.NewCoins() + for _, b := range balances { + // add genesis acc tokens and delegated tokens to total supply + totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(utils.BaseDenom, totalBondAmt))...) + } + + // add bonded amount to bonded pool module account + balances = append(balances, banktypes.Balance{ + Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), + Coins: sdk.Coins{sdk.NewCoin(utils.BaseDenom, totalBondAmt)}, + }) + + // update total supply + bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.SendEnabled{}) + genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) + + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + suite.Require().NoError(err) + + // init chain will set the validator set and initialize the genesis accounts + app.InitChain( + abci.RequestInitChain{ + ChainId: cmn.DefaultChainID, + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: evmosapp.DefaultConsensusParams, + AppStateBytes: stateBytes, + }, + ) + app.Commit() + + // instantiate new header + header := testutil.NewHeader( + 2, + time.Now().UTC(), + cmn.DefaultChainID, + sdk.ConsAddress(validators[0].GetOperator()), + tmhash.Sum([]byte("app")), + tmhash.Sum([]byte("validators")), + ) + + app.BeginBlock(abci.RequestBeginBlock{ + Header: header, + }) + + // need to create UncachedContext when retrieving historical state + suite.ctx = app.BaseApp.NewUncachedContext(false, header) + suite.app = app +} + +func (suite *KeeperTestSuite) DoSetupTest() { + // generate validator private/public key + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + suite.Require().NoError(err) + + privVal2 := mock.NewPV() + pubKey2, err := privVal2.GetPubKey() + suite.Require().NoError(err) + + // create validator set with two validators + validator := tmtypes.NewValidator(pubKey, 1) + validator2 := tmtypes.NewValidator(pubKey2, 2) + suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator, validator2}) + signers := make(map[string]tmtypes.PrivValidator) + signers[pubKey.Address().String()] = privVal + signers[pubKey2.Address().String()] = privVal2 + + // accAddress + pubBz := make([]byte, ed25519.PubKeySize) + pub := &ed25519.PubKey{Key: pubBz} + rand.Read(pub.Key) + suite.accAddress = sdk.AccAddress(pub.Address()) + + // generate genesis account + addr, priv := testutiltx.NewAddrKey() + suite.privKey = priv + suite.address = addr + suite.signer = testutiltx.NewSigner(priv) + + baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0) + + acc := &evmostypes.EthAccount{ + BaseAccount: baseAcc, + CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(), + } + + amount := sdk.TokensFromConsensusPower(5, evmostypes.PowerReduction) + + balance := banktypes.Balance{ + Address: acc.GetAddress().String(), + Coins: sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, amount)), + } + + suite.SetupWithGenesisValSet(suite.valSet, []authtypes.GenesisAccount{acc}, balance) + + // Create StateDB + suite.stateDB = statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes()))) + + // bond denom + stakingParams := suite.app.StakingKeeper.GetParams(suite.ctx) + stakingParams.BondDenom = utils.BaseDenom + suite.bondDenom = stakingParams.BondDenom + err = suite.app.StakingKeeper.SetParams(suite.ctx, stakingParams) + suite.Require().NoError(err) + + suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID()) + + coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(5000000000000000000))) + inflCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(2000000000000000000))) + distrCoins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(3000000000000000000))) + err = suite.app.BankKeeper.MintCoins(suite.ctx, inflationtypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, inflationtypes.ModuleName, authtypes.FeeCollectorName, inflCoins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, inflationtypes.ModuleName, distrtypes.ModuleName, distrCoins) + suite.Require().NoError(err) + +} + +// NextBlock commits the current block and sets up the next block. +func (suite *KeeperTestSuite) NextBlock() { + var err error + suite.ctx, err = testutil.CommitAndCreateNewCtx(suite.ctx, suite.app, time.Second, suite.valSet) + suite.Require().NoError(err) +} diff --git a/x/taskmanageravs/module.go b/x/taskmanageravs/module.go new file mode 100644 index 000000000..e99364fef --- /dev/null +++ b/x/taskmanageravs/module.go @@ -0,0 +1,89 @@ +package taskmanageravs + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/client/cli" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/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 types.ModuleName +} + +func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(amino) +} + +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil { + panic(err) + } +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +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) { + types.RegisterMsgServer(cfg.MsgServer(), &am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// GenerateGenesisState creates a randomized GenState of the inflation module. +func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { +} + +// RegisterStoreDecoder registers a decoder for inflation module's types. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +} + +// WeightedOperations doesn't return any inflation module operation. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} diff --git a/x/taskmanageravs/simulation/helpers.go b/x/taskmanageravs/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/taskmanageravs/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/taskmanageravs/types/codec.go b/x/taskmanageravs/types/codec.go new file mode 100644 index 000000000..3d8d1c99b --- /dev/null +++ b/x/taskmanageravs/types/codec.go @@ -0,0 +1,50 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global erc20 module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding. + // + // The actual codec used for serialization should be provided to modules/erc20 and + // defined at the application level. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino JSON compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +const ( + // Amino names + RegisterAVSTask = "exocore/RegisterAVSTask" +) + +// 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), + &RegisterAVSTaskReq{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec registers the necessary x/restaking_assets_manage interfaces and +// concrete types on the provided LegacyAmino codec. These types are used for +// Amino JSON serialization and EIP-712 compatibility. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&RegisterAVSTaskReq{}, RegisterAVSTask, nil) +} diff --git a/x/taskmanageravs/types/errors.go b/x/taskmanageravs/types/errors.go new file mode 100644 index 000000000..499b6e225 --- /dev/null +++ b/x/taskmanageravs/types/errors.go @@ -0,0 +1,15 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/taskmanageravs module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrNoKeyInTheStore = errorsmod.Register(ModuleName, 0, "there is not the key for in the store") + ErrNotYetRegistered = errorsmod.Register(ModuleName, 1101, "this AVS has not been registered yet") +) diff --git a/x/taskmanageravs/types/expected_keepers.go b/x/taskmanageravs/types/expected_keepers.go new file mode 100644 index 000000000..b4338ccc1 --- /dev/null +++ b/x/taskmanageravs/types/expected_keepers.go @@ -0,0 +1,27 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} +type AvsKeeper struct{} + +func (k AvsKeeper) IsAVS(sdk.Context, sdk.AccAddress) bool { + return true +} + +func (k AvsKeeper) getAvsAddress(sdk.Context, sdk.AccAddress) string { + return "0x00000000000000000000000000000000000009999" +} diff --git a/x/taskmanageravs/types/genesis.go b/x/taskmanageravs/types/genesis.go new file mode 100644 index 000000000..c41be0742 --- /dev/null +++ b/x/taskmanageravs/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/taskmanageravs/types/genesis.pb.go b/x/taskmanageravs/types/genesis.pb.go new file mode 100644 index 000000000..e85fb70cc --- /dev/null +++ b/x/taskmanageravs/types/genesis.pb.go @@ -0,0 +1,323 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/taskmanageravs/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the taskmanageravs module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_e135dd7e592266ea, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "exocore.taskmanageravs.GenesisState") +} + +func init() { + proto.RegisterFile("exocore/taskmanageravs/genesis.proto", fileDescriptor_e135dd7e592266ea) +} + +var fileDescriptor_e135dd7e592266ea = []byte{ + // 204 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x49, 0x2c, 0xce, 0xce, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0x2d, 0x4a, + 0x2c, 0x2b, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x83, 0xaa, 0xd2, 0x43, 0x55, 0x25, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa2, + 0x0f, 0x62, 0x41, 0x54, 0x4b, 0x29, 0xe3, 0x30, 0xb3, 0x20, 0xb1, 0x28, 0x31, 0x17, 0x6a, 0xa4, + 0x92, 0x0f, 0x17, 0x8f, 0x3b, 0xc4, 0x8e, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x1b, 0x2e, 0x36, + 0x88, 0xbc, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x9c, 0x1e, 0x76, 0x3b, 0xf5, 0x02, 0xc0, + 0xaa, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x71, 0x0a, 0x3a, 0xf1, 0x48, 0x8e, + 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, + 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x8b, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, + 0xfc, 0x5c, 0x7d, 0x57, 0x88, 0x89, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0xfa, 0x30, 0x67, + 0x56, 0xa0, 0x3b, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x50, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xe6, 0x36, 0x08, 0xc7, 0x23, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/taskmanageravs/types/genesis_test.go b/x/taskmanageravs/types/genesis_test.go new file mode 100644 index 000000000..44207e493 --- /dev/null +++ b/x/taskmanageravs/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/types" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + } { + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} \ No newline at end of file diff --git a/x/taskmanageravs/types/keys.go b/x/taskmanageravs/types/keys.go new file mode 100644 index 000000000..d9cfac5e0 --- /dev/null +++ b/x/taskmanageravs/types/keys.go @@ -0,0 +1,32 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "taskmanageravs" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_taskmanageravs" +) + +const ( + prefixAVSTaskInfo = iota + 1 + prefixAVSTaskMap + PrefixAvsTaskIdMap +) + +var ( + // KeyPrefixAVSTaskInfo key-value: avsAddr->AVSTaskInfo + KeyPrefixAVSTaskInfo = []byte{prefixAVSTaskInfo} + KeyPrefixAVSTaskMap = []byte{prefixAVSTaskMap} + KeyPrefixAvsTaskIdMap = []byte{PrefixAvsTaskIdMap} +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/taskmanageravs/types/msg.go b/x/taskmanageravs/types/msg.go new file mode 100644 index 000000000..830dfcad6 --- /dev/null +++ b/x/taskmanageravs/types/msg.go @@ -0,0 +1,29 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = &RegisterAVSTaskReq{} +) + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *RegisterAVSTaskReq) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(m.AVSAddress) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check of the provided data +func (m *RegisterAVSTaskReq) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.AVSAddress); err != nil { + return errorsmod.Wrap(err, "invalid address") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (m *RegisterAVSTaskReq) GetSignBytes() []byte { + return nil +} diff --git a/x/taskmanageravs/types/params.go b/x/taskmanageravs/types/params.go new file mode 100644 index 000000000..52a8a059f --- /dev/null +++ b/x/taskmanageravs/types/params.go @@ -0,0 +1,47 @@ +package types + +import ( + + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + + + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams( +) Params { + return Params{ + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + ) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/taskmanageravs/types/params.pb.go b/x/taskmanageravs/types/params.pb.go new file mode 100644 index 000000000..257c0c310 --- /dev/null +++ b/x/taskmanageravs/types/params.pb.go @@ -0,0 +1,267 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/taskmanageravs/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_9851cd4b575e9d94, []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 init() { + proto.RegisterType((*Params)(nil), "exocore.taskmanageravs.Params") +} + +func init() { + proto.RegisterFile("exocore/taskmanageravs/params.proto", fileDescriptor_9851cd4b575e9d94) +} + +var fileDescriptor_9851cd4b575e9d94 = []byte{ + // 162 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x49, 0x2c, 0xce, 0xce, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0x2d, 0x4a, + 0x2c, 0x2b, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x83, 0x2a, 0xd2, 0x43, 0x55, 0x24, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa2, 0x0f, + 0x62, 0x41, 0x54, 0x2b, 0xf1, 0x71, 0xb1, 0x05, 0x80, 0x75, 0x5b, 0xb1, 0xcc, 0x58, 0x20, 0xcf, + 0xe0, 0x14, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x16, 0xe9, 0x99, + 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xae, 0x10, 0x2b, 0xfc, 0x52, 0x4b, 0xca, + 0xf3, 0x8b, 0xb2, 0xf5, 0x61, 0xce, 0xaa, 0x40, 0x77, 0x58, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0xd8, 0x2a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6, 0xbc, 0x92, 0x25, 0xbf, 0x00, + 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 + 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 + 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 { + 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/taskmanageravs/types/query.pb.go b/x/taskmanageravs/types/query.pb.go new file mode 100644 index 000000000..447492d5d --- /dev/null +++ b/x/taskmanageravs/types/query.pb.go @@ -0,0 +1,540 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/taskmanageravs/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a379a79b4cdb497c, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_a379a79b4cdb497c, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "exocore.taskmanageravs.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "exocore.taskmanageravs.QueryParamsResponse") +} + +func init() { + proto.RegisterFile("exocore/taskmanageravs/query.proto", fileDescriptor_a379a79b4cdb497c) +} + +var fileDescriptor_a379a79b4cdb497c = []byte{ + // 312 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xb1, 0x4b, 0x3b, 0x31, + 0x14, 0xc7, 0x2f, 0x3f, 0x7e, 0x76, 0x38, 0xb7, 0xb3, 0x88, 0x14, 0x89, 0x72, 0x2e, 0x52, 0xf1, + 0x42, 0x2b, 0x82, 0x83, 0x53, 0xc1, 0x55, 0xb4, 0x6e, 0x6e, 0xef, 0xca, 0x23, 0x1e, 0xf5, 0xf2, + 0xd2, 0x24, 0xad, 0xed, 0xea, 0x5f, 0x20, 0xb8, 0x38, 0xfb, 0xd7, 0x74, 0x2c, 0xb8, 0x38, 0x89, + 0xb4, 0xfe, 0x21, 0xd2, 0xcb, 0x2d, 0x55, 0x4f, 0xdc, 0xc2, 0xcb, 0xe7, 0xfb, 0xc9, 0x37, 0x2f, + 0x8c, 0x71, 0x4c, 0x3d, 0x32, 0x28, 0x1c, 0xd8, 0x7e, 0x0e, 0x0a, 0x24, 0x1a, 0x18, 0x59, 0x31, + 0x18, 0xa2, 0x99, 0x24, 0xda, 0x90, 0xa3, 0x68, 0xb3, 0x64, 0x92, 0x55, 0xa6, 0x51, 0x97, 0x24, + 0xa9, 0x40, 0xc4, 0xf2, 0xe4, 0xe9, 0xc6, 0xb6, 0x24, 0x92, 0xb7, 0x28, 0x40, 0x67, 0x02, 0x94, + 0x22, 0x07, 0x2e, 0x23, 0x65, 0xcb, 0xdb, 0x66, 0x8f, 0x6c, 0x4e, 0x56, 0xa4, 0x60, 0xd1, 0x3f, + 0x22, 0x46, 0xad, 0x14, 0x1d, 0xb4, 0x84, 0x06, 0x99, 0xa9, 0x02, 0x2e, 0xd9, 0xbd, 0x8a, 0x6e, + 0x1a, 0x0c, 0xe4, 0xa5, 0x30, 0xae, 0x87, 0xd1, 0xe5, 0x52, 0x73, 0x51, 0x0c, 0xbb, 0x38, 0x18, + 0xa2, 0x75, 0xf1, 0x55, 0xb8, 0xb1, 0x32, 0xb5, 0x9a, 0x94, 0xc5, 0xe8, 0x34, 0xac, 0xf9, 0xf0, + 0x16, 0xdb, 0x65, 0xfb, 0xeb, 0x6d, 0x9e, 0xfc, 0xfc, 0xb5, 0xc4, 0xe7, 0x3a, 0xff, 0xa7, 0x6f, + 0x3b, 0x41, 0xb7, 0xcc, 0xb4, 0x9f, 0x59, 0xb8, 0x56, 0x58, 0xa3, 0x27, 0x16, 0xd6, 0x3c, 0x12, + 0x35, 0xab, 0x14, 0xdf, 0x5b, 0x35, 0x0e, 0xfe, 0xc4, 0xfa, 0xae, 0xf1, 0xf1, 0xfd, 0xcb, 0xc7, + 0xe3, 0x3f, 0x11, 0x1d, 0x8a, 0x33, 0x1f, 0x3a, 0x47, 0x77, 0x47, 0xa6, 0x2f, 0x7e, 0xdd, 0x4a, + 0xa7, 0x3b, 0x9d, 0x73, 0x36, 0x9b, 0x73, 0xf6, 0x3e, 0xe7, 0xec, 0x61, 0xc1, 0x83, 0xd9, 0x82, + 0x07, 0xaf, 0x0b, 0x1e, 0x5c, 0x9f, 0xc8, 0xcc, 0xdd, 0x0c, 0xd3, 0xa4, 0x47, 0x79, 0x95, 0x72, + 0xfc, 0x55, 0xea, 0x26, 0x1a, 0x6d, 0x5a, 0x2b, 0x56, 0x7d, 0xf4, 0x19, 0x00, 0x00, 0xff, 0xff, + 0x96, 0x51, 0x46, 0x11, 0x2d, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.taskmanageravs.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.taskmanageravs.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.taskmanageravs.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/taskmanageravs/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/taskmanageravs/types/query.pb.gw.go b/x/taskmanageravs/types/query.pb.gw.go new file mode 100644 index 000000000..89c703a8c --- /dev/null +++ b/x/taskmanageravs/types/query.pb.gw.go @@ -0,0 +1,152 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: exocore/taskmanageravs/query.proto + +/* +Package types is a reverse proxy. +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "taskmanageravs", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) \ No newline at end of file diff --git a/x/taskmanageravs/types/tx.pb.go b/x/taskmanageravs/types/tx.pb.go new file mode 100644 index 000000000..c8b01e35e --- /dev/null +++ b/x/taskmanageravs/types/tx.pb.go @@ -0,0 +1,1684 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/taskmanageravs/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type TaskContractInfo struct { + TaskContractId uint64 `protobuf:"varint,1,opt,name=TaskContractId,proto3" json:"TaskContractId,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` + MetaInfo string `protobuf:"bytes,3,opt,name=MetaInfo,proto3" json:"MetaInfo,omitempty"` + TaskContractAddress string `protobuf:"bytes,4,opt,name=TaskContractAddress,proto3" json:"TaskContractAddress,omitempty"` + Status string `protobuf:"bytes,5,opt,name=Status,proto3" json:"Status,omitempty"` + SourceCode string `protobuf:"bytes,6,opt,name=sourceCode,proto3" json:"sourceCode,omitempty"` +} + +func (m *TaskContractInfo) Reset() { *m = TaskContractInfo{} } +func (m *TaskContractInfo) String() string { return proto.CompactTextString(m) } +func (*TaskContractInfo) ProtoMessage() {} +func (*TaskContractInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c8692217960aa4f9, []int{0} +} +func (m *TaskContractInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TaskContractInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TaskContractInfo.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 *TaskContractInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_TaskContractInfo.Merge(m, src) +} +func (m *TaskContractInfo) XXX_Size() int { + return m.Size() +} +func (m *TaskContractInfo) XXX_DiscardUnknown() { + xxx_messageInfo_TaskContractInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_TaskContractInfo proto.InternalMessageInfo + +func (m *TaskContractInfo) GetTaskContractId() uint64 { + if m != nil { + return m.TaskContractId + } + return 0 +} + +func (m *TaskContractInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *TaskContractInfo) GetMetaInfo() string { + if m != nil { + return m.MetaInfo + } + return "" +} + +func (m *TaskContractInfo) GetTaskContractAddress() string { + if m != nil { + return m.TaskContractAddress + } + return "" +} + +func (m *TaskContractInfo) GetStatus() string { + if m != nil { + return m.Status + } + return "" +} + +func (m *TaskContractInfo) GetSourceCode() string { + if m != nil { + return m.SourceCode + } + return "" +} + +type TaskInstance struct { + TaskId string `protobuf:"bytes,1,opt,name=TaskId,proto3" json:"TaskId,omitempty"` + NumberToBeSquared uint64 `protobuf:"varint,2,opt,name=numberToBeSquared,proto3" json:"numberToBeSquared,omitempty"` + TaskCreatedBlock uint64 `protobuf:"varint,3,opt,name=taskCreatedBlock,proto3" json:"taskCreatedBlock,omitempty"` + QuorumNumbers string `protobuf:"bytes,4,opt,name=quorumNumbers,proto3" json:"quorumNumbers,omitempty"` + // each task needs to reach at least thresholdPercentage of operator signatures. + QuorumThresholdPercentage uint64 `protobuf:"varint,5,opt,name=quorumThresholdPercentage,proto3" json:"quorumThresholdPercentage,omitempty"` + ContractAddr string `protobuf:"bytes,6,opt,name=ContractAddr,proto3" json:"ContractAddr,omitempty"` +} + +func (m *TaskInstance) Reset() { *m = TaskInstance{} } +func (m *TaskInstance) String() string { return proto.CompactTextString(m) } +func (*TaskInstance) ProtoMessage() {} +func (*TaskInstance) Descriptor() ([]byte, []int) { + return fileDescriptor_c8692217960aa4f9, []int{1} +} +func (m *TaskInstance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TaskInstance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TaskInstance.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 *TaskInstance) XXX_Merge(src proto.Message) { + xxx_messageInfo_TaskInstance.Merge(m, src) +} +func (m *TaskInstance) XXX_Size() int { + return m.Size() +} +func (m *TaskInstance) XXX_DiscardUnknown() { + xxx_messageInfo_TaskInstance.DiscardUnknown(m) +} + +var xxx_messageInfo_TaskInstance proto.InternalMessageInfo + +func (m *TaskInstance) GetTaskId() string { + if m != nil { + return m.TaskId + } + return "" +} + +func (m *TaskInstance) GetNumberToBeSquared() uint64 { + if m != nil { + return m.NumberToBeSquared + } + return 0 +} + +func (m *TaskInstance) GetTaskCreatedBlock() uint64 { + if m != nil { + return m.TaskCreatedBlock + } + return 0 +} + +func (m *TaskInstance) GetQuorumNumbers() string { + if m != nil { + return m.QuorumNumbers + } + return "" +} + +func (m *TaskInstance) GetQuorumThresholdPercentage() uint64 { + if m != nil { + return m.QuorumThresholdPercentage + } + return 0 +} + +func (m *TaskInstance) GetContractAddr() string { + if m != nil { + return m.ContractAddr + } + return "" +} + +type TaskManagerInfo struct { + TaskManager map[string]*TaskContractInfo `protobuf:"bytes,1,rep,name=TaskManager,proto3" json:"TaskManager,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *TaskManagerInfo) Reset() { *m = TaskManagerInfo{} } +func (m *TaskManagerInfo) String() string { return proto.CompactTextString(m) } +func (*TaskManagerInfo) ProtoMessage() {} +func (*TaskManagerInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c8692217960aa4f9, []int{2} +} +func (m *TaskManagerInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TaskManagerInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TaskManagerInfo.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 *TaskManagerInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_TaskManagerInfo.Merge(m, src) +} +func (m *TaskManagerInfo) XXX_Size() int { + return m.Size() +} +func (m *TaskManagerInfo) XXX_DiscardUnknown() { + xxx_messageInfo_TaskManagerInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_TaskManagerInfo proto.InternalMessageInfo + +func (m *TaskManagerInfo) GetTaskManager() map[string]*TaskContractInfo { + if m != nil { + return m.TaskManager + } + return nil +} + +type RegisterAVSTaskReq struct { + AVSAddress string `protobuf:"bytes,1,opt,name=AVSAddress,proto3" json:"AVSAddress,omitempty"` + Task *TaskContractInfo `protobuf:"bytes,2,opt,name=task,proto3" json:"task,omitempty"` +} + +func (m *RegisterAVSTaskReq) Reset() { *m = RegisterAVSTaskReq{} } +func (m *RegisterAVSTaskReq) String() string { return proto.CompactTextString(m) } +func (*RegisterAVSTaskReq) ProtoMessage() {} +func (*RegisterAVSTaskReq) Descriptor() ([]byte, []int) { + return fileDescriptor_c8692217960aa4f9, []int{3} +} +func (m *RegisterAVSTaskReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterAVSTaskReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterAVSTaskReq.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 *RegisterAVSTaskReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterAVSTaskReq.Merge(m, src) +} +func (m *RegisterAVSTaskReq) XXX_Size() int { + return m.Size() +} +func (m *RegisterAVSTaskReq) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterAVSTaskReq.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterAVSTaskReq proto.InternalMessageInfo + +func (m *RegisterAVSTaskReq) GetAVSAddress() string { + if m != nil { + return m.AVSAddress + } + return "" +} + +func (m *RegisterAVSTaskReq) GetTask() *TaskContractInfo { + if m != nil { + return m.Task + } + return nil +} + +type RegisterAVSTaskResponse struct { +} + +func (m *RegisterAVSTaskResponse) Reset() { *m = RegisterAVSTaskResponse{} } +func (m *RegisterAVSTaskResponse) String() string { return proto.CompactTextString(m) } +func (*RegisterAVSTaskResponse) ProtoMessage() {} +func (*RegisterAVSTaskResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c8692217960aa4f9, []int{4} +} +func (m *RegisterAVSTaskResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterAVSTaskResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterAVSTaskResponse.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 *RegisterAVSTaskResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterAVSTaskResponse.Merge(m, src) +} +func (m *RegisterAVSTaskResponse) XXX_Size() int { + return m.Size() +} +func (m *RegisterAVSTaskResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterAVSTaskResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterAVSTaskResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*TaskContractInfo)(nil), "exocore.taskmanageravs.TaskContractInfo") + proto.RegisterType((*TaskInstance)(nil), "exocore.taskmanageravs.TaskInstance") + proto.RegisterType((*TaskManagerInfo)(nil), "exocore.taskmanageravs.TaskManagerInfo") + proto.RegisterMapType((map[string]*TaskContractInfo)(nil), "exocore.taskmanageravs.TaskManagerInfo.TaskManagerEntry") + proto.RegisterType((*RegisterAVSTaskReq)(nil), "exocore.taskmanageravs.RegisterAVSTaskReq") + proto.RegisterType((*RegisterAVSTaskResponse)(nil), "exocore.taskmanageravs.RegisterAVSTaskResponse") +} + +func init() { proto.RegisterFile("exocore/taskmanageravs/tx.proto", fileDescriptor_c8692217960aa4f9) } + +var fileDescriptor_c8692217960aa4f9 = []byte{ + // 524 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x41, 0x6f, 0x12, 0x41, + 0x14, 0x66, 0x61, 0x4b, 0xec, 0xa3, 0x5a, 0x1c, 0x93, 0xba, 0xe5, 0xb0, 0x92, 0x8d, 0x31, 0xa4, + 0x31, 0x60, 0xf0, 0x42, 0x4c, 0x63, 0x02, 0xa4, 0x87, 0x1e, 0x20, 0x66, 0x20, 0x3d, 0xf4, 0x36, + 0xec, 0x3e, 0xa1, 0x01, 0x66, 0x60, 0x66, 0xb6, 0xc2, 0x3f, 0xf0, 0xe8, 0xcf, 0xf2, 0xd8, 0x83, + 0x89, 0x1e, 0x0d, 0xfc, 0x11, 0xb3, 0xb3, 0x60, 0x16, 0xb6, 0x35, 0xf6, 0xb6, 0xef, 0x9b, 0x6f, + 0xbe, 0x6f, 0xdf, 0x9b, 0x2f, 0x0f, 0x5e, 0xe1, 0x42, 0xf8, 0x42, 0x62, 0x4d, 0x33, 0x35, 0x9e, + 0x32, 0xce, 0x86, 0x28, 0xd9, 0xad, 0xaa, 0xe9, 0x45, 0x75, 0x26, 0x85, 0x16, 0xe4, 0x64, 0x43, + 0xa8, 0xee, 0x12, 0xbc, 0x1f, 0x16, 0x14, 0xfb, 0x4c, 0x8d, 0xdb, 0x82, 0x6b, 0xc9, 0x7c, 0x7d, + 0xc9, 0x3f, 0x0b, 0xf2, 0x06, 0x9e, 0xed, 0x60, 0x81, 0x63, 0x95, 0xad, 0x8a, 0x4d, 0xf7, 0x50, + 0x42, 0xc0, 0xee, 0xb2, 0x29, 0x3a, 0xd9, 0xb2, 0x55, 0x39, 0xa4, 0xe6, 0x9b, 0x94, 0xe0, 0x49, + 0x07, 0x35, 0x8b, 0x74, 0x9c, 0x9c, 0xc1, 0xff, 0xd6, 0xe4, 0x1d, 0xbc, 0x48, 0x2a, 0x34, 0x83, + 0x40, 0xa2, 0x52, 0x8e, 0x6d, 0x68, 0xf7, 0x1d, 0x91, 0x13, 0xc8, 0xf7, 0x34, 0xd3, 0xa1, 0x72, + 0x0e, 0x0c, 0x69, 0x53, 0x11, 0x17, 0x40, 0x89, 0x50, 0xfa, 0xd8, 0x16, 0x01, 0x3a, 0x79, 0x73, + 0x96, 0x40, 0xbc, 0xaf, 0x59, 0x38, 0x8a, 0xf4, 0x2e, 0xb9, 0xd2, 0x8c, 0xfb, 0x18, 0x09, 0x99, + 0x3a, 0x6e, 0xe5, 0x90, 0x6e, 0x2a, 0xf2, 0x16, 0x9e, 0xf3, 0x70, 0x3a, 0x40, 0xd9, 0x17, 0x2d, + 0xec, 0xcd, 0x43, 0x26, 0x31, 0x30, 0xfd, 0xd8, 0x34, 0x7d, 0x40, 0xce, 0xa0, 0x18, 0xcd, 0xaf, + 0x2d, 0x91, 0x69, 0x0c, 0x5a, 0x13, 0xe1, 0x8f, 0x4d, 0x93, 0x36, 0x4d, 0xe1, 0xe4, 0x35, 0x3c, + 0x9d, 0x87, 0x42, 0x86, 0xd3, 0xae, 0x91, 0xd9, 0xb6, 0xb9, 0x0b, 0x92, 0x73, 0x38, 0x8d, 0x81, + 0xfe, 0x48, 0xa2, 0x1a, 0x89, 0x49, 0xf0, 0x09, 0xa5, 0x8f, 0x5c, 0xb3, 0x21, 0x9a, 0x9e, 0x6d, + 0xfa, 0x30, 0x81, 0x78, 0x70, 0x94, 0x9c, 0xd8, 0x66, 0x10, 0x3b, 0x98, 0xf7, 0xd3, 0x82, 0xe3, + 0xa8, 0xd9, 0x4e, 0xfc, 0xe8, 0xe6, 0x21, 0xae, 0xa1, 0x90, 0x80, 0x1c, 0xab, 0x9c, 0xab, 0x14, + 0xea, 0x8d, 0xea, 0xfd, 0x19, 0xa9, 0xee, 0xdd, 0x4e, 0xd6, 0x17, 0x5c, 0xcb, 0x25, 0x4d, 0x8a, + 0x95, 0x46, 0x71, 0xa0, 0x92, 0x04, 0x52, 0x84, 0xdc, 0x18, 0x97, 0x9b, 0xd1, 0x47, 0x9f, 0xe4, + 0x23, 0x1c, 0xdc, 0xb2, 0x49, 0x18, 0x67, 0xa7, 0x50, 0xaf, 0xfc, 0xcb, 0x3b, 0x99, 0x4d, 0x1a, + 0x5f, 0xfb, 0x90, 0x6d, 0x58, 0x9e, 0x04, 0x42, 0x71, 0x78, 0xa3, 0x34, 0xca, 0xe6, 0x55, 0x2f, + 0x62, 0x52, 0x9c, 0x47, 0xd1, 0x68, 0x5e, 0xf5, 0xb6, 0xd9, 0x8a, 0x2d, 0x13, 0x08, 0x39, 0x07, + 0x3b, 0xf2, 0x78, 0xb4, 0xb1, 0xb9, 0xe5, 0x9d, 0xc2, 0xcb, 0x94, 0xa7, 0x9a, 0x09, 0xae, 0xb0, + 0x1e, 0x42, 0xae, 0xa3, 0x86, 0x84, 0xc3, 0xf1, 0x1e, 0x83, 0x9c, 0x3d, 0x64, 0x92, 0xfe, 0xfd, + 0x52, 0xed, 0xbf, 0xb9, 0xb1, 0x6d, 0x8b, 0x7e, 0x5f, 0xb9, 0xd6, 0xdd, 0xca, 0xb5, 0x7e, 0xaf, + 0x5c, 0xeb, 0xdb, 0xda, 0xcd, 0xdc, 0xad, 0xdd, 0xcc, 0xaf, 0xb5, 0x9b, 0xb9, 0x6e, 0x0c, 0x6f, + 0xf4, 0x28, 0x1c, 0x54, 0x7d, 0x31, 0xad, 0x5d, 0xc4, 0xa2, 0x5d, 0xd4, 0x5f, 0x84, 0x1c, 0xd7, + 0xb6, 0xeb, 0x62, 0x91, 0x5a, 0x18, 0xcb, 0x19, 0xaa, 0x41, 0xde, 0x2c, 0x8d, 0xf7, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0xe9, 0xc5, 0x19, 0x8e, 0x57, 0x04, 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 { + RegisterAVSTask(ctx context.Context, in *RegisterAVSTaskReq, opts ...grpc.CallOption) (*RegisterAVSTaskResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterAVSTask(ctx context.Context, in *RegisterAVSTaskReq, opts ...grpc.CallOption) (*RegisterAVSTaskResponse, error) { + out := new(RegisterAVSTaskResponse) + err := c.cc.Invoke(ctx, "/exocore.taskmanageravs.Msg/RegisterAVSTask", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + RegisterAVSTask(context.Context, *RegisterAVSTaskReq) (*RegisterAVSTaskResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterAVSTask(ctx context.Context, req *RegisterAVSTaskReq) (*RegisterAVSTaskResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterAVSTask not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterAVSTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterAVSTaskReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterAVSTask(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.taskmanageravs.Msg/RegisterAVSTask", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterAVSTask(ctx, req.(*RegisterAVSTaskReq)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.taskmanageravs.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterAVSTask", + Handler: _Msg_RegisterAVSTask_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/taskmanageravs/tx.proto", +} + +func (m *TaskContractInfo) 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 *TaskContractInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TaskContractInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SourceCode) > 0 { + i -= len(m.SourceCode) + copy(dAtA[i:], m.SourceCode) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceCode))) + i-- + dAtA[i] = 0x32 + } + if len(m.Status) > 0 { + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = encodeVarintTx(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0x2a + } + if len(m.TaskContractAddress) > 0 { + i -= len(m.TaskContractAddress) + copy(dAtA[i:], m.TaskContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.TaskContractAddress))) + i-- + dAtA[i] = 0x22 + } + 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] = 0x1a + } + 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] = 0x12 + } + if m.TaskContractId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TaskContractId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TaskInstance) 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 *TaskInstance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TaskInstance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddr) > 0 { + i -= len(m.ContractAddr) + copy(dAtA[i:], m.ContractAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddr))) + i-- + dAtA[i] = 0x32 + } + if m.QuorumThresholdPercentage != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.QuorumThresholdPercentage)) + i-- + dAtA[i] = 0x28 + } + if len(m.QuorumNumbers) > 0 { + i -= len(m.QuorumNumbers) + copy(dAtA[i:], m.QuorumNumbers) + i = encodeVarintTx(dAtA, i, uint64(len(m.QuorumNumbers))) + i-- + dAtA[i] = 0x22 + } + if m.TaskCreatedBlock != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TaskCreatedBlock)) + i-- + dAtA[i] = 0x18 + } + if m.NumberToBeSquared != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NumberToBeSquared)) + i-- + dAtA[i] = 0x10 + } + if len(m.TaskId) > 0 { + i -= len(m.TaskId) + copy(dAtA[i:], m.TaskId) + i = encodeVarintTx(dAtA, i, uint64(len(m.TaskId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TaskManagerInfo) 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 *TaskManagerInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TaskManagerInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TaskManager) > 0 { + for k := range m.TaskManager { + v := m.TaskManager[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] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RegisterAVSTaskReq) 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 *RegisterAVSTaskReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterAVSTaskReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Task != nil { + { + size, err := m.Task.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.AVSAddress) > 0 { + i -= len(m.AVSAddress) + copy(dAtA[i:], m.AVSAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.AVSAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RegisterAVSTaskResponse) 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 *RegisterAVSTaskResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterAVSTaskResponse) 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 *TaskContractInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TaskContractId != 0 { + n += 1 + sovTx(uint64(m.TaskContractId)) + } + 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.TaskContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Status) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SourceCode) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *TaskInstance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TaskId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.NumberToBeSquared != 0 { + n += 1 + sovTx(uint64(m.NumberToBeSquared)) + } + if m.TaskCreatedBlock != 0 { + n += 1 + sovTx(uint64(m.TaskCreatedBlock)) + } + l = len(m.QuorumNumbers) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.QuorumThresholdPercentage != 0 { + n += 1 + sovTx(uint64(m.QuorumThresholdPercentage)) + } + l = len(m.ContractAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *TaskManagerInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TaskManager) > 0 { + for k, v := range m.TaskManager { + _ = 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 *RegisterAVSTaskReq) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AVSAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Task != nil { + l = m.Task.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *RegisterAVSTaskResponse) 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 *TaskContractInfo) 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: TaskContractInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TaskContractInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TaskContractId", wireType) + } + m.TaskContractId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TaskContractId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MetaInfo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MetaInfo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TaskContractAddress", 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.TaskContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", 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.Status = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceCode", 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.SourceCode = 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 *TaskInstance) 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: TaskInstance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TaskInstance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TaskId", 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.TaskId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberToBeSquared", wireType) + } + m.NumberToBeSquared = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberToBeSquared |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TaskCreatedBlock", wireType) + } + m.TaskCreatedBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TaskCreatedBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuorumNumbers", 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.QuorumNumbers = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuorumThresholdPercentage", wireType) + } + m.QuorumThresholdPercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuorumThresholdPercentage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddr", 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.ContractAddr = 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 *TaskManagerInfo) 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: TaskManagerInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TaskManagerInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TaskManager", 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.TaskManager == nil { + m.TaskManager = make(map[string]*TaskContractInfo) + } + var mapkey string + var mapvalue *TaskContractInfo + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthTx + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthTx + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthTx + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthTx + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &TaskContractInfo{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.TaskManager[mapkey] = mapvalue + 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 *RegisterAVSTaskReq) 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: RegisterAVSTaskReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterAVSTaskReq: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AVSAddress", 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.AVSAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Task", 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.Task == nil { + m.Task = &TaskContractInfo{} + } + if err := m.Task.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 *RegisterAVSTaskResponse) 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: RegisterAVSTaskResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterAVSTaskResponse: 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") +) \ No newline at end of file diff --git a/x/taskmanageravs/types/types.go b/x/taskmanageravs/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/taskmanageravs/types/types.go @@ -0,0 +1 @@ +package types