did-btcr2-js

ADR 135: An Update Is Refused If the Source Resolution Misses an Update of the Sidecar Data

Context

updateDid and deactivateDid take a DID or a resolved state as the source (ADR 123). For a DID, the api resolves the DID first. It takes the source document and its versionId from that resolution. The new update gets the targetVersionId versionId + 1.

The resolution applies a beacon signal only after minConf confirmations, default 6 (ADR 105). A controller can make a second update before the signal of the first update has 6 confirmations. The resolution then returns the version before the first update. The api makes a second update with the same targetVersionId as the first update.

Both signals go into blocks. The resolver applies the first update. It then compares the second update with the applied update of the same version. The hashes are different, so the resolution stops with LATE_PUBLISHING. No later update can repair the DID.

Specification position

Spec PR 377 added a rule to the update operation. A DID controller MUST NOT announce a BTCR2 Signed Update if it cannot resolve all previous updates of the DID. It cannot resolve them if a fresh resolution returns a versionId less than the highest targetVersionId that the controller announced. The remedy is a new resolution after the beacon signal of the last update has minConf confirmations. A lower minConf decreases the time to wait, but increases the risk from block reorganizations.

The specification does not say where the controller keeps the updates that it announced.

Decision

The api compares the resolved version with the sidecar updates

For a DID source, the api reads resolutionOptions.sidecar.updates after the resolution. It keeps the updates whose proof.invocationTarget is the DID. It takes the highest targetVersionId of these updates. If the resolved versionId is less, the api refuses the update before it signs.

The check is in the source helper that updateDid and deactivateDid share. Both operations apply it.

The sidecar data is the only data source

The api keeps no other list of the updates that a controller announced. The sidecar updates are the updates that the caller gives to the resolution. If an update is not in a CAS, the caller must give it to each later resolution. Thus the sidecar data holds it.

The cli records each update that it makes in the identifier record (ADR 133). The sidecar data of the record joins the resolution options of the next update or deactivate. Thus the cli gets the check for each update that it made, with no new cli code.

Without sidecar updates, the api does no check

If the resolution options hold no sidecar update of the DID, the api cannot see the announced updates. It does no check. The api documentation states this limit.

The error gives the remedy and the escape

The error is an UpdateError with the type INVALID_DID_UPDATE. The data is { did, versionId, announcedVersionId, minConf }. minConf is the value of the resolution options, else DEFAULT_MIN_CONF. The message gives the remedy of the specification: resolve again after the beacon signal of the last update has minConf confirmations, or set a lower minConf.

A state source { document, versionId } skips the check. This is the escape for a caller whose sidecar data holds an update that no beacon signal announced. Example: the signal transaction of the last update left the mempool, and the caller makes a new update for the same version.

The cli shows the api message with no change. The cli documentation gives the cli form of the remedy (--min-conf) and of the escape (--source-document with --source-version-id).

The check meets the api guard criterion

The api refuses a write only if two conditions are true:

  1. The failure is permanent for the DID.
  2. The api already holds the data to find the failure.

A second update with the same targetVersionId is permanent (LATE_PUBLISHING). The api itself makes the targetVersionId, from a view that hides the last signal of the controller. The sidecar data is already an input of the resolution. ADR 102 (funding guard) and ADR 134 (fee guard) apply the same criterion.

Alternatives

Consequences

Positive.

Negative.

Neutral.

Implementation

References