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

Commit

Permalink
Merge branch 'main' into update-proposer-gaslimit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Aug 2, 2023
2 parents e2e52ea + cf261d3 commit b74a8fb
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cmd/flags/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ var (
Usage: "Timeout in seconds for RPC calls",
Category: commonCategory,
}
WaitReceiptTimeout = &cli.Uint64Flag{
Name: "rpc.waitReceiptTimeout",
Usage: "Timeout in seconds for wait for receipts for RPC transactions",
Category: commonCategory,
Value: 60,
}
)

// All common flags.
Expand All @@ -117,6 +123,7 @@ var CommonFlags = []cli.Flag{
BackOffMaxRetrys,
BackOffRetryInterval,
RPCTimeout,
WaitReceiptTimeout,
}

// MergeFlags merges the given flag slices.
Expand Down
1 change: 1 addition & 0 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 10 * time.Second,
})))

s.p = prop
Expand Down
1 change: 1 addition & 0 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (s *DriverTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 10 * time.Second,
})))
s.p = p
}
Expand Down
2 changes: 2 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
BackOffRetryInterval time.Duration
ProposeBlockTxReplacementMultiplier uint64
RPCTimeout *time.Duration
WaitReceiptTimeout time.Duration
}

// NewConfigFromCliContext initializes a Config instance from
Expand Down Expand Up @@ -112,5 +113,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
ProposeBlockTxReplacementMultiplier: proposeBlockTxReplacementMultiplier,
RPCTimeout: timeout,
WaitReceiptTimeout: time.Duration(c.Uint64(flags.WaitReceiptTimeout.Name)) * time.Second,
}, nil
}
3 changes: 3 additions & 0 deletions proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
&cli.StringFlag{Name: flags.TxPoolLocals.Name},
&cli.Uint64Flag{Name: flags.ProposeBlockTxReplacementMultiplier.Name},
&cli.Uint64Flag{Name: flags.RPCTimeout.Name},
&cli.Uint64Flag{Name: flags.WaitReceiptTimeout.Name},
}
app.Action = func(ctx *cli.Context) error {
c, err := NewConfigFromCliContext(ctx)
Expand All @@ -52,6 +53,7 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
s.Equal(goldenTouchAddress, c.LocalAddresses[0])
s.Equal(uint64(5), c.ProposeBlockTxReplacementMultiplier)
s.Equal(rpcTimeout, *c.RPCTimeout)
s.Equal(10*time.Second, c.WaitReceiptTimeout)
s.Nil(new(Proposer).InitFromCli(context.Background(), ctx))

return err
Expand All @@ -69,5 +71,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
"-" + flags.TxPoolLocals.Name, goldenTouchAddress.Hex(),
"-" + flags.ProposeBlockTxReplacementMultiplier.Name, "5",
"-" + flags.RPCTimeout.Name, "5",
"-" + flags.WaitReceiptTimeout.Name, "10",
}))
}
6 changes: 4 additions & 2 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

var (
errNoNewTxs = errors.New("no new transactions")
waitReceiptTimeout = 1 * time.Minute
maxSendProposeBlockTxRetry = 10
)

Expand Down Expand Up @@ -62,6 +61,8 @@ type Proposer struct {

ctx context.Context
wg sync.WaitGroup

waitReceiptTimeout time.Duration
}

// New initializes the given proposer instance based on the command line flags.
Expand All @@ -88,6 +89,7 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
p.maxProposedTxListsPerEpoch = cfg.MaxProposedTxListsPerEpoch
p.txReplacementTipMultiplier = cfg.ProposeBlockTxReplacementMultiplier
p.ctx = ctx
p.waitReceiptTimeout = cfg.WaitReceiptTimeout

// RPC clients
if p.rpc, err = rpc.NewClient(p.ctx, &rpc.ClientConfig{
Expand Down Expand Up @@ -409,7 +411,7 @@ func (p *Proposer) ProposeTxList(
return err
}

ctxWithTimeout, cancel := context.WithTimeout(ctx, waitReceiptTimeout)
ctxWithTimeout, cancel := context.WithTimeout(ctx, p.waitReceiptTimeout)
defer cancel()

if _, err := rpc.WaitReceipt(ctxWithTimeout, p.rpc.L1, tx); err != nil {
Expand Down
1 change: 1 addition & 0 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (s *ProposerTestSuite) SetupTest() {
ProposeInterval: &proposeInterval,
MaxProposedTxListsPerEpoch: 1,
ProposeBlockTxReplacementMultiplier: 2,
WaitReceiptTimeout: 10 * time.Second,
})))

