Skip to content

Commit

Permalink
fix bug in constructor
Browse files Browse the repository at this point in the history
blsoperatorstateretriever was getting fetched wrong
  • Loading branch information
samlaf committed Oct 3, 2023
1 parent 5c9a0d9 commit a47fa58
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions chainio/constructor/constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
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"
blsRegistryCoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/BLSRegistryCoordinatorWithIndices"
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"
Expand All @@ -18,13 +19,13 @@ import (
)

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"`
blsPubKeyCompendiumAddr string `yaml:"bls_pubkey_compendium_address"`
avsName string `yaml:"avs_name"`
ipPortAddress string `yaml:"ip_port_address"`
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"`
ipPortAddress string `yaml:"ip_port_address"`
}

type Clients struct {
Expand Down Expand Up @@ -113,22 +114,32 @@ func (config *Config) buildElContractsChainClient(
ethWsClient eth.EthClient,
) (clients.ELContractsClient, error) {
blsRegistryCoordinatorAddr := gethcommon.HexToAddress(config.blsRegistryCoordinatorAddr)
contractBLSRegistryCoordWithIndices, err := blsRegistryCoordinator.NewContractBLSRegistryCoordinatorWithIndices(
contractBLSRegistryCoordWithIndices, err := blsregcoord.NewContractBLSRegistryCoordinatorWithIndices(
blsRegistryCoordinatorAddr,
ethHttpClient,
)
if err != nil {
logger.Error("Failed to fetch BLSRegistryCoordinatorWithIndices contract", "err", err)
return nil, err
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
}

blsPubKeyCompendiumAddr := gethcommon.HexToAddress(config.blsPubKeyCompendiumAddr)
elContractsChainClient, err := clients.NewELContractsChainClient(
slasherAddr,
blsPubKeyCompendiumAddr,
Expand Down Expand Up @@ -211,7 +222,7 @@ func (config *Config) buildAvsRegistryContractsChainClient(
ethHttpClient eth.EthClient,
) (clients.AVSRegistryContractsClient, error) {
blsRegistryCoordinatorAddr := gethcommon.HexToAddress(config.blsRegistryCoordinatorAddr)
contractBLSRegistryCoordWithIndices, err := blsRegistryCoordinator.NewContractBLSRegistryCoordinatorWithIndices(
contractBLSRegistryCoordWithIndices, err := blsregcoord.NewContractBLSRegistryCoordinatorWithIndices(
blsRegistryCoordinatorAddr,
ethHttpClient,
)
Expand All @@ -220,12 +231,6 @@ func (config *Config) buildAvsRegistryContractsChainClient(
return nil, err
}

blsOperatorStateRetrieverAddr, err := contractBLSRegistryCoordWithIndices.BlsPubkeyRegistry(&bind.CallOpts{})
if err != nil {
logger.Error("Failed to fetch BLSOperatorStateRetriever contract", "err", err)
return nil, err
}

stakeregistryAddr, err := contractBLSRegistryCoordWithIndices.StakeRegistry(&bind.CallOpts{})
if err != nil {
logger.Error("Failed to fetch StakeRegistry contract", "err", err)
Expand All @@ -240,7 +245,7 @@ func (config *Config) buildAvsRegistryContractsChainClient(

avsregistryContractsChainClient, err := clients.NewAVSContractsChainClient(
blsRegistryCoordinatorAddr,
blsOperatorStateRetrieverAddr,
gethcommon.HexToAddress(config.blsOperatorStateRetrieverAddr),
stakeregistryAddr,
blsPubkeyRegistryAddr,
ethHttpClient,
Expand Down

0 comments on commit a47fa58

Please sign in to comment.