Skip to content

support both input and data in eth_call, eth_estimateGas, personal_sendTransaction #597

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

Merged
merged 3 commits into from
Aug 21, 2024

Conversation

JukLee0ira
Copy link

@JukLee0ira JukLee0ira commented Jul 31, 2024

Proposed changes

A user reported a bug in here when using the Go-Ethereum client to call JSON-RPC. The issue arises because the parameter field 'data' has been renamed to 'input' from version 1.13 onwards.

This PR adds support of "input" field in eth_call,eth_estimateGas . Field "data" will be still supported

Test

When this PR is not merged:

eth_call

  • data field

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_call",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "data": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x000000000000000000000000000000000000000000000000000000000000000b"
}
  • input field

Request:

RPC="https://arpc.apothem.network/"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_call",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "error": {
    "code": -32000,
    "message": "execution reverted"
  }
}

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_call",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x000000000000000000000000000000000000000000000000000000000000000b"
}
  • Requests that include both an input field and a data field, and these fields have the same value.

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_call",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622",
      "data": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x000000000000000000000000000000000000000000000000000000000000000b"
}
  • Requests that include both an input field and a data field, but these fields have different values.

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_call",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622",
      "data": "0x12345678"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x000000000000000000000000000000000000000000000000000000000000000b"
}

eth_estimateGas

  • data field

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_estimateGas",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "data": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x574a"
}
  • input field

Request:

RPC="https://arpc.apothem.network/"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_estimateGas",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "error": {
    "code": -32000,
    "message": "execution reverted"
  }
}

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_estimateGas",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x574a"
}
  • Requests that include both an input field and a data field, and these fields have the same value.

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_estimateGas",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622",
      "data": "0x0db02622"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x574a"
}
  • Requests that include both an input field and a data field, but these fields have different values.

Request:

RPC="http://127.0.0.1:8545"
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 8001,
  "method": "eth_estimateGas",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000088",
      "input": "0x0db02622",
      "data": "0x12345678"
    },
    "latest"]}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 8001,
  "result": "0x574a"
}

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
  • N/A

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

@JukLee0ira JukLee0ira force-pushed the api-tx-args-update branch 3 times, most recently from 6c98403 to b340fe9 Compare August 1, 2024 06:02
@gzliudan gzliudan changed the title [WIP] Support "input" field in eth_call, eth_estimateGas [WIP] support field input in eth_call and eth_estimateGas Aug 2, 2024
@gzliudan
Copy link
Collaborator

gzliudan commented Aug 2, 2024

Please use code format for request and json format for response, such as:

```shell
// request code
```
 
```json
// response text
```

@JukLee0ira JukLee0ira force-pushed the api-tx-args-update branch 3 times, most recently from c9c5d18 to fbb6014 Compare August 5, 2024 02:35
@JukLee0ira JukLee0ira changed the title [WIP] support field input in eth_call and eth_estimateGas support field input in eth_call and eth_estimateGas Aug 5, 2024
@JukLee0ira JukLee0ira force-pushed the api-tx-args-update branch 2 times, most recently from 7596f66 to 7c4165a Compare August 6, 2024 07:26
@gzliudan gzliudan self-requested a review August 7, 2024 01:10
Copy link
Collaborator

@gzliudan gzliudan left a comment

Choose a reason for hiding this comment

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

LGTM

@JukLee0ira JukLee0ira force-pushed the api-tx-args-update branch 2 times, most recently from f05af0f to 64ae8a3 Compare August 12, 2024 05:04
@gzliudan gzliudan changed the title support field input in eth_call and eth_estimateGas support both input and data in eth_call, eth_estimateGas, personal_sendTransaction Aug 12, 2024
@gzliudan gzliudan merged commit 925c200 into XinFinOrg:dev-upgrade Aug 21, 2024
17 checks passed
@JukLee0ira JukLee0ira deleted the api-tx-args-update branch March 18, 2025 03:55
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.

4 participants