Skip to content

Instantly share code, notes, and snippets.

@zhangyouxin
Last active May 26, 2022 01:58
Show Gist options
  • Save zhangyouxin/6c8ef50ff2d71e51757d7b49db810579 to your computer and use it in GitHub Desktop.
Save zhangyouxin/6c8ef50ff2d71e51757d7b49db810579 to your computer and use it in GitHub Desktop.
godwoken deposit/withdrawal flow chart
graph TD
    S[Start v0/v1 deposit] --> A[asset on Layer 1]
    A --> B[transfer to v0/v1 depositLock]
    B --> dp1(pending)
    dp1 --> dp2[Deposit Cell]
    dp2 --> |Consumed by rollup in cancel_time|CC[asset in custodian cell]
    CC --> C[asset on Layer 2]
    C --> dd2(success)
    dd2 --> e(end)
    B --> |Layer 1 tx timeout|ff1(fail)
    ff1 --> e
    dp2 --> |Still alive after cancel_time|cc[deposit timeout]
    cc --> uc[User cancel]
    uc --> ff1

    s2[Start v0/v1 withdrawal] --> LAYER_2[asset on v0/v1 Layer 2]
    LAYER_2 --> w1[User Send Withdrawal Tx, to layer 1 owner lock]
    w1 --> p2(v0/v1 Layer 2 pending)
    p2 --> |wait for v0/v1 layer 2 withdrawal tx commited|c2(v0/v1 Layer 2 committed)
    c2 --> p1(Layer 1 pending)
    p1 --> |wait for withdrawal lock time|r1{Layer 1 ready to unlock}
    r1 -- V0 --> u0[User unlock] 
    u0 --> l1[Layer 1]
    l1 --> d1(success)
    d1 --> e2(end)
    r1 -- V1 --> u1[Rollup auto unlock] 
    u1 --> l1[asset on Layer 1]
    w1 --> |layer 2 tx timeout|ff2(fail)
    ff2 --> e2

    ss[Start v0 fast withdrawal] --> f0[asset on V0 Layer 2]
    f0 --> f1[User Send Withdrawal Tx, to v1 deposit lock]
    f1 --> f2(v0 Layer 2 pending)
    f2 --> |wait for v0 layer 2 withdrawal tx commited|f3(v0 Layer 2 committed)
    f3 --> f4(Layer 1 pending)
    f4 --> |wait for 1 layer 2 block|f5[Rollup consume layer 1 deposit cell]
    f5 --> |Layer 1 Deposit Cell Consumed|f6[asset on v1 Layer 2]
    f6 --> f7(success)
    f7 --> e3(end)
    f1 --> |layer 2 tx timeout|ff3(fail)
    ff3 --> e3

  
  
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment