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

add method eth_getAccountInfo #479

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Mar 6, 2024

Proposed changes

Add method eth_getAccountInfo which returns below properties for an account:

  • address
  • balance
  • code hash
    • for contract: Keccak256(code)
    • for exist EOA: Keccak256(nil) = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
    • for inexistent account: 0x0000000000000000000000000000000000000000000000000000000000000000
  • code size
  • nonce
  • storage hash

Test

1. system contract

request

 curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_getAccountInfo",
  "params": [
    "0x0000000000000000000000000000000000000088",
    "latest"
  ]
}' | jq

response

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": {
    "address": "0x0000000000000000000000000000000000000088",
    "balance": "0x1fc3842bd1f071c00000",
    "codeHash": "0x43e5b04f4015a9345835af4980fea519f1a1f499cbfddd624696cca4dcd43657",
    "codeSize": 14452,
    "nonce": 0,
    "storageHash": "0x69fc7cb82b5837876debf26719e7057afa53678154477a9a8376f371caef86b8"
  }
}

2. exist EOA

0xD4CE02705041F04135f1949Bc835c1Fe0885513c is my test account which is exist on chain when I test.

request

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8002,
  "method": "eth_getAccountInfo",
  "params": [
    "0xD4CE02705041F04135f1949Bc835c1Fe0885513c",
    "latest"
  ]
}' | jq

response

{
  "jsonrpc": "2.0",
  "id": 8002,
  "result": {
    "address": "0xd4ce02705041f04135f1949bc835c1fe0885513c",
    "balance": "0x200000000000000000000000000000000000000000000000000000000000000",
    "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
    "codeSize": 0,
    "nonce": 0,
    "storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
  }
}

3. inexistent account

*request

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8003,
  "method": "eth_getAccountInfo",
  "params": [
    "0xf756fdbb39E5491AFE9FDab2B69E48e408e84888",
    "latest"
  ]
}' | jq

response

{
  "jsonrpc": "2.0",
  "id": 8003,
  "result": {
    "address": "0xf756fdbb39e5491afe9fdab2b69e48e408e84888",
    "balance": "0x0",
    "codeHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "codeSize": 0,
    "nonce": 0,
    "storageHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
  }
}

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

@gzliudan gzliudan merged commit 476bda6 into XinFinOrg:dev-upgrade Mar 6, 2024
@gzliudan gzliudan deleted the get-account-info branch March 7, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants