From 4ee8f684a292627357b64b918cbc6cbc6c0a331b Mon Sep 17 00:00:00 2001 From: devin Date: Mon, 17 Feb 2025 15:59:08 +0800 Subject: [PATCH] fix lint err --- precompiles/avs/IAVSManager.sol | 8 ++++---- precompiles/avs/abi.json | 10 +++++----- precompiles/avs/query.go | 13 +++++-------- precompiles/avs/query_test.go | 2 +- precompiles/avs/types.go | 4 ++-- x/avs/keeper/keeper.go | 8 ++++---- x/avs/types/utils.go | 2 +- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index ff766b17c..bb806b1d2 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -53,7 +53,7 @@ struct TaskInfo { address taskContractAddress; string name; bytes hash; - uint64 taskId; + uint64 taskID; uint64 taskResponsePeriod; uint64 taskStatisticalPeriod; uint64 taskChallengePeriod; @@ -85,13 +85,13 @@ interface IAVSManager { event OperatorLeft(address indexed avsAddress, address sender); event TaskCreated( address indexed taskContractAddress, - uint64 indexed taskId, + uint64 indexed taskID, address sender, string name, bytes hash, uint64 taskResponsePeriod, uint64 taskChallengePeriod, - uint64 thresholdPercentage, + uint8 thresholdPercentage, uint64 taskStatisticalPeriod ); event ChallengeInitiated( @@ -100,7 +100,7 @@ interface IAVSManager { event PublicKeyRegistered(address sender, address avsAddress); event TaskSubmittedByOperator( address indexed taskContractAddress, - uint64 indexed taskId, + uint64 indexed taskID, address sender, bytes taskResponse, bytes blsSignature, diff --git a/precompiles/avs/abi.json b/precompiles/avs/abi.json index 288739739..4ccdbf032 100644 --- a/precompiles/avs/abi.json +++ b/precompiles/avs/abi.json @@ -180,7 +180,7 @@ { "indexed": true, "internalType": "uint64", - "name": "taskId", + "name": "taskID", "type": "uint64" }, { @@ -215,9 +215,9 @@ }, { "indexed": false, - "internalType": "uint64", + "internalType": "uint8", "name": "thresholdPercentage", - "type": "uint64" + "type": "uint8" }, { "indexed": false, @@ -241,7 +241,7 @@ { "indexed": true, "internalType": "uint64", - "name": "taskId", + "name": "taskID", "type": "uint64" }, { @@ -590,7 +590,7 @@ }, { "internalType": "uint64", - "name": "taskId", + "name": "taskID", "type": "uint64" }, { diff --git a/precompiles/avs/query.go b/precompiles/avs/query.go index 398489588..8296beaf6 100644 --- a/precompiles/avs/query.go +++ b/precompiles/avs/query.go @@ -73,8 +73,10 @@ func (p Precompile) GetOptedInOperatorAccAddresses( } list, err := p.avsKeeper.GetOperatorKeeper().GetOptedInOperatorListByAVS(ctx, strings.ToLower(avsaddress.String())) - - var commonAddressList []common.Address + if err != nil { + return nil, err + } + commonAddressList := make([]common.Address, 0) for _, operatorAddressStr := range list { acc, err := sdk.AccAddressFromBech32(operatorAddressStr) if err != nil { @@ -83,10 +85,6 @@ func (p Precompile) GetOptedInOperatorAccAddresses( operatorAddress := common.BytesToAddress(acc) commonAddressList = append(commonAddressList, operatorAddress) } - - if err != nil { - return nil, err - } return method.Outputs.Pack(commonAddressList) } @@ -224,7 +222,7 @@ func (p Precompile) GetTaskInfo( TaskContractAddress: common.HexToAddress(task.TaskContractAddress), Name: task.Name, Hash: task.Hash, - TaskId: task.TaskId, + TaskID: task.TaskId, TaskResponsePeriod: task.TaskResponsePeriod, TaskStatisticalPeriod: task.TaskStatisticalPeriod, TaskChallengePeriod: task.TaskChallengePeriod, @@ -242,7 +240,6 @@ func (p Precompile) GetTaskInfo( EligibleSlashOperators: p.stringToAddress(task.EligibleSlashOperators), } return method.Outputs.Pack(result) - } func ParseActivePower(list []*avstype.OperatorActivePowerInfo) []OperatorActivePower { diff --git a/precompiles/avs/query_test.go b/precompiles/avs/query_test.go index 6709a5b55..cf4a74b8a 100644 --- a/precompiles/avs/query_test.go +++ b/precompiles/avs/query_test.go @@ -535,7 +535,7 @@ func (suite *AVSManagerPrecompileSuite) TestGetTaskInfo() { TaskContractAddress common.Address `json:"taskContractAddress"` Name string `json:"name"` Hash []byte `json:"hash"` - TaskId uint64 `json:"taskId"` + TaskID uint64 `json:"taskID"` TaskResponsePeriod uint64 `json:"taskResponsePeriod"` TaskStatisticalPeriod uint64 `json:"taskStatisticalPeriod"` TaskChallengePeriod uint64 `json:"taskChallengePeriod"` diff --git a/precompiles/avs/types.go b/precompiles/avs/types.go index 486af3f20..5827ddc24 100644 --- a/precompiles/avs/types.go +++ b/precompiles/avs/types.go @@ -147,7 +147,7 @@ func (p Precompile) GetTaskParamsFromInputs(_ sdk.Context, args []interface{}) ( if !ok || thresholdPercentage > 100 { return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 5, "uint64", thresholdPercentage) } - taskParams.ThresholdPercentage = uint64(thresholdPercentage) + taskParams.ThresholdPercentage = thresholdPercentage taskStatisticalPeriod, ok := args[6].(uint64) if !ok { @@ -210,7 +210,7 @@ type TaskInfo struct { TaskContractAddress common.Address Name string Hash []byte - TaskId uint64 + TaskID uint64 TaskResponsePeriod uint64 TaskStatisticalPeriod uint64 TaskChallengePeriod uint64 diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index 007f9d9a8..7e27b7dd5 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -266,7 +266,7 @@ func (k Keeper) CreateAVSTask(ctx sdk.Context, params *types.TaskInfoParams) (ui TaskContractAddress: strings.ToLower(params.TaskContractAddress.String()), TaskId: params.TaskID, TaskChallengePeriod: params.TaskChallengePeriod, - ThresholdPercentage: params.ThresholdPercentage, + ThresholdPercentage: uint64(params.ThresholdPercentage), TaskResponsePeriod: params.TaskResponsePeriod, TaskStatisticalPeriod: params.TaskStatisticalPeriod, StartingEpoch: uint64(epoch.CurrentEpoch + 1), @@ -430,7 +430,7 @@ func (k Keeper) RaiseAndResolveChallenge(ctx sdk.Context, params *types.Challeng return errorsmod.Wrap( types.ErrInconsistentParams, fmt.Sprintf("Task response does not match the one recorded,task addr: %s ,(TaskContractAddress: %s)"+ - ",(TaskId: %d),(TaskResponseHash: %s)", + ",(TaskID: %d),(TaskResponseHash: %s)", params.OperatorAddress, params.TaskContractAddress, params.TaskID, params.TaskResponseHash), ) } @@ -581,7 +581,7 @@ func (k Keeper) SubmitTaskResult(ctx sdk.Context, addr string, info *types.TaskR return errorsmod.Wrap( types.ErrInconsistentParams, fmt.Sprintf("SetTaskResultInfo: invalid param OperatorAddress: %s ,(TaskContractAddress: %s)"+ - ",(TaskId: %d),(BlsSignature: %s)", + ",(TaskID: %d),(BlsSignature: %s)", info.OperatorAddress, info.TaskContractAddress, info.TaskId, info.BlsSignature), ) } @@ -608,7 +608,7 @@ func (k Keeper) SubmitTaskResult(ctx sdk.Context, addr string, info *types.TaskR if err != nil || info.TaskId != resp.TaskID { return errorsmod.Wrap( types.ErrInconsistentParams, - fmt.Sprintf("SetTaskResultInfo: invalid TaskId param value:%s", info.TaskResponse), + fmt.Sprintf("SetTaskResultInfo: invalid TaskID param value:%s", info.TaskResponse), ) } // check bls sig diff --git a/x/avs/types/utils.go b/x/avs/types/utils.go index ea8bdb08e..275b90b36 100644 --- a/x/avs/types/utils.go +++ b/x/avs/types/utils.go @@ -25,7 +25,7 @@ type TaskInfoParams struct { TaskResponsePeriod uint64 `json:"task_response_period"` TaskStatisticalPeriod uint64 `json:"task_statistical_period"` TaskChallengePeriod uint64 `json:"task_challenge_period"` - ThresholdPercentage uint64 `json:"threshold_percentage"` + ThresholdPercentage uint8 `json:"threshold_percentage"` StartingEpoch uint64 `json:"starting_epoch"` OperatorAddress sdk.AccAddress `json:"operator_address"` TaskResponseHash string `json:"task_response_hash"`