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

lncli: Added support for backup/verify/restore of single chanpoint to/from file #7437

Merged

Conversation

ardevd
Copy link
Contributor

@ardevd ardevd commented Feb 21, 2023

Added support for backup/verify/restore of a single chanpoint to file.

Fixes #7436

Change Description

Previously, specifying both a chan_point and a output file to write the backup to resulted in the output file argument being ignored and json output to be written to the console. Effectively discarding the desire to write to file.

Also, there was no way to restore a single channel from a file nor was there a way to verify such backups.

Steps to Test

lncli exportchanbackup <chan_point> --output_file <filename>
lncli verifychanbackup --single_file <filename> lncli restorechanbackup --single_file `

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

@ardevd
Copy link
Contributor Author

ardevd commented Feb 21, 2023

Someone should figure out whether this change makes sense. It seems to me that backup restoration currently does not support restoring a single chan_point from file. Whether this design is intentional is unknown to me.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. Looks good, just one nit. And you're right, it doesn't look like you can specify a single file when restoring just yet. Maybe it would make sense to add a --single_file flag to the restorechanbackup command as well in this PR?

cmd/lncli/commands.go Outdated Show resolved Hide resolved
@ardevd
Copy link
Contributor Author

ardevd commented Feb 21, 2023

Agreed! I'll look at implementing the restore part as well. Thanks.

@ardevd ardevd changed the title Draft: fix(lncli): Write to file for chan_point backups. Draft: fix(lncli): Added support for backup/verify/restore of single chanpoints to/from file Feb 22, 2023
@ardevd ardevd changed the title Draft: fix(lncli): Added support for backup/verify/restore of single chanpoints to/from file Draft: fix(lncli): Added support for backup/verify/restore of single chanpoint to/from file Feb 22, 2023
@ardevd ardevd changed the title Draft: fix(lncli): Added support for backup/verify/restore of single chanpoint to/from file fix(lncli): Added support for backup/verify/restore of single chanpoint to/from file Feb 22, 2023
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Code looks good, thanks. Please take a look at the pull request check list and contribution guideline about commit structure and naming as well as other requirements (like running the linter).

cmd/lncli/commands.go Outdated Show resolved Hide resolved
cmd/lncli/commands.go Outdated Show resolved Hide resolved
@ardevd ardevd changed the title fix(lncli): Added support for backup/verify/restore of single chanpoint to/from file lncli: Added support for backup/verify/restore of single chanpoint to/from file Feb 25, 2023
@ardevd
Copy link
Contributor Author

ardevd commented Feb 25, 2023

@guggero Should I add an entry in release notes myself in this merge request?

@guggero
Copy link
Collaborator

guggero commented Feb 27, 2023

@guggero Should I add an entry in release notes myself in this merge request?

Yes. You can add a new file docs/release-notes/release-notes-0.16.1.md since this PR won't make it into 0.16.0 as the RC just dropped last week.

@ardevd
Copy link
Contributor Author

ardevd commented Mar 1, 2023

Not entirely sure why the CI is failing. Anything I can do to fix it?

Copy link
Collaborator

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Not entirely sure why the CI is failing. Anything I can do to fix it?

There are known flakes that are under investigation so we'll see what's failed exactly. Meanwhile the linter should not fail tho, plus you may want to squash and clean your commit messages a bit.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Can you rebase and squash the commits into a single one for the changes in cmd/lncli and one for the release notes please?


* A single channel packed SCB, which can be obtained from
exportchanbackup. This should be passed in hex encoded format.

* A packed multi-channel SCB, which couples several individual
static channel backups in single blob.

* A file path which points to a packed single-channel backup within a
file, using the same format that lnd does in its channel.backup file.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line is longer than 80 characters (when using 8 spaces for the tab character in your editor), that's why the linter is complaining.

@ardevd ardevd force-pushed the 7436-chanbackup-writer-fix branch 3 times, most recently from ee28e33 to e118289 Compare March 1, 2023 21:17
@ardevd
Copy link
Contributor Author

ardevd commented Mar 1, 2023

Rebased and squashed!

@guggero guggero self-requested a review March 1, 2023 22:20
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

tACK, LGTM 🎉

This will need to wait with being merged until after 0.16.0 final is out.

@guggero guggero added this to the v0.16.1 milestone Mar 6, 2023
@saubyk saubyk changed the base branch from master to 0-16-1-staging March 16, 2023 15:25
@guggero
Copy link
Collaborator

guggero commented Mar 17, 2023

@ardevd can you rebase this on top of the 0-16-1-staging branch please? Then we can get it merged.

@ardevd ardevd force-pushed the 7436-chanbackup-writer-fix branch from 318b6f2 to 0756093 Compare March 17, 2023 19:26
@ardevd
Copy link
Contributor Author

ardevd commented Mar 17, 2023

Rebased now, but conflicts with release notes.

@guggero
Copy link
Collaborator

guggero commented Mar 18, 2023

Yes, can you resolve the conflict? When doing git rebase you should be given a file that contains both versions and then you can edit the way it should be resolved. Or your IDE should present you some kind of merge conflict resolution window.

@ardevd
Copy link
Contributor Author

ardevd commented Mar 20, 2023

Should be good to go.

@guggero
Copy link
Collaborator

guggero commented Mar 20, 2023

No, it looks like you merged the target branch into yours. Instead you should rebase your branch on top of 0-16-1-staging.

author ardevd <edvard.holst@gmail.com> 1676983861 +0100
committer ardevd <ardevd@users.noreply.github.com> 1677705118 +0100

Write to the specified file if the user specifies a chan_point for
backup and also specifies an output file to write the backup to.

Fixes lightningnetwork#7436
@ardevd ardevd force-pushed the 7436-chanbackup-writer-fix branch from c5db55d to d1f961c Compare March 25, 2023 14:32
@ardevd
Copy link
Contributor Author

ardevd commented Mar 25, 2023

@guggero should be good to go now

@guggero
Copy link
Collaborator

guggero commented Mar 27, 2023

Looks good, thanks a lot, @ardevd. Integration test failures are flakes, as this is a CLI change only.

@guggero guggero merged commit 5272e91 into lightningnetwork:0-16-1-staging Mar 27, 2023
@ardevd ardevd deleted the 7436-chanbackup-writer-fix branch March 27, 2023 10:20
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.

[bug]: exportchanbackup --output_file argument does nothing when chanpoint is provided
3 participants