Skip to content

Commit

Permalink
Fix: rpc gas price option should not incoditionally override smaller …
Browse files Browse the repository at this point in the history
…tx gas limit

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 committed Sep 30, 2024
1 parent c3aa3f4 commit 0959c98
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,23 @@ public Optional<TransactionSimulatorResult> processWithWorldUpdater(
final Account sender = updater.get(senderAddress);
final long nonce = sender != null ? sender.getNonce() : 0L;

long gasLimit =
final long txGasLimit =
callParams.getGasLimit() >= 0
? callParams.getGasLimit()
: blockHeaderToProcess.getGasLimit();

final long simulationGasLimit;
if (rpcGasCap > 0) {
gasLimit = rpcGasCap;
simulationGasLimit = Math.min(txGasLimit, rpcGasCap);
LOG.trace(
"Gas limit capped at {} for transaction simulation due to provided RPC gas cap.",
"Gas limit capped at {} for transaction simulation, tx gas limit is {} and provided RPC gas cap is {}",
simulationGasLimit,
txGasLimit,
rpcGasCap);
} else {
simulationGasLimit = txGasLimit;
}

final Wei value = callParams.getValue() != null ? callParams.getValue() : Wei.ZERO;
final Bytes payload = callParams.getPayload() != null ? callParams.getPayload() : Bytes.EMPTY;

Expand All @@ -265,7 +272,7 @@ public Optional<TransactionSimulatorResult> processWithWorldUpdater(
header,
senderAddress,
nonce,
gasLimit,
simulationGasLimit,
value,
payload,
blobGasPrice);
Expand Down

0 comments on commit 0959c98

Please sign in to comment.