raiden-network / raiden-services

Development of the Raiden Monitoring and Pathfinding Services
MIT License
10 stars 18 forks source link

ValueError: x_list must be in strictly ascending order! #636

Closed palango closed 4 years ago

palango commented 4 years ago

Problem Definition

In the BF1 scenario that @manuelwedler ran, some transfer failed. In the PFS I found this logs:

Exception on /api/v1/0xDa1fBc048f503635950058953f5c60FC1F564ee6/paths [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 458, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 573, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/services/src/pathfinding_service/api.py", line 142, in post
    **optional_args,
  File "/services/src/pathfinding_service/model/token_network.py", line 437, in get_paths
    fee_penalty=fee_penalty,
  File "/services/src/pathfinding_service/model/token_network.py", line 384, in _get_single_path
    Path(self.G, nodes, value, address_to_reachability) for nodes in all_paths
  File "/services/src/pathfinding_service/model/token_network.py", line 382, in <genexpr>
    p
  File "/services/src/pathfinding_service/model/token_network.py", line 384, in <genexpr>
    Path(self.G, nodes, value, address_to_reachability) for nodes in all_paths
  File "/services/src/pathfinding_service/model/token_network.py", line 81, in __init__
    self._calculate_fees()
  File "/services/src/pathfinding_service/model/token_network.py", line 97, in _calculate_fees
    receivable_amount=view_in.capacity,
  File "/usr/local/lib/python3.7/site-packages/raiden/tests/utils/mediation_fees.py", line 94, in get_amount_with_fees
    cap_fees=schedule_in.cap_fees,
  File "/usr/local/lib/python3.7/site-packages/raiden/transfer/mediated_transfer/mediation_fee.py", line 225, in mediation_fee_backwards_func
    cap_fees=cap_fees,
  File "/usr/local/lib/python3.7/site-packages/raiden/transfer/mediated_transfer/mediation_fee.py", line 120, in _mediation_fee_func
    schedule_in._penalty_func = Interpolate([0, balance_in + receivable], [0, 0])
  File "/usr/local/lib/python3.7/site-packages/raiden/transfer/mediated_transfer/mediation_fee.py", line 30, in __init__
    raise ValueError("x_list must be in strictly ascending order!")
ValueError: x_list must be in strictly ascending order!

Used nodes:

"node": 0, "address": "0x937d2De8dE33E761259e4F2E95C474f0Ce4e3B3d"
"node": 1, "address": "0xadE14e3C7609434684b4769369397513B3bD6D24"
"node": 2, "address": "0x2fAC81a40a63f82F1E7042B2650c6e08DeCD6B51"
"node": 3, "address": "0xA25b6Bb033A9712698c037d6E357e01C829049E0"
"node": 4, "address": "0x14be0397787764A76Cc42CC980d965442b0893D9"

Logs

@manuelwedler Can you attach the scenario logs here?

[SP 3]

manuelwedler commented 4 years ago

Yes, sure. scenario-player-run_bf1_basic_functionality_2019-11-19T11:09:23.log And the logs of the nodes: nodes.zip

palango commented 4 years ago

An idea for people looking into this:

karlb commented 4 years ago

This has been mostly likely caused by asking the PFS for a route before it has received the PFSBalance updated. Then balance_in + receivable can be zero and we call Interpolate([0, 0], [0, 0]) which raises this error because each x value is only allowed once.

But this error case should be handled in a better way: