Trying to use ledger export to Daml Script but failing

I’m trying to use the Ledger Export feature, see Ledger Export — Daml SDK 2.2.0 documentation

I have created a new project, with daml new <project_name> and started Sandbox with daml start.

While the ledger running in Sandbox, I issued the following command:

daml ledger export script --host localhost --port 6865 --all-parties --output ../out --sdk-version 2.2.0

The command created a Daml project for me as expected. When I try to start the created project (after stopping the original ledger), I get the following error message:

gyorgybalazsi@BGY out % daml start

2022-06-03 14:54:29.02 [INFO]  [build] 
Compiling export to a DAR.

2022-06-03 14:54:29.65 [INFO]  [build] 
Created .daml/dist/export-1.0.0.dar
Waiting for canton sandbox to start.
Uploading .daml/dist/export-1.0.0.dar to localhost:6865
DAR upload succeeded.
Running the initialization script.
Exception in thread "main" com.daml.lf.engine.script.ScriptF$FailedCmd: Command submit failed: NOT_FOUND: NO_DOMAIN_ON_WHICH_ALL_SUBMITTERS_CAN_SUBMIT(11,00d3f0c5): This participant can not submit as the given submitter on any connected domain
Daml stacktrace:
submit at 5053e1348089bc3c062e48c38fe8faa62ec294d06bc78f8fbe0edb871b9571b2:Export:65
        at com.daml.lf.engine.script.Runner.$anonfun$runWithClients$10(Runner.scala:460)
        at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:475)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:63)
        at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:100)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:100)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: io.grpc.StatusRuntimeException: NOT_FOUND: NO_DOMAIN_ON_WHICH_ALL_SUBMITTERS_CAN_SUBMIT(11,00d3f0c5): This participant can not submit as the given submitter on any connected domain
        at io.grpc.Status.asRuntimeException(Status.java:535)
        at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:534)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:562)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
daml-helper: Received ExitFailure 1 when running
Raw command: java -Dlogback.configurationFile=/Users/gyorgybalazsi/.daml/sdk/2.2.0/daml-sdk/script-logback.xml -jar /Users/gyorgybalazsi/.daml/sdk/2.2.0/daml-sdk/daml-sdk.jar script --dar .daml/dist/export-1.0.0.dar --script-name Export:export --wall-clock-time --ledger-host localhost --ledger-port 6865 --input-file args.json

daml-helper: Received ExitFailure 1 when running
Shell command: /Users/gyorgybalazsi/.daml/bin/daml script --dar .daml/dist/export-1.0.0.dar --script-name 'Export:export' --wall-clock-time --ledger-host localhost --ledger-port 6865 --input-file args.json

gyorgybalazsi@BGY out % 

What am I doing wrong?

1 Like

My guess is that you are no allocating and mapping parties appropriately. The script export tool auto-generates an args.json file which contains the identity map. Eg if on my source ledger I had a party party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9, my args.json will look like this:

{
  "contracts": {

  },
  "parties": {
    "party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9": "party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9"
  }
}

Now if that party had a User contract from the getting started guide on the ledger, that will translate into

export : Args -> Script ()
export Args{parties, contracts} = do
  let party879934e4776947d3b1d4207784fa3ae01220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9_0 = lookupParty "party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9" parties
  _ <- submit party879934e4776947d3b1d4207784fa3ae01220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9_0 do
    createCmd User.User with
      username = party879934e4776947d3b1d4207784fa3ae01220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9_0
      following = []
  pure ()

Then you run your script using this command:

daml script --dar .daml/dist/export-1.0.0.dar --script-name 'Export:export' --wall-clock-time --ledger-host localhost --ledger-port 6865 --input-file args.json

What now happens is that daml script will try to submit a command using party literal "party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9".

This party does not exist, for which the error is NOT_FOUND: NO_DOMAIN_ON_WHICH_ALL_SUBMITTERS_CAN_SUBMIT(11,945e9ffc): This participant can not submit as the given submitter on any connected domain meaning the sandbox (“this participant”) is not able to submit as the given submitter (party-879934e4...).

To fix this you have a few options:

  1. Manually allocate new parties and create the mapping in args.json.
  2. Do things fully automatically by running the testExport script instead.
  3. Run party allocation with allocateParties and copy the result into args.json.

To demonstrate option 3 here:

First extract the parties:

daml script --dar .daml/dist/export-1.0.0.dar --script-name 'Export:allocateParties' --wall-clock-time --ledger-host localhost --ledger-port 6865 --output-file parties.json

Copy the contents into args.json.

Contents of parties.json:

{
  "party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9": "party-00956367-ef01-465d-bcd6-09b8e4f8e3c9::122093b7d7fb2db6af34024f710d03549ac26072064a4689996ace34c424fa16b941"
}

Resulting args.json:

{
  "contracts": {

  },
  "parties": {
    "party-879934e4-7769-47d3-b1d4-207784fa3ae0::1220c6a25c56ff8fbb6176309138da27b2a2cef8bd720b08500719175bfdff4ef6d9": "party-00956367-ef01-465d-bcd6-09b8e4f8e3c9::122093b7d7fb2db6af34024f710d03549ac26072064a4689996ace34c424fa16b941"
  }
}

Now run the script with the new args.json:

daml script --dar .daml/dist/export-1.0.0.dar --script-name 'Export:export' --wall-clock-time --ledger-host localhost --ledger-port 6865 --input-file args.json
2 Likes

Thanks, Bernhard, I more or less understand how it needs to be done. After performing your steps I cannot see the contract which was active on the original ledger in Navigator, but I can see it in the script results. Maybe I am messing up the party ids in Navigator, will try and find the solution.