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

Set GasPrice to 0 for gas estimation tx #176

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Mar 22, 2024

Closes: #161

Description

The EOA test account used for signing the transaction that encapsulates the user's TransactionArgs, does not have any funds. This means that if GasPrice is greater than 0, we return:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32000,
    "message": "insufficient funds for gas * price + value"
  }
}

By setting this argument to 0, we now return the intrinsic gas, which is 0xcf08 (or 53000 in decimal). The gas is mainly affected by the length of the data / input field value.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@m-Peter m-Peter added this to the Flow-EVM-M2 milestone Mar 22, 2024
@m-Peter m-Peter self-assigned this Mar 22, 2024

tx := types.NewTx(
&types.LegacyTx{
Nonce: 0,
To: args.To,
Value: value,
Value: big.NewInt(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe like discussed this can be problematic in cases where the execution depends on a specific value provided, hence the estimation would be incorrect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed 👍 Most likely I will open an issue in flow-go, since there's no way to achieve this functionality without exposing a relevant method on the EVM contract.

@m-Peter m-Peter force-pushed the gas-estimate-zero-gas-price branch from 2772820 to 9238963 Compare March 27, 2024 16:28
@m-Peter m-Peter changed the title Set GasPrice and Value to 0 for gas estimation tx Set GasPrice to 0 for gas estimation tx Mar 27, 2024
@m-Peter m-Peter merged commit 80db9e7 into onflow:main Mar 27, 2024
1 check passed
@m-Peter m-Peter deleted the gas-estimate-zero-gas-price branch March 27, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Set a gas price of 0 for the self-rolled transaction used on gas estimation
2 participants