From ee870396538cb548f26ecc24482b24b4915155d5 Mon Sep 17 00:00:00 2001 From: Maciej Skrzypkowski Date: Thu, 2 Jan 2025 11:06:37 +0100 Subject: [PATCH] Empty blocks built by using calldata --- packages/taiko-client/proposer/proposer.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/taiko-client/proposer/proposer.go b/packages/taiko-client/proposer/proposer.go index 411c3ef86be..4d1202a2c31 100644 --- a/packages/taiko-client/proposer/proposer.go +++ b/packages/taiko-client/proposer/proposer.go @@ -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. @@ -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 @@ -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 @@ -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 @@ -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,