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 EIP: GAS2ETH opcode #8980

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

charles-cooper
Copy link
Contributor

ATTENTION: ERC-RELATED PULL REQUESTS NOW OCCUR IN ETHEREUM/ERCS

--

When opening a pull request to submit a new EIP, please use the suggested template: https://github.com/ethereum/EIPs/blob/master/eip-template.md

We have a GitHub bot that automatically merges some PRs. It will merge yours immediately if certain criteria are met:

  • The PR edits only existing draft PRs.
  • The build passes.
  • Your GitHub username or email address is listed in the 'author' header of all affected PRs, inside .
  • If matching on email address, the email address is the one publicly listed on your GitHub profile.

@eth-bot
Copy link
Collaborator

eth-bot commented Oct 20, 2024

File EIPS/eip-7791.md

Requires 1 more reviewers from @axic, @g11tech, @gcolvin, @lightclient, @SamWilsn

@github-actions github-actions bot added the w-ci Waiting on CI to pass label Oct 20, 2024
EIPS/eip-gas_to_eth.md Outdated Show resolved Hide resolved
EIPS/eip-gas_to_eth.md Outdated Show resolved Hide resolved
EIPS/eip-gas_to_eth.md Outdated Show resolved Hide resolved
charles-cooper and others added 2 commits October 21, 2024 07:58
Co-authored-by: Andrew B Coathup <[email protected]>
Co-authored-by: Andrew B Coathup <[email protected]>
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Oct 21, 2024
Co-authored-by: Andrew B Coathup <[email protected]>
@github-actions github-actions bot added c-new Creates a brand new proposal s-draft This EIP is a Draft t-core labels Oct 21, 2024
@eth-bot eth-bot added e-consensus Waiting on editor consensus e-review Waiting on editor to review labels Oct 21, 2024
@eth-bot eth-bot changed the title GAS2ETH opcode Add EIP: GAS2ETH opcode Oct 21, 2024
@github-actions github-actions bot added the w-ci Waiting on CI to pass label Oct 21, 2024
Copy link

The commit 3a58567 (as a parent of 95e214f) contains errors.
Please inspect the Run Summary for details.

@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Oct 21, 2024
Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Some questions/remarks.


- Pops two values from the stack: `addr` then `gas_amount`. If there are fewer than two values on the stack, the calling context should fail with stack underflow.
- Deducts `gas_amount` from the current calling context.
- Computes `wei_val` by multiplying `gas_amount` by the current transaction context's `gas_price`.
Copy link
Member

Choose a reason for hiding this comment

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

What is the gas price? Is this the base fee? Or is this the tip? Or is it both?

- If the gas cost of this opcode + `gas_amount` is greater than the available gas in the current calling context, the calling context should fail with "out-of-gas" and any state changes reverted.
- Pushes `wei_val` onto the stack.

Note that the transfer of `wei_val` to the given account cannot fail. In particular, the destination account code (if any) is not executed, or, if the account does not exist, the balance is still added to the given address `addr`.
Copy link
Member

Choose a reason for hiding this comment

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

There is extra gas cost in CALL if the call sends value and a new address is created in the trie. I think this should be added here as well.


The proposed cost of this opcode is similar to the recently proposed `PAY` opcode, but changing the base cost from `9000` to `2400`. That is:

- The base cost of this opcode is `2400`. This is priced so that invoking `GAS2ETH` on a cold account costs the same as a cold `SSTORE`.
Copy link
Member

Choose a reason for hiding this comment

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

SSTORE cold on a storage slot which is currently nonzero changing to another nonzero value costs 5000 gas (if its warm: 2900 gas). I'm not sure how to get 2400.

EIPS/eip-7791.md Outdated
The proposed cost of this opcode is similar to the recently proposed `PAY` opcode, but changing the base cost from `9000` to `2400`. That is:

- The base cost of this opcode is `2400`. This is priced so that invoking `GAS2ETH` on a cold account costs the same as a cold `SSTORE`.
- If `addr` is not the zero address, the [EIP-2929](./eip-2929.md) account access costs for `addr` (but NOT the current account) are also incurred: 100 gas for a warm account, 2600 gas for a cold account, and 25000 gas for a new account.
Copy link
Member

Choose a reason for hiding this comment

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

What does the zero address have to do with this? Does this change some behavior of this opcode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that must be a mistake that slipped in over the course of revisions, will fix

@PatrickAlphaC
Copy link

PatrickAlphaC commented Oct 22, 2024

This seems like a great idea, but I'm nervous about people abusing this. Why would I, as a protocol developer, ever us msg.value if I can "trick" users into paying me via gas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-new Creates a brand new proposal e-consensus Waiting on editor consensus e-review Waiting on editor to review s-draft This EIP is a Draft t-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants