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

EIP150 - Part II #129

Closed

Conversation

sdtsui
Copy link
Contributor

@sdtsui sdtsui commented Jun 25, 2017

(Edit: updated to included a quick walkthrough from @cdetrio in the last comment.)

Small PR. Note that the PR is being made to ethereumjs/eip150, on top of @axic 's work. Merging this will complete that branch, for a final merge into master.

  • increases gas base cost values for EIP150.
  • 06/25/2017 - completes everything left undone in eip150, including "do not return an OOG error" requirement, by calling calcCallLimit in CREATE opFn.
  • also fixes up some comments in runTx.js.

/cc @axic in case I did anything incorrectly.

  • I wasn't sure if this was the right way to change gas baseCost values (maybe we need a flag for homestead gas costs?).

Thanks in advance for any feedback / tips!


Remaining Tasks:

(old list, using outdated EIP)

  [ ]If block.number >= METROPOLIS_FORK_BLKNUM, then:
    [ x ] Increase the gas cost of EXTCODESIZE to 4000
    [ x ] Increase the base gas cost of EXTCODECOPY to 4000
    [ x ] Increase the gas cost of BALANCE to 400
    [ x ] Increase the gas cost of SLOAD to 200
    [ x ] Increase the gas cost of CALL, CALLDELEGATE, CALLCODE to 4000
    [ x ] Increase the gas cost of SUICIDE to 5000
    [ x ] If SUICIDE hits a newly created account, it triggers an additional gas cost of 25000 (similar to CALLs)
      - Done in 95: uses `ethereum-commmon` as `fees` obj
    [ x ] Define "all but one 64th" of N as N - floor(N / 64) (N / 64)
      - Done in pull/95
    [ x ] If a call asks for more gas than the maximum allowed amount, do not return an OOG error; instead, if a call asks for more gas than all but one 64th of the maximum allowed amount, call with all but one 64th of the maximum allowed amount of gas (this is equivalent to a version of #90 plus #114). CREATE only provides all but one 64th of the parent gas to the child call.
      - This seems to be WIP in pull/95, and will be worked on next by @alexc.
      - Note to self: pyethereum/415: see where callGas is used in the rest of the project and it should be clear where to find the check for maximum allowed amount.    

new list, using up-to-date EIP:

Complete

If block.number >= FORK_BLKNUM, then:

  • Increase the gas cost of EXTCODESIZE to 700
  • Increase the base gas cost of EXTCODECOPY to 700
  • Increase the gas cost of BALANCE to 400
  • Increase the gas cost of SLOAD to 200
  • Increase the gas cost of CALL, DELEGATECALL, CALLCODE to 700
  • Increase the gas cost of SELFDESTRUCT to 5000
  • If SELFDESTRUCT hits a newly created account, it triggers an additional gas cost of 25000 (similar to CALLs)
  • Increase the recommended gas limit target to 5.5 million
  • Define "all but one 64th" of N as N - floor(N / 64)

Remaining:

  • If a call asks for more gas than the maximum allowed amount (ie. total amount of gas remaining in the parent after subtracting the gas cost of the call and memory expansion), do not return an OOG error; instead, if a call asks for more gas than all but one 64th of the maximum allowed amount, call with all but one 64th of the maximum allowed amount of gas (this is equivalent to a version of Update async to version 2.1.2 🚀 #90 plus Error: Number can only safely store up to 53 bits #114). CREATE only provides all but one 64th of the parent gas to the child call.

@sdtsui sdtsui changed the title Wip/eip150 increase gas base cost [WIP] EIP150 - Increase gas baseCost Jun 25, 2017
@sdtsui
Copy link
Contributor Author

sdtsui commented Jun 25, 2017

Chatted with @cdetrio - we need to use the finalized spec doc, not the eip issue.
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md
Fewer requirements, gas prices change as well (700 instead of 4000).

@sdtsui
Copy link
Contributor Author

sdtsui commented Jun 25, 2017

@cdetrio - 716b6a9 should take care of the last requirement.

 [ ] If a call asks for more gas than the maximum allowed amount, do not return an OOG error; instead, if a call asks for more gas than all but one 64th of the maximum allowed amount, call with all but one 64th of the maximum allowed amount of gas (this is equivalent to a version of #90 plus #114). CREATE only provides all but one 64th of the parent gas to the child call.
      - This seems to be WIP in pull/95, and will be worked on next by @alexc.
      - Note to self: pyethereum/415: see where callGas is used in the rest of the project and it should be clear where to find the check for maximum allowed amount.

I think this is ready to be merged into EIP150, and then to master after a final review.

@sdtsui sdtsui changed the title [WIP] EIP150 - Increase gas baseCost [WIP] EIP150 - Part II - Increase gas baseCost Jun 25, 2017
@sdtsui sdtsui changed the title [WIP] EIP150 - Part II - Increase gas baseCost EIP150 - Part II Jun 25, 2017
@sdtsui
Copy link
Contributor Author

sdtsui commented Jun 30, 2017

When changing fork config to EIP150, running master's stateTests fails 951 tests.

1..2412
# tests 2412
# pass  1461
# fail  951

After these changes: we're at

1..2412
# tests 2412
# pass  2006
# fail  406

npm run stateTest to repro. Would appreciate work on top to get EIP150 completed.

FAQ/Walkthrough

This file will be used to answer any common questions from the Gitter or elsewhere. We'll add to separate documentation/the README later, but using hackmd for easy collab/editing for now.

@sdtsui sdtsui changed the base branch from eip150 to master July 1, 2017 00:29
Copy link
Contributor Author

@sdtsui sdtsui left a comment

Choose a reason for hiding this comment

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

Left some comments for checkOutOfGas.
@cdetrio - left you a message on Gitter about this.

lib/opFns.js Outdated

function checkOutOfGas (runState, callOptions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving checkOutOfGas logic into a new function helps reduce the number of responsibilities forcheckCallMemCost. This will help with maintainability, and implementation of EIP150 (so that the gas required for a call can be calculated separate from memCost and OOG Error logic).

Copy link
Contributor Author

@sdtsui sdtsui left a comment

Choose a reason for hiding this comment

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

@cdetrio

Update on EIP150 progress. I've cleaned it up: only 359 tests are failing (down from 900+ before #129).

1..2412
# tests 2412
# pass  2053
# fail  359

I think this will be a more complicated refactor that originally expected because checkCallGas (and others) are used by many op code functions (not just the ones that need a limit applied). This means means we can't simply change the functions. We must refactor the logic that does not apply to CALL and CREATE.

Do you have a moment to chat later this week? I'd love your guidance on what to do next. I have some ideas about how we can move forward quickly, especially now that we have more contributors.

For example, I think these following EIP150 requirements can be split into separate issues that different contributors can grab.

- If SELFDESTRUCT hits a newly created account, it triggers an additional gas cost of 25000 (similar to CALLs)
- If a call asks for more gas than the maximum allowed amount (ie. total amount of gas remaining in the parent after subtracting the gas cost of the call and memory expansion), do not return an OOG error; instead, if a call asks for more gas than all but one 64th of the maximum allowed amount, call with all but one 64th of the maximum allowed amount of gas (this is equivalent to a version of #90 plus #114). CREATE only provides all but one 64th of the parent gas to the child call.

I can help with this by creating issues and EIP-150 specific instructions. I can also lead on putting the PRs back together into a cohesive feature that passes CI. Let me know what you think..

Thanks!

@sdtsui
Copy link
Contributor Author

sdtsui commented Jul 5, 2017

1..2412
# tests 2412
# pass  2202
# fail  210

@sdtsui
Copy link
Contributor Author

sdtsui commented Jul 5, 2017

quick note for @inclu-media :

Test output before I pushed:

179 failing
2233 passing (1m 57.3s)

Latest test failure:
createJS_NoCollision

Thanks for the help!

@inclu-media
Copy link
Contributor

Moved refund handling in the SUICIDE op to after subGas for non existing toAccount otherwise a refund could be given followed by an OOG resulting in wrong gas.

1..2412
# tests 2412
# pass  2410
# fail  2 

@inclu-media
Copy link
Contributor

1..2412
# tests 2412
# pass  2412

# ok

we are though!

tests/hooked.js Outdated
@@ -32,7 +32,8 @@ tape('hooked-vm', function (test) {
}

var vm = createHookedVm({
enableHomestead: true
enableHomestead: true,
enableHomsteadReprice: true,
Copy link

Choose a reason for hiding this comment

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

typo: Homstead

@cdetrio cdetrio mentioned this pull request Jul 10, 2017
@sdtsui
Copy link
Contributor Author

sdtsui commented Jul 11, 2017

Rebased by @cdetrio. Please see #143 for the final PR.

@sdtsui sdtsui closed this Jul 11, 2017
holgerd77 added a commit that referenced this pull request Dec 1, 2020
holgerd77 added a commit that referenced this pull request Mar 11, 2021
holgerd77 added a commit that referenced this pull request May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants