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
In this case, res_accum is defined as a stream of optional values. Finally it compiles to smth like this:
(matchtruetrue
(ap"a" $res)
)
(ap $res $res_accum)
This code will fail, as $res value is not deterministic: different peers may observe different state of $res. $res, being a stream, forms a locally consistent CRDT, its state may differ for different points of view, and may grow in time.
To use $res safely as a value of type ?string (the return type of the function), it needs to be canonicalized: converted from the mutable $res form to an immutable res form.
Canonicalization is not yet implemented on AquaVM side, but we can think of it as a point of observation:
(can peer_id $res res)
After this can call, res will contain a fixed value of $res for the moment of the first can call on peer_id. All other peers will check that res was derived the right way, get tetraplets, etc.
Until we have this implemented, we can mock can with (call peer_id ("op" "identity") [$res] res). Currently, it does the same: converts argument to a scalar value. But it misses tetraplets.
The task is to add this call implicitly when a stream is pushed into a stream. Once we have native canonicalization support, replace op identity call with it.
The text was updated successfully, but these errors were encountered:
One of the common patterns in Aqua is building optional values by writing or not writing to a stream:
Consider the following snippet:
In this case, res_accum is defined as a stream of optional values. Finally it compiles to smth like this:
This code will fail, as
$res
value is not deterministic: different peers may observe different state of$res
.$res
, being a stream, forms a locally consistent CRDT, its state may differ for different points of view, and may grow in time.To use
$res
safely as a value of type?string
(the return type of the function), it needs to be canonicalized: converted from the mutable$res
form to an immutableres
form.Canonicalization is not yet implemented on AquaVM side, but we can think of it as a point of observation:
(can peer_id $res res)
After this
can
call,res
will contain a fixed value of$res
for the moment of the firstcan
call onpeer_id
. All other peers will check thatres
was derived the right way, get tetraplets, etc.Until we have this implemented, we can mock
can
with(call peer_id ("op" "identity") [$res] res)
. Currently, it does the same: converts argument to a scalar value. But it misses tetraplets.The task is to add this call implicitly when a stream is pushed into a stream. Once we have native canonicalization support, replace op identity call with it.
The text was updated successfully, but these errors were encountered: