Commit Graph
100 Commits
Author SHA1 Message Date
Elle Mouton 32fbea2f85 lnd: use structured logs in mkErr helper 2024-12-02 09:23:06 +02:00
Elle Mouton 755ad49440 build: Append commit hash to the main LND context
It can be disabled via the new `logging.no-commit-hash` config option.
2024-12-02 09:23:06 +02:00
Elle Mouton efe08b836e docs: add structured logging docs in code formatting rules doc 2024-12-02 09:23:06 +02:00
Elle Mouton a04f8dfd4f lnd: pass ctx to rest proxy 2024-12-02 09:23:06 +02:00
Elle Mouton c5d849e044 .golangci: Replace lll with custom ll 2024-12-02 09:23:06 +02:00
Elle Mouton ab7aae0708 multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Elle Mouton 88f5369066 tools+.: add custom linter configuration file
Add this file both to the main LND directory so that devs can use it for
local linter runs and also add it to the `tools` directory so that the
docker environment used to run the linter in CI has access to it. A
custom linter binary can be built via `golangci-lint custom`. This will
pull in and register all the plugins listed in the new config file when
building the new binary. The new binary can then be run using
`custom-gcl run`.
2024-12-02 09:14:21 +02:00
Elle Mouton bd55b2795b tools/linters: ignore log lines
This commit adds a feature to our custom lll linter which will ignore
log lines (both single and multi-lined log lines) for the lll linter.
2024-12-02 09:14:21 +02:00
Elle Mouton 9637a8132e tools/linters: convert to LinterPlugin implementation
This commit introduces the `LLPlugin` type and converts the existing lll
code such that the LLPlugin implements the register.LinterPlugin
interface. This will allow us to plug it into golangci-linter as a
plugin.
2024-11-29 11:03:27 +02:00
Elle Mouton acbcb771af tools/linters: Add copied golangci-lint lll linter code
In this commit, we copy the implementation of the golangci-lint lll
linter which we currently use in our CI flow during the `make lint`
check. This commit copies the code mostly as is (the only exception
being the line which trims white space before checking if a line starts
with "import"), and formats it to fit our codebase guidelines. A test is
also added so that we can be sure that the following commits which
adjust the implementation have the intended results.

The custom linter is put into its own module as this is requied by the
`golangci-lint custom` when building the custom linter binary which
includes the plugin.
2024-11-29 10:44:22 +02:00
Elle Mouton 54dbaa60c9 docs: add release notes entry for 9236 2024-11-28 13:51:15 +02:00
Elle Mouton 439a6c7d6c multi: rename chan DB Open method to OpenForTesting 2024-11-28 13:51:15 +02:00
Elle Mouton 4089fbcb44 multi: fix linter errors 2024-11-28 13:51:15 +02:00
Elle Mouton fd2ea411be itest: assert no failed updates in test
So that this fails earlier on if the actual call to UpdateChannelPolicy
fails.
2024-11-28 13:51:14 +02:00
Elle Mouton adcaa8802f multi: remove kvdb.Tx from ChannelGraphSource.ForAllOutgoingChannels
and the same for ChannelStateDB.FetchChannel. Most of the calls to these
methods provide a `nil` Tx anyways. The only place that currently
provides a non-nil tx is in the `localchans.Manager`. It takes the
transaction provided to the `ForAllOutgoingChannels` callback and passes
it to it's `updateEdge` method. Note, however, that the
`ForAllOutgoingChannels` call is a call to the graph db and the call to
`updateEdge` is a call to the `ChannelStateDB`. There is no reason that
these two calls need to happen under the same transaction as they are
reading from two completely disjoint databases. And so in the effort to
completely split untangle the relationship between the two databases, we
now dont use the same transaction for these two calls.
2024-11-28 13:49:41 +02:00
Elle Mouton 6e13898981 multi: move LightningNode struct to models package 2024-11-28 13:36:32 +02:00
Elle Mouton ccb8f0eeb8 refactor: move graphsession pkg to graph package 2024-11-28 13:36:15 +02:00
Elle Mouton b86980ec40 channeldb: remove graph db from channeldb
Now that the channel.DB no longer uses the ChannelGraph pointer, we can
completely remove it as a member of channeldb.DB.
2024-11-28 13:36:15 +02:00
Elle Mouton 2c083bc017 multi: let chan and graph db implement AddrSource
Then use both to construct a multiAddrSource AddrSource and use that
around the code-base.
2024-11-28 13:36:15 +02:00
Elle Mouton 51c2f709e1 channeldb: let AddrsForNode indicate if the node was found or not
Before this commit, the `(channeldb.DB).AddrsForNode` method treats the
results from the channel db and the graph db slightly differently. It
errors out if the channel db is unaware of the node in question but does
not error out if the graph is unaware of the node. So this commit
changes the logic slightly so that a "node-unknown" error from either
backing source is not seen as an error.
2024-11-28 13:36:15 +02:00
Elle Mouton 9537026df9 channeldb: implement a multi-source AddrSource
In this commit, we implement a version of the AddrSource interface which
merges the results of a set of AddrSource implementations. This will
later be used to merge the results of the channel db and graph db.
2024-11-28 13:36:15 +02:00
Elle Mouton 083d3c9d7c channeldb: define a single AddrSource interface
Our aim is to completely remove the `channeldb.DB`'s direct dependence
on the `graphdb.ChannelGraph` pointer. The only place where it still
depends on this pointer is in the `(DB).AddrsForNode(..)` method where
it queries both the channel DB and the graph db for the known addresses
for the node in question and then combines the results. So, to separate
these out, we will define an AddrsForNodes interface in this commit
which we will later let both the ChannelGraph and channeldb.DB both
implement and we will merge these results outside of the channeldb
package.

