ethereum / eth-keys

A common API for Ethereum key operations.
MIT License
159 stars 64 forks source link

Suspected infinite recursion in jacobian #49

Open mderka opened 5 years ago

mderka commented 5 years ago

(Submitting as instructed on Gitter by @carver .)

What was wrong?

When running a transaction in our test suited, the following error showed up. The error appears like an infinite loop/recursion. It appears intermittently and I do not have solid way of reproducing it.

Please include any of the following that are applicable:

exception = <class 'StopIteration'>, exception_message = None

def _raise_exception(exception, exception_message):
    """ This function checks if a exception message is given.

    If there is no exception message, the default behaviour is maintained.
    If there is an exception message, the message is passed to the exception with the 'value' keyword.
    """
    if exception_message is None:
      raise exception()

E StopIteration

/usr/lib/python3.6/site-packages/timeout_decorator/timeout_decorator.py:45: StopIteration



### How can it be fixed?

I do not have an insight.
pipermerriam commented 5 years ago

It would be really helpful if we could get the values from this section.

/usr/lib/python3.6/site-packages/eth_keys/backends/native/main.py:30: in ecdsa_recover
    public_key_bytes = ecdsa_raw_recover(msg_hash, signature.vrs)

Specifically the msg_hash and signature.vrs values. This will let us confirm this bug in isolation.

mderka commented 5 years ago

Those values will likely not be available. They are dynamic and I cannot consistently reproduce the issue, so they are hard to get. I will try to run the tests whenever possible and report if I manage to retrieve them.

carver commented 5 years ago

Recovering a signature is a feature that we already test on lots of random inputs, even on invalid signatures. See https://github.com/ethereum/eth-keys/blob/ce2aade354c77531babaa16669529082a7835f39/tests/backends/test_native_backend_against_coincurve.py

So it's going to be tricky for us to figure out this bug without the specific inputs. One thing we could do in the meantime is catch that StopIteration in eth-keys main and re-raise the exception with the message & signature. (also, should StopIteration be a timeout exception instead?)