100 Commits
Author SHA1 Message Date
Keagan McClelland a72cadf2ed lnwire: convert DynPropose and DynCommit to use typed tlv records 2025-06-25 02:22:22 +08:00
Keagan McClelland 79e4e74447 lnwire: change DynPropose/DynCommit TLV numbers to align with spec 2025-06-25 02:09:08 +08:00
Keagan McClelland 72582d4acc lnwire: add HtlcMinimum to DynPropose and DynCommit 2025-06-25 02:08:58 +08:00
Keagan McClelland f40530e4f4 lnwire: remove FundingKey from DynPropose and DynCommit 2025-06-25 02:08:56 +08:00
Keagan McClelland cbca5b1152 lnwire: remove kickoff feerate from propose/commit 2025-06-25 02:08:22 +08:00
Keagan McClelland 36f53d74ab lnwire: add convenience functions for protocol validation 2025-06-25 02:06:16 +08:00
Keagan McClelland 60887ad3ef lnwire: add signature to DynAck 2025-06-25 01:10:49 +08:00
Keagan McClelland c6861770de lnwire: remove no longer used initiator field 2025-06-25 01:10:46 +08:00
Keagan McClelland ed2989ae33 multi: update to fn v2 2024-12-04 13:19:00 -07:00
Keagan McClelland debc43daf2 docs: add quiescence to release notes 2024-11-26 14:13:44 -07:00
Keagan McClelland 127e4fff28 htlcswitch: add logging to quiescer 2024-11-26 14:13:44 -07:00
Keagan McClelland ac0c24aa7b htlcswitch: don't pass pending update counts into quiescer
This change simplifies some of the quiescer responsibilities in
favor of making the link check whether or not it has a clean state
to be able to send or receive an stfu. This change was made on the
basis that the only use the quiescer makes of this information is
to assess that it is or is not zero. Further the difficulty of
checking this condition in the link is barely more burdensome than
selecting the proper information to pass to the quiescer anyway.
2024-11-26 14:13:43 -07:00
Keagan McClelland a4c49a88f1 htlcswitch: add quiescence timeout that is aborted by Resume 2024-11-26 14:13:43 -07:00
Keagan McClelland 111c9b05f3 htlcswitch+peer: allow the disabling of quiescence
Here we add a flag where we can disable quiescence. This will be used
in the case where the feature is not negotiated with our peer.
2024-11-26 14:13:39 -07:00
Keagan McClelland 48ee643c0d htlcswitch: implement noop quiescer
In this commit we implement a noop quiescer that we will use when
the feature hasn't been negotiated. This will make it far easier to
manage quiescence operations without having a number of if statements
in the link logic.
2024-11-26 13:52:54 -07:00
Keagan McClelland 5906ca2537 htlcswitch: add test for deferred processing remote adds when quiescent 2024-11-26 13:52:54 -07:00
Keagan McClelland 4fbab45a5f htlcswitch: defer processRemoteAdds when quiescent
In this commit we defer processRemoteAdds using a new mechanism on
the quiescer where we capture a closure that needs to be run. We
do this because we need to avoid the scenario where we send back
immediate resolutions to the newly added HTLCs when quiescent as
it is a protocol violation. It is not enough for us to simply defer
sending the messages since the purpose of quiescence itself is to
have well-defined and agreed upon channel state. If, for whatever
reason, the node (or connection) is restarted between when these
hooks are captured and when they are ultimately run, they will
be resolved by the resolveFwdPkgs logic when the link comes back
up.

