Skip to content

Instantly share code, notes, and snippets.

@cdetrio
Created July 8, 2017 21:25
Show Gist options
  • Save cdetrio/41172f374ae32047a6c9e97fa9d09ad0 to your computer and use it in GitHub Desktop.
Save cdetrio/41172f374ae32047a6c9e97fa9d09ad0 to your computer and use it in GitHub Desktop.
Instructions for generating EVM traces of state tests in pyethereum

Instructions for generating EVM traces of state tests in pyethereum

Step 1. Install pyethereum modules and pytest

I'd suggest using pipenv.

mkdir pyeth
cd pyeth
pipenv --three

Then install pyethereum modules and pytest.

pipenv install git+https://github.com/ethereum/py_pairing.git@5f609da9222bbd8b0d6ba061b45406808a9fc51b#egg=py_ecc

pipenv install git+https://github.com/ethereum/pyethereum.git@a6875c8ddc4b11c5a3707534a63bdab22e7b2a59#egg=ethereum

pipenv install pycryptodome

pipenv install pytest

Now clone pyethereum and fetch the tests submodule (i.e. pyethereum/fixtures).

git clone https://github.com/ethereum/pyethereum.git
cd pyethereum
git checkout a6875c8ddc4b11c5a3707534a63bdab22e7b2a59
git submodule update --init

Step 2. Fix pyethereum

Open ethereum/specials.py and edit:

from py_ecc.secp256k1 import privtopub, ecdsa_raw_recover, N as secp256k1n -> from py_ecc.secp256k1 import privtopub, ecdsa_raw_recover

Open pyethereum/ethereum/tests/test_state.py and add one line (configure_logging(':trace')):

checker = new_statetest_utils.verify_state_test
place_to_check = 'GeneralStateTests'

->

checker = new_statetest_utils.verify_state_test
place_to_check = 'GeneralStateTests'
configure_logging(':trace')

Step 3. Workaround to run only one test file

Go to the pyethereum/fixtures directory and make a copy of GeneralStateTests.

cd fixtures
cp -a GeneralStateTests GeneralStateTestsCopy

In the GeneralStateTests directory, put only the test case that you want to run.

cd GeneralStateTests
rm -rf st*
cp ../GeneralStateTestsCopy/stTransactionTest/SuicidesAndInternlCallSuicidesSuccess.json ./

Now run the state test in pipenv shell.

pipenv shell
pytest -s ethereum/tests/test_state.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment