Skip to content

BOLT #7: receiving node requirements related to timestamp for channel_update message#621

Merged
t-bast merged 12 commits intolightning:masterfrom
ugamkamat:ugamkamat-patch-2
Jul 16, 2019
Merged

BOLT #7: receiving node requirements related to timestamp for channel_update message#621
t-bast merged 12 commits intolightning:masterfrom
ugamkamat:ugamkamat-patch-2

Conversation

@ugamkamat
Copy link
Contributor

While going through BOLT #7 I was confused by this receiving node requirement for channel_update message: "if the timestamp is equal to the last-received channel_update AND the fields (other than signature) differ: MAY blacklist this node_id; MAY forget all channels associated with it." On the outset it might read to "timestamp should be same, the signature should be same as previous but if the other data is different; then blacklist the node_id". However, if signature is same as previous update but data is different, then the signature would be rendered invalid. And since signature check is done prior to the timestamp check, this situation of checking may not arise. So this check seems to be redundant. However, Mark H corrected me on stackexchange (https://bitcoin.stackexchange.com/questions/88350/bolt-7-can-receiving-node-requirements-in-channel-update-message-give-rise-to) by saying that a valid signature must be provided for this channel_update and timestamp to go through. This pull request slightly corrects the language behind this check and adds a paragraph in the rationale to explain that point.

In correcting the point, I have said fields below timestamp differs for the following reason: (1) short_channel_id and chain_hash requirements are processed prior to timestamp and (2) valid signature check is also done prior to the timestamp.

While creating this pull request, I also noticed a slight typo in the same section. The sentence prior to the one I mentioned above says that if the timestamp is not greater than the previous message, the node should ignore the message. And the second sentence is about comparing if timestamp is equal. But again, the equal to check might not be processed as the message will be discarded if it is not greater. I have changed that to "greater than or equal to". Would love your comments and suggestions.

While going through the BOLT lightning#7 I was confused by this receiving node requirement for `channel_update` message: "if the `timestamp` is equal to the last-received `channel_update` AND the fields (other than `signature`) differ: MAY blacklist this `node_id`; MAY forget all channels associated with it." On the outset it might read to "`timestamp` should be same, the `signature` should be same as previous but if the other data is different; then blacklist the `node_id`". However, if `signature` is same as previous update but data is different, then the `signature` would be rendered invalid. And since `signature` check is done prior to the `timestamp` check, this situation of checking may not arise. So this check seems to be redundant. However, Mark H corrected me on stackexchange (https://bitcoin.stackexchange.com/questions/88350/bolt-7-can-receiving-node-requirements-in-channel-update-message-give-rise-to) by saying that a valid signature must be provided for this update and timestamp to go through. This pull request corrects the language behind this check.

While creating this pull request, I also noticed a slight typo in the same section. The sentence prior to the one I mentioned above says that if the timestamp is not greater than the previous message, the node should ignore the message. And the second sentence is about comparing if timestamp is equal. But again, this check might not be processed as the message will be discarded if it is not greater. I have changed that to "greater than or equal to".
…or channel_update message

While going through the BOLT lightning#7 I was confused by this receiving node requirement for `channel_update` message: "if the `timestamp` is equal to the last-received `channel_update` AND the fields (other than `signature`) differ: MAY blacklist this `node_id`; MAY forget all channels associated with it." On the outset it might read to "`timestamp` should be same, the `signature` should be same as previous but if the other data is different; then blacklist the `node_id`". However, if `signature` is same as previous update but data is different, then the `signature` would be rendered invalid. And since `signature` check is done prior to the `timestamp` check, this situation of checking may not arise. So this check seems to be redundant. However, Mark H corrected me on stackexchange (https://bitcoin.stackexchange.com/questions/88350/bolt-7-can-receiving-node-requirements-in-channel-update-message-give-rise-to) by saying that a valid signature must be provided for this update and timestamp to go through. This pull slightly corrects the language behind this check and adds a paragraph in the rationale to explain that point.

