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

Commit

Permalink
feat(proposer): use TaikoConfig.blockMaxGasLimit as proposed block …
Browse files Browse the repository at this point in the history
…gasLimit && remove some unused flags (#344)
  • Loading branch information
davidtaikocha authored Aug 2, 2023
1 parent cf261d3 commit f0a3da7
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 72 deletions.
15 changes: 0 additions & 15 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package flags

import (
"math/rand"

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

Expand All @@ -29,12 +27,6 @@ var (
Usage: "Time interval to propose L2 pending transactions",
Category: proposerCategory,
}
CommitSlot = &cli.Uint64Flag{
Name: "commitSlot",
Usage: "The commit slot will be used by proposer, by default, a random number will be used",
Value: rand.Uint64(),
Category: proposerCategory,
}
TxPoolLocals = &cli.StringFlag{
Name: "txpool.locals",
Usage: "Comma separated accounts to treat as locals (priority inclusion)",
Expand All @@ -51,11 +43,6 @@ var (
Usage: "Time interval to propose empty blocks",
Category: proposerCategory,
}
MinBlockGasLimit = &cli.Uint64Flag{
Name: "minimalBlockGasLimit",
Usage: "Minimal block gasLimit when proposing a block",
Category: proposerCategory,
}
MaxProposedTxListsPerEpoch = &cli.Uint64Flag{
Name: "maxProposedTxListsPerEpoch",
Value: 1,
Expand All @@ -80,11 +67,9 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
L1ProposerPrivKey,
L2SuggestedFeeRecipient,
ProposeInterval,
CommitSlot,
TxPoolLocals,
TxPoolLocalsOnly,
ProposeEmptyBlocksInterval,
MinBlockGasLimit,
MaxProposedTxListsPerEpoch,
ProposeBlockTxGasLimit,
ProposeBlockTxReplacementMultiplier,
Expand Down
2 changes: 1 addition & 1 deletion integration_test/nodes/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- "0.0.0.0"

l2_execution_engine:
image: gcr.io/evmchain/taiko-geth:sha-cb2c81a # TODO: change this tag back to `taiko`
image: gcr.io/evmchain/taiko-geth:taiko
restart: unless-stopped
pull_policy: always
volumes:
Expand Down
4 changes: 0 additions & 4 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ type Config struct {
L1ProposerPrivKey *ecdsa.PrivateKey
L2SuggestedFeeRecipient common.Address
ProposeInterval *time.Duration
CommitSlot uint64
LocalAddresses []common.Address
LocalAddressesOnly bool
ProposeEmptyBlocksInterval *time.Duration
MinBlockGasLimit uint64
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit *uint64
BackOffRetryInterval time.Duration
Expand Down Expand Up @@ -107,11 +105,9 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(l2SuggestedFeeRecipient),
ProposeInterval: proposingInterval,
CommitSlot: c.Uint64(flags.CommitSlot.Name),
LocalAddresses: localAddresses,
LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name),
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
ProposeBlockTxGasLimit: proposeBlockTxGasLimit,
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
Expand Down
5 changes: 0 additions & 5 deletions proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package proposer
import (
"context"
"os"
"strconv"
"time"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -18,7 +17,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
taikoL1 := os.Getenv("TAIKO_L1_ADDRESS")
taikoL2 := os.Getenv("TAIKO_L2_ADDRESS")
proposeInterval := "10s"
commitSlot := 1024
rpcTimeout := 5 * time.Second

goldenTouchAddress, err := s.RpcClient.TaikoL2.GOLDENTOUCHADDRESS(nil)
Expand All @@ -36,7 +34,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
&cli.StringFlag{Name: flags.L1ProposerPrivKey.Name},
&cli.StringFlag{Name: flags.L2SuggestedFeeRecipient.Name},
&cli.StringFlag{Name: flags.ProposeInterval.Name},
&cli.Uint64Flag{Name: flags.CommitSlot.Name},
&cli.StringFlag{Name: flags.TxPoolLocals.Name},
&cli.Uint64Flag{Name: flags.ProposeBlockTxReplacementMultiplier.Name},
&cli.Uint64Flag{Name: flags.RPCTimeout.Name},
Expand All @@ -52,7 +49,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
s.Equal(goldenTouchAddress, crypto.PubkeyToAddress(c.L1ProposerPrivKey.PublicKey))
s.Equal(goldenTouchAddress, c.L2SuggestedFeeRecipient)
s.Equal(float64(10), c.ProposeInterval.Seconds())
s.Equal(uint64(commitSlot), c.CommitSlot)
s.Equal(1, len(c.LocalAddresses))
s.Equal(goldenTouchAddress, c.LocalAddresses[0])
s.Equal(uint64(5), c.ProposeBlockTxReplacementMultiplier)
Expand All @@ -72,7 +68,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
"-" + flags.L1ProposerPrivKey.Name, common.Bytes2Hex(goldenTouchPrivKey.Bytes()),
"-" + flags.L2SuggestedFeeRecipient.Name, goldenTouchAddress.Hex(),
"-" + flags.ProposeInterval.Name, proposeInterval,
"-" + flags.CommitSlot.Name, strconv.Itoa(commitSlot),
"-" + flags.TxPoolLocals.Name, goldenTouchAddress.Hex(),
"-" + flags.ProposeBlockTxReplacementMultiplier.Name, "5",
"-" + flags.RPCTimeout.Name, "5",
Expand Down
31 changes: 2 additions & 29 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ type Proposer struct {
proposingInterval *time.Duration
proposeEmptyBlocksInterval *time.Duration
proposingTimer *time.Timer
commitSlot uint64
locals []common.Address
localsOnly bool
minBlockGasLimit *uint64
maxProposedTxListsPerEpoch uint64
proposeBlockTxGasLimit *uint64
txReplacementTipMultiplier uint64
Expand Down Expand Up @@ -88,7 +86,6 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
p.wg = sync.WaitGroup{}
p.locals = cfg.LocalAddresses
p.localsOnly = cfg.LocalAddressesOnly
p.commitSlot = cfg.CommitSlot
p.maxProposedTxListsPerEpoch = cfg.MaxProposedTxListsPerEpoch
p.txReplacementTipMultiplier = cfg.ProposeBlockTxReplacementMultiplier
p.ctx = ctx
Expand All @@ -113,17 +110,6 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
}
p.protocolConfigs = &protocolConfigs

if cfg.MinBlockGasLimit != 0 {
if uint32(cfg.MinBlockGasLimit) > p.protocolConfigs.BlockMaxGasLimit {
return fmt.Errorf(
"minimal block gas limit too large, set: %d, limit: %d",
cfg.MinBlockGasLimit,
p.protocolConfigs.BlockMaxGasLimit,
)
}
p.minBlockGasLimit = &cfg.MinBlockGasLimit
}

log.Info("Protocol configs", "configs", p.protocolConfigs)

return nil
Expand Down Expand Up @@ -299,7 +285,7 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
txNonce := nonce + uint64(i)
if err := p.ProposeTxList(ctx, &encoding.TaikoL1BlockMetadataInput{
Beneficiary: p.l2SuggestedFeeRecipient,
GasLimit: uint32(sumTxsGasLimit(txs)),
GasLimit: p.protocolConfigs.BlockMaxGasLimit,
TxListHash: crypto.Keccak256Hash(txListBytes),
TxListByteStart: common.Big0,
TxListByteEnd: new(big.Int).SetUint64(uint64(len(txListBytes))),
Expand Down Expand Up @@ -334,10 +320,6 @@ func (p *Proposer) sendProposeBlockTx(
nonce *uint64,
isReplacement bool,
) (*types.Transaction, error) {
if p.minBlockGasLimit != nil && meta.GasLimit < uint32(*p.minBlockGasLimit) {
meta.GasLimit = uint32(*p.minBlockGasLimit)
}

// Propose the transactions list
inputs, err := encoding.EncodeProposeBlockInput(meta)
if err != nil {
Expand Down Expand Up @@ -449,7 +431,7 @@ func (p *Proposer) ProposeEmptyBlockOp(ctx context.Context) error {
return p.ProposeTxList(ctx, &encoding.TaikoL1BlockMetadataInput{
TxListHash: crypto.Keccak256Hash([]byte{}),
Beneficiary: p.L2SuggestedFeeRecipient(),
GasLimit: 21000,
GasLimit: p.protocolConfigs.BlockMaxGasLimit,
TxListByteStart: common.Big0,
TxListByteEnd: common.Big0,
CacheTxListInfo: 0,
Expand Down Expand Up @@ -484,15 +466,6 @@ func (p *Proposer) L2SuggestedFeeRecipient() common.Address {
return p.l2SuggestedFeeRecipient
}

// sumTxsGasLimit calculates the accumulated gas limit of all transactions in the list.
func sumTxsGasLimit(txs []*types.Transaction) uint64 {
var total uint64
for i := range txs {
total += txs[i].Gas()
}
return total
}

// getTxOpts creates a bind.TransactOpts instance using the given private key.
func getTxOpts(
ctx context.Context,
Expand Down
10 changes: 0 additions & 10 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ func (s *ProposerTestSuite) SetupTest() {
s.cancel = cancel
}

func (s *ProposerTestSuite) TestSumTxsGasLimit() {
txs := []*types.Transaction{
types.NewTransaction(0, common.Address{}, common.Big0, 1, common.Big0, []byte{}), // gasLimit: 1
types.NewTransaction(0, common.Address{}, common.Big0, 2, common.Big0, []byte{}), // gasLimit: 2
types.NewTransaction(0, common.Address{}, common.Big0, 3, common.Big0, []byte{}), // gasLimit: 3
}

s.Equal(uint64(1+2+3), sumTxsGasLimit(txs))
}

func (s *ProposerTestSuite) TestName() {
s.Equal("proposer", s.p.Name())
}
Expand Down
8 changes: 0 additions & 8 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/taikoxyz/taiko-client/metrics"
eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator"
"github.com/taikoxyz/taiko-client/pkg/rpc"
txListValidator "github.com/taikoxyz/taiko-client/pkg/tx_list_validator"
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
proofSubmitter "github.com/taikoxyz/taiko-client/prover/proof_submitter"
"github.com/urfave/cli/v2"
Expand All @@ -45,7 +44,6 @@ type Prover struct {
rpc *rpc.Client

// Contract configurations
txListValidator *txListValidator.TxListValidator
protocolConfigs *bindings.TaikoDataConfig

// States
Expand Down Expand Up @@ -131,12 +129,6 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
log.Info("Protocol configs", "configs", p.protocolConfigs)

p.submitProofTxMutex = &sync.Mutex{}
p.txListValidator = txListValidator.NewTxListValidator(
uint64(p.protocolConfigs.BlockMaxGasLimit),
p.protocolConfigs.BlockMaxTransactions,
p.protocolConfigs.BlockMaxTxListBytes,
p.rpc.L2ChainID,
)
p.proverAddress = crypto.PubkeyToAddress(p.cfg.L1ProverPrivKey.PublicKey)

chBufferSize := p.protocolConfigs.BlockMaxProposals.Uint64()
Expand Down

0 comments on commit f0a3da7

Please sign in to comment.