One case walks the three unpadded bands with a signature ending in 0x01 and
asserts the fragments carry the whole frame; it loses a byte without the fix.
The other pins the padded case, so the frame keeps being fragmented without
its padding.
createFragments encoded the packet with padding on and then called
MessagePadding.unpad to strip it again. Across most of the fragmentation range
no padding was ever applied: pad() declines a request needing more than 255
bytes, and optimalBlockSize() returns the input size unchanged above 2048, so
frames of 513-768, 1009-1792 and >=2033 bytes come back untouched.
An unpadded frame ends with the last byte of the signature, which is uniformly
random. unpad reads it as a PKCS#7 pad length, and a value of 0x01 satisfies
the tail check trivially, so a real signature byte is stripped. Every receiver
reassembles the fragments faithfully and then fails the size check in
decodeCore, which is why the message dies on all of them at once with nothing
in the sender's log.
Ask the encoder for the unpadded frame instead. Byte-identical for frames that
really were padded, so nothing changes on the wire.
If SQLite clearAll fails mid-panic, in-memory state was already cleared
but a process restart could reload encrypted history from disk (#699).
Fall back to deleting the database files before reporting failure.
A relay that fails is retried on an exponential backoff, then abandoned
for the lifetime of the process. Nothing brings it back: the relay layer
registers no connectivity callback, the periodic subscription validator
only repairs subscriptions on sockets that are already open (and returns
immediately when connectedRelayCount is 0, which is exactly the state
after an outage), and connect() runs once from NostrClient.initialize().
The remaining paths that reset reconnectAttempts are a manual retry, a
Tor state change, and a successful open.
Two ways a relay died permanently:
- Any error whose message mentioned DNS returned before scheduling
anything at all. "Unable to resolve host" is what this device reports
when it simply has no network, so a moment in a tunnel killed every
relay at once, with no retry ever.
- Otherwise the schedule stopped at MAX_RECONNECT_ATTEMPTS. With
INITIAL=1s and MULTIPLIER=2 that is nine waits totalling about eight
and a half minutes, after which the relay was dead. MAX_BACKOFF_INTERVAL
was unreachable: attempt 9 asks for 256s and attempt 10 gave up, so the
five-minute ceiling the constant defines never applied to anything.
Let the backoff saturate at MAX_BACKOFF_INTERVAL and keep retrying there.
A name-resolution failure now backs off like any other error. Steady state
costs one connection attempt per relay per five minutes; the previous
behaviour cost the user every internet DM, delivery receipt and geohash
channel until they noticed and restarted the app.
The schedule moves into RelayReconnectPolicy so it is unit-testable
without OkHttp or a Context.
The collision case fails on main: two packets sharing a 64-byte prefix and
a timestamp, where the second was silently dropped.
The other two pass before and after on purpose. Replay of an identical
packet must still be caught, and the same packet arriving from two
different peers must still be tracked separately — strengthening the
identity must not quietly weaken either.