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

Error when sending duplicate "Data" and "Input" Fields #3875

Closed
1 task done
0xJchen opened this issue Jul 22, 2023 · 5 comments · Fixed by #3911
Closed
1 task done

Error when sending duplicate "Data" and "Input" Fields #3875

0xJchen opened this issue Jul 22, 2023 · 5 comments · Fixed by #3911
Assignees
Labels
C-bug An unexpected or incorrect behavior

Comments

@0xJchen
Copy link

0xJchen commented Jul 22, 2023

Describe the bug

When sending an eth rpc call with duplicate "Data" and "Input" Fields, it reports:

{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":"duplicate field `data` at line # column #"},"id":5}%

This is problematic when interacting RETH with web3js for reading a contract, as web3js will send both fields by default (thanks Zootree for pointing this out on the telegram group).

He also points out a temporary solution:

Commenting #[serde(rename = "input")] here

Steps to reproduce

Send an eth rpc call with duplicate "Data" and "Input" Fields

For example, calling the getReserves function of Comet contract:

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0xc3d688B66703497DAA19211EEdff47f25384cdc3", "data": "0x0902f1ac"}, "latest"],"id":1}' http://localhost:8545

Node logs

No response

Platform(s)

Linux (x86)

What version/commit are you on?

reth Version: 0.1.0-alpha.3

What database version are you on?

Current database version: 1

If you've built Reth from source, provide the full command you used

No response

Code of Conduct

  • I agree to follow the Code of Conduct
@0xJchen 0xJchen added C-bug An unexpected or incorrect behavior S-needs-triage This issue needs to be labelled labels Jul 22, 2023
@0xJchen
Copy link
Author

0xJchen commented Jul 23, 2023

Just find that web3js community had an ongoing PR about the duplication issue.

web3/web3.js#6294

@mattsse mattsse self-assigned this Jul 24, 2023
@Muhammad-Altabba
Copy link

Muhammad-Altabba commented Jul 25, 2023

Hello guys,
Because not all RPC providers follow the specs, web3.js provided both input and data. This is for the sake of a unified user code. As it would not be optimal to cause the user to decide whether he should provide or read data or input, based on the provider he is connecting to. And this could be especially problematic for him if he used the same code to communicate with multiple providers, each at a time.

However, web3.js ensures that input and data are identical. And if they are both given to the RPC provider but with different values, it throws the error: You can\'t have "data" and "input" as properties of transactions at the same time, please use either "data" or "input" instead..

So, I suggest that reth tolerate the case, and do not throw, if both input and data are identical. And to throw only if input and data are both provided and they are also not identical. Or what do you think?

Thanks,

@mattsse
Copy link
Collaborator

mattsse commented Jul 25, 2023

sgtm,

will add this after having a look at other reference impls

@0xJchen
Copy link
Author

0xJchen commented Jul 26, 2023

Hello guys, Because not all RPC providers follow the specs, web3.js provided both input and data. This is for the sake of a unified user code. As it would not be optimal to cause the user to decide whether he should provide or read data or input, based on the provider he is connecting to. And this could be especially problematic for him if he used the same code to communicate with multiple providers, each at a time.

However, web3.js ensures that input and data are identical. And if they are both given to the RPC provider but with different values, it throws the error: You can\'t have "data" and "input" as properties of transactions at the same time, please use either "data" or "input" instead..

So, I suggest that reth tolerate the case, and do not throw, if both input and data are identical. And to throw only if input and data are both provided and they are also not identical. Or what do you think?

Thanks,

Thank you ser. I am switching to rust wrapper instead of web3js.

@Muhammad-Altabba
Copy link

Thanks all,
And for those who come to this issue in the future, here is the conclusion:

So, upgrading to the latest reth or upgrading web3.js to v4.1.0 once it is released, would resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug An unexpected or incorrect behavior
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants