Skip to content

Commit

Permalink
remove slasher references in chainio and cmd, need to add allocation …
Browse files Browse the repository at this point in the history
…manager address references and update eigenpod bindings
  • Loading branch information
afkbyte committed Dec 23, 2024
1 parent afae647 commit 71be09a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 61 deletions.
27 changes: 0 additions & 27 deletions chainio/clients/elcontracts/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -149,11 +124,9 @@ func NewEigenlayerContractBindings(
}

return &ContractBindings{
SlasherAddr: slasherAddr,
StrategyManagerAddr: strategyManagerAddr,
DelegationManagerAddr: delegationManagerAddr,
AvsDirectoryAddr: avsDirectoryAddr,
Slasher: contractSlasher,
StrategyManager: contractStrategyManager,
DelegationManager: contractDelegationManager,
AvsDirectory: avsDirectory,
Expand Down
3 changes: 0 additions & 3 deletions chainio/clients/elcontracts/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func BuildReadClients(
}

elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand Down Expand Up @@ -54,7 +53,6 @@ func BuildClients(
}

elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -64,7 +62,6 @@ func BuildClients(
)

elChainWriter := NewChainWriter(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.RewardsCoordinator,
Expand Down
34 changes: 17 additions & 17 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -40,7 +38,6 @@ type ChainReader struct {
}

func NewChainReader(
slasher slasher.ContractISlasherCalls,
delegationManager *delegationmanager.ContractDelegationManager,
strategyManager *strategymanager.ContractStrategyManager,
avsDirectory *avsdirectory.ContractIAVSDirectory,
Expand All @@ -51,7 +48,6 @@ func NewChainReader(
logger = logger.With(logging.ComponentKey, "elcontracts/reader")

return &ChainReader{
slasher: slasher,
delegationManager: delegationManager,
strategyManager: strategyManager,
avsDirectory: avsDirectory,
Expand Down Expand Up @@ -79,7 +75,6 @@ func BuildELChainReader(
return nil, err
}
return NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -103,7 +98,6 @@ func NewReaderFromConfig(
return nil, err
}
return NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand Down Expand Up @@ -197,31 +191,37 @@ 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(
ctx context.Context,
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")
}
Expand Down
8 changes: 0 additions & 8 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -31,7 +30,6 @@ type Reader interface {
}

type ChainWriter struct {
slasher *slasher.ContractISlasher
delegationManager *delegationmanager.ContractDelegationManager
strategyManager *strategymanager.ContractStrategyManager
rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator
Expand All @@ -44,7 +42,6 @@ type ChainWriter struct {
}

func NewChainWriter(
slasher *slasher.ContractISlasher,
delegationManager *delegationmanager.ContractDelegationManager,
strategyManager *strategymanager.ContractStrategyManager,
rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator,
Expand All @@ -59,7 +56,6 @@ func NewChainWriter(
logger = logger.With(logging.ComponentKey, "elcontracts/writer")

return &ChainWriter{
slasher: slasher,
delegationManager: delegationManager,
strategyManager: strategyManager,
strategyManagerAddr: strategyManagerAddr,
Expand Down Expand Up @@ -92,7 +88,6 @@ func BuildELChainWriter(
return nil, err
}
elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -101,7 +96,6 @@ func BuildELChainWriter(
ethClient,
)
return NewChainWriter(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.RewardsCoordinator,
Expand Down Expand Up @@ -131,7 +125,6 @@ func NewWriterFromConfig(
return nil, err
}
elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -140,7 +133,6 @@ func NewWriterFromConfig(
ethClient,
)
return NewChainWriter(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.RewardsCoordinator,
Expand Down
1 change: 0 additions & 1 deletion cmd/egnaddrs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ $$$ egnaddrs --registry-coordinator 0x9E545E3C0baAB3E08CdfD552C960A1050f373042
},
"eigenlayer": {
"delegation-manager": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"slasher": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"strategy-manager": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"
},
"network": {
Expand Down
5 changes: 0 additions & 5 deletions cmd/egnaddrs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down

0 comments on commit 71be09a

Please sign in to comment.