Skip to content

Commit 288f0e1

Browse files
authored
Merge pull request #9460 from lightningnetwork/0-18-5-branch-rc1
release: create branch for v0.18.5-beta.rc1
2 parents ddeb835 + 871061e commit 288f0e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1446
-531
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ env:
2525

2626
TRANCHES: 8
2727

28-
# If you change this value, please change it in the following files as well:
29-
# /.travis.yml
30-
# /Dockerfile
31-
# /dev.Dockerfile
32-
# /make/builder.Dockerfile
33-
# /.github/workflows/release.yml
34-
GO_VERSION: 1.22.6
28+
# If you change this please also update GO_VERSION in Makefile (then run
29+
# `make lint` to see where else it needs to be updated as well).
30+
GO_VERSION: 1.22.11
3531

3632
jobs:
3733
########################
@@ -202,15 +198,6 @@ jobs:
202198
if: github.event_name == 'pull_request'
203199
uses: ./.github/actions/rebase
204200

205-
- name: git checkout fuzzing seeds
206-
uses: actions/checkout@v3
207-
with:
208-
repository: lightninglabs/lnd-fuzz
209-
path: lnd-fuzz
210-
211-
- name: rsync fuzzing seeds
212-
run: rsync -a --ignore-existing lnd-fuzz/ ./
213-
214201
- name: setup go ${{ env.GO_VERSION }}
215202
uses: ./.github/actions/setup-go
216203
with:
@@ -297,10 +284,10 @@ jobs:
297284
- name: Zip log files on failure
298285
if: ${{ failure() }}
299286
timeout-minutes: 5 # timeout after 5 minute
300-
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log
287+
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log itest/postgres.log
301288

302289
- name: Upload log files on failure
303-
uses: actions/upload-artifact@v3
290+
uses: actions/upload-artifact@v4
304291
if: ${{ failure() }}
305292
with:
306293
name: logs-itest-${{ matrix.name }}
@@ -345,7 +332,7 @@ jobs:
345332
run: 7z a logs-itest-windows.zip itest/**/*.log
346333

347334
- name: Upload log files on failure
348-
uses: actions/upload-artifact@v3
335+
uses: actions/upload-artifact@v4
349336
if: ${{ failure() }}
350337
with:
351338
name: logs-itest-windows
@@ -390,7 +377,7 @@ jobs:
390377
run: 7z a logs-itest-macos.zip itest/**/*.log
391378

392379
- name: Upload log files on failure
393-
uses: actions/upload-artifact@v3
380+
uses: actions/upload-artifact@v4
394381
if: ${{ failure() }}
395382
with:
396383
name: logs-itest-macos

.github/workflows/release.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ defaults:
1010
shell: bash
1111

1212
env:
13-
# If you change this value, please change it in the following files as well:
14-
# /Dockerfile
15-
# /dev.Dockerfile
16-
# /make/builder.Dockerfile
17-
# /.github/workflows/main.yml
18-
GO_VERSION: 1.22.6
13+
# If you change this please also update GO_VERSION in Makefile (then run
14+
# `make lint` to see where else it needs to be updated as well).
15+
GO_VERSION: 1.22.11
1916

2017
jobs:
2118
main:

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
run:
2-
go: "1.22.6"
2+
# If you change this please also update GO_VERSION in Makefile (then run
3+
# `make lint` to see where else it needs to be updated as well).
4+
go: "1.22.11"
35

46
# Abort after 10 minutes.
57
timeout: 10m

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# If you change this value, please change it in the following files as well:
2-
# /dev.Dockerfile
3-
# /make/builder.Dockerfile
4-
# /.github/workflows/main.yml
5-
# /.github/workflows/release.yml
6-
FROM golang:1.22.6-alpine as builder
1+
# If you change this please also update GO_VERSION in Makefile (then run
2+
# `make lint` to see where else it needs to be updated as well).
3+
FROM golang:1.22.11-alpine as builder
74

85
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
96
# queries required to connect to linked containers succeed.

Makefile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ endif
3535
# GO_VERSION is the Go version used for the release build, docker files, and
3636
# GitHub Actions. This is the reference version for the project. All other Go
3737
# versions are checked against this version.
38-
GO_VERSION = 1.22.6
38+
GO_VERSION = 1.22.11
3939

