From f02bb58486c0f73589c04d192356a2b7ab167c79 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Wed, 22 May 2024 09:17:58 -0400 Subject: [PATCH] multi: add experimental endorsement feature bit and disable option --- feature/default_sets.go | 3 +++ feature/manager.go | 10 ++++++++++ lncfg/protocol.go | 9 +++++++++ lncfg/protocol_integration.go | 9 +++++++++ lnwire/features.go | 10 ++++++++++ rpcserver.go | 4 ++++ sample-lnd.conf | 3 +++ server.go | 31 ++++++++++++++++++------------- 8 files changed, 66 insertions(+), 13 deletions(-) diff --git a/feature/default_sets.go b/feature/default_sets.go index 4a9b2bf64..616abc8ba 100644 --- a/feature/default_sets.go +++ b/feature/default_sets.go @@ -96,4 +96,7 @@ var defaultSetDesc = setDesc{ SetInit: {}, // I SetNodeAnn: {}, // N }, + lnwire.ExperimentalEndorsementOptional: { + SetNodeAnn: {}, // N + }, } diff --git a/feature/manager.go b/feature/manager.go index 89f1d4b6b..e0bcfc96b 100644 --- a/feature/manager.go +++ b/feature/manager.go @@ -66,6 +66,10 @@ type Config struct { // NoTaprootOverlay unsets the taproot overlay channel feature bits. NoTaprootOverlay bool + // NoExperimentalEndorsement unsets any bits that signal support for + // forwarding experimental endorsement. + NoExperimentalEndorsement bool + // CustomFeatures is a set of custom features to advertise in each // set. CustomFeatures map[Set][]lnwire.FeatureBit @@ -199,6 +203,12 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) { raw.Unset(lnwire.SimpleTaprootOverlayChansOptional) raw.Unset(lnwire.SimpleTaprootOverlayChansRequired) } + + if cfg.NoExperimentalEndorsement { + raw.Unset(lnwire.ExperimentalEndorsementOptional) + raw.Unset(lnwire.ExperimentalEndorsementRequired) + } + for _, custom := range cfg.CustomFeatures[set] { if custom > set.Maximum() { return nil, fmt.Errorf("feature bit: %v "+ diff --git a/lncfg/protocol.go b/lncfg/protocol.go index c670b1894..80809f49d 100644 --- a/lncfg/protocol.go +++ b/lncfg/protocol.go @@ -67,6 +67,9 @@ type ProtocolOptions struct { // NoRouteBlindingOption disables forwarding of payments in blinded routes. NoRouteBlindingOption bool `long:"no-route-blinding" description:"do not forward payments that are a part of a blinded route"` + // NoExperimentalEndorsementOption disables experimental endorsement. + NoExperimentalEndorsementOption bool `long:"no-experimental-endorsement" description:"do not forward experimental endorsement signals"` + // CustomMessage allows the custom message APIs to handle messages with // the provided protocol numbers, which fall outside the custom message // number range. @@ -132,6 +135,12 @@ func (l *ProtocolOptions) NoRouteBlinding() bool { return l.NoRouteBlindingOption } +// NoExperimentalEndorsement returns true if experimental endorsement should +// be disabled. +func (l *ProtocolOptions) NoExperimentalEndorsement() bool { + return l.NoExperimentalEndorsementOption +} + // CustomMessageOverrides returns the set of protocol messages that we override // to allow custom handling. func (p ProtocolOptions) CustomMessageOverrides() []uint16 { diff --git a/lncfg/protocol_integration.go b/lncfg/protocol_integration.go index 5c5150a0e..52cc658c3 100644 --- a/lncfg/protocol_integration.go +++ b/lncfg/protocol_integration.go @@ -70,6 +70,9 @@ type ProtocolOptions struct { // NoRouteBlindingOption disables forwarding of payments in blinded routes. NoRouteBlindingOption bool `long:"no-route-blinding" description:"do not forward payments that are a part of a blinded route"` + // NoExperimentalEndorsementOption disables experimental endorsement. + NoExperimentalEndorsementOption bool `long:"no-experimental-endorsement" description:"do not forward experimental endorsement signals"` + // CustomMessage allows the custom message APIs to handle messages with // the provided protocol numbers, which fall outside the custom message // number range. @@ -127,6 +130,12 @@ func (l *ProtocolOptions) NoRouteBlinding() bool { return l.NoRouteBlindingOption } +// NoExperimentalEndorsement returns true if experimental endorsement should +// be disabled. +func (l *ProtocolOptions) NoExperimentalEndorsement() bool { + return l.NoExperimentalEndorsementOption +} + // CustomMessageOverrides returns the set of protocol messages that we override // to allow custom handling. func (l ProtocolOptions) CustomMessageOverrides() []uint16 { diff --git a/lnwire/features.go b/lnwire/features.go index c597b0398..bc6204f42 100644 --- a/lnwire/features.go +++ b/lnwire/features.go @@ -263,6 +263,14 @@ const ( // being finalized. SimpleTaprootChannelsOptionalStaging = 181 + // ExperimentalEndorsementRequired is a required feature bit that + // indicates that the node will relay experimental endorsement signals. + ExperimentalEndorsementRequired FeatureBit = 260 + + // ExperimentalEndorsementOptional is an optional feature bit that + // indicates that the node will relay experimental endorsement signals. + ExperimentalEndorsementOptional FeatureBit = 261 + // Bolt11BlindedPathsRequired is a required feature bit that indicates // that the node is able to understand the blinded path tagged field in // a BOLT 11 invoice. @@ -349,6 +357,8 @@ var Features = map[FeatureBit]string{ SimpleTaprootChannelsOptionalStaging: "simple-taproot-chans-x", SimpleTaprootOverlayChansOptional: "taproot-overlay-chans", SimpleTaprootOverlayChansRequired: "taproot-overlay-chans", + ExperimentalEndorsementRequired: "endorsement-x", + ExperimentalEndorsementOptional: "endorsement-x", Bolt11BlindedPathsOptional: "bolt-11-blinded-paths", Bolt11BlindedPathsRequired: "bolt-11-blinded-paths", } diff --git a/rpcserver.go b/rpcserver.go index 60433be24..4c593d857 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -760,6 +760,10 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service, return nil }, ShouldSetExpEndorsement: func() bool { + if s.cfg.ProtocolOptions.NoExperimentalEndorsement() { + return false + } + return clock.NewDefaultClock().Now().Before( EndorsementExperimentEnd, ) diff --git a/sample-lnd.conf b/sample-lnd.conf index 6af5e4b57..4d3da3779 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -1399,6 +1399,9 @@ ; Set to disable blinded route forwarding. ; protocol.no-route-blinding=false +; Set to disable experimental endorsement signaling. +; protocol.no-experimental-endorsement=false + ; Set to handle messages of a particular type that falls outside of the ; custom message number range (i.e. 513 is onion messages). Note that you can ; set this option as many times as you want to support more than one custom diff --git a/server.go b/server.go index a66609332..6f263a4c2 100644 --- a/server.go +++ b/server.go @@ -573,19 +573,20 @@ func newServer(cfg *Config, listenAddrs []net.Addr, //nolint:lll featureMgr, err := feature.NewManager(feature.Config{ - NoTLVOnion: cfg.ProtocolOptions.LegacyOnion(), - NoStaticRemoteKey: cfg.ProtocolOptions.NoStaticRemoteKey(), - NoAnchors: cfg.ProtocolOptions.NoAnchorCommitments(), - NoWumbo: !cfg.ProtocolOptions.Wumbo(), - NoScriptEnforcementLease: cfg.ProtocolOptions.NoScriptEnforcementLease(), - NoKeysend: !cfg.AcceptKeySend, - NoOptionScidAlias: !cfg.ProtocolOptions.ScidAlias(), - NoZeroConf: !cfg.ProtocolOptions.ZeroConf(), - NoAnySegwit: cfg.ProtocolOptions.NoAnySegwit(), - CustomFeatures: cfg.ProtocolOptions.CustomFeatures(), - NoTaprootChans: !cfg.ProtocolOptions.TaprootChans, - NoTaprootOverlay: !cfg.ProtocolOptions.TaprootOverlayChans, - NoRouteBlinding: cfg.ProtocolOptions.NoRouteBlinding(), + NoTLVOnion: cfg.ProtocolOptions.LegacyOnion(), + NoStaticRemoteKey: cfg.ProtocolOptions.NoStaticRemoteKey(), + NoAnchors: cfg.ProtocolOptions.NoAnchorCommitments(), + NoWumbo: !cfg.ProtocolOptions.Wumbo(), + NoScriptEnforcementLease: cfg.ProtocolOptions.NoScriptEnforcementLease(), + NoKeysend: !cfg.AcceptKeySend, + NoOptionScidAlias: !cfg.ProtocolOptions.ScidAlias(), + NoZeroConf: !cfg.ProtocolOptions.ZeroConf(), + NoAnySegwit: cfg.ProtocolOptions.NoAnySegwit(), + CustomFeatures: cfg.ProtocolOptions.CustomFeatures(), + NoTaprootChans: !cfg.ProtocolOptions.TaprootChans, + NoTaprootOverlay: !cfg.ProtocolOptions.TaprootOverlayChans, + NoRouteBlinding: cfg.ProtocolOptions.NoRouteBlinding(), + NoExperimentalEndorsement: cfg.ProtocolOptions.NoExperimentalEndorsement(), }) if err != nil { return nil, err @@ -4221,6 +4222,10 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, AuxChanCloser: s.implCfg.AuxChanCloser, AuxResolver: s.implCfg.AuxContractResolver, ShouldFwdExpEndorsement: func() bool { + if s.cfg.ProtocolOptions.NoExperimentalEndorsement() { + return false + } + return clock.NewDefaultClock().Now().Before( EndorsementExperimentEnd, )