Skip to content

Commit ff2fa2e

Browse files
fix: Re-enable gas throttle; disable ops duration throttle (#21845)
Signed-off-by: Lukasz Gasior <[email protected]>
1 parent 3ffc3b1 commit ff2fa2e

File tree

8 files changed

+66
-65
lines changed

8 files changed

+66
-65
lines changed

hedera-node/hedera-config/src/main/java/com/hedera/node/config/data/ContractsConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public record ContractsConfig(
1919
boolean noncesExternalizationEnabled,
2020
@ConfigProperty(defaultValue = "false") @NetworkProperty boolean enforceCreationThrottle,
2121
@ConfigProperty(defaultValue = "15000000") @NetworkProperty long maxGasPerTransaction,
22-
@ConfigProperty(defaultValue = "1500000000") @NetworkProperty long maxGasPerSec,
23-
@ConfigProperty(defaultValue = "1500000000") @NetworkProperty long maxGasPerSecBackend,
22+
@ConfigProperty(defaultValue = "15000000") @NetworkProperty long maxGasPerSec,
23+
@ConfigProperty(defaultValue = "15000000") @NetworkProperty long maxGasPerSecBackend,
2424
@ConfigProperty(defaultValue = "500000000") @NetworkProperty long opsDurationThrottleCapacity,
2525
@ConfigProperty(defaultValue = "500000000") @NetworkProperty long opsDurationThrottleUnitsFreedPerSecond,
2626
@ConfigProperty(value = "maxKvPairs.aggregate", defaultValue = "500000000") @NetworkProperty
@@ -34,11 +34,11 @@ public record ContractsConfig(
3434
@ConfigProperty(defaultValue = "CONTRACT_STATE_CHANGE,CONTRACT_BYTECODE,CONTRACT_ACTION") @NetworkProperty
3535
Set<SidecarType> sidecars,
3636
@ConfigProperty(defaultValue = "false") @NetworkProperty boolean sidecarValidationEnabled,
37-
@ConfigProperty(value = "throttle.throttleByGas", defaultValue = "false") @NetworkProperty
37+
@ConfigProperty(value = "throttle.throttleByGas", defaultValue = "true") @NetworkProperty
3838
boolean throttleThrottleByGas,
39-
@ConfigProperty(value = "throttle.throttleByOpsDuration", defaultValue = "true") @NetworkProperty
39+
@ConfigProperty(value = "throttle.throttleByOpsDuration", defaultValue = "false") @NetworkProperty
4040
boolean throttleThrottleByOpsDuration,
41-
@ConfigProperty(defaultValue = "100") @NetworkProperty int maxRefundPercentOfGasLimit,
41+
@ConfigProperty(defaultValue = "20") @NetworkProperty int maxRefundPercentOfGasLimit,
4242
@ConfigProperty(value = "precompile.exchangeRateGasCost", defaultValue = "100") @NetworkProperty
4343
long precompileExchangeRateGasCost,
4444
@ConfigProperty(value = "precompile.htsDefaultGasCost", defaultValue = "10000") @NetworkProperty

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/ethereum/EthereumSuite.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -277,23 +277,24 @@ List<Stream<DynamicTest>> feePaymentMatrix() {
277277
final long noPayment = 0L;
278278
final long thirdOfFee = GAS_PRICE / 3;
279279
final long thirdOfPayment = thirdOfFee * chargedGasLimit;
280+
final long thirdOfLimit = thirdOfFee * GAS_LIMIT;
280281
final long fullAllowance = GAS_PRICE * chargedGasLimit * 5 / 4;
282+
final long fullPayment = GAS_PRICE * chargedGasLimit;
281283
final long ninetyPercentFee = GAS_PRICE * 9 / 10;
282-
final boolean charged = true;
283-
final boolean notCharged = false;
284+
284285
return Stream.of(
285-
new Object[] {false, noPayment, noPayment, notCharged},
286-
new Object[] {false, noPayment, thirdOfPayment, notCharged},
287-
new Object[] {true, noPayment, fullAllowance, notCharged},
288-
new Object[] {false, thirdOfFee, noPayment, notCharged},
289-
new Object[] {false, thirdOfFee, thirdOfPayment, notCharged},
290-
new Object[] {true, thirdOfFee, fullAllowance, charged},
291-
new Object[] {true, thirdOfFee, fullAllowance * 9 / 10, charged},
292-
new Object[] {false, ninetyPercentFee, noPayment, notCharged},
293-
new Object[] {true, ninetyPercentFee, thirdOfPayment, charged},
294-
new Object[] {true, GAS_PRICE, noPayment, charged},
295-
new Object[] {true, GAS_PRICE, thirdOfPayment, charged},
296-
new Object[] {true, GAS_PRICE, fullAllowance, charged})
286+
new Object[] {false, noPayment, noPayment, noPayment},
287+
new Object[] {false, noPayment, thirdOfPayment, noPayment},
288+
new Object[] {true, noPayment, fullAllowance, noPayment},
289+
new Object[] {false, thirdOfFee, noPayment, noPayment},
290+
new Object[] {false, thirdOfFee, thirdOfPayment, noPayment},
291+
new Object[] {true, thirdOfFee, fullAllowance, thirdOfLimit},
292+
new Object[] {true, thirdOfFee, fullAllowance * 9 / 10, thirdOfLimit},
293+
new Object[] {false, ninetyPercentFee, noPayment, noPayment},
294+
new Object[] {true, ninetyPercentFee, thirdOfPayment, fullPayment},
295+
new Object[] {true, GAS_PRICE, noPayment, fullPayment},
296+
new Object[] {true, GAS_PRICE, thirdOfPayment, fullPayment},
297+
new Object[] {true, GAS_PRICE, fullAllowance, fullPayment})
297298
.map(params ->
298299
// [0] - success
299300
// [1] - sender gas price
@@ -302,7 +303,7 @@ List<Stream<DynamicTest>> feePaymentMatrix() {
302303
// relayer charged amount can easily be calculated via
303304
// wholeTransactionFee - senderChargedAmount
304305
matrixedPayerRelayerTest(
305-
(boolean) params[0], (long) params[1], (long) params[2], (boolean) params[3]))
306+
(boolean) params[0], (long) params[1], (long) params[2], (long) params[3]))
306307
.toList();
307308
}
308309

@@ -367,7 +368,7 @@ final Stream<DynamicTest> matrixedPayerRelayerTest12() {
367368
}
368369

369370
final Stream<DynamicTest> matrixedPayerRelayerTest(
370-
final boolean success, final long senderGasPrice, final long relayerOffered, final boolean senderCharged) {
371+
final boolean success, final long senderGasPrice, final long relayerOffered, final long senderCharged) {
371372
return Stream.of(namedHapiTest(
372373
"feePaymentMatrix " + (success ? "Success/" : "Failure/") + senderGasPrice + "/" + relayerOffered,
373374
newKeyNamed(SECP_256K1_SOURCE_KEY).shape(SECP_256K1_SHAPE),
@@ -405,15 +406,14 @@ final Stream<DynamicTest> matrixedPayerRelayerTest(
405406

406407
final long wholeTransactionFee =
407408
hapiGetTxnRecord.getResponseRecord().getTransactionFee();
408-
final var senderGasCharged = senderCharged ? (gasUsed.get() * GAS_PRICE) : 0;
409409
final var subop4 = getAutoCreatedAccountBalance(SECP_256K1_SOURCE_KEY)
410-
.hasTinyBars(changeFromSnapshot(
411-
senderBalance, success ? (-DEPOSIT_AMOUNT - senderGasCharged) : 0));
410+
.hasTinyBars(
411+
changeFromSnapshot(senderBalance, success ? (-DEPOSIT_AMOUNT - senderCharged) : 0));
412412
// The relayer is not charged with Hapi fee unless the relayed transaction failed
413413
final var subop5 = getAccountBalance(RELAYER)
414414
.hasTinyBars(changeFromSnapshot(
415415
payerBalance,
416-
success ? -(wholeTransactionFee - senderGasCharged) : -wholeTransactionFee));
416+
success ? -(wholeTransactionFee - senderCharged) : -wholeTransactionFee));
417417
allRunFor(spec, subop4, subop5);
418418
})));
419419
}

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/ethereum/JumboTransactionsEnabledTest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,29 @@ public Stream<DynamicTest> jumboTransactionShouldPass() {
152152
// send jumbo payload to jumbo endpoint and assert the used gas
153153
jumboEthCall(CONTRACT_CALLDATA_SIZE, FUNCTION, jumboPayload)
154154
.gasLimit(800000)
155-
.exposingGasTo((s, gasUsed) -> assertEquals(63_742, gasUsed)),
155+
.exposingGasTo((s, gasUsed) -> assertEquals(640000, gasUsed)),
156156
jumboEthCall(CONTRACT_CALLDATA_SIZE, FUNCTION, halfJumboPayload)
157157
.gasLimit(500000)
158-
.exposingGasTo((s, gasUsed) -> assertEquals(43_262, gasUsed)),
158+
.exposingGasTo((s, gasUsed) -> assertEquals(400000, gasUsed)),
159159
jumboEthCall(CONTRACT_CALLDATA_SIZE, FUNCTION, thirdJumboPayload)
160160
.gasLimit(300000)
161-
.exposingGasTo((s, gasUsed) -> assertEquals(35_070, gasUsed)));
161+
.exposingGasTo((s, gasUsed) -> assertEquals(240000, gasUsed)));
162162
}
163163

