nervosnetwork / fiber

15 stars 8 forks source link

Save remote commitment numbers whenever a new local commitment transaction is committed #132

Closed contrun closed 2 months ago

contrun commented 2 months ago

When we build and partially sign a commitment transaction, we are using a snapshot of the channel state. There are a few required parameters that need saving in order to construct this commitment transaction later.

Since the direct payment keys are rotated each time the remote commitment number updates and the list of TLCs to be included depends on the remote commitment number. We need to save the remote commitment number in order to reconstruct this local commitment transaction later.

chenyukang commented 2 months ago

currently, we store the latest commitment transaction. what's is the intention to reconstruct an older commitment transaction? I mean the older one than the latest one.

contrun commented 2 months ago

I should have said older commitment transaction parameters (but not commitment transaction per se). Commitment transaction witnesses are required for revoke old transactions. Imagine that we signed nth local transactions in total, and the adversary broadcast the mth ($0 \leq m \leq n$) to the network, then we need to reconstruct the witnesses, which depend on the remote commitment number.

contrun commented 2 months ago

I currently used the wrong public key to construct the commitment transaction. We shouldn't need remote commitment number to build local commitment transaction witnesses. I fixed this in https://github.com/nervosnetwork/cfn-node/pull/133/commits/f24ad0856f98749684da0e7d542f97d0833a4df0