Latency implications of adding an observer to a contract

Let’s say, I have:

  • A party P1 allocated on participant node N1
  • A party P2 allocated on participant node N2
  • A single template T with a single signatory and a list of observers
  • A command is submitted by P1 on N1’s Ledger API to create an instance of T with P1 as the sole signatory, and …
    Scenario 1: … observers = []
    Scenario 2: … observers = [P2]
  1. In Scenario 1, the contract won’t need to be synchronized with N2 via the domain, while in Scenario 2, it will need to be synchronized with N2 via the domain for P2 to witness.
    Are there any restrictions on when the CreatedEvent for the contract creation becomes available to be emitted on the Transaction Stream via N1’s Ledger API, in relation to when the tx is sent to N2 for P2 to “observe”? Could the former happen before/after (in parallel) with the latter? In other words, does adding an observer from Scenario 1 to Scenario 2 causes additional latency to the emission of the CreatedEvent via N1’s Ledger API?

  2. How does the answer to the above question change if I add multiple observers (assume distributed across multiple nodes) instead of just 1 observer?

1 Like

Observers have only a negligible impact on latency. The transaction protocol always goes via the domain, even if only one participant is involved. By default, only signatories need to confirm so the latency is always due to the process

  1. N1 interprets and sends confirmation request to sequencer
  2. Sequencer records and broadcasts confirmation request to N1, N2 and Mediator
  3. N1 confirms (as sole confirmer) via the sequencer
  4. Sequencer broadcasts confirmation to Mediator
  5. Mediator sends commit message to sequencer
  6. Sequencer records commit message and broadcasts it to N1 and N2.
  7. N1 emits the successful transaction.

Since N2 is purely on the receiving end in all this, it has no impact on the latency. The only extra workload is on the sequencer, but that won’t move the needle much.

4 Likes

As @bernhard mentioned, currently all the synchronization goes via the domain, even if only N1 is involved. In the future, with multi-domain feature going GA, it should be possible to deploy a local domain together with N1 and give it higher priority, thus automatically restricting Scenario 1 to be N1 local (further reducing latency).

2 Likes

Thanks @bernhard and @Kirill-DA1 !