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

File tree

23 files changed

+1858
-21
lines changed

23 files changed

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

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.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

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
@@ -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

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

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)