diff options
| -rw-r--r-- | docs/dashboard.md | 5 | ||||
| -rw-r--r-- | docs/guides/federation/proposing-and-voting.md | 14 | ||||
| -rw-r--r-- | docs/openapi.yaml | 10 | ||||
| -rw-r--r-- | src/api/dashboard/check.js | 9 | ||||
| -rw-r--r-- | src/api/dashboard/dashboard.html | 7 | ||||
| -rw-r--r-- | src/api/events.rs | 9 | ||||
| -rw-r--r-- | src/federation/attacks.rs | 4 | ||||
| -rw-r--r-- | src/federation/fold.rs | 6 | ||||
| -rw-r--r-- | src/federation/party.rs | 3 |
9 files changed, 52 insertions, 15 deletions
diff --git a/docs/dashboard.md b/docs/dashboard.md index a5676ce..f68fb06 100644 --- a/docs/dashboard.md +++ b/docs/dashboard.md @@ -411,8 +411,9 @@ federation again; the page keeps the choice. While shown, it is read every 5 s: whose path holds what is typed in it; * **proposals on version …**: each proposal on the current version, by its hash: whether it passed, is dead, or can still pass; the parties voting `true` and `false`; - how many events propose it and how many votes are on it; and what its version changes - of the current one, a line each, as `continuum-party proposals` says it; + how many events propose it and how many votes are on it; why no party's client backs + it, where none does (no version as this node reads it, say); and what its version + changes of the current one, a line each, as `continuum-party proposals` says it; * **refused**: what this node refused by what it took before (keys voted twice: tell its party), what it dropped as its operator says, and what it refused as every node does, each with its kind and why. diff --git a/docs/guides/federation/proposing-and-voting.md b/docs/guides/federation/proposing-and-voting.md index 12f8dfd..0f303ea 100644 --- a/docs/guides/federation/proposing-and-voting.md +++ b/docs/guides/federation/proposing-and-voting.md @@ -136,17 +136,19 @@ kills it the sooner, and frees its backers for another. `GET /events/counts` names each proposal on the current version with the events proposing it (`proposals`) and the votes on it (`votes`), each by its ID; the parties -voting `true` (`yes`) and `false` (`no`); and whether it passed (`passed`) and whether -it is dead (`dead`), as the node reads its votes: +voting `true` (`yes`) and `false` (`no`); whether it passed (`passed`) and whether it is +dead (`dead`), as the node reads its votes; and why no party's client backs it (`none`), +where it is no version this node reads, none changing the current one, or one naming the +heads of the current one's checkpoint, else `null`: ```sh curl -s -u tv:secret localhost:3000/events/counts | jq .proposals -# {"8d02…":{"dead":true,"no":["lass"],"passed":false,"proposals":["c41e…"], -# "votes":["5a77…","e019…"],"yes":["tv"]}} +# {"8d02…":{"dead":true,"no":["lass"],"none":null,"passed":false, +# "proposals":["c41e…"],"votes":["5a77…","e019…"],"yes":["tv"]}} ``` -The client shows the same, and what each proposal's version changes of the current one, -field by field and party by party: +The client shows the same, why it backs one not, by the federation it knows, and what +each proposal's version changes of the current one, field by field and party by party: ```sh continuum-party --node http://tv:secret@localhost:3000 proposals diff --git a/docs/openapi.yaml b/docs/openapi.yaml index e1e602a..57ef132 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1533,7 +1533,11 @@ paths: (`proposals`) and of the votes on it (`votes`), the parties voting `true` (`yes`) and `false` (`no`), whether it passed (`passed`: two thirds of the parties voted `true`) and whether it is dead (`dead`: so many voted `false` that the rest can't - pass it). A passed proposal is written at once, and lapses with the rest. + pass it), and why a party's client backs it not (`none`), where it is no version, + none changing the current one, or one naming the heads of the current one's + checkpoint, as this node reads it: one that passed all the same is never written, + or, no version here, this node stops at its version event. A passed proposal is + written at once, and lapses with the rest. responses: '200': description: What counts. @@ -1559,7 +1563,7 @@ paths: type: object additionalProperties: type: object - required: [proposals, votes, yes, no, passed, dead] + required: [proposals, votes, yes, no, passed, dead, none] properties: proposals: type: array @@ -1581,6 +1585,8 @@ paths: type: boolean dead: type: boolean + none: + type: [string, 'null'] '404': $ref: '#/components/responses/Error' /events/refused: diff --git a/src/api/dashboard/check.js b/src/api/dashboard/check.js index 125fc3b..ee37aa6 100644 --- a/src/api/dashboard/check.js +++ b/src/api/dashboard/check.js @@ -103,7 +103,9 @@ const check = (ok, what) => { values: { "home/tv/motd": "hello", "home/tv/hosts/laptop": { ip6: "42::1" } }, members: [["continuum:a", "tv"]], proposals: { "22": { proposals: ["cc"], votes: ["dd"], yes: ["tv"], no: [], - passed: false, dead: false } } }; + passed: false, dead: false, none: null }, + "33": { proposals: ["ee"], votes: [], yes: [], no: [], passed: false, dead: false, + none: "no version: of federation 2, and this continuum knows 1 alone" } } }; federation.refused = { own: [], dropped: [], refused: [] }; federation.versions.set("22", next); showFederation(); @@ -128,7 +130,10 @@ const check = (ok, what) => { && federated.text.includes('keys.lass: {"keys":["ssh-ed25519 AAAA2"],"since":0} -> ' + '{"keys":["ssh-ed25519 AAAA3"],"since":1}'), "a proposal: where it stands, and what its version changes, party by party"); - check(federated.votes === 2, "a proposal that can still pass has a vote of each kind"); + check(federated.votes === 4, "a proposal that can still pass has a vote of each kind"); + check(federated.text.includes("Backed by no client: no version: of federation 2") + && (federated.text.match(/Backed by no client/g) || []).length === 1, + "a proposal that is no version says why no client backs it"); check(!federated.text.includes("stopped at") && federated.stopped.includes("stopped at ee") && federated.stopped.includes("4 held back"), "a store that stopped: the event it stopped at, why, and how many it holds back"); diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html index f5d258b..99434e0 100644 --- a/src/api/dashboard/dashboard.html +++ b/src/api/dashboard/dashboard.html @@ -4251,8 +4251,8 @@ function connect() { // `/events/refused`; docs/guides/federation/) instead of the document, until `document` // says otherwise: the current version, the event the store stopped at, if any, the // parties, the rules, the values at places (each with who writes there), the proposals on -// the version (where each stands, who voted what, and what its version changes) and what -// the node refused. A vote goes through +// the version (where each stands, who voted what, why no client backs it, where none +// does, and what its version changes) and what the node refused. A vote goes through // this node (`POST /admin/events/vote`), which casts it only where it votes for its party // by itself (`votesByItself`). Read every 5 s while shown, what counts anew where the // store's heads changed. Writing values takes a key of the party, which the page has @@ -4509,6 +4509,9 @@ function federationProposals(counts, summary) { const parts = [federationLeaf("proposed by " + count(proposal.proposals.length, "event") + " · " + count(proposal.votes.length, "vote"), null, [...proposal.proposals, ...proposal.votes].join("\n"))]; + if (proposal.none) { + parts.push(el("div", { class: "note error" }, "Backed by no client: " + proposal.none)); + } const proposed = federation.versions.get(hash); if (proposed === undefined) { parts.push(el("div", { class: "note" }, "Its version isn't read yet.")); diff --git a/src/api/events.rs b/src/api/events.rs index bd6db70..496a077 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -17,6 +17,7 @@ use serde_json::{Value as JsonValue, json}; use super::auth::AuthenticatedUser; use super::{ApiError, error_response, store_status}; +use crate::federation::client; use crate::federation::fold::Federation; use crate::federation::fork; use crate::federation::jcs::Json as Jcs; @@ -124,7 +125,9 @@ async fn event(State(state): State<AppState>, Path(id): Path<String>) -> Respons /// `GET /events/counts`: what counts, as the store reads now: the current version, each /// party's keys and nodes, the values at places, the members, and the proposals on the /// current version, each with the events proposing it, the votes on it, the parties -/// voting `true` and `false`, and whether it passed and whether it is dead. +/// voting `true` and `false`, whether it passed and whether it is dead, and why a party's +/// client backs it not, where it is no version that can be written on the current one +/// (`client::backable`). async fn counts(State(state): State<AppState>) -> Response { with_store(&state, |store| { let read = store.state(); @@ -152,6 +155,9 @@ async fn counts(State(state): State<AppState>) -> Response { .into_iter() .map(|(hash, ballot)| { let tally = read.tally(current, &hash); + let none = read + .proposal(&hash) + .and_then(|proposed| client::backable(current, proposed).err()); ( hash.to_string(), json!({ @@ -161,6 +167,7 @@ async fn counts(State(state): State<AppState>) -> Response { "no": tally.no, "passed": tally.passed, "dead": tally.dead, + "none": none, }), ) }) diff --git a/src/federation/attacks.rs b/src/federation/attacks.rs index 8782528..3f44ad0 100644 --- a/src/federation/attacks.rs +++ b/src/federation/attacks.rs @@ -928,6 +928,10 @@ fn federation_attack_48() { let mut bad = fed.first.after(on); bad.rules.push(("_continuum/x".to_owned(), s("tv"))); let proposal = fed.take(tv.propose(&[root], &bad.json())); + // A node shows why a client backs it not (`none` in `GET /events/counts`). + let state = fed.store.state(); + let why = super::client::backable(state.current(), state.proposal(&bad.hash()).unwrap()); + assert!(why.unwrap_err().contains("_continuum/x")); let yes = fed.take(tv.vote(&[proposal], on, bad.hash(), true)); let also = fed.take(lass.vote(&[proposal], on, bad.hash(), true)); fed.stops(harness::version_event(&[yes, also], bad.hash())); diff --git a/src/federation/fold.rs b/src/federation/fold.rs index fddedc0..3ebeebf 100644 --- a/src/federation/fold.rs +++ b/src/federation/fold.rs @@ -341,6 +341,12 @@ impl State { ballots } + /// The version the proposal of hash `proposal` proposes, as JSON, where it holds one: + /// whether it is a version is asked apart (`Version::read`). + pub(crate) fn proposal(&self, proposal: &Id) -> Option<&Json> { + self.proposed.get(proposal) + } + /// The version event writing the proposal of hash `proposal` on the current version, /// where it passed here: on the `true` votes of the first parties by name that pass it, /// each party's of the lowest ID, so that nodes holding those votes write the same. diff --git a/src/federation/party.rs b/src/federation/party.rs index 60b7e18..04837c3 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -807,6 +807,9 @@ async fn proposals(node: &Node) -> Result<()> { does: Does::Proposal { hash: of, version }, .. })) if of.to_string() == *hash => { + if let Err(why) = client::backable(¤t, &version) { + println!(" backed by no client: {why}"); + } for line in client::changes(¤t.json, &version) { println!(" {line}"); } |
