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

Test suite: VMTests are only for Homestead, blockNumber-fork mapping should be ignored #64

Closed
mratsim opened this issue Jul 3, 2018 · 2 comments
Labels

Comments

@mratsim
Copy link
Contributor

mratsim commented Jul 3, 2018

Currently we are testing the gas ending balance module 15000 if there was an SSTORE operation involved.

https://github.com/status-im/nimbus/blob/6f28d1186675f648e0587f44e730b9dc23291bab/tests/test_vm_json.nim#L89-L92

This was probably a workaround (in Py-EVM or Nimbus) as Py-EVM does not do it currently: https://github.com/ethereum/py-evm/blob/6708b9eedde39b3b8d4c0db57a7bd2b1770c72d9/tests/json-fixtures/test_virtual_machine.py#L236

Example test that should fail: expXY_success.json

https://github.com/status-im/nimbus/blob/6f28d1186675f648e0587f44e730b9dc23291bab/tests/fixtures/VMTests/vmArithmeticTest/expXY_success.json#L1-L54

"currentNumber" : "0x00": this is the block number

"gas" : "0x9bad" = 39853 should be left over after execution but 84853 are left currently and Nimbus passes the test.

Note that the blockNumber for this test is 0x00 but it seems to imply latest block:

  • Sha3 uses the post-EIP150 computation scheme (costs gas 20 instead of 10)
  • SSTORE is supposed to cost 20000 instead of 5000 in this test (== post EIP-150 cost as well)
vmArithmeticTestexpXY_success.json
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
#vm.computation.BaseComputation: COMPUTATION STARTING: gas: 100000 | from: cd1722f2947def4cf144679da39c4c32bdc35681 | to: 0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 | value: 1000000
000000000000 | depth: 0 | static: n
#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 0
#gas: GAS CONSUMPTION: 100000 - 3 -> 99997 (Push1)
#vm.computation.BaseComputation: Stack:
  0


#vm.computation.BaseComputation: OPCODE: 0x35 (CallDataLoad) | pc: 2
#gas: GAS CONSUMPTION: 99997 - 3 -> 99994 (CallDataLoad)
#vm.computation.BaseComputation: Stack:
  21923370962747092222049241656982978670225693601166209560647359695041422438448


#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 3
#gas: GAS CONSUMPTION: 99994 - 3 -> 99991 (Push1)
#vm.computation.BaseComputation: Stack:
  21923370962747092222049241656982978670225693601166209560647359695041422438448
  0


#vm.computation.BaseComputation: OPCODE: 0x55 (Sstore) | pc: 5
#gas: GAS CONSUMPTION: 99991 - 5000 -> 94991 (SSTORE: [15, 87, 46, 82, 149, 197, 127, 21, 136, 111, 155, 38, 62, 47, 109, 45, 108, 123, 94, 198][slot] -> 2192337096274709222204924
1656982978670225693601166209560647359695041422438448 (0))
#vm.computation.BaseComputation: Stack:



#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 6
#gas: GAS CONSUMPTION: 94991 - 3 -> 94988 (Push1)
#vm.computation.BaseComputation: Stack:
  32


#vm.computation.BaseComputation: OPCODE: 0x35 (CallDataLoad) | pc: 8
#gas: GAS CONSUMPTION: 94988 - 3 -> 94985 (CallDataLoad)
#vm.computation.BaseComputation: Stack:
  21796157974083048550319244236929488537086114760591164995662604048548353814576


#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 9
#gas: GAS CONSUMPTION: 94985 - 3 -> 94982 (Push1)
#vm.computation.BaseComputation: Stack:
  21796157974083048550319244236929488537086114760591164995662604048548353814576
  1