While creating this pull request, I also noticed a slight typo in the same section. The sentence prior to the one I mentioned above says that if the timestamp is not greater than the previous message, the node should ignore the message. And the second sentence is about comparing if timestamp is equal. But again, the equal to check might not be processed as the message will be discarded if it is not greater. I have changed that to "greater than or equal to".
ugamkamat and others added 3 commits June 17, 2019 21:34
Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
the specified chain):
- MUST ignore the channel update.
- if `timestamp` is NOT greater than that of the last-received
- if `timestamp` is lower than that of the last-received
Copy link
Collaborator

Choose a reason for hiding this comment

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

this the new rewording leaves a gap, since it doesn't specify what to do if the timestamp is equal to the last-received and the message is indeed a duplicate. in this case, the message should still be ignored.

i think this is resolved keeping the NOT greater than here and removing the otherwise on line 500. i think it also requires switching the order of the checks, since the blacklist check is a stricter subset of the <=check.

to be clear, i'm suggesting:

if blacklist:
  ...
if timestamp <=:
  ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cfromknecht Thanks! I included your suggestion for the condition where the timestamp is equal. But in order to not leave other holes, I slightly changed it in terms of order than what you suggested. Let me know if its good.

It is assumed that more than one `channel_update` message changing the channel
parameters in the same second may be a DoS attempt, and therefore, the node responsible
for signing such messages may be blacklisted. However, a node can send a same
`channel_update` message with a different signature (changing the nonce in signature
Copy link
Collaborator

Choose a reason for hiding this comment

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

important to note that since ECDSA signatures are malleable, the signatures can be different even if the node only signed once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very fair point. I'm incorporating this in the rationale.

Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

ACK 2393f3a

@t-bast
Copy link
Collaborator

t-bast commented Jul 9, 2019

@ugamkamat could you update to fix the typo (which would make the build succeed)?
@cfromknecht could you provide feedback/ack?

@t-bast t-bast added the spelling These changes may be merged without additional sign off from the weekly meeting label Jul 9, 2019
Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
@ugamkamat
Copy link
Contributor Author

@t-bast Done, typo is fixed

@t-bast
Copy link
Collaborator

t-bast commented Jul 9, 2019

The build is still failing because you introduce words that aren't in the spellcheck list yet.
Could you add "DoS" and "ECDSA" to the .aspell.en.pws file?

@ugamkamat
Copy link
Contributor Author

@t-bast Done. Since this was my first time adding a commit, I wasn't entirely sure how to update that file. I have created a PR with those words added.

@t-bast t-bast mentioned this pull request Jul 9, 2019
Updated for DoS and ECDSA
@ugamkamat
Copy link
Contributor Author

@t-bast So, I have pushed the file to this PR. Let me know if that is correct.

@t-bast
Copy link
Collaborator

t-bast commented Jul 9, 2019

ACK 839d5b3
We need two approvals to commit, so I'll wait for @cfromknecht or someone else to chime in.

Copy link
Collaborator

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 🏖

@t-bast t-bast merged commit 1db481f into lightning:master Jul 16, 2019
- if `timestamp` is lower than that of the last-received
`channel_update` for this `short_channel_id` AND for `node_id`:
- SHOULD ignore the message.
- otherwise:
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this otherwise could have been removed too?

Copy link
Contributor Author

@ugamkamat ugamkamat Jul 17, 2019

Choose a reason for hiding this comment

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

@jtimon No that otherwise is needed. Just that both the if and otherwise should be indented on the previous otherwise. I think there was a formatting error when creating the pull request.

The idea was to have it this way. Timestamp equal to previous do this. Time stamp lower than previous do that. Otherwise: if timestamp too large in future do this, otherwise do that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is reverting the commit and making changes the right way to go?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No we don't rewrite history. You can submit a tiny indentation fix PR and it should be approved very quickly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@t-bast cool. Will submit one soon.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks!

ugamkamat added a commit to ugamkamat/lightning-rfc that referenced this pull request Jul 18, 2019
Related to pull lightning#621 

Corrected the indentation in the otherwise section in the `timestamp` check of the `channel_update` message. Both the if appeared at the same level of otherwise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spelling These changes may be merged without additional sign off from the weekly meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants