createAndExercise transaction flow in Canton

My understanding is that a single Daml transaction on Canton involves 2 roundtrips between a participant Node and the domain. Assuming a scenario wherein there are 2 parties (a creator of a contract and an exerciser of a choice on the created contract) and a JWT that authorizes both these parties in the actAs:

  1. A createAndExercise command is supposed to create a new contract and, within the same transaction, immediately exercise a choice on it. If the creator and exerciser are the same party or are 2 distinct parties allocated on the same participant node, this would be a single Daml transaction and hence 2 roundtrips between the participant Node and the domain - is this understanding correct?

  2. How does this createAndExercise command work if the creator and exerciser parties are two distinct parties allocated on 2 different participant nodes? Would it be 2 separate Daml transactions and hence 2 roundtrips per participant Node to the domain, so a total of 4 roundtrips?

1 Like
  1. This is correct
  2. createAndExercise is a single command submission, so it is not possible to do this with parties hosted on separate participants, because it is not possible to properly authorize this transaction (we need authorization from the second party which is hosted elsewhere, i.e. the private keys of for this party are not available in this participant).
    And of course for the scenario of separate participants one can just use separate create and exercise transactions submitted in the respective nodes.
    It is also possible to host a party on multiple participants.
3 Likes

Thanks @Kirill-DA1 for the clear explanation!

Hello @Mr_Mannoroth
I have seen your both points want to share some related information
Yes, your understanding is correct. If the creator and exerciser parties are the same or are allocated on the same participant node, then the createAndExercise command can be executed within a single Daml transaction, and this would require two roundtrips between the participant node and the domain.

If the creator and exerciser parties are allocated on different participant nodes, then executing the createAndExercise command would require two separate Daml transactions, one on each participant node. This would result in four roundtrips between the participant nodes and the domain, as each participant node would need to communicate with the domain twice (once for creating the contract, and once for exercising the choice).

However, Canton provides optimizations for reducing the number of roundtrips required in such cases. For example, if the two participant nodes are part of the same network segment and can communicate with each other directly, Canton can optimize the transaction flow by allowing the two nodes to communicate with each other directly instead of going through the domain. This can significantly reduce the latency and improve the overall performance of the transaction flow. Hope so it will also help and your given solution is also very helpful.

1 Like