From cf1bc9017e2ec374b0183f2a5a556580e1d2fda3 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Sun, 14 Jul 2024 00:01:55 -0700 Subject: [PATCH 1/3] refactored elcontracts and avsregistry builders to use wire dependency injection --- ...eck-mocks.yml => check-generate-files.yml} | 8 +- Makefile | 3 +- chainio/clients/avsregistry/reader.go | 18 +-- chainio/clients/avsregistry/subscriber.go | 22 +-- chainio/clients/avsregistry/wire_builder.go | 121 +++++++++++++++++ chainio/clients/avsregistry/wire_gen.go | 127 ++++++++++++++++++ chainio/clients/avsregistry/writer.go | 52 +++---- chainio/clients/elcontracts/builder.go | 1 + chainio/clients/elcontracts/reader.go | 36 ++--- chainio/clients/elcontracts/wire_builder.go | 61 +++++++++ chainio/clients/elcontracts/wire_gen.go | 58 ++++++++ chainio/clients/elcontracts/writer.go | 42 ++---- go.mod | 42 +++--- go.sum | 42 ++++++ 14 files changed, 494 insertions(+), 139 deletions(-) rename .github/workflows/{check-mocks.yml => check-generate-files.yml} (73%) create mode 100644 chainio/clients/avsregistry/wire_builder.go create mode 100644 chainio/clients/avsregistry/wire_gen.go create mode 100644 chainio/clients/elcontracts/wire_builder.go create mode 100644 chainio/clients/elcontracts/wire_gen.go diff --git a/.github/workflows/check-mocks.yml b/.github/workflows/check-generate-files.yml similarity index 73% rename from .github/workflows/check-mocks.yml rename to .github/workflows/check-generate-files.yml index a6b6c23d..798cbddf 100644 --- a/.github/workflows/check-mocks.yml +++ b/.github/workflows/check-generate-files.yml @@ -1,4 +1,4 @@ -name: check mocks up-to-date +name: check generated files (mocks+wire) up-to-date on: push: branches: @@ -10,7 +10,7 @@ permissions: jobs: make-mocks: - name: make mocks and check for diffs + name: make generate (mocks+wire) and check for diffs runs-on: ubuntu-latest steps: - name: checkout repo @@ -21,9 +21,9 @@ jobs: with: go-version: "1.21" - - name: run make mocks and check for diffs + - name: run make generate and check for diffs run: | - make mocks + make generate if [ ! -z "$(git status --porcelain)" ]; then printf "Current generated mocks not up to date\n" git diff diff --git a/Makefile b/Makefile index 97bc876e..19bc0997 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,9 @@ help: bindings: ## generates contract bindings cd contracts && rm -rf bindings/* && ./generate-bindings.sh -mocks: ## generates mocks +generate: ## generates mocks and wire files go install go.uber.org/mock/mockgen@v0.4.0 + go install github.com/google/wire/cmd/wire@v0.6.0 go generate ./... tests: ## runs all tests diff --git a/chainio/clients/avsregistry/reader.go b/chainio/clients/avsregistry/reader.go index 64120b40..801e6347 100644 --- a/chainio/clients/avsregistry/reader.go +++ b/chainio/clients/avsregistry/reader.go @@ -128,17 +128,11 @@ func NewChainReader( } } -// NewReaderFromConfig creates a new ChainReader -func NewReaderFromConfig( - cfg Config, - client eth.Client, +func NewChainReaderFromBindings( + bindings *ContractBindings, + ethClient eth.Client, logger logging.Logger, -) (*ChainReader, error) { - bindings, err := NewBindingsFromConfig(cfg, client, logger) - if err != nil { - return nil, err - } - +) *ChainReader { return NewChainReader( bindings.RegistryCoordinatorAddr, bindings.BlsApkRegistryAddr, @@ -146,8 +140,8 @@ func NewReaderFromConfig( bindings.OperatorStateRetriever, bindings.StakeRegistry, logger, - client, - ), nil + ethClient, + ) } // BuildAvsRegistryChainReader creates a new ChainReader diff --git a/chainio/clients/avsregistry/subscriber.go b/chainio/clients/avsregistry/subscriber.go index 26f3dde2..a64dee2c 100644 --- a/chainio/clients/avsregistry/subscriber.go +++ b/chainio/clients/avsregistry/subscriber.go @@ -42,6 +42,13 @@ func NewChainSubscriber( } } +func NewChainSubscriberFromBindings( + bindings *ContractBindings, + logger logging.Logger, +) *ChainSubscriber { + return NewChainSubscriber(bindings.RegistryCoordinator, bindings.BlsApkRegistry, logger) +} + // BuildAvsRegistryChainSubscriber creates a new instance of ChainSubscriber // Deprecated: Use NewSubscriberFromConfig instead func BuildAvsRegistryChainSubscriber( @@ -64,21 +71,6 @@ func BuildAvsRegistryChainSubscriber( return NewChainSubscriber(regCoord, blsApkReg, logger), nil } -// NewSubscriberFromConfig creates a new instance of ChainSubscriber -// A websocket ETH Client must be provided -func NewSubscriberFromConfig( - cfg Config, - wsClient eth.Client, - logger logging.Logger, -) (*ChainSubscriber, error) { - bindings, err := NewBindingsFromConfig(cfg, wsClient, logger) - if err != nil { - return nil, err - } - - return NewChainSubscriber(bindings.RegistryCoordinator, bindings.BlsApkRegistry, logger), nil -} - func (s *ChainSubscriber) SubscribeToNewPubkeyRegistrations() (chan *blsapkreg.ContractBLSApkRegistryNewPubkeyRegistration, event.Subscription, error) { newPubkeyRegistrationChan := make(chan *blsapkreg.ContractBLSApkRegistryNewPubkeyRegistration) sub, err := s.blsApkRegistry.WatchNewPubkeyRegistration( diff --git a/chainio/clients/avsregistry/wire_builder.go b/chainio/clients/avsregistry/wire_builder.go new file mode 100644 index 00000000..51dc522d --- /dev/null +++ b/chainio/clients/avsregistry/wire_builder.go @@ -0,0 +1,121 @@ +//go:build wireinject +// +build wireinject + +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" + "github.com/google/wire" +) + +func NewReaderFromConfig( + cfg Config, + ethClient eth.Client, + logger logging.Logger, +) (*ChainReader, error) { + wire.Build(NewBindingsFromConfig, NewChainReaderFromBindings) + return &ChainReader{}, nil +} + +// including here because needed in NewWriterFromConfig +func NewElConfigFromAvsBindings( + bindings *ContractBindings, +) elcontracts.Config { + return elcontracts.Config{ + // TODO: missing RewardsCoordinatorAddr in bindings, because no other contract points to + // RewardsCoordinator so bindings doesn't return that address... + // Ways to fix this bug: + // 1. Make some other contract point to RewardsCoordinator so we can get the address from bindings + // 2. Pass RewardsCoordinatorAddr as a parameter to NewAVSRegistryContractBindings + // 3. Pass RewardsCoordinatorAddr as a parameter to this function and NewWriterFromConfig + DelegationManagerAddress: bindings.DelegationManagerAddr, + AvsDirectoryAddress: bindings.AvsDirectoryAddr, + } +} + +func NewWriterFromConfig( + cfg Config, + ethClient eth.Client, + txMgr txmgr.TxManager, + logger logging.Logger, +) (*ChainWriter, error) { + wire.Build( + NewBindingsFromConfig, + NewElConfigFromAvsBindings, + elcontracts.NewReaderFromConfig, + wire.Bind(new(elcontracts.Reader), new(*elcontracts.ChainReader)), + NewChainWriterFromBindings, + ) + return &ChainWriter{}, nil +} + +// Note that unlike reader/writer, a websocket eth client must be provided +func NewSubscriberFromConfig( + cfg Config, + wsClient eth.Client, + logger logging.Logger, +) (*ChainSubscriber, error) { + wire.Build(NewBindingsFromConfig, NewChainSubscriberFromBindings) + return &ChainSubscriber{}, nil +} + +type ClientsAndBindings struct { + ChainReader *ChainReader + ChainWriter *ChainWriter + ChainSubscriber *ChainSubscriber + ContractBindings *ContractBindings +} + +// ============= Workaround Code ================= +// this section is needed because wire does not allow a Build dependency graph +// with two dependencies of the same type. See: +// https://github.com/google/wire/blob/main/docs/faq.md#what-if-my-dependency-graph-has-two-dependencies-of-the-same-type +// In BuildClientsFromConfig since both ethHttpClient and ethWsClient have type eth.Client, +// we need to wrap one of them in a new type to avoid the error. +type ethWsClient eth.Client + +func newEthWsClient( + wsClient eth.Client, +) ethWsClient { + return (ethWsClient)(wsClient) +} + +func newSubscriberFromConfigWithEthWsClientType( + cfg Config, + wsClient ethWsClient, + logger logging.Logger, +) (*ChainSubscriber, error) { + return NewSubscriberFromConfig(cfg, eth.Client(wsClient), logger) +} + +func buildClientsFromConfig( + cfg Config, + ethHttpClient eth.Client, + ethWsClient ethWsClient, + txMgr txmgr.TxManager, + logger logging.Logger, +) (*ClientsAndBindings, error) { + wire.Build( + NewBindingsFromConfig, + NewReaderFromConfig, + NewWriterFromConfig, + newSubscriberFromConfigWithEthWsClientType, + wire.Struct(new(ClientsAndBindings), "*"), + ) + return &ClientsAndBindings{}, nil +} + +// ============= End of Workaround Code ================= + +func BuildClientsFromConfig( + cfg Config, + ethHttpClient eth.Client, + ethWsClient eth.Client, + txMgr txmgr.TxManager, + logger logging.Logger, +) (*ClientsAndBindings, error) { + return buildClientsFromConfig(cfg, ethHttpClient, ethWsClient, txMgr, logger) +} diff --git a/chainio/clients/avsregistry/wire_gen.go b/chainio/clients/avsregistry/wire_gen.go new file mode 100644 index 00000000..5e75e51d --- /dev/null +++ b/chainio/clients/avsregistry/wire_gen.go @@ -0,0 +1,127 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +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" +) + +// Injectors from wire_builder.go: + +func NewReaderFromConfig(cfg Config, ethClient eth.Client, logger logging.Logger) (*ChainReader, error) { + contractBindings, err := NewBindingsFromConfig(cfg, ethClient, logger) + if err != nil { + return nil, err + } + chainReader := NewChainReaderFromBindings(contractBindings, ethClient, logger) + return chainReader, nil +} + +func NewWriterFromConfig(cfg Config, ethClient eth.Client, txMgr txmgr.TxManager, logger logging.Logger) (*ChainWriter, error) { + contractBindings, err := NewBindingsFromConfig(cfg, ethClient, logger) + if err != nil { + return nil, err + } + config := NewElConfigFromAvsBindings(contractBindings) + chainReader, err := elcontracts.NewReaderFromConfig(config, ethClient, logger) + if err != nil { + return nil, err + } + chainWriter := NewChainWriterFromBindings(contractBindings, chainReader, logger, ethClient, txMgr) + return chainWriter, nil +} + +// Note that unlike reader/writer, a websocket eth client must be provided +func NewSubscriberFromConfig(cfg Config, wsClient eth.Client, logger logging.Logger) (*ChainSubscriber, error) { + contractBindings, err := NewBindingsFromConfig(cfg, wsClient, logger) + if err != nil { + return nil, err + } + chainSubscriber := NewChainSubscriberFromBindings(contractBindings, logger) + return chainSubscriber, nil +} + +func buildClientsFromConfig(cfg Config, ethHttpClient eth.Client, ethWsClient2 ethWsClient, txMgr txmgr.TxManager, logger logging.Logger) (*ClientsAndBindings, error) { + chainReader, err := NewReaderFromConfig(cfg, ethHttpClient, logger) + if err != nil { + return nil, err + } + chainWriter, err := NewWriterFromConfig(cfg, ethHttpClient, txMgr, logger) + if err != nil { + return nil, err + } + chainSubscriber, err := newSubscriberFromConfigWithEthWsClientType(cfg, ethWsClient2, logger) + if err != nil { + return nil, err + } + contractBindings, err := NewBindingsFromConfig(cfg, ethHttpClient, logger) + if err != nil { + return nil, err + } + clientsAndBindings := &ClientsAndBindings{ + ChainReader: chainReader, + ChainWriter: chainWriter, + ChainSubscriber: chainSubscriber, + ContractBindings: contractBindings, + } + return clientsAndBindings, nil +} + +// wire_builder.go: + +// including here because needed in NewWriterFromConfig +func NewElConfigFromAvsBindings( + bindings *ContractBindings, +) elcontracts.Config { + return elcontracts.Config{ + + DelegationManagerAddress: bindings.DelegationManagerAddr, + AvsDirectoryAddress: bindings.AvsDirectoryAddr, + } +} + +type ClientsAndBindings struct { + ChainReader *ChainReader + ChainWriter *ChainWriter + ChainSubscriber *ChainSubscriber + ContractBindings *ContractBindings +} + +// ============= Workaround Code ================= +// this section is needed because wire does not allow a Build dependency graph +// with two dependencies of the same type. See: +// https://github.com/google/wire/blob/main/docs/faq.md#what-if-my-dependency-graph-has-two-dependencies-of-the-same-type +// In BuildClientsFromConfig since both ethHttpClient and ethWsClient have type eth.Client, +// we need to wrap one of them in a new type to avoid the error. +type ethWsClient eth.Client + +func newEthWsClient( + wsClient eth.Client, +) ethWsClient { + return (ethWsClient)(wsClient) +} + +func newSubscriberFromConfigWithEthWsClientType( + cfg Config, + wsClient ethWsClient, + logger logging.Logger, +) (*ChainSubscriber, error) { + return NewSubscriberFromConfig(cfg, eth.Client(wsClient), logger) +} + +func BuildClientsFromConfig( + cfg Config, + ethHttpClient eth.Client, ethWsClient2 eth.Client, + + txMgr txmgr.TxManager, + logger logging.Logger, +) (*ClientsAndBindings, error) { + return buildClientsFromConfig(cfg, ethHttpClient, ethWsClient2, txMgr, logger) +} diff --git a/chainio/clients/avsregistry/writer.go b/chainio/clients/avsregistry/writer.go index 1747faf0..abd61542 100644 --- a/chainio/clients/avsregistry/writer.go +++ b/chainio/clients/avsregistry/writer.go @@ -128,6 +128,26 @@ func NewChainWriter( } } +func NewChainWriterFromBindings( + bindings *ContractBindings, + elReader elcontracts.Reader, + logger logging.Logger, + ethClient eth.Client, + txMgr txmgr.TxManager, +) *ChainWriter { + return NewChainWriter( + bindings.ServiceManagerAddr, + bindings.RegistryCoordinator, + bindings.OperatorStateRetriever, + bindings.StakeRegistry, + bindings.BlsApkRegistry, + elReader, + logger, + ethClient, + txMgr, + ) +} + // BuildAvsRegistryChainWriter creates a new ChainWriter instance from the provided contract addresses // Deprecated: Use NewWriterFromConfig instead func BuildAvsRegistryChainWriter( @@ -197,38 +217,6 @@ func BuildAvsRegistryChainWriter( ), nil } -// NewWriterFromConfig creates a new ChainWriter from the provided config -func NewWriterFromConfig( - cfg Config, - client eth.Client, - txMgr txmgr.TxManager, - logger logging.Logger, -) (*ChainWriter, error) { - bindings, err := NewBindingsFromConfig(cfg, client, logger) - if err != nil { - return nil, err - } - elReader, err := elcontracts.NewReaderFromConfig(elcontracts.Config{ - DelegationManagerAddress: bindings.DelegationManagerAddr, - AvsDirectoryAddress: bindings.AvsDirectoryAddr, - }, client, logger) - if err != nil { - return nil, err - } - - return NewChainWriter( - bindings.ServiceManagerAddr, - bindings.RegistryCoordinator, - bindings.OperatorStateRetriever, - bindings.StakeRegistry, - bindings.BlsApkRegistry, - elReader, - logger, - client, - txMgr, - ), nil -} - func (w *ChainWriter) RegisterOperatorInQuorumWithAVSRegistryCoordinator( ctx context.Context, // we need to pass the private key explicitly and can't use the signer because registering requires signing a diff --git a/chainio/clients/elcontracts/builder.go b/chainio/clients/elcontracts/builder.go index ba966d6c..74b0b7a4 100644 --- a/chainio/clients/elcontracts/builder.go +++ b/chainio/clients/elcontracts/builder.go @@ -7,6 +7,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/metrics" ) +// Deprecated: Use BuildClientsFromConfig instead. func BuildClients( config Config, client eth.Client, diff --git a/chainio/clients/elcontracts/reader.go b/chainio/clients/elcontracts/reader.go index 05db2c30..dedc50ed 100644 --- a/chainio/clients/elcontracts/reader.go +++ b/chainio/clients/elcontracts/reader.go @@ -107,6 +107,18 @@ func NewChainReader( } } +func NewChainReaderFromBindings(bindings *ContractBindings, ethClient eth.Client, logger logging.Logger) *ChainReader { + return NewChainReader( + bindings.Slasher, + bindings.DelegationManager, + bindings.StrategyManager, + bindings.AvsDirectory, + bindings.RewardsCoordinator, + logger, + ethClient, + ) +} + // BuildELChainReader creates a new ELChainReader // Deprecated: Use BuildFromConfig instead func BuildELChainReader( @@ -135,30 +147,6 @@ func BuildELChainReader( ), nil } -func NewReaderFromConfig( - cfg Config, - ethClient eth.Client, - logger logging.Logger, -) (*ChainReader, error) { - elContractBindings, err := NewBindingsFromConfig( - cfg, - ethClient, - logger, - ) - if err != nil { - return nil, err - } - return NewChainReader( - elContractBindings.Slasher, - elContractBindings.DelegationManager, - elContractBindings.StrategyManager, - elContractBindings.AvsDirectory, - elContractBindings.RewardsCoordinator, - logger, - ethClient, - ), nil -} - func (r *ChainReader) IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error) { if r.delegationManager == nil { return false, errors.New("DelegationManager contract not provided") diff --git a/chainio/clients/elcontracts/wire_builder.go b/chainio/clients/elcontracts/wire_builder.go new file mode 100644 index 00000000..b4379fb8 --- /dev/null +++ b/chainio/clients/elcontracts/wire_builder.go @@ -0,0 +1,61 @@ +//go:build wireinject +// +build wireinject + +package elcontracts + +import ( + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" + "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/metrics" + "github.com/google/wire" +) + +func NewReaderFromConfig( + cfg Config, + ethClient eth.Client, + logger logging.Logger, +) (*ChainReader, error) { + wire.Build(NewBindingsFromConfig, NewChainReaderFromBindings) + return &ChainReader{}, nil +} + +func NewWriterFromConfig( + cfg Config, + ethClient eth.Client, + logger logging.Logger, + eigenMetrics metrics.Metrics, + txMgr txmgr.TxManager, +) (*ChainWriter, error) { + wire.Build( + NewBindingsFromConfig, + NewChainReaderFromBindings, + wire.Bind(new(Reader), new(*ChainReader)), + NewChainWriterFromBindings, + ) + return &ChainWriter{}, nil +} + +type ClientsAndBindings struct { + ChainReader *ChainReader + ChainWriter *ChainWriter + ContractBindings *ContractBindings +} + +func BuildClientsFromConfig( + cfg Config, + ethClient eth.Client, + logger logging.Logger, + eigenMetrics *metrics.EigenMetrics, + txMgr txmgr.TxManager, +) (*ClientsAndBindings, error) { + wire.Build( + NewBindingsFromConfig, + NewChainReaderFromBindings, + wire.Bind(new(Reader), new(*ChainReader)), + wire.Bind(new(metrics.Metrics), new(*metrics.EigenMetrics)), + NewChainWriterFromBindings, + wire.Struct(new(ClientsAndBindings), "*"), + ) + return &ClientsAndBindings{}, nil +} diff --git a/chainio/clients/elcontracts/wire_gen.go b/chainio/clients/elcontracts/wire_gen.go new file mode 100644 index 00000000..dc5861a3 --- /dev/null +++ b/chainio/clients/elcontracts/wire_gen.go @@ -0,0 +1,58 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +package elcontracts + +import ( + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" + "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/metrics" +) + +// Injectors from wire_builder.go: + +func NewReaderFromConfig(cfg Config, ethClient eth.Client, logger logging.Logger) (*ChainReader, error) { + contractBindings, err := NewBindingsFromConfig(cfg, ethClient, logger) + if err != nil { + return nil, err + } + chainReader := NewChainReaderFromBindings(contractBindings, ethClient, logger) + return chainReader, nil +} + +func NewWriterFromConfig(cfg Config, ethClient eth.Client, logger logging.Logger, eigenMetrics metrics.Metrics, txMgr txmgr.TxManager) (*ChainWriter, error) { + contractBindings, err := NewBindingsFromConfig(cfg, ethClient, logger) + if err != nil { + return nil, err + } + chainReader := NewChainReaderFromBindings(contractBindings, ethClient, logger) + chainWriter := NewChainWriterFromBindings(contractBindings, chainReader, ethClient, logger, eigenMetrics, txMgr) + return chainWriter, nil +} + +func BuildClientsFromConfig(cfg Config, ethClient eth.Client, logger logging.Logger, eigenMetrics *metrics.EigenMetrics, txMgr txmgr.TxManager) (*ClientsAndBindings, error) { + contractBindings, err := NewBindingsFromConfig(cfg, ethClient, logger) + if err != nil { + return nil, err + } + chainReader := NewChainReaderFromBindings(contractBindings, ethClient, logger) + chainWriter := NewChainWriterFromBindings(contractBindings, chainReader, ethClient, logger, eigenMetrics, txMgr) + clientsAndBindings := &ClientsAndBindings{ + ChainReader: chainReader, + ChainWriter: chainWriter, + ContractBindings: contractBindings, + } + return clientsAndBindings, nil +} + +// wire_builder.go: + +type ClientsAndBindings struct { + ChainReader *ChainReader + ChainWriter *ChainWriter + ContractBindings *ContractBindings +} diff --git a/chainio/clients/elcontracts/writer.go b/chainio/clients/elcontracts/writer.go index c426c258..3fb16ac5 100644 --- a/chainio/clients/elcontracts/writer.go +++ b/chainio/clients/elcontracts/writer.go @@ -94,34 +94,14 @@ func NewChainWriter( } } -// BuildELChainWriter builds an ChainWriter instance. -// Deprecated: Use NewWriterFromConfig instead. -func BuildELChainWriter( - delegationManagerAddr gethcommon.Address, - avsDirectoryAddr gethcommon.Address, +func NewChainWriterFromBindings( + elContractBindings *ContractBindings, + elChainReader Reader, ethClient eth.Client, logger logging.Logger, eigenMetrics metrics.Metrics, txMgr txmgr.TxManager, -) (*ChainWriter, error) { - elContractBindings, err := NewEigenlayerContractBindings( - delegationManagerAddr, - avsDirectoryAddr, - ethClient, - logger, - ) - if err != nil { - return nil, err - } - elChainReader := NewChainReader( - elContractBindings.Slasher, - elContractBindings.DelegationManager, - elContractBindings.StrategyManager, - elContractBindings.AvsDirectory, - elContractBindings.RewardsCoordinator, - logger, - ethClient, - ) +) *ChainWriter { return NewChainWriter( elContractBindings.Slasher, elContractBindings.DelegationManager, @@ -133,18 +113,22 @@ func BuildELChainWriter( logger, eigenMetrics, txMgr, - ), nil + ) } -func NewWriterFromConfig( - cfg Config, +// BuildELChainWriter builds an ChainWriter instance. +// Deprecated: Use NewWriterFromConfig instead. +func BuildELChainWriter( + delegationManagerAddr gethcommon.Address, + avsDirectoryAddr gethcommon.Address, ethClient eth.Client, logger logging.Logger, eigenMetrics metrics.Metrics, txMgr txmgr.TxManager, ) (*ChainWriter, error) { - elContractBindings, err := NewBindingsFromConfig( - cfg, + elContractBindings, err := NewEigenlayerContractBindings( + delegationManagerAddr, + avsDirectoryAddr, ethClient, logger, ) diff --git a/go.mod b/go.mod index 7e996799..c4caf7d9 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,10 @@ require ( github.com/consensys/gnark-crypto v0.12.1 github.com/ethereum/go-ethereum v1.14.0 github.com/google/uuid v1.6.0 + github.com/google/wire v0.6.0 github.com/lmittmann/tint v1.0.4 github.com/prometheus/client_golang v1.19.0 + github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 github.com/stretchr/testify v1.9.0 github.com/testcontainers/testcontainers-go v0.30.0 github.com/urfave/cli/v2 v2.27.1 @@ -18,38 +20,25 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/aws/aws-sdk-go-v2 v1.26.1 + github.com/aws/aws-sdk-go-v2/config v1.27.11 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 // indirect + github.com/aws/aws-sdk-go-v2/service/kms v1.31.0 + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.6 github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect github.com/aws/smithy-go v1.20.2 // indirect - github.com/distribution/reference v0.5.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/go-logr/logr v1.4.1 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/moby/sys/user v0.1.0 // indirect - github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect -) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/Microsoft/hcsshim v0.11.4 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect - github.com/aws/aws-sdk-go-v2 v1.26.1 - github.com/aws/aws-sdk-go-v2/config v1.27.11 - github.com/aws/aws-sdk-go-v2/service/kms v1.31.0 - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.6 github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect @@ -64,11 +53,15 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/distribution/reference v0.5.0 // indirect github.com/docker/docker v25.0.5+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible @@ -81,6 +74,7 @@ require ( github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/moby/patternmatcher v0.6.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/sys/user v0.1.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect @@ -101,6 +95,10 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect diff --git a/go.sum b/go.sum index d95b471e..6d89adf3 100644 --- a/go.sum +++ b/go.sum @@ -140,6 +140,7 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -149,6 +150,8 @@ github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= +github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= @@ -275,6 +278,7 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRT github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= @@ -304,41 +308,75 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -347,6 +385,10 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 77c60bcc561c921b3176973097b629a8daa4efa0 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Sun, 14 Jul 2024 00:53:04 -0700 Subject: [PATCH 2/3] make lint and make generate --- chainio/clients/builder.go | 2 +- chainio/clients/elcontracts/wire_builder.go | 18 ++++++++++++++++-- chainio/clients/elcontracts/wire_gen.go | 16 +++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/chainio/clients/builder.go b/chainio/clients/builder.go index c3f4b320..120a2ec7 100644 --- a/chainio/clients/builder.go +++ b/chainio/clients/builder.go @@ -104,7 +104,7 @@ func BuildAll( } // creating EL clients: Reader, Writer and EigenLayer Contract Bindings - elChainReader, elChainWriter, elContractBindings, err := elcontracts.BuildClients( + elChainReader, elChainWriter, elContractBindings, err := elcontracts.BuildClientsFromConfig( elcontracts.Config{ DelegationManagerAddress: avsRegistryContractBindings.DelegationManagerAddr, AvsDirectoryAddress: avsRegistryContractBindings.AvsDirectoryAddr, diff --git a/chainio/clients/elcontracts/wire_builder.go b/chainio/clients/elcontracts/wire_builder.go index b4379fb8..47a4075e 100644 --- a/chainio/clients/elcontracts/wire_builder.go +++ b/chainio/clients/elcontracts/wire_builder.go @@ -42,12 +42,12 @@ type ClientsAndBindings struct { ContractBindings *ContractBindings } -func BuildClientsFromConfig( +func buildClientsFromConfig( cfg Config, ethClient eth.Client, + txMgr txmgr.TxManager, logger logging.Logger, eigenMetrics *metrics.EigenMetrics, - txMgr txmgr.TxManager, ) (*ClientsAndBindings, error) { wire.Build( NewBindingsFromConfig, @@ -59,3 +59,17 @@ func BuildClientsFromConfig( ) return &ClientsAndBindings{}, nil } + +func BuildClientsFromConfig( + cfg Config, + ethClient eth.Client, + txMgr txmgr.TxManager, + logger logging.Logger, + eigenMetrics *metrics.EigenMetrics, +) (*ChainReader, *ChainWriter, *ContractBindings, error) { + clientsAndBindings, err := buildClientsFromConfig(cfg, ethClient, txMgr, logger, eigenMetrics) + if err != nil { + return nil, nil, nil, err + } + return clientsAndBindings.ChainReader, clientsAndBindings.ChainWriter, clientsAndBindings.ContractBindings, nil +} diff --git a/chainio/clients/elcontracts/wire_gen.go b/chainio/clients/elcontracts/wire_gen.go index dc5861a3..454de766 100644 --- a/chainio/clients/elcontracts/wire_gen.go +++ b/chainio/clients/elcontracts/wire_gen.go @@ -34,7 +34,7 @@ func NewWriterFromConfig(cfg Config, ethClient eth.Client, logger logging.Logger return chainWriter, nil } -func BuildClientsFromConfig(cfg Config, ethClient eth.Client, logger logging.Logger, eigenMetrics *metrics.EigenMetrics, txMgr txmgr.TxManager) (*ClientsAndBindings, error) { +func buildClientsFromConfig(cfg Config, ethClient eth.Client, txMgr txmgr.TxManager, logger logging.Logger, eigenMetrics *metrics.EigenMetrics) (*ClientsAndBindings, error) { contractBindings, err := NewBindingsFromConfig(cfg, ethClient, logger) if err != nil { return nil, err @@ -56,3 +56,17 @@ type ClientsAndBindings struct { ChainWriter *ChainWriter ContractBindings *ContractBindings } + +func BuildClientsFromConfig( + cfg Config, + ethClient eth.Client, + txMgr txmgr.TxManager, + logger logging.Logger, + eigenMetrics *metrics.EigenMetrics, +) (*ChainReader, *ChainWriter, *ContractBindings, error) { + clientsAndBindings, err := buildClientsFromConfig(cfg, ethClient, txMgr, logger, eigenMetrics) + if err != nil { + return nil, nil, nil, err + } + return clientsAndBindings.ChainReader, clientsAndBindings.ChainWriter, clientsAndBindings.ContractBindings, nil +} From 401d9c5a2485f06e47d538d2b8dcce3105ddfe30 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Sun, 14 Jul 2024 00:59:15 -0700 Subject: [PATCH 3/3] add explicit google/subcommands dependency to tools.go --- go.mod | 1 + go.sum | 1 + tools.go | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 tools.go diff --git a/go.mod b/go.mod index c4caf7d9..0e618992 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/aws/aws-sdk-go-v2/credentials v1.17.11 github.com/consensys/gnark-crypto v0.12.1 github.com/ethereum/go-ethereum v1.14.0 + github.com/google/subcommands v1.2.0 github.com/google/uuid v1.6.0 github.com/google/wire v0.6.0 github.com/lmittmann/tint v1.0.4 diff --git a/go.sum b/go.sum index 6d89adf3..79959dae 100644 --- a/go.sum +++ b/go.sum @@ -147,6 +147,7 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/tools.go b/tools.go new file mode 100644 index 00000000..549b3a6c --- /dev/null +++ b/tools.go @@ -0,0 +1,8 @@ +// +build tools + +package tools + +import ( + // required for go generate to work + _ "github.com/google/subcommands" +) \ No newline at end of file