Closed Patrik-Stas closed 1 year ago
Nice, thanks for this Patrik. Perhaps the only nuance (at least that I know of) of source_id
is that in Connections, the source_id
is used as the label
that is sent to the peer you're connecting with. So if it's removed, something else will need to take it's place within the Connection handlers
Well, following up last aries-vcx community call, we agreed the users should not rely on what serialization format looks like, hence there's not much value in trying to make it nicer or better structured.
We can still discuss removal of source_id
, but I'll leave that for separate issue.
We are currently applying new approach for implementing state machines in https://github.com/hyperledger/aries-vcx/pull/743. This PR is performing breaking changes on
Connection
object which only has been added recently (as opposed to the originalMediatedConnection
). The young age ofConnection
was rationale why we were able to simply rewrite the implementation.This also allows us to rething serialization formats which with the original state machine are far from ideal. A testament for that is the need for
aries-vcx
consumers to come up with their own, better, serialization formats as indicated here https://github.com/hyperledger/aries-vcx/issues/742The current problems are:
Unnecessary top json root
The current state
Example: serialized Verifier state machine
Example: serialized Issuer state machine
Proposal
Because the top level node is varying between state machines, this makes it harder to work with, as the "json access path" is always different. The serialized state machine should encode what protocol it represents, but in more optimal way. Suggestion would be to instead encode that as follows:
where:
.protocol
would contain value of<protocol_family>/<version>
.protocol_role
would encode role within the.protocol
Difficult access to state variant
The current state
Example: serialized Verifier state machine
The current protocol state variant is currently encoded as JSON key inside
state
attribute. This makes it awkward to access, as you need to read key ofstate
(issuer_sm.state.???
)The current state
It would be easier to read protocol state if we instead can rely on a particular static JSON path, such as
issuer_sm.protocol_state
- hence the example above would look instead like:Finished
tofinished
Is
source_id
useful?I am not sure if this is useful for consumers. I think to keep aries-vcx minimal, identification of state machines should not be responsibility of
aries-vcx
, but application code should handle that instead (when storing state machines in storage, etc).Combined proposal
Combining the changes above, here's combined example of all changes. Given state machine
it would now become:
which includes changes:
source_id
.issuer_sm
and instead:.protocol
to identify protocol family and its version.protocol_role
to identify role within the.protocol
.state.???
and instead:.state
to identity state variant.state_data
to encode data associated with the current.state
of given.protocol