Skip to content

Commit

Permalink
get secret path instead of values
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim committed Mar 18, 2024
1 parent e7a6412 commit 0665961
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions avssync.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,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}, []types.QuorumNum{types.QuorumNum(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 @@ -164,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}, []types.QuorumNum{types.QuorumNum(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
10 changes: 5 additions & 5 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ var (
Usage: "Fireblocks API Key. Ignored if ecdsa-private-key is set.",
EnvVar: envVarPrefix + "FIREBLOCKS_API_KEY",
}
FireblocksAPISecretFlag = cli.StringFlag{
Name: "fireblocks-api-secret",
Usage: "Fireblocks API Secret. Ignored if ecdsa-private-key is set.",
EnvVar: envVarPrefix + "FIREBLOCKS_API_SECRET",
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",
Expand Down Expand Up @@ -121,7 +121,7 @@ var OptionalFlags = []cli.Flag{
retrySyncNTimes,
EcdsaPrivateKeyFlag,
FireblocksAPIKeyFlag,
FireblocksAPISecretFlag,
FireblocksAPISecretPathFlag,
FireblocksBaseURLFlag,
FireblocksVaultAccountNameFlag,
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Layr-Labs/avs-sync
go 1.21.2

require (
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240314000707-2e4582065143
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240316185645-e035f359ddfa
github.com/ethereum/go-ethereum v1.13.14
github.com/testcontainers/testcontainers-go v0.29.1
github.com/urfave/cli v1.22.14
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ github.com/Layr-Labs/eigensdk-go v0.1.2 h1:0CbdLMr9IPWFW3RPfPORFWQYgXMAa/K4tA8rn
github.com/Layr-Labs/eigensdk-go v0.1.2/go.mod h1:J+d9zxN4VyMtchmsPzGASFcCjpnh1eT4aE2ggiqOz/g=
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240314000707-2e4582065143 h1:rE3u3EFI3G/VVjxiXL5YbDBqyzZSNGnZcppwjaef0Dk=
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240314000707-2e4582065143/go.mod h1:J+d9zxN4VyMtchmsPzGASFcCjpnh1eT4aE2ggiqOz/g=
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240316050204-63be00407527 h1:jxEWXjCfmHT+yUG8VfEKlBjIgOQneBGGbtqwmwPpxtM=
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240316050204-63be00407527/go.mod h1:J+d9zxN4VyMtchmsPzGASFcCjpnh1eT4aE2ggiqOz/g=
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240316185645-e035f359ddfa h1:c19dWUGTbIhQxbVZko9CCikC3M151OeWNZOOcpjZxOs=
github.com/Layr-Labs/eigensdk-go v0.1.3-0.20240316185645-e035f359ddfa/go.mod h1:J+d9zxN4VyMtchmsPzGASFcCjpnh1eT4aE2ggiqOz/g=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
Expand Down
20 changes: 12 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func avsSyncMain(cliCtx *cli.Context) error {
}

var wallet walletsdk.Wallet
var sender common.Address
operatorEcdsaPrivKeyHexStr := cliCtx.String(EcdsaPrivateKeyFlag.Name)
if len(operatorEcdsaPrivKeyHexStr) > 0 {
ecdsaPrivKey, err := crypto.HexToECDSA(operatorEcdsaPrivKeyHexStr)
Expand All @@ -74,16 +73,15 @@ func avsSyncMain(cliCtx *cli.Context) error {
if err != nil {
return err
}
sender = address
} else {
fbAPIKey := cliCtx.String(FireblocksAPIKeyFlag.Name)
fbSecret := cliCtx.String(FireblocksAPISecretFlag.Name)
fbSecretPath := cliCtx.String(FireblocksAPISecretPathFlag.Name)
fbBaseURL := cliCtx.String(FireblocksBaseURLFlag.Name)
fbVaultAccountName := cliCtx.String(FireblocksVaultAccountNameFlag.Name)
if fbAPIKey == "" {
return errors.New("Fireblocks API key is not set")
}
if fbSecret == "" {
if fbSecretPath == "" {
return errors.New("Fireblocks API secret is not set")
}
if fbBaseURL == "" {
Expand All @@ -93,9 +91,13 @@ func avsSyncMain(cliCtx *cli.Context) error {
return errors.New("Fireblocks vault account name is not set")
}

secretKey, err := os.ReadFile(fbSecretPath)
if err != nil {
return fmt.Errorf("Cannot read fireblocks secret from %s: %w", fbSecretPath, err)
}
fireblocksClient, err := fireblocks.NewClient(
fbAPIKey,
[]byte(fbSecret),
[]byte(secretKey),
fbBaseURL,
writerTimeout,
logger,
Expand All @@ -107,11 +109,13 @@ func avsSyncMain(cliCtx *cli.Context) error {
if err != nil {
return err
}
// TODO: read this from wallet
// sender, err = wallet.SenderAddress()
sender = common.HexToAddress("0x0000000000000000000000000000000000000123")
}

sender, err := wallet.SenderAddress(context.Background())
if err != nil {
return fmt.Errorf("Cannot get sender address: %w", err)
}
logger.Infof("Sender address: %s", sender.Hex())
txMgr := txmgr.NewSimpleTxManager(wallet, ethHttpClient, logger, sender)

avsWriter, err := avsregistry.BuildAvsRegistryChainWriter(
Expand Down

0 comments on commit 0665961

Please sign in to comment.