Skip to content

Commit 64463d8

Browse files
authored
feat: bump go mod versions and trim leading 0x on private keys (#181)
* chore: bump go mod versions * refactor: consolidate prepare account logic
1 parent 9172c32 commit 64463d8

File tree

3 files changed

+108
-120
lines changed

3 files changed

+108
-120
lines changed

cli/core/utils/utils.go

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -595,52 +595,30 @@ func PanicIfNoConsent(prompt string) {
595595
}
596596

597597
func PrepareAccount(owner *string, chainID *big.Int, noSend bool) (*Owner, error) {
598-
if noSend {
599-
isSimulatingGas := owner != nil && *owner != ""
600-
var senderPk = func() string {
601-
if owner == nil || *owner == "" {
602-
return "372d94b8645091147a5dfc10a454d0d539773d2431293bf0a195b44fa5ddbb33" // this is a RANDOM private key. Do not use this for anything.
598+
isSimulatingGas := owner != nil && *owner != ""
599+
senderPk, err := func() (string, error) {
600+
// if we're trying to send a transaction, make sure we were supplied a private key
601+
if owner == nil || *owner == "" {
602+
if !noSend {
603+
return "", errors.New("no private key supplied")
603604
}
604-
return *owner
605-
}()
606605

607-
privateKey, err := crypto.HexToECDSA(senderPk)
608-
if err != nil {
609-
return nil, err
610-
}
611-
612-
publicKey := privateKey.Public()
613-
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
614-
if !ok {
615-
log.Fatal("error casting public key to ECDSA")
616-
}
617-
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
618-
auth, err := bind.NewKeyedTransactorWithChainID(privateKey, chainID)
619-
if err != nil {
620-
return nil, err
606+
return "372d94b8645091147a5dfc10a454d0d539773d2431293bf0a195b44fa5ddbb33", nil // this is a RANDOM private key used as a default value. do not use.
621607
}
622608

623-
if !isSimulatingGas {
624-
auth.GasPrice = nil // big.NewInt(10) // Gas price to use for the transaction execution (nil = gas price oracle)
625-
auth.GasFeeCap = big.NewInt(10) // big.NewInt(10) // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
626-
auth.GasTipCap = big.NewInt(2) // big.NewInt(2) // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
627-
auth.GasLimit = 21000
628-
}
629-
auth.NoSend = true
609+
return *owner, nil
610+
}()
630611

631-
return &Owner{
632-
FromAddress: fromAddress,
633-
PublicKey: nil,
634-
TransactionOptions: auth,
635-
IsDryRun: true,
636-
}, nil
612+
if err != nil {
613+
return nil, err
637614
}
638615

639-
if owner == nil {
640-
return nil, errors.New("no owner")
616+
// trim leading "0x" if needed
617+
if senderPk[0:2] == "0x" {
618+
senderPk = senderPk[2:]
641619
}
642620

643-
privateKey, err := crypto.HexToECDSA(*owner)
621+
privateKey, err := crypto.HexToECDSA(senderPk)
644622
if err != nil {
645623
return nil, err
646624
}
@@ -656,6 +634,14 @@ func PrepareAccount(owner *string, chainID *big.Int, noSend bool) (*Owner, error
656634
return nil, err
657635
}
658636

637+
auth.NoSend = noSend
638+
if noSend && !isSimulatingGas {
639+
auth.GasPrice = nil // big.NewInt(10) // Gas price to use for the transaction execution (nil = gas price oracle)
640+
auth.GasFeeCap = big.NewInt(10) // big.NewInt(10) // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
641+
auth.GasTipCap = big.NewInt(2) // big.NewInt(2) // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
642+
auth.GasLimit = 21000
643+
}
644+
659645
return &Owner{
660646
FromAddress: fromAddress,
661647
PublicKey: publicKeyECDSA,

go.mod

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module github.com/Layr-Labs/eigenpod-proofs-generation
22

3-
go 1.22.0
3+
go 1.23.0
44

5-
toolchain go1.22.4
5+
toolchain go1.23.10
66

77
require (
8-
github.com/Layr-Labs/eigenlayer-contracts v1.4.1-testnet-holeksy.0.20250515141756-179e268ddbff
8+
github.com/Layr-Labs/eigenlayer-contracts v1.6.0
99
github.com/attestantio/go-eth2-client v0.24.0
10-
github.com/ethereum/go-ethereum v1.14.9
10+
github.com/ethereum/go-ethereum v1.16.1
1111
github.com/fatih/color v1.18.0
1212
github.com/ferranbt/fastssz v0.1.4
1313
github.com/hashicorp/golang-lru/v2 v2.0.7
@@ -17,27 +17,25 @@ require (
1717
github.com/pkg/errors v0.9.1
1818
github.com/rs/zerolog v1.32.0
1919
github.com/samber/lo v1.47.0
20-
github.com/stretchr/testify v1.9.0
21-
github.com/urfave/cli/v2 v2.27.1
20+
github.com/stretchr/testify v1.10.0
21+
github.com/urfave/cli/v2 v2.27.5
2222
)
2323

2424
require (
2525
github.com/Microsoft/go-winio v0.6.2 // indirect
2626
github.com/beorn7/perks v1.0.1 // indirect
27-
github.com/bits-and-blooms/bitset v1.14.3 // indirect
28-
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
27+
github.com/bits-and-blooms/bitset v1.20.0 // indirect
2928
github.com/cespare/xxhash/v2 v2.3.0 // indirect
30-
github.com/consensys/bavard v0.1.16 // indirect
31-
github.com/consensys/gnark-crypto v0.14.0 // indirect
32-
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
29+
github.com/consensys/gnark-crypto v0.18.0 // indirect
30+
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
31+
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
3332
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
34-
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
3533
github.com/davecgh/go-spew v1.1.1 // indirect
3634
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
3735
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
3836
github.com/emicklei/dot v1.6.4 // indirect
39-
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
40-
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
37+
github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect
38+
github.com/ethereum/go-verkle v0.2.2 // indirect
4139
github.com/fsnotify/fsnotify v1.7.0 // indirect
4240
github.com/go-logr/logr v1.2.4 // indirect
4341
github.com/go-logr/stdr v1.2.2 // indirect
@@ -51,7 +49,6 @@ require (
5149
github.com/mattn/go-colorable v0.1.14 // indirect
5250
github.com/mattn/go-isatty v0.0.20 // indirect
5351
github.com/mitchellh/mapstructure v1.5.0 // indirect
54-
github.com/mmcloughlin/addchain v0.4.0 // indirect
5552
github.com/pk910/dynamic-ssz v0.0.4 // indirect
5653
github.com/pmezard/go-difflib v1.0.0 // indirect
5754
github.com/prometheus/client_golang v1.19.0 // indirect
@@ -62,24 +59,23 @@ require (
6259
github.com/r3labs/sse/v2 v2.10.0 // indirect
6360
github.com/russross/blackfriday/v2 v2.1.0 // indirect
6461
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
65-
github.com/supranational/blst v0.3.13 // indirect
62+
github.com/supranational/blst v0.3.14 // indirect
6663
github.com/tklauser/go-sysconf v0.3.14 // indirect
6764
github.com/tklauser/numcpus v0.8.0 // indirect
68-
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
65+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
6966
github.com/yusufpapurcu/wmi v1.2.4 // indirect
7067
go.opentelemetry.io/otel v1.16.0 // indirect
7168
go.opentelemetry.io/otel/metric v1.16.0 // indirect
7269
go.opentelemetry.io/otel/trace v1.16.0 // indirect
73-
golang.org/x/crypto v0.33.0 // indirect
70+
golang.org/x/crypto v0.36.0 // indirect
7471
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
75-
golang.org/x/net v0.29.0 // indirect
76-
golang.org/x/sync v0.11.0 // indirect
77-
golang.org/x/sys v0.30.0 // indirect
78-
golang.org/x/text v0.22.0 // indirect
72+
golang.org/x/net v0.38.0 // indirect
73+
golang.org/x/sync v0.12.0 // indirect
74+
golang.org/x/sys v0.31.0 // indirect
75+
golang.org/x/text v0.23.0 // indirect
7976
google.golang.org/protobuf v1.34.2 // indirect
8077
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
8178
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
8279
gopkg.in/yaml.v2 v2.4.0 // indirect
8380
gopkg.in/yaml.v3 v3.0.1 // indirect
84-
rsc.io/tmplfunc v0.0.3 // indirect
8581
)

0 commit comments

Comments
 (0)