Skip to content
This repository has been archived by the owner on Apr 11, 2021. It is now read-only.

Commit

Permalink
fix: cap the suggested fee to the gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Mar 23, 2021
1 parent 479d23c commit ba71677
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,15 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash

// 3. calculate the fee
fee := core.CalculateRollupFee(*args.Data, uint64(gasUsed), dataPrice, executionPrice)
return (hexutil.Uint64)(fee.Uint64()), nil

// 4. Do not allow it the fee to be higher than the gas limit
block, err := b.BlockByNumberOrHash(ctx, blockNrOrHash)
res := fee.Uint64()
if res > block.GasLimit() {
res = block.GasLimit()
}

return (hexutil.Uint64)(res), nil
}

func legacyDoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (hexutil.Uint64, error) {
Expand Down

0 comments on commit ba71677

Please sign in to comment.