s.p = p
Expand Down
2 changes: 2 additions & 0 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Config struct {
CheckProofWindowExpiredInterval time.Duration
ProveUnassignedBlocks bool
RPCTimeout *time.Duration
WaitReceiptTimeout time.Duration
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -136,5 +137,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
) * time.Second,
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
RPCTimeout: timeout,
WaitReceiptTimeout: time.Duration(c.Uint64(flags.WaitReceiptTimeout.Name)) * time.Second,
}, nil
}
6 changes: 5 additions & 1 deletion prover/proof_submitter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func sendTxWithBackoff(
sendTxFunc func() (*types.Transaction, error),
retryInterval time.Duration,
maxRetry *uint64,
waitReceiptTimeout time.Duration,
) error {
var (
isUnretryableError bool
Expand Down Expand Up @@ -120,7 +121,10 @@ func sendTxWithBackoff(
return nil
}

if _, err := rpc.WaitReceipt(ctx, cli.L1, tx); err != nil {
ctxWithTimeout, cancel := context.WithTimeout(ctx, waitReceiptTimeout)
defer cancel()

if _, err := rpc.WaitReceipt(ctxWithTimeout, cli.L1, tx); err != nil {
log.Warn("Failed to wait till transaction executed", "blockID", blockID, "txHash", tx.Hash(), "error", err)
return err
}
Expand Down
2 changes: 2 additions & 0 deletions prover/proof_submitter/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (s *ProofSubmitterTestSuite) TestSendTxWithBackoff() {
func() (*types.Transaction, error) { return nil, errors.New("L1_TEST") },
12*time.Second,
&testMaxRetry,
5*time.Second,
))

s.Nil(sendTxWithBackoff(
Expand Down Expand Up @@ -75,5 +76,6 @@ func (s *ProofSubmitterTestSuite) TestSendTxWithBackoff() {
},
12*time.Second,
&testMaxRetry,
5*time.Second,
))
}
4 changes: 4 additions & 0 deletions prover/proof_submitter/valid_proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type ValidProofSubmitter struct {
graffiti [32]byte
submissionMaxRetry uint64
retryInterval time.Duration
waitReceiptTimeout time.Duration
}

// NewValidProofSubmitter creates a new ValidProofSubmitter instance.
Expand All @@ -56,6 +57,7 @@ func NewValidProofSubmitter(
graffiti string,
submissionMaxRetry uint64,
retryInterval time.Duration,
waitReceiptTimeout time.Duration,
) (*ValidProofSubmitter, error) {
anchorValidator, err := anchorTxValidator.New(taikoL2Address, rpcClient.L2ChainID, rpcClient)
if err != nil {
Expand Down Expand Up @@ -87,6 +89,7 @@ func NewValidProofSubmitter(
graffiti: rpc.StringToBytes32(graffiti),
submissionMaxRetry: submissionMaxRetry,
retryInterval: retryInterval,
waitReceiptTimeout: waitReceiptTimeout,
}, nil
}

Expand Down Expand Up @@ -271,6 +274,7 @@ func (s *ValidProofSubmitter) SubmitProof(
sendTx,
s.retryInterval,
maxRetry,
s.waitReceiptTimeout,
); err != nil {
if errors.Is(err, errUnretryable) {
return nil
Expand Down
2 changes: 2 additions & 0 deletions prover/proof_submitter/valid_proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
"test",
1,
12*time.Second,
10*time.Second,
)
s.Nil(err)

Expand Down Expand Up @@ -82,6 +83,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 10 * time.Second,
})))

s.proposer = prop
Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
p.cfg.Graffiti,
p.cfg.ProofSubmissionMaxRetry,
p.cfg.BackOffRetryInterval,
p.cfg.WaitReceiptTimeout,
); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (s *ProverTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: &proposeInterval, // No need to periodically propose transactions list in unit tests
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 10 * time.Second,
})))

s.proposer = prop
Expand Down

0 comments on commit b74a8fb

Please sign in to comment.