TXXM Churn KOR — Voluntary High-Cycle Exchange

A dedicated KOR namespace for high-cycle TXXM churn — rapid, voluntary exchange of TXXMs between Kapnet clients. Think of it as a coordination stress test and sync mesh. - **Voluntary opt-in only** —

TXXM Churn KOR — Voluntary High-Cycle Exchange

Concept

A dedicated KOR namespace for high-cycle TXXM churn — rapid, voluntary exchange of TXXMs between Kapnet clients. Think of it as a coordination stress test and sync mesh.

  • Voluntary opt-in only — clients choose to participate
  • High cycle — rapid TXXM submission, validation, and braid sync
  • Mesh topology — every churn participant is both producer and consumer
  • Ephemeral-friendly — short-lived TXXMs for testing, long-lived for state

KOR Namespace

txxm-churn.kor

Full npub-style identifier: txxm-churn.kor@kapnet

Registration

Clients opt in by publishing a kind-30078 event with d-tag txxm-churn-opt-in:

{
  "kind": 30078,
  "tags": [
    ["t", "kapnet"],
    ["t", "txxm-churn"],
    ["t", "opt-in"],
    ["d", "txxm-churn-opt-in"],
    ["p", "npub1dwpeuyfjv27nsl3qma3stqckfwusu053ncasmaru0vsy69d9vdqrcau36"]
  ],
  "content": JSON.stringify({
    "type": "txxm_churn_opt_in",
    "version": "1.0",
    "npub": "<client-npub>",
    "instance": "<instance-name>",
    "capabilities": ["txxm-submit", "txxm-validate", "braid-sync", "weakwork"],
    "planes": ["ipc", "nostr-vesicle", "sd-sneakernet"],
    "auth_level": "AUTH_4",
    "relay_hints": ["wss://relay.damus.io", "wss://nos.lol"],
    "timestamp": Math.floor(Date.now() / 1000)
  })
}

Churn Cycle

Each churn round:

ROUND N:
  1. Each participant submits TXXM (kind-30078, d: txxm-churn-<round>)
  2. All participants fetch new TXXMs from relay
  3. Each participant validates received TXXMs
  4. Valid TXXMs appended to local braid
  5. Braid state sync between participants (direct or relay)
  6. Knot checkpoint if quorum reached
  7. Next round

Round Interval

  • Fast churn: 30 seconds (testing, development)
  • Normal churn: 5 minutes (production sync)
  • Slow churn: 30 minutes (low-power, WAN)
  • Manual: On-demand trigger via Nostr signal

Churn TXXM Format

{
  "kind": 30078,
  "tags": [
    ["t", "kapnet"],
    ["t", "txxm-churn"],
    ["t", "round-<N>"],
    ["d", "txxm-churn-<round>-<npub-prefix>"],
    ["p", "<target-npub-or-broadcast>"],
    ["ref", "<parent-txxm-id>"]
  ],
  "content": JSON.stringify({
    "type": "txxm_churn",
    "version": "1.0",
    "round": "<N>",
    "from_npub": "<sender-npub>",
    "sequence": "<seq-in-round>",
    "payload": {
      "action": "ping|pong|sync|checkpoint|validate|bid|claim",
      "data": {}
    },
    "braid_ref": "<latest-local-braid-tip>",
    "knot_ref": "<latest-local-knot>",
    "weakwork": "<weakwork-score>",
    "timestamp": Math.floor(Date.now() / 1000)
  })
}

Churn Actions

Action Purpose Payload
ping Liveness check {}
pong Liveness response {"ref": "<ping-txxm-id>"}
sync Braid state sync {"braid_tip": "...", "knot_height": N}
checkpoint Knot proposal {"knot_data": {...}}
validate Validation attestation {"ref": "<txxm-id>", "valid": true|false}
bid Slot lottery bid {"template": "...", "bid_amount": N}
claim Hedlbit claim {"work_proof": "...", "amount": N}

Slot Lottery (Within Weakwork Template)

This is the key mechanism you described:

WEAKWORK TEMPLATE:
  Every churn round generates a weakwork template.
  Participants submit bids (weakwork proofs) into the template.
  Deterministic lottery selects winner based on:
    1. Weakwork score (higher = better chance)
    2. Bid amount (higher = better chance)
    3. Deterministic tiebreak: lowest hash(bid + nonce)

WINNER:
  Gets to include their Kapnet block in the template.
  Their TXXM is prioritized for braid inclusion.
  No coinbase commitment needed — template parsing IS the anchor.

LOSERS:
  Their TXXMs are still valid, just lower priority.
  Can retry in next round.

Lottery Algorithm

function selectWinner(bids, template) {
  // Each bid has: weakwork_score, bid_amount, npub, nonce
  const scored = bids.map(bid => {
    const score = bid.weakwork_score * bid.bid_amount;
    const hash = sha256(bid.npub + bid.nonce + template.id);
    return { ...bid, score, hash };
  });
  
  // Sort by score descending, then hash ascending for tiebreak
  scored.sort((a, b) => {
    if (a.score !== b.score) return b.score - a.score;
    return a.hash.localeCompare(b.hash);
  });
  
  return scored[0]; // Winner
}

Implementation

churn-client.cjs

Background process that:

  1. Subscribes to txxm-churn tag on relay
  2. On new round, submits churn TXXM
  3. Collects TXXMs from other participants
  4. Validates and appends to local braid
  5. Runs slot lottery
  6. Publishes results
  7. Sleeps until next round

Configuration

const CHURN_CONFIG = {
  kor: 'txxm-churn.kor',
  round_interval_ms: 300000,     // 5 minutes default
  min_participants: 2,           // Minimum for a round
  max_round_txs: 100,            // Max TXXMs per round
  lottery_enabled: true,         // Enable slot lottery
  weakwork_difficulty: 64,       // Weakwork target bits
  braid_sync: true,              // Sync braid state between rounds
  knot_interval: 10,             // Checkpoint every N rounds
  relay_hints: ['wss://relay.damus.io', 'wss://nos.lol'],
  inbox_dir: '/media/user/shared-rw/messaging/churn/inbox',
  outbox_dir: '/media/user/shared-rw/messaging/churn/outbox',
  state_file: '/media/user/shared-rw/messaging/churn/state.json',
  log_file: '/media/user/shared-rw/messaging/churn/churn.log'
};

module.exports = { CHURN_CONFIG };

GitHub Repo Structure

When kor-git is ready:

txxm-churn/
├── README.md              ← Protocol spec
├── schema/
│   ├── churn-txxm.json    ← JSON Schema for churn TXXMs
│   └── lottery.json       ← Lottery algorithm spec
├── src/
│   ├── churn-client.cjs   ← Main churn client
│   ├── lottery.js         ← Slot lottery implementation
│   ├── validator.js       ← TXXM validation
│   └── braid-sync.js      ← Braid state sync
├── config/
│   └── default.json       ← Default configuration
├── tests/
│   ├── churn.test.js
│   ├── lottery.test.js
│   └── validator.test.js
└── .github/
    └── workflows/
        └── churn CI.yml   ← Automated testing

Invitation

Elder herms running Kapnet clients opt in by:

  1. Running churn-client.cjs
  2. Publishing opt-in event
  3. Participating in churn rounds

The churn KOR is the living coordination mesh — where Kapnet theory meets practice.


Write a comment
No comments yet.