Deploying to DABL with multiple triggers

Hey, DABLer’s! Happy New Year! :fireworks: :champagne:

I am working on deploying our app similar to ex-bond-issuance to DABL but am having a bit of trouble understanding the DABL docs (specifically how to deploy)).

  1. Do I need to deploy individual .dar files for each trigger (and do they need to have individual daml.yaml files that reference the rest of the model in the dependencies)?

When I read the DABL docs it seems like I need to upload individual .dar files with individual daml.yaml. But in my experimenting, it seems like DABL is recognizing the 6 triggers, and I can manually deploy to the respective parties.

Which is the proper way to deploy triggers?

  1. Do I need to remove all triggers from the source daml code so that DABL recognizes that I’m uploading my daml model and not triggers?

I think 1 and 2 are related but a bit of clarification will be helpful. Thanks!

1 Like

@jamesljaworski85
Happy New Year!

  1. You don’t need to deploy individual .dar files for each trigger. The doc is emphasizing the fact that DABL will treat any dar containing triggers as “Trigger”(just like a function) so the Model(template definition) inside the same dar won’t be uploaded to the ledger.

  2. The recommended way(and the required way for DABL) to iterate over Model + Triggers is to add Model .dar as one of the dependencies in the trigger’s daml.yaml. In other word, have a dar only contains template definition as a dependency of your triggers dar(defined in daml.yaml), so that you can keep iterating the trigger dar with functional changes.

If I understand your situation correctly, You only need to separate your Model template definition into a
bond-issuance-model.dar, and have another trigger dar: bond-issuance-trigger.dar built from a daml.yaml containing:
dependencies: - bond-issuance-model.dar
Then upload/deploy both dar to your DABL Ledger.

Sorry for the confusion on the docs, we are on our way improving it!

5 Likes

Hi, @Li_Ma. Happy New Year! :partying_face: Thanks for working with me on this.

I am going to give it another shot with the above clarifications and let you know how it works!

1 Like

Hi @Li_Ma! I was able to get my trigger and model .dar files uploaded but have a question on how to initialize my ledger.

I have my script written but I am confused about the steps specified in the docs.

Is it preferred to add a separate .dar file for the ledger initialization script or to somehow initialize directly from the model .dar file?

I am also confused by this section. Is there a command line in the DABL workspace where this step is supposed to be run?

For context, when running in Sandbox, I specify the init-script: DA.RefApps.Bond.Test.MarketSetupScript:setupMarket in my daml.yaml file and I am interested in initializing the ledger to produce the same result on DABL.

2 Likes

@jamesljaworski85
Good to hear you got the model and trigger working!

To initialize your ledger with DAML Script, DABL currently does not support calling the script in a dar. However, you could run the script using daml script cli from local to your DABL ledger as described in the docs, with --json-api
flag. more details for that is described here.

To do that, you only need to download a participants.json from “Ledger Settings”, and take a look at party_participants fields, and prepare another ledger-parties.json file having a reverse mapping of your partyId: partyLiterals. all other credentials are already exists in the participants.json. Finally you can run the script by

daml script --participant-config participants.json --json-api --dar <Name of .dar that contains the DAML Script> --script-name <Name of DAML Script function> --input-file ledger-parties.json

Let me know how it goes!

1 Like

Hi @Li_Ma. Thanks for the response! It wasn’t clear to me that I had to run from the command line on my own machine in order to run the script.

I was able to get things up and running but had to make some changes to the script because of the following error when running the script from master branch.

daml script --participant-config participants.json 
            --json-api 
            --dar target/bond-issuance model.dar 
            --script-name "DA.RefApps.Bond.Test.MarketSetupScript:setupMarket" 
            --input-file ledger-parties.json

the error:

Exception in thread "main" java.lang.RuntimeException: The script 8fcf2e9b1f2ccf2bc482daea6ea3a1a613d1d31641e5f096a5c48dd188f18811:DA.RefApps.Bond.Test.MarketSetupScript:setupMarket does not take arguments.
        at com.daml.lf.engine.script.Runner$.run(Runner.scala:296)
        at com.daml.lf.engine.script.RunnerMain$.$anonfun$main$13(RunnerMain.scala:105)
        at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
        at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
        at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
        at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
        at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
daml-helper: Received ExitFailure 1 when running
Raw command: java "-Dlogback.configurationFile=C:\\Users\\James Jaworski\\AppData\\Roaming\\daml\\sdk\\1.8.0\\daml-sdk/script-logback.xml" -jar "C:\\Users\\James Jaworski\\AppData\\Roaming\\daml\\sdk\\1.8.0\\daml-sdk/daml-sdk.jar" script --participant-config participants.json --json-api --dar target/bond-issuance-model.dar --script-name DA.RefApps.Bond.Test.MarketSetupScript:setupMarket --input-file ledger-parties.json

By modifying the script to allow the parties to be received as an input, I was able to get the script to run when I using this script from the bond-on-dabl branch :partying_face:.

2 Likes

Great! Glad it worked!

And thanks for the feedback on the documentation. We will be making efforts to make it more clear.

3 Likes