Skip to content

Commit

Permalink
Move fireblocks API timeout to FireblocksConfig (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim authored May 1, 2024
1 parent 1407f54 commit 06f794b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
12 changes: 12 additions & 0 deletions common/fireblocks_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package common

import (
"time"

"github.com/urfave/cli"
)

Expand All @@ -12,6 +14,7 @@ const (
FireblocksWalletAddressFlagName = "fireblocks-wallet-address"
FireblocksSecretManagerRegion = "fireblocks-secret-manager-region"
FireblocksDisable = "fireblocks-disable"
FireblocksAPITimeoutFlagName = "fireblocks-api-timeout"
)

type FireblocksConfig struct {
Expand All @@ -22,6 +25,7 @@ type FireblocksConfig struct {
WalletAddress string
Region string
Disable bool
APITimeout time.Duration
}

func FireblocksCLIFlags(envPrefix string, flagPrefix string) []cli.Flag {
Expand Down Expand Up @@ -68,6 +72,13 @@ func FireblocksCLIFlags(envPrefix string, flagPrefix string) []cli.Flag {
Required: false,
EnvVar: PrefixEnvVar(envPrefix, "FIREBLOCKS_DISABLE"),
},
cli.DurationFlag{
Name: PrefixFlag(flagPrefix, FireblocksAPITimeoutFlagName),
Usage: "Timeout for Fireblocks API requests",
Required: false,
Value: 2 * time.Minute,
EnvVar: PrefixEnvVar(envPrefix, "FIREBLOCKS_API_TIMEOUT"),
},
}
}

Expand All @@ -80,5 +91,6 @@ func ReadFireblocksCLIConfig(ctx *cli.Context, flagPrefix string) FireblocksConf
WalletAddress: ctx.GlobalString(PrefixFlag(flagPrefix, FireblocksWalletAddressFlagName)),
Region: ctx.GlobalString(PrefixFlag(flagPrefix, FireblocksSecretManagerRegion)),
Disable: ctx.GlobalBool(PrefixFlag(flagPrefix, FireblocksDisable)),
APITimeout: ctx.GlobalDuration(PrefixFlag(flagPrefix, FireblocksAPITimeoutFlagName)),
}
}
13 changes: 6 additions & 7 deletions disperser/batcher/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ type QuorumInfo struct {
}

type TimeoutConfig struct {
EncodingTimeout time.Duration
AttestationTimeout time.Duration
ChainReadTimeout time.Duration
ChainWriteTimeout time.Duration
ChainStateTimeout time.Duration
FireblocksAPITimeout time.Duration
TxnBroadcastTimeout time.Duration
EncodingTimeout time.Duration
AttestationTimeout time.Duration
ChainReadTimeout time.Duration
ChainWriteTimeout time.Duration
ChainStateTimeout time.Duration
TxnBroadcastTimeout time.Duration
}

type Config struct {
Expand Down
13 changes: 6 additions & 7 deletions disperser/cmd/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ func NewConfig(ctx *cli.Context) (Config, error) {
FinalizationBlockDelay: ctx.GlobalUint(flags.FinalizationBlockDelayFlag.Name),
},
TimeoutConfig: batcher.TimeoutConfig{
EncodingTimeout: ctx.GlobalDuration(flags.EncodingTimeoutFlag.Name),
AttestationTimeout: ctx.GlobalDuration(flags.AttestationTimeoutFlag.Name),
ChainReadTimeout: ctx.GlobalDuration(flags.ChainReadTimeoutFlag.Name),
ChainWriteTimeout: ctx.GlobalDuration(flags.ChainWriteTimeoutFlag.Name),
ChainStateTimeout: ctx.GlobalDuration(flags.ChainStateTimeoutFlag.Name),
FireblocksAPITimeout: ctx.GlobalDuration(flags.FireblocksAPITimeoutFlag.Name),
TxnBroadcastTimeout: ctx.GlobalDuration(flags.TransactionBroadcastTimeoutFlag.Name),
EncodingTimeout: ctx.GlobalDuration(flags.EncodingTimeoutFlag.Name),
AttestationTimeout: ctx.GlobalDuration(flags.AttestationTimeoutFlag.Name),
ChainReadTimeout: ctx.GlobalDuration(flags.ChainReadTimeoutFlag.Name),
ChainWriteTimeout: ctx.GlobalDuration(flags.ChainWriteTimeoutFlag.Name),
ChainStateTimeout: ctx.GlobalDuration(flags.ChainStateTimeoutFlag.Name),
TxnBroadcastTimeout: ctx.GlobalDuration(flags.TransactionBroadcastTimeoutFlag.Name),
},
MetricsConfig: batcher.MetricsConfig{
HTTPPort: ctx.GlobalString(flags.MetricsHTTPPort.Name),
Expand Down
8 changes: 0 additions & 8 deletions disperser/cmd/batcher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ var (
Value: 15 * time.Second,
EnvVar: common.PrefixEnvVar(envVarPrefix, "CHAIN_STATE_TIMEOUT"),
}
FireblocksAPITimeoutFlag = cli.DurationFlag{
Name: "fireblocks-write-timeout",
Usage: "connection timeout to get API response from Fireblocks",
Required: false,
Value: 10 * time.Second,
EnvVar: common.PrefixEnvVar(envVarPrefix, "FIREBLOCKS_API_TIMEOUT"),
}
TransactionBroadcastTimeoutFlag = cli.DurationFlag{
Name: "transaction-broadcast-timeout",
Usage: "timeout to broadcast transaction",
Expand Down Expand Up @@ -223,7 +216,6 @@ var optionalFlags = []cli.Flag{
ChainReadTimeoutFlag,
ChainWriteTimeoutFlag,
ChainStateTimeoutFlag,
FireblocksAPITimeoutFlag,
TransactionBroadcastTimeoutFlag,
NumConnectionsFlag,
FinalizerIntervalFlag,
Expand Down
2 changes: 1 addition & 1 deletion disperser/cmd/batcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func RunBatcher(ctx *cli.Context) error {
apiKey,
[]byte(secretKey),
config.FireblocksConfig.BaseURL,
config.TimeoutConfig.FireblocksAPITimeout,
config.FireblocksConfig.APITimeout,
logger.With("component", "FireblocksClient"),
)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions disperser/cmd/dataapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ type Config struct {
ChurnerHostname string
BatcherHealthEndpt string

FireblockAPITimeout time.Duration
TxnTimeout time.Duration
TxnTimeout time.Duration
}

func NewConfig(ctx *cli.Context) (Config, error) {
Expand Down Expand Up @@ -87,8 +86,7 @@ func NewConfig(ctx *cli.Context) (Config, error) {
ChurnerHostname: ctx.GlobalString(flags.ChurnerHostnameFlag.Name),
BatcherHealthEndpt: ctx.GlobalString(flags.BatcherHealthEndptFlag.Name),

FireblockAPITimeout: ctx.GlobalDuration(flags.FireblockAPITimeoutFlag.Name),
TxnTimeout: ctx.GlobalDuration(flags.TxnTimeoutFlag.Name),
TxnTimeout: ctx.GlobalDuration(flags.TxnTimeoutFlag.Name),
}
return config, nil
}
2 changes: 1 addition & 1 deletion disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func getWallet(config Config, ethClient common.EthClient, logger logging.Logger)
apiKey,
[]byte(secretKey),
config.FireblocksConfig.BaseURL,
config.FireblockAPITimeout,
config.FireblocksConfig.APITimeout,
logger.With("component", "FireblocksClient"),
)
if err != nil {
Expand Down

0 comments on commit 06f794b

Please sign in to comment.