Skip to content

Commit

Permalink
fix: showing allocations for registered ops
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Dec 18, 2024
1 parent 7f37efa commit 8689882
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
42 changes: 29 additions & 13 deletions pkg/operator/allocations/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down
9 changes: 5 additions & 4 deletions pkg/operator/register_operator_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8689882

Please sign in to comment.