Multiple DAR on Canton (or Daml ledger in general)

When multiple DARs are uploaded in a participant node, is there a mechanism to specify which DAR file (then which template) to be used? Or we just use the module name to specify the template such as Main:Asset and Iou:Iou, despite that they are coming from different DARs? What happens if a collision in templates happens (e.g. Iou:Iou appears in both DARs)? Thanks in advance.

kc

1 Like

Templates have a sort-of “fully-qualified” name that includes their package ID. For example, in a brand new skeleton project:

$ daml new t
Created a new project in "t" based on the template "skeleton".
$ cd t
$ daml build

2022-01-20 16:05:03.82 [INFO]  [build] 
Compiling t to a DAR.

2022-01-20 16:05:04.51 [INFO]  [build] 
Created .daml/dist/t-0.0.1.dar
$ daml damlc inspect .daml/dist/t-0.0.1.dar | head -1
package 9f0305f31394fd9fe037f6d69312191c439fdb300f713c1368bd847eed36d3b9
$ 

the name Main:setup is a convenient shortcut for 9f0305f31394fd9fe037f6d69312191c439fdb300f713c1368bd847eed36d3b9:Main:setup, which is what our APIs really want to work with.

There are a number of places where we allow short forms if they are unambiguous, or where tooling auto-fills the package part based on locally loaded DARs, but it’s important to be aware that in Daml-LF (what actually travels on the wire, and what’s stored in DAR files), names are always fully-qualified.

The package name is a hash of the package itself and all of its dependencies, so there is very little chance of collision when using full names.

1 Like

Thanks @Gary_Verhaegen

So I assume that the daml runtime does not distinguish the templates based on which DAR it comes from, but rather it is the fully-qualified name for each template, which contains the package ID.

All the DAR files, after uploaded, will be treated “all together” (sorry that I can’t find a more accurate term), and the applications only specifying the right template names in order to reach the right template.

See if my understanding is correct. Thanks again!

As I understand it, DAR files are just zip files with DALF files in them. A DALF is a Daml package and that is the level at which package IDs are determined.

The upshot is that if you have two DAR files containing the same DALF, they end up pointing to the same package in the runtime (as you would want to expect, presumably).

However, it’s important to bear in mind that the granularity is at the DALF level here. If you have the exact same template in two different packages, they will count as different templates at runtime as they will have a different package ID.

1 Like