Skip to content

Commit

Permalink
feat: modularize bindings generation
Browse files Browse the repository at this point in the history
make improve

init

address comments

address comments

slashing push

working slashing

update contracts submodules

update to new AM

fix test

update to remove slasher and into AM

feat: add new funcs (#382)

Co-authored-by: Madhur Shrimal <[email protected]>

update contracts submodules

update contracts submodules

update with latest methods

rebase

update to ctx

change name

address comments

more methods

rebase and new changes

fix reader tests

fix reader tests

fmt

Updating core bindings and adding UserCanCall for UAM.

Adding PermissionController binding to binding constructors.

Adding list users and list permissions APIs to EL reader.

fix: anvil setup (#400)

Updating bindings and adding appointee remove & set implementations.

Fixing import ordering and returning tx receipt for appointee mutations.

Adding IsPendingAdmin & IsAdmin read APIs.

Adding admin mutation request types and APIs to writer implementation.

Updating based on make fmt results.

Updating user naming to appointee.
  • Loading branch information
shrimalmadhur committed Dec 12, 2024
1 parent 7211728 commit 953e000
Show file tree
Hide file tree
Showing 41 changed files with 10,413 additions and 4,101 deletions.
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 AVSDirectory AllocationManager PermissionController"
core_location := "./lib/eigenlayer-middleware/lib/eigenlayer-contracts"
core_bindings_location := "../../../../bindings"

Expand Down
63 changes: 32 additions & 31 deletions chainio/clients/elcontracts/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
package elcontracts

import (
permissioncontroller "github.com/Layr-Labs/eigensdk-go/contracts/bindings/PermissionController"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
gethcommon "github.com/ethereum/go-ethereum/common"

"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
avsdirectory "github.com/Layr-Labs/eigensdk-go/contracts/bindings/AVSDirectory"
allocationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/AllocationManager"
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,16 +22,17 @@ 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
AllocationManagerAddr gethcommon.Address
DelegationManager *delegationmanager.ContractDelegationManager
StrategyManager *strategymanager.ContractStrategyManager
AvsDirectory *avsdirectory.ContractIAVSDirectory
AvsDirectory *avsdirectory.ContractAVSDirectory
RewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator
AllocationManager *allocationmanager.ContractAllocationManager
PermissionController *permissioncontroller.ContractPermissionController
}

func NewBindingsFromConfig(
Expand All @@ -42,12 +44,13 @@ func NewBindingsFromConfig(
err error

contractDelegationManager *delegationmanager.ContractDelegationManager
contractSlasher *slasher.ContractISlasher
contractStrategyManager *strategymanager.ContractStrategyManager
slasherAddr gethcommon.Address
contractAllocationManager *allocationmanager.ContractAllocationManager
strategyManagerAddr gethcommon.Address
avsDirectory *avsdirectory.ContractIAVSDirectory
allocationManagerAddr gethcommon.Address
avsDirectory *avsdirectory.ContractAVSDirectory
rewardsCoordinator *rewardscoordinator.ContractIRewardsCoordinator
permissionController *permissioncontroller.ContractPermissionController
)

if isZeroAddress(cfg.DelegationManagerAddress) {
Expand All @@ -58,29 +61,37 @@ func NewBindingsFromConfig(
return nil, utils.WrapError("Failed to create DelegationManager contract", err)
}

slasherAddr, err = contractDelegationManager.Slasher(&bind.CallOpts{})
strategyManagerAddr, err = contractDelegationManager.StrategyManager(&bind.CallOpts{})
if err != nil {
return nil, utils.WrapError("Failed to fetch Slasher address", err)
return nil, utils.WrapError("Failed to fetch StrategyManager address", err)
}
contractSlasher, err = slasher.NewContractISlasher(slasherAddr, client)
contractStrategyManager, err = strategymanager.NewContractStrategyManager(strategyManagerAddr, client)
if err != nil {
return nil, utils.WrapError("Failed to fetch Slasher contract", err)
return nil, utils.WrapError("Failed to fetch StrategyManager contract", err)
}

strategyManagerAddr, err = contractDelegationManager.StrategyManager(&bind.CallOpts{})
allocationManagerAddr, err = contractDelegationManager.AllocationManager(&bind.CallOpts{})
if err != nil {
return nil, utils.WrapError("Failed to fetch StrategyManager address", err)
return nil, utils.WrapError("Failed to fetch AllocationManager address", err)
}
contractStrategyManager, err = strategymanager.NewContractStrategyManager(strategyManagerAddr, client)
contractAllocationManager, err = allocationmanager.NewContractAllocationManager(allocationManagerAddr, client)
if err != nil {
return nil, utils.WrapError("Failed to fetch StrategyManager contract", err)
return nil, utils.WrapError("Failed to fetch AllocationManager contract", err)
}
}

permissionController, err = permissioncontroller.NewContractPermissionController(
cfg.PermissionsControllerAddress,
client,
)
if err != nil {
return nil, utils.WrapError("Failed to fetch RewardsCoordinator contract", err)
}

if isZeroAddress(cfg.AvsDirectoryAddress) {
logger.Debug("AVSDirectory address not provided, the calls to the contract will not work")
} else {
avsDirectory, err = avsdirectory.NewContractIAVSDirectory(cfg.AvsDirectoryAddress, client)
avsDirectory, err = avsdirectory.NewContractAVSDirectory(cfg.AvsDirectoryAddress, client)
if err != nil {
return nil, utils.WrapError("Failed to fetch AVSDirectory contract", err)
}
Expand All @@ -96,16 +107,17 @@ 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,
RewardsCoordinator: rewardsCoordinator,
AllocationManager: contractAllocationManager,
AllocationManagerAddr: allocationManagerAddr,
PermissionController: permissionController,
}, nil
}
func isZeroAddress(address gethcommon.Address) bool {
Expand All @@ -125,15 +137,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 @@ -143,17 +146,15 @@ func NewEigenlayerContractBindings(
return nil, utils.WrapError("Failed to fetch StrategyManager contract", err)
}

avsDirectory, err := avsdirectory.NewContractIAVSDirectory(avsDirectoryAddr, ethclient)
avsDirectory, err := avsdirectory.NewContractAVSDirectory(avsDirectoryAddr, ethclient)
if err != nil {
return nil, utils.WrapError("Failed to fetch AVSDirectory contract", err)
}

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

elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
elContractBindings.RewardsCoordinator,
elContractBindings.AllocationManager,
elContractBindings.PermissionController,
logger,
client,
)
Expand All @@ -54,21 +55,23 @@ func BuildClients(
}

elChainReader := NewChainReader(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.AvsDirectory,
elContractBindings.RewardsCoordinator,
elContractBindings.AllocationManager,
elContractBindings.PermissionController,
logger,
client,
)

elChainWriter := NewChainWriter(
elContractBindings.Slasher,
elContractBindings.DelegationManager,
elContractBindings.StrategyManager,
elContractBindings.RewardsCoordinator,
elContractBindings.AvsDirectory,
elContractBindings.AllocationManager,
elContractBindings.PermissionController,
elContractBindings.StrategyManagerAddr,
elChainReader,
client,
Expand Down
Loading

0 comments on commit 953e000

Please sign in to comment.