diff --git a/chainio/clients/avsregistry/builder.go b/chainio/clients/avsregistry/builder.go new file mode 100644 index 00000000..6faf9589 --- /dev/null +++ b/chainio/clients/avsregistry/builder.go @@ -0,0 +1,68 @@ +package avsregistry + +import ( + "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" + "github.com/Layr-Labs/eigensdk-go/logging" +) + +func BuildClients( + config Config, + client eth.Client, + txMgr txmgr.TxManager, + logger logging.Logger, +) (*ChainReader, *ChainSubscriber, *ChainWriter, *ContractBindings, error) { + avsBindings, err := NewBindingsFromConfig( + config, + client, + logger, + ) + + if err != nil { + return nil, nil, nil, nil, err + } + + chainReader := NewChainReader( + avsBindings.RegistryCoordinatorAddr, + avsBindings.BlsApkRegistryAddr, + avsBindings.RegistryCoordinator, + avsBindings.OperatorStateRetriever, + avsBindings.StakeRegistry, + logger, + client, + ) + + chainSubscriber := NewChainSubscriber( + avsBindings.RegistryCoordinator, + avsBindings.BlsApkRegistry, + logger, + ) + + // This is ugly but we need elReader to be able to create the AVS writer + elChainReader, err := elcontracts.NewReaderFromConfig( + elcontracts.Config{ + DelegationManagerAddress: avsBindings.DelegationManagerAddr, + AvsDirectoryAddress: avsBindings.AvsDirectoryAddr, + }, + client, + logger, + ) + if err != nil { + return nil, nil, nil, nil, err + } + + chainWriter := NewChainWriter( + avsBindings.ServiceManagerAddr, + avsBindings.RegistryCoordinator, + avsBindings.OperatorStateRetriever, + avsBindings.StakeRegistry, + avsBindings.BlsApkRegistry, + elChainReader, + logger, + client, + txMgr, + ) + + return chainReader, chainSubscriber, chainWriter, avsBindings, nil +} diff --git a/chainio/clients/avsregistry/subscriber.go b/chainio/clients/avsregistry/subscriber.go index 1aeb6bf8..24ffb73e 100644 --- a/chainio/clients/avsregistry/subscriber.go +++ b/chainio/clients/avsregistry/subscriber.go @@ -27,17 +27,17 @@ type ChainSubscriber struct { var _ Subscriber = (*ChainSubscriber)(nil) func NewChainSubscriber( - logger logging.Logger, regCoord regcoord.ContractRegistryCoordinatorFilters, blsApkRegistry blsapkreg.ContractBLSApkRegistryFilters, -) (*ChainSubscriber, error) { + logger logging.Logger, +) *ChainSubscriber { logger = logger.With(logging.ComponentKey, "avsregistry/ChainSubscriber") return &ChainSubscriber{ - logger: logger, regCoord: regCoord, blsApkRegistry: blsApkRegistry, - }, nil + logger: logger, + } } func BuildAvsRegistryChainSubscriber( @@ -57,7 +57,7 @@ func BuildAvsRegistryChainSubscriber( if err != nil { return nil, utils.WrapError("Failed to create BLSApkRegistry contract", err) } - return NewChainSubscriber(logger, regCoord, blsApkReg) + return NewChainSubscriber(regCoord, blsApkReg, logger), nil } func NewSubscriberFromConfig( @@ -70,7 +70,7 @@ func NewSubscriberFromConfig( return nil, err } - return NewChainSubscriber(logger, bindings.RegistryCoordinator, bindings.BlsApkRegistry) + return NewChainSubscriber(bindings.RegistryCoordinator, bindings.BlsApkRegistry, logger), nil } func (s *ChainSubscriber) SubscribeToNewPubkeyRegistrations() (chan *blsapkreg.ContractBLSApkRegistryNewPubkeyRegistration, event.Subscription, error) { diff --git a/chainio/clients/avsregistry/writer.go b/chainio/clients/avsregistry/writer.go index 98cd540d..1747faf0 100644 --- a/chainio/clients/avsregistry/writer.go +++ b/chainio/clients/avsregistry/writer.go @@ -94,7 +94,7 @@ type ChainWriter struct { operatorStateRetriever *opstateretriever.ContractOperatorStateRetriever stakeRegistry *stakeregistry.ContractStakeRegistry blsApkRegistry *blsapkregistry.ContractBLSApkRegistry - elReader elcontracts.ELReader + elReader elcontracts.Reader logger logging.Logger ethClient eth.Client txMgr txmgr.TxManager @@ -108,11 +108,11 @@ func NewChainWriter( operatorStateRetriever *opstateretriever.ContractOperatorStateRetriever, stakeRegistry *stakeregistry.ContractStakeRegistry, blsApkRegistry *blsapkregistry.ContractBLSApkRegistry, - elReader elcontracts.ELReader, + elReader elcontracts.Reader, logger logging.Logger, ethClient eth.Client, txMgr txmgr.TxManager, -) (*ChainWriter, error) { +) *ChainWriter { logger = logger.With(logging.ComponentKey, "avsregistry/ChainWriter") return &ChainWriter{ @@ -125,7 +125,7 @@ func NewChainWriter( logger: logger, ethClient: ethClient, txMgr: txMgr, - }, nil + } } // BuildAvsRegistryChainWriter creates a new ChainWriter instance from the provided contract addresses @@ -194,7 +194,7 @@ func BuildAvsRegistryChainWriter( logger, ethClient, txMgr, - ) + ), nil } // NewWriterFromConfig creates a new ChainWriter from the provided config @@ -226,7 +226,7 @@ func NewWriterFromConfig( logger, client, txMgr, - ) + ), nil } func (w *ChainWriter) RegisterOperatorInQuorumWithAVSRegistryCoordinator( diff --git a/chainio/clients/builder.go b/chainio/clients/builder.go index 0526e6f1..c5836f7a 100644 --- a/chainio/clients/builder.go +++ b/chainio/clients/builder.go @@ -14,7 +14,6 @@ import ( "github.com/Layr-Labs/eigensdk-go/metrics" "github.com/Layr-Labs/eigensdk-go/signerv2" "github.com/Layr-Labs/eigensdk-go/utils" - "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/prometheus/client_golang/prometheus" ) @@ -28,6 +27,7 @@ type BuildAllConfig struct { PromMetricsIpPortAddress string } +// Clients is a struct that holds all the clients that are needed to interact with the AVS and EL contracts. // TODO: this is confusing right now because clients are not instrumented clients, but // we return metrics and prometheus reg, so user has to build instrumented clients at the call // site if they need them. We should probably separate into two separate constructors, one @@ -37,8 +37,8 @@ type Clients struct { AvsRegistryChainReader *avsregistry.ChainReader AvsRegistryChainSubscriber *avsregistry.ChainSubscriber AvsRegistryChainWriter *avsregistry.ChainWriter - ElChainReader *elcontracts.ELChainReader - ElChainWriter *elcontracts.ELChainWriter + ElChainReader *elcontracts.ChainReader + ElChainWriter *elcontracts.ChainWriter EthHttpClient eth.Client EthWsClient eth.Client Wallet wallet.Wallet @@ -87,27 +87,34 @@ func BuildAll( return nil, utils.WrapError("Failed to create transaction sender", err) } txMgr := txmgr.NewSimpleTxManager(pkWallet, ethHttpClient, logger, addr) - // creating EL clients: Reader, Writer and EigenLayer Contract Bindings - elChainReader, elChainWriter, elContractBindings, err := config.BuildELClients( + + // creating AVS clients: Reader and Writer + avsRegistryChainReader, avsRegistryChainSubscriber, avsRegistryChainWriter, avsRegistryContractBindings, err := avsregistry.BuildClients( + avsregistry.Config{ + RegistryCoordinatorAddress: gethcommon.HexToAddress(config.RegistryCoordinatorAddr), + OperatorStateRetrieverAddress: gethcommon.HexToAddress(config.OperatorStateRetrieverAddr), + }, ethHttpClient, txMgr, logger, - eigenMetrics, ) if err != nil { - return nil, utils.WrapError("Failed to create EL Reader, Writer and Subscriber", err) + return nil, utils.WrapError("Failed to create AVS Registry Reader and Writer", err) } - // creating AVS clients: Reader and Writer - avsRegistryChainReader, avsRegistryChainSubscriber, avsRegistryChainWriter, avsRegistryContractBindings, err := config.BuildAVSRegistryClients( - elChainReader, + // creating EL clients: Reader, Writer and EigenLayer Contract Bindings + elChainReader, elChainWriter, elContractBindings, err := elcontracts.BuildClients( + elcontracts.Config{ + DelegationManagerAddress: avsRegistryContractBindings.DelegationManagerAddr, + AvsDirectoryAddress: avsRegistryContractBindings.AvsDirectoryAddr, + }, ethHttpClient, - ethWsClient, txMgr, logger, + eigenMetrics, ) if err != nil { - return nil, utils.WrapError("Failed to create AVS Registry Reader and Writer", err) + return nil, utils.WrapError("Failed to create EL Reader and Writer", err) } return &Clients{ @@ -128,153 +135,6 @@ func BuildAll( } -func (config *BuildAllConfig) buildAVSRegistryContractBindings( - ethHttpClient eth.Client, - logger logging.Logger, -) (*avsregistry.ContractBindings, error) { - avsRegistryContractBindings, err := avsregistry.NewAVSRegistryContractBindings( - gethcommon.HexToAddress(config.RegistryCoordinatorAddr), - gethcommon.HexToAddress(config.OperatorStateRetrieverAddr), - ethHttpClient, - logger, - ) - if err != nil { - return nil, utils.WrapError("Failed to create AVSRegistryContractBindings", err) - } - return avsRegistryContractBindings, nil -} - -func (config *BuildAllConfig) buildEigenLayerContractBindings( - delegationManagerAddr, avsDirectoryAddr gethcommon.Address, - ethHttpClient eth.Client, - logger logging.Logger, -) (*elcontracts.ContractBindings, error) { - - elContractBindings, err := elcontracts.NewEigenlayerContractBindings( - delegationManagerAddr, - avsDirectoryAddr, - ethHttpClient, - logger, - ) - if err != nil { - return nil, utils.WrapError("Failed to create ContractBindings", err) - } - return elContractBindings, nil -} - -func (config *BuildAllConfig) BuildELClients( - ethHttpClient eth.Client, - txMgr txmgr.TxManager, - logger logging.Logger, - eigenMetrics *metrics.EigenMetrics, -) (*elcontracts.ELChainReader, *elcontracts.ELChainWriter, *elcontracts.ContractBindings, error) { - avsRegistryContractBindings, err := config.buildAVSRegistryContractBindings(ethHttpClient, logger) - if err != nil { - return nil, nil, nil, err - } - - delegationManagerAddr, err := avsRegistryContractBindings.StakeRegistry.Delegation(&bind.CallOpts{}) - if err != nil { - logger.Fatal("Failed to fetch DelegationManager contract", "err", err) - } - avsDirectoryAddr, err := avsRegistryContractBindings.ServiceManager.AvsDirectory(&bind.CallOpts{}) - if err != nil { - logger.Fatal("Failed to fetch AVSDirectory contract", "err", err) - } - - elContractBindings, err := config.buildEigenLayerContractBindings( - delegationManagerAddr, - avsDirectoryAddr, - ethHttpClient, - logger, - ) - if err != nil { - return nil, nil, nil, utils.WrapError("Failed to create ContractBindings", err) - } - - // get the Reader for the EL contracts - elChainReader := elcontracts.NewELChainReader( - elContractBindings.Slasher, - elContractBindings.DelegationManager, - elContractBindings.StrategyManager, - elContractBindings.AvsDirectory, - logger, - ethHttpClient, - ) - - elChainWriter := elcontracts.NewELChainWriter( - elContractBindings.Slasher, - elContractBindings.DelegationManager, - elContractBindings.StrategyManager, - nil, // this is nil because we don't have access to the rewards coordinator contract right now. we are going to refactor this method later - elContractBindings.StrategyManagerAddr, - elChainReader, - ethHttpClient, - logger, - eigenMetrics, - txMgr, - ) - - return elChainReader, elChainWriter, elContractBindings, nil -} - -func (config *BuildAllConfig) BuildAVSRegistryClients( - elReader elcontracts.ELReader, - ethHttpClient eth.Client, - ethWsClient eth.Client, - txMgr txmgr.TxManager, - logger logging.Logger, -) (*avsregistry.ChainReader, *avsregistry.ChainSubscriber, *avsregistry.ChainWriter, *avsregistry.ContractBindings, error) { - - avsRegistryContractBindings, err := avsregistry.NewAVSRegistryContractBindings( - gethcommon.HexToAddress(config.RegistryCoordinatorAddr), - gethcommon.HexToAddress(config.OperatorStateRetrieverAddr), - ethHttpClient, - logger, - ) - if err != nil { - return nil, nil, nil, nil, utils.WrapError("Failed to create AVSRegistryContractBindings", err) - } - - avsRegistryChainReader := avsregistry.NewChainReader( - avsRegistryContractBindings.RegistryCoordinatorAddr, - avsRegistryContractBindings.BlsApkRegistryAddr, - avsRegistryContractBindings.RegistryCoordinator, - avsRegistryContractBindings.OperatorStateRetriever, - avsRegistryContractBindings.StakeRegistry, - logger, - ethHttpClient, - ) - - avsRegistryChainWriter, err := avsregistry.NewChainWriter( - avsRegistryContractBindings.ServiceManagerAddr, - avsRegistryContractBindings.RegistryCoordinator, - avsRegistryContractBindings.OperatorStateRetriever, - avsRegistryContractBindings.StakeRegistry, - avsRegistryContractBindings.BlsApkRegistry, - elReader, - logger, - ethHttpClient, - txMgr, - ) - if err != nil { - return nil, nil, nil, nil, utils.WrapError("Failed to create AVSRegistryChainWriter", err) - } - - // get the Subscriber for Avs Registry contracts - // note that the subscriber needs a ws connection instead of http - avsRegistrySubscriber, err := avsregistry.BuildAvsRegistryChainSubscriber( - avsRegistryContractBindings.RegistryCoordinatorAddr, - ethWsClient, - logger, - ) - if err != nil { - return nil, nil, nil, nil, utils.WrapError("Failed to create ELChainSubscriber", err) - } - - return avsRegistryChainReader, avsRegistrySubscriber, avsRegistryChainWriter, avsRegistryContractBindings, nil -} - // Very basic validation that makes sure all fields are nonempty // we might eventually want more sophisticated validation, based on regexp, // or use something like https://json-schema.org/ (?) diff --git a/chainio/clients/elcontracts/builder.go b/chainio/clients/elcontracts/builder.go index 970de2dc..d8f7265e 100644 --- a/chainio/clients/elcontracts/builder.go +++ b/chainio/clients/elcontracts/builder.go @@ -9,37 +9,37 @@ import ( func BuildClients( config Config, - ethHttpClient eth.Client, + client eth.Client, txMgr txmgr.TxManager, logger logging.Logger, eigenMetrics *metrics.EigenMetrics, -) (*ELChainReader, *ELChainWriter, *ContractBindings, error) { +) (*ChainReader, *ChainWriter, *ContractBindings, error) { elContractBindings, err := NewBindingsFromConfig( config, - ethHttpClient, + client, logger, ) if err != nil { return nil, nil, nil, err } - elChainReader := NewELChainReader( + elChainReader := NewChainReader( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, logger, - ethHttpClient, + client, ) - elChainWriter := NewELChainWriter( + elChainWriter := NewChainWriter( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.RewardsCoordinator, elContractBindings.StrategyManagerAddr, elChainReader, - ethHttpClient, + client, logger, eigenMetrics, txMgr, diff --git a/chainio/clients/elcontracts/reader.go b/chainio/clients/elcontracts/reader.go index abf7c707..fc9095af 100644 --- a/chainio/clients/elcontracts/reader.go +++ b/chainio/clients/elcontracts/reader.go @@ -20,7 +20,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/utils" ) -type ELReader interface { +type Reader interface { IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error) GetOperatorDetails(opts *bind.CallOpts, operator types.Operator) (types.Operator, error) @@ -66,7 +66,7 @@ type Config struct { RewardsCoordinatorAddress common.Address } -type ELChainReader struct { +type ChainReader struct { logger logging.Logger slasher slasher.ContractISlasherCalls delegationManager *delegationmanager.ContractDelegationManager @@ -76,19 +76,19 @@ type ELChainReader struct { } // forces EthReader to implement the chainio.Reader interface -var _ ELReader = (*ELChainReader)(nil) +var _ Reader = (*ChainReader)(nil) -func NewELChainReader( +func NewChainReader( slasher slasher.ContractISlasherCalls, delegationManager *delegationmanager.ContractDelegationManager, strategyManager *strategymanager.ContractStrategyManager, avsDirectory *avsdirectory.ContractAVSDirectory, logger logging.Logger, ethClient eth.Client, -) *ELChainReader { +) *ChainReader { logger = logger.With(logging.ComponentKey, "elcontracts/reader") - return &ELChainReader{ + return &ChainReader{ slasher: slasher, delegationManager: delegationManager, strategyManager: strategyManager, @@ -105,7 +105,7 @@ func BuildELChainReader( avsDirectoryAddr gethcommon.Address, ethClient eth.Client, logger logging.Logger, -) (*ELChainReader, error) { +) (*ChainReader, error) { elContractBindings, err := NewEigenlayerContractBindings( delegationManagerAddr, avsDirectoryAddr, @@ -115,7 +115,7 @@ func BuildELChainReader( if err != nil { return nil, err } - return NewELChainReader( + return NewChainReader( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, @@ -129,7 +129,7 @@ func NewReaderFromConfig( cfg Config, ethClient eth.Client, logger logging.Logger, -) (*ELChainReader, error) { +) (*ChainReader, error) { elContractBindings, err := NewBindingsFromConfig( cfg, ethClient, @@ -138,7 +138,7 @@ func NewReaderFromConfig( if err != nil { return nil, err } - return NewELChainReader( + return NewChainReader( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, @@ -148,7 +148,7 @@ func NewReaderFromConfig( ), nil } -func (r *ELChainReader) IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error) { +func (r *ChainReader) IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error) { if r.delegationManager == nil { return false, errors.New("DelegationManager contract not provided") } @@ -164,7 +164,7 @@ func (r *ELChainReader) IsOperatorRegistered(opts *bind.CallOpts, operator types return isOperator, nil } -func (r *ELChainReader) GetOperatorDetails(opts *bind.CallOpts, operator types.Operator) (types.Operator, error) { +func (r *ChainReader) GetOperatorDetails(opts *bind.CallOpts, operator types.Operator) (types.Operator, error) { if r.delegationManager == nil { return types.Operator{}, errors.New("DelegationManager contract not provided") } @@ -186,7 +186,7 @@ func (r *ELChainReader) GetOperatorDetails(opts *bind.CallOpts, operator types.O } // GetStrategyAndUnderlyingToken returns the strategy contract and the underlying token address -func (r *ELChainReader) GetStrategyAndUnderlyingToken( +func (r *ChainReader) GetStrategyAndUnderlyingToken( opts *bind.CallOpts, strategyAddr gethcommon.Address, ) (*strategy.ContractIStrategy, gethcommon.Address, error) { contractStrategy, err := strategy.NewContractIStrategy(strategyAddr, r.ethClient) @@ -202,7 +202,7 @@ func (r *ELChainReader) GetStrategyAndUnderlyingToken( // GetStrategyAndUnderlyingERC20Token returns the strategy contract, the erc20 bindings for the underlying token // and the underlying token address -func (r *ELChainReader) GetStrategyAndUnderlyingERC20Token( +func (r *ChainReader) GetStrategyAndUnderlyingERC20Token( opts *bind.CallOpts, strategyAddr gethcommon.Address, ) (*strategy.ContractIStrategy, erc20.ContractIERC20Methods, gethcommon.Address, error) { contractStrategy, err := strategy.NewContractIStrategy(strategyAddr, r.ethClient) @@ -220,7 +220,7 @@ func (r *ELChainReader) GetStrategyAndUnderlyingERC20Token( return contractStrategy, contractUnderlyingToken, underlyingTokenAddr, nil } -func (r *ELChainReader) ServiceManagerCanSlashOperatorUntilBlock( +func (r *ChainReader) ServiceManagerCanSlashOperatorUntilBlock( opts *bind.CallOpts, operatorAddr gethcommon.Address, serviceManagerAddr gethcommon.Address, @@ -238,7 +238,7 @@ func (r *ELChainReader) ServiceManagerCanSlashOperatorUntilBlock( return serviceManagerCanSlashOperatorUntilBlock, nil } -func (r *ELChainReader) OperatorIsFrozen(opts *bind.CallOpts, operatorAddr gethcommon.Address) (bool, error) { +func (r *ChainReader) OperatorIsFrozen(opts *bind.CallOpts, operatorAddr gethcommon.Address) (bool, error) { if r.slasher == nil { return false, errors.New("slasher contract not provided") } @@ -250,7 +250,7 @@ func (r *ELChainReader) OperatorIsFrozen(opts *bind.CallOpts, operatorAddr gethc return operatorIsFrozen, nil } -func (r *ELChainReader) GetOperatorSharesInStrategy( +func (r *ChainReader) GetOperatorSharesInStrategy( opts *bind.CallOpts, operatorAddr gethcommon.Address, strategyAddr gethcommon.Address, @@ -270,7 +270,7 @@ func (r *ELChainReader) GetOperatorSharesInStrategy( return operatorSharesInStrategy, nil } -func (r *ELChainReader) CalculateDelegationApprovalDigestHash( +func (r *ChainReader) CalculateDelegationApprovalDigestHash( opts *bind.CallOpts, staker gethcommon.Address, operator gethcommon.Address, delegationApprover gethcommon.Address, approverSalt [32]byte, expiry *big.Int, ) ([32]byte, error) { @@ -283,7 +283,7 @@ func (r *ELChainReader) CalculateDelegationApprovalDigestHash( ) } -func (r *ELChainReader) CalculateOperatorAVSRegistrationDigestHash( +func (r *ChainReader) CalculateOperatorAVSRegistrationDigestHash( opts *bind.CallOpts, operator gethcommon.Address, avs gethcommon.Address, salt [32]byte, expiry *big.Int, ) ([32]byte, error) { if r.avsDirectory == nil { diff --git a/chainio/clients/elcontracts/writer.go b/chainio/clients/elcontracts/writer.go index 0699280d..b436a2c9 100644 --- a/chainio/clients/elcontracts/writer.go +++ b/chainio/clients/elcontracts/writer.go @@ -23,7 +23,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/types" ) -type ELWriter interface { +type Writer interface { // RegisterAsOperator registers an operator onchain. RegisterAsOperator(ctx context.Context, operator types.Operator) (*gethtypes.Receipt, error) @@ -47,35 +47,35 @@ type ELWriter interface { ) (*gethtypes.Receipt, error) } -type ELChainWriter struct { +type ChainWriter struct { slasher *slasher.ContractISlasher delegationManager *delegationmanager.ContractDelegationManager strategyManager *strategymanager.ContractStrategyManager rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator strategyManagerAddr gethcommon.Address - elChainReader ELReader + elChainReader Reader ethClient eth.Client logger logging.Logger txMgr txmgr.TxManager } -var _ ELWriter = (*ELChainWriter)(nil) +var _ Writer = (*ChainWriter)(nil) -func NewELChainWriter( +func NewChainWriter( slasher *slasher.ContractISlasher, delegationManager *delegationmanager.ContractDelegationManager, strategyManager *strategymanager.ContractStrategyManager, rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator, strategyManagerAddr gethcommon.Address, - elChainReader ELReader, + elChainReader Reader, ethClient eth.Client, logger logging.Logger, eigenMetrics metrics.Metrics, txMgr txmgr.TxManager, -) *ELChainWriter { +) *ChainWriter { logger = logger.With(logging.ComponentKey, "elcontracts/writer") - return &ELChainWriter{ + return &ChainWriter{ slasher: slasher, delegationManager: delegationManager, strategyManager: strategyManager, @@ -88,7 +88,7 @@ func NewELChainWriter( } } -// BuildELChainWriter builds an ELChainWriter instance. +// BuildELChainWriter builds an ChainWriter instance. // Deprecated: Use NewWriterFromConfig instead. func BuildELChainWriter( delegationManagerAddr gethcommon.Address, @@ -97,7 +97,7 @@ func BuildELChainWriter( logger logging.Logger, eigenMetrics metrics.Metrics, txMgr txmgr.TxManager, -) (*ELChainWriter, error) { +) (*ChainWriter, error) { elContractBindings, err := NewEigenlayerContractBindings( delegationManagerAddr, avsDirectoryAddr, @@ -107,7 +107,7 @@ func BuildELChainWriter( if err != nil { return nil, err } - elChainReader := NewELChainReader( + elChainReader := NewChainReader( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, @@ -115,7 +115,7 @@ func BuildELChainWriter( logger, ethClient, ) - return NewELChainWriter( + return NewChainWriter( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, @@ -135,7 +135,7 @@ func NewWriterFromConfig( logger logging.Logger, eigenMetrics metrics.Metrics, txMgr txmgr.TxManager, -) (*ELChainWriter, error) { +) (*ChainWriter, error) { elContractBindings, err := NewBindingsFromConfig( cfg, ethClient, @@ -144,7 +144,7 @@ func NewWriterFromConfig( if err != nil { return nil, err } - elChainReader := NewELChainReader( + elChainReader := NewChainReader( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, @@ -152,7 +152,7 @@ func NewWriterFromConfig( logger, ethClient, ) - return NewELChainWriter( + return NewChainWriter( elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, @@ -166,7 +166,7 @@ func NewWriterFromConfig( ), nil } -func (w *ELChainWriter) RegisterAsOperator(ctx context.Context, operator types.Operator) (*gethtypes.Receipt, error) { +func (w *ChainWriter) RegisterAsOperator(ctx context.Context, operator types.Operator) (*gethtypes.Receipt, error) { if w.delegationManager == nil { return nil, errors.New("DelegationManager contract not provided") } @@ -195,7 +195,7 @@ func (w *ELChainWriter) RegisterAsOperator(ctx context.Context, operator types.O return receipt, nil } -func (w *ELChainWriter) UpdateOperatorDetails( +func (w *ChainWriter) UpdateOperatorDetails( ctx context.Context, operator types.Operator, ) (*gethtypes.Receipt, error) { @@ -234,7 +234,7 @@ func (w *ELChainWriter) UpdateOperatorDetails( return receipt, nil } -func (w *ELChainWriter) UpdateMetadataURI(ctx context.Context, uri string) (*gethtypes.Receipt, error) { +func (w *ChainWriter) UpdateMetadataURI(ctx context.Context, uri string) (*gethtypes.Receipt, error) { if w.delegationManager == nil { return nil, errors.New("DelegationManager contract not provided") } @@ -261,7 +261,7 @@ func (w *ELChainWriter) UpdateMetadataURI(ctx context.Context, uri string) (*get return receipt, nil } -func (w *ELChainWriter) DepositERC20IntoStrategy( +func (w *ChainWriter) DepositERC20IntoStrategy( ctx context.Context, strategyAddr gethcommon.Address, amount *big.Int, @@ -305,7 +305,7 @@ func (w *ELChainWriter) DepositERC20IntoStrategy( return receipt, nil } -func (w *ELChainWriter) SetClaimerFor( +func (w *ChainWriter) SetClaimerFor( ctx context.Context, claimer gethcommon.Address, ) (*gethtypes.Receipt, error) { diff --git a/metrics/collectors/economic/economic.go b/metrics/collectors/economic/economic.go index 89fd7cdc..533e4d37 100644 --- a/metrics/collectors/economic/economic.go +++ b/metrics/collectors/economic/economic.go @@ -25,7 +25,7 @@ import ( // so that they are exported on the same port type Collector struct { // TODO(samlaf): we use a chain as the backend for now, but should eventually move to a subgraph - elReader elcontracts.ELReader + elReader elcontracts.Reader avsRegistryReader avsregistry.Reader logger logging.Logger // params to query the metrics for @@ -62,7 +62,7 @@ type Collector struct { var _ prometheus.Collector = (*Collector)(nil) func NewCollector( - elReader elcontracts.ELReader, avsRegistryReader avsregistry.Reader, + elReader elcontracts.Reader, avsRegistryReader avsregistry.Reader, avsName string, logger logging.Logger, operatorAddr common.Address, quorumNames map[types.QuorumNum]string, ) *Collector {