Skip to content

Commit a1d46be

Browse files
committed
fix: showing allocations for registered ops (#272)
1 parent 81618ef commit a1d46be

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12 h1:G5Q1SnLmFbEjhOkky3vIHk
1212
github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12/go.mod h1:OlJd1QjqEW53wfWG/lJyPCGvrXwWVEjPQsP4TV+gttQ=
1313
github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e h1:DvW0/kWHV9mZsbH2KOjEHKTSIONNPUj6X05FJvUohy4=
1414
github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e/go.mod h1:T7tYN8bTdca2pkMnz9G2+ZwXYWw5gWqQUIu4KLgC/vM=
15-
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217222530-549e0185cee6 h1:v2SQn+Yq/HMAkv0a11NHnZXJS0K+2F4JWU0ogOV6+jg=
16-
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217222530-549e0185cee6/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s=
1715
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217234459-1dd4a5c5b30a h1:spyS+Tp1PgVIPmAesVVRuOkC3jAZRyKXhttAieTBxmg=
1816
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241217234459-1dd4a5c5b30a/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s=
1917
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=

pkg/operator/allocations/show.go

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,25 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
169169
strategyShares := operatorDelegatedSharesMap[strategy]
170170
totalMagnitude := totalMagnitudeMap[strategy]
171171
for _, alloc := range allocations {
172-
currentShares := slashableSharesMap[gethcommon.HexToAddress(strategy)][getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)]
173-
currentSharesPercentage := getSharePercentage(currentShares, strategyShares)
174-
175-
newMagnitudeBigInt := big.NewInt(0)
176-
if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 {
177-
newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff)
178-
}
179-
180-
newShares, newSharesPercentage := getSharesFromMagnitude(
181-
strategyShares,
182-
newMagnitudeBigInt.Uint64(),
183-
totalMagnitude,
184-
)
185172

186173
// Check if the operator set is not registered and add it to the unregistered list
187174
// Then skip the rest of the loop
188175
if _, ok := registeredOperatorSetsMap[getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)]; !ok {
176+
currentShares, currentSharesPercentage := getSharesFromMagnitude(
177+
strategyShares,
178+
alloc.CurrentMagnitude.Uint64(),
179+
totalMagnitude,
180+
)
181+
182+
// If the operator set is not registered and has no shares, skip it
183+
// This comes as valid scenario since we iterate first over
184+
// strategy addresses and then over allocations.
185+
// This can be fixed by first going over allocations and then over strategy addresses
186+
// We will fix this in a subsequent PR and improve (TODO: shrimalmadhur)
187+
if currentShares == nil || currentShares.Cmp(big.NewInt(0)) == 0 {
188+
continue
189+
}
190+
189191
dergisteredOpsets = append(dergisteredOpsets, DeregisteredOperatorSet{
190192
StrategyAddress: gethcommon.HexToAddress(strategy),
191193
AVSAddress: alloc.AvsAddress,
@@ -197,6 +199,20 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
197199
continue
198200
}
199201

202+
currentShares := slashableSharesMap[gethcommon.HexToAddress(strategy)][getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)]
203+
currentSharesPercentage := getSharePercentage(currentShares, strategyShares)
204+
205+
newMagnitudeBigInt := big.NewInt(0)
206+
if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 {
207+
newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff)
208+
}
209+
210+
newShares, newSharesPercentage := getSharesFromMagnitude(
211+
strategyShares,
212+
newMagnitudeBigInt.Uint64(),
213+
totalMagnitude,
214+
)
215+
200216
// Add the operator set to the registered list
201217
slashableMagnitudeHolders = append(slashableMagnitudeHolders, SlashableMagnitudesHolder{
202218
StrategyAddress: gethcommon.HexToAddress(strategy),

pkg/operator/register_operator_sets.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error {
7878
receipt, err := eLWriter.RegisterForOperatorSets(
7979
ctx,
8080
elcontracts.RegistrationRequest{
81-
AVSAddress: config.avsAddress,
82-
OperatorSetIds: config.operatorSetIds,
83-
WaitForReceipt: true,
81+
OperatorAddress: config.operatorAddress,
82+
AVSAddress: config.avsAddress,
83+
OperatorSetIds: config.operatorSetIds,
84+
WaitForReceipt: true,
8485
})
8586
if err != nil {
86-
return eigenSdkUtils.WrapError("failed to deregister from operator sets", err)
87+
return eigenSdkUtils.WrapError("failed to register for operator sets", err)
8788
}
8889
common.PrintTransactionInfo(receipt.TxHash.String(), config.chainID)
8990
} else {

0 commit comments

Comments
 (0)