Skip to content
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

language: docu: documentation for the migrate command of damlc #2579

Merged
3 commits merged into from
Aug 19, 2019

Conversation

ghost
Copy link

@ghost ghost commented Aug 16, 2019

This adds a chapter on how to migrate between two different versions of
two packages.

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Add a line to the release notes, if appropriate
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

@ghost ghost requested a review from bame-da as a code owner August 16, 2019 16:08
@ghost ghost force-pushed the upgrading_docu branch from a926876 to 234c995 Compare August 16, 2019 16:45
Copy link
Contributor

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks a lot.

I'd prefer if @bame-da and/or someone from the DAML Seals has a look as well before we merge this since I'm too deep in the details already.


Available options:
TARGET_PATH Path where the new project should be located
SOURCE Path to the main source file ('source' entry of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we determine this from the manifest in the DAR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible, I'll try to change it.


.. code-block:: shell

./build.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does daml migrate generate build.sh?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no :P. I just tried it out and got the .daml files, but no build scripts.


./build.sh

respectively ``.\build.cmd`` if your on a Windows system. Note that you can **not** use the usual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does daml build not work? Can you please give a short explanation? Can we maybe actually make it work?

Copy link
Author

@ghost ghost Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

daml build will initialize the package db from the given .dar dependencies. However, we want to generate the interface files from the .dars and put those into the package db. This is done during the migrate command. If you call daml build you will overwrite them again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean daml build will bork the migration project? If so, we should fix that.


where the ``Foo.daml`` file contains

.. code-block:: daml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put this in a separate file and use an include directive. I'm afraid the code will stop working at some point otherwise. Same below.

with
inC : ContractId A.Foo
sigs : [Party]
controller sigs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as sigs contains more than one party calling this choice needs another template to collect the signatures. We should generate that one as well. We should also base as much of this as possible on generic templates in the near future.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the generic templates. I think we need some input anyways on how these upgrade templates should look like and what authorization they should have.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we should include a workflow to collect signatures, either via generic templates, or by generating an UpgradeAgreement template, which collects signatures and has non-consuming choices for op to create and trigger Upgrade on any of the generated templates.

conv : (Generic a repA, Generic b repB, Conv repA repB) => a -> b

From its type signature you can see that it can convert any two data types that are instances of the
``Generic`` class and whose generic representation can be converted itself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need an explanation aiming at our users intuition here.

two packages. In our example, you'll find them in the files ``FooAInstances.daml`` and
``FooBInstances.daml``.

Generic representations can be converted when they are ``isomorphic``. That means the corresponding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there are function called isomorphic? If not, we should change the formatting from code-like to italic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.


The important hint is that the compiler is not able to deduce that our data type is an instance of
the ``DA.Upgrade.Conv`` class and hence not convertible. In this case you will have to add your own
upgrade/rollback templates to ``daml/Foo.daml``, that describe how to convert a contract of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

daml/Foo.daml` from which package?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of the migration project you're building. I'll add it.

You find more information on how to deploy DAML archive packages :ref:`here <deploy-ref_index>` .
After the ``foo-upgrade-2.0.0`` package has been deployed on the ledger, there exists for every
contract defined in ``foo-1.0.0`` a DAML workflow with a choice to upgrade it to ``foo-2.0.0`` or
roll it back. A future iteration might add DAML triggers to carry out the upgrade process
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please remove the last sentence. I can be misread as a promise.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

@bame-da bame-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these docs are good. I could follow them very easily, except that there was no mention that TARGET_PATH has to be outside your project.

I also couldn't try it out as I got no build scripts.


.. code-block:: shell

./build.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no :P. I just tried it out and got the .daml files, but no build scripts.


./build.sh

respectively ``.\build.cmd`` if your on a Windows system. Note that you can **not** use the usual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean daml build will bork the migration project? If so, we should fix that.

with
inC : ContractId A.Foo
sigs : [Party]
controller sigs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we should include a workflow to collect signatures, either via generic templates, or by generating an UpgradeAgreement template, which collects signatures and has non-consuming choices for op to create and trigger Upgrade on any of the generated templates.

data Maybe a = Just a | Nothing

When the package ``foo-2.0.0`` contains an extended data type of the ``Foo`` template that is not
isomorphic, the build will fail. For example, let's assume the ``Foo`` module in the ``foo-2.0.0``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be much nicer if it went through with as much as possible, but left stubs for Conv instances that it can't automatically derive. So the user can open Main.daml and fill in those cv definitions.

Copy link
Author

@ghost ghost Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will add the templates, but it won't compile so you really just have to change the line containing the application of the conv function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a sentence to the docs.

@hurryabit
Copy link
Contributor

@bame-da said there are plenty of "unused import" warnings. We can suppress them with

importGenerated qual i = i{ideclImplicit=True, ideclQualified=qual}

Copy link
Contributor

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this and keep improving in incremental steps.

Robin Krom added 2 commits August 19, 2019 15:11
This adds a section on how to migrate between two different versions of
two packages.
@ghost ghost force-pushed the upgrading_docu branch from 234c995 to 4c23848 Compare August 19, 2019 13:44
@ghost
Copy link
Author

ghost commented Aug 19, 2019

@bame-da ah, to follow this one of the PR's still needs to go to master

@ghost ghost merged commit 47238a5 into master Aug 19, 2019
@ghost ghost deleted the upgrading_docu branch August 19, 2019 14:58
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants