We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Implement rooms v5
Synapse v1.0 will default to rooms v4, however the intention is that it also ships with rooms v5 which is envisaged to be rooms v4 + https://github.com/matrix-org/synapse/issues/4364

rooms v5 is yet to be MSC'd so does not formally exist at this point, this issue is a place holder.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `synapse/api/room_versions.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # Copyright 2019 New Vector Ltd
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 import attr
16 
17 
18 class EventFormatVersions(object):
19     """This is an internal enum for tracking the version of the event format,
20     independently from the room version.
21     """
22     V1 = 1   # $id:server event id format
23     V2 = 2   # MSC1659-style $hash event id format: introduced for room v3
24     V3 = 3   # MSC1884-style $hash format: introduced for room v4
25 
26 
27 KNOWN_EVENT_FORMAT_VERSIONS = {
28     EventFormatVersions.V1,
29     EventFormatVersions.V2,
30     EventFormatVersions.V3,
31 }
32 
33 
34 class StateResolutionVersions(object):
35     """Enum to identify the state resolution algorithms"""
36     V1 = 1   # room v1 state res
37     V2 = 2   # MSC1442 state res: room v2 and later
38 
39 
40 class RoomDisposition(object):
41     STABLE = "stable"
42     UNSTABLE = "unstable"
43 
44 
45 @attr.s(slots=True, frozen=True)
46 class RoomVersion(object):
47     """An object which describes the unique attributes of a room version."""
48 
49     identifier = attr.ib()      # str; the identifier for this version
50     disposition = attr.ib()     # str; one of the RoomDispositions
51     event_format = attr.ib()    # int; one of the EventFormatVersions
52     state_res = attr.ib()       # int; one of the StateResolutionVersions
53     enforce_key_validity = attr.ib()  # bool
54 
55 
56 class RoomVersions(object):
57     V1 = RoomVersion(
58         "1",
59         RoomDisposition.STABLE,
60         EventFormatVersions.V1,
61         StateResolutionVersions.V1,
62         enforce_key_validity=False,
63     )
64     V2 = RoomVersion(
65         "2",
66         RoomDisposition.STABLE,
67         EventFormatVersions.V1,
68         StateResolutionVersions.V2,
69         enforce_key_validity=False,
70     )
71     V3 = RoomVersion(
72         "3",
73         RoomDisposition.STABLE,
74         EventFormatVersions.V2,
75         StateResolutionVersions.V2,
76         enforce_key_validity=False,
77     )
78     V4 = RoomVersion(
79         "4",
80         RoomDisposition.STABLE,
81         EventFormatVersions.V3,
82         StateResolutionVersions.V2,
83         enforce_key_validity=False,
84     )
85     VDH_TEST_KEY_VALIDITY = RoomVersion(
86         "vdh-test-key-validity",
87         RoomDisposition.UNSTABLE,
88         EventFormatVersions.V3,
89         StateResolutionVersions.V2,
90         enforce_key_validity=False,
91     )
92 
93 
94 KNOWN_ROOM_VERSIONS = {
95     v.identifier: v for v in (
96         RoomVersions.V1,
97         RoomVersions.V2,
98         RoomVersions.V3,
99         RoomVersions.V4,
100         RoomVersions.VDH_TEST_KEY_VALIDITY,
101     )
102 }   # type: dict[str, RoomVersion]
103
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/synapse/api/room_versions.py b/synapse/api/room_versions.py
--- a/synapse/api/room_versions.py
+++ b/synapse/api/room_versions.py
@@ -82,12 +82,12 @@
         StateResolutionVersions.V2,
         enforce_key_validity=False,
     )
-    VDH_TEST_KEY_VALIDITY = RoomVersion(
-        "vdh-test-key-validity",
-        RoomDisposition.UNSTABLE,
+    V5 = RoomVersion(
+        "5",
+        RoomDisposition.STABLE,
         EventFormatVersions.V3,
         StateResolutionVersions.V2,
-        enforce_key_validity=False,
+        enforce_key_validity=True,
     )
 
 
@@ -97,6 +97,6 @@
         RoomVersions.V2,
         RoomVersions.V3,
         RoomVersions.V4,
-        RoomVersions.VDH_TEST_KEY_VALIDITY,
+        RoomVersions.V5,
     )
 }   # type: dict[str, RoomVersion]

{"golden_diff": "diff --git a/synapse/api/room_versions.py b/synapse/api/room_versions.py\n--- a/synapse/api/room_versions.py\n+++ b/synapse/api/room_versions.py\n@@ -82,12 +82,12 @@\n         StateResolutionVersions.V2,\n         enforce_key_validity=False,\n     )\n-    VDH_TEST_KEY_VALIDITY = RoomVersion(\n-        \"vdh-test-key-validity\",\n-        RoomDisposition.UNSTABLE,\n+    V5 = RoomVersion(\n+        \"5\",\n+        RoomDisposition.STABLE,\n         EventFormatVersions.V3,\n         StateResolutionVersions.V2,\n-        enforce_key_validity=False,\n+        enforce_key_validity=True,\n     )\n \n \n@@ -97,6 +97,6 @@\n         RoomVersions.V2,\n         RoomVersions.V3,\n         RoomVersions.V4,\n-        RoomVersions.VDH_TEST_KEY_VALIDITY,\n+        RoomVersions.V5,\n     )\n }   # type: dict[str, RoomVersion]\n", "issue": "Implement rooms v5\nSynapse v1.0 will default to rooms v4, however the intention is that it also ships with rooms v5 which is envisaged to be rooms v4 + https://github.com/matrix-org/synapse/issues/4364\r\n\r\nrooms v5 is yet to be MSC'd so does not formally exist at this point, this issue is a place holder.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2019 New Vector Ltd\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport attr\n\n\nclass EventFormatVersions(object):\n    \"\"\"This is an internal enum for tracking the version of the event format,\n    independently from the room version.\n    \"\"\"\n    V1 = 1   # $id:server event id format\n    V2 = 2   # MSC1659-style $hash event id format: introduced for room v3\n    V3 = 3   # MSC1884-style $hash format: introduced for room v4\n\n\nKNOWN_EVENT_FORMAT_VERSIONS = {\n    EventFormatVersions.V1,\n    EventFormatVersions.V2,\n    EventFormatVersions.V3,\n}\n\n\nclass StateResolutionVersions(object):\n    \"\"\"Enum to identify the state resolution algorithms\"\"\"\n    V1 = 1   # room v1 state res\n    V2 = 2   # MSC1442 state res: room v2 and later\n\n\nclass RoomDisposition(object):\n    STABLE = \"stable\"\n    UNSTABLE = \"unstable\"\n\n\n@attr.s(slots=True, frozen=True)\nclass RoomVersion(object):\n    \"\"\"An object which describes the unique attributes of a room version.\"\"\"\n\n    identifier = attr.ib()      # str; the identifier for this version\n    disposition = attr.ib()     # str; one of the RoomDispositions\n    event_format = attr.ib()    # int; one of the EventFormatVersions\n    state_res = attr.ib()       # int; one of the StateResolutionVersions\n    enforce_key_validity = attr.ib()  # bool\n\n\nclass RoomVersions(object):\n    V1 = RoomVersion(\n        \"1\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V1,\n        enforce_key_validity=False,\n    )\n    V2 = RoomVersion(\n        \"2\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n    V3 = RoomVersion(\n        \"3\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V2,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n    V4 = RoomVersion(\n        \"4\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n    VDH_TEST_KEY_VALIDITY = RoomVersion(\n        \"vdh-test-key-validity\",\n        RoomDisposition.UNSTABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n\n\nKNOWN_ROOM_VERSIONS = {\n    v.identifier: v for v in (\n        RoomVersions.V1,\n        RoomVersions.V2,\n        RoomVersions.V3,\n        RoomVersions.V4,\n        RoomVersions.VDH_TEST_KEY_VALIDITY,\n    )\n}   # type: dict[str, RoomVersion]\n", "path": "synapse/api/room_versions.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2019 New Vector Ltd\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport attr\n\n\nclass EventFormatVersions(object):\n    \"\"\"This is an internal enum for tracking the version of the event format,\n    independently from the room version.\n    \"\"\"\n    V1 = 1   # $id:server event id format\n    V2 = 2   # MSC1659-style $hash event id format: introduced for room v3\n    V3 = 3   # MSC1884-style $hash format: introduced for room v4\n\n\nKNOWN_EVENT_FORMAT_VERSIONS = {\n    EventFormatVersions.V1,\n    EventFormatVersions.V2,\n    EventFormatVersions.V3,\n}\n\n\nclass StateResolutionVersions(object):\n    \"\"\"Enum to identify the state resolution algorithms\"\"\"\n    V1 = 1   # room v1 state res\n    V2 = 2   # MSC1442 state res: room v2 and later\n\n\nclass RoomDisposition(object):\n    STABLE = \"stable\"\n    UNSTABLE = \"unstable\"\n\n\n@attr.s(slots=True, frozen=True)\nclass RoomVersion(object):\n    \"\"\"An object which describes the unique attributes of a room version.\"\"\"\n\n    identifier = attr.ib()      # str; the identifier for this version\n    disposition = attr.ib()     # str; one of the RoomDispositions\n    event_format = attr.ib()    # int; one of the EventFormatVersions\n    state_res = attr.ib()       # int; one of the StateResolutionVersions\n    enforce_key_validity = attr.ib()  # bool\n\n\nclass RoomVersions(object):\n    V1 = RoomVersion(\n        \"1\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V1,\n        enforce_key_validity=False,\n    )\n    V2 = RoomVersion(\n        \"2\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n    V3 = RoomVersion(\n        \"3\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V2,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n    V4 = RoomVersion(\n        \"4\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n    )\n    V5 = RoomVersion(\n        \"5\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n    )\n\n\nKNOWN_ROOM_VERSIONS = {\n    v.identifier: v for v in (\n        RoomVersions.V1,\n        RoomVersions.V2,\n        RoomVersions.V3,\n        RoomVersions.V4,\n        RoomVersions.V5,\n    )\n}   # type: dict[str, RoomVersion]\n", "path": "synapse/api/room_versions.py"}]}