Skip to content

Commit 70809f1

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 add more code add more code working slashing %age and comments update with latest contracts Update show.go (#226) updated to latest AM updated to latest AM updated to latest AM
1 parent 69328e4 commit 70809f1

23 files changed

+1858
-21
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

+1-1
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.11
10+
github.com/Layr-Labs/eigensdk-go v0.1.12-0.20241018155539-679b1c56366a
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

+2-2
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.11 h1:ZTOPKGoOyzKfi7DbYI2azMECcjmK2sRtHoPpjCq1MBc=
16-
github.com/Layr-Labs/eigensdk-go v0.1.11/go.mod h1:XcLVDtlB1vOPj63D236b451+SC75B8gwgkpNhYHSxNs=
15+
github.com/Layr-Labs/eigensdk-go v0.1.12-0.20241018155539-679b1c56366a h1:/zU/lLtvpDHvhfDX2cEYYLern3UEoHX9KiBkrkunBG4=
16+
github.com/Layr-Labs/eigensdk-go v0.1.12-0.20241018155539-679b1c56366a/go.mod h1:39gZE9jybgmpncEruNnY2G8OCHT0/3bOegQWYTbszd0=
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/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

+46
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package common
33
import (
44
"fmt"
55
"math/big"
6+
"strconv"
67
"strings"
78

9+
"github.com/ethereum/go-ethereum/common"
810
"github.com/ethereum/go-ethereum/core/types"
911
)
1012

@@ -46,3 +48,47 @@ func GetTxFeeDetails(tx *types.Transaction) *TxFeeDetails {
4648
GasFeeCapGwei: gasFeeCapGwei,
4749
}
4850
}
51+
52+
func ConvertStringSliceToGethAddressSlice(addresses []string) []common.Address {
53+
gethAddresses := make([]common.Address, 0, len(addresses))
54+
for _, address := range addresses {
55+
parsed := common.HexToAddress(address)
56+
gethAddresses = append(gethAddresses, parsed)
57+
}
58+
return gethAddresses
59+
}
60+
61+
func ShortEthAddress(address common.Address) string {
62+
return fmt.Sprintf("%s...%s", address.Hex()[:6], address.Hex()[len(address.Hex())-4:])
63+
}
64+
65+
func Uint64ToString(num uint64) string {
66+
return strconv.FormatUint(num, 10)
67+
}
68+
69+
func FormatNumberWithUnderscores(numStr string) string {
70+
71+
// If the number is less than 1000, no formatting is needed
72+
if len(numStr) <= 3 {
73+
return numStr
74+
}
75+
76+
// Calculate the number of groups of 3 digits
77+
groups := (len(numStr) - 1) / 3
78+
79+
// Create a slice to hold the result
80+
result := make([]byte, len(numStr)+groups)
81+
82+
// Fill the result slice from right to left
83+
resultIndex := len(result) - 1
84+
for i := len(numStr) - 1; i >= 0; i-- {
85+
if (len(numStr)-i-1)%3 == 0 && i != len(numStr)-1 {
86+
result[resultIndex] = '_'
87+
resultIndex--
88+
}
89+
result[resultIndex] = numStr[i]
90+
resultIndex--
91+
}
92+
93+
return string(result)
94+
}

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

+21
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@ func GetAVSDirectoryAddress(chainID *big.Int) (string, error) {
317317
}
318318
}
319319

320+
func GetDelegationManagerAddress(chainID *big.Int) (string, error) {
321+
chainIDInt := chainID.Int64()
322+
chainMetadata, ok := ChainMetadataMap[chainIDInt]
323+
if !ok {
324+
return "", fmt.Errorf("chain ID %d not supported", chainIDInt)
325+
} else {
326+
return chainMetadata.ELDelegationManagerAddress, nil
327+
}
328+
}
329+
320330
func GetTransactionLink(txHash string, chainId *big.Int) string {
321331
chainIDInt := chainId.Int64()
322332
chainMetadata, ok := ChainMetadataMap[chainIDInt]
@@ -473,3 +483,14 @@ func GetNoSendTxOpts(from common.Address) *bind.TransactOpts {
473483
func Trim0x(s string) string {
474484
return strings.TrimPrefix(s, "0x")
475485
}
486+
487+
func GetEnvFromNetwork(network string) string {
488+
switch network {
489+
case utils.HoleskyNetworkName:
490+
return "testnet"
491+
case utils.MainnetNetworkName:
492+
return "mainnet"
493+
default:
494+
return "local"
495+
}
496+
}

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)