LNP-WG / lnp-node

Lightning network protocol daemon (suitable for generalized Lightning Network)
MIT License
145 stars 40 forks source link

Fix struct fields order #66

Closed crisdut closed 1 year ago

crisdut commented 1 year ago

I tried open a channel between two lnp nodes, but this error occurs:

[2023-01-10T08:59:31Z ERROR microservices::esb::controller] ESB request processing error: message serialization or structure error. Details: Data integrity problem during strict decoding operation: encoded values are not deterministically ordered: value `Type(10995120572727296)` should go before `Type(10995120572727302)`

After invetigate, I found the reason:

For some reason, the type tvl::Stream (BTreeMap<Type, RawValue>) need the last field of the struct when we uses strict encode/decode.

dr-orlovsky commented 1 year ago

It is very impressive that you was able to figure out the reason of the issue. From your results it becomes clear that indeed TLV stream has to be the last data in the structure, so if emedded structures have TLV stream and they are not the last field they would not work! This is a logical bug in lightning/strict encoding crates, opening an issues for that: