Commit Graph
100 Commits
Author SHA1 Message Date
eugene 25a0fe2902 docs: update release notes for 0.13.3 2021-09-30 13:44:35 -04:00
eugene 702b3a3258 multi: introduce config-level DustThreshold for defining threshold 2021-09-30 13:44:35 -04:00
eugene 3897baff0a htlcswitch: call evaluateDustThreshold in SendHTLC, handlePacketForward
This commit makes SendHTLC (we are the source) evaluate the dust
threshold of the outgoing channel against the default threshold of
500K satoshis. If the threshold is exceeded by adding this HTLC, we
fail backwards. It also makes handlePacketForward (we are forwarding)
evaluate the dust threshold of the incoming channel and the outgoing
channel and fails backwards if either channel's dust sum exceeds the
default threshold.
2021-09-30 13:44:34 -04:00
eugene 0ce6194e1e htlcswitch: extend ChannelLink iface with dustHandler iface
This allows the Switch to determine the dust exposure of a certain
channel and allows the link to set the feerate of the mailbox given
a fee update.
2021-09-30 13:44:34 -04:00
eugene 0b24603aef htlcswitch: extend Mailbox iface with dust, fee methods
This commit extends the Mailbox interface with the SetDustClosure,
SetFeeRate, and DustPackets methods. This enables the mailbox to
report the dust exposure to the Switch when the Switch decides whether
to forward a dust packet. The dust is counted from the time an Add is
introduced via AddPacket until it is removed via AckPacket. This can
lead to some packets being counted twice before they are signed for,
but this is a trade-off between accuracy and simplicity.
2021-09-30 13:44:34 -04:00
eugene 7d16e58b5c lnwallet: introduce GetDustSum method to calculate worst-case dust sum
It over-estimates the local or remote commitment's dust sum by
counting all updates in both updateLogs that are dust using the
trimmed-to-dust mechanism if applicable. The over-estimation is done
because ensuring an accurate counting is a trade-off between code
simplicity and accuracy.
2021-09-30 13:44:26 -04:00
eugene b0018f2387 docs: update release notes for 0.14.0 2021-09-29 17:09:29 -04:00
eugene 49877545ba htlcswitch: fix flake in TestShutdownIfChannelClean
When Alice receives a CommitSig near the end of the test, the test
assumed that she wouldn't reply with a RevokeAndAck message before
shutdownAssert was called. This led to a test flake. Instead, only
call shutdownAssert after we've received the RevokeAndAck.
2021-09-29 17:04:53 -04:00
eugene b8bfaf076f docs: update release notes for 0.13.3 2021-09-29 13:33:12 -04:00
eugene 950063840a funding+lnwallet: validate ChannelReserve is above DustLimit
This is necessary and is implied by BOLT#02. Both ChannelReserve
parameters should be above both DustLimit parameters. Otherwise,
it is possible for one side to have nothing at stake.
2021-09-29 13:33:12 -04:00
eugene fdcd726f9a multi: replace DefaultDustLimit with script-specific DustLimitForSize
This commit updates call-sites to use the proper dust limits for
various script types. This also updates the default dust limit used
in the funding flow to be 354 satoshis instead of 573 satoshis.
2021-09-29 13:33:10 -04:00
eugene 868958d2bc docs: update release notes for 0.14 2021-09-13 13:29:51 -04:00
eugene aeaa009e92 peer+chancloser: tryLinkShutdown during cooperative close process
Adds a new Brontide struct method tryLinkShutdown that attempts to
fetch the target link and calls ShutdownIfChannelClean on it. This
allows the coop close process to guarantee atomicity of the underlying
channel state. Also removes the UnregisterChannel method from the
chancloser's config as the link is shut down before the chancloser
is created.
2021-09-13 13:29:51 -04:00
eugene 608d11dcbc peer: add mockUpdateHandler for use in mockMessageSwitch 2021-09-13 13:29:50 -04:00
eugene b2e90480ed htlcswitch: extend ChannelLink interface with ShutdownIfChannelClean
This allows a caller to ensure to optimistically shut down the link
if the channel is clean. If the channel is not clean, an error is
returned and the link continues functioning as normal. The caller
should also call RemoveLink to ensure that the link isn't seen as
usable within the switch.
2021-09-13 13:29:50 -04:00
eugene 7621d7f902 lnwallet: add IsChannelClean method and related tests
Adds a method to the LightningChannel struct called IsChannelClean
that returns a boolean telling the caller whether the channel state
is clean or not. Clean in this case means there are no lingering
updates to be signed for, no HTLC's active on either sides commitment
transaction, and no pending commitments on either side. This can be
used for dynamic commitments or during a strict cooperative close
process that ensures atomicity of the channel.
2021-09-13 13:29:43 -04:00
eugene 74693ed491 docs: update release notes for 0.14.0 2021-09-01 16:49:28 -04:00
eugene 2fbee31c6e chainntnfs: populate spendsByHeight during historical dispatch
This commit fixes a buggy scenario where:
- a spend of the desired outpoint occurs
- RegisterSpend is called, not immediately notifying
- caller performs a historical dispatch, calling UpdateSpendDetails
- caller is notified on the Spend channel
- re-org occurs
- caller is not notified of the re-org
We fix this by correctly populating the spendsByHeight map when
dispatchSpendDetails is called. This mirrors the confirmation case.
2021-09-01 16:45:13 -04:00
eugene 9f6f5e963a docs: update release notes for 0.14 2021-08-27 14:12:02 -04:00
eugene de71195bcb chainntnfs/neutrinonotify: update EndHeight after filter update
After the error is received on the filter update errChan, update the
EndHeight if we're performing a historical scan. If a block was mined
after the call to RegisterConf/RegisterSpend but before the filter was
updated, then the block would not have the filter applied. This means
that a block containing the desired conf/spend parameters would be
undetected. Fix this by ensuring the historical scan also includes this
height, as it would previously not be included.
2021-08-27 14:12:02 -04:00
eugene 0d39c0799a chainntnfs/neutrinonotify: call drainChainUpdates when updating filter
Moves filter handling logic for connecting blocks to the
connectFilteredBlock method. The disconnect logic now lives in
disconnectFilteredBlock. After updating the filter, drainChainUpdates
is called which will drain everything from the chainUpdates chan and
apply all updates by calling either connectFilteredBlock or
disconnectFilteredBlock. This will allow callers to update their
EndHeight if performing a historical dispatch, as blocks up to this
height may not have had the filter applied.
2021-08-27 14:12:01 -04:00
eugene b7de0eae93 chainntnfs/neutrinonotify: make chainUpdates a buffered chan
ConcurrentQueue has internal structures so if a filterUpdate exists
in it, the idea of draining the queue may not work reliably. The
update may exist in the ConcurrentQueue but may not be available via
ChanOut() when we're ready to drain the ConcurrentQueue. Fix this by
using a regular buffered chan, which will either have the update or
not have the update. Its size is set to 100 as our tests may generate
quite a bit of updates.
2021-08-27 14:12:01 -04:00
eugene 86f28cdc1d chainntnfs: skip conf dispatch if ntfn already dispatched
This mirrors the logic for the spend case. This prevents a double
dispatch scenario when combined with a later commit. Otherwise, the
confirmation would linger in the buffer which is not ideal.
2021-08-27 14:11:55 -04:00
eugene c3ac95abbd docs: update release notes for 0.14 2021-08-11 16:59:16 -04:00
eugene 9cea8741b1 fuzz/lnwire: minor touch-ups, remove MaxPayloadLength
This commit makes the fuzz/lnwire tests build and run without
crashing.
2021-08-11 16:59:16 -04:00
eugene cbbad3a674 docs: update release notes for 0.14 2021-08-11 15:37:53 -04:00
eugene d0191cb5ed rpcserver: validate FinalCltvDelta and CltvLimit for REST
Missed this check in PR #5293.
2021-08-11 15:37:53 -04:00
eugene db4a488e23 docs: update 0.14 release notes 2021-08-10 17:15:52 -04:00
eugene 23a4fad4ac htlcswitch+peer: CreateAndAddLink in switch, add messageSwitch to peer
This commit allows the peer to be tested without relying on a raw
htlcswitch.Switch pointer. This is accomplished by using a messageSwitch
interface and adding the CreateAndAddLink method to the
htlcswitch.Switch.
2021-08-10 17:15:52 -04:00
eugene e72468646c htlcswitch+peer: embed ChannelUpdateHandler in ChannelLink
GetLink, GetLinksByInterface now use ChannelUpdateHandler.
2021-08-10 17:15:52 -04:00
eugene 051cd8793a htlcswitch: introduce and embed packetHandler interface in ChannelLink
This will allow separating the now-private *htlcPacket methods from
the publicly-used ChannelLink interface methods.
2021-08-10 17:15:51 -04:00
eugene 6c6e353597 htlcswitch+peer: pass BestHeight to ChannelLinkConfig
This allows non-test usages of ChannelLinkConfig to omit the raw
htlcswitch.Switch pointer.
2021-08-10 17:15:49 -04:00
eugene 13d7e97a84 docs: update fuzz.md to explain new build/run process 2021-06-16 12:49:26 -04:00
eugene 6d04f11f94 lnwallet+funding: sanitize upfront_shutdown_script
Otherwise, we would get non-standard txn's and fail to broadcast
them when cooperatively closing a channel. This wouldn't affect
funds security as no HTLCs would be active to steal. This is just
a safety measure as we should only generate standard txn's.
2021-06-11 10:46:21 -04:00
eugene 17646b0c04 go.mod: update btcutil, btcutil/psbt commits for psbt fix
This pulls in the latest btcutil and btcutil/psbt commits which
include a panic fix for malformed PSBT inputs.
2021-05-20 15:56:42 -04:00
eugene a70d0bef34 multi: validate payment params at RPC layer
With this patch, we'll fail out earlier in the cycle in case of
some wonky parameters, and not leave zombie payments in the router
which currently are not cleaned up.
2021-05-13 17:17:52 -04:00
eugene fa5627b779 lnwallet/chanfunding: non-segwit spend Verify test
Also fixes error-handling in the Verify test when expectedErr == ""
2021-04-22 13:04:25 -04:00
eugene b3f14d66f0 lnwallet/chanfunding: assert PSBT Inputs have WitnessUtxo 2021-04-22 13:04:24 -04:00
eugene 9e2cccdbbd docs: add malleability note in psbt.md 2021-04-22 13:04:23 -04:00
eugene 0547364091 lnwallet: add test for state machine regression 2021-04-21 17:42:56 -04:00
eugene 7da2080a3d lnwallet: use tail() instead of tip() in getUnsignedAckedUpdates
The previous behavior would allow updates to be overwritten in some
scenarios. Upon restart, this would lead to a missing settle/fail in
the update logs.
2021-04-21 17:42:56 -04:00
eugene 97007fc4fa lnwallet: fix logUpdate scope in restorePendingLocalUpdates 2021-04-21 17:42:56 -04:00
eugene 9d0d5bdfaf channeldb: AdvanceCommitChainTail clarification comment 2021-04-21 17:42:53 -04:00
eugene 8b463fbc2b lnd: optionally listen on localhost for better security
The --profile flag now accepts both a port and a host:port string.
If profile is set to a port, then pprof debugging information will
be served over localhost. Otherwise, we will attempt to serve pprof
information on the specified host:port (if we are allowed to listen
on it.)

