You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(network): throw on unsigned messages in dkgGossipMsgId (Codex PR #501)
Codex review feedback on PR #501 (round 4):
> For type: 'unsigned' this falls back to fromBytes = [] and seqno =
> 0n, so two different unsigned publishers sending the same payload
> on the same topic will produce the same msgId and one publish will
> be falsely deduplicated. Because this helper is now exported
> publicly, consumers can hit that collision even before core wires
> it in.
Real bug at the API surface level. The earlier draft handled
unsigned by zero-filling the publisher and seqno fields, which
preserves the upstream-default false-dedup property — fine if
nothing ever calls it with unsigned messages, but a footgun for
external consumers of the exported function.
V10 configures gossipsub with the StrictSign default, so unsigned
messages don't appear in the wild today. Throwing here makes the
"unsigned not supported in this msgId scheme" stance explicit:
- any code path that tries to publish an unsigned message fails
loudly (easy to debug),
- external consumers of the exported function can't accidentally
hit the false-dedup case,
- a future PR that wants to support unsigned has to deliberately
extend the scheme with a per-message identity (nonce / hash
prefix / etc.), pinned by tests.
Implementation:
- New `DkgGossipUnsignedMessageError` class (also exported) with a
message that explains the constraint and points at the workarounds.
- `dkgGossipMsgId` throws the error for `msg.type !== 'signed'` before
building the hash input.
- Updated tests: replaced the "unsigned: length-framed sha256 with
seqno=0n and empty from" case with "unsigned: throws
DkgGossipUnsignedMessageError"; dropped the now-impossible
"signed and unsigned with same topic/payload differ" case.
Tests:
- core gossip-msg-id 10/10 (was 11; net -1 because the
signed-vs-unsigned diff test became unreachable)
Co-authored-by: Cursor <cursoragent@cursor.com>
0 commit comments