In a future commit we will explicitly call the quiescer's resume
method when it is OK for htlc traffic to commence.
2024-11-26 13:52:53 -07:00
Keagan McClelland 77fd8c6a21 itest+lntest: add itest for Quiesce RPC method 2024-11-26 13:52:51 -07:00
Keagan McClelland 7255b7357c htlcswitch: implement InitStfu link operation 2024-11-26 13:51:57 -07:00
Keagan McClelland bca1516429 lnd: finish Quiesce implementation using new link op 2024-11-26 13:51:57 -07:00
Keagan McClelland 70e3804121 htlcswitch: add link operation for initiating quiescence 2024-11-26 13:51:57 -07:00
Keagan McClelland a085b59814 lnd: implement new Quiesce RPC with link operation stub 2024-11-26 13:51:57 -07:00
Keagan McClelland 99f5ca4018 lnrpc add new RPC 'Quiesce' to protobuf definitions 2024-11-26 13:51:57 -07:00
Keagan McClelland 7a5b55a473 lnwire: signal that we support quiescence 2024-11-26 13:51:56 -07:00
Keagan McClelland 6d30ab6c4f htlcswitch: drop connection if link updates after stfu 2024-11-26 13:51:56 -07:00
Keagan McClelland 44c87ef1d7 htlcswitch: bounce packets when quiescent 2024-11-26 13:51:56 -07:00
Keagan McClelland c9debea408 lnwire: add IsChannelUpdate function to distinguish channel updates 2024-11-26 13:51:56 -07:00
Keagan McClelland 2ece1fdc54 htlcswitch: implement stfu response
htlcswitch: use quiescer SendOwedStfu method in link stfu implementation
2024-11-26 13:51:56 -07:00
Keagan McClelland f5b7866287 htlcswitch: define state machine for quiescence
htlcswitch: add sendOwedStfu method to quiescer
2024-11-26 13:51:46 -07:00
Keagan McClelland 2a1384174b tlv: update to fn v2 2024-11-25 13:25:52 -07:00
Keagan McClelland a3e87cfebd fn: update fn/go.mod to v2 2024-11-20 10:28:55 -07:00
Keagan McClelland 9f35664a12 fn: breaking - make or else functions accept error argument 2024-11-06 17:32:59 -07:00
Keagan McClelland dd7f1569c7 fn: breaking - rename ChainOption to FlatMapOption for consistency 2024-11-06 17:32:59 -07:00
Keagan McClelland 5e947046a3 fn: breaking - give Result's FlatMap proper functor annotation 2024-11-06 17:32:59 -07:00
Keagan McClelland 4d16d5ff15 fn: breaking - replace AndThen2 with more principled LiftA2Result 2024-11-06 17:32:59 -07:00
Keagan McClelland 1480287cfc fn: breaking - improve naming of option api functions 2024-11-06 17:32:59 -07:00
Keagan McClelland be50dd9acb fn: breaking - remove deprecated Result functions 2024-11-06 17:32:59 -07:00
Keagan McClelland 1805fd6f19 fn: breaking - polish Either API 2024-11-06 17:32:58 -07:00
Keagan McClelland c6734ea013 fn: breaking - reverse argument order in slice funcs 2024-11-06 17:32:50 -07:00
Keagan McClelland a026d64c1b fn: breaking - fix type variables for better inference 2024-11-06 16:50:06 -07:00
Keagan McClelland 9bbd327a10 fn: add Sink to Result 2024-11-06 16:50:02 -07:00
Keagan McClelland 5dec35426c fn: add transpositions for Option and Result 2024-11-06 16:40:36 -07:00
Keagan McClelland 8971c4c3ae fn: add operations to Result API 2024-11-06 16:40:15 -07:00
Keagan McClelland 5faad77f33 fn: add conversions between Result and Option 2024-11-06 16:39:33 -07:00
Keagan McClelland a741c54175 fn: add compound slice functions 2024-11-06 16:29:41 -07:00
Keagan McClelland 7a7f3bdb2c fn: fix UnwrapOrFail semantics 2024-11-06 15:55:18 -07:00
ProofOfKeags 7bf9b59816 Merge pull request #9097 from ProofOfKeags/refactor/evaluate-htlc-view
[KILO]: DynComms Prefactor: Refactor/evaluate htlc view
2024-10-14 13:10:00 -06:00
Keagan McClelland 5307e7a5e4 lnwallet: return balance changes rather than modifying references
Here we return the balance deltas from evaluateHTLCView rather than
passing in references to variables that will be modified. It is a
far cleaner and compositional approach which allows readers of this
code to more effectively reason about the code without having to
keep the whole codebase in their head.
2024-10-14 09:40:47 -06:00
Keagan McClelland f0eecfa2cd lnwallet: inline and remove process[Add|Remove]Entry
This commit observes that processAddEntry and processRemoveEntry
are only invoked at a single call-site. Here we inline them at their
call-sites, which will unlock further simplifications of the code
that will allow us to remove pointer mutations in favor of explicit
expression oriented programming.

