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

feat: update middleware submodule to v1.0.3-testnet-slashing release #478

Merged
merged 47 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e3e6909
feat: prefix registration parameters with type
MegaRedHand Jan 27, 2025
a741bd2
feat: make encoding function public
MegaRedHand Jan 27, 2025
4a10928
feat: add registration type prefix to registration
MegaRedHand Jan 27, 2025
a7b90f5
test: add test for abi encoding
MegaRedHand Jan 27, 2025
9ead4b5
refactor: move new type to types module
MegaRedHand Jan 27, 2025
14b1c1c
chore: lint
MegaRedHand Jan 27, 2025
bd21097
chore: re-add imports
MegaRedHand Jan 27, 2025
b15c586
feat: update middleware reference to v1.0.3
MegaRedHand Jan 28, 2025
b527bf2
chore: format contracts
MegaRedHand Jan 28, 2025
5564687
chore: update SDK contracts
MegaRedHand Jan 28, 2025
4a22a66
feat: update bindings list
MegaRedHand Jan 28, 2025
331ef2d
chore: regenerate bindings
MegaRedHand Jan 28, 2025
d893423
fix: update initialize calls
MegaRedHand Jan 28, 2025
485bbc1
chore: regenerate anvil state dump
MegaRedHand Jan 28, 2025
94581cc
fix: update types to use new Types interfaces
MegaRedHand Jan 28, 2025
1ada8d8
fix: use correct path when cleaning bindings
MegaRedHand Jan 28, 2025
8ad2301
chore: regenerate bindings
MegaRedHand Jan 28, 2025
3b7510a
chore: re-add MockAvsServiceManager
MegaRedHand Jan 28, 2025
d4e3e91
fix: update contracts
MegaRedHand Jan 28, 2025
f6b52e6
chore: regenerate bindings
MegaRedHand Jan 28, 2025
2507e8b
fix: update types to new interface
MegaRedHand Jan 28, 2025
527fb4d
feat: set permissions on deploy script
MegaRedHand Jan 28, 2025
f4a08d9
chore: regenerate state dump
MegaRedHand Jan 28, 2025
9f81a7f
fix: make serviceManager field optional
MegaRedHand Jan 29, 2025
fb06a7f
refactor: change name of new function
MegaRedHand Jan 29, 2025
821f5d1
fix: move service manager address to Config
MegaRedHand Jan 29, 2025
eeddc01
fix: use cfg address and set in test
MegaRedHand Jan 29, 2025
94b2951
feat: add new config to builder
MegaRedHand Jan 29, 2025
67671f4
feat: add log message when service manager address is missing
MegaRedHand Jan 29, 2025
c41b4dd
revert: use RegistryCoordinator instead of Slashing one
MegaRedHand Jan 29, 2025
6e12b49
test: change deployed coordinator to RegistryCoordinator
MegaRedHand Jan 29, 2025
bacb663
chore: regenerate state dump
MegaRedHand Jan 29, 2025
a6e5901
feat: add LegacyRegistryCoordinator
MegaRedHand Jan 29, 2025
7d7344f
feat: return to M2 expected state for RegistryCoordinator
MegaRedHand Jan 29, 2025
a3ee1c6
chore: regenerate state dump
MegaRedHand Jan 29, 2025
80179de
Merge branch 'dev' into registration-params-prefix
MegaRedHand Jan 29, 2025
05d0c8a
fix: add service manager to config
MegaRedHand Jan 29, 2025
f342358
fix: set the service manager as AVS address
MegaRedHand Jan 30, 2025
957067d
fix: remove unused variable
MegaRedHand Jan 30, 2025
10d4b8e
fix: add service manager address to the config
MegaRedHand Jan 30, 2025
436390e
chore: regenerate state dump
MegaRedHand Jan 30, 2025
ad36295
chore: revert license change on contract
MegaRedHand Jan 30, 2025
dc8b031
chore: remove commented code
MegaRedHand Jan 30, 2025
83391c4
Merge branch 'dev' into registration-params-prefix
MegaRedHand Jan 30, 2025
4bcbde7
Merge branch 'dev' into registration-params-prefix
MegaRedHand Feb 3, 2025
5feb7d1
Merge branch 'dev' into registration-params-prefix
MegaRedHand Feb 4, 2025
536054a
Merge branch 'dev' into registration-params-prefix
MegaRedHand Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ core_default := "DelegationManager IRewardsCoordinator StrategyManager EigenPod
core_location := "./lib/eigenlayer-middleware/lib/eigenlayer-contracts"
core_bindings_location := "../../../../bindings"

