Skip to content

Commit

Permalink
Merge branch 'main' into eth-call-blob-gas-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jflo authored Mar 18, 2024
2 parents 4b016d3 + 5c1e1e1 commit 6df155d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public static long deltaBound(final long currentGasLimit) {
return Long.divideUnsigned(currentGasLimit, GAS_LIMIT_BOUND_DIVISOR);
}

/**
* Verify that the target gas limit is within the allowed bounds.
*
* @param targetGasLimit the target gas limit to validate
* @return true if within bounds
*/
@SuppressWarnings("ComparisonOutOfRange")
public static boolean isValidTargetGasLimit(final long targetGasLimit) {
return DEFAULT_MIN_GAS_LIMIT <= targetGasLimit && DEFAULT_MAX_GAS_LIMIT >= targetGasLimit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public void verifyMinGasLimit() {
.isFalse();
}

@Test
public void verifyMaxGasLimit() {
assertThat(AbstractGasLimitSpecification.isValidTargetGasLimit(Long.MAX_VALUE - 1)).isTrue();
assertThat(AbstractGasLimitSpecification.isValidTargetGasLimit(Long.MAX_VALUE)).isTrue();
}

@Test
public void verifyWithinGasLimitDelta() {
final long targetGasLimit = 10_000_000L;
Expand Down

0 comments on commit 6df155d

Please sign in to comment.