From d822d75f00512ae8fec00ab4c006ce1d3e252bfe Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 17 Jul 2023 12:53:27 +0200 Subject: [PATCH] server+funding: remove previous link update mechanism Because we now send the correct initial forwarding policy to Brontide, the correct initial values are inserted into the link and we no longer need to update the link in a later step. --- funding/manager.go | 27 ------------------------ funding/manager_test.go | 46 +++++------------------------------------ server.go | 5 ++--- 3 files changed, 7 insertions(+), 71 deletions(-) diff --git a/funding/manager.go b/funding/manager.go index edd6b5f5f..3701cff7a 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -516,11 +516,6 @@ type Config struct { // transition from pending open to open. NotifyOpenChannelEvent func(wire.OutPoint) - // UpdateForwardingPolicies is used by the manager to update active - // links with a new policy. - UpdateForwardingPolicies func( - chanPolicies map[wire.OutPoint]models.ForwardingPolicy) - // OpenChannelPredicate is a predicate on the lnwire.OpenChannel message // and on the requesting node's public key that returns a bool which // tells the funding manager whether or not to accept the channel. @@ -3246,28 +3241,6 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel, return ErrFundingManagerShuttingDown } - // The user can define non-default channel policies when opening a - // channel. They are stored in the database to be persisted from the - // moment of funding the channel to it being confirmed. We just - // announced those policies to the network, but we also need to update - // our local policy in the switch to make sure we can forward payments - // with the correct fees. We can't do this when creating the link - // initially as that only takes the static channel parameters. - updatedPolicy := map[wire.OutPoint]models.ForwardingPolicy{ - completeChan.FundingOutpoint: { - MinHTLCOut: ann.chanUpdateAnn.HtlcMinimumMsat, - MaxHTLC: ann.chanUpdateAnn.HtlcMaximumMsat, - BaseFee: lnwire.MilliSatoshi( - ann.chanUpdateAnn.BaseFee, - ), - FeeRate: lnwire.MilliSatoshi( - ann.chanUpdateAnn.FeeRate, - ), - TimeLockDelta: uint32(ann.chanUpdateAnn.TimeLockDelta), - }, - } - f.cfg.UpdateForwardingPolicies(updatedPolicy) - return nil } diff --git a/funding/manager_test.go b/funding/manager_test.go index c1fc17a81..685d49f20 100644 --- a/funding/manager_test.go +++ b/funding/manager_test.go @@ -252,7 +252,6 @@ type testNode struct { testDir string shutdownChannel chan struct{} reportScidChan chan struct{} - updatedPolicies chan map[wire.OutPoint]models.ForwardingPolicy localFeatures []lnwire.FeatureBit remoteFeatures []lnwire.FeatureBit @@ -381,9 +380,6 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, publTxChan := make(chan *wire.MsgTx, 1) shutdownChan := make(chan struct{}) reportScidChan := make(chan struct{}) - updatedPolicies := make( - chan map[wire.OutPoint]models.ForwardingPolicy, 1, - ) wc := &mock.WalletController{ RootKey: alicePrivKey, @@ -541,11 +537,6 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, return nil, nil }, AliasManager: aliasMgr, - UpdateForwardingPolicies: func( - p map[wire.OutPoint]models.ForwardingPolicy) { - - updatedPolicies <- p - }, } for _, op := range options { @@ -570,7 +561,6 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, testDir: tempTestDir, shutdownChannel: shutdownChan, reportScidChan: reportScidChan, - updatedPolicies: updatedPolicies, addr: addr, } @@ -651,12 +641,11 @@ func recreateAliceFundingManager(t *testing.T, alice *testNode) { UpdateLabel: func(chainhash.Hash, string) error { return nil }, - ZombieSweeperInterval: oldCfg.ZombieSweeperInterval, - ReservationTimeout: oldCfg.ReservationTimeout, - OpenChannelPredicate: chainedAcceptor, - DeleteAliasEdge: oldCfg.DeleteAliasEdge, - AliasManager: oldCfg.AliasManager, - UpdateForwardingPolicies: oldCfg.UpdateForwardingPolicies, + ZombieSweeperInterval: oldCfg.ZombieSweeperInterval, + ReservationTimeout: oldCfg.ReservationTimeout, + OpenChannelPredicate: chainedAcceptor, + DeleteAliasEdge: oldCfg.DeleteAliasEdge, + AliasManager: oldCfg.AliasManager, }) require.NoError(t, err, "failed recreating aliceFundingManager") @@ -1145,21 +1134,6 @@ func assertChannelAnnouncements(t *testing.T, alice, bob *testNode, } } - // At this point we should also have gotten a policy update that - // was sent to the switch subsystem. Make sure it contains the - // same values. - var policyUpdate models.ForwardingPolicy - select { - case policyUpdateMap := <-node.updatedPolicies: - require.Len(t, policyUpdateMap, 1) - for _, policy := range policyUpdateMap { - policyUpdate = policy - } - - case <-time.After(time.Second * 5): - t.Fatalf("node didn't send policy update") - } - gotChannelAnnouncement := false gotChannelUpdate := false for _, msg := range announcements { @@ -1188,34 +1162,24 @@ func assertChannelAnnouncements(t *testing.T, alice, bob *testNode, minHtlc = customMinHtlc[j] } require.Equal(t, minHtlc, m.HtlcMinimumMsat) - require.Equal( - t, minHtlc, policyUpdate.MinHTLCOut, - ) // We might expect a custom MaxHltc value. if len(customMaxHtlc) > 0 { maxHtlc = customMaxHtlc[j] } require.Equal(t, maxHtlc, m.HtlcMaximumMsat) - require.Equal(t, maxHtlc, policyUpdate.MaxHTLC) // We might expect a custom baseFee value. if len(baseFees) > 0 { baseFee = baseFees[j] } require.EqualValues(t, baseFee, m.BaseFee) - require.EqualValues( - t, baseFee, policyUpdate.BaseFee, - ) // We might expect a custom feeRate value. if len(feeRates) > 0 { feeRate = feeRates[j] } require.EqualValues(t, feeRate, m.FeeRate) - require.EqualValues( - t, feeRate, policyUpdate.FeeRate, - ) gotChannelUpdate = true } diff --git a/server.go b/server.go index ff8738edf..206ab43f1 100644 --- a/server.go +++ b/server.go @@ -1459,9 +1459,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr, RegisteredChains: cfg.registeredChains, MaxAnchorsCommitFeeRate: chainfee.SatPerKVByte( s.cfg.MaxCommitFeeRateAnchors * 1000).FeePerKWeight(), - DeleteAliasEdge: deleteAliasEdge, - AliasManager: s.aliasMgr, - UpdateForwardingPolicies: s.htlcSwitch.UpdateForwardingPolicies, + DeleteAliasEdge: deleteAliasEdge, + AliasManager: s.aliasMgr, }) if err != nil { return nil, err