4040
GOBUILD := $(LOOPVARFIX) go build -v
4141
GOINSTALL := $(LOOPVARFIX) go install -v
@@ -195,19 +195,31 @@ ifeq ($(dbbackend),postgres)
195195
docker rm lnd-postgres --force || echo "Starting new postgres container"
196196

197197
# Start a fresh postgres instance. Allow a maximum of 500 connections so
198-
# that multiple lnd instances with a maximum number of connections of 50
199-
# each can run concurrently.
200-
docker run --name lnd-postgres -e POSTGRES_PASSWORD=postgres -p 6432:5432 -d postgres:13-alpine -N 500
201-
docker logs -f lnd-postgres &
198+
# that multiple lnd instances with a maximum number of connections of 20
199+
# each can run concurrently. Note that many of the settings here are
200+
# specifically for integration testing and are not fit for running
201+
# production nodes. The increase in max connections ensures that there
202+
# are enough entries allocated for the RWConflictPool to allow multiple
203+
# conflicting transactions to track serialization conflicts. The
204+
# increase in predicate locks and locks per transaction is to allow the
205+
# queries to lock individual rows instead of entire tables, helping
206+
# reduce serialization conflicts. Disabling sequential scan for small
207+
# tables also helps prevent serialization conflicts by ensuring lookups
208+
# lock only relevant rows in the index rather than the entire table.
209+
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
210+
docker logs -f lnd-postgres >itest/postgres.log 2>&1 &
202211

203212
# Wait for the instance to be started.
204213
sleep $(POSTGRES_START_DELAY)
205214
endif
206215

216+
clean-itest-logs:
217+
rm -rf itest/*.log itest/.logs-*
218+
207219
#? itest-only: Only run integration tests without re-building binaries
208-
itest-only: db-instance
220+
itest-only: clean-itest-logs db-instance
209221
@$(call print, "Running integration tests with ${backend} backend.")
210-
rm -rf itest/*.log itest/.logs-*; date
222+
date
211223
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS)
212224
$(COLLECT_ITEST_COVERAGE)
213225

@@ -218,9 +230,9 @@ itest: build-itest itest-only
218230
itest-race: build-itest-race itest-only
219231

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

batch/batch.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"sync"
66

77
"github.com/lightningnetwork/lnd/kvdb"
8+
"github.com/lightningnetwork/lnd/sqldb"
89
)
910

1011
// errSolo is a sentinel error indicating that the requester should re-run the
@@ -55,8 +56,20 @@ func (b *batch) run() {
5556
for i, req := range b.reqs {
5657
err := req.Update(tx)
5758
if err != nil {
58-
failIdx = i
59-
return err
59+
// If we get a serialization error, we
60+
// want the underlying SQL retry
61+
// mechanism to retry the entire batch.
62+
// Otherwise, we can succeed in an
63+
// sqldb retry and still re-execute the
64+
// failing request individually.
65+
dbErr := sqldb.MapSQLError(err)
66+
if !sqldb.IsSerializationError(dbErr) {
67+
failIdx = i
68+
69+
return err
70+
}
71+
72+
return dbErr
6073
}
6174
}
6275
return nil

batch/batch_test.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package batch
2+
3+
import (
4+
"errors"
5+
"path/filepath"
6+
"sync"
7+
"testing"
8+
"time"
9+
10+
"github.com/btcsuite/btcwallet/walletdb"
11+
"github.com/lightningnetwork/lnd/kvdb"
12+
"github.com/stretchr/testify/require"
13+
)
14+
15+
func TestRetry(t *testing.T) {
16+
dbDir := t.TempDir()
17+
18+
dbName := filepath.Join(dbDir, "weks.db")
19+
db, err := walletdb.Create(
20+
"bdb", dbName, true, kvdb.DefaultDBTimeout,
21+
)
22+
if err != nil {
23+
t.Fatalf("unable to create walletdb: %v", err)
24+
}
25+
t.Cleanup(func() {
26+
db.Close()
27+
})
28+
29+
var (
30+
mu sync.Mutex
31+
called int
32+
)
33+
sched := NewTimeScheduler(db, &mu, time.Second)
34+
35+
// First, we construct a request that should retry individually and
36+
// execute it non-lazily. It should still return the error the second
37+
// time.
38+
req := &Request{
39+
Update: func(tx kvdb.RwTx) error {
40+
called++
41+
42+
return errors.New("test")
43+
},
44+
}
45+
err = sched.Execute(req)
46+
47+
// Check and reset the called counter.
48+
mu.Lock()
49+
require.Equal(t, 2, called)
50+
called = 0
51+
mu.Unlock()
52+
53+
require.ErrorContains(t, err, "test")
54+
55+
// Now, we construct a request that should NOT retry because it returns
56+
// a serialization error, which should cause the underlying postgres
57+
// transaction to retry. Since we aren't using postgres, this will
58+
// cause the transaction to not be retried at all.
59+
req = &Request{
60+
Update: func(tx kvdb.RwTx) error {
61+
called++
62+
63+
return errors.New("could not serialize access")
64+
},
65+
}
66+
err = sched.Execute(req)
67+
68+
// Check the called counter.
69+
mu.Lock()
70+
require.Equal(t, 1, called)
71+
mu.Unlock()
72+
73+
require.ErrorContains(t, err, "could not serialize access")
74+
}

build/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ const (
4343
AppMinor uint = 18
4444

4545
// AppPatch defines the application patch for this binary.
46-
AppPatch uint = 4
46+
AppPatch uint = 5
4747

4848
// AppPreRelease MUST only contain characters from semanticAlphabet per
4949
// the semantic versioning spec.
50-
AppPreRelease = "beta"
50+
AppPreRelease = "beta.rc1"
5151
)
5252

5353
func init() {

channeldb/graph.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,10 @@ func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo,
10231023
}
10241024

10251025
for _, f := range op {
1026+
if f == nil {
1027+
return fmt.Errorf("nil scheduler option was used")
1028+
}
1029+
10261030
f(r)
10271031
}
10281032

@@ -1079,7 +1083,7 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx,
10791083
err := addLightningNode(tx, &node1Shell)
10801084
if err != nil {
10811085
return fmt.Errorf("unable to create shell node "+
1082-
"for: %x", edge.NodeKey1Bytes)
1086+
"for: %x: %w", edge.NodeKey1Bytes, err)
10831087
}
10841088
case node1Err != nil:
10851089
return err
@@ -1095,7 +1099,7 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx,
10951099
err := addLightningNode(tx, &node2Shell)
10961100
if err != nil {
10971101
return fmt.Errorf("unable to create shell node "+
1098-
"for: %x", edge.NodeKey2Bytes)
1102+
"for: %x: %w", edge.NodeKey2Bytes, err)
10991103
}
11001104
case node2Err != nil:
11011105
return err
@@ -2622,8 +2626,14 @@ func (c *ChannelGraph) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex,
26222626

26232627
// As part of deleting the edge we also remove all disabled entries
26242628
// from the edgePolicyDisabledIndex bucket. We do that for both directions.
2625-
updateEdgePolicyDisabledIndex(edges, cid, false, false)
2626-
updateEdgePolicyDisabledIndex(edges, cid, true, false)
2629+
err = updateEdgePolicyDisabledIndex(edges, cid, false, false)
2630+
if err != nil {
2631+
return err
2632+
}
2633+
err = updateEdgePolicyDisabledIndex(edges, cid, true, false)
2634+
if err != nil {
2635+
return err
2636+
}
26272637

26282638
// With the edge data deleted, we can purge the information from the two
26292639
// edge indexes.
@@ -4452,11 +4462,14 @@ func putChanEdgePolicy(edges kvdb.RwBucket, edge *models.ChannelEdgePolicy,
44524462
return err
44534463
}
44544464

4455-
updateEdgePolicyDisabledIndex(
4465+
err = updateEdgePolicyDisabledIndex(
44564466
edges, edge.ChannelID,
44574467
edge.ChannelFlags&lnwire.ChanUpdateDirection > 0,
44584468
edge.IsDisabled(),
44594469
)
4470+
if err != nil {
4471+
return err
4472+
}
44604473

44614474
return edges.Put(edgeKey[:], b.Bytes()[:])
44624475
}

0 commit comments

Comments
 (0)