-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typed features #2164
Typed features #2164
Conversation
But that's not what we want though, we want exactly the opposite behavior. I really like having better types, but as I pointed out the first time we explored it, this creates a tension with dynamic data we receive from the external world that might not pass these static checks (and that we still want to allow because we need to be a bit lenient here in case other implementations aren't strict enough with how they use feature bits). Properly typing this is useful only if we can actually use these types for:
If we were the only implementation in the network, we'd know that external data would follow these rules and could enforce them, but in a decentralized network such as lightning I don't think we can be that strict. |
I don't think you understand what it does. If the invoice contains a mandatory feature that we don't know, we will reject the invoice, the case when we would accept a previously rejected invoice is it contains a mandatory feature we don't support but that we know is not for invoices.
And we won't, we'll just ignore these non-invoice feature bits. |
Ok, then your description was very misleading!
I'm still not sure how that sentence should be interpreted.
But we don't want to ignore them completely, if they are mandatory, we do want to verify that we also support them. |
Why do we care about non-invoice features ? If we receive an invoice that says "option_anchor_outputs is mandatory" and we don't support anchor outputs, why should we reject the invoice, it means we probably don't have a direct channel with that node as our channel features are incompatible but that doesn't prevent us from paying this invoice. |
Because if it's an unknown feature, it could be an invoice feature, we simply don't know, right? If you see feature bit 64 for example, we don't know what it is, but it may be a new invoice feature that has been introduced and we don't know about. I completely agree that if we see a known, non-invoice feature, then we probably don't care. I haven't read the code yet, so maybe this is properly handled already? |
Unknown features are processed separately, I'm talking here about features that we know are not invoice features, these are features that we know, or features above 5120 because they don't fit in invoices anyway. |
Great, then that should work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make that work, and it would be a nice improvement.
We need to test and fix the subtle signature issues, but that shouldn't be impossible to handle.
eclair-core/src/main/scala/fr/acinq/eclair/remote/EclairInternalsSerializer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LightningMessageCodecs.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/Bolt11Invoice.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/LightningMessageCodecsSpec.scala
Outdated
Show resolved
Hide resolved
af40875
to
41cf3ae
Compare
It should be ready now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, looks good to me! A couple of test improvements and this should be good to go 👍
eclair-core/src/test/scala/fr/acinq/eclair/router/AnnouncementsSpec.scala
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala
Outdated
Show resolved
Hide resolved
Invalid features are now reported to the user instead of being silently ignores
eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
It's good to get that refactoring done!
Give different types to init features / node announcement features / invoice features.
This also fixes the lack of unknown features in the invoice (users can now add their custom unknown features) and we now accept more invoices (we would previously reject invoices if they required a non invoice feature that we don't support).