-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[1/?] Local reputation: subsystem core, read only #10919
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
Open
GeorgeTsagk
wants to merge
6
commits into
lightningnetwork:master
Choose a base branch
from
GeorgeTsagk:local-reputation-subsystem
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ee7988
reputation: add decaying average and revenue aggregation
GeorgeTsagk fd439cc
reputation: add HTLC fee and reputation scoring
GeorgeTsagk 78bd595
reputation: add the reputation manager
GeorgeTsagk 8915d22
htlcswitch+lnd: connect reputation manager to the switch
GeorgeTsagk 1fe2ffa
itest: test the local reputation subsystem end-to-end
GeorgeTsagk a79ffec
docs: add release note for the local reputation subsystem
GeorgeTsagk 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package htlcswitch | ||
|
|
||
| import ( | ||
| "github.com/lightningnetwork/lnd/lnwire" | ||
| ) | ||
|
|
||
| // guardedReputationManager wraps a ReputationManager so that a panic in any of | ||
| // its hooks can never propagate into the switch's forwarding goroutine. The | ||
| // reputation subsystem is log-only and MUST NOT be able to degrade forwarding; | ||
| // if a hook panics we log it and carry on forwarding. | ||
| // | ||
| // The hooks run synchronously on the switch's forwarding goroutine, so this | ||
| // boundary keeps a subsystem bug, such as a nil deref or an arithmetic panic, | ||
| // from taking down the node's HTLC forwarding. | ||
| type guardedReputationManager struct { | ||
| inner ReputationManager | ||
| } | ||
|
|
||
| // NewGuardedReputationManager wraps the given ReputationManager with a panic | ||
| // boundary. It returns nil when inner is nil, so the switch's existing nil | ||
| // check still short-circuits a disabled subsystem with zero overhead. | ||
| func NewGuardedReputationManager(inner ReputationManager) ReputationManager { | ||
| if inner == nil { | ||
| return nil | ||
| } | ||
|
|
||
| return &guardedReputationManager{inner: inner} | ||
| } | ||
|
|
||
| // OnForward forwards the observation to the wrapped manager behind a panic | ||
| // boundary. | ||
| func (g *guardedReputationManager) OnForward(incoming CircuitKey, | ||
| outgoing lnwire.ShortChannelID, incomingAmt, outgoingAmt, | ||
| advertisedFee lnwire.MilliSatoshi, incomingCltv, height uint32, | ||
| accountable bool) { | ||
|
|
||
| defer g.recoverHook("OnForward") | ||
|
|
||
| g.inner.OnForward( | ||
| incoming, outgoing, incomingAmt, outgoingAmt, advertisedFee, | ||
| incomingCltv, height, accountable, | ||
| ) | ||
| } | ||
|
|
||
| // OnSettle forwards the observation to the wrapped manager behind a panic | ||
| // boundary. | ||
| func (g *guardedReputationManager) OnSettle(incoming CircuitKey) { | ||
| defer g.recoverHook("OnSettle") | ||
|
|
||
| g.inner.OnSettle(incoming) | ||
| } | ||
|
|
||
| // OnFail forwards the observation to the wrapped manager behind a panic | ||
| // boundary. | ||
| func (g *guardedReputationManager) OnFail(incoming CircuitKey) { | ||
| defer g.recoverHook("OnFail") | ||
|
|
||
| g.inner.OnFail(incoming) | ||
| } | ||
|
|
||
| // recoverHook recovers from a panic in a reputation hook and logs it, so that a | ||
| // bug in the log-only subsystem cannot affect forwarding. | ||
| func (g *guardedReputationManager) recoverHook(method string) { | ||
| if r := recover(); r != nil { | ||
| log.Errorf("Reputation %s hook panicked (forwarding is "+ | ||
| "unaffected): %v", method, r) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.