Commit Graph

1484 Commits (fd971d4951912a4c82683a28b1b5695ca130e272)
 

Author SHA1 Message Date
Boris Nagaev fd971d4951
sweepbatcher: add field SweepInfo.MinFeeRate
MinFeeRate is minimum fee rate that must be used by a batch of
the sweep. If it is specified, confTarget is ignored.

This is useful for external source of fees.
3 months ago
Boris Nagaev 4e085f11a3
Merge pull request #783 from starius/sweepbatcher-WithNoBumping
sweepbatcher: add option WithNoBumping
3 months ago
Boris Nagaev 1b9e3069a8
sweepbatcher: add option WithNoBumping
It disables fee bumping. It is useful when fee rate is set externally.

Add test for fee bumping, testing both modes.
3 months ago
Boris Nagaev bff1fd8004
Merge pull request #782 from starius/sweep-GetSweepFeeDetails
sweep: factor out method GetSweepFeeDetails
3 months ago
Boris Nagaev 84ae3667d5
sweep: factor out method GetSweepFeeDetails
It was factored out from GetSweepFee method. It provides fee rate
and weight in addition to absolute fee.
3 months ago
Boris Nagaev 0ec63a61d4
Merge pull request #778 from starius/sweepbatcher-sql-test
sweepbatcher: unit tests with SQL loopdb as well
3 months ago
Boris Nagaev 029d0870b5
sweepbatcher: unit tests with SQL loopdb as well
This is needed to cover the code of SQLStore with tests.

To achieve compatibility with loopdb (SQLite), the following changes were done:

 - DestAddr is filled to avoid crash in SQL layer
 - Preimage is filled to avoid uniqueness checks by the DB
 - the code working with batch IDs was changed to work correctly
   when batch_id starts with 1 instead of 0
 - SQL swap store has to have a swap with swap_hash from sweep
   to satisfy foreign key constraint of the DB
3 months ago
Boris Nagaev 137dd80d39
sweepbatcher: use %w for wrapped errors
Fix errors.Is(err, context.Canceled) check in tests.
3 months ago
Boris Nagaev a4e01027ea
Merge pull request #781 from starius/sweepbatcher-exectx
loopdb: parameterize ExecTx with subset of methods used by a package
3 months ago
Boris Nagaev d6aa4fe8a9
loopdb: all BaseDB's methods use receiver name db 3 months ago
Boris Nagaev 4c2d874b8d
loopdb: use passed transaction in ExecTx calls
Some calls used external queries instead of the passed one,
bypassing the transaction.
3 months ago
Boris Nagaev 1947b90842
multi: typed callback in ExecTx
Provide a wrapped store type, exposing ExecTx method with a subset
interface in the callback argument. BaseDB interfaces in instantout,
reservation and sweepbatcher use ExecTx with their subset Querier
instead of whole sqlc.Querier (*sqlc.Queries).

This is needed to make the packages more reusable, so they don't
depend on methods of *sqlc.Queries they don't use.
3 months ago
Boris Nagaev d341448568
loopdb: fix description of BaseDB.ExecTx 3 months ago
Boris Nagaev 2847e83fcf
multi: separate Querier from BaseDB interfaces
A Querier holds the methods of sqlc.Querier interface relevant for a package.
BaseDB has Querier + ExecTx method.

This change is needed to simplify further rework of ExecTx.
3 months ago
Boris Nagaev 8d8cd9129f
reservation: add missing BaseDB interface method
Method InsertReservationUpdate was missing in the interface.
3 months ago
Boris Nagaev 91507d8633
reservation: fix description of UpdateReservation
The description was from another method (InsertReservationUpdate).
3 months ago
Boris Nagaev 4ad86b615a
Merge pull request #779 from starius/sweepbatcher-fix-race
sweepbatcher: fix race condition when stopping
3 months ago
Boris Nagaev c34d04e2f7
sweepbatcher: fix race condition when stopping
The race was detected in CI and locally when running with -race.
It happened between the following calls:

WARNING: DATA RACE
Write at 0x00c0003e6638 by goroutine 1374:
  runtime.racewrite()
      <autogenerated>:1 +0x1e
  github.com/lightninglabs/loop/sweepbatcher.(*batch).Wait()
      sweepbatcher/sweep_batch.go:463 +0x6e
  github.com/lightninglabs/loop/sweepbatcher.(*Batcher).Run.func1()
      sweepbatcher/sweep_batcher.go:272 +0x10e

Previous read at 0x00c0003e6638 by goroutine 1388:
  runtime.raceread()
      <autogenerated>:1 +0x1e
  github.com/lightninglabs/loop/sweepbatcher.(*batch).monitorConfirmations()
      sweepbatcher/sweep_batch.go:1144 +0x285
  github.com/lightninglabs/loop/sweepbatcher.(*batch).handleSpend()
      sweepbatcher/sweep_batch.go:1309 +0x10e4
  github.com/lightninglabs/loop/sweepbatcher.(*batch).Run()
      sweepbatcher/sweep_batch.go:526 +0xb04
  github.com/lightninglabs/loop/sweepbatcher.(*Batcher).spinUpBatch.func1()
      sweepbatcher/sweep_batcher.go:455 +0xbd

The race was caused because wg.Add(1) and wg.Wait() were running from different
goroutines (one goroutine was running batch.Run() and another - batcher.Run()).