#vm.computation.BaseComputation: OPCODE: 0x55 (Sstore) | pc: 11
#gas: GAS CONSUMPTION: 94982 - 5000 -> 89982 (SSTORE: [15, 87, 46, 82, 149, 197, 127, 21, 136, 111, 155, 38, 62, 47, 109, 45, 108, 123, 94, 198][slot] -> 21796157974083048550319244236929488537086114760591164995662604048548353814576 (0))
#vm.computation.BaseComputation: Stack:



#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 12
#gas: GAS CONSUMPTION: 89982 - 3 -> 89979 (Push1)
#vm.computation.BaseComputation: Stack:
  1


#vm.computation.BaseComputation: OPCODE: 0x54 (Sload) | pc: 14
#gas: GAS CONSUMPTION: 89979 - 50 -> 89929 (Sload)
#vm.computation.BaseComputation: Stack:
  2


#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 15
#gas: GAS CONSUMPTION: 89929 - 3 -> 89926 (Push1)
#vm.computation.BaseComputation: Stack:
  2
  0


#vm.computation.BaseComputation: OPCODE: 0x54 (Sload) | pc: 17
#gas: GAS CONSUMPTION: 89926 - 50 -> 89876 (Sload)
#vm.computation.BaseComputation: Stack:
  2
  2


#vm.computation.BaseComputation: OPCODE: 0x0A (Exp) | pc: 18
#gas: GAS CONSUMPTION: 89876 - 20 -> 89856 (EXP: exponent bytes)
#vm.computation.BaseComputation: Stack:
  4


#vm.computation.BaseComputation: OPCODE: 0x60 (Push1) | pc: 19
#gas: GAS CONSUMPTION: 89856 - 3 -> 89853 (Push1)
#vm.computation.BaseComputation: Stack:
  4
  2


#vm.computation.BaseComputation: OPCODE: 0x55 (Sstore) | pc: 21
#gas: GAS CONSUMPTION: 89853 - 5000 -> 84853 (SSTORE: [15, 87, 46, 82, 149, 197, 127, 21, 136, 111, 155, 38, 62, 47, 109, 45, 108, 123, 94, 198][slot] -> 4 (0))
#vm.computation.BaseComputation: Stack:



#vm.computation.BaseComputation: COMPUTATION SUCCESS: from: cd1722f2947def4cf144679da39c4c32bdc35681 | to: 0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 | value: 1000000000000000000 | depth: 0 | static: n | gas-used: 15147 | gas-remaining: 84853
  [OK] tests/fixtures/VMTests/vmArithmeticTest/expXY_success.json
@mratsim mratsim added the tests label Jul 3, 2018
@mratsim mratsim changed the title Test suite: block number 0x00 seem to imply "latest fork" Test suite: block number 0x00 seems to imply "latest fork" Jul 3, 2018
@mratsim
Copy link
Contributor Author

mratsim commented Jul 3, 2018

Checking the official documentation, for the VMTests, only Homestead fork is supported: https://ethereum-tests.readthedocs.io/en/latest/test_types/vm_tests.html

So we should ignore the block number read and always use Homestead.

@mratsim mratsim changed the title Test suite: block number 0x00 seems to imply "latest fork" Test suite: VMTests are only for Homestead, blockNumber 0x00 should be ignored to decide fork Jul 3, 2018
@mratsim mratsim changed the title Test suite: VMTests are only for Homestead, blockNumber 0x00 should be ignored to decide fork Test suite: VMTests are only for Homestead, blockNumber<->fork mapping should be ignored Jul 3, 2018
@mratsim mratsim changed the title Test suite: VMTests are only for Homestead, blockNumber<->fork mapping should be ignored Test suite: VMTests are only for Homestead, blockNumber-fork mapping should be ignored Jul 3, 2018
jangko added a commit to jangko/nimbus-eth1 that referenced this issue Aug 14, 2019
jangko added a commit to jangko/nimbus-eth1 that referenced this issue Aug 14, 2019
@jangko
Copy link
Contributor

jangko commented Aug 15, 2019

fixed by #373, closing

@jangko jangko closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants