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

feat(flags): remove --rpc.waitReceiptTimeout flag #684

Merged
merged 5 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cmd/flags/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ var (
Category: commonCategory,
Value: 12 * time.Second,
}
WaitReceiptTimeout = &cli.DurationFlag{
Name: "rpc.waitReceiptTimeout",
Usage: "Timeout for waiting for receipts for RPC transactions",
Category: commonCategory,
Value: 1 * time.Minute,
}
)

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

// MergeFlags merges the given flag slices.
Expand Down
1 change: 0 additions & 1 deletion driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func (s *CalldataSyncerTestSuite) initProposer() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down
1 change: 0 additions & 1 deletion driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (s *ChainSyncerTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down
1 change: 0 additions & 1 deletion driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func (s *DriverTestSuite) InitProposer() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down
9 changes: 2 additions & 7 deletions internal/testutils/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ func (s *ClientTestSuite) SetupTest() {
proverBalance := new(big.Int).Div(balance, common.Big2)
s.Greater(proverBalance.Cmp(common.Big0), 0)

tx, err := rpcCli.TaikoToken.Transfer(opts, crypto.PubkeyToAddress(l1ProverPrivKey.PublicKey), proverBalance)
s.Nil(err)
_, err = rpc.WaitReceipt(context.Background(), rpcCli.L1, tx)
_, err = rpcCli.TaikoToken.Transfer(opts, crypto.PubkeyToAddress(l1ProverPrivKey.PublicKey), proverBalance)
s.Nil(err)

// Increase allowance for AssignmentHook and TaikoL1
Expand All @@ -117,15 +115,12 @@ func (s *ClientTestSuite) setAllowance(key *ecdsa.PrivateKey) {
)
s.Nil(err)

tx, err := s.RPCClient.TaikoToken.Approve(
_, err = s.RPCClient.TaikoToken.Approve(
opts,
common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
bigInt,
)
s.Nil(err)

_, err = rpc.WaitReceipt(context.Background(), s.RPCClient.L1, tx)
s.Nil(err)
}

func (s *ClientTestSuite) TearDownTest() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (c *Client) GetProtocolStateVariables(opts *bind.CallOpts) (*struct {
if opts.Context != nil {
ctx = opts.Context
}
ctxWithTimeout, cancel := context.WithTimeout(ctx, defaultWaitReceiptTimeout)
ctxWithTimeout, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()
opts.Context = ctxWithTimeout

Expand Down
45 changes: 0 additions & 45 deletions pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import (
"context"
"fmt"
"math/big"
"os"
"strconv"
"strings"
"time"
Expand All @@ -23,8 +21,7 @@

var (
ZeroAddress common.Address
waitReceiptPollingInterval = 3 * time.Second

Check failure on line 24 in pkg/rpc/utils.go

View workflow job for this annotation

GitHub Actions / Lint

var `waitReceiptPollingInterval` is unused (unused)
defaultWaitReceiptTimeout = 1 * time.Minute
BlobBytes = params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob
BlockMaxTxListBytes uint64 = (params.BlobTxBytesPerFieldElement - 1) * params.BlobTxFieldElementsPerBlob
)
Expand Down Expand Up @@ -96,48 +93,6 @@
return true, nil
}

// WaitReceipt keeps waiting until the given transaction has an execution
// receipt to know whether it was reverted or not.
func WaitReceipt(
ctx context.Context,
client *EthClient,
tx *types.Transaction,
) (*types.Receipt, error) {
ticker := time.NewTicker(waitReceiptPollingInterval)
ctxWithTimeout, cancel := ctxWithTimeoutOrDefault(ctx, defaultWaitReceiptTimeout)

defer func() {
cancel()
ticker.Stop()
}()

// If we are running tests, we don't need to wait for `waitL1OriginPollingInterval` seconds
// at first, just start fetching the receipt immediately.
if os.Getenv("RUN_TESTS") == "" {
<-time.After(waitL1OriginPollingInterval)
}

for ; true; <-ticker.C {
if ctxWithTimeout.Err() != nil {
return nil, ctxWithTimeout.Err()
}

receipt, err := client.TransactionReceipt(ctxWithTimeout, tx.Hash())
if err != nil {
log.Debug("Failed to fetch transaction receipt", "hash", tx.Hash(), "error", err)
continue
}

if receipt.Status != types.ReceiptStatusSuccessful {
return nil, fmt.Errorf("transaction reverted, hash: %s", tx.Hash())
}

return receipt, nil
}

return nil, fmt.Errorf("failed to find the receipt for transaction %s", tx.Hash())
}

// BlockProofStatus represents the proving status of the given L2 block.
type BlockProofStatus struct {
IsSubmitted bool
Expand Down
14 changes: 0 additions & 14 deletions pkg/rpc/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,13 @@ import (
"os"
"strconv"
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
)

func TestWaitReceiptTimeout(t *testing.T) {
client := newTestClient(t)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

_, err := WaitReceipt(
ctx, client.L1, types.NewTransaction(0, common.Address{}, common.Big0, 0, common.Big0, []byte{}),
)

require.ErrorContains(t, err, "context deadline exceeded")
}

func TestSetHead(t *testing.T) {
require.Nil(t, SetHead(context.Background(), newTestClient(t).L2, common.Big0))
}
Expand Down
2 changes: 0 additions & 2 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Config struct {
ProposeEmptyBlocksInterval time.Duration
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit uint64
WaitReceiptTimeout time.Duration
ProverEndpoints []*url.URL
OptimisticTierFee *big.Int
SgxTierFee *big.Int
Expand Down Expand Up @@ -96,7 +95,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
ProposeEmptyBlocksInterval: c.Duration(flags.ProposeEmptyBlocksInterval.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name),
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
ProverEndpoints: proverEndpoints,
OptimisticTierFee: new(big.Int).SetUint64(c.Uint64(flags.OptimisticTierFee.Name)),
SgxTierFee: new(big.Int).SetUint64(c.Uint64(flags.SgxTierFee.Name)),
Expand Down
3 changes: 0 additions & 3 deletions proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
s.Equal(1, len(c.LocalAddresses))
s.Equal(goldenTouchAddress, c.LocalAddresses[0])
s.Equal(5*time.Second, c.Timeout)
s.Equal(10*time.Second, c.WaitReceiptTimeout)
s.Equal(uint64(tierFee), c.OptimisticTierFee.Uint64())
s.Equal(uint64(tierFee), c.SgxTierFee.Uint64())
s.Equal(uint64(15), c.TierFeePriceBump.Uint64())
Expand All @@ -73,7 +72,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
"--" + flags.ProposeInterval.Name, proposeInterval,
"--" + flags.TxPoolLocals.Name, goldenTouchAddress.Hex(),
"--" + flags.RPCTimeout.Name, rpcTimeout,
"--" + flags.WaitReceiptTimeout.Name, "10s",
"--" + flags.TxGasLimit.Name, "100000",
"--" + flags.ProverEndpoints.Name, proverEndpoints,
"--" + flags.OptimisticTierFee.Name, fmt.Sprint(tierFee),
Expand Down Expand Up @@ -138,7 +136,6 @@ func (s *ProposerTestSuite) SetupApp() *cli.App {
&cli.Uint64Flag{Name: flags.OptimisticTierFee.Name},
&cli.Uint64Flag{Name: flags.SgxTierFee.Name},
&cli.DurationFlag{Name: flags.RPCTimeout.Name},
&cli.DurationFlag{Name: flags.WaitReceiptTimeout.Name},
&cli.Uint64Flag{Name: flags.TierFeePriceBump.Name},
&cli.Uint64Flag{Name: flags.MaxTierFeePriceBumps.Name},
&cli.BoolFlag{Name: flags.ProposeBlockIncludeParentMetaHash.Name},
Expand Down
1 change: 0 additions & 1 deletion proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (s *ProposerTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down
2 changes: 0 additions & 2 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type Config struct {
ContesterMode bool
EnableLivenessBondProof bool
RPCTimeout time.Duration
WaitReceiptTimeout time.Duration
ProveBlockGasLimit *uint64
HTTPServerPort uint64
Capacity uint64
Expand Down Expand Up @@ -150,7 +149,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
ContesterMode: c.Bool(flags.ContesterMode.Name),
EnableLivenessBondProof: c.Bool(flags.EnableLivenessBondProof.Name),
RPCTimeout: c.Duration(flags.RPCTimeout.Name),
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
ProveBlockGasLimit: proveBlockTxGasLimit,
Capacity: c.Uint64(flags.ProverCapacity.Name),
HTTPServerPort: c.Uint64(flags.ProverHTTPServerPort.Name),
Expand Down
1 change: 0 additions & 1 deletion prover/event_handler/transition_proved_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func (s *EventHandlerTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down
19 changes: 12 additions & 7 deletions prover/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ package prover
import (
"context"
"math/big"
"os"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/taikoxyz/taiko-client/pkg/rpc"
"github.com/taikoxyz/taiko-client/bindings/encoding"
)

func (s *ProverTestSuite) TestSetApprovalAmount() {
opts, err := bind.NewKeyedTransactorWithChainID(s.p.cfg.L1ProverPrivKey, s.p.rpc.L1.ChainID)
data, err := encoding.TaikoTokenABI.Pack(
"approve",
common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
common.Big0,
)
s.Nil(err)

tx, err := s.p.rpc.TaikoToken.Approve(opts, s.p.cfg.AssignmentHookAddress, common.Big0)
s.Nil(err)

_, err = rpc.WaitReceipt(context.Background(), s.p.rpc.L1, tx)
_, err = s.p.txmgr.Send(context.Background(), txmgr.TxCandidate{
TxData: data,
To: &s.p.cfg.TaikoTokenAddress,
})
s.Nil(err)

allowance, err := s.p.rpc.TaikoToken.Allowance(nil, s.p.ProverAddress(), s.p.cfg.AssignmentHookAddress)
Expand Down
1 change: 0 additions & 1 deletion prover/proof_submitter/proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down
2 changes: 0 additions & 2 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func (s *ProverTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
WaitReceiptTimeout: 12 * time.Second,
ProverEndpoints: []*url.URL{proverServerURL},
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
Expand Down Expand Up @@ -507,7 +506,6 @@ func (s *ProverTestSuite) initProver(
MinOptimisticTierFee: common.Big1,
MinSgxTierFee: common.Big1,
HTTPServerPort: uint64(port),
WaitReceiptTimeout: 12 * time.Second,
Allowance: new(big.Int).Exp(big.NewInt(1_000_000_100), new(big.Int).SetUint64(uint64(decimal)), nil),
RPCTimeout: 3 * time.Second,
BackOffRetryInterval: 3 * time.Second,
Expand Down
Loading