From 34d989727ccc770e62a5a93e25da5964f8aabbca Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Tue, 17 Dec 2024 16:56:40 -0800 Subject: [PATCH] fix: showing allocations for registered ops (#272) --- go.sum | 2 -- pkg/operator/allocations/show.go | 42 ++++++++++++++++++-------- pkg/operator/register_operator_sets.go | 9 +++--- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/go.sum b/go.sum index 42d4a602..31a66dd5 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,6 @@ github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12 h1:G5Q1SnLmFbEjhOkky3vIHk github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12/go.mod h1:OlJd1QjqEW53wfWG/lJyPCGvrXwWVEjPQsP4TV+gttQ= github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e h1:DvW0/kWHV9mZsbH2KOjEHKTSIONNPUj6X05FJvUohy4= github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e/go.mod h1:T7tYN8bTdca2pkMnz9G2+ZwXYWw5gWqQUIu4KLgC/vM= -github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217222530-549e0185cee6 h1:v2SQn+Yq/HMAkv0a11NHnZXJS0K+2F4JWU0ogOV6+jg= -github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217222530-549e0185cee6/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s= github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217234459-1dd4a5c5b30a h1:spyS+Tp1PgVIPmAesVVRuOkC3jAZRyKXhttAieTBxmg= github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217234459-1dd4a5c5b30a/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= diff --git a/pkg/operator/allocations/show.go b/pkg/operator/allocations/show.go index ac8f4871..55b1235f 100644 --- a/pkg/operator/allocations/show.go +++ b/pkg/operator/allocations/show.go @@ -169,23 +169,25 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error { strategyShares := operatorDelegatedSharesMap[strategy] totalMagnitude := totalMagnitudeMap[strategy] for _, alloc := range allocations { - currentShares := slashableSharesMap[gethcommon.HexToAddress(strategy)][getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)] - currentSharesPercentage := getSharePercentage(currentShares, strategyShares) - - newMagnitudeBigInt := big.NewInt(0) - if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 { - newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff) - } - - newShares, newSharesPercentage := getSharesFromMagnitude( - strategyShares, - newMagnitudeBigInt.Uint64(), - totalMagnitude, - ) // Check if the operator set is not registered and add it to the unregistered list // Then skip the rest of the loop if _, ok := registeredOperatorSetsMap[getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)]; !ok { + currentShares, currentSharesPercentage := getSharesFromMagnitude( + strategyShares, + alloc.CurrentMagnitude.Uint64(), + totalMagnitude, + ) + + // If the operator set is not registered and has no shares, skip it + // This comes as valid scenario since we iterate first over + // strategy addresses and then over allocations. + // This can be fixed by first going over allocations and then over strategy addresses + // We will fix this in a subsequent PR and improve (TODO: shrimalmadhur) + if currentShares == nil || currentShares.Cmp(big.NewInt(0)) == 0 { + continue + } + dergisteredOpsets = append(dergisteredOpsets, DeregisteredOperatorSet{ StrategyAddress: gethcommon.HexToAddress(strategy), AVSAddress: alloc.AvsAddress, @@ -197,6 +199,20 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error { continue } + currentShares := slashableSharesMap[gethcommon.HexToAddress(strategy)][getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)] + currentSharesPercentage := getSharePercentage(currentShares, strategyShares) + + newMagnitudeBigInt := big.NewInt(0) + if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 { + newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff) + } + + newShares, newSharesPercentage := getSharesFromMagnitude( + strategyShares, + newMagnitudeBigInt.Uint64(), + totalMagnitude, + ) + // Add the operator set to the registered list slashableMagnitudeHolders = append(slashableMagnitudeHolders, SlashableMagnitudesHolder{ StrategyAddress: gethcommon.HexToAddress(strategy), diff --git a/pkg/operator/register_operator_sets.go b/pkg/operator/register_operator_sets.go index 07b4e573..3589b697 100644 --- a/pkg/operator/register_operator_sets.go +++ b/pkg/operator/register_operator_sets.go @@ -78,12 +78,13 @@ func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error { receipt, err := eLWriter.RegisterForOperatorSets( ctx, elcontracts.RegistrationRequest{ - AVSAddress: config.avsAddress, - OperatorSetIds: config.operatorSetIds, - WaitForReceipt: true, + OperatorAddress: config.operatorAddress, + AVSAddress: config.avsAddress, + OperatorSetIds: config.operatorSetIds, + WaitForReceipt: true, }) if err != nil { - return eigenSdkUtils.WrapError("failed to deregister from operator sets", err) + return eigenSdkUtils.WrapError("failed to register for operator sets", err) } common.PrintTransactionInfo(receipt.TxHash.String(), config.chainID) } else {