Skip to content

Instantly share code, notes, and snippets.

@veox
Last active April 23, 2021 05:48
Show Gist options
  • Save veox/81dd5500946f5ce07b670220447195b0 to your computer and use it in GitHub Desktop.
Save veox/81dd5500946f5ce07b670220447195b0 to your computer and use it in GitHub Desktop.
% pytest -vvvvv --capture=no -k "test_state_fixtures[/home/veox/src/py-evm/fixtures/GeneralStateTests/stReturnDataTest/modexp_modsize0_returndatasize.json:modexp_modsize0_returndatasize:Byzantium:4]"
========================================================================================= test session starts =========================================================================================
platform linux -- Python 3.7.0, pytest-3.6.4, py-1.6.0, pluggy-0.7.1 -- /home/veox/src/py-evm/.virtualenv/py-evm/bin/python
cachedir: .pytest_cache
rootdir: /home/veox/src/py-evm, inifile: pytest.ini
plugins: xdist-1.18.1, cov-2.5.1, asyncio-0.9.0, asyncio-network-simulator-0.1.0a2, hypothesis-3.69.5
collected 82815 items / 82814 deselected / 1 skipped
tests/json-fixtures/test_state.py::test_state_fixtures[/home/veox/src/py-evm/fixtures/GeneralStateTests/stReturnDataTest/modexp_modsize0_returndatasize.json:modexp_modsize0_returndatasize:Byzantium:4] Set level for logger: eth
Set level for logger: p2p
Set level for logger: trinity
Generating AccountDB trie
TRANSACTION: sender: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b | to: 0x1000000000000000000000000000000000000000 | value: 0 | gas: 1000000000 | gas-price: 1 | s: 13621143048526588506862799462283916133293811860612719748513146487649688695973 | r: 8871728107123313783612332975171019870077055321389879585797480748028168320763 | v: 28 | data-hash: 0x7bc9dbd09195275429a19d51a23fb9b38ab1b61cb525aa516de05c932ab72450
COMPUTATION STARTING: gas: 999978092 | from: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth 0 | static: n
OPCODE: 0x36 (CALLDATASIZE) | pc: 0
GAS CONSUMPTION: 999978092 - 2 -> 999978090 (CALLDATASIZE)
OPCODE: 0x60 (PUSH1) | pc: 1
GAS CONSUMPTION: 999978090 - 3 -> 999978087 (PUSH1)
OPCODE: 0x60 (PUSH1) | pc: 3
GAS CONSUMPTION: 999978087 - 3 -> 999978084 (PUSH1)
OPCODE: 0x37 (CALLDATACOPY) | pc: 5
GAS CONSUMPTION: 999978084 - 3 -> 999978081 (CALLDATACOPY)
MEMORY: size (0 -> 128) | cost (0 -> 12)
GAS CONSUMPTION: 999978081 - 12 -> 999978069 (Expanding memory 0 -> 128)
GAS CONSUMPTION: 999978069 - 12 -> 999978057 (CALLDATACOPY fee)
OPCODE: 0x60 (PUSH1) | pc: 6
GAS CONSUMPTION: 999978057 - 3 -> 999978054 (PUSH1)
OPCODE: 0x61 (PUSH2) | pc: 8
GAS CONSUMPTION: 999978054 - 3 -> 999978051 (PUSH2)
OPCODE: 0x36 (CALLDATASIZE) | pc: 11
GAS CONSUMPTION: 999978051 - 2 -> 999978049 (CALLDATASIZE)
OPCODE: 0x60 (PUSH1) | pc: 12
GAS CONSUMPTION: 999978049 - 3 -> 999978046 (PUSH1)
OPCODE: 0x60 (PUSH1) | pc: 14
GAS CONSUMPTION: 999978046 - 3 -> 999978043 (PUSH1)
OPCODE: 0x60 (PUSH1) | pc: 16
GAS CONSUMPTION: 999978043 - 3 -> 999978040 (PUSH1)
OPCODE: 0x5a (GAS) | pc: 18
GAS CONSUMPTION: 999978040 - 2 -> 999978038 (GAS)
OPCODE: 0xf2 (CALLCODE) | pc: 19
GAS CONSUMPTION: 999978038 - 700 -> 999977338 (CALLCODE)
MEMORY: size (128 -> 128) | cost (12 -> 12)
MEMORY: size (128 -> 1056) | cost (12 -> 101)
GAS CONSUMPTION: 999977338 - 89 -> 999977249 (Expanding memory 128 -> 1056)
GAS CONSUMPTION: 999977249 - 984352605 -> 15624644 (CALLCODE)
COMPUTATION STARTING: gas: 984352605 | from: 0x1000000000000000000000000000000000000000 | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth 1 | static: n
GAS CONSUMPTION: 984352605 - 23970528 -> 960382077 (MODEXP Precompile)
COMPUTATION SUCCESS: from: 0x1000000000000000000000000000000000000000 | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth: 1 | static: n | gas-used: 23970528 | gas-remaining: 960382077
GAS RETURNED: 15624644 + 960382077 -> 976006721
OPCODE: 0x60 (PUSH1) | pc: 20
GAS CONSUMPTION: 976006721 - 3 -> 976006718 (PUSH1)
OPCODE: 0x55 (SSTORE) | pc: 22
GAS CONSUMPTION: 976006718 - 20000 -> 975986718 (SSTORE: 0x1000000000000000000000000000000000000000[1] -> 1 (0))
OPCODE: 0x61 (PUSH2) | pc: 23
GAS CONSUMPTION: 975986718 - 3 -> 975986715 (PUSH2)
OPCODE: 0x51 (MLOAD) | pc: 26
GAS CONSUMPTION: 975986715 - 3 -> 975986712 (MLOAD)
MEMORY: size (1056 -> 1056) | cost (101 -> 101)
OPCODE: 0x60 (PUSH1) | pc: 27
GAS CONSUMPTION: 975986712 - 3 -> 975986709 (PUSH1)
OPCODE: 0x55 (SSTORE) | pc: 29
GAS CONSUMPTION: 975986709 - 5000 -> 975981709 (SSTORE: 0x1000000000000000000000000000000000000000[2] -> 0 (0))
OPCODE: 0x3d (RETURNDATASIZE) | pc: 30
GAS CONSUMPTION: 975981709 - 2 -> 975981707 (RETURNDATASIZE)
OPCODE: 0x60 (PUSH1) | pc: 31
GAS CONSUMPTION: 975981707 - 3 -> 975981704 (PUSH1)
OPCODE: 0x55 (SSTORE) | pc: 33
GAS CONSUMPTION: 975981704 - 5000 -> 975976704 (SSTORE: 0x1000000000000000000000000000000000000000[3] -> 999188 (4294967295))
OPCODE: 0x0 (STOP) | pc: 33
COMPUTATION SUCCESS: from: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth: 0 | static: n | gas-used: 24001388 | gas-remaining: 975976704
TRANSACTION REFUND: 975976704 -> 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
TRANSACTION FEE: 24023296 -> 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
Generating AccountDB trie
FAILED
============================================================================================== FAILURES ===============================================================================================
________________ test_state_fixtures[/home/veox/src/py-evm/fixtures/GeneralStateTests/stReturnDataTest/modexp_modsize0_returndatasize.json:modexp_modsize0_returndatasize:Byzantium:4] ________________
fixture = {'env': {'currentCoinbase': b'*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba', 'currentDifficulty': 13107...x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f?\x14\x01\x01\x01', 'gasLimit': 1000000000, 'gasPrice': 1, 'nonce': 0, ...}}
fixture_vm_class = <class 'abc.ByzantiumVMForTesting'>
def test_state_fixtures(fixture, fixture_vm_class):
header = BlockHeader(
coinbase=fixture['env']['currentCoinbase'],
difficulty=fixture['env']['currentDifficulty'],
block_number=fixture['env']['currentNumber'],
gas_limit=fixture['env']['currentGasLimit'],
timestamp=fixture['env']['currentTimestamp'],
parent_hash=fixture['env']['previousHash'],
)
chaindb = ChainDB(get_db_backend())
vm = fixture_vm_class(header=header, chaindb=chaindb)
state = vm.state
apply_state_dict(state.account_db, fixture['pre'])
state.account_db.persist()
# Update state_root manually
vm.block = vm.block.copy(header=vm.block.header.copy(state_root=state.state_root))
if 'secretKey' in fixture['transaction']:
unsigned_transaction = vm.create_unsigned_transaction(
nonce=fixture['transaction']['nonce'],
gas_price=fixture['transaction']['gasPrice'],
gas=fixture['transaction']['gasLimit'],
to=fixture['transaction']['to'],
value=fixture['transaction']['value'],
data=fixture['transaction']['data'],
)
private_key = keys.PrivateKey(fixture['transaction']['secretKey'])
transaction = unsigned_transaction.as_signed_transaction(private_key=private_key)
elif 'vrs' in fixture['transaction']:
v, r, s = (
fixture['transaction']['v'],
fixture['transaction']['r'],
fixture['transaction']['s'],
)
transaction = vm.create_transaction(
nonce=fixture['transaction']['nonce'],
gas_price=fixture['transaction']['gasPrice'],
gas=fixture['transaction']['gasLimit'],
to=fixture['transaction']['to'],
value=fixture['transaction']['value'],
data=fixture['transaction']['data'],
v=v,
r=r,
s=s,
)
try:
header, receipt, computation = vm.apply_transaction(vm.block.header, transaction)
transactions = vm.block.transactions + (transaction, )
receipts = vm.block.get_receipts(chaindb) + (receipt, )
block = vm.set_block_transactions(vm.block, header, transactions, receipts)
except ValidationError as err:
block = vm.block
transaction_error = err
logger.warn("Got transaction error", exc_info=True)
else:
transaction_error = False
if not transaction_error:
log_entries = computation.get_log_entries()
actual_logs_hash = hash_log_entries(log_entries)
if 'logs' in fixture['post']:
expected_logs_hash = fixture['post']['logs']
assert expected_logs_hash == actual_logs_hash
elif log_entries:
raise AssertionError("Got log {0} entries. hash:{1}".format(
len(log_entries),
actual_logs_hash,
))
if 'out' in fixture:
expected_output = fixture['out']
if isinstance(expected_output, int):
assert len(computation.output) == expected_output
else:
assert computation.output == expected_output
> assert block.header.state_root == fixture['post']['hash']
E AssertionError: assert b'\x08\x0e\x9...ef?\x1eK\x87}' == b'\x9a\xfeG\x8...2\xe4\xce\xa3'
E At index 0 diff: 8 != 154
E Full diff:
E - (b'\x08\x0e\x9d\xfd\xef\x1a\xb1()V\xc2/\xf6\x9b\x98\xe3\xc8\xd1\x93\xcfx\xf1mX'
E - b'e4\xef?\x1eK\x87}')
E + (b'\x9a\xfeG\x85\xe7\x1e\xf1\xd3&8\xc3\xcc|c.%W\x00]b\xfes\\\xaeZ\xaa\xd6\xf3'
E + b'\x02\xe4\xce\xa3')
actual_logs_hash = b'\x1d\xccM\xe8\xde\xc7]z\xab\x85\xb5g\xb6\xcc\xd4\x1a\xd3\x12E\x1b\x94\x8at\x13\xf0\xa1B\xfd@\xd4\x93G'
block = <ByzantiumBlock(#Block #1)>
chaindb = <eth.db.chain.ChainDB object at 0x7f4d345a4cc0>
computation = <eth.vm.forks.byzantium.computation.ByzantiumComputation object at 0x7f4d14aaf6d8>
expected_logs_hash = b'\x1d\xccM\xe8\xde\xc7]z\xab\x85\xb5g\xb6\xcc\xd4\x1a\xd3\x12E\x1b\x94\x8at\x13\xf0\xa1B\xfd@\xd4\x93G'
fixture = {'env': {'currentCoinbase': b'*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba', 'currentDifficulty': 13107...x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f?\x14\x01\x01\x01', 'gasLimit': 1000000000, 'gasPrice': 1, 'nonce': 0, ...}}
fixture_vm_class = <class 'abc.ByzantiumVMForTesting'>
header = <BlockHeader #1 4e25f5d9>
log_entries = ()
memcontents = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
offset = 1056
private_key = '0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8'
receipt = <eth.rlp.receipts.Receipt object at 0x7f4d14aaf588>
receipts = (<eth.rlp.receipts.Receipt object at 0x7f4d14aaf588>,)
state = <abc.ByzantiumStateForTesting object at 0x7f4d14aa43b8>
step = 32
transaction = <eth.vm.forks.byzantium.transactions.ByzantiumTransaction object at 0x7f4d14aaf400>
transaction_error = False
transactions = (<eth.vm.forks.byzantium.transactions.ByzantiumTransaction object at 0x7f4d14aaf400>,)
unsigned_transaction = <eth.vm.forks.byzantium.transactions.ByzantiumUnsignedTransaction object at 0x7f4d345a4dd8>
vm = <abc.ByzantiumVMForTesting object at 0x7f4d345a4d68>
tests/json-fixtures/test_state.py:350: AssertionError
----------------------------------------------------------------------------------------- Captured log setup ------------------------------------------------------------------------------------------
conftest.py 46 INFO Set level for logger: eth
conftest.py 46 INFO Set level for logger: p2p
conftest.py 46 INFO Set level for logger: trinity
------------------------------------------------------------------------------------------ Captured log call ------------------------------------------------------------------------------------------
logging.py 10 TRACE Generating AccountDB trie
logging.py 10 TRACE TRANSACTION: sender: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b | to: 0x1000000000000000000000000000000000000000 | value: 0 | gas: 1000000000 | gas-price: 1 | s: 13621143048526588506862799462283916133293811860612719748513146487649688695973 | r: 8871728107123313783612332975171019870077055321389879585797480748028168320763 | v: 28 | data-hash: 0x7bc9dbd09195275429a19d51a23fb9b38ab1b61cb525aa516de05c932ab72450
logging.py 10 TRACE COMPUTATION STARTING: gas: 999978092 | from: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth 0 | static: n
logging.py 10 TRACE OPCODE: 0x36 (CALLDATASIZE) | pc: 0
logging.py 10 TRACE GAS CONSUMPTION: 999978092 - 2 -> 999978090 (CALLDATASIZE)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 1
logging.py 10 TRACE GAS CONSUMPTION: 999978090 - 3 -> 999978087 (PUSH1)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 3
logging.py 10 TRACE GAS CONSUMPTION: 999978087 - 3 -> 999978084 (PUSH1)
logging.py 10 TRACE OPCODE: 0x37 (CALLDATACOPY) | pc: 5
logging.py 10 TRACE GAS CONSUMPTION: 999978084 - 3 -> 999978081 (CALLDATACOPY)
logging.py 10 TRACE MEMORY: size (0 -> 128) | cost (0 -> 12)
logging.py 10 TRACE GAS CONSUMPTION: 999978081 - 12 -> 999978069 (Expanding memory 0 -> 128)
logging.py 10 TRACE GAS CONSUMPTION: 999978069 - 12 -> 999978057 (CALLDATACOPY fee)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 6
logging.py 10 TRACE GAS CONSUMPTION: 999978057 - 3 -> 999978054 (PUSH1)
logging.py 10 TRACE OPCODE: 0x61 (PUSH2) | pc: 8
logging.py 10 TRACE GAS CONSUMPTION: 999978054 - 3 -> 999978051 (PUSH2)
logging.py 10 TRACE OPCODE: 0x36 (CALLDATASIZE) | pc: 11
logging.py 10 TRACE GAS CONSUMPTION: 999978051 - 2 -> 999978049 (CALLDATASIZE)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 12
logging.py 10 TRACE GAS CONSUMPTION: 999978049 - 3 -> 999978046 (PUSH1)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 14
logging.py 10 TRACE GAS CONSUMPTION: 999978046 - 3 -> 999978043 (PUSH1)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 16
logging.py 10 TRACE GAS CONSUMPTION: 999978043 - 3 -> 999978040 (PUSH1)
logging.py 10 TRACE OPCODE: 0x5a (GAS) | pc: 18
logging.py 10 TRACE GAS CONSUMPTION: 999978040 - 2 -> 999978038 (GAS)
logging.py 10 TRACE OPCODE: 0xf2 (CALLCODE) | pc: 19
logging.py 10 TRACE GAS CONSUMPTION: 999978038 - 700 -> 999977338 (CALLCODE)
logging.py 10 TRACE MEMORY: size (128 -> 128) | cost (12 -> 12)
logging.py 10 TRACE MEMORY: size (128 -> 1056) | cost (12 -> 101)
logging.py 10 TRACE GAS CONSUMPTION: 999977338 - 89 -> 999977249 (Expanding memory 128 -> 1056)
logging.py 10 TRACE GAS CONSUMPTION: 999977249 - 984352605 -> 15624644 (CALLCODE)
logging.py 10 TRACE COMPUTATION STARTING: gas: 984352605 | from: 0x1000000000000000000000000000000000000000 | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth 1 | static: n
logging.py 10 TRACE GAS CONSUMPTION: 984352605 - 23970528 -> 960382077 (MODEXP Precompile)
logging.py 10 TRACE COMPUTATION SUCCESS: from: 0x1000000000000000000000000000000000000000 | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth: 1 | static: n | gas-used: 23970528 | gas-remaining: 960382077
logging.py 10 TRACE GAS RETURNED: 15624644 + 960382077 -> 976006721
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 20
logging.py 10 TRACE GAS CONSUMPTION: 976006721 - 3 -> 976006718 (PUSH1)
logging.py 10 TRACE OPCODE: 0x55 (SSTORE) | pc: 22
logging.py 10 TRACE GAS CONSUMPTION: 976006718 - 20000 -> 975986718 (SSTORE: 0x1000000000000000000000000000000000000000[1] -> 1 (0))
logging.py 10 TRACE OPCODE: 0x61 (PUSH2) | pc: 23
logging.py 10 TRACE GAS CONSUMPTION: 975986718 - 3 -> 975986715 (PUSH2)
logging.py 10 TRACE OPCODE: 0x51 (MLOAD) | pc: 26
logging.py 10 TRACE GAS CONSUMPTION: 975986715 - 3 -> 975986712 (MLOAD)
logging.py 10 TRACE MEMORY: size (1056 -> 1056) | cost (101 -> 101)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 27
logging.py 10 TRACE GAS CONSUMPTION: 975986712 - 3 -> 975986709 (PUSH1)
logging.py 10 TRACE OPCODE: 0x55 (SSTORE) | pc: 29
logging.py 10 TRACE GAS CONSUMPTION: 975986709 - 5000 -> 975981709 (SSTORE: 0x1000000000000000000000000000000000000000[2] -> 0 (0))
logging.py 10 TRACE OPCODE: 0x3d (RETURNDATASIZE) | pc: 30
logging.py 10 TRACE GAS CONSUMPTION: 975981709 - 2 -> 975981707 (RETURNDATASIZE)
logging.py 10 TRACE OPCODE: 0x60 (PUSH1) | pc: 31
logging.py 10 TRACE GAS CONSUMPTION: 975981707 - 3 -> 975981704 (PUSH1)
logging.py 10 TRACE OPCODE: 0x55 (SSTORE) | pc: 33
logging.py 10 TRACE GAS CONSUMPTION: 975981704 - 5000 -> 975976704 (SSTORE: 0x1000000000000000000000000000000000000000[3] -> 999188 (4294967295))
logging.py 10 TRACE OPCODE: 0x0 (STOP) | pc: 33
logging.py 10 TRACE COMPUTATION SUCCESS: from: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b | to: 0x1000000000000000000000000000000000000000 | value: 0 | depth: 0 | static: n | gas-used: 24001388 | gas-remaining: 975976704
logging.py 10 TRACE TRANSACTION REFUND: 975976704 -> 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
logging.py 10 TRACE TRANSACTION FEE: 24023296 -> 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
logging.py 10 TRACE Generating AccountDB trie
======================================================================= 1 failed, 1 skipped, 82814 deselected in 14.95 seconds ========================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment