Skip to content

Commit

Permalink
feat(taiko-client): introduce --epoch.allowZeroInterval flag (#17727)
Browse files Browse the repository at this point in the history
Co-authored-by: gavin <[email protected]>
  • Loading branch information
davidtaikocha and YoGhurt111 committed Jul 3, 2024
1 parent a331e9d commit e76890d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
12 changes: 10 additions & 2 deletions packages/taiko-client/cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ var (
Value: 0,
EnvVars: []string{"EPOCH_MIN_TX_LIST_BYTES"},
}
MinTip = &cli.Uint64Flag{
MinTip = &cli.Float64Flag{
Name: "epoch.minTip",
Usage: "Minimum tip for a transaction to propose",
Usage: "Minimum tip (in GWei) for a transaction to propose",
Category: proposerCategory,
Value: 0,
EnvVars: []string{"EPOCH_MIN_TIP"},
Expand All @@ -96,6 +96,13 @@ var (
Value: 0,
EnvVars: []string{"EPOCH_MIN_PROPOSING_INTERNAL"},
}
AllowZeroInterval = &cli.Uint64Flag{
Name: "epoch.allowZeroInterval",
Usage: "If set, after this many epochs, proposer will allow propose zero tip transactions once",
Category: proposerCategory,
Value: 0,
EnvVars: []string{"EPOCH_ALLOW_ZERO_INTERVAL"},
}
// Proposing metadata related.
ExtraData = &cli.StringFlag{
Name: "extraData",
Expand Down Expand Up @@ -164,6 +171,7 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
MinTxListBytes,
MinTip,
MinProposingInternal,
AllowZeroInterval,
MaxProposedTxListsPerEpoch,
ProverEndpoints,
OptimisticTierFee,
Expand Down
9 changes: 8 additions & 1 deletion packages/taiko-client/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
MinTxListBytes uint64
MinTip uint64
MinProposingInternal time.Duration
AllowZeroInterval uint64
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit uint64
ProverEndpoints []*url.URL
Expand Down Expand Up @@ -94,6 +95,11 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return nil, err
}

minTip, err := utils.GWeiToWei(c.Float64(flags.MinTip.Name))
if err != nil {
return nil, err
}

return &Config{
ClientConfig: &rpc.ClientConfig{
L1Endpoint: c.String(flags.L1WSEndpoint.Name),
Expand All @@ -114,9 +120,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name),
MinGasUsed: c.Uint64(flags.MinGasUsed.Name),
MinTxListBytes: c.Uint64(flags.MinTxListBytes.Name),
MinTip: c.Uint64(flags.MinTip.Name),
MinTip: minTip.Uint64(),
MinProposingInternal: c.Duration(flags.MinProposingInternal.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
AllowZeroInterval: c.Uint64(flags.AllowZeroInterval.Name),
ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name),
ProverEndpoints: proverEndpoints,
OptimisticTierFee: optimisticTierFee,
Expand Down
11 changes: 10 additions & 1 deletion packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Proposer struct {
protocolConfigs *bindings.TaikoDataConfig

lastProposedAt time.Time
totalEpochs uint64

txmgr *txmgr.SimpleTxManager

Expand Down Expand Up @@ -177,6 +178,7 @@ func (p *Proposer) eventLoop() {
// proposing interval timer has been reached
case <-p.proposingTimer.C:
metrics.ProposerProposeEpochCounter.Add(1)
p.totalEpochs++

// Attempt a proposing operation
if err := p.ProposeOp(p.ctx); err != nil {
Expand All @@ -194,6 +196,13 @@ func (p *Proposer) Close(_ context.Context) {

// fetchPoolContent fetches the transaction pool content from L2 execution engine.
func (p *Proposer) fetchPoolContent(filterPoolContent bool) ([]types.Transactions, error) {
minTip := p.MinTip
// If `--epoch.allowZeroInterval` flag is set, allow proposing zero tip transactions once when
// the total epochs number is divisible by the flag value.
if p.AllowZeroInterval > 0 && p.totalEpochs%p.AllowZeroInterval == 0 {
minTip = 0
}

// Fetch the pool content.
preBuiltTxList, err := p.rpc.GetPoolContent(
p.ctx,
Expand All @@ -202,7 +211,7 @@ func (p *Proposer) fetchPoolContent(filterPoolContent bool) ([]types.Transaction
rpc.BlockMaxTxListBytes,
p.LocalAddresses,
p.MaxProposedTxListsPerEpoch,
p.MinTip,
minTip,
)
if err != nil {
return nil, fmt.Errorf("failed to fetch transaction pool content: %w", err)
Expand Down

0 comments on commit e76890d

Please sign in to comment.