middleware_default := "RegistryCoordinator IndexRegistry OperatorStateRetriever StakeRegistry BLSApkRegistry IBLSSignatureChecker ServiceManagerBase IERC20"
middleware_default := "RegistryCoordinator SlashingRegistryCoordinator IndexRegistry OperatorStateRetriever StakeRegistry BLSApkRegistry SocketRegistry IBLSSignatureChecker ServiceManagerBase IERC20"
middleware_location := "./lib/eigenlayer-middleware"
middleware_bindings_location := "../../bindings"

Expand Down Expand Up @@ -113,7 +113,7 @@ eigenpod-bindings: ## generates contract bindings for eigenpod

.PHONY: bindings
bindings: ## generates all contract bindings
rm -rf bindings/* && make core-bindings middleware-bindings sdk-bindings eigenpod-bindings
rm -rf contracts/bindings/* && make core-bindings middleware-bindings sdk-bindings eigenpod-bindings


___CONTRACTS___: ##
Expand Down
36 changes: 18 additions & 18 deletions chainio/clients/avsregistry/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func NewBindingsFromConfig(
var (
err error

serviceManagerAddr gethcommon.Address
stakeRegistryAddr gethcommon.Address
blsApkRegistryAddr gethcommon.Address
indexRegistryAddr gethcommon.Address
Expand All @@ -74,18 +73,6 @@ func NewBindingsFromConfig(
return nil, utils.WrapError("Failed to create BLSRegistryCoordinator contract", err)
}

serviceManagerAddr, err = contractBlsRegistryCoordinator.ServiceManager(&bind.CallOpts{})
if err != nil {
return nil, utils.WrapError("Failed to fetch ServiceManager address", err)
}
contractServiceManager, err = servicemanager.NewContractServiceManagerBase(
serviceManagerAddr,
client,
)
if err != nil {
return nil, utils.WrapError("Failed to create ServiceManager contract", err)
}

stakeRegistryAddr, err = contractBlsRegistryCoordinator.StakeRegistry(&bind.CallOpts{})
if err != nil {
return nil, utils.WrapError("Failed to fetch StakeRegistry address", err)
Expand Down Expand Up @@ -123,10 +110,6 @@ func NewBindingsFromConfig(
if err != nil {
return nil, utils.WrapError("Failed to get DelegationManager address", err)
}
avsDirectoryAddr, err = contractServiceManager.AvsDirectory(&bind.CallOpts{})
if err != nil {
return nil, utils.WrapError("Failed to get AvsDirectory address", err)
}

delegationManager, err := contractDelegationManager.NewContractDelegationManager(
delegationManagerAddr,
Expand All @@ -140,6 +123,23 @@ func NewBindingsFromConfig(
}
}

if isZeroAddress(cfg.ServiceManagerAddress) {
logger.Debug("ServiceManager address not provided, the calls to the contract will not work")
} else {
contractServiceManager, err = servicemanager.NewContractServiceManagerBase(
cfg.ServiceManagerAddress,
client,
)
if err != nil {
return nil, utils.WrapError("Failed to create ServiceManager contract", err)
}

avsDirectoryAddr, err = contractServiceManager.AvsDirectory(&bind.CallOpts{})
if err != nil {
return nil, utils.WrapError("Failed to get AvsDirectory address", err)
}
}

if isZeroAddress(cfg.OperatorStateRetrieverAddress) {
logger.Debug("OperatorStateRetriever address not provided, the calls to the contract will not work")
} else {
Expand All @@ -154,7 +154,7 @@ func NewBindingsFromConfig(
}

return &ContractBindings{
ServiceManagerAddr: serviceManagerAddr,
ServiceManagerAddr: cfg.ServiceManagerAddress,
RegistryCoordinatorAddr: cfg.RegistryCoordinatorAddress,
StakeRegistryAddr: stakeRegistryAddr,
BlsApkRegistryAddr: blsApkRegistryAddr,
Expand Down
3 changes: 3 additions & 0 deletions chainio/clients/avsregistry/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ var DefaultQueryBlockRange = big.NewInt(10_000)
type Config struct {
RegistryCoordinatorAddress common.Address
OperatorStateRetrieverAddress common.Address

/// The address of the ServiceManager contract.
ServiceManagerAddress common.Address
}

// The ChainReader provides methods to call the
Expand Down
22 changes: 11 additions & 11 deletions chainio/clients/avsregistry/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (w *ChainWriter) RegisterOperatorInQuorumWithAVSRegistryCoordinator(
)
G1pubkeyBN254 := chainioutils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1())
G2pubkeyBN254 := chainioutils.ConvertToBN254G2Point(blsKeyPair.GetPubKeyG2())
pubkeyRegParams := regcoord.IBLSApkRegistryPubkeyRegistrationParams{
pubkeyRegParams := regcoord.IBLSApkRegistryTypesPubkeyRegistrationParams{
PubkeyRegistrationSignature: signedMsg,
PubkeyG1: G1pubkeyBN254,
PubkeyG2: G2pubkeyBN254,
Expand Down Expand Up @@ -260,15 +260,15 @@ func (w *ChainWriter) RegisterOperator(
)
G1pubkeyBN254 := chainioutils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1())
G2pubkeyBN254 := chainioutils.ConvertToBN254G2Point(blsKeyPair.GetPubKeyG2())
pubkeyRegParams := regcoord.IBLSApkRegistryPubkeyRegistrationParams{
pubkeyRegParams := regcoord.IBLSApkRegistryTypesPubkeyRegistrationParams{
PubkeyRegistrationSignature: signedMsg,
PubkeyG1: G1pubkeyBN254,
PubkeyG2: G2pubkeyBN254,
}

// generate a random salt and 1 hour expiry for the signature
var operatorToAvsRegistrationSigSalt [32]byte
_, err = rand.Read(operatorToAvsRegistrationSigSalt[:])
var signatureSalt [32]byte
_, err = rand.Read(signatureSalt[:])
if err != nil {
return nil, err
}
Expand All @@ -282,17 +282,17 @@ func (w *ChainWriter) RegisterOperator(
return nil, err
}
sigValidForSeconds := int64(60 * 60) // 1 hour
operatorToAvsRegistrationSigExpiry := new(
big.Int,
).Add(new(big.Int).SetUint64(curBlock.Time()), big.NewInt(sigValidForSeconds))

curTime := new(big.Int).SetUint64(curBlock.Time())
signatureExpiry := new(big.Int).Add(curTime, big.NewInt(sigValidForSeconds))

// params to register operator in delegation manager's operator-avs mapping
msgToSign, err := w.elReader.CalculateOperatorAVSRegistrationDigestHash(
ctx,
operatorAddr,
w.serviceManagerAddr,
operatorToAvsRegistrationSigSalt,
operatorToAvsRegistrationSigExpiry,
signatureSalt,
signatureExpiry,
)
if err != nil {
return nil, err
Expand All @@ -307,8 +307,8 @@ func (w *ChainWriter) RegisterOperator(
operatorSignature[64] += 27
operatorSignatureWithSaltAndExpiry := regcoord.ISignatureUtilsSignatureWithSaltAndExpiry{
Signature: operatorSignature,
Salt: operatorToAvsRegistrationSigSalt,
Expiry: operatorToAvsRegistrationSigExpiry,
Salt: signatureSalt,
Expiry: signatureExpiry,
}

noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
Expand Down
1 change: 1 addition & 0 deletions chainio/clients/avsregistry/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestWriterMethods(t *testing.T) {
config := avsregistry.Config{
RegistryCoordinatorAddress: contractAddrs.RegistryCoordinator,
OperatorStateRetrieverAddress: contractAddrs.OperatorStateRetriever,
ServiceManagerAddress: contractAddrs.ServiceManager,
}

chainWriter, err := testclients.NewTestAvsRegistryWriterFromConfig(anvilHttpEndpoint, operatorPrivateKeyHex, config)
Expand Down
31 changes: 23 additions & 8 deletions chainio/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type BuildAllConfig struct {
OperatorStateRetrieverAddr string
AvsName string
PromMetricsIpPortAddress string

/// The address of the ServiceManager contract.
ServiceManagerAddress string
}

// ReadClients is a struct that holds only the read clients for interacting with the AVS and EL contracts.
Expand Down Expand Up @@ -77,12 +80,17 @@ func BuildReadClients(
return nil, utils.WrapError("Failed to create Eth WS client", err)
}

avsCfg := avsregistry.Config{
RegistryCoordinatorAddress: gethcommon.HexToAddress(config.RegistryCoordinatorAddr),
OperatorStateRetrieverAddress: gethcommon.HexToAddress(config.OperatorStateRetrieverAddr),
}
if config.ServiceManagerAddress != "" {
avsCfg.ServiceManagerAddress = gethcommon.HexToAddress(config.ServiceManagerAddress)
}

// creating AVS clients: Reader
avsRegistryChainReader, avsRegistryChainSubscriber, avsRegistryContractBindings, err := avsregistry.BuildReadClients(
avsregistry.Config{
RegistryCoordinatorAddress: gethcommon.HexToAddress(config.RegistryCoordinatorAddr),
OperatorStateRetrieverAddress: gethcommon.HexToAddress(config.OperatorStateRetrieverAddr),
},
avsCfg,
ethHttpClient,
ethWsClient,
logger,
Expand Down Expand Up @@ -168,13 +176,17 @@ func BuildAll(
return nil, utils.WrapError("Failed to create transaction sender", err)
}
txMgr := txmgr.NewSimpleTxManager(pkWallet, ethHttpClient, logger, addr)
avsCfg := avsregistry.Config{
RegistryCoordinatorAddress: gethcommon.HexToAddress(config.RegistryCoordinatorAddr),
OperatorStateRetrieverAddress: gethcommon.HexToAddress(config.OperatorStateRetrieverAddr),
}
if config.ServiceManagerAddress != "" {
avsCfg.ServiceManagerAddress = gethcommon.HexToAddress(config.ServiceManagerAddress)
}

// creating AVS clients: Reader and Writer
avsRegistryChainReader, avsRegistryChainSubscriber, avsRegistryChainWriter, avsRegistryContractBindings, err := avsregistry.BuildClients(
avsregistry.Config{
RegistryCoordinatorAddress: gethcommon.HexToAddress(config.RegistryCoordinatorAddr),
OperatorStateRetrieverAddress: gethcommon.HexToAddress(config.OperatorStateRetrieverAddr),
},
avsCfg,
ethHttpClient,
ethWsClient,
txMgr,
Expand Down Expand Up @@ -236,6 +248,9 @@ func (config *BuildAllConfig) validate(logger logging.Logger) error {
logger.Error("BuildAllConfig.validate: Missing bls registry coordinator address")
return fmt.Errorf("BuildAllConfig.validate: Missing bls registry coordinator address")
}
if config.ServiceManagerAddress == "" {
logger.Info("BuildAllConfig.validate: Missing optional service manager address")
}
if config.OperatorStateRetrieverAddr == "" {
logger.Error("BuildAllConfig.validate: Missing bls operator state retriever address")
return fmt.Errorf("BuildAllConfig.validate: Missing bls operator state retriever address")
Expand Down
7 changes: 7 additions & 0 deletions chainio/clients/elcontracts/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import (
"github.com/ethereum/go-ethereum/common"
)

type RegistrationType uint8

const (
RegistrationTypeNormal RegistrationType = 0
RegistrationTypeChurn RegistrationType = 1
)

type OperatorSetStakes struct {
OperatorSet allocationmanager.OperatorSet
Strategies []common.Address
Expand Down
18 changes: 11 additions & 7 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func (w *ChainWriter) RegisterForOperatorSets(
return nil, utils.WrapError("failed to get public key registration params", err)
}

data, err := abiEncodeRegistrationParams(request.Socket, *pubkeyRegParams)
data, err := AbiEncodeRegistrationParams(RegistrationTypeNormal, request.Socket, *pubkeyRegParams)
if err != nil {
return nil, utils.WrapError("failed to encode registration params", err)
}
Expand Down Expand Up @@ -851,7 +851,7 @@ func getPubkeyRegistrationParams(
ethClient bind.ContractBackend,
registryCoordinatorAddr, operatorAddress gethcommon.Address,
blsKeyPair *bls.KeyPair,
) (*regcoord.IBLSApkRegistryPubkeyRegistrationParams, error) {
) (*regcoord.IBLSApkRegistryTypesPubkeyRegistrationParams, error) {
registryCoordinator, err := regcoord.NewContractRegistryCoordinator(registryCoordinatorAddr, ethClient)
if err != nil {
return nil, utils.WrapError("failed to create registry coordinator", err)
Expand All @@ -869,7 +869,7 @@ func getPubkeyRegistrationParams(
)
G1pubkeyBN254 := chainioutils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1())
G2pubkeyBN254 := chainioutils.ConvertToBN254G2Point(blsKeyPair.GetPubKeyG2())
pubkeyRegParams := regcoord.IBLSApkRegistryPubkeyRegistrationParams{
pubkeyRegParams := regcoord.IBLSApkRegistryTypesPubkeyRegistrationParams{
PubkeyRegistrationSignature: signedMsg,
PubkeyG1: G1pubkeyBN254,
PubkeyG2: G2pubkeyBN254,
Expand All @@ -878,11 +878,13 @@ func getPubkeyRegistrationParams(
}

// Returns the ABI encoding of the given registration params.
func abiEncodeRegistrationParams(
func AbiEncodeRegistrationParams(
registrationType RegistrationType,
socket string,
pubkeyRegistrationParams regcoord.IBLSApkRegistryPubkeyRegistrationParams,
pubkeyRegistrationParams regcoord.IBLSApkRegistryTypesPubkeyRegistrationParams,
) ([]byte, error) {
registrationParamsType, err := abi.NewType("tuple", "", []abi.ArgumentMarshaling{
{Name: "RegistrationType", Type: "uint8"},
{Name: "Socket", Type: "string"},
{Name: "PubkeyRegParams", Type: "tuple", Components: []abi.ArgumentMarshaling{
{Name: "PubkeyRegistrationSignature", Type: "tuple", Components: []abi.ArgumentMarshaling{
Expand All @@ -904,9 +906,11 @@ func abiEncodeRegistrationParams(
}

registrationParams := struct {
Socket string
PubkeyRegParams regcoord.IBLSApkRegistryPubkeyRegistrationParams
RegistrationType RegistrationType
Socket string
PubkeyRegParams regcoord.IBLSApkRegistryTypesPubkeyRegistrationParams
}{
registrationType,
socket,
pubkeyRegistrationParams,
}
Expand Down
Loading