From 238b8c9d000726cf36941641b5857c0a69ab95d2 Mon Sep 17 00:00:00 2001 From: trestinlsd Date: Mon, 25 Mar 2024 08:46:03 +0800 Subject: [PATCH] feat:Add implementation for task module --- precompiles/avsTask/abi.json | 31 + precompiles/avsTask/avsTask.sol | 90 + precompiles/avsTask/error.go | 8 + precompiles/avsTask/events.go | 54 + precompiles/avsTask/methods.go | 71 + precompiles/avsTask/parser.go | 27 + precompiles/avsTask/setup_test.go | 36 + precompiles/avsTask/task.go | 128 ++ precompiles/avsTask/task_test.go | 150 ++ proto/exocore/taskmanageravs/genesis.proto | 12 + proto/exocore/taskmanageravs/params.proto | 12 + proto/exocore/taskmanageravs/query.proto | 26 + proto/exocore/taskmanageravs/tx.proto | 42 + testutil/abci.go | 12 +- testutil/keeper/taskmanageravs.go | 52 + testutil/tx/eip712.go | 3 +- testutil/utils.go | 6 +- x/taskmanageravs/client/cli/query.go | 31 + x/taskmanageravs/client/cli/query_params.go | 36 + x/taskmanageravs/client/cli/tx.go | 82 + x/taskmanageravs/genesis.go | 23 + x/taskmanageravs/genesis_test.go | 25 + x/taskmanageravs/keeper/abci.go | 22 + x/taskmanageravs/keeper/keeper.go | 45 + x/taskmanageravs/keeper/msg_server.go | 35 + x/taskmanageravs/keeper/msg_server_test.go | 23 + x/taskmanageravs/keeper/params.go | 16 + x/taskmanageravs/keeper/params_test.go | 18 + x/taskmanageravs/keeper/query.go | 7 + x/taskmanageravs/keeper/query_params.go | 19 + x/taskmanageravs/keeper/query_params_test.go | 21 + x/taskmanageravs/keeper/setup_test.go | 65 + x/taskmanageravs/keeper/task.go | 85 + x/taskmanageravs/keeper/task_test.go | 22 + x/taskmanageravs/keeper/utils_test.go | 207 +++ x/taskmanageravs/module.go | 89 + x/taskmanageravs/types/codec.go | 50 + x/taskmanageravs/types/errors.go | 15 + x/taskmanageravs/types/expected_keepers.go | 27 + x/taskmanageravs/types/genesis.go | 24 + x/taskmanageravs/types/genesis.pb.go | 323 ++++ x/taskmanageravs/types/genesis_test.go | 41 + x/taskmanageravs/types/keys.go | 32 + x/taskmanageravs/types/msg.go | 29 + x/taskmanageravs/types/params.go | 47 + x/taskmanageravs/types/params.pb.go | 267 +++ x/taskmanageravs/types/query.pb.go | 540 ++++++ x/taskmanageravs/types/query.pb.gw.go | 153 ++ x/taskmanageravs/types/tx.pb.go | 1684 ++++++++++++++++++ x/taskmanageravs/types/types.go | 1 + 50 files changed, 4850 insertions(+), 14 deletions(-) create mode 100644 precompiles/avsTask/abi.json create mode 100644 precompiles/avsTask/avsTask.sol create mode 100644 precompiles/avsTask/error.go create mode 100644 precompiles/avsTask/events.go create mode 100644 precompiles/avsTask/methods.go create mode 100644 precompiles/avsTask/parser.go create mode 100644 precompiles/avsTask/setup_test.go create mode 100644 precompiles/avsTask/task.go create mode 100644 precompiles/avsTask/task_test.go create mode 100644 proto/exocore/taskmanageravs/genesis.proto create mode 100644 proto/exocore/taskmanageravs/params.proto create mode 100644 proto/exocore/taskmanageravs/query.proto create mode 100644 proto/exocore/taskmanageravs/tx.proto create mode 100644 testutil/keeper/taskmanageravs.go create mode 100644 x/taskmanageravs/client/cli/query.go create mode 100644 x/taskmanageravs/client/cli/query_params.go create mode 100644 x/taskmanageravs/client/cli/tx.go create mode 100644 x/taskmanageravs/genesis.go create mode 100644 x/taskmanageravs/genesis_test.go create mode 100644 x/taskmanageravs/keeper/abci.go create mode 100644 x/taskmanageravs/keeper/keeper.go create mode 100644 x/taskmanageravs/keeper/msg_server.go create mode 100644 x/taskmanageravs/keeper/msg_server_test.go create mode 100644 x/taskmanageravs/keeper/params.go create mode 100644 x/taskmanageravs/keeper/params_test.go create mode 100644 x/taskmanageravs/keeper/query.go create mode 100644 x/taskmanageravs/keeper/query_params.go create mode 100644 x/taskmanageravs/keeper/query_params_test.go create mode 100644 x/taskmanageravs/keeper/setup_test.go create mode 100644 x/taskmanageravs/keeper/task.go create mode 100644 x/taskmanageravs/keeper/task_test.go create mode 100644 x/taskmanageravs/keeper/utils_test.go create mode 100644 x/taskmanageravs/module.go create mode 100644 x/taskmanageravs/types/codec.go create mode 100644 x/taskmanageravs/types/errors.go create mode 100644 x/taskmanageravs/types/expected_keepers.go create mode 100644 x/taskmanageravs/types/genesis.go create mode 100644 x/taskmanageravs/types/genesis.pb.go create mode 100644 x/taskmanageravs/types/genesis_test.go create mode 100644 x/taskmanageravs/types/keys.go create mode 100644 x/taskmanageravs/types/msg.go create mode 100644 x/taskmanageravs/types/params.go create mode 100644 x/taskmanageravs/types/params.pb.go create mode 100644 x/taskmanageravs/types/query.pb.go create mode 100644 x/taskmanageravs/types/query.pb.gw.go create mode 100644 x/taskmanageravs/types/tx.pb.go create mode 100644 x/taskmanageravs/types/types.go 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..9917fd90e --- /dev/null +++ b/precompiles/avsTask/methods.go @@ -0,0 +1,71 @@ +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, + _ *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..e053efd14 --- /dev/null +++ b/precompiles/avsTask/setup_test.go @@ -0,0 +1,36 @@ +package task_test + +import ( + "github.com/ExocoreNetwork/exocore/testutil" + "testing" + + "github.com/ExocoreNetwork/exocore/precompiles/slash" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/stretchr/testify/suite" +) + +var s *TaskPrecompileTestSuite + +type TaskPrecompileTestSuite struct { + testutil.BaseTestSuite + precompile *slash.Precompile +} + +func TestPrecompileTestSuite(t *testing.T) { + s = new(TaskPrecompileTestSuite) + suite.Run(t, s) + + // Run Ginkgo integration tests + RegisterFailHandler(Fail) + RunSpecs(t, "Slash Precompile Suite") +} + +func (s *TaskPrecompileTestSuite) SetupTest() { + s.DoSetupTest() + precompile, err := slash.NewPrecompile(s.App.StakingAssetsManageKeeper, s.App.ExoSlashKeeper, s.App.AuthzKeeper) + s.Require().NoError(err) + s.precompile = precompile +} diff --git a/precompiles/avsTask/task.go b/precompiles/avsTask/task.go new file mode 100644 index 000000000..6e421f3e5 --- /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.AvshKeeper +} + +// NewPrecompile creates a new task Precompile instance as a +// PrecompiledContract interface. +func NewPrecompile( + authzKeeper authzkeeper.Keeper, + taskKeeper taskKeeper.Keeper, + avsKeeper tasktype.AvshKeeper, +) (*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/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..3cf784d82 --- /dev/null +++ b/proto/exocore/taskmanageravs/tx.proto @@ -0,0 +1,42 @@ +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); +} + + + 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/taskmanageravs.go b/testutil/keeper/taskmanageravs.go new file mode 100644 index 000000000..451ba400b --- /dev/null +++ b/testutil/keeper/taskmanageravs.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "testing" + + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/keeper" + "github.com/ExocoreNetwork/exocore/x/taskmanageravs/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 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) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "TaskmanageravsParams", + ) + 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/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/taskmanageravs/client/cli/query.go b/x/taskmanageravs/client/cli/query.go new file mode 100644 index 000000000..deae9c91c --- /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..baa3f949d --- /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.AvshKeeper + } +) + +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.AvshKeeper, +) 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..ec49db553 --- /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.AvsTaskKeeper.SetAvsTaskInfo(suite.ctx, info) + suite.NoError(err) + + getOperatorInfo, err := suite.app.AvsTaskKeeper.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..a8ad7a45e --- /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, false) + 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/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..ae5c179a4 --- /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 AvshKeeper struct{} + +func (k AvshKeeper) IsAVS(sdk.Context, sdk.AccAddress) bool { + return true +} + +func (k AvshKeeper) 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..8da7f6c7c --- /dev/null +++ b/x/taskmanageravs/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// 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 +) diff --git a/x/taskmanageravs/types/tx.pb.go b/x/taskmanageravs/types/tx.pb.go new file mode 100644 index 000000000..db5b17b83 --- /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") +) 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