We also delete the tests associated with these functions, the overall
functionality is implicitly tested by the TestEvaluateHTLCView tests.
2024-10-14 09:33:39 -06:00
Keagan McClelland 1222cb8b10 lnwallet: remove continue statements from evaluateHTLCView loops
This further reduces loop complexity in evaluateHTLCView by using
explicit filter steps rather than loop continue statements.
2024-10-14 09:33:39 -06:00
Keagan McClelland d5aab4a8c1 lnwallet: consolidate loops in evaluateHTLCView
We had four for-loops in evaluateHTLCView that were exact mirror
images of each other. By making use of the new ChannelParty and
Dual facilities introduced in prior commits, we consolidate these
into two for-loops.
2024-10-14 09:33:39 -06:00
Keagan McClelland 51c28496a4 lnwallet: simplify fee calculation in evaluateHTLCView
This commit simplifies how we compute the commitment fee rate based
off of the live updates. Prior to this commit we processed all of
the FeeUpdate paymentDescriptors of both ChannelParty's. Now we only
process the last FeeUpdate of the OpeningParty
2024-10-14 09:33:38 -06:00
Keagan McClelland 4b2a4e36ad lnwallet: pack htlcView.{OurUpdates|TheirUpdates} into Dual.
This commit moves the collection of updates behind a Dual structure.
This allows us in a later commit to index into it via a ChannelParty
parameter which will simplify the loops in evaluateHTLCView.
2024-10-14 09:33:38 -06:00
Keagan McClelland 1b2cb14254 lnwallet: change bool isIncoming to new lntypes.ChannelParty
This commit removes another raw boolean value and replaces it with
a more clear type/name. This will also assist us when we later try
and consolidate the logic of evaluateHTLCView into a single
coherent computation.
2024-10-14 09:33:38 -06:00
Keagan McClelland b902d0825d lnwallet: use fn.Set API directly instead of empty struct map. 2024-10-14 09:33:38 -06:00
Keagan McClelland d82d02831d lnwallet: remove mutateState from evaluateHTLCView
In line with previous commits we are progressively removing the
mutateState argument from this call stack for a more principled
software design approach.

NOTE FOR REVIEWERS:
We take a naive approach to updating the tests here and simply
take the functionality we are removing from evaluateHTLCView and
run it directly after the function in the test suite.

It's possible that we should instead remove this from the test
suite altogether but I opted to take a more conservative approach
with respect to reducing the scope of tests. If you have opinions
here, please make them known.
2024-10-14 09:33:16 -06:00
Keagan McClelland 819239c5c8 lnwallet: inline processUpdateFee and remove the function entirely
In this commit we observe that the previous commit reduced the role
of this function to a single assignment statement with numerous newly
irrelevant parameters. This commit makes the choice of inlining it at
the two call-sites within evaluateHTLCView and removing the funciton
definition entirely. This also allows us to drop a huge portion of
newly irrelevant test code.
2024-10-11 11:25:58 +02:00
Keagan McClelland 05347c8392 lnwallet: bring processFeeUpdate in line with process[Add|Remove]Entry
This commit redoes the API and semantics of processFeeUpdate to make
it consistent with the semantics of it's sister functions. This is
part of an ongoing series of commits to remove mutateState arguments
pervasively from the codebase.

As with the previous commit this makes state mutation the caller's
responsibility. This temporarily increases code duplication at the
call-sites, but this will unlock other refactor opportunities.
2024-10-11 11:25:58 +02:00
Keagan McClelland 49add0f57b lnwallet: eliminate inner-most layer of evil mutateState nonsense
This commit begins the process of moving towards a more principled
means of state tracking. We eliminate the mutateState argument from
processAddEntry and processRemoveEntry and move the responsibility
of mutating said state to the call-sites.

The current call-sites of these functions still have their *own*
mutateState argument which will be eliminated during upcoming commits.
However, following the principle of micro-commits I opted to break
these changes up to make review simpler.
2024-10-11 11:25:52 +02:00
Keagan McClelland 71da6b5336 lnwallet: consolidate redundant cases using Dual.ForParty 2024-10-11 11:12:36 +02:00
Keagan McClelland b457b40f80 lnwallet: pack paymentDescriptor add/remove heights into Duals
The purpose of this commit is to begin the process of packing
symmetric fields into the newly introduced Dual structure. The
reason for this is that the Dual structure has a handy indexing
method where we can supply a ChannelParty and get back a value.
This will cut down on the amount of branching code in the main
lines of the codebase logic, making it easier to follow what is
going on.
2024-10-11 11:10:37 +02:00
Keagan McClelland 4e1579cf4c fn: add uncons, unsnoc and its component projections 2024-10-04 14:47:11 -06:00
Keagan McClelland f7264e6a5b fn: add Filter to List
This commit adds an immutable Filter method to the linked List API.
This is useful because there are several instances wherein we iterate
through the linked List and only process a subset of it in some way
or another.
2024-09-26 14:24:36 -06:00
Keagan McClelland 93d17a48a8 lnwallet: remove unnecessary chanID argument form unsignedLocalUpdates 2024-09-10 13:57:05 -07:00
Keagan McClelland 4fadbb09bd htlcswitch+lnwallet: quarantine paymentDescriptor to lnwallet
The objective of this commit is to make paymentDescriptor a private
data structure so we can quarantine it to the lnwallet package.
To accomplish this we had to prevent it from leaking out via the
arguments or return values of the public functions in lnwallet.
This naturally had consequences for the htlcswitch package as we
choose other mechanisms for tracking the data that paymentDescriptor
was responsible for.