All this commit does is to unify the `AddrSource` interface since this
has been defined separately in a couple of places.
2024-11-28 13:36:15 +02:00
Elle Mouton 1859993734 channeldb+graphdb: init graph DB outside of channel db
We also now use the graph DB's own optional functions. An instance of
the graph is currently still passed to the channeldb's
`CreateWithBackend` function. This will be removed in a later commit
once the two have been completely disjoint.
2024-11-28 13:36:15 +02:00
Elle Mouton 74a4b1922b refactor: move graph related DB code to graph/db from channeldb
This is a pure refactor commit. It moves over all the graph related CRUD
code from `channeldb` to `graph/db`.
2024-11-28 13:36:13 +02:00
Elle Mouton 9f54ec90aa multi+refactor: move models package to graph/db
All the structs defined in the `channeldb/models` package are graph
related. So once we move all the graph CRUD code to the graph package,
it makes sense to have the schema structs there too. So this just moves
the `models` package over to `graph/db/models`.
2024-11-28 13:34:33 +02:00
Elle Mouton b707fd55b2 contractcourt: use graphdb outpoint helpers
Start using the single set of exported write/read functions for
wire.Outpoint.
2024-11-28 13:34:08 +02:00
Elle Mouton 382539a6eb channeldb/graphdb: move outpoint ser/deser funcs to graphdb
We have the same helpers for writing and reading a wire.Outpoint type
defined separately in a couple places. We will want to use these from
the graph db package soon though so instead of defining them again
there, this commit unifies things and creates a single exported set of
helpers. The next commit will make use of these.
2024-11-28 13:34:08 +02:00
Elle Mouton 3365461500 channeldb+graph/db: move net.Addr encode/decode to graph db package
In preparation for moving the graph related schema structs to the graph
package in an upcoming commit, we move these methods to the graph
package. The structs we will move make use of these methods but we still
import them from channeldb so as to keep the ReadElement and
WriteElement helpers working as they do today.
2024-11-28 13:34:08 +02:00
Elle Mouton 1e81d83f78 channeldb: export net.Addr encode/decode methods
We'll move these to the new graphdb package later and import them from
there.
2024-11-28 13:34:08 +02:00
Elle Mouton c2923e2214 multi: remove PrefixLog
And instead use the new btclog Logger `WithPrefix` method.
2024-11-27 10:44:32 +02:00
Elle Mouton b98fc168ec go.mod+build: update btclog dep 2024-11-27 10:44:01 +02:00
Elle fbeab726e1 Merge pull request #8390 from carlaKC/7883-experimental-endorsement
Add Experimental Endorsement Signalling
2024-11-26 09:43:22 +02: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
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
Elle Mouton 90ed0fe54c lntest: nil check edges 2024-11-18 21:09:16 +02:00
Elle 4430687076 Merge pull request #9240 from carlaKC/9166-mergeonly
htlcswitch: merge htlc custom records on modify
2024-11-08 08:38:00 +02:00
Elle Mouton 30e0d6ca9c docs: update release notes 2024-11-01 12:28:06 +02:00
Elle Mouton 5370c90906 routing+migration32: update MC encoding to use pure TLV
In this commit, we update an existing migration which at the time of
writing has not been included in a release. We update it so that it
converts the format used for MissionControl result encoding to use pure
TLV instead. The 3 structs that have been updated are: `mcHop`,
`mcRoute` and `paymentResult`.
2024-11-01 12:28:06 +02:00
Elle Mouton d9a073ad7e routing+channeldb: let Vertex implement tlv.RecordProducer
So that we can use it in TLV encoding.
Also add this to the codec for channeldb migration 32 since we will be
using it there in an upcoming adjustment commit.
2024-11-01 08:59:54 +02:00
Elle Mouton a5f3fa17e7 lnwire21: update Msat and TrueBoolean
Add the TrueBoolean type along with its Record method. Also update the
Millisatoshi type with a Record method. Both of these will be used in an
upcoming commit which adjusts a mission control migration to use pure
TLV types.
2024-11-01 08:59:54 +02:00
Elle Mouton e547d21920 multi: update log file max num and size defaults 2024-10-30 13:30:04 +02:00
Elle Mouton 8106810d9e docs: add release notes 2024-10-30 13:30:04 +02:00
Elle Mouton 22c13790df build+config: move maxlogfiles and maxfilesize to logger config
Add deprecation notices but continue to read both.
2024-10-30 13:30:04 +02:00
Elle Mouton 3adbdbb39a multi: move logcompressor to logging.file.compressor
This is not a breaking change since the logcompressor config option has
not been released yet.
2024-10-30 13:30:04 +02:00
Elle Mouton 1886d3865b build: extract File logging options into own struct
In preparation for extending LoggerConfig with file specific config.
2024-10-30 13:16:39 +02:00
Elle Mouton 0512357c17 build: dedup logging config
Move all shared code to config.go which has no build tags.
2024-10-30 13:15:34 +02:00
Elle Mouton 4c5e5653e4 build: rename config.go file
to config_prod.go in preparation for adding a shared config.go file.
2024-10-30 13:15:33 +02:00
Elle 7ceb3d61b5 Merge pull request #9213 from ellemouton/updateSubmodules
go.mod: update LND sub-module deps
2024-10-30 09:13:07 +02:00
Elle Mouton b4d098fb29 go.mod: update LND sub-module deps 2024-10-29 15:01:00 +02:00
Elle Mouton 67419a7c0c Revert "kvdb/postgres: remove global application level lock"
This reverts commit 43a1ca4f3d.
2024-10-28 09:35:18 +02:00
Elle Mouton a03d5fcb9e tor: update btclog dep 2024-10-26 14:18:32 +02:00
Elle Mouton 83751ee208 sqldb: update btclog dep 2024-10-26 14:18:00 +02:00
Elle Mouton a6e68cb6b8 kvdb: update btclog dep 2024-10-26 14:16:31 +02:00
Elle Mouton de358667f3 healthcheck: bump btclog dep 2024-10-26 14:16:25 +02:00
Elle Mouton 1e39e3758e build: apply log type flags in NewDefaultLogHandlers
So that the logging config "Disable" options and log type flags are all
handled in one place. Other repo's can then re-use this nicely.
2024-10-26 14:15:14 +02:00
Elle b4ef22bf47 Merge pull request #9083 from ellemouton/slog
log: structured logging
2024-10-22 20:00:56 +02:00
Elle Mouton 30d39ac595 build+sample_conf: option to print log call-site 2024-10-22 17:07:50 +02:00
Elle Mouton eddcdb2a5a docs: add release note entry 2024-10-22 17:03:56 +02:00
Elle Mouton 9d0cd3ff4f multi: update more loggers to the v2 type 2024-10-22 17:03:56 +02:00
Elle Mouton 49bfbecc4e build: add CriticalS to ShutdownLogger
Ensure that the ShutdownLogger correctly calls shutdown for the new
CriticalS method added to the btclog.Logger.
2024-10-22 17:03:56 +02:00
Elle Mouton ba1ce84b27 build: update prefixed logger
Such that it implements the new expanded interface of btclog v2.
2024-10-22 17:03:56 +02:00
Elle Mouton 23602e017e multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
Elle Mouton a8da3e525b build: add styling option for console logger
This will only be available when the dev build tag is set
2024-10-22 17:03:55 +02:00
Elle Mouton cfa7fceb0b build+config: add default handler constructor
Since most of our projects will use the same handler duo and apply the
config options the same way, let's make our lives easier and add a
default handler constructor.
2024-10-22 17:03:55 +02:00
Elle Mouton 5ed7bf1b71 config: add logging config options
This commit adds config options so that users can for both the console
logger and the file logger set the following things:

