Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in chainio/clients/elcontracts/bindings.go to fix compatibility issue #418

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ lint: ## runs all linters

___BINDINGS___: ##

core_default := "DelegationManager IRewardsCoordinator ISlasher StrategyManager EigenPod EigenPodManager IStrategy IAVSDirectory"
core_default := "DelegationManager IRewardsCoordinator StrategyManager EigenPod EigenPodManager IStrategy IAVSDirectory"
core_location := "./lib/eigenlayer-middleware/lib/eigenlayer-contracts"
core_bindings_location := "../../../../bindings"

Expand Down
24 changes: 0 additions & 24 deletions chainio/clients/elcontracts/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,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 +56,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 +85,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 +112,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 +127,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
30 changes: 5 additions & 25 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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 ChainReader struct {
logger logging.Logger
slasher slasher.ContractISlasherCalls
delegationManager *delegationmanager.ContractDelegationManager
strategyManager *strategymanager.ContractStrategyManager
avsDirectory *avsdirectory.ContractIAVSDirectory
Expand All @@ -40,7 +38,6 @@
}

func NewChainReader(
slasher slasher.ContractISlasherCalls,
delegationManager *delegationmanager.ContractDelegationManager,
strategyManager *strategymanager.ContractStrategyManager,
avsDirectory *avsdirectory.ContractIAVSDirectory,
Expand All @@ -51,7 +48,6 @@
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 @@
return nil, err
}
return NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -103,7 +98,6 @@
return nil, err
}
return NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand Down Expand Up @@ -140,7 +134,7 @@
return types.Operator{}, errors.New("DelegationManager contract not provided")
}

operatorDetails, err := r.delegationManager.OperatorDetails(

Check failure on line 137 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Test

r.delegationManager.OperatorDetails undefined (type *contractDelegationManager.ContractDelegationManager has no field or method OperatorDetails)

Check failure on line 137 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Lint

r.delegationManager.OperatorDetails undefined (type *contractDelegationManager.ContractDelegationManager has no field or method OperatorDetails)
&bind.CallOpts{Context: ctx},
gethcommon.HexToAddress(operator.Address),
)
Expand Down Expand Up @@ -192,29 +186,15 @@
return contractStrategy, contractUnderlyingToken, underlyingTokenAddr, nil
}

func (r *ChainReader) ServiceManagerCanSlashOperatorUntilBlock(
ctx context.Context,
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,
)
}

// NOTE: this function is kept for backward compatibility and
// should be removed in the future
//
// TODO: remove this function
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)
return false, nil
}

func (r *ChainReader) GetOperatorSharesInStrategy(
Expand Down Expand Up @@ -293,9 +273,9 @@

func (r *ChainReader) GetCurrentClaimableDistributionRoot(
ctx context.Context,
) (rewardscoordinator.IRewardsCoordinatorDistributionRoot, error) {

Check failure on line 276 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Test

undefined: rewardscoordinator.IRewardsCoordinatorDistributionRoot

Check failure on line 276 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: rewardscoordinator.IRewardsCoordinatorDistributionRoot
if r.rewardsCoordinator == nil {
return rewardscoordinator.IRewardsCoordinatorDistributionRoot{}, errors.New(

Check failure on line 278 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Test

undefined: rewardscoordinator.IRewardsCoordinatorDistributionRoot

Check failure on line 278 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: rewardscoordinator.IRewardsCoordinatorDistributionRoot
"RewardsCoordinator contract not provided",
)
}
Expand Down Expand Up @@ -328,7 +308,7 @@

func (r *ChainReader) CheckClaim(
ctx context.Context,
claim rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,

Check failure on line 311 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Test

undefined: rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim

Check failure on line 311 in chainio/clients/elcontracts/reader.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim
) (bool, error) {
if r.rewardsCoordinator == nil {
return false, errors.New("RewardsCoordinator contract not provided")
Expand Down
9 changes: 0 additions & 9 deletions chainio/clients/elcontracts/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ func TestChainReader(t *testing.T) {
assert.NotEmpty(t, tokenName)
})

t.Run("service manager can slash operator until block", func(t *testing.T) {
_, err := clients.ElChainReader.ServiceManagerCanSlashOperatorUntilBlock(
ctx,
common.HexToAddress(operator.Address),
contractAddrs.ServiceManager,
)
assert.NoError(t, err)
})

t.Run("operator is frozen", func(t *testing.T) {
isFrozen, err := clients.ElChainReader.OperatorIsFrozen(
ctx,
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 @@
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 ChainWriter struct {
slasher *slasher.ContractISlasher
delegationManager *delegationmanager.ContractDelegationManager
strategyManager *strategymanager.ContractStrategyManager
rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator
Expand All @@ -44,7 +42,6 @@
}

func NewChainWriter(
slasher *slasher.ContractISlasher,
delegationManager *delegationmanager.ContractDelegationManager,
strategyManager *strategymanager.ContractStrategyManager,
rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator,
Expand All @@ -59,7 +56,6 @@
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 @@
return nil, err
}
elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -101,7 +96,6 @@
ethClient,
)
return NewChainWriter(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.RewardsCoordinator,
Expand Down Expand Up @@ -131,7 +125,6 @@
return nil, err
}
elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
Expand All @@ -140,7 +133,6 @@
ethClient,
)
return NewChainWriter(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.RewardsCoordinator,
Expand All @@ -164,7 +156,7 @@
}

w.logger.Infof("registering operator %s to EigenLayer", operator.Address)
opDetails := delegationmanager.IDelegationManagerOperatorDetails{

Check failure on line 159 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Test

undefined: delegationmanager.IDelegationManagerOperatorDetails

Check failure on line 159 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: delegationmanager.IDelegationManagerOperatorDetails
// Earning receiver has been deprecated, so we just use the operator address as a dummy value
// Any reward related setup is via RewardsCoordinator contract
DeprecatedEarningsReceiver: gethcommon.HexToAddress(operator.Address),
Expand All @@ -176,7 +168,7 @@
if err != nil {
return nil, err
}
tx, err := w.delegationManager.RegisterAsOperator(noSendTxOpts, opDetails, operator.MetadataUrl)

Check failure on line 171 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Test

not enough arguments in call to w.delegationManager.RegisterAsOperator

Check failure on line 171 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to w.delegationManager.RegisterAsOperator
if err != nil {
return nil, err
}
Expand All @@ -199,7 +191,7 @@
}

w.logger.Infof("updating operator details of operator %s to EigenLayer", operator.Address)
opDetails := delegationmanager.IDelegationManagerOperatorDetails{

Check failure on line 194 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Test

undefined: delegationmanager.IDelegationManagerOperatorDetails

Check failure on line 194 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: delegationmanager.IDelegationManagerOperatorDetails
// Earning receiver has been deprecated, so we just use the operator address as a dummy value
// Any reward related setup is via RewardsCoordinator contract
DeprecatedEarningsReceiver: gethcommon.HexToAddress(operator.Address),
Expand All @@ -212,7 +204,7 @@
return nil, err
}

tx, err := w.delegationManager.ModifyOperatorDetails(noSendTxOpts, opDetails)

Check failure on line 207 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Test

not enough arguments in call to w.delegationManager.ModifyOperatorDetails

Check failure on line 207 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to w.delegationManager.ModifyOperatorDetails
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -332,7 +324,7 @@

func (w *ChainWriter) ProcessClaim(
ctx context.Context,
claim rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,

Check failure on line 327 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Test

undefined: rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim

Check failure on line 327 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim
earnerAddress gethcommon.Address,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
Expand Down Expand Up @@ -414,7 +406,7 @@

func (w *ChainWriter) ProcessClaims(
ctx context.Context,
claims []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,

Check failure on line 409 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Test

undefined: rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim

Check failure on line 409 in chainio/clients/elcontracts/writer.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim
earnerAddress gethcommon.Address,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/bindings/BLSApkRegistry/binding.go

Large diffs are not rendered by default.

2,286 changes: 1,033 additions & 1,253 deletions contracts/bindings/DelegationManager/binding.go

Large diffs are not rendered by default.

Loading
Loading