Astoundingly, this was highly successful and allowed us to remove
a ton of redundant code. The diff for this commit represents a
substantial reduction in total lines of code as well as extraneous
arguments and return values from key functions.

This also sets the stage for future commits where we actually will
be attempting to rid lnwallet of paymentDescriptor completely.
2024-09-10 13:56:56 -07:00
Keagan McClelland 27ff5f085a lnwallet: remove unused function PayDescsFromRemoteLogUpdates
This function is no longer used as of the last commit and it is the
last remaining leak of the PaymentDescriptor type through the public
API.
2024-09-09 20:59:41 -06:00
Keagan McClelland dc60f78f7f htlcswitch: remove PaymentDescriptor conversion from reforwardSettleFails
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 20:59:41 -06:00
Keagan McClelland 957557a937 htlcswitch+lnwallet: remove PaymentDescriptor from ReceiveRevocation returns
This is part of a systematic removal of PaymentDescriptor from the public
API of the lnwallet package. This marks the last change needed before we
make the PaymentDescriptor structure private.
2024-09-09 20:59:22 -06:00
Keagan McClelland 1ae5705954 htlcswitch: remove PaymentDescriptor from processRemoteSettleFails call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 17:15:31 -06:00
Keagan McClelland aa38041240 htlcswitch: remove PaymentDescriptor from processRemoteAdds call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 17:15:30 -06:00
Keagan McClelland d881809a4d htlcswitch: remove PaymentDescriptor from hodlHtlc
This is part of a systematic removal of PaymentDescriptor from the
mechanics of the htlcswitch package.
2024-09-09 16:53:11 -06:00
Keagan McClelland a0818a0d16 htlcswitch: remove PaymentDescriptor from the processExitHop's call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 16:53:10 -06:00
Keagan McClelland 07647fe53a htlcswitch: remove PaymentDescriptor from settleHTLC's call signature
This is done as part of a systematic removal of PaymentDescriptor from
the mechanics of the htlcswitch package.
2024-09-09 16:53:10 -06:00
Keagan McClelland 877d29c717 htlcswitch: remove PaymentDescriptor from sendHTLCError's call signature
This is done as part of a systematic removal of PaymentDescriptor from
the mechanics of the htlcswitch package.
2024-09-09 16:53:10 -06:00
Keagan McClelland 0fb29b2598 channeldb: add convenience functions for generating Source/Dest Refs 2024-09-09 16:53:10 -06:00
Keagan McClelland 1e2bf3e0b3 lnwallet: add function to convert paymentDescriptor to LogUpdate
Here we add a function that is capable of recovering LogUpdates from
paymentDescriptors and we refactor the lnwallet code to use this
rather than doing JIT inline construction of the LogUpdates.
2024-09-09 16:53:08 -06:00
Keagan McClelland 721a0c5edc lnwire+htlcswitch: change NewInvalidBlinding to use array instead of slice 2024-09-09 16:26:41 -06:00
Keagan McClelland 5505b6daff htlcswitch: change sendMalformedHTLCError to take array instead of slice 2024-09-09 16:26:41 -06:00
Keagan McClelland 5deb4c253a htlcswitch+lnwallet: fix OnionBlob to 1366 bytes 2024-09-09 16:26:41 -06:00
Keagan McClelland df3c6b72ab lnwallet: track ChannelID on PaymentDescriptor
In this commit we track the ChannelID on the PaymentDescriptor.
This will be useful in upcoming commits that need to be able to
reconstruct lnwire.Message values from PaymentDescriptors as the
Messages that are exchanged to update channel state all include
the ChannelID.
2024-09-09 16:26:41 -06:00
Keagan McClelland a89e24f487 lnwallet: add ChannelID method to LightningChannel
In this commit we introduce a convenience method to LightningChannel
to allow us to quickly grab the channel id. This will be important
in upcoming commits where we need to remember the ChannelID to
reconstruct update messages.
2024-09-09 16:26:41 -06:00
Keagan McClelland 1422729f80 lnwallet+htlcswitch: define expanded NumPendingUpdates
This commit squashes the below operations for a net result where
we have an expanded capability of assessing pending updates. This
is made possible by packing the components into Duals in the prior
commits. We squash the operations to simplify review.

