Skip to content

Pr secrethash related#4150

Closed
offerm wants to merge 1 commit into
raiden-network:developfrom
offerm:PR-secrethash-related
Closed

Pr secrethash related#4150
offerm wants to merge 1 commit into
raiden-network:developfrom
offerm:PR-secrethash-related

Conversation

@offerm
Copy link
Copy Markdown
Contributor

@offerm offerm commented May 27, 2019

No description provided.

@offerm offerm force-pushed the PR-secrethash-related branch from 5612600 to 8004530 Compare May 28, 2019 05:49
@offerm offerm mentioned this pull request May 28, 2019
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2019

Codecov Report

Merging #4150 into develop will increase coverage by 0.04%.
The diff coverage is 72.72%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4150      +/-   ##
===========================================
+ Coverage    87.17%   87.22%   +0.04%     
===========================================
  Files          102      102              
  Lines        12843    12977     +134     
===========================================
+ Hits         11196    11319     +123     
- Misses        1647     1658      +11
Impacted Files Coverage Δ
raiden/transfer/node.py 92.88% <100%> (+0.07%) ⬆️
raiden/transfer/mediated_transfer/initiator.py 97.08% <40%> (-2.17%) ⬇️
raiden/utils/__init__.py 53.27% <0%> (-3.28%) ⬇️
raiden/network/blockchain_service.py 92.96% <0%> (-2.35%) ⬇️
raiden/messages.py 86.73% <0%> (-1.67%) ⬇️
raiden/network/transport/matrix/transport.py 91.54% <0%> (-0.96%) ⬇️
raiden/raiden_service.py 94.41% <0%> (-0.94%) ⬇️
raiden/waiting.py 88.07% <0%> (-0.92%) ⬇️
raiden/network/proxies/secret_registry.py 84.34% <0%> (-0.87%) ⬇️
raiden/network/transport/matrix/utils.py 95.63% <0%> (-0.87%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8ff0cf...b1b26f0. Read the comment docs.


if initiator_state.transfer_description.secret == EMPTY_SECRET:
transfer_description = initiator_state.transfer_description
payment_failed = EventPaymentSentFailed(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this event should be used here. We can only guarantee that a payment has failed after the lock has expired and we expect this event to mean that.

The handling is probably better done on the handle_secret_request on the message handler, and do the same thing as the handle_refund_transfer (as in, handle the special case when the secret is unknown).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hackaugusto So you suggest that I will just ignore this request and let the transfer expire?

Clearly I can do that but let's consider the app that made the payment (XUD). It can take some time until the transfer expires and in that time, XUD does not know what to do with the order in it order book.
XUD knows for sure that it never released the secret so there is no risk in getting back immediately and letting XUD knows that its peer is not configured right.

I added this handling as it was hard to find what is causing XUD transfer to fail. Keep in mind that this is a result of misconfiguration of the peer node and it is the sending that is suffering due to it.

The handling we added in handle_message_refundtransfer is not similar. Here, if the first route fails the transfer is blocked until expiration. However, on XUD level we are checking that there is a direct channel between the peers and that both peers are up, running, and connected to Raiden. So practically this situation of long payment can be avoided.

Let me know what you think.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@offerm I believe Augusto's argument was against using EventPaymentSentFailed as the event to indicate that the payment actually failed. At this point in time where you emit this event, the lockedd amounts are still locked and the payment never really failed in the sense that the locks no longer exist. At this point, we could end up in a situation where the secret request failed because the XUD did not provided it (False returned by the resolve)... so we send this event here but after a while the same request is sent and the resolver provides the secret and the payment was a success. Do you see where this is going?
The alternative is as Augusto suggests, is to check this in the message handler to make sure that:

  1. This is an atomic swap transfer (via secret being unknown to the node)
  2. The resolver request fails
  3. Iff both conditions above happen, then we never dispatch the secret request to the state machine.

At least, this is how i am thinking about it right now. Maybe Augusto has a better approach to how this can be done in details.

Copy link
Copy Markdown
Contributor

@hackaugusto hackaugusto Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @rakanalh described, IMO the payment is failed only after the lock has expired, this is important because the event is tied to change in the channel capacity. Here is some relevant discussion we had in the past: #3024 (comment)

You could add a new event as from the linked discussion. Since your application controls the secret, it knows the payment will never succeed.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2019

Codecov Report

Merging #4150 into develop will increase coverage by 0.46%.
The diff coverage is 70%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4150      +/-   ##
===========================================
+ Coverage    86.73%   87.19%   +0.46%     
===========================================
  Files          102      102              
  Lines        13001    12975      -26     
===========================================
+ Hits         11276    11314      +38     
+ Misses        1725     1661      -64
Impacted Files Coverage Δ
raiden/api/python.py 89.4% <100%> (+2.93%) ⬆️
raiden/transfer/mediated_transfer/initiator.py 97.08% <40%> (-2.17%) ⬇️
raiden/network/proxies/utils.py 89.28% <0%> (-3.22%) ⬇️
raiden/app.py 96.96% <0%> (-3.04%) ⬇️
raiden/network/proxies/token_network_registry.py 91.3% <0%> (-3.02%) ⬇️
raiden/connection_manager.py 80.89% <0%> (-2.55%) ⬇️
raiden/network/proxies/user_deposit.py 67.81% <0%> (-2.3%) ⬇️
raiden/api/v1/resources.py 97.82% <0%> (-2.18%) ⬇️
raiden/messages.py 86.73% <0%> (-1.7%) ⬇️
raiden/utils/cli.py 55.14% <0%> (-1.45%) ⬇️
... and 48 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc3ce0d...5368248. Read the comment docs.

If the target is asking for the secret but the initiator does not have it, emit and error.
If secrethash provided with payment request and there is another inflight payment request with the same secrethash, emit an error
@offerm offerm force-pushed the PR-secrethash-related branch from b1b26f0 to 5368248 Compare May 31, 2019 06:59
@offerm
Copy link
Copy Markdown
Contributor Author

offerm commented May 31, 2019

@rakanalh @hackaugusto need tests restart please.

@offerm
Copy link
Copy Markdown
Contributor Author

offerm commented May 31, 2019 via email

@offerm
Copy link
Copy Markdown
Contributor Author

offerm commented Jun 11, 2019

@rakanalh @hackaugusto Will you be OK to include in the EventPaymentSentFailed class a member like final: bool = True ? A value of True indicates that the status is final (lock expired) while a value of False indicates that this may not be a final result. A value False can be used with Atomic swaps.

Let me know if this can pass.

Offer

@rakanalh
Copy link
Copy Markdown
Contributor

Hey @offerm,

@hackaugusto and I discussed this use case and we believe we have an alternative that requires some work on the XUD's end.
The reason for this is that, Raiden's codebase has one constraint for determining a payment failure which is for the lock to expire.
For your use case, failing the payment using that event is not correct because as explained, even if emitting EventPaymentSentFailed the payment has not in reality failed as the locks are still locked. The only way to unlock the locked amount is for either the payment to succeed or for the lock to expire.

In this case, the error you're trying to handle is a bit specific to the fact that Raiden does not know the secret iff the transfer currently in-flight is an atomic swap. We think that the best approach for this to be implemented is:

  1. the XUD to start the transfer using Raiden.
  2. If a SecretRequest is received, emit a EventSecretUnknown event.
  3. XUD would periodically poll Raiden's events API and look for this event.
  4. XUD realises that the the transfer has failed and acts accordingly. Not sure what the XUD does here but there's nothing you can do on Raiden other than waiting for the lock to expire and only in this case will EventPaymentSentFailed be emitted.

@rakanalh
Copy link
Copy Markdown
Contributor

Hey @offerm,

Is this PR something that you would like to pursue?

@offerm
Copy link
Copy Markdown
Contributor Author

offerm commented Aug 30, 2019

Depend what you mean by "pursue".

In out Raiden fork we are using this change. Without it you get wired situations or complicated logic. Let me know what can we do about it.

Offer

@rakanalh
Copy link
Copy Markdown
Contributor

My meaning was whether this was still important to you and if you wanted to continue working on this PR according to our suggestions previously made.

@Dominik1999
Copy link
Copy Markdown
Contributor

Please close or finish this PR until Thursday 20 of Feb.

@hackaugusto
Copy link
Copy Markdown
Contributor

closing this for now

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

Successfully merging this pull request may close these issues.

5 participants