Skip to content

Commit

Permalink
Improve AVS registering flow (#93)
Browse files Browse the repository at this point in the history
* feat: Register operator in AVS only if not already registered

* feat: Deposit in mock strategy only if address is not zeroed

* feat: Set register_operator_on_startup to true as default

* feat: Add info log if operator was already registered in avs
  • Loading branch information
Hyodar authored Apr 18, 2024
1 parent 24293cd commit 14fb488
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,19 +459,30 @@ func (o *Operator) registerOperatorOnStartup(
o.logger.Infof("Registered operator with eigenlayer")
}

// TODO(samlaf): shouldn't hardcode number here
amount := big.NewInt(1000)
err = o.DepositIntoStrategy(mockTokenStrategyAddr, amount)
if err != nil {
o.logger.Fatal("Error depositing into strategy", "err", err)
if mockTokenStrategyAddr.Cmp(common.Address{}) != 0 {
// TODO(samlaf): shouldn't hardcode number here
amount := big.NewInt(1000)
err = o.DepositIntoStrategy(mockTokenStrategyAddr, amount)
if err != nil {
o.logger.Fatal("Error depositing into strategy", "err", err)
}
o.logger.Infof("Deposited %s into strategy %s", amount, mockTokenStrategyAddr)
}
o.logger.Infof("Deposited %s into strategy %s", amount, mockTokenStrategyAddr)

err = o.avsManager.RegisterOperatorWithAvs(o.ethClient, operatorEcdsaPrivateKey, o.blsKeypair)
isOperatorRegistered, err := o.avsManager.avsReader.IsOperatorRegistered(&bind.CallOpts{}, o.operatorAddr)
if err != nil {
o.logger.Fatal("Error registering operator with avs", "err", err)
o.logger.Fatal("Error checking if operator is registered", "err", err)
}

if !isOperatorRegistered {
err = o.avsManager.RegisterOperatorWithAvs(o.ethClient, operatorEcdsaPrivateKey, o.blsKeypair)
if err != nil {
o.logger.Fatal("Error registering operator with avs", "err", err)
}
o.logger.Infof("Registered operator with avs")
} else {
o.logger.Infof("Operator already registered with avs")
}
o.logger.Infof("Registered operator with avs")
}

func (o *Operator) BlsPubkeyG1() *bls.G1Point {
Expand Down
2 changes: 1 addition & 1 deletion setup/operator/config/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enable_metrics: true
node_api_ip_port_address: near-sffl-operator0:9010
enable_node_api: true

register_operator_on_startup: false
register_operator_on_startup: true
token_strategy_addr: 0x0000000000000000000000000000000000000000

near_da_indexer_rmq_ip_port_address: amqp://rmq:5672
Expand Down

0 comments on commit 14fb488

Please sign in to comment.