diff --git a/cmd/flags/proposer.go b/cmd/flags/proposer.go index ffe715226..9c5751b6a 100644 --- a/cmd/flags/proposer.go +++ b/cmd/flags/proposer.go @@ -64,11 +64,13 @@ var ( Name: "epoch.interval", Usage: "Time interval to propose L2 pending transactions", Category: proposerCategory, + Value: 0, } ProposeEmptyBlocksInterval = &cli.DurationFlag{ Name: "epoch.emptyBlockInterval", Usage: "Time interval to propose empty blocks", Category: proposerCategory, + Value: 0, } // Proposing metadata related. ExtraData = &cli.StringFlag{ diff --git a/driver/chain_syncer/calldata/syncer_test.go b/driver/chain_syncer/calldata/syncer_test.go index 9c8157d1b..c44421f90 100644 --- a/driver/chain_syncer/calldata/syncer_test.go +++ b/driver/chain_syncer/calldata/syncer_test.go @@ -45,7 +45,6 @@ func (s *CalldataSyncerTestSuite) SetupTest() { prop := new(proposer.Proposer) l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) s.Nil(err) - proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ @@ -58,7 +57,7 @@ func (s *CalldataSyncerTestSuite) SetupTest() { AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), - ProposeInterval: &proposeInterval, + ProposeInterval: 1024 * time.Hour, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, ProverEndpoints: s.ProverEndpoints, diff --git a/driver/chain_syncer/chain_syncer_test.go b/driver/chain_syncer/chain_syncer_test.go index 39617564c..96e8a4050 100644 --- a/driver/chain_syncer/chain_syncer_test.go +++ b/driver/chain_syncer/chain_syncer_test.go @@ -46,7 +46,6 @@ func (s *ChainSyncerTestSuite) SetupTest() { prop := new(proposer.Proposer) l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) s.Nil(err) - proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ @@ -59,7 +58,7 @@ func (s *ChainSyncerTestSuite) SetupTest() { AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), - ProposeInterval: &proposeInterval, + ProposeInterval: 1024 * time.Hour, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, ProverEndpoints: s.ProverEndpoints, diff --git a/driver/config.go b/driver/config.go index e056321c7..f61557bc1 100644 --- a/driver/config.go +++ b/driver/config.go @@ -19,6 +19,7 @@ type Config struct { P2PSyncVerifiedBlocks bool P2PSyncTimeout time.Duration RPCTimeout time.Duration + RetryInterval time.Duration } // NewConfigFromCliContext creates a new config instance from @@ -53,9 +54,9 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)), L2EngineEndpoint: c.String(flags.L2AuthEndpoint.Name), JwtSecret: string(jwtSecret), - RetryInterval: c.Duration(flags.BackOffRetryInterval.Name), Timeout: timeout, }, + RetryInterval: c.Duration(flags.BackOffRetryInterval.Name), P2PSyncVerifiedBlocks: p2pSyncVerifiedBlocks, P2PSyncTimeout: c.Duration(flags.P2PSyncTimeout.Name), RPCTimeout: timeout, diff --git a/driver/driver.go b/driver/driver.go index b962fa15b..b0e95c9ff 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -54,7 +54,6 @@ func (d *Driver) InitFromCli(ctx context.Context, c *cli.Context) error { // InitFromConfig initializes the driver instance based on the given configurations. func (d *Driver) InitFromConfig(ctx context.Context, cfg *Config) (err error) { d.l1HeadCh = make(chan *types.Header, 1024) - d.wg = sync.WaitGroup{} d.syncNotify = make(chan struct{}, 1) d.ctx = ctx d.Config = cfg diff --git a/driver/driver_test.go b/driver/driver_test.go index 282ca6422..7952a3147 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -54,7 +54,6 @@ func (s *DriverTestSuite) SetupTest() { l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) s.Nil(err) - proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests s.Nil(p.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), @@ -66,7 +65,7 @@ func (s *DriverTestSuite) SetupTest() { AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), - ProposeInterval: &proposeInterval, + ProposeInterval: 1024 * time.Hour, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, ProverEndpoints: s.ProverEndpoints, diff --git a/internal/testutils/suite.go b/internal/testutils/suite.go index 461ad8bbb..39e314bf1 100644 --- a/internal/testutils/suite.go +++ b/internal/testutils/suite.go @@ -8,7 +8,6 @@ import ( "os" "strconv" - "github.com/cenkalti/backoff/v4" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -61,7 +60,6 @@ func (s *ClientTestSuite) SetupTest() { GuardianProverAddress: common.HexToAddress(os.Getenv("GUARDIAN_PROVER_CONTRACT_ADDRESS")), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: string(jwtSecret), - RetryInterval: backoff.DefaultMaxInterval, }) s.Nil(err) s.RPCClient = rpcCli diff --git a/pkg/chain_iterator/block_batch_iterator.go b/pkg/chain_iterator/block_batch_iterator.go index 9ae7a9f6a..69ceefca2 100644 --- a/pkg/chain_iterator/block_batch_iterator.go +++ b/pkg/chain_iterator/block_batch_iterator.go @@ -64,7 +64,7 @@ type BlockBatchIteratorConfig struct { EndHeight *big.Int OnBlocks OnBlocksFunc ReorgRewindDepth *uint64 - RetryInterval *time.Duration + RetryInterval time.Duration } // NewBlockBatchIterator creates a new block batch iterator instance. @@ -109,10 +109,10 @@ func NewBlockBatchIterator(ctx context.Context, cfg *BlockBatchIteratorConfig) ( iterator.blocksReadPerEpoch = DefaultBlocksReadPerEpoch } - if cfg.RetryInterval == nil { + if cfg.RetryInterval == 0 { iterator.retryInterval = DefaultRetryInterval } else { - iterator.retryInterval = *cfg.RetryInterval + iterator.retryInterval = cfg.RetryInterval } if cfg.EndHeight != nil { diff --git a/pkg/chain_iterator/block_batch_iterator_test.go b/pkg/chain_iterator/block_batch_iterator_test.go index 1c291bbe4..d6dee4699 100644 --- a/pkg/chain_iterator/block_batch_iterator_test.go +++ b/pkg/chain_iterator/block_batch_iterator_test.go @@ -85,12 +85,11 @@ func (s *BlockBatchIteratorTestSuite) TestIterCtxCancel() { headHeight, err := s.RPCClient.L1.BlockNumber(context.Background()) s.Nil(err) ctx, cancel := context.WithCancel(context.Background()) - retry := 5 * time.Second itr, err := NewBlockBatchIterator(ctx, &BlockBatchIteratorConfig{ Client: s.RPCClient.L1, MaxBlocksReadPerEpoch: nil, - RetryInterval: &retry, + RetryInterval: 5 * time.Second, StartHeight: common.Big0, EndHeight: new(big.Int).SetUint64(headHeight), OnBlocks: func( diff --git a/pkg/rpc/client.go b/pkg/rpc/client.go index 4c39c0da2..25d48219e 100644 --- a/pkg/rpc/client.go +++ b/pkg/rpc/client.go @@ -48,9 +48,7 @@ type ClientConfig struct { GuardianProverAddress common.Address L2EngineEndpoint string JwtSecret string - RetryInterval time.Duration Timeout time.Duration - BackOffMaxRetries uint64 } // NewClient initializes all RPC clients used by Taiko client software. diff --git a/pkg/rpc/client_test.go b/pkg/rpc/client_test.go index 4100494b5..46b625d2a 100644 --- a/pkg/rpc/client_test.go +++ b/pkg/rpc/client_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/cenkalti/backoff/v4" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) @@ -20,7 +19,6 @@ func newTestClient(t *testing.T) *Client { TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: os.Getenv("JWT_SECRET"), - RetryInterval: backoff.DefaultMaxInterval, }) require.Nil(t, err) @@ -38,7 +36,6 @@ func newTestClientWithTimeout(t *testing.T) *Client { TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: os.Getenv("JWT_SECRET"), - RetryInterval: backoff.DefaultMaxInterval, Timeout: 5 * time.Second, }) diff --git a/proposer/config.go b/proposer/config.go index 61d8fe351..a3fc9562f 100644 --- a/proposer/config.go +++ b/proposer/config.go @@ -23,10 +23,10 @@ type Config struct { L1ProposerPrivKey *ecdsa.PrivateKey L2SuggestedFeeRecipient common.Address ExtraData string - ProposeInterval *time.Duration + ProposeInterval time.Duration LocalAddresses []common.Address LocalAddressesOnly bool - ProposeEmptyBlocksInterval *time.Duration + ProposeEmptyBlocksInterval time.Duration MaxProposedTxListsPerEpoch uint64 ProposeBlockTxGasLimit uint64 ProposeBlockTxReplacementMultiplier uint64 @@ -52,19 +52,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { return nil, fmt.Errorf("invalid L1 proposer private key: %w", err) } - // Proposing configuration - var proposingInterval *time.Duration - if c.IsSet(flags.ProposeInterval.Name) { - interval := c.Duration(flags.ProposeInterval.Name) - proposingInterval = &interval - } - - var proposeEmptyBlocksInterval *time.Duration - if c.IsSet(flags.ProposeEmptyBlocksInterval.Name) { - interval := c.Duration(flags.ProposeEmptyBlocksInterval.Name) - proposeEmptyBlocksInterval = &interval - } - l2SuggestedFeeRecipient := c.String(flags.L2SuggestedFeeRecipient.Name) if !common.IsHexAddress(l2SuggestedFeeRecipient) { return nil, fmt.Errorf("invalid L2 suggested fee recipient address: %s", l2SuggestedFeeRecipient) @@ -109,17 +96,16 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)), TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)), TaikoTokenAddress: common.HexToAddress(c.String(flags.TaikoTokenAddress.Name)), - RetryInterval: c.Duration(flags.BackOffRetryInterval.Name), Timeout: c.Duration(flags.RPCTimeout.Name), }, AssignmentHookAddress: common.HexToAddress(c.String(flags.ProposerAssignmentHookAddress.Name)), L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(l2SuggestedFeeRecipient), ExtraData: c.String(flags.ExtraData.Name), - ProposeInterval: proposingInterval, + ProposeInterval: c.Duration(flags.ProposeInterval.Name), LocalAddresses: localAddresses, LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name), - ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval, + ProposeEmptyBlocksInterval: c.Duration(flags.ProposeEmptyBlocksInterval.Name), MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name), ProposeBlockTxGasLimit: c.Uint64(flags.ProposeBlockTxGasLimit.Name), ProposeBlockTxReplacementMultiplier: proposeBlockTxReplacementMultiplier, diff --git a/proposer/proposer.go b/proposer/proposer.go index a50db7a57..b605618ed 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -77,7 +77,6 @@ func (p *Proposer) InitFromCli(ctx context.Context, c *cli.Context) error { // InitFromConfig initializes the proposer instance based on the given configurations. func (p *Proposer) InitFromConfig(ctx context.Context, cfg *Config) (err error) { p.proposerAddress = crypto.PubkeyToAddress(cfg.L1ProposerPrivKey.PublicKey) - p.wg = sync.WaitGroup{} p.ctx = ctx p.Config = cfg @@ -160,8 +159,8 @@ func (p *Proposer) eventLoop() { continue } // if no new transactions and empty block interval has passed, propose an empty block - if p.ProposeEmptyBlocksInterval != nil { - if time.Now().Before(lastNonEmptyBlockProposedAt.Add(*p.ProposeEmptyBlocksInterval)) { + if p.ProposeEmptyBlocksInterval != 0 { + if time.Now().Before(lastNonEmptyBlockProposedAt.Add(p.ProposeEmptyBlocksInterval)) { continue } @@ -518,8 +517,8 @@ func (p *Proposer) updateProposingTicker() { } var duration time.Duration - if p.ProposeInterval != nil { - duration = *p.ProposeInterval + if p.ProposeInterval != 0 { + duration = p.ProposeInterval } else { // Random number between 12 - 120 randomSeconds := rand.Intn(120-11) + 12 // nolint: gosec diff --git a/proposer/proposer_test.go b/proposer/proposer_test.go index 230a3dff3..617173b0a 100644 --- a/proposer/proposer_test.go +++ b/proposer/proposer_test.go @@ -33,7 +33,6 @@ func (s *ProposerTestSuite) SetupTest() { p := new(Proposer) ctx, cancel := context.WithCancel(context.Background()) - proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests s.Nil(p.InitFromConfig(ctx, &Config{ ClientConfig: &rpc.ClientConfig{ @@ -46,7 +45,7 @@ func (s *ProposerTestSuite) SetupTest() { AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), - ProposeInterval: &proposeInterval, + ProposeInterval: 1024 * time.Hour, MaxProposedTxListsPerEpoch: 1, ProposeBlockTxReplacementMultiplier: 2, WaitReceiptTimeout: 12 * time.Second, @@ -202,11 +201,10 @@ func (s *ProposerTestSuite) TestAssignProverSuccessFirstRound() { } func (s *ProposerTestSuite) TestUpdateProposingTicker() { - oneHour := 1 * time.Hour - s.p.ProposeInterval = &oneHour + s.p.ProposeInterval = 1 * time.Hour s.NotPanics(s.p.updateProposingTicker) - s.p.ProposeInterval = nil + s.p.ProposeInterval = 0 s.NotPanics(s.p.updateProposingTicker) } diff --git a/prover/proof_submitter/proof_submitter_test.go b/prover/proof_submitter/proof_submitter_test.go index 9d5307f50..0856de1c1 100644 --- a/prover/proof_submitter/proof_submitter_test.go +++ b/prover/proof_submitter/proof_submitter_test.go @@ -86,7 +86,6 @@ func (s *ProofSubmitterTestSuite) SetupTest() { prop := new(proposer.Proposer) l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) s.Nil(err) - proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ @@ -100,7 +99,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() { L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), - ProposeInterval: &proposeInterval, + ProposeInterval: 1024 * time.Hour, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, ProverEndpoints: s.ProverEndpoints, diff --git a/prover/prover.go b/prover/prover.go index c31c8db9b..a00d2a4e7 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -104,9 +104,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { TaikoL2Address: cfg.TaikoL2Address, TaikoTokenAddress: cfg.TaikoTokenAddress, GuardianProverAddress: cfg.GuardianProverAddress, - RetryInterval: cfg.BackOffRetryInterval, Timeout: cfg.RPCTimeout, - BackOffMaxRetries: cfg.BackOffMaxRetrys, }); err != nil { return err } diff --git a/prover/prover_test.go b/prover/prover_test.go index 04a0b0a64..e19a8ca3b 100644 --- a/prover/prover_test.go +++ b/prover/prover_test.go @@ -71,7 +71,6 @@ func (s *ProverTestSuite) SetupTest() { prop := new(proposer.Proposer) - proposeInterval := 1024 * time.Hour // No need to periodically propose transactions list in unit tests s.Nil(prop.InitFromConfig(context.Background(), &proposer.Config{ ClientConfig: &rpc.ClientConfig{ L1Endpoint: os.Getenv("L1_NODE_WS_ENDPOINT"), @@ -83,7 +82,7 @@ func (s *ProverTestSuite) SetupTest() { AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), L1ProposerPrivKey: l1ProposerPrivKey, L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")), - ProposeInterval: &proposeInterval, + ProposeInterval: 1024 * time.Hour, MaxProposedTxListsPerEpoch: 1, WaitReceiptTimeout: 12 * time.Second, ProverEndpoints: []*url.URL{proverServerURL}, diff --git a/prover/server/server_test.go b/prover/server/server_test.go index 13889a331..c5f37173f 100644 --- a/prover/server/server_test.go +++ b/prover/server/server_test.go @@ -39,7 +39,6 @@ func (s *ProverServerTestSuite) SetupTest() { TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")), L2EngineEndpoint: os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT"), JwtSecret: os.Getenv("JWT_SECRET"), - RetryInterval: backoff.DefaultMaxInterval, Timeout: 5 * time.Second, }) s.Nil(err)