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

fix: showing allocations for registered ops #272

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading