Skip to content

Commit a467cb1

Browse files
authored
[pectra] Eigenpod CLI updates (#174)
* [pectra] fix the EigenPod CLI * major refactor * save * update mod
1 parent 6f4bada commit a467cb1

21 files changed

+324
-352
lines changed

cli/commands/assignSubmitter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66

77
"github.com/Layr-Labs/eigenlayer-contracts/pkg/bindings/EigenPod"
8-
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core"
8+
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core/utils"
99
"github.com/ethereum/go-ethereum/common"
1010
"github.com/ethereum/go-ethereum/ethclient"
1111
"github.com/fatih/color"
@@ -39,7 +39,7 @@ func AssignSubmitterCommand(args TAssignSubmitterArgs) error {
3939
return fmt.Errorf("failed to reach eth node for chain id: %w", err)
4040
}
4141

42-
ownerAccount, err := core.PrepareAccount(&args.Sender, chainId, false /* noSend */)
42+
ownerAccount, err := utils.PrepareAccount(&args.Sender, chainId, false /* noSend */)
4343
if err != nil {
4444
return fmt.Errorf("failed to parse --sender: %w", err)
4545
}
@@ -60,7 +60,7 @@ func AssignSubmitterCommand(args TAssignSubmitterArgs) error {
6060

6161
if !args.NoPrompt {
6262
fmt.Printf("Your pod's current proof submitter is %s.\n", currentSubmitter)
63-
core.PanicIfNoConsent(fmt.Sprintf("This will update your EigenPod to allow %s to submit proofs on its behalf. As the EigenPod's owner, you can always change this later.", newSubmitter))
63+
utils.PanicIfNoConsent(fmt.Sprintf("This will update your EigenPod to allow %s to submit proofs on its behalf. As the EigenPod's owner, you can always change this later.", newSubmitter))
6464
}
6565

6666
txn, err := pod.SetProofSubmitter(ownerAccount.TransactionOptions, newSubmitter)

cli/commands/checkpoint.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55

66
"github.com/Layr-Labs/eigenlayer-contracts/pkg/bindings/EigenPod"
77
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core"
8-
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/utils"
8+
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core/utils"
99
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1010
"github.com/ethereum/go-ethereum/common"
1111
"github.com/ethereum/go-ethereum/core/types"
1212
"github.com/fatih/color"
1313
"github.com/pkg/errors"
14+
lo "github.com/samber/lo"
1415
)
1516

1617
type TCheckpointCommandArgs struct {
@@ -36,31 +37,31 @@ func CheckpointCommand(args TCheckpointCommandArgs) error {
3637
isGasEstimate := args.SimulateTransaction && args.Sender != ""
3738
isVerbose := !args.SimulateTransaction || args.Verbose
3839

39-
eth, beaconClient, chainId, err := core.GetClients(ctx, args.Node, args.BeaconNode, isVerbose)
40-
core.PanicOnError("failed to reach ethereum clients", err)
40+
eth, beaconClient, chainId, err := utils.GetClients(ctx, args.Node, args.BeaconNode, isVerbose)
41+
utils.PanicOnError("failed to reach ethereum clients", err)
4142

42-
currentCheckpoint, err := core.GetCurrentCheckpoint(args.EigenpodAddress, eth)
43-
core.PanicOnError("failed to load checkpoint", err)
43+
currentCheckpoint, err := utils.GetCurrentCheckpoint(args.EigenpodAddress, eth)
44+
utils.PanicOnError("failed to load checkpoint", err)
4445

4546
eigenpod, err := EigenPod.NewEigenPod(common.HexToAddress(args.EigenpodAddress), eth)
46-
core.PanicOnError("failed to connect to eigenpod", err)
47+
utils.PanicOnError("failed to connect to eigenpod", err)
4748

4849
if currentCheckpoint == 0 {
4950
if len(args.Sender) > 0 || args.SimulateTransaction {
5051
if !args.NoPrompt && !args.SimulateTransaction {
51-
core.PanicIfNoConsent(core.StartCheckpointProofConsent())
52+
utils.PanicIfNoConsent(utils.StartCheckpointProofConsent())
5253
}
5354

54-
txn, err := core.StartCheckpoint(ctx, args.EigenpodAddress, args.Sender, chainId, eth, args.ForceCheckpoint, args.SimulateTransaction)
55-
core.PanicOnError("failed to start checkpoint", err)
55+
txn, err := utils.StartCheckpoint(ctx, args.EigenpodAddress, args.Sender, chainId, eth, args.ForceCheckpoint, args.SimulateTransaction)
56+
utils.PanicOnError("failed to start checkpoint", err)
5657

5758
if !args.SimulateTransaction {
5859
color.Green("starting checkpoint: %s.. (waiting for txn to be mined)", txn.Hash().Hex())
5960
bind.WaitMined(ctx, eth, txn)
6061
color.Green("started checkpoint! txn: %s", txn.Hash().Hex())
6162
} else {
6263
gas := txn.Gas()
63-
printAsJSON([]Transaction{
64+
PrintAsJSON([]Transaction{
6465
{
6566
Type: "checkpoint_start",
6667
To: txn.To().Hex(),
@@ -78,11 +79,11 @@ func CheckpointCommand(args TCheckpointCommandArgs) error {
7879
}
7980

8081
newCheckpoint, err := eigenpod.CurrentCheckpointTimestamp(nil)
81-
core.PanicOnError("failed to fetch current checkpoint", err)
82+
utils.PanicOnError("failed to fetch current checkpoint", err)
8283

8384
currentCheckpoint = newCheckpoint
8485
} else {
85-
core.PanicOnError("no checkpoint active and no private key provided to start one", errors.New("no checkpoint"))
86+
utils.PanicOnError("no checkpoint active and no private key provided to start one", errors.New("no checkpoint"))
8687
}
8788
}
8889

@@ -91,24 +92,24 @@ func CheckpointCommand(args TCheckpointCommandArgs) error {
9192
}
9293

9394
proof, err := core.GenerateCheckpointProof(ctx, args.EigenpodAddress, eth, chainId, beaconClient, isVerbose)
94-
core.PanicOnError("failed to generate checkpoint proof", err)
95+
utils.PanicOnError("failed to generate checkpoint proof", err)
9596

9697
txns, err := core.SubmitCheckpointProof(ctx, args.Sender, args.EigenpodAddress, chainId, proof, eth, args.BatchSize, args.NoPrompt, args.SimulateTransaction, args.Verbose)
9798
if args.SimulateTransaction {
98-
printableTxns := utils.Map(txns, func(txn *types.Transaction, _ uint64) Transaction {
99+
printableTxns := lo.Map(txns, func(txn *types.Transaction, _ int) Transaction {
99100
return Transaction{
100101
To: txn.To().Hex(),
101102
CallData: common.Bytes2Hex(txn.Data()),
102103
Type: "checkpoint_proof",
103104
}
104105
})
105-
printAsJSON(printableTxns)
106+
PrintAsJSON(printableTxns)
106107
} else {
107108
for i, txn := range txns {
108109
color.Green("transaction(%d): %s", i, txn.Hash().Hex())
109110
}
110111
}
111-
core.PanicOnError("an error occurred while submitting your checkpoint proofs", err)
112+
utils.PanicOnError("an error occurred while submitting your checkpoint proofs", err)
112113

113114
return nil
114115
}

cli/commands/completeAllWithdrawals.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/Layr-Labs/eigenlayer-contracts/pkg/bindings/EigenPod"
1212
"github.com/Layr-Labs/eigenlayer-contracts/pkg/bindings/IDelegationManager"
1313
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core"
14+
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core/utils"
1415
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1516
"github.com/ethereum/go-ethereum/common"
1617
"github.com/ethereum/go-ethereum/ethclient"
@@ -43,35 +44,35 @@ func CompleteAllWithdrawalsCommand(args TCompleteWithdrawalArgs) error {
4344
isSimulation := args.EstimateGas
4445

4546
eth, err := ethclient.DialContext(ctx, args.EthNode)
46-
core.PanicOnError("failed to reach eth node", err)
47+
utils.PanicOnError("failed to reach eth node", err)
4748

4849
chainId, err := eth.ChainID(ctx)
49-
core.PanicOnError("failed to load chainId", err)
50+
utils.PanicOnError("failed to load chainId", err)
5051

51-
acc, err := core.PrepareAccount(&args.Sender, chainId, isSimulation)
52-
core.PanicOnError("failed to parse private key", err)
52+
acc, err := utils.PrepareAccount(&args.Sender, chainId, isSimulation)
53+
utils.PanicOnError("failed to parse private key", err)
5354

5455
curBlockNumber, err := eth.BlockNumber(ctx)
55-
core.PanicOnError("failed to load current block number", err)
56+
utils.PanicOnError("failed to load current block number", err)
5657

5758
pod, err := EigenPod.NewEigenPod(common.HexToAddress(args.EigenPod), eth)
58-
core.PanicOnError("failed to reach eigenpod", err)
59+
utils.PanicOnError("failed to reach eigenpod", err)
5960

6061
reg, err := pod.WithdrawableRestakedExecutionLayerGwei(nil)
61-
core.PanicOnError("failed to fetch REG", err)
62-
rew := core.GweiToWei(new(big.Float).SetUint64(reg))
62+
utils.PanicOnError("failed to fetch REG", err)
63+
rew := utils.GweiToWei(new(big.Float).SetUint64(reg))
6364

6465
podOwner, err := pod.PodOwner(nil)
65-
core.PanicOnError("failed to read podOwner", err)
66+
utils.PanicOnError("failed to read podOwner", err)
6667

6768
delegationManager, err := IDelegationManager.NewIDelegationManager(DelegationManager(chainId), eth)
68-
core.PanicOnError("failed to reach delegation manager", err)
69+
utils.PanicOnError("failed to reach delegation manager", err)
6970

7071
minDelay, err := delegationManager.MinWithdrawalDelayBlocks(nil)
71-
core.PanicOnError("failed to read MinWithdrawalDelayBlocks", err)
72+
utils.PanicOnError("failed to read MinWithdrawalDelayBlocks", err)
7273

7374
queuedWithdrawals, err := delegationManager.GetQueuedWithdrawals(nil, podOwner)
74-
core.PanicOnError("failed to read queuedWithdrawals", err)
75+
utils.PanicOnError("failed to read queuedWithdrawals", err)
7576

7677
eligibleWithdrawals := lo.Map(queuedWithdrawals.Withdrawals, func(withdrawal IDelegationManager.IDelegationManagerTypesWithdrawal, index int) *IDelegationManager.IDelegationManagerTypesWithdrawal {
7778
isBeaconWithdrawal := len(withdrawal.Strategies) == 1 && withdrawal.Strategies[0].Cmp(core.BeaconStrategy()) == 0
@@ -128,10 +129,10 @@ func CompleteAllWithdrawalsCommand(args TCompleteWithdrawalArgs) error {
128129

129130
fmt.Printf("Your podOwner(%s) has %d withdrawal(s) that can be completed right now.\n", podOwner.Hex(), len(affordedWithdrawals))
130131
runningSumWeiInt, _ := runningSumWei.Int(nil)
131-
fmt.Printf("Total ETH on all withdrawals: %sETH\n", core.GweiToEther(core.WeiToGwei(runningSumWeiInt)).String())
132+
fmt.Printf("Total ETH on all withdrawals: %sETH\n", utils.GweiToEther(utils.WeiToGwei(runningSumWeiInt)).String())
132133

133134
if !isSimulation {
134-
core.PanicIfNoConsent("Would you like to continue?")
135+
utils.PanicIfNoConsent("Would you like to continue?")
135136
} else {
136137
color.Yellow("THIS IS A SIMULATION. No transaction will be recorded onchain.\n")
137138
}
@@ -149,15 +150,15 @@ func CompleteAllWithdrawalsCommand(args TCompleteWithdrawalArgs) error {
149150
})
150151

151152
txn, err := delegationManager.CompleteQueuedWithdrawals(acc.TransactionOptions, withdrawals, tokens, receiveAsTokens)
152-
core.PanicOnError("CompleteQueuedWithdrawals failed.", err)
153+
utils.PanicOnError("CompleteQueuedWithdrawals failed.", err)
153154

154155
if !isSimulation {
155156
_, err := bind.WaitMined(ctx, eth, txn)
156-
core.PanicOnError("waitMined failed", err)
157+
utils.PanicOnError("waitMined failed", err)
157158

158159
color.Green("%s\n", txn.Hash().Hex())
159160
} else {
160-
printAsJSON(Transaction{
161+
PrintAsJSON(Transaction{
161162
Type: "complete-withdrawals",
162163
To: txn.To().Hex(),
163164
CallData: common.Bytes2Hex(txn.Data()),

cli/commands/credentials.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77
"math/big"
88

99
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core"
10-
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/utils"
10+
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core/utils"
1111
"github.com/ethereum/go-ethereum/common"
1212
"github.com/ethereum/go-ethereum/core/types"
1313
"github.com/fatih/color"
14+
lo "github.com/samber/lo"
1415
)
1516

1617
type TCredentialCommandArgs struct {
@@ -37,8 +38,8 @@ func CredentialsCommand(args TCredentialCommandArgs) error {
3738
isGasEstimate := args.SimulateTransaction && args.Sender != ""
3839
isVerbose := (!args.UseJSON && !args.SimulateTransaction) || args.Verbose
3940

40-
eth, beaconClient, chainId, err := core.GetClients(ctx, args.Node, args.BeaconNode, isVerbose)
41-
core.PanicOnError("failed to reach ethereum clients", err)
41+
eth, beaconClient, chainId, err := utils.GetClients(ctx, args.Node, args.BeaconNode, isVerbose)
42+
utils.PanicOnError("failed to reach ethereum clients", err)
4243

4344
var specificValidatorIndex *big.Int = nil
4445
if args.SpecificValidator != math.MaxUint64 && args.SpecificValidator != 0 {
@@ -51,13 +52,13 @@ func CredentialsCommand(args TCredentialCommandArgs) error {
5152
validatorProofs, oracleBeaconTimestamp, err := core.GenerateValidatorProof(ctx, args.EigenpodAddress, eth, chainId, beaconClient, specificValidatorIndex, isVerbose)
5253

5354
if err != nil || validatorProofs == nil {
54-
core.PanicOnError("Failed to generate validator proof", err)
55-
core.Panic("no inactive validators")
55+
utils.PanicOnError("Failed to generate validator proof", err)
56+
utils.Panic("no inactive validators")
5657
}
5758

5859
if len(args.Sender) != 0 || args.SimulateTransaction {
5960
txns, indices, err := core.SubmitValidatorProof(ctx, args.Sender, args.EigenpodAddress, chainId, eth, args.BatchSize, validatorProofs, oracleBeaconTimestamp, args.NoPrompt, args.SimulateTransaction, isVerbose)
60-
core.PanicOnError(fmt.Sprintf("failed to %s validator proof", func() string {
61+
utils.PanicOnError(fmt.Sprintf("failed to %s validator proof", func() string {
6162
if args.SimulateTransaction {
6263
return "simulate"
6364
} else {
@@ -66,7 +67,7 @@ func CredentialsCommand(args TCredentialCommandArgs) error {
6667
}()), err)
6768

6869
if args.SimulateTransaction {
69-
out := utils.Map(txns, func(txn *types.Transaction, _ uint64) CredentialProofTransaction {
70+
out := lo.Map(txns, func(txn *types.Transaction, _ int) CredentialProofTransaction {
7071
gas := txn.Gas()
7172
return CredentialProofTransaction{
7273
Transaction: Transaction{
@@ -80,12 +81,12 @@ func CredentialsCommand(args TCredentialCommandArgs) error {
8081
return nil
8182
}(),
8283
},
83-
ValidatorIndices: utils.Map(utils.Flatten(indices), func(index *big.Int, _ uint64) uint64 {
84+
ValidatorIndices: lo.Map(lo.Flatten(indices), func(index *big.Int, _ int) uint64 {
8485
return index.Uint64()
8586
}),
8687
}
8788
})
88-
printAsJSON(out)
89+
PrintAsJSON(out)
8990
} else {
9091
for i, txn := range txns {
9192
color.Green("transaction(%d): %s", i, txn.Hash().Hex())

cli/commands/findStalePods.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core"
8+
"github.com/Layr-Labs/eigenpod-proofs-generation/cli/core/utils"
89
"github.com/fatih/color"
910
)
1011

@@ -17,14 +18,14 @@ type TFindStalePodsCommandArgs struct {
1718

1819
func FindStalePodsCommand(args TFindStalePodsCommandArgs) error {
1920
ctx := context.Background()
20-
eth, beacon, chainId, err := core.GetClients(ctx, args.EthNode, args.BeaconNode /* verbose */, args.Verbose)
21-
core.PanicOnError("failed to dial clients", err)
21+
eth, beacon, chainId, err := utils.GetClients(ctx, args.EthNode, args.BeaconNode /* verbose */, args.Verbose)
22+
utils.PanicOnError("failed to dial clients", err)
2223

2324
results, err := core.FindStaleEigenpods(ctx, eth, args.EthNode, beacon, chainId, args.Verbose, args.Tolerance)
24-
core.PanicOnError("failed to find stale eigenpods", err)
25+
utils.PanicOnError("failed to find stale eigenpods", err)
2526

2627
if !args.Verbose {
27-
printAsJSON(results)
28+
PrintAsJSON(results)
2829
return nil
2930
}
3031

0 commit comments

Comments
 (0)