From e1eb1f3fb959468ddacb46e0766ce0c2ce938778 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 9 Sep 2015 17:02:39 +0100 Subject: [PATCH 1/7] Various bug fixes to crypto.keyring --- synapse/crypto/keyring.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index aa74d4d0c..644c7b14a 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -162,7 +162,9 @@ class Keyring(object): def remove_deferreds(res, server_name, group_id): server_to_gids[server_name].discard(group_id) if not server_to_gids[server_name]: - server_to_deferred.pop(server_name).callback(None) + d = server_to_deferred.pop(server_name, None) + if d: + d.callback(None) return res for g_id, deferred in deferreds.items(): @@ -200,8 +202,15 @@ class Keyring(object): else: break - for server_name, deferred in server_to_deferred: - self.key_downloads[server_name] = ObservableDeferred(deferred) + for server_name, deferred in server_to_deferred.items(): + d = ObservableDeferred(deferred) + self.key_downloads[server_name] = d + + def rm(r, server_name): + self.key_downloads.pop(server_name, None) + return r + + d.addBoth(rm, server_name) def get_server_verify_keys(self, group_id_to_group, group_id_to_deferred): """Takes a dict of KeyGroups and tries to find at least one key for @@ -220,9 +229,8 @@ class Keyring(object): merged_results = {} missing_keys = { - group.server_name: key_id + group.server_name: set(group.key_ids) for group in group_id_to_group.values() - for key_id in group.key_ids } for fn in key_fetch_fns: @@ -279,16 +287,15 @@ class Keyring(object): def get_keys_from_store(self, server_name_and_key_ids): res = yield defer.gatherResults( [ - self.store.get_server_verify_keys(server_name, key_ids) + self.store.get_server_verify_keys( + server_name, key_ids + ).addCallback(lambda ks, server: (server, ks), server_name) for server_name, key_ids in server_name_and_key_ids ], consumeErrors=True, ).addErrback(unwrapFirstError) - defer.returnValue(dict(zip( - [server_name for server_name, _ in server_name_and_key_ids], - res - ))) + defer.returnValue(dict(res)) @defer.inlineCallbacks def get_keys_from_perspectives(self, server_name_and_key_ids): From 3f604816555040a501874c8638d861b66dcd960b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 10 Sep 2015 09:58:32 +0100 Subject: [PATCH 2/7] Bump version and change log --- CHANGES.rst | 6 ++++++ synapse/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a0a12ca4a..1f6b712cb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,9 @@ +Changes in synapse v0.10.0-r2 (2015-09-10) +========================================== + +* Fix bug where we always fetched remote server signing keys instead of using + ones in our cache. + Changes in synapse v0.10.0-r1 (2015-09-08) ========================================== diff --git a/synapse/__init__.py b/synapse/__init__.py index 5b5ff6c3f..d62294e6b 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -16,4 +16,4 @@ """ This is a reference implementation of a Matrix home server. """ -__version__ = "0.10.0-r1" +__version__ = "0.10.0-r2" From ca32c7a0657c056a4d503b92e4120b880639663f Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 10 Sep 2015 10:33:48 +0100 Subject: [PATCH 3/7] Fix adding threepids to an existing account --- synapse/rest/client/v2_alpha/account.py | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/rest/client/v2_alpha/account.py b/synapse/rest/client/v2_alpha/account.py index 522a312c9..6281e2d02 100644 --- a/synapse/rest/client/v2_alpha/account.py +++ b/synapse/rest/client/v2_alpha/account.py @@ -96,6 +96,7 @@ class ThreepidRestServlet(RestServlet): self.hs = hs self.identity_handler = hs.get_handlers().identity_handler self.auth = hs.get_auth() + self.auth_handler = hs.get_handlers().auth_handler @defer.inlineCallbacks def on_GET(self, request): From 4ba8189b744ab942322b7da5136292d3c4bb4e58 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 10 Sep 2015 10:45:22 +0100 Subject: [PATCH 4/7] Bump change log --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 1f6b712cb..cab5e495c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,7 @@ Changes in synapse v0.10.0-r2 (2015-09-10) * Fix bug where we always fetched remote server signing keys instead of using ones in our cache. +* Fix adding threepids to an existing account. Changes in synapse v0.10.0-r1 (2015-09-08) ========================================== From 3b05b67c89bacfa729f14ad7c6de80b32d87cc98 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 15 Sep 2015 16:34:42 +0100 Subject: [PATCH 5/7] When updating a stored event from outlier to non-outlier, remember to update the extremeties --- synapse/storage/event_federation.py | 3 +++ synapse/storage/events.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py index dda3027b6..27284cd08 100644 --- a/synapse/storage/event_federation.py +++ b/synapse/storage/event_federation.py @@ -303,6 +303,9 @@ class EventFederationStore(SQLBaseStore): ], ) + self._update_extremeties(txn, events) + + def _update_extremeties(self, txn, events): events_by_room = {} for ev in events: events_by_room.setdefault(ev.room_id, []).append(ev) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index e3eabab13..8774b3b38 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -275,6 +275,8 @@ class EventsStore(SQLBaseStore): (False, event.event_id,) ) + self._update_extremeties(txn, [event]) + events_and_contexts = filter( lambda ec: ec[0] not in to_remove, events_and_contexts From 8148c48f11845af1747dc9447e47f9cce70c615f Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 15 Sep 2015 16:54:43 +0100 Subject: [PATCH 6/7] "Comments" --- synapse/storage/event_federation.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py index 27284cd08..7cb314dee 100644 --- a/synapse/storage/event_federation.py +++ b/synapse/storage/event_federation.py @@ -306,6 +306,12 @@ class EventFederationStore(SQLBaseStore): self._update_extremeties(txn, events) def _update_extremeties(self, txn, events): + """Updates the event_*_extremities tables based on the new/updated + events being persisted. + + This is called for new events *and* for events that were outliers, but + are are now being persisted as non-outliers. + """ events_by_room = {} for ev in events: events_by_room.setdefault(ev.room_id, []).append(ev) From 0b1a55c60a7b10a987583dc2c231e8b1cfd29f30 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 16 Sep 2015 09:55:44 +0100 Subject: [PATCH 7/7] Update changelog --- CHANGES.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index cab5e495c..f1d2c7a76 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,11 @@ -Changes in synapse v0.10.0-r2 (2015-09-10) +Changes in synapse v0.10.0-r2 (2015-09-16) ========================================== * Fix bug where we always fetched remote server signing keys instead of using ones in our cache. * Fix adding threepids to an existing account. +* Fix bug with invinting over federation where remote server was already in + the room. (PR #281, SYN-392) Changes in synapse v0.10.0-r1 (2015-09-08) ==========================================