feat: let callers set an explicit versionTime on create/update - #48
Merged
Conversation
create_did and update_did hardcoded the new log entry's versionTime to now(). versionTime serializes at second granularity and must be strictly increasing and not in the future, so a caller creating multiple entries in quick succession (e.g. a VTA doing create-then-update back-to-back) produces same-second entries that serialize identically and make the DID unresolvable. Expose an optional version_time on CreateDIDConfig and UpdateDIDConfig (default None preserves the now() behavior exactly). Callers that batch updates can now backdate and space the entries — e.g. now-1h, now-1h+1min — keeping the log strictly increasing and in the past. The low-level create_log_entry already accepted this; the high-level builders just hadn't surfaced it. Honored on the single-entry operations (genesis create, standard update, migrate); the multi-entry deactivation path keeps per-entry now() stamping since one caller-supplied value can't keep its two entries distinct. Test: a genesis backdated to now-1h plus an update at now-1h+1min validates end-to-end (report.truncated.is_none()) — the sequence that fails with same-second defaults. Signed-off-by: Glenn Gore <glenn@affinidi.com>
Bumps the crate to 0.5.6 (publishable for the caller-settable versionTime feature) and updates Cargo.lock to the latest compatible dependency versions. All direct-dependency latest releases are within the existing version requirements; no manifest req changes were needed. Signed-off-by: Glenn Gore <glenn@affinidi.com>
stormer78
added a commit
to OpenVTC/verifiable-trust-infrastructure
that referenced
this pull request
Jun 28, 2026
The VTA creates its did:webvh at setup and updates it moments later (e.g.
'services didcomm enable'). versionTime serialises at second granularity and must
be strictly increasing and not in the future, so two entries minted in the same
second serialise identically and make the DID unresolvable — surfacing as a
resolution failure ("versionTime must be greater than previous") only once a
client fetches did.jsonl.
Set an explicit versionTime on the genesis-create and standard-update log
entries: backdated a day and spaced a minute apart by entry index
(backdated_version_time). The wall-clock value is irrelevant to did:webvh; this
keeps the log strictly increasing and in the past regardless of how fast the
entries are minted. Requires didwebvh-rs 0.5.6, which exposes version_time on
CreateDIDConfig/UpdateDIDConfig (decentralized-identity/didwebvh-rs#48).
Validated end-to-end: a fresh VTA set up and didcomm-enabled back-to-back with no
delay now resolves and completes a containerised did:peer agent round-trip.
Signed-off-by: Glenn Gore <glenn@affinidi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
version_timetoCreateDIDConfigandUpdateDIDConfigso callers can set an explicitversionTimeon the log entries they create. DefaultNonepreserves today's behavior exactly (the lib stampsnow()).Why
versionTimeserializes at second granularity (SecondsFormat::Secs) andverify_version_timerequires each entry to be strictly greater than the previous and not in the future.create_did/update_didhardcodedcreate_log_entry(None, …)→now(), so a caller creating multiple entries in quick succession (e.g. a service that does create-then-update back-to-back) gets two same-second entries that serialize identically and make the DID unresolvable ("versionTime must be greater than previous").Notably this passes every in-memory test (the monotonic check runs on the full-precision parsed
DateTime) but fails once the log is serialized + re-resolved — which is exactly how it bites in practice.Rather than have the lib invent timestamps (bumping to
prev+1strips the not-in-the-future check; widening serialization precision would change the canonical/hashed form and break existing dids), the clean fix is to let the caller decide: a batch of updates can backdate + space the entries (e.g.now−1h,now−1h+1min) so the log stays strictly increasing and in the past. The low-levelDIDWebVHState::create_log_entryalready tookOption<DateTime<FixedOffset>>; this just surfaces it on the high-level builders.Scope
version_timeis honored on the single-entry operations: genesiscreate_did, the standardupdate_did, and the migrate path.now()stamping (unchanged).Test
create_then_update_with_spaced_version_times_validates— a genesis backdated tonow−1hplus an update atnow−1h+1minvalidates end-to-end (report.truncated.is_none()), the sequence that fails with same-second defaults. All existing tests unchanged and green.