Skip to content

Commit b6130fb

Browse files
Merge branch 'matrix-org:main' into main
2 parents af658e9 + 2259e71 commit b6130fb

File tree

283 files changed

+11544
-5052
lines changed

Some content is hidden

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

283 files changed

+11544
-5052
lines changed

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
bin
2-
*.wasm
3-
.git
2+
*.wasm

.github/workflows/dendrite.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
with:
124124
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
125125
token: ${{ secrets.GITHUB_TOKEN }}
126-
- run: go test -json -v ./... 2>&1 | gotestfmt
126+
- run: go test -json -v ./... 2>&1 | gotestfmt -hide all
127127
env:
128128
POSTGRES_HOST: localhost
129129
POSTGRES_USER: postgres
@@ -255,7 +255,7 @@ jobs:
255255
key: ${{ runner.os }}-go-stable-test-race-${{ hashFiles('**/go.sum') }}
256256
restore-keys: |
257257
${{ runner.os }}-go-stable-test-race-
258-
- run: go test -race -json -v -coverpkg=./... -coverprofile=cover.out $(go list ./... | grep -v /cmd/dendrite*) 2>&1 | gotestfmt
258+
- run: go test -race -json -v -coverpkg=./... -coverprofile=cover.out $(go list ./... | grep -v /cmd/dendrite*) 2>&1 | gotestfmt -hide all
259259
env:
260260
POSTGRES_HOST: localhost
261261
POSTGRES_USER: postgres
@@ -280,6 +280,8 @@ jobs:
280280
with:
281281
go-version: "stable"
282282
cache: true
283+
- name: Docker version
284+
run: docker version
283285
- name: Build upgrade-tests
284286
run: go build ./cmd/dendrite-upgrade-tests
285287
- name: Test upgrade (PostgreSQL)
@@ -300,6 +302,8 @@ jobs:
300302
with:
301303
go-version: "stable"
302304
cache: true
305+
- name: Docker version
306+
run: docker version
303307
- name: Build upgrade-tests
304308
run: go build ./cmd/dendrite-upgrade-tests
305309
- name: Test upgrade (PostgreSQL)
@@ -436,7 +440,7 @@ jobs:
436440
# Run Complement
437441
- run: |
438442
set -o pipefail &&
439-
go test -v -json -tags dendrite_blacklist ./tests/... 2>&1 | gotestfmt
443+
go test -v -json -tags dendrite_blacklist ./tests/... 2>&1 | gotestfmt -hide all
440444
shell: bash
441445
name: Run Complement Tests
442446
env:

.github/workflows/docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
id: docker_build_monolith
5858
uses: docker/build-push-action@v3
5959
with:
60-
cache-from: type=gha
61-
cache-to: type=gha,mode=max
60+
cache-from: type=registry,ref=ghcr.io/${{ env.GHCR_NAMESPACE }}/dendrite-monolith:buildcache
61+
cache-to: type=registry,ref=ghcr.io/${{ env.GHCR_NAMESPACE }}/dendrite-monolith:buildcache,mode=max
6262
context: .
6363
build-args: FLAGS=-X github.com/matrix-org/dendrite/internal.branch=${{ env.BRANCH }} -X github.com/matrix-org/dendrite/internal.build=${{ env.BUILD }}
6464
platforms: ${{ env.PLATFORMS }}

.github/workflows/helm.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ jobs:
3232
version: v3.10.0
3333

3434
- name: Run chart-releaser
35-
uses: helm/chart-releaser-action@v1.4.1
35+
uses: helm/chart-releaser-action@ed43eb303604cbc0eeec8390544f7748dc6c790d # specific commit, since `mark_as_latest` is not yet in a release
3636
env:
3737
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3838
with:
3939
config: helm/cr.yaml
4040
charts_dir: helm/
41+
mark_as_latest: false

.github/workflows/schedules.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
# See https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md specifically GOROOT_1_17_X64
129129
run: |
130130
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
131-
go get -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
131+
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
132132
- name: Run actions/checkout@v3 for dendrite
133133
uses: actions/checkout@v3
134134
with:

CHANGES.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,105 @@
11
# Changelog
22

3+
## Dendrite 0.13.3 (2023-09-28)
4+
5+
### Fixes:
6+
7+
- The `user_id` query parameter when authenticating is now used correctly (contributed by [tulir](https://github.com/tulir))
8+
- Invitations are now correctly pushed to devices
9+
- A bug which could result in the corruption of `m.direct` account data has been fixed
10+
11+
### Features
12+
13+
- [Sliding Sync proxy](https://github.com/matrix-org/sliding-sync) can be configured in the `/.well-known/matrix/client` response
14+
- Room version 11 is now supported
15+
- Clients can request the `federation` `event_format` when creating filters
16+
- Many under the hood improvements for [MSC4014: Pseudonymous Identities](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/pseudo-ids/proposals/4014-pseudonymous-identities.md)
17+
18+
### Other
19+
20+
- Dendrite now requires Go 1.20 if building from source
21+
22+
## Dendrite 0.13.2 (2023-08-23)
23+
24+
### Fixes:
25+
26+
- Migrations in SQLite are now prepared on the correct context (transaction or database)
27+
- The `InputRoomEvent` stream now has a maximum age of 24h, which should help with slow start up times of NATS JetStream (contributed by [neilalexander](https://github.com/neilalexander))
28+
- Event size checks are more in line with Synapse
29+
- Requests to `/messages` have been optimized, possibly reducing database round trips
30+
- Re-add the revision of Dendrite when building from source (Note: This only works if git is installed)
31+
- Getting local members to notify has been optimized, which should significantly reduce memory allocation and cache usage
32+
- When getting queried about user profiles, we now return HTTP404 if the user/profiles does not exist
33+
- Background federated joins should now be fixed and not timeout after a short time
34+
- Database connections are now correctly re-used
35+
- Restored the old behavior of the `/purgeRoom` admin endpoint (does not evacuate the room before purging)
36+
- Don't expose information about the system when trying to download files that don't exist
37+
38+
### Features
39+
40+
- Further improvements and fixes for [MSC4014: Pseudonymous Identities](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/pseudo-ids/proposals/4014-pseudonymous-identities.md)
41+
- Lookup correct prev events in the sync API
42+
- Populate `prev_sender` correctly in the sync API
43+
- Event federation should work better
44+
- Added new `dendrite_up` Prometheus metric, containing the version of Dendrite
45+
- Space summaries ([MSC2946](https://github.com/matrix-org/matrix-spec-proposals/pull/2946)) have been moved from MSC to being natively supported
46+
- For easier issue investigation, logs for application services now contain the application service ID (contributed by [maxberger](https://github.com/maxberger))
47+
- The default room version to use when creating rooms can now be configured using `room_server.default_room_version`
48+
49+
## Dendrite 0.13.1 (2023-07-06)
50+
51+
This releases fixes a long-standing "off-by-one" error which could result in state resets. Upgrading to this version is **highly** recommended.
52+
53+
When deduplicating state events, we were checking if the event in question was already in a state snapshot. If it was in a previous state snapshot, we would
54+
then remove it from the list of events to store. If this happened, we were, unfortunately, skipping the next event to check. This resulted in
55+
events getting stored in state snapshots where they may not be needed. When we now compared two of those state snapshots, one of them
56+
contained the skipped event, while the other didn't. This difference possibly shouldn't exist, resulting in unexpected state resets and explains
57+
reports of missing state events as well.
58+
59+
Rooms where a state reset occurred earlier should, hopefully, reconcile over time.
60+
61+
### Fixes:
62+
63+
- A long-standing "off-by-one" error has been fixed, which could result in state resets
64+
- Roomserver Prometheus Metrics are available again
65+
66+
### Features
67+
68+
- Updated dependencies
69+
- Internal NATS Server has been updated from v2.9.15 to v2.9.19
70+
71+
## Dendrite 0.13.0 (2023-06-30)
72+
73+
### Features
74+
75+
- Results in responses to `/search` now highlight words more accurately and not only the search terms as before
76+
- Support for connecting to appservices listening on unix sockets has been added (contributed by [cyberb](https://github.com/cyberb))
77+
- Admin APIs for token authenticated registration have been added (contributed by [santhoshivan23](https://github.com/santhoshivan23))
78+
- Initial support for [MSC4014: Pseudonymous Identities](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/pseudo-ids/proposals/4014-pseudonymous-identities.md)
79+
- This is **highly experimental**, things like changing usernames/avatars, inviting users, upgrading rooms isn't working
80+
81+
### Fixes
82+
83+
- `m.upload.size` is now optional, finally allowing uploads with unlimited file size
84+
- A bug while resolving server names has been fixed (contributed by [anton-molyboha](https://github.com/anton-molyboha))
85+
- Application services should only receive one invitation instead of 2 (or worse), which could result in state resets previously
86+
- Several admin endpoints are now using `POST` instead of `GET`
87+
- `/delete_devices` now uses user-interactive authentication
88+
- Several "membership" (e.g `/kick`, `/ban`) endpoints are using less heavy database queries to check if the user is allowed to perform this action
89+
- `/3pid` endpoints are now available on `/v3` instead of the `/unstable` prefix
90+
- Upgrading rooms ignores state events of other users, which could result in failed upgrades before
91+
- Uploading key backups with a wrong version now returns `M_WRONG_ROOM_KEYS_VERSION`
92+
- A potential state reset when joining the same room multiple times in short sequence has been fixed
93+
- A bug where we returned the full event as `redacted_because` in redaction events has been fixed
94+
- The `displayname` and `avatar_url` can now be set to empty strings
95+
- Unsafe hotserving of files has been fixed (contributed by [joshqou](https://github.com/joshqou))
96+
- Joining new rooms would potentially return "redacted" events, due to history visibility not being set correctly, this could result in events being rejected
97+
- Backfilling resulting in `unsuported room version ''` should now be solved
98+
99+
### Other
100+
101+
- Huge refactoring of Dendrite and gomatrixserverlib
102+
3103
## Dendrite 0.12.0 (2023-03-13)
4104

5105
### Features

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# base installs required dependencies and runs go mod download to cache dependencies
55
#
66
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.20-alpine AS base
7-
RUN apk --update --no-cache add bash build-base curl
7+
RUN apk --update --no-cache add bash build-base curl git
88

99
#
1010
# build creates all needed binaries

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ It intends to provide an **efficient**, **reliable** and **scalable** alternativ
1313

1414
Dendrite is **beta** software, which means:
1515

16-
- Dendrite is ready for early adopters. We recommend running in Monolith mode with a PostgreSQL database.
16+
- Dendrite is ready for early adopters. We recommend running Dendrite with a PostgreSQL database.
1717
- Dendrite has periodic releases. We intend to release new versions as we fix bugs and land significant features.
1818
- Dendrite supports database schema upgrades between releases. This means you should never lose your messages when upgrading Dendrite.
1919

2020
This does not mean:
2121

2222
- Dendrite is bug-free. It has not yet been battle-tested in the real world and so will be error prone initially.
2323
- Dendrite is feature-complete. There may be client or federation APIs that are not implemented.
24-
- Dendrite is ready for massive homeserver deployments. There is no sharding of microservices (although it is possible to run them on separate machines) and there is no high-availability/clustering support.
24+
- Dendrite is ready for massive homeserver deployments. There is no high-availability/clustering support.
2525

2626
Currently, we expect Dendrite to function well for small (10s/100s of users) homeserver deployments as well as P2P Matrix nodes in-browser or on mobile devices.
2727

@@ -36,7 +36,7 @@ If you have further questions, please take a look at [our FAQ](docs/FAQ.md) or j
3636
See the [Planning your Installation](https://matrix-org.github.io/dendrite/installation/planning) page for
3737
more information on requirements.
3838

39-
To build Dendrite, you will need Go 1.18 or later.
39+
To build Dendrite, you will need Go 1.20 or later.
4040

4141
For a usable federating Dendrite deployment, you will also need:
4242

@@ -47,7 +47,7 @@ For a usable federating Dendrite deployment, you will also need:
4747
Also recommended are:
4848

4949
- A PostgreSQL database engine, which will perform better than SQLite with many users and/or larger rooms
50-
- A reverse proxy server, such as nginx, configured [like this sample](https://github.com/matrix-org/dendrite/blob/master/docs/nginx/monolith-sample.conf)
50+
- A reverse proxy server, such as nginx, configured [like this sample](https://github.com/matrix-org/dendrite/blob/main/docs/nginx/dendrite-sample.conf)
5151

5252
The [Federation Tester](https://federationtester.matrix.org) can be used to verify your deployment.
5353

@@ -60,7 +60,7 @@ The following instructions are enough to get Dendrite started as a non-federatin
6060
```bash
6161
$ git clone https://github.com/matrix-org/dendrite
6262
$ cd dendrite
63-
$ ./build.sh
63+
$ go build -o bin/ ./cmd/...
6464

6565
# Generate a Matrix signing key for federation (required)
6666
$ ./bin/generate-keys --private-key matrix_key.pem
@@ -85,7 +85,7 @@ Then point your favourite Matrix client at `http://localhost:8008` or `https://l
8585

8686
## Progress
8787

88-
We use a script called Are We Synapse Yet which checks Sytest compliance rates. Sytest is a black-box homeserver
88+
We use a script called "Are We Synapse Yet" which checks Sytest compliance rates. Sytest is a black-box homeserver
8989
test rig with around 900 tests. The script works out how many of these tests are passing on Dendrite and it
9090
updates with CI. As of January 2023, we have 100% server-server parity with Synapse, and the client-server parity is at 93% , though check
9191
CI for the latest numbers. In practice, this means you can communicate locally and via federation with Synapse

appservice/appservice_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ func TestAppserviceInternalAPI(t *testing.T) {
134134
}
135135
as.CreateHTTPClient(cfg.AppServiceAPI.DisableTLSValidation)
136136
cfg.AppServiceAPI.Derived.ApplicationServices = []config.ApplicationService{*as}
137-
138137
t.Cleanup(func() {
139138
ctx.ShutdownDendrite()
140139
ctx.WaitForShutdown()
@@ -144,6 +143,7 @@ func TestAppserviceInternalAPI(t *testing.T) {
144143
natsInstance := jetstream.NATSInstance{}
145144
cm := sqlutil.NewConnectionManager(ctx, cfg.Global.DatabaseOptions)
146145
rsAPI := roomserver.NewInternalAPI(ctx, cfg, cm, &natsInstance, caches, caching.DisableMetrics)
146+
rsAPI.SetFederationAPI(nil, nil)
147147
usrAPI := userapi.NewInternalAPI(ctx, cfg, cm, &natsInstance, rsAPI, nil)
148148
asAPI := appservice.NewInternalAPI(ctx, cfg, &natsInstance, usrAPI, rsAPI)
149149

@@ -238,6 +238,7 @@ func TestAppserviceInternalAPI_UnixSocket_Simple(t *testing.T) {
238238
natsInstance := jetstream.NATSInstance{}
239239
cm := sqlutil.NewConnectionManager(ctx, cfg.Global.DatabaseOptions)
240240
rsAPI := roomserver.NewInternalAPI(ctx, cfg, cm, &natsInstance, caches, caching.DisableMetrics)
241+
rsAPI.SetFederationAPI(nil, nil)
241242
usrAPI := userapi.NewInternalAPI(ctx, cfg, cm, &natsInstance, rsAPI, nil)
242243
asAPI := appservice.NewInternalAPI(ctx, cfg, &natsInstance, usrAPI, rsAPI)
243244

appservice/consumers/roomserver.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (s *OutputRoomEventConsumer) onMessage(
128128
if len(output.NewRoomEvent.AddsStateEventIDs) > 0 {
129129
newEventID := output.NewRoomEvent.Event.EventID()
130130
eventsReq := &api.QueryEventsByIDRequest{
131-
RoomID: output.NewRoomEvent.Event.RoomID(),
131+
RoomID: output.NewRoomEvent.Event.RoomID().String(),
132132
EventIDs: make([]string, 0, len(output.NewRoomEvent.AddsStateEventIDs)),
133133
}
134134
eventsRes := &api.QueryEventsByIDResponse{}
@@ -181,7 +181,9 @@ func (s *OutputRoomEventConsumer) sendEvents(
181181
// Create the transaction body.
182182
transaction, err := json.Marshal(
183183
ApplicationServiceTransaction{
184-
Events: synctypes.ToClientEvents(gomatrixserverlib.ToPDUs(events), synctypes.FormatAll),
184+
Events: synctypes.ToClientEvents(gomatrixserverlib.ToPDUs(events), synctypes.FormatAll, func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
185+
return s.rsAPI.QueryUserIDForSender(ctx, roomID, senderID)
186+
}),
185187
},
186188
)
187189
if err != nil {
@@ -233,12 +235,18 @@ func (s *appserviceState) backoffAndPause(err error) error {
233235
//
234236
// TODO: This should be cached, see https://github.com/matrix-org/dendrite/issues/1682
235237
func (s *OutputRoomEventConsumer) appserviceIsInterestedInEvent(ctx context.Context, event *types.HeaderedEvent, appservice *config.ApplicationService) bool {
238+
user := ""
239+
userID, err := s.rsAPI.QueryUserIDForSender(ctx, event.RoomID(), event.SenderID())
240+
if err == nil {
241+
user = userID.String()
242+
}
243+
236244
switch {
237245
case appservice.URL == "":
238246
return false
239-
case appservice.IsInterestedInUserID(event.Sender()):
247+
case appservice.IsInterestedInUserID(user):
240248
return true
241-
case appservice.IsInterestedInRoomID(event.RoomID()):
249+
case appservice.IsInterestedInRoomID(event.RoomID().String()):
242250
return true
243251
}
244252

@@ -249,7 +257,7 @@ func (s *OutputRoomEventConsumer) appserviceIsInterestedInEvent(ctx context.Cont
249257
}
250258

251259
// Check all known room aliases of the room the event came from
252-
queryReq := api.GetAliasesForRoomIDRequest{RoomID: event.RoomID()}
260+
queryReq := api.GetAliasesForRoomIDRequest{RoomID: event.RoomID().String()}
253261
var queryRes api.GetAliasesForRoomIDResponse
254262
if err := s.rsAPI.GetAliasesForRoomID(ctx, &queryReq, &queryRes); err == nil {
255263
for _, alias := range queryRes.Aliases {
@@ -260,7 +268,7 @@ func (s *OutputRoomEventConsumer) appserviceIsInterestedInEvent(ctx context.Cont
260268
} else {
261269
log.WithFields(log.Fields{
262270
"appservice": appservice.ID,
263-
"room_id": event.RoomID(),
271+
"room_id": event.RoomID().String(),
264272
}).WithError(err).Errorf("Unable to get aliases for room")
265273
}
266274

@@ -276,7 +284,7 @@ func (s *OutputRoomEventConsumer) appserviceJoinedAtEvent(ctx context.Context, e
276284
// until we have a lighter way of checking the state before the event that
277285
// doesn't involve state res, then this is probably OK.
278286
membershipReq := &api.QueryMembershipsForRoomRequest{
279-
RoomID: event.RoomID(),
287+
RoomID: event.RoomID().String(),
280288
JoinedOnly: true,
281289
}
282290
membershipRes := &api.QueryMembershipsForRoomResponse{}
@@ -305,7 +313,7 @@ func (s *OutputRoomEventConsumer) appserviceJoinedAtEvent(ctx context.Context, e
305313
} else {
306314
log.WithFields(log.Fields{
307315
"appservice": appservice.ID,
308-
"room_id": event.RoomID(),
316+
"room_id": event.RoomID().String(),
309317
}).WithError(err).Errorf("Unable to get membership for room")
310318
}
311319
return false

appservice/query/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (a *AppServiceQueryAPI) Locations(
217217
}
218218

219219
if err := requestDo[[]api.ASLocationResponse](as.HTTPClient, url+"?"+params.Encode(), &asLocations); err != nil {
220-
log.WithError(err).Error("unable to get 'locations' from application service")
220+
log.WithError(err).WithField("application_service", as.ID).Error("unable to get 'locations' from application service")
221221
continue
222222
}
223223

@@ -252,7 +252,7 @@ func (a *AppServiceQueryAPI) User(
252252
}
253253

254254
if err := requestDo[[]api.ASUserResponse](as.HTTPClient, url+"?"+params.Encode(), &asUsers); err != nil {
255-
log.WithError(err).Error("unable to get 'user' from application service")
255+
log.WithError(err).WithField("application_service", as.ID).Error("unable to get 'user' from application service")
256256
continue
257257
}
258258

@@ -290,7 +290,7 @@ func (a *AppServiceQueryAPI) Protocols(
290290
for _, as := range a.Cfg.Derived.ApplicationServices {
291291
var proto api.ASProtocolResponse
292292
if err := requestDo[api.ASProtocolResponse](as.HTTPClient, as.RequestUrl()+api.ASProtocolPath+req.Protocol, &proto); err != nil {
293-
log.WithError(err).Error("unable to get 'protocol' from application service")
293+
log.WithError(err).WithField("application_service", as.ID).Error("unable to get 'protocol' from application service")
294294
continue
295295
}
296296

@@ -320,7 +320,7 @@ func (a *AppServiceQueryAPI) Protocols(
320320
for _, p := range as.Protocols {
321321
var proto api.ASProtocolResponse
322322
if err := requestDo[api.ASProtocolResponse](as.HTTPClient, as.RequestUrl()+api.ASProtocolPath+p, &proto); err != nil {
323-
log.WithError(err).Error("unable to get 'protocol' from application service")
323+
log.WithError(err).WithField("application_service", as.ID).Error("unable to get 'protocol' from application service")
324324
continue
325325
}
326326
existing, ok := response[p]

0 commit comments

Comments
 (0)