From 507255b783b3db72b515887c1fb3c49f0ab1cd1b Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Mon, 20 May 2024 13:11:19 -0300 Subject: [PATCH 01/12] Remove duplicated imports --- operator/operator.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/operator/operator.go b/operator/operator.go index 0bef2e37..1276501e 100644 --- a/operator/operator.go +++ b/operator/operator.go @@ -21,7 +21,6 @@ import ( "github.com/Layr-Labs/eigensdk-go/nodeapi" "github.com/Layr-Labs/eigensdk-go/signerv2" eigentypes "github.com/Layr-Labs/eigensdk-go/types" - sdktypes "github.com/Layr-Labs/eigensdk-go/types" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/prometheus/client_golang/prometheus" @@ -184,7 +183,7 @@ func NewOperatorFromConfig(c optypes.NodeConfig) (*Operator, error) { // We must register the economic metrics separately because they are exported metrics (from jsonrpc or subgraph calls) // and not instrumented metrics: see https://prometheus.io/docs/instrumenting/writing_clientlibs/#overall-structure - quorumNames := map[sdktypes.QuorumNum]string{ + quorumNames := map[eigentypes.QuorumNum]string{ 0: "quorum0", } economicMetricsCollector := economic.NewCollector( From 58c95ee7eb649980a533713a51a4399c8fe051b4 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Mon, 20 May 2024 14:32:09 -0300 Subject: [PATCH 02/12] Add `DeregisterOperator` method to `AVSManager` --- operator/avs_manager.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/operator/avs_manager.go b/operator/avs_manager.go index aba61dd7..632e9b53 100644 --- a/operator/avs_manager.go +++ b/operator/avs_manager.go @@ -14,6 +14,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/crypto/bls" sdklogging "github.com/Layr-Labs/eigensdk-go/logging" eigentypes "github.com/Layr-Labs/eigensdk-go/types" + eigenutils "github.com/Layr-Labs/eigensdk-go/chainio/utils" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -285,6 +286,21 @@ func (avsManager *AvsManager) RegisterOperatorWithAvs( return nil } +func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair,) (error) { + // TODO: 'QuorumNums' is hardcoded for now + quorumNumbers := eigentypes.QuorumNums{0} + pubKey := eigenutils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1()) + + _, err := avsManager.avsWriter.DeregisterOperator(context.Background(), quorumNumbers, pubKey) + if err != nil { + avsManager.logger.Errorf("Unable to deregister operator with avs registry coordinator") + return err + } + avsManager.logger.Infof("Deregistered operator with avs registry coordinator.") + + return nil +} + func (avsManager *AvsManager) IsOperatorRegistered(options *bind.CallOpts, address common.Address) (bool, error) { return avsManager.avsReader.IsOperatorRegistered(options, address) } From 6dd94ac2cd87131a07816a6a4c0ace1ecd9c464d Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Mon, 20 May 2024 14:32:50 -0300 Subject: [PATCH 03/12] Add `opt-out` command --- plugin/cmd/main.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugin/cmd/main.go b/plugin/cmd/main.go index b04385a3..f15380dc 100644 --- a/plugin/cmd/main.go +++ b/plugin/cmd/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "fmt" "log" "math/big" "os" @@ -11,7 +10,6 @@ import ( "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" "github.com/Layr-Labs/eigensdk-go/chainio/clients/wallet" "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" - regcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/RegistryCoordinator" "github.com/Layr-Labs/eigensdk-go/crypto/bls" sdkecdsa "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa" "github.com/Layr-Labs/eigensdk-go/logging" @@ -185,7 +183,15 @@ func plugin(ctx *cli.Context) { avsManager.RegisterOperatorWithAvs(ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) } else if operationType == "opt-out" { - fmt.Println("Opting out of slashing - unimplemented") + blsKeyPassword := ctx.GlobalString(BlsKeyPasswordFlag.Name) + + blsKeypair, err := bls.ReadPrivateKeyFromFile(avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) + if err != nil { + logger.Error("Failed to read bls private key", "err", err) + return + } + + avsManager.DeregisterOperator(blsKeypair) } else if operationType == "deposit" { starategyAddrString := ctx.GlobalString(StrategyAddrFlag.Name) if len(starategyAddrString) == 0 { @@ -231,9 +237,3 @@ func plugin(ctx *cli.Context) { } } -func pubKeyG1ToBN254G1Point(p *bls.G1Point) regcoord.BN254G1Point { - return regcoord.BN254G1Point{ - X: p.X.BigInt(new(big.Int)), - Y: p.Y.BigInt(new(big.Int)), - } -} From ca7970bc4e6be325977fc0978794dfcf8c1322c3 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 21 May 2024 10:34:12 -0300 Subject: [PATCH 04/12] Remove extra comma --- operator/avs_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operator/avs_manager.go b/operator/avs_manager.go index 632e9b53..a7eafbd0 100644 --- a/operator/avs_manager.go +++ b/operator/avs_manager.go @@ -286,7 +286,7 @@ func (avsManager *AvsManager) RegisterOperatorWithAvs( return nil } -func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair,) (error) { +func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair) (error) { // TODO: 'QuorumNums' is hardcoded for now quorumNumbers := eigentypes.QuorumNums{0} pubKey := eigenutils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1()) From 40b22e6375e1d33f5c2b1b41b4dac34499a4357c Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 21 May 2024 10:34:33 -0300 Subject: [PATCH 05/12] Print `DeregisterOperator` error --- operator/avs_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operator/avs_manager.go b/operator/avs_manager.go index a7eafbd0..782f9f6b 100644 --- a/operator/avs_manager.go +++ b/operator/avs_manager.go @@ -293,7 +293,7 @@ func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair) (error _, err := avsManager.avsWriter.DeregisterOperator(context.Background(), quorumNumbers, pubKey) if err != nil { - avsManager.logger.Errorf("Unable to deregister operator with avs registry coordinator") + avsManager.logger.Errorf("Unable to deregister operator with avs registry coordinator: %v", err) return err } avsManager.logger.Infof("Deregistered operator with avs registry coordinator.") From 64ae1852fad1a61cd67d3598fc0ffd7ee8e8f993 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 21 May 2024 10:53:39 -0300 Subject: [PATCH 06/12] Propagate errors in CLI commands --- plugin/cmd/main.go | 60 ++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/plugin/cmd/main.go b/plugin/cmd/main.go index f15380dc..4a4f1e06 100644 --- a/plugin/cmd/main.go +++ b/plugin/cmd/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "log" "math/big" "os" @@ -76,7 +77,7 @@ func main() { } } -func plugin(ctx *cli.Context) { +func plugin(ctx *cli.Context) error { goCtx := context.Background() logger, _ := logging.NewZapLogger(logging.Development) @@ -87,7 +88,7 @@ func plugin(ctx *cli.Context) { err := utils.ReadYamlConfig(configPath, &avsConfig) if err != nil { logger.Error("Failed to read config", "err", err) - return + return err } logger.Info("Starting with config", "avsConfig", avsConfig) @@ -105,12 +106,12 @@ func plugin(ctx *cli.Context) { ethHttpClient, err := eth.NewClient(avsConfig.EthRpcUrl) if err != nil { logger.Error("Failed to connect to eth client", "err", err) - return + return err } chainID, err := ethHttpClient.ChainID(goCtx) if err != nil { logger.Error("Failed to get chain ID", "err", err) - return + return err } signerV2, _, err := signerv2.SignerFromConfig(signerv2.Config{ KeystorePath: avsConfig.EcdsaPrivateKeyStorePath, @@ -118,17 +119,17 @@ func plugin(ctx *cli.Context) { }, chainID) if err != nil { logger.Error("Failed to create signer", "err", err) - return + return err } ecdsaPrivateKey, err := sdkecdsa.ReadKey(avsConfig.EcdsaPrivateKeyStorePath, ecdsaKeyPassword) if err != nil { logger.Error("Failed to read ecdsa private key", "err", err) - return + return err } clients, err := sdkclients.BuildAll(buildClientConfig, ecdsaPrivateKey, logger) if err != nil { logger.Error("Failed to create sdk clients", "err", err) - return + return err } avsReader, err := chainio.BuildAvsReader( common.HexToAddress(avsConfig.AVSRegistryCoordinatorAddress), @@ -138,12 +139,12 @@ func plugin(ctx *cli.Context) { ) if err != nil { logger.Error("Failed to create avs reader", "err", err) - return + return err } txSender, err := wallet.NewPrivateKeyWallet(ethHttpClient, signerV2, common.HexToAddress(avsConfig.OperatorAddress), logger) if err != nil { logger.Error("Failed to create tx sender", "err", err) - return + return err } txMgr := txmgr.NewSimpleTxManager(txSender, ethHttpClient, logger, common.HexToAddress(avsConfig.OperatorAddress)).WithGasLimitMultiplier(1.5) avsWriter, err := chainio.BuildAvsWriter( @@ -155,12 +156,12 @@ func plugin(ctx *cli.Context) { ) if err != nil { logger.Error("Failed to create avs writer", "err", err) - return + return err } avsManager, err := operator.NewAvsManager(&avsConfig, clients.EthHttpClient, clients.EthWsClient, clients, txMgr, logger) if err != nil { logger.Error("Failed to create avs manager", "err", err) - return + return err } if operationType == "opt-in" { @@ -169,7 +170,7 @@ func plugin(ctx *cli.Context) { blsKeypair, err := bls.ReadPrivateKeyFromFile(avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) if err != nil { logger.Error("Failed to read bls private key", "err", err) - return + return err } operatorEcdsaPrivateKey, err := sdkecdsa.ReadKey( @@ -178,62 +179,69 @@ func plugin(ctx *cli.Context) { ) if err != nil { logger.Error("Failed to read operator ecdsa private key", "err", err) - return + return err } - avsManager.RegisterOperatorWithAvs(ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) + err = avsManager.RegisterOperatorWithAvs(ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) + if (err != nil) { + logger.Error("Failed to register operator with avs", "err", err) + return err + } } else if operationType == "opt-out" { blsKeyPassword := ctx.GlobalString(BlsKeyPasswordFlag.Name) blsKeypair, err := bls.ReadPrivateKeyFromFile(avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) if err != nil { logger.Error("Failed to read bls private key", "err", err) - return + return err } - avsManager.DeregisterOperator(blsKeypair) + err = avsManager.DeregisterOperator(blsKeypair) + if (err != nil) { + logger.Error("Failed to deregister operator", "err", err) + return err + } } else if operationType == "deposit" { starategyAddrString := ctx.GlobalString(StrategyAddrFlag.Name) if len(starategyAddrString) == 0 { logger.Error("Strategy address is required for deposit operation") - return + return err } strategyAddr := common.HexToAddress(ctx.GlobalString(StrategyAddrFlag.Name)) _, tokenAddr, err := clients.ElChainReader.GetStrategyAndUnderlyingToken(&bind.CallOpts{}, strategyAddr) if err != nil { logger.Error("Failed to fetch strategy contract", "err", err) - return + return err } contractErc20Mock, err := avsReader.GetErc20Mock(context.Background(), tokenAddr) if err != nil { logger.Error("Failed to fetch ERC20Mock contract", "err", err) - return + return err } txOpts, err := avsWriter.TxMgr.GetNoSendTxOpts() if err != nil { logger.Error("Failed to get tx opts", "err", err) - return + return err } amount := big.NewInt(1000) tx, err := contractErc20Mock.Mint(txOpts, common.HexToAddress(avsConfig.OperatorAddress), amount) if err != nil { logger.Error("Failed to assemble Mint tx", "err", err) - return + return err } _, err = avsWriter.TxMgr.Send(context.Background(), tx) if err != nil { logger.Error("Failed to submit Mint tx", "err", err) - return + return err } _, err = clients.ElChainWriter.DepositERC20IntoStrategy(context.Background(), strategyAddr, amount) if err != nil { logger.Error("Failed to deposit into strategy", "err", err) - return + return err } - return } else { - logger.Error("Invalid operation type") + return cli.NewExitError(fmt.Sprintf("Invalid operation type: %v", operationType), 1) } + return nil } - From 47e84e0fe342e19d2b7a3cfcbb4189d9fd13e3a0 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 21 May 2024 10:54:56 -0300 Subject: [PATCH 07/12] Remove extra parenthesis --- operator/avs_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operator/avs_manager.go b/operator/avs_manager.go index 782f9f6b..46d6a7b6 100644 --- a/operator/avs_manager.go +++ b/operator/avs_manager.go @@ -286,7 +286,7 @@ func (avsManager *AvsManager) RegisterOperatorWithAvs( return nil } -func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair) (error) { +func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair) error { // TODO: 'QuorumNums' is hardcoded for now quorumNumbers := eigentypes.QuorumNums{0} pubKey := eigenutils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1()) From 5a1576c86811ca8a99ad913c158258cd7a7f6658 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 21 May 2024 15:46:50 -0300 Subject: [PATCH 08/12] Extend `AvsManagerer` interface --- operator/avs_manager.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/operator/avs_manager.go b/operator/avs_manager.go index 46d6a7b6..fa3d0f49 100644 --- a/operator/avs_manager.go +++ b/operator/avs_manager.go @@ -36,7 +36,7 @@ type AvsManagerer interface { operatorEcdsaKeyPair *ecdsa.PrivateKey, blsKeyPair *bls.KeyPair, ) error - + DeregisterOperator(blsKeyPair *bls.KeyPair) error GetOperatorId(options *bind.CallOpts, address common.Address) ([32]byte, error) GetCheckpointTaskCreatedChan() <-chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated GetOperatorSetUpdateChan() <-chan messages.OperatorSetUpdateMessage @@ -59,7 +59,9 @@ type AvsManager struct { logger sdklogging.Logger } -func NewAvsManager(config *optypes.NodeConfig, ethRpcClient eth.Client, ethWsClient eth.Client, sdkClients *clients.Clients, txManager *txmgr.SimpleTxManager, logger sdklogging.Logger) (*AvsManager, error) { +var _ AvsManagerer = (*AvsManager)(nil) + +func NewAvsManager(config *optypes.NodeConfig, ethRpcClient eth.Client, ethWsClient eth.Client, sdkClients *clients.Clients, txManager txmgr.TxManager, logger sdklogging.Logger) (*AvsManager, error) { avsWriter, err := chainio.BuildAvsWriter( txManager, common.HexToAddress(config.AVSRegistryCoordinatorAddress), common.HexToAddress(config.OperatorStateRetrieverAddress), ethRpcClient, logger, From 9aef1926770b52ddb9eb896ddbb8c91f44017ba7 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Wed, 22 May 2024 13:01:21 -0300 Subject: [PATCH 09/12] Separate CLI from Operator plugin --- plugin/cmd/main.go | 201 +++-------------------------- plugin/cmd/operator_plugin.go | 229 ++++++++++++++++++++++++++++++++++ 2 files changed, 245 insertions(+), 185 deletions(-) create mode 100644 plugin/cmd/operator_plugin.go diff --git a/plugin/cmd/main.go b/plugin/cmd/main.go index 4a4f1e06..11e14ad8 100644 --- a/plugin/cmd/main.go +++ b/plugin/cmd/main.go @@ -1,26 +1,10 @@ package main import ( - "context" "fmt" "log" - "math/big" "os" - sdkclients "github.com/Layr-Labs/eigensdk-go/chainio/clients" - "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - "github.com/Layr-Labs/eigensdk-go/chainio/clients/wallet" - "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" - "github.com/Layr-Labs/eigensdk-go/crypto/bls" - sdkecdsa "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa" - "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/Layr-Labs/eigensdk-go/signerv2" - "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/NethermindEth/near-sffl/core/chainio" - "github.com/NethermindEth/near-sffl/operator" - optypes "github.com/NethermindEth/near-sffl/operator/types" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/urfave/cli" ) @@ -70,178 +54,25 @@ func main() { app.Name = "sffl-plugin" app.Usage = "SFFL Plugin" app.Description = "This is used to run one time operations like avs opt-in/opt-out" - app.Action = plugin - err := app.Run(os.Args) - if err != nil { - log.Fatalln("Application failed.", "Message:", err) - } -} - -func plugin(ctx *cli.Context) error { - goCtx := context.Background() - logger, _ := logging.NewZapLogger(logging.Development) - - operationType := ctx.GlobalString(OperationFlag.Name) - configPath := ctx.GlobalString(ConfigFileFlag.Name) - - avsConfig := optypes.NodeConfig{} - err := utils.ReadYamlConfig(configPath, &avsConfig) - if err != nil { - logger.Error("Failed to read config", "err", err) - return err - } - - logger.Info("Starting with config", "avsConfig", avsConfig) - - ecdsaKeyPassword := ctx.GlobalString(EcdsaKeyPasswordFlag.Name) - - buildClientConfig := sdkclients.BuildAllConfig{ - EthHttpUrl: avsConfig.EthRpcUrl, - EthWsUrl: avsConfig.EthWsUrl, - RegistryCoordinatorAddr: avsConfig.AVSRegistryCoordinatorAddress, - OperatorStateRetrieverAddr: avsConfig.OperatorStateRetrieverAddress, - AvsName: "super-fast-finality-layer", - PromMetricsIpPortAddress: avsConfig.EigenMetricsIpPortAddress, - } - ethHttpClient, err := eth.NewClient(avsConfig.EthRpcUrl) - if err != nil { - logger.Error("Failed to connect to eth client", "err", err) - return err - } - chainID, err := ethHttpClient.ChainID(goCtx) - if err != nil { - logger.Error("Failed to get chain ID", "err", err) - return err - } - signerV2, _, err := signerv2.SignerFromConfig(signerv2.Config{ - KeystorePath: avsConfig.EcdsaPrivateKeyStorePath, - Password: ecdsaKeyPassword, - }, chainID) - if err != nil { - logger.Error("Failed to create signer", "err", err) - return err - } - ecdsaPrivateKey, err := sdkecdsa.ReadKey(avsConfig.EcdsaPrivateKeyStorePath, ecdsaKeyPassword) - if err != nil { - logger.Error("Failed to read ecdsa private key", "err", err) - return err - } - clients, err := sdkclients.BuildAll(buildClientConfig, ecdsaPrivateKey, logger) - if err != nil { - logger.Error("Failed to create sdk clients", "err", err) - return err - } - avsReader, err := chainio.BuildAvsReader( - common.HexToAddress(avsConfig.AVSRegistryCoordinatorAddress), - common.HexToAddress(avsConfig.OperatorStateRetrieverAddress), - ethHttpClient, - logger, - ) - if err != nil { - logger.Error("Failed to create avs reader", "err", err) - return err - } - txSender, err := wallet.NewPrivateKeyWallet(ethHttpClient, signerV2, common.HexToAddress(avsConfig.OperatorAddress), logger) - if err != nil { - logger.Error("Failed to create tx sender", "err", err) - return err - } - txMgr := txmgr.NewSimpleTxManager(txSender, ethHttpClient, logger, common.HexToAddress(avsConfig.OperatorAddress)).WithGasLimitMultiplier(1.5) - avsWriter, err := chainio.BuildAvsWriter( - txMgr, - common.HexToAddress(avsConfig.AVSRegistryCoordinatorAddress), - common.HexToAddress(avsConfig.OperatorStateRetrieverAddress), - ethHttpClient, - logger, - ) - if err != nil { - logger.Error("Failed to create avs writer", "err", err) - return err - } - avsManager, err := operator.NewAvsManager(&avsConfig, clients.EthHttpClient, clients.EthWsClient, clients, txMgr, logger) - if err != nil { - logger.Error("Failed to create avs manager", "err", err) - return err - } - - if operationType == "opt-in" { - blsKeyPassword := ctx.GlobalString(BlsKeyPasswordFlag.Name) - - blsKeypair, err := bls.ReadPrivateKeyFromFile(avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) - if err != nil { - logger.Error("Failed to read bls private key", "err", err) - return err - } - - operatorEcdsaPrivateKey, err := sdkecdsa.ReadKey( - avsConfig.EcdsaPrivateKeyStorePath, - ecdsaKeyPassword, - ) - if err != nil { - logger.Error("Failed to read operator ecdsa private key", "err", err) - return err - } - - err = avsManager.RegisterOperatorWithAvs(ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) - if (err != nil) { - logger.Error("Failed to register operator with avs", "err", err) - return err - } - } else if operationType == "opt-out" { - blsKeyPassword := ctx.GlobalString(BlsKeyPasswordFlag.Name) - - blsKeypair, err := bls.ReadPrivateKeyFromFile(avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) - if err != nil { - logger.Error("Failed to read bls private key", "err", err) - return err - } - - err = avsManager.DeregisterOperator(blsKeypair) - if (err != nil) { - logger.Error("Failed to deregister operator", "err", err) - return err - } - } else if operationType == "deposit" { - starategyAddrString := ctx.GlobalString(StrategyAddrFlag.Name) - if len(starategyAddrString) == 0 { - logger.Error("Strategy address is required for deposit operation") - return err - } - strategyAddr := common.HexToAddress(ctx.GlobalString(StrategyAddrFlag.Name)) - _, tokenAddr, err := clients.ElChainReader.GetStrategyAndUnderlyingToken(&bind.CallOpts{}, strategyAddr) - if err != nil { - logger.Error("Failed to fetch strategy contract", "err", err) - return err - } - contractErc20Mock, err := avsReader.GetErc20Mock(context.Background(), tokenAddr) - if err != nil { - logger.Error("Failed to fetch ERC20Mock contract", "err", err) - return err - } - txOpts, err := avsWriter.TxMgr.GetNoSendTxOpts() - if err != nil { - logger.Error("Failed to get tx opts", "err", err) - return err - } - amount := big.NewInt(1000) - tx, err := contractErc20Mock.Mint(txOpts, common.HexToAddress(avsConfig.OperatorAddress), amount) - if err != nil { - logger.Error("Failed to assemble Mint tx", "err", err) - return err - } - _, err = avsWriter.TxMgr.Send(context.Background(), tx) + app.Action = func(ctx *cli.Context) error { + operatorPlugin, err := NewOperatorPluginFromCLIContext(ctx) if err != nil { - logger.Error("Failed to submit Mint tx", "err", err) return err } - - _, err = clients.ElChainWriter.DepositERC20IntoStrategy(context.Background(), strategyAddr, amount) - if err != nil { - logger.Error("Failed to deposit into strategy", "err", err) - return err + operationType := ctx.GlobalString(OperationFlag.Name) + switch operationType { + case "opt-in": + return operatorPlugin.OptIn() + case "opt-out": + return operatorPlugin.OptOut() + case "deposit": + return operatorPlugin.Deposit() + default: + return cli.NewExitError(fmt.Sprintf("Invalid operation type: %v", operationType), 1) } - } else { - return cli.NewExitError(fmt.Sprintf("Invalid operation type: %v", operationType), 1) } - return nil + err := app.Run(os.Args) + if err != nil { + log.Fatalln("Application failed.", "Message:", err) + } } diff --git a/plugin/cmd/operator_plugin.go b/plugin/cmd/operator_plugin.go new file mode 100644 index 00000000..2e4b5569 --- /dev/null +++ b/plugin/cmd/operator_plugin.go @@ -0,0 +1,229 @@ +package main + +import ( + "context" + "errors" + "math/big" + + sdkclients "github.com/Layr-Labs/eigensdk-go/chainio/clients" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/wallet" + "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" + "github.com/Layr-Labs/eigensdk-go/crypto/bls" + sdkecdsa "github.com/Layr-Labs/eigensdk-go/crypto/ecdsa" + "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/signerv2" + "github.com/Layr-Labs/eigensdk-go/utils" + "github.com/NethermindEth/near-sffl/core/chainio" + "github.com/NethermindEth/near-sffl/operator" + optypes "github.com/NethermindEth/near-sffl/operator/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/urfave/cli" +) + +type OperatorPlugin struct { + ecdsaKeyPassword string + ethHttpClient eth.Client + clients *sdkclients.Clients + avsConfig optypes.NodeConfig + avsManager *operator.AvsManager + avsReader *chainio.AvsReader + avsWriter *chainio.AvsWriter + + ctx *cli.Context + logger logging.Logger +} + +type IOperatorPlugin interface { + OptIn() error + OptOut() error + Deposit() error +} + +var _ IOperatorPlugin = &OperatorPlugin{} + +func (o *OperatorPlugin) OptIn() error { + blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) + + blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) + if err != nil { + o.logger.Error("Failed to read bls private key", "err", err) + return err + } + + operatorEcdsaPrivateKey, err := sdkecdsa.ReadKey( + o.avsConfig.EcdsaPrivateKeyStorePath, + o.ecdsaKeyPassword, + ) + if err != nil { + o.logger.Error("Failed to read operator ecdsa private key", "err", err) + return err + } + + err = o.avsManager.RegisterOperatorWithAvs(o.ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) + if err != nil { + o.logger.Error("Failed to register operator with avs", "err", err) + return err + } + + return nil +} + +func (o *OperatorPlugin) OptOut() error { + blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) + + blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) + if err != nil { + o.logger.Error("Failed to read bls private key", "err", err) + return err + } + + err = o.avsManager.DeregisterOperator(blsKeypair) + if err != nil { + o.logger.Error("Failed to deregister operator", "err", err) + return err + } + + return nil +} + +func (o *OperatorPlugin) Deposit() error { + starategyAddrString := o.ctx.GlobalString(StrategyAddrFlag.Name) + if len(starategyAddrString) == 0 { + o.logger.Error("Strategy address is required for deposit operation") + return errors.New("strategy address is required for deposit operation") + } + strategyAddr := common.HexToAddress(o.ctx.GlobalString(StrategyAddrFlag.Name)) + _, tokenAddr, err := o.clients.ElChainReader.GetStrategyAndUnderlyingToken(&bind.CallOpts{}, strategyAddr) + if err != nil { + o.logger.Error("Failed to fetch strategy contract", "err", err) + return err + } + contractErc20Mock, err := o.avsReader.GetErc20Mock(context.Background(), tokenAddr) + if err != nil { + o.logger.Error("Failed to fetch ERC20Mock contract", "err", err) + return err + } + txOpts, err := o.avsWriter.TxMgr.GetNoSendTxOpts() + if err != nil { + o.logger.Error("Failed to get tx opts", "err", err) + return err + } + amount := big.NewInt(1000) + tx, err := contractErc20Mock.Mint(txOpts, common.HexToAddress(o.avsConfig.OperatorAddress), amount) + if err != nil { + o.logger.Error("Failed to assemble Mint tx", "err", err) + return err + } + _, err = o.avsWriter.TxMgr.Send(context.Background(), tx) + if err != nil { + o.logger.Error("Failed to submit Mint tx", "err", err) + return err + } + + _, err = o.clients.ElChainWriter.DepositERC20IntoStrategy(context.Background(), strategyAddr, amount) + if err != nil { + o.logger.Error("Failed to deposit into strategy", "err", err) + return err + } + + return nil +} + +func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*OperatorPlugin, error) { + goCtx := context.Background() + logger, _ := logging.NewZapLogger(logging.Development) + + configPath := ctx.GlobalString(ConfigFileFlag.Name) + + avsConfig := optypes.NodeConfig{} + err := utils.ReadYamlConfig(configPath, &avsConfig) + if err != nil { + logger.Error("Failed to read config", "err", err) + return nil, err + } + + logger.Info("Starting with config", "avsConfig", avsConfig) + + ecdsaKeyPassword := ctx.GlobalString(EcdsaKeyPasswordFlag.Name) + + buildClientConfig := sdkclients.BuildAllConfig{ + EthHttpUrl: avsConfig.EthRpcUrl, + EthWsUrl: avsConfig.EthWsUrl, + RegistryCoordinatorAddr: avsConfig.AVSRegistryCoordinatorAddress, + OperatorStateRetrieverAddr: avsConfig.OperatorStateRetrieverAddress, + AvsName: "super-fast-finality-layer", + PromMetricsIpPortAddress: avsConfig.EigenMetricsIpPortAddress, + } + ethHttpClient, err := eth.NewClient(avsConfig.EthRpcUrl) + if err != nil { + logger.Error("Failed to connect to eth client", "err", err) + return nil, err + } + chainID, err := ethHttpClient.ChainID(goCtx) + if err != nil { + logger.Error("Failed to get chain ID", "err", err) + return nil, err + } + signerV2, _, err := signerv2.SignerFromConfig(signerv2.Config{ + KeystorePath: avsConfig.EcdsaPrivateKeyStorePath, + Password: ecdsaKeyPassword, + }, chainID) + if err != nil { + logger.Error("Failed to create signer", "err", err) + return nil, err + } + ecdsaPrivateKey, err := sdkecdsa.ReadKey(avsConfig.EcdsaPrivateKeyStorePath, ecdsaKeyPassword) + if err != nil { + logger.Error("Failed to read ecdsa private key", "err", err) + return nil, err + } + clients, err := sdkclients.BuildAll(buildClientConfig, ecdsaPrivateKey, logger) + if err != nil { + logger.Error("Failed to create sdk clients", "err", err) + return nil, err + } + avsReader, err := chainio.BuildAvsReader( + common.HexToAddress(avsConfig.AVSRegistryCoordinatorAddress), + common.HexToAddress(avsConfig.OperatorStateRetrieverAddress), + ethHttpClient, + logger, + ) + if err != nil { + logger.Error("Failed to create avs reader", "err", err) + return nil, err + } + txSender, err := wallet.NewPrivateKeyWallet(ethHttpClient, signerV2, common.HexToAddress(avsConfig.OperatorAddress), logger) + if err != nil { + logger.Error("Failed to create tx sender", "err", err) + return nil, err + } + txMgr := txmgr.NewSimpleTxManager(txSender, ethHttpClient, logger, common.HexToAddress(avsConfig.OperatorAddress)).WithGasLimitMultiplier(1.5) + avsWriter, err := chainio.BuildAvsWriter( + txMgr, + common.HexToAddress(avsConfig.AVSRegistryCoordinatorAddress), + common.HexToAddress(avsConfig.OperatorStateRetrieverAddress), + ethHttpClient, + logger, + ) + if err != nil { + logger.Error("Failed to create avs writer", "err", err) + return nil, err + } + avsManager, err := operator.NewAvsManager(&avsConfig, clients.EthHttpClient, clients.EthWsClient, clients, txMgr, logger) + if err != nil { + logger.Error("Failed to create avs manager", "err", err) + return nil, err + } + + return &OperatorPlugin{ + ecdsaKeyPassword: ecdsaKeyPassword, + ethHttpClient: ethHttpClient, + clients: clients, + avsConfig: avsConfig, + avsManager: avsManager, + avsReader: avsReader, + avsWriter: avsWriter, + }, nil +} From 8d1dc75c45cdfc9ea26169f2bd1816a597582e1f Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Wed, 22 May 2024 13:49:19 -0300 Subject: [PATCH 10/12] Formatting --- plugin/cmd/operator_plugin.go | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/plugin/cmd/operator_plugin.go b/plugin/cmd/operator_plugin.go index 2e4b5569..0a8f651a 100644 --- a/plugin/cmd/operator_plugin.go +++ b/plugin/cmd/operator_plugin.go @@ -22,7 +22,7 @@ import ( "github.com/urfave/cli" ) -type OperatorPlugin struct { +type CliOperatorPlugin struct { ecdsaKeyPassword string ethHttpClient eth.Client clients *sdkclients.Clients @@ -35,15 +35,15 @@ type OperatorPlugin struct { logger logging.Logger } -type IOperatorPlugin interface { +type OperatorPlugin interface { OptIn() error OptOut() error Deposit() error } -var _ IOperatorPlugin = &OperatorPlugin{} +var _ OperatorPlugin = &CliOperatorPlugin{} -func (o *OperatorPlugin) OptIn() error { +func (o *CliOperatorPlugin) OptIn() error { blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) @@ -70,7 +70,7 @@ func (o *OperatorPlugin) OptIn() error { return nil } -func (o *OperatorPlugin) OptOut() error { +func (o *CliOperatorPlugin) OptOut() error { blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) @@ -88,34 +88,39 @@ func (o *OperatorPlugin) OptOut() error { return nil } -func (o *OperatorPlugin) Deposit() error { - starategyAddrString := o.ctx.GlobalString(StrategyAddrFlag.Name) - if len(starategyAddrString) == 0 { +func (o *CliOperatorPlugin) Deposit() error { + strategy := o.ctx.GlobalString(StrategyAddrFlag.Name) + if len(strategy) == 0 { o.logger.Error("Strategy address is required for deposit operation") return errors.New("strategy address is required for deposit operation") } + strategyAddr := common.HexToAddress(o.ctx.GlobalString(StrategyAddrFlag.Name)) _, tokenAddr, err := o.clients.ElChainReader.GetStrategyAndUnderlyingToken(&bind.CallOpts{}, strategyAddr) if err != nil { o.logger.Error("Failed to fetch strategy contract", "err", err) return err } + contractErc20Mock, err := o.avsReader.GetErc20Mock(context.Background(), tokenAddr) if err != nil { o.logger.Error("Failed to fetch ERC20Mock contract", "err", err) return err } + txOpts, err := o.avsWriter.TxMgr.GetNoSendTxOpts() if err != nil { o.logger.Error("Failed to get tx opts", "err", err) return err } + amount := big.NewInt(1000) tx, err := contractErc20Mock.Mint(txOpts, common.HexToAddress(o.avsConfig.OperatorAddress), amount) if err != nil { o.logger.Error("Failed to assemble Mint tx", "err", err) return err } + _, err = o.avsWriter.TxMgr.Send(context.Background(), tx) if err != nil { o.logger.Error("Failed to submit Mint tx", "err", err) @@ -131,7 +136,7 @@ func (o *OperatorPlugin) Deposit() error { return nil } -func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*OperatorPlugin, error) { +func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*CliOperatorPlugin, error) { goCtx := context.Background() logger, _ := logging.NewZapLogger(logging.Development) @@ -156,16 +161,19 @@ func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*OperatorPlugin, error) AvsName: "super-fast-finality-layer", PromMetricsIpPortAddress: avsConfig.EigenMetricsIpPortAddress, } + ethHttpClient, err := eth.NewClient(avsConfig.EthRpcUrl) if err != nil { logger.Error("Failed to connect to eth client", "err", err) return nil, err } + chainID, err := ethHttpClient.ChainID(goCtx) if err != nil { logger.Error("Failed to get chain ID", "err", err) return nil, err } + signerV2, _, err := signerv2.SignerFromConfig(signerv2.Config{ KeystorePath: avsConfig.EcdsaPrivateKeyStorePath, Password: ecdsaKeyPassword, @@ -174,16 +182,19 @@ func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*OperatorPlugin, error) logger.Error("Failed to create signer", "err", err) return nil, err } + ecdsaPrivateKey, err := sdkecdsa.ReadKey(avsConfig.EcdsaPrivateKeyStorePath, ecdsaKeyPassword) if err != nil { logger.Error("Failed to read ecdsa private key", "err", err) return nil, err } + clients, err := sdkclients.BuildAll(buildClientConfig, ecdsaPrivateKey, logger) if err != nil { logger.Error("Failed to create sdk clients", "err", err) return nil, err } + avsReader, err := chainio.BuildAvsReader( common.HexToAddress(avsConfig.AVSRegistryCoordinatorAddress), common.HexToAddress(avsConfig.OperatorStateRetrieverAddress), @@ -194,11 +205,13 @@ func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*OperatorPlugin, error) logger.Error("Failed to create avs reader", "err", err) return nil, err } + txSender, err := wallet.NewPrivateKeyWallet(ethHttpClient, signerV2, common.HexToAddress(avsConfig.OperatorAddress), logger) if err != nil { logger.Error("Failed to create tx sender", "err", err) return nil, err } + txMgr := txmgr.NewSimpleTxManager(txSender, ethHttpClient, logger, common.HexToAddress(avsConfig.OperatorAddress)).WithGasLimitMultiplier(1.5) avsWriter, err := chainio.BuildAvsWriter( txMgr, @@ -211,13 +224,14 @@ func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*OperatorPlugin, error) logger.Error("Failed to create avs writer", "err", err) return nil, err } + avsManager, err := operator.NewAvsManager(&avsConfig, clients.EthHttpClient, clients.EthWsClient, clients, txMgr, logger) if err != nil { logger.Error("Failed to create avs manager", "err", err) return nil, err } - return &OperatorPlugin{ + return &CliOperatorPlugin{ ecdsaKeyPassword: ecdsaKeyPassword, ethHttpClient: ethHttpClient, clients: clients, From b69d900669318fc3cbba9d3807ba1e3fff987a6a Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Thu, 23 May 2024 11:02:02 -0300 Subject: [PATCH 11/12] Move constructor up --- plugin/cmd/operator_plugin.go | 186 +++++++++++++++++----------------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/plugin/cmd/operator_plugin.go b/plugin/cmd/operator_plugin.go index 0a8f651a..3e5fccad 100644 --- a/plugin/cmd/operator_plugin.go +++ b/plugin/cmd/operator_plugin.go @@ -43,99 +43,6 @@ type OperatorPlugin interface { var _ OperatorPlugin = &CliOperatorPlugin{} -func (o *CliOperatorPlugin) OptIn() error { - blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) - - blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) - if err != nil { - o.logger.Error("Failed to read bls private key", "err", err) - return err - } - - operatorEcdsaPrivateKey, err := sdkecdsa.ReadKey( - o.avsConfig.EcdsaPrivateKeyStorePath, - o.ecdsaKeyPassword, - ) - if err != nil { - o.logger.Error("Failed to read operator ecdsa private key", "err", err) - return err - } - - err = o.avsManager.RegisterOperatorWithAvs(o.ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) - if err != nil { - o.logger.Error("Failed to register operator with avs", "err", err) - return err - } - - return nil -} - -func (o *CliOperatorPlugin) OptOut() error { - blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) - - blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) - if err != nil { - o.logger.Error("Failed to read bls private key", "err", err) - return err - } - - err = o.avsManager.DeregisterOperator(blsKeypair) - if err != nil { - o.logger.Error("Failed to deregister operator", "err", err) - return err - } - - return nil -} - -func (o *CliOperatorPlugin) Deposit() error { - strategy := o.ctx.GlobalString(StrategyAddrFlag.Name) - if len(strategy) == 0 { - o.logger.Error("Strategy address is required for deposit operation") - return errors.New("strategy address is required for deposit operation") - } - - strategyAddr := common.HexToAddress(o.ctx.GlobalString(StrategyAddrFlag.Name)) - _, tokenAddr, err := o.clients.ElChainReader.GetStrategyAndUnderlyingToken(&bind.CallOpts{}, strategyAddr) - if err != nil { - o.logger.Error("Failed to fetch strategy contract", "err", err) - return err - } - - contractErc20Mock, err := o.avsReader.GetErc20Mock(context.Background(), tokenAddr) - if err != nil { - o.logger.Error("Failed to fetch ERC20Mock contract", "err", err) - return err - } - - txOpts, err := o.avsWriter.TxMgr.GetNoSendTxOpts() - if err != nil { - o.logger.Error("Failed to get tx opts", "err", err) - return err - } - - amount := big.NewInt(1000) - tx, err := contractErc20Mock.Mint(txOpts, common.HexToAddress(o.avsConfig.OperatorAddress), amount) - if err != nil { - o.logger.Error("Failed to assemble Mint tx", "err", err) - return err - } - - _, err = o.avsWriter.TxMgr.Send(context.Background(), tx) - if err != nil { - o.logger.Error("Failed to submit Mint tx", "err", err) - return err - } - - _, err = o.clients.ElChainWriter.DepositERC20IntoStrategy(context.Background(), strategyAddr, amount) - if err != nil { - o.logger.Error("Failed to deposit into strategy", "err", err) - return err - } - - return nil -} - func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*CliOperatorPlugin, error) { goCtx := context.Background() logger, _ := logging.NewZapLogger(logging.Development) @@ -241,3 +148,96 @@ func NewOperatorPluginFromCLIContext(ctx *cli.Context) (*CliOperatorPlugin, erro avsWriter: avsWriter, }, nil } + +func (o *CliOperatorPlugin) OptIn() error { + blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) + + blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) + if err != nil { + o.logger.Error("Failed to read bls private key", "err", err) + return err + } + + operatorEcdsaPrivateKey, err := sdkecdsa.ReadKey( + o.avsConfig.EcdsaPrivateKeyStorePath, + o.ecdsaKeyPassword, + ) + if err != nil { + o.logger.Error("Failed to read operator ecdsa private key", "err", err) + return err + } + + err = o.avsManager.RegisterOperatorWithAvs(o.ethHttpClient, operatorEcdsaPrivateKey, blsKeypair) + if err != nil { + o.logger.Error("Failed to register operator with avs", "err", err) + return err + } + + return nil +} + +func (o *CliOperatorPlugin) OptOut() error { + blsKeyPassword := o.ctx.GlobalString(BlsKeyPasswordFlag.Name) + + blsKeypair, err := bls.ReadPrivateKeyFromFile(o.avsConfig.BlsPrivateKeyStorePath, blsKeyPassword) + if err != nil { + o.logger.Error("Failed to read bls private key", "err", err) + return err + } + + err = o.avsManager.DeregisterOperator(blsKeypair) + if err != nil { + o.logger.Error("Failed to deregister operator", "err", err) + return err + } + + return nil +} + +func (o *CliOperatorPlugin) Deposit() error { + strategy := o.ctx.GlobalString(StrategyAddrFlag.Name) + if len(strategy) == 0 { + o.logger.Error("Strategy address is required for deposit operation") + return errors.New("strategy address is required for deposit operation") + } + + strategyAddr := common.HexToAddress(o.ctx.GlobalString(StrategyAddrFlag.Name)) + _, tokenAddr, err := o.clients.ElChainReader.GetStrategyAndUnderlyingToken(&bind.CallOpts{}, strategyAddr) + if err != nil { + o.logger.Error("Failed to fetch strategy contract", "err", err) + return err + } + + contractErc20Mock, err := o.avsReader.GetErc20Mock(context.Background(), tokenAddr) + if err != nil { + o.logger.Error("Failed to fetch ERC20Mock contract", "err", err) + return err + } + + txOpts, err := o.avsWriter.TxMgr.GetNoSendTxOpts() + if err != nil { + o.logger.Error("Failed to get tx opts", "err", err) + return err + } + + amount := big.NewInt(1000) + tx, err := contractErc20Mock.Mint(txOpts, common.HexToAddress(o.avsConfig.OperatorAddress), amount) + if err != nil { + o.logger.Error("Failed to assemble Mint tx", "err", err) + return err + } + + _, err = o.avsWriter.TxMgr.Send(context.Background(), tx) + if err != nil { + o.logger.Error("Failed to submit Mint tx", "err", err) + return err + } + + _, err = o.clients.ElChainWriter.DepositERC20IntoStrategy(context.Background(), strategyAddr, amount) + if err != nil { + o.logger.Error("Failed to deposit into strategy", "err", err) + return err + } + + return nil +} From 9d45fbe61c0d057fd642323399cc6506839fdf63 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Thu, 23 May 2024 11:07:13 -0300 Subject: [PATCH 12/12] Consistent logging tags --- operator/avs_manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/operator/avs_manager.go b/operator/avs_manager.go index fa3d0f49..b1f06d64 100644 --- a/operator/avs_manager.go +++ b/operator/avs_manager.go @@ -295,10 +295,10 @@ func (avsManager *AvsManager) DeregisterOperator(blsKeyPair *bls.KeyPair) error _, err := avsManager.avsWriter.DeregisterOperator(context.Background(), quorumNumbers, pubKey) if err != nil { - avsManager.logger.Errorf("Unable to deregister operator with avs registry coordinator: %v", err) + avsManager.logger.Error("Unable to deregister operator with avs registry coordinator", "err", err) return err } - avsManager.logger.Infof("Deregistered operator with avs registry coordinator.") + avsManager.logger.Info("Deregistered operator with avs registry coordinator") return nil }