diff --git a/packages/taiko-client/proposer/transaction_builder/fallback.go b/packages/taiko-client/proposer/transaction_builder/fallback.go index 9305e7ec69b..120017b2067 100644 --- a/packages/taiko-client/proposer/transaction_builder/fallback.go +++ b/packages/taiko-client/proposer/transaction_builder/fallback.go @@ -143,23 +143,33 @@ func (b *TxBuilderWithFallback) estimateCandidateCost( ctx context.Context, candidate *txmgr.TxCandidate, ) (*big.Int, error) { - txmgr, _ := b.txmgrSelector.Select() - gasTipCap, baseFee, blobBaseFee, err := txmgr.SuggestGasPriceCaps(ctx) + txMgr, _ := b.txmgrSelector.Select() + gasTipCap, baseFee, blobBaseFee, err := txMgr.SuggestGasPriceCaps(ctx) if err != nil { return nil, err } log.Debug("Suggested gas price", "gasTipCap", gasTipCap, "baseFee", baseFee, "blobBaseFee", blobBaseFee) gasFeeCap := new(big.Int).Add(baseFee, gasTipCap) - gasUsed, err := b.rpc.L1.EstimateGas(ctx, ethereum.CallMsg{ - From: txmgr.From(), + msg := ethereum.CallMsg{ + From: txMgr.From(), To: candidate.To, Gas: candidate.GasLimit, GasFeeCap: gasFeeCap, GasTipCap: gasTipCap, Value: candidate.Value, Data: candidate.TxData, - }) + } + if len(candidate.Blobs) != 0 { + var blobHashes []common.Hash + if _, blobHashes, err = txmgr.MakeSidecar(candidate.Blobs); err != nil { + return nil, fmt.Errorf("failed to make sidecar: %w", err) + } + msg.BlobHashes = blobHashes + msg.BlobGasFeeCap = blobBaseFee + } + + gasUsed, err := b.rpc.L1.EstimateGas(ctx, msg) if err != nil { return nil, fmt.Errorf("failed to estimate gas used: %w", err) } diff --git a/packages/taiko-client/proposer/transaction_builder/fallback_test.go b/packages/taiko-client/proposer/transaction_builder/fallback_test.go index 3fcd0eb63c1..8107875b6f6 100644 --- a/packages/taiko-client/proposer/transaction_builder/fallback_test.go +++ b/packages/taiko-client/proposer/transaction_builder/fallback_test.go @@ -30,6 +30,13 @@ func (s *TransactionBuilderTestSuite) TestBuildCalldataWithBlobAllowed() { s.NotZero(len(candidate.Blobs)) } +func (s *TransactionBuilderTestSuite) TestBlobAllowed() { + builder := s.newTestBuilderWithFallback(false, false) + s.False(builder.BlobAllow()) + builder = s.newTestBuilderWithFallback(true, false) + s.True(builder.BlobAllow()) +} + func (s *TransactionBuilderTestSuite) newTestBuilderWithFallback(blobAllowed, fallback bool) *TxBuilderWithFallback { l1ProposerPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY"))) s.Nil(err)