Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat: update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Sep 29, 2023
1 parent 1dc851d commit 7cb6d70
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 124 deletions.
14 changes: 8 additions & 6 deletions cmd/flags/common.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package flags

import (
"time"

"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -89,22 +91,22 @@ var (
Category: commonCategory,
Value: 10,
}
BackOffRetryInterval = &cli.Uint64Flag{
BackOffRetryInterval = &cli.DurationFlag{
Name: "backoff.retryInterval",
Usage: "Retry interval in seconds when there is an error",
Category: commonCategory,
Value: 12,
Value: 12 * time.Second,
}
RPCTimeout = &cli.Uint64Flag{
RPCTimeout = &cli.DurationFlag{
Name: "rpc.timeout",
Usage: "Timeout in seconds for RPC calls",
Category: commonCategory,
}
WaitReceiptTimeout = &cli.Uint64Flag{
WaitReceiptTimeout = &cli.DurationFlag{
Name: "rpc.waitReceiptTimeout",
Usage: "Timeout in seconds for wait for receipts for RPC transactions",
Usage: "Timeout for wait for receipts for RPC transactions",
Category: commonCategory,
Value: 60,
Value: 1 * time.Minute,
}
)

Expand Down
18 changes: 6 additions & 12 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ var (
Required: true,
Category: proverCategory,
}
ProverCapacity = &cli.Uint64Flag{
Name: "prover.capacity",
Usage: "Capacity of prover, required if oracleProver is false",
Required: true,
Category: proverCategory,
}
)

// Optional flags used by prover.
Expand Down Expand Up @@ -109,11 +115,6 @@ var (
Category: proverCategory,
Value: 9876,
}
ProverCapacity = &cli.Uint64Flag{
Name: "prover.capacity",
Usage: "Capacity of prover, required if oracleProver is false",
Category: proverCategory,
}
MaxExpiry = &cli.DurationFlag{
Name: "prover.maxExpiry",
Usage: "maximum accepted expiry in seconds for accepting proving a block",
Expand All @@ -133,12 +134,6 @@ var (
Value: false,
Category: proverCategory,
}
RandomDummyProofDelay = &cli.StringFlag{
Name: "randomDummyProofDelay",
Usage: "Set the random dummy proof delay between the bounds using the format: " +
"`lowerBound-upperBound` (e.g. `30m-1h`), testing purposes only",
Category: proverCategory,
}
)

// All prover flags.
Expand All @@ -153,7 +148,6 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
StartingBlockID,
MaxConcurrentProvingJobs,
Dummy,
RandomDummyProofDelay,
OracleProver,
OracleProverPrivateKey,
OracleProofSubmissionDelay,
Expand Down
6 changes: 3 additions & 3 deletions driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
var timeout *time.Duration

if c.IsSet(flags.RPCTimeout.Name) {
duration := time.Duration(c.Uint64(flags.RPCTimeout.Name)) * time.Second
duration := c.Duration(flags.RPCTimeout.Name)
timeout = &duration
}

Expand All @@ -59,8 +59,8 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)),
JwtSecret: string(jwtSecret),
P2PSyncVerifiedBlocks: p2pSyncVerifiedBlocks,
P2PSyncTimeout: time.Duration(int64(time.Second) * int64(c.Uint(flags.P2PSyncTimeout.Name))),
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
P2PSyncTimeout: c.Duration(flags.P2PSyncTimeout.Name),
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
RPCTimeout: timeout,
}, nil
}
8 changes: 4 additions & 4 deletions driver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
"--" + flags.TaikoL1Address.Name, taikoL1,
"--" + flags.TaikoL2Address.Name, taikoL2,
"--" + flags.JWTSecret.Name, os.Getenv("JWT_SECRET"),
"--" + flags.P2PSyncTimeout.Name, "120",
"--" + flags.RPCTimeout.Name, "5",
"--" + flags.P2PSyncTimeout.Name, "120s",
"--" + flags.RPCTimeout.Name, "5s",
"--" + flags.P2PSyncVerifiedBlocks.Name,
"--" + flags.CheckPointSyncUrl.Name, "http://localhost:8545",
}))
Expand Down Expand Up @@ -82,8 +82,8 @@ func (s *DriverTestSuite) SetupApp() *cli.App {
&cli.StringFlag{Name: flags.TaikoL2Address.Name},
&cli.StringFlag{Name: flags.JWTSecret.Name},
&cli.BoolFlag{Name: flags.P2PSyncVerifiedBlocks.Name},
&cli.UintFlag{Name: flags.P2PSyncTimeout.Name},
&cli.UintFlag{Name: flags.RPCTimeout.Name},
&cli.DurationFlag{Name: flags.P2PSyncTimeout.Name},
&cli.DurationFlag{Name: flags.RPCTimeout.Name},
&cli.StringFlag{Name: flags.CheckPointSyncUrl.Name},
}
app.Action = func(ctx *cli.Context) error {
Expand Down
19 changes: 8 additions & 11 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
TaikoTokenAddress common.Address
L1ProposerPrivKey *ecdsa.PrivateKey
L2SuggestedFeeRecipient common.Address
ExtraData string
ProposeInterval *time.Duration
LocalAddresses []common.Address
LocalAddressesOnly bool
Expand Down Expand Up @@ -53,18 +54,13 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
// Proposing configuration
var proposingInterval *time.Duration
if c.IsSet(flags.ProposeInterval.Name) {
interval, err := time.ParseDuration(c.String(flags.ProposeInterval.Name))
if err != nil {
return nil, fmt.Errorf("invalid proposing interval: %w", err)
}
interval := c.Duration(flags.ProposeInterval.Name)
proposingInterval = &interval
}

var proposeEmptyBlocksInterval *time.Duration
if c.IsSet(flags.ProposeEmptyBlocksInterval.Name) {
interval, err := time.ParseDuration(c.String(flags.ProposeEmptyBlocksInterval.Name))
if err != nil {
return nil, fmt.Errorf("invalid proposing empty blocks interval: %w", err)
}
interval := c.Duration(flags.ProposeEmptyBlocksInterval.Name)
proposeEmptyBlocksInterval = &interval
}

Expand Down Expand Up @@ -100,7 +96,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {

var timeout *time.Duration
if c.IsSet(flags.RPCTimeout.Name) {
duration := time.Duration(c.Uint64(flags.RPCTimeout.Name)) * time.Second
duration := c.Duration(flags.RPCTimeout.Name)
timeout = &duration
}

Expand Down Expand Up @@ -131,16 +127,17 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
TaikoTokenAddress: common.HexToAddress(c.String(flags.TaikoTokenAddress.Name)),
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(l2SuggestedFeeRecipient),
ExtraData: c.String(flags.ExtraData.Name),
ProposeInterval: proposingInterval,
LocalAddresses: localAddresses,
LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name),
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
ProposeBlockTxGasLimit: proposeBlockTxGasLimit,
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
ProposeBlockTxReplacementMultiplier: proposeBlockTxReplacementMultiplier,
RPCTimeout: timeout,
WaitReceiptTimeout: time.Duration(c.Uint64(flags.WaitReceiptTimeout.Name)) * time.Second,
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
ProposeBlockTxGasTipCap: proposeBlockTxGasTipCap,
ProverEndpoints: proverEndpoints,
BlockProposalFee: blockProposalFee,
Expand Down
12 changes: 6 additions & 6 deletions proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
"--" + flags.ProposeInterval.Name, proposeInterval,
"--" + flags.TxPoolLocals.Name, goldenTouchAddress.Hex(),
"--" + flags.ProposeBlockTxReplacementMultiplier.Name, "5",
"--" + flags.RPCTimeout.Name, "5",
"--" + flags.WaitReceiptTimeout.Name, "10",
"--" + flags.RPCTimeout.Name, "5s",
"--" + flags.WaitReceiptTimeout.Name, "10s",
"--" + flags.ProposeBlockTxGasTipCap.Name, "100000",
"--" + flags.ProposeBlockTxGasLimit.Name, "100000",
"--" + flags.ProverEndpoints.Name, proverEndpoints,
Expand Down Expand Up @@ -187,14 +187,14 @@ func (s *ProposerTestSuite) SetupApp() *cli.App {
&cli.StringFlag{Name: flags.TaikoTokenAddress.Name},
&cli.StringFlag{Name: flags.L1ProposerPrivKey.Name},
&cli.StringFlag{Name: flags.L2SuggestedFeeRecipient.Name},
&cli.StringFlag{Name: flags.ProposeEmptyBlocksInterval.Name},
&cli.StringFlag{Name: flags.ProposeInterval.Name},
&cli.DurationFlag{Name: flags.ProposeEmptyBlocksInterval.Name},
&cli.DurationFlag{Name: flags.ProposeInterval.Name},
&cli.StringFlag{Name: flags.TxPoolLocals.Name},
&cli.StringFlag{Name: flags.ProverEndpoints.Name},
&cli.Uint64Flag{Name: flags.BlockProposalFee.Name},
&cli.Uint64Flag{Name: flags.ProposeBlockTxReplacementMultiplier.Name},
&cli.Uint64Flag{Name: flags.RPCTimeout.Name},
&cli.Uint64Flag{Name: flags.WaitReceiptTimeout.Name},
&cli.DurationFlag{Name: flags.RPCTimeout.Name},
&cli.DurationFlag{Name: flags.WaitReceiptTimeout.Name},
&cli.Uint64Flag{Name: flags.ProposeBlockTxGasTipCap.Name},
&cli.Uint64Flag{Name: flags.ProposeBlockTxGasLimit.Name},
&cli.Uint64Flag{Name: flags.BlockProposalFeeIncreasePercentage.Name},
Expand Down
92 changes: 25 additions & 67 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/ecdsa"
"fmt"
"math/big"
"strings"
"time"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -33,8 +32,6 @@ type Config struct {
OracleProofSubmissionDelay time.Duration
ProofSubmissionMaxRetry uint64
Graffiti string
RandomDummyProofDelayLowerBound *time.Duration
RandomDummyProofDelayUpperBound *time.Duration
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
CheckProofWindowExpiredInterval time.Duration
Expand All @@ -60,10 +57,8 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return nil, fmt.Errorf("invalid L1 prover private key: %w", err)
}

oracleProverSet := c.IsSet(flags.OracleProver.Name)

var oracleProverPrivKey *ecdsa.PrivateKey
if oracleProverSet {
if c.IsSet(flags.OracleProver.Name) {
if !c.IsSet(flags.OracleProverPrivateKey.Name) {
return nil, fmt.Errorf("oracleProver flag set without oracleProverPrivateKey set")
}
Expand All @@ -72,39 +67,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
if err != nil {
return nil, fmt.Errorf("invalid oracle private key: %w", err)
}
} else {
if !c.IsSet(flags.ProverCapacity.Name) {
return nil, fmt.Errorf("capacity is required if oracleProver is not set to true")
}
}

var (
randomDummyProofDelayLowerBound *time.Duration
randomDummyProofDelayUpperBound *time.Duration
)
if c.IsSet(flags.RandomDummyProofDelay.Name) {
flagValue := c.String(flags.RandomDummyProofDelay.Name)
splitted := strings.Split(flagValue, "-")
if len(splitted) != 2 {
return nil, fmt.Errorf("invalid random dummy proof delay value: %s", flagValue)
}

lower, err := time.ParseDuration(splitted[0])
if err != nil {
return nil, fmt.Errorf("invalid random dummy proof delay value: %s, err: %w", flagValue, err)
}
upper, err := time.ParseDuration(splitted[1])
if err != nil {
return nil, fmt.Errorf("invalid random dummy proof delay value: %s, err: %w", flagValue, err)
}
if lower > upper {
return nil, fmt.Errorf("invalid random dummy proof delay value (lower > upper): %s", flagValue)
}

if upper != time.Duration(0) {
randomDummyProofDelayLowerBound = &lower
randomDummyProofDelayUpperBound = &upper
}
}

var startingBlockID *big.Int
Expand All @@ -114,7 +76,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {

var timeout *time.Duration
if c.IsSet(flags.RPCTimeout.Name) {
duration := time.Duration(c.Uint64(flags.RPCTimeout.Name)) * time.Second
duration := c.Duration(flags.RPCTimeout.Name)
timeout = &duration
}

Expand Down Expand Up @@ -143,41 +105,37 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
}

return &Config{
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
L2WsEndpoint: c.String(flags.L2WSEndpoint.Name),
L2HttpEndpoint: c.String(flags.L2HTTPEndpoint.Name),
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)),
TaikoTokenAddress: common.HexToAddress(c.String(flags.TaikoTokenAddress.Name)),
L1ProverPrivKey: l1ProverPrivKey,
ZKEvmRpcdEndpoint: c.String(flags.ZkEvmRpcdEndpoint.Name),
ZkEvmRpcdParamsPath: c.String(flags.ZkEvmRpcdParamsPath.Name),
StartingBlockID: startingBlockID,
MaxConcurrentProvingJobs: c.Uint(flags.MaxConcurrentProvingJobs.Name),
Dummy: c.Bool(flags.Dummy.Name),
OracleProver: c.Bool(flags.OracleProver.Name),
OracleProverPrivateKey: oracleProverPrivKey,
OracleProofSubmissionDelay: time.Duration(c.Uint64(flags.OracleProofSubmissionDelay.Name)) * time.Second,
ProofSubmissionMaxRetry: c.Uint64(flags.ProofSubmissionMaxRetry.Name),
Graffiti: c.String(flags.Graffiti.Name),
RandomDummyProofDelayLowerBound: randomDummyProofDelayLowerBound,
RandomDummyProofDelayUpperBound: randomDummyProofDelayUpperBound,
BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
CheckProofWindowExpiredInterval: time.Duration(
c.Uint64(flags.CheckProofWindowExpiredInterval.Name),
) * time.Second,
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
L2WsEndpoint: c.String(flags.L2WSEndpoint.Name),
L2HttpEndpoint: c.String(flags.L2HTTPEndpoint.Name),
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)),
TaikoTokenAddress: common.HexToAddress(c.String(flags.TaikoTokenAddress.Name)),
L1ProverPrivKey: l1ProverPrivKey,
ZKEvmRpcdEndpoint: c.String(flags.ZkEvmRpcdEndpoint.Name),
ZkEvmRpcdParamsPath: c.String(flags.ZkEvmRpcdParamsPath.Name),
StartingBlockID: startingBlockID,
MaxConcurrentProvingJobs: c.Uint(flags.MaxConcurrentProvingJobs.Name),
Dummy: c.Bool(flags.Dummy.Name),
OracleProver: c.Bool(flags.OracleProver.Name),
OracleProverPrivateKey: oracleProverPrivKey,
OracleProofSubmissionDelay: c.Duration(flags.OracleProofSubmissionDelay.Name),
ProofSubmissionMaxRetry: c.Uint64(flags.ProofSubmissionMaxRetry.Name),
Graffiti: c.String(flags.Graffiti.Name),
BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
CheckProofWindowExpiredInterval: c.Duration(flags.CheckProofWindowExpiredInterval.Name),
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
RPCTimeout: timeout,
WaitReceiptTimeout: time.Duration(c.Uint64(flags.WaitReceiptTimeout.Name)) * time.Second,
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
ProveBlockGasLimit: proveBlockTxGasLimit,
Capacity: c.Uint64(flags.ProverCapacity.Name),
TempCapacityExpiresAt: c.Duration(flags.TempCapacityExpiresAt.Name),
ProveBlockTxReplacementMultiplier: proveBlockTxReplacementMultiplier,
ProveBlockMaxTxGasTipCap: proveBlockMaxTxGasTipCap,
HTTPServerPort: c.Uint64(flags.ProverHTTPServerPort.Name),
MinProofFee: minProofFee,
MaxExpiry: time.Duration(c.Uint64(flags.MaxExpiry.Name)) * time.Second,
MaxExpiry: c.Duration(flags.MaxExpiry.Name),
}, nil
}
Loading

0 comments on commit 7cb6d70

Please sign in to comment.