-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State metadata serialization for the stardust DID method #947
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code can be simplified but I agree with the overall approach and reasoning (i.e. why string replacement won't work with alternative serializations).
Can we avoid DIDOrPlaceholder
somehow or is it necessary for performance?
There are also a few other missing pieces:
- We still need something similar to
DIDMessage
with a version flag, and maybe a format flag and magic bytes "DID" prefix. - The
controllers
and all other fields likeid
that (should be) inferred from theAliasOutput
should be removed from the serialization. Maybe. We might need to keep theid
field if that's difficult to remove and to keep thenetwork
information.
Otherwise looking good, let's keep iterating.
Thanks for the simplifications! Not sure how I ended up making it so unnecessarily complicated. How would it be possible to remove the Agreed, we have to keep the network information in the serialization. Since it's unclear what serialization format we'll end up using, I'd leave this for the PR that eventually closes 942. Implementing removal of |
The controller will be the state controller of the Edit: where the controller is another |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of change
Adds a
StateMetadataDocument
that represents the serialized DID document in an alias output for the stardust DID method.The
AliasId
, which corresponds to the DID, is not computable before the alias output itself has been created. So a placeholder is required in absence of the DID. In order to avoid having to publish twice when creating the alias output, so that the DID document contained in the alias output has the correct DID set, the approach is to always use the placeholder. During resolution a transformation step that takes the block or alias output, and the contained DID document as inputs, produces the actualStardustDocument
that contains the correct DID. This means that our solution to this issue is consistent no matter if the alias output existed or is newly created.Since we'd like to enable smart contracts to build on top of the DID document in the alias output, we might not be able to use an expensive serialization format or even compression. Thus the shortest valid
CoreDID
is chosen as the placeholder, which isdid:0:0
. All references to the DID of the document itself are replaced by this DID. When using JSON, a simple string replace suffices to replace this string with the actual DID during the transformation. However, it's likely that we will not end up using JSON, due to determinism considerations and perhaps because other serialization formats offer tighter packing, so the lack of compression doesn't weigh in as much. This PR introduces a dedicatedStateMetadataDocument
that handles conversion to and fromStardustDocument
.StateMetadataDocument
can eventually be used to implement the serialization format of choice. The trade-off is that the conversion requires quite a few lines of code.In general, always using a small placeholder DID has significant effects on the size of the document. For example, a
StateMetadataDocument
with 10 verification methods is about half the size of the correspondingStardustDocument
, when converted to a vector of uncompressed json bytes. That in turn saves byte costs.Links to any relevant issues
part of #942 and #908.
Type of change
Add an
x
to the boxes that are relevant to your changes.How the change has been tested
A transformation roundtrip (
StateMetadataDocument
<->StardustDocument
) test was added.Change checklist
Add an
x
to the boxes that are relevant to your changes.