Remove legacy nip_ee_mls feature-gating code

This commit is contained in:
2026-03-13 22:33:48 +01:00
parent c1bebd5553
commit 99983bbb32
12 changed files with 14 additions and 79 deletions

View File

@@ -60,7 +60,7 @@ Implementation checklist for Parrhesia relay.
- [x] NIP-17/59 recipient-protected giftwrap read path (`kind:1059`) - [x] NIP-17/59 recipient-protected giftwrap read path (`kind:1059`)
- [x] NIP-29 group event policy + relay metadata events - [x] NIP-29 group event policy + relay metadata events
- [x] NIP-43 membership request flow (`28934/28935/28936`, `8000/8001`, `13534`) - [x] NIP-43 membership request flow (`28934/28935/28936`, `8000/8001`, `13534`)
- [x] NIP-EE (feature-flagged): `443`, `445`, `10051` handling - [x] Marmot MIP relay surface: `443`, `445`, `10051` handling
- [x] MLS retention policy + tests for commit race edge cases - [x] MLS retention policy + tests for commit race edge cases
## Phase 8 — management API + operations ## Phase 8 — management API + operations

View File

@@ -39,7 +39,6 @@ config :parrhesia,
nip_45_count: true, nip_45_count: true,
nip_50_search: true, nip_50_search: true,
nip_77_negentropy: true, nip_77_negentropy: true,
nip_ee_mls: false,
marmot_push_notifications: false marmot_push_notifications: false
], ],
storage: [ storage: [

View File

@@ -30,7 +30,6 @@ defmodule Parrhesia.Policy.EventPolicy do
| :pow_below_minimum | :pow_below_minimum
| :pubkey_banned | :pubkey_banned
| :event_banned | :event_banned
| :mls_disabled
@spec authorize_read([map()], MapSet.t(String.t())) :: :ok | {:error, policy_error()} @spec authorize_read([map()], MapSet.t(String.t())) :: :ok | {:error, policy_error()}
def authorize_read(filters, authenticated_pubkeys) when is_list(filters) do def authorize_read(filters, authenticated_pubkeys) when is_list(filters) do
@@ -57,8 +56,7 @@ defmodule Parrhesia.Policy.EventPolicy do
fn -> enforce_pow(event) end, fn -> enforce_pow(event) end,
fn -> enforce_protected_event(event, authenticated_pubkeys) end, fn -> enforce_protected_event(event, authenticated_pubkeys) end,
fn -> enforce_media_metadata_policy(event) end, fn -> enforce_media_metadata_policy(event) end,
fn -> enforce_push_notification_policy(event) end, fn -> enforce_push_notification_policy(event) end
fn -> enforce_mls_feature_flag(event) end
] ]
Enum.reduce_while(checks, :ok, fn check, :ok -> Enum.reduce_while(checks, :ok, fn check, :ok ->
@@ -135,7 +133,6 @@ defmodule Parrhesia.Policy.EventPolicy do
def error_message(:pow_below_minimum), do: "pow: minimum proof-of-work difficulty not met" def error_message(:pow_below_minimum), do: "pow: minimum proof-of-work difficulty not met"
def error_message(:pubkey_banned), do: "blocked: pubkey is banned" def error_message(:pubkey_banned), do: "blocked: pubkey is banned"
def error_message(:event_banned), do: "blocked: event is banned" def error_message(:event_banned), do: "blocked: event is banned"
def error_message(:mls_disabled), do: "blocked: mls feature flag is disabled"
defp maybe_require_auth_for_write(authenticated_pubkeys) do defp maybe_require_auth_for_write(authenticated_pubkeys) do
if config_bool([:policies, :auth_required_for_writes], false) and if config_bool([:policies, :auth_required_for_writes], false) and
@@ -651,14 +648,6 @@ defmodule Parrhesia.Policy.EventPolicy do
end end
end end
defp enforce_mls_feature_flag(event) do
if event["kind"] in [443, 445, 10_051] and not config_bool([:features, :nip_ee_mls], false) do
{:error, :mls_disabled}
else
:ok
end
end
defp config_bool([scope, key], default) do defp config_bool([scope, key], default) do
case Application.get_env(:parrhesia, scope, []) |> Keyword.get(key, default) do case Application.get_env(:parrhesia, scope, []) |> Keyword.get(key, default) do
true -> true true -> true

View File

@@ -855,12 +855,12 @@ defmodule Parrhesia.Storage.Adapters.Postgres.Events do
defp parse_unix_seconds(_unix_seconds), do: nil defp parse_unix_seconds(_unix_seconds), do: nil
defp maybe_apply_mls_group_retention(nil, 445, created_at) do defp maybe_apply_mls_group_retention(nil, 445, created_at) do
if Application.get_env(:parrhesia, :features, []) |> Keyword.get(:nip_ee_mls, false) do ttl =
ttl = :parrhesia
:parrhesia |> Application.get_env(:policies, [])
|> Application.get_env(:policies, []) |> Keyword.get(:mls_group_event_ttl_seconds, 300)
|> Keyword.get(:mls_group_event_ttl_seconds, 300)
if is_integer(ttl) and ttl > 0 do
created_at + ttl created_at + ttl
else else
nil nil

View File

@@ -443,8 +443,7 @@ defmodule Parrhesia.Web.Connection do
:push_notification_replay_window_exceeded, :push_notification_replay_window_exceeded,
:push_notification_missing_expiration, :push_notification_missing_expiration,
:push_notification_expiration_too_far, :push_notification_expiration_too_far,
:push_notification_server_recipients_exceeded, :push_notification_server_recipients_exceeded
:mls_disabled
], ],
do: EventPolicy.error_message(reason) do: EventPolicy.error_message(reason)

View File

@@ -37,15 +37,6 @@ defmodule Parrhesia.Web.RelayInfo do
86, 86,
98 98
] ]
|> maybe_add_mls()
end
defp maybe_add_mls(nips) do
if Parrhesia.Config.get([:features, :nip_ee_mls], false) do
["EE" | nips]
else
nips
end
end end
defp limitations do defp limitations do

View File

@@ -12,7 +12,6 @@ defmodule Parrhesia.ConfigTest do
assert Parrhesia.Config.get([:policies, :marmot_media_reject_mip04_v1]) == true assert Parrhesia.Config.get([:policies, :marmot_media_reject_mip04_v1]) == true
assert Parrhesia.Config.get([:policies, :marmot_push_max_trigger_age_seconds]) == 120 assert Parrhesia.Config.get([:policies, :marmot_push_max_trigger_age_seconds]) == 120
assert Parrhesia.Config.get([:features, :nip_50_search]) == true assert Parrhesia.Config.get([:features, :nip_50_search]) == true
assert Parrhesia.Config.get([:features, :nip_ee_mls]) == false
assert Parrhesia.Config.get([:features, :marmot_push_notifications]) == false assert Parrhesia.Config.get([:features, :marmot_push_notifications]) == false
end end

View File

@@ -229,7 +229,6 @@ defmodule Parrhesia.Policy.EventPolicyTest do
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:features, :features,
nip_ee_mls: false,
marmot_push_notifications: true marmot_push_notifications: true
) )
@@ -281,7 +280,6 @@ defmodule Parrhesia.Policy.EventPolicyTest do
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:features, :features,
nip_ee_mls: false,
marmot_push_notifications: true marmot_push_notifications: true
) )
@@ -337,7 +335,6 @@ defmodule Parrhesia.Policy.EventPolicyTest do
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:features, :features,
nip_ee_mls: false,
marmot_push_notifications: true marmot_push_notifications: true
) )
@@ -424,15 +421,6 @@ defmodule Parrhesia.Policy.EventPolicyTest do
) )
end end
test "rejects mls kinds when feature is disabled" do
Application.put_env(:parrhesia, :features, nip_ee_mls: false)
event = %{"kind" => 443, "tags" => [], "pubkey" => String.duplicate("d", 64), "id" => ""}
assert {:error, :mls_disabled} =
EventPolicy.authorize_write(event, MapSet.new([String.duplicate("d", 64)]))
end
test "enforces min pow difficulty" do test "enforces min pow difficulty" do
Application.put_env(:parrhesia, :policies, min_pow_difficulty: 8) Application.put_env(:parrhesia, :policies, min_pow_difficulty: 8)

View File

@@ -346,7 +346,7 @@ defmodule Parrhesia.Storage.Adapters.Postgres.EventsQueryCountTest do
}) })
assert {:ok, results} = assert {:ok, results} =
Events.query(%{}, [%{"kinds" => [445], "#h" => [group_id]}], []) Events.query(%{}, [%{"kinds" => [445], "#h" => [group_id]}], now: 1_700_000_700)
tie_winner_id = Enum.min([tie_a["id"], tie_b["id"]]) tie_winner_id = Enum.min([tie_a["id"], tie_b["id"]])
tie_loser_id = Enum.max([tie_a["id"], tie_b["id"]]) tie_loser_id = Enum.max([tie_a["id"], tie_b["id"]])
@@ -368,7 +368,7 @@ defmodule Parrhesia.Storage.Adapters.Postgres.EventsQueryCountTest do
end) end)
assert {:ok, results} = assert {:ok, results} =
Events.query(%{}, [%{"kinds" => [445], "#h" => [group_id]}], []) Events.query(%{}, [%{"kinds" => [445], "#h" => [group_id]}], now: 1_700_001_100)
expected_ids = expected_ids =
events events

