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

Support gas prices pre-EIP 150 #34

Closed
mratsim opened this issue May 18, 2018 · 1 comment
Closed

Support gas prices pre-EIP 150 #34

mratsim opened this issue May 18, 2018 · 1 comment

Comments

@mratsim
Copy link
Contributor

mratsim commented May 18, 2018

Some tests are failing because the environment is pre-EIP 150 which increased a lot of gas prices.

For example SLOAD opcode changed from 50 to 200 and impacts this test:

Decompiling the code yields

import ../src/vm/code_stream, ../src/opcode_values, strformat

var c = newCodeStreamFromUnescaped("0x6000356000556020356001556001546000540a600255")

let opcodes = c.decompile()
for op in opcodes:
  echo &"[{op[0]}]\t{op[1]}\t{op[2]}"

# [1]     PUSH1   0x00
# [2]     CALLDATALOAD
# [4]     PUSH1   0x00
# [5]     SSTORE
# [7]     PUSH1   0x20
# [8]     CALLDATALOAD
# [10]    PUSH1   0x01
# [11]    SSTORE
# [13]    PUSH1   0x01
# [14]    SLOAD
# [16]    PUSH1   0x00
# [17]    SLOAD
# [18]    EXP
# [20]    PUSH1   0x02
# [21]    SSTORE
# [-1]    STOP

Expected gas balance is 39853, current resulting gas balance was 39553

Other almost certainly impacted (gas not matching in logs) includes:

  • expXY
  • blockhash257Block
  • blockhashInRange
  • coinbase
  • blockhashOutOfRange
  • blockhashMyBlock
  • blockhashNotExistingBlock
  • blockhash258Block
  • smod5 (out of gas error)
  • smod7 (out of gas error)
  • signextend_Overflow_dj42
@mratsim
Copy link
Contributor Author

mratsim commented May 22, 2018

Note that the current constants.nim was probably translated from py-evm while py-evm was also undergoing gas refactoring or many constants were introduced temporarily pending further refactoring:

The current py-evm does not have the following:

  • GAS_SLOAD (200 post-EIP150) vs GAS_SLOAD_COST (20 pre-EIP150)
  • GAS_EXT_CODE (20 pre-EIP150) vs GAS_EXT_CODE_COST (700 post-EIP150)
  • GAS_BALANCE (20 pre-EIP150) vs GAS_COST_BALANCE (400 post-EIP150).
  • ...

Py-EVM defaults to Genesis costs and then each VM forks load and amend the relevant constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant