difficulty: the default for listings, reports and revocations is 24 bits (was 16)
About 4 s to mine one listing on 8 cores now that the miner is fast. Nodes of the old default refuse nothing from new ones, but a node at 24 refuses listings mined for 16, so the bootstrap node needs the new image to exchange listings with updated nodes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
+10
-4
@@ -89,7 +89,7 @@ Canonical JSON (RFC 8785), integers only. See `internal/listing`.
|
||||
| `features`, `title`, `description` | bounded text |
|
||||
| `images` | `{hash, thumb_hash}`, content-addressed, **no location** |
|
||||
| `delegate` | optional always-on host's peer ID, chosen by the owner |
|
||||
| `pow` | nonce; sha256 of the unsigned canonical bytes has N leading zero bits |
|
||||
| `pow` | nonce; sha256 of the unsigned canonical bytes has at least the network's *difficulty* leading zero bits (default **24**, `--difficulty`) |
|
||||
| `sig` | device signature over the unsigned canonical bytes (with context prefix) |
|
||||
|
||||
There is **no address, name, phone or email** in the record.
|
||||
@@ -538,9 +538,15 @@ makes the canonical bytes hash to enough leading zero bits, so every miner that
|
||||
tries 0, 1, 2, ... finds the same one. The node hashes the bytes before the
|
||||
nonce once and, per attempt, only the number and what follows, on every core
|
||||
but one. Measured on an 8-core machine under other load, mining one listing
|
||||
takes about 19 ms at difficulty 16 (the default), 0.14 s at 20, 1.1 s at 22,
|
||||
3.6 s at 24 and 15 s at 26: about 16 times longer per 4 bits. (Before this,
|
||||
every attempt re-encoded the JSON and one listing at 16 took about 2 s.)
|
||||
takes about 19 ms at difficulty 16, 0.14 s at 20, 1.1 s at 22, 3.6 s at 24
|
||||
(the default since 2026-11-19; it was 16) and 15 s at 26: about 16 times longer
|
||||
per 4 bits, with a spread of about three times either way from one listing to
|
||||
the next. On fewer cores it takes proportionally longer. (Before the fast
|
||||
miner every attempt re-encoded the JSON and one listing at 16 took about 2 s.)
|
||||
Listings, reports and revocations use this difficulty (`--difficulty`);
|
||||
messages have their own, lower one (`--message-difficulty`, 14). A listing
|
||||
mined for 16 is refused by a node at 24, so nodes of the old default and of
|
||||
the new one do not exchange listings until both are updated.
|
||||
|
||||
**What it can and cannot do.** The difficulty is a number of hashes, so it
|
||||
prices the work the same for everyone, but hardware is not equal: an attacker
|
||||
|
||||
@@ -36,8 +36,11 @@ const (
|
||||
)
|
||||
|
||||
// DefaultDifficulty is the proof-of-work (leading zero bits) the network
|
||||
// requires. All nodes must agree on it, or they reject each other's messages.
|
||||
const DefaultDifficulty = 16
|
||||
// requires of listings, reports and revocations. All nodes must agree on it,
|
||||
// or they reject each other's records: a node refuses what carries less than
|
||||
// its own value. 24 bits is a few seconds of mining for an honest node (see
|
||||
// "Spam" in docs/PROTOCOL.md); it was 16 until the miner became fast.
|
||||
const DefaultDifficulty = 24
|
||||
|
||||
// ErrTimeWindow marks failures caused by the clock (expired, or created in
|
||||
// the future). They are not the sender's fault, so the p2p layer ignores such
|
||||
|
||||
Reference in New Issue
Block a user