From 6c7fe34a1b626fda911d1a774db96406aff03d25 Mon Sep 17 00:00:00 2001 From: trestin Date: Thu, 24 Oct 2024 16:34:36 +0800 Subject: [PATCH] fix some comments --- precompiles/avs/IAVSManager.sol | 3 +-- x/avs/keeper/keeper.go | 12 ++++++------ x/avs/types/types.go | 2 ++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 844ec046b..e15b81beb 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -27,7 +27,6 @@ interface IAVSManager { event TaskSubmittedByOperator(address indexed sender, uint64 taskID, string taskResponse, string blsSignature, string taskContractAddress, string stage, bool success); - enum SubmissionStage { Stage1, Stage2 } /// @dev Register AVS contract to EXO. /// @param sender The external address for calling this method. @@ -173,7 +172,7 @@ interface IAVSManager { bytes calldata taskResponse, bytes calldata blsSignature, address taskContractAddress, - SubmissionStage stage + string memory stage ) external returns (bool success); /// QUERIES diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 54c58a5a2..ad81f0dd8 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -228,27 +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 { - return 0, errorsmod.Wrap(err, "failed to get AVS USD value") + return types.InvalidTaskID, errorsmod.Wrap(err, "failed to get AVS USD value") } if taskPowerTotal.IsZero() || taskPowerTotal.IsNegative() { - return 0, errorsmod.Wrap(types.ErrVotingPowerIncorrect, fmt.Sprintf("the voting power of AVS is zero or negative, AVS address: %s", avsInfo.AvsAddress)) + 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 { 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