feat(attribution): carry a miner's name across chains by reward preimage
deploy / build (push) Successful in 7m6s
deploy / deploy-web (push) Successful in 5s
deploy / deploy-api (push) Successful in 14s

Live telemetry names the miners who win often and leaves everyone else as a
hex string. Measured on mainnet: of 22 miners, 2 were named and 14 had no name
available anywhere — but 6 already had one on Planck, under the same reward
preimage. Those 6 are exactly the small operators the naming is worst for,
because a name needs a block whose first reporter the feed could separate and
they win few blocks.

The preimage is derived from a secret only its owner holds, so the same
preimage on two chains is the same operator. That is an inference the site can
stand behind, unlike guessing from timing — and it is the only lever that works
without waiting on the feed at all.

It is a separate `AttributionSource` and renders as one. `Carried` names carry
no confidence and no votes, because they assert nothing about this chain: only
that this is who the operator was last known to be. Any live attribution here
outranks one, and the row shows an `elsewhere` chip rather than the telemetry
`node` chip so the two can never be read as the same claim.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jp6a8EDar9ueEhAxzep4V5
This commit is contained in:
2026-09-09 14:59:29 +03:00
co-authored by Claude Opus 5
parent a177e805f4
commit ffcfb79cab
8 changed files with 188 additions and 9 deletions
+73 -5
View File
@@ -117,6 +117,9 @@ struct AuthorVotes {
/// Rolling per-author attribution state.
#[derive(Debug, Default)]
pub struct Attributor {
/// Names this operator earned on another chain, keyed by reward preimage.
/// Consulted only when no live attribution has been held on this one.
carried: HashMap<MinerId, String>,
authors: HashMap<MinerId, AuthorVotes>,
}
@@ -151,6 +154,18 @@ impl Attributor {
entry.votes.push_back(vote);
}
/// Record a name this operator earned on another chain.
///
/// Seeded at startup from the same reward preimage on a chain we no longer
/// hold an endpoint for. It is a floor, not a claim: the moment live
/// telemetry names this miner here, that wins.
pub fn carry(&mut self, miner: MinerId, name: String) {
if name.is_empty() {
return;
}
self.carried.insert(miner, name);
}
/// Seed a held name from persisted state, so a restart does not strip every
/// author of its name for a few blocks.
///
@@ -196,11 +211,22 @@ impl Attributor {
where
F: Fn(&NodeKey) -> Option<String>,
{
let fallback = Attribution {
display: miner.abbreviated(),
source: AttributionSource::Preimage,
confidence: 0.0,
votes: 0,
// A name carried from another chain stands in until this chain's feed
// names the miner itself — better than an abbreviated preimage, and
// labelled so nobody reads it as a live observation.
let fallback = match self.carried.get(miner) {
Some(name) => Attribution {
display: name.clone(),
source: AttributionSource::Carried,
confidence: 0.0,
votes: 0,
},
None => Attribution {
display: miner.abbreviated(),
source: AttributionSource::Preimage,
confidence: 0.0,
votes: 0,
},
};
let Some(entry) = self.authors.get_mut(miner) else {
return fallback;
@@ -289,6 +315,48 @@ impl NodeKey {
#[cfg(test)]
mod tests {
/// A carried name stands in until this chain's own feed resolves the miner.
#[test]
fn a_carried_name_fills_in_for_an_unresolved_miner() {
let mut a = Attributor::new();
let m = MinerId("0x11".into());
a.carry(m.clone(), "aria-dev".into());
// No votes at all on this chain yet.
let got = a.attribute(&m, |_| None);
assert_eq!(got.source, AttributionSource::Carried);
assert_eq!(got.display, "aria-dev");
// Carried names assert nothing about current agreement.
assert_eq!(got.confidence, 0.0);
assert_eq!(got.votes, 0);
}
/// And yields the moment this chain has something better.
#[test]
fn a_live_attribution_outranks_a_carried_name() {
let mut a = Attributor::new();
let m = MinerId("0x22".into());
a.carry(m.clone(), "old-testnet-name".into());
for _ in 0..4 {
a.observe(&m, Some((NodeKey::Peer("QmLive".into()), Some(80))));
}
let got = a.attribute(&m, |_| Some("live-name".into()));
assert_eq!(got.source, AttributionSource::Telemetry);
assert_eq!(got.display, "live-name");
}
/// A miner with no name anywhere is still its preimage.
#[test]
fn carrying_nothing_leaves_the_preimage() {
let mut a = Attributor::new();
let m = MinerId("0x33".into());
a.carry(m.clone(), String::new()); // empty names are not names
assert_eq!(
a.attribute(&m, |_| None).source,
AttributionSource::Preimage
);
}
/// A name, once earned, must not evaporate because the feed went quiet.
///
/// Reported from the live site: names appeared and were "often forgotten if