Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reapply 8644 on 9260 #9313

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
001a789
sweep: add new state `TxFatal` for erroneous sweepings
yyforyongyu Apr 30, 2024
bdd97d7
sweep: add new error `ErrZeroFeeRateDelta`
yyforyongyu Oct 25, 2024
e295cd1
sweep: add new interface method `Immediate`
yyforyongyu Oct 25, 2024
fadcf9c
sweep: handle inputs locally instead of relying on the tx
yyforyongyu Oct 25, 2024
027ac83
sweep: add `handleInitialBroadcast` to handle initial broadcast
yyforyongyu Oct 25, 2024
05d0033
sweep: remove redundant error from `Broadcast`
yyforyongyu Apr 30, 2024
7da0eb0
sweep: add method `handleBumpEventError` and fix `markInputFailed`
yyforyongyu Apr 30, 2024
4e04844
sweep: add method `isMature` on `SweeperInput`
yyforyongyu Apr 30, 2024
038a8c0
sweep: make sure defaultDeadline is derived from the mature height
yyforyongyu Apr 30, 2024
be5f15f
sweep: remove redundant loopvar assign
yyforyongyu Oct 25, 2024
d0d8d4c
sweep: break `initialBroadcast` into two steps
yyforyongyu Nov 7, 2024
6b891a9
sweep: make sure nil tx is handled
yyforyongyu Nov 7, 2024
a2d0748
chainio: introduce `chainio` to handle block synchronization
yyforyongyu Jun 27, 2024
8cf0c3d
chainio: implement `Blockbeat`
yyforyongyu Jun 27, 2024
2683dd9
chainio: add helper methods to dispatch beats
yyforyongyu Oct 31, 2024
7bc96e8
chainio: add `BlockbeatDispatcher` to dispatch blockbeats
yyforyongyu Jun 27, 2024
f648d3c
chainio: add partial implementation of `Consumer` interface
yyforyongyu Oct 17, 2024
d034718
multi: implement `Consumer` on subsystems
yyforyongyu Oct 29, 2024
5274a6e
sweep: remove block subscription in `UtxoSweeper` and `TxPublisher`
yyforyongyu Jun 4, 2024
7512a93
sweep: remove redundant notifications during shutdown
yyforyongyu Nov 18, 2024
472eccb
contractcourt: remove `waitForHeight` in resolvers
yyforyongyu Jun 4, 2024
3a1d1a5
contractcourt: remove block subscription in chain arbitrator
yyforyongyu Oct 29, 2024
e72c993
contractcourt: remove block subscription in channel arbitrator
yyforyongyu Oct 29, 2024
1230f57
contractcourt: remove the `immediate` param used in `Resolve`
yyforyongyu Jun 4, 2024
7ac658a
contractcourt: start channel arbitrator with blockbeat
yyforyongyu Oct 29, 2024
6c9bdb2
multi: start consumers with a starting blockbeat
yyforyongyu Oct 29, 2024
06cab5e
lnd: add new method `startLowLevelServices`
yyforyongyu Oct 17, 2024
ebbe0d5
lnd: start `blockbeatDispatcher` and register consumers
yyforyongyu Oct 17, 2024
8f3928f
contractcourt: fix linter `funlen`
yyforyongyu Oct 29, 2024
ff6b9cf
multi: improve loggings
yyforyongyu May 22, 2024
437595d
chainio: use `errgroup` to limit num of goroutines
yyforyongyu Nov 19, 2024
1643508
chainio: update `fn` to `v2`
yyforyongyu Dec 10, 2024
82d77bb
contractcourt: add verbose logging in resolvers
yyforyongyu Jun 20, 2024
3cb48a0
contractcourt: add spend path helpers in timeout/success resolver
yyforyongyu Nov 13, 2024
10d9544
contractcourt: add sweep senders in `htlcSuccessResolver`
yyforyongyu Nov 14, 2024
693287f
contractcourt: add resolver handlers in `htlcSuccessResolver`
yyforyongyu Nov 14, 2024
fe29961
contractcourt: remove redundant return value in `claimCleanUp`
yyforyongyu Nov 14, 2024
7e0623c
contractcourt: add sweep senders in `htlcTimeoutResolver`
yyforyongyu Nov 14, 2024
066d351
contractcourt: add methods to checkpoint states
yyforyongyu Jul 16, 2024
c108487
contractcourt: add resolve handlers in `htlcTimeoutResolver`
yyforyongyu Jul 16, 2024
d78fd7a
contractcourt: add `Launch` method to anchor/breach resolver
yyforyongyu Jun 24, 2024
629c037
contractcourt: add `Launch` method to commit resolver
yyforyongyu Jun 20, 2024
406f443
contractcourt: add `Launch` method to htlc success resolver
yyforyongyu Jul 15, 2024
dcf7144
contractcourt: add `Launch` method to htlc timeout resolver
yyforyongyu Jul 16, 2024
dfaff63
invoices: exit early when the subscriber chan is nil
yyforyongyu Nov 17, 2024
fe4ab4e
contractcourt: add `Launch` method to incoming contest resolver
yyforyongyu Nov 17, 2024
dbfe5df
contractcourt: add `Launch` method to outgoing contest resolver
yyforyongyu Jun 20, 2024
1c8cbc8
contractcourt: fix concurrent access to `resolved`
yyforyongyu Jul 10, 2024
b6c4dd9
contractcourt: fix concurrent access to `launched`
yyforyongyu Jul 11, 2024
b3cec2c
contractcourt: break `launchResolvers` into two steps
yyforyongyu Jun 25, 2024
7751b1b
contractcourt: offer outgoing htlc one block earlier before its expiry
yyforyongyu Nov 25, 2024
cea8758
contractcourt: implement `Consumer` on `chainWatcher`
yyforyongyu Jun 20, 2024
d1fc5c5
contractcourt: register spend notification during init
yyforyongyu Nov 16, 2024
fdbec4c
contractcourt: add method `handleCommitSpend`
yyforyongyu Nov 16, 2024
8436960
contractcourt: handle blockbeat in `chainWatcher`
yyforyongyu Nov 16, 2024
5e59b80
contractcourt: notify blockbeat for `chainWatcher`
yyforyongyu Nov 16, 2024
9b90376
contractcourt: use close height instead of best height
yyforyongyu Dec 3, 2024
eec5a59
multi: add new method `ChainArbitrator.RedispatchBlockbeat`
yyforyongyu Nov 13, 2024
e5bdf00
contractcourt: add close event handlers in `ChannelArbitrator`
yyforyongyu Nov 16, 2024
3568385
contractcourt: process channel close event on new beat
yyforyongyu Nov 13, 2024
e4e67db
contractcourt: register conf notification once and cancel when confirmed
yyforyongyu Nov 22, 2024
304eea2
chainntnfs: skip dispatched conf details
yyforyongyu Nov 25, 2024
0882921
docs: add release notes for `blockbeat` series
yyforyongyu Nov 25, 2024
f949dac
multi: optimize loggings around changes from `blockbeat`
yyforyongyu Oct 17, 2024
335a962
lntest+itest: fix `testSweepCPFPAnchorOutgoingTimeout`
yyforyongyu Oct 24, 2024
cd4b497
itest: fix `testSweepCPFPAnchorIncomingTimeout`
yyforyongyu Oct 24, 2024
31d7e8e
itest: fix `testSweepHTLCs`
yyforyongyu Oct 24, 2024
5fc9a58
itest: fix `testSweepCommitOutputAndAnchor`
yyforyongyu Oct 24, 2024
1d95d83
itest: fix `testBumpForceCloseFee`
yyforyongyu Oct 17, 2024
d358333
itest: fix `testPaymentSucceededHTLCRemoteSwept`
yyforyongyu Oct 24, 2024
aa784ce
lntest+itest: start flattening the multi-hop tests
yyforyongyu Oct 17, 2024
7a5e595
itest: simplify and flatten `testMultiHopReceiverChainClaim`
yyforyongyu Oct 18, 2024
50a51b7
lntest+itest: flatten `testMultiHopLocalForceCloseOnChainHtlcTimeout`
yyforyongyu Oct 18, 2024
1c7cfdb
lntest+itest: flatten `testMultiHopRemoteForceCloseOnChainHtlcTimeout`
yyforyongyu Oct 19, 2024
0d5f5c8
itest: flatten `testMultiHopHtlcLocalChainClaim`
yyforyongyu Oct 21, 2024
c5a1731
itest: flatten `testMultiHopHtlcRemoteChainClaim`
yyforyongyu Oct 22, 2024
ea6ee91
itest: flatten `testMultiHopHtlcAggregation`
yyforyongyu Oct 23, 2024
8715438
itest: flatten `testHtlcTimeoutResolverExtractPreimageLocal`
yyforyongyu Oct 23, 2024
860715a
itest: flatten `testHtlcTimeoutResolverExtractPreimageRemote`
yyforyongyu Oct 23, 2024
b985434
itest: rename file to reflect the tests
yyforyongyu Oct 23, 2024
0310594
itest: remove unnecessary force close
yyforyongyu Oct 23, 2024
001dedd
itest: remove redundant block mining in `testFailingChannel`
yyforyongyu Oct 24, 2024
aafd4cc
itest: remove redunant block mining in `testChannelFundingWithUnstabl…
yyforyongyu Oct 24, 2024
f08cf62
itest: remove redudant block in `testPsbtChanFundingWithUnstableUtxos`
yyforyongyu Oct 24, 2024
75b8e43
itest: remove redundant blocks in channel backup tests
yyforyongyu Oct 24, 2024
552bbcc
itest+lntest: fix channel force close test
yyforyongyu Jun 29, 2024
4c73eec
itest: flatten and fix `testWatchtower`
yyforyongyu Oct 25, 2024
1eb150d
itest: remove redundant block in multiple tests
yyforyongyu Oct 25, 2024
931ec34
itest: assert payment status after sending
yyforyongyu Oct 24, 2024
c6ed7aa
lntest+itest: remove the usage of `ht.AssertActiveHtlcs`
yyforyongyu Nov 5, 2024
dbd5657
htlcswitch: handle nil circuit properly when settling
yyforyongyu Nov 10, 2024
96256d8
routing: fix nil pointer dereference in `exitWithErr`
yyforyongyu Nov 7, 2024
e5ed4c9
lnwallet: add debug logs
yyforyongyu Nov 5, 2024
ac63ed0
itest: print num of blocks for debugging
yyforyongyu Oct 25, 2024
2ba9622
itest: shuffle test cases to even out blocks mined in tranches
yyforyongyu Oct 24, 2024
13db8fa
workflows: pass action ID as the shuffle seed
yyforyongyu Nov 7, 2024
723b3c5
itest: remove direct reference to stanby nodes
yyforyongyu Oct 26, 2024
a3ef2aa
itest: remove the use of standby nodes
yyforyongyu Nov 20, 2024
3f3bdee
itest: remove unused method `setupFourHopNetwork`
yyforyongyu Nov 20, 2024
ea359a9
itest+lntest: remove standby nodes
yyforyongyu Nov 20, 2024
8b547dc
itest: remove unnecessary channel close and node shutdown
yyforyongyu Oct 29, 2024
49cddf8
lntest: make sure node is properly shut down
yyforyongyu Nov 2, 2024
fabc5c2
lntest: add human-readble names and check num of nodes
yyforyongyu Nov 20, 2024
50d61fc
itest: fix `testOpenChannelUpdateFeePolicy`
yyforyongyu Oct 29, 2024
d03a8b2
itest: fix flake in `testSendDirectPayment`
yyforyongyu Nov 20, 2024
3640d1d
itest: fix spawning temp miner
yyforyongyu Oct 29, 2024
56a1623
itest: fix flake for neutrino backend
yyforyongyu Oct 30, 2024
ba56598
itest: flatten PSBT funding test cases
yyforyongyu Oct 30, 2024
75142d3
itest: fix and document flake in sweeping tests
yyforyongyu Oct 30, 2024
90bb09a
itest: remove loop in `wsTestCaseBiDirectionalSubscription`
yyforyongyu Oct 30, 2024
87b68ae
itest: fix flake in `testRevokedCloseRetributionZeroValueRemoteOutput`
yyforyongyu Nov 2, 2024
8f69fb1
itest: fix flake in `testSwitchOfflineDelivery`
yyforyongyu Nov 3, 2024
2e30d9e
itest+routing: fix flake in `runFeeEstimationTestCase`
yyforyongyu Nov 3, 2024
79cfae2
itest: use `ht.CreateSimpleNetwork` whenever applicable
yyforyongyu Nov 3, 2024
555c5be
itest: put mpp tests in one file
yyforyongyu Nov 4, 2024
53513cc
lntest+itest: remove `AssertNumActiveEdges`
yyforyongyu Nov 8, 2024
cc45999
itest: fix flake in runPsbtChanFundingWithNodes
yyforyongyu Nov 10, 2024
d700d7c
itest: fix flake in `testPrivateUpdateAlias`
yyforyongyu Nov 16, 2024
284fe91
itest: fix flake in `update_pending_open_channels`
yyforyongyu Nov 16, 2024
2ad1a4a
lntest: increase `rpcmaxwebsockets` for `btcd`
yyforyongyu Nov 20, 2024
7ebf527
itest: document details about MPP-related tests
yyforyongyu Nov 21, 2024
ca689f1
itest+lntest: fix flake in MPP-related tests
yyforyongyu Nov 21, 2024
e9b5227
lntest: fix flakeness in `openChannelsForNodes`
yyforyongyu Nov 22, 2024
565f95d
itest: document a rare flake found in `macOS`
yyforyongyu Dec 4, 2024
598f2a0
itest: document a flake found in `SendToRoute`
yyforyongyu Dec 4, 2024
8baa1a3
itest: optimize blocks mined in `testGarbageCollectLinkNodes`
yyforyongyu Nov 8, 2024
8f4e260
itest: break remote signer into independent cases
yyforyongyu Nov 8, 2024
6d1c3c2
itest: break down channel restore commit types cases
yyforyongyu Nov 8, 2024
a9dbd36
itest: break down utxo selection funding tests
yyforyongyu Nov 8, 2024
6f26186
itest: break all multihop test cases
yyforyongyu Nov 8, 2024
428829a
itest: break down scid alias channel update tests
yyforyongyu Nov 8, 2024
c8e6d74
itest: break down open channel fee policy
yyforyongyu Nov 8, 2024
41ae04c
itest: break down payment failed tests
yyforyongyu Nov 8, 2024
b69e214
itest: break down channel backup restore tests
yyforyongyu Nov 8, 2024
c82610c
itest: break down wallet import account tests
yyforyongyu Nov 8, 2024
6bef51d
itest: break down basic funding flow tests
yyforyongyu Nov 9, 2024
f42b108
itest: break down single hop send to route
yyforyongyu Nov 9, 2024
80895be
itest: break down taproot tests
yyforyongyu Nov 9, 2024
c0ffd29
itest: break down channel fundmax tests
yyforyongyu Nov 9, 2024
93765f2
itest: breakdown `testSendDirectPayment`
yyforyongyu Dec 5, 2024
b3f99c3
itest: further reduce block mined in tests
yyforyongyu Nov 9, 2024
5326b1b
itest: track and skip flaky tests for windows
yyforyongyu Nov 7, 2024
fc7f282
lntest: increase node start timeout and payment benchmark timeout
yyforyongyu Nov 9, 2024
5aec1ff
lntest: make sure policies are populated in `AssertChannelInGraph`
yyforyongyu Nov 21, 2024
9aea852
workflows: use `btcd` for macOS
yyforyongyu Nov 9, 2024
9a819b8
itest+lntest: add new method `FundNumCoins`
yyforyongyu Nov 25, 2024
ef54c92
lntest: limit the num of blocks mined in each test
yyforyongyu Nov 25, 2024
72b0985
docs: update release notes
yyforyongyu Nov 26, 2024
b0a1f90
itest: add a prefix before appending a subtest case
yyforyongyu Dec 3, 2024
0ac77d5
itest: even out num of tests per tranche
yyforyongyu Dec 4, 2024
90e84c8
lntest: increase port timeout
yyforyongyu Dec 4, 2024
e39ba4d
lntest: add timeouts for windows
yyforyongyu Dec 4, 2024
0a0ab90
lntest: properly handle shutdown error
yyforyongyu Dec 5, 2024
2088e36
workflows: increase num of tranches to 16
yyforyongyu Dec 5, 2024
e31c412
lntest: make sure chain backend is synced to miner
yyforyongyu Dec 7, 2024
e1407ff
itest: document and fix wallet UTXO flake
yyforyongyu Dec 7, 2024
cc89b32
itest: fix flake in `testCoopCloseWithExternalDeliveryImpl`
yyforyongyu Dec 10, 2024
26611ea
go.mod: update btcwallet to latest to eliminate waddrmgr deadlock
aakselrod Dec 9, 2024
6af70e4
go.mod: use local kvdb to reapply removal of global postgres lock
aakselrod Oct 30, 2024
5a55c25
Reapply "kvdb/postgres: remove global application level lock"
aakselrod Oct 30, 2024
82a04f0
log: add sub-logger for kvdb/sqlbase
aakselrod Dec 12, 2024
26564c2
itest: fix flake in multi-hop payments
aakselrod Nov 18, 2024
42afb51
batch: handle serialization errors correctly
aakselrod Nov 2, 2024
fa545f1
graph/db: handle previously-unhandled errors
aakselrod Nov 5, 2024
feafcc0
sqldb: improve serialization error handling
aakselrod Nov 6, 2024
7f1a72b
Makefile: tune params for db-instance for postgres itests
aakselrod Nov 6, 2024
819bc24
Makefile: log to file instead of console
aakselrod Nov 15, 2024
db4bf51
github workflow: save postgres log to zip file
aakselrod Nov 15, 2024
175711a
docs: update release-notes for 0.19.0
aakselrod Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 80 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ defaults:
env:
BITCOIN_VERSION: "28"

TRANCHES: 8
# TRANCHES defines the number of tranches used in the itests.
TRANCHES: 16

# SMALL_TRANCHES defines the number of tranches used in the less stable itest
# builds
#
# TODO(yy): remove this value and use TRANCHES.
SMALL_TRANCHES: 8

# If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well).
Expand Down Expand Up @@ -229,10 +236,10 @@ jobs:


########################
# run ubuntu integration tests
# run integration tests with TRANCHES
########################
ubuntu-integration-test:
name: run ubuntu itests
basic-integration-test:
name: basic itests
runs-on: ubuntu-latest
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
strategy:
Expand All @@ -246,20 +253,75 @@ jobs:
args: backend=bitcoind cover=1
- name: bitcoind-notxindex
args: backend="bitcoind notxindex"
- name: neutrino
args: backend=neutrino cover=1
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: fetch and rebase on ${{ github.base_ref }}
if: github.event_name == 'pull_request'
uses: ./.github/actions/rebase

- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test

- name: install bitcoind
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION

- name: run ${{ matrix.name }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}

- name: Send coverage
if: ${{ contains(matrix.args, 'cover=1') }}
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.txt
flag-name: 'itest-${{ matrix.name }}'
parallel: true

- name: Zip log files on failure
if: ${{ failure() }}
timeout-minutes: 5 # timeout after 5 minute
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log

- name: Upload log files on failure
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: logs-itest-${{ matrix.name }}
path: logs-itest-${{ matrix.name }}.zip
retention-days: 5

########################
# run integration tests with SMALL_TRANCHES
########################
integration-test:
name: itests
runs-on: ubuntu-latest
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
strategy:
# Allow other tests in the matrix to continue if one fails.
fail-fast: false
matrix:
include:
- name: bitcoind-rpcpolling
args: backend="bitcoind rpcpolling" cover=1
args: backend="bitcoind rpcpolling"
- name: bitcoind-etcd
args: backend=bitcoind dbbackend=etcd
- name: bitcoind-postgres
args: backend=bitcoind dbbackend=postgres
- name: bitcoind-sqlite
args: backend=bitcoind dbbackend=sqlite
- name: bitcoind-postgres-nativesql
args: backend=bitcoind dbbackend=postgres nativesql=true
- name: bitcoind-sqlite-nativesql
args: backend=bitcoind dbbackend=sqlite nativesql=true
- name: neutrino
args: backend=neutrino cover=1
- name: bitcoind-postgres
args: backend=bitcoind dbbackend=postgres
- name: bitcoind-postgres-nativesql
args: backend=bitcoind dbbackend=postgres nativesql=true
steps:
- name: git checkout
uses: actions/checkout@v3
Expand All @@ -280,7 +342,7 @@ jobs:
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION

- name: run ${{ matrix.name }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }}
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}

- name: Send coverage
if: ${{ contains(matrix.args, 'cover=1') }}
Expand All @@ -293,7 +355,7 @@ jobs:
- name: Zip log files on failure
if: ${{ failure() }}
timeout-minutes: 5 # timeout after 5 minute
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log itest/postgres.log

- name: Upload log files on failure
uses: actions/upload-artifact@v3
Expand All @@ -308,7 +370,7 @@ jobs:
# run windows integration test
########################
windows-integration-test:
name: run windows itest
name: windows itest
runs-on: windows-latest
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
steps:
Expand All @@ -328,7 +390,7 @@ jobs:
key-prefix: integration-test

- name: run itest
run: make itest-parallel tranches=${{ env.TRANCHES }} windows=1
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} windows=1 shuffleseed=${{ github.run_id }}

- name: kill any remaining lnd processes
if: ${{ failure() }}
Expand All @@ -352,7 +414,7 @@ jobs:
# run macOS integration test
########################
macos-integration-test:
name: run macOS itest
name: macOS itest
runs-on: macos-14
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
steps:
Expand All @@ -371,14 +433,8 @@ jobs:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test

- name: install bitcoind
run: |
wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}.0/bitcoin-${BITCOIN_VERSION}.0-arm64-apple-darwin.tar.gz
tar zxvf bitcoin-${BITCOIN_VERSION}.0-arm64-apple-darwin.tar.gz
mv bitcoin-${BITCOIN_VERSION}.0 /tmp/bitcoin

- name: run itest
run: PATH=$PATH:/tmp/bitcoin/bin make itest-parallel tranches=${{ env.TRANCHES }} backend=bitcoind
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} shuffleseed=${{ github.run_id }}

- name: Zip log files on failure
if: ${{ failure() }}
Expand Down Expand Up @@ -431,7 +487,7 @@ jobs:
# Notify about the completion of all coverage collecting jobs.
finish:
if: ${{ always() }}
needs: [unit-test, ubuntu-integration-test]
needs: [unit-test, basic-integration-test]
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
Expand Down
32 changes: 22 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,32 @@ ifeq ($(dbbackend),postgres)
docker rm lnd-postgres --force || echo "Starting new postgres container"

# Start a fresh postgres instance. Allow a maximum of 500 connections so
# that multiple lnd instances with a maximum number of connections of 50
# each can run concurrently.
docker run --name lnd-postgres -e POSTGRES_PASSWORD=postgres -p 6432:5432 -d postgres:13-alpine -N 500
docker logs -f lnd-postgres &
# that multiple lnd instances with a maximum number of connections of 20
# each can run concurrently. Note that many of the settings here are
# specifically for integration testing and are not fit for running
# production nodes. The increase in max connections ensures that there
# are enough entries allocated for the RWConflictPool to allow multiple
# conflicting transactions to track serialization conflicts. The
# increase in predicate locks and locks per transaction is to allow the
# queries to lock individual rows instead of entire tables, helping
# reduce serialization conflicts. Disabling sequential scan for small
# tables also helps prevent serialization conflicts by ensuring lookups
# lock only relevant rows in the index rather than the entire table.
docker run --name lnd-postgres -e POSTGRES_PASSWORD=postgres -p 6432:5432 -d postgres:13-alpine -N 1500 -c max_pred_locks_per_transaction=1024 -c max_locks_per_transaction=128 -c enable_seqscan=off
docker logs -f lnd-postgres >itest/postgres.log 2>&1 &

# Wait for the instance to be started.
sleep $(POSTGRES_START_DELAY)
endif

clean-itest-logs:
rm -rf itest/*.log itest/.logs-*

#? itest-only: Only run integration tests without re-building binaries
itest-only: db-instance
itest-only: clean-itest-logs db-instance
@$(call print, "Running integration tests with ${backend} backend.")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS) -test.v
date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS) -test.v
$(COLLECT_ITEST_COVERAGE)

#? itest: Build and run integration tests
Expand All @@ -218,10 +230,10 @@ itest: build-itest itest-only
itest-race: build-itest-race itest-only

#? itest-parallel: Build and run integration tests in parallel mode, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
itest-parallel: build-itest db-instance
itest-parallel: clean-itest-logs build-itest db-instance
@$(call print, "Running tests")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)

#? itest-clean: Kill all running itest processes
Expand Down
17 changes: 15 additions & 2 deletions batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sync"

"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/sqldb"
)

// errSolo is a sentinel error indicating that the requester should re-run the
Expand Down Expand Up @@ -55,8 +56,20 @@ func (b *batch) run() {
for i, req := range b.reqs {
err := req.Update(tx)
if err != nil {
failIdx = i
return err
// If we get a serialization error, we
// want the underlying SQL retry
// mechanism to retry the entire batch.
// Otherwise, we can succeed in an
// sqldb retry and still re-execute the
// failing request individually.
dbErr := sqldb.MapSQLError(err)
if !sqldb.IsSerializationError(dbErr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It'd be nice to cover batch with a simple unit test to make sure the serialization errors are correctly handled and we don't regress later.

failIdx = i

return err
}

return dbErr
}
}
return nil
Expand Down
74 changes: 74 additions & 0 deletions batch/batch_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package batch

import (
"errors"
"path/filepath"
"sync"
"testing"
"time"

"github.com/btcsuite/btcwallet/walletdb"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/stretchr/testify/require"
)

func TestRetry(t *testing.T) {
dbDir := t.TempDir()

dbName := filepath.Join(dbDir, "weks.db")
db, err := walletdb.Create(
"bdb", dbName, true, kvdb.DefaultDBTimeout,
)
if err != nil {
t.Fatalf("unable to create walletdb: %v", err)
}
t.Cleanup(func() {
db.Close()
})

var (
mu sync.Mutex
called int
)
sched := NewTimeScheduler(db, &mu, time.Second)

// First, we construct a request that should retry individually and
// execute it non-lazily. It should still return the error the second
// time.
req := &Request{
Update: func(tx kvdb.RwTx) error {
called++

return errors.New("test")
},
}
err = sched.Execute(req)

// Check and reset the called counter.
mu.Lock()
require.Equal(t, 2, called)
called = 0
mu.Unlock()

require.ErrorContains(t, err, "test")

// Now, we construct a request that should NOT retry because it returns
// a serialization error, which should cause the underlying postgres
// transaction to retry. Since we aren't using postgres, this will
// cause the transaction to not be retried at all.
req = &Request{
Update: func(tx kvdb.RwTx) error {
called++

return errors.New("could not serialize access")
},
}
err = sched.Execute(req)

// Check the called counter.
mu.Lock()
require.Equal(t, 1, called)
mu.Unlock()

require.ErrorContains(t, err, "could not serialize access")
}
Loading
Loading