Skip to content
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

Prefix all stored LN messages by their length #1239

Closed
wants to merge 1 commit into from

Conversation

pm47
Copy link
Member

@pm47 pm47 commented Dec 7, 2019

Now that we have optional fields at the end of messages, we have to
store their length in database, otherwise disasters will happen.

Now that we have optional fields at the end of messages, we have to
store their length in database, otherwise disasters will happen.
@codecov-io
Copy link

Codecov Report

Merging #1239 into master will increase coverage by 0.17%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1239      +/-   ##
==========================================
+ Coverage    76.6%   76.78%   +0.17%     
==========================================
  Files         140      140              
  Lines        9700     9723      +23     
  Branches      397      394       -3     
==========================================
+ Hits         7431     7466      +35     
+ Misses       2269     2257      -12
Impacted Files Coverage Δ
...ain/scala/fr/acinq/eclair/wire/ChannelCodecs.scala 100% <100%> (ø) ⬆️
...clair/blockchain/electrum/ElectrumClientPool.scala 74.19% <0%> (-4.31%) ⬇️
...-core/src/main/scala/fr/acinq/eclair/io/Peer.scala 75.52% <0%> (+0.29%) ⬆️
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 83.77% <0%> (+0.46%) ⬆️
...src/main/scala/fr/acinq/eclair/router/Router.scala 92.71% <0%> (+0.71%) ⬆️
...cala/fr/acinq/eclair/crypto/TransportHandler.scala 92.3% <0%> (+1.18%) ⬆️
...q/eclair/blockchain/electrum/ElectrumWatcher.scala 51.72% <0%> (+1.72%) ⬆️
...cinq/eclair/blockchain/bitcoind/zmq/ZMQActor.scala 94.87% <0%> (+5.12%) ⬆️

Copy link
Member

@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.

I think I'd prefer the solution where we create a separate "legacy codecs" file where we put the non-length prefixed ones, and directly change the others here to be length-prefixed.
This duplicates code but makes reading the non-legacy code easier.


val DATA_WAIT_FOR_FUNDING_CONFIRMED_COMPAT_08_Codec: Codec[DATA_WAIT_FOR_FUNDING_CONFIRMED] = DATA_WAIT_FOR_FUNDING_CONFIRMED_Codec(false)

val DATA_WAIT_FOR_FUNDING_CONFIRMED_11_Codec: Codec[DATA_WAIT_FOR_FUNDING_CONFIRMED] = DATA_WAIT_FOR_FUNDING_CONFIRMED_Codec(false)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this one be true?

assert(htlcCodec.decodeValue(htlcCodec.encode(htlc2).require).require === htlc2)
assert(htlcCodec(false).decodeValue(htlcCodec(false).encode(htlc1).require).require === htlc1)
assert(htlcCodec(false).decodeValue(htlcCodec(false).encode(htlc2).require).require === htlc2)
assert(htlcCodec(true).decodeValue(htlcCodec(true).encode(htlc2).require).require === htlc2)
Copy link
Member

Choose a reason for hiding this comment

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

it should be htlc1 here

@pm47
Copy link
Member Author

pm47 commented Jun 29, 2020

Superseded by #1442.

@pm47 pm47 closed this Jun 29, 2020
@t-bast t-bast deleted the length-prefix-codec branch August 11, 2020 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants