Skip to content

Commit

Permalink
add status api for proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT committed Aug 29, 2024
1 parent e4601d0 commit 34fadf8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions generic-operator-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
"github.com/Layr-Labs/eigensdk-go/logging"
sdktypes "github.com/Layr-Labs/eigensdk-go/types"
gethrpc "github.com/ethereum/go-ethereum/rpc"

"github.com/alt-research/avs-generic-aggregator/core/config"
"github.com/alt-research/avs-generic-aggregator/core/types"
Expand All @@ -28,6 +29,7 @@ type ProxyHashRpcServer struct {
chainIds map[string]uint32
workProofsBlockNumMod map[string]uint32
defaultAVSName string
genericOperatorAddr string
logger logging.Logger
// We use this rpc server as the handler for jsonrpc
// to make sure same as legacy operator 's api
Expand Down Expand Up @@ -79,6 +81,7 @@ func NewAlertProxyRpcServer(
avsCfgs: avsCfgsMap,
chainIds: chainIds,
workProofsBlockNumMod: workProofsBlockNumMod,
genericOperatorAddr: genericOperatorAddr,
}

// not need do this because we not need use this server impl
Expand Down Expand Up @@ -344,3 +347,35 @@ func (s *ProxyHashRpcServer) commitWorkProof(ctx context.Context, avsName string

return nil
}

type OperatorStatusAVSStatus struct {
AVSName string `json:"avs_name"`
AVSContractAddress string `json:"avs_contract_address"`
OperatorId string `json:"operator_id"`
OperatorAddress string `json:"operator_address"`
}

type OperatorStatusResponse struct {
NodeName string `json:"node_name"`
Version string `json:"version"`
Avs []OperatorStatusAVSStatus `json:"avs"`
}

func (s *ProxyHashRpcServer) OperatorStatus(ctx context.Context) (OperatorStatusResponse, error) {
s.logger.Debug("OperatorStatus")

res := OperatorStatusResponse{}

client, err := gethrpc.DialContext(ctx, s.genericOperatorAddr)
if err != nil {
return res, errors.Wrapf(err, "dial OperatorStatus connection failed")
}

err = client.CallContext(
ctx, &res, "operator_operatorStatus")
if err != nil {
return res, errors.Wrapf(err, "call OperatorStatus failed")
}

return res, nil
}

0 comments on commit 34fadf8

Please sign in to comment.