Skip to content

Commit

Permalink
update proto enum phase
Browse files Browse the repository at this point in the history
  • Loading branch information
trestinlsd committed Oct 29, 2024
1 parent 4bbf229 commit 33875a4
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 169 deletions.
4 changes: 2 additions & 2 deletions precompiles/avs/IAVSManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion precompiles/avs/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 4 additions & 7 deletions proto/exocore/avs/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ 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.
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.
Expand All @@ -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.
Expand Down
64 changes: 28 additions & 36 deletions proto/exocore/avs/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, int64> 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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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 {
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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 {
Expand All @@ -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;

Check failure on line 230 in proto/exocore/avs/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "7" with name "phase" on message "TaskResultInfo" changed option "json_name" from "stage" to "phase".

Check failure on line 230 in proto/exocore/avs/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "7" on message "TaskResultInfo" changed type from "string" to "enum".

Check failure on line 230 in proto/exocore/avs/v1/tx.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "7" on message "TaskResultInfo" changed name from "stage" to "phase".
}

Expand All @@ -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;
}
Expand All @@ -256,19 +248,19 @@ 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.
rpc RegisterAVSTask(RegisterAVSTaskReq) returns (RegisterAVSTaskResponse) {
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";
};
}
2 changes: 1 addition & 1 deletion x/avs/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion x/avs/keeper/avs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"
"strconv"
"strings"

errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
Expand Down Expand Up @@ -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
})
Expand Down
Loading

0 comments on commit 33875a4

Please sign in to comment.