The results of Summer of Bitcoin were declared the previous week and I am really excited to announce that my proposal was accepted by LDK. I will be continuing the project which I started last year titled Integrating LDK into the Lnprototest test suite
About the Project
This project aims at Integrating LDK into the Lnprototest test suite and ensuring that this lightning implementation follows all the BOLT protocols.
Progress made during Summer of Bitcoin 2022
- Implementing
features.rs
in LDK-Sample. This file simply displays the features of LDK-Sample node. These features are then used by theldk.py
script inside Lnprototest. - Adding an exit function in LDK-Sample. Having an exit function ensures that the port used by LDK-Sample is unoccupied after the node is exited and can be used for other purposes.
- Implementing
myKeysManager
struct in LDK-Sample. This struct manages the node secrets and uses akey_seed
to generate different keys. The advantage of using this instead of the defaultKeysManager
is that it allows me to use my own set of channel secrets(funding_key, revocation_base_key, payment_key, delayed_payment_base_key, htlc_base_key) instead of the randomly generated ones. This was useful for setting up the configuration required by Lnprototest. - Implementing
KeysInterface
trait for themyKeysManager
struct. This was essential formyKeysManager
as it has a lot of useful methods. - Implementing
openchannel_test
method in LDK-Sample. This method allows opening a fundchannel without providing the host or port. - Adding the
ldk.py
script inside Lnprototest. This script does all the heavy lifting in the integration process. - Implementing the
LDKConn
class inside the script. This class is used to connect to the node usingpyln.proto.wire
module and intercept all the messages that the node initiates and receives. - Implementing the
LDK Runner
class. This class contains all the functions used to start/stop bitcoind, start/stop LDK-Sample node, adding a connection, connecting to a peer, carrying out transactions, receiving output messages etc. The tests are run against this class and it basically tells the node to do a particular task(like connecting to a peer) and theLDKConn
class intercepts the messages sent by the node.
Week 1 and 2
I started working on the project and discovered that both LDK-Sample and Lnprototest repos were updated. On updating my forks, I found out that LDK-Sample now uses Lightning crate version 0.0.115
instead of 0.0.108
. This meant that I had to make a lot of changes to make it work. This involved:
- Removing
features.rs
as theFeatures::known()
method was deprecated. After discussion with the devs, I am now usinglightning_msg_handler.chan_handler.provided_init_features()
method to display the features. - Reimplementing
myKeysManager
as a lot of traits and methods changed. - Implementing various methods and structs as a lot of methods used in
KeysManager
were private.
After all the bugs from my LDK-Sample were removed and my custom channel secrets were added, LDK-Sample was built and it ran successfully.
I then started the testing phase. The bug I had opened last year in Lnprototest was fixed by Vincenzo. After encountering some minor errors and tweaking some things in my LDK script, I was able to pass all the BOLT #1 tests. These included:
- test_namespace_override
- test_echo_init
- test_init_check_received_msg
- test_init_invalid_globalfeatures
- test_init_is_first_msg
- test_init_check_free_featurebits
- test_init_fail_connection_if_receive_an_even_unknown_featurebits
- test_init_fail_connection_if_receive_an_even_unknown_globalfeaturebits
- test_init_fail_ask_for_option_data_loss_protect
- test_init_advertize_option_data_loss_protect
- test_init_required_option_data_loss_protect
- test_init_reject_option_data_loss_protect_if_not_supported
- test_init_advertize_option_anchor_outputs
- test_init_required_option_anchor_outputs
- test_init_advertize_option_static_remotekey
- test_unknowns
Now I will start working on the BOLT2 tests.