Commit graph

710 commits

Author SHA1 Message Date
Neil Alexander 8591f3c4b3 Try to prepare event using room ID in sarama metadata 2020-03-11 11:20:27 +00:00
Neil Alexander ba7f0c44a0 Use PrepareAs 2020-03-11 11:04:38 +00:00
Neil Alexander e2803ab4a6 more fixes 2020-03-10 17:37:58 +00:00
Neil Alexander 9016bbd44b try to be btter behaved when updating room_version in syncapi 2020-03-10 17:31:53 +00:00
Neil Alexander 6ba953efb8 More logging 2020-03-10 16:56:06 +00:00
Neil Alexander 734935042d Revert "Don't panic"
This reverts commit 55680d21ca.
2020-03-10 16:36:09 +00:00
Neil Alexander 55680d21ca Don't panic 2020-03-10 16:33:22 +00:00
Neil Alexander 243788878e Fix makeOutputNewRoomEvent 2020-03-10 16:25:52 +00:00
Neil Alexander 091e98a2d1 more logging needed 2020-03-10 16:18:24 +00:00
Neil Alexander 70fdf9f834 Send room version of kafka for output events from roomserver 2020-03-10 16:09:06 +00:00
Neil Alexander b7744e3c0c Fix create-room-events 2020-03-10 15:42:47 +00:00
Neil Alexander 0c67aa99bd Update gomatrixserverlib 2020-03-10 15:41:08 +00:00
Neil Alexander b49be53e17 Update gomatrixserverlib 2020-03-10 15:19:45 +00:00
Neil Alexander a78ecad80c Hopefully finish wiring room versions into syncapi 2020-03-10 14:00:59 +00:00
Neil Alexander ea2fa4a401 Merge branch 'master' into neilalexander/stateresv2 2020-03-10 11:46:36 +00:00
Neil Alexander 176f722d53 Update .gitignore 2020-03-10 11:42:40 +00:00
Neil Alexander 6bf0e69499 Fix a lot of room versions wiring (apart from syncapi) 2020-03-10 11:31:55 +00:00
Kegsay cdc1157785
Improve logging when sending events (#883)
We have some failing sytests on sqlite but it's very difficult to debug
due to lack of useful logging. This adds a log line for when a new event
is sent (incl. logging the event ID) as well as adding a user_id field
for all contextual logs so we know who initiated certain actions.
2020-03-09 14:37:51 +00:00
Neil Alexander 1b52775ccd If room_version isn't specified in the m.room.create event, assume room version 1 2020-03-09 09:10:01 +00:00
Kegsay c31cb02271
bugfix: Fix a race condition when creating guest accounts (#882)
* bugfix: Fix a race condition when creating guest accounts

It was possible to both select the same next numeric ID and then both
attempt to INSERT this into the table. This would cause a UNIQUE violation
which then presented itself as an error in sqlite because it does not
implement `common.IsUniqueConstraintViolationErr`.

The fix here is NOT to implement `common.IsUniqueConstraintViolationErr`
otherwise the 2 users would get the SAME guest account. Instead, all of
these operations should be done inside a transaction. This is what this
PR does.

* Update postgres

* Typo

* Actually use the txn when creating accounts

* bugfix for database is locked on guest reg
2020-03-06 18:00:07 +00:00
Neil Alexander e43d8a17ae Merge branch 'master' into neilalexander/stateresv2 2020-03-06 17:00:15 +00:00
Neil Alexander 6a1111c3d4
Try to recursively find auth events (to a point) if they are missing (#881)
* Try to recursively find auth events (to a point) if they are missing

* Remove recursion limit for now and other review fixes

* Simplify error handling for recursion

* Pass room version 1 only to MakeJoin until room version support comes later
2020-03-06 16:58:10 +00:00
Kegan Dougal 87283e9de7 bugfix: fix sytest 155 by actually returning depth+1 and not 0 2020-03-06 14:31:12 +00:00
Neil Alexander 16365357b7 whoops compile error 2020-03-06 13:58:00 +00:00
Neil Alexander adf2726f20 Fully populate eventIDMap 2020-03-06 13:41:59 +00:00
Neil Alexander 0a3db9e952 Update gomatrixserverlib 2020-03-06 13:01:13 +00:00
Neil Alexander 45f60e7a65 Fix type of room_version in make_join 2020-03-06 12:15:59 +00:00
Neil Alexander fb3f97e9fe Update room version checking code 2020-03-06 11:57:45 +00:00
Neil Alexander a4401e3fb0 Update common.BuildEvent 2020-03-06 11:23:11 +00:00
Neil Alexander 85e658ca06 Update gomatrixserverlib 2020-03-06 11:15:21 +00:00
Neil Alexander 8257c22700 Merge branch 'master' into neilalexander/stateresv2 2020-03-06 10:38:26 +00:00
Kegsay a97b8eafd4
Add peer-to-peer support into Dendrite via libp2p and fetch (#880)
* Use a fork of pq which supports userCurrent on wasm

* Use sqlite3_js driver when running in JS

* Add cmd/dendritejs to pull in sqlite3_js driver for wasm only

* Update to latest go-sqlite-js version

* Replace prometheus with a stub. sigh

* Hard-code a config and don't use opentracing

* Latest go-sqlite3-js version

* Generate a key for now

* Listen for fetch traffic rather than HTTP

* Latest hacks for js

* libp2p support

* More libp2p

* Fork gjson to allow us to enforce auth checks as before

Previously, all events would come down redacted because the hash
checks would fail. They would fail because sjson.DeleteBytes didn't
remove keys not used for hashing. This didn't work because of a build
tag which included a file which no-oped the index returned.

See https://github.com/tidwall/gjson/issues/157

When it's resolved, let's go back to mainline.

* Use gjson@1.6.0 as it fixes https://github.com/tidwall/gjson/issues/157

* Use latest gomatrixserverlib for sig checks

* Fix a bug which could cause exclude_from_sync to not be set

Caused when sending events over federation.

* Use query variadic to make lookups actually work!

* Latest gomatrixserverlib

* Add notes on getting p2p up and running

Partly so I don't forget myself!

* refactor: Move p2p specific stuff to cmd/dendritejs

This is important or else the normal build of dendrite will fail
because the p2p libraries depend on syscall/js which doesn't work
on normal builds.

Also, clean up main.go to read a bit better.

* Update ho-http-js-libp2p to return errors from RoundTrip

* Add an LRU cache around the key DB

We actually need this for P2P because otherwise we can *segfault*
with things like: "runtime: unexpected return pc for runtime.handleEvent"
where the event is a `syscall/js` event, caused by spamming sql.js
caused by "Checking event signatures for 14 events of room state" which
hammers the key DB repeatedly in quick succession.

Using a cache fixes this, though the underlying cause is probably a bug
in the version of Go I'm on (1.13.7)

* breaking: Add Tracing.Enabled to toggle whether we do opentracing

Defaults to false, which is why this is a breaking change. We need
this flag because WASM builds cannot do opentracing.

* Start adding conditional builds for wasm to handle lib/pq

The general idea here is to have the wasm build have a `NewXXXDatabase`
that doesn't import any postgres package and hence we never import
`lib/pq`, which doesn't work under WASM (undefined `userCurrent`).

* Remove lib/pq for wasm for syncapi

* Add conditional building to remaining storage APIs

* Update build script to set env vars correctly for dendritejs

* sqlite bug fixes

* Docs

* Add a no-op main for dendritejs when not building under wasm

* Use the real prometheus, even for WASM

Instead, the dendrite-sw.js must mock out `process.pid` and
`fs.stat` - which must invoke the callback with an error (e.g `EINVAL`)
in order for it to work:

```
    global.process = {
        pid: 1,
    };
    global.fs.stat = function(path, cb) {
        cb({
            code: "EINVAL",
        });
    }
```

* Linting
2020-03-06 10:23:55 +00:00
Neil Alexander f3dee39c9d Implement API for querying room version 2020-03-05 10:22:33 +00:00
Neil Alexander 25cdf733e2 Update gomatrixserverlib 2020-03-04 17:56:55 +00:00
Neil Alexander 3f31c4d5ca Try to establish auth difference for state res v2 2020-03-04 11:37:23 +00:00
Neil Alexander 0ec7403c2d Update gomatrixserverlib 2020-03-03 11:45:55 +00:00
Neil Alexander f69a553ad6 Merge branch 'neilalexander/stateresv2' of github.com:matrix-org/dendrite into neilalexander/stateresv2 2020-03-03 09:22:43 +00:00
Neil Alexander d22067f7d6 Merge branch 'master' into neilalexander/stateresv2 2020-03-02 18:02:13 +00:00
Neil Alexander 0cda3c52d0 Don't fail hard if backward topology position fails, just use 1 instead 2020-03-02 18:01:24 +00:00
Neil Alexander 11e8557529
Merge branch 'master' into neilalexander/stateresv2 2020-03-02 16:21:02 +00:00
Neil Alexander 59a1f4b8ed
Remove httputil.LogThenError so that the line numbers are reported properly - make error reporting slightly more useful (#879) 2020-03-02 16:20:44 +00:00
Neil Alexander 2e8438ee56 Update go.mod/go.sum 2020-02-28 16:40:58 +00:00
Neil Alexander 1ac571973c Try to take room version from createRoomReq 2020-02-28 16:29:42 +00:00
Neil Alexander c5163313e4
Merge branch 'master' into neilalexander/stateresv2 2020-02-28 15:08:26 +00:00
Neil Alexander 72565f2eeb
Fix bug in devices endpoint (#877) 2020-02-28 15:06:16 +00:00
Neil Alexander 6460b3725d
Make sure PDUs and EDUs in transaction don't marshal to null (#876) 2020-02-28 14:54:51 +00:00
Kegan Dougal 420ee15433 Kick CI 2020-02-28 14:46:03 +00:00
Neil Alexander 2f45bc417b Get room version from initial persistence of m.room.create 2020-02-26 17:57:47 +00:00
Neil Alexander 15f9672c7d Try to get room version from m.room.create event at first NID assign 2020-02-26 17:40:17 +00:00
Neil Alexander 892180cb2c Try that again 2020-02-26 17:06:11 +00:00