Skip to content
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

fix: fixed eth_getCode to now use blockNumber when address is an HTS token #3433

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

Conversation

simzzz
Copy link
Contributor

@simzzz simzzz commented Jan 28, 2025

Description:
If we pass an HTS token address to getCode, we do not take into account the block number, resulting in a bug where it would return the smart contract code even if the block number provided is earlier than the one where the token was created.

Related issue(s):

Fixes #3155

Notes for reviewer:

Checklist

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

Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
@simzzz simzzz requested review from a team as code owners January 28, 2025 12:12
@simzzz simzzz requested a review from bubo January 28, 2025 12:12
Copy link

github-actions bot commented Jan 28, 2025

Test Results

 20 files   -   2  292 suites  +21   38m 53s ⏱️ - 26m 50s
615 tests +  6  605 ✅ + 13  4 💤 +1  6 ❌  -  8 
695 runs   - 151  685 ✅  - 139  4 💤 ±0  6 ❌  - 12 

For more details on these failures, see this check.

Results for commit 004b072. ± Comparison against base commit 373f1dc.

This pull request removes 4 and adds 10 tests. Note that renamed tests count towards both.
"after all" hook in "RPC Server Acceptance Tests" ‑ RPC Server Acceptance Tests "after all" hook in "RPC Server Acceptance Tests"
"before all" hook for "should execute "eth_getCode" for hts token" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode "before all" hook for "should execute "eth_getCode" for hts token"
"before all" hook in "@api-batch-2 RPC Server Acceptance Tests" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before all" hook in "@api-batch-2 RPC Server Acceptance Tests"
"before each" hook for "from/to Addresses when transferring HTS tokens to the tokenAddress are in evm and long-zero format" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before each" hook for "from/to Addresses when transferring HTS tokens to the tokenAddress are in evm and long-zero format"
"after each" hook for "@release captures transfer events" ‑ RPC Server Acceptance Tests Acceptance tests @web-socket-batch-3 eth_subscribe "after each" hook for "@release captures transfer events"
"before all" hook for "Subscribes for debug" ‑ RPC Server Acceptance Tests Acceptance tests @web-socket-batch-3 eth_subscribe Subscribes to log events "before all" hook for "Subscribes for debug"
"before each" hook for "@release captures transfer events" ‑ RPC Server Acceptance Tests Acceptance tests @web-socket-batch-3 eth_subscribe "before each" hook for "@release captures transfer events"
@release should execute "eth_getCode" for contract evm_address ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode @release should execute "eth_getCode" for contract evm_address
@release should execute "eth_getCode" for contract with id converted to evm_address ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode @release should execute "eth_getCode" for contract with id converted to evm_address
should execute "eth_getCode" for hts token ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should execute "eth_getCode" for hts token
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
should return 0x0 for account alias on eth_getCode ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should return 0x0 for account alias on eth_getCode
should return 0x0 for account evm_address on eth_getCode ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should return 0x0 for account evm_address on eth_getCode
should return 0x0 for non-existing contract on eth_getCode ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should return 0x0 for non-existing contract on eth_getCode

♻️ This comment has been updated with latest results.

@simzzz simzzz added the bug Something isn't working label Jan 28, 2025
@simzzz simzzz added this to the 0.64.3 milestone Jan 28, 2025
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
@quiet-node quiet-node modified the milestones: 0.64.3, 0.66.0 Jan 29, 2025
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.45%. Comparing base (fe6c0cf) to head (004b072).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/relay/src/lib/eth.ts 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3433      +/-   ##
==========================================
+ Coverage   85.20%   85.45%   +0.25%     
==========================================
  Files          69       69              
  Lines        4711     4724      +13     
  Branches     1048     1052       +4     
==========================================
+ Hits         4014     4037      +23     
+ Misses        397      391       -6     
+ Partials      300      296       -4     
Flag Coverage Δ
config-service 98.14% <ø> (ø)
relay 79.31% <84.61%> (+0.10%) ⬆️
server 83.30% <ø> (ø)
ws-server 36.66% <ø> (ø)

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

Files with missing lines Coverage Δ
.../lib/services/ethService/ethCommonService/index.ts 91.42% <100.00%> (+0.12%) ⬆️
packages/relay/src/lib/eth.ts 86.59% <81.81%> (+0.48%) ⬆️

... and 3 files with indirect coverage changes

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.

eth_getCode does not use blockNumber when address corresponds to an HTS token
2 participants