Skip to content

Commit

Permalink
fix(taiko-client): fix blob transactions estimation when proposing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jan 3, 2025
1 parent ca3987a commit 395ac5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/taiko-client/proposer/transaction_builder/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 395ac5f

Please sign in to comment.