View File

@@ -28,12 +28,9 @@ defmodule Parrhesia.Storage.Adapters.Postgres.EventsTest do
assert normalized.pubkey == Base.decode16!(pubkey, case: :lower) assert normalized.pubkey == Base.decode16!(pubkey, case: :lower)
end end
test "applies MLS retention TTL to kind 445 when enabled" do test "applies MLS retention TTL to kind 445" do
previous_features = Application.get_env(:parrhesia, :features, [])
previous_policies = Application.get_env(:parrhesia, :policies, []) previous_policies = Application.get_env(:parrhesia, :policies, [])
Application.put_env(:parrhesia, :features, Keyword.put(previous_features, :nip_ee_mls, true))
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:policies, :policies,
@@ -41,7 +38,6 @@ defmodule Parrhesia.Storage.Adapters.Postgres.EventsTest do
) )
on_exit(fn -> on_exit(fn ->
Application.put_env(:parrhesia, :features, previous_features)
Application.put_env(:parrhesia, :policies, previous_policies) Application.put_env(:parrhesia, :policies, previous_policies)
end) end)
@@ -60,11 +56,8 @@ defmodule Parrhesia.Storage.Adapters.Postgres.EventsTest do
end end
test "keeps explicit expiration tag for kind 445 when present" do test "keeps explicit expiration tag for kind 445 when present" do
previous_features = Application.get_env(:parrhesia, :features, [])
previous_policies = Application.get_env(:parrhesia, :policies, []) previous_policies = Application.get_env(:parrhesia, :policies, [])
Application.put_env(:parrhesia, :features, Keyword.put(previous_features, :nip_ee_mls, true))
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:policies, :policies,
@@ -72,7 +65,6 @@ defmodule Parrhesia.Storage.Adapters.Postgres.EventsTest do
) )
on_exit(fn -> on_exit(fn ->
Application.put_env(:parrhesia, :features, previous_features)
Application.put_env(:parrhesia, :policies, previous_policies) Application.put_env(:parrhesia, :policies, previous_policies)
end) end)

View File

@@ -97,14 +97,6 @@ defmodule Parrhesia.Web.ConformanceTest do
end end
test "kind 445 commit ACK implies durable visibility before wrapped welcome ACK" do test "kind 445 commit ACK implies durable visibility before wrapped welcome ACK" do
previous_features = Application.get_env(:parrhesia, :features, [])
Application.put_env(:parrhesia, :features, Keyword.put(previous_features, :nip_ee_mls, true))
on_exit(fn ->
Application.put_env(:parrhesia, :features, previous_features)
end)
{:ok, state} = Connection.init(subscription_index: nil) {:ok, state} = Connection.init(subscription_index: nil)
commit_event = commit_event =
@@ -158,9 +150,7 @@ defmodule Parrhesia.Web.ConformanceTest do
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:features, :features,
previous_features Keyword.put(previous_features, :marmot_push_notifications, true)
|> Keyword.put(:marmot_push_notifications, true)
|> Keyword.put(:nip_ee_mls, false)
) )
Application.put_env( Application.put_env(

View File

@@ -159,14 +159,6 @@ defmodule Parrhesia.Web.ConnectionTest do
end end
test "malformed kind 445 envelope EVENT is rejected" do test "malformed kind 445 envelope EVENT is rejected" do
previous_features = Application.get_env(:parrhesia, :features, [])
Application.put_env(:parrhesia, :features, Keyword.put(previous_features, :nip_ee_mls, true))
on_exit(fn ->
Application.put_env(:parrhesia, :features, previous_features)
end)
state = connection_state() state = connection_state()
event = event =
@@ -232,9 +224,7 @@ defmodule Parrhesia.Web.ConnectionTest do
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:features, :features,
previous_features Keyword.put(previous_features, :marmot_push_notifications, true)
|> Keyword.put(:marmot_push_notifications, true)
|> Keyword.put(:nip_ee_mls, false)
) )
Application.put_env( Application.put_env(
@@ -285,9 +275,7 @@ defmodule Parrhesia.Web.ConnectionTest do
Application.put_env( Application.put_env(
:parrhesia, :parrhesia,
:features, :features,
previous_features Keyword.put(previous_features, :marmot_push_notifications, true)
|> Keyword.put(:marmot_push_notifications, true)
|> Keyword.put(:nip_ee_mls, false)
) )
Application.put_env( Application.put_env(