Giter Club home page Giter Club logo

Comments (3)

dognie avatar dognie commented on August 27, 2024

Once the secret registered on the chain is received, it should be unlock immediately.

from photon.

Liamgettingbetter avatar Liamgettingbetter commented on August 27, 2024

Case Description

  1. Reconnects before Expiration

In this case, we have four transaction participants, which are Alice, Bob, Charlie, and Dave. Alice wishes to send 20 tokens to Dave, and she cannot do that due to the fact that there is no direct channel between them. And fortunately Alice can indirectly connect to Dave via Bob and Charlie. This is the background of our case.

Alice sends a MediatedTransfer to Bob with 20 tokens locked in it, and once Bob receives it, he will send back an ACK to notify Alice that her message has been received. This process continues with no fault till Dave finally receives MediatedTransfer from Alice.

At this phase, we have

  • In channel (Alice, Bob), there are 20 tokens hash locked.
  • In channel (Bob, Charlie), there are 20 tokens hash locked.
  • In channel (Charlie, Dave), there are 20 tokens hash locked.

After that, Dave wishes to know the secret to unlock this transfer. Hence, he asks for secret in a way of
sending a SecretRequest to Alice. With no hesitation, Alice reveals her secret to Dave by a RevealSecret message.

At the time Dave gets the secret, he can unlock that 20 tokens locked in channel (Charlie, Dave). Via RevealSecret, Dave passes this secret to Charlie. As for Charlie, before she has the chance to reveal this secret to Bob, she crashes down within a sec. To Dave, he has no idea whether Charlie receives his secret, therefore he has to keep sending RevealSecret to Charlie.

Within this case, Charlie resumes online ahead of Expiration of transfers. Right after that, she sends an ACK to Dave to make sure that Dave knows she has got the secret. After that Charlie halts.

Dave, after receiving the ACK from Charlie, waits for Unlock from Charlie, but nothing he gets after the only ACK. With no way around, Dave has to register this secret on chain via RegisterSecret.

Once Dave registers secret on chain, Alice sends Unlock to Bob, who responds to Alice with an ACK. And Bob, as a potentially fraudulent actor, is not willing to unlock 20 tokens locked in channel (Bob, Charlie), and he does nothing.

As for Charlie, she has to Unlock tokens because Dave registers secret on chain. Dave gives her an ACK to confirm the message.

After that, transfer succeeds but in channel (Bob, Charlie) there is still 20 tokens locked.

from photon.

Liamgettingbetter avatar Liamgettingbetter commented on August 27, 2024
  1. Reconnects after Expiration

As for this scenario, all these processes are the same, compared with Reconnect before Expiration. But with only one little difference, which is Charlie resumes after all those transfers have expired.

Process for MediatedTransfer operates normally. And channel states are

  • In channel (Alice, Bob), 20 tokens are hash-locked.
  • In channel (Bob, Charlie), 20 tokens are hash-locked.
  • In channel (Charlie, Dave), 20 tokens are hash-locked.

Once Dave has received this MediatedTransfer from Alice, he starts to send SecretRequest to Alice in order that she can reveal the secret in time. And Alice, as Dave wishes, sends back the secret by RevealSecret. Finally, Dave receives the secret.

Then, Dave can reveal his secret to Charlie, so Charlie can unlock those tokens locked in channel (Charlie, Dave). And Charlie, prior to the moment she begins to send RevealSecret to Bob, she crashes down without any notice. Hence, Bob can not know the secret and Dave has to keep sending RevealSecret to Charlie because she has no response to Dave.

This time, it seems that Charlie can't get online instantly, and Dave, who is afraid of losing assets, registers the secret on chain by RegisterSecret. Till now, everyone in this channel network knows the secret.

Alice, then sends a Unlock to Bob, and Bob returns an ACK to Alice showing that he has already received this message.

However, as a potentially fraudulent actor, Bob is not willing to unlock those tokens in channel (Bob, Charlie), the choice of him is to do nothing till all these transfers expired.

Charlie, after transfers get expired, reconnects to our network. Due to the fact that Dave has registered secret on chain, Charlie now learns about the secret and she then sends Unlock to Dave, who replies with an ACK.

Till now, transaction succeeds but tokens in channel (Bob, Charlie) are still locked.

from photon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.