You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
This summarizes the requirements for a tool that could be used to conveniently run the state test files and possibly be used by fuzzing infrastructure as mentioned by @holiman#4613 (comment)
It looks like testeth currently is not too far from these requirements.
Summary of requirements
Input
--statetest <path>
--json - boolean flag, output json output for each opcode or not (it's useful to disable json when benchmarking)
--nomemory - disable showing the full memory output for each op
One important aspect is that the execution should not hold on to the data during the entire execution, and spit it out as a json array. Instead, it should output jsonl, one line per op.
However, it will not output any summary (output, gasUsed, stateRoot etc.) either in this case.
We need to fix this (always output json summary in --testfile mode)
Disabling memory output. This works with --jsontrace '{"disableMemory" : true}'
(there're also options to disable stack and storage output)
Output currently looks like this
>test/testeth -t GeneralStateTests -- --testfile /home/andrei/dev/sar00.json --jsontrace {}
Test Case "customTestSuite":
{"depth":"0","gas":"379000","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[],"storage":{"0x00":"0x03"}}
{"depth":"0","gas":"378997","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x00"]}
{"depth":"0","gas":"378994","gasCost":"3","op":"SAR","pc":"4","stack":["0x00","0x00"]}
{"depth":"0","gas":"378991","gasCost":"3","op":"PUSH1","pc":"5","stack":["0x00"]}
{"depth":"0","gas":"378988","gasCost":"0","op":"SSTORE","pc":"7","stack":["0x00","0x00"]}
{"depth":"0","gas":"373988","gasCost":"0","op":"STOP","pc":"8","stack":[],"storage":{}}
{"stateRoot": "a4b37b548bc12ee198ce885d83b511302d9d8f6b2ec5775618b3893c60e0dc75"}
*** No errors detected
This looks close, but
a. There are additional lines on top and at the bottom. They come from boost.test, but we could look into how to suppress them if that's important.
b. We need to add memSize field (add this in StandardTrace::operator())
c. op should have opcode number and opName the mnemonic
d. depth is off-by-one comparing to Martin's examples. This also can be adjusted in StandardTrace::operator()
e. We need to add the summary line {"output":"","gasUsed":"0x3","time":141485}
That should be added here:
The required data (except execution time) is returned from State::execute. Execution time is probably not so important (but it's easy to add, too)
testeth accumulates all the traces of the execution, then in the end outputs all of them (in the same code that I linked above). This can be fixed by modifying StandartTrace class to have an option to output immediately.
@holiman To summarize, there's somewhat quirky CLI to run it, there are some additional non-json lines in the output, the rest will be fixed to match the requirements of evmlab.
This summarizes the requirements for a tool that could be used to conveniently run the state test files and possibly be used by fuzzing infrastructure as mentioned by @holiman #4613 (comment)
It looks like testeth currently is not too far from these requirements.
Summary of requirements
Input
--statetest <path>--json- boolean flag, output json output for each opcode or not (it's useful to disable json when benchmarking)--nomemory- disable showing the full memory output for each opOutput
It should output a
jsonobject for each operation. Example:Required:
pc,op,gas,stack,depthOptional:
opName,gasCost,errorThe
stack,memoryandmemSizeare the values before execution of the op.At the end of execution, some summarical info is good, e.g.
Another thing mentioned by Martin #4613 (comment) :
testeth status
--testfileparameter -- should work after fix testeth -t <TestSuite> -- --singletest <path> <testname> running a test from file #5750 is finished. However-t GeneralStateTestsprobably will still be required, for now it's easier for us to leave it.So the command line to run a test would look like
--jsontracedisables it.However, it will not output any summary (
output,gasUsed,stateRootetc.) either in this case.We need to fix this (always output json summary in
--testfilemode)--jsontrace '{"disableMemory" : true}'(there're also options to disable stack and storage output)
This looks close, but
a. There are additional lines on top and at the bottom. They come from boost.test, but we could look into how to suppress them if that's important.
b. We need to add
memSizefield (add this inStandardTrace::operator())c.
opshould have opcode number andopNamethe mnemonicd.
depthis off-by-one comparing to Martin's examples. This also can be adjusted inStandardTrace::operator()e. We need to add the summary line
{"output":"","gasUsed":"0x3","time":141485}That should be added here:
aleth/test/tools/libtesteth/ImportTest.cpp
Lines 351 to 359 in 9f31c8b
The required data (except execution time) is returned from
State::execute. Execution time is probably not so important (but it's easy to add, too)StandartTraceclass to have an option to output immediately.@holiman To summarize, there's somewhat quirky CLI to run it, there are some additional non-json lines in the output, the rest will be fixed to match the requirements of evmlab.
cc @winsvega
TODO
memSizefieldopNamefield and changeopto have numberdepthstart with 1outputandgasUsed--testfilemode even without--jsontrace