Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so no longer comparing gasCap to gasLimit, just if > zero?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is essentially an override value from the cli. @matkt can speak to the specifics about why we would raise the cap beyond the requested limit, but I think it has something to do with simulating transactions that will exceed the anticipated gas, but not exceed some predefined hard cap (DoS vector).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is need in order to allow user setting a high gasLimit for ethcall

}
final Wei value = callParams.getValue() != null ? callParams.getValue() : Wei.ZERO;
final Bytes payload = callParams.getPayload() != null ? callParams.getPayload() : Bytes.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
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() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if cap is lower than gasLimit

Copy link
Copy Markdown
Contributor Author

@garyschulte garyschulte Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this test can really just be renamed to something like "when present rpc gas cap supersedes request gas limit"

// 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