Skip to content

Commit

Permalink
add a cli to query the opted info for specified operator and avs
Browse files Browse the repository at this point in the history
  • Loading branch information
TimmyExogenous committed Oct 15, 2024
1 parent 39902dd commit 082e5eb
Show file tree
Hide file tree
Showing 6 changed files with 462 additions and 95 deletions.
3 changes: 3 additions & 0 deletions local_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
LOCAL_ADDRESS_HEX=0x$(exocored keys parse "$LOCAL_ADDRESS_EXO" --output json | jq -r .bytes | tr '[:upper:]' '[:lower:]')
CONSENSUS_KEY=$(exocored keys consensus-pubkey-to-bytes --keyring-backend "$KEYRING" --home "$HOMEDIR" --output json | jq -r .bytes32)

echo "the local operator address is $LOCAL_ADDRESS_EXO"
echo "the dogfood AVS address is $AVS_ADDRESS"

# Change parameter token denominations to hua
jq '.app_state["crisis"]["constant_fee"]["denom"]="hua"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="hua"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
Expand Down
17 changes: 16 additions & 1 deletion proto/exocore/operator/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ message QueryOperatorUSDValueRequest {
// QueryOperatorUSDValueResponse is the response to obtain the USD value for operator.
message QueryOperatorUSDValueResponse {
// usd_info includes the self and total staking for the operator and AVS
OperatorOptedUSDValue usd_values = 1
OperatorOptedUSDValue usd_values = 1
[(gogoproto.customname) = "USDValues"];
}

Expand Down Expand Up @@ -213,6 +213,14 @@ message QueryAllAVSsByOperatorResponse {
// avs_list is a list of avs addresses .
repeated string avs_list = 1;
}

// QueryOptInfoRequest is the request to obtain the opted information of specified operator
// and AVS
message QueryOptInfoRequest {
// details is the operator and AVS address
OperatorAVSAddressDetails details = 1;
}

// Query defines the gRPC querier service.
service Query {
// QueryOperatorInfo queries the operator information.
Expand Down Expand Up @@ -294,4 +302,11 @@ service Query {
get: "/exocore/operator/v1/opt/avs_list/{operator}"
};
}

// QueryOptInfo queries specified opted information.
rpc QueryOptInfo(QueryOptInfoRequest) returns (OptedInfo) {
option (google.api.http) = {
get: "/exocore/operator/v1/opt_info"
};
}
}
46 changes: 42 additions & 4 deletions x/operator/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func GetQueryCmd() *cobra.Command {
QueryOperatorSlashInfo(),
QueryAllOperatorsWithOptInAVS(),
QueryAllAVSsByOperator(),
GetOptInfo(),
)
return cmd
}
Expand Down Expand Up @@ -314,10 +315,11 @@ func QueryAVSUSDValue() *cobra.Command {
// QueryOperatorSlashInfo queries the slash information for the specified operator and AVS
func QueryOperatorSlashInfo() *cobra.Command {
cmd := &cobra.Command{
Use: "QueryOperatorSlashInfo <operatorAddr> <avsAddr>",
Short: "Get the the slash information for the operator",
Long: "Get the the slash information for the operator",
Args: cobra.ExactArgs(2),
Use: "QueryOperatorSlashInfo <operatorAddr> <avsAddr>",
Short: "Get the the slash information for the operator",
Long: "Get the the slash information for the operator",
Example: "exocored query operator QueryOperatorSlashInfo exo1c5x7mxphvgavjhu0au9jjqnfqcyspevtyy27mz 0xaa089ba103f765fcea44808bd3d4073523254c57",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
_, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand Down Expand Up @@ -415,3 +417,39 @@ func QueryAllAVSsByOperator() *cobra.Command {
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

// GetOptInfo queries opt info
func GetOptInfo() *cobra.Command {
cmd := &cobra.Command{
Use: "GetOptInfo <operatorAddr> <avsAddr>",
Short: "Get opt info",
Long: "Get opt info of specified operator and AVS",
Example: "exocored query operator GetOptInfo exo1c5x7mxphvgavjhu0au9jjqnfqcyspevtyy27mz 0xaa089ba103f765fcea44808bd3d4073523254c57",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
_, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return xerrors.Errorf("invalid operator address,err:%s", err.Error())
}
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := operatortypes.NewQueryClient(clientCtx)
req := &operatortypes.QueryOptInfoRequest{
Details: &operatortypes.OperatorAVSAddressDetails{
OperatorAddr: args[0],
AVSAddress: args[1],
},
}
res, err := queryClient.QueryOptInfo(context.Background(), req)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}
5 changes: 5 additions & 0 deletions x/operator/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,8 @@ func (k *Keeper) QueryAllAVSsByOperator(goCtx context.Context, req *types.QueryA
AvsList: avsList,
}, nil
}

func (k *Keeper) QueryOptInfo(goCtx context.Context, req *types.QueryOptInfoRequest) (*types.OptedInfo, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
return k.GetOptedInfo(ctx, req.Details.OperatorAddr, req.Details.AVSAddress)
}
Loading

0 comments on commit 082e5eb

Please sign in to comment.