Skip to content

feat: fix contract creation tx receipt compatibility with Ethereum spec #3825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mwb-al
Copy link
Contributor

@mwb-al mwb-al commented Jun 5, 2025

Description:
There is a discrepancy between Hedera and standard Ethereum behavior regarding the to field in transaction receipts for contract creation transactions:

  • Standard Ethereum JSON-RPC: When a contract is created via a transaction with a null to field, the transaction receipt also reports a null to field
  • Hedera Mirror Node: Automatically populates the to field with the address of the newly created contract

This inconsistency affects both eth_getTransactionReceipt and eth_getBlockReceipts endpoints, causing compatibility issues with Ethereum tooling that expects standard transaction receipt formats.

Solution

This PR implements a centralized fix in TransactionReceiptFactory.createRegularReceipt() to correct the to field behavior for contract creation transactions. The solution:

  1. Checks for direct contract creation: Examines if a contract was directly created by the transaction by verifying if the contract's ID appears in the created_contract_ids array
  2. Sets to field to null: When direct contract creation is detected, the to field is set to null to match standard Ethereum JSON-RPC behavior
  3. Ensures consistent behavior: Since both affected endpoints (eth_getTransactionReceipt and eth_getBlockReceipts) use the same factory method, this change ensures consistent behavior across both endpoints

This change affects:

  • eth_getTransactionReceipt - Individual transaction receipt queries
  • eth_getBlockReceipts - Batch transaction receipt queries for entire blocks

Related issue(s):

Fixes #3814

Checklist

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

mwb-al added 2 commits June 5, 2025 12:58
…n nullable types and add tests validating address resolution logic (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
…ation compatibility with Ethereum JSON-RPC standards and add corresponding tests (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
@lfdt-bot
Copy link

lfdt-bot commented Jun 5, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...b/services/ethService/blockService/BlockService.ts 0.00% 4 Missing ⚠️
...thService/transactionService/TransactionService.ts 0.00% 1 Missing and 1 partial ⚠️
...vices/ethService/ethCommonService/CommonService.ts 0.00% 0 Missing and 1 partial ⚠️
@@           Coverage Diff           @@
##             main    #3825   +/-   ##
=======================================
  Coverage        ?   46.67%           
=======================================
  Files           ?       80           
  Lines           ?     4692           
  Branches        ?      975           
=======================================
  Hits            ?     2190           
  Misses          ?     2153           
  Partials        ?      349           
Files with missing lines Coverage Δ
...lay/src/lib/factories/transactionReceiptFactory.ts 68.42% <ø> (ø)
...vices/ethService/ethCommonService/CommonService.ts 24.77% <0.00%> (ø)
...thService/transactionService/TransactionService.ts 39.36% <0.00%> (ø)
...b/services/ethService/blockService/BlockService.ts 28.77% <0.00%> (ø)
🚀 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.

…ro-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
@mwb-al mwb-al marked this pull request as ready for review June 9, 2025 10:34
@mwb-al mwb-al requested review from a team as code owners June 9, 2025 10:34
@mwb-al mwb-al requested a review from konstantinabl June 9, 2025 10:34
mwb-al added 3 commits June 10, 2025 11:54
… transactions (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
…r#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
@mwb-al mwb-al requested a review from quiet-node June 10, 2025 10:44
…with `null` to field (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
Copy link
Contributor

@acuarica acuarica left a comment

Choose a reason for hiding this comment

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

Does this change only impact eth_getBlockReceipts, or eth_getTransactionReceipt as well? Because there is test change for eth_getTransactionReceipt, but I would have assumed that TransactionService.ts::handleRegularTransactionReceipt needs to be changed as well.

In any case, we should update both this PR and issue descriptions to match the actual scope of this PR.

…ipts to `transactionReceiptFactory` (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
@mwb-al mwb-al requested a review from acuarica June 12, 2025 10:45
…nReceiptFactory` (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
@natanasow natanasow modified the milestones: 0.69.0, 0.70.0 Jun 13, 2025
quiet-node
quiet-node previously approved these changes Jun 17, 2025
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

LGTM

@mwb-al
Copy link
Contributor Author

mwb-al commented Jun 18, 2025

@quiet-node I have updated the branch with the latest main and made sure all tests pass.

@quiet-node
Copy link
Contributor

@quiet-node I have updated the branch with the latest main and made sure all tests pass.

@mwb-al hey thanks looks like the DCO is still failing. Please update the branch and will approve again

@mwb-al mwb-al force-pushed the 3814_to-field-is-not-null-eth-getBlockReceipts branch from 30829ca to 525de14 Compare June 23, 2025 12:01
@mwb-al mwb-al requested a review from a team as a code owner June 23, 2025 12:01
@mwb-al mwb-al requested a review from andrewb1269hg June 23, 2025 12:01
@mwb-al mwb-al marked this pull request as draft June 23, 2025 12:08
@mwb-al mwb-al force-pushed the 3814_to-field-is-not-null-eth-getBlockReceipts branch from 525de14 to 30829ca Compare June 23, 2025 12:12
mwb-al added 4 commits June 23, 2025 14:26
…ct deployments with `null` to field (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
…n-existent block

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
…deployment tests (hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
…hiero-ledger#3814)

Signed-off-by: Michał Walczak <michal.walczak@arianelabs.com>
@mwb-al mwb-al force-pushed the 3814_to-field-is-not-null-eth-getBlockReceipts branch from 30829ca to 7789fe7 Compare June 23, 2025 12:28
Signed-off-by: Michał Walczak <151550037+mwb-al@users.noreply.github.com>
@mwb-al mwb-al marked this pull request as ready for review June 23, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ArianeLabs Items ArianeLabs is contributing to
Projects
None yet
Development

Successfully merging this pull request may close these issues.

to field is not null for contract creation transactions in eth_getBlockReceipts
6 participants