- disable the logger
- omit timestamps from log lines.
2024-10-22 17:03:55 +02:00
Elle Mouton cd697913ef build: switch to slog Handlers
Start using the new slog handlers. With this commit we also remove the
need for the LogWriter since we let our LogRotator implement io.Writer
and pass that in to our log file handler.
2024-10-22 17:03:51 +02:00
Elle Mouton 9a9761008c build: add handler set implementations
This commit then also adds an implementation of the btclog.Handler
interface called `handlerSets` which basically lets us have a Handler
backed by many Handlers (we need one for the stdout and one for our log
file).
2024-10-22 15:29:34 +02:00
Elle Mouton 387a1a8831 build: separate sublogger and rotator pipe management
These are two separate concerns. So this commit splits them up and just
passes a LogWriter from the one to the other. This will become cleaner
in an upcoming commit where the Rotator will implement io.Writer and
there will no longer be a need for LogWriter.
2024-10-22 15:19:58 +02:00
Elle Mouton ec5b39c120 build: move LevelSubLogger to own file
To make the upcoming commits easier to review and for general code
organisation.
2024-10-22 15:17:10 +02:00
Elle Mouton 63d5e92af1 tlv: generate types for gossip unsigned range
For pure TLV messages such as Gossip 1.75 and Bolt12 messages, there are
defined TLV ranges for unsigned data vs signed data. The signed ranges are
the inclusive ranges of 0 to 159 and 1000000000 to 2999999999.
What we do here in this commit is: 1) update the number of main types
generated so that they include type 160 which is the first type in the
un-signed range and we will make use of this type for signature fields
in gossip messages. Next, we add two marker types so that we can define
the rest of the ranges.
2024-10-15 06:21:55 +02:00
Elle d90871bee7 Merge pull request #9161 from ellemouton/fixInvalidBlindingEncodeSig
channeldb/mig/lnwire21: fix FailInvalidBlinding Encode sig
2024-10-04 12:52:49 +02:00
Elle Mouton 8f6d336ab2 channeldb/mig/lnwire21: fix FailInvalidBlinding Encode sig
fix the signature of the Encode method so that it does in fact implement
the Serializable interface defined in the lnwire21 package. This differs
slightly from the interface defined in the main lnwire package.
2024-10-04 10:31:46 +02:00
Elle Mouton 4d44d11ece rpcserver: use SetBit helper for setting Bolt11 blinded bit
This commit uses the new SetBit helper for setting the Bolt11 route
blinding required bit in a generated invoice. This helper will take care
of setting the dependent bits of the feature bit (namely the route
blinding and TLV feature bits and will use the required variant of
both).
2024-10-02 10:52:59 +02:00
Elle Mouton 49a87469db feature: add SetBit helper to set dependent bits
This commit adds a new SetBit helper function in the features package
along with a test for it.  SetBit sets the given feature bit on the
given feature bit vector along with any of its dependencies. If the bit
is required, then all the dependencies are also set to required,
otherwise, the optional dependency bits are set. Existing bits are only
upgraded from optional to required but never downgraded from required to
optional.
2024-10-02 10:52:59 +02:00
Elle f1207ef740 Merge pull request #9001 from ellemouton/namespacedMC
routing: Namespaced Mission Control
2024-10-01 20:21:53 +02:00
Elle Mouton 83c1d731e7 docs: add release note entry 2024-10-01 18:02:26 +02:00
Elle Mouton 8126930d6c routing: support multiple namespaced MissionControls 2024-10-01 14:11:05 +02:00
Elle Mouton 5eff056933 routing: prefix MC logs with namespace 2024-10-01 14:06:54 +02:00
Elle Mouton f0f4f2df21 routing: separate MissionControl from MissionControlManager
This commit renames the previous MissionControl to MissionController and
the previous MissionController interface to MissionControlQuerier. This
is done because soon the (new) MissionController will back multiple
namespaced MissionControl instances.  For now, it just houses a single
MissionControl in the default namespace.

