Skip to content

fix: ignore the gas price for noop context so that gas can be zero#25919

Closed
joshmarinacci wants to merge 7 commits into
mainfrom
fix-noop-gas-context
Closed

fix: ignore the gas price for noop context so that gas can be zero#25919
joshmarinacci wants to merge 7 commits into
mainfrom
fix-noop-gas-context

Conversation

@joshmarinacci

@joshmarinacci joshmarinacci commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Description:

The Single Day Performance Test (SDPT) is failing because it sets the price of the GAS extra to 1. Under Simple Fees all values are in tiny cents, so a fee of 1 will get rounded to 0 when it is converted to tiny bars at a rate of 12 to 1. This triggers isNoopGasContext() to return true even though the price of gas is really more than zero.

This PR fixes the SDPT failure on a gas price of 1 tinycent by changing HederaEvmContext.isNoopGasContext() to not care about the price of gas, only if it is a static call.

Related issue(s):

Fixes #

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

add unit test

Signed-off-by: Josh Marinacci <joshua@marinacci.org>
@joshmarinacci joshmarinacci requested review from a team and tinker-michaelj as code owners June 14, 2026 21:22
@joshmarinacci joshmarinacci self-assigned this Jun 14, 2026
@trunk-io

trunk-io Bot commented Jun 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@lfdt-bot

lfdt-bot commented Jun 14, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Signed-off-by: Josh Marinacci <joshua@marinacci.org>
Signed-off-by: Josh Marinacci <joshua@marinacci.org>
Signed-off-by: Josh Marinacci <joshua@marinacci.org>
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #25919      +/-   ##
============================================
- Coverage     70.34%   70.34%   -0.01%     
+ Complexity    11841    11838       -3     
============================================
  Files          2627     2627              
  Lines        110309   110309              
  Branches      12109    12109              
============================================
- Hits          77602    77597       -5     
- Misses        28693    28694       +1     
- Partials       4014     4018       +4     
Files with missing lines Coverage Δ Complexity Δ
...vice/contract/impl/exec/gas/CustomGasCharging.java 86.04% <100.00%> (ø) 22.00 <0.00> (ø)
...p/service/contract/impl/hevm/HederaEvmContext.java 91.66% <100.00%> (ø) 7.00 <1.00> (-2.00)

... and 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tinker-michaelj tinker-michaelj left a comment

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.

LGTM, tyvm @joshmarinacci !


public boolean isNoopGasContext() {
return staticCall || gasPrice == 0;
return staticCall;

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.

This method now means static/query context rather than no gas accounting context. Can we either rename it or add a short javadoc?

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.

good point. I'll rename it to isStaticCall().

@Neeharika-Sompalli Neeharika-Sompalli left a comment

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.

LGTM! Thanks @joshmarinacci

@@ -38,7 +38,7 @@ public BlockValues blockValuesOf(final long gasLimit) {
}

public boolean isNoopGasContext() {

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.

Codex review on this PR suggest to validate these points:

The change from staticCall || gasPrice == 0 to just staticCall means zero-tinybar gas price transactions now go through the normal charging path with zero amounts. 

- Ethereum transaction signer nonce: before, zero gas price returned before sender.incrementNonce(); now it increments. This affects later WRONG_NONCE checks, aliased account nonce, and newSenderNonce/signer nonce in records.

- Intrinsic gas validation: zero-price transactions now still require gasLimit >= intrinsicGas; before that check was skipped.

- Zero-amount gas events: collectGasFee(..., 0, withNonceIncrement) and refunds can now be recorded/replayed. Amounts net to zero, but the nonce increment flag matters, especially rollback handling.

- Value balance checks: normal charging paths validate sender balance against value even when gas cost is zero, so failure status/timing may change for underfunded value transfers.

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.

Thank you @Neeharika-Sompalli for this input.

  • Ethereum transaction signer nonce: before, zero gas price returned before sender.incrementNonce(); now it increments. This affects later WRONG_NONCE checks, aliased account nonce, and newSenderNonce/signer nonce in records.
    • sounds like exactly the goal (as I understand)
  • Intrinsic gas validation: zero-price transactions now still require gasLimit >= intrinsicGas; before that check was skipped.
    • sound reasonable
  • Zero-amount gas events: collectGasFee(..., 0, withNonceIncrement) and refunds can now be recorded/replayed. Amounts net to zero, but the nonce increment flag matters, especially rollback handling.
    • not sure on this one. Seems also ok if we use 0 gasPrice transactions and expect the nonce to increment.
  • Value balance checks: normal charging paths validate sender balance against value even when gas cost is zero, so failure status/timing may change for underfunded value transfers.
    • sound reasonable

}

@Test
void zeroPriceGasDoesNoChargingWorkButDoesReturnIntrinsicGas() {

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.

Are we sure we want to just remove this test? Maybe adjust it to match the new rules and add a comment explaining what is checked?

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.

That's a good point. I'll add it back and modify it.

@OlegMazurov

Copy link
Copy Markdown
Contributor

HeliSwapLoadTest now fails with CONTRACT_REVERT_EXECUTED when executing a smart contract call.

add back the unit test

Signed-off-by: Josh Marinacci <joshua@marinacci.org>
@swirlds-automation swirlds-automation dismissed stale reviews from tinker-michaelj and Neeharika-Sompalli June 15, 2026 18:29

3 file(s) changed in commit f688a84

@testlens-app

testlens-app Bot commented Jun 15, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: f688a84
▶️ Tests: 21452 executed
⚪️ Checks: 46/46 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants