Skip to content

Conversation

@konstantinabl
Copy link
Contributor

@konstantinabl konstantinabl commented Dec 5, 2025

Description

Updates the transactionIntrinsicGasCost method to align with Ethereum's Pectra upgrade specifications.

Changes

EIP-7623: Calldata Floor Pricing

Added floor price validation to prevent underpriced data-heavy transactions:

  • floorPrice = 21000 + 10 × tokens
  • tokens = zeroBytes + nonZeroBytes × 4

EIP-3860: Contract Creation Cost

Added initcode cost for contract deployment transactions:

  • contractCreationCost = 32000 + 2 × words(calldata)

EIP-7702: Authorization List

Added support for type 4 transaction authorization list costs:

  • authListCost = 25000 × authorizationList.length

Implementation Details

  • Updated method signature from transactionIntrinsicGasCost(data: string) to transactionIntrinsicGasCost(tx: Transaction)
  • Added new constants: TOTAL_COST_FLOOR_PER_TOKEN, INITCODE_WORD_COST, PER_EMPTY_ACCOUNT_COST
  • Updated ContractService.ts to use new method signature
  • Updated unit tests with new expected values
  • Removed obsolete acceptance test that relied on relay accepting transactions that CN would reject (no longer possible with stricter precheck)

References

Related issue(s)

Fixes #4659

Testing Guide

Changes from original design (optional)

N/A

Additional work needed (optional)

N/A

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
@konstantinabl konstantinabl linked an issue Dec 5, 2025 that may be closed by this pull request
6 tasks
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Test Results

 20 files  ±0  272 suites  ±0   21m 40s ⏱️ ±0s
789 tests  - 2  785 ✅  - 1  4 💤 ±0  0 ❌  - 1 
805 runs   - 2  801 ✅  - 1  4 💤 ±0  0 ❌  - 1 

Results for commit 564e291. ± Comparison against base commit 2e9648a.

This pull request removes 2 tests.
should have equal nonces (pending and latest) after CN reverted transaction ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-1 RPC Server Acceptance Tests RPC Server Acceptance Tests Transaction related RPC Calls Transaction Pool feature ENABLE_TX_POOL = true should have equal nonces (pending and latest) after CN reverted transaction
should have equal nonces (pending and latest) after multiple CN reverted transactions ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-1 RPC Server Acceptance Tests RPC Server Acceptance Tests Transaction related RPC Calls Transaction Pool feature ENABLE_TX_POOL = true should have equal nonces (pending and latest) after multiple CN reverted transactions

♻️ This comment has been updated with latest results.

Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
expect(nonceLatest).to.equal(noncePending);
});

it('should have equal nonces (pending and latest) after CN reverted transaction', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed test: This test relied on a transaction passing relay precheck but failing
at Consensus Node with INSUFFICIENT_GAS. After implementing EIP-7623 and EIP-3860
(contract creation cost), the relay now correctly calculates intrinsic gas including
contract creation overhead (73,806 vs 41,484), catching this case at precheck level, so we want achieve the revert on CN and we alrady have other tests failing for CONTRACT_REVERT that test the desired behaviour of pending and latest nonces https://github.com/hiero-ledger/hiero-json-rpc-relay/pull/4686/files#diff-eaa3ef5444041f9a635e11c9d1137963b53436c9a1949faf37c903a4c74300eaR995

@konstantinabl konstantinabl self-assigned this Dec 5, 2025
@konstantinabl konstantinabl added the enhancement New feature or request label Dec 5, 2025
@konstantinabl konstantinabl added this to the 0.74.0 milestone Dec 5, 2025
@konstantinabl konstantinabl marked this pull request as ready for review December 5, 2025 10:31
@konstantinabl konstantinabl requested review from a team as code owners December 5, 2025 10:31
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Copy link
Contributor

@simzzz simzzz left a comment

Choose a reason for hiding this comment

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

LG, just left one question

const contractCall = '0xcfae3217';
const transfer = '0x';
const invalidTx = '0x60806040523480156200001157600080fd5b';
it('should be able to calculate small contract create', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Should we also add a test that verifies the floor price kicks in when floorPrice > standardIntrinsicGas?

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 95.58824% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/relay/src/lib/precheck.ts 96.29% 2 Missing ⚠️
...ices/ethService/contractService/ContractService.ts 75.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #4686      +/-   ##
==========================================
- Coverage   95.47%   95.47%   -0.01%     
==========================================
  Files         129      129              
  Lines       20928    20973      +45     
  Branches     1793     1799       +6     
==========================================
+ Hits        19982    20024      +42     
- Misses        926      929       +3     
  Partials       20       20              
Flag Coverage Δ
config-service 98.83% <ø> (ø)
relay 90.88% <94.11%> (+<0.01%) ⬆️
server 88.99% <ø> (ø)
ws-server 97.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/relay/src/lib/constants.ts 100.00% <100.00%> (ø)
...ices/ethService/contractService/ContractService.ts 93.81% <75.00%> (-0.13%) ⬇️
packages/relay/src/lib/precheck.ts 98.22% <96.29%> (-0.46%) ⬇️
🚀 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.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update gas validation for Pectra upgrade (EIP-7623, EIP-7702)

3 participants