Skip to content

Conversation

@romangzz
Copy link
Contributor

@romangzz romangzz commented Jun 18, 2025

Description:

Ensure eth_getFilterChanges returns a 32-byte block hash to match Ethereum's expectations.

  • Truncate Hedera's 48-byte block hash (from mirror node record files) to 32 bytes
  • Aligns with Ethereum's EVM compatibility requirements
  • Enables valid usage of returned hashes with eth_getBlockByHash
  • Fixes compatibility issue affecting downstream clients/tools

Notes for reviewer:

Previously, eth_getFilterChanges returned 48-byte block hashes, causing eth_getBlockByHash to fail with a parameter validation error. This PR ensures that only the first 32 bytes are returned, complying with Ethereum's JSON-RPC spec.

Example of uncorrected output response:

{
    "result": [
      "0x3c08bbbee74d287b1dcd3f0ca6d1d2cb92c90883c4acf9747de9f3f3162ad25b999fc7e86699f60f2a3fb3ed9a646c6b"
    ],
    "jsonrpc": "2.0",
    "id": 1
}

Example of corrected output response:

{
    "result": [
        "0x3c08bbbee74d287b1dcd3f0ca6d1d2cb92c90883c4acf9747de9f3f3162ad25b"
    ],
    "jsonrpc": "2.0",
    "id": 1
}

Documentation:

According to the Ethereum JSON-RPC Specification, the blockHash must match the following pattern: ^0x[0-9a-f]{64}$, which represents a 32-byte Ethereum block hash.

Fixes #3975.

Checklist

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

@romangzz romangzz requested review from a team as code owners June 18, 2025 10:17
@romangzz romangzz requested a review from acuarica June 18, 2025 10:17
@lfdt-bot
Copy link

lfdt-bot commented Jun 18, 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)

@quiet-node quiet-node added the enhancement New feature or request label Jun 18, 2025
@quiet-node quiet-node added this to the 0.70.0 milestone Jun 18, 2025
@romangzz romangzz force-pushed the fix/get-filter-changes branch from 61885d8 to 0e572d0 Compare June 19, 2025 06:11
@quiet-node
Copy link
Contributor

quiet-node commented Jun 20, 2025

Hey @romangzz, thanks much for the PR great catch indeed! Could you kindly include some links to documentation, if any, supporting this update like from official Ethereum's JSON-RPC spec or whatnot? It’ll help provide context for future reference. If possible, please add the links to the PR description for better clarity.

@codecov
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...vices/ethService/ethFilterService/FilterService.ts 50.00% 1 Missing ⚠️
@@           Coverage Diff           @@
##             main    #3863   +/-   ##
=======================================
  Coverage        ?   50.66%           
=======================================
  Files           ?       83           
  Lines           ?     4767           
  Branches        ?      972           
=======================================
  Hits            ?     2415           
  Misses          ?     1990           
  Partials        ?      362           
Files with missing lines Coverage Δ
...vices/ethService/ethFilterService/FilterService.ts 17.50% <50.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.

@quiet-node
Copy link
Contributor

Hey @romangzz are there any new updates on this PR?

@romangzz romangzz force-pushed the fix/get-filter-changes branch from 0e572d0 to 3e2ee41 Compare July 21, 2025 13:34
@romangzz
Copy link
Contributor Author

Hey @romangzz, thanks much for the PR great catch indeed! Could you kindly include some links to documentation, if any, supporting this update like from official Ethereum's JSON-RPC spec or whatnot? It’ll help provide context for future reference. If possible, please add the links to the PR description for better clarity.

Hey @quiet-node, sorry for the delay. I've just updated the PR description to include the Ethereum JSON-RPC specification that outlines the expected format of the response.

@acuarica acuarica modified the milestones: 0.70.0, 0.71.0 Jul 21, 2025
@quiet-node
Copy link
Contributor

quiet-node commented Jul 22, 2025

Hey @romangzz, thanks much for the PR great catch indeed! Could you kindly include some links to documentation, if any, supporting this update like from official Ethereum's JSON-RPC spec or whatnot? It’ll help provide context for future reference. If possible, please add the links to the PR description for better clarity.

Hey @quiet-node, sorry for the delay. I've just updated the PR description to include the Ethereum JSON-RPC specification that outlines the expected format of the response.

Hey @romangzz thanks much! The team will review soon! Seems like the tests are failing please resolve them when you have a chance.

@acuarica
Copy link
Contributor

Hi @romangzz, nice catch indeed!

Please fix the failing test (it's failing because it's actually checking for 48-byte hashes)

it('@release should be able to call eth_getFilterChanges for NEW_BLOCK filter', async function () {
const filterId = await relay.call(RelayCalls.ETH_ENDPOINTS.ETH_NEW_BLOCK_FILTER, [], requestId);
await new Promise((r) => setTimeout(r, 4000));
const result = await relay.call(RelayCalls.ETH_ENDPOINTS.ETH_GET_FILTER_CHANGES, [filterId], requestId);
expect(result).to.exist;
expect(result.length).to.gt(0, 'returns the latest block hashes');
result.forEach((hash: string) => {
expect(RelayAssertions.validateHash(hash, 96)).to.eq(true);
});
await new Promise((r) => setTimeout(r, 2000));
const result2 = await relay.call(RelayCalls.ETH_ENDPOINTS.ETH_GET_FILTER_CHANGES, [filterId], requestId);
expect(result2).to.exist;
expect(result2.length).to.be.greaterThanOrEqual(1);
expect(RelayAssertions.validateHash(result2[0], 96)).to.eq(true);
});
});

@acuarica acuarica added bug Something isn't working and removed enhancement New feature or request labels Jul 22, 2025
@romangzz romangzz force-pushed the fix/get-filter-changes branch 2 times, most recently from bbad0f1 to 15c78e8 Compare July 23, 2025 05:30
@quiet-node
Copy link
Contributor

Nice work @romangzz but unit test CI is still failing. Please resolve when you have a chance

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.

There was an issue with the test

@romangzz romangzz force-pushed the fix/get-filter-changes branch from 15c78e8 to 27bb79a Compare July 25, 2025 07:46
@romangzz romangzz requested a review from acuarica July 25, 2025 07:49
@acuarica
Copy link
Contributor

@romangzz we just fix an issue on main that was making CI to fail. Please rebase this branch.

@romangzz romangzz force-pushed the fix/get-filter-changes branch from 27bb79a to d4a81e0 Compare July 28, 2025 05:16
@romangzz
Copy link
Contributor Author

Hey @acuarica, I just rebased the branch.

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 thanks much for the effort!

@acuarica acuarica changed the title Return 32-byte block hash from eth_getFilterChanges to ensure EVM compatibility fix: return 32-byte block hash from eth_getFilterChanges to ensure EVM compatibility Jul 28, 2025
@acuarica acuarica merged commit bc2733e into hiero-ledger:main Jul 28, 2025
39 of 41 checks passed
@acuarica
Copy link
Contributor

Hi @romangzz, merged! thanks for your contribution!

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[track] Return 32-byte block hash from eth_getFilterChanges to ensure EVM compatibility

4 participants