raiden-network / raiden

Raiden Network

Home Page:https://developer.raiden.network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate E2E-interoperability test failure

ezdac opened this issue · comments

Even after #7298 the E2E-interoperability test from the LC-team fails.
We have to investigate further what is happening here.

It seems like the PC nodes don't start up properly because of a type mismatch in the secret decryption

Traceback (most recent call last):
  File "/opt/raiden/lib/python3.9/site-packages/raiden/ui/cli.py", line 721, in _run
    run_services(kwargs)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/ui/runners.py", line 18, in run_services
    raiden_service = run_raiden_service(**options)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/ui/app.py", line 457, in run_raiden_service
    raiden_service.start()
  File "/opt/raiden/lib/python3.9/site-packages/raiden/raiden_service.py", line 494, in start
    self._start_transport()
  File "/opt/raiden/lib/python3.9/site-packages/raiden/raiden_service.py", line 612, in _start_transport
    self.transport.start(raiden_service=self, prev_auth_data=None)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 524, in start
    self._initialize_first_sync()
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 800, in _initialize_first_sync
    self._client.blocking_sync(
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/client.py", line 482, in blocking_sync
    self._handle_responses(pending_queue)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/client.py", line 640, in _handle_responses
    self.handle_messages_callback(messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 930, in _handle_messages
    self._process_raiden_messages(raiden_messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 919, in _process_raiden_messages
    self._raiden_service.on_messages(incoming_messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/raiden_service.py", line 866, in on_messages
    self.message_handler.on_messages(self, messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/message_handler.py", line 101, in on_messages
    for greenlet in joinall(set(pool), raise_error=True):
  File "src/gevent/greenlet.py", line 1057, in gevent._gevent_cgreenlet.joinall
  File "src/gevent/greenlet.py", line 1073, in gevent._gevent_cgreenlet.joinall
  File "src/gevent/greenlet.py", line 371, in gevent._gevent_cgreenlet.Greenlet._raise_exception
  File "/opt/raiden/lib/python3.9/site-packages/gevent/_compat.py", line 65, in reraise
    raise value.with_traceback(tb)
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/opt/raiden/lib/python3.9/site-packages/raiden/message_handler.py", line 356, in handle_message_lockedtransfer
    from_transfer.lock.amount < amount
TypeError: '<' not supported between instances of 'int' and 'str'
ReturnCode.FATAL
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/opt/raiden/lib/python3.9/site-packages/raiden/message_handler.py", line 356, in handle_message_lockedtransfer
    from_transfer.lock.amount < amount
TypeError: '<' not supported between instances of 'int' and 'str'
2021-08-19T14:40:56Z <Greenlet at 0x7f3014fc7040: handle_message_lockedtransfer(<RaidenService node:0x517aAD51D0e9BbeF3c64803F86b3, <LockedTransfer ...>)> failed with TypeError

Traceback (most recent call last):
  File "/opt/raiden/lib/python3.9/site-packages/raiden/ui/cli.py", line 721, in _run
    run_services(kwargs)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/ui/runners.py", line 18, in run_services
    raiden_service = run_raiden_service(**options)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/ui/app.py", line 457, in run_raiden_service
    raiden_service.start()
  File "/opt/raiden/lib/python3.9/site-packages/raiden/raiden_service.py", line 494, in start
    self._start_transport()
  File "/opt/raiden/lib/python3.9/site-packages/raiden/raiden_service.py", line 612, in _start_transport
    self.transport.start(raiden_service=self, prev_auth_data=None)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 524, in start
    self._initialize_first_sync()
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 800, in _initialize_first_sync
    self._client.blocking_sync(
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/client.py", line 482, in blocking_sync
    self._handle_responses(pending_queue)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/client.py", line 640, in _handle_responses
    self.handle_messages_callback(messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 930, in _handle_messages
    self._process_raiden_messages(raiden_messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/network/transport/matrix/transport.py", line 919, in _process_raiden_messages
    self._raiden_service.on_messages(incoming_messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/raiden_service.py", line 866, in on_messages
    self.message_handler.on_messages(self, messages)
  File "/opt/raiden/lib/python3.9/site-packages/raiden/message_handler.py", line 101, in on_messages
    for greenlet in joinall(set(pool), raise_error=True):
  File "src/gevent/greenlet.py", line 1057, in gevent._gevent_cgreenlet.joinall
  File "src/gevent/greenlet.py", line 1073, in gevent._gevent_cgreenlet.joinall
  File "src/gevent/greenlet.py", line 371, in gevent._gevent_cgreenlet.Greenlet._raise_exception
  File "/opt/raiden/lib/python3.9/site-packages/gevent/_compat.py", line 65, in reraise
    raise value.with_traceback(tb)
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/opt/raiden/lib/python3.9/site-packages/raiden/message_handler.py", line 356, in handle_message_lockedtransfer
    from_transfer.lock.amount < amount
TypeError: '<' not supported between instances of 'int' and 'str'

With the relevant code:

if encrypted_secret is not None:
try:
secret, amount, payment_identifier = decrypt_secret(
encrypted_secret, raiden.rpc_client.privkey
)
if (
from_transfer.lock.amount < amount
or from_transfer.payment_identifier != payment_identifier
):
raise InvalidSecret
log.info("Using encrypted secret", sender=to_checksum_address(sender))

Since the decrypt_secretis decoding the amount to an int, the bug must be somewhere in the decoding of theLockedTransfer` message

The amount returned from the decrypt_secret seems to be a string, instead of an int - this is possible when the json.loads() succeeds but decodes the amount as a str. There is no strict validation or type-cast in decrypt_secret, only functionality related to type checking:

def decrypt_secret(
encrypted_secret: EncryptedSecret, private_key: PrivateKey
) -> Tuple[Secret, PaymentAmount, PaymentID]:
try:
secret_dict = json.loads(decrypt(private_key, encrypted_secret).decode())
except (ValueError, json.JSONDecodeError):
raise InvalidSecret
secret = Secret(decode_hex(secret_dict["secret"]))
amount = PaymentAmount(secret_dict["amount"])
payment_id = PaymentID(secret_dict["payment_identifier"])
return secret, amount, payment_id

The instructions to build and run the LCs e2e tests: raiden-network/light-client#2896 (comment)

@ezdac it seems this is caused by an issue I raised a couple of times

Yes, that is exactly the issue here