164164
@Nested
165165
@DisplayName("Jumbo Ethereum Transactions Positive Tests")
166166
class JumboEthereumTransactionsPositiveTests {
167167

168168
private final Stream<TestCombinationWithGas> positiveBoundariesTestCases = Stream.of(
169-
new TestCombinationWithGas(SIX_KB_SIZE, EthTxData.EthTransactionType.LEGACY_ETHEREUM, 400_000, 47_358),
170-
new TestCombinationWithGas(SIX_KB_SIZE, EthTxData.EthTransactionType.EIP2930, 400_000, 47_358),
171-
new TestCombinationWithGas(SIX_KB_SIZE, EthTxData.EthTransactionType.EIP1559, 400_000, 47_358),
169+
new TestCombinationWithGas(SIX_KB_SIZE, EthTxData.EthTransactionType.LEGACY_ETHEREUM, 400_000, 320_000),
170+
new TestCombinationWithGas(SIX_KB_SIZE, EthTxData.EthTransactionType.EIP2930, 400_000, 320_000),
171+
new TestCombinationWithGas(SIX_KB_SIZE, EthTxData.EthTransactionType.EIP1559, 400_000, 320_000),
172172
new TestCombinationWithGas(
173-
MAX_ALLOWED_SIZE, EthTxData.EthTransactionType.LEGACY_ETHEREUM, 9_000_000, 542_986),
174-
new TestCombinationWithGas(MAX_ALLOWED_SIZE, EthTxData.EthTransactionType.EIP2930, 9_000_000, 542_986),
175-
new TestCombinationWithGas(MAX_ALLOWED_SIZE, EthTxData.EthTransactionType.EIP1559, 9_000_000, 542_986));
173+
MAX_ALLOWED_SIZE, EthTxData.EthTransactionType.LEGACY_ETHEREUM, 9_000_000, 7_200_000),
174+
new TestCombinationWithGas(
175+
MAX_ALLOWED_SIZE, EthTxData.EthTransactionType.EIP2930, 9_000_000, 7_200_000),
176+
new TestCombinationWithGas(
177+
MAX_ALLOWED_SIZE, EthTxData.EthTransactionType.EIP1559, 9_000_000, 7_200_000));
176178

177179
@RepeatableHapiTest(RepeatableReason.NEEDS_VIRTUAL_TIME_FOR_FAST_EXECUTION)
178180
@DisplayName("Jumbo Ethereum transactions should pass for valid sizes and expected gas used")

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/ethereum/batch/AtomicEthereumSuite.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -299,24 +299,24 @@ List<Stream<DynamicTest>> feePaymentMatrix() {
299299
final long noPayment = 0L;
300300
final long thirdOfFee = GAS_PRICE / 3;
301301
final long thirdOfPayment = thirdOfFee * chargedGasLimit;
302+
final long thirdOfLimit = thirdOfFee * GAS_LIMIT;
302303
final long fullAllowance = GAS_PRICE * chargedGasLimit * 5 / 4;
304+
final long fullPayment = GAS_PRICE * chargedGasLimit;
303305
final long ninetyPercentFee = GAS_PRICE * 9 / 10;
304-
final boolean charged = true;
305-
final boolean notCharged = false;
306306

307307
return Stream.of(
308-
new Object[] {false, noPayment, noPayment, notCharged},
309-
new Object[] {false, noPayment, thirdOfPayment, notCharged},
310-
new Object[] {true, noPayment, fullAllowance, notCharged},
311-
new Object[] {false, thirdOfFee, noPayment, notCharged},
312-
new Object[] {false, thirdOfFee, thirdOfPayment, notCharged},
313-
new Object[] {true, thirdOfFee, fullAllowance, charged},
314-
new Object[] {true, thirdOfFee, fullAllowance * 9 / 10, charged},
315-
new Object[] {false, ninetyPercentFee, noPayment, notCharged},
316-
new Object[] {true, ninetyPercentFee, thirdOfPayment, charged},
317-
new Object[] {true, GAS_PRICE, noPayment, charged},
318-
new Object[] {true, GAS_PRICE, thirdOfPayment, charged},
319-
new Object[] {true, GAS_PRICE, fullAllowance, charged})
308+
new Object[] {false, noPayment, noPayment, noPayment},
309+
new Object[] {false, noPayment, thirdOfPayment, noPayment},
310+
new Object[] {true, noPayment, fullAllowance, noPayment},
311+
new Object[] {false, thirdOfFee, noPayment, noPayment},
312+
new Object[] {false, thirdOfFee, thirdOfPayment, noPayment},
313+
new Object[] {true, thirdOfFee, fullAllowance, thirdOfLimit},
314+
new Object[] {true, thirdOfFee, fullAllowance * 9 / 10, thirdOfLimit},
315+
new Object[] {false, ninetyPercentFee, noPayment, noPayment},
316+
new Object[] {true, ninetyPercentFee, thirdOfPayment, fullPayment},
317+
new Object[] {true, GAS_PRICE, noPayment, fullPayment},
318+
new Object[] {true, GAS_PRICE, thirdOfPayment, fullPayment},
319+
new Object[] {true, GAS_PRICE, fullAllowance, fullPayment})
320320
.map(params ->
321321
// [0] - success
322322
// [1] - sender gas price
@@ -325,7 +325,7 @@ List<Stream<DynamicTest>> feePaymentMatrix() {
325325
// relayer charged amount can easily be calculated via
326326
// wholeTransactionFee - senderChargedAmount
327327
matrixedPayerRelayerTest(
328-
(boolean) params[0], (long) params[1], (long) params[2], (boolean) params[3]))
328+
(boolean) params[0], (long) params[1], (long) params[2], (long) params[3]))
329329
.toList();
330330
}
331331

@@ -391,7 +391,7 @@ final Stream<DynamicTest> matrixedPayerRelayerTest12() {
391391
}
392392

393393
final Stream<DynamicTest> matrixedPayerRelayerTest(
394-
final boolean success, final long senderGasPrice, final long relayerOffered, final boolean senderCharged) {
394+
final boolean success, final long senderGasPrice, final long relayerOffered, final long senderCharged) {
395395
return Stream.of(namedHapiTest(
396396
"feePaymentMatrix " + (success ? "Success/" : "Failure/") + senderGasPrice + "/" + relayerOffered,
397397
newKeyNamed(SECP_256K1_SOURCE_KEY).shape(SECP_256K1_SHAPE),
@@ -433,15 +433,14 @@ final Stream<DynamicTest> matrixedPayerRelayerTest(
433433

434434
final long wholeTransactionFee =
435435
hapiGetTxnRecord.getResponseRecord().getTransactionFee();
436-
final var senderGasCharged = senderCharged ? (gasUsed.get() * GAS_PRICE) : 0;
437436
final var subop4 = getAutoCreatedAccountBalance(SECP_256K1_SOURCE_KEY)
438-
.hasTinyBars(changeFromSnapshot(
439-
senderBalance, success ? (-DEPOSIT_AMOUNT - senderGasCharged) : 0));
437+
.hasTinyBars(
438+
changeFromSnapshot(senderBalance, success ? (-DEPOSIT_AMOUNT - senderCharged) : 0));
440439
// The relayer is not charged with Hapi fee unless the relayed transaction failed
441440
final var subop5 = getAccountBalance(RELAYER)
442441
.hasTinyBars(changeFromSnapshot(
443442
payerBalance,
444-
success ? -(wholeTransactionFee - senderGasCharged) : -wholeTransactionFee));
443+
success ? -(wholeTransactionFee - senderCharged) : -wholeTransactionFee));
445444
allRunFor(spec, subop4, subop5);
446445
})));
447446
}

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/fees/AtomicSmartContractServiceFeesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ final Stream<DynamicTest> contractCreateBaseUSDFee() {
7878
.batchKey(BATCH_OPERATOR))
7979
.via(ATOMIC_BATCH)
8080
.signedByPayerAnd(BATCH_OPERATOR),
81-
validateInnerTxnChargedUsd(creation, ATOMIC_BATCH, 0.72, 5));
81+
validateInnerTxnChargedUsd(creation, ATOMIC_BATCH, 0.73, 5));
8282
}
8383

