Commit Graph

17677 Commits

Author SHA1 Message Date
Oliver Gugger
ea72db711c
docs: fix release notes 2024-11-19 21:09:15 +01:00
Olaoluwa Osuntokun
ab3b3c848c
Merge pull request #9258 from yyforyongyu/fix-notification
chainntnfs: fix missing notifications
2024-11-19 10:43:25 -08:00
Olaoluwa Osuntokun
c3fac0eb92
Merge pull request #8337 from lightningnetwork/protofsm
[1/4] - protofsm: add new package for driving generic protocol FSMs
2024-11-19 10:41:49 -08:00
Oliver Gugger
e1df8e9161
Merge pull request #9281 from ziggie1984/export-towerclientdb-version
wtdb: export versions of wtclient.db
2024-11-19 17:53:14 +01:00
Oliver Gugger
9519a23a97
Merge pull request #9278 from starius/debuglevel-show-no-checks
config: fix "lnd --debuglevel show" command
2024-11-19 17:53:00 +01:00
Boris Nagaev
64c660c19e
itest: test "lnd --debuglevel=show" command
Tests that "lnd --debuglevel=show" command works and prints the list of
supported subsystems.
2024-11-19 12:44:57 -03:00
Boris Nagaev
3360d285fb
config: improve error message
Previously, the error message had one missing space:
"... either --bitcoin.mainnet, or bitcoin.testnet,bitcoin.simnet, ..."

I added a space after "bitcoin.testnet,".
2024-11-19 12:44:57 -03:00
Boris Nagaev
1bc25c1136
config: fix "lnd --debuglevel show" command
Previously, "lnd --debuglevel show" complained that bitcoin backend is not
configured:

$ lnd --debuglevel show
failed to load config: ValidateConfig: either --bitcoin.mainnet, or ...

To make it working, the user had to specify --bitcoin.mainnet and configure one
of the backends, e.g. "--bitcoin.node neutrino".

With this fix, the command works without any additional flags.
2024-11-19 12:44:55 -03:00
ziggie
aaa0abc8a9
wtdb: export versions of wtclient.db
We now make it possible to get the current db version of the
wtclient.db. Moreover we can now fetch the latest available
migration version for the client db. This allows us to compare
whether the client.db has all the expected migrations applied.
2024-11-19 16:42:52 +01:00
Oliver Gugger
411ad1d9cd
Merge pull request #9271 from morehouse/simplify_fuzz_wtwire
wtwire: simply fuzz targets
2024-11-19 12:57:34 +01:00
Oliver Gugger
c136901f24
Merge pull request #9270 from starius/goroutine-manager-bool
fn: improvements for GoroutineManager
2024-11-19 12:56:04 +01:00
Oliver Gugger
f4a1299d37
Merge pull request #9272 from lightningnetwork/sweeper-output-index
sweep: update storeRecord to include utxo index
2024-11-19 12:42:26 +01:00
Elle
d14f4c7e1f
Merge pull request #9279 from ellemouton/misc
misc: nil checks and remove deprecated default values
2024-11-19 10:37:01 +02:00
yyforyongyu
db6901c9f3
chainntnfs: skip duplicate numConfsLeft notifications
This commit adds a new state to the `ConfNtfn` struct to start tracking
the number of confs left to be notified to avoid sending duplicate
notifications.
2024-11-19 16:27:26 +08:00
yyforyongyu
7695880c13
chainntnfs: add new method notifyNumConfsLeft
So it's easier to handle the following commit where we start skipping
duplicate notifications.
2024-11-19 16:02:19 +08:00
yyforyongyu
0c3b2b5e06
docs: update release notes 2024-11-19 15:56:27 +08:00
yyforyongyu
4ff1f19fbf
chainntnfs: make sure notification is sent to the whole set
This commit fixes a bug where the confirmation details may be missed.
When the same tx is subscribed via `RegisterConfirmationsNtfn`, we will
put them into the same set and notify the whole set. However, this logic
is missing when performing the rescan - once the confirmation detail is
found, we only notify the current subscriber. Later we will skip
notifying other subscribers in `UpdateConfDetails` due to the
`confSet.details != nil` check. We now fix it by immediately notify all
the subscribers when the confirmation detail is found during the rescan.
2024-11-19 15:56:08 +08:00
yyforyongyu
1200b75546
chainntnfs: always notify txns before block
This commit changes the order of notifications when a relevant tx is
found in a block and now we will always notify the tx subscribers before
notifying the block, which has implications in the upcoming blockbeat.

