Skip to content

Commit

Permalink
R4R: fix calculate sponsor amount while estimateGas with metatx
Browse files Browse the repository at this point in the history
  • Loading branch information
wwq authored and wwq committed Jan 22, 2024
1 parent 4071839 commit 39292bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
return 0, err
}
if metaTxParams != nil {
sponsorAmount, _ := types.CalculateSponsorPercentAmount(metaTxParams, feeCap)
sponsorAmount, _ := types.CalculateSponsorPercentAmount(metaTxParams, new(big.Int).Mul(feeCap, new(big.Int).SetUint64(b.CurrentHeader().GasLimit)))
sponsorBalance := state.GetBalance(metaTxParams.GasFeeSponsor)
if sponsorBalance.Cmp(sponsorAmount) <= 0 {
return 0, types.ErrSponsorBalanceNotEnough
Expand Down Expand Up @@ -1329,7 +1329,7 @@ func calculateGasWithAllowance(ctx context.Context, b Backend, args TransactionA
}
if metaTxParams != nil {
feeCap := new(big.Int).Mul(gasPriceForEstimate, big.NewInt(0).SetUint64(gasCap))
sponsorAmount, _ := types.CalculateSponsorPercentAmount(metaTxParams, feeCap)
sponsorAmount, _ := types.CalculateSponsorPercentAmount(metaTxParams, new(big.Int).Mul(feeCap, new(big.Int).SetUint64(b.CurrentHeader().GasLimit)))
sponsorBalance := state.GetBalance(metaTxParams.GasFeeSponsor)
if sponsorBalance.Cmp(sponsorAmount) <= 0 {
return 0, types.ErrSponsorBalanceNotEnough
Expand Down

0 comments on commit 39292bf

Please sign in to comment.