This commit also replaces the MissionControl's `now` function with a
`clock.Clock`.
2024-10-01 14:06:50 +02:00
Elle Mouton 28a828a11e routing: unexport MissionControl mutex
Only the MissionControl instance should use this variable and it should
not be accessible to users of MissionControl.
2024-10-01 13:50:50 +02:00
Elle Mouton 6b449a6633 routing: start writing and reading from namespaced MC
and invoke the associated mission control migration.
2024-10-01 13:50:50 +02:00
Elle Mouton bfe4a08341 channeldb/migration33: migrate MC store pairs to default namespace
In this commit, the mission control store is migrated such that all
existing pairs which are currently stored directly in the top level
results bucket are now instead moved to a "default" namespace bucket.

Note that this migration is not yet invoked in this commit. The
migration will be invoked in the same commit that starts writing and
reading the new format.
2024-10-01 13:50:50 +02:00
Elle Mouton 2dd9046622 routing: introduce missionControlDB abstraction
So that `missionControlStore` can be unaware of the backing DB structure
it is writing to. In an upcoming commit when we change mission control
to write to namespaced buckets instead, we then only need to update the
`namespacedDB` implementation.
2024-10-01 13:50:50 +02:00
Elle 75eaaf7c5c Merge pull request #8911 from ellemouton/reduceMCRouteEncoding
routing+channeldb: use a more minimal encoding for MC routes
2024-10-01 13:49:11 +02:00
Elle Mouton 34303e77a1 docs: add release notes entry 2024-10-01 10:53:48 +02:00
Elle Mouton 383a6d274f routing+channeldb: migrate MC store to use minimal Route encoding
Add a new mcRoute type that houses the data about a route that MC
actually uses. Then add a migration (channeldb/migration32) that
migrates the existing store from its current serialisation to the new,
more minimal serialisation.
2024-09-30 11:40:25 +02:00
Elle Mouton 96445f99b4 channeldb: boiler plate code for migration32
In preparation for the commit which will add the main logic for
migration 32 (which will migrate the MC store to use a more minimal
encoding), this commit just adds some of the code that the migration
will need to the package.
2024-09-30 11:40:25 +02:00
Elle Mouton 82ae0220c8 lnwire21: add custom records parsing
We add the new custom records encoding/decoding logic to the "frozen"
lnwire21 package. We can do this because nothing uses this logic yet. If
the custom records logic changes, the changes should _not_ be added to
the lnwire21 version.
2024-09-30 08:59:02 +02:00
Elle Mouton 33ab4b9db9 lnwire21: add CodeInvalidBlinding
To prevent the need to copy the entire onion_error.go file for a new
Mission Control migration, this commit just updates the existing
lnwire21/onion_error.go file with the new CodeInvalidBlinding code. The
lnwire21 should not really ever be updated but adding a new code should
be fine as it does not affect old migrations since this is a new code.
2024-09-30 08:58:15 +02:00
Elle Mouton 8663950c68 feature: remove b11 feature bit from default invoice set 2024-09-25 14:32:52 +09:00
Elle Mouton f1015cd58d server: stop interceptable switch in Stop 2024-09-25 14:32:52 +09:00
Elle Mouton 0bd76ffe32 invoices: init quit channel of modifier
Also add atomic start and stop vars to prevent close of a closed
channel.
2024-09-25 14:32:29 +09:00
Elle Mouton 7dc86acb8c multi: update PaymentAddr to use fn.Option
Since it is allowed to not be set and so can lead to nil deref panics if
it is a pointer.
2024-09-25 11:14:35 +09:00
Elle Mouton 077273e66e docs: update release notes 2024-09-18 16:20:28 +02:00
Elle Mouton a62201b61d netann: add chan update 2 validate and verify funcs 2024-09-18 16:20:28 +02:00
Elle Mouton 580c10477f lnwire: add ChannelUpdate2
Add the new ChannelUpdate2 message and ensure that it implements the
ChannelUpdate interface.
2024-09-18 16:20:28 +02:00
Elle Mouton 21c9ef8904 netann: validation and verification funcs for ChannelAnnouncement2 2024-09-18 16:14:59 +02:00
Elle Mouton 5fc1da3abe netann: add MsgHash helper
This commit adds the MsgHash helper function which can be used to
calculate the digest of a message to be signed using schnorr signatures.
2024-09-18 16:14:59 +02:00
Elle Mouton a438eb3af3 lnwire: add ChannelAnnouncement2 message
And ensure that it implements the ChannelAnnouncement interface.
2024-09-18 16:14:59 +02:00
Elle Mouton 66302ceb29 lnwire: make RawFeatureVector a Record producer 2024-09-18 16:14:58 +02:00