Skip to content

Commit

Permalink
feature: Add module limit verification to linea_estimateGas
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia committed Apr 8, 2024
1 parent 498a478 commit 03cdacf
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ private Long estimateGasUsed(

// else do a binary search to find the right estimation
int iterations = 0;
var high = highGasEstimation(lr.getGasEstimate(), tracerAggregator);
var high =
highGasEstimation(lr.getGasEstimate(), estimateGasOperationTracer);
var mid = high;
var low = lowGasEstimation;
while (low + 1 < high) {
Expand Down Expand Up @@ -383,14 +384,14 @@ private void validateParameters(final JsonCallParameter callParameters) {
* @param operationTracer estimate gas operation tracer
* @return estimate gas
*/
private long highGasEstimation(final long gasEstimation, final TracerAggregator operationTracer) {
var estimateGasTracer = operationTracer.getTracer(EstimateGasOperationTracer.class);
private long highGasEstimation(
final long gasEstimation, final EstimateGasOperationTracer operationTracer) {

// no more than 63/64s of the remaining gas can be passed to the sub calls
final double subCallMultiplier =
Math.pow(SUB_CALL_REMAINING_GAS_RATIO, estimateGasTracer.getMaxDepth());
Math.pow(SUB_CALL_REMAINING_GAS_RATIO, operationTracer.getMaxDepth());
// and minimum gas remaining is necessary for some operation (additionalStipend)
final long gasStipend = estimateGasTracer.getStipendNeeded();
final long gasStipend = operationTracer.getStipendNeeded();
return ((long) ((gasEstimation + gasStipend) * subCallMultiplier));
}

Expand Down

0 comments on commit 03cdacf

Please sign in to comment.