Skip to content

Commit

Permalink
Empty blocks built by using calldata
Browse files Browse the repository at this point in the history
  • Loading branch information
mskrzypkows committed Jan 2, 2025
1 parent e5000b0 commit ee87039
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Proposer struct {
checkProfitability bool

allowEmptyBlocks bool
initDone bool
initDone bool
}

// InitFromCli initializes the given proposer instance based on the command line flags.
Expand Down Expand Up @@ -461,7 +461,7 @@ func (p *Proposer) ProposeTxListOntake(
return errors.New("insufficient prover balance")
}

txCandidate, cost, err := p.buildCheaperOnTakeTransaction(ctx, txListsBytesArray)
txCandidate, cost, err := p.buildCheaperOnTakeTransaction(ctx, txListsBytesArray, p.isEmptyBlock(txLists))
if err != nil {
log.Warn("Failed to build TaikoL1.proposeBlocksV2 transaction", "error", encoding.TryParsingCustomError(err))
return err
Expand Down Expand Up @@ -491,7 +491,7 @@ func (p *Proposer) ProposeTxListOntake(
}

func (p *Proposer) buildCheaperOnTakeTransaction(ctx context.Context,
txListsBytesArray [][]byte) (*txmgr.TxCandidate, *big.Int, error) {
txListsBytesArray [][]byte, isEmptyBlock bool) (*txmgr.TxCandidate, *big.Int, error) {
txCallData, err := p.txCallDataBuilder.BuildOntake(ctx, txListsBytesArray)
if err != nil {
return nil, nil, err
Expand All @@ -500,7 +500,7 @@ func (p *Proposer) buildCheaperOnTakeTransaction(ctx context.Context,
var tx *txmgr.TxCandidate
var cost *big.Int

if p.txBlobBuilder != nil {
if p.txBlobBuilder != nil && !isEmptyBlock {
txBlob, err := p.txBlobBuilder.BuildOntake(ctx, txListsBytesArray)
if err != nil {
return nil, nil, err
Expand All @@ -521,6 +521,17 @@ func (p *Proposer) buildCheaperOnTakeTransaction(ctx context.Context,
return tx, cost, nil
}

func (p *Proposer) isEmptyBlock(txLists []types.Transactions) bool {
for _, txs := range txLists {
for _, tx := range txs {
if tx.To() != nil {
return false
}
}
}
return true
}

func (p *Proposer) chooseCheaperTransaction(
txCallData *txmgr.TxCandidate,
txBlob *txmgr.TxCandidate,
Expand Down

0 comments on commit ee87039

Please sign in to comment.