Skip to content

Commit

Permalink
Merge pull request #19 from Layr-Labs/hot-wallet
Browse files Browse the repository at this point in the history
Integrate with eigensdk wallet
  • Loading branch information
ian-shim authored Mar 18, 2024
2 parents 43beab3 + e8eed2b commit 98723bb
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 178 deletions.
5 changes: 3 additions & 2 deletions avssync.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry"
sdklogging "github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/types"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)
Expand Down Expand Up @@ -150,7 +151,7 @@ func (a *AvsSync) tryNTimesUpdateStakesOfEntireOperatorSetForQuorum(quorum byte,
defer cancel()
// we need to refetch the operator set because one reason for update stakes failing is that the operator set has changed
// in between us fetching it and trying to update it (the contract makes sure the entire operator set is updated and reverts if not)
operatorAddrsPerQuorum, err := a.avsReader.GetOperatorAddrsInQuorumsAtCurrentBlock(&bind.CallOpts{Context: timeoutCtx}, []byte{quorum})
operatorAddrsPerQuorum, err := a.avsReader.GetOperatorAddrsInQuorumsAtCurrentBlock(&bind.CallOpts{Context: timeoutCtx}, types.QuorumNums{types.QuorumNum(quorum)})
if err != nil {
a.logger.Error("Error fetching operator addresses in quorums", "err", err, "quorum", quorum, "retryNTimes", retryNTimes, "try", i+1)
continue
Expand All @@ -163,7 +164,7 @@ func (a *AvsSync) tryNTimesUpdateStakesOfEntireOperatorSetForQuorum(quorum byte,
a.logger.Infof("Updating stakes of operators in quorum %d: %v", int(quorum), operators)
timeoutCtx, cancel = context.WithTimeout(context.Background(), a.writerTimeoutDuration)
defer cancel()
_, err = a.avsWriter.UpdateStakesOfEntireOperatorSetForQuorums(timeoutCtx, [][]common.Address{operators}, []byte{quorum})
_, err = a.avsWriter.UpdateStakesOfEntireOperatorSetForQuorums(timeoutCtx, [][]common.Address{operators}, types.QuorumNums{types.QuorumNum(quorum)})
if err != nil {
a.logger.Error("Error updating stakes of entire operator set for quorum", "err", err, "quorum", int(quorum))
continue
Expand Down
39 changes: 32 additions & 7 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ var envVarPrefix = "AVS_SYNC_"

var (
/* Required Flags */
EcdsaPrivateKeyFlag = cli.StringFlag{
Name: "ecdsa-private-key",
Required: true,
Usage: "Ethereum ecdsa private key",
EnvVar: envVarPrefix + "ECDSA_PRIVATE_KEY",
}
RegistryCoordinatorAddrFlag = cli.StringFlag{
Name: "registry-coordinator-addr",
Required: true,
Expand Down Expand Up @@ -81,10 +75,36 @@ var (
Value: 3,
EnvVar: envVarPrefix + "RETRY_SYNC_N_TIMES",
}
EcdsaPrivateKeyFlag = cli.StringFlag{
Name: "ecdsa-private-key",
Usage: "Ethereum ecdsa private key. If not set, Fireblocks credentials must be set.",
EnvVar: envVarPrefix + "ECDSA_PRIVATE_KEY",
}
// Fireblocks flags
FireblocksAPIKeyFlag = cli.StringFlag{
Name: "fireblocks-api-key",
Usage: "Fireblocks API Key. Ignored if ecdsa-private-key is set.",
EnvVar: envVarPrefix + "FIREBLOCKS_API_KEY",
}
FireblocksAPISecretPathFlag = cli.StringFlag{
Name: "fireblocks-api-secret-path",
Usage: "Path to Fireblocks API Secret. Ignored if ecdsa-private-key is set.",
EnvVar: envVarPrefix + "FIREBLOCKS_API_SECRET_PATH",
}
FireblocksBaseURLFlag = cli.StringFlag{
Name: "fireblocks-api-url",
Usage: "Fireblocks API URL. Ignored if ecdsa-private-key is set.",
EnvVar: envVarPrefix + "FIREBLOCKS_API_URL",
Value: "https://api.fireblocks.io",
}
FireblocksVaultAccountNameFlag = cli.StringFlag{
Name: "fireblocks-vault-account-name",
Usage: "Fireblocks Vault Account Name. Ignored if ecdsa-private-key is set.",
EnvVar: envVarPrefix + "FIREBLOCKS_VAULT_ACCOUNT_NAME",
}
)

var RequiredFlags = []cli.Flag{
EcdsaPrivateKeyFlag,
RegistryCoordinatorAddrFlag,
OperatorStateRetrieverAddrFlag,
EthHttpUrlFlag,
Expand All @@ -99,6 +119,11 @@ var OptionalFlags = []cli.Flag{
ReaderTimeoutDurationFlag,
WriterTimeoutDurationFlag,
retrySyncNTimes,
EcdsaPrivateKeyFlag,
FireblocksAPIKeyFlag,
FireblocksAPISecretPathFlag,
FireblocksBaseURLFlag,
FireblocksVaultAccountNameFlag,
}

func init() {
Expand Down
44 changes: 25 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/Layr-Labs/avs-sync
go 1.21.2

require (
github.com/Layr-Labs/eigensdk-go v0.1.1
github.com/ethereum/go-ethereum v1.13.12
github.com/testcontainers/testcontainers-go v0.26.0
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240318050546-8d038f135826
github.com/ethereum/go-ethereum v1.13.14
github.com/testcontainers/testcontainers-go v0.29.1
github.com/urfave/cli v1.22.14
go.uber.org/mock v0.3.0
go.uber.org/mock v0.4.0
)

require (
Expand All @@ -23,64 +23,70 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v25.0.3+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.23.11 // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Expand Down
Loading

0 comments on commit 98723bb

Please sign in to comment.