Skip to content

Commit

Permalink
added node api to operator
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Oct 27, 2023
1 parent e255ec6 commit ac33620
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions config-files/operator-docker-compose.anvil.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bls_private_key_store_path: tests/keys/test.bls.key.json
aggregator_server_ip_port_address: incredible-squaring-aggregator:8090
eigen_metrics_ip_port_address: 0.0.0.0:9090
use_instrumented_eth_client: false
node_api_ip_port_address: localhost:9010

# we need to register the operator on startup when running the docker compose file
# because unfortunately we cannot register the operator previously and save it in the anvil json file
Expand Down
1 change: 1 addition & 0 deletions config-files/operator.anvil.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ bls_private_key_store_path: tests/keys/test.bls.key.json
aggregator_server_ip_port_address: localhost:8090
eigen_metrics_ip_port_address: localhost:9090
use_instrumented_eth_client: false
node_api_ip_port_address: localhost:9010

register_operator_on_startup: false
8 changes: 8 additions & 0 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ import (
sdkmetrics "github.com/Layr-Labs/eigensdk-go/metrics"
"github.com/Layr-Labs/eigensdk-go/metrics/collectors/economic"
rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls"
"github.com/Layr-Labs/eigensdk-go/nodeapi"
"github.com/Layr-Labs/eigensdk-go/signer"
sdktypes "github.com/Layr-Labs/eigensdk-go/types"
)

const AVS_NAME = "incredible-squaring"
const SEM_VER = "0.0.1"

type Operator struct {
logger logging.Logger
Expand All @@ -43,6 +45,7 @@ type Operator struct {
// writing to the chain should be done via the cli only
metricsReg *prometheus.Registry
metrics metrics.Metrics
nodeApi *nodeapi.NodeApi
avsWriter *chainio.AvsWriter
avsReader chainio.AvsReaderer
avsSubscriber chainio.AvsSubscriberer
Expand Down Expand Up @@ -76,6 +79,9 @@ func NewOperatorFromConfig(c types.NodeConfig) (*Operator, error) {
eigenMetrics := sdkmetrics.NewEigenMetrics(AVS_NAME, c.EigenMetricsIpPortAddress, reg, logger)
avsAndEigenMetrics := metrics.NewAvsAndEigenMetrics(AVS_NAME, eigenMetrics, reg)

// Setup Node Api
nodeApi := nodeapi.NewNodeApi(AVS_NAME, SEM_VER, c.NodeApiIpPortAddress, logger)

var ethRpcClient, ethWsClient eth.EthClient
if c.UseInstrumentedEthClient {
rpcCallsCollector := rpccalls.NewCollector(AVS_NAME, reg)
Expand Down Expand Up @@ -224,6 +230,7 @@ func NewOperatorFromConfig(c types.NodeConfig) (*Operator, error) {
logger: logger,
metricsReg: reg,
metrics: avsAndEigenMetrics,
nodeApi: nodeApi,
ethClient: ethRpcClient,
avsWriter: avsWriter,
avsReader: avsReader,
Expand Down Expand Up @@ -276,6 +283,7 @@ func (o *Operator) Start(ctx context.Context) error {

o.logger.Infof("Starting operator.")

o.nodeApi.Start()
metricsErrChan := o.metrics.Start(ctx, o.metricsReg)

// TODO(samlaf): wrap this call with increase in avs-node-spec metric
Expand Down
1 change: 1 addition & 0 deletions types/avs_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ type NodeConfig struct {
EigenMetricsIpPortAddress string `yaml:"eigen_metrics_ip_port_address"`
RegisterOperatorOnStartup bool `yaml:"register_operator_on_startup"`
UseInstrumentedEthClient bool `yaml:"use_instrumented_eth_client"`
NodeApiIpPortAddress string `yaml:"node_api_ip_port_address"`
}

0 comments on commit ac33620

Please sign in to comment.