When a block notification is subscribed via `RegisterBlockEpochNtfn` and
a confirm or spend is subscribed via `RegisterConfirmationsNtfn` or
`RegisterSpendNtfn`, we would always notify the block first before the
tx, causing the subsystem to think there's no relevant txns found in
this block, while the notifications are sent later. We now fix it by
always sending the txns notifications first, so the subsystem can
receive the txns, process them, then attempt to advance its state based
on the block received.
2024-11-19 15:55:22 +08:00
Olaoluwa Osuntokun
2e3c0b2a7d
protofsm: use new fn.GoroutineManager to manage goroutines
This fixes an isuse that can occur when we have concurrent calls to
`Stop` while the state machine is driving forward.
2024-11-18 20:49:01 -08:00
Olaoluwa Osuntokun
6de0615cd5
protofsm: allow multiple internal events to be emitted
In this commit, we update the execution logic to allow multiple internal
events to be emitted. This is useful to handle potential out of order
state transitions, as they can be cached, then emitted once the relevant
pre-conditions have been met.
2024-11-18 20:49:00 -08:00
Olaoluwa Osuntokun
847c1a789d
protofsm: add SpendMapper to craft custom spend events
In this commit, we add the SpendMapper which allows callers to create
custom spent events. Before this commit, the caller would be able to
have an event sent to them in the case a spend happens, but that event
wouldn't have any of the relevant spend details.

With this new addition, the caller can specify how to take a generic
spend event, and transform it into the state machine specific spend
event.
2024-11-18 20:49:00 -08:00
Olaoluwa Osuntokun
d805c0fc3c
protofsm: add CustomPollInterval for mocking purposes
Adding this makes a state machine easier to unit test, as the caller can
specify a custom polling interval.
2024-11-18 20:49:00 -08:00
Olaoluwa Osuntokun
35ea05d5dc
protofsm: add ErrorReporter interface
We'll use this to be able to signal to a caller that a critical error
occurred during the state transition.
2024-11-18 20:49:00 -08:00
Olaoluwa Osuntokun
96a98bc071
protofsm: add logging 2024-11-18 20:49:00 -08:00
Olaoluwa Osuntokun
44f035330b
protofsm: add a Name() method to the env
This'll be used later to uniquely identify state machines for
routing/dispatch purposes.
2024-11-18 20:49:00 -08:00
Olaoluwa Osuntokun
424ae09631
protofsm: add ability for state machine to consume wire msgs
In this commit, we add the ability for the state machine to consume wire
messages. This'll allow the creation of a new generic message router
that takes the place of the current peer `readHandler` in an upcoming
commit.
2024-11-18 20:48:59 -08:00
Olaoluwa Osuntokun
bf10e31167
protofsm: convert state machine args into config 2024-11-18 20:48:59 -08:00
Olaoluwa Osuntokun
d17e737558
protofsm: add optional daemon event on init
In this commit, we add an optional daemon event that can be specified to
dispatch during init. This is useful for instances where before we
start, we want to make sure we have a registered spend/conf notification
before normal operation starts.

We also add new unit tests to cover this, and the prior spend/conf event
additions.
2024-11-18 20:48:59 -08:00
Olaoluwa Osuntokun
7f69ceb2d4
protofsm: add daemon events for spend+conf registration 2024-11-18 20:48:59 -08:00
Olaoluwa Osuntokun
3bae7f32cd
protofsm: add new package for driving generic protocol FSMs
In this PR, we create a new package, `protofsm` which is intended to
abstract away from something we've done dozens of time in the daemon:
create a new event-drive protocol FSM. One example of this is the co-op
close state machine, and also the channel state machine itself.

This packages picks out the common themes of:

  * clear states and transitions between them
  * calling out to special daemon adapters for I/O such as transaction
    broadcast or sending a message to a peer
  * cleaning up after state machine execution
  * notifying relevant callers of updates to the state machine

The goal of this PR, is that devs can now implement a state machine
based off of this primary interface:
```go
// State defines an abstract state along, namely its state transition function
// that takes as input an event and an environment, and returns a state
// transition (next state, and set of events to emit). As state can also either
// be terminal, or not, a terminal event causes state execution to halt.
type State[Event any, Env Environment] interface {
	// ProcessEvent takes an event and an environment, and returns a new
	// state transition. This will be iteratively called until either a
	// terminal state is reached, or no further internal events are
	// emitted.
	ProcessEvent(event Event, env Env) (*StateTransition[Event, Env], error)

	// IsTerminal returns true if this state is terminal, and false otherwise.
	IsTerminal() bool
}
```

With their focus being _only_ on each state transition, rather than all
the boiler plate involved (processing new events, advancing to
completion, doing I/O, etc, etc).

Instead, they just make their states, then create the state machine
given the starting state and env. The only other custom component needed
is something capable of mapping wire messages or other events from the
"outside world" into the domain of the state machine.

The set of types is based on a pseudo sum type system wherein you
declare an interface, make the sole method private, then create other
instances based on that interface. This restricts call sites (must pass
in that interface) type, and with some tooling, exhaustive matching can
also be enforced via a linter.

The best way to get a hang of the pattern proposed here is to check out
the tests. They make a mock state machine, and then use the new executor
to drive it to completion. You'll also get a view of how the code will
actually look, with the focus being on the: input event, current state,
and output transition (can also emit events to drive itself forward).
2024-11-18 20:48:57 -08:00
Olaoluwa Osuntokun
0e999ed9f5
Merge pull request #9275 from yyforyongyu/fix-peer-shutdown
peer+lnd: fix peer blocking on node shutdown
2024-11-18 20:15:12 -08:00
Elle Mouton
9f72ce7dd4
config: remove default values for deprecated fields
These values have been deprecated but since we still set the default
values, the "please remove it" error still shows up.
2024-11-19 05:49:30 +02:00
Olaoluwa Osuntokun
7ed2c10671
sweep: update storeRecord to include utxo index
In this commit, we complete a recently added feature by ensuring that
even if we go through the RBF loop to create a txn, that we still
populate the `outpointToIndex` map. Unit tests have been updated to
ensure this is always set as expected.
2024-11-18 18:12:41 -08:00
Elle Mouton
90ed0fe54c
lntest: nil check edges 2024-11-18 21:09:16 +02:00
yyforyongyu
3ab5669ff2
docs: update release notes 2024-11-18 18:49:34 +08:00
yyforyongyu
fe03aa0201
peer+lnd: fix peer blocking on node shutdown
This commit fixes a case where the peer blocks the shutdown process.
During the shutdown, the server will call `s.DisconnectPeer`, which
calls `peer.Disconnect`. Because the peer never enters `peer.Start` via
`s.peerInitializer`, the `startReady` chan will not be closed, causing
`peer.Disconnect` to hang forever. We now fix it by only block on
`startReady` when the peer is started.
2024-11-18 18:49:34 +08:00
Oliver Gugger
bd36f76530
Merge pull request #9273 from Roasbeef/itests-pid
lntest: print node PID when launching in itests
2024-11-18 09:38:48 +01:00
Olaoluwa Osuntokun
b9105c35e5 lntest: print node PID when launching in itests
In this commit, we start to print the PID of node's we created within an
itest. This is useful when debugging itests with `dlv` by attaching to a
given node. By printing out the PID, we facilitate such debugging
attempts.
2024-11-15 17:21:43 -08:00
Oliver Gugger
95b248a1ef
Merge pull request #9194 from lightningnetwork/aux-channel-htlc
multi: generate and pass along HTLC resolution blobs for aux channels
2024-11-15 13:07:35 +01:00
Oliver Gugger
9a1adbeeaa
docs: move 0.18.4 items, add full list of custom chan PRs 2024-11-15 09:50:01 +01:00
Oliver Gugger
e6efa2e438
Merge pull request #9269 from hieblmi/sendpayment-fix-negative-feelimit
routerrpc: fix sendpayment_v2 negative fee limit
2024-11-15 09:40:43 +01:00
Olaoluwa Osuntokun
414894348a
sweep: update BudgetInputSet.Budget() to factor in extra budget
In this commit, we update the `Budget()` call to factor in the
`extraBudget` value. Otherwise, when we go to intialize the fee
function, we won't factor in the extra budget, and will determine that
we can't broadcast/bump.
2024-11-14 16:09:59 -08:00
Olaoluwa Osuntokun
87b4991bb6
lnwallet: add whoseCommit to FetchLeavesFromCommit
This is useful for additional context to know which commit the
AuxLeafStore is fetching the leaves for.
2024-11-14 16:09:58 -08:00
Olaoluwa Osuntokun
ba16a74491
sweep: expand NotifyBroadcast to include an outpoint index
In this commit, we expand the `NotifyBroadcast` to include an outpoint
index. This is useful as it indicates the index of a given required tx
out input.
2024-11-14 16:09:58 -08:00
Olaoluwa Osuntokun
ab41f28a8f
contractcourt: pass in new aux resolution blob to sweeper in resolvers
With this commit, we update all the resolvers to pass in the new htlc
resolution blobs. Along the way, we remove the old blocking guard on
this resolution logic for HTLCs with blobs.
2024-11-14 16:09:58 -08:00
Olaoluwa Osuntokun
7ef2683586
contractcourt: update encode/decode for taproot aux data
When we read/write the aux data, we need to make sure we always set the
new fields for aux HTLCs.
2024-11-14 16:09:58 -08:00
Olaoluwa Osuntokun
9b8adf5f5c
contractcourt: add HtlcBlobs to taprootBriefcase
In this commit, we add the set of HtlcBlobs to the taprootBriefcase
struct. This new field will store all the resolution blobs for a given
HTLC. We also add some new property based tests along the way for
adequate test coverage.
2024-11-14 16:09:58 -08:00
Olaoluwa Osuntokun
1e7c5415ae
input: add new Preimage method to input.Input
In this commit, we add a new method to obtain an option of a preimage to
the input.Input struct. This is useful for callers that have an Input,
and want to optionally obtain the preimage.
2024-11-14 16:09:58 -08:00
Olaoluwa Osuntokun
af60fa0c3a
lnwallet: populate resolution blob for incoming+outgoing HTLC resolutions
In this commit, we populate the resolution blobs for the incoming and
outgoing HTLCs. We take care to populate the AuxSigDesc with the correct
information, as we need to pass along the second-level aux signature and
also sign desc along with it.
2024-11-14 16:09:57 -08:00
Olaoluwa Osuntokun
08d0aa2368
channel: add ResolutionBlob to Incoming+Outgoing HtlcResolution
Similar to the other blobs we have for the commitment output force close
resolution, these blobs will be used to ensure that we have everything
needed to sweep aux HTLCs.
2024-11-14 16:09:57 -08:00