diff --git a/Makefile b/Makefile index b34576a4..970162d7 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ mocks: ## generates mocks go generate ./... tests: ## runs all tests - go test ./... -covermode=atomic + go test ./... -covermode=atomic -timeout=30s tests-cover: ## run all tests with test coverge go test ./... -coverprofile=coverage.out -covermode=atomic -v -count=1 diff --git a/chainio/clients/avs_registry_contracts_client.go b/chainio/clients/avs_registry_contracts_client.go deleted file mode 100644 index 11071d64..00000000 --- a/chainio/clients/avs_registry_contracts_client.go +++ /dev/null @@ -1,219 +0,0 @@ -package clients - -import ( - "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - blsoperatorstateretrievar "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" - blspubkeyregistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPubkeyRegistry" - regcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" - "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/Layr-Labs/eigensdk-go/types" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - gethcommon "github.com/ethereum/go-ethereum/common" - gethTypes "github.com/ethereum/go-ethereum/core/types" -) - -type AVSRegistryContractsClient interface { - RegisterOperatorWithCoordinator( - opts *bind.TransactOpts, - quorumNumbers []byte, - pubkey regcoord.BN254G1Point, - socket string, - ) (*gethTypes.Transaction, error) - - GetOperatorId( - opts *bind.CallOpts, - operatorAddress gethcommon.Address, - ) ([32]byte, error) - - GetCurrentOperatorStakeForQuorum( - opts *bind.CallOpts, - operatorId types.OperatorId, - quorumNum types.QuorumNum, - ) (types.StakeAmount, error) - - GetOperatorQuorumsAtCurrentBlock( - opts *bind.CallOpts, - operatorId types.OperatorId, - ) ([]types.QuorumNum, error) - - GetOperatorsStakeInQuorumsAtBlock( - opts *bind.CallOpts, - quorumNumbers []types.QuorumNum, - blockNumber uint32, - ) ([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) - - GetOperatorsStakeInQuorumsOfOperatorAtBlock( - opts *bind.CallOpts, - operatorId types.OperatorId, - blockNumber uint32, - ) ([]types.QuorumNum, [][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) - - GetCheckSignaturesIndices( - opts *bind.CallOpts, - referenceBlockNumber uint32, - quorumNumbers []byte, - nonSignerOperatorIds [][32]byte, - ) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) - - UpdateStakes( - opts *bind.TransactOpts, - operators []gethcommon.Address, - ) (*gethTypes.Transaction, error) - - DeregisterOperator( - opts *bind.TransactOpts, - operator gethcommon.Address, - quorumNumbers []byte, - pubkey blspubkeyregistry.BN254G1Point, - ) (*gethTypes.Transaction, error) -} - -type AvsRegistryContractsChainClient struct { - avsRegistryBindings *avsRegistryContractBindings - ethHttpClient eth.EthClient - registryCoordinatorAddr gethcommon.Address - logger logging.Logger -} - -var _ AVSRegistryContractsClient = (*AvsRegistryContractsChainClient)(nil) - -func NewAvsRegistryContractsChainClient( - blsRegistryCoordinatorAddr gethcommon.Address, - blsOperatorStateRetrieverAddr gethcommon.Address, - stakeregistryAddr gethcommon.Address, - blsPubkeyRegistryAddr gethcommon.Address, - ethClient eth.EthClient, - logger logging.Logger, -) (*AvsRegistryContractsChainClient, error) { - avsRegistryBindings, err := newAVSRegistryContractBindings( - blsRegistryCoordinatorAddr, - blsOperatorStateRetrieverAddr, - stakeregistryAddr, - blsPubkeyRegistryAddr, - ethClient, - logger) - if err != nil { - return nil, err - } - - return &AvsRegistryContractsChainClient{ - avsRegistryBindings: avsRegistryBindings, - ethHttpClient: ethClient, - registryCoordinatorAddr: blsRegistryCoordinatorAddr, - logger: logger, - }, nil -} - -// Registration specific functions -func (a *AvsRegistryContractsChainClient) RegisterOperatorWithCoordinator( - opts *bind.TransactOpts, - quorumNumbers []byte, - pubkey regcoord.BN254G1Point, - socket string, -) (*gethTypes.Transaction, error) { - return a.avsRegistryBindings.RegistryCoordinator.RegisterOperatorWithCoordinator1( - opts, - quorumNumbers, - pubkey, - socket, - ) -} - -func (a *AvsRegistryContractsChainClient) GetOperatorId( - opts *bind.CallOpts, - operatorAddress gethcommon.Address, -) ([32]byte, error) { - return a.avsRegistryBindings.RegistryCoordinator.GetOperatorId(opts, operatorAddress) -} - -func (a *AvsRegistryContractsChainClient) GetOperatorsStakeInQuorumsAtBlock( - opts *bind.CallOpts, - quorumNumbers []byte, - blockNumber uint32, -) ([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) { - return a.avsRegistryBindings.BlsOperatorStateRetriever.GetOperatorState( - opts, - a.registryCoordinatorAddr, - quorumNumbers, - blockNumber) -} - -func (a *AvsRegistryContractsChainClient) GetCurrentOperatorStakeForQuorum( - opts *bind.CallOpts, - operatorId types.OperatorId, - quorumNum types.QuorumNum, -) (types.StakeAmount, error) { - return a.avsRegistryBindings.StakeRegistry.GetCurrentOperatorStakeForQuorum(opts, operatorId, quorumNum) -} - -// registry currently only has a fct to retrieve operatorQuorums at current block -// if we need it at a specific block, we first need to call -// getQuorumBitmapIndicesByOperatorIdsAtBlockNumber to get the index of the quorum bitmap -// followed by getQuorumBitmapByOperatorIdAtBlockNumberByIndex -func (a *AvsRegistryContractsChainClient) GetOperatorQuorumsAtCurrentBlock( - opts *bind.CallOpts, - operatorId types.OperatorId, -) ([]types.QuorumNum, error) { - quorumBitmap, err := a.avsRegistryBindings.RegistryCoordinator.GetCurrentQuorumBitmapByOperatorId(opts, operatorId) - if err != nil { - return nil, err - } - quorums := types.BitmapToQuorumIds(quorumBitmap) - return quorums, nil -} - -func (a *AvsRegistryContractsChainClient) GetOperatorsStakeInQuorumsOfOperatorAtBlock( - opts *bind.CallOpts, - operatorId types.OperatorId, - blockNumber uint32, -) ([]types.QuorumNum, [][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) { - quorumBitmap, blsOperatorStateRetrieverOperator, err := a.avsRegistryBindings.BlsOperatorStateRetriever.GetOperatorState0( - opts, - a.registryCoordinatorAddr, - operatorId, - blockNumber, - ) - if err != nil { - return nil, nil, err - } - quorums := types.BitmapToQuorumIds(quorumBitmap) - return quorums, blsOperatorStateRetrieverOperator, nil -} - -func (a *AvsRegistryContractsChainClient) GetCheckSignaturesIndices( - opts *bind.CallOpts, - referenceBlockNumber uint32, - quorumNumbers []byte, - nonSignerOperatorIds [][32]byte, -) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { - return a.avsRegistryBindings.BlsOperatorStateRetriever.GetCheckSignaturesIndices( - opts, - a.registryCoordinatorAddr, - referenceBlockNumber, - quorumNumbers, - nonSignerOperatorIds) -} - -func (a *AvsRegistryContractsChainClient) UpdateStakes( - opts *bind.TransactOpts, - operators []gethcommon.Address, -) (*gethTypes.Transaction, error) { - return a.avsRegistryBindings.StakeRegistry.UpdateStakes( - opts, - operators, - ) -} - -func (a *AvsRegistryContractsChainClient) DeregisterOperator( - opts *bind.TransactOpts, - operator gethcommon.Address, - quorumNumbers []byte, - pubkey blspubkeyregistry.BN254G1Point, -) (*gethTypes.Transaction, error) { - return a.avsRegistryBindings.BlsPubkeyRegistry.DeregisterOperator( - opts, - operator, - quorumNumbers, - pubkey) -} diff --git a/chainio/avsregistry/reader.go b/chainio/clients/avsregistry/reader.go similarity index 55% rename from chainio/avsregistry/reader.go rename to chainio/clients/avsregistry/reader.go index 36880558..ddefbe2e 100644 --- a/chainio/avsregistry/reader.go +++ b/chainio/clients/avsregistry/reader.go @@ -1,81 +1,95 @@ package avsregistry import ( - "context" "math" + "math/big" - "github.com/Layr-Labs/eigensdk-go/chainio/clients" "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - blsoperatorstateretrievar "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/types" "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" + + blsoperatorstateretriever "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" + blsregistrycoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" + stakeregistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StakeRegistry" ) type AvsRegistryReader interface { GetOperatorsStakeInQuorumsAtBlock( - ctx context.Context, + opts *bind.CallOpts, quorumNumbers []byte, blockNumber uint32, - ) ([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) + ) ([][]blsoperatorstateretriever.BLSOperatorStateRetrieverOperator, error) GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock( - ctx context.Context, + opts *bind.CallOpts, operatorId types.OperatorId, ) (map[types.QuorumNum]types.StakeAmount, error) GetOperatorsStakeInQuorumsOfOperatorAtBlock( - ctx context.Context, + opts *bind.CallOpts, operatorId types.OperatorId, blockNumber uint32, - ) ([]types.QuorumNum, [][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) + ) ([]types.QuorumNum, [][]blsoperatorstateretriever.BLSOperatorStateRetrieverOperator, error) GetOperatorsStakeInQuorumsOfOperatorAtCurrentBlock( - ctx context.Context, + opts *bind.CallOpts, operatorId types.OperatorId, - ) ([]types.QuorumNum, [][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) + ) ([]types.QuorumNum, [][]blsoperatorstateretriever.BLSOperatorStateRetrieverOperator, error) GetCheckSignaturesIndices( - ctx context.Context, + opts *bind.CallOpts, referenceBlockNumber uint32, quorumNumbers []byte, nonSignerOperatorIds [][32]byte, - ) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) + ) (blsoperatorstateretriever.BLSOperatorStateRetrieverCheckSignaturesIndices, error) - GetOperatorId(ctx context.Context, operatorAddress gethcommon.Address) ([32]byte, error) + GetOperatorId(opts *bind.CallOpts, operatorAddress gethcommon.Address) ([32]byte, error) - IsOperatorRegistered(ctx context.Context, operatorAddress gethcommon.Address) (bool, error) + IsOperatorRegistered(opts *bind.CallOpts, operatorAddress gethcommon.Address) (bool, error) } type AvsRegistryChainReader struct { - logger logging.Logger - avsRegistryContractsClient clients.AVSRegistryContractsClient - ethClient eth.EthClient + logger logging.Logger + registryCoordinatorAddr gethcommon.Address + registryCoordinator *blsregistrycoordinator.ContractBLSRegistryCoordinatorWithIndices + blsOperatorStateRetriever *blsoperatorstateretriever.ContractBLSOperatorStateRetriever + stakeRegistry *stakeregistry.ContractStakeRegistry + ethClient eth.EthClient } // forces AvsReader to implement the clients.ReaderInterface interface var _ AvsRegistryReader = (*AvsRegistryChainReader)(nil) func NewAvsRegistryReader( - avsRegistryContractsClient clients.AVSRegistryContractsClient, + registryCoordinatorAddr gethcommon.Address, + registryCoordinator *blsregistrycoordinator.ContractBLSRegistryCoordinatorWithIndices, + blsOperatorStateRetriever *blsoperatorstateretriever.ContractBLSOperatorStateRetriever, + stakeRegistry *stakeregistry.ContractStakeRegistry, logger logging.Logger, ethClient eth.EthClient, ) (*AvsRegistryChainReader, error) { return &AvsRegistryChainReader{ - avsRegistryContractsClient: avsRegistryContractsClient, - logger: logger, - ethClient: ethClient, + registryCoordinatorAddr: registryCoordinatorAddr, + registryCoordinator: registryCoordinator, + blsOperatorStateRetriever: blsOperatorStateRetriever, + stakeRegistry: stakeRegistry, + logger: logger, + ethClient: ethClient, }, nil } +// the contract stores historical state, so blockNumber should be the block number of the state you want to query +// and the blockNumber in opts should be the block number of the latest block (or set to nil, which is equivalent) func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsAtBlock( - ctx context.Context, + opts *bind.CallOpts, quorumNumbers []byte, blockNumber uint32, -) ([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) { - operatorStakes, err := r.avsRegistryContractsClient.GetOperatorsStakeInQuorumsAtBlock( - &bind.CallOpts{}, +) ([][]blsoperatorstateretriever.BLSOperatorStateRetrieverOperator, error) { + operatorStakes, err := r.blsOperatorStateRetriever.GetOperatorState( + opts, + r.registryCoordinatorAddr, quorumNumbers, blockNumber) if err != nil { @@ -87,12 +101,13 @@ func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsAtBlock( } func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsOfOperatorAtBlock( - ctx context.Context, + opts *bind.CallOpts, operatorId types.OperatorId, blockNumber uint32, -) ([]types.QuorumNum, [][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) { - quorums, operatorStakes, err := r.avsRegistryContractsClient.GetOperatorsStakeInQuorumsOfOperatorAtBlock( - &bind.CallOpts{}, +) ([]types.QuorumNum, [][]blsoperatorstateretriever.BLSOperatorStateRetrieverOperator, error) { + quorumBitmap, operatorStakes, err := r.blsOperatorStateRetriever.GetOperatorState0( + opts, + r.registryCoordinatorAddr, operatorId, blockNumber) if err != nil { @@ -105,15 +120,17 @@ func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsOfOperatorAtBlock( ) return nil, nil, err } - + quorums := types.BitmapToQuorumIds(quorumBitmap) return quorums, operatorStakes, nil } +// opts will be modified to have the latest blockNumber, so make sure not to reuse it +// blockNumber in opts will be ignored, and the chain will be queried to get the latest blockNumber func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsOfOperatorAtCurrentBlock( - ctx context.Context, + opts *bind.CallOpts, operatorId types.OperatorId, -) ([]types.QuorumNum, [][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator, error) { - curBlock, err := r.ethClient.BlockNumber(ctx) +) ([]types.QuorumNum, [][]blsoperatorstateretriever.BLSOperatorStateRetrieverOperator, error) { + curBlock, err := r.ethClient.BlockNumber(opts.Context) if err != nil { r.logger.Error("Failed to get current block number", "err", err) return nil, nil, err @@ -122,24 +139,26 @@ func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsOfOperatorAtCurrentBl r.logger.Error("Current block number is too large to be converted to uint32") return nil, nil, err } - return r.GetOperatorsStakeInQuorumsOfOperatorAtBlock(ctx, operatorId, uint32(curBlock)) + opts.BlockNumber = big.NewInt(int64(curBlock)) + return r.GetOperatorsStakeInQuorumsOfOperatorAtBlock(opts, operatorId, uint32(curBlock)) } // GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock could have race conditions // it currently makes a bunch of calls to fetch "current block" information, // so some of them could actually return information from different blocks func (r *AvsRegistryChainReader) GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock( - ctx context.Context, + opts *bind.CallOpts, operatorId types.OperatorId, ) (map[types.QuorumNum]types.StakeAmount, error) { - quorums, err := r.avsRegistryContractsClient.GetOperatorQuorumsAtCurrentBlock(&bind.CallOpts{}, operatorId) + quorumBitmap, err := r.registryCoordinator.GetCurrentQuorumBitmapByOperatorId(opts, operatorId) if err != nil { r.logger.Error("Failed to get operator quorums", "err", err) return nil, err } + quorums := types.BitmapToQuorumIds(quorumBitmap) quorumStakes := make(map[types.QuorumNum]types.StakeAmount) for _, quorum := range quorums { - stake, err := r.avsRegistryContractsClient.GetCurrentOperatorStakeForQuorum( + stake, err := r.stakeRegistry.GetCurrentOperatorStakeForQuorum( &bind.CallOpts{}, operatorId, quorum, @@ -154,30 +173,31 @@ func (r *AvsRegistryChainReader) GetOperatorStakeInQuorumsOfOperatorAtCurrentBlo } func (r *AvsRegistryChainReader) GetCheckSignaturesIndices( - ctx context.Context, + opts *bind.CallOpts, referenceBlockNumber uint32, quorumNumbers []byte, nonSignerOperatorIds [][32]byte, -) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { - checkSignatureIndices, err := r.avsRegistryContractsClient.GetCheckSignaturesIndices( - &bind.CallOpts{}, +) (blsoperatorstateretriever.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { + checkSignatureIndices, err := r.blsOperatorStateRetriever.GetCheckSignaturesIndices( + opts, + r.registryCoordinatorAddr, referenceBlockNumber, quorumNumbers, nonSignerOperatorIds, ) if err != nil { r.logger.Error("Failed to get check signatures indices", "err", err) - return blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices{}, err + return blsoperatorstateretriever.BLSOperatorStateRetrieverCheckSignaturesIndices{}, err } return checkSignatureIndices, nil } func (r *AvsRegistryChainReader) GetOperatorId( - ctx context.Context, + opts *bind.CallOpts, operatorAddress gethcommon.Address, ) ([32]byte, error) { - operatorId, err := r.avsRegistryContractsClient.GetOperatorId( - &bind.CallOpts{}, + operatorId, err := r.registryCoordinator.GetOperatorId( + opts, operatorAddress, ) if err != nil { @@ -188,10 +208,10 @@ func (r *AvsRegistryChainReader) GetOperatorId( } func (r *AvsRegistryChainReader) IsOperatorRegistered( - ctx context.Context, + opts *bind.CallOpts, operatorAddress gethcommon.Address, ) (bool, error) { - operatorId, err := r.avsRegistryContractsClient.GetOperatorId(&bind.CallOpts{}, operatorAddress) + operatorId, err := r.registryCoordinator.GetOperatorId(opts, operatorAddress) if err != nil { r.logger.Error("Cannot get operator id", "err", err) return false, err diff --git a/chainio/avsregistry/writer.go b/chainio/clients/avsregistry/writer.go similarity index 55% rename from chainio/avsregistry/writer.go rename to chainio/clients/avsregistry/writer.go index c63d4a72..beb7b4c5 100644 --- a/chainio/avsregistry/writer.go +++ b/chainio/clients/avsregistry/writer.go @@ -3,21 +3,23 @@ package avsregistry import ( "context" - "github.com/Layr-Labs/eigensdk-go/chainio/clients" "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - blspubkeyregistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPubkeyRegistry" - regcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/signer" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + + blsoperatorstateretriever "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" + blspubkeyregistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPubkeyRegistry" + blsregistrycoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" + stakeregistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StakeRegistry" ) type AvsRegistryWriter interface { RegisterOperatorWithAVSRegistryCoordinator( ctx context.Context, quorumNumbers []byte, - pubkey regcoord.BN254G1Point, + pubkey blsregistrycoordinator.BN254G1Point, socket string, ) (*types.Receipt, error) @@ -28,44 +30,54 @@ type AvsRegistryWriter interface { DeregisterOperator( ctx context.Context, - operator gethcommon.Address, quorumNumbers []byte, - pubkey blspubkeyregistry.BN254G1Point, + pubkey blsregistrycoordinator.BN254G1Point, ) (*types.Receipt, error) } type AvsRegistryChainWriter struct { - avsRegistryContractsClient clients.AVSRegistryContractsClient - signer signer.Signer - logger logging.Logger - ethClient eth.EthClient + registryCoordinator *blsregistrycoordinator.ContractBLSRegistryCoordinatorWithIndices + blsOperatorStateRetriever *blsoperatorstateretriever.ContractBLSOperatorStateRetriever + stakeRegistry *stakeregistry.ContractStakeRegistry + blsPubkeyRegistry *blspubkeyregistry.ContractBLSPubkeyRegistry + signer signer.Signer + logger logging.Logger + ethClient eth.EthClient } var _ AvsRegistryWriter = (*AvsRegistryChainWriter)(nil) func NewAvsRegistryWriter( - avsRegistryContractsClient clients.AVSRegistryContractsClient, + registryCoordinator *blsregistrycoordinator.ContractBLSRegistryCoordinatorWithIndices, + blsOperatorStateRetriever *blsoperatorstateretriever.ContractBLSOperatorStateRetriever, + stakeRegistry *stakeregistry.ContractStakeRegistry, + blsPubkeyRegistry *blspubkeyregistry.ContractBLSPubkeyRegistry, logger logging.Logger, signer signer.Signer, ethClient eth.EthClient, ) (*AvsRegistryChainWriter, error) { return &AvsRegistryChainWriter{ - avsRegistryContractsClient: avsRegistryContractsClient, - signer: signer, - logger: logger, - ethClient: ethClient, + registryCoordinator: registryCoordinator, + blsOperatorStateRetriever: blsOperatorStateRetriever, + stakeRegistry: stakeRegistry, + blsPubkeyRegistry: blsPubkeyRegistry, + signer: signer, + logger: logger, + ethClient: ethClient, }, nil } func (w *AvsRegistryChainWriter) RegisterOperatorWithAVSRegistryCoordinator( ctx context.Context, quorumNumbers []byte, - pubkey regcoord.BN254G1Point, + pubkey blsregistrycoordinator.BN254G1Point, socket string, ) (*types.Receipt, error) { w.logger.Info("registering operator with the AVS's registry coordinator") txOpts := w.signer.GetTxOpts() - tx, err := w.avsRegistryContractsClient.RegisterOperatorWithCoordinator(txOpts, quorumNumbers, pubkey, socket) + // TODO: this call will fail if max number of operators are already registered + // in that case, need to call churner to kick out another operator. See eigenDA's node/operator.go implementation + tx, err := w.registryCoordinator.RegisterOperatorWithCoordinator1(txOpts, quorumNumbers, pubkey, socket) if err != nil { return nil, err } @@ -81,7 +93,7 @@ func (w *AvsRegistryChainWriter) UpdateStakes( ) (*types.Receipt, error) { w.logger.Info("updating stakes") txOpts := w.signer.GetTxOpts() - tx, err := w.avsRegistryContractsClient.UpdateStakes(txOpts, operators) + tx, err := w.stakeRegistry.UpdateStakes(txOpts, operators) if err != nil { return nil, err } @@ -94,13 +106,12 @@ func (w *AvsRegistryChainWriter) UpdateStakes( func (w *AvsRegistryChainWriter) DeregisterOperator( ctx context.Context, - operator gethcommon.Address, quorumNumbers []byte, - pubkey blspubkeyregistry.BN254G1Point, + pubkey blsregistrycoordinator.BN254G1Point, ) (*types.Receipt, error) { w.logger.Info("deregistering operator with the AVS's registry coordinator") txOpts := w.signer.GetTxOpts() - tx, err := w.avsRegistryContractsClient.DeregisterOperator(txOpts, operator, quorumNumbers, pubkey) + tx, err := w.registryCoordinator.DeregisterOperatorWithCoordinator(txOpts, quorumNumbers, pubkey) if err != nil { return nil, err } diff --git a/chainio/clients/builder.go b/chainio/clients/builder.go new file mode 100644 index 00000000..b141175e --- /dev/null +++ b/chainio/clients/builder.go @@ -0,0 +1,251 @@ +package clients + +import ( + avsregistry "github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry" + elcontracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + chainioutils "github.com/Layr-Labs/eigensdk-go/chainio/utils" + blspubkeycompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" + logging "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/metrics" + "github.com/Layr-Labs/eigensdk-go/signer" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + gethcommon "github.com/ethereum/go-ethereum/common" + "github.com/prometheus/client_golang/prometheus" +) + +type BuildAllConfig struct { + EthHttpUrl string `yaml:"eth_http_url"` + EthWsUrl string `yaml:"eth_ws_url"` + BlsRegistryCoordinatorAddr string `yaml:"bls_registry_coordinator_address"` + BlsOperatorStateRetrieverAddr string `yaml:"bls_operator_state_retriever_address"` + AvsName string `yaml:"avs_name"` + PromMetricsIpPortAddress string `yaml:"prometheus_metrics_ip_port_address"` +} + +// 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 +// for non-instrumented clients that doesn't return metrics/reg, and another instrumented-constructor +// that returns instrumented clients and the metrics/reg. +type Clients struct { + AvsRegistryChainReader avsregistry.AvsRegistryReader + AvsRegistryChainWriter avsregistry.AvsRegistryWriter + ElChainReader elcontracts.ELReader + ElChainSubscriber elcontracts.ELSubscriber + ElChainWriter elcontracts.ELWriter + EthHttpClient *eth.Client + EthWsClient *eth.Client + Metrics *metrics.EigenMetrics // exposes main avs node spec metrics that need to be incremented by avs code and used to start the metrics server + PrometheusRegistry *prometheus.Registry // Used if avs teams need to register avs-specific metrics +} + +func BuildAll(config BuildAllConfig, signer signer.Signer, logger logging.Logger) (*Clients, error) { + config.validate(logger) + + // Create the metrics server + promReg := prometheus.NewRegistry() + eigenMetrics := metrics.NewEigenMetrics(config.AvsName, config.PromMetricsIpPortAddress, promReg, logger) + + // creating two types of Eth clients: HTTP and WS + ethHttpClient, err := eth.NewClient(config.EthHttpUrl) + if err != nil { + logger.Error("Failed to create Eth Http client", "err", err) + return nil, err + } + + ethWsClient, err := eth.NewClient(config.EthWsUrl) + if err != nil { + logger.Error("Failed to create Eth WS client", "err", err) + return nil, err + } + + // creating EL clients: Reader, Writer and Subscriber + elChainReader, elChainWriter, elChainSubscriber, err := config.buildElClients( + ethHttpClient, + ethWsClient, + signer, + logger, + eigenMetrics, + ) + if err != nil { + logger.Error("Failed to create EL Reader, Writer and Subscriber", "err", err) + return nil, err + } + + // creating AVS clients: Reader and Writer + avsRegistryChainReader, avsRegistryChainWriter, err := config.buildAvsClients( + ethHttpClient, + signer, + logger, + ) + if err != nil { + logger.Error("Failed to create AVS Registry Reader and Writer", "err", err) + return nil, err + } + + return &Clients{ + ElChainReader: elChainReader, + ElChainSubscriber: elChainSubscriber, + ElChainWriter: elChainWriter, + AvsRegistryChainReader: avsRegistryChainReader, + AvsRegistryChainWriter: avsRegistryChainWriter, + EthHttpClient: ethHttpClient, + EthWsClient: ethWsClient, + Metrics: eigenMetrics, + PrometheusRegistry: promReg, + }, nil + +} + +func (config *BuildAllConfig) buildElClients( + ethHttpClient eth.EthClient, + ethWsClient eth.EthClient, + signer signer.Signer, + logger logging.Logger, + eigenMetrics *metrics.EigenMetrics, +) (elcontracts.ELReader, elcontracts.ELWriter, elcontracts.ELSubscriber, error) { + + avsRegistryContractBindings, err := chainioutils.NewAVSRegistryContractBindings( + gethcommon.HexToAddress(config.BlsRegistryCoordinatorAddr), + gethcommon.HexToAddress(config.BlsOperatorStateRetrieverAddr), + ethHttpClient, + logger, + ) + if err != nil { + logger.Error("Failed to create AVSRegistryContractBindings", "err", err) + return nil, nil, nil, err + } + + slasherAddr, err := avsRegistryContractBindings.RegistryCoordinator.Slasher(&bind.CallOpts{}) + if err != nil { + logger.Fatal("Failed to fetch Slasher contract", "err", err) + } + + elContractBindings, err := chainioutils.NewEigenlayerContractBindings( + slasherAddr, + avsRegistryContractBindings.BlsPubkeyCompendiumAddr, + ethHttpClient, + logger, + ) + if err != nil { + logger.Error("Failed to create EigenlayerContractBindings", "err", err) + return nil, nil, nil, err + } + + // get the Reader for the EL contracts + elChainReader := elcontracts.NewELChainReader( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.BlsPubkeyCompendium, + elContractBindings.BlspubkeyCompendiumAddr, + logger, + ethHttpClient, + ) + + // get the Subscriber for the EL contracts + contractBlsPubkeyCompendiumWs, err := blspubkeycompendium.NewContractBLSPublicKeyCompendium(elContractBindings.BlspubkeyCompendiumAddr, ethWsClient) + if err != nil { + logger.Fatal("Failed to fetch BLSPublicKeyCompendium contract", "err", err) + } + elChainSubscriber, err := elcontracts.NewELChainSubscriber( + contractBlsPubkeyCompendiumWs, + logger, + ) + if err != nil { + logger.Error("Failed to create ELChainSubscriber", "err", err) + return nil, nil, nil, err + } + + elChainWriter := elcontracts.NewELChainWriter( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.StrategyManagerAddr, + elContractBindings.BlsPubkeyCompendium, + elContractBindings.BlspubkeyCompendiumAddr, + elChainReader, + ethHttpClient, + signer, + logger, + eigenMetrics, + ) + if err != nil { + logger.Error("Failed to create ELChainWriter", "err", err) + return nil, nil, nil, err + } + + return elChainReader, elChainWriter, elChainSubscriber, nil +} + +func (config *BuildAllConfig) buildAvsClients( + ethHttpClient eth.EthClient, + signer signer.Signer, + logger logging.Logger, +) (avsregistry.AvsRegistryReader, avsregistry.AvsRegistryWriter, error) { + + avsRegistryContractBindings, err := chainioutils.NewAVSRegistryContractBindings( + gethcommon.HexToAddress(config.BlsRegistryCoordinatorAddr), + gethcommon.HexToAddress(config.BlsOperatorStateRetrieverAddr), + ethHttpClient, + logger, + ) + if err != nil { + logger.Error("Failed to create AVSRegistryContractBindings", "err", err) + return nil, nil, err + } + + avsRegistryChainReader, err := avsregistry.NewAvsRegistryReader( + avsRegistryContractBindings.RegistryCoordinatorAddr, + avsRegistryContractBindings.RegistryCoordinator, + avsRegistryContractBindings.BlsOperatorStateRetriever, + avsRegistryContractBindings.StakeRegistry, + logger, + ethHttpClient, + ) + if err != nil { + logger.Error("Failed to create AVSRegistryChainReader", "err", err) + return nil, nil, err + } + + avsRegistryChainWriter, err := avsregistry.NewAvsRegistryWriter( + avsRegistryContractBindings.RegistryCoordinator, + avsRegistryContractBindings.BlsOperatorStateRetriever, + avsRegistryContractBindings.StakeRegistry, + avsRegistryContractBindings.BlsPubkeyRegistry, + logger, + signer, + ethHttpClient, + ) + if err != nil { + logger.Error("Failed to create AVSRegistryChainWriter", "err", err) + return nil, nil, err + } + + return avsRegistryChainReader, avsRegistryChainWriter, 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/ (?) +func (config *BuildAllConfig) validate(logger logging.Logger) { + if config.EthHttpUrl == "" { + logger.Fatalf("BuildAllConfig.validate: Missing eth http url") + } + if config.EthWsUrl == "" { + logger.Fatalf("BuildAllConfig.validate: Missing eth ws url") + } + if config.BlsRegistryCoordinatorAddr == "" { + logger.Fatalf("BuildAllConfig.validate: Missing bls registry coordinator address") + } + if config.BlsOperatorStateRetrieverAddr == "" { + logger.Fatalf("BuildAllConfig.validate: Missing bls operator state retriever address") + } + if config.AvsName == "" { + logger.Fatalf("BuildAllConfig.validate: Missing avs name") + } + if config.PromMetricsIpPortAddress == "" { + logger.Fatalf("BuildAllConfig.validate: Missing prometheus metrics ip port address") + } +} diff --git a/chainio/clients/el_contracts_client.go b/chainio/clients/el_contracts_client.go deleted file mode 100644 index cf8f7dbe..00000000 --- a/chainio/clients/el_contracts_client.go +++ /dev/null @@ -1,294 +0,0 @@ -package clients - -import ( - "math/big" - - "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - blspubkeycompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" - contractDelegationManager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" - strategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" - "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - gethTypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -type ELContractsClient interface { - - // Write methods - - RegisterAsOperator( - opts *bind.TransactOpts, - registeringOperatorDetails contractDelegationManager.IDelegationManagerOperatorDetails, - metadataURI string, - ) (*gethTypes.Transaction, error) - - ModifyOperatorDetails( - opts *bind.TransactOpts, - registeringOperatorDetails contractDelegationManager.IDelegationManagerOperatorDetails, - ) (*gethTypes.Transaction, error) - - UpdateOperatorMetadataURI( - opts *bind.TransactOpts, - metadataURI string, - ) (*gethTypes.Transaction, error) - - OptIntoSlashing( - opts *bind.TransactOpts, - avsServiceManagerAddr common.Address, - ) (*gethTypes.Transaction, error) - - RegisterBLSPublicKey( - opts *bind.TransactOpts, - signedMessageHash blspubkeycompendium.BN254G1Point, - pubkeyG1 blspubkeycompendium.BN254G1Point, - pubkeyG2 blspubkeycompendium.BN254G2Point, - ) (*gethTypes.Transaction, error) - - DepositIntoStrategy( - opts *bind.TransactOpts, - strategy common.Address, - token common.Address, - amount *big.Int, - ) (*gethTypes.Transaction, error) - - // Subscribe methods - - WatchNewPubkeyRegistration( - opts *bind.WatchOpts, - sink chan<- *blspubkeycompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration, - operator []common.Address, - ) (event.Subscription, error) - - // Read methods - - GetStrategyManagerContractAddress() (common.Address, error) - - GetBLSPublicKeyCompendiumContractAddress() common.Address - - IsOperator(opts *bind.CallOpts, operator common.Address) (bool, error) - - OperatorDetails( - opts *bind.CallOpts, - operator common.Address, - ) (contractDelegationManager.IDelegationManagerOperatorDetails, error) - - ContractCanSlashOperatorUntilBlock( - opts *bind.CallOpts, - operator common.Address, - serviceContract common.Address, - ) (uint32, error) - - IsFrozen(opts *bind.CallOpts, staker common.Address) (bool, error) - - GetStrategyAndUnderlyingToken( - strategyAddr common.Address, - ) (*strategy.ContractIStrategy, common.Address, error) - - GetStrategyAndUnderlyingERC20Token( - strategyAddr common.Address, - ) (*strategy.ContractIStrategy, ERC20ContractClient, common.Address, error) - - GetOperatorPubkeyHash( - opts *bind.CallOpts, - operatorAddr common.Address, - ) ([32]byte, error) - - GetOperatorAddressFromPubkeyHash(opts *bind.CallOpts, pubkeyHash [32]byte) (common.Address, error) - - OperatorShares(opts *bind.CallOpts, operatorAddr common.Address, strategyAddr common.Address) (*big.Int, error) -} - -// ElContractsChainClient is really just a wrapper around the go bindings that has a proper interface, so that we can -// mock it in tests. -// TODO(samlaf): should we instead just make the -type ElContractsChainClient struct { - elHttpBindings *eigenlayerContractBindings - // TODO(samlaf): currently we're creating a second set of bindings backed by a websocket client, so that we can - // subscribe to events. perhaps a better way would be to make our EthClient implementation have both an http and - // websocket client, and use the websocket client for - // the SubscribeFilterLogs() method, and the http client for everything else... - // Yet another option is to start using an indexer (maybe - // https://github.com/ethereum-optimism/optimism/tree/develop/indexer) and drop websocket subscriptions altogether. - elWsBindings *eigenlayerContractBindings - ethHttpClient eth.EthClient - logger logging.Logger - blsPubKeyCompendiumAddr common.Address -} - -var _ ELContractsClient = (*ElContractsChainClient)(nil) - -func NewELContractsChainClient( - slasherAddr common.Address, - blsPubKeyCompendiumAddr common.Address, - ethHttpClient eth.EthClient, - ethWsClient eth.EthClient, - logger logging.Logger, -) (*ElContractsChainClient, error) { - elHttpBindings, err := newEigenlayerContractBindings(slasherAddr, blsPubKeyCompendiumAddr, ethHttpClient, logger) - if err != nil { - return nil, err - } - elWsBindings, err := newEigenlayerContractBindings(slasherAddr, blsPubKeyCompendiumAddr, ethWsClient, logger) - if err != nil { - return nil, err - } - - return &ElContractsChainClient{ - elHttpBindings: elHttpBindings, - elWsBindings: elWsBindings, - ethHttpClient: ethHttpClient, - logger: logger, - blsPubKeyCompendiumAddr: blsPubKeyCompendiumAddr, - }, nil -} - -func (e *ElContractsChainClient) RegisterAsOperator( - opts *bind.TransactOpts, - registeringOperatorDetails contractDelegationManager.IDelegationManagerOperatorDetails, - metadataURI string, -) (*gethTypes.Transaction, error) { - return e.elHttpBindings.DelegationManager.RegisterAsOperator(opts, registeringOperatorDetails, metadataURI) -} - -func (e *ElContractsChainClient) ModifyOperatorDetails( - opts *bind.TransactOpts, - registeringOperatorDetails contractDelegationManager.IDelegationManagerOperatorDetails, -) (*gethTypes.Transaction, error) { - return e.elHttpBindings.DelegationManager.ModifyOperatorDetails(opts, registeringOperatorDetails) -} - -func (e *ElContractsChainClient) UpdateOperatorMetadataURI( - opts *bind.TransactOpts, - metadataURI string, -) (*gethTypes.Transaction, error) { - return e.elHttpBindings.DelegationManager.UpdateOperatorMetadataURI(opts, metadataURI) -} - -func (e *ElContractsChainClient) OptIntoSlashing( - opts *bind.TransactOpts, - avsServiceManagerAddr common.Address, -) (*gethTypes.Transaction, error) { - return e.elHttpBindings.Slasher.OptIntoSlashing(opts, avsServiceManagerAddr) -} - -func (e *ElContractsChainClient) RegisterBLSPublicKey( - opts *bind.TransactOpts, - signedMessageHash blspubkeycompendium.BN254G1Point, - pubkeyG1 blspubkeycompendium.BN254G1Point, - pubkeyG2 blspubkeycompendium.BN254G2Point, -) (*gethTypes.Transaction, error) { - return e.elHttpBindings.BlsPubKeyCompendium.RegisterBLSPublicKey(opts, signedMessageHash, pubkeyG1, pubkeyG2) -} - -func (e *ElContractsChainClient) GetStrategyAndUnderlyingToken( - strategyAddr common.Address, -) (*strategy.ContractIStrategy, common.Address, error) { - contractStrategy, err := strategy.NewContractIStrategy(strategyAddr, e.ethHttpClient) - if err != nil { - e.logger.Error("Failed to fetch strategy contract", "err", err) - return nil, common.Address{}, err - } - underlyingTokenAddr, err := contractStrategy.UnderlyingToken(&bind.CallOpts{}) - if err != nil { - e.logger.Error("Failed to fetch token contract", "err", err) - return nil, common.Address{}, err - } - return contractStrategy, underlyingTokenAddr, nil -} - -func (e *ElContractsChainClient) GetStrategyAndUnderlyingERC20Token( - strategyAddr common.Address, -) (*strategy.ContractIStrategy, ERC20ContractClient, common.Address, error) { - contractStrategy, err := strategy.NewContractIStrategy(strategyAddr, e.ethHttpClient) - if err != nil { - e.logger.Error("Failed to fetch strategy contract", "err", err) - return nil, nil, common.Address{}, err - } - underlyingTokenAddr, err := contractStrategy.UnderlyingToken(&bind.CallOpts{}) - if err != nil { - e.logger.Error("Failed to fetch token contract", "err", err) - return nil, nil, common.Address{}, err - } - contractUnderlyingToken, err := NewERC20ContractChainClient(underlyingTokenAddr, e.ethHttpClient) - if err != nil { - e.logger.Error("Failed to fetch token contract", "err", err) - return nil, nil, common.Address{}, err - } - return contractStrategy, contractUnderlyingToken, underlyingTokenAddr, nil -} - -func (e *ElContractsChainClient) DepositIntoStrategy( - opts *bind.TransactOpts, - strategy common.Address, - token common.Address, - amount *big.Int, -) (*gethTypes.Transaction, error) { - return e.elHttpBindings.StrategyManager.DepositIntoStrategy(opts, strategy, token, amount) -} - -func (e *ElContractsChainClient) GetStrategyManagerContractAddress() (common.Address, error) { - return e.elHttpBindings.Slasher.StrategyManager(&bind.CallOpts{}) -} - -func (e *ElContractsChainClient) WatchNewPubkeyRegistration( - opts *bind.WatchOpts, - sink chan<- *blspubkeycompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration, - operator []common.Address, -) (event.Subscription, error) { - return e.elWsBindings.BlsPubKeyCompendium.WatchNewPubkeyRegistration(opts, sink, operator) -} - -func (e *ElContractsChainClient) IsOperator(opts *bind.CallOpts, operator common.Address) (bool, error) { - return e.elHttpBindings.DelegationManager.IsOperator(opts, operator) -} - -func (e *ElContractsChainClient) OperatorDetails( - opts *bind.CallOpts, - operator common.Address, -) (contractDelegationManager.IDelegationManagerOperatorDetails, error) { - return e.elHttpBindings.DelegationManager.OperatorDetails(opts, operator) -} - -func (e *ElContractsChainClient) ContractCanSlashOperatorUntilBlock( - opts *bind.CallOpts, - operator common.Address, - serviceContract common.Address, -) (uint32, error) { - return e.elHttpBindings.Slasher.ContractCanSlashOperatorUntilBlock(opts, operator, serviceContract) -} - -func (e *ElContractsChainClient) IsFrozen(opts *bind.CallOpts, staker common.Address) (bool, error) { - return e.elHttpBindings.Slasher.IsFrozen(opts, staker) -} - -func (e *ElContractsChainClient) GetBLSPublicKeyCompendiumContractAddress() common.Address { - return e.blsPubKeyCompendiumAddr -} - -func (e *ElContractsChainClient) GetOperatorPubkeyHash( - opts *bind.CallOpts, - operatorAddr common.Address, -) ([32]byte, error) { - return e.elHttpBindings.BlsPubKeyCompendium.OperatorToPubkeyHash(opts, operatorAddr) -} - -func (e *ElContractsChainClient) GetOperatorAddressFromPubkeyHash( - opts *bind.CallOpts, - pubkeyHash [32]byte, -) (common.Address, error) { - return e.elHttpBindings.BlsPubKeyCompendium.PubkeyHashToOperator(opts, pubkeyHash) -} - -func (e *ElContractsChainClient) OperatorShares( - opts *bind.CallOpts, - operatorAddr common.Address, - strategyAddr common.Address, -) (*big.Int, error) { - operatorSharesInStrategy, err := e.elHttpBindings.DelegationManager.OperatorShares(opts, operatorAddr, strategyAddr) - if err != nil { - return nil, err - } - return operatorSharesInStrategy, nil -} diff --git a/chainio/clients/elcontracts/reader.go b/chainio/clients/elcontracts/reader.go new file mode 100644 index 00000000..f3fee20b --- /dev/null +++ b/chainio/clients/elcontracts/reader.go @@ -0,0 +1,320 @@ +package elcontracts + +import ( + "bytes" + "context" + "math/big" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + gethcommon "github.com/ethereum/go-ethereum/common" + + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + chainioutils "github.com/Layr-Labs/eigensdk-go/chainio/utils" + "github.com/Layr-Labs/eigensdk-go/crypto/bls" + "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/types" + eigenabi "github.com/Layr-Labs/eigensdk-go/types/abi" + + blspkcompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" + delegationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" + erc20 "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IERC20" + strategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" + slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/Slasher" + strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" +) + +type ELReader interface { + IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error) + + GetOperatorDetails(opts *bind.CallOpts, operator types.Operator) (types.Operator, error) + + // GetStrategyAndUnderlyingToken returns the strategy contract and the underlying token address + // use GetStrategyAndUnderlyingERC20Token if the contract address confirms with ERC20 standard + GetStrategyAndUnderlyingToken( + opts *bind.CallOpts, strategyAddr gethcommon.Address, + ) (*strategy.ContractIStrategy, gethcommon.Address, error) + + // GetStrategyAndUnderlyingERC20Token returns the strategy contract and the underlying ERC20 token address + GetStrategyAndUnderlyingERC20Token( + opts *bind.CallOpts, strategyAddr gethcommon.Address, + ) (*strategy.ContractIStrategy, erc20.ContractIERC20Methods, gethcommon.Address, error) + + QueryExistingRegisteredOperatorPubKeys( + ctx context.Context, startBlock *big.Int, stopBlock *big.Int, + ) ([]types.OperatorAddr, []types.OperatorPubkeys, error) + + GetOperatorPubkeyHash(opts *bind.CallOpts, operator types.Operator) ([32]byte, error) + + GetOperatorAddressFromPubkeyHash(opts *bind.CallOpts, pubkeyHash [32]byte) (gethcommon.Address, error) + + ServiceManagerCanSlashOperatorUntilBlock( + opts *bind.CallOpts, + operatorAddr gethcommon.Address, + serviceManagerAddr gethcommon.Address, + ) (uint32, error) + + OperatorIsFrozen(opts *bind.CallOpts, operatorAddr gethcommon.Address) (bool, error) + + GetOperatorSharesInStrategy( + opts *bind.CallOpts, + operatorAddr gethcommon.Address, + strategyAddr gethcommon.Address, + ) (*big.Int, error) +} + +type ELChainReader struct { + logger logging.Logger + slasher slasher.ContractSlasherCalls + delegationManager delegationmanager.ContractDelegationManagerCalls + strategyManager strategymanager.ContractStrategyManagerCalls + blsPubkeyCompendium blspkcompendium.ContractBLSPublicKeyCompendiumCalls + blsPubKeyCompendiumAddr common.Address + ethClient eth.EthClient +} + +// forces EthReader to implement the chainio.Reader interface +var _ ELReader = (*ELChainReader)(nil) + +func NewELChainReader( + slasher slasher.ContractSlasherCalls, + delegationManager delegationmanager.ContractDelegationManagerCalls, + strategyManager strategymanager.ContractStrategyManagerCalls, + blsPubkeyCompendium blspkcompendium.ContractBLSPublicKeyCompendiumCalls, + blsPubKeyCompendiumAddr common.Address, + logger logging.Logger, + ethClient eth.EthClient, +) *ELChainReader { + return &ELChainReader{ + slasher: slasher, + delegationManager: delegationManager, + strategyManager: strategyManager, + blsPubkeyCompendium: blsPubkeyCompendium, + blsPubKeyCompendiumAddr: blsPubKeyCompendiumAddr, + logger: logger, + ethClient: ethClient, + } +} + +func BuildELChainReader( + slasherAddr gethcommon.Address, + blsPubKeyCompendiumAddr gethcommon.Address, + ethClient eth.EthClient, + logger logging.Logger, +) (*ELChainReader, error) { + elContractBindings, err := chainioutils.NewEigenlayerContractBindings(slasherAddr, blsPubKeyCompendiumAddr, ethClient, logger) + if err != nil { + return nil, err + } + return NewELChainReader( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.BlsPubkeyCompendium, + blsPubKeyCompendiumAddr, + logger, + ethClient, + ), nil +} + +// TODO(samlaf): should we just pass the CallOpts directly as argument instead of the context? +func (r *ELChainReader) IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error) { + isOperator, err := r.delegationManager.IsOperator( + opts, + gethcommon.HexToAddress(operator.Address), + ) + if err != nil { + return false, err + } + + return isOperator, nil +} + +func (r *ELChainReader) GetOperatorPubkeyHash(opts *bind.CallOpts, operator types.Operator) ([32]byte, error) { + operatorPubkeyHash, err := r.blsPubkeyCompendium.OperatorToPubkeyHash( + opts, + gethcommon.HexToAddress(operator.Address), + ) + if err != nil { + return [32]byte{}, err + } + + return operatorPubkeyHash, nil +} + +func (r *ELChainReader) GetOperatorAddressFromPubkeyHash( + opts *bind.CallOpts, + pubkeyHash [32]byte, +) (gethcommon.Address, error) { + return r.blsPubkeyCompendium.PubkeyHashToOperator( + opts, + pubkeyHash, + ) +} + +func (r *ELChainReader) GetOperatorDetails(opts *bind.CallOpts, operator types.Operator) (types.Operator, error) { + operatorDetails, err := r.delegationManager.OperatorDetails( + opts, + gethcommon.HexToAddress(operator.Address), + ) + if err != nil { + return types.Operator{}, err + } + + return types.Operator{ + Address: operator.Address, + EarningsReceiverAddress: operatorDetails.EarningsReceiver.Hex(), + StakerOptOutWindowBlocks: operatorDetails.StakerOptOutWindowBlocks, + DelegationApproverAddress: operatorDetails.DelegationApprover.Hex(), + }, nil +} + +// GetStrategyAndUnderlyingToken returns the strategy contract and the underlying token address +func (r *ELChainReader) GetStrategyAndUnderlyingToken( + opts *bind.CallOpts, strategyAddr gethcommon.Address, +) (*strategy.ContractIStrategy, gethcommon.Address, error) { + contractStrategy, err := strategy.NewContractIStrategy(strategyAddr, r.ethClient) + if err != nil { + r.logger.Error("Failed to fetch strategy contract", "err", err) + return nil, common.Address{}, err + } + underlyingTokenAddr, err := contractStrategy.UnderlyingToken(opts) + if err != nil { + r.logger.Error("Failed to fetch token contract", "err", err) + return nil, common.Address{}, err + } + return contractStrategy, underlyingTokenAddr, nil +} + +// GetStrategyAndUnderlyingERC20Token returns the strategy contract, the erc20 bindings for the underlying token +// and the underlying token address +func (r *ELChainReader) GetStrategyAndUnderlyingERC20Token( + opts *bind.CallOpts, strategyAddr gethcommon.Address, +) (*strategy.ContractIStrategy, erc20.ContractIERC20Methods, gethcommon.Address, error) { + contractStrategy, err := strategy.NewContractIStrategy(strategyAddr, r.ethClient) + if err != nil { + r.logger.Error("Failed to fetch strategy contract", "err", err) + return nil, nil, common.Address{}, err + } + underlyingTokenAddr, err := contractStrategy.UnderlyingToken(opts) + if err != nil { + r.logger.Error("Failed to fetch token contract", "err", err) + return nil, nil, common.Address{}, err + } + contractUnderlyingToken, err := erc20.NewContractIERC20(underlyingTokenAddr, r.ethClient) + if err != nil { + r.logger.Error("Failed to fetch token contract", "err", err) + return nil, nil, common.Address{}, err + } + return contractStrategy, contractUnderlyingToken, underlyingTokenAddr, nil +} + +func (r *ELChainReader) ServiceManagerCanSlashOperatorUntilBlock( + opts *bind.CallOpts, + operatorAddr gethcommon.Address, + serviceManagerAddr gethcommon.Address, +) (uint32, error) { + serviceManagerCanSlashOperatorUntilBlock, err := r.slasher.ContractCanSlashOperatorUntilBlock( + opts, operatorAddr, serviceManagerAddr, + ) + if err != nil { + return 0, err + } + return serviceManagerCanSlashOperatorUntilBlock, nil +} + +func (r *ELChainReader) OperatorIsFrozen(opts *bind.CallOpts, operatorAddr gethcommon.Address) (bool, error) { + operatorIsFrozen, err := r.slasher.IsFrozen(opts, operatorAddr) + if err != nil { + return false, err + } + return operatorIsFrozen, nil +} + +func (r *ELChainReader) QueryExistingRegisteredOperatorPubKeys( + ctx context.Context, + startBlock *big.Int, + stopBlock *big.Int, +) ([]types.OperatorAddr, []types.OperatorPubkeys, error) { + + query := ethereum.FilterQuery{ + FromBlock: startBlock, + ToBlock: stopBlock, + Addresses: []gethcommon.Address{ + r.blsPubKeyCompendiumAddr, + }, + } + + logs, err := r.ethClient.FilterLogs(ctx, query) + if err != nil { + r.logger.Error("Error filtering logs", "err", err) + return nil, nil, err + } + r.logger.Info("logs:", "logs", logs) + + pubkeyCompendiumAbi, err := abi.JSON(bytes.NewReader(eigenabi.BLSPublicKeyCompendiumAbi)) + if err != nil { + r.logger.Error("Error getting Abi", "err", err) + return nil, nil, err + } + + operatorAddresses := make([]types.OperatorAddr, 0) + operatorPubkeys := make([]types.OperatorPubkeys, 0) + + for _, vLog := range logs { + + // get the operator address + operatorAddr := gethcommon.HexToAddress(vLog.Topics[1].Hex()) + operatorAddresses = append(operatorAddresses, operatorAddr) + + event, err := pubkeyCompendiumAbi.Unpack("NewPubkeyRegistration", vLog.Data) + if err != nil { + r.logger.Error("Error unpacking event data", "err", err) + return nil, nil, err + } + + G1Pubkey := event[0].(struct { + X *big.Int "json:\"X\"" + Y *big.Int "json:\"Y\"" + }) + + G2Pubkey := event[1].(struct { + X [2]*big.Int "json:\"X\"" + Y [2]*big.Int "json:\"Y\"" + }) + + operatorPubkey := types.OperatorPubkeys{ + G1Pubkey: bls.NewG1Point( + G1Pubkey.X, + G1Pubkey.Y, + ), + G2Pubkey: bls.NewG2Point( + G2Pubkey.X, + G2Pubkey.Y, + ), + } + + operatorPubkeys = append(operatorPubkeys, operatorPubkey) + + } + + return operatorAddresses, operatorPubkeys, nil +} + +func (r *ELChainReader) GetOperatorSharesInStrategy( + opts *bind.CallOpts, + operatorAddr gethcommon.Address, + strategyAddr gethcommon.Address, +) (*big.Int, error) { + operatorSharesInStrategy, err := r.delegationManager.OperatorShares( + opts, + operatorAddr, + strategyAddr, + ) + if err != nil { + return nil, err + } + return operatorSharesInStrategy, nil +} diff --git a/chainio/elcontracts/subscriber.go b/chainio/clients/elcontracts/subscriber.go similarity index 78% rename from chainio/elcontracts/subscriber.go rename to chainio/clients/elcontracts/subscriber.go index 3e0eb02b..cc5f6a39 100644 --- a/chainio/elcontracts/subscriber.go +++ b/chainio/clients/elcontracts/subscriber.go @@ -4,7 +4,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/event" - "github.com/Layr-Labs/eigensdk-go/chainio/clients" pubkeycompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" "github.com/Layr-Labs/eigensdk-go/logging" ) @@ -14,27 +13,27 @@ type ELSubscriber interface { } type ELChainSubscriber struct { - logger logging.Logger - elContractsClient clients.ELContractsClient + logger logging.Logger + blsPubkeyCompendium pubkeycompendium.ContractBLSPublicKeyCompendiumFilters } // forces EthSubscriber to implement the chainio.Subscriber interface var _ ELSubscriber = (*ELChainSubscriber)(nil) func NewELChainSubscriber( - elContractsClient clients.ELContractsClient, + blsPubkeyCompendium pubkeycompendium.ContractBLSPublicKeyCompendiumFilters, logger logging.Logger, ) (*ELChainSubscriber, error) { return &ELChainSubscriber{ - logger: logger, - elContractsClient: elContractsClient, + logger: logger, + blsPubkeyCompendium: blsPubkeyCompendium, }, nil } func (s *ELChainSubscriber) SubscribeToNewPubkeyRegistrations() (chan *pubkeycompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration, event.Subscription, error) { newPubkeyRegistrationChan := make(chan *pubkeycompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration) - sub, err := s.elContractsClient.WatchNewPubkeyRegistration( + sub, err := s.blsPubkeyCompendium.WatchNewPubkeyRegistration( &bind.WatchOpts{}, newPubkeyRegistrationChan, nil, ) if err != nil { diff --git a/chainio/elcontracts/writer.go b/chainio/clients/elcontracts/writer.go similarity index 61% rename from chainio/elcontracts/writer.go rename to chainio/clients/elcontracts/writer.go index 9e376cd7..8d80d757 100644 --- a/chainio/elcontracts/writer.go +++ b/chainio/clients/elcontracts/writer.go @@ -4,19 +4,23 @@ import ( "context" "math/big" + "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" gethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/Layr-Labs/eigensdk-go/chainio/clients" "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" "github.com/Layr-Labs/eigensdk-go/chainio/utils" - blspubkeycompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" - contractDelegationManager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" + chainioutils "github.com/Layr-Labs/eigensdk-go/chainio/utils" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/metrics" "github.com/Layr-Labs/eigensdk-go/signer" "github.com/Layr-Labs/eigensdk-go/types" + + blspubkeycompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" + delegationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" + slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/Slasher" + strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" ) type ELWriter interface { @@ -41,37 +45,94 @@ type ELWriter interface { } type ELChainWriter struct { - elContractsClient clients.ELContractsClient - signer signer.Signer - logger logging.Logger - ethClient eth.EthClient + slasher slasher.ContractSlasherTransacts + delegationManager delegationmanager.ContractDelegationManagerTransacts + strategyManager strategymanager.ContractStrategyManagerTransacts + strategyManagerAddr gethcommon.Address + blsPubkeyCompendium blspubkeycompendium.ContractBLSPublicKeyCompendiumTransacts + blsPubkeyCompendiumAddr gethcommon.Address + elChainReader ELReader + ethClient eth.EthClient + signer signer.Signer + logger logging.Logger } var _ ELWriter = (*ELChainWriter)(nil) func NewELChainWriter( - elContractsClient clients.ELContractsClient, + slasher slasher.ContractSlasherTransacts, + delegationManager delegationmanager.ContractDelegationManagerTransacts, + strategyManager strategymanager.ContractStrategyManagerTransacts, + strategyManagerAddr gethcommon.Address, + blsPubkeyCompendium blspubkeycompendium.ContractBLSPublicKeyCompendiumTransacts, + blsPubkeyCompendiumAddr gethcommon.Address, + elChainReader ELReader, ethClient eth.EthClient, signer signer.Signer, logger logging.Logger, eigenMetrics metrics.Metrics, ) *ELChainWriter { return &ELChainWriter{ - elContractsClient: elContractsClient, - signer: signer, - logger: logger, - ethClient: ethClient, + slasher: slasher, + delegationManager: delegationManager, + strategyManager: strategyManager, + strategyManagerAddr: strategyManagerAddr, + blsPubkeyCompendium: blsPubkeyCompendium, + blsPubkeyCompendiumAddr: blsPubkeyCompendiumAddr, + elChainReader: elChainReader, + signer: signer, + logger: logger, + ethClient: ethClient, } } +func BuildELChainWriter( + slasherAddr gethcommon.Address, + blsPubKeyCompendiumAddr gethcommon.Address, + ethClient eth.EthClient, + signer signer.Signer, + logger logging.Logger, + eigenMetrics metrics.Metrics, +) (*ELChainWriter, error) { + elContractBindings, err := chainioutils.NewEigenlayerContractBindings(slasherAddr, blsPubKeyCompendiumAddr, ethClient, logger) + if err != nil { + return nil, err + } + elChainReader := NewELChainReader( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.BlsPubkeyCompendium, + blsPubKeyCompendiumAddr, + logger, + ethClient, + ) + return NewELChainWriter( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.StrategyManagerAddr, + elContractBindings.BlsPubkeyCompendium, + blsPubKeyCompendiumAddr, + elChainReader, + ethClient, + signer, + logger, + eigenMetrics, + ), nil +} + +// TODO(madhur): we wait for txreceipts in these functions right now, but +// this will be changed once we have a better tx manager design implemented +// see https://github.com/Layr-Labs/eigensdk-go/pull/75 func (w *ELChainWriter) RegisterAsOperator(ctx context.Context, operator types.Operator) (*gethtypes.Receipt, error) { w.logger.Infof("registering operator %s to EigenLayer", operator.Address) - opDetails := contractDelegationManager.IDelegationManagerOperatorDetails{ + opDetails := delegationmanager.IDelegationManagerOperatorDetails{ EarningsReceiver: gethcommon.HexToAddress(operator.EarningsReceiverAddress), StakerOptOutWindowBlocks: operator.StakerOptOutWindowBlocks, } txOpts := w.signer.GetTxOpts() - tx, err := w.elContractsClient.RegisterAsOperator(txOpts, opDetails, operator.MetadataUrl) + tx, err := w.delegationManager.RegisterAsOperator(txOpts, opDetails, operator.MetadataUrl) if err != nil { return nil, err } @@ -89,13 +150,13 @@ func (w *ELChainWriter) UpdateOperatorDetails( txOpts := w.signer.GetTxOpts() w.logger.Infof("updating operator details of operator %s to EigenLayer", operator.Address) - opDetails := contractDelegationManager.IDelegationManagerOperatorDetails{ + opDetails := delegationmanager.IDelegationManagerOperatorDetails{ EarningsReceiver: gethcommon.HexToAddress(operator.EarningsReceiverAddress), DelegationApprover: gethcommon.HexToAddress(operator.DelegationApproverAddress), StakerOptOutWindowBlocks: operator.StakerOptOutWindowBlocks, } - tx, err := w.elContractsClient.ModifyOperatorDetails(txOpts, opDetails) + tx, err := w.delegationManager.ModifyOperatorDetails(txOpts, opDetails) if err != nil { return nil, err } @@ -103,7 +164,7 @@ func (w *ELChainWriter) UpdateOperatorDetails( w.ethClient.WaitForTransactionReceipt(ctx, tx.Hash()) w.logger.Infof("updated operator metadata URI for operator %s to EigenLayer", operator.Address) - tx, err = w.elContractsClient.UpdateOperatorMetadataURI(txOpts, operator.MetadataUrl) + tx, err = w.delegationManager.UpdateOperatorMetadataURI(txOpts, operator.MetadataUrl) if err != nil { return nil, err } @@ -121,19 +182,15 @@ func (w *ELChainWriter) DepositERC20IntoStrategy( ) (*gethtypes.Receipt, error) { w.logger.Infof("depositing %s tokens into strategy %s", amount.String(), strategyAddr) txOpts := w.signer.GetTxOpts() - _, underlyingTokenContract, underlyingTokenAddr, err := w.elContractsClient.GetStrategyAndUnderlyingERC20Token( + _, underlyingTokenContract, underlyingTokenAddr, err := w.elChainReader.GetStrategyAndUnderlyingERC20Token( + &bind.CallOpts{Context: ctx}, strategyAddr, ) if err != nil { return nil, err } - strategyManagerAddr, err := w.elContractsClient.GetStrategyManagerContractAddress() - if err != nil { - return nil, err - } - - tx, err := underlyingTokenContract.Approve(txOpts, strategyManagerAddr, amount) + tx, err := underlyingTokenContract.Approve(txOpts, w.strategyManagerAddr, amount) if err != nil { return nil, err } @@ -141,7 +198,7 @@ func (w *ELChainWriter) DepositERC20IntoStrategy( // but playing it safe by waiting for approve tx to be mined before sending deposit tx w.ethClient.WaitForTransactionReceipt(ctx, tx.Hash()) - tx, err = w.elContractsClient.DepositIntoStrategy(txOpts, strategyAddr, underlyingTokenAddr, amount) + tx, err = w.strategyManager.DepositIntoStrategy(txOpts, strategyAddr, underlyingTokenAddr, amount) if err != nil { return nil, err } @@ -158,7 +215,7 @@ func (w *ELChainWriter) OptOperatorIntoSlashing( avsServiceManagerAddr gethcommon.Address, ) (*gethtypes.Receipt, error) { txOpts := w.signer.GetTxOpts() - tx, err := w.elContractsClient.OptIntoSlashing(txOpts, avsServiceManagerAddr) + tx, err := w.slasher.OptIntoSlashing(txOpts, avsServiceManagerAddr) if err != nil { return nil, err } @@ -185,13 +242,13 @@ func (w *ELChainWriter) RegisterBLSPublicKey( } signedMsgHash := blsKeyPair.MakePubkeyRegistrationData( gethcommon.HexToAddress(operator.Address), - w.elContractsClient.GetBLSPublicKeyCompendiumContractAddress(), + w.blsPubkeyCompendiumAddr, chainID, ) signedMsgHashBN254 := blspubkeycompendium.BN254G1Point(utils.ConvertToBN254G1Point(signedMsgHash)) G1pubkeyBN254 := blspubkeycompendium.BN254G1Point(utils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1())) G2pubkeyBN254 := blspubkeycompendium.BN254G2Point(utils.ConvertToBN254G2Point(blsKeyPair.GetPubKeyG2())) - tx, err := w.elContractsClient.RegisterBLSPublicKey( + tx, err := w.blsPubkeyCompendium.RegisterBLSPublicKey( txOpts, signedMsgHashBN254, G1pubkeyBN254, diff --git a/chainio/clients/erc20_contract_client.go b/chainio/clients/erc20_contract_client.go deleted file mode 100644 index fcfabc79..00000000 --- a/chainio/clients/erc20_contract_client.go +++ /dev/null @@ -1,41 +0,0 @@ -package clients - -import ( - "math/big" - - "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - erc20 "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IERC20" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type ERC20ContractClient interface { - Approve(opts *bind.TransactOpts, spender common.Address, amount *big.Int) (*types.Transaction, error) -} - -type eRC20ContractChainClient struct { - erc20Contract *erc20.ContractIERC20 -} - -var _ ERC20ContractClient = (*eRC20ContractChainClient)(nil) - -func NewERC20ContractChainClient( - address common.Address, - client eth.EthClient, -) (*eRC20ContractChainClient, error) { - contract, err := erc20.NewContractIERC20(address, client) - if err != nil { - panic(err) - } - return &eRC20ContractChainClient{erc20Contract: contract}, nil -} - -// Approve implements ERC20ContractService. -func (e *eRC20ContractChainClient) Approve( - opts *bind.TransactOpts, - spender common.Address, - amount *big.Int, -) (*types.Transaction, error) { - return e.erc20Contract.Approve(opts, spender, amount) -} diff --git a/chainio/constructor/constructor.go b/chainio/constructor/constructor.go deleted file mode 100644 index 918694d3..00000000 --- a/chainio/constructor/constructor.go +++ /dev/null @@ -1,314 +0,0 @@ -package constructor - -import ( - "context" - - avsregistry "github.com/Layr-Labs/eigensdk-go/chainio/avsregistry" - clients "github.com/Layr-Labs/eigensdk-go/chainio/clients" - "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - elcontracts "github.com/Layr-Labs/eigensdk-go/chainio/elcontracts" - blspubkeyreg "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPubkeyRegistry" - blsregcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" - logging "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/Layr-Labs/eigensdk-go/metrics" - "github.com/Layr-Labs/eigensdk-go/signer" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - gethcommon "github.com/ethereum/go-ethereum/common" - crypto "github.com/ethereum/go-ethereum/crypto" - "github.com/prometheus/client_golang/prometheus" -) - -type Config struct { - EcdsaPrivateKeyString string `yaml:"ecdsa_private_key_string"` - EthHttpUrl string `yaml:"eth_http_url"` - EthWsUrl string `yaml:"eth_ws_url"` - BlsRegistryCoordinatorAddr string `yaml:"bls_registry_coordinator_address"` - BlsOperatorStateRetrieverAddr string `yaml:"bls_operator_state_retriever_address"` - AvsName string `yaml:"avs_name"` - PromMetricsIpPortAddress string `yaml:"prometheus_metrics_ip_port_address"` -} - -// 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 -// for non-instrumented clients that doesn't return metrics/reg, and another instrumented-constructor -// that returns instrumented clients and the metrics/reg. -type Clients struct { - AvsRegistryChainReader avsregistry.AvsRegistryReader - AvsRegistryChainWriter avsregistry.AvsRegistryWriter - ElChainReader elcontracts.ELReader - ElChainSubscriber elcontracts.ELSubscriber - ElChainWriter elcontracts.ELWriter - EthHttpClient *eth.Client - EthWsClient *eth.Client - Metrics *metrics.EigenMetrics // exposes main avs node spec metrics that need to be incremented by avs code and used to start the metrics server - PrometheusRegistry *prometheus.Registry // Used if avs teams need to register avs-specific metrics -} - -func BuildClients(config Config, logger logging.Logger) (*Clients, error) { - - // Create the metrics server - promReg := prometheus.NewRegistry() - eigenMetrics := metrics.NewEigenMetrics(config.AvsName, config.PromMetricsIpPortAddress, promReg, logger) - - // creating two types of Eth clients: HTTP and WS - ethHttpClient, err := eth.NewClient(config.EthHttpUrl) - if err != nil { - logger.Error("Failed to create Eth Http client", "err", err) - return nil, err - } - - ethWsClient, err := eth.NewClient(config.EthWsUrl) - if err != nil { - logger.Error("Failed to create Eth WS client", "err", err) - return nil, err - } - - // creating EL contracts client (simple wrapper around abigen bindings) - elContractsClient, err := config.buildElContractsChainClient(logger, ethHttpClient, ethWsClient) - if err != nil { - logger.Error("Failed to create ELHttpContractsChainClient", "err", err) - return nil, err - } - - // creating EL clients: Reader, Writer and Subscriber - elChainReader, elChainWriter, elChainSubscriber, err := config.buildElClients( - elContractsClient, - ethHttpClient, - logger, - eigenMetrics, - ) - if err != nil { - logger.Error("Failed to create EL Reader, Writer and Subscriber", "err", err) - return nil, err - } - - // creating AVS contracts client - avsRegistryContractsClient, err := config.buildAvsRegistryContractsChainClient(logger, ethHttpClient) - if err != nil { - logger.Error("Failed to create AvsRegistryContractsChainClient", "err", err) - return nil, err - } - - // creating AVS clients: Reader and Writer - avsRegistryChainReader, avsRegistryChainWriter, err := config.buildAvsClients( - avsRegistryContractsClient, - logger, - ethHttpClient, - ) - if err != nil { - logger.Error("Failed to create AVS Registry Reader and Writer", "err", err) - return nil, err - } - - return &Clients{ - ElChainReader: elChainReader, - ElChainSubscriber: elChainSubscriber, - ElChainWriter: elChainWriter, - AvsRegistryChainReader: avsRegistryChainReader, - AvsRegistryChainWriter: avsRegistryChainWriter, - EthHttpClient: ethHttpClient, - EthWsClient: ethWsClient, - Metrics: eigenMetrics, - PrometheusRegistry: promReg, - }, nil - -} - -func (config *Config) buildElContractsChainClient( - logger logging.Logger, - ethHttpClient eth.EthClient, - ethWsClient eth.EthClient, -) (clients.ELContractsClient, error) { - blsRegistryCoordinatorAddr := gethcommon.HexToAddress(config.BlsRegistryCoordinatorAddr) - contractBLSRegistryCoordWithIndices, err := blsregcoord.NewContractBLSRegistryCoordinatorWithIndices( - blsRegistryCoordinatorAddr, - ethHttpClient, - ) - if err != nil { - logger.Fatal("Failed to fetch BLSRegistryCoordinatorWithIndices contract", "err", err) - } - - blsPubkeyRegistryAddr, err := contractBLSRegistryCoordWithIndices.BlsPubkeyRegistry(&bind.CallOpts{}) - if err != nil { - logger.Fatal("Failed to fetch BlsPubkeyRegistry contract", "err", err) - } - contractBlsPubkeyRegistry, err := blspubkeyreg.NewContractBLSPubkeyRegistry(blsPubkeyRegistryAddr, ethHttpClient) - if err != nil { - logger.Fatal("Failed to construct BlsPubkeyRegistry contract", "err", err) - } - blsPubKeyCompendiumAddr, err := contractBlsPubkeyRegistry.PubkeyCompendium(&bind.CallOpts{}) - if err != nil { - logger.Fatal("Failed to fetch PubkeyCompendium contract", "err", err) - } - - slasherAddr, err := contractBLSRegistryCoordWithIndices.Slasher(&bind.CallOpts{}) - if err != nil { - logger.Error("Failed to fetch Slasher contract", "err", err) - return nil, err - } - elContractsChainClient, err := clients.NewELContractsChainClient( - slasherAddr, - blsPubKeyCompendiumAddr, - ethHttpClient, - ethWsClient, - logger, - ) - if err != nil { - logger.Error("Failed to create ELContractsChainClient", "err", err) - return nil, err - } - - return elContractsChainClient, nil -} - -func (config *Config) buildElClients( - elContractsClient clients.ELContractsClient, - ethHttpClient eth.EthClient, - logger logging.Logger, - eigenMetrics *metrics.EigenMetrics, -) (elcontracts.ELReader, elcontracts.ELWriter, elcontracts.ELSubscriber, error) { - - // get the Reader for the EL contracts - elChainReader, err := elcontracts.NewELChainReader( - elContractsClient, - logger, - ethHttpClient, - ) - if err != nil { - logger.Error("Failed to create ELChainReader", "err", err) - return nil, nil, nil, err - } - - // get the Subscriber for the EL contracts - elChainSubscriber, err := elcontracts.NewELChainSubscriber( - elContractsClient, - logger, - ) - if err != nil { - logger.Error("Failed to create ELChainSubscriber", "err", err) - return nil, nil, nil, err - } - - // get the Writer for the EL contracts - ecdsaPrivateKey, err := crypto.HexToECDSA(config.EcdsaPrivateKeyString) - if err != nil { - logger.Errorf("Cannot parse ecdsa private key", "err", err) - return nil, nil, nil, err - } - - chainId, err := ethHttpClient.ChainID(context.Background()) - if err != nil { - logger.Error("Cannot get chainId", "err", err) - return nil, nil, nil, err - } - - privateKeySigner, err := signer.NewPrivateKeySigner(ecdsaPrivateKey, chainId) - if err != nil { - logger.Error("Cannot create signer", "err", err) - return nil, nil, nil, err - } - - elChainWriter := elcontracts.NewELChainWriter( - elContractsClient, - ethHttpClient, - privateKeySigner, - logger, - eigenMetrics, - ) - if err != nil { - logger.Error("Failed to create ELChainWriter", "err", err) - return nil, nil, nil, err - } - - return elChainReader, elChainWriter, elChainSubscriber, nil -} - -func (config *Config) buildAvsRegistryContractsChainClient( - logger logging.Logger, - ethHttpClient eth.EthClient, -) (clients.AVSRegistryContractsClient, error) { - blsRegistryCoordinatorAddr := gethcommon.HexToAddress(config.BlsRegistryCoordinatorAddr) - contractBLSRegistryCoordWithIndices, err := blsregcoord.NewContractBLSRegistryCoordinatorWithIndices( - blsRegistryCoordinatorAddr, - ethHttpClient, - ) - if err != nil { - logger.Error("Failed to fetch BLSRegistryCoordinatorWithIndices contract", "err", err) - return nil, err - } - - stakeregistryAddr, err := contractBLSRegistryCoordWithIndices.StakeRegistry(&bind.CallOpts{}) - if err != nil { - logger.Error("Failed to fetch StakeRegistry contract", "err", err) - return nil, err - } - - blsPubkeyRegistryAddr, err := contractBLSRegistryCoordWithIndices.BlsPubkeyRegistry(&bind.CallOpts{}) - if err != nil { - logger.Error("Failed to fetch BlsPubkeyRegistry contract", "err", err) - return nil, err - } - - avsregistryContractsChainClient, err := clients.NewAvsRegistryContractsChainClient( - blsRegistryCoordinatorAddr, - gethcommon.HexToAddress(config.BlsOperatorStateRetrieverAddr), - stakeregistryAddr, - blsPubkeyRegistryAddr, - ethHttpClient, - logger, - ) - if err != nil { - logger.Error("Failed to create AVSRegistryContractsChainClient", "err", err) - return nil, err - } - - return avsregistryContractsChainClient, nil -} - -func (config *Config) buildAvsClients( - avsContractsClient clients.AVSRegistryContractsClient, - logger logging.Logger, - ethHttpClient eth.EthClient, -) (avsregistry.AvsRegistryReader, avsregistry.AvsRegistryWriter, error) { - avsRegistryChainReader, err := avsregistry.NewAvsRegistryReader( - avsContractsClient, - logger, - ethHttpClient, - ) - if err != nil { - logger.Error("Failed to create AVSRegistryChainReader", "err", err) - return nil, nil, err - } - - ecdsaPrivateKey, err := crypto.HexToECDSA(config.EcdsaPrivateKeyString) - if err != nil { - logger.Errorf("Cannot parse ecdsa private key", "err", err) - return nil, nil, err - } - - chainId, err := ethHttpClient.ChainID(context.Background()) - if err != nil { - logger.Error("Cannot get chainId", "err", err) - return nil, nil, err - } - - privateKeySigner, err := signer.NewPrivateKeySigner(ecdsaPrivateKey, chainId) - if err != nil { - logger.Error("Cannot create signer", "err", err) - return nil, nil, err - } - - avsRegistryChainWriter, err := avsregistry.NewAvsRegistryWriter( - avsContractsClient, - logger, - privateKeySigner, - ethHttpClient, - ) - if err != nil { - logger.Error("Failed to create AVSRegistryChainWriter", "err", err) - return nil, nil, err - } - - return avsRegistryChainReader, avsRegistryChainWriter, nil -} diff --git a/chainio/elcontracts/reader.go b/chainio/elcontracts/reader.go deleted file mode 100644 index 43b238b9..00000000 --- a/chainio/elcontracts/reader.go +++ /dev/null @@ -1,251 +0,0 @@ -package elcontracts - -import ( - "bytes" - "context" - "math/big" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - gethcommon "github.com/ethereum/go-ethereum/common" - - "github.com/Layr-Labs/eigensdk-go/chainio/clients" - "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - strategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" - "github.com/Layr-Labs/eigensdk-go/crypto/bls" - "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/Layr-Labs/eigensdk-go/types" - eigenabi "github.com/Layr-Labs/eigensdk-go/types/abi" -) - -type ELReader interface { - IsOperatorRegistered(ctx context.Context, operator types.Operator) (bool, error) - - GetOperatorDetails(ctx context.Context, operator types.Operator) (types.Operator, error) - - // GetStrategyAndUnderlyingToken returns the strategy contract and the underlying token address - // use GetStrategyAndUnderlyingERC20Token if the contract address confirms with ERC20 standard - GetStrategyAndUnderlyingToken( - ctx context.Context, strategyAddr gethcommon.Address, - ) (*strategy.ContractIStrategy, gethcommon.Address, error) - - // GetStrategyAndUnderlyingERC20Token returns the strategy contract and the underlying ERC20 token address - GetStrategyAndUnderlyingERC20Token( - ctx context.Context, strategyAddr gethcommon.Address, - ) (*strategy.ContractIStrategy, clients.ERC20ContractClient, gethcommon.Address, error) - - QueryExistingRegisteredOperatorPubKeys( - startBlock *big.Int, - stopBlock *big.Int, - ) ([]types.OperatorAddr, []types.OperatorPubkeys, error) - - GetOperatorPubkeyHash(ctx context.Context, operator types.Operator) ([32]byte, error) - - GetOperatorAddressFromPubkeyHash(ctx context.Context, pubkeyHash [32]byte) (gethcommon.Address, error) - - ServiceManagerCanSlashOperatorUntilBlock( - ctx context.Context, - operatorAddr gethcommon.Address, - serviceManagerAddr gethcommon.Address, - ) (uint32, error) - - OperatorIsFrozen(ctx context.Context, operatorAddr gethcommon.Address) (bool, error) - - GetOperatorSharesInStrategy( - ctx context.Context, - operatorAddr gethcommon.Address, - strategyAddr gethcommon.Address, - ) (*big.Int, error) -} - -type ELChainReader struct { - logger logging.Logger - elContractsClient clients.ELContractsClient - ethClient eth.EthClient -} - -// forces EthReader to implement the chainio.Reader interface -var _ ELReader = (*ELChainReader)(nil) - -func NewELChainReader( - elContractsClient clients.ELContractsClient, - logger logging.Logger, - ethClient eth.EthClient, -) (*ELChainReader, error) { - return &ELChainReader{ - elContractsClient: elContractsClient, - logger: logger, - ethClient: ethClient, - }, nil -} - -func (r *ELChainReader) IsOperatorRegistered(ctx context.Context, operator types.Operator) (bool, error) { - isOperator, err := r.elContractsClient.IsOperator( - &bind.CallOpts{}, - gethcommon.HexToAddress(operator.Address), - ) - if err != nil { - return false, err - } - - return isOperator, nil -} - -func (r *ELChainReader) GetOperatorPubkeyHash(ctx context.Context, operator types.Operator) ([32]byte, error) { - operatorPubkeyHash, err := r.elContractsClient.GetOperatorPubkeyHash( - &bind.CallOpts{}, - gethcommon.HexToAddress(operator.Address), - ) - if err != nil { - return [32]byte{}, err - } - - return operatorPubkeyHash, nil -} - -func (r *ELChainReader) GetOperatorAddressFromPubkeyHash( - ctx context.Context, - pubkeyHash [32]byte, -) (gethcommon.Address, error) { - return r.elContractsClient.GetOperatorAddressFromPubkeyHash( - &bind.CallOpts{}, - pubkeyHash, - ) -} - -func (r *ELChainReader) GetOperatorDetails(ctx context.Context, operator types.Operator) (types.Operator, error) { - operatorDetails, err := r.elContractsClient.OperatorDetails( - &bind.CallOpts{}, - gethcommon.HexToAddress(operator.Address), - ) - if err != nil { - return types.Operator{}, err - } - - return types.Operator{ - Address: operator.Address, - EarningsReceiverAddress: operatorDetails.EarningsReceiver.Hex(), - StakerOptOutWindowBlocks: operatorDetails.StakerOptOutWindowBlocks, - DelegationApproverAddress: operatorDetails.DelegationApprover.Hex(), - }, nil -} - -func (r *ELChainReader) GetStrategyAndUnderlyingToken( - ctx context.Context, strategyAddr gethcommon.Address, -) (*strategy.ContractIStrategy, gethcommon.Address, error) { - return r.elContractsClient.GetStrategyAndUnderlyingToken(strategyAddr) -} - -func (r *ELChainReader) GetStrategyAndUnderlyingERC20Token( - ctx context.Context, strategyAddr gethcommon.Address, -) (*strategy.ContractIStrategy, clients.ERC20ContractClient, gethcommon.Address, error) { - return r.elContractsClient.GetStrategyAndUnderlyingERC20Token(strategyAddr) -} - -func (r *ELChainReader) ServiceManagerCanSlashOperatorUntilBlock( - ctx context.Context, - operatorAddr gethcommon.Address, - serviceManagerAddr gethcommon.Address, -) (uint32, error) { - serviceManagerCanSlashOperatorUntilBlock, err := r.elContractsClient.ContractCanSlashOperatorUntilBlock( - &bind.CallOpts{Context: ctx}, operatorAddr, serviceManagerAddr, - ) - if err != nil { - return 0, err - } - return serviceManagerCanSlashOperatorUntilBlock, nil -} - -func (r *ELChainReader) OperatorIsFrozen(ctx context.Context, operatorAddr gethcommon.Address) (bool, error) { - operatorIsFrozen, err := r.elContractsClient.IsFrozen(&bind.CallOpts{Context: ctx}, operatorAddr) - if err != nil { - return false, err - } - return operatorIsFrozen, nil -} - -func (r *ELChainReader) QueryExistingRegisteredOperatorPubKeys( - startBlock *big.Int, - stopBlock *big.Int, -) ([]types.OperatorAddr, []types.OperatorPubkeys, error) { - - query := ethereum.FilterQuery{ - FromBlock: startBlock, - ToBlock: stopBlock, - Addresses: []gethcommon.Address{ - r.elContractsClient.GetBLSPublicKeyCompendiumContractAddress(), - }, - } - - logs, err := r.ethClient.FilterLogs(context.Background(), query) - if err != nil { - r.logger.Error("Error filtering logs", "err", err) - return nil, nil, err - } - r.logger.Info("logs:", "logs", logs) - - pubkeyCompendiumAbi, err := abi.JSON(bytes.NewReader(eigenabi.BLSPublicKeyCompendiumAbi)) - if err != nil { - r.logger.Error("Error getting Abi", "err", err) - return nil, nil, err - } - - operatorAddresses := make([]types.OperatorAddr, 0) - operatorPubkeys := make([]types.OperatorPubkeys, 0) - - for _, vLog := range logs { - - // get the operator address - operatorAddr := gethcommon.HexToAddress(vLog.Topics[1].Hex()) - operatorAddresses = append(operatorAddresses, operatorAddr) - - event, err := pubkeyCompendiumAbi.Unpack("NewPubkeyRegistration", vLog.Data) - if err != nil { - r.logger.Error("Error unpacking event data", "err", err) - return nil, nil, err - } - - G1Pubkey := event[0].(struct { - X *big.Int "json:\"X\"" - Y *big.Int "json:\"Y\"" - }) - - G2Pubkey := event[1].(struct { - X [2]*big.Int "json:\"X\"" - Y [2]*big.Int "json:\"Y\"" - }) - - operatorPubkey := types.OperatorPubkeys{ - G1Pubkey: bls.NewG1Point( - G1Pubkey.X, - G1Pubkey.Y, - ), - G2Pubkey: bls.NewG2Point( - G2Pubkey.X, - G2Pubkey.Y, - ), - } - - operatorPubkeys = append(operatorPubkeys, operatorPubkey) - - } - - return operatorAddresses, operatorPubkeys, nil -} - -func (r *ELChainReader) GetOperatorSharesInStrategy( - ctx context.Context, - operatorAddr gethcommon.Address, - strategyAddr gethcommon.Address, -) (*big.Int, error) { - operatorSharesInStrategy, err := r.elContractsClient.OperatorShares( - &bind.CallOpts{Context: ctx}, - operatorAddr, - strategyAddr, - ) - if err != nil { - return nil, err - } - return operatorSharesInStrategy, nil -} diff --git a/chainio/gen.go b/chainio/gen.go index b31a777d..ba082ce6 100644 --- a/chainio/gen.go +++ b/chainio/gen.go @@ -1,13 +1,9 @@ package chainio -//go:generate mockgen -destination=./mocks/avsRegistryContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/avsregistry AvsRegistryReader -//go:generate mockgen -destination=./mocks/avsRegistryContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/avsregistry AvsRegistryWriter -//go:generate mockgen -destination=./mocks/elContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/elcontracts ELReader -//go:generate mockgen -destination=./mocks/elContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/elcontracts ELWriter -//go:generate mockgen -destination=./mocks/elContractsSubscriber.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/elcontracts ELSubscriber -//go:generate mockgen -destination=./mocks/elContractsClient.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients ELContractsClient -//go:generate mockgen -destination=./mocks/erc20ContractClient.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients ERC20ContractClient -//go:generate mockgen -destination=./mocks/avsRegistryContractClient.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients AVSRegistryContractsClient +//go:generate mockgen -destination=./mocks/avsRegistryContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry AvsRegistryReader +//go:generate mockgen -destination=./mocks/avsRegistryContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry AvsRegistryWriter +//go:generate mockgen -destination=./mocks/elContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELReader +//go:generate mockgen -destination=./mocks/elContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELWriter +//go:generate mockgen -destination=./mocks/elContractsSubscriber.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELSubscriber //go:generate mockgen -destination=./mocks/ethclient.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/eth EthClient - //go:generate mockgen -destination=./mocks/eventSubscription.go -package=mocks github.com/ethereum/go-ethereum/event Subscription diff --git a/chainio/mocks/avsRegistryContractsReader.go b/chainio/mocks/avsRegistryContractsReader.go index 9cca3d2e..fe606e74 100644 --- a/chainio/mocks/avsRegistryContractsReader.go +++ b/chainio/mocks/avsRegistryContractsReader.go @@ -1,19 +1,19 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/Layr-Labs/eigensdk-go/chainio/avsregistry (interfaces: AvsRegistryReader) +// Source: github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry (interfaces: AvsRegistryReader) // // Generated by this command: // -// mockgen -destination=./mocks/avsRegistryContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/avsregistry AvsRegistryReader +// mockgen -destination=./mocks/avsRegistryContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry AvsRegistryReader // // Package mocks is a generated GoMock package. package mocks import ( - context "context" big "math/big" reflect "reflect" contractBLSOperatorStateRetriever "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" + bind "github.com/ethereum/go-ethereum/accounts/abi/bind" common "github.com/ethereum/go-ethereum/common" gomock "go.uber.org/mock/gomock" ) @@ -42,7 +42,7 @@ func (m *MockAvsRegistryReader) EXPECT() *MockAvsRegistryReaderMockRecorder { } // GetCheckSignaturesIndices mocks base method. -func (m *MockAvsRegistryReader) GetCheckSignaturesIndices(arg0 context.Context, arg1 uint32, arg2 []byte, arg3 [][32]byte) (contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { +func (m *MockAvsRegistryReader) GetCheckSignaturesIndices(arg0 *bind.CallOpts, arg1 uint32, arg2 []byte, arg3 [][32]byte) (contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCheckSignaturesIndices", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverCheckSignaturesIndices) @@ -57,7 +57,7 @@ func (mr *MockAvsRegistryReaderMockRecorder) GetCheckSignaturesIndices(arg0, arg } // GetOperatorId mocks base method. -func (m *MockAvsRegistryReader) GetOperatorId(arg0 context.Context, arg1 common.Address) ([32]byte, error) { +func (m *MockAvsRegistryReader) GetOperatorId(arg0 *bind.CallOpts, arg1 common.Address) ([32]byte, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorId", arg0, arg1) ret0, _ := ret[0].([32]byte) @@ -72,7 +72,7 @@ func (mr *MockAvsRegistryReaderMockRecorder) GetOperatorId(arg0, arg1 any) *gomo } // GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock mocks base method. -func (m *MockAvsRegistryReader) GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock(arg0 context.Context, arg1 [32]byte) (map[byte]*big.Int, error) { +func (m *MockAvsRegistryReader) GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock(arg0 *bind.CallOpts, arg1 [32]byte) (map[byte]*big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock", arg0, arg1) ret0, _ := ret[0].(map[byte]*big.Int) @@ -87,7 +87,7 @@ func (mr *MockAvsRegistryReaderMockRecorder) GetOperatorStakeInQuorumsOfOperator } // GetOperatorsStakeInQuorumsAtBlock mocks base method. -func (m *MockAvsRegistryReader) GetOperatorsStakeInQuorumsAtBlock(arg0 context.Context, arg1 []byte, arg2 uint32) ([][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator, error) { +func (m *MockAvsRegistryReader) GetOperatorsStakeInQuorumsAtBlock(arg0 *bind.CallOpts, arg1 []byte, arg2 uint32) ([][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorsStakeInQuorumsAtBlock", arg0, arg1, arg2) ret0, _ := ret[0].([][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator) @@ -102,7 +102,7 @@ func (mr *MockAvsRegistryReaderMockRecorder) GetOperatorsStakeInQuorumsAtBlock(a } // GetOperatorsStakeInQuorumsOfOperatorAtBlock mocks base method. -func (m *MockAvsRegistryReader) GetOperatorsStakeInQuorumsOfOperatorAtBlock(arg0 context.Context, arg1 [32]byte, arg2 uint32) ([]byte, [][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator, error) { +func (m *MockAvsRegistryReader) GetOperatorsStakeInQuorumsOfOperatorAtBlock(arg0 *bind.CallOpts, arg1 [32]byte, arg2 uint32) ([]byte, [][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorsStakeInQuorumsOfOperatorAtBlock", arg0, arg1, arg2) ret0, _ := ret[0].([]byte) @@ -118,7 +118,7 @@ func (mr *MockAvsRegistryReaderMockRecorder) GetOperatorsStakeInQuorumsOfOperato } // GetOperatorsStakeInQuorumsOfOperatorAtCurrentBlock mocks base method. -func (m *MockAvsRegistryReader) GetOperatorsStakeInQuorumsOfOperatorAtCurrentBlock(arg0 context.Context, arg1 [32]byte) ([]byte, [][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator, error) { +func (m *MockAvsRegistryReader) GetOperatorsStakeInQuorumsOfOperatorAtCurrentBlock(arg0 *bind.CallOpts, arg1 [32]byte) ([]byte, [][]contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverOperator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorsStakeInQuorumsOfOperatorAtCurrentBlock", arg0, arg1) ret0, _ := ret[0].([]byte) @@ -134,7 +134,7 @@ func (mr *MockAvsRegistryReaderMockRecorder) GetOperatorsStakeInQuorumsOfOperato } // IsOperatorRegistered mocks base method. -func (m *MockAvsRegistryReader) IsOperatorRegistered(arg0 context.Context, arg1 common.Address) (bool, error) { +func (m *MockAvsRegistryReader) IsOperatorRegistered(arg0 *bind.CallOpts, arg1 common.Address) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsOperatorRegistered", arg0, arg1) ret0, _ := ret[0].(bool) diff --git a/chainio/mocks/avsRegistryContractsWriter.go b/chainio/mocks/avsRegistryContractsWriter.go index 8a89461d..aebf364b 100644 --- a/chainio/mocks/avsRegistryContractsWriter.go +++ b/chainio/mocks/avsRegistryContractsWriter.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/Layr-Labs/eigensdk-go/chainio/avsregistry (interfaces: AvsRegistryWriter) +// Source: github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry (interfaces: AvsRegistryWriter) // // Generated by this command: // -// mockgen -destination=./mocks/avsRegistryContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/avsregistry AvsRegistryWriter +// mockgen -destination=./mocks/avsRegistryContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry AvsRegistryWriter // // Package mocks is a generated GoMock package. package mocks @@ -12,7 +12,6 @@ import ( context "context" reflect "reflect" - contractBLSPubkeyRegistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPubkeyRegistry" contractBLSRegistryCoordinatorWithIndices "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" common "github.com/ethereum/go-ethereum/common" types "github.com/ethereum/go-ethereum/core/types" @@ -43,18 +42,18 @@ func (m *MockAvsRegistryWriter) EXPECT() *MockAvsRegistryWriterMockRecorder { } // DeregisterOperator mocks base method. -func (m *MockAvsRegistryWriter) DeregisterOperator(arg0 context.Context, arg1 common.Address, arg2 []byte, arg3 contractBLSPubkeyRegistry.BN254G1Point) (*types.Receipt, error) { +func (m *MockAvsRegistryWriter) DeregisterOperator(arg0 context.Context, arg1 []byte, arg2 contractBLSRegistryCoordinatorWithIndices.BN254G1Point) (*types.Receipt, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeregisterOperator", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "DeregisterOperator", arg0, arg1, arg2) ret0, _ := ret[0].(*types.Receipt) ret1, _ := ret[1].(error) return ret0, ret1 } // DeregisterOperator indicates an expected call of DeregisterOperator. -func (mr *MockAvsRegistryWriterMockRecorder) DeregisterOperator(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockAvsRegistryWriterMockRecorder) DeregisterOperator(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeregisterOperator", reflect.TypeOf((*MockAvsRegistryWriter)(nil).DeregisterOperator), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeregisterOperator", reflect.TypeOf((*MockAvsRegistryWriter)(nil).DeregisterOperator), arg0, arg1, arg2) } // RegisterOperatorWithAVSRegistryCoordinator mocks base method. diff --git a/chainio/mocks/elContractsClient.go b/chainio/mocks/elContractsClient.go deleted file mode 100644 index cc4769e8..00000000 --- a/chainio/mocks/elContractsClient.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/Layr-Labs/eigensdk-go/chainio/clients (interfaces: ELContractsClient) -// -// Generated by this command: -// -// mockgen -destination=./mocks/elContractsClient.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients ELContractsClient -// -// Package mocks is a generated GoMock package. -package mocks - -import ( - big "math/big" - reflect "reflect" - - clients "github.com/Layr-Labs/eigensdk-go/chainio/clients" - contractBLSPublicKeyCompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" - contractDelegationManager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" - contractIStrategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" - bind "github.com/ethereum/go-ethereum/accounts/abi/bind" - common "github.com/ethereum/go-ethereum/common" - types "github.com/ethereum/go-ethereum/core/types" - event "github.com/ethereum/go-ethereum/event" - gomock "go.uber.org/mock/gomock" -) - -// MockELContractsClient is a mock of ELContractsClient interface. -type MockELContractsClient struct { - ctrl *gomock.Controller - recorder *MockELContractsClientMockRecorder -} - -// MockELContractsClientMockRecorder is the mock recorder for MockELContractsClient. -type MockELContractsClientMockRecorder struct { - mock *MockELContractsClient -} - -// NewMockELContractsClient creates a new mock instance. -func NewMockELContractsClient(ctrl *gomock.Controller) *MockELContractsClient { - mock := &MockELContractsClient{ctrl: ctrl} - mock.recorder = &MockELContractsClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockELContractsClient) EXPECT() *MockELContractsClientMockRecorder { - return m.recorder -} - -// ContractCanSlashOperatorUntilBlock mocks base method. -func (m *MockELContractsClient) ContractCanSlashOperatorUntilBlock(arg0 *bind.CallOpts, arg1, arg2 common.Address) (uint32, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ContractCanSlashOperatorUntilBlock", arg0, arg1, arg2) - ret0, _ := ret[0].(uint32) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ContractCanSlashOperatorUntilBlock indicates an expected call of ContractCanSlashOperatorUntilBlock. -func (mr *MockELContractsClientMockRecorder) ContractCanSlashOperatorUntilBlock(arg0, arg1, arg2 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContractCanSlashOperatorUntilBlock", reflect.TypeOf((*MockELContractsClient)(nil).ContractCanSlashOperatorUntilBlock), arg0, arg1, arg2) -} - -// DepositIntoStrategy mocks base method. -func (m *MockELContractsClient) DepositIntoStrategy(arg0 *bind.TransactOpts, arg1, arg2 common.Address, arg3 *big.Int) (*types.Transaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DepositIntoStrategy", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*types.Transaction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DepositIntoStrategy indicates an expected call of DepositIntoStrategy. -func (mr *MockELContractsClientMockRecorder) DepositIntoStrategy(arg0, arg1, arg2, arg3 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DepositIntoStrategy", reflect.TypeOf((*MockELContractsClient)(nil).DepositIntoStrategy), arg0, arg1, arg2, arg3) -} - -// GetBLSPublicKeyCompendiumContractAddress mocks base method. -func (m *MockELContractsClient) GetBLSPublicKeyCompendiumContractAddress() common.Address { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBLSPublicKeyCompendiumContractAddress") - ret0, _ := ret[0].(common.Address) - return ret0 -} - -// GetBLSPublicKeyCompendiumContractAddress indicates an expected call of GetBLSPublicKeyCompendiumContractAddress. -func (mr *MockELContractsClientMockRecorder) GetBLSPublicKeyCompendiumContractAddress() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBLSPublicKeyCompendiumContractAddress", reflect.TypeOf((*MockELContractsClient)(nil).GetBLSPublicKeyCompendiumContractAddress)) -} - -// GetOperatorAddressFromPubkeyHash mocks base method. -func (m *MockELContractsClient) GetOperatorAddressFromPubkeyHash(arg0 *bind.CallOpts, arg1 [32]byte) (common.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOperatorAddressFromPubkeyHash", arg0, arg1) - ret0, _ := ret[0].(common.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetOperatorAddressFromPubkeyHash indicates an expected call of GetOperatorAddressFromPubkeyHash. -func (mr *MockELContractsClientMockRecorder) GetOperatorAddressFromPubkeyHash(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOperatorAddressFromPubkeyHash", reflect.TypeOf((*MockELContractsClient)(nil).GetOperatorAddressFromPubkeyHash), arg0, arg1) -} - -// GetOperatorPubkeyHash mocks base method. -func (m *MockELContractsClient) GetOperatorPubkeyHash(arg0 *bind.CallOpts, arg1 common.Address) ([32]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOperatorPubkeyHash", arg0, arg1) - ret0, _ := ret[0].([32]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetOperatorPubkeyHash indicates an expected call of GetOperatorPubkeyHash. -func (mr *MockELContractsClientMockRecorder) GetOperatorPubkeyHash(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOperatorPubkeyHash", reflect.TypeOf((*MockELContractsClient)(nil).GetOperatorPubkeyHash), arg0, arg1) -} - -// GetStrategyAndUnderlyingERC20Token mocks base method. -func (m *MockELContractsClient) GetStrategyAndUnderlyingERC20Token(arg0 common.Address) (*contractIStrategy.ContractIStrategy, clients.ERC20ContractClient, common.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStrategyAndUnderlyingERC20Token", arg0) - ret0, _ := ret[0].(*contractIStrategy.ContractIStrategy) - ret1, _ := ret[1].(clients.ERC20ContractClient) - ret2, _ := ret[2].(common.Address) - ret3, _ := ret[3].(error) - return ret0, ret1, ret2, ret3 -} - -// GetStrategyAndUnderlyingERC20Token indicates an expected call of GetStrategyAndUnderlyingERC20Token. -func (mr *MockELContractsClientMockRecorder) GetStrategyAndUnderlyingERC20Token(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStrategyAndUnderlyingERC20Token", reflect.TypeOf((*MockELContractsClient)(nil).GetStrategyAndUnderlyingERC20Token), arg0) -} - -// GetStrategyAndUnderlyingToken mocks base method. -func (m *MockELContractsClient) GetStrategyAndUnderlyingToken(arg0 common.Address) (*contractIStrategy.ContractIStrategy, common.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStrategyAndUnderlyingToken", arg0) - ret0, _ := ret[0].(*contractIStrategy.ContractIStrategy) - ret1, _ := ret[1].(common.Address) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetStrategyAndUnderlyingToken indicates an expected call of GetStrategyAndUnderlyingToken. -func (mr *MockELContractsClientMockRecorder) GetStrategyAndUnderlyingToken(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStrategyAndUnderlyingToken", reflect.TypeOf((*MockELContractsClient)(nil).GetStrategyAndUnderlyingToken), arg0) -} - -// GetStrategyManagerContractAddress mocks base method. -func (m *MockELContractsClient) GetStrategyManagerContractAddress() (common.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStrategyManagerContractAddress") - ret0, _ := ret[0].(common.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetStrategyManagerContractAddress indicates an expected call of GetStrategyManagerContractAddress. -func (mr *MockELContractsClientMockRecorder) GetStrategyManagerContractAddress() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStrategyManagerContractAddress", reflect.TypeOf((*MockELContractsClient)(nil).GetStrategyManagerContractAddress)) -} - -// IsFrozen mocks base method. -func (m *MockELContractsClient) IsFrozen(arg0 *bind.CallOpts, arg1 common.Address) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsFrozen", arg0, arg1) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// IsFrozen indicates an expected call of IsFrozen. -func (mr *MockELContractsClientMockRecorder) IsFrozen(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsFrozen", reflect.TypeOf((*MockELContractsClient)(nil).IsFrozen), arg0, arg1) -} - -// IsOperator mocks base method. -func (m *MockELContractsClient) IsOperator(arg0 *bind.CallOpts, arg1 common.Address) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsOperator", arg0, arg1) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// IsOperator indicates an expected call of IsOperator. -func (mr *MockELContractsClientMockRecorder) IsOperator(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOperator", reflect.TypeOf((*MockELContractsClient)(nil).IsOperator), arg0, arg1) -} - -// ModifyOperatorDetails mocks base method. -func (m *MockELContractsClient) ModifyOperatorDetails(arg0 *bind.TransactOpts, arg1 contractDelegationManager.IDelegationManagerOperatorDetails) (*types.Transaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ModifyOperatorDetails", arg0, arg1) - ret0, _ := ret[0].(*types.Transaction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ModifyOperatorDetails indicates an expected call of ModifyOperatorDetails. -func (mr *MockELContractsClientMockRecorder) ModifyOperatorDetails(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModifyOperatorDetails", reflect.TypeOf((*MockELContractsClient)(nil).ModifyOperatorDetails), arg0, arg1) -} - -// OperatorDetails mocks base method. -func (m *MockELContractsClient) OperatorDetails(arg0 *bind.CallOpts, arg1 common.Address) (contractDelegationManager.IDelegationManagerOperatorDetails, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OperatorDetails", arg0, arg1) - ret0, _ := ret[0].(contractDelegationManager.IDelegationManagerOperatorDetails) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OperatorDetails indicates an expected call of OperatorDetails. -func (mr *MockELContractsClientMockRecorder) OperatorDetails(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OperatorDetails", reflect.TypeOf((*MockELContractsClient)(nil).OperatorDetails), arg0, arg1) -} - -// OperatorShares mocks base method. -func (m *MockELContractsClient) OperatorShares(arg0 *bind.CallOpts, arg1, arg2 common.Address) (*big.Int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OperatorShares", arg0, arg1, arg2) - ret0, _ := ret[0].(*big.Int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OperatorShares indicates an expected call of OperatorShares. -func (mr *MockELContractsClientMockRecorder) OperatorShares(arg0, arg1, arg2 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OperatorShares", reflect.TypeOf((*MockELContractsClient)(nil).OperatorShares), arg0, arg1, arg2) -} - -// OptIntoSlashing mocks base method. -func (m *MockELContractsClient) OptIntoSlashing(arg0 *bind.TransactOpts, arg1 common.Address) (*types.Transaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OptIntoSlashing", arg0, arg1) - ret0, _ := ret[0].(*types.Transaction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OptIntoSlashing indicates an expected call of OptIntoSlashing. -func (mr *MockELContractsClientMockRecorder) OptIntoSlashing(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OptIntoSlashing", reflect.TypeOf((*MockELContractsClient)(nil).OptIntoSlashing), arg0, arg1) -} - -// RegisterAsOperator mocks base method. -func (m *MockELContractsClient) RegisterAsOperator(arg0 *bind.TransactOpts, arg1 contractDelegationManager.IDelegationManagerOperatorDetails, arg2 string) (*types.Transaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegisterAsOperator", arg0, arg1, arg2) - ret0, _ := ret[0].(*types.Transaction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// RegisterAsOperator indicates an expected call of RegisterAsOperator. -func (mr *MockELContractsClientMockRecorder) RegisterAsOperator(arg0, arg1, arg2 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterAsOperator", reflect.TypeOf((*MockELContractsClient)(nil).RegisterAsOperator), arg0, arg1, arg2) -} - -// RegisterBLSPublicKey mocks base method. -func (m *MockELContractsClient) RegisterBLSPublicKey(arg0 *bind.TransactOpts, arg1, arg2 contractBLSPublicKeyCompendium.BN254G1Point, arg3 contractBLSPublicKeyCompendium.BN254G2Point) (*types.Transaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegisterBLSPublicKey", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*types.Transaction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// RegisterBLSPublicKey indicates an expected call of RegisterBLSPublicKey. -func (mr *MockELContractsClientMockRecorder) RegisterBLSPublicKey(arg0, arg1, arg2, arg3 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterBLSPublicKey", reflect.TypeOf((*MockELContractsClient)(nil).RegisterBLSPublicKey), arg0, arg1, arg2, arg3) -} - -// UpdateOperatorMetadataURI mocks base method. -func (m *MockELContractsClient) UpdateOperatorMetadataURI(arg0 *bind.TransactOpts, arg1 string) (*types.Transaction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateOperatorMetadataURI", arg0, arg1) - ret0, _ := ret[0].(*types.Transaction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UpdateOperatorMetadataURI indicates an expected call of UpdateOperatorMetadataURI. -func (mr *MockELContractsClientMockRecorder) UpdateOperatorMetadataURI(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateOperatorMetadataURI", reflect.TypeOf((*MockELContractsClient)(nil).UpdateOperatorMetadataURI), arg0, arg1) -} - -// WatchNewPubkeyRegistration mocks base method. -func (m *MockELContractsClient) WatchNewPubkeyRegistration(arg0 *bind.WatchOpts, arg1 chan<- *contractBLSPublicKeyCompendium.ContractBLSPublicKeyCompendiumNewPubkeyRegistration, arg2 []common.Address) (event.Subscription, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WatchNewPubkeyRegistration", arg0, arg1, arg2) - ret0, _ := ret[0].(event.Subscription) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WatchNewPubkeyRegistration indicates an expected call of WatchNewPubkeyRegistration. -func (mr *MockELContractsClientMockRecorder) WatchNewPubkeyRegistration(arg0, arg1, arg2 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WatchNewPubkeyRegistration", reflect.TypeOf((*MockELContractsClient)(nil).WatchNewPubkeyRegistration), arg0, arg1, arg2) -} diff --git a/chainio/mocks/elContractsReader.go b/chainio/mocks/elContractsReader.go index 8f4ec7c7..a9a86496 100644 --- a/chainio/mocks/elContractsReader.go +++ b/chainio/mocks/elContractsReader.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/Layr-Labs/eigensdk-go/chainio/elcontracts (interfaces: ELReader) +// Source: github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts (interfaces: ELReader) // // Generated by this command: // -// mockgen -destination=./mocks/elContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/elcontracts ELReader +// mockgen -destination=./mocks/elContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELReader // // Package mocks is a generated GoMock package. package mocks @@ -13,9 +13,10 @@ import ( big "math/big" reflect "reflect" - clients "github.com/Layr-Labs/eigensdk-go/chainio/clients" + contractIERC20 "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IERC20" contractIStrategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" types "github.com/Layr-Labs/eigensdk-go/types" + bind "github.com/ethereum/go-ethereum/accounts/abi/bind" common "github.com/ethereum/go-ethereum/common" gomock "go.uber.org/mock/gomock" ) @@ -44,7 +45,7 @@ func (m *MockELReader) EXPECT() *MockELReaderMockRecorder { } // GetOperatorAddressFromPubkeyHash mocks base method. -func (m *MockELReader) GetOperatorAddressFromPubkeyHash(arg0 context.Context, arg1 [32]byte) (common.Address, error) { +func (m *MockELReader) GetOperatorAddressFromPubkeyHash(arg0 *bind.CallOpts, arg1 [32]byte) (common.Address, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorAddressFromPubkeyHash", arg0, arg1) ret0, _ := ret[0].(common.Address) @@ -59,7 +60,7 @@ func (mr *MockELReaderMockRecorder) GetOperatorAddressFromPubkeyHash(arg0, arg1 } // GetOperatorDetails mocks base method. -func (m *MockELReader) GetOperatorDetails(arg0 context.Context, arg1 types.Operator) (types.Operator, error) { +func (m *MockELReader) GetOperatorDetails(arg0 *bind.CallOpts, arg1 types.Operator) (types.Operator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorDetails", arg0, arg1) ret0, _ := ret[0].(types.Operator) @@ -74,7 +75,7 @@ func (mr *MockELReaderMockRecorder) GetOperatorDetails(arg0, arg1 any) *gomock.C } // GetOperatorPubkeyHash mocks base method. -func (m *MockELReader) GetOperatorPubkeyHash(arg0 context.Context, arg1 types.Operator) ([32]byte, error) { +func (m *MockELReader) GetOperatorPubkeyHash(arg0 *bind.CallOpts, arg1 types.Operator) ([32]byte, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorPubkeyHash", arg0, arg1) ret0, _ := ret[0].([32]byte) @@ -89,7 +90,7 @@ func (mr *MockELReaderMockRecorder) GetOperatorPubkeyHash(arg0, arg1 any) *gomoc } // GetOperatorSharesInStrategy mocks base method. -func (m *MockELReader) GetOperatorSharesInStrategy(arg0 context.Context, arg1, arg2 common.Address) (*big.Int, error) { +func (m *MockELReader) GetOperatorSharesInStrategy(arg0 *bind.CallOpts, arg1, arg2 common.Address) (*big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperatorSharesInStrategy", arg0, arg1, arg2) ret0, _ := ret[0].(*big.Int) @@ -104,11 +105,11 @@ func (mr *MockELReaderMockRecorder) GetOperatorSharesInStrategy(arg0, arg1, arg2 } // GetStrategyAndUnderlyingERC20Token mocks base method. -func (m *MockELReader) GetStrategyAndUnderlyingERC20Token(arg0 context.Context, arg1 common.Address) (*contractIStrategy.ContractIStrategy, clients.ERC20ContractClient, common.Address, error) { +func (m *MockELReader) GetStrategyAndUnderlyingERC20Token(arg0 *bind.CallOpts, arg1 common.Address) (*contractIStrategy.ContractIStrategy, contractIERC20.ContractIERC20Methods, common.Address, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStrategyAndUnderlyingERC20Token", arg0, arg1) ret0, _ := ret[0].(*contractIStrategy.ContractIStrategy) - ret1, _ := ret[1].(clients.ERC20ContractClient) + ret1, _ := ret[1].(contractIERC20.ContractIERC20Methods) ret2, _ := ret[2].(common.Address) ret3, _ := ret[3].(error) return ret0, ret1, ret2, ret3 @@ -121,7 +122,7 @@ func (mr *MockELReaderMockRecorder) GetStrategyAndUnderlyingERC20Token(arg0, arg } // GetStrategyAndUnderlyingToken mocks base method. -func (m *MockELReader) GetStrategyAndUnderlyingToken(arg0 context.Context, arg1 common.Address) (*contractIStrategy.ContractIStrategy, common.Address, error) { +func (m *MockELReader) GetStrategyAndUnderlyingToken(arg0 *bind.CallOpts, arg1 common.Address) (*contractIStrategy.ContractIStrategy, common.Address, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStrategyAndUnderlyingToken", arg0, arg1) ret0, _ := ret[0].(*contractIStrategy.ContractIStrategy) @@ -137,7 +138,7 @@ func (mr *MockELReaderMockRecorder) GetStrategyAndUnderlyingToken(arg0, arg1 any } // IsOperatorRegistered mocks base method. -func (m *MockELReader) IsOperatorRegistered(arg0 context.Context, arg1 types.Operator) (bool, error) { +func (m *MockELReader) IsOperatorRegistered(arg0 *bind.CallOpts, arg1 types.Operator) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsOperatorRegistered", arg0, arg1) ret0, _ := ret[0].(bool) @@ -152,7 +153,7 @@ func (mr *MockELReaderMockRecorder) IsOperatorRegistered(arg0, arg1 any) *gomock } // OperatorIsFrozen mocks base method. -func (m *MockELReader) OperatorIsFrozen(arg0 context.Context, arg1 common.Address) (bool, error) { +func (m *MockELReader) OperatorIsFrozen(arg0 *bind.CallOpts, arg1 common.Address) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "OperatorIsFrozen", arg0, arg1) ret0, _ := ret[0].(bool) @@ -167,9 +168,9 @@ func (mr *MockELReaderMockRecorder) OperatorIsFrozen(arg0, arg1 any) *gomock.Cal } // QueryExistingRegisteredOperatorPubKeys mocks base method. -func (m *MockELReader) QueryExistingRegisteredOperatorPubKeys(arg0, arg1 *big.Int) ([]common.Address, []types.OperatorPubkeys, error) { +func (m *MockELReader) QueryExistingRegisteredOperatorPubKeys(arg0 context.Context, arg1, arg2 *big.Int) ([]common.Address, []types.OperatorPubkeys, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "QueryExistingRegisteredOperatorPubKeys", arg0, arg1) + ret := m.ctrl.Call(m, "QueryExistingRegisteredOperatorPubKeys", arg0, arg1, arg2) ret0, _ := ret[0].([]common.Address) ret1, _ := ret[1].([]types.OperatorPubkeys) ret2, _ := ret[2].(error) @@ -177,13 +178,13 @@ func (m *MockELReader) QueryExistingRegisteredOperatorPubKeys(arg0, arg1 *big.In } // QueryExistingRegisteredOperatorPubKeys indicates an expected call of QueryExistingRegisteredOperatorPubKeys. -func (mr *MockELReaderMockRecorder) QueryExistingRegisteredOperatorPubKeys(arg0, arg1 any) *gomock.Call { +func (mr *MockELReaderMockRecorder) QueryExistingRegisteredOperatorPubKeys(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryExistingRegisteredOperatorPubKeys", reflect.TypeOf((*MockELReader)(nil).QueryExistingRegisteredOperatorPubKeys), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryExistingRegisteredOperatorPubKeys", reflect.TypeOf((*MockELReader)(nil).QueryExistingRegisteredOperatorPubKeys), arg0, arg1, arg2) } // ServiceManagerCanSlashOperatorUntilBlock mocks base method. -func (m *MockELReader) ServiceManagerCanSlashOperatorUntilBlock(arg0 context.Context, arg1, arg2 common.Address) (uint32, error) { +func (m *MockELReader) ServiceManagerCanSlashOperatorUntilBlock(arg0 *bind.CallOpts, arg1, arg2 common.Address) (uint32, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ServiceManagerCanSlashOperatorUntilBlock", arg0, arg1, arg2) ret0, _ := ret[0].(uint32) diff --git a/chainio/mocks/elContractsSubscriber.go b/chainio/mocks/elContractsSubscriber.go index fd627e52..cb9ddf77 100644 --- a/chainio/mocks/elContractsSubscriber.go +++ b/chainio/mocks/elContractsSubscriber.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/Layr-Labs/eigensdk-go/chainio/elcontracts (interfaces: ELSubscriber) +// Source: github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts (interfaces: ELSubscriber) // // Generated by this command: // -// mockgen -destination=./mocks/elContractsSubscriber.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/elcontracts ELSubscriber +// mockgen -destination=./mocks/elContractsSubscriber.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELSubscriber // // Package mocks is a generated GoMock package. package mocks diff --git a/chainio/mocks/elContractsWriter.go b/chainio/mocks/elContractsWriter.go index f933bcf1..269bdac3 100644 --- a/chainio/mocks/elContractsWriter.go +++ b/chainio/mocks/elContractsWriter.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/Layr-Labs/eigensdk-go/chainio/elcontracts (interfaces: ELWriter) +// Source: github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts (interfaces: ELWriter) // // Generated by this command: // -// mockgen -destination=./mocks/elContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/elcontracts ELWriter +// mockgen -destination=./mocks/elContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELWriter // // Package mocks is a generated GoMock package. package mocks diff --git a/chainio/clients/bindings.go b/chainio/utils/bindings.go similarity index 52% rename from chainio/clients/bindings.go rename to chainio/utils/bindings.go index 2fcac664..39b54d14 100644 --- a/chainio/clients/bindings.go +++ b/chainio/utils/bindings.go @@ -1,4 +1,6 @@ -package clients +// bindings.go contains functions that create contract bindings for the Eigenlayer and AVS contracts. +// These functions are meant to be used by constructors of the chainio package. +package utils import ( "github.com/Layr-Labs/eigensdk-go/logging" @@ -6,7 +8,7 @@ import ( gethcommon "github.com/ethereum/go-ethereum/common" "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - blsoperatorstateretrievar "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" + blsoperatorstateretriever "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" blspubkeyregistry "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPubkeyRegistry" blspubkeycompendium "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSPublicKeyCompendium" blsregistrycoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices" @@ -16,20 +18,26 @@ import ( strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" ) -type eigenlayerContractBindings struct { - Slasher *slasher.ContractSlasher - DelegationManager *delegationmanager.ContractDelegationManager - StrategyManager *strategymanager.ContractStrategyManager - BlsPubKeyCompendium *blspubkeycompendium.ContractBLSPublicKeyCompendium - logger logging.Logger +// Unclear to me why geth bindings don't store and expose the contract address... +// so we also store them here in case the different constructors that use this struct need them +type EigenlayerContractBindings struct { + SlasherAddr gethcommon.Address + StrategyManagerAddr gethcommon.Address + DelegationManagerAddr gethcommon.Address + BlspubkeyCompendiumAddr gethcommon.Address + Slasher *slasher.ContractSlasher + DelegationManager *delegationmanager.ContractDelegationManager + StrategyManager *strategymanager.ContractStrategyManager + // TODO: should this really be here? or moved to avs bindings + BlsPubkeyCompendium *blspubkeycompendium.ContractBLSPublicKeyCompendium } -func newEigenlayerContractBindings( +func NewEigenlayerContractBindings( slasherAddr gethcommon.Address, blsPubKeyCompendiumAddr gethcommon.Address, ethclient eth.EthClient, logger logging.Logger, -) (*eigenlayerContractBindings, error) { +) (*EigenlayerContractBindings, error) { contractSlasher, err := slasher.NewContractSlasher(slasherAddr, ethclient) if err != nil { logger.Error("Failed to fetch Slasher contract", "err", err) @@ -66,30 +74,41 @@ func newEigenlayerContractBindings( return nil, err } - return &eigenlayerContractBindings{ - Slasher: contractSlasher, - StrategyManager: contractStrategyManager, - DelegationManager: contractDelegationManager, - BlsPubKeyCompendium: contractBlsCompendium, - logger: logger, + return &EigenlayerContractBindings{ + SlasherAddr: slasherAddr, + StrategyManagerAddr: strategyManagerAddr, + DelegationManagerAddr: delegationManagerAddr, + BlspubkeyCompendiumAddr: blsPubKeyCompendiumAddr, + Slasher: contractSlasher, + StrategyManager: contractStrategyManager, + DelegationManager: contractDelegationManager, + BlsPubkeyCompendium: contractBlsCompendium, }, nil } -type avsRegistryContractBindings struct { +// Unclear to me why geth bindings don't store and expose the contract address... +// so we also store them here in case the different constructors that use this struct need them +type AvsRegistryContractBindings struct { + // contract addresses + RegistryCoordinatorAddr gethcommon.Address + StakeRegistryAddr gethcommon.Address + BlsPubkeyRegistryAddr gethcommon.Address + BlsPubkeyCompendiumAddr gethcommon.Address + OperatorStateRetriever gethcommon.Address + // contract bindings RegistryCoordinator *blsregistrycoordinator.ContractBLSRegistryCoordinatorWithIndices - BlsOperatorStateRetriever *blsoperatorstateretrievar.ContractBLSOperatorStateRetriever StakeRegistry *stakeregistry.ContractStakeRegistry BlsPubkeyRegistry *blspubkeyregistry.ContractBLSPubkeyRegistry + BlsPubkeyCompendium *blspubkeycompendium.ContractBLSPublicKeyCompendium + BlsOperatorStateRetriever *blsoperatorstateretriever.ContractBLSOperatorStateRetriever } -func newAVSRegistryContractBindings( +func NewAVSRegistryContractBindings( blsRegistryCoordinatorAddr gethcommon.Address, blsOperatorStateRetrieverAddr gethcommon.Address, - stakeregistryAddr gethcommon.Address, - BlsPubkeyRegistryAddr gethcommon.Address, ethclient eth.EthClient, logger logging.Logger, -) (*avsRegistryContractBindings, error) { +) (*AvsRegistryContractBindings, error) { contractBlsRegistryCoordinator, err := blsregistrycoordinator.NewContractBLSRegistryCoordinatorWithIndices( blsRegistryCoordinatorAddr, ethclient, @@ -99,15 +118,11 @@ func newAVSRegistryContractBindings( return nil, err } - contractBlsOperatorStateRetriever, err := blsoperatorstateretrievar.NewContractBLSOperatorStateRetriever( - blsOperatorStateRetrieverAddr, - ethclient, - ) + stakeregistryAddr, err := contractBlsRegistryCoordinator.StakeRegistry(&bind.CallOpts{}) if err != nil { - logger.Error("Failed to fetch OperatorStateRetriever contract", "err", err) + logger.Error("Failed to fetch StakeRegistry address", "err", err) return nil, err } - contractStakeRegistry, err := stakeregistry.NewContractStakeRegistry( stakeregistryAddr, ethclient, @@ -117,8 +132,13 @@ func newAVSRegistryContractBindings( return nil, err } + blsPubkeyRegistryAddr, err := contractBlsRegistryCoordinator.BlsPubkeyRegistry(&bind.CallOpts{}) + if err != nil { + logger.Error("Failed to fetch BLSPubkeyRegistry address", "err", err) + return nil, err + } contractBlsPubkeyRegistry, err := blspubkeyregistry.NewContractBLSPubkeyRegistry( - BlsPubkeyRegistryAddr, + blsPubkeyRegistryAddr, ethclient, ) if err != nil { @@ -126,10 +146,39 @@ func newAVSRegistryContractBindings( return nil, err } - return &avsRegistryContractBindings{ + blsPubkeyCompendiumAddr, err := contractBlsPubkeyRegistry.PubkeyCompendium(&bind.CallOpts{}) + if err != nil { + logger.Error("Failed to fetch BLSPublicKeyCompendium address", "err", err) + return nil, err + } + contractBlsPubkeyCompendium, err := blspubkeycompendium.NewContractBLSPublicKeyCompendium( + blsPubkeyCompendiumAddr, + ethclient, + ) + if err != nil { + logger.Error("Failed to fetch BLSPublicKeyCompendium contract", "err", err) + return nil, err + } + + contractBlsOperatorStateRetriever, err := blsoperatorstateretriever.NewContractBLSOperatorStateRetriever( + blsOperatorStateRetrieverAddr, + ethclient, + ) + if err != nil { + logger.Error("Failed to fetch OperatorStateRetriever contract", "err", err) + return nil, err + } + + return &AvsRegistryContractBindings{ + RegistryCoordinatorAddr: blsRegistryCoordinatorAddr, + StakeRegistryAddr: stakeregistryAddr, + BlsPubkeyRegistryAddr: blsPubkeyRegistryAddr, + BlsPubkeyCompendiumAddr: blsPubkeyCompendiumAddr, + OperatorStateRetriever: blsOperatorStateRetrieverAddr, RegistryCoordinator: contractBlsRegistryCoordinator, - BlsOperatorStateRetriever: contractBlsOperatorStateRetriever, StakeRegistry: contractStakeRegistry, BlsPubkeyRegistry: contractBlsPubkeyRegistry, + BlsPubkeyCompendium: contractBlsPubkeyCompendium, + BlsOperatorStateRetriever: contractBlsOperatorStateRetriever, }, nil } diff --git a/contracts/abigen-with-interfaces.Dockerfile b/contracts/abigen-with-interfaces.Dockerfile new file mode 100644 index 00000000..3f20c401 --- /dev/null +++ b/contracts/abigen-with-interfaces.Dockerfile @@ -0,0 +1,17 @@ +# use the below command to build this docker image locally +# docker build -t abigen-with-interfaces -f abigen-with-interfaces.Dockerfile . +FROM golang:1.21 as build + +# this installs our fork of abigen with also creates interfaces for the binding structs +# See https://github.com/ethereum/go-ethereum/pull/28279 +RUN apt update && \ + apt install git -y && \ + git clone https://github.com/samlaf/go-ethereum.git && \ + cd go-ethereum/cmd/abigen && \ + git checkout issue-28278/abigen-interfaces && \ + go build . + + +FROM debian:latest +COPY --from=build /go/go-ethereum/cmd/abigen/abigen /usr/local/bin/abigen +ENTRYPOINT [ "abigen"] \ No newline at end of file diff --git a/contracts/bindings/BLSOperatorStateRetriever/binding.go b/contracts/bindings/BLSOperatorStateRetriever/binding.go index 11e98933..0eb5ac3f 100644 --- a/contracts/bindings/BLSOperatorStateRetriever/binding.go +++ b/contracts/bindings/BLSOperatorStateRetriever/binding.go @@ -74,6 +74,30 @@ func DeployContractBLSOperatorStateRetriever(auth *bind.TransactOpts, backend bi return address, tx, &ContractBLSOperatorStateRetriever{ContractBLSOperatorStateRetrieverCaller: ContractBLSOperatorStateRetrieverCaller{contract: contract}, ContractBLSOperatorStateRetrieverTransactor: ContractBLSOperatorStateRetrieverTransactor{contract: contract}, ContractBLSOperatorStateRetrieverFilterer: ContractBLSOperatorStateRetrieverFilterer{contract: contract}}, nil } +// ContractBLSOperatorStateRetrieverMethods is an auto generated interface around an Ethereum contract. +type ContractBLSOperatorStateRetrieverMethods interface { + ContractBLSOperatorStateRetrieverCalls + ContractBLSOperatorStateRetrieverTransacts + ContractBLSOperatorStateRetrieverFilters +} + +// ContractBLSOperatorStateRetrieverCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractBLSOperatorStateRetrieverCalls interface { + GetCheckSignaturesIndices(opts *bind.CallOpts, registryCoordinator common.Address, referenceBlockNumber uint32, quorumNumbers []byte, nonSignerOperatorIds [][32]byte) (BLSOperatorStateRetrieverCheckSignaturesIndices, error) + + GetOperatorState(opts *bind.CallOpts, registryCoordinator common.Address, quorumNumbers []byte, blockNumber uint32) ([][]BLSOperatorStateRetrieverOperator, error) + + GetOperatorState0(opts *bind.CallOpts, registryCoordinator common.Address, operatorId [32]byte, blockNumber uint32) (*big.Int, [][]BLSOperatorStateRetrieverOperator, error) +} + +// ContractBLSOperatorStateRetrieverTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractBLSOperatorStateRetrieverTransacts interface { +} + +// ContractBLSOperatorStateRetrieverFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractBLSOperatorStateRetrieverFilters interface { +} + // ContractBLSOperatorStateRetriever is an auto generated Go binding around an Ethereum contract. type ContractBLSOperatorStateRetriever struct { ContractBLSOperatorStateRetrieverCaller // Read-only binding to the contract @@ -81,21 +105,33 @@ type ContractBLSOperatorStateRetriever struct { ContractBLSOperatorStateRetrieverFilterer // Log filterer for contract events } +// ContractBLSOperatorStateRetriever implements the ContractBLSOperatorStateRetrieverMethods interface. +var _ ContractBLSOperatorStateRetrieverMethods = (*ContractBLSOperatorStateRetriever)(nil) + // ContractBLSOperatorStateRetrieverCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractBLSOperatorStateRetrieverCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSOperatorStateRetrieverCaller implements the ContractBLSOperatorStateRetrieverCalls interface. +var _ ContractBLSOperatorStateRetrieverCalls = (*ContractBLSOperatorStateRetrieverCaller)(nil) + // ContractBLSOperatorStateRetrieverTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractBLSOperatorStateRetrieverTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSOperatorStateRetrieverTransactor implements the ContractBLSOperatorStateRetrieverTransacts interface. +var _ ContractBLSOperatorStateRetrieverTransacts = (*ContractBLSOperatorStateRetrieverTransactor)(nil) + // ContractBLSOperatorStateRetrieverFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractBLSOperatorStateRetrieverFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSOperatorStateRetrieverFilterer implements the ContractBLSOperatorStateRetrieverFilters interface. +var _ ContractBLSOperatorStateRetrieverFilters = (*ContractBLSOperatorStateRetrieverFilterer)(nil) + // ContractBLSOperatorStateRetrieverSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractBLSOperatorStateRetrieverSession struct { diff --git a/contracts/bindings/BLSPubkeyRegistry/binding.go b/contracts/bindings/BLSPubkeyRegistry/binding.go index 192dbbc4..8cf4d895 100644 --- a/contracts/bindings/BLSPubkeyRegistry/binding.go +++ b/contracts/bindings/BLSPubkeyRegistry/binding.go @@ -73,6 +73,65 @@ func DeployContractBLSPubkeyRegistry(auth *bind.TransactOpts, backend bind.Contr return address, tx, &ContractBLSPubkeyRegistry{ContractBLSPubkeyRegistryCaller: ContractBLSPubkeyRegistryCaller{contract: contract}, ContractBLSPubkeyRegistryTransactor: ContractBLSPubkeyRegistryTransactor{contract: contract}, ContractBLSPubkeyRegistryFilterer: ContractBLSPubkeyRegistryFilterer{contract: contract}}, nil } +// ContractBLSPubkeyRegistryMethods is an auto generated interface around an Ethereum contract. +type ContractBLSPubkeyRegistryMethods interface { + ContractBLSPubkeyRegistryCalls + ContractBLSPubkeyRegistryTransacts + ContractBLSPubkeyRegistryFilters +} + +// ContractBLSPubkeyRegistryCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractBLSPubkeyRegistryCalls interface { + GetApkForQuorum(opts *bind.CallOpts, quorumNumber uint8) (BN254G1Point, error) + + GetApkHashForQuorumAtBlockNumberFromIndex(opts *bind.CallOpts, quorumNumber uint8, blockNumber uint32, index *big.Int) ([24]byte, error) + + GetApkIndicesForQuorumsAtBlockNumber(opts *bind.CallOpts, quorumNumbers []byte, blockNumber *big.Int) ([]uint32, error) + + GetApkUpdateForQuorumByIndex(opts *bind.CallOpts, quorumNumber uint8, index *big.Int) (IBLSPubkeyRegistryApkUpdate, error) + + GetOperatorFromPubkeyHash(opts *bind.CallOpts, pubkeyHash [32]byte) (common.Address, error) + + GetQuorumApkHistoryLength(opts *bind.CallOpts, quorumNumber uint8) (uint32, error) + + PubkeyCompendium(opts *bind.CallOpts) (common.Address, error) + + QuorumApk(opts *bind.CallOpts, arg0 uint8) (struct { + X *big.Int + Y *big.Int + }, error) + + QuorumApkUpdates(opts *bind.CallOpts, arg0 uint8, arg1 *big.Int) (struct { + ApkHash [24]byte + UpdateBlockNumber uint32 + NextUpdateBlockNumber uint32 + }, error) + + RegistryCoordinator(opts *bind.CallOpts) (common.Address, error) +} + +// ContractBLSPubkeyRegistryTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractBLSPubkeyRegistryTransacts interface { + DeregisterOperator(opts *bind.TransactOpts, operator common.Address, quorumNumbers []byte, pubkey BN254G1Point) (*types.Transaction, error) + + RegisterOperator(opts *bind.TransactOpts, operator common.Address, quorumNumbers []byte, pubkey BN254G1Point) (*types.Transaction, error) +} + +// ContractBLSPubkeyRegistryFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractBLSPubkeyRegistryFilters interface { + FilterInitialized(opts *bind.FilterOpts) (*ContractBLSPubkeyRegistryInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractBLSPubkeyRegistryInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractBLSPubkeyRegistryInitialized, error) + + FilterOperatorAddedToQuorums(opts *bind.FilterOpts) (*ContractBLSPubkeyRegistryOperatorAddedToQuorumsIterator, error) + WatchOperatorAddedToQuorums(opts *bind.WatchOpts, sink chan<- *ContractBLSPubkeyRegistryOperatorAddedToQuorums) (event.Subscription, error) + ParseOperatorAddedToQuorums(log types.Log) (*ContractBLSPubkeyRegistryOperatorAddedToQuorums, error) + + FilterOperatorRemovedFromQuorums(opts *bind.FilterOpts) (*ContractBLSPubkeyRegistryOperatorRemovedFromQuorumsIterator, error) + WatchOperatorRemovedFromQuorums(opts *bind.WatchOpts, sink chan<- *ContractBLSPubkeyRegistryOperatorRemovedFromQuorums) (event.Subscription, error) + ParseOperatorRemovedFromQuorums(log types.Log) (*ContractBLSPubkeyRegistryOperatorRemovedFromQuorums, error) +} + // ContractBLSPubkeyRegistry is an auto generated Go binding around an Ethereum contract. type ContractBLSPubkeyRegistry struct { ContractBLSPubkeyRegistryCaller // Read-only binding to the contract @@ -80,21 +139,33 @@ type ContractBLSPubkeyRegistry struct { ContractBLSPubkeyRegistryFilterer // Log filterer for contract events } +// ContractBLSPubkeyRegistry implements the ContractBLSPubkeyRegistryMethods interface. +var _ ContractBLSPubkeyRegistryMethods = (*ContractBLSPubkeyRegistry)(nil) + // ContractBLSPubkeyRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractBLSPubkeyRegistryCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSPubkeyRegistryCaller implements the ContractBLSPubkeyRegistryCalls interface. +var _ ContractBLSPubkeyRegistryCalls = (*ContractBLSPubkeyRegistryCaller)(nil) + // ContractBLSPubkeyRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractBLSPubkeyRegistryTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSPubkeyRegistryTransactor implements the ContractBLSPubkeyRegistryTransacts interface. +var _ ContractBLSPubkeyRegistryTransacts = (*ContractBLSPubkeyRegistryTransactor)(nil) + // ContractBLSPubkeyRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractBLSPubkeyRegistryFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSPubkeyRegistryFilterer implements the ContractBLSPubkeyRegistryFilters interface. +var _ ContractBLSPubkeyRegistryFilters = (*ContractBLSPubkeyRegistryFilterer)(nil) + // ContractBLSPubkeyRegistrySession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractBLSPubkeyRegistrySession struct { diff --git a/contracts/bindings/BLSPublicKeyCompendium/binding.go b/contracts/bindings/BLSPublicKeyCompendium/binding.go index 1bb5d2fd..fdd149f2 100644 --- a/contracts/bindings/BLSPublicKeyCompendium/binding.go +++ b/contracts/bindings/BLSPublicKeyCompendium/binding.go @@ -44,7 +44,7 @@ type BN254G2Point struct { // ContractBLSPublicKeyCompendiumMetaData contains all meta data concerning the ContractBLSPublicKeyCompendium contract. var ContractBLSPublicKeyCompendiumMetaData = &bind.MetaData{ ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"structBN254.G1Point\",\"name\":\"pubkeyG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"indexed\":false,\"internalType\":\"structBN254.G2Point\",\"name\":\"pubkeyG2\",\"type\":\"tuple\"}],\"name\":\"NewPubkeyRegistration\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"getMessageHash\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"operatorToPubkeyHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"pubkeyHashToOperator\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"signedMessageHash\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"pubkeyG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"internalType\":\"structBN254.G2Point\",\"name\":\"pubkeyG2\",\"type\":\"tuple\"}],\"name\":\"registerBLSPublicKey\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50610f81806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063161a334d146100515780631f5ac1b214610066578063de29fac01461008f578063e8bb9ae6146100bd575b600080fd5b61006461005f366004610d03565b6100fe565b005b610079610074366004610d7c565b61045b565b6040516100869190610dac565b60405180910390f35b6100af61009d366004610d7c565b60006020819052908152604090205481565b604051908152602001610086565b6100e66100cb366004610dc3565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610086565b6000610109836104f6565b33600090815260208190526040902054909150156101ac5760405162461bcd60e51b815260206004820152604f60248201527f424c535075626c69634b6579436f6d70656e6469756d2e72656769737465724260448201527f4c535075626c69634b65793a206f70657261746f7220616c726561647920726560648201526e6769737465726564207075626b657960881b608482015260a4015b60405180910390fd5b6000818152600160205260409020546001600160a01b03161561024a5760405162461bcd60e51b815260206004820152604a60248201527f424c535075626c69634b6579436f6d70656e6469756d2e72656769737465724260448201527f4c535075626c69634b65793a207075626c6963206b657920616c7265616479206064820152691c9959da5cdd195c995960b21b608482015260a4016101a3565b60006102553361045b565b8551602080880151875188830151885189850151875186890151604051999a506000997f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001996102ad9990989796959493929101610e05565b6040516020818303038152906040528051906020012060001c6102d09190610e51565b90506103376102e96102e28784610539565b88906105d0565b6102f1610664565b61033161032a85610324604080518082018252600080825260209182015281518083019092526001825260029082015290565b90610539565b86906105d0565b87610724565b6103ec5760405162461bcd60e51b815260206004820152607460248201527f424c535075626c69634b6579436f6d70656e6469756d2e72656769737465724260448201527f4c535075626c69634b65793a2065697468657220746865204731207369676e6160648201527f747572652069732077726f6e672c206f7220473120616e6420473220707269766084820152730c2e8ca40d6caf240c8de40dcdee840dac2e8c6d60631b60a482015260c4016101a3565b3360008181526020818152604080832087905586835260019091529081902080546001600160a01b03191683179055517fe3fb6613af2e8930cf85d47fcf6db10192224a64c6cbe8023e0eee1ba38280419061044b9088908890610e73565b60405180910390a2505050505050565b60408051808201909152600080825260208201526040516bffffffffffffffffffffffff19606084811b8216602084015230901b1660348201524660488201527f456967656e4c617965725f424e3235345f5075626b65795f52656769737472616068820152633a34b7b760e11b60888201526104f090608c0160405160208183030381529060405280519060200120610991565b92915050565b60008160000151826020015160405160200161051c929190918252602082015260400190565b604051602081830303815290604052805190602001209050919050565b6040805180820190915260008082526020820152610555610b4b565b835181526020808501519082015260408082018490526000908360608460076107d05a03fa90508080156105885761058a565bfe5b50806105c85760405162461bcd60e51b815260206004820152600d60248201526c1958cb5b5d5b0b59985a5b1959609a1b60448201526064016101a3565b505092915050565b60408051808201909152600080825260208201526105ec610b69565b835181526020808501518183015283516040808401919091529084015160608301526000908360808460066107d05a03fa90508080156105885750806105c85760405162461bcd60e51b815260206004820152600d60248201526c1958cb5859190b59985a5b1959609a1b60448201526064016101a3565b61066c610b87565b50604080516080810182527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c28183019081527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed6060830152815281518083019092527f275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec82527f1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d60208381019190915281019190915290565b604080518082018252858152602080820185905282518084019093528583528201839052600091610753610bac565b60005b600281101561091857600061076c826006610ed9565b905084826002811061078057610780610ead565b60200201515183610792836000610ef8565b600c81106107a2576107a2610ead565b60200201528482600281106107b9576107b9610ead565b602002015160200151838260016107d09190610ef8565b600c81106107e0576107e0610ead565b60200201528382600281106107f7576107f7610ead565b602002015151518361080a836002610ef8565b600c811061081a5761081a610ead565b602002015283826002811061083157610831610ead565b602002015151600160200201518361084a836003610ef8565b600c811061085a5761085a610ead565b602002015283826002811061087157610871610ead565b60200201516020015160006002811061088c5761088c610ead565b60200201518361089d836004610ef8565b600c81106108ad576108ad610ead565b60200201528382600281106108c4576108c4610ead565b6020020151602001516001600281106108df576108df610ead565b6020020151836108f0836005610ef8565b600c811061090057610900610ead565b6020020152508061091081610f10565b915050610756565b50610921610bcb565b60006020826101808560086107d05a03fa90508080156105885750806109815760405162461bcd60e51b81526020600482015260156024820152741c185a5c9a5b99cb5bdc18dbd9194b59985a5b1959605a1b60448201526064016101a3565b5051151598975050505050505050565b6040805180820190915260008082526020820152600080806109c1600080516020610f2c83398151915286610e51565b90505b6109cd81610a21565b9093509150600080516020610f2c833981519152828309831415610a07576040805180820190915290815260208101919091529392505050565b600080516020610f2c8339815191526001820890506109c4565b60008080600080516020610f2c8339815191526003600080516020610f2c83398151915286600080516020610f2c833981519152888909090890506000610a97827f0c19139cb84c680a6e14116da060561765e05aa45a1c72a34f082305b61f3f52600080516020610f2c833981519152610aa3565b91959194509092505050565b600080610aae610bcb565b610ab6610be9565b602080825281810181905260408201819052606082018890526080820187905260a082018690528260c08360056107d05a03fa9250828015610588575082610b405760405162461bcd60e51b815260206004820152601a60248201527f424e3235342e6578704d6f643a2063616c6c206661696c75726500000000000060448201526064016101a3565b505195945050505050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b6040518060400160405280610b9a610c07565b8152602001610ba7610c07565b905290565b604051806101800160405280600c906020820280368337509192915050565b60405180602001604052806001906020820280368337509192915050565b6040518060c001604052806006906020820280368337509192915050565b60405180604001604052806002906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610c5e57610c5e610c25565b60405290565b600060408284031215610c7657600080fd5b6040516040810181811067ffffffffffffffff82111715610c9957610c99610c25565b604052823581526020928301359281019290925250919050565b600082601f830112610cc457600080fd5b610ccc610c3b565b806040840185811115610cde57600080fd5b845b81811015610cf8578035845260209384019301610ce0565b509095945050505050565b6000806000838503610100811215610d1a57600080fd5b610d248686610c64565b9350610d338660408701610c64565b92506080607f1982011215610d4757600080fd5b50610d50610c3b565b610d5d8660808701610cb3565b8152610d6c8660c08701610cb3565b6020820152809150509250925092565b600060208284031215610d8e57600080fd5b81356001600160a01b0381168114610da557600080fd5b9392505050565b8151815260208083015190820152604081016104f0565b600060208284031215610dd557600080fd5b5035919050565b8060005b6002811015610dff578151845260209384019390910190600101610de0565b50505050565b888152876020820152866040820152856060820152610e276080820186610ddc565b610e3460c0820185610ddc565b610100810192909252610120820152610140019695505050505050565b600082610e6e57634e487b7160e01b600052601260045260246000fd5b500690565b825181526020808401519082015260c08101610e93604083018451610ddc565b6020830151610ea56080840182610ddc565b509392505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615610ef357610ef3610ec3565b500290565b60008219821115610f0b57610f0b610ec3565b500190565b6000600019821415610f2457610f24610ec3565b506001019056fe30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47a264697066735822122077f5f60f7e746ac608a05d181a66caa39b1f066f7c956b6b32cd1e6d1e185abb64736f6c634300080c0033", + Bin: "0x6", } // ContractBLSPublicKeyCompendiumABI is the input ABI used to generate the binding from. @@ -72,6 +72,34 @@ func DeployContractBLSPublicKeyCompendium(auth *bind.TransactOpts, backend bind. return address, tx, &ContractBLSPublicKeyCompendium{ContractBLSPublicKeyCompendiumCaller: ContractBLSPublicKeyCompendiumCaller{contract: contract}, ContractBLSPublicKeyCompendiumTransactor: ContractBLSPublicKeyCompendiumTransactor{contract: contract}, ContractBLSPublicKeyCompendiumFilterer: ContractBLSPublicKeyCompendiumFilterer{contract: contract}}, nil } +// ContractBLSPublicKeyCompendiumMethods is an auto generated interface around an Ethereum contract. +type ContractBLSPublicKeyCompendiumMethods interface { + ContractBLSPublicKeyCompendiumCalls + ContractBLSPublicKeyCompendiumTransacts + ContractBLSPublicKeyCompendiumFilters +} + +// ContractBLSPublicKeyCompendiumCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractBLSPublicKeyCompendiumCalls interface { + GetMessageHash(opts *bind.CallOpts, operator common.Address) (BN254G1Point, error) + + OperatorToPubkeyHash(opts *bind.CallOpts, arg0 common.Address) ([32]byte, error) + + PubkeyHashToOperator(opts *bind.CallOpts, arg0 [32]byte) (common.Address, error) +} + +// ContractBLSPublicKeyCompendiumTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractBLSPublicKeyCompendiumTransacts interface { + RegisterBLSPublicKey(opts *bind.TransactOpts, signedMessageHash BN254G1Point, pubkeyG1 BN254G1Point, pubkeyG2 BN254G2Point) (*types.Transaction, error) +} + +// ContractBLSPublicKeyCompendiumFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractBLSPublicKeyCompendiumFilters interface { + FilterNewPubkeyRegistration(opts *bind.FilterOpts, operator []common.Address) (*ContractBLSPublicKeyCompendiumNewPubkeyRegistrationIterator, error) + WatchNewPubkeyRegistration(opts *bind.WatchOpts, sink chan<- *ContractBLSPublicKeyCompendiumNewPubkeyRegistration, operator []common.Address) (event.Subscription, error) + ParseNewPubkeyRegistration(log types.Log) (*ContractBLSPublicKeyCompendiumNewPubkeyRegistration, error) +} + // ContractBLSPublicKeyCompendium is an auto generated Go binding around an Ethereum contract. type ContractBLSPublicKeyCompendium struct { ContractBLSPublicKeyCompendiumCaller // Read-only binding to the contract @@ -79,21 +107,33 @@ type ContractBLSPublicKeyCompendium struct { ContractBLSPublicKeyCompendiumFilterer // Log filterer for contract events } +// ContractBLSPublicKeyCompendium implements the ContractBLSPublicKeyCompendiumMethods interface. +var _ ContractBLSPublicKeyCompendiumMethods = (*ContractBLSPublicKeyCompendium)(nil) + // ContractBLSPublicKeyCompendiumCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractBLSPublicKeyCompendiumCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSPublicKeyCompendiumCaller implements the ContractBLSPublicKeyCompendiumCalls interface. +var _ ContractBLSPublicKeyCompendiumCalls = (*ContractBLSPublicKeyCompendiumCaller)(nil) + // ContractBLSPublicKeyCompendiumTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractBLSPublicKeyCompendiumTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSPublicKeyCompendiumTransactor implements the ContractBLSPublicKeyCompendiumTransacts interface. +var _ ContractBLSPublicKeyCompendiumTransacts = (*ContractBLSPublicKeyCompendiumTransactor)(nil) + // ContractBLSPublicKeyCompendiumFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractBLSPublicKeyCompendiumFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSPublicKeyCompendiumFilterer implements the ContractBLSPublicKeyCompendiumFilters interface. +var _ ContractBLSPublicKeyCompendiumFilters = (*ContractBLSPublicKeyCompendiumFilterer)(nil) + // ContractBLSPublicKeyCompendiumSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractBLSPublicKeyCompendiumSession struct { diff --git a/contracts/bindings/BLSRegistryCoordinatorWithIndices/binding.go b/contracts/bindings/BLSRegistryCoordinatorWithIndices/binding.go index a86730a7..2bf0aa83 100644 --- a/contracts/bindings/BLSRegistryCoordinatorWithIndices/binding.go +++ b/contracts/bindings/BLSRegistryCoordinatorWithIndices/binding.go @@ -100,6 +100,142 @@ func DeployContractBLSRegistryCoordinatorWithIndices(auth *bind.TransactOpts, ba return address, tx, &ContractBLSRegistryCoordinatorWithIndices{ContractBLSRegistryCoordinatorWithIndicesCaller: ContractBLSRegistryCoordinatorWithIndicesCaller{contract: contract}, ContractBLSRegistryCoordinatorWithIndicesTransactor: ContractBLSRegistryCoordinatorWithIndicesTransactor{contract: contract}, ContractBLSRegistryCoordinatorWithIndicesFilterer: ContractBLSRegistryCoordinatorWithIndicesFilterer{contract: contract}}, nil } +// ContractBLSRegistryCoordinatorWithIndicesMethods is an auto generated interface around an Ethereum contract. +type ContractBLSRegistryCoordinatorWithIndicesMethods interface { + ContractBLSRegistryCoordinatorWithIndicesCalls + ContractBLSRegistryCoordinatorWithIndicesTransacts + ContractBLSRegistryCoordinatorWithIndicesFilters +} + +// ContractBLSRegistryCoordinatorWithIndicesCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractBLSRegistryCoordinatorWithIndicesCalls interface { + OPERATORCHURNAPPROVALTYPEHASH(opts *bind.CallOpts) ([32]byte, error) + + BlsPubkeyRegistry(opts *bind.CallOpts) (common.Address, error) + + CalculateOperatorChurnApprovalDigestHash(opts *bind.CallOpts, registeringOperatorId [32]byte, operatorKickParams []IBLSRegistryCoordinatorWithIndicesOperatorKickParam, salt [32]byte, expiry *big.Int) ([32]byte, error) + + ChurnApprover(opts *bind.CallOpts) (common.Address, error) + + Ejector(opts *bind.CallOpts) (common.Address, error) + + GetCurrentQuorumBitmapByOperatorId(opts *bind.CallOpts, operatorId [32]byte) (*big.Int, error) + + GetOperator(opts *bind.CallOpts, operator common.Address) (IRegistryCoordinatorOperator, error) + + GetOperatorFromId(opts *bind.CallOpts, operatorId [32]byte) (common.Address, error) + + GetOperatorId(opts *bind.CallOpts, operator common.Address) ([32]byte, error) + + GetOperatorSetParams(opts *bind.CallOpts, quorumNumber uint8) (IBLSRegistryCoordinatorWithIndicesOperatorSetParam, error) + + GetOperatorStatus(opts *bind.CallOpts, operator common.Address) (uint8, error) + + GetQuorumBitmapByOperatorIdAtBlockNumberByIndex(opts *bind.CallOpts, operatorId [32]byte, blockNumber uint32, index *big.Int) (*big.Int, error) + + GetQuorumBitmapIndicesByOperatorIdsAtBlockNumber(opts *bind.CallOpts, blockNumber uint32, operatorIds [][32]byte) ([]uint32, error) + + GetQuorumBitmapUpdateByOperatorIdByIndex(opts *bind.CallOpts, operatorId [32]byte, index *big.Int) (IRegistryCoordinatorQuorumBitmapUpdate, error) + + GetQuorumBitmapUpdateByOperatorIdLength(opts *bind.CallOpts, operatorId [32]byte) (*big.Int, error) + + IndexRegistry(opts *bind.CallOpts) (common.Address, error) + + IsChurnApproverSaltUsed(opts *bind.CallOpts, arg0 [32]byte) (bool, error) + + NumRegistries(opts *bind.CallOpts) (*big.Int, error) + + Paused(opts *bind.CallOpts, index uint8) (bool, error) + + Paused0(opts *bind.CallOpts) (*big.Int, error) + + PauserRegistry(opts *bind.CallOpts) (common.Address, error) + + Registries(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) + + ServiceManager(opts *bind.CallOpts) (common.Address, error) + + Slasher(opts *bind.CallOpts) (common.Address, error) + + StakeRegistry(opts *bind.CallOpts) (common.Address, error) +} + +// ContractBLSRegistryCoordinatorWithIndicesTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractBLSRegistryCoordinatorWithIndicesTransacts interface { + DeregisterOperatorWithCoordinator(opts *bind.TransactOpts, quorumNumbers []byte, pubkey BN254G1Point) (*types.Transaction, error) + + DeregisterOperatorWithCoordinator0(opts *bind.TransactOpts, quorumNumbers []byte, deregistrationData []byte) (*types.Transaction, error) + + EjectOperatorFromCoordinator(opts *bind.TransactOpts, operator common.Address, quorumNumbers []byte, pubkey BN254G1Point) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, _churnApprover common.Address, _ejector common.Address, _operatorSetParams []IBLSRegistryCoordinatorWithIndicesOperatorSetParam, _pauserRegistry common.Address, _initialPausedStatus *big.Int) (*types.Transaction, error) + + Pause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + PauseAll(opts *bind.TransactOpts) (*types.Transaction, error) + + RegisterOperatorWithCoordinator(opts *bind.TransactOpts, quorumNumbers []byte, pubkey BN254G1Point, socket string, operatorKickParams []IBLSRegistryCoordinatorWithIndicesOperatorKickParam, signatureWithSaltAndExpiry ISignatureUtilsSignatureWithSaltAndExpiry) (*types.Transaction, error) + + RegisterOperatorWithCoordinator0(opts *bind.TransactOpts, quorumNumbers []byte, registrationData []byte) (*types.Transaction, error) + + RegisterOperatorWithCoordinator1(opts *bind.TransactOpts, quorumNumbers []byte, pubkey BN254G1Point, socket string) (*types.Transaction, error) + + SetChurnApprover(opts *bind.TransactOpts, _churnApprover common.Address) (*types.Transaction, error) + + SetEjector(opts *bind.TransactOpts, _ejector common.Address) (*types.Transaction, error) + + SetOperatorSetParams(opts *bind.TransactOpts, quorumNumber uint8, operatorSetParam IBLSRegistryCoordinatorWithIndicesOperatorSetParam) (*types.Transaction, error) + + SetPauserRegistry(opts *bind.TransactOpts, newPauserRegistry common.Address) (*types.Transaction, error) + + Unpause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + UpdateSocket(opts *bind.TransactOpts, socket string) (*types.Transaction, error) +} + +// ContractBLSRegistryCoordinatorWithIndicesFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractBLSRegistryCoordinatorWithIndicesFilters interface { + FilterChurnApproverUpdated(opts *bind.FilterOpts) (*ContractBLSRegistryCoordinatorWithIndicesChurnApproverUpdatedIterator, error) + WatchChurnApproverUpdated(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesChurnApproverUpdated) (event.Subscription, error) + ParseChurnApproverUpdated(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesChurnApproverUpdated, error) + + FilterEjectorUpdated(opts *bind.FilterOpts) (*ContractBLSRegistryCoordinatorWithIndicesEjectorUpdatedIterator, error) + WatchEjectorUpdated(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesEjectorUpdated) (event.Subscription, error) + ParseEjectorUpdated(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesEjectorUpdated, error) + + FilterInitialized(opts *bind.FilterOpts) (*ContractBLSRegistryCoordinatorWithIndicesInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesInitialized, error) + + FilterOperatorDeregistered(opts *bind.FilterOpts, operator []common.Address, operatorId [][32]byte) (*ContractBLSRegistryCoordinatorWithIndicesOperatorDeregisteredIterator, error) + WatchOperatorDeregistered(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesOperatorDeregistered, operator []common.Address, operatorId [][32]byte) (event.Subscription, error) + ParseOperatorDeregistered(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesOperatorDeregistered, error) + + FilterOperatorRegistered(opts *bind.FilterOpts, operator []common.Address, operatorId [][32]byte) (*ContractBLSRegistryCoordinatorWithIndicesOperatorRegisteredIterator, error) + WatchOperatorRegistered(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesOperatorRegistered, operator []common.Address, operatorId [][32]byte) (event.Subscription, error) + ParseOperatorRegistered(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesOperatorRegistered, error) + + FilterOperatorSetParamsUpdated(opts *bind.FilterOpts, quorumNumber []uint8) (*ContractBLSRegistryCoordinatorWithIndicesOperatorSetParamsUpdatedIterator, error) + WatchOperatorSetParamsUpdated(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesOperatorSetParamsUpdated, quorumNumber []uint8) (event.Subscription, error) + ParseOperatorSetParamsUpdated(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesOperatorSetParamsUpdated, error) + + FilterOperatorSocketUpdate(opts *bind.FilterOpts, operatorId [][32]byte) (*ContractBLSRegistryCoordinatorWithIndicesOperatorSocketUpdateIterator, error) + WatchOperatorSocketUpdate(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesOperatorSocketUpdate, operatorId [][32]byte) (event.Subscription, error) + ParseOperatorSocketUpdate(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesOperatorSocketUpdate, error) + + FilterPaused(opts *bind.FilterOpts, account []common.Address) (*ContractBLSRegistryCoordinatorWithIndicesPausedIterator, error) + WatchPaused(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesPaused, account []common.Address) (event.Subscription, error) + ParsePaused(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesPaused, error) + + FilterPauserRegistrySet(opts *bind.FilterOpts) (*ContractBLSRegistryCoordinatorWithIndicesPauserRegistrySetIterator, error) + WatchPauserRegistrySet(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesPauserRegistrySet) (event.Subscription, error) + ParsePauserRegistrySet(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesPauserRegistrySet, error) + + FilterUnpaused(opts *bind.FilterOpts, account []common.Address) (*ContractBLSRegistryCoordinatorWithIndicesUnpausedIterator, error) + WatchUnpaused(opts *bind.WatchOpts, sink chan<- *ContractBLSRegistryCoordinatorWithIndicesUnpaused, account []common.Address) (event.Subscription, error) + ParseUnpaused(log types.Log) (*ContractBLSRegistryCoordinatorWithIndicesUnpaused, error) +} + // ContractBLSRegistryCoordinatorWithIndices is an auto generated Go binding around an Ethereum contract. type ContractBLSRegistryCoordinatorWithIndices struct { ContractBLSRegistryCoordinatorWithIndicesCaller // Read-only binding to the contract @@ -107,21 +243,33 @@ type ContractBLSRegistryCoordinatorWithIndices struct { ContractBLSRegistryCoordinatorWithIndicesFilterer // Log filterer for contract events } +// ContractBLSRegistryCoordinatorWithIndices implements the ContractBLSRegistryCoordinatorWithIndicesMethods interface. +var _ ContractBLSRegistryCoordinatorWithIndicesMethods = (*ContractBLSRegistryCoordinatorWithIndices)(nil) + // ContractBLSRegistryCoordinatorWithIndicesCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractBLSRegistryCoordinatorWithIndicesCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSRegistryCoordinatorWithIndicesCaller implements the ContractBLSRegistryCoordinatorWithIndicesCalls interface. +var _ ContractBLSRegistryCoordinatorWithIndicesCalls = (*ContractBLSRegistryCoordinatorWithIndicesCaller)(nil) + // ContractBLSRegistryCoordinatorWithIndicesTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractBLSRegistryCoordinatorWithIndicesTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSRegistryCoordinatorWithIndicesTransactor implements the ContractBLSRegistryCoordinatorWithIndicesTransacts interface. +var _ ContractBLSRegistryCoordinatorWithIndicesTransacts = (*ContractBLSRegistryCoordinatorWithIndicesTransactor)(nil) + // ContractBLSRegistryCoordinatorWithIndicesFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractBLSRegistryCoordinatorWithIndicesFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractBLSRegistryCoordinatorWithIndicesFilterer implements the ContractBLSRegistryCoordinatorWithIndicesFilters interface. +var _ ContractBLSRegistryCoordinatorWithIndicesFilters = (*ContractBLSRegistryCoordinatorWithIndicesFilterer)(nil) + // ContractBLSRegistryCoordinatorWithIndicesSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractBLSRegistryCoordinatorWithIndicesSession struct { diff --git a/contracts/bindings/DelegationManager/binding.go b/contracts/bindings/DelegationManager/binding.go index 095a99e2..dc318957 100644 --- a/contracts/bindings/DelegationManager/binding.go +++ b/contracts/bindings/DelegationManager/binding.go @@ -107,6 +107,202 @@ func DeployContractDelegationManager(auth *bind.TransactOpts, backend bind.Contr return address, tx, &ContractDelegationManager{ContractDelegationManagerCaller: ContractDelegationManagerCaller{contract: contract}, ContractDelegationManagerTransactor: ContractDelegationManagerTransactor{contract: contract}, ContractDelegationManagerFilterer: ContractDelegationManagerFilterer{contract: contract}}, nil } +// ContractDelegationManagerMethods is an auto generated interface around an Ethereum contract. +type ContractDelegationManagerMethods interface { + ContractDelegationManagerCalls + ContractDelegationManagerTransacts + ContractDelegationManagerFilters +} + +// ContractDelegationManagerCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractDelegationManagerCalls interface { + DELEGATIONAPPROVALTYPEHASH(opts *bind.CallOpts) ([32]byte, error) + + DOMAINTYPEHASH(opts *bind.CallOpts) ([32]byte, error) + + MAXSTAKEROPTOUTWINDOWBLOCKS(opts *bind.CallOpts) (*big.Int, error) + + MAXWITHDRAWALDELAYBLOCKS(opts *bind.CallOpts) (*big.Int, error) + + STAKERDELEGATIONTYPEHASH(opts *bind.CallOpts) ([32]byte, error) + + BeaconChainETHStrategy(opts *bind.CallOpts) (common.Address, error) + + CalculateCurrentStakerDelegationDigestHash(opts *bind.CallOpts, staker common.Address, operator common.Address, expiry *big.Int) ([32]byte, error) + + CalculateDelegationApprovalDigestHash(opts *bind.CallOpts, staker common.Address, operator common.Address, _delegationApprover common.Address, approverSalt [32]byte, expiry *big.Int) ([32]byte, error) + + CalculateStakerDelegationDigestHash(opts *bind.CallOpts, staker common.Address, _stakerNonce *big.Int, operator common.Address, expiry *big.Int) ([32]byte, error) + + CalculateWithdrawalRoot(opts *bind.CallOpts, withdrawal IDelegationManagerWithdrawal) ([32]byte, error) + + CumulativeWithdrawalsQueued(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) + + DelegatedTo(opts *bind.CallOpts, arg0 common.Address) (common.Address, error) + + DelegationApprover(opts *bind.CallOpts, operator common.Address) (common.Address, error) + + DelegationApproverSaltIsSpent(opts *bind.CallOpts, arg0 common.Address, arg1 [32]byte) (bool, error) + + DomainSeparator(opts *bind.CallOpts) ([32]byte, error) + + EarningsReceiver(opts *bind.CallOpts, operator common.Address) (common.Address, error) + + EigenPodManager(opts *bind.CallOpts) (common.Address, error) + + GetDelegatableShares(opts *bind.CallOpts, staker common.Address) ([]common.Address, []*big.Int, error) + + IsDelegated(opts *bind.CallOpts, staker common.Address) (bool, error) + + IsOperator(opts *bind.CallOpts, operator common.Address) (bool, error) + + OperatorDetails(opts *bind.CallOpts, operator common.Address) (IDelegationManagerOperatorDetails, error) + + OperatorShares(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) + + Owner(opts *bind.CallOpts) (common.Address, error) + + Paused(opts *bind.CallOpts, index uint8) (bool, error) + + Paused0(opts *bind.CallOpts) (*big.Int, error) + + PauserRegistry(opts *bind.CallOpts) (common.Address, error) + + PendingWithdrawals(opts *bind.CallOpts, arg0 [32]byte) (bool, error) + + Slasher(opts *bind.CallOpts) (common.Address, error) + + StakeRegistry(opts *bind.CallOpts) (common.Address, error) + + StakerNonce(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) + + StakerOptOutWindowBlocks(opts *bind.CallOpts, operator common.Address) (*big.Int, error) + + StrategyManager(opts *bind.CallOpts) (common.Address, error) + + WithdrawalDelayBlocks(opts *bind.CallOpts) (*big.Int, error) +} + +// ContractDelegationManagerTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractDelegationManagerTransacts interface { + CompleteQueuedWithdrawal(opts *bind.TransactOpts, withdrawal IDelegationManagerWithdrawal, tokens []common.Address, middlewareTimesIndex *big.Int, receiveAsTokens bool) (*types.Transaction, error) + + CompleteQueuedWithdrawals(opts *bind.TransactOpts, withdrawals []IDelegationManagerWithdrawal, tokens [][]common.Address, middlewareTimesIndexes []*big.Int, receiveAsTokens []bool) (*types.Transaction, error) + + DecreaseDelegatedShares(opts *bind.TransactOpts, staker common.Address, strategy common.Address, shares *big.Int) (*types.Transaction, error) + + DelegateTo(opts *bind.TransactOpts, operator common.Address, approverSignatureAndExpiry ISignatureUtilsSignatureWithExpiry, approverSalt [32]byte) (*types.Transaction, error) + + DelegateToBySignature(opts *bind.TransactOpts, staker common.Address, operator common.Address, stakerSignatureAndExpiry ISignatureUtilsSignatureWithExpiry, approverSignatureAndExpiry ISignatureUtilsSignatureWithExpiry, approverSalt [32]byte) (*types.Transaction, error) + + IncreaseDelegatedShares(opts *bind.TransactOpts, staker common.Address, strategy common.Address, shares *big.Int) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, initialOwner common.Address, _pauserRegistry common.Address, initialPausedStatus *big.Int) (*types.Transaction, error) + + MigrateQueuedWithdrawals(opts *bind.TransactOpts, withdrawalsToMigrate []IStrategyManagerDeprecatedStructQueuedWithdrawal) (*types.Transaction, error) + + ModifyOperatorDetails(opts *bind.TransactOpts, newOperatorDetails IDelegationManagerOperatorDetails) (*types.Transaction, error) + + Pause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + PauseAll(opts *bind.TransactOpts) (*types.Transaction, error) + + QueueWithdrawals(opts *bind.TransactOpts, queuedWithdrawalParams []IDelegationManagerQueuedWithdrawalParams) (*types.Transaction, error) + + RegisterAsOperator(opts *bind.TransactOpts, registeringOperatorDetails IDelegationManagerOperatorDetails, metadataURI string) (*types.Transaction, error) + + RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) + + SetPauserRegistry(opts *bind.TransactOpts, newPauserRegistry common.Address) (*types.Transaction, error) + + SetStakeRegistry(opts *bind.TransactOpts, _stakeRegistry common.Address) (*types.Transaction, error) + + SetWithdrawalDelayBlocks(opts *bind.TransactOpts, newWithdrawalDelayBlocks *big.Int) (*types.Transaction, error) + + TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) + + Undelegate(opts *bind.TransactOpts, staker common.Address) (*types.Transaction, error) + + Unpause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + UpdateOperatorMetadataURI(opts *bind.TransactOpts, metadataURI string) (*types.Transaction, error) +} + +// ContractDelegationManagerFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractDelegationManagerFilters interface { + FilterInitialized(opts *bind.FilterOpts) (*ContractDelegationManagerInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractDelegationManagerInitialized, error) + + FilterOperatorDetailsModified(opts *bind.FilterOpts, operator []common.Address) (*ContractDelegationManagerOperatorDetailsModifiedIterator, error) + WatchOperatorDetailsModified(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerOperatorDetailsModified, operator []common.Address) (event.Subscription, error) + ParseOperatorDetailsModified(log types.Log) (*ContractDelegationManagerOperatorDetailsModified, error) + + FilterOperatorMetadataURIUpdated(opts *bind.FilterOpts, operator []common.Address) (*ContractDelegationManagerOperatorMetadataURIUpdatedIterator, error) + WatchOperatorMetadataURIUpdated(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerOperatorMetadataURIUpdated, operator []common.Address) (event.Subscription, error) + ParseOperatorMetadataURIUpdated(log types.Log) (*ContractDelegationManagerOperatorMetadataURIUpdated, error) + + FilterOperatorRegistered(opts *bind.FilterOpts, operator []common.Address) (*ContractDelegationManagerOperatorRegisteredIterator, error) + WatchOperatorRegistered(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerOperatorRegistered, operator []common.Address) (event.Subscription, error) + ParseOperatorRegistered(log types.Log) (*ContractDelegationManagerOperatorRegistered, error) + + FilterOperatorSharesDecreased(opts *bind.FilterOpts, operator []common.Address) (*ContractDelegationManagerOperatorSharesDecreasedIterator, error) + WatchOperatorSharesDecreased(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerOperatorSharesDecreased, operator []common.Address) (event.Subscription, error) + ParseOperatorSharesDecreased(log types.Log) (*ContractDelegationManagerOperatorSharesDecreased, error) + + FilterOperatorSharesIncreased(opts *bind.FilterOpts, operator []common.Address) (*ContractDelegationManagerOperatorSharesIncreasedIterator, error) + WatchOperatorSharesIncreased(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerOperatorSharesIncreased, operator []common.Address) (event.Subscription, error) + ParseOperatorSharesIncreased(log types.Log) (*ContractDelegationManagerOperatorSharesIncreased, error) + + FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ContractDelegationManagerOwnershipTransferredIterator, error) + WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) + ParseOwnershipTransferred(log types.Log) (*ContractDelegationManagerOwnershipTransferred, error) + + FilterPaused(opts *bind.FilterOpts, account []common.Address) (*ContractDelegationManagerPausedIterator, error) + WatchPaused(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerPaused, account []common.Address) (event.Subscription, error) + ParsePaused(log types.Log) (*ContractDelegationManagerPaused, error) + + FilterPauserRegistrySet(opts *bind.FilterOpts) (*ContractDelegationManagerPauserRegistrySetIterator, error) + WatchPauserRegistrySet(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerPauserRegistrySet) (event.Subscription, error) + ParsePauserRegistrySet(log types.Log) (*ContractDelegationManagerPauserRegistrySet, error) + + FilterStakeRegistrySet(opts *bind.FilterOpts) (*ContractDelegationManagerStakeRegistrySetIterator, error) + WatchStakeRegistrySet(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerStakeRegistrySet) (event.Subscription, error) + ParseStakeRegistrySet(log types.Log) (*ContractDelegationManagerStakeRegistrySet, error) + + FilterStakerDelegated(opts *bind.FilterOpts, staker []common.Address, operator []common.Address) (*ContractDelegationManagerStakerDelegatedIterator, error) + WatchStakerDelegated(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerStakerDelegated, staker []common.Address, operator []common.Address) (event.Subscription, error) + ParseStakerDelegated(log types.Log) (*ContractDelegationManagerStakerDelegated, error) + + FilterStakerForceUndelegated(opts *bind.FilterOpts, staker []common.Address, operator []common.Address) (*ContractDelegationManagerStakerForceUndelegatedIterator, error) + WatchStakerForceUndelegated(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerStakerForceUndelegated, staker []common.Address, operator []common.Address) (event.Subscription, error) + ParseStakerForceUndelegated(log types.Log) (*ContractDelegationManagerStakerForceUndelegated, error) + + FilterStakerUndelegated(opts *bind.FilterOpts, staker []common.Address, operator []common.Address) (*ContractDelegationManagerStakerUndelegatedIterator, error) + WatchStakerUndelegated(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerStakerUndelegated, staker []common.Address, operator []common.Address) (event.Subscription, error) + ParseStakerUndelegated(log types.Log) (*ContractDelegationManagerStakerUndelegated, error) + + FilterUnpaused(opts *bind.FilterOpts, account []common.Address) (*ContractDelegationManagerUnpausedIterator, error) + WatchUnpaused(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerUnpaused, account []common.Address) (event.Subscription, error) + ParseUnpaused(log types.Log) (*ContractDelegationManagerUnpaused, error) + + FilterWithdrawalCompleted(opts *bind.FilterOpts) (*ContractDelegationManagerWithdrawalCompletedIterator, error) + WatchWithdrawalCompleted(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerWithdrawalCompleted) (event.Subscription, error) + ParseWithdrawalCompleted(log types.Log) (*ContractDelegationManagerWithdrawalCompleted, error) + + FilterWithdrawalDelayBlocksSet(opts *bind.FilterOpts) (*ContractDelegationManagerWithdrawalDelayBlocksSetIterator, error) + WatchWithdrawalDelayBlocksSet(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerWithdrawalDelayBlocksSet) (event.Subscription, error) + ParseWithdrawalDelayBlocksSet(log types.Log) (*ContractDelegationManagerWithdrawalDelayBlocksSet, error) + + FilterWithdrawalMigrated(opts *bind.FilterOpts) (*ContractDelegationManagerWithdrawalMigratedIterator, error) + WatchWithdrawalMigrated(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerWithdrawalMigrated) (event.Subscription, error) + ParseWithdrawalMigrated(log types.Log) (*ContractDelegationManagerWithdrawalMigrated, error) + + FilterWithdrawalQueued(opts *bind.FilterOpts) (*ContractDelegationManagerWithdrawalQueuedIterator, error) + WatchWithdrawalQueued(opts *bind.WatchOpts, sink chan<- *ContractDelegationManagerWithdrawalQueued) (event.Subscription, error) + ParseWithdrawalQueued(log types.Log) (*ContractDelegationManagerWithdrawalQueued, error) +} + // ContractDelegationManager is an auto generated Go binding around an Ethereum contract. type ContractDelegationManager struct { ContractDelegationManagerCaller // Read-only binding to the contract @@ -114,21 +310,33 @@ type ContractDelegationManager struct { ContractDelegationManagerFilterer // Log filterer for contract events } +// ContractDelegationManager implements the ContractDelegationManagerMethods interface. +var _ ContractDelegationManagerMethods = (*ContractDelegationManager)(nil) + // ContractDelegationManagerCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractDelegationManagerCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractDelegationManagerCaller implements the ContractDelegationManagerCalls interface. +var _ ContractDelegationManagerCalls = (*ContractDelegationManagerCaller)(nil) + // ContractDelegationManagerTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractDelegationManagerTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractDelegationManagerTransactor implements the ContractDelegationManagerTransacts interface. +var _ ContractDelegationManagerTransacts = (*ContractDelegationManagerTransactor)(nil) + // ContractDelegationManagerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractDelegationManagerFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractDelegationManagerFilterer implements the ContractDelegationManagerFilters interface. +var _ ContractDelegationManagerFilters = (*ContractDelegationManagerFilterer)(nil) + // ContractDelegationManagerSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractDelegationManagerSession struct { diff --git a/contracts/bindings/EigenPod/binding.go b/contracts/bindings/EigenPod/binding.go index b7cca815..26f4c388 100644 --- a/contracts/bindings/EigenPod/binding.go +++ b/contracts/bindings/EigenPod/binding.go @@ -97,6 +97,110 @@ func DeployContractEigenPod(auth *bind.TransactOpts, backend bind.ContractBacken return address, tx, &ContractEigenPod{ContractEigenPodCaller: ContractEigenPodCaller{contract: contract}, ContractEigenPodTransactor: ContractEigenPodTransactor{contract: contract}, ContractEigenPodFilterer: ContractEigenPodFilterer{contract: contract}}, nil } +// ContractEigenPodMethods is an auto generated interface around an Ethereum contract. +type ContractEigenPodMethods interface { + ContractEigenPodCalls + ContractEigenPodTransacts + ContractEigenPodFilters +} + +// ContractEigenPodCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractEigenPodCalls interface { + GENESISTIME(opts *bind.CallOpts) (uint64, error) + + MAXRESTAKEDBALANCEGWEIPERVALIDATOR(opts *bind.CallOpts) (uint64, error) + + DelayedWithdrawalRouter(opts *bind.CallOpts) (common.Address, error) + + EigenPodManager(opts *bind.CallOpts) (common.Address, error) + + EthPOS(opts *bind.CallOpts) (common.Address, error) + + HasRestaked(opts *bind.CallOpts) (bool, error) + + MostRecentWithdrawalTimestamp(opts *bind.CallOpts) (uint64, error) + + NonBeaconChainETHBalanceWei(opts *bind.CallOpts) (*big.Int, error) + + PodOwner(opts *bind.CallOpts) (common.Address, error) + + ProvenWithdrawal(opts *bind.CallOpts, arg0 [32]byte, arg1 uint64) (bool, error) + + SumOfPartialWithdrawalsClaimedGwei(opts *bind.CallOpts) (uint64, error) + + ValidatorPubkeyHashToInfo(opts *bind.CallOpts, validatorPubkeyHash [32]byte) (IEigenPodValidatorInfo, error) + + ValidatorStatus(opts *bind.CallOpts, pubkeyHash [32]byte) (uint8, error) + + WithdrawableRestakedExecutionLayerGwei(opts *bind.CallOpts) (uint64, error) +} + +// ContractEigenPodTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractEigenPodTransacts interface { + ActivateRestaking(opts *bind.TransactOpts) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, _podOwner common.Address) (*types.Transaction, error) + + RecoverTokens(opts *bind.TransactOpts, tokenList []common.Address, amountsToWithdraw []*big.Int, recipient common.Address) (*types.Transaction, error) + + Stake(opts *bind.TransactOpts, pubkey []byte, signature []byte, depositDataRoot [32]byte) (*types.Transaction, error) + + VerifyAndProcessWithdrawals(opts *bind.TransactOpts, oracleTimestamp uint64, stateRootProof BeaconChainProofsStateRootProof, withdrawalProofs []BeaconChainProofsWithdrawalProof, validatorFieldsProofs [][]byte, validatorFields [][][32]byte, withdrawalFields [][][32]byte) (*types.Transaction, error) + + VerifyBalanceUpdates(opts *bind.TransactOpts, oracleTimestamp uint64, validatorIndices []*big.Int, stateRootProof BeaconChainProofsStateRootProof, balanceUpdateProofs []BeaconChainProofsBalanceUpdateProof, validatorFields [][][32]byte) (*types.Transaction, error) + + VerifyWithdrawalCredentials(opts *bind.TransactOpts, oracleTimestamp uint64, stateRootProof BeaconChainProofsStateRootProof, validatorIndices []*big.Int, validatorFieldsProofs [][]byte, validatorFields [][][32]byte) (*types.Transaction, error) + + WithdrawBeforeRestaking(opts *bind.TransactOpts) (*types.Transaction, error) + + WithdrawNonBeaconChainETHBalanceWei(opts *bind.TransactOpts, recipient common.Address, amountToWithdraw *big.Int) (*types.Transaction, error) + + WithdrawRestakedBeaconChainETH(opts *bind.TransactOpts, recipient common.Address, amountWei *big.Int) (*types.Transaction, error) +} + +// ContractEigenPodFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractEigenPodFilters interface { + FilterEigenPodStaked(opts *bind.FilterOpts) (*ContractEigenPodEigenPodStakedIterator, error) + WatchEigenPodStaked(opts *bind.WatchOpts, sink chan<- *ContractEigenPodEigenPodStaked) (event.Subscription, error) + ParseEigenPodStaked(log types.Log) (*ContractEigenPodEigenPodStaked, error) + + FilterFullWithdrawalRedeemed(opts *bind.FilterOpts, recipient []common.Address) (*ContractEigenPodFullWithdrawalRedeemedIterator, error) + WatchFullWithdrawalRedeemed(opts *bind.WatchOpts, sink chan<- *ContractEigenPodFullWithdrawalRedeemed, recipient []common.Address) (event.Subscription, error) + ParseFullWithdrawalRedeemed(log types.Log) (*ContractEigenPodFullWithdrawalRedeemed, error) + + FilterInitialized(opts *bind.FilterOpts) (*ContractEigenPodInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractEigenPodInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractEigenPodInitialized, error) + + FilterNonBeaconChainETHReceived(opts *bind.FilterOpts) (*ContractEigenPodNonBeaconChainETHReceivedIterator, error) + WatchNonBeaconChainETHReceived(opts *bind.WatchOpts, sink chan<- *ContractEigenPodNonBeaconChainETHReceived) (event.Subscription, error) + ParseNonBeaconChainETHReceived(log types.Log) (*ContractEigenPodNonBeaconChainETHReceived, error) + + FilterNonBeaconChainETHWithdrawn(opts *bind.FilterOpts, recipient []common.Address) (*ContractEigenPodNonBeaconChainETHWithdrawnIterator, error) + WatchNonBeaconChainETHWithdrawn(opts *bind.WatchOpts, sink chan<- *ContractEigenPodNonBeaconChainETHWithdrawn, recipient []common.Address) (event.Subscription, error) + ParseNonBeaconChainETHWithdrawn(log types.Log) (*ContractEigenPodNonBeaconChainETHWithdrawn, error) + + FilterPartialWithdrawalRedeemed(opts *bind.FilterOpts, recipient []common.Address) (*ContractEigenPodPartialWithdrawalRedeemedIterator, error) + WatchPartialWithdrawalRedeemed(opts *bind.WatchOpts, sink chan<- *ContractEigenPodPartialWithdrawalRedeemed, recipient []common.Address) (event.Subscription, error) + ParsePartialWithdrawalRedeemed(log types.Log) (*ContractEigenPodPartialWithdrawalRedeemed, error) + + FilterRestakedBeaconChainETHWithdrawn(opts *bind.FilterOpts, recipient []common.Address) (*ContractEigenPodRestakedBeaconChainETHWithdrawnIterator, error) + WatchRestakedBeaconChainETHWithdrawn(opts *bind.WatchOpts, sink chan<- *ContractEigenPodRestakedBeaconChainETHWithdrawn, recipient []common.Address) (event.Subscription, error) + ParseRestakedBeaconChainETHWithdrawn(log types.Log) (*ContractEigenPodRestakedBeaconChainETHWithdrawn, error) + + FilterRestakingActivated(opts *bind.FilterOpts, podOwner []common.Address) (*ContractEigenPodRestakingActivatedIterator, error) + WatchRestakingActivated(opts *bind.WatchOpts, sink chan<- *ContractEigenPodRestakingActivated, podOwner []common.Address) (event.Subscription, error) + ParseRestakingActivated(log types.Log) (*ContractEigenPodRestakingActivated, error) + + FilterValidatorBalanceUpdated(opts *bind.FilterOpts) (*ContractEigenPodValidatorBalanceUpdatedIterator, error) + WatchValidatorBalanceUpdated(opts *bind.WatchOpts, sink chan<- *ContractEigenPodValidatorBalanceUpdated) (event.Subscription, error) + ParseValidatorBalanceUpdated(log types.Log) (*ContractEigenPodValidatorBalanceUpdated, error) + + FilterValidatorRestaked(opts *bind.FilterOpts) (*ContractEigenPodValidatorRestakedIterator, error) + WatchValidatorRestaked(opts *bind.WatchOpts, sink chan<- *ContractEigenPodValidatorRestaked) (event.Subscription, error) + ParseValidatorRestaked(log types.Log) (*ContractEigenPodValidatorRestaked, error) +} + // ContractEigenPod is an auto generated Go binding around an Ethereum contract. type ContractEigenPod struct { ContractEigenPodCaller // Read-only binding to the contract @@ -104,21 +208,33 @@ type ContractEigenPod struct { ContractEigenPodFilterer // Log filterer for contract events } +// ContractEigenPod implements the ContractEigenPodMethods interface. +var _ ContractEigenPodMethods = (*ContractEigenPod)(nil) + // ContractEigenPodCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractEigenPodCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractEigenPodCaller implements the ContractEigenPodCalls interface. +var _ ContractEigenPodCalls = (*ContractEigenPodCaller)(nil) + // ContractEigenPodTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractEigenPodTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractEigenPodTransactor implements the ContractEigenPodTransacts interface. +var _ ContractEigenPodTransacts = (*ContractEigenPodTransactor)(nil) + // ContractEigenPodFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractEigenPodFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractEigenPodFilterer implements the ContractEigenPodFilters interface. +var _ ContractEigenPodFilters = (*ContractEigenPodFilterer)(nil) + // ContractEigenPodSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractEigenPodSession struct { diff --git a/contracts/bindings/EigenPodManager/binding.go b/contracts/bindings/EigenPodManager/binding.go index e71fbbb1..8e822f3e 100644 --- a/contracts/bindings/EigenPodManager/binding.go +++ b/contracts/bindings/EigenPodManager/binding.go @@ -60,6 +60,128 @@ func DeployContractEigenPodManager(auth *bind.TransactOpts, backend bind.Contrac return address, tx, &ContractEigenPodManager{ContractEigenPodManagerCaller: ContractEigenPodManagerCaller{contract: contract}, ContractEigenPodManagerTransactor: ContractEigenPodManagerTransactor{contract: contract}, ContractEigenPodManagerFilterer: ContractEigenPodManagerFilterer{contract: contract}}, nil } +// ContractEigenPodManagerMethods is an auto generated interface around an Ethereum contract. +type ContractEigenPodManagerMethods interface { + ContractEigenPodManagerCalls + ContractEigenPodManagerTransacts + ContractEigenPodManagerFilters +} + +// ContractEigenPodManagerCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractEigenPodManagerCalls interface { + BeaconChainETHStrategy(opts *bind.CallOpts) (common.Address, error) + + BeaconChainOracle(opts *bind.CallOpts) (common.Address, error) + + DelegationManager(opts *bind.CallOpts) (common.Address, error) + + EigenPodBeacon(opts *bind.CallOpts) (common.Address, error) + + EthPOS(opts *bind.CallOpts) (common.Address, error) + + GetBlockRootAtTimestamp(opts *bind.CallOpts, timestamp uint64) ([32]byte, error) + + GetPod(opts *bind.CallOpts, podOwner common.Address) (common.Address, error) + + HasPod(opts *bind.CallOpts, podOwner common.Address) (bool, error) + + MaxPods(opts *bind.CallOpts) (*big.Int, error) + + NumPods(opts *bind.CallOpts) (*big.Int, error) + + Owner(opts *bind.CallOpts) (common.Address, error) + + OwnerToPod(opts *bind.CallOpts, arg0 common.Address) (common.Address, error) + + Paused(opts *bind.CallOpts, index uint8) (bool, error) + + Paused0(opts *bind.CallOpts) (*big.Int, error) + + PauserRegistry(opts *bind.CallOpts) (common.Address, error) + + PodOwnerShares(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) + + Slasher(opts *bind.CallOpts) (common.Address, error) + + StrategyManager(opts *bind.CallOpts) (common.Address, error) +} + +// ContractEigenPodManagerTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractEigenPodManagerTransacts interface { + AddShares(opts *bind.TransactOpts, podOwner common.Address, shares *big.Int) (*types.Transaction, error) + + CreatePod(opts *bind.TransactOpts) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, _maxPods *big.Int, _beaconChainOracle common.Address, initialOwner common.Address, _pauserRegistry common.Address, _initPausedStatus *big.Int) (*types.Transaction, error) + + Pause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + PauseAll(opts *bind.TransactOpts) (*types.Transaction, error) + + RecordBeaconChainETHBalanceUpdate(opts *bind.TransactOpts, podOwner common.Address, sharesDelta *big.Int) (*types.Transaction, error) + + RemoveShares(opts *bind.TransactOpts, podOwner common.Address, shares *big.Int) (*types.Transaction, error) + + RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) + + SetMaxPods(opts *bind.TransactOpts, newMaxPods *big.Int) (*types.Transaction, error) + + SetPauserRegistry(opts *bind.TransactOpts, newPauserRegistry common.Address) (*types.Transaction, error) + + Stake(opts *bind.TransactOpts, pubkey []byte, signature []byte, depositDataRoot [32]byte) (*types.Transaction, error) + + TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) + + Unpause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + UpdateBeaconChainOracle(opts *bind.TransactOpts, newBeaconChainOracle common.Address) (*types.Transaction, error) + + WithdrawSharesAsTokens(opts *bind.TransactOpts, podOwner common.Address, destination common.Address, shares *big.Int) (*types.Transaction, error) +} + +// ContractEigenPodManagerFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractEigenPodManagerFilters interface { + FilterBeaconChainETHDeposited(opts *bind.FilterOpts, podOwner []common.Address) (*ContractEigenPodManagerBeaconChainETHDepositedIterator, error) + WatchBeaconChainETHDeposited(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerBeaconChainETHDeposited, podOwner []common.Address) (event.Subscription, error) + ParseBeaconChainETHDeposited(log types.Log) (*ContractEigenPodManagerBeaconChainETHDeposited, error) + + FilterBeaconChainETHWithdrawalCompleted(opts *bind.FilterOpts, podOwner []common.Address) (*ContractEigenPodManagerBeaconChainETHWithdrawalCompletedIterator, error) + WatchBeaconChainETHWithdrawalCompleted(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerBeaconChainETHWithdrawalCompleted, podOwner []common.Address) (event.Subscription, error) + ParseBeaconChainETHWithdrawalCompleted(log types.Log) (*ContractEigenPodManagerBeaconChainETHWithdrawalCompleted, error) + + FilterBeaconOracleUpdated(opts *bind.FilterOpts, newOracleAddress []common.Address) (*ContractEigenPodManagerBeaconOracleUpdatedIterator, error) + WatchBeaconOracleUpdated(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerBeaconOracleUpdated, newOracleAddress []common.Address) (event.Subscription, error) + ParseBeaconOracleUpdated(log types.Log) (*ContractEigenPodManagerBeaconOracleUpdated, error) + + FilterInitialized(opts *bind.FilterOpts) (*ContractEigenPodManagerInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractEigenPodManagerInitialized, error) + + FilterMaxPodsUpdated(opts *bind.FilterOpts) (*ContractEigenPodManagerMaxPodsUpdatedIterator, error) + WatchMaxPodsUpdated(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerMaxPodsUpdated) (event.Subscription, error) + ParseMaxPodsUpdated(log types.Log) (*ContractEigenPodManagerMaxPodsUpdated, error) + + FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ContractEigenPodManagerOwnershipTransferredIterator, error) + WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) + ParseOwnershipTransferred(log types.Log) (*ContractEigenPodManagerOwnershipTransferred, error) + + FilterPaused(opts *bind.FilterOpts, account []common.Address) (*ContractEigenPodManagerPausedIterator, error) + WatchPaused(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerPaused, account []common.Address) (event.Subscription, error) + ParsePaused(log types.Log) (*ContractEigenPodManagerPaused, error) + + FilterPauserRegistrySet(opts *bind.FilterOpts) (*ContractEigenPodManagerPauserRegistrySetIterator, error) + WatchPauserRegistrySet(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerPauserRegistrySet) (event.Subscription, error) + ParsePauserRegistrySet(log types.Log) (*ContractEigenPodManagerPauserRegistrySet, error) + + FilterPodDeployed(opts *bind.FilterOpts, eigenPod []common.Address, podOwner []common.Address) (*ContractEigenPodManagerPodDeployedIterator, error) + WatchPodDeployed(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerPodDeployed, eigenPod []common.Address, podOwner []common.Address) (event.Subscription, error) + ParsePodDeployed(log types.Log) (*ContractEigenPodManagerPodDeployed, error) + + FilterUnpaused(opts *bind.FilterOpts, account []common.Address) (*ContractEigenPodManagerUnpausedIterator, error) + WatchUnpaused(opts *bind.WatchOpts, sink chan<- *ContractEigenPodManagerUnpaused, account []common.Address) (event.Subscription, error) + ParseUnpaused(log types.Log) (*ContractEigenPodManagerUnpaused, error) +} + // ContractEigenPodManager is an auto generated Go binding around an Ethereum contract. type ContractEigenPodManager struct { ContractEigenPodManagerCaller // Read-only binding to the contract @@ -67,21 +189,33 @@ type ContractEigenPodManager struct { ContractEigenPodManagerFilterer // Log filterer for contract events } +// ContractEigenPodManager implements the ContractEigenPodManagerMethods interface. +var _ ContractEigenPodManagerMethods = (*ContractEigenPodManager)(nil) + // ContractEigenPodManagerCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractEigenPodManagerCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractEigenPodManagerCaller implements the ContractEigenPodManagerCalls interface. +var _ ContractEigenPodManagerCalls = (*ContractEigenPodManagerCaller)(nil) + // ContractEigenPodManagerTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractEigenPodManagerTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractEigenPodManagerTransactor implements the ContractEigenPodManagerTransacts interface. +var _ ContractEigenPodManagerTransacts = (*ContractEigenPodManagerTransactor)(nil) + // ContractEigenPodManagerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractEigenPodManagerFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractEigenPodManagerFilterer implements the ContractEigenPodManagerFilters interface. +var _ ContractEigenPodManagerFilters = (*ContractEigenPodManagerFilterer)(nil) + // ContractEigenPodManagerSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractEigenPodManagerSession struct { diff --git a/contracts/bindings/IBLSSignatureChecker/binding.go b/contracts/bindings/IBLSSignatureChecker/binding.go index d47d3cc2..bde7e6b5 100644 --- a/contracts/bindings/IBLSSignatureChecker/binding.go +++ b/contracts/bindings/IBLSSignatureChecker/binding.go @@ -68,6 +68,32 @@ var ContractIBLSSignatureCheckerMetaData = &bind.MetaData{ // Deprecated: Use ContractIBLSSignatureCheckerMetaData.ABI instead. var ContractIBLSSignatureCheckerABI = ContractIBLSSignatureCheckerMetaData.ABI +// ContractIBLSSignatureCheckerMethods is an auto generated interface around an Ethereum contract. +type ContractIBLSSignatureCheckerMethods interface { + ContractIBLSSignatureCheckerCalls + ContractIBLSSignatureCheckerTransacts + ContractIBLSSignatureCheckerFilters +} + +// ContractIBLSSignatureCheckerCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractIBLSSignatureCheckerCalls interface { + BlsPubkeyRegistry(opts *bind.CallOpts) (common.Address, error) + + CheckSignatures(opts *bind.CallOpts, msgHash [32]byte, quorumNumbers []byte, referenceBlockNumber uint32, nonSignerStakesAndSignature IBLSSignatureCheckerNonSignerStakesAndSignature) (IBLSSignatureCheckerQuorumStakeTotals, [32]byte, error) + + RegistryCoordinator(opts *bind.CallOpts) (common.Address, error) + + StakeRegistry(opts *bind.CallOpts) (common.Address, error) +} + +// ContractIBLSSignatureCheckerTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractIBLSSignatureCheckerTransacts interface { +} + +// ContractIBLSSignatureCheckerFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractIBLSSignatureCheckerFilters interface { +} + // ContractIBLSSignatureChecker is an auto generated Go binding around an Ethereum contract. type ContractIBLSSignatureChecker struct { ContractIBLSSignatureCheckerCaller // Read-only binding to the contract @@ -75,21 +101,33 @@ type ContractIBLSSignatureChecker struct { ContractIBLSSignatureCheckerFilterer // Log filterer for contract events } +// ContractIBLSSignatureChecker implements the ContractIBLSSignatureCheckerMethods interface. +var _ ContractIBLSSignatureCheckerMethods = (*ContractIBLSSignatureChecker)(nil) + // ContractIBLSSignatureCheckerCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractIBLSSignatureCheckerCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIBLSSignatureCheckerCaller implements the ContractIBLSSignatureCheckerCalls interface. +var _ ContractIBLSSignatureCheckerCalls = (*ContractIBLSSignatureCheckerCaller)(nil) + // ContractIBLSSignatureCheckerTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractIBLSSignatureCheckerTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIBLSSignatureCheckerTransactor implements the ContractIBLSSignatureCheckerTransacts interface. +var _ ContractIBLSSignatureCheckerTransacts = (*ContractIBLSSignatureCheckerTransactor)(nil) + // ContractIBLSSignatureCheckerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractIBLSSignatureCheckerFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIBLSSignatureCheckerFilterer implements the ContractIBLSSignatureCheckerFilters interface. +var _ ContractIBLSSignatureCheckerFilters = (*ContractIBLSSignatureCheckerFilterer)(nil) + // ContractIBLSSignatureCheckerSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractIBLSSignatureCheckerSession struct { diff --git a/contracts/bindings/IERC20/binding.go b/contracts/bindings/IERC20/binding.go index 225860ed..d979f639 100644 --- a/contracts/bindings/IERC20/binding.go +++ b/contracts/bindings/IERC20/binding.go @@ -38,6 +38,42 @@ var ContractIERC20MetaData = &bind.MetaData{ // Deprecated: Use ContractIERC20MetaData.ABI instead. var ContractIERC20ABI = ContractIERC20MetaData.ABI +// ContractIERC20Methods is an auto generated interface around an Ethereum contract. +type ContractIERC20Methods interface { + ContractIERC20Calls + ContractIERC20Transacts + ContractIERC20Filters +} + +// ContractIERC20Calls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractIERC20Calls interface { + Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) + + BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) + + TotalSupply(opts *bind.CallOpts) (*big.Int, error) +} + +// ContractIERC20Transacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractIERC20Transacts interface { + Approve(opts *bind.TransactOpts, spender common.Address, amount *big.Int) (*types.Transaction, error) + + Transfer(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) + + TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) +} + +// ContractIERC20Filterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractIERC20Filters interface { + FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*ContractIERC20ApprovalIterator, error) + WatchApproval(opts *bind.WatchOpts, sink chan<- *ContractIERC20Approval, owner []common.Address, spender []common.Address) (event.Subscription, error) + ParseApproval(log types.Log) (*ContractIERC20Approval, error) + + FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*ContractIERC20TransferIterator, error) + WatchTransfer(opts *bind.WatchOpts, sink chan<- *ContractIERC20Transfer, from []common.Address, to []common.Address) (event.Subscription, error) + ParseTransfer(log types.Log) (*ContractIERC20Transfer, error) +} + // ContractIERC20 is an auto generated Go binding around an Ethereum contract. type ContractIERC20 struct { ContractIERC20Caller // Read-only binding to the contract @@ -45,21 +81,33 @@ type ContractIERC20 struct { ContractIERC20Filterer // Log filterer for contract events } +// ContractIERC20 implements the ContractIERC20Methods interface. +var _ ContractIERC20Methods = (*ContractIERC20)(nil) + // ContractIERC20Caller is an auto generated read-only Go binding around an Ethereum contract. type ContractIERC20Caller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIERC20Caller implements the ContractIERC20Calls interface. +var _ ContractIERC20Calls = (*ContractIERC20Caller)(nil) + // ContractIERC20Transactor is an auto generated write-only Go binding around an Ethereum contract. type ContractIERC20Transactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIERC20Transactor implements the ContractIERC20Transacts interface. +var _ ContractIERC20Transacts = (*ContractIERC20Transactor)(nil) + // ContractIERC20Filterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractIERC20Filterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIERC20Filterer implements the ContractIERC20Filters interface. +var _ ContractIERC20Filters = (*ContractIERC20Filterer)(nil) + // ContractIERC20Session is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractIERC20Session struct { diff --git a/contracts/bindings/IStrategy/binding.go b/contracts/bindings/IStrategy/binding.go index 9e186e4d..6d4a13ac 100644 --- a/contracts/bindings/IStrategy/binding.go +++ b/contracts/bindings/IStrategy/binding.go @@ -38,6 +38,47 @@ var ContractIStrategyMetaData = &bind.MetaData{ // Deprecated: Use ContractIStrategyMetaData.ABI instead. var ContractIStrategyABI = ContractIStrategyMetaData.ABI +// ContractIStrategyMethods is an auto generated interface around an Ethereum contract. +type ContractIStrategyMethods interface { + ContractIStrategyCalls + ContractIStrategyTransacts + ContractIStrategyFilters +} + +// ContractIStrategyCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractIStrategyCalls interface { + Explanation(opts *bind.CallOpts) (string, error) + + Shares(opts *bind.CallOpts, user common.Address) (*big.Int, error) + + SharesToUnderlyingView(opts *bind.CallOpts, amountShares *big.Int) (*big.Int, error) + + TotalShares(opts *bind.CallOpts) (*big.Int, error) + + UnderlyingToSharesView(opts *bind.CallOpts, amountUnderlying *big.Int) (*big.Int, error) + + UnderlyingToken(opts *bind.CallOpts) (common.Address, error) + + UserUnderlyingView(opts *bind.CallOpts, user common.Address) (*big.Int, error) +} + +// ContractIStrategyTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractIStrategyTransacts interface { + Deposit(opts *bind.TransactOpts, token common.Address, amount *big.Int) (*types.Transaction, error) + + SharesToUnderlying(opts *bind.TransactOpts, amountShares *big.Int) (*types.Transaction, error) + + UnderlyingToShares(opts *bind.TransactOpts, amountUnderlying *big.Int) (*types.Transaction, error) + + UserUnderlying(opts *bind.TransactOpts, user common.Address) (*types.Transaction, error) + + Withdraw(opts *bind.TransactOpts, recipient common.Address, token common.Address, amountShares *big.Int) (*types.Transaction, error) +} + +// ContractIStrategyFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractIStrategyFilters interface { +} + // ContractIStrategy is an auto generated Go binding around an Ethereum contract. type ContractIStrategy struct { ContractIStrategyCaller // Read-only binding to the contract @@ -45,21 +86,33 @@ type ContractIStrategy struct { ContractIStrategyFilterer // Log filterer for contract events } +// ContractIStrategy implements the ContractIStrategyMethods interface. +var _ ContractIStrategyMethods = (*ContractIStrategy)(nil) + // ContractIStrategyCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractIStrategyCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIStrategyCaller implements the ContractIStrategyCalls interface. +var _ ContractIStrategyCalls = (*ContractIStrategyCaller)(nil) + // ContractIStrategyTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractIStrategyTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIStrategyTransactor implements the ContractIStrategyTransacts interface. +var _ ContractIStrategyTransacts = (*ContractIStrategyTransactor)(nil) + // ContractIStrategyFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractIStrategyFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractIStrategyFilterer implements the ContractIStrategyFilters interface. +var _ ContractIStrategyFilters = (*ContractIStrategyFilterer)(nil) + // ContractIStrategySession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractIStrategySession struct { diff --git a/contracts/bindings/Slasher/binding.go b/contracts/bindings/Slasher/binding.go index ef73aa24..38045c7a 100644 --- a/contracts/bindings/Slasher/binding.go +++ b/contracts/bindings/Slasher/binding.go @@ -73,6 +73,128 @@ func DeployContractSlasher(auth *bind.TransactOpts, backend bind.ContractBackend return address, tx, &ContractSlasher{ContractSlasherCaller: ContractSlasherCaller{contract: contract}, ContractSlasherTransactor: ContractSlasherTransactor{contract: contract}, ContractSlasherFilterer: ContractSlasherFilterer{contract: contract}}, nil } +// ContractSlasherMethods is an auto generated interface around an Ethereum contract. +type ContractSlasherMethods interface { + ContractSlasherCalls + ContractSlasherTransacts + ContractSlasherFilters +} + +// ContractSlasherCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractSlasherCalls interface { + CanSlash(opts *bind.CallOpts, toBeSlashed common.Address, slashingContract common.Address) (bool, error) + + CanWithdraw(opts *bind.CallOpts, operator common.Address, withdrawalStartBlock uint32, middlewareTimesIndex *big.Int) (bool, error) + + ContractCanSlashOperatorUntilBlock(opts *bind.CallOpts, operator common.Address, serviceContract common.Address) (uint32, error) + + Delegation(opts *bind.CallOpts) (common.Address, error) + + GetCorrectValueForInsertAfter(opts *bind.CallOpts, operator common.Address, updateBlock uint32) (*big.Int, error) + + GetMiddlewareTimesIndexServeUntilBlock(opts *bind.CallOpts, operator common.Address, index uint32) (uint32, error) + + GetMiddlewareTimesIndexStalestUpdateBlock(opts *bind.CallOpts, operator common.Address, index uint32) (uint32, error) + + GetPreviousWhitelistedContractByUpdate(opts *bind.CallOpts, operator common.Address, node *big.Int) (bool, *big.Int, error) + + IsFrozen(opts *bind.CallOpts, staker common.Address) (bool, error) + + LatestUpdateBlock(opts *bind.CallOpts, operator common.Address, serviceContract common.Address) (uint32, error) + + MiddlewareTimesLength(opts *bind.CallOpts, operator common.Address) (*big.Int, error) + + OperatorToMiddlewareTimes(opts *bind.CallOpts, operator common.Address, arrayIndex *big.Int) (ISlasherMiddlewareTimes, error) + + OperatorWhitelistedContractsLinkedListEntry(opts *bind.CallOpts, operator common.Address, node common.Address) (bool, *big.Int, *big.Int, error) + + OperatorWhitelistedContractsLinkedListSize(opts *bind.CallOpts, operator common.Address) (*big.Int, error) + + Owner(opts *bind.CallOpts) (common.Address, error) + + Paused(opts *bind.CallOpts, index uint8) (bool, error) + + Paused0(opts *bind.CallOpts) (*big.Int, error) + + PauserRegistry(opts *bind.CallOpts) (common.Address, error) + + StrategyManager(opts *bind.CallOpts) (common.Address, error) + + WhitelistedContractDetails(opts *bind.CallOpts, operator common.Address, serviceContract common.Address) (ISlasherMiddlewareDetails, error) +} + +// ContractSlasherTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractSlasherTransacts interface { + FreezeOperator(opts *bind.TransactOpts, toBeFrozen common.Address) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, initialOwner common.Address, _pauserRegistry common.Address, initialPausedStatus *big.Int) (*types.Transaction, error) + + OptIntoSlashing(opts *bind.TransactOpts, contractAddress common.Address) (*types.Transaction, error) + + Pause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + PauseAll(opts *bind.TransactOpts) (*types.Transaction, error) + + RecordFirstStakeUpdate(opts *bind.TransactOpts, operator common.Address, serveUntilBlock uint32) (*types.Transaction, error) + + RecordLastStakeUpdateAndRevokeSlashingAbility(opts *bind.TransactOpts, operator common.Address, serveUntilBlock uint32) (*types.Transaction, error) + + RecordStakeUpdate(opts *bind.TransactOpts, operator common.Address, updateBlock uint32, serveUntilBlock uint32, insertAfter *big.Int) (*types.Transaction, error) + + RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) + + ResetFrozenStatus(opts *bind.TransactOpts, frozenAddresses []common.Address) (*types.Transaction, error) + + SetPauserRegistry(opts *bind.TransactOpts, newPauserRegistry common.Address) (*types.Transaction, error) + + TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) + + Unpause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) +} + +// ContractSlasherFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractSlasherFilters interface { + FilterFrozenStatusReset(opts *bind.FilterOpts, previouslySlashedAddress []common.Address) (*ContractSlasherFrozenStatusResetIterator, error) + WatchFrozenStatusReset(opts *bind.WatchOpts, sink chan<- *ContractSlasherFrozenStatusReset, previouslySlashedAddress []common.Address) (event.Subscription, error) + ParseFrozenStatusReset(log types.Log) (*ContractSlasherFrozenStatusReset, error) + + FilterInitialized(opts *bind.FilterOpts) (*ContractSlasherInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractSlasherInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractSlasherInitialized, error) + + FilterMiddlewareTimesAdded(opts *bind.FilterOpts) (*ContractSlasherMiddlewareTimesAddedIterator, error) + WatchMiddlewareTimesAdded(opts *bind.WatchOpts, sink chan<- *ContractSlasherMiddlewareTimesAdded) (event.Subscription, error) + ParseMiddlewareTimesAdded(log types.Log) (*ContractSlasherMiddlewareTimesAdded, error) + + FilterOperatorFrozen(opts *bind.FilterOpts, slashedOperator []common.Address, slashingContract []common.Address) (*ContractSlasherOperatorFrozenIterator, error) + WatchOperatorFrozen(opts *bind.WatchOpts, sink chan<- *ContractSlasherOperatorFrozen, slashedOperator []common.Address, slashingContract []common.Address) (event.Subscription, error) + ParseOperatorFrozen(log types.Log) (*ContractSlasherOperatorFrozen, error) + + FilterOptedIntoSlashing(opts *bind.FilterOpts, operator []common.Address, contractAddress []common.Address) (*ContractSlasherOptedIntoSlashingIterator, error) + WatchOptedIntoSlashing(opts *bind.WatchOpts, sink chan<- *ContractSlasherOptedIntoSlashing, operator []common.Address, contractAddress []common.Address) (event.Subscription, error) + ParseOptedIntoSlashing(log types.Log) (*ContractSlasherOptedIntoSlashing, error) + + FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ContractSlasherOwnershipTransferredIterator, error) + WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ContractSlasherOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) + ParseOwnershipTransferred(log types.Log) (*ContractSlasherOwnershipTransferred, error) + + FilterPaused(opts *bind.FilterOpts, account []common.Address) (*ContractSlasherPausedIterator, error) + WatchPaused(opts *bind.WatchOpts, sink chan<- *ContractSlasherPaused, account []common.Address) (event.Subscription, error) + ParsePaused(log types.Log) (*ContractSlasherPaused, error) + + FilterPauserRegistrySet(opts *bind.FilterOpts) (*ContractSlasherPauserRegistrySetIterator, error) + WatchPauserRegistrySet(opts *bind.WatchOpts, sink chan<- *ContractSlasherPauserRegistrySet) (event.Subscription, error) + ParsePauserRegistrySet(log types.Log) (*ContractSlasherPauserRegistrySet, error) + + FilterSlashingAbilityRevoked(opts *bind.FilterOpts, operator []common.Address, contractAddress []common.Address) (*ContractSlasherSlashingAbilityRevokedIterator, error) + WatchSlashingAbilityRevoked(opts *bind.WatchOpts, sink chan<- *ContractSlasherSlashingAbilityRevoked, operator []common.Address, contractAddress []common.Address) (event.Subscription, error) + ParseSlashingAbilityRevoked(log types.Log) (*ContractSlasherSlashingAbilityRevoked, error) + + FilterUnpaused(opts *bind.FilterOpts, account []common.Address) (*ContractSlasherUnpausedIterator, error) + WatchUnpaused(opts *bind.WatchOpts, sink chan<- *ContractSlasherUnpaused, account []common.Address) (event.Subscription, error) + ParseUnpaused(log types.Log) (*ContractSlasherUnpaused, error) +} + // ContractSlasher is an auto generated Go binding around an Ethereum contract. type ContractSlasher struct { ContractSlasherCaller // Read-only binding to the contract @@ -80,21 +202,33 @@ type ContractSlasher struct { ContractSlasherFilterer // Log filterer for contract events } +// ContractSlasher implements the ContractSlasherMethods interface. +var _ ContractSlasherMethods = (*ContractSlasher)(nil) + // ContractSlasherCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractSlasherCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractSlasherCaller implements the ContractSlasherCalls interface. +var _ ContractSlasherCalls = (*ContractSlasherCaller)(nil) + // ContractSlasherTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractSlasherTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractSlasherTransactor implements the ContractSlasherTransacts interface. +var _ ContractSlasherTransacts = (*ContractSlasherTransactor)(nil) + // ContractSlasherFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractSlasherFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractSlasherFilterer implements the ContractSlasherFilters interface. +var _ ContractSlasherFilters = (*ContractSlasherFilterer)(nil) + // ContractSlasherSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractSlasherSession struct { diff --git a/contracts/bindings/StakeRegistry/binding.go b/contracts/bindings/StakeRegistry/binding.go index 85ba50ad..8221d531 100644 --- a/contracts/bindings/StakeRegistry/binding.go +++ b/contracts/bindings/StakeRegistry/binding.go @@ -73,6 +73,125 @@ func DeployContractStakeRegistry(auth *bind.TransactOpts, backend bind.ContractB return address, tx, &ContractStakeRegistry{ContractStakeRegistryCaller: ContractStakeRegistryCaller{contract: contract}, ContractStakeRegistryTransactor: ContractStakeRegistryTransactor{contract: contract}, ContractStakeRegistryFilterer: ContractStakeRegistryFilterer{contract: contract}}, nil } +// ContractStakeRegistryMethods is an auto generated interface around an Ethereum contract. +type ContractStakeRegistryMethods interface { + ContractStakeRegistryCalls + ContractStakeRegistryTransacts + ContractStakeRegistryFilters +} + +// ContractStakeRegistryCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractStakeRegistryCalls interface { + MAXQUORUMCOUNT(opts *bind.CallOpts) (uint8, error) + + MAXWEIGHINGFUNCTIONLENGTH(opts *bind.CallOpts) (uint8, error) + + WEIGHTINGDIVISOR(opts *bind.CallOpts) (*big.Int, error) + + Delegation(opts *bind.CallOpts) (common.Address, error) + + GetCurrentOperatorStakeForQuorum(opts *bind.CallOpts, operatorId [32]byte, quorumNumber uint8) (*big.Int, error) + + GetCurrentTotalStakeForQuorum(opts *bind.CallOpts, quorumNumber uint8) (*big.Int, error) + + GetLengthOfOperatorIdStakeHistoryForQuorum(opts *bind.CallOpts, operatorId [32]byte, quorumNumber uint8) (*big.Int, error) + + GetLengthOfTotalStakeHistoryForQuorum(opts *bind.CallOpts, quorumNumber uint8) (*big.Int, error) + + GetMostRecentStakeUpdateByOperatorId(opts *bind.CallOpts, operatorId [32]byte, quorumNumber uint8) (IStakeRegistryOperatorStakeUpdate, error) + + GetOperatorIdToStakeHistory(opts *bind.CallOpts, operatorId [32]byte, quorumNumber uint8) ([]IStakeRegistryOperatorStakeUpdate, error) + + GetStakeForOperatorIdForQuorumAtBlockNumber(opts *bind.CallOpts, operatorId [32]byte, quorumNumber uint8, blockNumber uint32) (*big.Int, error) + + GetStakeForQuorumAtBlockNumberFromOperatorIdAndIndex(opts *bind.CallOpts, quorumNumber uint8, blockNumber uint32, operatorId [32]byte, index *big.Int) (*big.Int, error) + + GetStakeUpdateForQuorumFromOperatorIdAndIndex(opts *bind.CallOpts, quorumNumber uint8, operatorId [32]byte, index *big.Int) (IStakeRegistryOperatorStakeUpdate, error) + + GetStakeUpdateIndexForOperatorIdForQuorumAtBlockNumber(opts *bind.CallOpts, operatorId [32]byte, quorumNumber uint8, blockNumber uint32) (uint32, error) + + GetTotalStakeAtBlockNumberFromIndex(opts *bind.CallOpts, quorumNumber uint8, blockNumber uint32, index *big.Int) (*big.Int, error) + + GetTotalStakeIndicesByQuorumNumbersAtBlockNumber(opts *bind.CallOpts, blockNumber uint32, quorumNumbers []byte) ([]uint32, error) + + GetTotalStakeUpdateForQuorumFromIndex(opts *bind.CallOpts, quorumNumber uint8, index *big.Int) (IStakeRegistryOperatorStakeUpdate, error) + + MinimumStakeForQuorum(opts *bind.CallOpts, arg0 *big.Int) (*big.Int, error) + + QuorumCount(opts *bind.CallOpts) (uint16, error) + + RegistryCoordinator(opts *bind.CallOpts) (common.Address, error) + + ServiceManager(opts *bind.CallOpts) (common.Address, error) + + Slasher(opts *bind.CallOpts) (common.Address, error) + + StrategiesConsideredAndMultipliers(opts *bind.CallOpts, arg0 uint8, arg1 *big.Int) (struct { + Strategy common.Address + Multiplier *big.Int + }, error) + + StrategiesConsideredAndMultipliersLength(opts *bind.CallOpts, quorumNumber uint8) (*big.Int, error) + + StrategyAndWeightingMultiplierForQuorumByIndex(opts *bind.CallOpts, quorumNumber uint8, index *big.Int) (IVoteWeigherStrategyAndWeightingMultiplier, error) + + StrategyManager(opts *bind.CallOpts) (common.Address, error) + + WeightOfOperatorForQuorum(opts *bind.CallOpts, quorumNumber uint8, operator common.Address) (*big.Int, error) +} + +// ContractStakeRegistryTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractStakeRegistryTransacts interface { + AddStrategiesConsideredAndMultipliers(opts *bind.TransactOpts, quorumNumber uint8, _newStrategiesConsideredAndMultipliers []IVoteWeigherStrategyAndWeightingMultiplier) (*types.Transaction, error) + + CreateQuorum(opts *bind.TransactOpts, _strategiesConsideredAndMultipliers []IVoteWeigherStrategyAndWeightingMultiplier) (*types.Transaction, error) + + DeregisterOperator(opts *bind.TransactOpts, operatorId [32]byte, quorumNumbers []byte) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, _minimumStakeForQuorum []*big.Int, _quorumStrategiesConsideredAndMultipliers [][]IVoteWeigherStrategyAndWeightingMultiplier) (*types.Transaction, error) + + ModifyStrategyWeights(opts *bind.TransactOpts, quorumNumber uint8, strategyIndices []*big.Int, newMultipliers []*big.Int) (*types.Transaction, error) + + RegisterOperator(opts *bind.TransactOpts, operator common.Address, operatorId [32]byte, quorumNumbers []byte) (*types.Transaction, error) + + RemoveStrategiesConsideredAndMultipliers(opts *bind.TransactOpts, quorumNumber uint8, indicesToRemove []*big.Int) (*types.Transaction, error) + + SetMinimumStakeForQuorum(opts *bind.TransactOpts, quorumNumber uint8, minimumStake *big.Int) (*types.Transaction, error) + + UpdateStakes(opts *bind.TransactOpts, operators []common.Address) (*types.Transaction, error) +} + +// ContractStakeRegistryFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractStakeRegistryFilters interface { + FilterInitialized(opts *bind.FilterOpts) (*ContractStakeRegistryInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractStakeRegistryInitialized, error) + + FilterMinimumStakeForQuorumUpdated(opts *bind.FilterOpts, quorumNumber []uint8) (*ContractStakeRegistryMinimumStakeForQuorumUpdatedIterator, error) + WatchMinimumStakeForQuorumUpdated(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryMinimumStakeForQuorumUpdated, quorumNumber []uint8) (event.Subscription, error) + ParseMinimumStakeForQuorumUpdated(log types.Log) (*ContractStakeRegistryMinimumStakeForQuorumUpdated, error) + + FilterQuorumCreated(opts *bind.FilterOpts, quorumNumber []uint8) (*ContractStakeRegistryQuorumCreatedIterator, error) + WatchQuorumCreated(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryQuorumCreated, quorumNumber []uint8) (event.Subscription, error) + ParseQuorumCreated(log types.Log) (*ContractStakeRegistryQuorumCreated, error) + + FilterStakeUpdate(opts *bind.FilterOpts, operatorId [][32]byte) (*ContractStakeRegistryStakeUpdateIterator, error) + WatchStakeUpdate(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryStakeUpdate, operatorId [][32]byte) (event.Subscription, error) + ParseStakeUpdate(log types.Log) (*ContractStakeRegistryStakeUpdate, error) + + FilterStrategyAddedToQuorum(opts *bind.FilterOpts, quorumNumber []uint8) (*ContractStakeRegistryStrategyAddedToQuorumIterator, error) + WatchStrategyAddedToQuorum(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryStrategyAddedToQuorum, quorumNumber []uint8) (event.Subscription, error) + ParseStrategyAddedToQuorum(log types.Log) (*ContractStakeRegistryStrategyAddedToQuorum, error) + + FilterStrategyMultiplierUpdated(opts *bind.FilterOpts, quorumNumber []uint8) (*ContractStakeRegistryStrategyMultiplierUpdatedIterator, error) + WatchStrategyMultiplierUpdated(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryStrategyMultiplierUpdated, quorumNumber []uint8) (event.Subscription, error) + ParseStrategyMultiplierUpdated(log types.Log) (*ContractStakeRegistryStrategyMultiplierUpdated, error) + + FilterStrategyRemovedFromQuorum(opts *bind.FilterOpts, quorumNumber []uint8) (*ContractStakeRegistryStrategyRemovedFromQuorumIterator, error) + WatchStrategyRemovedFromQuorum(opts *bind.WatchOpts, sink chan<- *ContractStakeRegistryStrategyRemovedFromQuorum, quorumNumber []uint8) (event.Subscription, error) + ParseStrategyRemovedFromQuorum(log types.Log) (*ContractStakeRegistryStrategyRemovedFromQuorum, error) +} + // ContractStakeRegistry is an auto generated Go binding around an Ethereum contract. type ContractStakeRegistry struct { ContractStakeRegistryCaller // Read-only binding to the contract @@ -80,21 +199,33 @@ type ContractStakeRegistry struct { ContractStakeRegistryFilterer // Log filterer for contract events } +// ContractStakeRegistry implements the ContractStakeRegistryMethods interface. +var _ ContractStakeRegistryMethods = (*ContractStakeRegistry)(nil) + // ContractStakeRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractStakeRegistryCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractStakeRegistryCaller implements the ContractStakeRegistryCalls interface. +var _ ContractStakeRegistryCalls = (*ContractStakeRegistryCaller)(nil) + // ContractStakeRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractStakeRegistryTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractStakeRegistryTransactor implements the ContractStakeRegistryTransacts interface. +var _ ContractStakeRegistryTransacts = (*ContractStakeRegistryTransactor)(nil) + // ContractStakeRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractStakeRegistryFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractStakeRegistryFilterer implements the ContractStakeRegistryFilters interface. +var _ ContractStakeRegistryFilters = (*ContractStakeRegistryFilterer)(nil) + // ContractStakeRegistrySession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractStakeRegistrySession struct { diff --git a/contracts/bindings/StrategyManager/binding.go b/contracts/bindings/StrategyManager/binding.go index 808f860e..3f684216 100644 --- a/contracts/bindings/StrategyManager/binding.go +++ b/contracts/bindings/StrategyManager/binding.go @@ -76,6 +76,128 @@ func DeployContractStrategyManager(auth *bind.TransactOpts, backend bind.Contrac return address, tx, &ContractStrategyManager{ContractStrategyManagerCaller: ContractStrategyManagerCaller{contract: contract}, ContractStrategyManagerTransactor: ContractStrategyManagerTransactor{contract: contract}, ContractStrategyManagerFilterer: ContractStrategyManagerFilterer{contract: contract}}, nil } +// ContractStrategyManagerMethods is an auto generated interface around an Ethereum contract. +type ContractStrategyManagerMethods interface { + ContractStrategyManagerCalls + ContractStrategyManagerTransacts + ContractStrategyManagerFilters +} + +// ContractStrategyManagerCalls is an auto generated interface that defines the call methods available for an Ethereum contract. +type ContractStrategyManagerCalls interface { + DEPOSITTYPEHASH(opts *bind.CallOpts) ([32]byte, error) + + DOMAINTYPEHASH(opts *bind.CallOpts) ([32]byte, error) + + CalculateWithdrawalRoot(opts *bind.CallOpts, queuedWithdrawal IStrategyManagerDeprecatedStructQueuedWithdrawal) ([32]byte, error) + + Delegation(opts *bind.CallOpts) (common.Address, error) + + DomainSeparator(opts *bind.CallOpts) ([32]byte, error) + + EigenPodManager(opts *bind.CallOpts) (common.Address, error) + + GetDeposits(opts *bind.CallOpts, staker common.Address) ([]common.Address, []*big.Int, error) + + Nonces(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) + + Owner(opts *bind.CallOpts) (common.Address, error) + + Paused(opts *bind.CallOpts, index uint8) (bool, error) + + Paused0(opts *bind.CallOpts) (*big.Int, error) + + PauserRegistry(opts *bind.CallOpts) (common.Address, error) + + Slasher(opts *bind.CallOpts) (common.Address, error) + + StakerStrategyList(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (common.Address, error) + + StakerStrategyListLength(opts *bind.CallOpts, staker common.Address) (*big.Int, error) + + StakerStrategyShares(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) + + StrategyIsWhitelistedForDeposit(opts *bind.CallOpts, arg0 common.Address) (bool, error) + + StrategyWhitelister(opts *bind.CallOpts) (common.Address, error) + + WithdrawalRootPending(opts *bind.CallOpts, arg0 [32]byte) (bool, error) +} + +// ContractStrategyManagerTransacts is an auto generated interface that defines the transact methods available for an Ethereum contract. +type ContractStrategyManagerTransacts interface { + AddShares(opts *bind.TransactOpts, staker common.Address, strategy common.Address, shares *big.Int) (*types.Transaction, error) + + AddStrategiesToDepositWhitelist(opts *bind.TransactOpts, strategiesToWhitelist []common.Address) (*types.Transaction, error) + + DepositIntoStrategy(opts *bind.TransactOpts, strategy common.Address, token common.Address, amount *big.Int) (*types.Transaction, error) + + DepositIntoStrategyWithSignature(opts *bind.TransactOpts, strategy common.Address, token common.Address, amount *big.Int, staker common.Address, expiry *big.Int, signature []byte) (*types.Transaction, error) + + Initialize(opts *bind.TransactOpts, initialOwner common.Address, initialStrategyWhitelister common.Address, _pauserRegistry common.Address, initialPausedStatus *big.Int) (*types.Transaction, error) + + MigrateQueuedWithdrawal(opts *bind.TransactOpts, queuedWithdrawal IStrategyManagerDeprecatedStructQueuedWithdrawal) (*types.Transaction, error) + + Pause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + PauseAll(opts *bind.TransactOpts) (*types.Transaction, error) + + RemoveShares(opts *bind.TransactOpts, staker common.Address, strategy common.Address, shares *big.Int) (*types.Transaction, error) + + RemoveStrategiesFromDepositWhitelist(opts *bind.TransactOpts, strategiesToRemoveFromWhitelist []common.Address) (*types.Transaction, error) + + RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) + + SetPauserRegistry(opts *bind.TransactOpts, newPauserRegistry common.Address) (*types.Transaction, error) + + SetStrategyWhitelister(opts *bind.TransactOpts, newStrategyWhitelister common.Address) (*types.Transaction, error) + + TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) + + Unpause(opts *bind.TransactOpts, newPausedStatus *big.Int) (*types.Transaction, error) + + WithdrawSharesAsTokens(opts *bind.TransactOpts, recipient common.Address, strategy common.Address, shares *big.Int, token common.Address) (*types.Transaction, error) +} + +// ContractStrategyManagerFilterer is an auto generated interface that defines the log filtering methods available for an Ethereum contract. +type ContractStrategyManagerFilters interface { + FilterDeposit(opts *bind.FilterOpts) (*ContractStrategyManagerDepositIterator, error) + WatchDeposit(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerDeposit) (event.Subscription, error) + ParseDeposit(log types.Log) (*ContractStrategyManagerDeposit, error) + + FilterInitialized(opts *bind.FilterOpts) (*ContractStrategyManagerInitializedIterator, error) + WatchInitialized(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerInitialized) (event.Subscription, error) + ParseInitialized(log types.Log) (*ContractStrategyManagerInitialized, error) + + FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ContractStrategyManagerOwnershipTransferredIterator, error) + WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) + ParseOwnershipTransferred(log types.Log) (*ContractStrategyManagerOwnershipTransferred, error) + + FilterPaused(opts *bind.FilterOpts, account []common.Address) (*ContractStrategyManagerPausedIterator, error) + WatchPaused(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerPaused, account []common.Address) (event.Subscription, error) + ParsePaused(log types.Log) (*ContractStrategyManagerPaused, error) + + FilterPauserRegistrySet(opts *bind.FilterOpts) (*ContractStrategyManagerPauserRegistrySetIterator, error) + WatchPauserRegistrySet(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerPauserRegistrySet) (event.Subscription, error) + ParsePauserRegistrySet(log types.Log) (*ContractStrategyManagerPauserRegistrySet, error) + + FilterStrategyAddedToDepositWhitelist(opts *bind.FilterOpts) (*ContractStrategyManagerStrategyAddedToDepositWhitelistIterator, error) + WatchStrategyAddedToDepositWhitelist(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerStrategyAddedToDepositWhitelist) (event.Subscription, error) + ParseStrategyAddedToDepositWhitelist(log types.Log) (*ContractStrategyManagerStrategyAddedToDepositWhitelist, error) + + FilterStrategyRemovedFromDepositWhitelist(opts *bind.FilterOpts) (*ContractStrategyManagerStrategyRemovedFromDepositWhitelistIterator, error) + WatchStrategyRemovedFromDepositWhitelist(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerStrategyRemovedFromDepositWhitelist) (event.Subscription, error) + ParseStrategyRemovedFromDepositWhitelist(log types.Log) (*ContractStrategyManagerStrategyRemovedFromDepositWhitelist, error) + + FilterStrategyWhitelisterChanged(opts *bind.FilterOpts) (*ContractStrategyManagerStrategyWhitelisterChangedIterator, error) + WatchStrategyWhitelisterChanged(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerStrategyWhitelisterChanged) (event.Subscription, error) + ParseStrategyWhitelisterChanged(log types.Log) (*ContractStrategyManagerStrategyWhitelisterChanged, error) + + FilterUnpaused(opts *bind.FilterOpts, account []common.Address) (*ContractStrategyManagerUnpausedIterator, error) + WatchUnpaused(opts *bind.WatchOpts, sink chan<- *ContractStrategyManagerUnpaused, account []common.Address) (event.Subscription, error) + ParseUnpaused(log types.Log) (*ContractStrategyManagerUnpaused, error) +} + // ContractStrategyManager is an auto generated Go binding around an Ethereum contract. type ContractStrategyManager struct { ContractStrategyManagerCaller // Read-only binding to the contract @@ -83,21 +205,33 @@ type ContractStrategyManager struct { ContractStrategyManagerFilterer // Log filterer for contract events } +// ContractStrategyManager implements the ContractStrategyManagerMethods interface. +var _ ContractStrategyManagerMethods = (*ContractStrategyManager)(nil) + // ContractStrategyManagerCaller is an auto generated read-only Go binding around an Ethereum contract. type ContractStrategyManagerCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractStrategyManagerCaller implements the ContractStrategyManagerCalls interface. +var _ ContractStrategyManagerCalls = (*ContractStrategyManagerCaller)(nil) + // ContractStrategyManagerTransactor is an auto generated write-only Go binding around an Ethereum contract. type ContractStrategyManagerTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractStrategyManagerTransactor implements the ContractStrategyManagerTransacts interface. +var _ ContractStrategyManagerTransacts = (*ContractStrategyManagerTransactor)(nil) + // ContractStrategyManagerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. type ContractStrategyManagerFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ContractStrategyManagerFilterer implements the ContractStrategyManagerFilters interface. +var _ ContractStrategyManagerFilters = (*ContractStrategyManagerFilterer)(nil) + // ContractStrategyManagerSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ContractStrategyManagerSession struct { diff --git a/contracts/generate-bindings.sh b/contracts/generate-bindings.sh index dc06f074..f30058c2 100755 --- a/contracts/generate-bindings.sh +++ b/contracts/generate-bindings.sh @@ -6,6 +6,12 @@ script_path=$( pwd -P ) +# build abigen-with-interfaces docker image if it doesn't exist +if [[ "$(docker images -q abigen-with-interfaces 2> /dev/null)" == "" ]]; then + docker build -t abigen-with-interfaces -f abigen-with-interfaces.Dockerfile $script_path +fi + +# TODO: refactor this function.. it got really ugly with the dockerizing of abigen function create_binding { contract_dir=$1 contract=$2 @@ -21,8 +27,8 @@ function create_binding { echo ${solc_bin} >data/tmp.bin rm -f $binding_dir/${contract}/binding.go - abigen --bin=data/tmp.bin --abi=data/tmp.abi --pkg=contract${contract} --out=$binding_dir/${contract}/binding.go - rm -rf ../data/tmp.abi ../data/tmp.bin + docker run -v $(realpath $binding_dir):/home/binding_dir -v .:/home/repo abigen-with-interfaces --bin=/home/repo/data/tmp.bin --abi=/home/repo/data/tmp.abi --pkg=contract${contract} --out=/home/binding_dir/${contract}/binding.go + rm -rf data/tmp.abi data/tmp.bin } EIGENLAYER_MIDDLEWARE_PATH=$script_path/lib/eigenlayer-middleware @@ -38,7 +44,9 @@ EIGENLAYER_CONTRACT_PATH=$EIGENLAYER_MIDDLEWARE_PATH/lib/eigenlayer-contracts cd $EIGENLAYER_CONTRACT_PATH forge build -el_contracts="DelegationManager Slasher StrategyManager IStrategy EigenPodManager EigenPod IERC20" +# No idea why but EigenPod needs to be right before EigenPodManager otherwise there's a bug and +# abigen fails... +el_contracts="DelegationManager Slasher StrategyManager IStrategy EigenPod EigenPodManager IERC20" for contract in $el_contracts; do create_binding . $contract ../../../../bindings done diff --git a/metrics/collectors/economic/economic.go b/metrics/collectors/economic/economic.go index 5336171a..5d8b7625 100644 --- a/metrics/collectors/economic/economic.go +++ b/metrics/collectors/economic/economic.go @@ -2,14 +2,14 @@ package economic import ( - "context" "errors" "strconv" - "github.com/Layr-Labs/eigensdk-go/chainio/avsregistry" - "github.com/Layr-Labs/eigensdk-go/chainio/elcontracts" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" "github.com/Layr-Labs/eigensdk-go/logging" "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" ) @@ -112,7 +112,7 @@ func (ec *Collector) Describe(ch chan<- *prometheus.Desc) { // initialize the operatorId if it hasn't already been initialized func (ec *Collector) initOperatorId() error { if ec.operatorId == [32]byte{} { - operatorId, err := ec.avsRegistryReader.GetOperatorId(context.Background(), ec.operatorAddr) + operatorId, err := ec.avsRegistryReader.GetOperatorId(&bind.CallOpts{}, ec.operatorAddr) if err != nil { ec.logger.Error("Failed to get operator id", "err", err) return err @@ -135,7 +135,7 @@ func (ec *Collector) Collect(ch chan<- prometheus.Metric) { // if we want instead to only output 1 if the operator has been slashed for a specific avs, we have 2 choices: // 1. keep this collector format but query the OperatorFrozen event from a subgraph // 2. subscribe to the event and keep a local state of whether the operator has been slashed, exporting it via normal prometheus instrumentation - operatorIsFrozen, err := ec.elReader.OperatorIsFrozen(context.Background(), ec.operatorAddr) + operatorIsFrozen, err := ec.elReader.OperatorIsFrozen(nil, ec.operatorAddr) if err != nil { ec.logger.Error("Failed to get slashing incurred", "err", err) } else { @@ -153,7 +153,7 @@ func (ec *Collector) Collect(ch chan<- prometheus.Metric) { } else { // probably should start using the avsregistry service instead of avsRegistryReader so that we can // swap out backend for a subgraph eventually - quorumStakeMap, err := ec.avsRegistryReader.GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock(context.Background(), ec.operatorId) + quorumStakeMap, err := ec.avsRegistryReader.GetOperatorStakeInQuorumsOfOperatorAtCurrentBlock(&bind.CallOpts{}, ec.operatorId) if err != nil { ec.logger.Error("Failed to get operator stake", "err", err) } else { diff --git a/metrics/eigenmetrics.go b/metrics/eigenmetrics.go index 846d11e4..af591e81 100644 --- a/metrics/eigenmetrics.go +++ b/metrics/eigenmetrics.go @@ -13,7 +13,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" ) -// Eigenmetrics contains instrumented metrics that should be incremented by the avs node using the methods below +// EigenMetrics contains instrumented metrics that should be incremented by the avs node using the methods below type EigenMetrics struct { ipPortAddress string logger logging.Logger diff --git a/metrics/eigenmetrics_example_test.go b/metrics/eigenmetrics_example_test.go index c3976072..5a088af0 100644 --- a/metrics/eigenmetrics_example_test.go +++ b/metrics/eigenmetrics_example_test.go @@ -6,17 +6,18 @@ package metrics_test import ( "context" + "math/big" - "github.com/Layr-Labs/eigensdk-go/chainio/avsregistry" - sdkclients "github.com/Layr-Labs/eigensdk-go/chainio/clients" + "github.com/Layr-Labs/eigensdk-go/chainio/clients" "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" - "github.com/Layr-Labs/eigensdk-go/chainio/elcontracts" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/metrics" "github.com/Layr-Labs/eigensdk-go/metrics/collectors/economic" - "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls" + rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls" + "github.com/Layr-Labs/eigensdk-go/signer" "github.com/Layr-Labs/eigensdk-go/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/prometheus/client_golang/prometheus" ) @@ -31,42 +32,30 @@ func ExampleEigenMetrics() { panic(err) } - reg := prometheus.NewRegistry() - eigenMetrics := metrics.NewEigenMetrics("exampleAvs", ":9090", reg, logger) - - slasherAddr := common.HexToAddress("0x0") - blsPubKeyCompendiumAddr := common.HexToAddress("0x0") - ethHttpClient, err := eth.NewClient("http://localhost:8545") + // get the Writer for the EL contracts + ecdsaPrivateKey, err := crypto.HexToECDSA("0x0") if err != nil { panic(err) } - ethWsClient, err := eth.NewClient("ws://localhost:8545") - if err != nil { - panic(err) - } - elContractsClient, err := sdkclients.NewELContractsChainClient(slasherAddr, blsPubKeyCompendiumAddr, ethHttpClient, ethWsClient, logger) - if err != nil { - panic(err) - } - eigenlayerReader, err := elcontracts.NewELChainReader(elContractsClient, logger, ethHttpClient) + privateKeySigner, err := signer.NewPrivateKeySigner(ecdsaPrivateKey, big.NewInt(1)) if err != nil { panic(err) } - blsRegistryCoordAddr := common.HexToAddress("0x0") - blsOperatorStateRetrieverAddr := common.HexToAddress("0x0") - stakeRegistry := common.HexToAddress("0x0") - blsPubkeyRegistryAddr := common.HexToAddress("0x0") - avsRegistryClients, err := sdkclients.NewAvsRegistryContractsChainClient( - blsRegistryCoordAddr, blsOperatorStateRetrieverAddr, stakeRegistry, blsPubkeyRegistryAddr, ethHttpClient, logger, - ) - if err != nil { - panic(err) + chainioConfig := clients.BuildAllConfig{ + EthHttpUrl: "http://localhost:8545", + EthWsUrl: "ws://localhost:8545", + BlsRegistryCoordinatorAddr: "0x0", + BlsOperatorStateRetrieverAddr: "0x0", + AvsName: "exampleAvs", + PromMetricsIpPortAddress: ":9090", } - avsRegistryReader, err := avsregistry.NewAvsRegistryReader(avsRegistryClients, logger, ethHttpClient) + clients, err := clients.BuildAll(chainioConfig, privateKeySigner, logger) if err != nil { panic(err) } + reg := prometheus.NewRegistry() + eigenMetrics := metrics.NewEigenMetrics("exampleAvs", ":9090", reg, logger) operatorAddr := common.HexToAddress("0x0") quorumNames := map[types.QuorumNum]string{ @@ -75,7 +64,7 @@ func ExampleEigenMetrics() { } // 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 - economicMetricsCollector := economic.NewCollector(eigenlayerReader, avsRegistryReader, "exampleAvs", logger, operatorAddr, quorumNames) + economicMetricsCollector := economic.NewCollector(clients.ElChainReader, clients.AvsRegistryChainReader, "exampleAvs", logger, operatorAddr, quorumNames) reg.MustRegister(economicMetricsCollector) rpcCallsCollector := rpccalls.NewCollector("exampleAvs", reg) diff --git a/services/avsregistry/avsregistry.go b/services/avsregistry/avsregistry.go index cbf67fb3..63627127 100644 --- a/services/avsregistry/avsregistry.go +++ b/services/avsregistry/avsregistry.go @@ -5,6 +5,7 @@ import ( blsoperatorstateretrievar "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" "github.com/Layr-Labs/eigensdk-go/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ) // AvsRegistryServicemService is a service that indexes the Avs Registry contracts and provides a way to query for operator state @@ -18,5 +19,5 @@ type AvsRegistryService interface { // This information is derivable from the Operators Avs State (returned from GetOperatorsAvsStateAtBlock), but this function is provided for convenience. GetQuorumsAvsStateAtBlock(ctx context.Context, quorumNumbers []types.QuorumNum, blockNumber types.BlockNum) (map[types.QuorumNum]types.QuorumAvsState, error) // GetCheckSignaturesIndices returns the registry indices of the nonsigner operators specified by nonSignerOperatorIds who were registered at referenceBlockNumber. - GetCheckSignaturesIndices(ctx context.Context, referenceBlockNumber types.BlockNum, quorumNumbers []types.QuorumNum, nonSignerOperatorIds []types.OperatorId) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) + GetCheckSignaturesIndices(opts *bind.CallOpts, referenceBlockNumber types.BlockNum, quorumNumbers []types.QuorumNum, nonSignerOperatorIds []types.OperatorId) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) } diff --git a/services/avsregistry/avsregistry_chaincaller.go b/services/avsregistry/avsregistry_chaincaller.go index bb46d18f..ac2f2531 100644 --- a/services/avsregistry/avsregistry_chaincaller.go +++ b/services/avsregistry/avsregistry_chaincaller.go @@ -4,12 +4,13 @@ import ( "context" "math/big" - avsregistry "github.com/Layr-Labs/eigensdk-go/chainio/avsregistry" - elcontracts "github.com/Layr-Labs/eigensdk-go/chainio/elcontracts" + avsregistry "github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry" + elcontracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/Layr-Labs/eigensdk-go/logging" pcservice "github.com/Layr-Labs/eigensdk-go/services/pubkeycompendium" "github.com/Layr-Labs/eigensdk-go/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ) // AvsRegistryServiceChainCaller is a wrapper around AvsRegistryReader that transforms the data into @@ -35,7 +36,7 @@ func NewAvsRegistryServiceChainCaller(avsRegistryReader avsregistry.AvsRegistryR func (ar *AvsRegistryServiceChainCaller) GetOperatorsAvsStateAtBlock(ctx context.Context, quorumNumbers []types.QuorumNum, blockNumber types.BlockNum) (map[types.OperatorId]types.OperatorAvsState, error) { operatorsAvsState := make(map[types.OperatorId]types.OperatorAvsState) // Get operator state for each quorum by querying BLSOperatorStateRetriever (this call is why this service implementation is called ChainCaller) - operatorsStakesInQuorums, err := ar.AvsRegistryReader.GetOperatorsStakeInQuorumsAtBlock(ctx, quorumNumbers, blockNumber) + operatorsStakesInQuorums, err := ar.AvsRegistryReader.GetOperatorsStakeInQuorumsAtBlock(&bind.CallOpts{Context: ctx}, quorumNumbers, blockNumber) if err != nil { ar.logger.Error("Failed to get operator state", "err", err, "service", "AvsRegistryServiceChainCaller") return nil, err @@ -106,7 +107,7 @@ func (ar *AvsRegistryServiceChainCaller) GetQuorumsAvsStateAtBlock(ctx context.C // When the above PR is merged, we should change this to instead call GetOperatorAddressFromOperatorId on the avsRegistryReader // and not hardcode the definition of the operatorId here func (ar *AvsRegistryServiceChainCaller) getOperatorPubkeys(ctx context.Context, operatorId types.OperatorId) (types.OperatorPubkeys, error) { - operatorAddr, err := ar.elReader.GetOperatorAddressFromPubkeyHash(ctx, operatorId) + operatorAddr, err := ar.elReader.GetOperatorAddressFromPubkeyHash(&bind.CallOpts{Context: ctx}, operatorId) if err != nil { ar.logger.Error("Failed to get operator address from pubkey hash", "err", err, "service", "AvsRegistryServiceChainCaller") return types.OperatorPubkeys{}, err diff --git a/services/avsregistry/avsregistry_chaincaller_test.go b/services/avsregistry/avsregistry_chaincaller_test.go index f58b92af..f3a19696 100644 --- a/services/avsregistry/avsregistry_chaincaller_test.go +++ b/services/avsregistry/avsregistry_chaincaller_test.go @@ -44,8 +44,8 @@ func TestAvsRegistryServiceChainCaller_getOperatorPubkeys(t *testing.T) { { name: "should return operatorpubkeys", mocksInitializationFunc: func(mockAvsRegistryReader *chainiomocks.MockAvsRegistryReader, mockElReader *chainiomocks.MockELReader, mockPubkeyCompendiumService *servicemocks.MockPubkeyCompendiumService) { - mockElReader.EXPECT().GetOperatorAddressFromPubkeyHash(context.Background(), testOperator.operatorId).Return(testOperator.operatorAddr, nil) - mockPubkeyCompendiumService.EXPECT().GetOperatorPubkeys(context.Background(), testOperator.operatorAddr).Return(testOperator.pubkeys, true) + mockElReader.EXPECT().GetOperatorAddressFromPubkeyHash(gomock.Any(), testOperator.operatorId).Return(testOperator.operatorAddr, nil) + mockPubkeyCompendiumService.EXPECT().GetOperatorPubkeys(gomock.Any(), testOperator.operatorAddr).Return(testOperator.pubkeys, true) }, queryOperatorId: testOperator.operatorId, wantErr: nil, @@ -101,7 +101,7 @@ func TestAvsRegistryServiceChainCaller_GetOperatorsAvsState(t *testing.T) { { name: "should return operatorsAvsState", mocksInitializationFunc: func(mockAvsRegistryReader *chainiomocks.MockAvsRegistryReader, mockElReader *chainiomocks.MockELReader, mockPubkeyCompendiumService *servicemocks.MockPubkeyCompendiumService) { - mockAvsRegistryReader.EXPECT().GetOperatorsStakeInQuorumsAtBlock(context.Background(), []types.QuorumNum{1}, types.BlockNum(1)).Return([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator{ + mockAvsRegistryReader.EXPECT().GetOperatorsStakeInQuorumsAtBlock(gomock.Any(), []types.QuorumNum{1}, types.BlockNum(1)).Return([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator{ { { OperatorId: testOperator.operatorId, @@ -109,8 +109,8 @@ func TestAvsRegistryServiceChainCaller_GetOperatorsAvsState(t *testing.T) { }, }, }, nil) - mockElReader.EXPECT().GetOperatorAddressFromPubkeyHash(context.Background(), testOperator.operatorId).Return(testOperator.operatorAddr, nil) - mockPubkeyCompendiumService.EXPECT().GetOperatorPubkeys(context.Background(), testOperator.operatorAddr).Return(testOperator.pubkeys, true) + mockElReader.EXPECT().GetOperatorAddressFromPubkeyHash(gomock.Any(), testOperator.operatorId).Return(testOperator.operatorAddr, nil) + mockPubkeyCompendiumService.EXPECT().GetOperatorPubkeys(gomock.Any(), testOperator.operatorAddr).Return(testOperator.pubkeys, true) }, queryQuorumNumbers: []types.QuorumNum{1}, queryBlockNum: 1, @@ -174,7 +174,7 @@ func TestAvsRegistryServiceChainCaller_GetQuorumsAvsState(t *testing.T) { { name: "should return operatorsAvsState", mocksInitializationFunc: func(mockAvsRegistryReader *chainiomocks.MockAvsRegistryReader, mockElReader *chainiomocks.MockELReader, mockPubkeyCompendiumService *servicemocks.MockPubkeyCompendiumService) { - mockAvsRegistryReader.EXPECT().GetOperatorsStakeInQuorumsAtBlock(context.Background(), []types.QuorumNum{1}, types.BlockNum(1)).Return([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator{ + mockAvsRegistryReader.EXPECT().GetOperatorsStakeInQuorumsAtBlock(gomock.Any(), []types.QuorumNum{1}, types.BlockNum(1)).Return([][]blsoperatorstateretrievar.BLSOperatorStateRetrieverOperator{ { { OperatorId: testOperator.operatorId, @@ -182,8 +182,8 @@ func TestAvsRegistryServiceChainCaller_GetQuorumsAvsState(t *testing.T) { }, }, }, nil) - mockElReader.EXPECT().GetOperatorAddressFromPubkeyHash(context.Background(), testOperator.operatorId).Return(testOperator.operatorAddr, nil) - mockPubkeyCompendiumService.EXPECT().GetOperatorPubkeys(context.Background(), testOperator.operatorAddr).Return(testOperator.pubkeys, true) + mockElReader.EXPECT().GetOperatorAddressFromPubkeyHash(gomock.Any(), testOperator.operatorId).Return(testOperator.operatorAddr, nil) + mockPubkeyCompendiumService.EXPECT().GetOperatorPubkeys(gomock.Any(), testOperator.operatorAddr).Return(testOperator.pubkeys, true) }, queryQuorumNumbers: []types.QuorumNum{1}, queryBlockNum: 1, diff --git a/services/avsregistry/avsregistry_fake.go b/services/avsregistry/avsregistry_fake.go index 25c22a8a..a3555752 100644 --- a/services/avsregistry/avsregistry_fake.go +++ b/services/avsregistry/avsregistry_fake.go @@ -8,6 +8,7 @@ import ( blsoperatorstateretrievar "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/Layr-Labs/eigensdk-go/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ) type FakeAvsRegistryService struct { @@ -67,6 +68,6 @@ func (f *FakeAvsRegistryService) GetQuorumsAvsStateAtBlock(ctx context.Context, return quorumsAvsState, nil } -func (f *FakeAvsRegistryService) GetCheckSignaturesIndices(ctx context.Context, referenceBlockNumber types.BlockNum, quorumNumbers []types.QuorumNum, nonSignerOperatorIds []types.OperatorId) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { +func (f *FakeAvsRegistryService) GetCheckSignaturesIndices(opts *bind.CallOpts, referenceBlockNumber types.BlockNum, quorumNumbers []types.QuorumNum, nonSignerOperatorIds []types.OperatorId) (blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { return blsoperatorstateretrievar.BLSOperatorStateRetrieverCheckSignaturesIndices{}, nil } diff --git a/services/bls_aggregation/blsagg.go b/services/bls_aggregation/blsagg.go index a529d002..54503b56 100644 --- a/services/bls_aggregation/blsagg.go +++ b/services/bls_aggregation/blsagg.go @@ -12,6 +12,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/services/avsregistry" "github.com/Layr-Labs/eigensdk-go/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ) var ( @@ -272,7 +273,7 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( nonSignersOperatorIds = append(nonSignersOperatorIds, operatorId) } } - indices, err := a.avsRegistryService.GetCheckSignaturesIndices(context.Background(), taskCreatedBlock, quorumNumbers, nonSignersOperatorIds) + indices, err := a.avsRegistryService.GetCheckSignaturesIndices(&bind.CallOpts{}, taskCreatedBlock, quorumNumbers, nonSignersOperatorIds) if err != nil { a.logger.Error("Failed to get check signatures indices", "err", err) a.aggregatedResponsesC <- BlsAggregationServiceResponse{ diff --git a/services/mocks/avsregistry.go b/services/mocks/avsregistry.go index 617fa60e..b0b58707 100644 --- a/services/mocks/avsregistry.go +++ b/services/mocks/avsregistry.go @@ -14,6 +14,7 @@ import ( contractBLSOperatorStateRetriever "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSOperatorStateRetriever" types "github.com/Layr-Labs/eigensdk-go/types" + bind "github.com/ethereum/go-ethereum/accounts/abi/bind" gomock "go.uber.org/mock/gomock" ) @@ -41,7 +42,7 @@ func (m *MockAvsRegistryService) EXPECT() *MockAvsRegistryServiceMockRecorder { } // GetCheckSignaturesIndices mocks base method. -func (m *MockAvsRegistryService) GetCheckSignaturesIndices(arg0 context.Context, arg1 uint32, arg2 []byte, arg3 [][32]byte) (contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { +func (m *MockAvsRegistryService) GetCheckSignaturesIndices(arg0 *bind.CallOpts, arg1 uint32, arg2 []byte, arg3 [][32]byte) (contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverCheckSignaturesIndices, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCheckSignaturesIndices", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(contractBLSOperatorStateRetriever.BLSOperatorStateRetrieverCheckSignaturesIndices) diff --git a/services/pubkeycompendium/pubkeycompendium_inmemory.go b/services/pubkeycompendium/pubkeycompendium_inmemory.go index 3ca3da94..eddb89c9 100644 --- a/services/pubkeycompendium/pubkeycompendium_inmemory.go +++ b/services/pubkeycompendium/pubkeycompendium_inmemory.go @@ -4,7 +4,7 @@ import ( "context" "sync" - sdkelcontracts "github.com/Layr-Labs/eigensdk-go/chainio/elcontracts" + sdkelcontracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/types" @@ -80,7 +80,7 @@ func (pkcs *PubkeyCompendiumServiceInMemory) startServiceInGoroutine(ctx context // see the warning above the struct definition to understand why we panic here panic(err) } - pkcs.queryPastRegisteredOperatorEventsAndFillDb(pubkeyDict) + pkcs.queryPastRegisteredOperatorEventsAndFillDb(ctx, pubkeyDict) // The constructor can return after we have backfilled the db by querying the events of operators that have registered with the pubkey compendium // before the block at which we started the ws subscription above wg.Done() @@ -118,10 +118,10 @@ func (pkcs *PubkeyCompendiumServiceInMemory) startServiceInGoroutine(ctx context }() } -func (pkcs *PubkeyCompendiumServiceInMemory) queryPastRegisteredOperatorEventsAndFillDb(pubkeydict map[common.Address]types.OperatorPubkeys) { +func (pkcs *PubkeyCompendiumServiceInMemory) queryPastRegisteredOperatorEventsAndFillDb(ctx context.Context, pubkeydict map[common.Address]types.OperatorPubkeys) { // Querying with nil startBlock and stopBlock will return all events. It doesn't matter if we query some events that we will receive again in the websocket, // since we will just overwrite the pubkey dict with the same values. - alreadyRegisteredOperatorAddrs, alreadyRegisteredOperatorPubkeys, err := pkcs.eigenlayerReader.QueryExistingRegisteredOperatorPubKeys(nil, nil) + alreadyRegisteredOperatorAddrs, alreadyRegisteredOperatorPubkeys, err := pkcs.eigenlayerReader.QueryExistingRegisteredOperatorPubKeys(ctx, nil, nil) if err != nil { pkcs.logger.Error("Fatal error querying existing registered operators", "err", err, "service", "PubkeyCompendiumServiceInMemory") panic(err) diff --git a/services/pubkeycompendium/pubkeycompendium_inmemory_test.go b/services/pubkeycompendium/pubkeycompendium_inmemory_test.go index 2993fa99..9d244579 100644 --- a/services/pubkeycompendium/pubkeycompendium_inmemory_test.go +++ b/services/pubkeycompendium/pubkeycompendium_inmemory_test.go @@ -56,7 +56,7 @@ func TestGetOperatorPubkeys(t *testing.T) { errC := make(chan error) mockSubscription.EXPECT().Err().AnyTimes().Return(errC) mockElSubscriber.EXPECT().SubscribeToNewPubkeyRegistrations().Return(nil, mockSubscription, nil) - mockElReader.EXPECT().QueryExistingRegisteredOperatorPubKeys(nil, nil).Return(nil, nil, nil) + mockElReader.EXPECT().QueryExistingRegisteredOperatorPubKeys(gomock.Any(), nil, nil).Return(nil, nil, nil) }, queryOperatorAddr: testOperator1.operatorAddr, wantOperatorFound: false, @@ -68,7 +68,7 @@ func TestGetOperatorPubkeys(t *testing.T) { errC := make(chan error) mockSubscription.EXPECT().Err().AnyTimes().Return(errC) mockElSubscriber.EXPECT().SubscribeToNewPubkeyRegistrations().Return(nil, mockSubscription, nil) - mockElReader.EXPECT().QueryExistingRegisteredOperatorPubKeys(nil, nil). + mockElReader.EXPECT().QueryExistingRegisteredOperatorPubKeys(gomock.Any(), nil, nil). Return([]common.Address{testOperator1.operatorAddr}, []types.OperatorPubkeys{testOperator1.pubkeys}, nil) }, queryOperatorAddr: testOperator1.operatorAddr, @@ -89,7 +89,7 @@ func TestGetOperatorPubkeys(t *testing.T) { pubkeyRegistrationEventC <- pubkeyRegistrationEvent mockSubscription.EXPECT().Err().AnyTimes().Return(errC) mockElSubscriber.EXPECT().SubscribeToNewPubkeyRegistrations().Return(pubkeyRegistrationEventC, mockSubscription, nil) - mockElReader.EXPECT().QueryExistingRegisteredOperatorPubKeys(nil, nil). + mockElReader.EXPECT().QueryExistingRegisteredOperatorPubKeys(gomock.Any(), nil, nil). Return([]common.Address{}, []types.OperatorPubkeys{}, nil) }, queryOperatorAddr: testOperator1.operatorAddr,