Skip to content

Commit 77c765b

Browse files
committed
update with latest contracts
1 parent 8b85e4c commit 77c765b

File tree

9 files changed

+94
-76
lines changed

9 files changed

+94
-76
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/Layr-Labs/eigenlayer-contracts v0.3.2-mainnet-rewards
88
github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.12
99
github.com/Layr-Labs/eigenpod-proofs-generation v0.0.14-stable.0.20240730152248-5c11a259293e
10-
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241023023134-a285de543731
10+
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241119232818-f7ce982c899e
1111
github.com/blang/semver/v4 v4.0.0
1212
github.com/consensys/gnark-crypto v0.12.1
1313
github.com/ethereum/go-ethereum v1.14.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ 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.13-0.20241023023134-a285de543731 h1:8F/wlaQoZG1+BcuP9cWhqKNbYgw4CphZFwp8SjMkW9A=
16-
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20241023023134-a285de543731/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s=
15+
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241119232818-f7ce982c899e h1:37FO9Rtc6XW5apFUfac4k03TBx+s2h8XqD5WdqOKjoA=
16+
github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241119232818-f7ce982c899e/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s=
1717
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1818
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
1919
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=

pkg/internal/common/flags/general.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ var (
9090
EnvVars: []string{"EXPIRY"},
9191
Value: 3600,
9292
}
93-
93+
9494
OperatorAddressFlag = cli.StringFlag{
9595
Name: "operator-address",
9696
Aliases: []string{"oa", "operator"},

pkg/operator/allocations/show.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/Layr-Labs/eigensdk-go/logging"
1616
eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils"
1717

18-
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1918
gethcommon "github.com/ethereum/go-ethereum/common"
2019
"github.com/ethereum/go-ethereum/ethclient"
2120

@@ -77,7 +76,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
7776
*/
7877
for _, strategyAddress := range config.strategyAddresses {
7978
allocatableMagnitude, err := elReader.GetAllocatableMagnitude(
80-
&bind.CallOpts{Context: ctx},
79+
ctx,
8180
config.operatorAddress,
8281
strategyAddress,
8382
)
@@ -96,7 +95,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
9695
*/
9796
totalMagnitudeMap := make(map[string]uint64)
9897
totalMagnitudes, err := elReader.GetMaxMagnitudes(
99-
&bind.CallOpts{Context: ctx},
98+
ctx,
10099
config.operatorAddress,
101100
config.strategyAddresses,
102101
)
@@ -114,7 +113,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
114113
allAllocations := make(map[string][]elcontracts.AllocationInfo, len(config.strategyAddresses))
115114
for _, strategyAddress := range config.strategyAddresses {
116115
allocations, err := elReader.GetAllocationInfo(
117-
&bind.CallOpts{Context: ctx},
116+
ctx,
118117
config.operatorAddress,
119118
strategyAddress,
120119
)
@@ -128,7 +127,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
128127
6. Get the operator scaled shares for all strategies
129128
*/
130129
operatorDelegatedSharesMap := make(map[string]*big.Int)
131-
shares, err := elReader.GetOperatorShares(&bind.CallOpts{}, config.operatorAddress, config.strategyAddresses)
130+
shares, err := elReader.GetOperatorShares(ctx, config.operatorAddress, config.strategyAddresses)
132131
for i, strategyAddress := range config.strategyAddresses {
133132
operatorDelegatedSharesMap[strategyAddress.String()] = shares[i]
134133
}
@@ -141,7 +140,10 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
141140
for strategy, allocations := range allAllocations {
142141
strategyShares := operatorDelegatedSharesMap[strategy]
143142
for _, alloc := range allocations {
144-
currentShares, currentSharesPercentage := getSharesFromMagnitude(strategyShares, alloc.CurrentMagnitude.Uint64())
143+
currentShares, currentSharesPercentage := getSharesFromMagnitude(
144+
strategyShares,
145+
alloc.CurrentMagnitude.Uint64(),
146+
)
145147
newMagnitudeBigInt := big.NewInt(0)
146148
if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 {
147149
newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff)
@@ -155,7 +157,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
155157
Shares: currentShares,
156158
SharesPercentage: currentSharesPercentage.String(),
157159
NewMagnitude: newMagnitudeBigInt.Uint64(),
158-
NewMagnitudeTimestamp: alloc.CompletableTimestamp,
160+
NewMagnitudeTimestamp: alloc.EffectBlock,
159161
NewAllocationShares: newShares,
160162
UpcomingSharesPercentage: newSharesPercentage.String(),
161163
})
@@ -273,7 +275,7 @@ func getSharesFromMagnitude(totalScaledShare *big.Int, magnitude uint64) (*big.I
273275
}
274276

275277
func getUniqueKey(strategyAddress gethcommon.Address, opSet allocationmanager.OperatorSet) string {
276-
return fmt.Sprintf("%s-%s-%d", strategyAddress.String(), opSet.Avs.String(), opSet.OperatorSetId)
278+
return fmt.Sprintf("%s-%s-%d", strategyAddress.String(), opSet.Avs.String(), opSet.Id)
277279
}
278280

279281
func readAndValidateShowConfig(cCtx *cli.Context, logger *logging.Logger) (*showConfig, error) {

pkg/operator/allocations/types.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"time"
99

1010
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common"
11-
1211
"github.com/Layr-Labs/eigenlayer-cli/pkg/types"
1312

1413
allocationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/AllocationManager"
@@ -17,7 +16,7 @@ import (
1716
)
1817

1918
type BulkModifyAllocations struct {
20-
Allocations []allocationmanager.IAllocationManagerTypesMagnitudeAllocation
19+
Allocations []allocationmanager.IAllocationManagerTypesAllocateParams
2120
AllocatableMagnitudes map[gethcommon.Address]uint64
2221
}
2322

@@ -28,13 +27,12 @@ func (b *BulkModifyAllocations) PrintPretty() {
2827
allocations := b.Allocations
2928
headers := []string{
3029
"Strategy",
31-
"Expected Total Magnitude",
3230
"Allocatable Magnitude",
3331
"Operator Set ID",
3432
"AVS",
3533
"Magnitude",
3634
}
37-
widths := []int{20, 25, 25, 20, 20, 25}
35+
widths := []int{20, 25, 20, 20, 25}
3836

3937
// print dashes
4038
for _, width := range widths {
@@ -59,21 +57,19 @@ func (b *BulkModifyAllocations) PrintPretty() {
5957

6058
// Print data rows
6159
for _, a := range allocations {
62-
for i, opSet := range a.OperatorSets {
60+
for i, strategy := range a.Strategies {
6361
fmt.Printf(
6462
"| %-*s| %-*s| %-*s| %-*d| %-*s| %-*s|\n",
6563
widths[0],
66-
common.ShortEthAddress(a.Strategy),
64+
common.ShortEthAddress(strategy),
6765
widths[1],
68-
common.FormatNumberWithUnderscores(common.Uint64ToString(a.ExpectedMaxMagnitude)),
66+
common.FormatNumberWithUnderscores(common.Uint64ToString(b.AllocatableMagnitudes[strategy])),
6967
widths[2],
70-
common.FormatNumberWithUnderscores(common.Uint64ToString(b.AllocatableMagnitudes[a.Strategy])),
68+
a.OperatorSet.Id,
7169
widths[3],
72-
opSet.OperatorSetId,
70+
common.ShortEthAddress(a.OperatorSet.Avs),
7371
widths[4],
74-
common.ShortEthAddress(opSet.Avs),
75-
widths[5],
76-
common.FormatNumberWithUnderscores(common.Uint64ToString(a.Magnitudes[i])),
72+
common.FormatNumberWithUnderscores(common.Uint64ToString(a.NewMagnitudes[i])),
7773
)
7874
}
7975
}

pkg/operator/allocations/update.go

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"sort"
1010
"sync"
1111

12-
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1312
gethcommon "github.com/ethereum/go-ethereum/common"
1413
"github.com/ethereum/go-ethereum/ethclient"
1514

@@ -29,12 +28,12 @@ import (
2928

3029
type elChainReader interface {
3130
GetMaxMagnitudes(
32-
opts *bind.CallOpts,
31+
ctx context.Context,
3332
operatorAddress gethcommon.Address,
3433
strategyAddresses []gethcommon.Address,
3534
) ([]uint64, error)
3635
GetAllocatableMagnitude(
37-
opts *bind.CallOpts,
36+
ctx context.Context,
3837
operator gethcommon.Address,
3938
strategy gethcommon.Address,
4039
) (uint64, error)
@@ -200,21 +199,21 @@ func generateAllocationsParams(
200199
config *updateConfig,
201200
logger logging.Logger,
202201
) (*BulkModifyAllocations, error) {
203-
allocations := make([]allocationmanager.IAllocationManagerTypesMagnitudeAllocation, 0)
202+
allocations := make([]allocationmanager.IAllocationManagerTypesAllocateParams, 0)
204203
var allocatableMagnitudes map[gethcommon.Address]uint64
205204

206205
var err error
207206
if len(config.csvFilePath) == 0 {
208207
magnitude, err := elReader.GetMaxMagnitudes(
209-
&bind.CallOpts{Context: ctx},
208+
ctx,
210209
config.operatorAddress,
211210
[]gethcommon.Address{config.strategyAddress},
212211
)
213212
if err != nil {
214213
return nil, eigenSdkUtils.WrapError("failed to get latest total magnitude", err)
215214
}
216215
allocatableMagnitude, err := elReader.GetAllocatableMagnitude(
217-
&bind.CallOpts{Context: ctx},
216+
ctx,
218217
config.operatorAddress,
219218
config.strategyAddress,
220219
)
@@ -226,16 +225,13 @@ func generateAllocationsParams(
226225
logger.Debugf("Bips to allocate: %d", config.bipsToAllocate)
227226
magnitudeToUpdate := calculateMagnitudeToUpdate(magnitude[0], config.bipsToAllocate)
228227
logger.Debugf("Magnitude to update: %d", magnitudeToUpdate)
229-
malloc := allocationmanager.IAllocationManagerTypesMagnitudeAllocation{
230-
Strategy: config.strategyAddress,
231-
ExpectedMaxMagnitude: magnitude[0],
232-
OperatorSets: []allocationmanager.OperatorSet{
233-
{
234-
Avs: config.avsAddress,
235-
OperatorSetId: config.operatorSetId,
236-
},
228+
malloc := allocationmanager.IAllocationManagerTypesAllocateParams{
229+
Strategies: []gethcommon.Address{config.strategyAddress},
230+
OperatorSet: allocationmanager.OperatorSet{
231+
Avs: config.avsAddress,
232+
Id: config.operatorSetId,
237233
},
238-
Magnitudes: []uint64{magnitudeToUpdate},
234+
NewMagnitudes: []uint64{magnitudeToUpdate},
239235
}
240236
allocations = append(allocations, malloc)
241237
} else {
@@ -255,7 +251,7 @@ func computeAllocations(
255251
filePath string,
256252
operatorAddress gethcommon.Address,
257253
elReader elChainReader,
258-
) ([]allocationmanager.IAllocationManagerTypesMagnitudeAllocation, map[gethcommon.Address]uint64, error) {
254+
) ([]allocationmanager.IAllocationManagerTypesAllocateParams, map[gethcommon.Address]uint64, error) {
259255
allocations, err := parseAllocationsCSV(filePath)
260256
if err != nil {
261257
return nil, nil, eigenSdkUtils.WrapError("failed to parse allocations csv", err)
@@ -314,7 +310,7 @@ func parallelGetAllocatableMagnitudes(
314310
wg.Add(1)
315311
go func(strategy gethcommon.Address) {
316312
defer wg.Done()
317-
magnitude, err := elReader.GetAllocatableMagnitude(&bind.CallOpts{}, operatorAddress, strategy)
313+
magnitude, err := elReader.GetAllocatableMagnitude(context.Background(), operatorAddress, strategy)
318314
if err != nil {
319315
errChan <- err
320316
return
@@ -340,7 +336,7 @@ func getMagnitudes(
340336
) (map[gethcommon.Address]uint64, error) {
341337
strategyTotalMagnitudes := make(map[gethcommon.Address]uint64, len(strategies))
342338
totalMagnitudes, err := reader.GetMaxMagnitudes(
343-
&bind.CallOpts{Context: context.Background()},
339+
context.Background(),
344340
operatorAddress,
345341
strategies,
346342
)
@@ -385,40 +381,62 @@ func parseAllocationsCSV(filePath string) ([]allocation, error) {
385381
func convertAllocationsToMagnitudeAllocations(
386382
allocations []allocation,
387383
strategyTotalMagnitudes map[gethcommon.Address]uint64,
388-
) []allocationmanager.IAllocationManagerTypesMagnitudeAllocation {
389-
magnitudeAllocations := make([]allocationmanager.IAllocationManagerTypesMagnitudeAllocation, 0)
390-
operatorSetsPerStragyMap := make(map[gethcommon.Address][]allocationmanager.OperatorSet)
391-
magnitudeAllocationsPerStrategyMap := make(map[gethcommon.Address][]uint64)
384+
) []allocationmanager.IAllocationManagerTypesAllocateParams {
385+
magnitudeAllocations := make([]allocationmanager.IAllocationManagerTypesAllocateParams, 0)
386+
//operatorSetsPerStragyMap := make(map[gethcommon.Address][]allocationmanager.OperatorSet)
387+
strategiesPerOperatorSetMap := make(map[allocationmanager.OperatorSet][]gethcommon.Address)
388+
//magnitudeAllocationsPerStrategyMap := make(map[gethcommon.Address][]uint64)
389+
magnitudeAllocationsPerOperatorSetMap := make(map[allocationmanager.OperatorSet][]uint64)
392390
for _, a := range allocations {
393391
totalMag := strategyTotalMagnitudes[a.StrategyAddress]
394392
magnitudeToUpdate := calculateMagnitudeToUpdate(totalMag, a.Bips)
395393

396-
operatorSets, ok := operatorSetsPerStragyMap[a.StrategyAddress]
394+
opSet := allocationmanager.OperatorSet{Avs: a.AvsAddress, Id: a.OperatorSetId}
395+
strategies, ok := strategiesPerOperatorSetMap[opSet]
397396
if !ok {
398-
operatorSets = make([]allocationmanager.OperatorSet, 0)
397+
strategies = make([]gethcommon.Address, 0)
399398
}
400-
operatorSets = append(operatorSets, allocationmanager.OperatorSet{
401-
Avs: a.AvsAddress,
402-
OperatorSetId: a.OperatorSetId,
403-
})
404-
operatorSetsPerStragyMap[a.StrategyAddress] = operatorSets
405399

406-
magnitudes := magnitudeAllocationsPerStrategyMap[a.StrategyAddress]
400+
strategies = append(strategies, a.StrategyAddress)
401+
strategiesPerOperatorSetMap[opSet] = strategies
402+
403+
//operatorSets, ok := operatorSetsPerStragyMap[a.StrategyAddress]
404+
//if !ok {
405+
// operatorSets = make([]allocationmanager.OperatorSet, 0)
406+
//}
407+
//operatorSets = append(operatorSets, allocationmanager.OperatorSet{
408+
// Avs: a.AvsAddress,
409+
// Id: a.OperatorSetId,
410+
//})
411+
//operatorSetsPerStragyMap[a.StrategyAddress] = operatorSets
412+
413+
magnitudes := magnitudeAllocationsPerOperatorSetMap[opSet]
407414
magnitudes = append(magnitudes, magnitudeToUpdate)
408-
magnitudeAllocationsPerStrategyMap[a.StrategyAddress] = magnitudes
415+
magnitudeAllocationsPerOperatorSetMap[opSet] = magnitudes
409416
}
410417

411-
for strategy, operatorSets := range operatorSetsPerStragyMap {
418+
for opSet, strategies := range strategiesPerOperatorSetMap {
412419
magnitudeAllocations = append(
413420
magnitudeAllocations,
414-
allocationmanager.IAllocationManagerTypesMagnitudeAllocation{
415-
Strategy: strategy,
416-
ExpectedMaxMagnitude: strategyTotalMagnitudes[strategy],
417-
OperatorSets: operatorSets,
418-
Magnitudes: magnitudeAllocationsPerStrategyMap[strategy],
421+
allocationmanager.IAllocationManagerTypesAllocateParams{
422+
OperatorSet: opSet,
423+
Strategies: strategies,
424+
NewMagnitudes: magnitudeAllocationsPerOperatorSetMap[opSet],
419425
},
420426
)
421427
}
428+
429+
//for strategy, operatorSets := range operatorSetsPerStragyMap {
430+
// magnitudeAllocations = append(
431+
// magnitudeAllocations,
432+
// allocationmanager.IAllocationManagerTypesAllocateParams{
433+
// Strategy: strategy,
434+
// ExpectedMaxMagnitude: strategyTotalMagnitudes[strategy],
435+
// OperatorSets: operatorSets,
436+
// Magnitudes: magnitudeAllocationsPerStrategyMap[strategy],
437+
// },
438+
// )
439+
//}
422440
return magnitudeAllocations
423441
}
424442

pkg/operator/allocations/update_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestGenerateAllocationsParams(t *testing.T) {
9898
},
9999
expectError: false,
100100
expectedAllocations: &BulkModifyAllocations{
101-
Allocations: []allocationmanager.IAllocationManagerTypesMagnitudeAllocation{
101+
Allocations: []allocationmanager.IAllocationManagerTypesAllocateParams{
102102
{
103103
Strategy: gethcommon.HexToAddress(strategyAddress),
104104
ExpectedMaxMagnitude: initialMagnitude,
@@ -121,7 +121,7 @@ func TestGenerateAllocationsParams(t *testing.T) {
121121
},
122122
expectError: false,
123123
expectedAllocations: &BulkModifyAllocations{
124-
Allocations: []allocationmanager.IAllocationManagerTypesMagnitudeAllocation{
124+
Allocations: []allocationmanager.IAllocationManagerTypesAllocateParams{
125125
{
126126
Strategy: gethcommon.HexToAddress("0x49989b32351Eb9b8ab2d5623cF22E7F7C23e5630"),
127127
ExpectedMaxMagnitude: initialMagnitude,

pkg/rewards/claim.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type elChainReader interface {
3939
GetRootIndexFromHash(ctx context.Context, hash [32]byte) (uint32, error)
4040
GetCurrentClaimableDistributionRoot(
4141
ctx context.Context,
42-
) (rewardscoordinator.IRewardsCoordinatorDistributionRoot, error)
42+
) (rewardscoordinator.IRewardsCoordinatorTypesDistributionRoot, error)
4343
CurrRewardsCalculationEndTimestamp(ctx context.Context) (uint32, error)
4444
}
4545

@@ -138,11 +138,11 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
138138
return eigenSdkUtils.WrapError("failed to generate claim proof for earner", err)
139139
}
140140

141-
elClaim := rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim{
141+
elClaim := rewardscoordinator.IRewardsCoordinatorTypesRewardsMerkleClaim{
142142
RootIndex: claim.RootIndex,
143143
EarnerIndex: claim.EarnerIndex,
144144
EarnerTreeProof: claim.EarnerTreeProof,
145-
EarnerLeaf: rewardscoordinator.IRewardsCoordinatorEarnerTreeMerkleLeaf{
145+
EarnerLeaf: rewardscoordinator.IRewardsCoordinatorTypesEarnerTreeMerkleLeaf{
146146
Earner: claim.EarnerLeaf.Earner,
147147
EarnerTokenRoot: claim.EarnerLeaf.EarnerTokenRoot,
148148
},
@@ -345,10 +345,10 @@ func filterClaimableTokenAddresses(
345345

346346
func convertClaimTokenLeaves(
347347
claimTokenLeaves []contractrewardscoordinator.IRewardsCoordinatorTokenTreeMerkleLeaf,
348-
) []rewardscoordinator.IRewardsCoordinatorTokenTreeMerkleLeaf {
349-
var tokenLeaves []rewardscoordinator.IRewardsCoordinatorTokenTreeMerkleLeaf
348+
) []rewardscoordinator.IRewardsCoordinatorTypesTokenTreeMerkleLeaf {
349+
var tokenLeaves []rewardscoordinator.IRewardsCoordinatorTypesTokenTreeMerkleLeaf
350350
for _, claimTokenLeaf := range claimTokenLeaves {
351-
tokenLeaves = append(tokenLeaves, rewardscoordinator.IRewardsCoordinatorTokenTreeMerkleLeaf{
351+
tokenLeaves = append(tokenLeaves, rewardscoordinator.IRewardsCoordinatorTypesTokenTreeMerkleLeaf{
352352
Token: claimTokenLeaf.Token,
353353
CumulativeEarnings: claimTokenLeaf.CumulativeEarnings,
354354
})

0 commit comments

Comments
 (0)