Skip to content

Commit

Permalink
Avoid returing an estimated priority fee that is less than the min ga…
Browse files Browse the repository at this point in the history
…s price (#598)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 authored and letypequividelespoubelles committed Feb 22, 2024
1 parent 163ce5e commit 57b9f8d
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,23 @@ public LineaEstimateGas.Response execute(final PluginRpcRequest request) {
.getNextBlockBaseFee()
.orElseThrow(() -> new IllegalStateException("Not on a baseFee market"));

final Wei priorityFeeLowerBound = minGasPrice.subtract(baseFee);
final Wei boundedEstimatedPriorityFee;
if (estimatedPriorityFee.lessThan(priorityFeeLowerBound)) {
boundedEstimatedPriorityFee = priorityFeeLowerBound;
log.atDebug()
.setMessage(
"Estimated priority fee {} is lower that the lower bound {}, returning the latter")
.addArgument(estimatedPriorityFee::toHumanReadableString)
.addArgument(boundedEstimatedPriorityFee::toHumanReadableString)
.log();
} else {
boundedEstimatedPriorityFee = estimatedPriorityFee;
}

final var response =
new Response(create(estimatedGasUsed), create(baseFee), create(estimatedPriorityFee));
new Response(
create(estimatedGasUsed), create(baseFee), create(boundedEstimatedPriorityFee));
log.debug("Response for call params {} is {}", callParameters, response);

return response;
Expand Down

0 comments on commit 57b9f8d

Please # to comment.