feat: multi sync example - #1622
Conversation
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com> Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com> Co-authored-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com> Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…ge manager Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
| // /app/app-synchronizer.sc by scripts/src/start-localnet.ts so the change | ||
| // survives a `yarn script:fetch:localnet` (the .localnet bundle is gitignored). | ||
| // | ||
| // TODO(#2283): this is a temporary workaround until we have a proper multi-synchronizer bootstrap script in the Canton repo |
There was a problem hiding this comment.
self comment: we will be able to remove this file after switching to splice >= 0.7.4
| providerVetted.nonEmpty && providerVetted.head.item.packages.nonEmpty | ||
| val multiSyncFeatureFlag = | ||
| Seq(SynchronizerTrustCertificate.ParticipantTopologyFeatureFlag.EnableMultiSynchronizer) | ||
| multiSyncParticipants.foreach { participant => |
There was a problem hiding this comment.
I wonder if we should await for those operations to take effect with utils.retry_until_true. Probably won't be a problem as there is plenty of time between this script finishing and multi sync e2e test starting in CI.
| // When a specific synchronizerId is provided, check whether the party | ||
| // is already registered on that synchronizer (not just on the participant). | ||
| if ( | ||
| await this.checkIfPartyExists( |
There was a problem hiding this comment.
Is this a problem, that it exits early if party exists on createPartyOptions?.synchronizerId, if also createPartyOptions?.additionalSynchronizerIds were passed? A couple of lines lower it loops through additionalSynchronizerIds and registers the party there.
There was a problem hiding this comment.
I think it's a problem but I'd like a confirmation from someone else too.
There was a problem hiding this comment.
The current logic is mostly result of code evolution: we have not realized about that problem.
meiersi-da
left a comment
There was a problem hiding this comment.
@jarekr-da @mjuchli-da @mateuszpiatkowski-da : I've done another high-level review. As you can see from my comments I'm still a bit worried about missing a problem due to
- not using a one-participant-per-party topology
- not relying on automatic reassignments, which is what ultimately want to promote.
How do you propose to address these two concerns?
| ) | ||
| if (!testTokenAllocation) throw new Error('TestToken allocation not found') | ||
| // ── Step 10b: Reassign Bob's TestToken allocation app-synchronizer → global ── | ||
| // TODO #2097 remove after bugfix in canton |
There was a problem hiding this comment.
@jarekr-da : I understand that fix to allow auto assignment has landed in Canton already hasn't it?
|
|
||
| // TokenAdmin offers the freshly-minted TestToken to Bob. The transfer factory | ||
| // and choice context come from the registry's transfer-instruction-v1 API | ||
| // (the TestToken registry is also resolved via the metadata-v1 API). |
There was a problem hiding this comment.
@jarekr-da or @mateuszpiatkowski-da : what's the status of this?
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
|
From my side: some of the minor issues listed here are already fixed, the rest of them is either implemented here: #2383 or moved as a follow-up task: #2391. @jarekr-da will also contribute by creating a PR to this branch implementing some stuff from his side. |
Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
|
|
||
| // TokenAdmin offers the freshly-minted TestToken to Bob. The transfer factory | ||
| // and choice context come from the registry's transfer-instruction-v1 API | ||
| // (the TestToken registry is also resolved via the metadata-v1 API). |
There was a problem hiding this comment.
@meiersi-da I have not understood the original issue/comment
|
|
||
| // The settlement is submitted by TradingApp (sv), so Alice's resulting Token | ||
| // holding propagates to her participant (app-user) asynchronously. Poll app-user until it | ||
| // becomes visible instead of reading once (cross-participant read-after-write). |
There was a problem hiding this comment.
With multiple synchronizers - events might be observer with a delay and sometime out of order (order is preserved for one synchronizer but not between). But I will just remove this comment.
| }, | ||
| } | ||
| ) | ||
| } catch (e: unknown) { |
There was a problem hiding this comment.
done ( this is not pretentious - thanks)
| originalError: e, | ||
| }) | ||
| } | ||
| throw e |
| > | ||
|
|
||
| export interface ReassignParams { | ||
| submitter: string |
There was a problem hiding this comment.
I do needed claude in this :-) - done
| // When a specific synchronizerId is provided, check whether the party | ||
| // is already registered on that synchronizer (not just on the participant). | ||
| if ( | ||
| await this.checkIfPartyExists( |
There was a problem hiding this comment.
The current logic is mostly result of code evolution: we have not realized about that problem.
| return | ||
| } | ||
|
|
||
| const topology = |
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com> Signed-off-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com> Co-authored-by: Mateusz Piątkowski <mateusz.piatkowski@digitalasset.com>
Multi-Synchronizer DvP Example - On ledger API - Part 1
Showcases automatic reassignment of Token from private synchronizer to global one, used on a realistic trade scenario with use of a custom Token.
New test:
https://github.com/canton-network/wallet/pull/1622/changes#diff-37db720ea457076fe6d04f6938d19c44e5dde3d7e1a5815953ff6b83199a1052
Design principles:
!!! We remove handling of synchronizers inside wallet-sdk.
Client code should be responsible of selecting
synchronizerIdin multi-sync scenarios.If not provided - synchronizer choice is left for canton participant logic.
Existing tests are updated (refactor(wallet-sdk): remove default synchronizer auto-selection #1740).
We try to show "realistic scenario" - we use multiple parties (Alice, Bob, TokenAdmin, TradingApp) we also
distribute dars to selected synchronizers (private dars to private). This contributes to relative complexity of the test code
source:
https://docs.google.com/presentation/d/1q6LpHi-wC_MO_mzf7wp5D-15j4lNeKjCMW5xmBggaTY
Example works with Token Standard V1
We have experimented with token standard V2 -> but as V2 is not yet merged to splice use of V2 means even more code
All tests run on multi-sync
This is a first PR in a series
Showcases only on-ledger part - and ensures code works.
There are 2 follow up PRs (wip)
off ledger api for tokens standard Implementation feat: multi sync example test token token standard api implementation #1782(code extracted and merged here)
Technical limitations:
In this PR we introduce separate tests for multi-sync (otherwise regular tests are flaky on multi-sync) - that split will be removed in a separate PR (above)
New example script:
docs/wallet-integration-guide/examples/scripts/15-multi-sync-trade.ts
Notes
we experimented with automatic reassignment of contracts - and it basically worked BUT.
It worked as long as
Bobis owner ofTokenRulescontract which seems unrealistic.We introduced TokenAdmin as additional party that is issuer of
Tokenonapp-synchronizer(private one).But this in fact forces us to use explicit reassignment.
But since the settlement actually happens on global - TestToken related models must be also on global synchronizer