We default to the safe option as if the port is connectable, anybody
can connect and see debugging information.

See: https://mmcloughlin.com/posts/your-pprof-is-showing
2021-04-01 12:14:24 -04:00
Eugene 6dca38c561 Merge pull request #5073 from Crypt-iQ/writemessage_03042021
lnwire: remove MaxPayloadLength from lnwire.Message interface
2021-03-09 04:50:40 -08:00
eugene 99a7271289 lntest/itest+lnwallet: add legacy chanrestore test
The test makes use of a nextRevocationProducer that is only used during
integration tests.
2021-03-05 12:49:18 -05:00
eugene bb84f0ebc8 multi: store KeyLocator in OpenChannel, use ECDH
This commit adds a RevocationKeyLocator field to the OpenChannel
struct so that the SCB derivation doesn't have to brute-force the
sha chain root key and match the public key. ECDH derivation is now
used to derive the key instead of regular private key derivation a
la DerivePrivKey. The legacy can still be used to recover old
channels.
2021-03-05 12:49:18 -05:00
eugene 986e69c81b channeldb: add KeyLocator Record 2021-03-05 12:49:16 -05:00
eugene 7ff04d8bad lnwire: remove MaxPayloadLength from Message interface
Removes the MaxPayloadLength function from the Message interface
and checks that each message payload is not greater than MaxMsgBody.
Since all messages are now allowed to be 65535 bytes in size, the
MaxPayloadLength is no longer needed.
2021-03-04 16:48:10 -05:00
eugene bc238ee84c lnd+lnwallet: make capacity check stricter by adding fee
Also patches breacharbiter tests by using the correct commitment
fee and balances.
2021-02-22 12:07:21 -05:00
eugene 80eb5dbece lncfg: add isIPv6Host helper to force v6 addrs through system resolver
With this commit, if --tor.active is specified, then IPv6 addresses
will no longer go through the connmgr.TorLookupIP function from btcd.
This function does not have proper IPv6 support and would fail with
the error "tor general error". Instead, use the system resolver.
2021-02-05 15:37:39 -05:00
eugene 1c407f4026 htlcswitch: reestablish unit tests 2021-02-03 16:47:47 -05:00
eugene 9b09895bde channeldb+lnwallet: lastWasRevokeKey to store last sent rev/sig 2021-02-03 16:43:04 -05:00
eugene f8b98a1d3b lntest/channels: introduce subpackage to deduplicate static structs 2021-01-25 14:04:39 -05:00
Eugene e0439965bb Merge pull request #4757 from Crypt-iQ/fmgr_1109
funding: move Manager to own package
2020-12-17 11:43:12 -05:00
eugene dcdf36f410 lnd+funding: move Manager to funding, change references 2020-12-17 10:45:05 -05:00
eugene e7e872f19a lnd: remove Manager's stop method, linter complaints 2020-12-17 09:50:55 -05:00
eugene 936227798a lnd: remove openChanReq, call InitFundingWorkflow with InitFundingMsg 2020-12-17 09:50:48 -05:00
eugene e85baea1b3 lnd: export InitFundingMsg 2020-12-17 09:36:34 -05:00
eugene 105e961b20 lnd: export Manager's InitFundingWorkflow method 2020-12-17 09:36:34 -05:00
eugene 1b84d07c4d lnd+funding: register funding logger 2020-12-17 09:36:34 -05:00
eugene 6a209bbdaf lnd: export Manager, NewFundingManager 2020-12-17 09:36:34 -05:00
eugene f43fd32daf lnd: remove PendingChannels call from fundingManager 2020-12-17 09:36:34 -05:00
eugene 9c72dd9eba funding+peer: rename Manager interface to Controller 2020-12-17 09:36:34 -05:00
eugene caa0f5da6a multi: move and export funding-related vars to funding package
Also moves the lnd global MaxFundingAmount to server.go
2020-12-17 09:36:34 -05:00
eugene f6524aabcb lnd+funding: use funding.WriteOutpoint instead of lnd version
This commit duplicates the utxonursery's writeOutpoint function
in the funding package so that when the rest of the fundingmanager
code is moved, it can use the WriteOutpoint function for its
channel opening state data.
2020-12-17 09:36:34 -05:00
eugene 61e0f67edf funding: rename from fmgr, change references 2020-12-17 09:36:34 -05:00
eugene f4593f95f4 channeldb/migration20: TestMigrateOutpointIndex 2020-12-10 17:37:59 -08:00
eugene 204b6c51cf channeldb: MigrateOutpointIndex, store indexStatus in outpoint index
Adds an outpoint index that stores a tlv stream. Currently the stream
only contains the outpoint's indexStatus. This should cut down on
big bbolt transactions in several places throughout the codebase.
2020-12-10 17:37:59 -08:00
eugene 81783d682b make: add zpay32 to fuzz_flags.mk 2020-11-30 07:59:41 -05:00
Eugene 225390ab5b Merge pull request #4487 from Crypt-iQ/cc_pkg_0723
chainreg: new chainreg package
2020-10-30 06:07:26 -04:00
Eugene 9571088756 lnd: log errors for ChainControl when shutting down 2020-10-29 15:24:17 -04:00
Eugene bebe258e2d chainregistry+lnd: moving chainregistry+chainparams to new package 2020-10-29 15:24:14 -04:00
Eugene 46ef212de4 lnd+lncfg: move normalizeNetwork to lncfg 2020-10-29 15:20:00 -04:00
Eugene 4d238cfa2f lnd: export ChainControl, ChainRegistry 2020-10-29 15:20:00 -04:00
Eugene cbdea57d52 chainregistry.go: export default values
This is needed so that git sees a subsequent commit as a code move.
2020-10-29 15:19:58 -04:00
Eugene f4fe76aaf1 chainreg: add Config, move chainparams.go
Creates a Config that initializes the chainregistry struct in the
lnd package. Also moves all of chainparams.go to the chainreg
package.
2020-10-29 15:19:58 -04:00
Eugene 933b959aa8 chainreg: export ChainCode to new pkg
Moves chainCode from the lnd package to the chainreg package,
where it is exported and can be used by other packages.
2020-10-29 15:19:57 -04:00
eugene afb6ad295e lnd: move initNeutrinoBackend to lnd.go 2020-10-29 15:19:56 -04:00
Eugene 426db548dd Merge pull request #4651 from Crypt-iQ/zpay32_fuzz
fuzz/zpay32: add Decode/Encode fuzz tests.
2020-10-22 10:23:24 -04:00
eugene bbe85f3c16 fuzz/zpay32: add Decode/Encode fuzz tests.
These can be expanded on in the future. Encoding is currently done
with a static key for test determinism.
2020-10-21 06:42:54 -04:00
Eugene 9e75c3eade Merge pull request #4682 from Crypt-iQ/fuzz_ret_1009
fuzz: change return values to 1 rather than 0 or -1
2020-10-14 16:07:54 -04:00
eugene f82653cb06 fuzz: change return values to 1 rather than 0 or -1
This allows gofuzz to store the mutating input as coverage if it reaches
any new coverage, even if it didn't make it to the end of the test.
2020-10-13 15:17:57 -04:00
Eugene 10a84f2c75 Merge pull request #4649 from Crypt-iQ/fmgr_abstract
multi: add fmgr.Manager interface, change usage in peer to use Manager
2020-10-02 08:21:15 -04:00
eugene e0859e121f multi: add fmgr.Manager interface, change usage in peer to use Manager
This gets rid of several config functions in the peer and should pave
the way for easier testing of the funding manager and peer.
2020-10-01 10:27:13 -04:00
Eugene 0a8f06651a Merge pull request #4645 from Crypt-iQ/peer_messageconn
peer: abstractions to aid in unit testing
2020-09-25 13:58:02 -04:00
eugene fada3dd871 server.go + peer: use MessageConn interface instead of brontide.Conn 2020-09-25 12:05:36 -04:00
Eugene cc29e1cce8 Merge pull request #4640 from Crypt-iQ/brontide_fuzz_fixups
fuzz/brontide: fix fuzz_utils.go NewBrontideMachine callsites
2020-09-24 00:53:43 -04:00
eugene 6ba35238ef fuzz/brontide: fix fuzz_utils.go NewBrontideMachine callsites 2020-09-22 15:53:49 -04:00
eugene ea467783e9 htlcswitch+peer: remove fwd pkgs once before tick, bump timer to 1hr
This commit changes the logic when garbage collecting forwarding
packages such that they are removed once when the function is called,
and then again upon subsequent ticks. This allows us to bump the
peer timer to 1 hour to limit the number of db transactions happening
in lnd. The forwarding packages need to be removed initially as
otherwise a flappy node will never have them garbage collected.
2020-08-31 20:52:51 -04:00
eugene 62e19185f1 htlcswitch+channeldb: single tx for removing fwdpkgs
This commit changes RemoveFwdPkg to RemoveFwdPkgs so that a single
tx is used instead of N where N is the number of fwd pkgs to remove.
2020-08-31 20:52:51 -04:00
eugene 9ce89c1b46 lnd: delete mock.go, move mockSpendNotifier to lntest/mock 2020-08-31 20:06:11 -04:00
eugene 4ff03afee0 lnd: move fundingBroadcastHeight to fundingmanager_test.go 2020-08-31 19:42:53 -04:00
eugene c7cbacc35b multi: move mockChainIO, mockNotifier to lntest/mock 2020-08-31 19:41:09 -04:00
eugene 3fa5d042c9 multi: move mockWalletController, mockSecretKeyRing to lntest/mock 2020-08-31 18:36:05 -04:00
eugene 49d8f04197 multi: migrate instances of mockSigner to the mock package
This commit moves all localized instances of mock implementations of
the Signer interface to the lntest/mock package. This allows us to
remove a lot of code and have it housed under a single interface in
many cases.
2020-08-28 15:43:51 -04:00
nsa 3791c9efcb lnd: removing activeNetParams global, passed around instead via configs
This commit removes the activeNetParams global in chainparams.go. This
is necessary to isolate code from the lnd package so we can import it
for use in tests, other projects, etc.
2020-08-11 11:41:24 -04:00
nsa c36840c2a5 lnwallet: add regression test TestChannelLocalUnsignedUpdatesFailure
This commit includes a regression test that checks that we remember
to restore updates that we sent to the peer but they haven't sent
us a signature for yet.
2020-07-29 19:03:44 -04:00
nsa e4188ba9c2 channeldb+lnwallet: store updates the peer should sign under new key
This fixes a long-standing force close bug. When we receive a
revocation, store the updates that the remote should sign next under
a new database key. Previously, these were not persisted which would
lead to force closure.
2020-07-29 19:03:44 -04:00
nsa b6eff5b0ec lnwallet: add regression test TestChannelUnsignedAckedFailure
This commit includes a regression test that checks that a force
close won't occur and that unsigned acked updates are properly
restored.
2020-07-27 16:18:11 -04:00