From 350bc45bbc2a8a556a3d1f6560fb21991b80caa9 Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Fri, 28 Jun 2024 14:53:30 -0700 Subject: [PATCH] address comments --- chainio/clients/avsregistry/bindings.go | 43 ++++++++++++----------- chainio/clients/avsregistry/reader.go | 2 +- chainio/clients/avsregistry/subscriber.go | 2 +- chainio/clients/avsregistry/writer.go | 2 +- chainio/clients/elcontracts/bindings.go | 19 +++++----- chainio/clients/elcontracts/reader.go | 2 +- chainio/clients/elcontracts/writer.go | 2 +- logging/constants.go | 5 +++ 8 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 logging/constants.go diff --git a/chainio/clients/avsregistry/bindings.go b/chainio/clients/avsregistry/bindings.go index 3e34786b..dedc3d1a 100644 --- a/chainio/clients/avsregistry/bindings.go +++ b/chainio/clients/avsregistry/bindings.go @@ -127,22 +127,25 @@ func NewBindingsFromConfig( client eth.Client, logger logging.Logger, ) (*ContractBindings, error) { - var err error - var serviceManagerAddr gethcommon.Address - var registryCoordinatorAddr gethcommon.Address - var stakeRegistryAddr gethcommon.Address - var blsApkRegistryAddr gethcommon.Address - var indexRegistryAddr gethcommon.Address - var operatorStateRetrieverAddr gethcommon.Address - var delegationManagerAddr gethcommon.Address - var avsDirectoryAddr gethcommon.Address - - var contractBlsRegistryCoordinator *regcoordinator.ContractRegistryCoordinator - var contractServiceManager *servicemanager.ContractServiceManagerBase - var contractStakeRegistry *stakeregistry.ContractStakeRegistry - var contractBlsApkRegistry *blsapkregistry.ContractBLSApkRegistry - var contractIndexRegistry *indexregistry.ContractIndexRegistry - var contractOperatorStateRetriever *opstateretriever.ContractOperatorStateRetriever + var ( + err error + + serviceManagerAddr gethcommon.Address + registryCoordinatorAddr gethcommon.Address + stakeRegistryAddr gethcommon.Address + blsApkRegistryAddr gethcommon.Address + indexRegistryAddr gethcommon.Address + operatorStateRetrieverAddr gethcommon.Address + delegationManagerAddr gethcommon.Address + avsDirectoryAddr gethcommon.Address + + contractBlsRegistryCoordinator *regcoordinator.ContractRegistryCoordinator + contractServiceManager *servicemanager.ContractServiceManagerBase + contractStakeRegistry *stakeregistry.ContractStakeRegistry + contractBlsApkRegistry *blsapkregistry.ContractBLSApkRegistry + contractIndexRegistry *indexregistry.ContractIndexRegistry + contractOperatorStateRetriever *opstateretriever.ContractOperatorStateRetriever + ) if isZeroAddress(cfg.RegistryCoordinatorAddress) { logger.Warn("RegistryCoordinator address not provided, the calls to the contract will not work") @@ -164,7 +167,7 @@ func NewBindingsFromConfig( client, ) if err != nil { - return nil, utils.WrapError("Failed to fetch ServiceManager contract", err) + return nil, utils.WrapError("Failed to create ServiceManager contract", err) } stakeRegistryAddr, err = contractBlsRegistryCoordinator.StakeRegistry(&bind.CallOpts{}) @@ -176,7 +179,7 @@ func NewBindingsFromConfig( client, ) if err != nil { - return nil, utils.WrapError("Failed to fetch StakeRegistry contract", err) + return nil, utils.WrapError("Failed to create StakeRegistry contract", err) } blsApkRegistryAddr, err = contractBlsRegistryCoordinator.BlsApkRegistry(&bind.CallOpts{}) @@ -188,7 +191,7 @@ func NewBindingsFromConfig( client, ) if err != nil { - return nil, utils.WrapError("Failed to fetch BLSPubkeyRegistry contract", err) + return nil, utils.WrapError("Failed to create BLSPubkeyRegistry contract", err) } indexRegistryAddr, err = contractBlsRegistryCoordinator.IndexRegistry(&bind.CallOpts{}) @@ -197,7 +200,7 @@ func NewBindingsFromConfig( } contractIndexRegistry, err = indexregistry.NewContractIndexRegistry(indexRegistryAddr, client) if err != nil { - return nil, utils.WrapError("Failed to fetch IndexRegistry contract", err) + return nil, utils.WrapError("Failed to create IndexRegistry contract", err) } delegationManagerAddr, err = contractStakeRegistry.Delegation(&bind.CallOpts{}) diff --git a/chainio/clients/avsregistry/reader.go b/chainio/clients/avsregistry/reader.go index 56ed35a3..64120b40 100644 --- a/chainio/clients/avsregistry/reader.go +++ b/chainio/clients/avsregistry/reader.go @@ -115,7 +115,7 @@ func NewChainReader( logger logging.Logger, ethClient eth.Client, ) *ChainReader { - logger = logger.With("module", "avsregistry/ChainReader") + logger = logger.With(logging.ComponentKey, "avsregistry/ChainReader") return &ChainReader{ blsApkRegistryAddr: blsApkRegistryAddr, diff --git a/chainio/clients/avsregistry/subscriber.go b/chainio/clients/avsregistry/subscriber.go index b4a81fbc..1aeb6bf8 100644 --- a/chainio/clients/avsregistry/subscriber.go +++ b/chainio/clients/avsregistry/subscriber.go @@ -31,7 +31,7 @@ func NewChainSubscriber( regCoord regcoord.ContractRegistryCoordinatorFilters, blsApkRegistry blsapkreg.ContractBLSApkRegistryFilters, ) (*ChainSubscriber, error) { - logger = logger.With("module", "avsregistry/ChainSubscriber") + logger = logger.With(logging.ComponentKey, "avsregistry/ChainSubscriber") return &ChainSubscriber{ logger: logger, diff --git a/chainio/clients/avsregistry/writer.go b/chainio/clients/avsregistry/writer.go index c5e5419b..98cd540d 100644 --- a/chainio/clients/avsregistry/writer.go +++ b/chainio/clients/avsregistry/writer.go @@ -113,7 +113,7 @@ func NewChainWriter( ethClient eth.Client, txMgr txmgr.TxManager, ) (*ChainWriter, error) { - logger = logger.With("module", "avsregistry/ChainWriter") + logger = logger.With(logging.ComponentKey, "avsregistry/ChainWriter") return &ChainWriter{ serviceManagerAddr: serviceManagerAddr, diff --git a/chainio/clients/elcontracts/bindings.go b/chainio/clients/elcontracts/bindings.go index 9c85d843..2d5845db 100644 --- a/chainio/clients/elcontracts/bindings.go +++ b/chainio/clients/elcontracts/bindings.go @@ -38,14 +38,17 @@ func NewBindingsFromConfig( client eth.Client, logger logging.Logger, ) (*ContractBindings, error) { - var contractDelegationManager *delegationmanager.ContractDelegationManager - var contractSlasher *slasher.ContractISlasher - var contractStrategyManager *strategymanager.ContractStrategyManager - var slasherAddr gethcommon.Address - var strategyManagerAddr gethcommon.Address - var avsDirectory *avsdirectory.ContractAVSDirectory - var rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator - var err error + var ( + err error + + contractDelegationManager *delegationmanager.ContractDelegationManager + contractSlasher *slasher.ContractISlasher + contractStrategyManager *strategymanager.ContractStrategyManager + slasherAddr gethcommon.Address + strategyManagerAddr gethcommon.Address + avsDirectory *avsdirectory.ContractAVSDirectory + rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator + ) if isZeroAddress(cfg.DelegationManagerAddress) { logger.Warn("DelegationManager address not provided, the calls to the contract will not work") diff --git a/chainio/clients/elcontracts/reader.go b/chainio/clients/elcontracts/reader.go index ee9de49c..abf7c707 100644 --- a/chainio/clients/elcontracts/reader.go +++ b/chainio/clients/elcontracts/reader.go @@ -86,7 +86,7 @@ func NewELChainReader( logger logging.Logger, ethClient eth.Client, ) *ELChainReader { - logger = logger.With("module", "elcontracts/reader") + logger = logger.With(logging.ComponentKey, "elcontracts/reader") return &ELChainReader{ slasher: slasher, diff --git a/chainio/clients/elcontracts/writer.go b/chainio/clients/elcontracts/writer.go index 6c95468a..0699280d 100644 --- a/chainio/clients/elcontracts/writer.go +++ b/chainio/clients/elcontracts/writer.go @@ -73,7 +73,7 @@ func NewELChainWriter( eigenMetrics metrics.Metrics, txMgr txmgr.TxManager, ) *ELChainWriter { - logger = logger.With("module", "elcontracts/writer") + logger = logger.With(logging.ComponentKey, "elcontracts/writer") return &ELChainWriter{ slasher: slasher, diff --git a/logging/constants.go b/logging/constants.go new file mode 100644 index 00000000..7353ee22 --- /dev/null +++ b/logging/constants.go @@ -0,0 +1,5 @@ +package logging + +const ( + ComponentKey = "component" +)