To avoid this scenario, wg.Wait() call was moved into batch.Run() call, so it
waits itself for its children goroutines, after which the channel b.finished
is closed, and it serves a signal for external waiters (the batcher, calling
batch.Wait()).

Also the channel batch.stopped was renamed to batch.stopping to better reflect
its nature.

Added TestSweepBatcherCloseDuringAdding to make sure adding a sweep during
shutting down does not cause a crash. The test did not catch the original
race condition.
3 months ago
Boris Nagaev 8f985143e2
Merge pull request #780 from starius/sweepbatcher-dropbatch-writetx
sweepbatcher: use write tx in DropBatch
3 months ago
Boris Nagaev b311649ce4
sweepbatcher: use write tx in DropBatch 3 months ago
Boris Nagaev 3fd3fab8d1
loopdb: provide function NewSqlWriteOpts
It returns transaction options resulting in full (read+write) tx.

Use it in loopdb and instantout stores.
3 months ago
Slyghtning 174a6b888b
Merge pull request #777 from hieblmi/refactor-select-hop-hints
utils: refactor SelectHopHints to use narrower interface
3 months ago
Slyghtning 5b797055f8
utils: refactor SelectHopHints to use narrower interface 3 months ago
Slyghtning 3b3d3ac64f
Merge pull request #776 from chengehe/master
chore: make function comments match function names
3 months ago
chengehe 0aff202988 chore: make function comments match function names
Signed-off-by: chengehe <hechenge@yeah.net>
3 months ago
Alex Bosworth 88c7194e2e
Merge pull request #775 from lightninglabs/alexbosworth-patch-3
version: bump version to v0.28.5-beta
4 months ago
Alex Bosworth 2efe224b9a
version: bump version to v0.28.5-beta 4 months ago
Konstantin Nick 557ac34959
Merge pull request #774 from jinjingroad/master
chore: fix some comments
4 months ago
jinjingroad 12bc3b2e9e chore: fix some comments
Signed-off-by: jinjingroad <jinjingroad@sina.com>
4 months ago
András Bánki-Horváth d47158d58e
Merge pull request #773 from bhandras/cost-migraton-pagination
loop: paginate fetching payments when running the cost migration
4 months ago
Andras Banki-Horvath 3754730525
loop: paginate fetching payments when running the cost migration 4 months ago
Alex Bosworth 4652417b25
Merge pull request #772 from lightninglabs/alexbosworth-patch-2
version: bump version to v0.28.4-beta
4 months ago
Alex Bosworth 6fe1686cc6
version: bump version to v0.28.4-beta 4 months ago
András Bánki-Horváth 18b0de3c5e
Merge pull request #771 from bhandras/cost-migration-timeout
loopd: make the LND RPC timeout configurable and fix cost migration for pending swaps
4 months ago
Andras Banki-Horvath 9cacd8eb75
loop: fix cost migration for pending swaps 4 months ago
Andras Banki-Horvath 28c09bec68
loopd: make the LND RPC timeout configurable 4 months ago
Boris Nagaev 3d1d3eb4aa
Merge pull request #766 from starius/sweepbatcher-sweep-fetcher
sweepbatcher: factor out loopdb-less version
4 months ago
Boris Nagaev 0c2ba74dba
sweepbatcher: factor out loopdb-less version
Changed argument of function NewBatcher from LoopOutFetcher to SweepFetcher
(returning new public type SweepInfo).
This change is backwards-incompatible on the package layer, but nobody seems
to use the package outside of Loop.

To use NewBatcher inside Loop, turn loopdb into SweepFetcher using
function NewSweepFetcherFromSwapStore.
4 months ago
Boris Nagaev 295198a902
Merge pull request #770 from starius/lnd-v0.18.0-beta.1
go.mod: update LND to v0.18.0-beta.1
4 months ago
Boris Nagaev 99a0f831b3
go.mod: update LND to v0.18.0-beta.1
This is the same as v0.18.0-beta.
4 months ago
Konstantin Nick c5245e1009
Merge pull request #769 from lightninglabs/fix_docker_build
build: fix dockerfile
4 months ago
sputn1ck 890718d0ee build: fix dockerfile 4 months ago
Alex Bosworth 67ab876879
Merge pull request #768 from lightninglabs/alexbosworth-patch-2
version: bump version to v0.28.3-beta
4 months ago
Alex Bosworth 9b1218a752
version: bump version to v0.28.3-beta 4 months ago
András Bánki-Horváth 55241ffe04
Merge pull request #764 from bhandras/costs-cleanup-migration
loop: add migration to fix stored loop out costs
4 months ago
Andras Banki-Horvath c7fa1e4109
loopd: run the cost migration on start 4 months ago
Andras Banki-Horvath f40ef193e9
loop: add migration for loopout swaps to fix negative stored costs
Previously we may have stored negative costs for some loop out swaps
which this commit attempts to correct by fetching all completed swap,
calculating the correct costs and overriding them in the database.
4 months ago
Andras Banki-Horvath c650cdc8a8
loopdb: add ability to track manual migrations 4 months ago
Andras Banki-Horvath 4f5c806ba5
loopdb: add helper methods to update swap costs
This commit adds the necessary sqlc code and SwapStore function to
update swap costs for all swaps in one transaction.
4 months ago
Andras Banki-Horvath 08aa4db35d
loopout: correctly account for the prepay amount when calculating costs
Previously we'd not account for the prepay amount which resulted in the
total swap cost reported being lower than what it actually is.
4 months ago