[#235] [TM-273] Improve address computation accuracy
Description
This PR replaces json encoding in the calculation of operation hashes (mkTransferOperationHash
and mkOriginationOperationHash
) with binary encoding.
Because binary serialization is only defined for typed values (as opposed to json serialization, which is only defined for untyped values), we had to make some changes to OriginationOperation
to support passing in a typed contract/storage instead.
As a result, we've addressed part of the problem described in TM-273.
Previously, Michelson.Test.Integrational.tOriginate
had to untype the contract and storage, pass them to the interpreter which would (needlessly) typecheck them again. Now, tOriginate
can just simply pass a typed contract/storage to the interpreter and that's it.
Furthermore, this required some small changes to the interpreter's API. Previously,
we used withGlobalOperation op $ execute* op
to execute a global
operation, where withGlobalOperation
was responsible for calculating
the OperationHash
. The execute*
functions (e.g.
executeOrigination
, executeTransfer
) would then consume this
OperationHash
.
However, because:
- calculating the
OperationHash
for a transfer operation now uses binary serialization, - binary serialization can only be used on typed values,
- the transfer's value can be untyped, and then later typechecked
inside
executeTransfer
,
... we can't calculate the OperationHash
upfront (in
withGlobalOperation
) anymore. It can only be calculated inside
executeTransfer
, after the transfer's value has been typechecked.
To solve this, we removed withGlobalOperation
function, and moved its logic inside the execute*
functions.
Related issue(s)
Resolves #235 (closed)
Resolves part of TM-273
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.