From 71be09ace09b2803a801e4bd94abe2e532a5d0b3 Mon Sep 17 00:00:00 2001 From: afkbyte Date: Mon, 23 Dec 2024 14:08:46 -0500 Subject: [PATCH] remove slasher references in chainio and cmd, need to add allocation manager address references and update eigenpod bindings --- chainio/clients/elcontracts/bindings.go | 27 -------------------- chainio/clients/elcontracts/builder.go | 3 --- chainio/clients/elcontracts/reader.go | 34 ++++++++++++------------- chainio/clients/elcontracts/writer.go | 8 ------ cmd/egnaddrs/README.md | 1 - cmd/egnaddrs/main.go | 5 ---- 6 files changed, 17 insertions(+), 61 deletions(-) diff --git a/chainio/clients/elcontracts/bindings.go b/chainio/clients/elcontracts/bindings.go index 09318061..ee0b5543 100644 --- a/chainio/clients/elcontracts/bindings.go +++ b/chainio/clients/elcontracts/bindings.go @@ -10,7 +10,6 @@ import ( delegationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" avsdirectory "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IAVSDirectory" rewardscoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IRewardsCoordinator" - slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/ISlasher" strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/utils" @@ -21,12 +20,10 @@ import ( // Unclear 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 ContractBindings struct { - SlasherAddr gethcommon.Address StrategyManagerAddr gethcommon.Address DelegationManagerAddr gethcommon.Address AvsDirectoryAddr gethcommon.Address RewardsCoordinatorAddress gethcommon.Address - Slasher *slasher.ContractISlasher DelegationManager *delegationmanager.ContractDelegationManager StrategyManager *strategymanager.ContractStrategyManager AvsDirectory *avsdirectory.ContractIAVSDirectory @@ -42,9 +39,7 @@ func NewBindingsFromConfig( err error contractDelegationManager *delegationmanager.ContractDelegationManager - contractSlasher *slasher.ContractISlasher contractStrategyManager *strategymanager.ContractStrategyManager - slasherAddr gethcommon.Address strategyManagerAddr gethcommon.Address avsDirectory *avsdirectory.ContractIAVSDirectory rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator @@ -58,15 +53,6 @@ func NewBindingsFromConfig( return nil, utils.WrapError("Failed to create DelegationManager contract", err) } - slasherAddr, err = contractDelegationManager.Slasher(&bind.CallOpts{}) - if err != nil { - return nil, utils.WrapError("Failed to fetch Slasher address", err) - } - contractSlasher, err = slasher.NewContractISlasher(slasherAddr, client) - if err != nil { - return nil, utils.WrapError("Failed to fetch Slasher contract", err) - } - strategyManagerAddr, err = contractDelegationManager.StrategyManager(&bind.CallOpts{}) if err != nil { return nil, utils.WrapError("Failed to fetch StrategyManager address", err) @@ -96,12 +82,10 @@ func NewBindingsFromConfig( } return &ContractBindings{ - SlasherAddr: slasherAddr, StrategyManagerAddr: strategyManagerAddr, DelegationManagerAddr: cfg.DelegationManagerAddress, AvsDirectoryAddr: cfg.AvsDirectoryAddress, RewardsCoordinatorAddress: cfg.RewardsCoordinatorAddress, - Slasher: contractSlasher, StrategyManager: contractStrategyManager, DelegationManager: contractDelegationManager, AvsDirectory: avsDirectory, @@ -125,15 +109,6 @@ func NewEigenlayerContractBindings( return nil, utils.WrapError("Failed to create DelegationManager contract", err) } - slasherAddr, err := contractDelegationManager.Slasher(&bind.CallOpts{}) - if err != nil { - return nil, utils.WrapError("Failed to fetch Slasher address", err) - } - contractSlasher, err := slasher.NewContractISlasher(slasherAddr, ethclient) - if err != nil { - return nil, utils.WrapError("Failed to fetch Slasher contract", err) - } - strategyManagerAddr, err := contractDelegationManager.StrategyManager(&bind.CallOpts{}) if err != nil { return nil, utils.WrapError("Failed to fetch StrategyManager address", err) @@ -149,11 +124,9 @@ func NewEigenlayerContractBindings( } return &ContractBindings{ - SlasherAddr: slasherAddr, StrategyManagerAddr: strategyManagerAddr, DelegationManagerAddr: delegationManagerAddr, AvsDirectoryAddr: avsDirectoryAddr, - Slasher: contractSlasher, StrategyManager: contractStrategyManager, DelegationManager: contractDelegationManager, AvsDirectory: avsDirectory, diff --git a/chainio/clients/elcontracts/builder.go b/chainio/clients/elcontracts/builder.go index 60f546b9..ac390e55 100644 --- a/chainio/clients/elcontracts/builder.go +++ b/chainio/clients/elcontracts/builder.go @@ -25,7 +25,6 @@ func BuildReadClients( } elChainReader := NewChainReader( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, @@ -54,7 +53,6 @@ func BuildClients( } elChainReader := NewChainReader( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, @@ -64,7 +62,6 @@ func BuildClients( ) elChainWriter := NewChainWriter( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.RewardsCoordinator, diff --git a/chainio/clients/elcontracts/reader.go b/chainio/clients/elcontracts/reader.go index 410c972f..4bd311a7 100644 --- a/chainio/clients/elcontracts/reader.go +++ b/chainio/clients/elcontracts/reader.go @@ -15,7 +15,6 @@ import ( avsdirectory "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IAVSDirectory" erc20 "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IERC20" rewardscoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IRewardsCoordinator" - slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/ISlasher" strategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" "github.com/Layr-Labs/eigensdk-go/logging" @@ -31,7 +30,6 @@ type Config struct { type ChainReader struct { logger logging.Logger - slasher slasher.ContractISlasherCalls delegationManager *delegationmanager.ContractDelegationManager strategyManager *strategymanager.ContractStrategyManager avsDirectory *avsdirectory.ContractIAVSDirectory @@ -40,7 +38,6 @@ type ChainReader struct { } func NewChainReader( - slasher slasher.ContractISlasherCalls, delegationManager *delegationmanager.ContractDelegationManager, strategyManager *strategymanager.ContractStrategyManager, avsDirectory *avsdirectory.ContractIAVSDirectory, @@ -51,7 +48,6 @@ func NewChainReader( logger = logger.With(logging.ComponentKey, "elcontracts/reader") return &ChainReader{ - slasher: slasher, delegationManager: delegationManager, strategyManager: strategyManager, avsDirectory: avsDirectory, @@ -79,7 +75,6 @@ func BuildELChainReader( return nil, err } return NewChainReader( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, @@ -103,7 +98,6 @@ func NewReaderFromConfig( return nil, err } return NewChainReader( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, @@ -197,24 +191,29 @@ func (r *ChainReader) ServiceManagerCanSlashOperatorUntilBlock( operatorAddr gethcommon.Address, serviceManagerAddr gethcommon.Address, ) (uint32, error) { - if r.slasher == nil { - return uint32(0), errors.New("slasher contract not provided") - } - - return r.slasher.ContractCanSlashOperatorUntilBlock( - &bind.CallOpts{Context: ctx}, operatorAddr, serviceManagerAddr, - ) + // TODO: Replace logic with new + // if r.slasher == nil { + // return uint32(0), errors.New("slasher contract not provided") + // } + + // return r.slasher.ContractCanSlashOperatorUntilBlock( + // &bind.CallOpts{Context: ctx}, operatorAddr, serviceManagerAddr, + // ) + return uint32(0), nil } func (r *ChainReader) OperatorIsFrozen( ctx context.Context, operatorAddr gethcommon.Address, ) (bool, error) { - if r.slasher == nil { - return false, errors.New("slasher contract not provided") - } - return r.slasher.IsFrozen(&bind.CallOpts{Context: ctx}, operatorAddr) + // TODO: replace logic with new + // if r.slasher == nil { + // return false, errors.New("slasher contract not provided") + // } + + // return r.slasher.IsFrozen(&bind.CallOpts{Context: ctx}, operatorAddr) + return false, nil } func (r *ChainReader) GetOperatorSharesInStrategy( @@ -222,6 +221,7 @@ func (r *ChainReader) GetOperatorSharesInStrategy( operatorAddr gethcommon.Address, strategyAddr gethcommon.Address, ) (*big.Int, error) { + // todo: add the allocation manager stuff if r.delegationManager == nil { return &big.Int{}, errors.New("DelegationManager contract not provided") } diff --git a/chainio/clients/elcontracts/writer.go b/chainio/clients/elcontracts/writer.go index a4e45a81..f5c9a3f7 100644 --- a/chainio/clients/elcontracts/writer.go +++ b/chainio/clients/elcontracts/writer.go @@ -15,7 +15,6 @@ import ( avsdirectory "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IAVSDirectory" erc20 "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IERC20" rewardscoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IRewardsCoordinator" - slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/ISlasher" strategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy" strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" "github.com/Layr-Labs/eigensdk-go/logging" @@ -31,7 +30,6 @@ type Reader interface { } type ChainWriter struct { - slasher *slasher.ContractISlasher delegationManager *delegationmanager.ContractDelegationManager strategyManager *strategymanager.ContractStrategyManager rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator @@ -44,7 +42,6 @@ type ChainWriter struct { } func NewChainWriter( - slasher *slasher.ContractISlasher, delegationManager *delegationmanager.ContractDelegationManager, strategyManager *strategymanager.ContractStrategyManager, rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator, @@ -59,7 +56,6 @@ func NewChainWriter( logger = logger.With(logging.ComponentKey, "elcontracts/writer") return &ChainWriter{ - slasher: slasher, delegationManager: delegationManager, strategyManager: strategyManager, strategyManagerAddr: strategyManagerAddr, @@ -92,7 +88,6 @@ func BuildELChainWriter( return nil, err } elChainReader := NewChainReader( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, @@ -101,7 +96,6 @@ func BuildELChainWriter( ethClient, ) return NewChainWriter( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.RewardsCoordinator, @@ -131,7 +125,6 @@ func NewWriterFromConfig( return nil, err } elChainReader := NewChainReader( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.AvsDirectory, @@ -140,7 +133,6 @@ func NewWriterFromConfig( ethClient, ) return NewChainWriter( - elContractBindings.Slasher, elContractBindings.DelegationManager, elContractBindings.StrategyManager, elContractBindings.RewardsCoordinator, diff --git a/cmd/egnaddrs/README.md b/cmd/egnaddrs/README.md index dff085f0..33d2c108 100644 --- a/cmd/egnaddrs/README.md +++ b/cmd/egnaddrs/README.md @@ -30,7 +30,6 @@ $$$ egnaddrs --registry-coordinator 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 }, "eigenlayer": { "delegation-manager": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", - "slasher": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", "strategy-manager": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" }, "network": { diff --git a/cmd/egnaddrs/main.go b/cmd/egnaddrs/main.go index 3d71d8fd..444f8738 100644 --- a/cmd/egnaddrs/main.go +++ b/cmd/egnaddrs/main.go @@ -210,17 +210,12 @@ func getEigenlayerContractAddrs( if err != nil { return nil, err } - slasherAddr, err := delegationManagerC.Slasher(&bind.CallOpts{}) - if err != nil { - return nil, err - } strategyManagerAddr, err := delegationManagerC.StrategyManager(&bind.CallOpts{}) if err != nil { return nil, err } addrsDict := map[string]string{ - "slasher": slasherAddr.Hex(), "delegation-manager": delegationManagerAddr.Hex(), "strategy-manager": strategyManagerAddr.Hex(), }