From 19b484531a768f90ac759d4f457ea2ebe81cae37 Mon Sep 17 00:00:00 2001 From: trestin Date: Wed, 16 Oct 2024 14:41:37 +0800 Subject: [PATCH 01/24] fix audit TOW-02:avs deregister --- x/avs/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 50265144d..a1b23f8e8 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -133,7 +133,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi // If avs DeRegisterAction check UnbondingPeriod // #nosec G115 - if epoch.CurrentEpoch-int64(avsInfo.GetInfo().StartingEpoch) > int64(avsInfo.Info.AvsUnbondingPeriod) { + if epoch.CurrentEpoch-int64(avsInfo.GetInfo().StartingEpoch) < int64(avsInfo.Info.AvsUnbondingPeriod) { return errorsmod.Wrap(types.ErrUnbondingPeriod, fmt.Sprintf("not qualified to deregister %s", avsInfo)) } From b8e2d1179b69a836259f12cc925145e1303e6524 Mon Sep 17 00:00:00 2001 From: trestin Date: Wed, 16 Oct 2024 19:59:55 +0800 Subject: [PATCH 02/24] fix audit TOW-02:avs deregister --- x/avs/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index a1b23f8e8..0fd948f03 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -133,7 +133,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi // If avs DeRegisterAction check UnbondingPeriod // #nosec G115 - if epoch.CurrentEpoch-int64(avsInfo.GetInfo().StartingEpoch) < int64(avsInfo.Info.AvsUnbondingPeriod) { + if epoch.CurrentEpoch-int64(avsInfo.GetInfo().StartingEpoch) <= int64(avsInfo.Info.AvsUnbondingPeriod) { return errorsmod.Wrap(types.ErrUnbondingPeriod, fmt.Sprintf("not qualified to deregister %s", avsInfo)) } From 5b9795303c39e7c5971699fa91c20b5754e5918f Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 17 Oct 2024 11:10:54 +0800 Subject: [PATCH 03/24] add some new precompile func --- precompiles/avs/IAVSManager.sol | 101 ++++++++++++++++++++++++++++---- precompiles/avs/avs.go | 17 +++++- precompiles/avs/query.go | 2 +- precompiles/avs/tx.go | 95 +++++++++++++++++++++++++++++- x/avs/keeper/keeper.go | 34 +++++++---- x/avs/keeper/params.go | 18 ++++++ x/avs/types/expected_keepers.go | 3 + 7 files changed, 240 insertions(+), 30 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 4e390481a..6e49a8dd3 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -13,6 +13,21 @@ IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager( /// @dev The interface through which solidity contracts will interact with AVS-Manager /// @custom:address 0x0000000000000000000000000000000000000901 interface IAVSManager { + event AVSRegistered(address indexed sender, string avsName, bool success); + event AVSUpdated(address indexed sender, string avsName, bool success); + event AVSDeregistered(address indexed sender, string avsName, bool success); + event OperatorRegistered(address indexed sender, bool success); + event OperatorDeregistered(address indexed sender, bool success); + event TaskCreated(address indexed sender,uint64 taskId,address indexed taskContractAddress,string name,bytes hash, + uint64 taskResponsePeriod,uint64 taskChallengePeriod,uint64 thresholdPercentage,uint64 taskStatisticalPeriod + ); + event ChallengeInitiated(address indexed sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, + string operatorAddress, bool success); + event PublicKeyRegistered(address indexed sender, string name, bool success); + event OperatorRegisteredToExocore(address indexed sender, string metaInfo, bool success); + event TaskSubmittedByOperator(address indexed sender, uint64 taskID, string taskResponse, + string blsSignature, string taskContractAddress, string stage, bool success); + /// @dev Register AVS contract to EXO. /// @param sender The external address for calling this method. /// @param avsName The name of AVS. @@ -112,7 +127,7 @@ interface IAVSManager { uint64 taskChallengePeriod, uint64 thresholdPercentage, uint64 taskStatisticalPeriod - ) external returns (bool success); + ) external returns (bool success,uint64 taskID); /// @dev challenge , this function enables a challenger to raise and resolve a challenge. /// @param sender The external address for calling this method. @@ -143,15 +158,39 @@ interface IAVSManager { bytes calldata pubkeyRegistrationMessageHash ) external returns (bool success); + /// @dev registerOperatorToExocore , this function enables a precompile handler for creating a RegisterOperatorReq. + /// @param sender The external address for calling this method. + /// @param metaInfo The data supplied by the contract, usually ABI-encoded. + function registerOperatorToExocore( + address sender, + string memory metaInfo + ) external returns (bool success); + /// @dev operatorSubmitTask , this function enables a operator submit a task result. + /// @param sender The external address for calling this method. + /// @param taskID The id of task. + /// @param taskResponse is the task response data.. + /// @param blsSignature is the operator bls sig info.. + /// @param taskContractAddress is contract address of task. + /// @param stage this field is used to solve the problem of task results being copied by other operators. + // It is a two-stage submission with two values, 1 and 2 + function operatorSubmitTask( + address sender, + uint64 taskID, + bytes calldata taskResponse, + bytes calldata blsSignature, + address taskContractAddress, + string memory stage + ) external returns (bool success); + /// QUERIES /// @dev Returns the pubkey and pubkey hash of an operator /// @param operator is the operator for whom the key is being registered - function getRegisteredPubkey(string memory operator) external pure returns (bytes memory pubkey); + function getRegisteredPubkey(string memory operator) external view returns (bytes memory pubkey); /// @dev Returns the operators of all opt-in in the current avs /// @param avsAddress avs address - function getOptInOperators(address avsAddress) external returns (string[] memory operators); + function getOptInOperators(address avsAddress) external view returns (string[] memory operators); /// @dev getAVSUSDValue is a function to retrieve the USD share of specified Avs. /// @param avsAddr The address of the avs @@ -169,14 +208,50 @@ interface IAVSManager { string memory operatorAddr ) external view returns (uint256 amount); - event TaskCreated( - uint64 taskId, - string taskContractAddress, - string name, - bytes hash, - uint64 taskResponsePeriod, - uint64 taskChallengePeriod, - uint64 thresholdPercentage, - uint64 taskStatisticalPeriod - ); + /// @dev getAVSInfo is a function to query Avs info. + /// @param avsAddr The address of the avs + function getAVSInfo( + address avsAddr + ) external view returns (bool, uint32[] memory); + + /// @dev getTaskInfo is a function to query task info. + /// @param taskAddr The address of the avs task + /// @param taskID The id of task. + function getTaskInfo( + address taskAddr, + uint64 taskID + ) external view returns (bool, uint32[] memory); + + /// @dev getChallengeInfo is a function to query challenge info. + /// @param taskAddr The address of the avs task + /// @param taskID The id of task. + /// @param operatorAddr The address of the operator + function getChallengeInfo( + address taskAddr, + uint64 taskID, + string memory operatorAddr + ) external view returns (bool, uint32[] memory); + + /// @dev getSubmitTaskResult is a function to query result info. + /// @param taskAddr The address of the avs task + /// @param taskID The id of task. + /// @param operatorAddr The address of the operator + function getSubmitTaskResult( + address taskAddr, + uint64 taskID, + string memory operatorAddr + ) external view returns (bool, uint32[] memory); + + /// @dev getOperatorInfo is a function to query operator info. + /// @param operatorAddr The address of the operator + function getOperatorInfo( + string memory operatorAddr + ) external view returns (bool, uint32[] memory); + + /// @dev getOperatorAssetInfos is a function to query operator asset info. + /// @param operatorAddr The address of the operator + function getOperatorAssetInfos( + string memory operatorAddr + ) external view returns (bool, uint32[] memory); + } diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index 5cb8cb83f..980bdf322 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -153,6 +153,20 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack(false) } + + case MethodRegisterOperatorToExocore: + bz, err = p.Challenge(ctx, evm.Origin, contract, stateDB, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } + + case MethodOperatorSubmitTask: + bz, err = p.Challenge(ctx, evm.Origin, contract, stateDB, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } } if err != nil { @@ -175,7 +189,8 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ func (Precompile) IsTransaction(methodID string) bool { switch methodID { case MethodRegisterAVS, MethodDeregisterAVS, MethodUpdateAVS, MethodRegisterOperatorToAVS, - MethodDeregisterOperatorFromAVS, MethodCreateAVSTask, MethodRegisterBLSPublicKey, MethodChallenge: + MethodDeregisterOperatorFromAVS, MethodCreateAVSTask, MethodRegisterBLSPublicKey, MethodChallenge, + MethodRegisterOperatorToExocore, MethodOperatorSubmitTask: return true case MethodGetRegisteredPubkey, MethodGetOptinOperators, MethodGetAVSUSDValue, MethodGetOperatorOptedUSDValue: return false diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 72cea06eb..497643b31 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -54,7 +54,7 @@ func (p Precompile) GetOptedInOperatorAccAddrs( return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr) } - list, err := p.avsKeeper.GetOptInOperators(ctx, addr.String()) + list, err := p.avsKeeper.GetOperatorKeeper().GetOptedInOperatorListByAVS(ctx, addr.String()) if err != nil { return nil, err } diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index a5d4b663c..5b1ab5617 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -3,6 +3,7 @@ package avs import ( "fmt" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "slices" errorsmod "cosmossdk.io/errors" @@ -26,6 +27,8 @@ const ( MethodCreateAVSTask = "createTask" MethodRegisterBLSPublicKey = "registerBLSPublicKey" MethodChallenge = "challenge" + MethodRegisterOperatorToExocore = "registerOperatorToExocore" + MethodOperatorSubmitTask = "operatorSubmitTask" ) // AVSInfoRegister register the avs related information and change the state in avs keeper module. @@ -192,14 +195,14 @@ func (p Precompile) CreateAVSTask( return nil, err } params.TaskContractAddress = contract.CallerAddress.String() - err = p.avsKeeper.CreateAVSTask(ctx, params) + taskID, err := p.avsKeeper.CreateAVSTask(ctx, params) if err != nil { return nil, err } if err = p.EmitCreateAVSTaskEvent(ctx, stateDB, params); err != nil { return nil, err } - return method.Outputs.Pack(true) + return method.Outputs.Pack(true, taskID) } // Challenge Middleware uses exocore's default avstask template to create tasks in avstask module. @@ -307,3 +310,91 @@ func (p Precompile) RegisterBLSPublicKey( return method.Outputs.Pack(true) } + +// RegisterOperatorToExocore operator register. +func (p Precompile) RegisterOperatorToExocore( + ctx sdk.Context, + _ common.Address, + _ *vm.Contract, + _ vm.StateDB, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + if len(args) != len(p.ABI.Methods[MethodRegisterOperatorToAVS].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterOperatorToAVS].Inputs), len(args)) + } + operatorParams := &avskeeper.OperatorParams{} + callerAddress, ok := args[0].(common.Address) + if !ok || (callerAddress == common.Address{}) { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + } + operatorParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + + OperatorMetaInfo, ok := args[1].(string) + if !ok || OperatorMetaInfo == "" { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", OperatorMetaInfo) + } + operatorParams.OperatorMetaInfo = OperatorMetaInfo + info := operatortypes.OperatorInfo{ + OperatorMetaInfo: OperatorMetaInfo, + } + err := p.avsKeeper.GetOperatorKeeper().SetOperatorInfo(ctx, operatorParams.CallerAddress, &info) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(true) +} + +// OperatorSubmitTask operator submit results +func (p Precompile) OperatorSubmitTask( + ctx sdk.Context, + _ common.Address, + contract *vm.Contract, + _ vm.StateDB, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + if len(args) != len(p.ABI.Methods[MethodOperatorSubmitTask].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodOperatorSubmitTask].Inputs), len(args)) + } + resultParams := &avskeeper.TaskResultParams{} + resultParams.TaskContractAddress = contract.CallerAddress + callerAddress, ok := args[0].(common.Address) + if !ok || (callerAddress == common.Address{}) { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) + } + resultParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + + taskID, ok := args[1].(uint64) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", taskID) + } + resultParams.TaskID = taskID + + taskResponse, ok := args[2].([]byte) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", taskResponse) + } + resultParams.TaskResponse = taskResponse + + blsSignature, ok := args[3].([]byte) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", blsSignature) + } + resultParams.BlsSignature = blsSignature + + stage, ok := args[4].(string) + if !ok || stage == "" { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "string", stage) + } + resultParams.Stage = stage + + resultParams.OperatorAddress = resultParams.CallerAddress + err := p.avsKeeper.SubmitTaskResult(ctx, resultParams) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(true) +} diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 0fd948f03..2771d839c 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -220,32 +220,32 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi } } -func (k Keeper) CreateAVSTask(ctx sdk.Context, params *TaskInfoParams) error { +func (k Keeper) CreateAVSTask(ctx sdk.Context, params *TaskInfoParams) (uint64, error) { avsInfo := k.GetAVSInfoByTaskAddress(ctx, params.TaskContractAddress) if avsInfo.AvsAddress == "" { - return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", params.TaskContractAddress)) + return 0, errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", params.TaskContractAddress)) } // If avs CreateAVSTask check CallerAddress if !slices.Contains(avsInfo.AvsOwnerAddress, params.CallerAddress) { - return errorsmod.Wrap(types.ErrCallerAddressUnauthorized, fmt.Sprintf("this caller not qualified to CreateAVSTask %s", params.CallerAddress)) + return 0, errorsmod.Wrap(types.ErrCallerAddressUnauthorized, fmt.Sprintf("this caller not qualified to CreateAVSTask %s", params.CallerAddress)) } taskPowerTotal, err := k.operatorKeeper.GetAVSUSDValue(ctx, avsInfo.AvsAddress) if err != nil || taskPowerTotal.IsZero() || taskPowerTotal.IsNegative() { - return errorsmod.Wrap(types.ErrVotingPowerIncorrect, fmt.Sprintf("the votingpower of avs is <<=0,avs addr is:%s", avsInfo.AvsAddress)) + return 0, errorsmod.Wrap(types.ErrVotingPowerIncorrect, fmt.Sprintf("the votingpower of avs is <<=0,avs addr is:%s", avsInfo.AvsAddress)) } epoch, found := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier) if !found { - return errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", avsInfo.EpochIdentifier)) + return 0, errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", avsInfo.EpochIdentifier)) } if k.IsExistTask(ctx, strconv.FormatUint(params.TaskID, 10), params.TaskContractAddress) { - return errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the task is :%s", strconv.FormatUint(params.TaskID, 10))) + return 0, errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the task is :%s", strconv.FormatUint(params.TaskID, 10))) } - operatorList, err := k.GetOptInOperators(ctx, avsInfo.AvsAddress) + operatorList, err := k.operatorKeeper.GetOptedInOperatorListByAVS(ctx, avsInfo.AvsAddress) if err != nil { - return errorsmod.Wrap(err, "CreateAVSTask: failed to get opt-in operators") + return 0, errorsmod.Wrap(err, "CreateAVSTask: failed to get opt-in operators") } params.TaskID = k.GetTaskID(ctx, common.HexToAddress(params.TaskContractAddress)) task := &types.TaskInfo{ @@ -261,7 +261,7 @@ func (k Keeper) CreateAVSTask(ctx sdk.Context, params *TaskInfoParams) error { ActualThreshold: 0, OptInOperators: operatorList, } - return k.SetTaskInfo(ctx, task) + return task.TaskId, k.SetTaskInfo(ctx, task) } func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *BlsParams) error { @@ -285,10 +285,6 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *BlsParams) error { return k.SetOperatorPubKey(ctx, bls) } -func (k Keeper) GetOptInOperators(ctx sdk.Context, avsAddr string) ([]string, error) { - return k.operatorKeeper.GetOptedInOperatorListByAVS(ctx, avsAddr) -} - func (k Keeper) OperatorOptAction(ctx sdk.Context, params *OperatorOptParams) error { operatorAddress := params.OperatorAddress opAccAddr, err := sdk.AccAddressFromBech32(operatorAddress) @@ -444,3 +440,15 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *ChallengeParam return k.SetTaskChallengedInfo(ctx, params.TaskID, params.OperatorAddress.String(), params.CallerAddress, params.TaskContractAddress) } +func (k Keeper) SubmitTaskResult(ctx sdk.Context, params *TaskResultParams) error { + + result := &types.TaskResultInfo{ + TaskId: params.TaskID, + OperatorAddress: params.OperatorAddress, + TaskContractAddress: params.TaskContractAddress.String(), + TaskResponse: params.TaskResponse, + BlsSignature: params.BlsSignature, + Stage: params.Stage, + } + return k.SetTaskResultInfo(ctx, params.OperatorAddress, result) +} diff --git a/x/avs/keeper/params.go b/x/avs/keeper/params.go index 5db1b8d13..47452336d 100644 --- a/x/avs/keeper/params.go +++ b/x/avs/keeper/params.go @@ -101,3 +101,21 @@ type ChallengeParams struct { TaskResponseHash []byte `json:"task_response_hash"` CallerAddress string `json:"caller_address"` } + +type TaskResultParams struct { + OperatorAddress string `json:"operator_address"` + TaskResponseHash string `json:"task_response_hash"` + TaskResponse []byte `json:"task_response"` + BlsSignature []byte `json:"bls_signature"` + TaskContractAddress common.Address `json:"task_contract_address"` + TaskID uint64 `json:"task_id"` + Stage string `json:"stage"` + CallerAddress string `json:"caller_address"` +} + +type OperatorParams struct { + EarningsAddr string `json:"earnings_addr"` + ApproveAddr string `son:"approve_addr"` + OperatorMetaInfo string `json:"operator_meta_info"` + CallerAddress string `json:"caller_address"` +} diff --git a/x/avs/types/expected_keepers.go b/x/avs/types/expected_keepers.go index e60ddc94e..299755acc 100644 --- a/x/avs/types/expected_keepers.go +++ b/x/avs/types/expected_keepers.go @@ -1,6 +1,7 @@ package types import ( + "context" sdkmath "cosmossdk.io/math" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -42,6 +43,7 @@ type OperatorKeeper interface { GetOptedInOperatorListByAVS(ctx sdk.Context, avsAddr string) ([]string, error) GetOperatorOptedUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) (operatortypes.OperatorOptedUSDValue, error) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) + SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) } // AssetsKeeper represents the expected keeper interface for the assets module. @@ -50,4 +52,5 @@ type AssetsKeeper interface { ctx sdk.Context, assetID string, ) (info *assetstype.StakingAssetInfo, err error) IsStakingAsset(sdk.Context, string) bool + QueOperatorAssetInfos(ctx context.Context, infos *assetstype.QueryOperatorAssetInfos) (*assetstype.QueryOperatorAssetInfosResponse, error) } From 264f534e7b18e333976eae75017fcbbf44a6ccbc Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 17 Oct 2024 18:00:19 +0800 Subject: [PATCH 04/24] fix avs precompile test err --- precompiles/avs/IAVSManager.sol | 47 ++- precompiles/avs/abi.json | 618 ++++++++++++++++++++++++++++++-- precompiles/avs/avs_test.go | 43 ++- precompiles/avs/events.go | 13 +- 4 files changed, 678 insertions(+), 43 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 6e49a8dd3..6da5cd5f2 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -28,6 +28,51 @@ interface IAVSManager { event TaskSubmittedByOperator(address indexed sender, uint64 taskID, string taskResponse, string blsSignature, string taskContractAddress, string stage, bool success); + struct AVSInfo { + string name; + string avsAddress; + uint64 minStakeAmount; + string taskAddr; + string slashAddr; + string rewardAddr; + string[] avsOwnerAddress; + string[] assetIDs; + uint64 avsUnbondingPeriod; + uint64 minSelfDelegation; + string epochIdentifier; + uint64 minOptInOperators; + uint64 minTotalStakeAmount; + uint64 startingEpoch; + string chainId; + string avsReward; + string avsSlash; + AssetReward[] assetRewardAmountEpochBasis; + } + struct QueryAVSInfoResponse { + AVSInfo info; + } + struct AssetReward { + string assetID; + int64 amountEpochBasis; + } + struct TaskInfo { + string taskContractAddress; + string name; + bytes hash; + uint64 taskId; + uint64 taskResponsePeriod; + uint64 taskStatisticalPeriod; + uint64 taskChallengePeriod; + uint64 thresholdPercentage; + uint64 startingEpoch; + uint64 actualThreshold; + string[] optInOperators; + string[] signedOperators; + string[] noSignedOperators; + string[] errSignedOperators; + string taskTotalPower; + // OperatorActivePowerList is not defined here as it's not clear from the provided message + } /// @dev Register AVS contract to EXO. /// @param sender The external address for calling this method. /// @param avsName The name of AVS. @@ -212,7 +257,7 @@ interface IAVSManager { /// @param avsAddr The address of the avs function getAVSInfo( address avsAddr - ) external view returns (bool, uint32[] memory); + ) external view returns (QueryAVSInfoResponse memory info); /// @dev getTaskInfo is a function to query task info. /// @param taskAddr The address of the avs task diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index ca475f27d..163846848 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -2,18 +2,230 @@ { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "avsName", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "AVSDeregistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "avsName", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "AVSRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "avsName", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "AVSUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "taskHash", + "type": "bytes" + }, { "indexed": false, "internalType": "uint64", - "name": "taskId", + "name": "taskID", "type": "uint64" }, + { + "indexed": false, + "internalType": "bytes", + "name": "taskResponseHash", + "type": "bytes" + }, { "indexed": false, "internalType": "string", - "name": "taskContractAddress", + "name": "operatorAddress", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "ChallengeInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "OperatorDeregistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "OperatorRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "metaInfo", "type": "string" }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "OperatorRegisteredToExocore", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "PublicKeyRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "taskId", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "address", + "name": "taskContractAddress", + "type": "address" + }, { "indexed": false, "internalType": "string", @@ -54,6 +266,55 @@ "name": "TaskCreated", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "taskID", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "string", + "name": "taskResponse", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "blsSignature", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "taskContractAddress", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "stage", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "name": "TaskSubmittedByOperator", + "type": "event" + }, { "inputs": [ { @@ -137,6 +398,11 @@ "internalType": "bool", "name": "success", "type": "bool" + }, + { + "internalType": "uint64", + "name": "taskID", + "type": "uint64" } ], "stateMutability": "nonpayable", @@ -185,6 +451,136 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "avsAddr", + "type": "address" + } + ], + "name": "getAVSInfo", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "avsAddress", + "type": "string" + }, + { + "internalType": "uint64", + "name": "minStakeAmount", + "type": "uint64" + }, + { + "internalType": "string", + "name": "taskAddr", + "type": "string" + }, + { + "internalType": "string", + "name": "slashAddr", + "type": "string" + }, + { + "internalType": "string", + "name": "rewardAddr", + "type": "string" + }, + { + "internalType": "string[]", + "name": "avsOwnerAddress", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "assetIDs", + "type": "string[]" + }, + { + "internalType": "uint64", + "name": "avsUnbondingPeriod", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "minSelfDelegation", + "type": "uint64" + }, + { + "internalType": "string", + "name": "epochIdentifier", + "type": "string" + }, + { + "internalType": "uint64", + "name": "minOptInOperators", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "minTotalStakeAmount", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "startingEpoch", + "type": "uint64" + }, + { + "internalType": "string", + "name": "chainId", + "type": "string" + }, + { + "internalType": "string", + "name": "avsReward", + "type": "string" + }, + { + "internalType": "string", + "name": "avsSlash", + "type": "string" + }, + { + "components": [ + { + "internalType": "string", + "name": "assetID", + "type": "string" + }, + { + "internalType": "int64", + "name": "amountEpochBasis", + "type": "int64" + } + ], + "internalType": "struct IAVSManager.AssetReward[]", + "name": "assetRewardAmountEpochBasis", + "type": "tuple[]" + } + ], + "internalType": "struct IAVSManager.AVSInfo", + "name": "info", + "type": "tuple" + } + ], + "internalType": "struct IAVSManager.QueryAVSInfoResponse", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -204,6 +600,88 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "taskAddr", + "type": "address" + }, + { + "internalType": "uint64", + "name": "taskID", + "type": "uint64" + }, + { + "internalType": "string", + "name": "operatorAddr", + "type": "string" + } + ], + "name": "getChallengeInfo", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "operatorAddr", + "type": "string" + } + ], + "name": "getOperatorAssetInfos", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "operatorAddr", + "type": "string" + } + ], + "name": "getOperatorInfo", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -244,7 +722,7 @@ "type": "string[]" } ], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { @@ -263,7 +741,114 @@ "type": "bytes" } ], - "stateMutability": "pure", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "taskAddr", + "type": "address" + }, + { + "internalType": "uint64", + "name": "taskID", + "type": "uint64" + }, + { + "internalType": "string", + "name": "operatorAddr", + "type": "string" + } + ], + "name": "getSubmitTaskResult", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "taskAddr", + "type": "address" + }, + { + "internalType": "uint64", + "name": "taskID", + "type": "uint64" + } + ], + "name": "getTaskInfo", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint64", + "name": "taskID", + "type": "uint64" + }, + { + "internalType": "bytes", + "name": "taskResponse", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "blsSignature", + "type": "bytes" + }, + { + "internalType": "address", + "name": "taskContractAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "stage", + "type": "string" + } + ], + "name": "operatorSubmitTask", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "stateMutability": "nonpayable", "type": "function" }, { @@ -401,32 +986,17 @@ { "inputs": [ { - "internalType": "string", - "name": "taskId", - "type": "string" - }, - { - "internalType": "string", - "name": "taskContractAddress", - "type": "string" - }, - { - "internalType": "string", - "name": "aggregator", - "type": "string" + "internalType": "address", + "name": "sender", + "type": "address" }, { "internalType": "string", - "name": "avsAddress", + "name": "metaInfo", "type": "string" - }, - { - "internalType": "bytes", - "name": "operatorStatus", - "type": "bytes" } ], - "name": "submitProof", + "name": "registerOperatorToExocore", "outputs": [ { "internalType": "bool", diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index ca8b66f14..ddd168297 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -66,6 +66,21 @@ func (suite *AVSManagerPrecompileSuite) TestIsTransaction() { suite.precompile.Methods[avs.MethodRegisterBLSPublicKey].Name, true, }, + { + avs.MethodChallenge, + suite.precompile.Methods[avs.MethodChallenge].Name, + true, + }, + { + avs.MethodRegisterOperatorToExocore, + suite.precompile.Methods[avs.MethodRegisterOperatorToExocore].Name, + true, + }, + { + avs.MethodOperatorSubmitTask, + suite.precompile.Methods[avs.MethodOperatorSubmitTask].Name, + true, + }, } for _, tc := range testCases { @@ -76,7 +91,7 @@ func (suite *AVSManagerPrecompileSuite) TestIsTransaction() { } func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { - avsName, operatorAddress, slashAddress, rewardAddress := "avsTest", "exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" + avsName, slashAddress, rewardAddress := "avsTest", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" avsOwnerAddress := []string{ sdk.AccAddress(suite.Address.Bytes()).String(), sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), @@ -88,16 +103,6 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { epochIdentifier := epochstypes.DayEpochID params := []uint64{2, 3, 4, 4} - registerOperator := func() { - registerReq := &operatortypes.RegisterOperatorReq{ - FromAddress: operatorAddress, - Info: &operatortypes.OperatorInfo{ - EarningsAddr: operatorAddress, - }, - } - _, err := suite.OperatorMsgServer.RegisterOperator(sdk.WrapSDKContext(suite.Ctx), registerReq) - suite.NoError(err) - } commonMalleate := func() (common.Address, []byte) { input, err := suite.precompile.Pack( avs.MethodRegisterAVS, @@ -132,7 +137,6 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { { name: "pass for avs-registered", malleate: func() (common.Address, []byte) { - registerOperator() return commonMalleate() }, readOnly: false, @@ -193,7 +197,14 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { // Run precompiled contract bz, err := suite.precompile.Run(evm, contract, tc.readOnly) - + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + suite.CommitAfter(time.Hour*24 + time.Nanosecond) // Check results if tc.expPass { suite.Require().NoError(err, "expected no error when running the precompile") @@ -210,7 +221,7 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { func (suite *AVSManagerPrecompileSuite) TestDeregisterAVS() { avsName := "avsTest" commonMalleate := func() (common.Address, []byte) { - // prepare the call input for delegation test + // prepare the call input for avs test input, err := suite.precompile.Pack( avs.MethodDeregisterAVS, suite.Address, @@ -474,8 +485,8 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { { name: "pass for operator opt-in avs", malleate: func() (common.Address, []byte) { - suite.TestRegisterAVS() registerOperator() + suite.TestRegisterAVS() avsAddr, intput := commonMalleate() asset := suite.Assets[0] _, defaultAssetID := assetstypes.GetStakerIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) @@ -717,7 +728,7 @@ func (suite *AVSManagerPrecompileSuite) TestRunRegTaskInfo() { suite.Require().NoError(err, "failed to pack input") return suite.Address, input } - successRet, err := suite.precompile.Methods[avs.MethodCreateAVSTask].Outputs.Pack(true) + successRet, err := suite.precompile.Methods[avs.MethodCreateAVSTask].Outputs.Pack(true, uint64(1)) suite.Require().NoError(err) testcases := []struct { name string diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index ff26f0fe2..b2013ccde 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -26,8 +26,17 @@ func (p Precompile) EmitCreateAVSTaskEvent(ctx sdk.Context, stateDB vm.StateDB, var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:8] - packed, err := arguments.Pack(task.TaskID, task.TaskContractAddress, task.TaskName, task.Hash, task.TaskResponsePeriod, task.TaskChallengePeriod, task.ThresholdPercentage, task.TaskStatisticalPeriod) + arguments := event.Inputs[0:9] + packed, err := arguments.Pack( + common.HexToAddress(task.CallerAddress), + task.TaskID, + common.HexToAddress(task.TaskContractAddress), + task.TaskName, + task.Hash, + task.TaskResponsePeriod, + task.TaskChallengePeriod, + task.ThresholdPercentage, + task.TaskStatisticalPeriod) if err != nil { return err } From cf1a45cb3bdc9748a452a511181bf4601e01e0bc Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 17 Oct 2024 18:55:20 +0800 Subject: [PATCH 05/24] add events for all transactions --- precompiles/avs/IAVSManager.sol | 4 +- precompiles/avs/abi.json | 4 +- precompiles/avs/events.go | 302 +++++++++++++++++++++++++++++++- precompiles/avs/tx.go | 49 ++++-- 4 files changed, 338 insertions(+), 21 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 6da5cd5f2..930c6cfca 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -16,8 +16,8 @@ interface IAVSManager { event AVSRegistered(address indexed sender, string avsName, bool success); event AVSUpdated(address indexed sender, string avsName, bool success); event AVSDeregistered(address indexed sender, string avsName, bool success); - event OperatorRegistered(address indexed sender, bool success); - event OperatorDeregistered(address indexed sender, bool success); + event OperatorJoined(address indexed sender, bool success); + event OperatorOuted(address indexed sender, bool success); event TaskCreated(address indexed sender,uint64 taskId,address indexed taskContractAddress,string name,bytes hash, uint64 taskResponsePeriod,uint64 taskChallengePeriod,uint64 thresholdPercentage,uint64 taskStatisticalPeriod ); diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 163846848..0149f4b8c 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -133,7 +133,7 @@ "type": "bool" } ], - "name": "OperatorDeregistered", + "name": "OperatorJoined", "type": "event" }, { @@ -152,7 +152,7 @@ "type": "bool" } ], - "name": "OperatorRegistered", + "name": "OperatorOuted", "type": "event" }, { diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index b2013ccde..2ef3421f1 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -1,7 +1,9 @@ package avs import ( + "encoding/hex" avskeep "github.com/ExocoreNetwork/exocore/x/avs/keeper" + avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -9,14 +11,174 @@ import ( ) const ( - // EventTypeRegisterAVSTask defines the event type for the avs CreateAVSTask transaction. - EventTypeRegisterAVSTask = "TaskCreated" + EventTypeAVSRegistered = "AVSRegistered" + EventTypeAVSUpdated = "AVSUpdated" + EventTypeAVSDeregistered = "AVSDeregistered" + EventTypeOperatorJoined = "OperatorJoined" + EventTypeOperatorOuted = "OperatorOuted" + EventTypeTaskCreated = "TaskCreated" + EventTypeChallengeInitiated = "ChallengeInitiated" + EventTypePublicKeyRegistered = "PublicKeyRegistered" + EventTypeOperatorRegisteredToExocore = "OperatorRegisteredToExocore" + EventTypeTaskSubmittedByOperator = "TaskSubmittedByOperator" ) -// EmitCreateAVSTaskEvent creates a new event emitted on a EmitCreateAVSTaskEvent transaction. -func (p Precompile) EmitCreateAVSTaskEvent(ctx sdk.Context, stateDB vm.StateDB, task *avskeep.TaskInfoParams) error { +func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { // Prepare the event topics - event := p.ABI.Events[EventTypeRegisterAVSTask] + event := p.ABI.Events[EventTypeAVSRegistered] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:2] + packed, err := arguments.Pack( + common.HexToAddress(avs.CallerAddress), + avs.AvsName, + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitAVSUpdated(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeAVSUpdated] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:2] + packed, err := arguments.Pack( + common.HexToAddress(avs.CallerAddress), + avs.AvsName, + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitAVSDeregistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeAVSDeregistered] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:2] + packed, err := arguments.Pack( + common.HexToAddress(avs.CallerAddress), + avs.AvsName, + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.OperatorOptParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeOperatorJoined] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:1] + packed, err := arguments.Pack( + common.HexToAddress(params.OperatorAddress), + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.OperatorOptParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeOperatorOuted] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:1] + packed, err := arguments.Pack( + common.HexToAddress(params.OperatorAddress), + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *avskeep.TaskInfoParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeTaskCreated] topics := make([]common.Hash, 1) @@ -50,3 +212,133 @@ func (p Precompile) EmitCreateAVSTaskEvent(ctx sdk.Context, stateDB vm.StateDB, return nil } + +func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.ChallengeParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeChallengeInitiated] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:5] + packed, err := arguments.Pack( + common.HexToAddress(params.CallerAddress), + params.TaskHash, + params.TaskID, + params.TaskResponseHash, + params.OperatorAddress, + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} +func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.BlsParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypePublicKeyRegistered] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:2] + packed, err := arguments.Pack( + common.HexToAddress(params.Operator), + params.Name, + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitOperatorRegisteredToExocore(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.OperatorParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeOperatorRegisteredToExocore] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:2] + packed, err := arguments.Pack( + common.HexToAddress(params.CallerAddress), + params.OperatorMetaInfo, + true) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + + return nil +} + +func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.TaskResultParams) error { + // Prepare the event topics + event := p.ABI.Events[EventTypeTaskSubmittedByOperator] + + topics := make([]common.Hash, 1) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + + // Pack the arguments to be used as the Data field + arguments := event.Inputs[0:6] + packed, err := arguments.Pack( + common.HexToAddress(params.CallerAddress), + params.TaskID, + hex.EncodeToString(params.TaskResponse), + hex.EncodeToString(params.BlsSignature), + params.TaskContractAddress.String(), + params.Stage, + true) + 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/avs/tx.go b/precompiles/avs/tx.go index 5b1ab5617..c230ee18a 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -36,7 +36,7 @@ func (p Precompile) RegisterAVS( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -58,7 +58,9 @@ func (p Precompile) RegisterAVS( fmt.Println("Failed to update AVS info", err) return nil, err } - + if err = p.EmitAVSRegistered(ctx, stateDB, avsParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -66,7 +68,7 @@ func (p Precompile) DeregisterAVS( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -93,14 +95,16 @@ func (p Precompile) DeregisterAVS( if err != nil { return nil, err } + if err = p.EmitAVSDeregistered(ctx, stateDB, avsParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } - func (p Precompile) UpdateAVS( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -125,6 +129,9 @@ func (p Precompile) UpdateAVS( return nil, err } + if err = p.EmitAVSUpdated(ctx, stateDB, avsParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -132,7 +139,7 @@ func (p Precompile) BindOperatorToAVS( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -152,6 +159,9 @@ func (p Precompile) BindOperatorToAVS( if err != nil { return nil, err } + if err = p.EmitOperatorJoined(ctx, stateDB, operatorParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -159,7 +169,7 @@ func (p Precompile) UnbindOperatorToAVS( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -178,6 +188,9 @@ func (p Precompile) UnbindOperatorToAVS( if err != nil { return nil, err } + if err = p.EmitOperatorOuted(ctx, stateDB, operatorParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -199,7 +212,7 @@ func (p Precompile) CreateAVSTask( if err != nil { return nil, err } - if err = p.EmitCreateAVSTaskEvent(ctx, stateDB, params); err != nil { + if err = p.EmitTaskCreated(ctx, stateDB, params); err != nil { return nil, err } return method.Outputs.Pack(true, taskID) @@ -210,7 +223,7 @@ func (p Precompile) Challenge( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -258,6 +271,9 @@ func (p Precompile) Challenge( return nil, err } + if err = p.EmitChallengeInitiated(ctx, stateDB, challengeParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -266,7 +282,7 @@ func (p Precompile) RegisterBLSPublicKey( ctx sdk.Context, _ common.Address, _ *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -308,6 +324,9 @@ func (p Precompile) RegisterBLSPublicKey( return nil, err } + if err = p.EmitPublicKeyRegistered(ctx, stateDB, blsParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -316,7 +335,7 @@ func (p Precompile) RegisterOperatorToExocore( ctx sdk.Context, _ common.Address, _ *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -343,6 +362,9 @@ func (p Precompile) RegisterOperatorToExocore( return nil, err } + if err = p.EmitOperatorRegisteredToExocore(ctx, stateDB, operatorParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } @@ -351,7 +373,7 @@ func (p Precompile) OperatorSubmitTask( ctx sdk.Context, _ common.Address, contract *vm.Contract, - _ vm.StateDB, + stateDB vm.StateDB, method *abi.Method, args []interface{}, ) ([]byte, error) { @@ -396,5 +418,8 @@ func (p Precompile) OperatorSubmitTask( return nil, err } + if err = p.EmitTaskSubmittedByOperator(ctx, stateDB, resultParams); err != nil { + return nil, err + } return method.Outputs.Pack(true) } From 33d7704d2d3980de4709f8721583ea1f8a9f2aeb Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 17 Oct 2024 20:50:56 +0800 Subject: [PATCH 06/24] fix lint err --- precompiles/avs/events.go | 24 ++++++++++++++++++------ precompiles/avs/tx.go | 6 ++++-- x/avs/keeper/avs_test.go | 7 +++++-- x/avs/keeper/keeper.go | 2 +- x/avs/types/expected_keepers.go | 1 + 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 2ef3421f1..7b8c9eaa5 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -2,6 +2,7 @@ package avs import ( "encoding/hex" + avskeep "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,8 +24,18 @@ const ( EventTypeTaskSubmittedByOperator = "TaskSubmittedByOperator" ) +// EmitAVSRegistered emits an Ethereum event when an AVS (Autonomous Verification Service) is registered. +// +// Parameters: +// - ctx: The SDK context containing information about the current state of the blockchain. +// - stateDB: The Ethereum state database where the event will be stored. +// - avs: A pointer to the AVSRegisterOrDeregisterParams struct containing the details of the AVS registration. +// +// Returns: +// - An error if there is an issue packing the event data or adding the log to the state database. +// - nil if the event is successfully emitted. func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - // Prepare the event topics + // Prepare the event topics event := p.ABI.Events[EventTypeAVSRegistered] topics := make([]common.Hash, 1) @@ -35,7 +46,7 @@ func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs * var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] + arguments := event.Inputs[0:3] packed, err := arguments.Pack( common.HexToAddress(avs.CallerAddress), avs.AvsName, @@ -66,7 +77,7 @@ func (p Precompile) EmitAVSUpdated(ctx sdk.Context, stateDB vm.StateDB, avs *avs var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] + arguments := event.Inputs[0:3] packed, err := arguments.Pack( common.HexToAddress(avs.CallerAddress), avs.AvsName, @@ -97,7 +108,7 @@ func (p Precompile) EmitAVSDeregistered(ctx sdk.Context, stateDB vm.StateDB, avs var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] + arguments := event.Inputs[0:3] packed, err := arguments.Pack( common.HexToAddress(avs.CallerAddress), avs.AvsName, @@ -128,7 +139,7 @@ func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, para var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:1] + arguments := event.Inputs[0:2] packed, err := arguments.Pack( common.HexToAddress(params.OperatorAddress), true) @@ -158,7 +169,7 @@ func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, param var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:1] + arguments := event.Inputs[0:2] packed, err := arguments.Pack( common.HexToAddress(params.OperatorAddress), true) @@ -246,6 +257,7 @@ func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, return nil } + func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.BlsParams) error { // Prepare the event topics event := p.ABI.Events[EventTypePublicKeyRegistered] diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index c230ee18a..7059728ec 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -3,9 +3,10 @@ package avs import ( "fmt" - operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" "slices" + operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" + errorsmod "cosmossdk.io/errors" exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" @@ -31,7 +32,7 @@ const ( MethodOperatorSubmitTask = "operatorSubmitTask" ) -// AVSInfoRegister register the avs related information and change the state in avs keeper module. +// RegisterAVS AVSInfoRegister register the avs related information and change the state in avs keeper module. func (p Precompile) RegisterAVS( ctx sdk.Context, _ common.Address, @@ -100,6 +101,7 @@ func (p Precompile) DeregisterAVS( } return method.Outputs.Pack(true) } + func (p Precompile) UpdateAVS( ctx sdk.Context, _ common.Address, diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index 0bdc36ba0..3ae306273 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -105,7 +105,7 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_DeRegister() { AvsOwnerAddress: avsOwnerAddress, AssetID: assetID, MinSelfDelegation: uint64(10), - UnbondingPeriod: uint64(7), + UnbondingPeriod: uint64(2), SlashContractAddr: slashAddress, EpochIdentifier: epochstypes.DayEpochID, } @@ -119,7 +119,10 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_DeRegister() { suite.NoError(err) info, err := suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddres) suite.Equal(avsAddres, info.GetInfo().AvsAddress) - + suite.CommitAfter(48*time.Hour + time.Nanosecond) + suite.CommitAfter(48*time.Hour + time.Nanosecond) + suite.CommitAfter(48*time.Hour + time.Nanosecond) + suite.CommitAfter(48*time.Hour + time.Nanosecond) avsParams.Action = avstypes.DeRegisterAction avsParams.CallerAddress = "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, avsParams) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 2771d839c..3bdf42184 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -440,8 +440,8 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *ChallengeParam return k.SetTaskChallengedInfo(ctx, params.TaskID, params.OperatorAddress.String(), params.CallerAddress, params.TaskContractAddress) } -func (k Keeper) SubmitTaskResult(ctx sdk.Context, params *TaskResultParams) error { +func (k Keeper) SubmitTaskResult(ctx sdk.Context, params *TaskResultParams) error { result := &types.TaskResultInfo{ TaskId: params.TaskID, OperatorAddress: params.OperatorAddress, diff --git a/x/avs/types/expected_keepers.go b/x/avs/types/expected_keepers.go index 299755acc..a2365fd71 100644 --- a/x/avs/types/expected_keepers.go +++ b/x/avs/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "context" + sdkmath "cosmossdk.io/math" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" From 3c8d1bdd3d4a1b7b639dd6fe1a6c31ec45806b24 Mon Sep 17 00:00:00 2001 From: trestin Date: Fri, 18 Oct 2024 01:10:31 +0800 Subject: [PATCH 07/24] add precompile query func --- precompiles/avs/IAVSManager.sol | 64 +-------- precompiles/avs/abi.json | 235 ++------------------------------ precompiles/avs/avs.go | 13 +- precompiles/avs/avs_test.go | 207 ++++++++++++++++++++++++++++ precompiles/avs/events.go | 4 +- precompiles/avs/query.go | 89 ++++++++++++ precompiles/avs/query_test.go | 235 ++++++++++++++++++++++++++++++++ precompiles/avs/tx.go | 16 ++- x/avs/keeper/task.go | 21 +-- x/avs/types/expected_keepers.go | 1 + 10 files changed, 582 insertions(+), 303 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 930c6cfca..b8baee238 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -28,33 +28,7 @@ interface IAVSManager { event TaskSubmittedByOperator(address indexed sender, uint64 taskID, string taskResponse, string blsSignature, string taskContractAddress, string stage, bool success); - struct AVSInfo { - string name; - string avsAddress; - uint64 minStakeAmount; - string taskAddr; - string slashAddr; - string rewardAddr; - string[] avsOwnerAddress; - string[] assetIDs; - uint64 avsUnbondingPeriod; - uint64 minSelfDelegation; - string epochIdentifier; - uint64 minOptInOperators; - uint64 minTotalStakeAmount; - uint64 startingEpoch; - string chainId; - string avsReward; - string avsSlash; - AssetReward[] assetRewardAmountEpochBasis; - } - struct QueryAVSInfoResponse { - AVSInfo info; - } - struct AssetReward { - string assetID; - int64 amountEpochBasis; - } + struct TaskInfo { string taskContractAddress; string name; @@ -257,7 +231,7 @@ interface IAVSManager { /// @param avsAddr The address of the avs function getAVSInfo( address avsAddr - ) external view returns (QueryAVSInfoResponse memory info); + ) external view returns (string memory epochIdentifier); /// @dev getTaskInfo is a function to query task info. /// @param taskAddr The address of the avs task @@ -265,38 +239,12 @@ interface IAVSManager { function getTaskInfo( address taskAddr, uint64 taskID - ) external view returns (bool, uint32[] memory); - - /// @dev getChallengeInfo is a function to query challenge info. - /// @param taskAddr The address of the avs task - /// @param taskID The id of task. - /// @param operatorAddr The address of the operator - function getChallengeInfo( - address taskAddr, - uint64 taskID, - string memory operatorAddr - ) external view returns (bool, uint32[] memory); - - /// @dev getSubmitTaskResult is a function to query result info. - /// @param taskAddr The address of the avs task - /// @param taskID The id of task. - /// @param operatorAddr The address of the operator - function getSubmitTaskResult( - address taskAddr, - uint64 taskID, - string memory operatorAddr - ) external view returns (bool, uint32[] memory); - - /// @dev getOperatorInfo is a function to query operator info. - /// @param operatorAddr The address of the operator - function getOperatorInfo( - string memory operatorAddr - ) external view returns (bool, uint32[] memory); + ) external view returns (uint64[] memory info); - /// @dev getOperatorAssetInfos is a function to query operator asset info. + /// @dev isOperator checks if the given address is registered as an operator on exocore. /// @param operatorAddr The address of the operator - function getOperatorAssetInfos( + function isOperator( string memory operatorAddr - ) external view returns (bool, uint32[] memory); + ) external view returns (bool); } diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 0149f4b8c..95e012d40 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -462,120 +462,9 @@ "name": "getAVSInfo", "outputs": [ { - "components": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "avsAddress", - "type": "string" - }, - { - "internalType": "uint64", - "name": "minStakeAmount", - "type": "uint64" - }, - { - "internalType": "string", - "name": "taskAddr", - "type": "string" - }, - { - "internalType": "string", - "name": "slashAddr", - "type": "string" - }, - { - "internalType": "string", - "name": "rewardAddr", - "type": "string" - }, - { - "internalType": "string[]", - "name": "avsOwnerAddress", - "type": "string[]" - }, - { - "internalType": "string[]", - "name": "assetIDs", - "type": "string[]" - }, - { - "internalType": "uint64", - "name": "avsUnbondingPeriod", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "minSelfDelegation", - "type": "uint64" - }, - { - "internalType": "string", - "name": "epochIdentifier", - "type": "string" - }, - { - "internalType": "uint64", - "name": "minOptInOperators", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "minTotalStakeAmount", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "startingEpoch", - "type": "uint64" - }, - { - "internalType": "string", - "name": "chainId", - "type": "string" - }, - { - "internalType": "string", - "name": "avsReward", - "type": "string" - }, - { - "internalType": "string", - "name": "avsSlash", - "type": "string" - }, - { - "components": [ - { - "internalType": "string", - "name": "assetID", - "type": "string" - }, - { - "internalType": "int64", - "name": "amountEpochBasis", - "type": "int64" - } - ], - "internalType": "struct IAVSManager.AssetReward[]", - "name": "assetRewardAmountEpochBasis", - "type": "tuple[]" - } - ], - "internalType": "struct IAVSManager.AVSInfo", - "name": "info", - "type": "tuple" - } - ], - "internalType": "struct IAVSManager.QueryAVSInfoResponse", - "name": "info", - "type": "tuple" + "internalType": "string", + "name": "epochIdentifier", + "type": "string" } ], "stateMutability": "view", @@ -600,88 +489,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "address", - "name": "taskAddr", - "type": "address" - }, - { - "internalType": "uint64", - "name": "taskID", - "type": "uint64" - }, - { - "internalType": "string", - "name": "operatorAddr", - "type": "string" - } - ], - "name": "getChallengeInfo", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "internalType": "uint32[]", - "name": "", - "type": "uint32[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "operatorAddr", - "type": "string" - } - ], - "name": "getOperatorAssetInfos", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "internalType": "uint32[]", - "name": "", - "type": "uint32[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "operatorAddr", - "type": "string" - } - ], - "name": "getOperatorInfo", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "internalType": "uint32[]", - "name": "", - "type": "uint32[]" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -755,24 +562,14 @@ "internalType": "uint64", "name": "taskID", "type": "uint64" - }, - { - "internalType": "string", - "name": "operatorAddr", - "type": "string" } ], - "name": "getSubmitTaskResult", + "name": "getTaskInfo", "outputs": [ { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "internalType": "uint32[]", - "name": "", - "type": "uint32[]" + "internalType": "uint64[]", + "name": "info", + "type": "uint64[]" } ], "stateMutability": "view", @@ -781,27 +578,17 @@ { "inputs": [ { - "internalType": "address", - "name": "taskAddr", - "type": "address" - }, - { - "internalType": "uint64", - "name": "taskID", - "type": "uint64" + "internalType": "string", + "name": "operatorAddr", + "type": "string" } ], - "name": "getTaskInfo", + "name": "isOperator", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" - }, - { - "internalType": "uint32[]", - "name": "", - "type": "uint32[]" } ], "stateMutability": "view", diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index 980bdf322..9e12e2909 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -133,8 +133,13 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ } case MethodGetOptinOperators: bz, err = p.GetOptedInOperatorAccAddrs(ctx, contract, method, args) - case MethodGetRegisteredPubkey: - bz, err = p.GetRegisteredPubkey(ctx, contract, method, args) + case MethodGetAVSInfo: + bz, err = p.GetAVSInfo(ctx, contract, method, args) + case MethodGetTaskInfo: + bz, err = p.GetTaskInfo(ctx, contract, method, args) + case MethodIsOperator: + bz, err = p.IsOperator(ctx, contract, method, args) + case MethodGetAVSUSDValue: bz, err = p.GetAVSUSDValue(ctx, contract, method, args) if err != nil { @@ -155,14 +160,14 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ } case MethodRegisterOperatorToExocore: - bz, err = p.Challenge(ctx, evm.Origin, contract, stateDB, method, args) + bz, err = p.RegisterOperatorToExocore(ctx, evm.Origin, contract, stateDB, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack(false) } case MethodOperatorSubmitTask: - bz, err = p.Challenge(ctx, evm.Origin, contract, stateDB, method, args) + bz, err = p.OperatorSubmitTask(ctx, evm.Origin, contract, stateDB, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack(false) diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index ddd168297..8b795bf8b 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -817,3 +817,210 @@ func (suite *AVSManagerPrecompileSuite) TestRunRegTaskInfo() { }) } } + +func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToExocore() { + metaInfo := "operator info" + + commonMalleate := func() (common.Address, []byte) { + input, err := suite.precompile.Pack( + avs.MethodRegisterOperatorToExocore, + suite.Address, + metaInfo, + ) + suite.Require().NoError(err, "failed to pack input") + return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input + } + + successRet, err := suite.precompile.Methods[avs.MethodRegisterOperatorToExocore].Outputs.Pack(true) + suite.Require().NoError(err) + + testcases := []struct { + name string + malleate func() (common.Address, []byte) + readOnly bool + expPass bool + errContains string + returnBytes []byte + }{ + { + name: "pass for avs-registered", + malleate: func() (common.Address, []byte) { + return commonMalleate() + }, + readOnly: false, + expPass: true, + returnBytes: successRet, + }, + } + + for _, tc := range testcases { + tc := tc + suite.Run(tc.name, func() { + baseFee := suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx) + + // malleate testcase + caller, input := tc.malleate() + + contract := vm.NewPrecompile(vm.AccountRef(caller), suite.precompile, big.NewInt(0), uint64(1e6)) + contract.Input = input + + contractAddr := contract.Address() + // Build and sign Ethereum transaction + txArgs := evmtypes.EvmTxArgs{ + ChainID: suite.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 = suite.Address.String() + err := msgEthereumTx.Sign(suite.EthSigner, suite.Signer) + suite.Require().NoError(err, "failed to sign Ethereum message") + + // Instantiate config + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + cfg, err := suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, suite.App.EvmKeeper.ChainID()) + suite.Require().NoError(err, "failed to instantiate EVM config") + + msg, err := msgEthereumTx.AsMessage(suite.EthSigner, baseFee) + suite.Require().NoError(err, "failed to instantiate Ethereum message") + + // Instantiate EVM + evm := suite.App.EvmKeeper.NewEVM( + suite.Ctx, msg, cfg, nil, suite.StateDB, + ) + + params := suite.App.EvmKeeper.GetParams(suite.Ctx) + activePrecompiles := params.GetActivePrecompilesAddrs() + precompileMap := suite.App.EvmKeeper.Precompiles(activePrecompiles...) + err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) + suite.Require().NoError(err, "invalid precompiles", activePrecompiles) + evm.WithPrecompiles(precompileMap, activePrecompiles) + + // Run precompiled contract + bz, err := suite.precompile.Run(evm, contract, tc.readOnly) + // Check results + if tc.expPass { + suite.Require().NoError(err, "expected no error when running the precompile") + suite.Require().Equal(tc.returnBytes, bz, "the return doesn't match the expected result") + } else { + suite.Require().Error(err, "expected error to be returned when running the precompile") + suite.Require().Nil(bz, "expected returned bytes to be nil") + suite.Require().ErrorContains(err, tc.errContains) + } + }) + } +} + +//func (suite *AVSManagerPrecompileSuite) TestOperatorSubmitTask() { +// taskID := uint64(1) +// blsSignature, _ := hex.DecodeString("a772ecef43eef7970609fcd7875076ae78c069dff69e5db5f2e121a298b00dc8332da813d3c2218838625d93957608150d98e6805be746525389dc67e5ca7c1a9001aab2bed742dd2694249dd54149eadfc1b4e0edef800cb545032e3a57640e") +// taskContractAddress := "0xdAC17F958D2ee523a2206206994597C13D831ec7" +// stage := "1" +// +// commonMalleate := func() (common.Address, []byte) { +// input, err := suite.precompile.Pack( +// avs.MethodOperatorSubmitTask, +// suite.Address, +// taskID, +// make([]byte, 0), +// blsSignature, +// common.HexToAddress(taskContractAddress), +// stage, +// ) +// suite.Require().NoError(err, "failed to pack input") +// return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input +// } +// +// successRet, err := suite.precompile.Methods[avs.MethodOperatorSubmitTask].Outputs.Pack(true) +// suite.Require().NoError(err) +// +// testcases := []struct { +// name string +// malleate func() (common.Address, []byte) +// readOnly bool +// expPass bool +// errContains string +// returnBytes []byte +// }{ +// { +// name: "pass for avs-registered", +// malleate: func() (common.Address, []byte) { +// return commonMalleate() +// }, +// readOnly: false, +// expPass: true, +// returnBytes: successRet, +// }, +// } +// +// for _, tc := range testcases { +// tc := tc +// suite.Run(tc.name, func() { +// baseFee := suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx) +// +// // malleate testcase +// caller, input := tc.malleate() +// +// contract := vm.NewPrecompile(vm.AccountRef(caller), suite.precompile, big.NewInt(0), uint64(1e6)) +// contract.Input = input +// +// contractAddr := contract.Address() +// // Build and sign Ethereum transaction +// txArgs := evmtypes.EvmTxArgs{ +// ChainID: suite.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 = suite.Address.String() +// err := msgEthereumTx.Sign(suite.EthSigner, suite.Signer) +// suite.Require().NoError(err, "failed to sign Ethereum message") +// +// // Instantiate config +// proposerAddress := suite.Ctx.BlockHeader().ProposerAddress +// cfg, err := suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, suite.App.EvmKeeper.ChainID()) +// suite.Require().NoError(err, "failed to instantiate EVM config") +// +// msg, err := msgEthereumTx.AsMessage(suite.EthSigner, baseFee) +// suite.Require().NoError(err, "failed to instantiate Ethereum message") +// +// // Instantiate EVM +// evm := suite.App.EvmKeeper.NewEVM( +// suite.Ctx, msg, cfg, nil, suite.StateDB, +// ) +// +// params := suite.App.EvmKeeper.GetParams(suite.Ctx) +// activePrecompiles := params.GetActivePrecompilesAddrs() +// precompileMap := suite.App.EvmKeeper.Precompiles(activePrecompiles...) +// err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) +// suite.Require().NoError(err, "invalid precompiles", activePrecompiles) +// evm.WithPrecompiles(precompileMap, activePrecompiles) +// +// // Run precompiled contract +// bz, err := suite.precompile.Run(evm, contract, tc.readOnly) +// // Check results +// if tc.expPass { +// suite.Require().NoError(err, "expected no error when running the precompile") +// suite.Require().Equal(tc.returnBytes, bz, "the return doesn't match the expected result") +// } else { +// suite.Require().Error(err, "expected error to be returned when running the precompile") +// suite.Require().Nil(bz, "expected returned bytes to be nil") +// suite.Require().ErrorContains(err, tc.errContains) +// } +// }) +// } +//} diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 7b8c9eaa5..9dca19863 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -301,7 +301,7 @@ func (p Precompile) EmitOperatorRegisteredToExocore(ctx sdk.Context, stateDB vm. var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] + arguments := event.Inputs[0:3] packed, err := arguments.Pack( common.HexToAddress(params.CallerAddress), params.OperatorMetaInfo, @@ -332,7 +332,7 @@ func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.Stat var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:6] + arguments := event.Inputs[0:7] packed, err := arguments.Pack( common.HexToAddress(params.CallerAddress), params.TaskID, diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 497643b31..7150a9fe0 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -2,8 +2,11 @@ package avs import ( "fmt" + "strconv" + "strings" exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" + avstype "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -16,6 +19,10 @@ const ( MethodGetOptinOperators = "getOptInOperators" MethodGetAVSUSDValue = "getAVSUSDValue" MethodGetOperatorOptedUSDValue = "getOperatorOptedUSDValue" + + MethodGetAVSInfo = "getAVSInfo" + MethodGetTaskInfo = "getTaskInfo" + MethodIsOperator = "isOperator" ) func (p Precompile) GetRegisteredPubkey( @@ -106,3 +113,85 @@ func (p Precompile) GetOperatorOptedUSDValue( } return method.Outputs.Pack(amount.ActiveUSDValue.BigInt()) } + +func (p Precompile) GetAVSInfo( + ctx sdk.Context, + _ *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + if len(args) != len(p.ABI.Methods[MethodGetAVSInfo].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetAVSInfo].Inputs), len(args)) + } + // the key is set using the operator's acc address so the same logic should apply here + addr, ok := args[0].(common.Address) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) + } + + avs, err := p.avsKeeper.QueryAVSInfo(ctx, &avstype.QueryAVSInfoReq{AVSAddress: addr.String()}) + if err != nil { + // if the avs does not exist, return empty array + if strings.Contains(err.Error(), avstype.ErrNoKeyInTheStore.Error()) { + return method.Outputs.Pack("") + } + return nil, err + } + + return method.Outputs.Pack(avs.GetInfo().EpochIdentifier) +} + +func (p Precompile) IsOperator( + ctx sdk.Context, + _ *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + if len(args) != len(p.ABI.Methods[MethodIsOperator].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodIsOperator].Inputs), len(args)) + } + operatorAddr, ok := args[0].(string) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", operatorAddr) + } + + param, err := sdk.AccAddressFromBech32(operatorAddr) + if err != nil { + return nil, err + } + flag := p.avsKeeper.GetOperatorKeeper().IsOperator(ctx, param) + + return method.Outputs.Pack(flag) +} + +func (p Precompile) GetTaskInfo( + ctx sdk.Context, + _ *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + if len(args) != len(p.ABI.Methods[MethodGetTaskInfo].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetTaskInfo].Inputs), len(args)) + } + // the key is set using the operator's acc address so the same logic should apply here + addr, ok := args[0].(common.Address) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) + } + taskID, ok := args[1].(uint64) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", taskID) + } + + task, err := p.avsKeeper.QueryAVSTaskInfo(ctx, &avstype.QueryAVSTaskInfoReq{TaskAddr: addr.String(), TaskId: strconv.FormatUint(taskID, 10)}) + if err != nil { + // if the avs does not exist, return empty array + if strings.Contains(err.Error(), avstype.ErrNoKeyInTheStore.Error()) { + return method.Outputs.Pack("") + } + return nil, err + } + info := []uint64{task.StartingEpoch, task.TaskResponsePeriod, task.TaskStatisticalPeriod} + + return method.Outputs.Pack(info) +} diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index e15725289..e5d954375 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -2,6 +2,9 @@ package avs_test import ( "fmt" + epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/prysmaticlabs/prysm/v4/crypto/bls/blst" "math/big" "time" @@ -12,8 +15,10 @@ import ( avsManagerPrecompile "github.com/ExocoreNetwork/exocore/precompiles/avs" exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" + avstype "github.com/ExocoreNetwork/exocore/x/avs/types" operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" @@ -313,3 +318,233 @@ func (suite *AVSManagerPrecompileSuite) TestGetOperatorOptedUSDValue() { }) } } + +func (suite *AVSManagerPrecompileSuite) TestGetRegisteredPubkey() { + method := suite.precompile.Methods[avsManagerPrecompile.MethodGetRegisteredPubkey] + privateKey, err := blst.RandKey() + operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" + + publicKey := privateKey.PublicKey() + setUp := func() { + suite.prepareOperator() + + blsPub := &avstype.BlsPubKeyInfo{ + Operator: operatorAddr, + PubKey: publicKey.Marshal(), + Name: "", + } + err = suite.App.AVSManagerKeeper.SetOperatorPubKey(suite.Ctx, blsPub) + suite.NoError(err) + } + testCases := []avsTestCases{ + { + "success - existent pubKey", + func() []interface{} { + setUp() + return []interface{}{ + operatorAddr, + } + }, + func(bz []byte) { + var out []byte + err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodGetRegisteredPubkey, bz) + suite.Require().NoError(err, "failed to unpack output", err) + suite.Require().Equal(48, len(out)) + suite.Require().Equal(publicKey.Marshal(), out) + }, + 100000, + false, + "", + }, + } + testCases = append(testCases, baseTestCases[0]) + + for _, tc := range testCases { + suite.Run(tc.name, func() { + contract := vm.NewContract(vm.AccountRef(suite.Address), suite.precompile, big.NewInt(0), tc.gas) + + bz, err := suite.precompile.GetRegisteredPubkey(suite.Ctx, contract, &method, tc.malleate()) + + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.errContains) + } else { + suite.Require().NoError(err) + suite.Require().NotEmpty(bz) + tc.postCheck(bz) + } + }) + } +} + +func (suite *AVSManagerPrecompileSuite) TestGetAVSInfo() { + method := suite.precompile.Methods[avsManagerPrecompile.MethodGetAVSInfo] + avsAddress := "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" + + setUp := func() { + avsName := "avsTest" + avsOwnerAddress := []string{"exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj1", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj2"} + assetID := suite.AssetIDs + avs := &avstype.AVSInfo{ + Name: avsName, + AvsAddress: avsAddress, + SlashAddr: utiltx.GenerateAddress().String(), + AvsOwnerAddress: avsOwnerAddress, + AssetIDs: assetID, + AvsUnbondingPeriod: 7, + MinSelfDelegation: 10, + EpochIdentifier: epochstypes.DayEpochID, + StartingEpoch: 1, + MinOptInOperators: 100, + MinTotalStakeAmount: 1000, + AvsSlash: sdk.MustNewDecFromStr("0.001"), + AvsReward: sdk.MustNewDecFromStr("0.002"), + TaskAddr: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + } + + err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) + suite.NoError(err) + } + testCases := []avsTestCases{ + { + "success - existent avs", + func() []interface{} { + setUp() + return []interface{}{ + common.HexToAddress(avsAddress), + } + }, + func(bz []byte) { + var out string + + err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodGetAVSInfo, bz) + suite.Require().NoError(err, "failed to unpack output", err) + suite.Require().Equal(epochstypes.DayEpochID, out) + }, + 100000, + false, + "", + }, + } + testCases = append(testCases, baseTestCases[0]) + + for _, tc := range testCases { + suite.Run(tc.name, func() { + contract := vm.NewContract(vm.AccountRef(suite.Address), suite.precompile, big.NewInt(0), tc.gas) + + bz, err := suite.precompile.GetAVSInfo(suite.Ctx, contract, &method, tc.malleate()) + + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.errContains) + } else { + suite.Require().NoError(err) + suite.Require().NotEmpty(bz) + tc.postCheck(bz) + } + }) + } +} + +func (suite *AVSManagerPrecompileSuite) TestIsoperator() { + method := suite.precompile.Methods[avsManagerPrecompile.MethodIsOperator] + operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" + + testCases := []avsTestCases{ + { + "success - existent operator", + func() []interface{} { + suite.prepareOperator() + return []interface{}{ + operatorAddr, + } + }, + func(bz []byte) { + var out bool + err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodIsOperator, bz) + suite.Require().NoError(err, "failed to unpack output", err) + suite.Require().Equal(true, out) + }, + 100000, + false, + "", + }, + } + testCases = append(testCases, baseTestCases[0]) + + for _, tc := range testCases { + suite.Run(tc.name, func() { + contract := vm.NewContract(vm.AccountRef(suite.Address), suite.precompile, big.NewInt(0), tc.gas) + + bz, err := suite.precompile.IsOperator(suite.Ctx, contract, &method, tc.malleate()) + + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.errContains) + } else { + suite.Require().NoError(err) + suite.Require().NotEmpty(bz) + tc.postCheck(bz) + } + }) + } +} +func (suite *AVSManagerPrecompileSuite) TestGetTaskInfo() { + method := suite.precompile.Methods[avsManagerPrecompile.MethodGetTaskInfo] + taskAddress := "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" + + setUp := func() { + info := &avstype.TaskInfo{ + TaskContractAddress: taskAddress, + Name: "test-avstask-01", + TaskId: uint64(3), + Hash: []byte("active"), + TaskResponsePeriod: 10, + StartingEpoch: 5, + TaskStatisticalPeriod: 60, + TaskTotalPower: sdk.Dec(sdkmath.NewInt(0)), + } + err := suite.App.AVSManagerKeeper.SetTaskInfo(suite.Ctx, info) + suite.NoError(err) + } + testCases := []avsTestCases{ + { + "success - existent task", + func() []interface{} { + setUp() + return []interface{}{ + common.HexToAddress(taskAddress), + uint64(3), + } + }, + func(bz []byte) { + var out []uint64 + + err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodGetTaskInfo, bz) + suite.Require().NoError(err, "failed to unpack output", err) + suite.Require().Equal([]uint64{5, 10, 60}, out) + }, + 100000, + false, + "", + }, + } + testCases = append(testCases, baseTestCases[0]) + + for _, tc := range testCases { + suite.Run(tc.name, func() { + contract := vm.NewContract(vm.AccountRef(suite.Address), suite.precompile, big.NewInt(0), tc.gas) + + bz, err := suite.precompile.GetTaskInfo(suite.Ctx, contract, &method, tc.malleate()) + + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.errContains) + } else { + suite.Require().NoError(err) + suite.Require().NotEmpty(bz) + tc.postCheck(bz) + } + }) + } +} diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 7059728ec..81db1e482 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -341,8 +341,8 @@ func (p Precompile) RegisterOperatorToExocore( method *abi.Method, args []interface{}, ) ([]byte, error) { - if len(args) != len(p.ABI.Methods[MethodRegisterOperatorToAVS].Inputs) { - return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterOperatorToAVS].Inputs), len(args)) + if len(args) != len(p.ABI.Methods[MethodRegisterOperatorToExocore].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterOperatorToExocore].Inputs), len(args)) } operatorParams := &avskeeper.OperatorParams{} callerAddress, ok := args[0].(common.Address) @@ -408,9 +408,15 @@ func (p Precompile) OperatorSubmitTask( } resultParams.BlsSignature = blsSignature - stage, ok := args[4].(string) + taskAddr, ok := args[4].(common.Address) + if !ok || (taskAddr == common.Address{}) { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "common.Address", taskAddr) + } + resultParams.TaskContractAddress = taskAddr + + stage, ok := args[5].(string) if !ok || stage == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "string", stage) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, "string", stage) } resultParams.Stage = stage @@ -420,7 +426,7 @@ func (p Precompile) OperatorSubmitTask( return nil, err } - if err = p.EmitTaskSubmittedByOperator(ctx, stateDB, resultParams); err != nil { + if err := p.EmitTaskSubmittedByOperator(ctx, stateDB, resultParams); err != nil { return nil, err } return method.Outputs.Pack(true) diff --git a/x/avs/keeper/task.go b/x/avs/keeper/task.go index f748a3d7c..17c1d3c36 100644 --- a/x/avs/keeper/task.go +++ b/x/avs/keeper/task.go @@ -5,6 +5,7 @@ import ( "fmt" "sort" "strconv" + "strings" "github.com/ethereum/go-ethereum/crypto" @@ -24,7 +25,7 @@ func (k Keeper) SetTaskInfo(ctx sdk.Context, task *types.TaskInfo) (err error) { return types.ErrInvalidAddr } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskInfo) - infoKey := assetstype.GetJoinedStoreKey(task.TaskContractAddress, strconv.FormatUint(task.TaskId, 10)) + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(task.TaskContractAddress), strconv.FormatUint(task.TaskId, 10)) bz := k.cdc.MustMarshal(task) store.Set(infoKey, bz) return nil @@ -35,7 +36,7 @@ func (k *Keeper) GetTaskInfo(ctx sdk.Context, taskID, taskContractAddress string return nil, types.ErrInvalidAddr } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskInfo) - infoKey := assetstype.GetJoinedStoreKey(taskContractAddress, taskID) + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(taskContractAddress), taskID) value := store.Get(infoKey) if value == nil { return nil, errorsmod.Wrap(types.ErrNoKeyInTheStore, @@ -49,7 +50,7 @@ func (k *Keeper) GetTaskInfo(ctx sdk.Context, taskID, taskContractAddress string func (k *Keeper) IsExistTask(ctx sdk.Context, taskID, taskContractAddress string) bool { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAVSTaskInfo) - infoKey := assetstype.GetJoinedStoreKey(taskContractAddress, taskID) + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(taskContractAddress), taskID) return store.Has(infoKey) } @@ -213,7 +214,7 @@ func (k *Keeper) SetTaskResultInfo( fmt.Sprintf("SetTaskResultInfo:submit too late, CurrentEpoch:%d", epoch.CurrentEpoch), ) } - infoKey := assetstype.GetJoinedStoreKey(info.OperatorAddress, info.TaskContractAddress, + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(info.OperatorAddress), strings.ToLower(info.TaskContractAddress), strconv.FormatUint(info.TaskId, 10)) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskResult) bz := k.cdc.MustMarshal(info) @@ -274,7 +275,7 @@ func (k *Keeper) SetTaskResultInfo( ) } - infoKey := assetstype.GetJoinedStoreKey(info.OperatorAddress, info.TaskContractAddress, strconv.FormatUint(info.TaskId, 10)) + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(info.OperatorAddress), strings.ToLower(info.TaskContractAddress), strconv.FormatUint(info.TaskId, 10)) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskResult) bz := k.cdc.MustMarshal(info) @@ -289,7 +290,7 @@ func (k *Keeper) SetTaskResultInfo( } func (k *Keeper) IsExistTaskResultInfo(ctx sdk.Context, operatorAddress, taskContractAddress string, taskID uint64) bool { - infoKey := assetstype.GetJoinedStoreKey(operatorAddress, taskContractAddress, + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(operatorAddress), strings.ToLower(taskContractAddress), strconv.FormatUint(taskID, 10)) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskResult) return store.Has(infoKey) @@ -300,7 +301,7 @@ func (k *Keeper) GetTaskResultInfo(ctx sdk.Context, operatorAddress, taskContrac return nil, types.ErrInvalidAddr } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskResult) - infoKey := assetstype.GetJoinedStoreKey(operatorAddress, taskContractAddress, + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(operatorAddress), strings.ToLower(taskContractAddress), strconv.FormatUint(taskID, 10)) value := store.Get(infoKey) if value == nil { @@ -359,7 +360,7 @@ func (k *Keeper) SetTaskChallengedInfo( ctx sdk.Context, taskID uint64, operatorAddress, challengeAddr string, taskAddr common.Address, ) (err error) { - infoKey := assetstype.GetJoinedStoreKey(operatorAddress, taskAddr.String(), + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(operatorAddress), strings.ToLower(taskAddr.String()), strconv.FormatUint(taskID, 10)) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskChallengeResult) @@ -373,7 +374,7 @@ func (k *Keeper) SetTaskChallengedInfo( } func (k *Keeper) IsExistTaskChallengedInfo(ctx sdk.Context, operatorAddress, taskContractAddress string, taskID uint64) bool { - infoKey := assetstype.GetJoinedStoreKey(operatorAddress, taskContractAddress, + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(operatorAddress), strings.ToLower(taskContractAddress), strconv.FormatUint(taskID, 10)) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskChallengeResult) return store.Has(infoKey) @@ -384,7 +385,7 @@ func (k *Keeper) GetTaskChallengedInfo(ctx sdk.Context, operatorAddress, taskCon return "", types.ErrInvalidAddr } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTaskChallengeResult) - infoKey := assetstype.GetJoinedStoreKey(operatorAddress, taskContractAddress, + infoKey := assetstype.GetJoinedStoreKey(strings.ToLower(operatorAddress), strings.ToLower(taskContractAddress), strconv.FormatUint(taskID, 10)) value := store.Get(infoKey) if value == nil { diff --git a/x/avs/types/expected_keepers.go b/x/avs/types/expected_keepers.go index a2365fd71..ffa0a3fca 100644 --- a/x/avs/types/expected_keepers.go +++ b/x/avs/types/expected_keepers.go @@ -45,6 +45,7 @@ type OperatorKeeper interface { GetOperatorOptedUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) (operatortypes.OperatorOptedUSDValue, error) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) + QueryOperatorInfo(ctx context.Context, req *operatortypes.GetOperatorInfoReq) (*operatortypes.OperatorInfo, error) } // AssetsKeeper represents the expected keeper interface for the assets module. From 64993ff947e0c91115cc218dbc634f2e788e97ea Mon Sep 17 00:00:00 2001 From: trestin Date: Mon, 21 Oct 2024 14:48:06 +0800 Subject: [PATCH 08/24] obtain the specified current epoch based on epochIdentifier --- precompiles/avs/IAVSManager.sol | 5 ++++ precompiles/avs/abi.json | 19 +++++++++++++++ precompiles/avs/avs.go | 25 +++++++++++++++++++- precompiles/avs/query.go | 32 +++++++++++++++++++++---- precompiles/avs/query_test.go | 41 +++++++++++++++++++++++++++++++++ x/avs/keeper/keeper.go | 5 ++++ 6 files changed, 121 insertions(+), 6 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index b8baee238..cbfd38142 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -247,4 +247,9 @@ interface IAVSManager { string memory operatorAddr ) external view returns (bool); + /// @dev getCurrentEpoch obtain the specified current epoch based on epochIdentifier. + /// @param epochIdentifier is a descriptive or unique identifier for the epoch + function getCurrentEpoch( + string memory epochIdentifier + ) external view returns (int64 currentEpoch); } diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 95e012d40..4b8baf81d 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -489,6 +489,25 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "string", + "name": "epochIdentifier", + "type": "string" + } + ], + "name": "getCurrentEpoch", + "outputs": [ + { + "internalType": "int64", + "name": "currentEpoch", + "type": "int64" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index 9e12e2909..53d6c7f63 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -133,12 +133,28 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ } case MethodGetOptinOperators: bz, err = p.GetOptedInOperatorAccAddrs(ctx, contract, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } case MethodGetAVSInfo: bz, err = p.GetAVSInfo(ctx, contract, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } case MethodGetTaskInfo: bz, err = p.GetTaskInfo(ctx, contract, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } case MethodIsOperator: bz, err = p.IsOperator(ctx, contract, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } case MethodGetAVSUSDValue: bz, err = p.GetAVSUSDValue(ctx, contract, method, args) @@ -152,6 +168,12 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack(common.Big0) } + case MethodGetCurrentEpoch: + bz, err = p.GetCurrentEpoch(ctx, contract, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack(false) + } case MethodChallenge: bz, err = p.Challenge(ctx, evm.Origin, contract, stateDB, method, args) if err != nil { @@ -197,7 +219,8 @@ func (Precompile) IsTransaction(methodID string) bool { MethodDeregisterOperatorFromAVS, MethodCreateAVSTask, MethodRegisterBLSPublicKey, MethodChallenge, MethodRegisterOperatorToExocore, MethodOperatorSubmitTask: return true - case MethodGetRegisteredPubkey, MethodGetOptinOperators, MethodGetAVSUSDValue, MethodGetOperatorOptedUSDValue: + case MethodGetRegisteredPubkey, MethodGetOptinOperators, MethodGetAVSUSDValue, MethodGetOperatorOptedUSDValue, + MethodGetAVSInfo, MethodGetTaskInfo, MethodIsOperator, MethodGetCurrentEpoch: return false default: return false diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 7150a9fe0..78367a3de 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -20,9 +20,10 @@ const ( MethodGetAVSUSDValue = "getAVSUSDValue" MethodGetOperatorOptedUSDValue = "getOperatorOptedUSDValue" - MethodGetAVSInfo = "getAVSInfo" - MethodGetTaskInfo = "getTaskInfo" - MethodIsOperator = "isOperator" + MethodGetAVSInfo = "getAVSInfo" + MethodGetTaskInfo = "getTaskInfo" + MethodIsOperator = "isOperator" + MethodGetCurrentEpoch = "getCurrentEpoch" ) func (p Precompile) GetRegisteredPubkey( @@ -76,7 +77,7 @@ func (p Precompile) GetAVSUSDValue( args []interface{}, ) ([]byte, error) { if len(args) != len(p.ABI.Methods[MethodGetAVSUSDValue].Inputs) { - return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterAVS].Inputs), len(args)) + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetAVSUSDValue].Inputs), len(args)) } addr, ok := args[0].(common.Address) if !ok { @@ -97,7 +98,7 @@ func (p Precompile) GetOperatorOptedUSDValue( args []interface{}, ) ([]byte, error) { if len(args) != len(p.ABI.Methods[MethodGetOperatorOptedUSDValue].Inputs) { - return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterAVS].Inputs), len(args)) + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetOperatorOptedUSDValue].Inputs), len(args)) } avsAddr, ok := args[0].(common.Address) if !ok { @@ -195,3 +196,24 @@ func (p Precompile) GetTaskInfo( return method.Outputs.Pack(info) } + +// GetCurrentEpoch obtain the specified current epoch based on epochIdentifier. +func (p Precompile) GetCurrentEpoch( + ctx sdk.Context, + _ *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + if len(args) != len(p.ABI.Methods[MethodGetCurrentEpoch].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetCurrentEpoch].Inputs), len(args)) + } + epochIdentifier, ok := args[0].(string) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", epochIdentifier) + } + epoch, flag := p.avsKeeper.GetEpochKeeper().GetEpochInfo(ctx, epochIdentifier) + if !flag { + return nil, nil + } + return method.Outputs.Pack(epoch.CurrentEpoch) +} diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index e5d954375..de9a99990 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -548,3 +548,44 @@ func (suite *AVSManagerPrecompileSuite) TestGetTaskInfo() { }) } } +func (suite *AVSManagerPrecompileSuite) TestGetCurrentEpoch() { + method := suite.precompile.Methods[avsManagerPrecompile.MethodGetCurrentEpoch] + testCases := []avsTestCases{ + { + "success - existent avs", + func() []interface{} { + return []interface{}{ + epochstypes.DayEpochID, + } + }, + func(bz []byte) { + var out int64 + + err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodGetCurrentEpoch, bz) + suite.Require().NoError(err, "failed to unpack output", err) + suite.Require().Equal(int64(1), out) + }, + 100000, + false, + "", + }, + } + testCases = append(testCases, baseTestCases[0]) + + for _, tc := range testCases { + suite.Run(tc.name, func() { + contract := vm.NewContract(vm.AccountRef(suite.Address), suite.precompile, big.NewInt(0), tc.gas) + + bz, err := suite.precompile.GetCurrentEpoch(suite.Ctx, contract, &method, tc.malleate()) + + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.errContains) + } else { + suite.Require().NoError(err) + suite.Require().NotEmpty(bz) + tc.postCheck(bz) + } + }) + } +} diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 3bdf42184..f21b11182 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -62,6 +62,11 @@ func (k Keeper) GetOperatorKeeper() types.OperatorKeeper { return k.operatorKeeper } +// GetEpochKeeper returns the operatorKeeper from the Keeper struct. +func (k Keeper) GetEpochKeeper() types.EpochsKeeper { + return k.epochsKeeper +} + func (k Keeper) ValidateAssetIDs(ctx sdk.Context, assetIDs []string) error { for _, assetID := range assetIDs { if !k.assetsKeeper.IsStakingAsset(ctx, assetID) { From 6ccf100e4013dba124ec1af1f7321df583ecbdaf Mon Sep 17 00:00:00 2001 From: trestin Date: Wed, 23 Oct 2024 12:46:54 +0800 Subject: [PATCH 09/24] fix some comments --- go.mod | 4 +- go.sum | 60 +--- precompiles/avs/IAVSManager.sol | 26 -- precompiles/avs/abi.json | 24 -- precompiles/avs/avs.go | 27 +- precompiles/avs/avs_test.go | 265 +++--------------- precompiles/avs/events.go | 67 ++--- precompiles/avs/query.go | 9 +- precompiles/avs/tx.go | 66 +---- precompiles/avs/types.go | 5 +- precompiles/avs/utils_test.go | 3 +- x/avs/keeper/avs.go | 2 +- x/avs/keeper/avs_test.go | 6 +- x/avs/keeper/keeper.go | 20 +- .../keeper/multi_operator_submit_task_test.go | 3 +- x/avs/keeper/params.go | 89 ------ x/avs/keeper/submit_task_test.go | 3 +- x/avs/types/expected_keepers.go | 5 +- x/avs/types/stage.go | 92 ++++++ x/dogfood/keeper/msg_server.go | 3 +- x/operator/keeper/opt_test.go | 3 +- 21 files changed, 205 insertions(+), 577 deletions(-) diff --git a/go.mod b/go.mod index 6c0fa830a..c53f172c4 100644 --- a/go.mod +++ b/go.mod @@ -271,8 +271,10 @@ replace ( github.com/evmos/evmos/v16 => github.com/ExocoreNetwork/evmos/v16 v16.0.3-0.20240828081344-d5cfcd34a812 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 + github.com/ledgerwatch/interfaces => github.com/ledgerwatch/interfaces v0.0.0-20240911002112-53ce6989bb37 // replace broken goleveldb github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - //fix cosmos-sdk error golang.org/x/exp => golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc + nhooyr.io/websocket => nhooyr.io/websocket v1.8.17 + ) diff --git a/go.sum b/go.sum index 7e290a7ad..b2324eb1a 100644 --- a/go.sum +++ b/go.sum @@ -642,9 +642,6 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -662,9 +659,6 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= @@ -851,18 +845,12 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= @@ -895,13 +883,6 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -910,18 +891,7 @@ github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= -github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= -github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/gobwas/ws v1.2.1 h1:F2aeBZrm2NDsc7vbovKrWSogd4wvfAxg0FQ89/iqOTk= -github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -1078,7 +1048,6 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -1187,8 +1156,6 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -1204,7 +1171,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= -github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= @@ -1212,7 +1178,6 @@ github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrD github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1230,8 +1195,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= @@ -1294,12 +1257,9 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= @@ -1362,7 +1322,6 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -1530,8 +1489,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -1566,13 +1523,9 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -1646,9 +1599,6 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1666,8 +1616,6 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= @@ -1782,7 +1730,6 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1928,7 +1875,6 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1956,7 +1902,6 @@ golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2423,9 +2368,8 @@ modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= -nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= -nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= +nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA= pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index cbfd38142..891e8929c 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -29,24 +29,6 @@ interface IAVSManager { string blsSignature, string taskContractAddress, string stage, bool success); - struct TaskInfo { - string taskContractAddress; - string name; - bytes hash; - uint64 taskId; - uint64 taskResponsePeriod; - uint64 taskStatisticalPeriod; - uint64 taskChallengePeriod; - uint64 thresholdPercentage; - uint64 startingEpoch; - uint64 actualThreshold; - string[] optInOperators; - string[] signedOperators; - string[] noSignedOperators; - string[] errSignedOperators; - string taskTotalPower; - // OperatorActivePowerList is not defined here as it's not clear from the provided message - } /// @dev Register AVS contract to EXO. /// @param sender The external address for calling this method. /// @param avsName The name of AVS. @@ -177,14 +159,6 @@ interface IAVSManager { bytes calldata pubkeyRegistrationMessageHash ) external returns (bool success); - /// @dev registerOperatorToExocore , this function enables a precompile handler for creating a RegisterOperatorReq. - /// @param sender The external address for calling this method. - /// @param metaInfo The data supplied by the contract, usually ABI-encoded. - function registerOperatorToExocore( - address sender, - string memory metaInfo - ) external returns (bool success); - /// @dev operatorSubmitTask , this function enables a operator submit a task result. /// @param sender The external address for calling this method. /// @param taskID The id of task. diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 4b8baf81d..6063b024a 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -789,30 +789,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "string", - "name": "metaInfo", - "type": "string" - } - ], - "name": "registerOperatorToExocore", - "outputs": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index 53d6c7f63..fc49f0835 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -123,7 +123,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.CreateAVSTask(ctx, evm.Origin, contract, stateDB, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack(false) + bz, err = method.Outputs.Pack(false, uint64(0)) } case MethodRegisterBLSPublicKey: bz, err = p.RegisterBLSPublicKey(ctx, evm.Origin, contract, stateDB, method, args) @@ -135,19 +135,19 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.GetOptedInOperatorAccAddrs(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack(false) + bz, err = method.Outputs.Pack([]string(nil)) } case MethodGetAVSInfo: bz, err = p.GetAVSInfo(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack(false) + bz, err = method.Outputs.Pack("") } case MethodGetTaskInfo: bz, err = p.GetTaskInfo(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack(false) + bz, err = method.Outputs.Pack([]uint64(nil)) } case MethodIsOperator: bz, err = p.IsOperator(ctx, contract, method, args) @@ -162,6 +162,13 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack(common.Big0) } + + case MethodGetRegisteredPubkey: + bz, err = p.GetRegisteredPubkey(ctx, contract, method, args) + if err != nil { + ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) + bz, err = method.Outputs.Pack([]byte(nil)) + } case MethodGetOperatorOptedUSDValue: bz, err = p.GetOperatorOptedUSDValue(ctx, contract, method, args) if err != nil { @@ -172,7 +179,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.GetCurrentEpoch(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack(false) + bz, err = method.Outputs.Pack(int64(0)) } case MethodChallenge: bz, err = p.Challenge(ctx, evm.Origin, contract, stateDB, method, args) @@ -181,13 +188,6 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = method.Outputs.Pack(false) } - case MethodRegisterOperatorToExocore: - bz, err = p.RegisterOperatorToExocore(ctx, evm.Origin, contract, stateDB, method, args) - if err != nil { - ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack(false) - } - case MethodOperatorSubmitTask: bz, err = p.OperatorSubmitTask(ctx, evm.Origin, contract, stateDB, method, args) if err != nil { @@ -216,8 +216,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ func (Precompile) IsTransaction(methodID string) bool { switch methodID { case MethodRegisterAVS, MethodDeregisterAVS, MethodUpdateAVS, MethodRegisterOperatorToAVS, - MethodDeregisterOperatorFromAVS, MethodCreateAVSTask, MethodRegisterBLSPublicKey, MethodChallenge, - MethodRegisterOperatorToExocore, MethodOperatorSubmitTask: + MethodDeregisterOperatorFromAVS, MethodCreateAVSTask, MethodRegisterBLSPublicKey, MethodChallenge, MethodOperatorSubmitTask: return true case MethodGetRegisteredPubkey, MethodGetOptinOperators, MethodGetAVSUSDValue, MethodGetOperatorOptedUSDValue, MethodGetAVSInfo, MethodGetTaskInfo, MethodIsOperator, MethodGetCurrentEpoch: diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index 8b795bf8b..5cd2ae474 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -3,9 +3,9 @@ package avs_test import ( "cosmossdk.io/math" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" "github.com/ExocoreNetwork/exocore/x/avs/types" "math/big" + "strconv" "time" sdkmath "cosmossdk.io/math" @@ -71,11 +71,6 @@ func (suite *AVSManagerPrecompileSuite) TestIsTransaction() { suite.precompile.Methods[avs.MethodChallenge].Name, true, }, - { - avs.MethodRegisterOperatorToExocore, - suite.precompile.Methods[avs.MethodRegisterOperatorToExocore].Name, - true, - }, { avs.MethodOperatorSubmitTask, suite.precompile.Methods[avs.MethodOperatorSubmitTask].Name, @@ -102,7 +97,6 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { avsUnbondingPeriod, minSelfDelegation := uint64(3), uint64(3) epochIdentifier := epochstypes.DayEpochID params := []uint64{2, 3, 4, 4} - commonMalleate := func() (common.Address, []byte) { input, err := suite.precompile.Pack( avs.MethodRegisterAVS, @@ -197,14 +191,6 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterAVS() { // Run precompiled contract bz, err := suite.precompile.Run(evm, contract, tc.readOnly) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) - suite.CommitAfter(time.Hour*24 + time.Nanosecond) // Check results if tc.expPass { suite.Require().NoError(err, "expected no error when running the precompile") @@ -228,11 +214,47 @@ func (suite *AVSManagerPrecompileSuite) TestDeregisterAVS() { avsName, ) suite.Require().NoError(err, "failed to pack input") - return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input + return suite.Address, input } successRet, err := suite.precompile.Methods[avs.MethodDeregisterAVS].Outputs.Pack(true) suite.Require().NoError(err) + setUp := func() { + slashAddress, rewardAddress := "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" + avsOwnerAddress := []string{ + sdk.AccAddress(suite.Address.Bytes()).String(), + sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), + sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), + } + assetID := suite.AssetIDs + minStakeAmount, taskAddr := uint64(3), "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" + avsUnbondingPeriod, minSelfDelegation := uint64(3), uint64(3) + epochIdentifier := epochstypes.DayEpochID + params := []uint64{2, 3, 4, 4} + avs := &types.AVSInfo{ + Name: avsName, + AvsAddress: suite.Address.String(), + SlashAddr: slashAddress, + RewardAddr: rewardAddress, + AvsOwnerAddress: avsOwnerAddress, + AssetIDs: assetID, + AvsUnbondingPeriod: avsUnbondingPeriod, + MinSelfDelegation: minSelfDelegation, + EpochIdentifier: epochIdentifier, + StartingEpoch: 1, + TaskAddr: taskAddr, + MinStakeAmount: minStakeAmount, + MinOptInOperators: params[0], + MinTotalStakeAmount: params[1], + AvsReward: sdk.MustNewDecFromStr(strconv.FormatUint(params[1], 10)), + AvsSlash: sdk.MustNewDecFromStr(strconv.FormatUint(params[2], 10)), + } + err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) + suite.NoError(err) + for i := 0; i < int(avsUnbondingPeriod)+2; i++ { + suite.CommitAfter(time.Hour*24 + time.Nanosecond) + } + } testcases := []struct { name string malleate func() (common.Address, []byte) @@ -244,7 +266,7 @@ func (suite *AVSManagerPrecompileSuite) TestDeregisterAVS() { { name: "pass for avs-deregister", malleate: func() (common.Address, []byte) { - suite.TestRegisterAVS() + setUp() return commonMalleate() }, readOnly: false, @@ -491,7 +513,7 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { asset := suite.Assets[0] _, defaultAssetID := assetstypes.GetStakerIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &types.AVSRegisterOrDeregisterParams{ - Action: avskeeper.UpdateAction, + Action: types.UpdateAction, AvsAddress: avsAddr.String(), AssetID: []string{defaultAssetID}, }) @@ -817,210 +839,3 @@ func (suite *AVSManagerPrecompileSuite) TestRunRegTaskInfo() { }) } } - -func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToExocore() { - metaInfo := "operator info" - - commonMalleate := func() (common.Address, []byte) { - input, err := suite.precompile.Pack( - avs.MethodRegisterOperatorToExocore, - suite.Address, - metaInfo, - ) - suite.Require().NoError(err, "failed to pack input") - return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input - } - - successRet, err := suite.precompile.Methods[avs.MethodRegisterOperatorToExocore].Outputs.Pack(true) - suite.Require().NoError(err) - - testcases := []struct { - name string - malleate func() (common.Address, []byte) - readOnly bool - expPass bool - errContains string - returnBytes []byte - }{ - { - name: "pass for avs-registered", - malleate: func() (common.Address, []byte) { - return commonMalleate() - }, - readOnly: false, - expPass: true, - returnBytes: successRet, - }, - } - - for _, tc := range testcases { - tc := tc - suite.Run(tc.name, func() { - baseFee := suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx) - - // malleate testcase - caller, input := tc.malleate() - - contract := vm.NewPrecompile(vm.AccountRef(caller), suite.precompile, big.NewInt(0), uint64(1e6)) - contract.Input = input - - contractAddr := contract.Address() - // Build and sign Ethereum transaction - txArgs := evmtypes.EvmTxArgs{ - ChainID: suite.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 = suite.Address.String() - err := msgEthereumTx.Sign(suite.EthSigner, suite.Signer) - suite.Require().NoError(err, "failed to sign Ethereum message") - - // Instantiate config - proposerAddress := suite.Ctx.BlockHeader().ProposerAddress - cfg, err := suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, suite.App.EvmKeeper.ChainID()) - suite.Require().NoError(err, "failed to instantiate EVM config") - - msg, err := msgEthereumTx.AsMessage(suite.EthSigner, baseFee) - suite.Require().NoError(err, "failed to instantiate Ethereum message") - - // Instantiate EVM - evm := suite.App.EvmKeeper.NewEVM( - suite.Ctx, msg, cfg, nil, suite.StateDB, - ) - - params := suite.App.EvmKeeper.GetParams(suite.Ctx) - activePrecompiles := params.GetActivePrecompilesAddrs() - precompileMap := suite.App.EvmKeeper.Precompiles(activePrecompiles...) - err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) - suite.Require().NoError(err, "invalid precompiles", activePrecompiles) - evm.WithPrecompiles(precompileMap, activePrecompiles) - - // Run precompiled contract - bz, err := suite.precompile.Run(evm, contract, tc.readOnly) - // Check results - if tc.expPass { - suite.Require().NoError(err, "expected no error when running the precompile") - suite.Require().Equal(tc.returnBytes, bz, "the return doesn't match the expected result") - } else { - suite.Require().Error(err, "expected error to be returned when running the precompile") - suite.Require().Nil(bz, "expected returned bytes to be nil") - suite.Require().ErrorContains(err, tc.errContains) - } - }) - } -} - -//func (suite *AVSManagerPrecompileSuite) TestOperatorSubmitTask() { -// taskID := uint64(1) -// blsSignature, _ := hex.DecodeString("a772ecef43eef7970609fcd7875076ae78c069dff69e5db5f2e121a298b00dc8332da813d3c2218838625d93957608150d98e6805be746525389dc67e5ca7c1a9001aab2bed742dd2694249dd54149eadfc1b4e0edef800cb545032e3a57640e") -// taskContractAddress := "0xdAC17F958D2ee523a2206206994597C13D831ec7" -// stage := "1" -// -// commonMalleate := func() (common.Address, []byte) { -// input, err := suite.precompile.Pack( -// avs.MethodOperatorSubmitTask, -// suite.Address, -// taskID, -// make([]byte, 0), -// blsSignature, -// common.HexToAddress(taskContractAddress), -// stage, -// ) -// suite.Require().NoError(err, "failed to pack input") -// return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input -// } -// -// successRet, err := suite.precompile.Methods[avs.MethodOperatorSubmitTask].Outputs.Pack(true) -// suite.Require().NoError(err) -// -// testcases := []struct { -// name string -// malleate func() (common.Address, []byte) -// readOnly bool -// expPass bool -// errContains string -// returnBytes []byte -// }{ -// { -// name: "pass for avs-registered", -// malleate: func() (common.Address, []byte) { -// return commonMalleate() -// }, -// readOnly: false, -// expPass: true, -// returnBytes: successRet, -// }, -// } -// -// for _, tc := range testcases { -// tc := tc -// suite.Run(tc.name, func() { -// baseFee := suite.App.FeeMarketKeeper.GetBaseFee(suite.Ctx) -// -// // malleate testcase -// caller, input := tc.malleate() -// -// contract := vm.NewPrecompile(vm.AccountRef(caller), suite.precompile, big.NewInt(0), uint64(1e6)) -// contract.Input = input -// -// contractAddr := contract.Address() -// // Build and sign Ethereum transaction -// txArgs := evmtypes.EvmTxArgs{ -// ChainID: suite.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 = suite.Address.String() -// err := msgEthereumTx.Sign(suite.EthSigner, suite.Signer) -// suite.Require().NoError(err, "failed to sign Ethereum message") -// -// // Instantiate config -// proposerAddress := suite.Ctx.BlockHeader().ProposerAddress -// cfg, err := suite.App.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, suite.App.EvmKeeper.ChainID()) -// suite.Require().NoError(err, "failed to instantiate EVM config") -// -// msg, err := msgEthereumTx.AsMessage(suite.EthSigner, baseFee) -// suite.Require().NoError(err, "failed to instantiate Ethereum message") -// -// // Instantiate EVM -// evm := suite.App.EvmKeeper.NewEVM( -// suite.Ctx, msg, cfg, nil, suite.StateDB, -// ) -// -// params := suite.App.EvmKeeper.GetParams(suite.Ctx) -// activePrecompiles := params.GetActivePrecompilesAddrs() -// precompileMap := suite.App.EvmKeeper.Precompiles(activePrecompiles...) -// err = vm.ValidatePrecompiles(precompileMap, activePrecompiles) -// suite.Require().NoError(err, "invalid precompiles", activePrecompiles) -// evm.WithPrecompiles(precompileMap, activePrecompiles) -// -// // Run precompiled contract -// bz, err := suite.precompile.Run(evm, contract, tc.readOnly) -// // Check results -// if tc.expPass { -// suite.Require().NoError(err, "expected no error when running the precompile") -// suite.Require().Equal(tc.returnBytes, bz, "the return doesn't match the expected result") -// } else { -// suite.Require().Error(err, "expected error to be returned when running the precompile") -// suite.Require().Nil(bz, "expected returned bytes to be nil") -// suite.Require().ErrorContains(err, tc.errContains) -// } -// }) -// } -//} diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 9dca19863..8aeba16b7 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -3,7 +3,6 @@ package avs import ( "encoding/hex" - avskeep "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -12,16 +11,15 @@ import ( ) const ( - EventTypeAVSRegistered = "AVSRegistered" - EventTypeAVSUpdated = "AVSUpdated" - EventTypeAVSDeregistered = "AVSDeregistered" - EventTypeOperatorJoined = "OperatorJoined" - EventTypeOperatorOuted = "OperatorOuted" - EventTypeTaskCreated = "TaskCreated" - EventTypeChallengeInitiated = "ChallengeInitiated" - EventTypePublicKeyRegistered = "PublicKeyRegistered" - EventTypeOperatorRegisteredToExocore = "OperatorRegisteredToExocore" - EventTypeTaskSubmittedByOperator = "TaskSubmittedByOperator" + EventTypeAVSRegistered = "AVSRegistered" + EventTypeAVSUpdated = "AVSUpdated" + EventTypeAVSDeregistered = "AVSDeregistered" + EventTypeOperatorJoined = "OperatorJoined" + EventTypeOperatorOuted = "OperatorOuted" + EventTypeTaskCreated = "TaskCreated" + EventTypeChallengeInitiated = "ChallengeInitiated" + EventTypePublicKeyRegistered = "PublicKeyRegistered" + EventTypeTaskSubmittedByOperator = "TaskSubmittedByOperator" ) // EmitAVSRegistered emits an Ethereum event when an AVS (Autonomous Verification Service) is registered. @@ -127,7 +125,7 @@ func (p Precompile) EmitAVSDeregistered(ctx sdk.Context, stateDB vm.StateDB, avs return nil } -func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.OperatorOptParams) error { +func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { // Prepare the event topics event := p.ABI.Events[EventTypeOperatorJoined] @@ -157,7 +155,7 @@ func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, para return nil } -func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.OperatorOptParams) error { +func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { // Prepare the event topics event := p.ABI.Events[EventTypeOperatorOuted] @@ -187,7 +185,7 @@ func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, param return nil } -func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *avskeep.TaskInfoParams) error { +func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *avstypes.TaskInfoParams) error { // Prepare the event topics event := p.ABI.Events[EventTypeTaskCreated] @@ -224,7 +222,7 @@ func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *a return nil } -func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.ChallengeParams) error { +func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.ChallengeParams) error { // Prepare the event topics event := p.ABI.Events[EventTypeChallengeInitiated] @@ -236,7 +234,7 @@ func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:5] + arguments := event.Inputs[0:6] packed, err := arguments.Pack( common.HexToAddress(params.CallerAddress), params.TaskHash, @@ -258,7 +256,7 @@ func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, return nil } -func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.BlsParams) error { +func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.BlsParams) error { // Prepare the event topics event := p.ABI.Events[EventTypePublicKeyRegistered] @@ -270,7 +268,7 @@ func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, var err error // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] + arguments := event.Inputs[0:3] packed, err := arguments.Pack( common.HexToAddress(params.Operator), params.Name, @@ -289,38 +287,7 @@ func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, return nil } -func (p Precompile) EmitOperatorRegisteredToExocore(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.OperatorParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeOperatorRegisteredToExocore] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:3] - packed, err := arguments.Pack( - common.HexToAddress(params.CallerAddress), - params.OperatorMetaInfo, - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil -} - -func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.StateDB, params *avskeep.TaskResultParams) error { +func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.TaskResultParams) error { // Prepare the event topics event := p.ABI.Events[EventTypeTaskSubmittedByOperator] diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 78367a3de..435397379 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -1,10 +1,8 @@ package avs import ( + "errors" "fmt" - "strconv" - "strings" - exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" avstype "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" cmn "github.com/evmos/evmos/v16/precompiles/common" + "strconv" ) const ( @@ -133,7 +132,7 @@ func (p Precompile) GetAVSInfo( avs, err := p.avsKeeper.QueryAVSInfo(ctx, &avstype.QueryAVSInfoReq{AVSAddress: addr.String()}) if err != nil { // if the avs does not exist, return empty array - if strings.Contains(err.Error(), avstype.ErrNoKeyInTheStore.Error()) { + if errors.Is(err, avstype.ErrNoKeyInTheStore) { return method.Outputs.Pack("") } return nil, err @@ -187,7 +186,7 @@ func (p Precompile) GetTaskInfo( task, err := p.avsKeeper.QueryAVSTaskInfo(ctx, &avstype.QueryAVSTaskInfoReq{TaskAddr: addr.String(), TaskId: strconv.FormatUint(taskID, 10)}) if err != nil { // if the avs does not exist, return empty array - if strings.Contains(err.Error(), avstype.ErrNoKeyInTheStore.Error()) { + if errors.Is(err, avstype.ErrNoKeyInTheStore) { return method.Outputs.Pack("") } return nil, err diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 81db1e482..32a4ac441 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -5,12 +5,9 @@ import ( "fmt" "slices" - operatortypes "github.com/ExocoreNetwork/exocore/x/operator/types" - errorsmod "cosmossdk.io/errors" exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -28,7 +25,6 @@ const ( MethodCreateAVSTask = "createTask" MethodRegisterBLSPublicKey = "registerBLSPublicKey" MethodChallenge = "challenge" - MethodRegisterOperatorToExocore = "registerOperatorToExocore" MethodOperatorSubmitTask = "operatorSubmitTask" ) @@ -52,7 +48,7 @@ func (p Precompile) RegisterAVS( } // The AVS registration is done by the calling contract. avsParams.AvsAddress = contract.CallerAddress.String() - avsParams.Action = avskeeper.RegisterAction + avsParams.Action = avstypes.RegisterAction // Finally, update the AVS information in the keeper. err = p.avsKeeper.UpdateAVSInfo(ctx, avsParams) if err != nil { @@ -89,7 +85,7 @@ func (p Precompile) DeregisterAVS( avsParams.AvsName = avsName avsParams.AvsAddress = contract.CallerAddress.String() - avsParams.Action = avskeeper.DeRegisterAction + avsParams.Action = avstypes.DeRegisterAction // validates that this is owner err := p.avsKeeper.UpdateAVSInfo(ctx, avsParams) @@ -117,7 +113,7 @@ func (p Precompile) UpdateAVS( } avsParams.AvsAddress = contract.CallerAddress.String() - avsParams.Action = avskeeper.UpdateAction + avsParams.Action = avstypes.UpdateAction previousAVSInfo, err := p.avsKeeper.GetAVSInfo(ctx, avsParams.AvsAddress) if err != nil { return nil, err @@ -153,10 +149,10 @@ func (p Precompile) BindOperatorToAVS( return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - operatorParams := &avskeeper.OperatorOptParams{} + operatorParams := &avstypes.OperatorOptParams{} operatorParams.OperatorAddress = sdk.AccAddress(callerAddress[:]).String() operatorParams.AvsAddress = contract.CallerAddress.String() - operatorParams.Action = avskeeper.RegisterAction + operatorParams.Action = avstypes.RegisterAction err := p.avsKeeper.OperatorOptAction(ctx, operatorParams) if err != nil { return nil, err @@ -182,10 +178,10 @@ func (p Precompile) UnbindOperatorToAVS( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - operatorParams := &avskeeper.OperatorOptParams{} + operatorParams := &avstypes.OperatorOptParams{} operatorParams.OperatorAddress = sdk.AccAddress(callerAddress[:]).String() operatorParams.AvsAddress = contract.CallerAddress.String() - operatorParams.Action = avskeeper.DeRegisterAction + operatorParams.Action = avstypes.DeRegisterAction err := p.avsKeeper.OperatorOptAction(ctx, operatorParams) if err != nil { return nil, err @@ -232,7 +228,7 @@ func (p Precompile) Challenge( if len(args) != len(p.ABI.Methods[MethodChallenge].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodChallenge].Inputs), len(args)) } - challengeParams := &avskeeper.ChallengeParams{} + challengeParams := &avstypes.ChallengeParams{} challengeParams.TaskContractAddress = contract.CallerAddress callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { @@ -291,7 +287,7 @@ func (p Precompile) RegisterBLSPublicKey( if len(args) != len(p.ABI.Methods[MethodRegisterBLSPublicKey].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterBLSPublicKey].Inputs), len(args)) } - blsParams := &avskeeper.BlsParams{} + blsParams := &avstypes.BlsParams{} callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) @@ -332,49 +328,11 @@ func (p Precompile) RegisterBLSPublicKey( return method.Outputs.Pack(true) } -// RegisterOperatorToExocore operator register. -func (p Precompile) RegisterOperatorToExocore( - ctx sdk.Context, - _ common.Address, - _ *vm.Contract, - stateDB vm.StateDB, - method *abi.Method, - args []interface{}, -) ([]byte, error) { - if len(args) != len(p.ABI.Methods[MethodRegisterOperatorToExocore].Inputs) { - return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodRegisterOperatorToExocore].Inputs), len(args)) - } - operatorParams := &avskeeper.OperatorParams{} - callerAddress, ok := args[0].(common.Address) - if !ok || (callerAddress == common.Address{}) { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) - } - operatorParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() - - OperatorMetaInfo, ok := args[1].(string) - if !ok || OperatorMetaInfo == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", OperatorMetaInfo) - } - operatorParams.OperatorMetaInfo = OperatorMetaInfo - info := operatortypes.OperatorInfo{ - OperatorMetaInfo: OperatorMetaInfo, - } - err := p.avsKeeper.GetOperatorKeeper().SetOperatorInfo(ctx, operatorParams.CallerAddress, &info) - if err != nil { - return nil, err - } - - if err = p.EmitOperatorRegisteredToExocore(ctx, stateDB, operatorParams); err != nil { - return nil, err - } - return method.Outputs.Pack(true) -} - // OperatorSubmitTask operator submit results func (p Precompile) OperatorSubmitTask( ctx sdk.Context, _ common.Address, - contract *vm.Contract, + _ *vm.Contract, stateDB vm.StateDB, method *abi.Method, args []interface{}, @@ -382,8 +340,8 @@ func (p Precompile) OperatorSubmitTask( if len(args) != len(p.ABI.Methods[MethodOperatorSubmitTask].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodOperatorSubmitTask].Inputs), len(args)) } - resultParams := &avskeeper.TaskResultParams{} - resultParams.TaskContractAddress = contract.CallerAddress + resultParams := &avstypes.TaskResultParams{} + callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index b34a61d61..17a2da732 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -4,7 +4,6 @@ import ( "fmt" exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" - avskeep "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -220,11 +219,11 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface return avsParams, nil } -func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) (*avskeep.TaskInfoParams, error) { +func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) (*avstypes.TaskInfoParams, error) { if len(args) != len(p.ABI.Methods[MethodCreateAVSTask].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, 3, len(args)) } - taskParams := &avskeep.TaskInfoParams{} + taskParams := &avstypes.TaskInfoParams{} callerAddress, ok := args[0].(common.Address) if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) diff --git a/precompiles/avs/utils_test.go b/precompiles/avs/utils_test.go index 72b413729..74519ca1d 100644 --- a/precompiles/avs/utils_test.go +++ b/precompiles/avs/utils_test.go @@ -8,7 +8,6 @@ import ( utiltx "github.com/ExocoreNetwork/exocore/testutil/tx" assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -102,7 +101,7 @@ func (suite *AVSManagerPrecompileSuite) prepareAvs(assetIDs []string, task strin "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj2", } err := suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &avstypes.AVSRegisterOrDeregisterParams{ - Action: avskeeper.RegisterAction, + Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, AvsAddress: suite.avsAddr, AssetID: assetIDs, diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index 88029157b..abbf48b77 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -162,7 +162,7 @@ func (k Keeper) RegisterAVSWithChainID( } // SetAVSInfo expects HexAddress for the AvsAddress params.AvsAddress = avsAddrStr - params.Action = RegisterAction + params.Action = types.RegisterAction if err := k.UpdateAVSInfo(ctx, params); err != nil { return common.Address{}, err diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index 3ae306273..ad99f5a47 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -6,8 +6,8 @@ import ( "math/big" "time" - avstypes "github.com/ExocoreNetwork/exocore/x/avs/keeper" "github.com/ExocoreNetwork/exocore/x/avs/types" + avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" delegationtypes "github.com/ExocoreNetwork/exocore/x/delegation/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" @@ -26,7 +26,7 @@ func (suite *AVSTestSuite) TestAVS() { SlashAddr: utiltx.GenerateAddress().String(), AvsOwnerAddress: avsOwnerAddress, AssetIDs: assetID, - AvsUnbondingPeriod: 7, + AvsUnbondingPeriod: 2, MinSelfDelegation: 10, EpochIdentifier: epochstypes.DayEpochID, StartingEpoch: 1, @@ -74,7 +74,7 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_Register() { AvsOwnerAddress: avsOwnerAddress, AssetID: assetID, MinSelfDelegation: uint64(10), - UnbondingPeriod: uint64(7), + UnbondingPeriod: uint64(2), SlashContractAddr: slashAddress, EpochIdentifier: epochstypes.DayEpochID, } diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index f21b11182..3329ebfa7 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -88,7 +88,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi return errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", epochIdentifier)) } switch action { - case RegisterAction: + case types.RegisterAction: if avsInfo != nil { return errorsmod.Wrap(types.ErrAlreadyRegistered, fmt.Sprintf("the avsaddress is :%s", params.AvsAddress)) } @@ -127,7 +127,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi } return k.SetAVSInfo(ctx, avs) - case DeRegisterAction: + case types.DeRegisterAction: if avsInfo == nil { return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the avsaddress is :%s", params.AvsAddress)) } @@ -147,7 +147,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi return errorsmod.Wrap(types.ErrAvsNameMismatch, fmt.Sprintf("Unregistered AVS name is incorrect %s", params.AvsName)) } return k.DeleteAVSInfo(ctx, params.AvsAddress) - case UpdateAction: + case types.UpdateAction: if avsInfo == nil { return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the avsaddress is :%s", params.AvsAddress)) } @@ -225,7 +225,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi } } -func (k Keeper) CreateAVSTask(ctx sdk.Context, params *TaskInfoParams) (uint64, error) { +func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (uint64, error) { avsInfo := k.GetAVSInfoByTaskAddress(ctx, params.TaskContractAddress) if avsInfo.AvsAddress == "" { return 0, errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", params.TaskContractAddress)) @@ -269,7 +269,7 @@ func (k Keeper) CreateAVSTask(ctx sdk.Context, params *TaskInfoParams) (uint64, return task.TaskId, k.SetTaskInfo(ctx, task) } -func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *BlsParams) error { +func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *types.BlsParams) error { // check bls signature to prevent rogue key attacks sig := params.PubkeyRegistrationSignature msgHash := params.PubkeyRegistrationMessageHash @@ -290,7 +290,7 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *BlsParams) error { return k.SetOperatorPubKey(ctx, bls) } -func (k Keeper) OperatorOptAction(ctx sdk.Context, params *OperatorOptParams) error { +func (k Keeper) OperatorOptAction(ctx sdk.Context, params *types.OperatorOptParams) error { operatorAddress := params.OperatorAddress opAccAddr, err := sdk.AccAddressFromBech32(operatorAddress) if err != nil { @@ -310,9 +310,9 @@ func (k Keeper) OperatorOptAction(ctx sdk.Context, params *OperatorOptParams) er } switch params.Action { - case RegisterAction: + case types.RegisterAction: return k.operatorKeeper.OptIn(ctx, opAccAddr, params.AvsAddress) - case DeRegisterAction: + case types.DeRegisterAction: return k.operatorKeeper.OptOut(ctx, opAccAddr, params.AvsAddress) default: return errorsmod.Wrap(types.ErrInvalidAction, fmt.Sprintf("Invalid action: %d", params.Action)) @@ -387,7 +387,7 @@ func (k Keeper) IterateAVSInfo(ctx sdk.Context, fn func(index int64, avsInfo typ } } -func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *ChallengeParams) error { +func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *types.ChallengeParams) error { taskInfo, err := k.GetTaskInfo(ctx, strconv.FormatUint(params.TaskID, 10), params.TaskContractAddress.String()) if err != nil { return fmt.Errorf("task does not exist,this task address: %s", params.TaskContractAddress) @@ -446,7 +446,7 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *ChallengeParam params.TaskContractAddress) } -func (k Keeper) SubmitTaskResult(ctx sdk.Context, params *TaskResultParams) error { +func (k Keeper) SubmitTaskResult(ctx sdk.Context, params *types.TaskResultParams) error { result := &types.TaskResultInfo{ TaskId: params.TaskID, OperatorAddress: params.OperatorAddress, diff --git a/x/avs/keeper/multi_operator_submit_task_test.go b/x/avs/keeper/multi_operator_submit_task_test.go index dda8de157..c80332f60 100644 --- a/x/avs/keeper/multi_operator_submit_task_test.go +++ b/x/avs/keeper/multi_operator_submit_task_test.go @@ -7,7 +7,6 @@ import ( sdkmath "cosmossdk.io/math" assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -86,7 +85,7 @@ func (suite *AVSTestSuite) prepareMulDelegation(operatorAddress sdk.AccAddress, func (suite *AVSTestSuite) prepareMulAvs(assetIDs []string) { err := suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &avstypes.AVSRegisterOrDeregisterParams{ AvsName: "avs01", - Action: avskeeper.RegisterAction, + Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, AvsAddress: suite.avsAddr, AssetID: assetIDs, diff --git a/x/avs/keeper/params.go b/x/avs/keeper/params.go index 47452336d..22740d996 100644 --- a/x/avs/keeper/params.go +++ b/x/avs/keeper/params.go @@ -3,8 +3,6 @@ package keeper import ( "fmt" - "github.com/ethereum/go-ethereum/common" - "github.com/ExocoreNetwork/exocore/x/avs/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,90 +30,3 @@ func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { store.Set(types.ParamsKey, bz) return nil } - -type OperatorOptParams struct { - Name string - BlsPublicKey string - IsRegistered bool - Action uint64 - OperatorAddress string - Status string - AvsAddress string -} - -type TaskInfoParams struct { - TaskContractAddress string `json:"task_contract_address"` - TaskName string `json:"name"` - Hash []byte `json:"hash"` - TaskID uint64 `json:"task_id"` - TaskResponsePeriod uint64 `json:"task_response_period"` - TaskStatisticalPeriod uint64 `json:"task_statistical_period"` - TaskChallengePeriod uint64 `json:"task_challenge_period"` - ThresholdPercentage uint64 `json:"threshold_percentage"` - StartingEpoch uint64 `json:"starting_epoch"` - OperatorAddress string `json:"operator_address"` - TaskResponseHash string `json:"task_response_hash"` - TaskResponse []byte `json:"task_response"` - BlsSignature []byte `json:"bls_signature"` - Stage string `json:"stage"` - ActualThreshold uint64 `json:"actual_threshold"` - OptInCount uint64 `json:"opt_in_count"` - SignedCount uint64 `json:"signed_count"` - NoSignedCount uint64 `json:"no_signed_count"` - ErrSignedCount uint64 `json:"err_signed_count"` - CallerAddress string `json:"caller_address"` -} -type BlsParams struct { - Operator string - Name string - PubKey []byte - PubkeyRegistrationSignature []byte - PubkeyRegistrationMessageHash []byte -} - -type ProofParams struct { - TaskID string - TaskContractAddress string - AvsAddress string - Aggregator string - OperatorStatus []OperatorStatusParams - CallerAddress string -} -type OperatorStatusParams struct { - OperatorAddress string - Status string - ProofData string -} - -const ( - RegisterAction = 1 - DeRegisterAction = 2 - UpdateAction = 3 -) - -type ChallengeParams struct { - TaskContractAddress common.Address `json:"task_contract_address"` - TaskHash []byte `json:"hash"` - TaskID uint64 `json:"task_id"` - OperatorAddress sdk.AccAddress `json:"operator_address"` - TaskResponseHash []byte `json:"task_response_hash"` - CallerAddress string `json:"caller_address"` -} - -type TaskResultParams struct { - OperatorAddress string `json:"operator_address"` - TaskResponseHash string `json:"task_response_hash"` - TaskResponse []byte `json:"task_response"` - BlsSignature []byte `json:"bls_signature"` - TaskContractAddress common.Address `json:"task_contract_address"` - TaskID uint64 `json:"task_id"` - Stage string `json:"stage"` - CallerAddress string `json:"caller_address"` -} - -type OperatorParams struct { - EarningsAddr string `json:"earnings_addr"` - ApproveAddr string `son:"approve_addr"` - OperatorMetaInfo string `json:"operator_meta_info"` - CallerAddress string `json:"caller_address"` -} diff --git a/x/avs/keeper/submit_task_test.go b/x/avs/keeper/submit_task_test.go index ce266cd3b..71df5a843 100644 --- a/x/avs/keeper/submit_task_test.go +++ b/x/avs/keeper/submit_task_test.go @@ -9,7 +9,6 @@ import ( sdkmath "cosmossdk.io/math" assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" delegationtype "github.com/ExocoreNetwork/exocore/x/delegation/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -79,7 +78,7 @@ func (suite *AVSTestSuite) prepareDelegation(isDelegation bool, assetAddr common func (suite *AVSTestSuite) prepareAvs(assetIDs []string) { err := suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &avstypes.AVSRegisterOrDeregisterParams{ AvsName: "avs01", - Action: avskeeper.RegisterAction, + Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, AvsAddress: suite.avsAddr, AssetID: assetIDs, diff --git a/x/avs/types/expected_keepers.go b/x/avs/types/expected_keepers.go index ffa0a3fca..0aab387f0 100644 --- a/x/avs/types/expected_keepers.go +++ b/x/avs/types/expected_keepers.go @@ -1,8 +1,6 @@ package types import ( - "context" - sdkmath "cosmossdk.io/math" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -45,7 +43,7 @@ type OperatorKeeper interface { GetOperatorOptedUSDValue(ctx sdk.Context, avsAddr, operatorAddr string) (operatortypes.OperatorOptedUSDValue, error) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) SetOperatorInfo(ctx sdk.Context, addr string, info *operatortypes.OperatorInfo) (err error) - QueryOperatorInfo(ctx context.Context, req *operatortypes.GetOperatorInfoReq) (*operatortypes.OperatorInfo, error) + OperatorInfo(ctx sdk.Context, addr string) (info *operatortypes.OperatorInfo, err error) } // AssetsKeeper represents the expected keeper interface for the assets module. @@ -54,5 +52,4 @@ type AssetsKeeper interface { ctx sdk.Context, assetID string, ) (info *assetstype.StakingAssetInfo, err error) IsStakingAsset(sdk.Context, string) bool - QueOperatorAssetInfos(ctx context.Context, infos *assetstype.QueryOperatorAssetInfos) (*assetstype.QueryOperatorAssetInfosResponse, error) } diff --git a/x/avs/types/stage.go b/x/avs/types/stage.go index 3486737c7..e951ca459 100644 --- a/x/avs/types/stage.go +++ b/x/avs/types/stage.go @@ -1,8 +1,100 @@ package types +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + const ( // TwoPhaseCommitOne The first stage of the two-stage submission. TwoPhaseCommitOne = "1" // TwoPhaseCommitTwo The second stage of submission. TwoPhaseCommitTwo = "2" ) + +type OperatorOptParams struct { + Name string + BlsPublicKey string + IsRegistered bool + Action uint64 + OperatorAddress string + Status string + AvsAddress string +} + +type TaskInfoParams struct { + TaskContractAddress string `json:"task_contract_address"` + TaskName string `json:"name"` + Hash []byte `json:"hash"` + TaskID uint64 `json:"task_id"` + TaskResponsePeriod uint64 `json:"task_response_period"` + TaskStatisticalPeriod uint64 `json:"task_statistical_period"` + TaskChallengePeriod uint64 `json:"task_challenge_period"` + ThresholdPercentage uint64 `json:"threshold_percentage"` + StartingEpoch uint64 `json:"starting_epoch"` + OperatorAddress string `json:"operator_address"` + TaskResponseHash string `json:"task_response_hash"` + TaskResponse []byte `json:"task_response"` + BlsSignature []byte `json:"bls_signature"` + Stage string `json:"stage"` + ActualThreshold uint64 `json:"actual_threshold"` + OptInCount uint64 `json:"opt_in_count"` + SignedCount uint64 `json:"signed_count"` + NoSignedCount uint64 `json:"no_signed_count"` + ErrSignedCount uint64 `json:"err_signed_count"` + CallerAddress string `json:"caller_address"` +} +type BlsParams struct { + Operator string + Name string + PubKey []byte + PubkeyRegistrationSignature []byte + PubkeyRegistrationMessageHash []byte +} + +type ProofParams struct { + TaskID string + TaskContractAddress string + AvsAddress string + Aggregator string + OperatorStatus []OperatorStatusParams + CallerAddress string +} +type OperatorStatusParams struct { + OperatorAddress string + Status string + ProofData string +} + +const ( + RegisterAction = 1 + DeRegisterAction = 2 + UpdateAction = 3 +) + +type ChallengeParams struct { + TaskContractAddress common.Address `json:"task_contract_address"` + TaskHash []byte `json:"hash"` + TaskID uint64 `json:"task_id"` + OperatorAddress sdk.AccAddress `json:"operator_address"` + TaskResponseHash []byte `json:"task_response_hash"` + CallerAddress string `json:"caller_address"` +} + +type TaskResultParams struct { + OperatorAddress string `json:"operator_address"` + TaskResponseHash string `json:"task_response_hash"` + TaskResponse []byte `json:"task_response"` + BlsSignature []byte `json:"bls_signature"` + TaskContractAddress common.Address `json:"task_contract_address"` + TaskID uint64 `json:"task_id"` + Stage string `json:"stage"` + CallerAddress string `json:"caller_address"` +} + +type OperatorParams struct { + EarningsAddr string `json:"earnings_addr"` + ApproveAddr string `json:"approve_addr"` + OperatorMetaInfo string `json:"operator_meta_info"` + CallerAddress string `json:"caller_address"` +} diff --git a/x/dogfood/keeper/msg_server.go b/x/dogfood/keeper/msg_server.go index 63a810670..88ee914d2 100644 --- a/x/dogfood/keeper/msg_server.go +++ b/x/dogfood/keeper/msg_server.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/utils" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" "github.com/ExocoreNetwork/exocore/x/dogfood/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -127,7 +126,7 @@ func (k Keeper) UpdateParams( MinSelfDelegation: nextParams.MinSelfDelegation.Uint64(), EpochIdentifier: nextParams.EpochIdentifier, ChainID: c.ChainID(), - Action: avskeeper.UpdateAction, + Action: avstypes.UpdateAction, }) if err != nil { return nil, errors.Wrap(types.ErrUpdateAVSInfo, err.Error()) diff --git a/x/operator/keeper/opt_test.go b/x/operator/keeper/opt_test.go index 7a2b77d45..1662c20ca 100644 --- a/x/operator/keeper/opt_test.go +++ b/x/operator/keeper/opt_test.go @@ -5,7 +5,6 @@ import ( "time" assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" - avskeeper "github.com/ExocoreNetwork/exocore/x/avs/keeper" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" @@ -94,7 +93,7 @@ func (suite *OperatorTestSuite) prepare() { func (suite *OperatorTestSuite) prepareAvs(assetIDs []string) { err := suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &avstypes.AVSRegisterOrDeregisterParams{ - Action: avskeeper.RegisterAction, + Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, AvsAddress: suite.avsAddr, AssetID: assetIDs, From 8c3649c55dbd70dce12fe189503c6852019066b1 Mon Sep 17 00:00:00 2001 From: trestin Date: Wed, 23 Oct 2024 12:48:11 +0800 Subject: [PATCH 10/24] fix lint err --- precompiles/avs/query.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 435397379..c4a3801cf 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -3,6 +3,8 @@ package avs import ( "errors" "fmt" + "strconv" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" avstype "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" cmn "github.com/evmos/evmos/v16/precompiles/common" - "strconv" ) const ( From c7dc3ad691c282d77cac50327727136c891274bb Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 24 Oct 2024 20:23:03 +0800 Subject: [PATCH 11/24] fix comments --- precompiles/avs/IAVSManager.sol | 30 +- precompiles/avs/abi.json | 104 +------ precompiles/avs/avs_test.go | 30 +- precompiles/avs/events.go | 292 +++--------------- precompiles/avs/query_test.go | 1 + precompiles/avs/tx.go | 25 +- precompiles/avs/types.go | 2 +- proto/exocore/avs/v1/tx.proto | 6 +- x/avs/client/cli/tx.go | 12 +- x/avs/keeper/keeper.go | 28 +- .../keeper/multi_operator_submit_task_test.go | 4 +- x/avs/keeper/submit_task_test.go | 4 +- x/avs/keeper/task.go | 8 +- x/avs/types/errors.go | 2 +- x/avs/types/tx.pb.go | 248 +++++++-------- x/avs/types/types.go | 2 + x/avs/types/{stage.go => utils.go} | 33 +- 17 files changed, 282 insertions(+), 549 deletions(-) rename x/avs/types/{stage.go => utils.go} (79%) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 891e8929c..d84730680 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -7,26 +7,24 @@ address constant AVSMANAGER_PRECOMPILE_ADDRESS = 0x00000000000000000000000000000 IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager( AVSMANAGER_PRECOMPILE_ADDRESS ); - /// @author Exocore Team /// @title AVS-Manager Precompile Contract /// @dev The interface through which solidity contracts will interact with AVS-Manager /// @custom:address 0x0000000000000000000000000000000000000901 interface IAVSManager { - event AVSRegistered(address indexed sender, string avsName, bool success); - event AVSUpdated(address indexed sender, string avsName, bool success); - event AVSDeregistered(address indexed sender, string avsName, bool success); - event OperatorJoined(address indexed sender, bool success); - event OperatorOuted(address indexed sender, bool success); + event AVSRegistered(address indexed sender, string avsName); + event AVSUpdated(address indexed sender, string avsName); + event AVSDeregistered(address indexed sender, string avsName); + event OperatorJoined(address indexed sender); + event OperatorOuted(address indexed sender); event TaskCreated(address indexed sender,uint64 taskId,address indexed taskContractAddress,string name,bytes hash, uint64 taskResponsePeriod,uint64 taskChallengePeriod,uint64 thresholdPercentage,uint64 taskStatisticalPeriod ); event ChallengeInitiated(address indexed sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, - string operatorAddress, bool success); - event PublicKeyRegistered(address indexed sender, string name, bool success); - event OperatorRegisteredToExocore(address indexed sender, string metaInfo, bool success); - event TaskSubmittedByOperator(address indexed sender, uint64 taskID, string taskResponse, - string blsSignature, string taskContractAddress, string stage, bool success); + string operatorAddress); + event PublicKeyRegistered(address indexed sender, string name); + event TaskSubmittedByOperator(address indexed sender, uint64 taskID, bytes taskResponse, + bytes blsSignature, address indexed taskContractAddress, uint8 phase); /// @dev Register AVS contract to EXO. @@ -108,7 +106,7 @@ interface IAVSManager { /// @dev DeregisterOperatorFromAVS operator opt out current avs /// @param sender The external address for calling this method. function deregisterOperatorFromAVS( - address sender + address sender ) external returns (bool success); @@ -128,7 +126,7 @@ interface IAVSManager { uint64 taskChallengePeriod, uint64 thresholdPercentage, uint64 taskStatisticalPeriod - ) external returns (bool success,uint64 taskID); + ) external returns (uint64 taskID); /// @dev challenge , this function enables a challenger to raise and resolve a challenge. /// @param sender The external address for calling this method. @@ -165,15 +163,15 @@ interface IAVSManager { /// @param taskResponse is the task response data.. /// @param blsSignature is the operator bls sig info.. /// @param taskContractAddress is contract address of task. - /// @param stage this field is used to solve the problem of task results being copied by other operators. - // It is a two-stage submission with two values, 1 and 2 + /// @param phase this field is used to solve the problem of task results being copied by other operators. + // It is a Two-Phase Commit with two values, 0 and 1 function operatorSubmitTask( address sender, uint64 taskID, bytes calldata taskResponse, bytes calldata blsSignature, address taskContractAddress, - string memory stage + uint8 phase ) external returns (bool success); /// QUERIES diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 6063b024a..a4c3b2506 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -13,12 +13,6 @@ "internalType": "string", "name": "avsName", "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "AVSDeregistered", @@ -38,12 +32,6 @@ "internalType": "string", "name": "avsName", "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "AVSRegistered", @@ -63,12 +51,6 @@ "internalType": "string", "name": "avsName", "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "AVSUpdated", @@ -106,12 +88,6 @@ "internalType": "string", "name": "operatorAddress", "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "ChallengeInitiated", @@ -125,12 +101,6 @@ "internalType": "address", "name": "sender", "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "OperatorJoined", @@ -144,42 +114,11 @@ "internalType": "address", "name": "sender", "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "OperatorOuted", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "metaInfo", - "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "name": "OperatorRegisteredToExocore", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -194,12 +133,6 @@ "internalType": "string", "name": "name", "type": "string" - }, - { - "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" } ], "name": "PublicKeyRegistered", @@ -283,33 +216,27 @@ }, { "indexed": false, - "internalType": "string", + "internalType": "bytes", "name": "taskResponse", - "type": "string" + "type": "bytes" }, { "indexed": false, - "internalType": "string", + "internalType": "bytes", "name": "blsSignature", - "type": "string" + "type": "bytes" }, { - "indexed": false, - "internalType": "string", + "indexed": true, + "internalType": "address", "name": "taskContractAddress", - "type": "string" - }, - { - "indexed": false, - "internalType": "string", - "name": "stage", - "type": "string" + "type": "address" }, { "indexed": false, - "internalType": "bool", - "name": "success", - "type": "bool" + "internalType": "uint8", + "name": "phase", + "type": "uint8" } ], "name": "TaskSubmittedByOperator", @@ -394,11 +321,6 @@ ], "name": "createTask", "outputs": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, { "internalType": "uint64", "name": "taskID", @@ -641,9 +563,9 @@ "type": "address" }, { - "internalType": "string", - "name": "stage", - "type": "string" + "internalType": "uint8", + "name": "phase", + "type": "uint8" } ], "name": "operatorSubmitTask", diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index 5cd2ae474..40d267168 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -370,12 +370,34 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() { params, ) suite.Require().NoError(err, "failed to pack input") - return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input + return suite.Address, input } successRet, err := suite.precompile.Methods[avs.MethodUpdateAVS].Outputs.Pack(true) suite.Require().NoError(err) + setUp := func() { + avs := &types.AVSInfo{ + Name: avsName, + AvsAddress: suite.Address.String(), + SlashAddr: slashAddress, + RewardAddr: rewardAddress, + AvsOwnerAddress: avsOwnerAddress, + AssetIDs: assetID, + AvsUnbondingPeriod: avsUnbondingPeriod, + MinSelfDelegation: minSelfDelegation, + EpochIdentifier: epochIdentifier, + StartingEpoch: 1, + TaskAddr: taskAddr, + MinStakeAmount: minStakeAmount, + MinOptInOperators: params[0], + MinTotalStakeAmount: params[1], + AvsReward: sdk.MustNewDecFromStr(strconv.FormatUint(params[1], 10)), + AvsSlash: sdk.MustNewDecFromStr(strconv.FormatUint(params[2], 10)), + } + err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) + suite.NoError(err) + } testcases := []struct { name string malleate func() (common.Address, []byte) @@ -387,7 +409,7 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() { { name: "pass for avs-update", malleate: func() (common.Address, []byte) { - suite.TestRegisterAVS() + setUp() return commonMalleate() }, readOnly: false, @@ -407,7 +429,7 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() { contract := vm.NewPrecompile(vm.AccountRef(caller), suite.precompile, big.NewInt(0), uint64(1e6)) contract.Input = input - contractAddr := contract.Address() + contractAddr := suite.Address // Build and sign Ethereum transaction txArgs := evmtypes.EvmTxArgs{ ChainID: suite.App.EvmKeeper.ChainID(), @@ -750,7 +772,7 @@ func (suite *AVSManagerPrecompileSuite) TestRunRegTaskInfo() { suite.Require().NoError(err, "failed to pack input") return suite.Address, input } - successRet, err := suite.precompile.Methods[avs.MethodCreateAVSTask].Outputs.Pack(true, uint64(1)) + successRet, err := suite.precompile.Methods[avs.MethodCreateAVSTask].Outputs.Pack(uint64(1)) suite.Require().NoError(err) testcases := []struct { name string diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 8aeba16b7..d24470c97 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -1,7 +1,7 @@ package avs import ( - "encoding/hex" + "github.com/ethereum/go-ethereum/accounts/abi" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -22,33 +22,11 @@ const ( EventTypeTaskSubmittedByOperator = "TaskSubmittedByOperator" ) -// EmitAVSRegistered emits an Ethereum event when an AVS (Autonomous Verification Service) is registered. -// -// Parameters: -// - ctx: The SDK context containing information about the current state of the blockchain. -// - stateDB: The Ethereum state database where the event will be stored. -// - avs: A pointer to the AVSRegisterOrDeregisterParams struct containing the details of the AVS registration. -// -// Returns: -// - An error if there is an issue packing the event data or adding the log to the state database. -// - nil if the event is successfully emitted. -func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeAVSRegistered] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID +func (p Precompile) emitEvent(ctx sdk.Context, stateDB vm.StateDB, eventName string, inputArgs abi.Arguments, args ...interface{}) error { + event := p.ABI.Events[eventName] + topics := []common.Hash{event.ID} - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:3] - packed, err := arguments.Pack( - common.HexToAddress(avs.CallerAddress), - avs.AvsName, - true) + packed, err := inputArgs.Pack(args...) if err != nil { return err } @@ -63,142 +41,52 @@ func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs * return nil } -func (p Precompile) EmitAVSUpdated(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeAVSUpdated] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:3] - packed, err := arguments.Pack( +// EmitAVSRegistered emits an Ethereum event when an AVS (Autonomous Verification Service) is registered. +// +// Parameters: +// - ctx: The SDK context containing information about the current state of the blockchain. +// - stateDB: The Ethereum state database where the event will be stored. +// - avs: A pointer to the AVSRegisterOrDeregisterParams struct containing the details of the AVS registration. +// +// Returns: +// - An error if there is an issue packing the event data or adding the log to the state database. +// - nil if the event is successfully emitted. +func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { + arguments := p.ABI.Events[EventTypeAVSRegistered].Inputs + return p.emitEvent(ctx, stateDB, EventTypeAVSRegistered, arguments, common.HexToAddress(avs.CallerAddress), - avs.AvsName, - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) + avs.AvsName) +} - return nil +func (p Precompile) EmitAVSUpdated(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { + arguments := p.ABI.Events[EventTypeAVSUpdated].Inputs + return p.emitEvent(ctx, stateDB, EventTypeAVSUpdated, arguments, + common.HexToAddress(avs.CallerAddress), + avs.AvsName) } func (p Precompile) EmitAVSDeregistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeAVSDeregistered] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:3] - packed, err := arguments.Pack( + arguments := p.ABI.Events[EventTypeAVSDeregistered].Inputs + return p.emitEvent(ctx, stateDB, EventTypeAVSDeregistered, arguments, common.HexToAddress(avs.CallerAddress), - avs.AvsName, - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil + avs.AvsName) } func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeOperatorJoined] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] - packed, err := arguments.Pack( - common.HexToAddress(params.OperatorAddress), - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil + arguments := p.ABI.Events[EventTypeOperatorJoined].Inputs + return p.emitEvent(ctx, stateDB, EventTypeOperatorJoined, arguments, + common.HexToAddress(params.OperatorAddress)) } func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeOperatorOuted] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:2] - packed, err := arguments.Pack( - common.HexToAddress(params.OperatorAddress), - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil + arguments := p.ABI.Events[EventTypeOperatorOuted].Inputs + return p.emitEvent(ctx, stateDB, EventTypeOperatorOuted, arguments, + common.HexToAddress(params.OperatorAddress)) } func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *avstypes.TaskInfoParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeTaskCreated] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:9] - packed, err := arguments.Pack( + arguments := p.ABI.Events[EventTypeTaskCreated].Inputs + return p.emitEvent(ctx, stateDB, EventTypeTaskCreated, arguments, common.HexToAddress(task.CallerAddress), task.TaskID, common.HexToAddress(task.TaskContractAddress), @@ -208,116 +96,32 @@ func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *a task.TaskChallengePeriod, task.ThresholdPercentage, task.TaskStatisticalPeriod) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil } func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.ChallengeParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeChallengeInitiated] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:6] - packed, err := arguments.Pack( + arguments := p.ABI.Events[EventTypeChallengeInitiated].Inputs + return p.emitEvent(ctx, stateDB, EventTypeChallengeInitiated, arguments, common.HexToAddress(params.CallerAddress), params.TaskHash, params.TaskID, params.TaskResponseHash, - params.OperatorAddress, - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil + params.OperatorAddress.String()) } func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.BlsParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypePublicKeyRegistered] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:3] - packed, err := arguments.Pack( + arguments := p.ABI.Events[EventTypePublicKeyRegistered].Inputs + return p.emitEvent(ctx, stateDB, EventTypePublicKeyRegistered, arguments, common.HexToAddress(params.Operator), - params.Name, - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil + params.Name) } func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.TaskResultParams) error { - // Prepare the event topics - event := p.ABI.Events[EventTypeTaskSubmittedByOperator] - - topics := make([]common.Hash, 1) - - // The first topic is always the signature of the event. - topics[0] = event.ID - - var err error - - // Pack the arguments to be used as the Data field - arguments := event.Inputs[0:7] - packed, err := arguments.Pack( + arguments := p.ABI.Events[EventTypeTaskSubmittedByOperator].Inputs + return p.emitEvent(ctx, stateDB, EventTypeTaskSubmittedByOperator, arguments, common.HexToAddress(params.CallerAddress), params.TaskID, - hex.EncodeToString(params.TaskResponse), - hex.EncodeToString(params.BlsSignature), - params.TaskContractAddress.String(), - params.Stage, - true) - if err != nil { - return err - } - - stateDB.AddLog(ðtypes.Log{ - Address: p.Address(), - Topics: topics, - Data: packed, - BlockNumber: uint64(ctx.BlockHeight()), - }) - - return nil + params.TaskResponse, + params.BlsSignature, + params.TaskContractAddress, + params.Phase) } diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index de9a99990..7d4ba5a7f 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -322,6 +322,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetOperatorOptedUSDValue() { func (suite *AVSManagerPrecompileSuite) TestGetRegisteredPubkey() { method := suite.precompile.Methods[avsManagerPrecompile.MethodGetRegisteredPubkey] privateKey, err := blst.RandKey() + suite.NoError(err) operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" publicKey := privateKey.PublicKey() diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 32a4ac441..7e8f2d06e 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -213,7 +213,7 @@ func (p Precompile) CreateAVSTask( if err = p.EmitTaskCreated(ctx, stateDB, params); err != nil { return nil, err } - return method.Outputs.Pack(true, taskID) + return method.Outputs.Pack(taskID) } // Challenge Middleware uses exocore's default avstask template to create tasks in avstask module. @@ -301,7 +301,7 @@ func (p Precompile) RegisterBLSPublicKey( pubkeyBz, ok := args[2].([]byte) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", pubkeyBz) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", pubkeyBz) } blsParams.PubKey = pubkeyBz @@ -350,7 +350,7 @@ func (p Precompile) OperatorSubmitTask( taskID, ok := args[1].(uint64) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", taskID) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", args[1]) } resultParams.TaskID = taskID @@ -372,14 +372,23 @@ func (p Precompile) OperatorSubmitTask( } resultParams.TaskContractAddress = taskAddr - stage, ok := args[5].(string) - if !ok || stage == "" { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, "string", stage) + phase, ok := args[5].(uint8) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, "uint8", phase) } - resultParams.Stage = stage + resultParams.Phase = phase resultParams.OperatorAddress = resultParams.CallerAddress - err := p.avsKeeper.SubmitTaskResult(ctx, resultParams) + + result := &avstypes.TaskResultInfo{ + TaskId: resultParams.TaskID, + OperatorAddress: resultParams.OperatorAddress, + TaskContractAddress: resultParams.TaskContractAddress.String(), + TaskResponse: resultParams.TaskResponse, + BlsSignature: resultParams.BlsSignature, + Phase: uint32(resultParams.Phase), + } + err := p.avsKeeper.SetTaskResultInfo(ctx, resultParams.OperatorAddress, result) if err != nil { return nil, err } diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index 17a2da732..2e2352292 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -221,7 +221,7 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) (*avstypes.TaskInfoParams, error) { if len(args) != len(p.ABI.Methods[MethodCreateAVSTask].Inputs) { - return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, 3, len(args)) + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodCreateAVSTask].Inputs), len(args)) } taskParams := &avstypes.TaskInfoParams{} callerAddress, ok := args[0].(common.Address) diff --git a/proto/exocore/avs/v1/tx.proto b/proto/exocore/avs/v1/tx.proto index 417e32afb..20735d7e9 100644 --- a/proto/exocore/avs/v1/tx.proto +++ b/proto/exocore/avs/v1/tx.proto @@ -226,9 +226,9 @@ message TaskResultInfo { string task_contract_address = 5; // task_id is the task id uint64 task_id = 6; - // stage this field is used to solve the problem of task results being copied by other operators. - // It is a two-stage submission with two values, 1 and 2 - string stage = 7; + // phase this field is used to solve the problem of task results being copied by other operators. + // It is a two-phase submission with two values, 0 and 1 + uint32 phase = 7; } // SubmitTaskResultReq is the request to submit task results. diff --git a/x/avs/client/cli/tx.go b/x/avs/client/cli/tx.go index 269c791e5..5f8fd2112 100644 --- a/x/avs/client/cli/tx.go +++ b/x/avs/client/cli/tx.go @@ -19,7 +19,7 @@ const ( FlagBlsSignature = "bls-signature" FlagTaskContractAddress = "task-contract-address" FlagTaskID = "task-id" - FlagStage = "stage" + FlagPhase = "phase" ) // GetTxCmd returns the transaction commands for this module @@ -78,14 +78,14 @@ func CmdSubmitTaskResult() *cobra.Command { f.Uint64( FlagTaskID, 1, "The task id", ) - f.String( - FlagStage, "", "The stage is a two-stage submission with two values, 1 and 2", + f.Uint32( + FlagPhase, 0, "The phase is a two-phase submission with two values, 0 and 1", ) // #nosec G703 // this only errors if the flag isn't defined. _ = cmd.MarkFlagRequired(FlagTaskID) _ = cmd.MarkFlagRequired(FlagBlsSignature) _ = cmd.MarkFlagRequired(FlagTaskContractAddress) - _ = cmd.MarkFlagRequired(FlagStage) + _ = cmd.MarkFlagRequired(FlagPhase) // transaction level flags from the SDK flags.AddTxFlagsToCmd(cmd) @@ -108,7 +108,7 @@ func newBuildMsg( taskContractAddress, _ := fs.GetString(FlagTaskContractAddress) taskID, _ := fs.GetUint64(FlagTaskID) - stage, _ := fs.GetString(FlagStage) + phase, _ := fs.GetUint32(FlagPhase) msg := &types.SubmitTaskResultReq{ FromAddress: sender.String(), @@ -118,7 +118,7 @@ func newBuildMsg( BlsSignature: sig, TaskContractAddress: taskContractAddress, TaskId: taskID, - Stage: stage, + Phase: phase, }, } return msg diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 3329ebfa7..ad81f0dd8 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -228,25 +228,27 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (uint64, error) { avsInfo := k.GetAVSInfoByTaskAddress(ctx, params.TaskContractAddress) if avsInfo.AvsAddress == "" { - return 0, errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", params.TaskContractAddress)) + return types.InvalidTaskID, errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", params.TaskContractAddress)) } // If avs CreateAVSTask check CallerAddress if !slices.Contains(avsInfo.AvsOwnerAddress, params.CallerAddress) { - return 0, errorsmod.Wrap(types.ErrCallerAddressUnauthorized, fmt.Sprintf("this caller not qualified to CreateAVSTask %s", params.CallerAddress)) + return types.InvalidTaskID, errorsmod.Wrap(types.ErrCallerAddressUnauthorized, fmt.Sprintf("this caller not qualified to CreateAVSTask %s", params.CallerAddress)) } taskPowerTotal, err := k.operatorKeeper.GetAVSUSDValue(ctx, avsInfo.AvsAddress) - - if err != nil || taskPowerTotal.IsZero() || taskPowerTotal.IsNegative() { - return 0, errorsmod.Wrap(types.ErrVotingPowerIncorrect, fmt.Sprintf("the votingpower of avs is <<=0,avs addr is:%s", avsInfo.AvsAddress)) + if err != nil { + return types.InvalidTaskID, errorsmod.Wrap(err, "failed to get AVS USD value") + } + if taskPowerTotal.IsZero() || taskPowerTotal.IsNegative() { + return types.InvalidTaskID, errorsmod.Wrap(types.ErrVotingPowerIncorrect, fmt.Sprintf("the voting power of AVS is zero or negative, AVS address: %s", avsInfo.AvsAddress)) } epoch, found := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier) if !found { - return 0, errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", avsInfo.EpochIdentifier)) + return types.InvalidTaskID, errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", avsInfo.EpochIdentifier)) } if k.IsExistTask(ctx, strconv.FormatUint(params.TaskID, 10), params.TaskContractAddress) { - return 0, errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the task is :%s", strconv.FormatUint(params.TaskID, 10))) + return types.InvalidTaskID, errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the task is :%s", strconv.FormatUint(params.TaskID, 10))) } operatorList, err := k.operatorKeeper.GetOptedInOperatorListByAVS(ctx, avsInfo.AvsAddress) if err != nil { @@ -445,15 +447,3 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *types.Challeng return k.SetTaskChallengedInfo(ctx, params.TaskID, params.OperatorAddress.String(), params.CallerAddress, params.TaskContractAddress) } - -func (k Keeper) SubmitTaskResult(ctx sdk.Context, params *types.TaskResultParams) error { - result := &types.TaskResultInfo{ - TaskId: params.TaskID, - OperatorAddress: params.OperatorAddress, - TaskContractAddress: params.TaskContractAddress.String(), - TaskResponse: params.TaskResponse, - BlsSignature: params.BlsSignature, - Stage: params.Stage, - } - return k.SetTaskResultInfo(ctx, params.OperatorAddress, result) -} diff --git a/x/avs/keeper/multi_operator_submit_task_test.go b/x/avs/keeper/multi_operator_submit_task_test.go index c80332f60..7320ea4b7 100644 --- a/x/avs/keeper/multi_operator_submit_task_test.go +++ b/x/avs/keeper/multi_operator_submit_task_test.go @@ -201,7 +201,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseOne_Mul() { TaskResponseHash: "", TaskResponse: nil, BlsSignature: sig.Marshal(), - Stage: avstypes.TwoPhaseCommitOne, + Phase: uint32(avstypes.PreparePhase), } err := suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, operatorAddress, info) suite.Require().NoError(err) @@ -229,7 +229,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseTwo_Mul() { TaskResponseHash: hash.String(), TaskResponse: jsonData, BlsSignature: sig.Marshal(), - Stage: avstypes.TwoPhaseCommitTwo, + Phase: uint32(avstypes.DoCommitPhase), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, operatorAddress, info) suite.NoError(err) diff --git a/x/avs/keeper/submit_task_test.go b/x/avs/keeper/submit_task_test.go index 71df5a843..d9d0867dd 100644 --- a/x/avs/keeper/submit_task_test.go +++ b/x/avs/keeper/submit_task_test.go @@ -187,7 +187,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseOne() { TaskResponseHash: "", TaskResponse: nil, BlsSignature: sig.Marshal(), - Stage: avstypes.TwoPhaseCommitOne, + Phase: uint32(avstypes.PreparePhase), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, suite.operatorAddr.String(), info) suite.NoError(err) @@ -216,7 +216,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseTwo() { TaskResponseHash: hash.String(), TaskResponse: jsonData, BlsSignature: sig.Marshal(), - Stage: avstypes.TwoPhaseCommitTwo, + Phase: uint32(avstypes.DoCommitPhase), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, suite.operatorAddr.String(), info) suite.NoError(err) diff --git a/x/avs/keeper/task.go b/x/avs/keeper/task.go index 17c1d3c36..4d3c29bd4 100644 --- a/x/avs/keeper/task.go +++ b/x/avs/keeper/task.go @@ -182,8 +182,8 @@ func (k *Keeper) SetTaskResultInfo( avsInfo.EpochIdentifier)) } - switch info.Stage { - case types.TwoPhaseCommitOne: + switch info.Phase { + case uint32(types.PreparePhase): if k.IsExistTaskResultInfo(ctx, info.OperatorAddress, info.TaskContractAddress, info.TaskId) { return errorsmod.Wrap( types.ErrResAlreadyExists, @@ -221,7 +221,7 @@ func (k *Keeper) SetTaskResultInfo( store.Set(infoKey, bz) return nil - case types.TwoPhaseCommitTwo: + case uint32(types.DoCommitPhase): // check task response if info.TaskResponse == nil { return errorsmod.Wrap( @@ -284,7 +284,7 @@ func (k *Keeper) SetTaskResultInfo( default: return errorsmod.Wrap( types.ErrParamError, - fmt.Sprintf("SetTaskResultInfo: invalid param value:%s", info.Stage), + fmt.Sprintf("SetTaskResultInfo: invalid param value:%d", info.Phase), ) } } diff --git a/x/avs/types/errors.go b/x/avs/types/errors.go index f052ea0a1..cea46359b 100644 --- a/x/avs/types/errors.go +++ b/x/avs/types/errors.go @@ -76,7 +76,7 @@ var ( ErrParamError = errorsmod.Register( ModuleName, 18, - "The parameter must be 1 or 2", + "The parameter must be 0 or 1", ) ErrParamNotEmptyError = errorsmod.Register( diff --git a/x/avs/types/tx.pb.go b/x/avs/types/tx.pb.go index 99a74f995..307d7c693 100644 --- a/x/avs/types/tx.pb.go +++ b/x/avs/types/tx.pb.go @@ -1012,9 +1012,9 @@ type TaskResultInfo struct { TaskContractAddress string `protobuf:"bytes,5,opt,name=task_contract_address,json=taskContractAddress,proto3" json:"task_contract_address,omitempty"` // task_id is the task id TaskId uint64 `protobuf:"varint,6,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` - // stage this field is used to solve the problem of task results being copied by other operators. - // It is a two-stage submission with two values, 1 and 2 - Stage string `protobuf:"bytes,7,opt,name=stage,proto3" json:"stage,omitempty"` + // phase this field is used to solve the problem of task results being copied by other operators. + // It is a two-phase submission with two values, 0 and 1 + Phase uint32 `protobuf:"varint,7,opt,name=phase,proto3" json:"phase,omitempty"` } func (m *TaskResultInfo) Reset() { *m = TaskResultInfo{} } @@ -1092,11 +1092,11 @@ func (m *TaskResultInfo) GetTaskId() uint64 { return 0 } -func (m *TaskResultInfo) GetStage() string { +func (m *TaskResultInfo) GetPhase() uint32 { if m != nil { - return m.Stage + return m.Phase } - return "" + return 0 } // SubmitTaskResultReq is the request to submit task results. @@ -1200,112 +1200,112 @@ func init() { func init() { proto.RegisterFile("exocore/avs/v1/tx.proto", fileDescriptor_ef1ed06249b07d86) } var fileDescriptor_ef1ed06249b07d86 = []byte{ - // 1667 bytes of a gzipped FileDescriptorProto + // 1670 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0x1b, 0xc7, 0x15, 0xd6, 0x4a, 0x94, 0x44, 0x3e, 0x52, 0x14, 0x35, 0xa2, 0xc3, 0x35, 0xdd, 0x92, 0xc2, 0xba, 0x4e, 0x64, 0x25, 0x26, 0x6d, 0xa5, 0x28, 0x0c, 0xf7, 0x24, 0x55, 0x6e, 0x2a, 0xa4, 0xb1, 0x85, - 0xa5, 0x9a, 0x16, 0xed, 0x61, 0x31, 0xe4, 0x8e, 0x56, 0x0b, 0x2d, 0x77, 0xd8, 0x9d, 0x21, 0x6d, + 0xa5, 0x9a, 0x16, 0xed, 0x61, 0x31, 0xe4, 0x8e, 0x96, 0x0b, 0x2d, 0x77, 0xd8, 0x9d, 0x21, 0x6d, 0xf7, 0x50, 0x14, 0x3e, 0x15, 0x41, 0x51, 0xb4, 0x08, 0xd0, 0x73, 0xee, 0xbd, 0x18, 0x45, 0x2e, 0x05, 0xda, 0x7b, 0x8e, 0x41, 0x7a, 0x29, 0x7a, 0x30, 0x0a, 0xb9, 0x80, 0xdb, 0xff, 0xa2, 0x98, - 0x37, 0xb3, 0x14, 0x97, 0x94, 0xac, 0xba, 0x39, 0x24, 0x17, 0x73, 0xe7, 0xfd, 0x9a, 0xef, 0xbd, - 0x79, 0xef, 0x9b, 0xb1, 0xa0, 0xc6, 0x1e, 0xf3, 0x1e, 0x4f, 0x58, 0x9b, 0x8e, 0x44, 0x7b, 0x74, - 0xa7, 0x2d, 0x1f, 0xb7, 0x06, 0x09, 0x97, 0x9c, 0x94, 0x8d, 0xa2, 0x45, 0x47, 0xa2, 0x35, 0xba, - 0x53, 0x5f, 0xa3, 0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c, 0xb1, 0xb0, 0x59, 0x70, 0x57, 0xe9, - 0x48, 0x3c, 0x54, 0xf2, 0x14, 0xf2, 0x4d, 0x28, 0x50, 0x21, 0x98, 0xf4, 0x42, 0x5f, 0xd8, 0x79, - 0x65, 0xb3, 0x5b, 0x3a, 0x7d, 0xde, 0xcc, 0xef, 0x28, 0xe1, 0xfe, 0x9e, 0x70, 0xf3, 0xa8, 0xde, - 0xf7, 0x05, 0xb9, 0x0d, 0x55, 0x15, 0x76, 0x18, 0x77, 0x79, 0xec, 0x87, 0x71, 0xe0, 0x0d, 0x58, - 0x12, 0x72, 0xdf, 0x2e, 0x60, 0x86, 0x84, 0x8e, 0xc4, 0x8f, 0x52, 0xd5, 0x01, 0x6a, 0x48, 0x0b, - 0xd6, 0xb1, 0x1e, 0x2c, 0x3a, 0xf2, 0x7c, 0x16, 0xb1, 0x00, 0xcb, 0x6d, 0x03, 0x3a, 0xac, 0xa9, - 0x92, 0xb0, 0xe8, 0x68, 0x6f, 0xac, 0x20, 0x37, 0xa1, 0xc2, 0x06, 0xbc, 0x77, 0xec, 0x85, 0x3e, - 0x8b, 0x65, 0x78, 0x14, 0xb2, 0xc4, 0x2e, 0x62, 0x7a, 0xab, 0x28, 0xdf, 0x1f, 0x8b, 0x49, 0x1b, - 0xaa, 0x2a, 0x34, 0x1f, 0x48, 0x0f, 0x7f, 0x58, 0x42, 0x25, 0x4f, 0x84, 0x5d, 0x1a, 0xc7, 0x7e, - 0x38, 0x90, 0xfb, 0xf1, 0xc3, 0x54, 0x41, 0xde, 0x85, 0x37, 0x94, 0x83, 0xe4, 0x92, 0x46, 0xd9, - 0x13, 0x5a, 0x41, 0x17, 0x85, 0xf4, 0x50, 0x29, 0x27, 0x8f, 0xe9, 0x06, 0x94, 0x85, 0xa4, 0x89, - 0x54, 0xd9, 0x22, 0x02, 0xbb, 0x8c, 0xc6, 0x2b, 0xa9, 0xf4, 0xbe, 0x12, 0x92, 0xab, 0x90, 0xef, - 0x1d, 0xd3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Reference imports to suppress errors if they are not otherwise used. @@ -2289,12 +2289,10 @@ func (m *TaskResultInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Stage) > 0 { - i -= len(m.Stage) - copy(dAtA[i:], m.Stage) - i = encodeVarintTx(dAtA, i, uint64(len(m.Stage))) + if m.Phase != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Phase)) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x38 } if m.TaskId != 0 { i = encodeVarintTx(dAtA, i, uint64(m.TaskId)) @@ -2792,9 +2790,8 @@ func (m *TaskResultInfo) Size() (n int) { if m.TaskId != 0 { n += 1 + sovTx(uint64(m.TaskId)) } - l = len(m.Stage) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Phase != 0 { + n += 1 + sovTx(uint64(m.Phase)) } return n } @@ -5504,10 +5501,10 @@ func (m *TaskResultInfo) Unmarshal(dAtA []byte) error { } } case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stage", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Phase", wireType) } - var stringLen uint64 + m.Phase = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5517,24 +5514,11 @@ func (m *TaskResultInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Phase |= uint32(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.Stage = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/avs/types/types.go b/x/avs/types/types.go index 5a031c568..175b714d1 100644 --- a/x/avs/types/types.go +++ b/x/avs/types/types.go @@ -46,6 +46,8 @@ var ( ChainIDPrefix = []byte("chain-id-prefix") ) +const InvalidTaskID = 0 + type AVSRegisterOrDeregisterParams struct { // AvsName is the name of the AVS as an arbitrary string. AvsName string diff --git a/x/avs/types/stage.go b/x/avs/types/utils.go similarity index 79% rename from x/avs/types/stage.go rename to x/avs/types/utils.go index e951ca459..e0ea1bac2 100644 --- a/x/avs/types/stage.go +++ b/x/avs/types/utils.go @@ -5,21 +5,22 @@ import ( "github.com/ethereum/go-ethereum/common" ) +// CommitPhase represents the phases of the Two-Phase Commit protocol +type CommitPhase uint32 + const ( - // TwoPhaseCommitOne The first stage of the two-stage submission. - TwoPhaseCommitOne = "1" - // TwoPhaseCommitTwo The second stage of submission. - TwoPhaseCommitTwo = "2" + PreparePhase CommitPhase = iota + DoCommitPhase ) type OperatorOptParams struct { - Name string - BlsPublicKey string - IsRegistered bool - Action uint64 - OperatorAddress string - Status string - AvsAddress string + Name string `json:"name"` + BlsPublicKey string `json:"bls_public_key"` + IsRegistered bool `json:"is_registered"` + Action uint64 `json:"action"` + OperatorAddress string `json:"operator_address"` + Status string `json:"status"` + AvsAddress string `json:"avs_address"` } type TaskInfoParams struct { @@ -88,13 +89,13 @@ type TaskResultParams struct { BlsSignature []byte `json:"bls_signature"` TaskContractAddress common.Address `json:"task_contract_address"` TaskID uint64 `json:"task_id"` - Stage string `json:"stage"` + Phase uint8 `json:"phase"` CallerAddress string `json:"caller_address"` } type OperatorParams struct { - EarningsAddr string `json:"earnings_addr"` - ApproveAddr string `json:"approve_addr"` - OperatorMetaInfo string `json:"operator_meta_info"` - CallerAddress string `json:"caller_address"` + EarningsAddr string `json:"earnings_addr"` + ApproveAddr string `json:"approve_addr"` + OperatorMetaInfo string `json:"operator_meta_info"` + CallerAddress sdk.AccAddress `json:"caller_address"` } From ecbb71c95bddf3c620df361b9214fd4aa332b0e2 Mon Sep 17 00:00:00 2001 From: trestin Date: Fri, 25 Oct 2024 17:25:17 +0800 Subject: [PATCH 12/24] fix comments --- precompiles/avs/IAVSManager.sol | 20 ++--- precompiles/avs/abi.json | 64 +++++++++++---- precompiles/avs/avs.go | 6 +- precompiles/avs/avs_test.go | 10 +-- precompiles/avs/events.go | 25 +++--- precompiles/avs/query.go | 16 ++-- precompiles/avs/tx.go | 34 ++++---- precompiles/avs/types.go | 18 ++--- precompiles/avs/utils_test.go | 6 +- x/avs/keeper/avs.go | 4 +- x/avs/keeper/avs_test.go | 37 +++++---- x/avs/keeper/epoch_test.go | 2 +- x/avs/keeper/keeper.go | 69 +++++++---------- .../keeper/multi_operator_submit_task_test.go | 8 +- x/avs/keeper/submit_task_test.go | 10 +-- x/avs/keeper/task.go | 8 +- x/avs/types/errors.go | 2 +- x/avs/types/types.go | 21 ++--- x/avs/types/utils.go | 77 +++++++++---------- x/dogfood/keeper/msg_server.go | 4 +- x/operator/keeper/opt_test.go | 2 +- 21 files changed, 235 insertions(+), 208 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index d84730680..c347d2ff2 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -12,18 +12,18 @@ IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager( /// @dev The interface through which solidity contracts will interact with AVS-Manager /// @custom:address 0x0000000000000000000000000000000000000901 interface IAVSManager { - event AVSRegistered(address indexed sender, string avsName); - event AVSUpdated(address indexed sender, string avsName); - event AVSDeregistered(address indexed sender, string avsName); - event OperatorJoined(address indexed sender); - event OperatorOuted(address indexed sender); - event TaskCreated(address indexed sender,uint64 taskId,address indexed taskContractAddress,string name,bytes hash, + event AVSRegistered(address indexed avsAddr, string sender, string avsName); + event AVSUpdated(address indexed avsAddr, string sender, string avsName); + event AVSDeregistered(address indexed avsAddr, string sender, string avsName); + event OperatorJoined(address indexed avsAddr,string sender); + event OperatorOuted(address indexed avsAddr,string sender); + event TaskCreated(string sender,uint64 taskId,address indexed taskContractAddress,string name,bytes hash, uint64 taskResponsePeriod,uint64 taskChallengePeriod,uint64 thresholdPercentage,uint64 taskStatisticalPeriod ); - event ChallengeInitiated(address indexed sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, + event ChallengeInitiated(string sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, string operatorAddress); - event PublicKeyRegistered(address indexed sender, string name); - event TaskSubmittedByOperator(address indexed sender, uint64 taskID, bytes taskResponse, + event PublicKeyRegistered(string sender, string name); + event TaskSubmittedByOperator(string sender, uint64 taskID, bytes taskResponse, bytes blsSignature, address indexed taskContractAddress, uint8 phase); @@ -199,7 +199,7 @@ interface IAVSManager { string memory operatorAddr ) external view returns (uint256 amount); - /// @dev getAVSInfo is a function to query Avs info. + /// @dev getAVSInfo is a function to query Avs epochIdentifier info. /// @param avsAddr The address of the avs function getAVSInfo( address avsAddr diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index a4c3b2506..7cbbdb7fc 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -5,9 +5,15 @@ { "indexed": true, "internalType": "address", - "name": "sender", + "name": "avsAddr", "type": "address" }, + { + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" + }, { "indexed": false, "internalType": "string", @@ -24,9 +30,15 @@ { "indexed": true, "internalType": "address", - "name": "sender", + "name": "avsAddr", "type": "address" }, + { + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" + }, { "indexed": false, "internalType": "string", @@ -43,9 +55,15 @@ { "indexed": true, "internalType": "address", - "name": "sender", + "name": "avsAddr", "type": "address" }, + { + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" + }, { "indexed": false, "internalType": "string", @@ -60,10 +78,10 @@ "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", + "indexed": false, + "internalType": "string", "name": "sender", - "type": "address" + "type": "string" }, { "indexed": false, @@ -99,8 +117,14 @@ { "indexed": true, "internalType": "address", - "name": "sender", + "name": "avsAddr", "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" } ], "name": "OperatorJoined", @@ -112,8 +136,14 @@ { "indexed": true, "internalType": "address", - "name": "sender", + "name": "avsAddr", "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" } ], "name": "OperatorOuted", @@ -123,10 +153,10 @@ "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", + "indexed": false, + "internalType": "string", "name": "sender", - "type": "address" + "type": "string" }, { "indexed": false, @@ -142,10 +172,10 @@ "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", + "indexed": false, + "internalType": "string", "name": "sender", - "type": "address" + "type": "string" }, { "indexed": false, @@ -203,10 +233,10 @@ "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "address", + "indexed": false, + "internalType": "string", "name": "sender", - "type": "address" + "type": "string" }, { "indexed": false, diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index fc49f0835..5a050ea2b 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -135,7 +135,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.GetOptedInOperatorAccAddrs(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack([]string(nil)) + bz, err = method.Outputs.Pack([]string{}) } case MethodGetAVSInfo: bz, err = p.GetAVSInfo(ctx, contract, method, args) @@ -147,7 +147,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.GetTaskInfo(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack([]uint64(nil)) + bz, err = method.Outputs.Pack([]uint64{}) } case MethodIsOperator: bz, err = p.IsOperator(ctx, contract, method, args) @@ -167,7 +167,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.GetRegisteredPubkey(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) - bz, err = method.Outputs.Pack([]byte(nil)) + bz, err = method.Outputs.Pack([]byte{}) } case MethodGetOperatorOptedUSDValue: bz, err = p.GetOperatorOptedUSDValue(ctx, contract, method, args) diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index 40d267168..4261ba031 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -245,8 +245,8 @@ func (suite *AVSManagerPrecompileSuite) TestDeregisterAVS() { MinStakeAmount: minStakeAmount, MinOptInOperators: params[0], MinTotalStakeAmount: params[1], - AvsReward: sdk.MustNewDecFromStr(strconv.FormatUint(params[1], 10)), - AvsSlash: sdk.MustNewDecFromStr(strconv.FormatUint(params[2], 10)), + AvsReward: sdk.MustNewDecFromStr(strconv.Itoa(int(params[1]))), + AvsSlash: sdk.MustNewDecFromStr(strconv.Itoa(int(params[2]))), } err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) @@ -391,8 +391,8 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() { MinStakeAmount: minStakeAmount, MinOptInOperators: params[0], MinTotalStakeAmount: params[1], - AvsReward: sdk.MustNewDecFromStr(strconv.FormatUint(params[1], 10)), - AvsSlash: sdk.MustNewDecFromStr(strconv.FormatUint(params[2], 10)), + AvsReward: sdk.MustNewDecFromStr(strconv.Itoa(int(params[1]))), + AvsSlash: sdk.MustNewDecFromStr(strconv.Itoa(int(params[2]))), } err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) @@ -536,7 +536,7 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { _, defaultAssetID := assetstypes.GetStakerIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &types.AVSRegisterOrDeregisterParams{ Action: types.UpdateAction, - AvsAddress: avsAddr.String(), + AvsAddress: avsAddr, AssetID: []string{defaultAssetID}, }) suite.NoError(err) diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index d24470c97..824ead060 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -54,42 +54,47 @@ func (p Precompile) emitEvent(ctx sdk.Context, stateDB vm.StateDB, eventName str func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { arguments := p.ABI.Events[EventTypeAVSRegistered].Inputs return p.emitEvent(ctx, stateDB, EventTypeAVSRegistered, arguments, - common.HexToAddress(avs.CallerAddress), + avs.AvsAddress, + avs.CallerAddress.String(), avs.AvsName) } func (p Precompile) EmitAVSUpdated(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { arguments := p.ABI.Events[EventTypeAVSUpdated].Inputs return p.emitEvent(ctx, stateDB, EventTypeAVSUpdated, arguments, - common.HexToAddress(avs.CallerAddress), + avs.AvsAddress, + avs.CallerAddress.String(), avs.AvsName) } func (p Precompile) EmitAVSDeregistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { arguments := p.ABI.Events[EventTypeAVSDeregistered].Inputs return p.emitEvent(ctx, stateDB, EventTypeAVSDeregistered, arguments, - common.HexToAddress(avs.CallerAddress), + avs.AvsAddress, + avs.CallerAddress.String(), avs.AvsName) } func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { arguments := p.ABI.Events[EventTypeOperatorJoined].Inputs return p.emitEvent(ctx, stateDB, EventTypeOperatorJoined, arguments, - common.HexToAddress(params.OperatorAddress)) + params.AvsAddress, + params.OperatorAddress.String()) } func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { arguments := p.ABI.Events[EventTypeOperatorOuted].Inputs return p.emitEvent(ctx, stateDB, EventTypeOperatorOuted, arguments, - common.HexToAddress(params.OperatorAddress)) + params.AvsAddress, + params.OperatorAddress.String()) } func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *avstypes.TaskInfoParams) error { arguments := p.ABI.Events[EventTypeTaskCreated].Inputs return p.emitEvent(ctx, stateDB, EventTypeTaskCreated, arguments, - common.HexToAddress(task.CallerAddress), + task.CallerAddress.String(), task.TaskID, - common.HexToAddress(task.TaskContractAddress), + task.TaskContractAddress, task.TaskName, task.Hash, task.TaskResponsePeriod, @@ -101,7 +106,7 @@ func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *a func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.ChallengeParams) error { arguments := p.ABI.Events[EventTypeChallengeInitiated].Inputs return p.emitEvent(ctx, stateDB, EventTypeChallengeInitiated, arguments, - common.HexToAddress(params.CallerAddress), + params.CallerAddress.String(), params.TaskHash, params.TaskID, params.TaskResponseHash, @@ -111,14 +116,14 @@ func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.BlsParams) error { arguments := p.ABI.Events[EventTypePublicKeyRegistered].Inputs return p.emitEvent(ctx, stateDB, EventTypePublicKeyRegistered, arguments, - common.HexToAddress(params.Operator), + params.Operator.String(), params.Name) } func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.TaskResultParams) error { arguments := p.ABI.Events[EventTypeTaskSubmittedByOperator].Inputs return p.emitEvent(ctx, stateDB, EventTypeTaskSubmittedByOperator, arguments, - common.HexToAddress(params.CallerAddress), + params.CallerAddress.String(), params.TaskID, params.TaskResponse, params.BlsSignature, diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index c4a3801cf..036fef55b 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -35,16 +35,18 @@ func (p Precompile) GetRegisteredPubkey( if len(args) != len(p.ABI.Methods[MethodGetRegisteredPubkey].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetRegisteredPubkey].Inputs), len(args)) } - // the key is set using the operator's acc address so the same logic should apply here addr, ok := args[0].(string) if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr) } - blsPubkeyInfo, err := p.avsKeeper.GetOperatorPubKey(ctx, addr) + blsPubKeyInfo, err := p.avsKeeper.GetOperatorPubKey(ctx, addr) if err != nil { + if errors.Is(err, avstype.ErrNoKeyInTheStore) { + return method.Outputs.Pack([]byte{}) + } return nil, err } - return method.Outputs.Pack(blsPubkeyInfo.PubKey) + return method.Outputs.Pack(blsPubKeyInfo.PubKey) } func (p Precompile) GetOptedInOperatorAccAddrs( @@ -85,6 +87,9 @@ func (p Precompile) GetAVSUSDValue( } amount, err := p.avsKeeper.GetOperatorKeeper().GetAVSUSDValue(ctx, addr.String()) if err != nil { + if errors.Is(err, avstype.ErrNoKeyInTheStore) { + return method.Outputs.Pack(common.Big0) + } return nil, err } return method.Outputs.Pack(amount.BigInt()) @@ -110,6 +115,9 @@ func (p Precompile) GetOperatorOptedUSDValue( } amount, err := p.avsKeeper.GetOperatorKeeper().GetOperatorOptedUSDValue(ctx, avsAddr.String(), operatorAddr) if err != nil { + if errors.Is(err, avstype.ErrNoKeyInTheStore) { + return method.Outputs.Pack(common.Big0) + } return nil, err } return method.Outputs.Pack(amount.ActiveUSDValue.BigInt()) @@ -124,7 +132,6 @@ func (p Precompile) GetAVSInfo( if len(args) != len(p.ABI.Methods[MethodGetAVSInfo].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetAVSInfo].Inputs), len(args)) } - // the key is set using the operator's acc address so the same logic should apply here addr, ok := args[0].(common.Address) if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) @@ -174,7 +181,6 @@ func (p Precompile) GetTaskInfo( if len(args) != len(p.ABI.Methods[MethodGetTaskInfo].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetTaskInfo].Inputs), len(args)) } - // the key is set using the operator's acc address so the same logic should apply here addr, ok := args[0].(common.Address) if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 7e8f2d06e..b468de81d 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -43,11 +43,11 @@ func (p Precompile) RegisterAVS( return nil, errorsmod.Wrap(err, "parse args error") } // verification of the calling address to ensure it is avs contract owner - if !slices.Contains(avsParams.AvsOwnerAddress, avsParams.CallerAddress) { + if !slices.Contains(avsParams.AvsOwnerAddress, avsParams.CallerAddress.String()) { return nil, errorsmod.Wrap(err, "not qualified to registerOrDeregister") } // The AVS registration is done by the calling contract. - avsParams.AvsAddress = contract.CallerAddress.String() + avsParams.AvsAddress = contract.CallerAddress avsParams.Action = avstypes.RegisterAction // Finally, update the AVS information in the keeper. err = p.avsKeeper.UpdateAVSInfo(ctx, avsParams) @@ -77,14 +77,14 @@ func (p Precompile) DeregisterAVS( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - avsParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + avsParams.CallerAddress = callerAddress[:] avsName, ok := args[1].(string) if !ok || avsName == "" { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", avsName) } avsParams.AvsName = avsName - avsParams.AvsAddress = contract.CallerAddress.String() + avsParams.AvsAddress = contract.CallerAddress avsParams.Action = avstypes.DeRegisterAction // validates that this is owner @@ -112,14 +112,14 @@ func (p Precompile) UpdateAVS( return nil, errorsmod.Wrap(err, "parse args error") } - avsParams.AvsAddress = contract.CallerAddress.String() + avsParams.AvsAddress = contract.CallerAddress avsParams.Action = avstypes.UpdateAction - previousAVSInfo, err := p.avsKeeper.GetAVSInfo(ctx, avsParams.AvsAddress) + previousAVSInfo, err := p.avsKeeper.GetAVSInfo(ctx, avsParams.AvsAddress.String()) if err != nil { return nil, err } // If avs UpdateAction check CallerAddress - if !slices.Contains(previousAVSInfo.Info.AvsOwnerAddress, avsParams.CallerAddress) { + if !slices.Contains(previousAVSInfo.Info.AvsOwnerAddress, avsParams.CallerAddress.String()) { return nil, fmt.Errorf("this caller not qualified to update %s", avsParams.CallerAddress) } err = p.avsKeeper.UpdateAVSInfo(ctx, avsParams) @@ -150,8 +150,8 @@ func (p Precompile) BindOperatorToAVS( } operatorParams := &avstypes.OperatorOptParams{} - operatorParams.OperatorAddress = sdk.AccAddress(callerAddress[:]).String() - operatorParams.AvsAddress = contract.CallerAddress.String() + operatorParams.OperatorAddress = callerAddress[:] + operatorParams.AvsAddress = contract.CallerAddress operatorParams.Action = avstypes.RegisterAction err := p.avsKeeper.OperatorOptAction(ctx, operatorParams) if err != nil { @@ -179,8 +179,8 @@ func (p Precompile) UnbindOperatorToAVS( return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } operatorParams := &avstypes.OperatorOptParams{} - operatorParams.OperatorAddress = sdk.AccAddress(callerAddress[:]).String() - operatorParams.AvsAddress = contract.CallerAddress.String() + operatorParams.OperatorAddress = callerAddress[:] + operatorParams.AvsAddress = contract.CallerAddress operatorParams.Action = avstypes.DeRegisterAction err := p.avsKeeper.OperatorOptAction(ctx, operatorParams) if err != nil { @@ -205,7 +205,7 @@ func (p Precompile) CreateAVSTask( if err != nil { return nil, err } - params.TaskContractAddress = contract.CallerAddress.String() + params.TaskContractAddress = contract.CallerAddress taskID, err := p.avsKeeper.CreateAVSTask(ctx, params) if err != nil { return nil, err @@ -234,7 +234,7 @@ func (p Precompile) Challenge( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - challengeParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + challengeParams.CallerAddress = callerAddress[:] taskHash, ok := args[1].([]byte) if !ok { @@ -292,7 +292,7 @@ func (p Precompile) RegisterBLSPublicKey( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - blsParams.Operator = sdk.AccAddress(callerAddress[:]).String() + blsParams.Operator = callerAddress[:] name, ok := args[1].(string) if !ok || name == "" { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", name) @@ -346,7 +346,7 @@ func (p Precompile) OperatorSubmitTask( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - resultParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + resultParams.CallerAddress = callerAddress[:] taskID, ok := args[1].(uint64) if !ok { @@ -382,13 +382,13 @@ func (p Precompile) OperatorSubmitTask( result := &avstypes.TaskResultInfo{ TaskId: resultParams.TaskID, - OperatorAddress: resultParams.OperatorAddress, + OperatorAddress: resultParams.OperatorAddress.String(), TaskContractAddress: resultParams.TaskContractAddress.String(), TaskResponse: resultParams.TaskResponse, BlsSignature: resultParams.BlsSignature, Phase: uint32(resultParams.Phase), } - err := p.avsKeeper.SetTaskResultInfo(ctx, resultParams.OperatorAddress, result) + err := p.avsKeeper.SetTaskResultInfo(ctx, resultParams.OperatorAddress.String(), result) if err != nil { return nil, err } diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index 2e2352292..155325731 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -23,7 +23,7 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - avsParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + avsParams.CallerAddress = callerAddress[:] avsName, ok := args[1].(string) if !ok || avsName == "" { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", avsName) @@ -40,19 +40,19 @@ func (p Precompile) GetAVSParamsFromInputs(_ sdk.Context, args []interface{}) (* if !ok || taskAddr == (common.Address{}) { return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 3, "common.Address", taskAddr) } - avsParams.TaskAddr = taskAddr.String() + avsParams.TaskAddr = taskAddr slashContractAddr, ok := args[4].(common.Address) if !ok || (slashContractAddr == common.Address{}) { return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 4, "common.Address", slashContractAddr) } - avsParams.SlashContractAddr = slashContractAddr.String() + avsParams.SlashContractAddr = slashContractAddr rewardContractAddr, ok := args[5].(common.Address) if !ok || (rewardContractAddr == common.Address{}) { return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 5, "common.Address", rewardContractAddr) } - avsParams.RewardContractAddr = rewardContractAddr.String() + avsParams.RewardContractAddr = rewardContractAddr // bech32 avsOwnerAddress, ok := args[6].([]string) @@ -125,7 +125,7 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - avsParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + avsParams.CallerAddress = callerAddress[:] avsName, ok := args[1].(string) if !ok { @@ -143,19 +143,19 @@ func (p Precompile) GetAVSParamsFromUpdateInputs(_ sdk.Context, args []interface if !ok || taskAddr == (common.Address{}) { return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 3, "common.Address", taskAddr) } - avsParams.TaskAddr = taskAddr.String() + avsParams.TaskAddr = taskAddr slashContractAddr, ok := args[4].(common.Address) if !ok { return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 4, "common.Address", slashContractAddr) } - avsParams.SlashContractAddr = slashContractAddr.String() + avsParams.SlashContractAddr = slashContractAddr rewardContractAddr, ok := args[5].(common.Address) if !ok { return nil, xerrors.Errorf(exocmn.ErrContractInputParaOrType, 5, "common.Address", rewardContractAddr) } - avsParams.RewardContractAddr = rewardContractAddr.String() + avsParams.RewardContractAddr = rewardContractAddr // bech32 avsOwnerAddress, ok := args[6].([]string) @@ -228,7 +228,7 @@ func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) ( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - taskParams.CallerAddress = sdk.AccAddress(callerAddress[:]).String() + taskParams.CallerAddress = callerAddress[:] name, ok := args[1].(string) if !ok || name == "" { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", name) diff --git a/precompiles/avs/utils_test.go b/precompiles/avs/utils_test.go index 74519ca1d..00a78dc5f 100644 --- a/precompiles/avs/utils_test.go +++ b/precompiles/avs/utils_test.go @@ -103,9 +103,9 @@ func (suite *AVSManagerPrecompileSuite) prepareAvs(assetIDs []string, task strin err := suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &avstypes.AVSRegisterOrDeregisterParams{ Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, - AvsAddress: suite.avsAddr, + AvsAddress: common.HexToAddress(suite.avsAddr), AssetID: assetIDs, - TaskAddr: task, + TaskAddr: common.HexToAddress(task), AvsOwnerAddress: avsOwnerAddress, }) suite.NoError(err) @@ -150,6 +150,7 @@ func (suite *AVSManagerPrecompileSuite) TestOptIn() { usdValue := operatorKeeper.CalculateUSDValue(suite.delegationAmount, price.Value, suite.assetDecimal, price.Decimal) expectedState := &StateForCheck{ OptedInfo: &operatorTypes.OptedInfo{ + SlashContract: "0x0000000000000000000000000000000000000000", OptedInHeight: uint64(suite.Ctx.BlockHeight()), OptedOutHeight: operatorTypes.DefaultOptedOutHeight, }, @@ -199,6 +200,7 @@ func (suite *AVSManagerPrecompileSuite) TestOptOut() { expectedState := &StateForCheck{ OptedInfo: &operatorTypes.OptedInfo{ + SlashContract: "0x0000000000000000000000000000000000000000", OptedInHeight: uint64(optInHeight), OptedOutHeight: uint64(suite.Ctx.BlockHeight()), }, diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index abbf48b77..f63ba2eea 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -85,7 +85,7 @@ func (k *Keeper) GetEpochEndAVSs(ctx sdk.Context, epochIdentifier string, ending // TODO:this function is frequently used while its implementation iterates over existing avs to find the target avs by task contract address, we should use a reverse mapping to avoid iteration func (k *Keeper) GetAVSInfoByTaskAddress(ctx sdk.Context, taskAddr string) types.AVSInfo { var avs types.AVSInfo - if taskAddr == "" { + if taskAddr == "" || taskAddr == "0x0000000000000000000000000000000000000000" { return avs } k.IterateAVSInfo(ctx, func(_ int64, avsInfo types.AVSInfo) (stop bool) { @@ -161,7 +161,7 @@ func (k Keeper) RegisterAVSWithChainID( return common.Address{}, err } // SetAVSInfo expects HexAddress for the AvsAddress - params.AvsAddress = avsAddrStr + params.AvsAddress = avsAddr params.Action = types.RegisterAction if err := k.UpdateAVSInfo(ctx, params); err != nil { diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index ad99f5a47..bf124a9e7 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "cosmossdk.io/math" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" + "github.com/ethereum/go-ethereum/common" "math/big" "time" @@ -62,20 +63,20 @@ func (suite *AVSTestSuite) TestAVS() { } func (suite *AVSTestSuite) TestUpdateAVSInfo_Register() { - avsName, avsAddres, slashAddress, rewardAddress := "avsTest", "exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" + avsName, avsAddres, slashAddress, rewardAddress := "avsTest", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" avsOwnerAddress := []string{"exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj1", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj2"} assetID := suite.AssetIDs avsParams := &types.AVSRegisterOrDeregisterParams{ AvsName: avsName, - AvsAddress: avsAddres, + AvsAddress: common.HexToAddress(avsAddres), Action: avstypes.RegisterAction, - RewardContractAddr: rewardAddress, + RewardContractAddr: common.HexToAddress(rewardAddress), AvsOwnerAddress: avsOwnerAddress, AssetID: assetID, MinSelfDelegation: uint64(10), UnbondingPeriod: uint64(2), - SlashContractAddr: slashAddress, + SlashContractAddr: common.HexToAddress(slashAddress), EpochIdentifier: epochstypes.DayEpochID, } @@ -94,19 +95,19 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_Register() { func (suite *AVSTestSuite) TestUpdateAVSInfo_DeRegister() { // Test case setup - avsName, avsAddres, slashAddress := "avsTest", suite.avsAddress.String(), "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutash" + avsName, avsAddress, slashAddress := "avsTest", suite.avsAddress.String(), "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" avsOwnerAddress := []string{"exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj1", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj2"} assetID := suite.AssetIDs avsParams := &types.AVSRegisterOrDeregisterParams{ AvsName: avsName, - AvsAddress: avsAddres, + AvsAddress: common.HexToAddress(avsAddress), Action: avstypes.DeRegisterAction, AvsOwnerAddress: avsOwnerAddress, AssetID: assetID, MinSelfDelegation: uint64(10), UnbondingPeriod: uint64(2), - SlashContractAddr: slashAddress, + SlashContractAddr: common.HexToAddress(slashAddress), EpochIdentifier: epochstypes.DayEpochID, } @@ -117,43 +118,41 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_DeRegister() { avsParams.Action = avstypes.RegisterAction err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, avsParams) suite.NoError(err) - info, err := suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddres) - suite.Equal(avsAddres, info.GetInfo().AvsAddress) + info, err := suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddress) + suite.Equal(avsAddress, info.GetInfo().AvsAddress) suite.CommitAfter(48*time.Hour + time.Nanosecond) suite.CommitAfter(48*time.Hour + time.Nanosecond) suite.CommitAfter(48*time.Hour + time.Nanosecond) suite.CommitAfter(48*time.Hour + time.Nanosecond) avsParams.Action = avstypes.DeRegisterAction - avsParams.CallerAddress = "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" + avsParams.CallerAddress, err = sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, avsParams) suite.NoError(err) - info, err = suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddres) + info, err = suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddress) suite.Error(err) suite.Contains(err.Error(), types.ErrNoKeyInTheStore.Error()) } func (suite *AVSTestSuite) TestUpdateAVSInfoWithOperator_Register() { avsAddress := suite.avsAddress - operatorAddress := sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String() + operatorAddress := sdk.AccAddress(utiltx.GenerateAddress().Bytes()) - opAccAddr, err := sdk.AccAddressFromBech32(operatorAddress) - suite.NoError(err) operatorParams := &avstypes.OperatorOptParams{ - AvsAddress: avsAddress.String(), + AvsAddress: avsAddress, Action: avstypes.RegisterAction, OperatorAddress: operatorAddress, } // operator Not Exist - err = suite.App.AVSManagerKeeper.OperatorOptAction(suite.Ctx, operatorParams) + err := suite.App.AVSManagerKeeper.OperatorOptAction(suite.Ctx, operatorParams) suite.Error(err) suite.Contains(err.Error(), delegationtypes.ErrOperatorNotExist.Error()) // register operator but avs not register // register operator registerReq := &operatorTypes.RegisterOperatorReq{ - FromAddress: opAccAddr.String(), + FromAddress: operatorAddress.String(), Info: &operatorTypes.OperatorInfo{ - EarningsAddr: opAccAddr.String(), + EarningsAddr: operatorAddress.String(), }, } _, err = suite.OperatorMsgServer.RegisterOperator(sdk.WrapSDKContext(suite.Ctx), registerReq) @@ -164,7 +163,7 @@ func (suite *AVSTestSuite) TestUpdateAVSInfoWithOperator_Register() { _, assetID := assetstypes.GetStakerIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) selfDelegateAmount := big.NewInt(10) minPrecisionSelfDelegateAmount := big.NewInt(0).Mul(selfDelegateAmount, big.NewInt(0).Exp(big.NewInt(10), big.NewInt(int64(asset.Decimals)), nil)) - err = suite.App.AssetsKeeper.UpdateOperatorAssetState(suite.Ctx, opAccAddr, assetID, assetstypes.DeltaOperatorSingleAsset{ + err = suite.App.AssetsKeeper.UpdateOperatorAssetState(suite.Ctx, operatorAddress, assetID, assetstypes.DeltaOperatorSingleAsset{ TotalAmount: math.NewIntFromBigInt(minPrecisionSelfDelegateAmount), TotalShare: math.LegacyNewDecFromBigInt(minPrecisionSelfDelegateAmount), OperatorShare: math.LegacyNewDecFromBigInt(minPrecisionSelfDelegateAmount), diff --git a/x/avs/keeper/epoch_test.go b/x/avs/keeper/epoch_test.go index eb9ab2e44..779251da6 100644 --- a/x/avs/keeper/epoch_test.go +++ b/x/avs/keeper/epoch_test.go @@ -23,7 +23,7 @@ func (suite *AVSTestSuite) TestEpochEnd_TaskCalculation() { suite.CommitAfter(suite.EpochDuration) suite.CommitAfter(suite.EpochDuration) suite.CommitAfter(suite.EpochDuration) - info, err := suite.App.AVSManagerKeeper.GetTaskInfo(suite.Ctx, strconv.FormatUint(suite.taskId, 10), common.Address(suite.taskAddress.Bytes()).String()) + info, err := suite.App.AVSManagerKeeper.GetTaskInfo(suite.Ctx, strconv.Itoa(int(suite.taskId)), common.Address(suite.taskAddress.Bytes()).String()) suite.NoError(err) expectInfo := &avstypes.TaskInfo{ TaskContractAddress: suite.taskAddress.String(), diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index ad81f0dd8..bdefca350 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -77,7 +77,7 @@ func (k Keeper) ValidateAssetIDs(ctx sdk.Context, assetIDs []string) error { } func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregisterParams) error { - avsInfo, _ := k.GetAVSInfo(ctx, params.AvsAddress) + avsInfo, _ := k.GetAVSInfo(ctx, params.AvsAddress.String()) action := params.Action epochIdentifier := params.EpochIdentifier if avsInfo != nil && avsInfo.Info.EpochIdentifier != "" { @@ -92,7 +92,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi if avsInfo != nil { return errorsmod.Wrap(types.ErrAlreadyRegistered, fmt.Sprintf("the avsaddress is :%s", params.AvsAddress)) } - if k.GetAVSInfoByTaskAddress(ctx, params.TaskAddr).AvsAddress != "" { + if k.GetAVSInfoByTaskAddress(ctx, params.TaskAddr.String()).AvsAddress != "" { return errorsmod.Wrap(types.ErrAlreadyRegistered, fmt.Sprintf("this TaskAddr has already been used by other AVS,the TaskAddr is :%s", params.TaskAddr)) } startingEpoch := uint64(epoch.CurrentEpoch + 1) @@ -107,9 +107,9 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi avs := &types.AVSInfo{ Name: params.AvsName, - AvsAddress: params.AvsAddress, - RewardAddr: params.RewardContractAddr, - SlashAddr: params.SlashContractAddr, + AvsAddress: params.AvsAddress.String(), + RewardAddr: params.RewardContractAddr.String(), + SlashAddr: params.SlashContractAddr.String(), AvsOwnerAddress: params.AvsOwnerAddress, AssetIDs: params.AssetID, MinSelfDelegation: params.MinSelfDelegation, @@ -117,7 +117,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi EpochIdentifier: epochIdentifier, StartingEpoch: startingEpoch, MinOptInOperators: params.MinOptInOperators, - TaskAddr: params.TaskAddr, + TaskAddr: params.TaskAddr.String(), MinStakeAmount: params.MinStakeAmount, // Effective at CurrentEpoch+1, avoid immediate effects and ensure that the first epoch time of avs is equal to a normal identifier MinTotalStakeAmount: params.MinTotalStakeAmount, // #nosec G115 @@ -132,7 +132,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the avsaddress is :%s", params.AvsAddress)) } // If avs DeRegisterAction check CallerAddress - if !slices.Contains(avsInfo.Info.AvsOwnerAddress, params.CallerAddress) { + if !slices.Contains(avsInfo.Info.AvsOwnerAddress, params.CallerAddress.String()) { return errorsmod.Wrap(types.ErrCallerAddressUnauthorized, fmt.Sprintf("this caller not qualified to deregister %s", params.CallerAddress)) } @@ -146,25 +146,19 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi if avsInfo.Info.Name != params.AvsName { return errorsmod.Wrap(types.ErrAvsNameMismatch, fmt.Sprintf("Unregistered AVS name is incorrect %s", params.AvsName)) } - return k.DeleteAVSInfo(ctx, params.AvsAddress) + return k.DeleteAVSInfo(ctx, params.AvsAddress.String()) case types.UpdateAction: if avsInfo == nil { return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the avsaddress is :%s", params.AvsAddress)) } // Check here to ensure that the task address is only used by one avs - avsAddress := k.GetAVSInfoByTaskAddress(ctx, params.TaskAddr).AvsAddress + avsAddress := k.GetAVSInfoByTaskAddress(ctx, params.TaskAddr.String()).AvsAddress if avsAddress != "" && avsAddress != avsInfo.Info.AvsAddress { return errorsmod.Wrap(types.ErrAlreadyRegistered, fmt.Sprintf("this TaskAddr has already been used by other AVS,the TaskAddr is :%s", params.TaskAddr)) } // TODO: The AvsUnbondingPeriod is used for undelegation, but this check currently blocks updates to AVS information. Remove this check to allow AVS updates, while detailed control mechanisms for updates should be considered and implemented in the future. // If avs UpdateAction check UnbondingPeriod - // #nosec G115 - // if int64(avsInfo.Info.AvsUnbondingPeriod) < (epoch.CurrentEpoch - int64(avsInfo.GetInfo().StartingEpoch)) { - // return errorsmod.Wrap(types.ErrUnbondingPeriod, fmt.Sprintf("not qualified to deregister %s", avsInfo)) - // } - // If avs UpdateAction check CallerAddress - avs := avsInfo.Info if params.AvsName != "" { @@ -173,14 +167,14 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi if params.MinStakeAmount > 0 { avs.MinStakeAmount = params.MinStakeAmount } - if params.TaskAddr != "" { - avs.TaskAddr = params.TaskAddr + if params.TaskAddr.String() != "" { + avs.TaskAddr = params.TaskAddr.String() } - if params.SlashContractAddr != "" { - avs.SlashAddr = params.SlashContractAddr + if params.SlashContractAddr.String() != "" { + avs.SlashAddr = params.SlashContractAddr.String() } - if params.RewardContractAddr != "" { - avs.RewardAddr = params.RewardContractAddr + if params.RewardContractAddr.String() != "" { + avs.RewardAddr = params.RewardContractAddr.String() } if params.AvsOwnerAddress != nil { avs.AvsOwnerAddress = params.AvsOwnerAddress @@ -216,7 +210,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi // #nosec G115 avs.AvsReward = sdk.NewDecWithPrec(int64(params.AvsReward), 2) } - avs.AvsAddress = params.AvsAddress + avs.AvsAddress = params.AvsAddress.String() avs.StartingEpoch = uint64(epoch.CurrentEpoch + 1) return k.SetAVSInfo(ctx, avs) @@ -226,12 +220,12 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi } func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (uint64, error) { - avsInfo := k.GetAVSInfoByTaskAddress(ctx, params.TaskContractAddress) + avsInfo := k.GetAVSInfoByTaskAddress(ctx, params.TaskContractAddress.String()) if avsInfo.AvsAddress == "" { return types.InvalidTaskID, errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", params.TaskContractAddress)) } // If avs CreateAVSTask check CallerAddress - if !slices.Contains(avsInfo.AvsOwnerAddress, params.CallerAddress) { + if !slices.Contains(avsInfo.AvsOwnerAddress, params.CallerAddress.String()) { return types.InvalidTaskID, errorsmod.Wrap(types.ErrCallerAddressUnauthorized, fmt.Sprintf("this caller not qualified to CreateAVSTask %s", params.CallerAddress)) } taskPowerTotal, err := k.operatorKeeper.GetAVSUSDValue(ctx, avsInfo.AvsAddress) @@ -247,18 +241,18 @@ func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (ui return types.InvalidTaskID, errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", avsInfo.EpochIdentifier)) } - if k.IsExistTask(ctx, strconv.FormatUint(params.TaskID, 10), params.TaskContractAddress) { + if k.IsExistTask(ctx, strconv.FormatUint(params.TaskID, 10), params.TaskContractAddress.String()) { return types.InvalidTaskID, errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the task is :%s", strconv.FormatUint(params.TaskID, 10))) } operatorList, err := k.operatorKeeper.GetOptedInOperatorListByAVS(ctx, avsInfo.AvsAddress) if err != nil { return 0, errorsmod.Wrap(err, "CreateAVSTask: failed to get opt-in operators") } - params.TaskID = k.GetTaskID(ctx, common.HexToAddress(params.TaskContractAddress)) + params.TaskID = k.GetTaskID(ctx, common.HexToAddress(params.TaskContractAddress.String())) task := &types.TaskInfo{ Name: params.TaskName, Hash: params.Hash, - TaskContractAddress: params.TaskContractAddress, + TaskContractAddress: params.TaskContractAddress.String(), TaskId: params.TaskID, TaskChallengePeriod: params.TaskChallengePeriod, ThresholdPercentage: params.ThresholdPercentage, @@ -281,29 +275,24 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *types.BlsParams) e return errorsmod.Wrap(types.ErrSigNotMatchPubKey, fmt.Sprintf("the operator is :%s", params.Operator)) } - if k.IsExistPubKey(ctx, params.Operator) { + if k.IsExistPubKey(ctx, params.Operator.String()) { return errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the operator is :%s", params.Operator)) } bls := &types.BlsPubKeyInfo{ Name: params.Name, - Operator: params.Operator, + Operator: params.Operator.String(), PubKey: params.PubKey, } return k.SetOperatorPubKey(ctx, bls) } func (k Keeper) OperatorOptAction(ctx sdk.Context, params *types.OperatorOptParams) error { - operatorAddress := params.OperatorAddress - opAccAddr, err := sdk.AccAddressFromBech32(operatorAddress) - if err != nil { - return errorsmod.Wrap(err, fmt.Sprintf("error occurred when parse acc address from Bech32,the addr is:%s", operatorAddress)) - } - + opAccAddr := params.OperatorAddress if !k.operatorKeeper.IsOperator(ctx, opAccAddr) { - return errorsmod.Wrap(delegationtypes.ErrOperatorNotExist, fmt.Sprintf("UpdateAVSInfo: invalid operator address:%s", operatorAddress)) + return errorsmod.Wrap(delegationtypes.ErrOperatorNotExist, fmt.Sprintf("UpdateAVSInfo: invalid operator address:%s", opAccAddr.String())) } - f, err := k.IsAVS(ctx, params.AvsAddress) + f, err := k.IsAVS(ctx, params.AvsAddress.String()) if err != nil { return errorsmod.Wrap(err, fmt.Sprintf("error occurred when get avs info,this avs address: %s", params.AvsAddress)) } @@ -313,9 +302,9 @@ func (k Keeper) OperatorOptAction(ctx sdk.Context, params *types.OperatorOptPara switch params.Action { case types.RegisterAction: - return k.operatorKeeper.OptIn(ctx, opAccAddr, params.AvsAddress) + return k.operatorKeeper.OptIn(ctx, opAccAddr, params.AvsAddress.String()) case types.DeRegisterAction: - return k.operatorKeeper.OptOut(ctx, opAccAddr, params.AvsAddress) + return k.operatorKeeper.OptOut(ctx, opAccAddr, params.AvsAddress.String()) default: return errorsmod.Wrap(types.ErrInvalidAction, fmt.Sprintf("Invalid action: %d", params.Action)) } @@ -444,6 +433,6 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *types.Challeng fmt.Sprintf("SetTaskResultInfo:submit too late, CurrentEpoch:%d", epoch.CurrentEpoch), ) } - return k.SetTaskChallengedInfo(ctx, params.TaskID, params.OperatorAddress.String(), params.CallerAddress, + return k.SetTaskChallengedInfo(ctx, params.TaskID, params.OperatorAddress.String(), params.CallerAddress.String(), params.TaskContractAddress) } diff --git a/x/avs/keeper/multi_operator_submit_task_test.go b/x/avs/keeper/multi_operator_submit_task_test.go index 7320ea4b7..e11bbbda7 100644 --- a/x/avs/keeper/multi_operator_submit_task_test.go +++ b/x/avs/keeper/multi_operator_submit_task_test.go @@ -87,11 +87,11 @@ func (suite *AVSTestSuite) prepareMulAvs(assetIDs []string) { AvsName: "avs01", Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, - AvsAddress: suite.avsAddr, + AvsAddress: common.HexToAddress(suite.avsAddr), AssetID: assetIDs, - TaskAddr: suite.taskAddress.String(), - SlashContractAddr: "", - RewardContractAddr: "", + TaskAddr: suite.taskAddress, + SlashContractAddr: common.Address{}, + RewardContractAddr: common.Address{}, MinSelfDelegation: 0, AvsOwnerAddress: nil, UnbondingPeriod: 7, diff --git a/x/avs/keeper/submit_task_test.go b/x/avs/keeper/submit_task_test.go index d9d0867dd..aea3bd56a 100644 --- a/x/avs/keeper/submit_task_test.go +++ b/x/avs/keeper/submit_task_test.go @@ -80,11 +80,11 @@ func (suite *AVSTestSuite) prepareAvs(assetIDs []string) { AvsName: "avs01", Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, - AvsAddress: suite.avsAddr, + AvsAddress: common.HexToAddress(suite.avsAddr), AssetID: assetIDs, - TaskAddr: suite.taskAddress.String(), - SlashContractAddr: "", - RewardContractAddr: "", + TaskAddr: suite.taskAddress, + SlashContractAddr: common.Address{}, + RewardContractAddr: common.Address{}, MinSelfDelegation: 3, AvsOwnerAddress: nil, UnbondingPeriod: 7, @@ -142,7 +142,7 @@ func (suite *AVSTestSuite) prepareTaskInfo() { err = suite.App.AVSManagerKeeper.SetTaskInfo(suite.Ctx, info) suite.NoError(err) - getTaskInfo, err := suite.App.AVSManagerKeeper.GetTaskInfo(suite.Ctx, strconv.FormatUint(suite.taskId, 10), common.Address(suite.taskAddress.Bytes()).String()) + getTaskInfo, err := suite.App.AVSManagerKeeper.GetTaskInfo(suite.Ctx, strconv.Itoa(int(suite.taskId)), common.Address(suite.taskAddress.Bytes()).String()) suite.NoError(err) suite.Equal(*info, *getTaskInfo) } diff --git a/x/avs/keeper/task.go b/x/avs/keeper/task.go index 4d3c29bd4..349f6fd1b 100644 --- a/x/avs/keeper/task.go +++ b/x/avs/keeper/task.go @@ -172,9 +172,9 @@ func (k *Keeper) SetTaskResultInfo( } // check prescribed period - // If submitted in the first stage, in order to avoid plagiarism by other operators, + // If submitted in the first phase, in order to avoid plagiarism by other operators, // TaskResponse and TaskResponseHash must be null values - // At the same time, it must be submitted within the response deadline in the first stage + // At the same time, it must be submitted within the response deadline in the first phase avsInfo := k.GetAVSInfoByTaskAddress(ctx, info.TaskContractAddress) epoch, found := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier) if !found { @@ -206,7 +206,7 @@ func (k *Keeper) SetTaskResultInfo( info.TaskResponseHash, info.TaskResponse), ) } - // check epoch,The first stage submission must be within the response window period + // check epoch,The first phase submission must be within the response window period // #nosec G115 if epoch.CurrentEpoch > int64(task.StartingEpoch)+int64(task.TaskResponsePeriod) { return errorsmod.Wrap( @@ -240,7 +240,7 @@ func (k *Keeper) SetTaskResultInfo( info.OperatorAddress, info.TaskContractAddress, info.TaskId, info.BlsSignature), ) } - // check epoch,The second stage submission must be within the statistical window period + // check epoch,The second phase submission must be within the statistical window period // #nosec G115 if epoch.CurrentEpoch <= int64(task.StartingEpoch)+int64(task.TaskResponsePeriod) { return errorsmod.Wrap( diff --git a/x/avs/types/errors.go b/x/avs/types/errors.go index cea46359b..3db686b13 100644 --- a/x/avs/types/errors.go +++ b/x/avs/types/errors.go @@ -81,7 +81,7 @@ var ( ErrParamNotEmptyError = errorsmod.Register( ModuleName, 19, - "In the first stage, the parameter must be empty.", + "In the first phase, the parameter must be empty.", ) ErrSubmitTooLateError = errorsmod.Register( ModuleName, 20, diff --git a/x/avs/types/types.go b/x/avs/types/types.go index 175b714d1..905a1988f 100644 --- a/x/avs/types/types.go +++ b/x/avs/types/types.go @@ -8,6 +8,8 @@ import ( "sort" "strings" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" @@ -52,15 +54,15 @@ type AVSRegisterOrDeregisterParams struct { // AvsName is the name of the AVS as an arbitrary string. AvsName string // AvsAddress is the hex address of the AVS. - AvsAddress string + AvsAddress common.Address // MinStakeAmount is the minimum amount of stake for a task to be considered valid. MinStakeAmount uint64 // TaskAddr is the hex address of the task contract. - TaskAddr string + TaskAddr common.Address // SlashContractAddr is the hex address of the slash contract. - SlashContractAddr string + SlashContractAddr common.Address // RewardContractAddr is the hex address of the reward contract. - RewardContractAddr string + RewardContractAddr common.Address // AvsOwnerAddress is the list of bech32 addresses of the AVS owners. AvsOwnerAddress []string // AssetID is the list of asset IDs that the AVS is allowed to use. @@ -71,12 +73,11 @@ type AVSRegisterOrDeregisterParams struct { EpochIdentifier string MinOptInOperators uint64 MinTotalStakeAmount uint64 - // CallerAddress is the bech32 address of the precompile caller. - CallerAddress string - ChainID string - AvsReward uint64 - AvsSlash uint64 - Action uint64 + CallerAddress sdk.AccAddress + ChainID string + AvsReward uint64 + AvsSlash uint64 + Action uint64 } var ( diff --git a/x/avs/types/utils.go b/x/avs/types/utils.go index e0ea1bac2..0ea705155 100644 --- a/x/avs/types/utils.go +++ b/x/avs/types/utils.go @@ -14,39 +14,39 @@ const ( ) type OperatorOptParams struct { - Name string `json:"name"` - BlsPublicKey string `json:"bls_public_key"` - IsRegistered bool `json:"is_registered"` - Action uint64 `json:"action"` - OperatorAddress string `json:"operator_address"` - Status string `json:"status"` - AvsAddress string `json:"avs_address"` + Name string `json:"name"` + BlsPublicKey string `json:"bls_public_key"` + IsRegistered bool `json:"is_registered"` + Action uint64 `json:"action"` + OperatorAddress sdk.AccAddress `json:"operator_address"` + Status string `json:"status"` + AvsAddress common.Address `json:"avs_address"` } type TaskInfoParams struct { - TaskContractAddress string `json:"task_contract_address"` - TaskName string `json:"name"` - Hash []byte `json:"hash"` - TaskID uint64 `json:"task_id"` - TaskResponsePeriod uint64 `json:"task_response_period"` - TaskStatisticalPeriod uint64 `json:"task_statistical_period"` - TaskChallengePeriod uint64 `json:"task_challenge_period"` - ThresholdPercentage uint64 `json:"threshold_percentage"` - StartingEpoch uint64 `json:"starting_epoch"` - OperatorAddress string `json:"operator_address"` - TaskResponseHash string `json:"task_response_hash"` - TaskResponse []byte `json:"task_response"` - BlsSignature []byte `json:"bls_signature"` - Stage string `json:"stage"` - ActualThreshold uint64 `json:"actual_threshold"` - OptInCount uint64 `json:"opt_in_count"` - SignedCount uint64 `json:"signed_count"` - NoSignedCount uint64 `json:"no_signed_count"` - ErrSignedCount uint64 `json:"err_signed_count"` - CallerAddress string `json:"caller_address"` + TaskContractAddress common.Address `json:"task_contract_address"` + TaskName string `json:"name"` + Hash []byte `json:"hash"` + TaskID uint64 `json:"task_id"` + TaskResponsePeriod uint64 `json:"task_response_period"` + TaskStatisticalPeriod uint64 `json:"task_statistical_period"` + TaskChallengePeriod uint64 `json:"task_challenge_period"` + ThresholdPercentage uint64 `json:"threshold_percentage"` + StartingEpoch uint64 `json:"starting_epoch"` + OperatorAddress sdk.AccAddress `json:"operator_address"` + TaskResponseHash string `json:"task_response_hash"` + TaskResponse []byte `json:"task_response"` + BlsSignature []byte `json:"bls_signature"` + Phase string `json:"phase"` + ActualThreshold uint64 `json:"actual_threshold"` + OptInCount uint64 `json:"opt_in_count"` + SignedCount uint64 `json:"signed_count"` + NoSignedCount uint64 `json:"no_signed_count"` + ErrSignedCount uint64 `json:"err_signed_count"` + CallerAddress sdk.AccAddress `json:"caller_address"` } type BlsParams struct { - Operator string + Operator sdk.AccAddress Name string PubKey []byte PubkeyRegistrationSignature []byte @@ -55,14 +55,14 @@ type BlsParams struct { type ProofParams struct { TaskID string - TaskContractAddress string - AvsAddress string + TaskContractAddress common.Address + AvsAddress common.Address Aggregator string OperatorStatus []OperatorStatusParams - CallerAddress string + CallerAddress sdk.AccAddress } type OperatorStatusParams struct { - OperatorAddress string + OperatorAddress sdk.AccAddress Status string ProofData string } @@ -79,23 +79,16 @@ type ChallengeParams struct { TaskID uint64 `json:"task_id"` OperatorAddress sdk.AccAddress `json:"operator_address"` TaskResponseHash []byte `json:"task_response_hash"` - CallerAddress string `json:"caller_address"` + CallerAddress sdk.AccAddress `json:"caller_address"` } type TaskResultParams struct { - OperatorAddress string `json:"operator_address"` + OperatorAddress sdk.AccAddress `json:"operator_address"` TaskResponseHash string `json:"task_response_hash"` TaskResponse []byte `json:"task_response"` BlsSignature []byte `json:"bls_signature"` TaskContractAddress common.Address `json:"task_contract_address"` TaskID uint64 `json:"task_id"` Phase uint8 `json:"phase"` - CallerAddress string `json:"caller_address"` -} - -type OperatorParams struct { - EarningsAddr string `json:"earnings_addr"` - ApproveAddr string `json:"approve_addr"` - OperatorMetaInfo string `json:"operator_meta_info"` - CallerAddress sdk.AccAddress `json:"caller_address"` + CallerAddress sdk.AccAddress `json:"caller_address"` } diff --git a/x/dogfood/keeper/msg_server.go b/x/dogfood/keeper/msg_server.go index 88ee914d2..32e03755d 100644 --- a/x/dogfood/keeper/msg_server.go +++ b/x/dogfood/keeper/msg_server.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/ethereum/go-ethereum/common" + "cosmossdk.io/errors" "github.com/ExocoreNetwork/exocore/utils" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" @@ -120,7 +122,7 @@ func (k Keeper) UpdateParams( } err := k.avsKeeper.UpdateAVSInfo(c, &avstypes.AVSRegisterOrDeregisterParams{ AvsName: c.ChainID(), - AvsAddress: avsAddr, + AvsAddress: common.HexToAddress(avsAddr), AssetID: nextParams.AssetIDs, UnbondingPeriod: uint64(nextParams.EpochsUntilUnbonded), MinSelfDelegation: nextParams.MinSelfDelegation.Uint64(), diff --git a/x/operator/keeper/opt_test.go b/x/operator/keeper/opt_test.go index 1662c20ca..56e54a175 100644 --- a/x/operator/keeper/opt_test.go +++ b/x/operator/keeper/opt_test.go @@ -95,7 +95,7 @@ func (suite *OperatorTestSuite) prepareAvs(assetIDs []string) { err := suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, &avstypes.AVSRegisterOrDeregisterParams{ Action: avstypes.RegisterAction, EpochIdentifier: epochstypes.HourEpochID, - AvsAddress: suite.avsAddr, + AvsAddress: common.HexToAddress(suite.avsAddr), AssetID: assetIDs, }) suite.NoError(err) From 08849fbacf7b1ef9d7b5597da57b84fb14979341 Mon Sep 17 00:00:00 2001 From: trestin Date: Fri, 25 Oct 2024 17:28:55 +0800 Subject: [PATCH 13/24] update for comments --- x/avs/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index bdefca350..bea9d5be8 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -246,7 +246,7 @@ func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (ui } operatorList, err := k.operatorKeeper.GetOptedInOperatorListByAVS(ctx, avsInfo.AvsAddress) if err != nil { - return 0, errorsmod.Wrap(err, "CreateAVSTask: failed to get opt-in operators") + return types.InvalidTaskID, errorsmod.Wrap(err, "CreateAVSTask: failed to get opt-in operators") } params.TaskID = k.GetTaskID(ctx, common.HexToAddress(params.TaskContractAddress.String())) task := &types.TaskInfo{ From 7f1dabf17b4b03e62b4bca54b701cbc4afd8a520 Mon Sep 17 00:00:00 2001 From: trestin Date: Tue, 29 Oct 2024 16:31:01 +0800 Subject: [PATCH 14/24] fix comments of max --- go.mod | 4 +- go.sum | 60 ++++- precompiles/avs/IAVSManager.sol | 95 ++++--- precompiles/avs/abi.json | 8 +- precompiles/avs/avs.go | 6 +- precompiles/avs/avs_test.go | 117 +++++++- precompiles/avs/events.go | 8 +- precompiles/avs/query.go | 31 ++- precompiles/avs/query_test.go | 26 +- precompiles/avs/tx.go | 20 +- proto/exocore/avs/v1/tx.proto | 10 +- x/avs/client/cli/tx.go | 26 +- x/avs/keeper/avs.go | 5 +- x/avs/keeper/avs_test.go | 14 +- x/avs/keeper/keeper.go | 11 +- .../keeper/multi_operator_submit_task_test.go | 4 +- x/avs/keeper/submit_task_test.go | 4 +- x/avs/keeper/task.go | 7 +- x/avs/types/tx.pb.go | 250 ++++++++++-------- x/avs/types/types.go | 2 +- x/avs/types/utils.go | 29 +- 21 files changed, 488 insertions(+), 249 deletions(-) diff --git a/go.mod b/go.mod index c53f172c4..6c0fa830a 100644 --- a/go.mod +++ b/go.mod @@ -271,10 +271,8 @@ replace ( github.com/evmos/evmos/v16 => github.com/ExocoreNetwork/evmos/v16 v16.0.3-0.20240828081344-d5cfcd34a812 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 - github.com/ledgerwatch/interfaces => github.com/ledgerwatch/interfaces v0.0.0-20240911002112-53ce6989bb37 // replace broken goleveldb github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 + //fix cosmos-sdk error golang.org/x/exp => golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc - nhooyr.io/websocket => nhooyr.io/websocket v1.8.17 - ) diff --git a/go.sum b/go.sum index b2324eb1a..7e290a7ad 100644 --- a/go.sum +++ b/go.sum @@ -642,6 +642,9 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -659,6 +662,9 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= @@ -845,12 +851,18 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= @@ -883,6 +895,13 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= +github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -891,7 +910,18 @@ github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= +github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= +github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= +github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= +github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/gobwas/ws v1.2.1 h1:F2aeBZrm2NDsc7vbovKrWSogd4wvfAxg0FQ89/iqOTk= +github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -1048,6 +1078,7 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -1156,6 +1187,8 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -1171,6 +1204,7 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= +github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= @@ -1178,6 +1212,7 @@ github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrD github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1195,6 +1230,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263 h1:LGEzZvf33Y1NhuP5+jI/ni9l1TFS6oYPDilgy74NusM= github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263/go.mod h1:OXgMDuUo2lZ3NpH29ZvMYbk+LxFd5ffDl2Z2mGMuY/I= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= @@ -1257,9 +1294,12 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= @@ -1322,6 +1362,7 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -1489,6 +1530,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -1523,9 +1566,13 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -1599,6 +1646,9 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1616,6 +1666,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= @@ -1730,6 +1782,7 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1875,6 +1928,7 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1902,6 +1956,7 @@ golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2368,8 +2423,9 @@ modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= -nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= -nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= +nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= +nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA= pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index c347d2ff2..abeeb99f8 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -4,28 +4,42 @@ pragma solidity >=0.8.17; address constant AVSMANAGER_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000901; /// @dev The avs-manager contract's instance. -IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager( - AVSMANAGER_PRECOMPILE_ADDRESS -); +IAVSManager constant AVSMANAGER_CONTRACT = IAVSManager(AVSMANAGER_PRECOMPILE_ADDRESS); /// @author Exocore Team /// @title AVS-Manager Precompile Contract /// @dev The interface through which solidity contracts will interact with AVS-Manager /// @custom:address 0x0000000000000000000000000000000000000901 + interface IAVSManager { + // note:string and bytes will be hashed. address / uintX will not be hashed when using indexed. event AVSRegistered(address indexed avsAddr, string sender, string avsName); event AVSUpdated(address indexed avsAddr, string sender, string avsName); event AVSDeregistered(address indexed avsAddr, string sender, string avsName); - event OperatorJoined(address indexed avsAddr,string sender); - event OperatorOuted(address indexed avsAddr,string sender); - event TaskCreated(string sender,uint64 taskId,address indexed taskContractAddress,string name,bytes hash, - uint64 taskResponsePeriod,uint64 taskChallengePeriod,uint64 thresholdPercentage,uint64 taskStatisticalPeriod + event OperatorJoined(address indexed avsAddr, string sender); + event OperatorLeft(address indexed avsAddr, string sender); + event TaskCreated( + string sender, + uint64 taskId, + address indexed taskContractAddress, + string name, + bytes hash, + uint64 taskResponsePeriod, + uint64 taskChallengePeriod, + uint64 thresholdPercentage, + uint64 taskStatisticalPeriod + ); + event ChallengeInitiated( + string sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, string operatorAddress ); - event ChallengeInitiated(string sender, bytes taskHash, uint64 taskID, bytes taskResponseHash, - string operatorAddress); event PublicKeyRegistered(string sender, string name); - event TaskSubmittedByOperator(string sender, uint64 taskID, bytes taskResponse, - bytes blsSignature, address indexed taskContractAddress, uint8 phase); - + event TaskSubmittedByOperator( + string sender, + uint64 taskID, + bytes taskResponse, + bytes blsSignature, + address indexed taskContractAddress, + uint8 phase + ); /// @dev Register AVS contract to EXO. /// @param sender The external address for calling this method. @@ -92,23 +106,15 @@ interface IAVSManager { /// @dev Deregister avs from exo /// @param sender The external address for calling this method. /// @param avsName The name of AVS. - function deregisterAVS( - address sender, - string memory avsName - ) external returns (bool success); + function deregisterAVS(address sender, string memory avsName) external returns (bool success); /// @dev RegisterOperatorToAVS operator opt in current avs /// @param sender The external address for calling this method. - function registerOperatorToAVS( - address sender - ) external returns (bool success); + function registerOperatorToAVS(address sender) external returns (bool success); /// @dev DeregisterOperatorFromAVS operator opt out current avs /// @param sender The external address for calling this method. - function deregisterOperatorFromAVS( - address sender - ) external returns (bool success); - + function deregisterOperatorFromAVS(address sender) external returns (bool success); /// @dev CreateTask , avs owner create a new task /// @param sender The external address for calling this method. @@ -142,7 +148,6 @@ interface IAVSManager { string memory operatorAddress ) external returns (bool success); - /// @dev Called by the avs manager service register an operator as the owner of a BLS public key. /// @param sender The external address for calling this method. /// @param name the name of public keys @@ -163,8 +168,9 @@ interface IAVSManager { /// @param taskResponse is the task response data.. /// @param blsSignature is the operator bls sig info.. /// @param taskContractAddress is contract address of task. - /// @param phase this field is used to solve the problem of task results being copied by other operators. - // It is a Two-Phase Commit with two values, 0 and 1 + /// @param phase The phase of the Two-Phase Commit protocol: + /// 0 = Prepare phase (commit preparation) + /// 1 = Commit phase (final commitment) function operatorSubmitTask( address sender, uint64 taskID, @@ -186,42 +192,35 @@ interface IAVSManager { /// @dev getAVSUSDValue is a function to retrieve the USD share of specified Avs. /// @param avsAddr The address of the avs /// @return amount The total USD share of specified operator and Avs. - function getAVSUSDValue( - address avsAddr - ) external view returns (uint256 amount); + function getAVSUSDValue(address avsAddr) external view returns (uint256 amount); /// @dev getOperatorOptedUSDValue is a function to retrieve the USD share of specified operator and Avs. /// @param avsAddr The address of the avs /// @param operatorAddr The address of the operator /// @return amount The total USD share of specified operator and Avs. - function getOperatorOptedUSDValue( - address avsAddr, - string memory operatorAddr - ) external view returns (uint256 amount); + function getOperatorOptedUSDValue(address avsAddr, string memory operatorAddr) + external + view + returns (uint256 amount); - /// @dev getAVSInfo is a function to query Avs epochIdentifier info. + /// @dev getAVSEpochIdentifier returns the epoch identifier for the given AVS. /// @param avsAddr The address of the avs - function getAVSInfo( - address avsAddr - ) external view returns (string memory epochIdentifier); + function getAVSEpochIdentifier(address avsAddr) external view returns (string memory epochIdentifier); /// @dev getTaskInfo is a function to query task info. /// @param taskAddr The address of the avs task /// @param taskID The id of task. - function getTaskInfo( - address taskAddr, - uint64 taskID - ) external view returns (uint64[] memory info); + /// @return info Array containing task information in the following order: + /// [0] = startingEpochNumber + /// [1] = taskResponsePeriod + /// [2] = taskStatisticalPeriod + function getTaskInfo(address taskAddr, uint64 taskID) external view returns (uint64[] memory info); /// @dev isOperator checks if the given address is registered as an operator on exocore. /// @param operatorAddr The address of the operator - function isOperator( - string memory operatorAddr - ) external view returns (bool); + function isOperator(address operatorAddr) external view returns (bool); /// @dev getCurrentEpoch obtain the specified current epoch based on epochIdentifier. /// @param epochIdentifier is a descriptive or unique identifier for the epoch - function getCurrentEpoch( - string memory epochIdentifier - ) external view returns (int64 currentEpoch); - } + function getCurrentEpoch(string memory epochIdentifier) external view returns (int64 currentEpoch); +} diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 7cbbdb7fc..35c03cc10 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -146,7 +146,7 @@ "type": "string" } ], - "name": "OperatorOuted", + "name": "OperatorLeft", "type": "event" }, { @@ -411,7 +411,7 @@ "type": "address" } ], - "name": "getAVSInfo", + "name": "getAVSEpochIdentifier", "outputs": [ { "internalType": "string", @@ -549,9 +549,9 @@ { "inputs": [ { - "internalType": "string", + "internalType": "address", "name": "operatorAddr", - "type": "string" + "type": "address" } ], "name": "isOperator", diff --git a/precompiles/avs/avs.go b/precompiles/avs/avs.go index 5a050ea2b..70a70e554 100644 --- a/precompiles/avs/avs.go +++ b/precompiles/avs/avs.go @@ -137,8 +137,8 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack([]string{}) } - case MethodGetAVSInfo: - bz, err = p.GetAVSInfo(ctx, contract, method, args) + case MethodGetAVSEpochIdentifier: + bz, err = p.GetAVSEpochIdentifier(ctx, contract, method, args) if err != nil { ctx.Logger().Error("internal error when calling avs precompile", "module", "avs precompile", "method", method.Name, "err", err) bz, err = method.Outputs.Pack("") @@ -219,7 +219,7 @@ func (Precompile) IsTransaction(methodID string) bool { MethodDeregisterOperatorFromAVS, MethodCreateAVSTask, MethodRegisterBLSPublicKey, MethodChallenge, MethodOperatorSubmitTask: return true case MethodGetRegisteredPubkey, MethodGetOptinOperators, MethodGetAVSUSDValue, MethodGetOperatorOptedUSDValue, - MethodGetAVSInfo, MethodGetTaskInfo, MethodIsOperator, MethodGetCurrentEpoch: + MethodGetAVSEpochIdentifier, MethodGetTaskInfo, MethodIsOperator, MethodGetCurrentEpoch: return false default: return false diff --git a/precompiles/avs/avs_test.go b/precompiles/avs/avs_test.go index 4261ba031..e634f59c3 100644 --- a/precompiles/avs/avs_test.go +++ b/precompiles/avs/avs_test.go @@ -487,6 +487,11 @@ func (suite *AVSManagerPrecompileSuite) TestUpdateAVS() { func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { // from := s.Address operatorAddress := sdk.AccAddress(suite.Address.Bytes()) + assetID := suite.AssetIDs + minStakeAmount, taskAddr := uint64(3), "0x3e108c058e8066DA635321Dc3018294cA82ddEdf" + avsUnbondingPeriod, minSelfDelegation := uint64(3), uint64(3) + epochIdentifier := epochstypes.DayEpochID + params := []uint64{2, 3, 4, 4} registerOperator := func() { registerReq := &operatortypes.RegisterOperatorReq{ @@ -507,13 +512,43 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { OperatorShare: math.LegacyNewDecFromBigInt(minPrecisionSelfDelegateAmount), }) } + avsName, slashAddress, rewardAddress := "avsTest", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" + avsOwnerAddress := []string{ + sdk.AccAddress(suite.Address.Bytes()).String(), + sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), + sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), + } + + setUp := func() { + avs := &types.AVSInfo{ + Name: avsName, + AvsAddress: suite.Address.String(), + SlashAddr: slashAddress, + RewardAddr: rewardAddress, + AvsOwnerAddress: avsOwnerAddress, + AssetIDs: assetID, + AvsUnbondingPeriod: avsUnbondingPeriod, + MinSelfDelegation: minSelfDelegation, + EpochIdentifier: epochIdentifier, + StartingEpoch: 1, + TaskAddr: taskAddr, + MinStakeAmount: minStakeAmount, + MinOptInOperators: params[0], + MinTotalStakeAmount: params[1], + AvsReward: sdk.MustNewDecFromStr(strconv.Itoa(int(params[1]))), + AvsSlash: sdk.MustNewDecFromStr(strconv.Itoa(int(params[2]))), + } + + err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) + suite.NoError(err) + } commonMalleate := func() (common.Address, []byte) { input, err := suite.precompile.Pack( avs.MethodRegisterOperatorToAVS, suite.Address, ) suite.Require().NoError(err, "failed to pack input") - return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input + return suite.Address, input } successRet, err := suite.precompile.Methods[avs.MethodRegisterAVS].Outputs.Pack(true) suite.Require().NoError(err) @@ -530,7 +565,7 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { name: "pass for operator opt-in avs", malleate: func() (common.Address, []byte) { registerOperator() - suite.TestRegisterAVS() + setUp() avsAddr, intput := commonMalleate() asset := suite.Assets[0] _, defaultAssetID := assetstypes.GetStakerIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) @@ -615,13 +650,80 @@ func (suite *AVSManagerPrecompileSuite) TestRegisterOperatorToAVS() { } func (suite *AVSManagerPrecompileSuite) TestDeregisterOperatorFromAVS() { + + // from := s.Address + operatorAddress := sdk.AccAddress(suite.Address.Bytes()) + assetID := suite.AssetIDs + minStakeAmount, taskAddr := uint64(3), "0x3e108c058e8066DA635321Dc3018294cA82ddEdf" + avsUnbondingPeriod, minSelfDelegation := uint64(3), uint64(3) + epochIdentifier := epochstypes.DayEpochID + params := []uint64{2, 3, 4, 4} + + registerOperator := func() { + registerReq := &operatortypes.RegisterOperatorReq{ + FromAddress: operatorAddress.String(), + Info: &operatortypes.OperatorInfo{ + EarningsAddr: operatorAddress.String(), + }, + } + _, err := suite.OperatorMsgServer.RegisterOperator(sdk.WrapSDKContext(suite.Ctx), registerReq) + suite.NoError(err) + asset := suite.Assets[0] + _, assetID := assetstypes.GetStakerIDAndAssetIDFromStr(asset.LayerZeroChainID, "", asset.Address) + selfDelegateAmount := big.NewInt(10) + minPrecisionSelfDelegateAmount := big.NewInt(0).Mul(selfDelegateAmount, big.NewInt(0).Exp(big.NewInt(10), big.NewInt(int64(asset.Decimals)), nil)) + err = suite.App.AssetsKeeper.UpdateOperatorAssetState(suite.Ctx, operatorAddress, assetID, assetstypes.DeltaOperatorSingleAsset{ + TotalAmount: math.NewIntFromBigInt(minPrecisionSelfDelegateAmount), + TotalShare: math.LegacyNewDecFromBigInt(minPrecisionSelfDelegateAmount), + OperatorShare: math.LegacyNewDecFromBigInt(minPrecisionSelfDelegateAmount), + }) + } + avsName, slashAddress, rewardAddress := "avsTest", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB", "0xDF907c29719154eb9872f021d21CAE6E5025d7aB" + avsOwnerAddress := []string{ + sdk.AccAddress(suite.Address.Bytes()).String(), + sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), + sdk.AccAddress(utiltx.GenerateAddress().Bytes()).String(), + } + + setUp := func() { + avs := &types.AVSInfo{ + Name: avsName, + AvsAddress: suite.Address.String(), + SlashAddr: slashAddress, + RewardAddr: rewardAddress, + AvsOwnerAddress: avsOwnerAddress, + AssetIDs: assetID, + AvsUnbondingPeriod: avsUnbondingPeriod, + MinSelfDelegation: minSelfDelegation, + EpochIdentifier: epochIdentifier, + StartingEpoch: 1, + TaskAddr: taskAddr, + MinStakeAmount: minStakeAmount, + MinOptInOperators: params[0], + MinTotalStakeAmount: params[1], + AvsReward: sdk.MustNewDecFromStr(strconv.Itoa(int(params[1]))), + AvsSlash: sdk.MustNewDecFromStr(strconv.Itoa(int(params[2]))), + } + + err := suite.App.AVSManagerKeeper.SetAVSInfo(suite.Ctx, avs) + suite.NoError(err) + } + optin := func() { + operatorParams := &types.OperatorOptParams{} + operatorParams.OperatorAddress = operatorAddress + operatorParams.AvsAddress = suite.Address + operatorParams.Action = types.RegisterAction + + err := suite.App.AVSManagerKeeper.OperatorOptAction(suite.Ctx, operatorParams) + suite.NoError(err) + } commonMalleate := func() (common.Address, []byte) { input, err := suite.precompile.Pack( avs.MethodDeregisterOperatorFromAVS, suite.Address, ) suite.Require().NoError(err, "failed to pack input") - return common.HexToAddress("0x3e108c058e8066DA635321Dc3018294cA82ddEdf"), input + return suite.Address, input } successRet, err := suite.precompile.Methods[avs.MethodDeregisterOperatorFromAVS].Outputs.Pack(true) suite.Require().NoError(err) @@ -637,8 +739,9 @@ func (suite *AVSManagerPrecompileSuite) TestDeregisterOperatorFromAVS() { { name: "pass for operator opt-out avs", malleate: func() (common.Address, []byte) { - suite.TestRegisterOperatorToAVS() - // registerOperator() + registerOperator() + setUp() + optin() return commonMalleate() }, readOnly: false, @@ -754,9 +857,7 @@ func (suite *AVSManagerPrecompileSuite) TestRunRegTaskInfo() { // updating the new voting power operatorKeeper.CalculateUSDValue(suite.delegationAmount, usdcPrice.Value, suite.assetDecimal, usdcPrice.Decimal) - suite.CommitAfter(time.Hour*1 + time.Nanosecond) - suite.CommitAfter(time.Hour*1 + time.Nanosecond) - suite.CommitAfter(time.Hour*1 + time.Nanosecond) + suite.CommitAfter(time.Hour*3 + time.Nanosecond) } commonMalleate := func() (common.Address, []byte) { input, err := suite.precompile.Pack( diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 824ead060..e44b95389 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -15,7 +15,7 @@ const ( EventTypeAVSUpdated = "AVSUpdated" EventTypeAVSDeregistered = "AVSDeregistered" EventTypeOperatorJoined = "OperatorJoined" - EventTypeOperatorOuted = "OperatorOuted" + EventTypeOperatorLeft = "OperatorLeft" EventTypeTaskCreated = "TaskCreated" EventTypeChallengeInitiated = "ChallengeInitiated" EventTypePublicKeyRegistered = "PublicKeyRegistered" @@ -83,8 +83,8 @@ func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, para } func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { - arguments := p.ABI.Events[EventTypeOperatorOuted].Inputs - return p.emitEvent(ctx, stateDB, EventTypeOperatorOuted, arguments, + arguments := p.ABI.Events[EventTypeOperatorLeft].Inputs + return p.emitEvent(ctx, stateDB, EventTypeOperatorLeft, arguments, params.AvsAddress, params.OperatorAddress.String()) } @@ -116,7 +116,7 @@ func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.BlsParams) error { arguments := p.ABI.Events[EventTypePublicKeyRegistered].Inputs return p.emitEvent(ctx, stateDB, EventTypePublicKeyRegistered, arguments, - params.Operator.String(), + params.OperatorAddress.String(), params.Name) } diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 036fef55b..dbf99060f 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -5,6 +5,8 @@ import ( "fmt" "strconv" + errorsmod "cosmossdk.io/errors" + exocmn "github.com/ExocoreNetwork/exocore/precompiles/common" avstype "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,10 +22,10 @@ const ( MethodGetAVSUSDValue = "getAVSUSDValue" MethodGetOperatorOptedUSDValue = "getOperatorOptedUSDValue" - MethodGetAVSInfo = "getAVSInfo" - MethodGetTaskInfo = "getTaskInfo" - MethodIsOperator = "isOperator" - MethodGetCurrentEpoch = "getCurrentEpoch" + MethodGetAVSEpochIdentifier = "getAVSEpochIdentifier" + MethodGetTaskInfo = "getTaskInfo" + MethodIsOperator = "isOperator" + MethodGetCurrentEpoch = "getCurrentEpoch" ) func (p Precompile) GetRegisteredPubkey( @@ -123,21 +125,21 @@ func (p Precompile) GetOperatorOptedUSDValue( return method.Outputs.Pack(amount.ActiveUSDValue.BigInt()) } -func (p Precompile) GetAVSInfo( +func (p Precompile) GetAVSEpochIdentifier( ctx sdk.Context, _ *vm.Contract, method *abi.Method, args []interface{}, ) ([]byte, error) { - if len(args) != len(p.ABI.Methods[MethodGetAVSInfo].Inputs) { - return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetAVSInfo].Inputs), len(args)) + if len(args) != len(p.ABI.Methods[MethodGetAVSEpochIdentifier].Inputs) { + return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodGetAVSEpochIdentifier].Inputs), len(args)) } addr, ok := args[0].(common.Address) if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", addr) } - avs, err := p.avsKeeper.QueryAVSInfo(ctx, &avstype.QueryAVSInfoReq{AVSAddress: addr.String()}) + avs, err := p.avsKeeper.GetAVSInfo(ctx, addr.String()) if err != nil { // if the avs does not exist, return empty array if errors.Is(err, avstype.ErrNoKeyInTheStore) { @@ -158,15 +160,12 @@ func (p Precompile) IsOperator( if len(args) != len(p.ABI.Methods[MethodIsOperator].Inputs) { return nil, fmt.Errorf(cmn.ErrInvalidNumberOfArgs, len(p.ABI.Methods[MethodIsOperator].Inputs), len(args)) } - operatorAddr, ok := args[0].(string) + operatorAddr, ok := args[0].(common.Address) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", operatorAddr) + return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", operatorAddr) } - param, err := sdk.AccAddressFromBech32(operatorAddr) - if err != nil { - return nil, err - } + param := operatorAddr[:] flag := p.avsKeeper.GetOperatorKeeper().IsOperator(ctx, param) return method.Outputs.Pack(flag) @@ -190,7 +189,7 @@ func (p Precompile) GetTaskInfo( return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "uint64", taskID) } - task, err := p.avsKeeper.QueryAVSTaskInfo(ctx, &avstype.QueryAVSTaskInfoReq{TaskAddr: addr.String(), TaskId: strconv.FormatUint(taskID, 10)}) + task, err := p.avsKeeper.GetTaskInfo(ctx, strconv.FormatUint(taskID, 10), addr.String()) if err != nil { // if the avs does not exist, return empty array if errors.Is(err, avstype.ErrNoKeyInTheStore) { @@ -219,7 +218,7 @@ func (p Precompile) GetCurrentEpoch( } epoch, flag := p.avsKeeper.GetEpochKeeper().GetEpochInfo(ctx, epochIdentifier) if !flag { - return nil, nil + return nil, errorsmod.Wrap(avstype.ErrNoKeyInTheStore, fmt.Sprintf("GetCurrentEpoch: epochIdentifier is %s", epochIdentifier)) } return method.Outputs.Pack(epoch.CurrentEpoch) } diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index 7d4ba5a7f..4cf9206db 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -379,9 +379,13 @@ func (suite *AVSManagerPrecompileSuite) TestGetRegisteredPubkey() { } func (suite *AVSManagerPrecompileSuite) TestGetAVSInfo() { - method := suite.precompile.Methods[avsManagerPrecompile.MethodGetAVSInfo] + method := suite.precompile.Methods[avsManagerPrecompile.MethodGetAVSEpochIdentifier] avsAddress := "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" - + testAVSUnbondingPeriod := 7 + testMinSelfDelegation := 10 + testMinOptInOperators := 100 + testMinTotalStakeAmount := 1000 + testStartingEpoch := 1 setUp := func() { avsName := "avsTest" avsOwnerAddress := []string{"exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj1", "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkj2"} @@ -392,12 +396,12 @@ func (suite *AVSManagerPrecompileSuite) TestGetAVSInfo() { SlashAddr: utiltx.GenerateAddress().String(), AvsOwnerAddress: avsOwnerAddress, AssetIDs: assetID, - AvsUnbondingPeriod: 7, - MinSelfDelegation: 10, + AvsUnbondingPeriod: uint64(testAVSUnbondingPeriod), + MinSelfDelegation: uint64(testMinSelfDelegation), EpochIdentifier: epochstypes.DayEpochID, - StartingEpoch: 1, - MinOptInOperators: 100, - MinTotalStakeAmount: 1000, + StartingEpoch: uint64(testStartingEpoch), + MinOptInOperators: uint64(testMinOptInOperators), + MinTotalStakeAmount: uint64(testMinTotalStakeAmount), AvsSlash: sdk.MustNewDecFromStr("0.001"), AvsReward: sdk.MustNewDecFromStr("0.002"), TaskAddr: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", @@ -418,7 +422,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetAVSInfo() { func(bz []byte) { var out string - err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodGetAVSInfo, bz) + err := suite.precompile.UnpackIntoInterface(&out, avsManagerPrecompile.MethodGetAVSEpochIdentifier, bz) suite.Require().NoError(err, "failed to unpack output", err) suite.Require().Equal(epochstypes.DayEpochID, out) }, @@ -433,7 +437,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetAVSInfo() { suite.Run(tc.name, func() { contract := vm.NewContract(vm.AccountRef(suite.Address), suite.precompile, big.NewInt(0), tc.gas) - bz, err := suite.precompile.GetAVSInfo(suite.Ctx, contract, &method, tc.malleate()) + bz, err := suite.precompile.GetAVSEpochIdentifier(suite.Ctx, contract, &method, tc.malleate()) if tc.expErr { suite.Require().Error(err) @@ -449,7 +453,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetAVSInfo() { func (suite *AVSManagerPrecompileSuite) TestIsoperator() { method := suite.precompile.Methods[avsManagerPrecompile.MethodIsOperator] - operatorAddr := "exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr" + opAccAddr, _ := sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") testCases := []avsTestCases{ { @@ -457,7 +461,7 @@ func (suite *AVSManagerPrecompileSuite) TestIsoperator() { func() []interface{} { suite.prepareOperator() return []interface{}{ - operatorAddr, + common.BytesToAddress(opAccAddr), } }, func(bz []byte) { diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index b468de81d..704edc3db 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -292,7 +292,7 @@ func (p Precompile) RegisterBLSPublicKey( if !ok || (callerAddress == common.Address{}) { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "common.Address", callerAddress) } - blsParams.Operator = callerAddress[:] + blsParams.OperatorAddress = callerAddress[:] name, ok := args[1].(string) if !ok || name == "" { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", name) @@ -374,21 +374,27 @@ func (p Precompile) OperatorSubmitTask( phase, ok := args[5].(uint8) if !ok { - return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 5, "uint8", phase) + return nil, fmt.Errorf("invalid phase type: expected uint8, got %T", args[5]) } - resultParams.Phase = phase - resultParams.OperatorAddress = resultParams.CallerAddress + // The phase of the Two-Phase Commit protocol: + // 0 = Prepare phase (commit preparation) + // 1 = Commit phase (final commitment) + // validation of the phase number + if err := avstypes.ValidatePhase(avstypes.CommitPhase(phase)); err != nil { + return nil, fmt.Errorf("invalid phase value: %d. Expected 0 (Prepare) or 1 (Commit)", phase) + } + resultParams.Phase = avstypes.CommitPhase(phase) result := &avstypes.TaskResultInfo{ TaskId: resultParams.TaskID, - OperatorAddress: resultParams.OperatorAddress.String(), + OperatorAddress: resultParams.CallerAddress.String(), TaskContractAddress: resultParams.TaskContractAddress.String(), TaskResponse: resultParams.TaskResponse, BlsSignature: resultParams.BlsSignature, - Phase: uint32(resultParams.Phase), + Phase: avstypes.Phase(resultParams.Phase), } - err := p.avsKeeper.SetTaskResultInfo(ctx, resultParams.OperatorAddress.String(), result) + err := p.avsKeeper.SetTaskResultInfo(ctx, resultParams.CallerAddress.String(), result) if err != nil { return nil, err } diff --git a/proto/exocore/avs/v1/tx.proto b/proto/exocore/avs/v1/tx.proto index 20735d7e9..b8b512d4b 100644 --- a/proto/exocore/avs/v1/tx.proto +++ b/proto/exocore/avs/v1/tx.proto @@ -211,7 +211,13 @@ message DeRegisterAVSResponse { // avs information AVSInfo info = 2; } - +// It is a two-phase submission with two values, 0 and 1 +enum Phase { + // the first phase (pre-commit) + PHASE_PREPARE = 0; + // the second phase + PHASE_DO_COMMIT = 1; +} // TaskResultInfo is the operator sign task info result. message TaskResultInfo { // operator_address operator address @@ -228,7 +234,7 @@ message TaskResultInfo { uint64 task_id = 6; // phase this field is used to solve the problem of task results being copied by other operators. // It is a two-phase submission with two values, 0 and 1 - uint32 phase = 7; + Phase phase = 7; } // SubmitTaskResultReq is the request to submit task results. diff --git a/x/avs/client/cli/tx.go b/x/avs/client/cli/tx.go index 5f8fd2112..78c742e52 100644 --- a/x/avs/client/cli/tx.go +++ b/x/avs/client/cli/tx.go @@ -54,8 +54,10 @@ func CmdSubmitTaskResult() *cobra.Command { return err } - msg := newBuildMsg(clientCtx, cmd.Flags()) - + msg, err := newBuildMsg(clientCtx, cmd.Flags()) + if err != nil { + return err + } // this calls ValidateBasic internally so we don't need to do that. return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) }, @@ -95,21 +97,29 @@ func CmdSubmitTaskResult() *cobra.Command { func newBuildMsg( clientCtx client.Context, fs *pflag.FlagSet, -) *types.SubmitTaskResultReq { +) (*types.SubmitTaskResultReq, error) { sender := clientCtx.GetFromAddress() operatorAddress, _ := fs.GetString(FlagOperatorAddress) if operatorAddress == "" { operatorAddress = sender.String() } taskResponse, _ := fs.GetString(FlagTaskResponse) - taskRes, _ := hex.DecodeString(taskResponse) + taskRes, err := hex.DecodeString(taskResponse) + if err != nil { + return nil, err + } blsSignature, _ := fs.GetString(FlagBlsSignature) - sig, _ := hex.DecodeString(blsSignature) + sig, err := hex.DecodeString(blsSignature) + if err != nil { + return nil, err + } taskContractAddress, _ := fs.GetString(FlagTaskContractAddress) taskID, _ := fs.GetUint64(FlagTaskID) phase, _ := fs.GetUint32(FlagPhase) - + if err := types.ValidatePhase(types.CommitPhase(phase)); err != nil { + return nil, err + } msg := &types.SubmitTaskResultReq{ FromAddress: sender.String(), Info: &types.TaskResultInfo{ @@ -118,8 +128,8 @@ func newBuildMsg( BlsSignature: sig, TaskContractAddress: taskContractAddress, TaskId: taskID, - Phase: phase, + Phase: types.Phase(phase), }, } - return msg + return msg, nil } diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index f63ba2eea..6f8e820bb 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -85,7 +85,7 @@ func (k *Keeper) GetEpochEndAVSs(ctx sdk.Context, epochIdentifier string, ending // TODO:this function is frequently used while its implementation iterates over existing avs to find the target avs by task contract address, we should use a reverse mapping to avoid iteration func (k *Keeper) GetAVSInfoByTaskAddress(ctx sdk.Context, taskAddr string) types.AVSInfo { var avs types.AVSInfo - if taskAddr == "" || taskAddr == "0x0000000000000000000000000000000000000000" { + if taskAddr == "" || taskAddr == (common.Address{}).String() { return avs } k.IterateAVSInfo(ctx, func(_ int64, avsInfo types.AVSInfo) (stop bool) { @@ -103,6 +103,9 @@ func (k *Keeper) GetTaskStatisticalEpochEndAVSs(ctx sdk.Context, epochIdentifier var taskResList []types.TaskResultInfo k.IterateResultInfo(ctx, func(_ int64, info types.TaskResultInfo) (stop bool) { avsInfo := k.GetAVSInfoByTaskAddress(ctx, info.TaskContractAddress) + if avsInfo.AvsAddress == "" { + return false + } taskInfo, err := k.GetTaskInfo(ctx, strconv.FormatUint(info.TaskId, 10), info.TaskContractAddress) if err != nil { return false diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index bf124a9e7..2063255d8 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -120,10 +120,16 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_DeRegister() { suite.NoError(err) info, err := suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddress) suite.Equal(avsAddress, info.GetInfo().AvsAddress) - suite.CommitAfter(48*time.Hour + time.Nanosecond) - suite.CommitAfter(48*time.Hour + time.Nanosecond) - suite.CommitAfter(48*time.Hour + time.Nanosecond) - suite.CommitAfter(48*time.Hour + time.Nanosecond) + + epoch, _ := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochstypes.DayEpochID) + // Numbered loops for epoch ends + for epochEnd := epoch.CurrentEpoch; epochEnd <= int64(info.Info.StartingEpoch)+2; epochEnd++ { + suite.CommitAfter(time.Hour * 24) + epoch, found := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochstypes.DayEpochID) + suite.Equal(found, true) + suite.Equal(epoch.CurrentEpoch, epochEnd+1) + } + avsParams.Action = avstypes.DeRegisterAction avsParams.CallerAddress, err = sdk.AccAddressFromBech32("exo13h6xg79g82e2g2vhjwg7j4r2z2hlncelwutkjr") err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, avsParams) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index bea9d5be8..60d4d7a90 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -272,15 +272,15 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *types.BlsParams) e pubKey, _ := bls.PublicKeyFromBytes(params.PubKey) valid, err := blst.VerifySignature(sig, [32]byte(msgHash), pubKey) if err != nil || !valid { - return errorsmod.Wrap(types.ErrSigNotMatchPubKey, fmt.Sprintf("the operator is :%s", params.Operator)) + return errorsmod.Wrap(types.ErrSigNotMatchPubKey, fmt.Sprintf("the operator is :%s", params.OperatorAddress)) } - if k.IsExistPubKey(ctx, params.Operator.String()) { - return errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the operator is :%s", params.Operator)) + if k.IsExistPubKey(ctx, params.OperatorAddress.String()) { + return errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the operator is :%s", params.OperatorAddress)) } bls := &types.BlsPubKeyInfo{ Name: params.Name, - Operator: params.Operator.String(), + Operator: params.OperatorAddress.String(), PubKey: params.PubKey, } return k.SetOperatorPubKey(ctx, bls) @@ -416,6 +416,9 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *types.Challeng // check challenge period // check epoch,The challenge must be within the challenge window period avsInfo := k.GetAVSInfoByTaskAddress(ctx, taskInfo.TaskContractAddress) + if avsInfo.AvsAddress == "" { + return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", taskInfo.TaskContractAddress)) + } epoch, found := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier) if !found { return errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", diff --git a/x/avs/keeper/multi_operator_submit_task_test.go b/x/avs/keeper/multi_operator_submit_task_test.go index e11bbbda7..be34ac639 100644 --- a/x/avs/keeper/multi_operator_submit_task_test.go +++ b/x/avs/keeper/multi_operator_submit_task_test.go @@ -201,7 +201,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseOne_Mul() { TaskResponseHash: "", TaskResponse: nil, BlsSignature: sig.Marshal(), - Phase: uint32(avstypes.PreparePhase), + Phase: avstypes.Phase(avstypes.PreparePhase), } err := suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, operatorAddress, info) suite.Require().NoError(err) @@ -229,7 +229,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseTwo_Mul() { TaskResponseHash: hash.String(), TaskResponse: jsonData, BlsSignature: sig.Marshal(), - Phase: uint32(avstypes.DoCommitPhase), + Phase: avstypes.Phase(avstypes.DoCommitPhase), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, operatorAddress, info) suite.NoError(err) diff --git a/x/avs/keeper/submit_task_test.go b/x/avs/keeper/submit_task_test.go index aea3bd56a..76b74b277 100644 --- a/x/avs/keeper/submit_task_test.go +++ b/x/avs/keeper/submit_task_test.go @@ -187,7 +187,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseOne() { TaskResponseHash: "", TaskResponse: nil, BlsSignature: sig.Marshal(), - Phase: uint32(avstypes.PreparePhase), + Phase: avstypes.Phase(avstypes.PreparePhase), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, suite.operatorAddr.String(), info) suite.NoError(err) @@ -216,7 +216,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseTwo() { TaskResponseHash: hash.String(), TaskResponse: jsonData, BlsSignature: sig.Marshal(), - Phase: uint32(avstypes.DoCommitPhase), + Phase: avstypes.Phase(avstypes.DoCommitPhase), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, suite.operatorAddr.String(), info) suite.NoError(err) diff --git a/x/avs/keeper/task.go b/x/avs/keeper/task.go index 349f6fd1b..a35db0e30 100644 --- a/x/avs/keeper/task.go +++ b/x/avs/keeper/task.go @@ -176,6 +176,9 @@ func (k *Keeper) SetTaskResultInfo( // TaskResponse and TaskResponseHash must be null values // At the same time, it must be submitted within the response deadline in the first phase avsInfo := k.GetAVSInfoByTaskAddress(ctx, info.TaskContractAddress) + if avsInfo.AvsAddress == "" { + return errorsmod.Wrap(types.ErrUnregisterNonExistent, fmt.Sprintf("the taskaddr is :%s", info.TaskContractAddress)) + } epoch, found := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier) if !found { return errorsmod.Wrap(types.ErrEpochNotFound, fmt.Sprintf("epoch info not found %s", @@ -183,7 +186,7 @@ func (k *Keeper) SetTaskResultInfo( } switch info.Phase { - case uint32(types.PreparePhase): + case types.Phase(types.PreparePhase): if k.IsExistTaskResultInfo(ctx, info.OperatorAddress, info.TaskContractAddress, info.TaskId) { return errorsmod.Wrap( types.ErrResAlreadyExists, @@ -221,7 +224,7 @@ func (k *Keeper) SetTaskResultInfo( store.Set(infoKey, bz) return nil - case uint32(types.DoCommitPhase): + case types.Phase(types.DoCommitPhase): // check task response if info.TaskResponse == nil { return errorsmod.Wrap( diff --git a/x/avs/types/tx.pb.go b/x/avs/types/tx.pb.go index 307d7c693..7e3cfd8c8 100644 --- a/x/avs/types/tx.pb.go +++ b/x/avs/types/tx.pb.go @@ -33,6 +33,34 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// It is a two-phase submission with two values, 0 and 1 +type Phase int32 + +const ( + // the first phase (pre-commit) + Phase_PHASE_PREPARE Phase = 0 + // the second phase + Phase_PHASE_DO_COMMIT Phase = 1 +) + +var Phase_name = map[int32]string{ + 0: "PHASE_PREPARE", + 1: "PHASE_DO_COMMIT", +} + +var Phase_value = map[string]int32{ + "PHASE_PREPARE": 0, + "PHASE_DO_COMMIT": 1, +} + +func (x Phase) String() string { + return proto.EnumName(Phase_name, int32(x)) +} + +func (Phase) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_ef1ed06249b07d86, []int{0} +} + // AVSinfo represent the information of avs type AVSInfo struct { // name of avs as an arbitrary string @@ -1014,7 +1042,7 @@ type TaskResultInfo struct { TaskId uint64 `protobuf:"varint,6,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // phase this field is used to solve the problem of task results being copied by other operators. // It is a two-phase submission with two values, 0 and 1 - Phase uint32 `protobuf:"varint,7,opt,name=phase,proto3" json:"phase,omitempty"` + Phase Phase `protobuf:"varint,7,opt,name=phase,proto3,enum=exocore.avs.v1.Phase" json:"phase,omitempty"` } func (m *TaskResultInfo) Reset() { *m = TaskResultInfo{} } @@ -1092,11 +1120,11 @@ func (m *TaskResultInfo) GetTaskId() uint64 { return 0 } -func (m *TaskResultInfo) GetPhase() uint32 { +func (m *TaskResultInfo) GetPhase() Phase { if m != nil { return m.Phase } - return 0 + return Phase_PHASE_PREPARE } // SubmitTaskResultReq is the request to submit task results. @@ -1178,6 +1206,7 @@ func (m *SubmitTaskResultResponse) XXX_DiscardUnknown() { var xxx_messageInfo_SubmitTaskResultResponse proto.InternalMessageInfo func init() { + proto.RegisterEnum("exocore.avs.v1.Phase", Phase_name, Phase_value) proto.RegisterType((*AVSInfo)(nil), "exocore.avs.v1.AVSInfo") proto.RegisterMapType((map[string]int64)(nil), "exocore.avs.v1.AVSInfo.AssetRewardAmountEpochBasisEntry") proto.RegisterType((*OperatorStatus)(nil), "exocore.avs.v1.OperatorStatus") @@ -1200,112 +1229,115 @@ func init() { func init() { proto.RegisterFile("exocore/avs/v1/tx.proto", fileDescriptor_ef1ed06249b07d86) } var fileDescriptor_ef1ed06249b07d86 = []byte{ - // 1670 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0x1b, 0xc7, - 0x15, 0xd6, 0x4a, 0x94, 0x44, 0x3e, 0x52, 0x14, 0x35, 0xa2, 0xc3, 0x35, 0xdd, 0x92, 0xc2, 0xba, - 0x4e, 0x64, 0x25, 0x26, 0x6d, 0xa5, 0x28, 0x0c, 0xf7, 0x24, 0x55, 0x6e, 0x2a, 0xa4, 0xb1, 0x85, + // 1715 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x4f, 0x6f, 0x1b, 0xc7, + 0x15, 0xd7, 0x4a, 0x94, 0x44, 0x3e, 0x52, 0x14, 0x35, 0x92, 0xc3, 0x35, 0xdd, 0x92, 0xc2, 0xba, + 0x4e, 0x64, 0x39, 0x26, 0x6d, 0xa5, 0x28, 0x0c, 0xf7, 0x24, 0x45, 0x6a, 0x22, 0xa4, 0xb6, 0x88, 0xa5, 0x9a, 0x16, 0xed, 0x61, 0x31, 0xe4, 0x8e, 0x96, 0x0b, 0x2d, 0x77, 0xd8, 0x9d, 0x21, 0x6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b6, 0xa8, 0x3c, 0x84, 0xcd, 0xcb, 0x02, 0x90, 0x12, 0x2c, 0x9c, 0xb2, 0x27, 0x7a, + 0x0c, 0xd5, 0x27, 0xd9, 0x80, 0xc5, 0x21, 0x0d, 0x06, 0x0c, 0xe7, 0x6f, 0xc1, 0x8e, 0x17, 0xf7, + 0xe7, 0xef, 0x19, 0x56, 0x04, 0xc5, 0xe4, 0xbc, 0x5b, 0x92, 0xca, 0x81, 0xea, 0xee, 0x52, 0xd2, + 0x1a, 0xa3, 0x41, 0x88, 0x43, 0xad, 0x26, 0xf2, 0x64, 0x10, 0xde, 0x82, 0x25, 0x81, 0x4e, 0x7a, + 0xae, 0xf5, 0x4a, 0x0d, 0x63, 0x3f, 0xe2, 0xfc, 0xc4, 0x71, 0xa9, 0xa4, 0x38, 0xcd, 0x05, 0x3b, + 0x87, 0x92, 0x7d, 0x2a, 0xa9, 0xf5, 0x1f, 0x03, 0x4a, 0x31, 0x7e, 0xac, 0x69, 0x53, 0x29, 0x48, + 0x19, 0x96, 0x71, 0xba, 0x7d, 0x57, 0xef, 0xb6, 0xa4, 0x96, 0x87, 0x2e, 0xd9, 0x81, 0x2b, 0xa8, + 0xe8, 0xf0, 0x50, 0x46, 0xb4, 0x23, 0x27, 0xb8, 0x64, 0x5d, 0x29, 0xdf, 0xd7, 0xba, 0x04, 0x58, + 0x15, 0x80, 0x7a, 0x5e, 0xa4, 0x66, 0x84, 0x47, 0x08, 0x40, 0x91, 0xce, 0x48, 0x32, 0xc9, 0x4a, + 0x99, 0x29, 0x56, 0xfa, 0x00, 0x46, 0xc9, 0x3a, 0x3a, 0xc5, 0x45, 0x3c, 0xd6, 0xea, 0xe4, 0xb1, + 0xa6, 0xab, 0x67, 0x17, 0x79, 0x6a, 0x6d, 0x3d, 0x5b, 0x82, 0xec, 0xb1, 0x4a, 0x44, 0x11, 0xe4, + 0xcc, 0x54, 0x8c, 0xd9, 0xa9, 0x24, 0xa4, 0x3a, 0x3f, 0x46, 0xaa, 0x04, 0x32, 0x5d, 0xd5, 0xcc, + 0x71, 0x65, 0xf1, 0x7b, 0xbc, 0x7e, 0x19, 0x9c, 0xb7, 0xa4, 0x7e, 0x77, 0x60, 0x03, 0x15, 0x11, + 0x13, 0x7d, 0x1e, 0x0a, 0x96, 0x50, 0xd0, 0x62, 0x4c, 0x41, 0x4a, 0x67, 0x6b, 0x95, 0xa6, 0xa0, + 0xef, 0x41, 0x19, 0x3d, 0x54, 0xe2, 0xbe, 0x90, 0x7e, 0x87, 0x06, 0x89, 0xd3, 0x12, 0x3a, 0x61, + 0x16, 0xad, 0x73, 0xad, 0xf6, 0x1b, 0xa5, 0xd7, 0xa5, 0x41, 0xc0, 0x42, 0x6f, 0xb4, 0xd5, 0x72, + 0xcc, 0x16, 0x98, 0x5e, 0xa2, 0xd3, 0x3e, 0x77, 0x61, 0x43, 0x76, 0x23, 0x26, 0xba, 0x3c, 0x70, + 0x95, 0x79, 0x87, 0x85, 0x92, 0x7a, 0xcc, 0xcc, 0x6a, 0x97, 0x44, 0xd7, 0x1c, 0xa9, 0x2e, 0x20, + 0x98, 0xdc, 0x45, 0x04, 0x73, 0x13, 0x4a, 0xb4, 0x23, 0x07, 0x34, 0x70, 0x46, 0x41, 0x34, 0x8b, + 0xae, 0xc6, 0xf2, 0xe3, 0x44, 0xac, 0xee, 0xa0, 0x29, 0x52, 0xcc, 0x23, 0xf7, 0x17, 0x79, 0x9a, + 0x11, 0x6f, 0x42, 0x49, 0xf8, 0x5e, 0xc8, 0xdc, 0x14, 0x7d, 0xe2, 0x2d, 0x11, 0xcb, 0xcf, 0x4d, + 0xeb, 0xb0, 0x1e, 0x72, 0x67, 0xca, 0x7a, 0x05, 0xad, 0xd7, 0x42, 0xde, 0x9a, 0xb0, 0xbf, 0x03, + 0x1b, 0x2c, 0x8a, 0xa6, 0x1d, 0x8a, 0xe8, 0x40, 0x58, 0x14, 0x4d, 0x7a, 0x3c, 0x86, 0x12, 0xd6, + 0x3b, 0xe6, 0x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, 0x8d, 0xf1, 0xcd, 0x9e, 0x1a, 0xb0, 0x92, 0x9a, 0x2a, 0xb2, 0x39, 0x19, 0x7e, 0x92, + 0x05, 0x2a, 0x37, 0x2e, 0xb1, 0xd0, 0x10, 0xb6, 0x10, 0x82, 0x65, 0x6d, 0x5e, 0x00, 0x21, 0xbd, + 0xe5, 0x27, 0x06, 0xac, 0x4e, 0x50, 0x35, 0xb1, 0x5e, 0x91, 0xa5, 0xbe, 0x86, 0x2a, 0xef, 0x5c, + 0x6a, 0xa3, 0xa1, 0x6c, 0x23, 0x94, 0xef, 0x58, 0xd6, 0xab, 0xab, 0x81, 0x1b, 0x2b, 0xe2, 0x9b, + 0x3c, 0x63, 0x32, 0x55, 0xf3, 0x0b, 0x7a, 0xb8, 0xb2, 0x75, 0xb9, 0x91, 0xc6, 0x73, 0x0b, 0xf1, + 0xdc, 0xb0, 0xae, 0x5f, 0x80, 0x67, 0xd2, 0xa9, 0xb2, 0xf8, 0xab, 0x97, 0xcf, 0xb6, 0x8d, 0xbd, + 0x0f, 0xbe, 0x38, 0xab, 0x1a, 0x5f, 0x9e, 0x55, 0x8d, 0x7f, 0x9e, 0x55, 0x8d, 0xdf, 0xbd, 0xa8, + 0xce, 0x7d, 0xf9, 0xa2, 0x3a, 0xf7, 0xf7, 0x17, 0xd5, 0xb9, 0x9f, 0xde, 0x1e, 0x7b, 0x54, 0x1c, + 0xc4, 0xf1, 0x1e, 0x32, 0xf9, 0x88, 0x47, 0xa7, 0xa3, 0xf0, 0x8f, 0x71, 0x03, 0x7c, 0x5f, 0xb4, + 0x97, 0xf0, 0x07, 0x9b, 0xf7, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x29, 0xea, 0x55, 0xd7, 0x56, + 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -5514,7 +5546,7 @@ func (m *TaskResultInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Phase |= uint32(b&0x7F) << shift + m.Phase |= Phase(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/avs/types/types.go b/x/avs/types/types.go index 905a1988f..c87f9a952 100644 --- a/x/avs/types/types.go +++ b/x/avs/types/types.go @@ -77,7 +77,7 @@ type AVSRegisterOrDeregisterParams struct { ChainID string AvsReward uint64 AvsSlash uint64 - Action uint64 + Action OperatorAction } var ( diff --git a/x/avs/types/utils.go b/x/avs/types/utils.go index 0ea705155..5d6f2d1de 100644 --- a/x/avs/types/utils.go +++ b/x/avs/types/utils.go @@ -1,12 +1,14 @@ package types import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ) // CommitPhase represents the phases of the Two-Phase Commit protocol -type CommitPhase uint32 +type CommitPhase uint8 const ( PreparePhase CommitPhase = iota @@ -17,7 +19,7 @@ type OperatorOptParams struct { Name string `json:"name"` BlsPublicKey string `json:"bls_public_key"` IsRegistered bool `json:"is_registered"` - Action uint64 `json:"action"` + Action OperatorAction `json:"action"` OperatorAddress sdk.AccAddress `json:"operator_address"` Status string `json:"status"` AvsAddress common.Address `json:"avs_address"` @@ -37,7 +39,6 @@ type TaskInfoParams struct { TaskResponseHash string `json:"task_response_hash"` TaskResponse []byte `json:"task_response"` BlsSignature []byte `json:"bls_signature"` - Phase string `json:"phase"` ActualThreshold uint64 `json:"actual_threshold"` OptInCount uint64 `json:"opt_in_count"` SignedCount uint64 `json:"signed_count"` @@ -46,7 +47,7 @@ type TaskInfoParams struct { CallerAddress sdk.AccAddress `json:"caller_address"` } type BlsParams struct { - Operator sdk.AccAddress + OperatorAddress sdk.AccAddress Name string PubKey []byte PubkeyRegistrationSignature []byte @@ -67,10 +68,13 @@ type OperatorStatusParams struct { ProofData string } +// OperatorAction represents the type of action an operator can perform +type OperatorAction uint64 + const ( - RegisterAction = 1 - DeRegisterAction = 2 - UpdateAction = 3 + RegisterAction OperatorAction = 1 + DeRegisterAction OperatorAction = 2 + UpdateAction OperatorAction = 3 ) type ChallengeParams struct { @@ -89,6 +93,15 @@ type TaskResultParams struct { BlsSignature []byte `json:"bls_signature"` TaskContractAddress common.Address `json:"task_contract_address"` TaskID uint64 `json:"task_id"` - Phase uint8 `json:"phase"` + Phase CommitPhase `json:"phase"` CallerAddress sdk.AccAddress `json:"caller_address"` } + +func ValidatePhase(phase CommitPhase) error { + switch phase { + case PreparePhase, DoCommitPhase: + return nil + default: + return fmt.Errorf("invalid phase value: %d", phase) + } +} From d84a457fdc20120130259bbb2410c581a8ddb4b7 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:28:17 +0000 Subject: [PATCH 15/24] fix(tests): use correct case --- x/dogfood/keeper/abci.go | 57 ++++++++++++++++++++++++---- x/dogfood/keeper/opt_out_test.go | 7 ++-- x/operator/keeper/impl_epoch_hook.go | 6 ++- x/operator/keeper/opt.go | 16 +++++--- x/operator/keeper/opt_test.go | 2 + x/operator/keeper/slash.go | 2 + 6 files changed, 73 insertions(+), 17 deletions(-) diff --git a/x/dogfood/keeper/abci.go b/x/dogfood/keeper/abci.go index 067b952f9..f09480ae3 100644 --- a/x/dogfood/keeper/abci.go +++ b/x/dogfood/keeper/abci.go @@ -20,6 +20,7 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } defer k.ClearEpochEnd(ctx) + logger := k.Logger(ctx) chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(ctx.ChainID()) // start by clearing the previous consensus keys for the chain. // each AVS can have a separate epoch and hence this function is a part of this module @@ -30,7 +31,10 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { for _, undelegation := range undelegations.GetList() { err := k.delegationKeeper.DecrementUndelegationHoldCount(ctx, undelegation) if err != nil { - k.Logger(ctx).Error("error decrementing undelegation hold count", "error", err) + logger.Error( + "error decrementing undelegation hold count", + "error", err, + ) } k.ClearUndelegationMaturityEpoch(ctx, undelegation) } @@ -42,7 +46,10 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { ctx, addr, chainIDWithoutRevision, ) if err != nil { - k.Logger(ctx).Error("error completing operator key removal", "error", err) + logger.Error( + "error completing operator key removal", + "error", err, + ) } } k.ClearPendingOptOuts(ctx) @@ -73,7 +80,10 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { pubKey, err := validator.ConsPubKey() if err != nil { // indicates an error in deserialization, and should never happen. - k.Logger(ctx).Error("error deserializing consensus public key", "error", err) + logger.Error( + "error deserializing consensus public key", + "error", err, + ) continue } addressString := sdk.GetConsAddress(pubKey).String() @@ -84,23 +94,28 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { ctx, operators, chainIDWithoutRevision, ) if err != nil { - k.Logger(ctx).Error("error getting vote power for chain", "error", err) + logger.Error( + "error getting vote power for chain", + "error", err, + ) return []abci.ValidatorUpdate{} } operators, keys, powers = utils.SortByPower(operators, keys, powers) maxVals := k.GetMaxValidators(ctx) - k.Logger(ctx).Info("max validators", "maxVals", maxVals, "len(operators)", len(operators)) + logger.Info("before loop", "maxVals", maxVals, "len(operators)", len(operators)) // the capacity of this list is twice the maximum number of validators. // this is because we can have a maximum of maxVals validators, and we can also have // a maximum of maxVals validators that are removed. res := make([]keytypes.WrappedConsKeyWithPower, 0, maxVals*2) for i := range operators { + logger.Debug("loop", i) // #nosec G701 // ok on 64-bit systems. if i >= int(maxVals) { // we have reached the maximum number of validators, amongst all the validators. // even if there are intersections with the previous validator set, this will // only be reached if we exceed the threshold. // if there are no intersections, this case is glaringly obvious. + logger.Debug("max validators reached", "i", i) break } power := powers[i] @@ -108,6 +123,7 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { // we have reached the bottom of the rung. // assumption is that negative vote power isn't provided by the module. // the consensus engine will reject it anyway and panic. + logger.Debug("power less than 1", "i", i) break } // find the previous power. @@ -117,10 +133,24 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { if found { // if the power has changed, queue an update. skip, otherwise. if prevPower != power { + logger.Debug( + "power changed", + "i", i, + "operator", operators[i].String(), + "power", power, + "prevPower", prevPower, + ) res = append(res, keytypes.WrappedConsKeyWithPower{ Key: wrappedKey, Power: power, }) + } else { + logger.Debug( + "power not changed", + "i", i, + "operator", operators[i].String(), + "power", power, + ) } // remove the validator from the previous map, so that 0 power // is not queued for it. @@ -131,11 +161,21 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { Key: wrappedKey, Power: power, }) + logger.Debug( + "new validator", + "i", i, + "operator", operators[i].String(), + "power", power, + ) } // all powers, regardless of whether the key exists, are added to the total power. totalPower = totalPower.Add(sdk.NewInt(power)) } - k.Logger(ctx).Info("total power", "totalPower", totalPower, "len(res)", len(res)) + logger.Info( + "before removal", + "totalPower", totalPower, + "len(res)", len(res), + ) // the remaining validators in prevMap have been removed. // we need to queue a change in power to 0 for them. for _, validator := range prevList { // O(N) @@ -152,7 +192,10 @@ func (k Keeper) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { // so the previous power of these validators does not need to be subtracted. } } - k.Logger(ctx).Info("total power", "totalPower", totalPower, "len(res)", len(res)) + logger.Info( + "after removal", + "len(res)", len(res), + ) // if there are any updates, set total power on lookup index. if len(res) > 0 { k.SetLastTotalPower(ctx, totalPower) diff --git a/x/dogfood/keeper/opt_out_test.go b/x/dogfood/keeper/opt_out_test.go index c69f7e71d..dba934dfa 100644 --- a/x/dogfood/keeper/opt_out_test.go +++ b/x/dogfood/keeper/opt_out_test.go @@ -29,9 +29,10 @@ func (suite *KeeperTestSuite) TestBasicOperations() { suite.NoError(err) suite.CheckLengthOfValidatorUpdates(0, nil, "register operator but don't opt in") - // opt-in with a key + // opt-in with a key - it will fail because there is not enough self delegation to opt-in chainIDWithoutRevision := avstypes.ChainIDWithoutRevision(suite.Ctx.ChainID()) - _, avsAddress := suite.App.AVSManagerKeeper.IsAVSByChainID(suite.Ctx, chainIDWithoutRevision) + found, avsAddress := suite.App.AVSManagerKeeper.IsAVSByChainID(suite.Ctx, chainIDWithoutRevision) + suite.True(found, "AVS not found") key := utiltx.GenerateConsensusKey() _, err = suite.OperatorMsgServer.OptIntoAVS(sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, @@ -114,7 +115,7 @@ func (suite *KeeperTestSuite) TestBasicOperations() { assetDecimals, 0, // price decimals ) - // opt in again when the self delegation meet the requirement + // opt in successfully after the self delegation meet the requirement _, err = suite.OperatorMsgServer.OptIntoAVS(sdk.WrapSDKContext(suite.Ctx), &operatortypes.OptIntoAVSReq{ FromAddress: operatorAddressString, AvsAddress: avsAddress, diff --git a/x/operator/keeper/impl_epoch_hook.go b/x/operator/keeper/impl_epoch_hook.go index 478a62439..8815d8909 100644 --- a/x/operator/keeper/impl_epoch_hook.go +++ b/x/operator/keeper/impl_epoch_hook.go @@ -1,6 +1,8 @@ package keeper import ( + "strings" + epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -29,8 +31,8 @@ func (wrapper EpochsHooksWrapper) AfterEpochEnd( // todo: need to consider the calling order avsList := wrapper.keeper.avsKeeper.GetEpochEndAVSs(ctx, epochIdentifier, epochNumber) for _, avs := range avsList { - // avs address should be hex - err := wrapper.keeper.UpdateVotingPower(ctx, avs) + // avs address is checksummed hex, we should convert it to lowercase + err := wrapper.keeper.UpdateVotingPower(ctx, strings.ToLower(avs)) if err != nil { ctx.Logger().Error("Failed to update voting power", "avs", avs, "error", err) // Handle the error gracefully, continue to the next AVS diff --git a/x/operator/keeper/opt.go b/x/operator/keeper/opt.go index 9128a9ad6..591972cd8 100644 --- a/x/operator/keeper/opt.go +++ b/x/operator/keeper/opt.go @@ -82,15 +82,21 @@ func (k *Keeper) OptIn( // OptInWithConsKey is a wrapper function to call OptIn and then SetOperatorConsKeyForChainID. // The caller must ensure that the operatorAddress passed is valid and that the AVS is a chain-type AVS. func (k Keeper) OptInWithConsKey( - ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, key keytypes.WrappedConsKey, + originalCtx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, key keytypes.WrappedConsKey, ) error { - err := k.OptIn(ctx, operatorAddress, avsAddr) - if err != nil { + logger := originalCtx.Logger() + ctx, writeFunc := originalCtx.CacheContext() + if err := k.OptIn(ctx, operatorAddress, avsAddr); err != nil { + logger.Error("OptInWithConsKey", "error", err) return err } chainID, _ := k.avsKeeper.GetChainIDByAVSAddr(ctx, avsAddr) - k.Logger(ctx).Info("OptInWithConsKey", "chainID", chainID) - return k.SetOperatorConsKeyForChainID(ctx, operatorAddress, chainID, key) + if err := k.SetOperatorConsKeyForChainID(ctx, operatorAddress, chainID, key); err != nil { + logger.Error("OptInWithConsKey", "error", err) + return err + } + writeFunc() + return nil } // OptOut call this function to opt out of AVS diff --git a/x/operator/keeper/opt_test.go b/x/operator/keeper/opt_test.go index 56e54a175..e5db044e5 100644 --- a/x/operator/keeper/opt_test.go +++ b/x/operator/keeper/opt_test.go @@ -141,6 +141,7 @@ func (suite *OperatorTestSuite) TestOptIn() { OptedInfo: &operatorTypes.OptedInfo{ OptedInHeight: uint64(suite.Ctx.BlockHeight()), OptedOutHeight: operatorTypes.DefaultOptedOutHeight, + SlashContract: common.Address{}.String(), }, AVSTotalShare: usdValue, AVSOperatorShare: usdValue, @@ -190,6 +191,7 @@ func (suite *OperatorTestSuite) TestOptOut() { OptedInfo: &operatorTypes.OptedInfo{ OptedInHeight: uint64(optInHeight), OptedOutHeight: uint64(suite.Ctx.BlockHeight()), + SlashContract: common.Address{}.String(), }, AVSTotalShare: sdkmath.LegacyNewDec(0), AVSOperatorShare: sdkmath.LegacyNewDec(0), diff --git a/x/operator/keeper/slash.go b/x/operator/keeper/slash.go index 1f1c6a58d..df384888e 100644 --- a/x/operator/keeper/slash.go +++ b/x/operator/keeper/slash.go @@ -5,6 +5,7 @@ import ( "github.com/ExocoreNetwork/exocore/utils" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" errorsmod "cosmossdk.io/errors" @@ -202,6 +203,7 @@ func (k Keeper) SlashWithInfractionReason( SlashID: slashID, SlashEventHeight: infractionHeight, SlashProportion: slashFactor, + SlashContract: common.Address{}.String(), } err := k.Slash(ctx, slashParam) if err != nil { From 4bbf2296668d8348e892c89f5120889336b94519 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:37:47 +0000 Subject: [PATCH 16/24] fix: use blank slash contract not 0x0000 --- precompiles/avs/utils_test.go | 2 -- x/avs/keeper/avs.go | 4 +++- x/operator/keeper/opt_test.go | 2 -- x/operator/keeper/slash.go | 2 -- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/precompiles/avs/utils_test.go b/precompiles/avs/utils_test.go index 00a78dc5f..5f52298d8 100644 --- a/precompiles/avs/utils_test.go +++ b/precompiles/avs/utils_test.go @@ -150,7 +150,6 @@ func (suite *AVSManagerPrecompileSuite) TestOptIn() { usdValue := operatorKeeper.CalculateUSDValue(suite.delegationAmount, price.Value, suite.assetDecimal, price.Decimal) expectedState := &StateForCheck{ OptedInfo: &operatorTypes.OptedInfo{ - SlashContract: "0x0000000000000000000000000000000000000000", OptedInHeight: uint64(suite.Ctx.BlockHeight()), OptedOutHeight: operatorTypes.DefaultOptedOutHeight, }, @@ -200,7 +199,6 @@ func (suite *AVSManagerPrecompileSuite) TestOptOut() { expectedState := &StateForCheck{ OptedInfo: &operatorTypes.OptedInfo{ - SlashContract: "0x0000000000000000000000000000000000000000", OptedInHeight: uint64(optInHeight), OptedOutHeight: uint64(suite.Ctx.BlockHeight()), }, diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index 6f8e820bb..646a9cd8a 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -46,7 +46,9 @@ func (k *Keeper) GetAVSSlashContract(ctx sdk.Context, avsAddr string) (string, e if err != nil { return "", errorsmod.Wrap(err, fmt.Sprintf("GetAVSSlashContract: key is %s", avsAddr)) } - + if avsInfo.Info.SlashAddr == (common.Address{}).String() { + return "", nil + } return avsInfo.Info.SlashAddr, nil } diff --git a/x/operator/keeper/opt_test.go b/x/operator/keeper/opt_test.go index e5db044e5..56e54a175 100644 --- a/x/operator/keeper/opt_test.go +++ b/x/operator/keeper/opt_test.go @@ -141,7 +141,6 @@ func (suite *OperatorTestSuite) TestOptIn() { OptedInfo: &operatorTypes.OptedInfo{ OptedInHeight: uint64(suite.Ctx.BlockHeight()), OptedOutHeight: operatorTypes.DefaultOptedOutHeight, - SlashContract: common.Address{}.String(), }, AVSTotalShare: usdValue, AVSOperatorShare: usdValue, @@ -191,7 +190,6 @@ func (suite *OperatorTestSuite) TestOptOut() { OptedInfo: &operatorTypes.OptedInfo{ OptedInHeight: uint64(optInHeight), OptedOutHeight: uint64(suite.Ctx.BlockHeight()), - SlashContract: common.Address{}.String(), }, AVSTotalShare: sdkmath.LegacyNewDec(0), AVSOperatorShare: sdkmath.LegacyNewDec(0), diff --git a/x/operator/keeper/slash.go b/x/operator/keeper/slash.go index df384888e..1f1c6a58d 100644 --- a/x/operator/keeper/slash.go +++ b/x/operator/keeper/slash.go @@ -5,7 +5,6 @@ import ( "github.com/ExocoreNetwork/exocore/utils" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" errorsmod "cosmossdk.io/errors" @@ -203,7 +202,6 @@ func (k Keeper) SlashWithInfractionReason( SlashID: slashID, SlashEventHeight: infractionHeight, SlashProportion: slashFactor, - SlashContract: common.Address{}.String(), } err := k.Slash(ctx, slashParam) if err != nil { From 33875a42bccd63009ede6ea7931878a274c1e849 Mon Sep 17 00:00:00 2001 From: trestin Date: Tue, 29 Oct 2024 22:57:33 +0800 Subject: [PATCH 17/24] update proto enum phase --- precompiles/avs/IAVSManager.sol | 4 +- precompiles/avs/tx.go | 2 +- proto/exocore/avs/v1/query.proto | 11 +- proto/exocore/avs/v1/tx.proto | 64 ++++---- x/avs/client/cli/tx.go | 2 +- x/avs/keeper/avs.go | 3 +- x/avs/types/tx.pb.go | 245 ++++++++++++++++--------------- x/avs/types/utils.go | 2 +- 8 files changed, 164 insertions(+), 169 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index abeeb99f8..cc63e83dd 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -169,8 +169,8 @@ interface IAVSManager { /// @param blsSignature is the operator bls sig info.. /// @param taskContractAddress is contract address of task. /// @param phase The phase of the Two-Phase Commit protocol: - /// 0 = Prepare phase (commit preparation) - /// 1 = Commit phase (final commitment) + /// 1 = Prepare phase (commit preparation) + /// 2 = Commit phase (final commitment) function operatorSubmitTask( address sender, uint64 taskID, diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 704edc3db..554c3c684 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -382,7 +382,7 @@ func (p Precompile) OperatorSubmitTask( // 1 = Commit phase (final commitment) // validation of the phase number if err := avstypes.ValidatePhase(avstypes.CommitPhase(phase)); err != nil { - return nil, fmt.Errorf("invalid phase value: %d. Expected 0 (Prepare) or 1 (Commit)", phase) + return nil, fmt.Errorf("invalid phase value: %d. Expected 1 (Prepare) or 2 (Commit)", phase) } resultParams.Phase = avstypes.CommitPhase(phase) diff --git a/proto/exocore/avs/v1/query.proto b/proto/exocore/avs/v1/query.proto index 3c4cb11f0..a9a1a41dd 100644 --- a/proto/exocore/avs/v1/query.proto +++ b/proto/exocore/avs/v1/query.proto @@ -37,7 +37,7 @@ message QueryAVSTaskInfoReq { // task_addr is the task contract address,its type should be a sdk.AccAddress string task_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // task_id is the task identifier - string task_id = 2 ; + string task_id = 2; } // QuerySubmitTaskResultReq is the request to obtain the task information. @@ -45,10 +45,9 @@ message QuerySubmitTaskResultReq { // task_addr is the task contract address,its type should be a sdk.AccAddress string task_addr = 1 [(gogoproto.customname) = "TaskAddress"]; // task_id is the task identifier - string task_id = 2 ; + string task_id = 2; // operator_addr is the operator address,its type should be a sdk.AccAddress - string operator_addr = 3 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string operator_addr = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // QueryChallengeInfoReq is the request to obtain the task information. @@ -58,11 +57,9 @@ message QueryChallengeInfoReq { // task_id is the task identifier string task_id = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // operator_addr is the operator address,its type should be a sdk.AccAddress - string operator_addr = 3 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string operator_addr = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } - // QuerySubmitTaskResultResponse is the response of avs related information message QuerySubmitTaskResultResponse { // info is the taskResult. diff --git a/proto/exocore/avs/v1/tx.proto b/proto/exocore/avs/v1/tx.proto index b8b512d4b..3fa03511e 100644 --- a/proto/exocore/avs/v1/tx.proto +++ b/proto/exocore/avs/v1/tx.proto @@ -44,32 +44,31 @@ message AVSInfo { string chain_id = 15; // avs_reward defines the proportion of reward string avs_reward = 16 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; // avs_slash defines the proportion of slash string avs_slash = 17 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; // asset_reward_commission_epoch_basis is the avs reward distribution based on asset per eopch end. map asset_reward_amount_epoch_basis = 18; } -//Status and proof of each operator +// Status and proof of each operator message OperatorStatus { // operator address string operator_address = 1; - //Status of the operator,(slash,reward,no) + // Status of the operator,(slash,reward,no) string status = 2; // proof data which is supplied by the contract, usually ABI-encoded bytes proof_data = 3; - } -//RewardSlashProof is the task info. +// RewardSlashProof is the task info. message RewardSlashProof { // task_id of task string task_id = 1; // contract address of avstask string task_contract_address = 2; - //aggregator address + // aggregator address string aggregator = 3; // address of avs string avs_address = 4; @@ -92,15 +91,14 @@ message TaskInfo { // Statistical period: threshold calculation, signature verification, // nosig quantity statistics, operator submits messages corresponding to signatures uint64 task_statistical_period = 6; - //challenge period for task + // challenge period for task uint64 task_challenge_period = 7; - //Signature threshold percentage + // Signature threshold percentage uint64 threshold_percentage = 8; // Effective current epoch, accounting for current_epoch + 1 // and current_epoch is the integer identifier of the epoch module uint64 starting_epoch = 9; - // actual_threshold is the Actual threshold uint64 actual_threshold = 10; // opt_in_count when creating a task, the actual opt-in operator counts at this moment @@ -112,15 +110,14 @@ message TaskInfo { // err_signed_count is the number of operators with final incorrect signatures repeated string err_signed_operators = 14; // task_total_power is the USD value owned by the avs task itself. - string task_total_power = 15 - [ + string task_total_power = 15 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.customname) = "TaskTotalPower" ]; // operator_active_power_list is a power list of operators opt-in to the current task - OperatorActivePowerList operator_active_power= 16; + OperatorActivePowerList operator_active_power = 16; } // OperatorActivePowerList is the power list of operators opt-in to the current task. // Because power is always changing, record the power of all operators @@ -135,8 +132,7 @@ message OperatorActivePowerInfo { // operator_addr is the operator address. string operator_addr = 1; // active_power is the USD value owned by the operator itself. - string active_power = 2 - [ + string active_power = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, @@ -147,11 +143,10 @@ message OperatorActivePowerInfo { message BlsPubKeyInfo { // operator address string operator = 1; - //the name of public keys + // the name of public keys string name = 2; // the bls public keys of the operator bytes pub_key = 3; - } // RegisterAVSTaskReq is the request to register a new task for avs. message RegisterAVSTaskReq { @@ -174,8 +169,7 @@ message RegisterAVSReq { // from_address is the source option (cosmos.msg.v1.signer) = "FromAddress"; // from_address is the source - string from_address = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // avs information AVSInfo info = 2; } @@ -185,8 +179,7 @@ message RegisterAVSResponse { // from_address is the source option (cosmos.msg.v1.signer) = "FromAddress"; // from_address is the source - string from_address = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // avs information AVSInfo info = 2; } @@ -195,8 +188,7 @@ message RegisterAVSResponse { message DeRegisterAVSReq { option (cosmos.msg.v1.signer) = "FromAddress"; // from_address is the source address - string from_address = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // avs information AVSInfo info = 2; } @@ -206,17 +198,18 @@ message DeRegisterAVSResponse { // from_address is the source address option (cosmos.msg.v1.signer) = "FromAddress"; // from_address is the source address - string from_address = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // avs information AVSInfo info = 2; } -// It is a two-phase submission with two values, 0 and 1 +// It is a two-phase submission with two values, 1 and 2 enum Phase { - // the first phase (pre-commit) - PHASE_PREPARE = 0; - // the second phase - PHASE_DO_COMMIT = 1; + // Default value when phase is not specified + PHASE_UNSPECIFIED = 0; + // First phase where operators prepare and submit their initial responses + PHASE_PREPARE = 1; + // Second phase where operators commit their prepared responses + PHASE_DO_COMMIT = 2; } // TaskResultInfo is the operator sign task info result. message TaskResultInfo { @@ -233,7 +226,7 @@ message TaskResultInfo { // task_id is the task id uint64 task_id = 6; // phase this field is used to solve the problem of task results being copied by other operators. - // It is a two-phase submission with two values, 0 and 1 + // It is a two-phase submission with two values, 1 and 2 Phase phase = 7; } @@ -245,8 +238,7 @@ message SubmitTaskResultReq { option (gogoproto.goproto_getters) = false; // from_address is the address of the operator (sdk.AccAddress). - string from_address = 1 - [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // info is the taskResult. TaskResultInfo info = 2; } @@ -256,11 +248,11 @@ message SubmitTaskResultResponse {} service Msg { option (cosmos.msg.v1.service) = true; // RegisterAVS registers a new AVS with corresponding operator. - rpc RegisterAVS (RegisterAVSReq) returns (RegisterAVSResponse) { + rpc RegisterAVS(RegisterAVSReq) returns (RegisterAVSResponse) { option (google.api.http).post = "/exocore/avs/v1/tx/RegisterAVS"; }; // DelegateAssetToOperator delegates asset to operator. - rpc DeRegisterAVS (DeRegisterAVSReq) returns (DeRegisterAVSResponse) { + rpc DeRegisterAVS(DeRegisterAVSReq) returns (DeRegisterAVSResponse) { option (google.api.http).post = "/exocore/avs/v1/tx/DeRegisterAVS"; }; // RegisterAVSTask registers a new task. @@ -268,7 +260,7 @@ service Msg { option (google.api.http).post = "/exocore/avs/v1/tx/RegisterAVSTask"; }; // SubmitTaskResult operator submit task results . - rpc SubmitTaskResult (SubmitTaskResultReq) returns (SubmitTaskResultResponse) { + rpc SubmitTaskResult(SubmitTaskResultReq) returns (SubmitTaskResultResponse) { option (google.api.http).post = "/exocore/avs/v1/tx/SubmitTaskResult"; }; } \ No newline at end of file diff --git a/x/avs/client/cli/tx.go b/x/avs/client/cli/tx.go index 78c742e52..2e5922ecc 100644 --- a/x/avs/client/cli/tx.go +++ b/x/avs/client/cli/tx.go @@ -81,7 +81,7 @@ func CmdSubmitTaskResult() *cobra.Command { FlagTaskID, 1, "The task id", ) f.Uint32( - FlagPhase, 0, "The phase is a two-phase submission with two values, 0 and 1", + FlagPhase, 0, "The phase is a two-phase submission with two values, 1 and 2", ) // #nosec G703 // this only errors if the flag isn't defined. _ = cmd.MarkFlagRequired(FlagTaskID) diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index 646a9cd8a..879f2b9b9 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -4,6 +4,7 @@ import ( "fmt" "math/big" "strconv" + "strings" errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" @@ -74,7 +75,7 @@ func (k *Keeper) GetEpochEndAVSs(ctx sdk.Context, epochIdentifier string, ending // it should be returned here, since the operator module should start tracking this. // #nosec G115 if epochIdentifier == avsInfo.EpochIdentifier && endingEpochNumber >= int64(avsInfo.StartingEpoch)-1 { - avsList = append(avsList, avsInfo.AvsAddress) + avsList = append(avsList, strings.ToLower(avsInfo.AvsAddress)) } return false }) diff --git a/x/avs/types/tx.pb.go b/x/avs/types/tx.pb.go index 7e3cfd8c8..7197fa11b 100644 --- a/x/avs/types/tx.pb.go +++ b/x/avs/types/tx.pb.go @@ -33,24 +33,28 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// It is a two-phase submission with two values, 0 and 1 +// It is a two-phase submission with two values, 1 and 2 type Phase int32 const ( - // the first phase (pre-commit) - Phase_PHASE_PREPARE Phase = 0 - // the second phase - Phase_PHASE_DO_COMMIT Phase = 1 + // Default value when phase is not specified + Phase_PHASE_UNSPECIFIED Phase = 0 + // First phase where operators prepare and submit their initial responses + Phase_PHASE_PREPARE Phase = 1 + // Second phase where operators commit their prepared responses + Phase_PHASE_DO_COMMIT Phase = 2 ) var Phase_name = map[int32]string{ - 0: "PHASE_PREPARE", - 1: "PHASE_DO_COMMIT", + 0: "PHASE_UNSPECIFIED", + 1: "PHASE_PREPARE", + 2: "PHASE_DO_COMMIT", } var Phase_value = map[string]int32{ - "PHASE_PREPARE": 0, - "PHASE_DO_COMMIT": 1, + "PHASE_UNSPECIFIED": 0, + "PHASE_PREPARE": 1, + "PHASE_DO_COMMIT": 2, } func (x Phase) String() string { @@ -1041,7 +1045,7 @@ type TaskResultInfo struct { // task_id is the task id TaskId uint64 `protobuf:"varint,6,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // phase this field is used to solve the problem of task results being copied by other operators. - // It is a two-phase submission with two values, 0 and 1 + // It is a two-phase submission with two values, 1 and 2 Phase Phase `protobuf:"varint,7,opt,name=phase,proto3,enum=exocore.avs.v1.Phase" json:"phase,omitempty"` } @@ -1124,7 +1128,7 @@ func (m *TaskResultInfo) GetPhase() Phase { if m != nil { return m.Phase } - return Phase_PHASE_PREPARE + return Phase_PHASE_UNSPECIFIED } // SubmitTaskResultReq is the request to submit task results. @@ -1229,115 +1233,116 @@ func init() { func init() { proto.RegisterFile("exocore/avs/v1/tx.proto", fileDescriptor_ef1ed06249b07d86) } var fileDescriptor_ef1ed06249b07d86 = []byte{ - // 1715 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x4f, 0x6f, 0x1b, 0xc7, - 0x15, 0xd7, 0x4a, 0x94, 0x44, 0x3e, 0x52, 0x14, 0x35, 0x92, 0xc3, 0x35, 0xdd, 0x92, 0xc2, 0xba, - 0x4e, 0x64, 0x39, 0x26, 0x6d, 0xa5, 0x28, 0x0c, 0xf7, 0x24, 0x45, 0x6a, 0x22, 0xa4, 0xb6, 0x88, - 0xa5, 0x9a, 0x16, 0xed, 0x61, 0x31, 0xe4, 0x8e, 0x96, 0x0b, 0x2d, 0x77, 0xd8, 0x9d, 0x21, 0x6d, - 0xf7, 0x50, 0x14, 0x3e, 0x15, 0x41, 0x51, 0xb4, 0xc8, 0x17, 0xc8, 0xbd, 0x28, 0x60, 0x14, 0xb9, - 0x14, 0x68, 0xef, 0x39, 0x06, 0xe9, 0xa5, 0xe8, 0xc1, 0x28, 0xe4, 0x02, 0x6e, 0xbf, 0x45, 0x31, - 0x6f, 0x67, 0x29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, 0x84, 0xcd, 0xcb, 0x02, 0x90, 0x12, 0x2c, 0x9c, 0xb2, 0x27, 0x7a, - 0x0c, 0xd5, 0x27, 0xd9, 0x80, 0xc5, 0x21, 0x0d, 0x06, 0x0c, 0xe7, 0x6f, 0xc1, 0x8e, 0x17, 0xf7, - 0xe7, 0xef, 0x19, 0x56, 0x04, 0xc5, 0xe4, 0xbc, 0x5b, 0x92, 0xca, 0x81, 0xea, 0xee, 0x52, 0xd2, - 0x1a, 0xa3, 0x41, 0x88, 0x43, 0xad, 0x26, 0xf2, 0x64, 0x10, 0xde, 0x82, 0x25, 0x81, 0x4e, 0x7a, - 0xae, 0xf5, 0x4a, 0x0d, 0x63, 0x3f, 0xe2, 0xfc, 0xc4, 0x71, 0xa9, 0xa4, 0x38, 0xcd, 0x05, 0x3b, - 0x87, 0x92, 0x7d, 0x2a, 0xa9, 0xf5, 0x1f, 0x03, 0x4a, 0x31, 0x7e, 0xac, 0x69, 0x53, 0x29, 0x48, - 0x19, 0x96, 0x71, 0xba, 0x7d, 0x57, 0xef, 0xb6, 0xa4, 0x96, 0x87, 0x2e, 0xd9, 0x81, 0x2b, 0xa8, - 0xe8, 0xf0, 0x50, 0x46, 0xb4, 0x23, 0x27, 0xb8, 0x64, 0x5d, 0x29, 0xdf, 0xd7, 0xba, 0x04, 0x58, - 0x15, 0x80, 0x7a, 0x5e, 0xa4, 0x66, 0x84, 0x47, 0x08, 0x40, 0x91, 0xce, 0x48, 0x32, 0xc9, 0x4a, - 0x99, 0x29, 0x56, 0xfa, 0x00, 0x46, 0xc9, 0x3a, 0x3a, 0xc5, 0x45, 0x3c, 0xd6, 0xea, 0xe4, 0xb1, - 0xa6, 0xab, 0x67, 0x17, 0x79, 0x6a, 0x6d, 0x3d, 0x5b, 0x82, 0xec, 0xb1, 0x4a, 0x44, 0x11, 0xe4, - 0xcc, 0x54, 0x8c, 0xd9, 0xa9, 0x24, 0xa4, 0x3a, 0x3f, 0x46, 0xaa, 0x04, 0x32, 0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0xcd, 0x9e, 0x1a, 0xb0, 0x92, 0x9a, 0x2a, 0xb2, 0x39, 0x19, 0x7e, 0x92, - 0x05, 0x2a, 0x37, 0x2e, 0xb1, 0xd0, 0x10, 0xb6, 0x10, 0x82, 0x65, 0x6d, 0x5e, 0x00, 0x21, 0xbd, - 0xe5, 0x27, 0x06, 0xac, 0x4e, 0x50, 0x35, 0xb1, 0x5e, 0x91, 0xa5, 0xbe, 0x86, 0x2a, 0xef, 0x5c, - 0x6a, 0xa3, 0xa1, 0x6c, 0x23, 0x94, 0xef, 0x58, 0xd6, 0xab, 0xab, 0x81, 0x1b, 0x2b, 0xe2, 0x9b, - 0x3c, 0x63, 0x32, 0x55, 0xf3, 0x0b, 0x7a, 0xb8, 0xb2, 0x75, 0xb9, 0x91, 0xc6, 0x73, 0x0b, 0xf1, - 0xdc, 0xb0, 0xae, 0x5f, 0x80, 0x67, 0xd2, 0xa9, 0xb2, 0xf8, 0xab, 0x97, 0xcf, 0xb6, 0x8d, 0xbd, - 0x0f, 0xbe, 0x38, 0xab, 0x1a, 0x5f, 0x9e, 0x55, 0x8d, 0x7f, 0x9e, 0x55, 0x8d, 0xdf, 0xbd, 0xa8, - 0xce, 0x7d, 0xf9, 0xa2, 0x3a, 0xf7, 0xf7, 0x17, 0xd5, 0xb9, 0x9f, 0xde, 0x1e, 0x7b, 0x54, 0x1c, - 0xc4, 0xf1, 0x1e, 0x32, 0xf9, 0x88, 0x47, 0xa7, 0xa3, 0xf0, 0x8f, 0x71, 0x03, 0x7c, 0x5f, 0xb4, - 0x97, 0xf0, 0x07, 0x9b, 0xf7, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x29, 0xea, 0x55, 0xd7, 0x56, - 0x12, 0x00, 0x00, + // 1734 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x41, 0x6f, 0x1b, 0xc7, + 0x15, 0xd6, 0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b4, 0x79, 0x28, 0x23, 0xda, 0x96, 0x53, 0x5c, 0xb2, 0xae, 0xc0, 0x7b, 0x06, 0x8b, 0x03, 0x2b, + 0x03, 0xd0, 0x6e, 0x37, 0x52, 0x33, 0xc2, 0x23, 0x0c, 0x40, 0x91, 0xce, 0x58, 0x32, 0xcd, 0x4a, + 0xa9, 0x19, 0x56, 0x7a, 0x1f, 0xc6, 0xc9, 0x7a, 0x26, 0xc5, 0x45, 0x3c, 0xd6, 0xf2, 0xf4, 0xb1, + 0x26, 0xab, 0xe7, 0xe6, 0x79, 0x62, 0xed, 0x3c, 0x5b, 0x82, 0xf4, 0x91, 0x4a, 0x44, 0x11, 0xe4, + 0x85, 0xa9, 0x58, 0x17, 0xa7, 0x12, 0x93, 0xea, 0xfc, 0x04, 0xa9, 0x12, 0x48, 0xf5, 0x54, 0x33, + 0xeb, 0xca, 0xe2, 0xf7, 0x64, 0xfd, 0x52, 0x38, 0x6f, 0x71, 0xfd, 0x6e, 0xc1, 0x06, 0x02, 0x11, + 0x13, 0x03, 0x1e, 0x0a, 0x16, 0x53, 0xd0, 0xa2, 0xa6, 0x20, 0x85, 0xb9, 0x06, 0x32, 0x14, 0xf4, + 0x03, 0x28, 0xa2, 0x85, 0x4a, 0xdc, 0x17, 0xd2, 0x6f, 0xd3, 0x20, 0x36, 0x5a, 0x42, 0x23, 0xcc, + 0xa2, 0x79, 0x86, 0x1a, 0xbb, 0x71, 0x7a, 0x3d, 0x1a, 0x04, 0x2c, 0xec, 0x8e, 0xb7, 0x5a, 0xd6, + 0x6c, 0x81, 0xe9, 0xc5, 0x98, 0xb1, 0xb9, 0x0d, 0x1b, 0xb2, 0x17, 0x31, 0xd1, 0xe3, 0x41, 0x47, + 0xa9, 0xb7, 0x59, 0x28, 0x69, 0x97, 0xd9, 0x69, 0x63, 0x12, 0x63, 0x8d, 0x31, 0x74, 0x0e, 0xc1, + 0x64, 0xce, 0x23, 0x98, 0xeb, 0x50, 0xa0, 0x6d, 0x39, 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, 0xaf, 0x5e, 0x3e, + 0xdb, 0xb6, 0xf6, 0xde, 0xff, 0xe2, 0xb4, 0x6c, 0x7d, 0x79, 0x5a, 0xb6, 0xfe, 0x79, 0x5a, 0xb6, + 0x7e, 0xf7, 0xa2, 0x3c, 0xf7, 0xe5, 0x8b, 0xf2, 0xdc, 0xdf, 0x5f, 0x94, 0xe7, 0x7e, 0x7a, 0x73, + 0xe2, 0xad, 0x71, 0xa0, 0xfd, 0x3d, 0x64, 0xf2, 0x11, 0x8f, 0x4e, 0xc6, 0xee, 0x1f, 0xe3, 0x06, + 0xf8, 0xec, 0x68, 0x2d, 0xe1, 0xef, 0x38, 0xef, 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff, 0x50, 0xb9, + 0x38, 0x01, 0x6d, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/avs/types/utils.go b/x/avs/types/utils.go index 5d6f2d1de..7794c7d84 100644 --- a/x/avs/types/utils.go +++ b/x/avs/types/utils.go @@ -11,7 +11,7 @@ import ( type CommitPhase uint8 const ( - PreparePhase CommitPhase = iota + PreparePhase CommitPhase = iota + 1 DoCommitPhase ) From b909d83c29c82e4838be67948f6a814b9743bb68 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Wed, 30 Oct 2024 02:59:29 +0000 Subject: [PATCH 18/24] revert unnecessary change The `runTx` ensures that, upon a message failure, the cache is not written to disk. --- x/operator/keeper/opt.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/x/operator/keeper/opt.go b/x/operator/keeper/opt.go index 591972cd8..9128a9ad6 100644 --- a/x/operator/keeper/opt.go +++ b/x/operator/keeper/opt.go @@ -82,21 +82,15 @@ func (k *Keeper) OptIn( // OptInWithConsKey is a wrapper function to call OptIn and then SetOperatorConsKeyForChainID. // The caller must ensure that the operatorAddress passed is valid and that the AVS is a chain-type AVS. func (k Keeper) OptInWithConsKey( - originalCtx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, key keytypes.WrappedConsKey, + ctx sdk.Context, operatorAddress sdk.AccAddress, avsAddr string, key keytypes.WrappedConsKey, ) error { - logger := originalCtx.Logger() - ctx, writeFunc := originalCtx.CacheContext() - if err := k.OptIn(ctx, operatorAddress, avsAddr); err != nil { - logger.Error("OptInWithConsKey", "error", err) + err := k.OptIn(ctx, operatorAddress, avsAddr) + if err != nil { return err } chainID, _ := k.avsKeeper.GetChainIDByAVSAddr(ctx, avsAddr) - if err := k.SetOperatorConsKeyForChainID(ctx, operatorAddress, chainID, key); err != nil { - logger.Error("OptInWithConsKey", "error", err) - return err - } - writeFunc() - return nil + k.Logger(ctx).Info("OptInWithConsKey", "chainID", chainID) + return k.SetOperatorConsKeyForChainID(ctx, operatorAddress, chainID, key) } // OptOut call this function to opt out of AVS From b75d7a5180ee3f02546982dca3c042fa763a8faa Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Wed, 30 Oct 2024 03:20:48 +0000 Subject: [PATCH 19/24] refactor(avs): remove unnecessary CommitPhase --- precompiles/avs/tx.go | 11 +- proto/exocore/avs/v1/tx.proto | 7 +- x/avs/client/cli/tx.go | 2 +- .../keeper/multi_operator_submit_task_test.go | 4 +- x/avs/keeper/submit_task_test.go | 7 +- x/avs/keeper/task.go | 4 +- x/avs/types/tx.pb.go | 229 +++++++++--------- x/avs/types/utils.go | 14 +- 8 files changed, 138 insertions(+), 140 deletions(-) diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 554c3c684..d9eba78fd 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -378,13 +378,14 @@ func (p Precompile) OperatorSubmitTask( } // The phase of the Two-Phase Commit protocol: - // 0 = Prepare phase (commit preparation) - // 1 = Commit phase (final commitment) + // 1 = Prepare phase (commit preparation) + // 2 = Commit phase (final commitment) // validation of the phase number - if err := avstypes.ValidatePhase(avstypes.CommitPhase(phase)); err != nil { + phaseEnum := avstypes.Phase(phase) + if err := avstypes.ValidatePhase(phaseEnum); err != nil { return nil, fmt.Errorf("invalid phase value: %d. Expected 1 (Prepare) or 2 (Commit)", phase) } - resultParams.Phase = avstypes.CommitPhase(phase) + resultParams.Phase = phaseEnum result := &avstypes.TaskResultInfo{ TaskId: resultParams.TaskID, @@ -392,7 +393,7 @@ func (p Precompile) OperatorSubmitTask( TaskContractAddress: resultParams.TaskContractAddress.String(), TaskResponse: resultParams.TaskResponse, BlsSignature: resultParams.BlsSignature, - Phase: avstypes.Phase(resultParams.Phase), + Phase: phaseEnum, } err := p.avsKeeper.SetTaskResultInfo(ctx, resultParams.CallerAddress.String(), result) if err != nil { diff --git a/proto/exocore/avs/v1/tx.proto b/proto/exocore/avs/v1/tx.proto index 3fa03511e..041375524 100644 --- a/proto/exocore/avs/v1/tx.proto +++ b/proto/exocore/avs/v1/tx.proto @@ -204,12 +204,13 @@ message DeRegisterAVSResponse { } // It is a two-phase submission with two values, 1 and 2 enum Phase { + option (gogoproto.goproto_enum_prefix) = false; // Default value when phase is not specified - PHASE_UNSPECIFIED = 0; + PHASE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "PhaseUnspecified"]; // First phase where operators prepare and submit their initial responses - PHASE_PREPARE = 1; + PHASE_PREPARE = 1 [(gogoproto.enumvalue_customname) = "PhasePrepare"]; // Second phase where operators commit their prepared responses - PHASE_DO_COMMIT = 2; + PHASE_DO_COMMIT = 2 [(gogoproto.enumvalue_customname) = "PhaseDoCommit"]; } // TaskResultInfo is the operator sign task info result. message TaskResultInfo { diff --git a/x/avs/client/cli/tx.go b/x/avs/client/cli/tx.go index 2e5922ecc..b73524a26 100644 --- a/x/avs/client/cli/tx.go +++ b/x/avs/client/cli/tx.go @@ -117,7 +117,7 @@ func newBuildMsg( taskID, _ := fs.GetUint64(FlagTaskID) phase, _ := fs.GetUint32(FlagPhase) - if err := types.ValidatePhase(types.CommitPhase(phase)); err != nil { + if err := types.ValidatePhase(types.Phase(phase)); err != nil { return nil, err } msg := &types.SubmitTaskResultReq{ diff --git a/x/avs/keeper/multi_operator_submit_task_test.go b/x/avs/keeper/multi_operator_submit_task_test.go index be34ac639..9c17628a6 100644 --- a/x/avs/keeper/multi_operator_submit_task_test.go +++ b/x/avs/keeper/multi_operator_submit_task_test.go @@ -201,7 +201,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseOne_Mul() { TaskResponseHash: "", TaskResponse: nil, BlsSignature: sig.Marshal(), - Phase: avstypes.Phase(avstypes.PreparePhase), + Phase: avstypes.Phase(avstypes.PhasePrepare), } err := suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, operatorAddress, info) suite.Require().NoError(err) @@ -229,7 +229,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseTwo_Mul() { TaskResponseHash: hash.String(), TaskResponse: jsonData, BlsSignature: sig.Marshal(), - Phase: avstypes.Phase(avstypes.DoCommitPhase), + Phase: avstypes.Phase(avstypes.PhaseDoCommit), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, operatorAddress, info) suite.NoError(err) diff --git a/x/avs/keeper/submit_task_test.go b/x/avs/keeper/submit_task_test.go index 76b74b277..1302b7e06 100644 --- a/x/avs/keeper/submit_task_test.go +++ b/x/avs/keeper/submit_task_test.go @@ -1,11 +1,12 @@ package keeper_test import ( - "github.com/ethereum/go-ethereum/common/math" "math/big" "strconv" "time" + "github.com/ethereum/go-ethereum/common/math" + sdkmath "cosmossdk.io/math" assetskeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" @@ -187,7 +188,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseOne() { TaskResponseHash: "", TaskResponse: nil, BlsSignature: sig.Marshal(), - Phase: avstypes.Phase(avstypes.PreparePhase), + Phase: avstypes.Phase(avstypes.PhasePrepare), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, suite.operatorAddr.String(), info) suite.NoError(err) @@ -216,7 +217,7 @@ func (suite *AVSTestSuite) TestSubmitTask_OnlyPhaseTwo() { TaskResponseHash: hash.String(), TaskResponse: jsonData, BlsSignature: sig.Marshal(), - Phase: avstypes.Phase(avstypes.DoCommitPhase), + Phase: avstypes.Phase(avstypes.PhaseDoCommit), } err = suite.App.AVSManagerKeeper.SetTaskResultInfo(suite.Ctx, suite.operatorAddr.String(), info) suite.NoError(err) diff --git a/x/avs/keeper/task.go b/x/avs/keeper/task.go index a35db0e30..3dd890c6d 100644 --- a/x/avs/keeper/task.go +++ b/x/avs/keeper/task.go @@ -186,7 +186,7 @@ func (k *Keeper) SetTaskResultInfo( } switch info.Phase { - case types.Phase(types.PreparePhase): + case types.PhasePrepare: if k.IsExistTaskResultInfo(ctx, info.OperatorAddress, info.TaskContractAddress, info.TaskId) { return errorsmod.Wrap( types.ErrResAlreadyExists, @@ -224,7 +224,7 @@ func (k *Keeper) SetTaskResultInfo( store.Set(infoKey, bz) return nil - case types.Phase(types.DoCommitPhase): + case types.PhaseDoCommit: // check task response if info.TaskResponse == nil { return errorsmod.Wrap( diff --git a/x/avs/types/tx.pb.go b/x/avs/types/tx.pb.go index 7197fa11b..d54782356 100644 --- a/x/avs/types/tx.pb.go +++ b/x/avs/types/tx.pb.go @@ -38,11 +38,11 @@ type Phase int32 const ( // Default value when phase is not specified - Phase_PHASE_UNSPECIFIED Phase = 0 + PhaseUnspecified Phase = 0 // First phase where operators prepare and submit their initial responses - Phase_PHASE_PREPARE Phase = 1 + PhasePrepare Phase = 1 // Second phase where operators commit their prepared responses - Phase_PHASE_DO_COMMIT Phase = 2 + PhaseDoCommit Phase = 2 ) var Phase_name = map[int32]string{ @@ -1128,7 +1128,7 @@ func (m *TaskResultInfo) GetPhase() Phase { if m != nil { return m.Phase } - return Phase_PHASE_UNSPECIFIED + return PhaseUnspecified } // SubmitTaskResultReq is the request to submit task results. @@ -1233,116 +1233,119 @@ func init() { func init() { proto.RegisterFile("exocore/avs/v1/tx.proto", fileDescriptor_ef1ed06249b07d86) } var fileDescriptor_ef1ed06249b07d86 = []byte{ - // 1734 bytes of a gzipped FileDescriptorProto + // 1787 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x41, 0x6f, 0x1b, 0xc7, - 0x15, 0xd6, 0x4a, 0x94, 0x44, 0x3e, 0x52, 0x14, 0x35, 0x92, 0xc3, 0x35, 0xdd, 0x92, 0xc2, 0xba, - 0x4e, 0x64, 0x39, 0x26, 0x6d, 0xa5, 0x28, 0x0c, 0xf7, 0x24, 0x59, 0x72, 0x42, 0xa4, 0xb6, 0x88, - 0xa5, 0x92, 0x16, 0xed, 0x61, 0x31, 0x24, 0x47, 0xe4, 0x42, 0xcb, 0x1d, 0x76, 0x67, 0x48, 0xdb, - 0x3d, 0x14, 0x85, 0x4f, 0x45, 0x50, 0x14, 0x2d, 0xf2, 0x07, 0x72, 0x2f, 0x0a, 0x18, 0x45, 0x2e, - 0x05, 0xda, 0x7b, 0x8e, 0x41, 0x7a, 0x29, 0x7a, 0x30, 0x0a, 0xb9, 0x80, 0xdb, 0x7f, 0x51, 0xcc, - 0x9b, 0x59, 0x8a, 0x4b, 0x4a, 0x76, 0xdd, 0x1c, 0x92, 0x8b, 0xb4, 0xf3, 0xbe, 0xf7, 0xde, 0xbc, - 0xf7, 0xe6, 0xbd, 0x6f, 0x06, 0x84, 0x22, 0x7b, 0xcc, 0xdb, 0x3c, 0x62, 0x35, 0x3a, 0x12, 0xb5, - 0xd1, 0xed, 0x9a, 0x7c, 0x5c, 0x1d, 0x44, 0x5c, 0x72, 0x92, 0x37, 0x40, 0x95, 0x8e, 0x44, 0x75, - 0x74, 0xbb, 0xb4, 0x46, 0xfb, 0x7e, 0xc8, 0x6b, 0xf8, 0x57, 0xab, 0x94, 0x8a, 0x6d, 0x2e, 0xfa, - 0x5c, 0xd4, 0xfa, 0xa2, 0xab, 0x4c, 0xfb, 0xa2, 0x6b, 0x80, 0xcb, 0x1a, 0xf0, 0x70, 0x55, 0xd3, - 0x0b, 0x03, 0x6d, 0x74, 0x79, 0x97, 0x6b, 0xb9, 0xfa, 0x32, 0xd2, 0xef, 0x74, 0x39, 0xef, 0x06, - 0xac, 0x46, 0x07, 0x7e, 0x8d, 0x86, 0x21, 0x97, 0x54, 0xfa, 0x3c, 0x34, 0x36, 0xce, 0x5f, 0x97, - 0x61, 0x79, 0xf7, 0xe3, 0x66, 0x3d, 0x3c, 0xe6, 0x84, 0x40, 0x2a, 0xa4, 0x7d, 0x66, 0x5b, 0x9b, - 0xd6, 0x56, 0xc6, 0xc5, 0x6f, 0x52, 0x81, 0x2c, 0x1d, 0x09, 0x8f, 0x76, 0x3a, 0x11, 0x13, 0xc2, - 0x9e, 0x47, 0x08, 0xe8, 0x48, 0xec, 0x6a, 0x09, 0xd9, 0x82, 0x42, 0xdf, 0x0f, 0x3d, 0x21, 0xe9, - 0x09, 0xf3, 0x68, 0x9f, 0x0f, 0x43, 0x69, 0x2f, 0x6c, 0x5a, 0x5b, 0x29, 0x37, 0xdf, 0xf7, 0xc3, - 0xa6, 0x12, 0xef, 0xa2, 0x94, 0x5c, 0x81, 0x8c, 0xa4, 0xe2, 0x04, 0x7d, 0xd9, 0x29, 0x74, 0x94, - 0x56, 0x02, 0xe5, 0x89, 0x7c, 0x17, 0x40, 0x04, 0x54, 0xf4, 0x34, 0xba, 0x88, 0x68, 0x06, 0x25, - 0x08, 0x57, 0x20, 0x1b, 0xb1, 0x47, 0x34, 0xea, 0x68, 0x7c, 0x49, 0x87, 0xa1, 0x45, 0xa8, 0xb0, - 0x0d, 0x6b, 0x2a, 0x4e, 0xfe, 0x28, 0x64, 0xd1, 0x38, 0xda, 0xe5, 0xcd, 0x85, 0xad, 0x8c, 0xbb, - 0x4a, 0x47, 0xe2, 0x50, 0xc9, 0xe3, 0x90, 0xaf, 0x43, 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, - 0x6c, 0x81, 0xe9, 0xc5, 0x98, 0xb1, 0xb9, 0x0d, 0x1b, 0xb2, 0x17, 0x31, 0xd1, 0xe3, 0x41, 0x47, - 0xa9, 0xb7, 0x59, 0x28, 0x69, 0x97, 0xd9, 0x69, 0x63, 0x12, 0x63, 0x8d, 0x31, 0x74, 0x0e, 0xc1, - 0x64, 0xce, 0x23, 0x98, 0xeb, 0x50, 0xa0, 0x6d, 0x39, 0xa4, 0x81, 0x37, 0x76, 0x62, 0x58, 0x74, - 0x55, 0xcb, 0x8f, 0x62, 0xb1, 0xba, 0x83, 0x66, 0x48, 0x31, 0x8b, 0xdc, 0x9f, 0xe7, 0x49, 0x46, - 0xbc, 0x0e, 0x05, 0xe1, 0x77, 0x43, 0xd6, 0x49, 0xd0, 0x27, 0xde, 0x12, 0x5a, 0x7e, 0xa6, 0x5a, - 0x85, 0xf5, 0x90, 0x7b, 0x33, 0xda, 0x2b, 0xa8, 0xbd, 0x16, 0xf2, 0xe6, 0x94, 0xfe, 0x2d, 0xd8, - 0x60, 0x51, 0x34, 0x6b, 0x90, 0x47, 0x03, 0xc2, 0xa2, 0x68, 0xda, 0xe2, 0x31, 0x14, 0xb0, 0xde, - 0x9a, 0x9f, 0x07, 0xfc, 0x11, 0x8b, 0x34, 0x95, 0xee, 0x3d, 0x7c, 0x33, 0x7e, 0x3b, 0x7d, 0x5e, - 0xc9, 0xab, 0x26, 0x45, 0x2e, 0x6f, 0x28, 0x3f, 0x5f, 0x7d, 0x7e, 0x13, 0xcc, 0xdb, 0x40, 0xf1, - 0x5f, 0x5e, 0x26, 0x50, 0xf2, 0x33, 0xb8, 0x74, 0xc6, 0x11, 0x6d, 0xe9, 0x8f, 0x98, 0xd9, 0x5e, - 0x91, 0x75, 0x76, 0xe7, 0x9d, 0x8b, 0x86, 0x64, 0x17, 0x75, 0xd1, 0xc7, 0x8f, 0x7c, 0x21, 0xdd, - 0x75, 0x3e, 0x0b, 0x38, 0x11, 0x14, 0x2f, 0xd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, 0xec, 0x28, 0xd3, 0x3d, 0x5f, 0x06, + 0x8f, 0xed, 0x4b, 0xf4, 0x7c, 0x8d, 0xe2, 0x7d, 0xa8, 0xbc, 0xce, 0x01, 0xc9, 0xc1, 0xc2, 0x11, + 0x7b, 0xac, 0xdb, 0x50, 0x7d, 0x92, 0x3c, 0x2c, 0x8e, 0x68, 0x6f, 0xc8, 0xb0, 0xff, 0x16, 0xec, + 0x70, 0x71, 0x67, 0xfe, 0xb6, 0x61, 0x05, 0x90, 0x8d, 0xce, 0xbb, 0x29, 0xa9, 0x1c, 0xaa, 0xdb, + 0x9d, 0x8b, 0xae, 0xc6, 0xb8, 0x11, 0x42, 0x57, 0xab, 0x91, 0x3c, 0x6a, 0x84, 0x77, 0x60, 0x49, + 0xa0, 0x91, 0xee, 0x6b, 0xbd, 0x52, 0xcd, 0x38, 0x08, 0x38, 0x3f, 0x74, 0x5c, 0x2a, 0x29, 0x76, + 0x73, 0xc6, 0x4e, 0xa1, 0x64, 0x97, 0x4a, 0x6a, 0xfd, 0xdb, 0x80, 0x5c, 0x18, 0x3f, 0xd6, 0xb4, + 0xa1, 0x00, 0x52, 0x80, 0x65, 0xec, 0x6e, 0xcf, 0xd5, 0xbb, 0x2d, 0xa9, 0x65, 0xdd, 0x25, 0x5b, + 0x70, 0x01, 0x81, 0x36, 0xf7, 0x65, 0x40, 0xdb, 0x72, 0x8a, 0x4b, 0xd6, 0x15, 0x78, 0x57, 0x63, + 0x51, 0x60, 0x25, 0x00, 0xda, 0xe9, 0x04, 0xaa, 0x47, 0x78, 0x80, 0x01, 0x28, 0xd2, 0x19, 0x4b, + 0xa6, 0x59, 0x29, 0x31, 0xc3, 0x4a, 0x1f, 0xc2, 0x38, 0x59, 0x47, 0xa7, 0xb8, 0x88, 0xc7, 0x5a, + 0x9a, 0x3e, 0xd6, 0x78, 0xf5, 0xec, 0x2c, 0x8f, 0xad, 0xad, 0x67, 0x4b, 0x90, 0x3c, 0x50, 0x89, + 0x28, 0x82,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0x7c, 0x75, 0x52, 0x32, + 0xfe, 0x71, 0x52, 0x32, 0x7e, 0xf3, 0xa2, 0x34, 0xf7, 0xd5, 0x8b, 0xd2, 0xdc, 0xdf, 0x5e, 0x94, + 0xe6, 0x7e, 0x7c, 0x63, 0xe2, 0xb5, 0xb2, 0x17, 0xfa, 0xbb, 0xcf, 0xe4, 0x43, 0x1e, 0x1c, 0x8d, + 0xdd, 0x3f, 0xc2, 0x0d, 0xf0, 0xe1, 0xd2, 0x5a, 0xc2, 0x5f, 0x82, 0xde, 0xff, 0x4f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xdb, 0xbf, 0x57, 0x92, 0xaf, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/avs/types/utils.go b/x/avs/types/utils.go index 7794c7d84..35e6fde5b 100644 --- a/x/avs/types/utils.go +++ b/x/avs/types/utils.go @@ -7,14 +7,6 @@ import ( "github.com/ethereum/go-ethereum/common" ) -// CommitPhase represents the phases of the Two-Phase Commit protocol -type CommitPhase uint8 - -const ( - PreparePhase CommitPhase = iota + 1 - DoCommitPhase -) - type OperatorOptParams struct { Name string `json:"name"` BlsPublicKey string `json:"bls_public_key"` @@ -93,13 +85,13 @@ type TaskResultParams struct { BlsSignature []byte `json:"bls_signature"` TaskContractAddress common.Address `json:"task_contract_address"` TaskID uint64 `json:"task_id"` - Phase CommitPhase `json:"phase"` + Phase Phase `json:"phase"` CallerAddress sdk.AccAddress `json:"caller_address"` } -func ValidatePhase(phase CommitPhase) error { +func ValidatePhase(phase Phase) error { switch phase { - case PreparePhase, DoCommitPhase: + case PhasePrepare, PhaseDoCommit: return nil default: return fmt.Errorf("invalid phase value: %d", phase) From 2c2927b9f6e93431471dbf85f1b128704a3f4097 Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 31 Oct 2024 09:40:06 +0800 Subject: [PATCH 20/24] format the address in lowercase --- x/avs/keeper/keeper.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 60d4d7a90..80286befa 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -5,6 +5,7 @@ import ( "fmt" "slices" "strconv" + "strings" "github.com/prysmaticlabs/prysm/v4/crypto/bls" "github.com/prysmaticlabs/prysm/v4/crypto/bls/blst" @@ -107,9 +108,9 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi avs := &types.AVSInfo{ Name: params.AvsName, - AvsAddress: params.AvsAddress.String(), - RewardAddr: params.RewardContractAddr.String(), - SlashAddr: params.SlashContractAddr.String(), + AvsAddress: strings.ToLower(params.AvsAddress.String()), + RewardAddr: strings.ToLower(params.RewardContractAddr.String()), + SlashAddr: strings.ToLower(params.SlashContractAddr.String()), AvsOwnerAddress: params.AvsOwnerAddress, AssetIDs: params.AssetID, MinSelfDelegation: params.MinSelfDelegation, @@ -117,7 +118,7 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi EpochIdentifier: epochIdentifier, StartingEpoch: startingEpoch, MinOptInOperators: params.MinOptInOperators, - TaskAddr: params.TaskAddr.String(), + TaskAddr: strings.ToLower(params.TaskAddr.String()), MinStakeAmount: params.MinStakeAmount, // Effective at CurrentEpoch+1, avoid immediate effects and ensure that the first epoch time of avs is equal to a normal identifier MinTotalStakeAmount: params.MinTotalStakeAmount, // #nosec G115 @@ -168,13 +169,13 @@ func (k Keeper) UpdateAVSInfo(ctx sdk.Context, params *types.AVSRegisterOrDeregi avs.MinStakeAmount = params.MinStakeAmount } if params.TaskAddr.String() != "" { - avs.TaskAddr = params.TaskAddr.String() + avs.TaskAddr = strings.ToLower(params.TaskAddr.String()) } if params.SlashContractAddr.String() != "" { - avs.SlashAddr = params.SlashContractAddr.String() + avs.SlashAddr = strings.ToLower(params.SlashContractAddr.String()) } if params.RewardContractAddr.String() != "" { - avs.RewardAddr = params.RewardContractAddr.String() + avs.RewardAddr = strings.ToLower(params.RewardContractAddr.String()) } if params.AvsOwnerAddress != nil { avs.AvsOwnerAddress = params.AvsOwnerAddress @@ -252,7 +253,7 @@ func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (ui task := &types.TaskInfo{ Name: params.TaskName, Hash: params.Hash, - TaskContractAddress: params.TaskContractAddress.String(), + TaskContractAddress: strings.ToLower(params.TaskContractAddress.String()), TaskId: params.TaskID, TaskChallengePeriod: params.TaskChallengePeriod, ThresholdPercentage: params.ThresholdPercentage, @@ -280,7 +281,7 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *types.BlsParams) e } bls := &types.BlsPubKeyInfo{ Name: params.Name, - Operator: params.OperatorAddress.String(), + Operator: strings.ToLower(params.OperatorAddress.String()), PubKey: params.PubKey, } return k.SetOperatorPubKey(ctx, bls) @@ -302,9 +303,9 @@ func (k Keeper) OperatorOptAction(ctx sdk.Context, params *types.OperatorOptPara switch params.Action { case types.RegisterAction: - return k.operatorKeeper.OptIn(ctx, opAccAddr, params.AvsAddress.String()) + return k.operatorKeeper.OptIn(ctx, opAccAddr, strings.ToLower(params.AvsAddress.String())) case types.DeRegisterAction: - return k.operatorKeeper.OptOut(ctx, opAccAddr, params.AvsAddress.String()) + return k.operatorKeeper.OptOut(ctx, opAccAddr, strings.ToLower(params.AvsAddress.String())) default: return errorsmod.Wrap(types.ErrInvalidAction, fmt.Sprintf("Invalid action: %d", params.Action)) } From ff21910ce290590e1de372a4b663c1562ef173d7 Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 31 Oct 2024 10:30:57 +0800 Subject: [PATCH 21/24] Fix the missing field of topic in the event --- precompiles/avs/IAVSManager.sol | 8 +- precompiles/avs/abi.json | 42 +++--- precompiles/avs/events.go | 238 ++++++++++++++++++++++++++------ x/avs/keeper/avs.go | 1 + x/avs/keeper/avs_test.go | 5 +- 5 files changed, 225 insertions(+), 69 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index cc63e83dd..bc4209ca6 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -18,9 +18,9 @@ interface IAVSManager { event OperatorJoined(address indexed avsAddr, string sender); event OperatorLeft(address indexed avsAddr, string sender); event TaskCreated( - string sender, - uint64 taskId, address indexed taskContractAddress, + uint64 indexed taskId, + string sender, string name, bytes hash, uint64 taskResponsePeriod, @@ -33,11 +33,11 @@ interface IAVSManager { ); event PublicKeyRegistered(string sender, string name); event TaskSubmittedByOperator( + address indexed taskContractAddress, + uint64 indexed taskId, string sender, - uint64 taskID, bytes taskResponse, bytes blsSignature, - address indexed taskContractAddress, uint8 phase ); diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 35c03cc10..bdd6ed2dd 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -172,22 +172,22 @@ "anonymous": false, "inputs": [ { - "indexed": false, - "internalType": "string", - "name": "sender", - "type": "string" + "indexed": true, + "internalType": "address", + "name": "taskContractAddress", + "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "uint64", "name": "taskId", "type": "uint64" }, { - "indexed": true, - "internalType": "address", - "name": "taskContractAddress", - "type": "address" + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" }, { "indexed": false, @@ -233,17 +233,23 @@ "anonymous": false, "inputs": [ { - "indexed": false, - "internalType": "string", - "name": "sender", - "type": "string" + "indexed": true, + "internalType": "address", + "name": "taskContractAddress", + "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "uint64", - "name": "taskID", + "name": "taskId", "type": "uint64" }, + { + "indexed": false, + "internalType": "string", + "name": "sender", + "type": "string" + }, { "indexed": false, "internalType": "bytes", @@ -256,12 +262,6 @@ "name": "blsSignature", "type": "bytes" }, - { - "indexed": true, - "internalType": "address", - "name": "taskContractAddress", - "type": "address" - }, { "indexed": false, "internalType": "uint8", diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index e44b95389..679042c08 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -2,6 +2,7 @@ package avs import ( "github.com/ethereum/go-ethereum/accounts/abi" + cmn "github.com/evmos/evmos/v16/precompiles/common" avstypes "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -52,55 +53,186 @@ func (p Precompile) emitEvent(ctx sdk.Context, stateDB vm.StateDB, eventName str // - An error if there is an issue packing the event data or adding the log to the state database. // - nil if the event is successfully emitted. func (p Precompile) EmitAVSRegistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - arguments := p.ABI.Events[EventTypeAVSRegistered].Inputs - return p.emitEvent(ctx, stateDB, EventTypeAVSRegistered, arguments, - avs.AvsAddress, - avs.CallerAddress.String(), - avs.AvsName) + event := p.ABI.Events[EventTypeAVSRegistered] + topics := make([]common.Hash, 2) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(avs.AvsAddress) + if err != nil { + return err + } + + // Prepare the event data: sender, avsName + arguments := abi.Arguments{event.Inputs[1], event.Inputs[2]} + packed, err := arguments.Pack(avs.CallerAddress.String(), avs.AvsName) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil } func (p Precompile) EmitAVSUpdated(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - arguments := p.ABI.Events[EventTypeAVSUpdated].Inputs - return p.emitEvent(ctx, stateDB, EventTypeAVSUpdated, arguments, - avs.AvsAddress, - avs.CallerAddress.String(), - avs.AvsName) + event := p.ABI.Events[EventTypeAVSUpdated] + topics := make([]common.Hash, 2) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(avs.AvsAddress) + if err != nil { + return err + } + + // Prepare the event data: sender, avsName + arguments := abi.Arguments{event.Inputs[1], event.Inputs[2]} + packed, err := arguments.Pack(avs.CallerAddress.String(), avs.AvsName) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil } func (p Precompile) EmitAVSDeregistered(ctx sdk.Context, stateDB vm.StateDB, avs *avstypes.AVSRegisterOrDeregisterParams) error { - arguments := p.ABI.Events[EventTypeAVSDeregistered].Inputs - return p.emitEvent(ctx, stateDB, EventTypeAVSDeregistered, arguments, - avs.AvsAddress, - avs.CallerAddress.String(), - avs.AvsName) + event := p.ABI.Events[EventTypeAVSDeregistered] + topics := make([]common.Hash, 2) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(avs.AvsAddress) + if err != nil { + return err + } + + // Prepare the event data: sender, avsName + arguments := abi.Arguments{event.Inputs[1], event.Inputs[2]} + packed, err := arguments.Pack(avs.CallerAddress.String(), avs.AvsName) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil } func (p Precompile) EmitOperatorJoined(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { - arguments := p.ABI.Events[EventTypeOperatorJoined].Inputs - return p.emitEvent(ctx, stateDB, EventTypeOperatorJoined, arguments, - params.AvsAddress, - params.OperatorAddress.String()) + event := p.ABI.Events[EventTypeOperatorJoined] + topics := make([]common.Hash, 2) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(params.AvsAddress) + if err != nil { + return err + } + + // Prepare the event data: operatorAddress + arguments := abi.Arguments{event.Inputs[1]} + packed, err := arguments.Pack(params.OperatorAddress.String()) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil } func (p Precompile) EmitOperatorOuted(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.OperatorOptParams) error { - arguments := p.ABI.Events[EventTypeOperatorLeft].Inputs - return p.emitEvent(ctx, stateDB, EventTypeOperatorLeft, arguments, - params.AvsAddress, - params.OperatorAddress.String()) + event := p.ABI.Events[EventTypeOperatorLeft] + topics := make([]common.Hash, 2) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(params.AvsAddress) + if err != nil { + return err + } + + // Prepare the event data: operatorAddress + arguments := abi.Arguments{event.Inputs[1]} + packed, err := arguments.Pack(params.OperatorAddress.String()) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil } func (p Precompile) EmitTaskCreated(ctx sdk.Context, stateDB vm.StateDB, task *avstypes.TaskInfoParams) error { - arguments := p.ABI.Events[EventTypeTaskCreated].Inputs - return p.emitEvent(ctx, stateDB, EventTypeTaskCreated, arguments, - task.CallerAddress.String(), - task.TaskID, - task.TaskContractAddress, - task.TaskName, - task.Hash, - task.TaskResponsePeriod, - task.TaskChallengePeriod, - task.ThresholdPercentage, - task.TaskStatisticalPeriod) + event := p.ABI.Events[EventTypeTaskCreated] + topics := make([]common.Hash, 3) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(task.TaskContractAddress) + if err != nil { + return err + } + + topics[2], err = cmn.MakeTopic(task.TaskID) + if err != nil { + return err + } + // Prepare the event data:sender,name, hash, taskResponsePeriod,taskChallengePeriod, + // thresholdPercentage,taskStatisticalPeriod + arguments := abi.Arguments{ + event.Inputs[2], event.Inputs[3], event.Inputs[4], + event.Inputs[5], event.Inputs[6], event.Inputs[7], event.Inputs[8], + } + packed, err := arguments.Pack(task.CallerAddress.String(), task.TaskName, task.Hash, task.TaskResponsePeriod, task.TaskChallengePeriod, + task.ThresholdPercentage, task.TaskStatisticalPeriod) + if err != nil { + return err + } + + stateDB.AddLog(ðtypes.Log{ + Address: p.Address(), + Topics: topics, + Data: packed, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil } func (p Precompile) EmitChallengeInitiated(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.ChallengeParams) error { @@ -121,12 +253,34 @@ func (p Precompile) EmitPublicKeyRegistered(ctx sdk.Context, stateDB vm.StateDB, } func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.StateDB, params *avstypes.TaskResultParams) error { - arguments := p.ABI.Events[EventTypeTaskSubmittedByOperator].Inputs - return p.emitEvent(ctx, stateDB, EventTypeTaskSubmittedByOperator, arguments, - params.CallerAddress.String(), - params.TaskID, - params.TaskResponse, - params.BlsSignature, - params.TaskContractAddress, - params.Phase) + event := p.ABI.Events[EventTypeTaskSubmittedByOperator] + topics := make([]common.Hash, 3) + + // The first topic is always the signature of the event. + topics[0] = event.ID + + var err error + topics[1], err = cmn.MakeTopic(params.TaskContractAddress) + if err != nil { + return err + } + + topics[2], err = cmn.MakeTopic(params.TaskID) + if err != nil { + return err + } + // Prepare the event data:sender,TaskResponse, BlsSignature, Phase + arguments := abi.Arguments{event.Inputs[2], event.Inputs[3], event.Inputs[4], event.Inputs[5]} + packed, err := arguments.Pack(params.CallerAddress.String(), params.TaskResponse, params.BlsSignature, params.Phase) + 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/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index 879f2b9b9..8f91b53a1 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -91,6 +91,7 @@ func (k *Keeper) GetAVSInfoByTaskAddress(ctx sdk.Context, taskAddr string) types if taskAddr == "" || taskAddr == (common.Address{}).String() { return avs } + taskAddr = strings.ToLower(taskAddr) k.IterateAVSInfo(ctx, func(_ int64, avsInfo types.AVSInfo) (stop bool) { if taskAddr == avsInfo.GetTaskAddr() { avs = avsInfo diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index 2063255d8..3ab1ed807 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -5,6 +5,7 @@ import ( assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types" "github.com/ethereum/go-ethereum/common" "math/big" + "strings" "time" "github.com/ExocoreNetwork/exocore/x/avs/types" @@ -86,7 +87,7 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_Register() { info, err := suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddres) suite.NoError(err) - suite.Equal(avsAddres, info.GetInfo().AvsAddress) + suite.Equal(strings.ToLower(avsAddres), info.GetInfo().AvsAddress) err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, avsParams) suite.Error(err) @@ -119,7 +120,7 @@ func (suite *AVSTestSuite) TestUpdateAVSInfo_DeRegister() { err = suite.App.AVSManagerKeeper.UpdateAVSInfo(suite.Ctx, avsParams) suite.NoError(err) info, err := suite.App.AVSManagerKeeper.GetAVSInfo(suite.Ctx, avsAddress) - suite.Equal(avsAddress, info.GetInfo().AvsAddress) + suite.Equal(strings.ToLower(avsAddress), info.GetInfo().AvsAddress) epoch, _ := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, epochstypes.DayEpochID) // Numbered loops for epoch ends From 8b3468f06a663ef6574c6a85aa8030e30e531f09 Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 31 Oct 2024 16:56:25 +0800 Subject: [PATCH 22/24] update hex address format --- precompiles/avs/query.go | 5 +++-- precompiles/avs/tx.go | 4 ++++ x/operator/keeper/operator.go | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index dbf99060f..00cb46213 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "strconv" + "strings" errorsmod "cosmossdk.io/errors" @@ -66,7 +67,7 @@ func (p Precompile) GetOptedInOperatorAccAddrs( return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", addr) } - list, err := p.avsKeeper.GetOperatorKeeper().GetOptedInOperatorListByAVS(ctx, addr.String()) + list, err := p.avsKeeper.GetOperatorKeeper().GetOptedInOperatorListByAVS(ctx, strings.ToLower(addr.String())) if err != nil { return nil, err } @@ -115,7 +116,7 @@ func (p Precompile) GetOperatorOptedUSDValue( if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", operatorAddr) } - amount, err := p.avsKeeper.GetOperatorKeeper().GetOperatorOptedUSDValue(ctx, avsAddr.String(), operatorAddr) + amount, err := p.avsKeeper.GetOperatorKeeper().GetOperatorOptedUSDValue(ctx, strings.ToLower(avsAddr.String()), operatorAddr) if err != nil { if errors.Is(err, avstype.ErrNoKeyInTheStore) { return method.Outputs.Pack(common.Big0) diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index d9eba78fd..4929fed78 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -360,6 +360,10 @@ func (p Precompile) OperatorSubmitTask( } resultParams.TaskResponse = taskResponse + if len(taskResponse) == 0 { + resultParams.TaskResponse = nil + } + blsSignature, ok := args[3].([]byte) if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", blsSignature) diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 86a9975ad..97b073acd 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "strings" errorsmod "cosmossdk.io/errors" @@ -106,7 +107,7 @@ func (k *Keeper) HandleOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, return errorsmod.Wrap(err, "HandleOptedInfo: error occurred when parse acc address from Bech32") } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) - infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) + infoKey := assetstype.GetJoinedStoreKey(operatorAddr, strings.ToLower(avsAddr)) // get info from the store value := store.Get(infoKey) if value == nil { @@ -130,7 +131,7 @@ func (k *Keeper) SetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string, inf if err != nil { return assetstype.ErrInvalidOperatorAddr } - infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) + infoKey := assetstype.GetJoinedStoreKey(operatorAddr, strings.ToLower(avsAddr)) bz := k.cdc.MustMarshal(info) store.Set(infoKey, bz) @@ -143,7 +144,7 @@ func (k *Keeper) GetOptedInfo(ctx sdk.Context, operatorAddr, avsAddr string) (in return nil, errorsmod.Wrap(err, "GetOptedInfo: error occurred when parse acc address from Bech32") } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorOptedAVSInfo) - infoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) + infoKey := assetstype.GetJoinedStoreKey(operatorAddr, strings.ToLower(avsAddr)) value := store.Get(infoKey) if value == nil { return nil, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOptedInfo: operator is %s, avs address is %s", opAccAddr, avsAddr)) From f566312196ae5d4f8192973748bd90c5e6fbed90 Mon Sep 17 00:00:00 2001 From: trestin Date: Mon, 4 Nov 2024 14:14:21 +0800 Subject: [PATCH 23/24] format the address in lowercase for operator module --- x/operator/keeper/grpc_query.go | 3 ++- x/operator/keeper/impl_epoch_hook.go | 4 +--- x/operator/keeper/operator.go | 2 +- x/operator/keeper/operator_slash_state.go | 8 +++++--- x/operator/keeper/usd_value.go | 21 +++++++++++---------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index 1273cff3b..a66e53acb 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" "errors" + "strings" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" @@ -203,7 +204,7 @@ func (k *Keeper) QueryOperatorSlashInfo(goCtx context.Context, req *types.QueryO ctx := sdk.UnwrapSDKContext(goCtx) res := make([]*types.OperatorSlashInfoByID, 0) - slashPrefix := types.AppendMany(types.KeyPrefixOperatorSlashInfo, assetstype.GetJoinedStoreKeyForPrefix(req.OperatorAddr, req.AvsAddress)) + slashPrefix := types.AppendMany(types.KeyPrefixOperatorSlashInfo, assetstype.GetJoinedStoreKeyForPrefix(req.OperatorAddr, strings.ToLower(req.AvsAddress))) store := prefix.NewStore(ctx.KVStore(k.storeKey), slashPrefix) pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error { ret := &types.OperatorSlashInfo{} diff --git a/x/operator/keeper/impl_epoch_hook.go b/x/operator/keeper/impl_epoch_hook.go index 8815d8909..432b6333f 100644 --- a/x/operator/keeper/impl_epoch_hook.go +++ b/x/operator/keeper/impl_epoch_hook.go @@ -1,8 +1,6 @@ package keeper import ( - "strings" - epochstypes "github.com/ExocoreNetwork/exocore/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -32,7 +30,7 @@ func (wrapper EpochsHooksWrapper) AfterEpochEnd( avsList := wrapper.keeper.avsKeeper.GetEpochEndAVSs(ctx, epochIdentifier, epochNumber) for _, avs := range avsList { // avs address is checksummed hex, we should convert it to lowercase - err := wrapper.keeper.UpdateVotingPower(ctx, strings.ToLower(avs)) + err := wrapper.keeper.UpdateVotingPower(ctx, avs) if err != nil { ctx.Logger().Error("Failed to update voting power", "avs", avs, "error", err) // Handle the error gracefully, continue to the next AVS diff --git a/x/operator/keeper/operator.go b/x/operator/keeper/operator.go index 97b073acd..72f292ddc 100644 --- a/x/operator/keeper/operator.go +++ b/x/operator/keeper/operator.go @@ -236,7 +236,7 @@ func (k *Keeper) GetOptedInOperatorListByAVS(ctx sdk.Context, avsAddr string) ([ if err != nil { return nil, err } - if avsAddr == keys[1] { + if strings.ToLower(avsAddr) == keys[1] { operatorList = append(operatorList, keys[0]) } } diff --git a/x/operator/keeper/operator_slash_state.go b/x/operator/keeper/operator_slash_state.go index 683fd8cef..72296f7c7 100644 --- a/x/operator/keeper/operator_slash_state.go +++ b/x/operator/keeper/operator_slash_state.go @@ -1,6 +1,8 @@ package keeper import ( + "strings" + assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" errorsmod "cosmossdk.io/errors" @@ -23,7 +25,7 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, if err != nil { return assetstype.ErrInvalidOperatorAddr } - slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) + slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, strings.ToLower(avsAddr), slashID) if store.Has(slashInfoKey) { return errorsmod.Wrapf(operatortypes.ErrSlashInfoExist, "slashInfoKey:%s", slashInfoKey) } @@ -54,7 +56,7 @@ func (k *Keeper) UpdateOperatorSlashInfo(ctx sdk.Context, operatorAddr, avsAddr, // Additionally, it might be used when implementing the veto function func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, slashID string) (changeState *operatortypes.OperatorSlashInfo, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) - slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr, slashID) + slashInfoKey := assetstype.GetJoinedStoreKey(operatorAddr, strings.ToLower(avsAddr), slashID) value := store.Get(slashInfoKey) if value == nil { return nil, errorsmod.Wrapf(operatortypes.ErrNoKeyInTheStore, "GetOperatorSlashInfo: key is %s", slashInfoKey) @@ -67,7 +69,7 @@ func (k *Keeper) GetOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr, sl // AllOperatorSlashInfo return all slash information for the specified operator and AVS func (k *Keeper) AllOperatorSlashInfo(ctx sdk.Context, avsAddr, operatorAddr string) (map[string]*operatortypes.OperatorSlashInfo, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixOperatorSlashInfo) - prefix := assetstype.GetJoinedStoreKey(operatorAddr, avsAddr) + prefix := assetstype.GetJoinedStoreKey(operatorAddr, strings.ToLower(avsAddr)) ret := make(map[string]*operatortypes.OperatorSlashInfo, 0) iterator := sdk.KVStorePrefixIterator(store, prefix) diff --git a/x/operator/keeper/usd_value.go b/x/operator/keeper/usd_value.go index fc1fdb5f2..16fb42e44 100644 --- a/x/operator/keeper/usd_value.go +++ b/x/operator/keeper/usd_value.go @@ -3,6 +3,7 @@ package keeper import ( "errors" "fmt" + "strings" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" delegationkeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" @@ -27,7 +28,7 @@ func (k *Keeper) UpdateOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "UpdateOperatorUSDValue the operatorAddr is empty") } - key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(strings.ToLower(avsAddr), operatorAddr) usdInfo := operatortypes.OperatorOptedUSDValue{ SelfUSDValue: sdkmath.LegacyNewDec(0), @@ -62,7 +63,7 @@ func (k *Keeper) InitOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr str if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "InitOperatorUSDValue the operatorAddr is empty") } - key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(strings.ToLower(avsAddr), operatorAddr) if store.Has(key) { return errorsmod.Wrap(operatortypes.ErrKeyAlreadyExist, fmt.Sprintf("avsAddr operatorAddr is: %s, %s", avsAddr, operatorAddr)) } @@ -87,7 +88,7 @@ func (k *Keeper) DeleteOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s if operatorAddr == "" { return errorsmod.Wrap(operatortypes.ErrParameterInvalid, "DeleteOperatorUSDValue the operatorAddr is empty") } - key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(strings.ToLower(avsAddr), operatorAddr) store.Delete(key) return nil @@ -95,7 +96,7 @@ func (k *Keeper) DeleteOperatorUSDValue(ctx sdk.Context, avsAddr, operatorAddr s func (k *Keeper) DeleteAllOperatorsUSDValueForAVS(ctx sdk.Context, avsAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) - iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(avsAddr)) + iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(strings.ToLower(avsAddr))) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -126,7 +127,7 @@ func (k *Keeper) GetOperatorOptedUSDValue(ctx sdk.Context, avsAddr, operatorAddr if operatorAddr == "" { return operatortypes.OperatorOptedUSDValue{}, errorsmod.Wrap(operatortypes.ErrParameterInvalid, "GetOperatorOptedUSDValue the operatorAddr is empty") } - key = assetstype.GetJoinedStoreKey(avsAddr, operatorAddr) + key = assetstype.GetJoinedStoreKey(strings.ToLower(avsAddr), operatorAddr) value := store.Get(key) if value == nil { return operatortypes.OperatorOptedUSDValue{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetOperatorOptedUSDValue: key is %s", key)) @@ -147,7 +148,7 @@ func (k *Keeper) UpdateAVSUSDValue(ctx sdk.Context, avsAddr string, opAmount sdk return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, fmt.Sprintf("UpdateAVSUSDValue the opAmount is:%v", opAmount)) } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) - key := []byte(avsAddr) + key := []byte(strings.ToLower(avsAddr)) totalValue := operatortypes.DecValueField{Amount: sdkmath.LegacyNewDec(0)} value := store.Get(key) if value != nil { @@ -169,7 +170,7 @@ func (k *Keeper) SetAVSUSDValue(ctx sdk.Context, avsAddr string, amount sdkmath. return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, fmt.Sprintf("SetAVSUSDValue the amount is:%v", amount)) } store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) - key := []byte(avsAddr) + key := []byte(strings.ToLower(avsAddr)) setValue := operatortypes.DecValueField{Amount: amount} bz := k.cdc.MustMarshal(&setValue) store.Set(key, bz) @@ -178,7 +179,7 @@ func (k *Keeper) SetAVSUSDValue(ctx sdk.Context, avsAddr string, amount sdkmath. func (k *Keeper) DeleteAVSUSDValue(ctx sdk.Context, avsAddr string) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForAVS) - key := []byte(avsAddr) + key := []byte(strings.ToLower(avsAddr)) store.Delete(key) return nil } @@ -192,7 +193,7 @@ func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.Legacy operatortypes.KeyPrefixUSDValueForAVS, ) var ret operatortypes.DecValueField - key := []byte(avsAddr) + key := []byte(strings.ToLower(avsAddr)) value := store.Get(key) if value == nil { return sdkmath.LegacyDec{}, errorsmod.Wrap(operatortypes.ErrNoKeyInTheStore, fmt.Sprintf("GetAVSUSDValue: key is %s", key)) @@ -206,7 +207,7 @@ func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.Legacy // `isUpdate` is a flag to indicate whether the change of the state should be set to the store. func (k *Keeper) IterateOperatorsForAVS(ctx sdk.Context, avsAddr string, isUpdate bool, opFunc func(operator string, optedUSDValues *operatortypes.OperatorOptedUSDValue) error) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), operatortypes.KeyPrefixUSDValueForOperator) - iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(avsAddr)) + iterator := sdk.KVStorePrefixIterator(store, operatortypes.IterateOperatorsForAVSPrefix(strings.ToLower(avsAddr))) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { From 0c527a16f300661678acaea814607bb54eea305e Mon Sep 17 00:00:00 2001 From: trestin Date: Mon, 4 Nov 2024 17:40:32 +0800 Subject: [PATCH 24/24] fix type errors in ABI --- precompiles/avs/events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/precompiles/avs/events.go b/precompiles/avs/events.go index 679042c08..0bf1a5234 100644 --- a/precompiles/avs/events.go +++ b/precompiles/avs/events.go @@ -271,7 +271,7 @@ func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.Stat } // Prepare the event data:sender,TaskResponse, BlsSignature, Phase arguments := abi.Arguments{event.Inputs[2], event.Inputs[3], event.Inputs[4], event.Inputs[5]} - packed, err := arguments.Pack(params.CallerAddress.String(), params.TaskResponse, params.BlsSignature, params.Phase) + packed, err := arguments.Pack(params.CallerAddress.String(), params.TaskResponse, params.BlsSignature, uint8(params.Phase)) if err != nil { return err }