-
Notifications
You must be signed in to change notification settings - Fork 353
Creating a GeneralStateTest (Yoichi's attempt, rough record)
I was going to test "RETURNDATACOPY" in the beginning should copy zero's into the memory.
I checked out https://github.com/ethereum/cpp-ethereum/pull/4062 at ~/src/cpp-ethereum, and
mkdir -p ~/src/cpp-ethereum/build
cd ~/src/cpp-ethereum/build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DVMTRACE=1 ..
make
This PR was still work in progress, but I thought it would perform correctly for this particular test case.
I also checked out https://github.com/ethereum/tests in ~/src/tests (develop branch).
I looked at ~/src/tests/src/GeneralStateTestsFilter.
stAttackTest/ stChangedEIP150/ stEIP158Specific/ stMemoryStressTest/ stRecursiveCreate/ stSystemOperationsTest/
stBoundsTest/ stCodeSizeLimit/ stExample/ stMemoryTest/ stRefundTest/ stTransactionTest/
stCallCodes/ stCreateTest/ stHomesteadSpecific/ stNonZeroCallsTest/ stRevertTest/ stTransitionTest/
stCallCreateCallCodeTest/ stDelegatecallTestHomestead/ stInitCodeTest/ stPreCompiledContracts/ stSolidityTest/ stWalletTest/
stCallDelegateCodesCallCodeHomestead/ stEIP150singleCodeGasPrices/ stLogTests/ stQuadraticComplexityTest/ stSpecialTest/ stZeroCallsRevert/
stCallDelegateCodesHomestead/ stEIP150Specific/ stMemExpandingEIP150Calls/ stRandom/ stStackTests/ stZeroCallsTest/
Maybe I need a new directory stReturnDataTest.
I created a file ~/src/tests/src/GeneralTestsFilter/stReturnDataTest/returndatacopy_initial.json.
I thought I should fill the memory with some random data first, and then perform "RETURNDATACOPY". Also, the result of the RETURNDATACOPY should be visible somewhere in the state, so I have to MLOAD and SSTORE the result of the RETURNDATACOPY.
The program looks like this
; hex description
;; store some non-zero word into memory [0..31]
30 ADDRESS
6000 PUSH1 [0]
52 MSTORE
;; RETURNDATACOPY should copy the first word into memory [0..31]
6020 PUSH1 [32]
6000 PUSH1 [0]
6000 PUSH1 [0]
0e RETURNDATACOPY
;; load memory[0..31] onto stack
6000 PUSH1 [0]
51 MLOAD
;; store the topmost stack into storage [0]
6000 PUSH1 [0]
55 SSTORE
;; an implicit `STOP` follows.
So, the callee should contain the code
0x306000526020600060000e600051600055
I expect the storage index 0 to be changed into zero. So, in the pre-state, the storage index 0 should contain something non-zero.
file a PR to cpp-ethereum?
file a PR to test? or this is not necessary?