chancloser: RBF coop close fails for channels without our policy in the graph
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- networking
Direzione di ricerca
Inizia da lnwallet/chancloser/rbf_coop_transitions.go, dove gli errori di DisableChannel impediscono al closer RBF di inviare shutdown, e confrontalo con il comportamento legacy in lnwallet/chancloser/chancloser.go. Esamina la logica dello stato del canale in netann/chan_status_manager.go e aggiungi o adatta il riproduttore in lnwallet/chancloser/rbf_disable_channel_test.go. Il lavoro è completo quando una policy del grafo mancante viene registrata come avviso mentre il closer prosegue verso lo stato di shutdown sia per gli eventi di shutdown locali sia per quelli remoti; esegui go test ./lnwallet/chancloser -run TestRbfShutdownDisableChannelFails -count=1.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The RBF closer aborts the close if it can't send a disabling channel_update for the channel. The legacy closer only logs a warning:
DisableChannel re-signs our latest channel_update from the graph, so it fails for any channel that has no policy of ours there (edge not found, or ErrUnableToExtractChanUpdate if the edge exists but our policy doesn't):
The state machine then stops without sending shutdown, and chanErrorReporter sends the peer an error for the channel:
Here is a replay where the peer sends shutdown right after channel_ready:
[INF] CHCL: ChannelPoint(4b72185c...f59c:0): received shutdown msg
[INF] CHCL: ChannelPoint(4b72185c...f59c:0): sending shutdown msg at next clean commit state
[ERR] PEER: Peer(034f355b...71aa): coop close error for channel 9cf511b3...724b: unable to disable channel: edge not found: op=4b72185c...f59c:0
[DBG] PEER: Peer(034f355b...71aa): Sending Error(chan_id=9cf511b3...724b, err=unable to disable channel: edge not found: op=4b72185c...f59c:0) ...
An open channel can be missing our policy:
- For ~1s after every open. The link and the RBF closer start when the peer's
channel_readyarrives, but the funding manager checks for it only once per second before callingaddToGraph:
https://github.com/lightningnetwork/lnd/blob/d5651c62990282fae6930e9e926b463bb74aaee0/funding/manager.go#L1293-L1308 - When
addToGraphfails. The channel stays inchannelReadySentwith its link up. This case was #11608 which should be fixed now by #11632. - "Under unknown circumstances", as the description of
updatechanpolicy --create_missing_edgesays:
https://github.com/lightningnetwork/lnd/blob/d5651c62990282fae6930e9e926b463bb74aaee0/lnrpc/lightning.proto#L4840-L4847
#9444 and #10585 may be examples of this case.
Impact
Low impact. Nodes that negotiate RBF coop close can't cooperatively close these channels when the policy is missing (rare). closechannel fails, and a peer's shutdown gets an error. The legacy closer works normally.
Reproducer
lnwallet/chancloser/rbf_disable_channel_test.go:
package chancloser
import (
"errors"
"testing"
"time"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/stretchr/testify/mock"
)
// TestRbfShutdownDisableChannelFails checks that the RBF closer still sends
// shutdown when it can't send a disabling channel_update, as the legacy closer
// does. DisableChannel fails for any channel that has no policy of ours in the
// graph, for example one whose funding flow stopped before addToGraph
// finished.
func TestRbfShutdownDisableChannelFails(t *testing.T) {
errNoEdge := errors.New("edge not found")
tests := []struct {
name string
event ProtocolEvent
local bool
}{
{
name: "local shutdown",
event: &SendShutdown{},
local: true,
},
{
name: "remote shutdown",
event: &ShutdownReceived{
ShutdownScript: remoteAddr,
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
ctx := t.Context()
h := newCloser(t, &harnessCfg{
localUpfrontAddr: fn.Some(localAddr),
})
defer h.stopAndAssert()
obs := h.chanObserver
obs.On("FinalBalances").Return(
fn.None[ShutdownBalances](),
)
obs.On("NoDanglingUpdates").Return(true).Maybe()
obs.On("DisableIncomingAdds").Return(nil).Maybe()
obs.On("DisableOutgoingAdds").Return(nil).Maybe()
obs.On(
"MarkShutdownSent", mock.Anything, tc.local,
).Return(nil).Maybe()
obs.On("DisableChannel").Return(errNoEdge)
h.daemonAdapters.On(
"SendMessages", mock.Anything, mock.Anything,
).Return(nil).Maybe()
h.errReporter.On("ReportError", mock.Anything).
Return().Maybe()
h.chanCloser.SendEvent(ctx, tc.event)
select {
case err := <-h.errReporter.errorReported:
t.Fatalf("shutdown failed: %v", err)
case state := <-h.stateSub.NewItemCreated.ChanOut():
if _, ok := state.(*ShutdownPending); !ok {
t.Fatalf("unexpected state %T", state)
}
case <-time.After(time.Second):
t.Fatalf("no state transition")
}
})
}
}
$ go test ./lnwallet/chancloser -run TestRbfShutdownDisableChannelFails -count=1
--- FAIL: TestRbfShutdownDisableChannelFails (0.02s)
--- FAIL: TestRbfShutdownDisableChannelFails/local_shutdown (0.01s)
rbf_disable_channel_test.go:68: shutdown failed: unable to disable channel: edge not found
--- FAIL: TestRbfShutdownDisableChannelFails/remote_shutdown (0.01s)
rbf_disable_channel_test.go:68: shutdown failed: unable to disable channel: edge not found
FAIL
Suggested fix
Do what the legacy closer does:
--- a/lnwallet/chancloser/rbf_coop_transitions.go
+++ b/lnwallet/chancloser/rbf_coop_transitions.go
@@ -103,10 +103,12 @@ func sendShutdownEvents(chanID lnwire.ChannelID, chanPoint wire.OutPoint,
// Before closing, we'll attempt to send a disable update for the
// channel. We do so before closing the channel as otherwise the
- // current edge policy won't be retrievable from the graph.
+ // current edge policy won't be retrievable from the graph. A channel
+ // without a policy of ours in the graph can't be disabled, but it can
+ // still be closed, so a failure here isn't fatal.
if err := chanState.DisableChannel(); err != nil {
- return nil, none, fmt.Errorf("unable to disable "+
- "channel: %w", err)
+ chancloserLog.Warnf("ChannelPoint(%v): unable to disable "+
+ "channel on close: %v", chanPoint, err)
}
// If we have a post-send event, then this means that we're the
Discovery
Found incidentally during LLM-assisted analysis of artifacts from a smite fuzzing campaign.
- Lingua principale
- Go
- Stelle
- 8.2k
- Fork
- 2.3k
- Merge medio
- 1g 11h
- PR unite (30g)
- 103
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lightningnetwork/lnd
-
funding: failure logs print `<nil>` error and zero channel IDForse già presa @litbot-9000 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
lightningnetwork/lnd#11676 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 85/100
lightningnetwork/lnd#11674 ·
I maintainer di solito rispondono entro 1 giorno
-
test flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
lightningnetwork/lnd#11663 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[flake]: lnwallet/test/bitcoind.TestLightningWalletBitcoindRPCPolling/spend_unconfirmed_outputsApertatest flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
lightningnetwork/lnd#11642 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
docker: pin the final alpine base imageForse di nuovo libera @danieldzansi l’ha presa 27 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
lightningnetwork/lnd#11437 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lightningnetwork/lnd
Issue simili
-
feat(arithmetization): update `arithmetization` to ZkC version `v1.2.38`Forse già presa @DavePearce l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
LFDT-Lineth/lineth-monorepo#4679 ·
I maintainer di solito rispondono entro 1 giorno
-
macOS: MixMusic stalls as the GPU times out drawing frames, and the media keys fail to register at every startForse già presa @fzn0x l’ha presa oggi. Apertabug priority: high
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
effort:s impact:low raised-by:reviewer risk:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
medici-finance/assay#8050 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
factory:subtask
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno