Skip to content

Commit

Permalink
Allow API configuration to override supplied gasLimit (#6978)
Browse files Browse the repository at this point in the history
* allow gasLimit configuration for transaction simulation
* revise unit test to reflect new behavior of rpcGasCap

Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: Karim Taam <karim.t2am@gmail.com>
  • Loading branch information
garyschulte and matkt committed May 1, 2024
1 parent 9006658 commit afea4e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Expand Up @@ -235,11 +235,8 @@ public Optional<TransactionSimulatorResult> processWithWorldUpdater(
? callParams.getGasLimit()
: blockHeaderToProcess.getGasLimit();
if (rpcGasCap > 0) {
final long gasCap = rpcGasCap;
if (gasCap < gasLimit) {
gasLimit = gasCap;
LOG.info("Capping gasLimit to " + gasCap);
}
gasLimit = rpcGasCap;
LOG.info("Capping gasLimit to " + rpcGasCap);
}
final Wei value = callParams.getValue() != null ? callParams.getValue() : Wei.ZERO;
final Bytes payload = callParams.getPayload() != null ? callParams.getPayload() : Bytes.EMPTY;
Expand Down
Expand Up @@ -565,8 +565,9 @@ public void shouldCapGasLimitWhenOriginalTransactionExceedsGasCap() {
}

@Test
public void shouldKeepOriginalGasLimitWhenCapIsHigherThanOriginalValue() {
// generate a transaction with a gas limit that is lower than the gas cap
public void shouldUseRpcGasCapWhenCapIsHigherThanGasLimit() {
// generate a transaction with a gas limit that is lower than the gas cap,
// expect the gas cap to override parameter gas limit
final CallParameter callParameter =
eip1559TransactionCallParameter(Wei.ZERO, Wei.ZERO, GASCAP - 1);

Expand All @@ -589,6 +590,7 @@ public void shouldKeepOriginalGasLimitWhenCapIsHigherThanOriginalValue() {
.value(callParameter.getValue())
.payload(callParameter.getPayload())
.signature(FAKE_SIGNATURE)
.gasLimit(GASCAP)
.build();

// call process with original transaction
Expand Down

0 comments on commit afea4e0

Please sign in to comment.