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

eth_getCode does not use blockNumber when address corresponds to an HTS token #3155

Open
acuarica opened this issue Oct 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@acuarica
Copy link
Contributor

acuarica commented Oct 25, 2024

Description

The JSON-RPC method eth_getCode does not take into account the blockNumber when the address corresponds to an HTS token. It always returns the redirect bytecode, specified by HIP-719, regardless of the provided blockNumber.

This means that is the blockNumber provided is less than the block number where the HTS token was created, the returned bytecode is incorrect.

Steps to reproduce

We use USDC on mainnet as an example. It was created at block 22193323. Running the following command we get the right bytecode

curl https://mainnet.hashio.io/api -X POST --data '{
    "method": "eth_getCode", "id": "1", "jsonrpc": "2.0",
    "params": ["0x000000000000000000000000000000000006f89a", "latest"]
}'
{"result":"6080604052348015600f57600080fd5b506000610167905077618dc65e000000000000000000000000000000000006f89a600052366000602037600080366018016008845af43d806000803e8160008114605857816000f35b816000fdfea2646970667358221220d8378feed472ba49a0005514ef7087017f707b45fb9bf56bb81bb93ff19a238b64736f6c634300080b0033","jsonrpc":"2.0","id":"1"}

However, when we specify 22193322 (0x152a4aa) as the blockNumber (the previous block where USDC was created), we still get the same bytecode as before

curl https://mainnet.hashio.io/api -X POST --data '{
    "method": "eth_getCode", "id": "1", "jsonrpc": "2.0",
    "params": ["0x000000000000000000000000000000000006f89a", "0x152a4aa"]
}'

However, the response in this case should have been 0x, empty bytecode.

Additional context

When querying the Mirror Node, it correctly uses the timestamp (determined by the blockNumber).

With block 22193323 (block where USDC Token was created).

We get the timestamp for block 22193323

$ curl https://mainnet.mirrornode.hedera.com/api/v1/blocks/22193323 | jq .timestamp.to
"1632175205.855270000"

and use it to query for the USDC Token at that timestamp

$ curl 'https://mainnet.mirrornode.hedera.com/api/v1/tokens/0.0.456858?timestamp=1632175205.855270000' | jq '.token_id,.name,.symbol'
"0.0.456858"
"USD Coin"
"USDC"

With block 22193322 (just before USDC Token was created).

$ curl https://mainnet.mirrornode.hedera.com/api/v1/blocks/22193322 | jq .timestamp.to
"1632175203.847228000"
$ curl 'https://mainnet.mirrornode.hedera.com/api/v1/tokens/0.0.456858?timestamp=1632175203.847228000'
{"_status":{"messages":[{"message":"Not found"}]}}%

Hedera network

any

Version

v0.58.0

Operating system

macOS

@Nana-EC
Copy link
Collaborator

Nana-EC commented Nov 22, 2024

Definitely a gap we want to address but feels mode "medium" as most users would want latest status of a token.
Should definitely resolve

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
Status: Backlog
Development

No branches or pull requests

2 participants