-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
multi: log additional information for local force closures #8072
Open
Chinwendu20
wants to merge
7
commits into
lightningnetwork:master
Choose a base branch
from
Chinwendu20:forcetemp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
844681d
cnct + channeldb: create LocalForceCloseInitiator
shaurya947 c60ea99
multi: specify local force close initator using functional options
shaurya947 b22d72d
cnct + channeldb: Log local force close chain actions.
Chinwendu20 e67dabd
multi: persist and fetch Force Close insights in channel
Chinwendu20 6824a82
rpc: Local force close insights added to lightning proto.
shaurya947 6fc6915
itest: update itest for local force close insights
shaurya947 65e7d6a
docs: add release notes for 0.18.0
shaurya947 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3252,6 +3252,96 @@ const ( | |
Abandoned ClosureType = 5 | ||
) | ||
|
||
// LocalForceCloseInitiator is a type that gives information about what led to a | ||
// channel being force closed locally. | ||
type LocalForceCloseInitiator string | ||
|
||
const ( | ||
// UserInitiated indicates that the force close was specifically | ||
// initiated by the user. | ||
UserInitiated LocalForceCloseInitiator = "user initiated" | ||
|
||
// ChainActionsInitiated indicates that the force close was | ||
// automatically initiated by an on-chain trigger such as HTLC timeout. | ||
ChainActionsInitiated LocalForceCloseInitiator = "chain action" + | ||
" initiated" | ||
|
||
// localForceCloseInitiatorType is used to serialize/deserialize | ||
// localForceCloseInitiator. | ||
localForceCloseInitiatorType tlv.Type = 0 | ||
) | ||
|
||
// String returns the human-readable format of the LocalForceCloseInitiator. | ||
func (l *LocalForceCloseInitiator) String() string { | ||
return string(*l) | ||
} | ||
|
||
// SerializeLocalForceCloseInitiator writes out the passed set of | ||
// LocalForceCloseInitiator to the passed writer. | ||
func SerializeLocalForceCloseInitiator(w io.Writer, | ||
lc *LocalForceCloseInitiator) error { | ||
|
||
localForceCloseReasonByte := []byte(*lc) | ||
|
||
tlvStream, err := tlv.NewStream( | ||
tlv.MakePrimitiveRecord(localForceCloseInitiatorType, | ||
&localForceCloseReasonByte), | ||
) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
var b bytes.Buffer | ||
err = tlvStream.Encode(&b) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = binary.Write(w, byteOrder, uint64(b.Len())) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if _, err = w.Write(b.Bytes()); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// DeserializeLocalForceCloseInitiator reads out the ForceCloseInitiator from | ||
// the reader. | ||
func DeserializeLocalForceCloseInitiator(r io.Reader) (LocalForceCloseInitiator, | ||
error) { | ||
|
||
var ( | ||
lc []byte | ||
) | ||
|
||
tlvStream, err := tlv.NewStream( | ||
tlv.MakePrimitiveRecord( | ||
localForceCloseInitiatorType, &lc, | ||
), | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for the newline? |
||
if err != nil { | ||
return LocalForceCloseInitiator(lc), err | ||
} | ||
|
||
var bodyLen int64 | ||
err = binary.Read(r, byteOrder, &bodyLen) | ||
if err != nil { | ||
return LocalForceCloseInitiator(lc), err | ||
} | ||
|
||
lr := io.LimitReader(r, bodyLen) | ||
if err = tlvStream.Decode(lr); err != nil { | ||
return LocalForceCloseInitiator(lc), err | ||
} | ||
|
||
return LocalForceCloseInitiator(lc), nil | ||
} | ||
|
||
// ChannelCloseSummary contains the final state of a channel at the point it | ||
// was closed. Once a channel is closed, all the information pertaining to that | ||
// channel within the openChannelBucket is deleted, and a compact summary is | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should use
uint8
plus aString
method to make this more space-efficient, something likelnd/feature/set.go
Lines 49 to 64 in 0df507e
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.
Also this should be called
ForceCloseInitiator
?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.
Also, my intial approach was to do just as you have stated concerning making it
unit8
instead of astring
but that would mean, creating a LocalForceCloseInitiator type for each of the LinkFailureError messages. Making the initiator a string, I can easily convert any link failure error message to the LocalForceCloseInitiator on the go instead of duplicating all the LinkFailure error message type the channel.go file.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.
Ref:
lnd/htlcswitch/failure.go
Lines 30 to 39 in 0df507e
LinkError
type.