nayutaco / ptarmigan

Lightning Network (BOLT)
Apache License 2.0
132 stars 19 forks source link

Message Retransmission #546

Open nayuta-ueno opened 6 years ago

nayuta-ueno commented 6 years ago

525

再接続の要件と実装については再確認すること。

nayuta-ueno commented 6 years ago

525 と同じ状況を、c-lightningを相手にして確認した。

c-lightningはcommitment_signedを送信した方になるが、再接続時に同じcommitment_signedを再送してきた。 BOLT仕様に明記されていない動作のように思うが、どうなのだろうか?


nayuta-ueno commented 6 years ago

上記のログ fail_comsig_log.zip

nayuta-ueno commented 6 years ago

BOLT#02の、一番下が該当すると思われる。


A node:

nayuta-ueno commented 6 years ago

該当するのか、よくわからなくなってきた。 c-lightningにissueで確認中。

nayuta-ueno commented 6 years ago

commitment_signed は再送とは呼ばない再送を行うと判断した。

commitment numberが不一致の場合の commitment_signed の再送受信には対応したが、再送ができていない。 unilateral closeしてしまっている。

nayuta-ueno commented 6 years ago

理想型

1. (disconnect after established)
2. connect
3. exchange `init`
4. exchange `channel_reestablish`
  * `next_local_commitment_number`: 1
  * `next_remote_revocation_number`: 0
5. `./cli/lightning-cli invoice`
6. [our --> their]`update_add_htlc`
7. [our --> their]`commitment_signed`
8. [their --> our]`revoke_and_ack`
9. [their --> our]`commitment_signed`
10. ★ our node disconnect before processing `commitment_signed`
11. connect
12. exchange `init`
13. exchange `channel_reestablish`
  * our node send:
    * `next_local_commitment_number`: 1
    * `next_remote_revocation_number`: 1
  * their send:
    * `next_local_commitment_number`: 2
    * `next_remote_revocation_number`: 0
14. [their --> our]`commitment_signed`
15. [our-->their]`revoke_and_ack`
16. [their --> our]`update_fulfill_htlc`
17. [their --> our]`commitment_signed`
18. [our-->their]`revoke_and_ack`
19. [our-->their]`commitment_signed`
20. [their --> our]`revoke_and_ack`
nayuta-ueno commented 6 years ago

618 も類件ではあるが、commitment_signedの再送はおこなっているので、closeでよい。

nayuta-ueno commented 6 years ago

commitment_signed / revoke_and_ack 交換を4状態に分け、状態2以降であればどちらか片方でもirrevocably committedになっているので再送などを行う。

もっと汎用的な見分け方はできないだろうか? P2Pなのにシーケンスに依存しすぎている気がする。

nayuta-ueno commented 6 years ago

もう1つ。 状態1から元に戻す場合、HTLCのidをどこに戻して良いのかが簡単に決められそうな感じがしていない。 DBに保存すれば可能なのか? それとも前回の「状態」という考え方を見直す必要があるのか?