diff options
| author | tv <tv@krebsco.de> | 2026-11-25 15:27:53 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-25 15:27:53 +0000 |
| commit | e22f2e5c38baa1866793338fc7abde8c8e53b635 (patch) | |
| tree | f6e7225e05bc35467b638416fa8487d538d02fed /src/federation/party.rs | |
| parent | 46fc2ab070b5f8d3cd6c8bd0d6bd15c624a061e5 (diff) | |
continuum-party vote: asks its node first whether a true is taken
A party's client recorded its vote, sent it, and only warned where its
node refused it: a true every node refuses, its party's earlier one not
dead where it builds, stayed in the record and bound the party, though no
node held it. Taking it back out on the node's word would let a node that
lies have its party vote twice.
So it asks before it signs: POST /events/back names the party, the
proposal and the events the vote would build on, and a node answers by
what it asks itself before it casts one (vote::takes_true). Nothing
signed is sent, so a node gets nothing it could pass on. Told it isn't
taken, the client casts and records nothing; a node that doesn't answer,
one before this, it says so of, and goes on as it did.
Diffstat (limited to 'src/federation/party.rs')
| -rw-r--r-- | src/federation/party.rs | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/src/federation/party.rs b/src/federation/party.rs index ff66de3..c8f19ea 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -1586,16 +1586,35 @@ async fn vote( .ok() .and_then(|version| version.checkpoint) .is_some(); - if checkpoint && yes && !kept.is_empty() { - eprintln!( - "Warning: this `true` builds on {proposing} alone, not on the nays that freed \ - {party}: where they came after the heads it names, and {party}'s `true` they \ - ended is in the history of {proposing}, nodes refuse it; a checkpoint proposed \ - after them takes {party}'s `true`", - party = signer.party - ); - } let on = client::building(proposing, checkpoint, &kept).map_err(|why| anyhow!(why))?; + // Asked first, with nothing signed: a `true` every node refuses is neither cast nor + // recorded, where it would bind the party by a vote no node holds. + if yes { + match node.takes_true(&signer.party, &proposal, &on).await { + Ok(None) => {} + Ok(Some(why)) => bail!( + "nothing cast: {why}. {party}'s earlier `true` on this version is on a \ + proposal that isn't dead where this vote would build; of a checkpoint, the \ + nays that ended it came after its heads were named: back the next one", + party = signer.party + ), + Err(error) => { + eprintln!( + "Warning: the node didn't say whether it takes this `true` ({error:#}); \ + one before 0.1.0 doesn't" + ); + if checkpoint && !kept.is_empty() { + eprintln!( + "Warning: this `true` builds on {proposing} alone, not on the nays \ + that freed {party}: where they came after the heads it names, and \ + {party}'s `true` they ended is in the history of {proposing}, nodes \ + refuse it; a checkpoint proposed after them takes {party}'s `true`", + party = signer.party + ); + } + } + } + } let word = if yes { "`true`" } else { "`false`" }; if ask && !confirmed(&format!( @@ -2603,6 +2622,33 @@ impl Node { } /// What the node answers to the bytes `body`. + /// Whether the node takes a `true` of `party` on `proposal` built on `on` (`POST + /// /events/back`): why not, where it doesn't. Nothing signed is sent. + async fn takes_true(&self, party: &str, proposal: &Id, on: &[Id]) -> Result<Option<String>> { + let asked = serde_json::json!({ + "party": party, + "proposal": proposal.to_string(), + "on": on.iter().map(Id::to_string).collect::<Vec<_>>(), + }); + let response = self + .request(reqwest::Method::POST, "/events/back")? + .header(reqwest::header::CONTENT_TYPE, "application/json") + .body(asked.to_string()) + .send() + .await?; + let answer: JsonValue = self.answer(response).await?.json().await?; + match answer["takes"].as_bool() { + Some(true) => Ok(None), + Some(false) => Ok(Some( + answer["why"] + .as_str() + .unwrap_or("no store takes it") + .to_owned(), + )), + None => bail!("no answer of its"), + } + } + async fn post_bytes(&self, path: &str, body: Vec<u8>) -> Result<JsonValue> { let response = self .request(reqwest::Method::POST, path)? |
