Skip to content

Commit 3839e40

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 39cf782 commit 3839e40

File tree

23 files changed

+1861
-25
lines changed

23 files changed

+1861
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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.20240927005004-ed4b05c87610
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
@@ -19,6 +19,7 @@ require (
1919
github.com/tyler-smith/go-bip39 v1.1.0
2020
github.com/urfave/cli/v2 v2.27.2
2121
github.com/wagslane/go-password-validator v0.3.0
22+
github.com/wk8/go-ordered-map/v2 v2.1.8
2223
go.uber.org/mock v0.4.0
2324
gopkg.in/yaml.v2 v2.4.0
2425
gopkg.in/yaml.v3 v3.0.1
@@ -100,7 +101,6 @@ require (
100101
github.com/tklauser/go-sysconf v0.3.12 // indirect
101102
github.com/tklauser/numcpus v0.6.1 // indirect
102103
github.com/wealdtech/go-merkletree/v2 v2.5.2-0.20240302222400-69219c450662 // indirect
103-
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
104104
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
105105
go.opentelemetry.io/otel v1.24.0 // indirect
106106
go.opentelemetry.io/otel/metric v1.24.0 // indirect

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +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/go.mod h1:XcLVDtlB1vOPj63D236b451+SC75B8gwgkpNhYHSxNs=
16-
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20240927005004-ed4b05c87610 h1:lGy4uSImJyOiaM8vSx0CEbsL3rbVfw0uEIuhGey/ubc=
17-
github.com/Layr-Labs/eigensdk-go v0.1.13-0.20240927005004-ed4b05c87610/go.mod h1:bA21qMfmUFZcUe+a1RsDeOGm25xZO802Kfll2GlS8Us=
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=
1817
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1918
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
2019
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
@@ -135,8 +134,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
135134
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
136135
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
137136
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
138-
github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg=
139-
github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
137+
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
138+
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
140139
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
141140
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
142141
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=

pkg/internal/common/contracts.go

Lines changed: 12 additions & 0 deletions
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

Lines changed: 46 additions & 0 deletions
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

Lines changed: 40 additions & 0 deletions
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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,25 @@ var (
8282
Usage: "Suppress unnecessary output",
8383
EnvVars: []string{"SILENT"},
8484
}
85+
86+
OperatorAddressFlag = cli.StringFlag{
87+
Name: "operator-address",
88+
Aliases: []string{"oa", "operator"},
89+
Usage: "Operator address",
90+
EnvVars: []string{"OPERATOR_ADDRESS"},
91+
}
92+
93+
CSVFileFlag = cli.StringFlag{
94+
Name: "csv-file",
95+
Aliases: []string{"csv"},
96+
Usage: "CSV file to read data from",
97+
EnvVars: []string{"CSV_FILE"},
98+
}
99+
100+
EnvironmentFlag = cli.StringFlag{
101+
Name: "environment",
102+
Aliases: []string{"env"},
103+
Usage: "environment to use. Currently supports 'preprod' ,'testnet' and 'prod'. If not provided, it will be inferred based on network",
104+
EnvVars: []string{"ENVIRONMENT"},
105+
}
85106
)

pkg/internal/common/helper.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ func GetAVSDirectoryAddress(chainID *big.Int) (string, error) {
318318
}
319319
}
320320

321+
func GetDelegationManagerAddress(chainID *big.Int) (string, error) {
322+
chainIDInt := chainID.Int64()
323+
chainMetadata, ok := ChainMetadataMap[chainIDInt]
324+
if !ok {
325+
return "", fmt.Errorf("chain ID %d not supported", chainIDInt)
326+
} else {
327+
return chainMetadata.ELDelegationManagerAddress, nil
328+
}
329+
}
330+
321331
func GetTransactionLink(txHash string, chainId *big.Int) string {
322332
chainIDInt := chainId.Int64()
323333
chainMetadata, ok := ChainMetadataMap[chainIDInt]
@@ -479,3 +489,14 @@ func GetNoSendTxOpts(from common.Address) *bind.TransactOpts {
479489
func Trim0x(s string) string {
480490
return strings.TrimPrefix(s, "0x")
481491
}
492+
493+
func GetEnvFromNetwork(network string) string {
494+
switch network {
495+
case utils.HoleskyNetworkName:
496+
return "testnet"
497+
case utils.MainnetNetworkName:
498+
return "mainnet"
499+
default:
500+
return "local"
501+
}
502+
}

pkg/operator.go

Lines changed: 1 addition & 0 deletions
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

Lines changed: 21 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)