Repository navigation
Tags
Tags
Add CPS subtree authorization with bounded cache (#23) * feat(edge): add CPS subtree authorization with bounded cache (fix #22) Add `[auth] mode = "cps"`: a verified sensor is authorized when its CPS node is a strict descendant of the configured sensors.social root. - make `AuthPolicy::authorize` async and fallible (`AuthError`) - add `auth/cps.rs` with a mockable `CpsReader`, bounded in-memory LRU (allow: no TTL, deny: configurable TTL, errors never cached), query timeout, genesis-hash and root verification - add shared lazy `ChainRegistry` so CPS auth and anchoring use a single embedded light client - pipeline drops messages on lookup errors and counts them separately - add cps_* config, validation, CLI hints, metrics, docs and tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(edge): bound CPS authorization and share one supervised chain connection - add a bounded asynchronous authorization stage to the pipeline: cache hits are answered at once via `AuthPolicy::try_authorize`, misses are parked and looked up by at most `cps_max_concurrent_lookups` (8) tasks with at most `cps_max_pending` (256) waiting messages, concurrent misses for a sensor share one lookup, overflow is dropped and counted - make `ChainRegistry` own connection init, light-client sync, retry and reconnect through one supervisor task per endpoint; a timed-out caller never cancels or restarts it, auth fails closed without waiting (`try_get`) - move the shared RPC endpoint to `[blockchain] endpoint` (optional; omitted means one embedded light client for auth and anchoring) and drop `auth.cps_endpoint` - anchor re-resolves the connection per submission to pick up reconnects - add regression tests and an ignored live-node libcps integration test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(edge): apply backpressure on CPS auth overload and gate on light-client sync - Pause the pipeline instead of dropping verified envelopes when the authorization stage is full; saturation reaches ingress as a full channel (HTTP 429, retryable). Replace edge_auth_pending_dropped_total with edge_auth_backpressure_total. - Report an embedded light client that fell back from Ready to Syncing as unavailable in ChainRegistry::try_get, so uncached CPS lookups fail closed while cached allows keep working. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>