Skip to content

Commit

Permalink
update contracts submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Nov 13, 2024
1 parent a285de5 commit ce9983d
Show file tree
Hide file tree
Showing 11 changed files with 2,488 additions and 3,491 deletions.
79 changes: 43 additions & 36 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package elcontracts

import (
"errors"
"math"

"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -162,7 +160,7 @@ func (r *ChainReader) GetOperatorDetails(opts *bind.CallOpts, operator types.Ope
return types.Operator{}, err
}

allocationDelayDetails, err := r.allocationManager.GetAllocationDelay(
isSet, delay, err := r.allocationManager.GetAllocationDelay(
opts,
gethcommon.HexToAddress(operator.Address),
)
Expand All @@ -171,8 +169,8 @@ func (r *ChainReader) GetOperatorDetails(opts *bind.CallOpts, operator types.Ope
}

var allocationDelay uint32
if allocationDelayDetails.IsSet {
allocationDelay = allocationDelayDetails.Delay
if isSet {
allocationDelay = delay
} else {
allocationDelay = 0
}
Expand Down Expand Up @@ -341,7 +339,7 @@ func (r *ChainReader) GetMaxMagnitudes(
return []uint64{}, errors.New("AllocationManager contract not provided")
}

return r.allocationManager.GetMaxMagnitudes(opts, operatorAddress, strategyAddresses)
return r.allocationManager.GetMaxMagnitudes0(opts, operatorAddress, strategyAddresses)
}

func (r *ChainReader) GetAllocationInfo(
Expand All @@ -353,19 +351,19 @@ func (r *ChainReader) GetAllocationInfo(
return nil, errors.New("AllocationManager contract not provided")
}

opSets, allocationInfo, err := r.allocationManager.GetAllocationInfo1(opts, operatorAddress, strategyAddress)
opSets, allocationInfo, err := r.allocationManager.GetStrategyAllocations(opts, operatorAddress, strategyAddress)
if err != nil {
return nil, err
}

allocationsInfo := make([]AllocationInfo, len(opSets))
for i, opSet := range opSets {
allocationsInfo[i] = AllocationInfo{
OperatorSetId: opSet.OperatorSetId,
AvsAddress: opSet.Avs,
CurrentMagnitude: big.NewInt(int64(allocationInfo[i].CurrentMagnitude)),
PendingDiff: allocationInfo[i].PendingDiff,
CompletableTimestamp: allocationInfo[i].EffectTimestamp,
OperatorSetId: opSet.Id,
AvsAddress: opSet.Avs,
CurrentMagnitude: big.NewInt(int64(allocationInfo[i].CurrentMagnitude)),
PendingDiff: allocationInfo[i].PendingDiff,
EffectBlock: allocationInfo[i].EffectBlock,
}
}

Expand Down Expand Up @@ -396,33 +394,37 @@ func (r *ChainReader) GetOperatorsShares(
return r.delegationManager.GetOperatorsShares(opts, operatorAddress, strategyAddresses)
}

// GetNumberOfOperatorSetsForOperator returns the number of operator sets that an operator is part of
// GetNumOperatorSetsForOperator returns the number of operator sets that an operator is part of
// Doesn't include M2 AVSs
func (r *ChainReader) GetNumOperatorSetsForOperator(
opts *bind.CallOpts,
operatorAddress gethcommon.Address,
) (*big.Int, error) {
return r.avsDirectory.GetNumOperatorSetsOfOperator(opts, operatorAddress)
opSets, err := r.allocationManager.GetAllocatedSets(opts, operatorAddress)
if err != nil {
return nil, err
}
return big.NewInt(int64(len(opSets))), nil
}

// GetOperatorSetsForOperator returns the list of operator sets that an operator is part of
// Doesn't include M2 AVSs
func (r *ChainReader) GetOperatorSetsForOperator(
opts *bind.CallOpts,
operatorAddress gethcommon.Address,
) ([]avsdirectory.OperatorSet, error) {
) ([]allocationmanager.OperatorSet, error) {
// TODO: we're fetching max int64 operatorSets here. What's the practical limit for timeout by RPC? do we need to
// paginate?
return r.avsDirectory.GetOperatorSetsOfOperator(opts, operatorAddress, gethcommon.Big0, big.NewInt(math.MaxInt64))
return r.allocationManager.GetAllocatedSets(opts, operatorAddress)
}

// IsOperatorRegisteredWithOperatorSet returns if an operator is registered with a specific operator set
func (r *ChainReader) IsOperatorRegisteredWithOperatorSet(
opts *bind.CallOpts,
operatorAddress gethcommon.Address,
operatorSet avsdirectory.OperatorSet,
operatorSet allocationmanager.OperatorSet,
) (bool, error) {
if operatorSet.OperatorSetId == 0 {
if operatorSet.Id == 0 {
// this is an M2 AVS
status, err := r.avsDirectory.AvsOperatorStatus(opts, operatorSet.Avs, operatorAddress)
if err != nil {
Expand All @@ -431,55 +433,60 @@ func (r *ChainReader) IsOperatorRegisteredWithOperatorSet(

return status == 1, nil
} else {
registered, err := r.avsDirectory.IsMember(opts, operatorAddress, operatorSet)
registeredOperatorSets, err := r.allocationManager.GetRegisteredSets(opts, operatorAddress)
if err != nil {
return false, err
}
for _, registeredOperatorSet := range registeredOperatorSets {
if registeredOperatorSet.Id == operatorSet.Id && registeredOperatorSet.Avs == operatorSet.Avs {
return true, nil
}
}

return registered, nil
return false, nil
}
}

// GetOperatorsForOperatorSet returns the list of operators in a specific operator set
// Not supported for M2 AVSs
func (r *ChainReader) GetOperatorsForOperatorSet(
opts *bind.CallOpts,
operatorSet avsdirectory.OperatorSet,
operatorSet allocationmanager.OperatorSet,
) ([]gethcommon.Address, error) {
if operatorSet.OperatorSetId == 0 {
if operatorSet.Id == 0 {
return nil, errLegacyAVSsNotSupported
} else {
return r.avsDirectory.GetOperatorsInOperatorSet(opts, operatorSet, gethcommon.Big0, big.NewInt(math.MaxInt64))
return r.allocationManager.GetMembers(opts, operatorSet)
}
}

// GetNumOperatorsForOperatorSet returns the number of operators in a specific operator set
func (r *ChainReader) GetNumOperatorsForOperatorSet(
opts *bind.CallOpts,
operatorSet avsdirectory.OperatorSet,
operatorSet allocationmanager.OperatorSet,
) (*big.Int, error) {
if operatorSet.OperatorSetId == 0 {
if operatorSet.Id == 0 {
return nil, errLegacyAVSsNotSupported
} else {
return r.avsDirectory.GetNumOperatorsInOperatorSet(opts, operatorSet)
return r.allocationManager.GetMemberCount(opts, operatorSet)
}
}

// GetStrategiesForOperatorSet returns the list of strategies that an operator set takes into account
// Not supported for M2 AVSs
func (r *ChainReader) GetStrategiesForOperatorSet(
opts *bind.CallOpts,
operatorSet avsdirectory.OperatorSet,
operatorSet allocationmanager.OperatorSet,
) ([]gethcommon.Address, error) {
if operatorSet.OperatorSetId == 0 {
if operatorSet.Id == 0 {
return nil, errLegacyAVSsNotSupported
} else {
return r.avsDirectory.GetStrategiesInOperatorSet(opts, operatorSet)
return r.allocationManager.GetStrategiesInOperatorSet(opts, operatorSet)
}
}

type OperatorSetStakes struct {
OperatorSet avsdirectory.OperatorSet
OperatorSet allocationmanager.OperatorSet
Strategies []gethcommon.Address
Operators []gethcommon.Address
DelegatedStakes [][]*big.Int
Expand All @@ -492,7 +499,7 @@ type OperatorSetStakes struct {
// Not supported for M2 AVSs
func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
opts *bind.CallOpts,
operatorSets []avsdirectory.OperatorSet,
operatorSets []allocationmanager.OperatorSet,
) ([]OperatorSetStakes, error) {
operatorSetStakes := make([]OperatorSetStakes, len(operatorSets))
for i, operatorSet := range operatorSets {
Expand All @@ -509,8 +516,8 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
delegatedShares, slashableShares, err := r.allocationManager.GetCurrentDelegatedAndSlashableOperatorShares(
opts,
allocationmanager.OperatorSet{
OperatorSetId: operatorSet.OperatorSetId,
Avs: operatorSet.Avs,
Id: operatorSet.Id,
Avs: operatorSet.Avs,
},
operators,
strategies,
Expand Down Expand Up @@ -538,7 +545,7 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
// Not supported for M2 AVSs
func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSetsBefore(
opts *bind.CallOpts,
operatorSets []avsdirectory.OperatorSet,
operatorSets []allocationmanager.OperatorSet,
beforeTimestamp uint32,
) ([]OperatorSetStakes, error) {
operatorSetStakes := make([]OperatorSetStakes, len(operatorSets))
Expand All @@ -556,8 +563,8 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSetsBefore(
delegatedShares, slashableShares, err := r.allocationManager.GetMinDelegatedAndSlashableOperatorSharesBefore(
opts,
allocationmanager.OperatorSet{
OperatorSetId: operatorSet.OperatorSetId,
Avs: operatorSet.Avs,
Id: operatorSet.Id,
Avs: operatorSet.Avs,
},
operators,
strategies,
Expand Down
10 changes: 5 additions & 5 deletions chainio/clients/elcontracts/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ type PendingDeallocation struct {
}

type AllocationInfo struct {
CurrentMagnitude *big.Int
PendingDiff *big.Int
CompletableTimestamp uint32
OperatorSetId uint32
AvsAddress common.Address
CurrentMagnitude *big.Int
PendingDiff *big.Int
EffectBlock uint32
OperatorSetId uint32
AvsAddress common.Address
}
43 changes: 7 additions & 36 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ func (w *ChainWriter) ForceDeregisterFromOperatorSets(
operator gethcommon.Address,
avs gethcommon.Address,
operatorSetIds []uint32,
operatorSignature avsdirectory.ISignatureUtilsSignatureWithSaltAndExpiry,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
if w.avsDirectory == nil {
Expand All @@ -384,12 +383,13 @@ func (w *ChainWriter) ForceDeregisterFromOperatorSets(
return nil, utils.WrapError("failed to get no send tx opts", err)
}

tx, err := w.avsDirectory.ForceDeregisterFromOperatorSets(
tx, err := w.allocationManager.DeregisterFromOperatorSets(
noSendTxOpts,
operator,
avs,
operatorSetIds,
operatorSignature,
allocationmanager.IAllocationManagerTypesDeregisterParams{
Operator: operator,
Avs: avs,
OperatorSetIds: operatorSetIds,
},
)

if err != nil {
Expand All @@ -404,38 +404,9 @@ func (w *ChainWriter) ForceDeregisterFromOperatorSets(
return receipt, nil
}

//func (w *ChainWriter) SetOperatorCommissionBips(
// ctx context.Context,
// operatorSet rewardscoordinator.OperatorSet,
// rewardType uint8,
// commissionBips uint16,
// waitForReceipt bool,
//) (*gethtypes.Receipt, error) {
// if w.rewardsCoordinator == nil {
// return nil, errors.New("RewardsCoordinator contract not provided")
// }
//
// noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
// if err != nil {
// return nil, utils.WrapError("failed to get no send tx opts", err)
// }
//
// tx, err := w.rewardsCoordinator.SetOperatorCommissionBips(noSendTxOpts, operatorSet, rewardType, commissionBips)
// if err != nil {
// return nil, utils.WrapError("failed to create SetOperatorCommissionBips tx", err)
// }
//
// receipt, err := w.txMgr.Send(ctx, tx, waitForReceipt)
// if err != nil {
// return nil, utils.WrapError("failed to send tx", err)
// }
//
// return receipt, nil
//}

func (w *ChainWriter) ModifyAllocations(
ctx context.Context,
allocations []allocationmanager.IAllocationManagerTypesMagnitudeAllocation,
allocations []allocationmanager.IAllocationManagerTypesAllocateParams,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
if w.allocationManager == nil {
Expand Down
2,622 changes: 489 additions & 2,133 deletions contracts/bindings/AVSDirectory/binding.go

Large diffs are not rendered by default.

2,027 changes: 1,613 additions & 414 deletions contracts/bindings/AllocationManager/binding.go

Large diffs are not rendered by default.

772 changes: 280 additions & 492 deletions contracts/bindings/DelegationManager/binding.go

Large diffs are not rendered by default.

Loading

0 comments on commit ce9983d

Please sign in to comment.