htlcswitch+lnwallet: rename PendingLocalUpdateCount

lnwallet: complete pending update queries API for LightningChannel

lnwallet+htlcswitch: consolidate NumPendingUpdates using ChannelParty

This commit makes the observation that we can cleanly define the
NumPendingUpdates function using a single expression by taking
advantage of the relevant fields being properly packed into Duals.
2024-08-28 14:03:00 -07:00
Keagan McClelland ce7fcd30f8 lnwallet: pack commitment message indices into Dual
This is yet another commit that packs a symmetric structure into
a Dual. This is the last one needed for the time being to consolidate
Num{X}UpdatesPendingOn{Y} functions into a single one.
2024-08-28 14:02:59 -07:00
Keagan McClelland 2e7fbc446f lnwallet: pack update logs into Dual
This commit, like the last one packs the update logs into a symmetric
Dual structure. This will allow us to index into them more concisely
in higher order logic.
2024-08-28 13:58:33 -07:00
Keagan McClelland 8077862225 lnwallet: pack commit chains into Dual
This commit packs the LightningChannel's localCommitmentChain and
remoteCommitmentChain into a Dual structure for better symmetric
access. This will be leveraged by an upcoming commit where we want
to more concisely express how we compute the number of pending
updates.
2024-08-28 13:51:23 -07:00
Keagan McClelland a0515a16db htlcswitch: extract error handling for syncChanStates 2024-08-28 13:46:52 -07:00
Keagan McClelland 34f7c31dc8 lntypes: Add Dual[A] primitive type
This commit introduces a new type Dual[A] to make it easier to
manage symmetric configurations or state for lightning channels.
2024-08-15 10:53:18 -07:00
ProofOfKeags 747abb4a0e Merge pull request #8980 from ProofOfKeags/refactor/modified-htlcs-fn-set
[NANO]: lnwallet: update updateLog.modifiedHtlcs to use fn.Set
2024-08-06 11:56:57 -06:00
Keagan McClelland c3c4e79593 lnwallet: update updateLog.modifiedHtlcs to use fn.Set 2024-08-06 10:05:20 -07:00
Keagan McClelland 935e7f1bee lnwallet: remove unused parameters in LightningChannel methods 2024-08-05 18:14:11 -07:00
Keagan McClelland 14e371948b lnwallet: remove unnecessary duplicate definition 2024-08-05 18:14:11 -07:00
Keagan McClelland 2ddc3db5f8 peer: add message summary for Stfu 2024-08-05 17:23:19 -07:00
Keagan McClelland b172227cb3 lnwire: add Stfu to LinkUpdater interface 2024-08-05 17:23:19 -07:00
Keagan McClelland 0176fca826 lnwire: add wire type for stfu 2024-08-05 17:22:56 -07:00
Keagan McClelland a2b19afe59 channeldb+lnwallet: define Initiator for OpenChannel and LightningChannel
This commit introduces a new API to return information on which party opened
the channel using the new ChannelParty type. It does not change the underlying
structure of how we store this information.
2024-08-05 12:58:46 -07:00
ProofOfKeags e3dd886580 Merge pull request #8962 from ProofOfKeags/refactor/quiescence-micro-spinoffs
[NANO]: Refactor/quiescence micro spinoffs
2024-08-01 13:57:29 -06:00
Keagan McClelland 22e34702d8 funding: replace newly edited log values with lazier variants 2024-08-01 12:11:52 -07:00
Keagan McClelland e3a9d0acbe multi: break ChannelConstraints into two sub-structures
This commit breaks the ChannelConstraints structure into two
sub-structures that reflect the fundamental differences in how
these parameters are used. On its face it may not seem necessary,
however the distinction introduced here is relevant for how we
will be implementing the Dynamic Commitments proposal.
2024-08-01 12:00:32 -07:00
Keagan McClelland dc03637ae3 htlcswitch: rename for test parameters for accuracy 2024-08-01 11:56:50 -07:00
Keagan McClelland f54c9ea8f7 htlcswitch: replace errors package implementation 2024-07-31 17:54:21 -07:00