8484
@HapiTest
@@ -96,7 +96,7 @@ final Stream<DynamicTest> contractCallBaseUSDFee() {
9696
.via(ATOMIC_BATCH)
9797
.signedByPayerAnd(BATCH_OPERATOR)
9898
.payingWith(BATCH_OPERATOR),
99-
validateInnerTxnChargedUsd(contract, ATOMIC_BATCH, 0.00184, 1));
99+
validateInnerTxnChargedUsd(contract, ATOMIC_BATCH, 0.0068, 1));
100100
}
101101

102102
@LeakyHapiTest(overrides = "contracts.evm.ethTransaction.zeroHapiFees.enabled")
@@ -124,6 +124,6 @@ final Stream<DynamicTest> ethereumTransactionBaseUSDFee(
124124
.signedByPayerAnd(BATCH_OPERATOR)
125125
.payingWith(BATCH_OPERATOR),
126126
// Estimated base fee for EthereumCall is 0.0001 USD and is paid by the relayer account
127-
validateInnerTxnChargedUsd(ethCall, ATOMIC_BATCH, 0.00194, 1));
127+
validateInnerTxnChargedUsd(ethCall, ATOMIC_BATCH, 0.0069, 1));
128128
}
129129
}

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/fees/SmartContractServiceFeesTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ final Stream<DynamicTest> contractCallBaseUSDFee() {
9090
return hapiTest(
9191
contract.call("contractCall1Byte", new byte[] {0}).gas(100_000L).via(contractCall),
9292
// ContractCall's fee is paid with gas only. Estimated price is based on call data and gas used
93-
validateChargedUsdForGasOnly(contractCall, 0.00184, 1),
94-
validateChargedUsd(contractCall, 0.00184, 1));
93+
validateChargedUsdForGasOnly(contractCall, 0.0068, 1),
94+
validateChargedUsd(contractCall, 0.0068, 1));
9595
}
9696

9797
@LeakyHapiTest(overrides = "contracts.evm.ethTransaction.zeroHapiFees.enabled")
@@ -113,8 +113,8 @@ final Stream<DynamicTest> ethereumTransactionBaseUSDFee(
113113
.nonce(0)
114114
.via(ethCall),
115115
// Estimated base fee for EthereumCall is 0.0001 USD and is paid by the relayer account
116-
validateChargedUsdWithin(ethCall, 0.00194, 1),
117-
validateChargedUsdForGasOnly(ethCall, 0.00184, 1),
116+
validateChargedUsdWithin(ethCall, 0.0069, 1),
117+
validateChargedUsdForGasOnly(ethCall, 0.0068, 1),
118118
validateChargedUsdWithoutGas(ethCall, 0.0001, 1));
119119
}
120120

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/contract/precompile/PrngPrecompileSuite.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ final Stream<DynamicTest> emptyInputCallFails() {
117117
.getTransactionRecord(emptyInputCall)
118118
.getContractCallResult()
119119
.getGasUsed();
120-
assertEquals(21_070L, gasUsed);
120+
assertEquals(320000, gasUsed);
121121
}));
122122
}
123123

@@ -142,7 +142,7 @@ final Stream<DynamicTest> invalidLargeInputFails() {
142142
.getTransactionRecord(largeInputCall)
143143
.getContractCallResult()
144144
.getGasUsed();
145-
assertEquals(26_134L, gasUsed);
145+
assertEquals(320000, gasUsed);
146146
}));
147147
}
148148

@@ -190,7 +190,7 @@ final Stream<DynamicTest> functionCallWithLessThanFourBytesFailsGracefully() {
190190
.getTransactionRecord(lessThan4Bytes)
191191
.getContractCallResult()
192192
.getGasUsed();
193-
assertEquals(21_118L, gasUsed);
193+
assertEquals(320000, gasUsed);
194194
}));
195195
}
196196

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip551/AtomicBatchNegativeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ final Stream<DynamicTest> nonceUpdatedAfterEvmReversionDueContractLogic() {
957957
.payingWith("batchOperator")
958958
.via("batchTxn")
959959
.hasKnownStatus(INNER_TRANSACTION_FAILED),
960-
validateChargedUsdForGasOnlyForInnerTxn("ethCall", "batchTxn", 0.00183, 5),
960+
validateChargedUsdForGasOnlyForInnerTxn("ethCall", "batchTxn", 0.015, 5),
961961
getAliasedAccountInfo(SECP_256K1_SOURCE_KEY)
962962
.has(accountWith().nonce(1L)),
963963
getTxnRecord("ethCall")

0 commit comments

Comments
 (0)