Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow API configuration to override supplied gasLimit #6978

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
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
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
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
Contributor Author

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