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

Feature: custom rpc method eth_simulateTransaction #2404

Closed
sambacha opened this issue Jul 20, 2022 · 9 comments
Closed

Feature: custom rpc method eth_simulateTransaction #2404

sambacha opened this issue Jul 20, 2022 · 9 comments
Labels
T-feature Type: feature

Comments

@sambacha
Copy link
Contributor

Component

Anvil

Describe the feature you would like

quoting the spec, ethereum/EIPs#2560

Motivation

When transaction signing is requested and presented to the user, wallet/DApp browser software ("wallets") should attempt to inform the user of what the transaction entails and what the side effects may be.

Currently, most wallets simply show basic transaction parameters such as the recipient address, the value of ETH being transferred, the gas price/limit, and the encoded data. For well-known transaction types such as ERC20 approve() and transfer(), some wallets decode the call data and present additional information.

For most smart contract transactions, however, what the transaction entails is completely opaque to average users, and a malicious transaction may even appear completely harmless (a smart contract transaction will show the value being transferred as zero as if no ETH is moved, but may nevertheless be moving other types of assets such as ERC20 tokens if an allowance was set previously).

This is terrible for the user experience as it encourages users to be accustomed to signing transactions blindly, which may have adverse consequences such as loss of funds.

A new JSONRPC method eth_simulateTransaction aims to improve the situation by providing a way for wallets to perform a dry run and read events emitted (such as the ERC20 Transfer events), thereby enabling the user to make a more informed decision about whether to sign a transaction that is requested.


Rationale

The request parameters are the same as eth_sendTransaction, and the response is a subset of a transaction receipt object you can obtain using eth_getTransactionReceipt, for consistency and familiarity.

Note that it does not require a signed transaction (raw tx), as the motivation is to provide more information to the user before signing happens.

Implementation

There is an existing method eth_estimateGas that already performs transaction dry runs, but the method only returns the amount of gas used by the transaction. The code for eth_estimateGas may be reusable for the implementation of eth_simulateTransaction.

Additional context

part of #2396

@onbjerg
Copy link
Member

onbjerg commented Jul 20, 2022

This should already covered by the tracing RPC calls (when implemented) and so should not really be needed?

@sambacha
Copy link
Contributor Author

This should already covered by the tracing RPC calls (when implemented) and so should not really be needed?

Can you be more specific as to which tracing RPC calls when implemented would cover this?

@onbjerg
Copy link
Member

onbjerg commented Jul 20, 2022

This one #1737

I don't think adding a dedicated RPC method geared towards wallets (as outlined in this issue) makes a lot of sense for a development node

@sambacha
Copy link
Contributor Author

This one #1737

I don't think adding a dedicated RPC method geared towards wallets (as outlined in this issue) makes a lot of sense for a development node

People use Ganache currently as a backing mock instance to test frontend implementations for contracts. It would be helpful also to verify such behavior is reproducible when contracts are deployed and in usage with a GUI as to what is being presented to the user vs what the developer intended to display to the user

@onbjerg
Copy link
Member

onbjerg commented Jul 20, 2022

But using a custom RPC will not aid you in front-end development if you have to replace the custom RPC endpoint with something else entirely, so I'm not sure this is a high value add considering the extra maintenance burden (and as mentioned previously, similar results can be achieved with more standard RPC methods)

@sambacha
Copy link
Contributor Author

But using a custom RPC will not aid you in front-end development if you have to replace the custom RPC endpoint with something else entirely, so I'm not sure this is a high value add considering the extra maintenance burden (and as mentioned previously, similar results can be achieved with more standard RPC methods)

Tenderly offers such RPC method, and its in use for the Sushi frontend as an example

@sambacha
Copy link
Contributor Author

I completely agree @onbjerg bout the maintenance concerns with any additional features, but hey, just laying out all these things for consideration

@onbjerg
Copy link
Member

onbjerg commented Aug 11, 2022

Closing this as out of scope since no production node supports this, and I think it is reasonable to assume that people write their front-ends targetting production RPC methods. We can revisit this if something similar is implemented in a production node

@onbjerg onbjerg closed this as completed Aug 11, 2022
Repository owner moved this from Todo to Done in Foundry Aug 11, 2022
@sambacha
Copy link
Contributor Author

sambacha commented Sep 17, 2022

Closing this as out of scope since no production node supports this, and I think it is reasonable to assume that people write their front-ends targetting production RPC methods. We can revisit this if something similar is implemented in a production node

Did not notice this was closed, this is how it works:

Logic

The request parameters are the same as eth_sendTransaction, and the response is a subset of a transaction receipt object you can obtain using eth_getTransactionReceipt, for consistency and familiarity.

Note that it does not require a signed transaction (raw tx), as the motivation is to provide more information to the user before signing happens.

Implementation

There is an existing method eth_estimateGas that already performs transaction dry runs, but the method only returns the amount of gas used by the transaction. The code for eth_estimateGas may be reusable for the implementation of eth_simulateTransaction.

#2191 would be an additional use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

2 participants