From bdc10eb289adfa5f5ac0345801993925a907c0e1 Mon Sep 17 00:00:00 2001 From: koalasat Date: Mon, 15 Jul 2024 10:19:53 +0200 Subject: [PATCH] Switch to strfry --- api/nostr.py | 2 +- docker-compose.yml | 10 +-- docker-tests.yml | 14 +-- nodeapp/rnostr/config/rnostr.toml | 145 ------------------------------ nodeapp/strfry/config/strfry.conf | 138 ++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 158 deletions(-) delete mode 100644 nodeapp/rnostr/config/rnostr.toml create mode 100644 nodeapp/strfry/config/strfry.conf diff --git a/api/nostr.py b/api/nostr.py index 6d14b24c..02effa65 100644 --- a/api/nostr.py +++ b/api/nostr.py @@ -15,7 +15,7 @@ class Nostr: client = Client(signer) # Add relays and connect - await client.add_relays(["ws://localhost:888"]) + await client.add_relays(["ws://localhost:7777"]) await client.connect() event = EventBuilder(38383, "", self.generate_tags(order)).to_event(keys) diff --git a/docker-compose.yml b/docker-compose.yml index 1542f8dc..df78c7d5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -163,7 +163,7 @@ services: ports: - 8000:8000 # dev frontend build - 12596:12596 # umbrel frontend - - 888:888 # nostr + - 7777:7777 # nostr lnd: build: ./docker/lnd @@ -227,12 +227,12 @@ services: volumes: - ./node/db:/var/lib/postgresql/data - rnostr: - build: https://github.com/rnostr/rnostr.git - container_name: rnostr-dev + strfry: + build: https://github.com/hoytech/strfry.git + container_name: strfry-dev restart: unless-stopped volumes: - - ./nodeapp/rnostr/config/rnostr.toml:/rnostr/config/rnostr.toml:r + - ./nodeapp/strfry/config/strfry.conf:/app/strfry.conf:r network_mode: service:tor # # Postgresql for CLN diff --git a/docker-tests.yml b/docker-tests.yml index 202f46dd..41d3b5aa 100644 --- a/docker-tests.yml +++ b/docker-tests.yml @@ -205,13 +205,13 @@ services: # - redis # network_mode: service:bitcoind - rnostr: - build: https://github.com/rnostr/rnostr.git - container_name: test-rnostr - restart: unless-stopped - volumes: - - ./nodeapp/rnostr/config/rnostr.toml:/rnostr/config/rnostr.toml:r - network_mode: service:bitcoind + # strfry: + # build: https://github.com/hoytech/strfry.git + # container_name: test-strfry + # restart: unless-stopped + # volumes: + # - ./nodeapp/strfry/config/strfry.conf:/strfry/strfry.conf:r + # network_mode: service:bitcoind volumes: diff --git a/nodeapp/rnostr/config/rnostr.toml b/nodeapp/rnostr/config/rnostr.toml deleted file mode 100644 index 1d3e3dbc..00000000 --- a/nodeapp/rnostr/config/rnostr.toml +++ /dev/null @@ -1,145 +0,0 @@ -# Configuration -# All duration format reference https://docs.rs/duration-str/latest/duration_str/ -# -# config relay information -[information] -name = "rnostr" -description = "A high-performance and scalable nostr relay written in Rust." -software = "https://github.com/rnostr/rnostr" -# pubkey = "" -# contact = "" - -# config data path -[data] -# the data path (restart required) -# the events db path is $path/events -path = "./data" - -# Query filter timeout time, default no timeout. -db_query_timeout = "100ms" - -# config network -[network] -# Interface to listen on. Use 0.0.0.0 to listen on all interfaces (restart required) -host = "127.0.0.1" -# Listen port (restart required) -port = 888 - -# real ip header (default empty) -# ie: cf-connecting-ip, x-real-ip, x-forwarded-for -# real_ip_header = "x-forwarded-for" - -# redirect to other site when user access the http index page -# index_redirect_to = "https://example.com" - -# heartbeat timeout (default 120 seconds, must bigger than heartbeat interval) -# How long before lack of client response causes a timeout -# heartbeat_timeout = "2m" - -# heartbeat interval (default 60 seconds) -# How often heartbeat pings are sent -# heartbeat_interval = "1m" - -# config thread (restart required) -[thread] -# number of http server threads (restart required) -# default 0 will use the num of cpus -# http = 0 - -# number of read event threads (restart required) -# default 0 will use the num of cpus -# reader = 0 - -[limitation] -# this is the maximum number of bytes for incoming JSON. default 512K -max_message_length = 524288 -# total number of subscriptions that may be active on a single websocket connection to this relay. default 20 -max_subscriptions = 1 -# maximum number of filter values in each subscription. default 10 -max_filters = 10 -# the relay server will clamp each filter's limit value to this number. This means the client won't be able to get more than this number of events from a single subscription filter. default 300 -max_limit = 300 -# maximum length of subscription id as a string. default 100 -max_subid_length = 100 -# for authors and ids filters which are to match against a hex prefix, you must provide at least this many hex digits in the prefix. default 10 -min_prefix = 10 -# in any event, this is the maximum number of elements in the tags list. default 5000 -max_event_tags = 15 -# Events older than this will be rejected. default 3 years -max_event_time_older_than_now = 94608000 -# Events newer than this will be rejected. default 15 minutes -max_event_time_newer_than_now = 900 - -# Metrics extension, get the metrics data from https://example.com/metrics?auth=auth_key -[metrics] -enabled = false -# change the auth key -auth = "auth_key" - -# Auth extension -[auth] -enabled = false - -# # Authenticate the command 'REQ' get event, subscribe filter -# [auth.req] -# # only the list IP are allowed to req -# ip_whitelist = ["127.0.0.1"] -# # only the list IP are denied to req -# ip_blacklist = ["127.0.0.1"] -# # Restrict on nip42 verified pubkey, so client needs to implement nip42 and authenticate success -# pubkey_whitelist = ["xxxxxx"] -# pubkey_blacklist = ["xxxx"] - -# # Authenticate the command 'EVENT' write event -# [auth.event] -# ip_whitelist = ["127.0.0.1"] -# ip_blacklist = ["127.0.0.1"] -# # Restrict on nip42 verified pubkey, so client needs to implement nip42 and authenticate success -# pubkey_whitelist = ["xxxxxx"] -# pubkey_blacklist = ["xxxx"] -# # Restrict on event author pubkey, No need nip42 authentication -# event_pubkey_whitelist = ["xxxxxx"] -# event_pubkey_blacklist = ["xxxx"] - -# IP Rate limiter extension -[rate_limiter] -enabled = false - -# # interval at second for clearing invalid data to free up memory. -# # 0 will be converted to default 60 seconds -# clear_interval = "60s" - -# # rate limiter ruler list when write event per user client IP -# [[rate_limiter.event]] -# # name of rate limiter, used by metrics -# name = "all" -# # description will notice the user when rate limiter exceeded -# description = "allow only ten events per minute" -# period = "1m" -# limit = 10 - -# # only limit for kinds -# # support kind list: [1, 2, 3] -# # kind ranges included(start) to excluded(end): [[0, 10000], [30000, 40000]] -# # mixed: [1, 2, [30000, 40000]] -# kinds = [[0, 40000]] - -# # skip when ip in whitelist -# ip_whitelist = ["127.0.0.1"] - -# [[rate_limiter.event]] -# name = "kind 10000" -# description = "allow only five write events per minute when event kind between 0 to 10000" -# period = "60s" -# limit = 5 -# kinds = [[0, 10000]] - -# NIP-45 Count extension -# use carefully. see README.md#count -[count] -enabled = false - -# NIP-50 Search extension -# use carefully. see README.md#search -[search] -enabled = false diff --git a/nodeapp/strfry/config/strfry.conf b/nodeapp/strfry/config/strfry.conf new file mode 100644 index 00000000..3bdcf584 --- /dev/null +++ b/nodeapp/strfry/config/strfry.conf @@ -0,0 +1,138 @@ +## +## Default strfry config +## + +# Directory that contains the strfry LMDB database (restart required) +db = "./strfry-db/" + +dbParams { + # Maximum number of threads/processes that can simultaneously have LMDB transactions open (restart required) + maxreaders = 256 + + # Size of mmap() to use when loading LMDB (default is 10TB, does *not* correspond to disk-space used) (restart required) + mapsize = 10995116277760 + + # Disables read-ahead when accessing the LMDB mapping. Reduces IO activity when DB size is larger than RAM. (restart required) + noReadAhead = false +} + +events { + # Maximum size of normalised JSON, in bytes + maxEventSize = 65536 + + # Events newer than this will be rejected + rejectEventsNewerThanSeconds = 900 + + # Events older than this will be rejected + rejectEventsOlderThanSeconds = 94608000 + + # Ephemeral events older than this will be rejected + rejectEphemeralEventsOlderThanSeconds = 60 + + # Ephemeral events will be deleted from the DB when older than this + ephemeralEventsLifetimeSeconds = 300 + + # Maximum number of tags allowed + maxNumTags = 2000 + + # Maximum size for tag values, in bytes + maxTagValSize = 1024 +} + +relay { + # Interface to listen on. Use 0.0.0.0 to listen on all interfaces (restart required) + bind = "127.0.0.1" + + # Port to open for the nostr websocket protocol (restart required) + port = 7777 + + # Set OS-limit on maximum number of open files/sockets (if 0, don't attempt to set) (restart required) + nofiles = 1000000 + + # HTTP header that contains the client's real IP, before reverse proxying (ie x-real-ip) (MUST be all lower-case) + realIpHeader = "" + + info { + # NIP-11: Name of this server. Short/descriptive (< 30 characters) + name = "Robosats" + + # NIP-11: Detailed information about relay, free-form + description = "Federation cache system." + + # NIP-11: Administrative nostr pubkey, for contact purposes + pubkey = "" + + # NIP-11: Alternative administrative contact (email, website, etc) + contact = "" + } + + # Maximum accepted incoming websocket frame size (should be larger than max event) (restart required) + maxWebsocketPayloadSize = 131072 + + # Websocket-level PING message frequency (should be less than any reverse proxy idle timeouts) (restart required) + autoPingSeconds = 55 + + # If TCP keep-alive should be enabled (detect dropped connections to upstream reverse proxy) + enableTcpKeepalive = false + + # How much uninterrupted CPU time a REQ query should get during its DB scan + queryTimesliceBudgetMicroseconds = 10000 + + # Maximum records that can be returned per filter + maxFilterLimit = 500 + + # Maximum number of subscriptions (concurrent REQs) a connection can have open at any time + maxSubsPerConnection = 20 + + writePolicy { + # If non-empty, path to an executable script that implements the writePolicy plugin logic + plugin = "" + } + + compression { + # Use permessage-deflate compression if supported by client. Reduces bandwidth, but slight increase in CPU (restart required) + enabled = true + + # Maintain a sliding window buffer for each connection. Improves compression, but uses more memory (restart required) + slidingWindow = true + } + + logging { + # Dump all incoming messages + dumpInAll = false + + # Dump all incoming EVENT messages + dumpInEvents = false + + # Dump all incoming REQ/CLOSE messages + dumpInReqs = false + + # Log performance metrics for initial REQ database scans + dbScanPerf = false + + # Log reason for invalid event rejection? Can be disabled to silence excessive logging + invalidEvents = true + } + + numThreads { + # Ingester threads: route incoming requests, validate events/sigs (restart required) + ingester = 3 + + # reqWorker threads: Handle initial DB scan for events (restart required) + reqWorker = 3 + + # reqMonitor threads: Handle filtering of new events (restart required) + reqMonitor = 3 + + # negentropy threads: Handle negentropy protocol messages (restart required) + negentropy = 2 + } + + negentropy { + # Support negentropy protocol messages + enabled = true + + # Maximum records that sync will process before returning an error + maxSyncEvents = 1000000 + } +}