Skip to content

Commit 9f3068a

Browse files
committed
feat: slashing commands
feat: add working cmds remove unrelated changes remove unrelated changes unsigned tx add some tests comment add readme more allocations basic show command update with latest contracts
1 parent 11fe204 commit 9f3068a

22 files changed

+1539
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ operator-config.yaml.old
88
operator.yaml
99
operator.yaml.old
1010
config/*
11+
updates.csv
1112

1213
# build
1314
dist/

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module github.com/Layr-Labs/eigenlayer-cli
22

33
go 1.21.11
44

5+
replace github.com/Layr-Labs/eigensdk-go v0.1.10 => /Users/madhurshrimal/Desktop/github/Layr-Labs/eigensdk-go
6+
57
require (
68
github.com/AlecAivazis/survey/v2 v2.3.7
79
github.com/Layr-Labs/eigenlayer-contracts v0.3.2-mainnet-rewards

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.10 h1:Uxf0MaBJNiFjEdNGuCmm/U
1212
github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.10/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.10 h1:VWXSoJ0Vm2ZEfSPgftOgmek3xwXKRmeKrNFXfMJJlko=
16-
github.com/Layr-Labs/eigensdk-go v0.1.10/go.mod h1:XcLVDtlB1vOPj63D236b451+SC75B8gwgkpNhYHSxNs=
1715
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1816
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
1917
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=

pkg/internal/common/contracts.go

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package common
22

33
import (
4+
"context"
45
"errors"
56
"math/big"
67

@@ -57,3 +58,14 @@ func GetELWriter(
5758

5859
return eLWriter, nil
5960
}
61+
62+
func IsSmartContractAddress(address gethcommon.Address, ethClient *ethclient.Client) bool {
63+
code, err := ethClient.CodeAt(context.Background(), address, nil)
64+
if err != nil {
65+
// We return true here because we want to treat the address as a smart contract
66+
// This is only used to gas estimation and creating unsigned transactions
67+
// So it's fine if eth client return an error
68+
return true
69+
}
70+
return len(code) > 0
71+
}

pkg/internal/common/eth.go

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"math/big"
66
"strings"
77

8+
"github.com/ethereum/go-ethereum/common"
89
"github.com/ethereum/go-ethereum/core/types"
910
)
1011

@@ -46,3 +47,12 @@ func GetTxFeeDetails(tx *types.Transaction) *TxFeeDetails {
4647
GasFeeCapGwei: gasFeeCapGwei,
4748
}
4849
}
50+
51+
func ConvertStringSliceToGethAddressSlice(addresses []string) []common.Address {
52+
gethAddresses := make([]common.Address, 0, len(addresses))
53+
for _, address := range addresses {
54+
parsed := common.HexToAddress(address)
55+
gethAddresses = append(gethAddresses, parsed)
56+
}
57+
return gethAddresses
58+
}

pkg/internal/common/flags/avs.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package flags
2+
3+
import "github.com/urfave/cli/v2"
4+
5+
var (
6+
AVSAddressesFlag = cli.StringSliceFlag{
7+
Name: "avs-addresses",
8+
Usage: "AVS addresses",
9+
Aliases: []string{"aa"},
10+
EnvVars: []string{"AVS_ADDRESSES"},
11+
}
12+
13+
AVSAddressFlag = cli.StringFlag{
14+
Name: "avs-address",
15+
Usage: "AVS addresses",
16+
Aliases: []string{"aa"},
17+
EnvVars: []string{"AVS_ADDRESS"},
18+
}
19+
20+
StrategyAddressesFlag = cli.StringSliceFlag{
21+
Name: "strategy-addresses",
22+
Usage: "Strategy addresses",
23+
Aliases: []string{"sa"},
24+
EnvVars: []string{"STRATEGY_ADDRESSES"},
25+
}
26+
27+
StrategyAddressFlag = cli.StringFlag{
28+
Name: "strategy-address",
29+
Usage: "Strategy addresses",
30+
Aliases: []string{"sa"},
31+
EnvVars: []string{"STRATEGY_ADDRESS"},
32+
}
33+
34+
OperatorSetIdFlag = cli.Uint64Flag{
35+
Name: "operator-set-id",
36+
Usage: "Operator set ID",
37+
Aliases: []string{"osid"},
38+
EnvVars: []string{"OPERATOR_SET_ID"},
39+
}
40+
)

pkg/internal/common/flags/general.go

+21
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,25 @@ var (
7575
Usage: "Enable verbose logging",
7676
EnvVars: []string{"VERBOSE"},
7777
}
78+
79+
OperatorAddressFlag = cli.StringFlag{
80+
Name: "operator-address",
81+
Aliases: []string{"oa", "operator"},
82+
Usage: "Operator address",
83+
EnvVars: []string{"OPERATOR_ADDRESS"},
84+
}
85+
86+
CSVFileFlag = cli.StringFlag{
87+
Name: "csv-file",
88+
Aliases: []string{"csv"},
89+
Usage: "CSV file to read data from",
90+
EnvVars: []string{"CSV_FILE"},
91+
}
92+
93+
EnvironmentFlag = cli.StringFlag{
94+
Name: "environment",
95+
Aliases: []string{"env"},
96+
Usage: "environment to use. Currently supports 'preprod' ,'testnet' and 'prod'. If not provided, it will be inferred based on network",
97+
EnvVars: []string{"ENVIRONMENT"},
98+
}
7899
)

pkg/internal/common/helper.go

+11
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,14 @@ func GetNoSendTxOpts(from common.Address) *bind.TransactOpts {
473473
func Trim0x(s string) string {
474474
return strings.TrimPrefix(s, "0x")
475475
}
476+
477+
func GetEnvFromNetwork(network string) string {
478+
switch network {
479+
case utils.HoleskyNetworkName:
480+
return "testnet"
481+
case utils.MainnetNetworkName:
482+
return "mainnet"
483+
default:
484+
return "local"
485+
}
486+
}

pkg/operator.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func OperatorCmd(p utils.Prompter) *cli.Command {
1717
operator.StatusCmd(p),
1818
operator.UpdateCmd(p),
1919
operator.UpdateMetadataURICmd(p),
20+
operator.AllocationsCmd(p),
2021
},
2122
}
2223

pkg/operator/allocations.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package operator
2+
3+
import (
4+
"github.com/Layr-Labs/eigenlayer-cli/pkg/operator/allocations"
5+
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"
6+
"github.com/urfave/cli/v2"
7+
)
8+
9+
func AllocationsCmd(p utils.Prompter) *cli.Command {
10+
var allocationsCmd = &cli.Command{
11+
Name: "allocations",
12+
Usage: "Stake allocation commands for operators",
13+
Subcommands: []*cli.Command{
14+
allocations.ShowCmd(p),
15+
allocations.UpdateCmd(p),
16+
allocations.InitializeDelayCmd(p),
17+
},
18+
}
19+
20+
return allocationsCmd
21+
}

pkg/operator/allocations/README.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## Allocations Command
2+
### Initialize Delay
3+
```bash
4+
eigenlayer operator allocations initialize-delay --help
5+
NAME:
6+
eigenlayer operator allocations initialize-delay - Initialize the allocation delay for operator
7+
8+
USAGE:
9+
initialize-delay [flags] <delay>
10+
11+
DESCRIPTION:
12+
Initializes the allocation delay for operator. This is a one time command. You can not change the allocation delay once
13+
14+
OPTIONS:
15+
--broadcast, -b Use this flag to broadcast the transaction (default: false) [$BROADCAST]
16+
--ecdsa-private-key value, -e value ECDSA private key hex to send transaction [$ECDSA_PRIVATE_KEY]
17+
--environment value, --env value environment to use. Currently supports 'preprod' ,'testnet' and 'prod'. If not provided, it will be inferred based on network [$ENVIRONMENT]
18+
--eth-rpc-url value, -r value URL of the Ethereum RPC [$ETH_RPC_URL]
19+
--fireblocks-api-key value, --ff value Fireblocks API key [$FIREBLOCKS_API_KEY]
20+
--fireblocks-aws-region value, --fa value AWS region if secret is stored in AWS KMS (default: "us-east-1") [$FIREBLOCKS_AWS_REGION]
21+
--fireblocks-base-url value, --fb value Fireblocks base URL [$FIREBLOCKS_BASE_URL]
22+
--fireblocks-secret-key value, --fs value Fireblocks secret key. If you are using AWS Secret Manager, this should be the secret name. [$FIREBLOCKS_SECRET_KEY]
23+
--fireblocks-secret-storage-type value, --fst value Fireblocks secret storage type. Supported values are 'plaintext' and 'aws_secret_manager' [$FIREBLOCKS_SECRET_STORAGE_TYPE]
24+
--fireblocks-timeout value, --ft value Fireblocks timeout (default: 30) [$FIREBLOCKS_TIMEOUT]
25+
--fireblocks-vault-account-name value, --fv value Fireblocks vault account name [$FIREBLOCKS_VAULT_ACCOUNT_NAME]
26+
--network value, -n value Network to use. Currently supports 'holesky' and 'mainnet' (default: "holesky") [$NETWORK]
27+
--operator-address value, --oa value, --operator value Operator address [$OPERATOR_ADDRESS]
28+
--output-file value, -o value Output file to write the data [$OUTPUT_FILE]
29+
--output-type value, --ot value Output format of the command. One of 'pretty', 'json' or 'calldata' (default: "pretty") [$OUTPUT_TYPE]
30+
--path-to-key-store value, -k value Path to the key store used to send transactions [$PATH_TO_KEY_STORE]
31+
--verbose, -v Enable verbose logging (default: false) [$VERBOSE]
32+
--web3signer-url value, -w value URL of the Web3Signer [$WEB3SIGNER_URL]
33+
--help, -h show help
34+
```
35+
36+
### Update allocations
37+
```bash
38+
eigenlayer operator allocations update --help
39+
NAME:
40+
eigenlayer operator allocations update - Update allocations
41+
42+
USAGE:
43+
update
44+
45+
DESCRIPTION:
46+
47+
Command to update allocations
48+
49+
50+
OPTIONS:
51+
--avs-address value, --aa value AVS addresses [$AVS_ADDRESS]
52+
--bips-to-allocate value, --bta value, --bips value, --bps value Bips to allocate to the strategy (default: 0) [$BIPS_TO_ALLOCATE]
53+
--broadcast, -b Use this flag to broadcast the transaction (default: false) [$BROADCAST]
54+
--csv-file value, --csv value CSV file to read data from [$CSV_FILE]
55+
--ecdsa-private-key value, -e value ECDSA private key hex to send transaction [$ECDSA_PRIVATE_KEY]
56+
--environment value, --env value environment to use. Currently supports 'preprod' ,'testnet' and 'prod'. If not provided, it will be inferred based on network [$ENVIRONMENT]
57+
--eth-rpc-url value, -r value URL of the Ethereum RPC [$ETH_RPC_URL]
58+
--fireblocks-api-key value, --ff value Fireblocks API key [$FIREBLOCKS_API_KEY]
59+
--fireblocks-aws-region value, --fa value AWS region if secret is stored in AWS KMS (default: "us-east-1") [$FIREBLOCKS_AWS_REGION]
60+
--fireblocks-base-url value, --fb value Fireblocks base URL [$FIREBLOCKS_BASE_URL]
61+
--fireblocks-secret-key value, --fs value Fireblocks secret key. If you are using AWS Secret Manager, this should be the secret name. [$FIREBLOCKS_SECRET_KEY]
62+
--fireblocks-secret-storage-type value, --fst value Fireblocks secret storage type. Supported values are 'plaintext' and 'aws_secret_manager' [$FIREBLOCKS_SECRET_STORAGE_TYPE]
63+
--fireblocks-timeout value, --ft value Fireblocks timeout (default: 30) [$FIREBLOCKS_TIMEOUT]
64+
--fireblocks-vault-account-name value, --fv value Fireblocks vault account name [$FIREBLOCKS_VAULT_ACCOUNT_NAME]
65+
--network value, -n value Network to use. Currently supports 'holesky' and 'mainnet' (default: "holesky") [$NETWORK]
66+
--operator-address value, --oa value, --operator value Operator address [$OPERATOR_ADDRESS]
67+
--operator-set-id value, --osid value Operator set ID (default: 0) [$OPERATOR_SET_ID]
68+
--output-file value, -o value Output file to write the data [$OUTPUT_FILE]
69+
--output-type value, --ot value Output format of the command. One of 'pretty', 'json' or 'calldata' (default: "pretty") [$OUTPUT_TYPE]
70+
--path-to-key-store value, -k value Path to the key store used to send transactions [$PATH_TO_KEY_STORE]
71+
--strategy-address value, --sa value Strategy addresses [$STRATEGY_ADDRESS]
72+
--verbose, -v Enable verbose logging (default: false) [$VERBOSE]
73+
--web3signer-url value, -w value URL of the Web3Signer [$WEB3SIGNER_URL]
74+
--help, -h show help
75+
```

pkg/operator/allocations/flags.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package allocations
2+
3+
import "github.com/urfave/cli/v2"
4+
5+
var (
6+
BipsToAllocateFlag = cli.Uint64Flag{
7+
Name: "bips-to-allocate",
8+
Aliases: []string{"bta", "bips", "bps"},
9+
Usage: "Bips to allocate to the strategy",
10+
EnvVars: []string{"BIPS_TO_ALLOCATE"},
11+
}
12+
13+
EnvironmentFlag = cli.StringFlag{
14+
Name: "environment",
15+
Aliases: []string{"env"},
16+
Usage: "environment to use. Currently supports 'preprod' ,'testnet' and 'prod'. If not provided, it will be inferred based on network",
17+
EnvVars: []string{"ENVIRONMENT"},
18+
}
19+
)

0 commit comments

Comments
 (0)