You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`GetSigner`'s default resolution path is a **fallback deserializer**: a linear scan across every `KeyManager` registered under the identity's type, each probed with a cryptographic sign+verify to find the one that actually matches. `SignerRouter` (`token/services/identity/signer_router.go`) is an optional fast path that skips this scan-and-probe entirely: it resolves the `conf_id` an identity was bound under (via a `ConfIDResolver`) and dispatches straight to the single `KeyManager` registered for that `conf_id`.
147
+
148
+
***Wiring**: a driver builds a `SignerRouter` with `identity.NewSignerRouter(m *Metrics)`, registers `KeyManager`s against their `conf_id` with `Register`, sets a `ConfIDResolver` with `SetConfIDResolver`, and attaches it to the `Provider` with `Provider.SetSignerRouter`. See `token/core/fabtoken/v1/driver/ws.go` and the zkatdlog equivalent.
149
+
***Fallback semantics**: `Resolve` returns `ok=false` (never an error) whenever routing cannot be attempted (no resolver set, no `conf_id` mapping, no `KeyManager` registered for it) or the routed `KeyManager` itself fails — callers always fall back to the probing deserializer in that case, never treating it as a hard failure.
150
+
***Probe-free deserialization**: when the registered `KeyManager` also implements `idriver.ProbeFreeSignerDeserializer`, `Resolve` calls `DeserializeSignerNoProbe` directly, skipping the cryptographic probe that the fallback path relies on to catch a mismatched `KeyManager`. This is only safe because the `conf_id` already pins the identity to exactly one `KeyManager`.
151
+
152
+
#### Metrics
153
+
154
+
`identity.Metrics` (`token/services/identity/metrics.go`) instruments both `Provider.GetSigner` and `SignerRouter`, sharing one `Metrics` instance built with `identity.NewMetrics(provider)` (a `nil` provider yields a `disabled.Provider`-backed noop):
155
+
156
+
| Metric | Type | Labels | Purpose |
157
+
|:-------|:-----|:-------|:--------|
158
+
|`identity_signer_resolutions_total`| Counter |`network`, `channel`, `namespace`, `outcome` = `cache`\|`routed`\|`fallback`| How each `GetSigner` call was ultimately resolved. |
159
+
|`identity_get_signer_duration_seconds`| Histogram |`network`, `channel`, `namespace`, `path` = `cache`\|`routed`\|`fallback`|`GetSigner` wall-clock time by resolution path; compares the latency saved by skipping the probe. |
160
+
|`identity_signer_router_registrations_total`| Counter |`network`, `channel`, `namespace`|`conf_id`→`KeyManager` bindings registered with the `SignerRouter`. A near-zero count in production means routing is never populated and every call falls back. |
161
+
|`identity_signer_router_no_probe_errors_total`| Counter |`network`, `channel`, `namespace`| Failures of the probe-free deserialization path — since that path skips the cryptographic check, a non-zero count is worth investigating as a `conf_id` routing bug. |
162
+
163
+
> **Note:**`provider` here is a `NewTMSProvider`-wrapped `Provider` (see [Driver Metrics](../drivers/metrics.md#pitfall-labelnames-must-include-network-channel-namespace)), which binds `network`/`channel`/`namespace` on every metric via `.With(...)` before returning it. Every `CounterOpts`/`HistogramOpts` above must therefore declare those three as `LabelNames` in addition to its own label(s), or the metric panics with "inconsistent label cardinality" on first use. This is exactly the bug that crashed the DVP/DLog integration suite in `SignerRouter.Register` before it was fixed.
164
+
144
165
## Identity Types
145
166
146
167
The Identity Service leverages a wrapper called **TypedIdentity** to support various identity schemes uniformly.
Copy file name to clipboardExpand all lines: docs/services/storage.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,16 +28,15 @@ The [`ttxdb/auditdb`](./storage/ttxdb.md) manages the token request lifecycle an
28
28
The following tables track the lifecycle of token requests from assembly to finality.
29
29
`AuditDB` uses the same schema but is isolated for compliance reporting.
30
30
31
-
***Requests**: Tracks high-level token request state. Contains marshaled requests, current status (Pending, Confirmed, Deleted, Orphan), and application/public metadata.
31
+
***Requests**: Tracks high-level token request state. Contains marshaled requests, current status (Pending, Confirmed, Deleted, Orphan), application/public metadata, and the `recovery_claimed_by`/`recovery_claim_expires_at` lease columns used by the Transaction Recovery Service to atomically claim batches of pending transactions.
32
32
***Transactions**: Records individual actions (Issue, Transfer, Redeem) within a request, including sender/recipient IDs and amounts (stored as `NUMERIC(78, 0)`).
33
33
***Movements**: Aggregates net value changes per enrollment ID (amounts stored as `NUMERIC(78, 0)`). Used to efficiently calculate balances and history.
34
34
***Endorsements**: Collects digital signatures from participants and auditors required for transaction finality.
35
35
36
36
### Endorser Store (EndorserDB)
37
-
The [`endorserdb`](./storage/endorserdb.md) manages validation records created during the token request endorsement process. It shares the physical database with TTXDB but provides a separate interface for validation-specific operations.
37
+
The [`endorserdb`](./storage/endorserdb.md) manages validation records created during the token request endorsement process. It shares the physical database with TTXDB but owns its own, self-contained table — it does not write to the Requests table.
38
38
39
-
***Validations**: Stores cryptographic validation metadata produced during the request verification phase. The Validations table is self-contained and stores the token request data directly (along with pp_hash) for efficient retrieval. When a validation record is created (typically by endorser nodes), it atomically creates entries in both the Requests table (for foreign key integrity and status tracking) and the Validations table (with embedded token request for direct access), ensuring that non-owner nodes can properly track and recover transactions.
40
-
***Requests** (shared): The endorserdb uses the Requests table to track validation status. While the table is shared with TTXDB, the endorserdb interface provides methods specifically for managing validation-related status updates.
39
+
***Validations**: Stores cryptographic validation metadata produced during the request verification phase. The table is self-contained: it stores the token request data, metadata, and pp_hash directly (along with its own `status`/`status_message` columns), so a validation record can be created and its status tracked without any foreign key into the Requests table. This lets non-owner (endorser) nodes track and recover transactions independently of the TTXDB/AuditDB Requests row for the same `tx_id`.
41
40
42
41
### Token Store (TokenDB)
43
42
This store serves as the authoritative registry for all tokens (UTXOs) known to the node.
@@ -166,10 +165,9 @@ The `ttxdb` serves as the central repository for the lifecycle of token requests
166
165
167
166
### Endorser Store (EndorserDB)
168
167
The `endorserdb` manages validation records for token requests during the endorsement process. It is used by the **Endorsement Service** to:
169
-
* **Validations**: Store validation metadata and token requests validated by endorser nodes.
170
-
* **Requests** (shared): Track the status of validated token requests.
168
+
* **Validations**: Store validation metadata, token requests, and their own status validated by endorser nodes, in a single self-contained table.
171
169
172
-
The endorserdb shares the same physical database as ttxdb but provides a separate, focused interface for validation-specific operations, improving modularity and separation of concerns.
170
+
The endorserdb shares the same physical database as ttxdb but owns its own table and interface for validation-specific operations, improving modularity and separation of concerns.
173
171
174
172
### Token Store (TokenDB)
175
173
The `tokendb` is the registry for the current state of all tokens (UTXOs) known to the node. It is used by the **Selector Service** and **Vault Service** to:
There is no foreign key to the Requests table — a validation record can be created and have its status tracked entirely independently of any TTXDB/AuditDB Requests row for the same `tx_id`.
139
133
140
134
## Relationship with TTXDB
141
135
142
-
The endorserdb was created by extracting validation-related functionality from the Token Transaction Database (ttxdb). While both services share the same physical database and some tables (like REQUESTS), they provide separate interfaces:
136
+
The endorserdb was created by extracting validation-related functionality from the Token Transaction Database (ttxdb). Both services share the same physical database, but each owns its own table (ttxdb owns Requests/Transactions/Movements/Endorsements, endorserdb owns Validations) and interface:
143
137
144
138
-**ttxdb**: Manages token transactions, movements, and token requests
145
139
-**endorserdb**: Manages validation records and their status
0 commit comments