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.)

@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

 19 files  +   15  263 suites   - 361   22m 35s ⏱️ + 21m 29s
780 tests  - 1 416  773 ✅  - 1 421  4 💤 +2  3 ❌ +3 
794 runs   - 1 414  787 ✅  - 1 419  4 💤 +2  3 ❌ +3 

For more details on these failures, see this check.

Results for commit df07b47. ± Comparison against base commit 1a6b3ca.

This pull request removes 2196 and adds 780 tests. Note that renamed tests count towards both.
"eth_blockNumber" return the latest block number on second try ‑ @ethGetBlockByNumber using MirrorNode "eth_blockNumber" return the latest block number on second try
"eth_blockNumber" should return the latest block number ‑ @ethGetBlockByNumber using MirrorNode "eth_blockNumber" should return the latest block number
"eth_blockNumber" should throw an error if no blocks are found after third try ‑ @ethGetBlockByNumber using MirrorNode "eth_blockNumber" should throw an error if no blocks are found after third try
"eth_blockNumber" should throw an error if no blocks are found ‑ @ethGetBlockByNumber using MirrorNode "eth_blockNumber" should throw an error if no blocks are found
Adds a revertReason field for receipts with errorMessage ‑ @ethGetTransactionReceipt eth_getTransactionReceipt tests Adds a revertReason field for receipts with errorMessage
BLOCK_HASH filter timeouts and throws the expected error ‑ @ethGetLogs using MirrorNode timeout BLOCK_HASH filter timeouts and throws the expected error
BLOCK_HASH filter ‑ @ethGetLogs using MirrorNode BLOCK_HASH filter
Can extract the account number out of an account pagination next link url ‑ MirrorNodeClient Can extract the account number out of an account pagination next link url
Can extract the evm address out of an account pagination next link url ‑ MirrorNodeClient Can extract the evm address out of an account pagination next link url
Can provide custom x-api-key header ‑ MirrorNodeClient given MIRROR_NODE_URL_HEADER_X_API_KEY=abc123iAManAPIkey are set Can provide custom x-api-key header
…
"after all" hook in "@web-socket-ratelimiter Shared Rate Limiting Acceptance Tests" ‑ RPC Server Acceptance Tests Acceptance tests @web-socket-ratelimiter Shared Rate Limiting Acceptance Tests "after all" hook in "@web-socket-ratelimiter Shared Rate Limiting Acceptance Tests"
"before all" hook in "@web-socket-ratelimiter Shared Rate Limiting Acceptance Tests" ‑ RPC Server Acceptance Tests Acceptance tests @web-socket-ratelimiter Shared Rate Limiting Acceptance Tests "before all" hook in "@web-socket-ratelimiter Shared Rate Limiting Acceptance Tests"
"eth_call" for non-existing contract address returns 0x ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call "eth_call" for non-existing contract address returns 0x
001 Should call pureMultiply ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With evm address 001 Should call pureMultiply
001 Should call pureMultiply ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With long-zero address 001 Should call pureMultiply
002 Should call msgSender ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With evm address 002 Should call msgSender
002 Should call msgSender ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With long-zero address 002 Should call msgSender
003 Should call txOrigin ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With evm address 003 Should call txOrigin
003 Should call txOrigin ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With long-zero address 003 Should call txOrigin
004 Should call msgSig ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With evm address 004 Should call msgSig
…
This pull request removes 2 skipped tests and adds 4 skipped tests. Note that renamed tests count towards both.
eth_gasPrice with cached value ‑ @ethGasPrice Gas Price spec @ethGasPrice eth_gasPrice with cached value
supports optionality of request id when configured ‑ RPC Server given REQUEST_ID_IS_OPTIONAL=true are set supports optionality of request id when configured
011 Should fail when calling msgValue with more value than available balance ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With evm address 011 Should fail when calling msgValue with more value than available balance
011 Should fail when calling msgValue with more value than available balance ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests eth_call Caller contract With long-zero address 011 Should fail when calling msgValue with more value than available balance
from/to Addresses in transaction to a contract (deployed through HAPI tx) are in evm and long-zero format ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests Formats of addresses in Transaction and Receipt results from/to Addresses in transaction to a contract (deployed through HAPI tx) are in evm and long-zero format
should not return contract bytecode after sefldestruct ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should not return contract bytecode after sefldestruct

♻️ This comment has been updated with latest results.

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
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
Signed-off-by: Konstantina Blazhukova <[email protected]>
@konstantinabl konstantinabl force-pushed the 4659-update-gas-validation-for-pectra-upgrade branch from 564e291 to 3162ac0 Compare December 9, 2025 12:37
Signed-off-by: Konstantina Blazhukova <[email protected]>
@konstantinabl konstantinabl requested review from a team and simzzz December 9, 2025 13:23
@codecov
Copy link

codecov bot commented Dec 9, 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.68%   95.67%   -0.02%     
==========================================
  Files         137      137              
  Lines       21544    21595      +51     
  Branches     1802     1804       +2     
==========================================
+ Hits        20615    20660      +45     
- Misses        910      916       +6     
  Partials       19       19              
Flag Coverage Δ
config-service 98.85% <ø> (ø)
relay 91.36% <94.11%> (+<0.01%) ⬆️
server 88.99% <ø> (ø)
ws-server 97.72% <ø> (ø)

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.30% <96.29%> (-0.43%) ⬇️

... and 1 file with indirect coverage changes

🚀 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