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

Reproducer halts partway through fetching data with web3.exceptions.InvalidAddress #127

Open
0x1d00ffff opened this issue Mar 23, 2020 · 2 comments

Comments

@0x1d00ffff
Copy link

Running the following trace:
python3.8 -m evmlab reproducer --web3 "http://127.0.0.1:8545" --hash 0xbaf6856f4657a348dd5fe1c757ffcb666eea7d4288df1d231e62047506553163

Fails with a web3.exceptions.InvalidAddress error. I assume the applications called by evmlab are meant to sanitize i/o between eachother. I am in the process of modifying reproduce.py to modify addresses into checksum addresses to see if that fixes the error.

Details of exception:

Flask not installed, disabling web mode
Setting Metro config for block 9730296
GetAccountInfo(0x722C7207cA852a62745B2e029d6F513304B6cd1b, 9730295)
GetAccountInfo(0x0451611635dB4A436F04a7929ea8D07e2FB51789, 9730295)
Executing tx...
docker run --rm -v /tmp:/tmp holiman/gethvm --prestate /tmp/0xbaf685-genesis-geth_QJ74iVig.json --gas 1700463 --sender 0x0451611635dB4A436F04a7929ea8D07e2FB51789 --receiver 0x722C7207cA852a62745B2e029d6F513304B6cd1b --input 206ec7a1000000
0000000000000000002bf91c18cd4ae9c2f2858ef9fe518180f7b5096df6299e1e2bc330c9cd2fa4b5940c0b60949590b199641adb985f8078d2b792ce00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000
0000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d00ffffb205cc0c5a51e7c77a7668a8b90bbb9000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000
000000000000000000011db3ddbed5 --nomemory --json run
Saved trace to /tmp/0xbaf685_quxvvi6n.txt
SLOTS to fetch: {('0x722C7207cA852a62745B2e029d6F513304B6cd1b', '0x0')}
GetStorageSlot(0x722C7207cA852a62745B2e029d6F513304B6cd1b, 0, 9730295)
Executing tx...
docker run --rm -v /tmp:/tmp holiman/gethvm --prestate /tmp/0xbaf685-genesis-geth_4Z1K8Mou.json --gas 1700463 --sender 0x0451611635dB4A436F04a7929ea8D07e2FB51789 --receiver 0x722C7207cA852a62745B2e029d6F513304B6cd1b --input 206ec7a1000000
0000000000000000002bf91c18cd4ae9c2f2858ef9fe518180f7b5096df6299e1e2bc330c9cd2fa4b5940c0b60949590b199641adb985f8078d2b792ce00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000
0000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d00ffffb205cc0c5a51e7c77a7668a8b90bbb9000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000
000000000000000000011db3ddbed5 --nomemory --json run
Saved trace to /tmp/0xbaf685_nwx6uolk.txt
External accounts to fetch: {'0x2bf91c18cd4ae9c2f2858ef9fe518180f7b5096d'}
SLOTS to fetch: {('0x722C7207cA852a62745B2e029d6F513304B6cd1b', '0x812ad9b113d15654e6086d14747d4cc4153f9c316205c599bb31050bd1c071f9')}
GetAccountInfo(0x2bf91c18cd4ae9c2f2858ef9fe518180f7b5096d, 9730295)
GetStorageSlot(0x722C7207cA852a62745B2e029d6F513304B6cd1b, 58424067496916919764417794416050710579217690992573278782164926114703089889785, 9730295)
Executing tx...
docker run --rm -v /tmp:/tmp holiman/gethvm --prestate /tmp/0xbaf685-genesis-geth_flcBy5yE.json --gas 1700463 --sender 0x0451611635dB4A436F04a7929ea8D07e2FB51789 --receiver 0x722C7207cA852a62745B2e029d6F513304B6cd1b --input 206ec7a1000000
0000000000000000002bf91c18cd4ae9c2f2858ef9fe518180f7b5096df6299e1e2bc330c9cd2fa4b5940c0b60949590b199641adb985f8078d2b792ce00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000
0000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d00ffffb205cc0c5a51e7c77a7668a8b90bbb9000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000
000000000000000000011db3ddbed5 --nomemory --json run
Saved trace to /tmp/0xbaf685_btkj4p82.txt
SLOTS to fetch: {('0x2bf91c18cd4ae9c2f2858ef9fe518180f7b5096d', '0x97bcff14c0f601121caaf589487f088538c3c2dbd3ef529077348cd52715dbaa')}
GetStorageSlot(0x2bf91c18cd4ae9c2f2858ef9fe518180f7b5096d, 68633167889090086086379242021938346680284226757602511038687277061016120581034, 9730295)
ERROR OCCURRED: trace may not be correct
Traceback (most recent call last):
  File /home/user/.local/lib/python3.8/site-packages/evmlab/multiapi.py, line 105, in getStorageSlot
      value = self.web3.eth.getStorageAt(addr, key, blnum)
      File /home/user/.local/lib/python3.8/site-packages/web3/eth.py, line 173, in getStorageAt
      return self.web3.manager.request_blocking(
      File /home/user/.local/lib/python3.8/site-packages/web3/manager.py, line 149, in request_blocking
      response = self._make_request(method, params)
      File /home/user/.local/lib/python3.8/site-packages/web3/manager.py, line 128, in _make_request
    return request_func(method, params)
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/formatting.py, line 75, in apply_formatters
    response = make_request(method, params)
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/gas_price_strategy.py, line 34, in middleware
    return make_request(method, params)
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/formatting.py, line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/attrdict.py, line 33, in middleware
    response = make_request(method, params)
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/formatting.py, line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/normalize_errors.py, line 25, in middleware
    result = make_request(method, params)
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/formatting.py, line 75, in apply_formatters
    response = make_request(method, params)
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/middleware/formatting.py, line 72, in apply_formatters
    formatted_params = formatter(params)
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/abi.py, line 788, in map_abi_data
    return pipe(data, *pipeline)
  File cytoolz/functoolz.pyx, line 669, in cytoolz.functoolz.pipe
  File cytoolz/functoolz.pyx, line 644, in cytoolz.functoolz.c_pipe
  File cytoolz/functoolz.pyx, line 250, in cytoolz.functoolz.curry.__call__
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/abi.py, line 822, in data_tree_map
    return recursive_map(map_to_typed_data, data_tree)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/decorators.py, line 30, in wrapped
    wrapped_val = to_wrap(*args)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/formatters.py, line 89, in recursive_map
    items_mapped = map_collection(recurse, data)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/formatters.py, line 76, in map_collection
    return datatype(map(func, collection))
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/formatters.py, line 88, in recurse
    return recursive_map(func, item)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/decorators.py, line 30, in wrapped
    wrapped_val = to_wrap(*args)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/formatters.py, line 90, in recursive_map
    return func(items_mapped)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/abi.py, line 819, in map_to_typed_data
    return ABITypedData(func(*elements))
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/normalizers.py, line 78, in wrapper
    modified = to_wrap(type_str, data)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/normalizers.py, line 196, in abi_address_to_hex
    validate_address(data)
  File /home/user/.local/lib/python3.8/site-packages/web3/_utils/validation.py, line 170, in validate_address
    raise InvalidAddress(
web3.exceptions.InvalidAddress: ('Web3.py only accepts checksum addresses. The software that gave you this non-checksum address should be considered unsafe, please file it as a bug on their platform. Try using an ENS name instead. Or, if
you must accept lower safety, use Web3.toChecksumAddress(lower_case_address).', '0x2bf91c18cd4ae9c2f2858ef9fe518180f7b5096d')
Traceback (most recent call last):
  File /usr/local/lib/python3.8/runpy.py, line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File /usr/local/lib/python3.8/runpy.py, line 86, in _run_code
    exec(code, run_globals)
  File /home/user/.local/lib/python3.8/site-packages/evmlab/__main__.py, line 49, in <module>
    main()
  File /home/user/.local/lib/python3.8/site-packages/evmlab/__main__.py, line 42, in main
    ret = SUBCOMMAND.get(cmd_util.strip().lower(), usage)()
  File /home/user/.local/lib/python3.8/site-packages/evmlab/__main__.py, line 33, in <lambda>
    'reproducer': lambda: reproducer.main()}
  File /home/user/.local/lib/python3.8/site-packages/evmlab/tools/reproducer/reproducer.py, line 192, in main
    artefacts, vm_args = reproduce.reproduceTx(args.hash, vm, api)
  File /home/user/.local/lib/python3.8/site-packages/evmlab/reproduce.py, line 172, in reproduceTx
    genesis.addStorage(addr, key, val)
  File /home/user/.local/lib/python3.8/site-packages/evmlab/genesis.py, line 221, in addStorage
    value = 0x{:064x}.format(int(value,16))
ValueError: invalid literal for int() with base 16: ''
@0x1d00ffff
Copy link
Author

This change allowed reproduce.py to finish the trace

MD5(reproduce.py)= 22f1b0ef9ffe1f3bed1b7f7f5937b813

--- /home/user/.local/lib/python3.8/site-packages/evmlab/reproduce.py  2020-03-23 15:34:52.442702220 -0700
+++ /home/user/.local/lib/python3.8/site-packages/evmlab/reproduce.py.new   2020-03-23 15:42:04.168996699 -0700
@@ -16,6 +16,8 @@
 import json
 import tempfile, os, traceback

+from web3 import Web3
+
 from sys import argv, exit

 from . import compiler as c
@@ -168,6 +170,7 @@
         externals_fetched.update(externals_tofetch)

         for (addr,key) in list(slots_to_fetch):
+            addr = Web3.toChecksumAddress(addr)
             val = api.getStorageSlot( addr, int(key,16), blnum - 1)  # need to load storage at block before tx
             genesis.addStorage(addr, key, val)
             done = False

@holiman
Copy link
Collaborator

holiman commented Mar 25, 2020

Nice. You're welcome to make a PR, but evmlab is no longer maintained actively, it's been deprecated in favour of https://github.com/holiman/goevmlab .
Although I don't think the reproducer - functionality has been implemented there yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants