Skip to content

refactor(wallet-sdk): remove default synchronizer auto-selection#1740

Open
jarekr-da wants to merge 9 commits into
wiktor/multisync-examplefrom
jarekr/sdk_synchronizers
Open

refactor(wallet-sdk): remove default synchronizer auto-selection#1740
jarekr-da wants to merge 9 commits into
wiktor/multisync-examplefrom
jarekr/sdk_synchronizers

Conversation

@jarekr-da

@jarekr-da jarekr-da commented May 13, 2026

Copy link
Copy Markdown
Contributor
  1. No automatic selection of synchonizer in wallet sdk code - if synchronizer is not explicitly provided by caller - we rely on canon ledger choice of synchronizer. There is no extra logic of choosing synchonizer in wallet sdk
  2. tests code changed to explicitly set synchronizer

Note:

This complicates all existing tests. Code must now explicitly select synchronizer in many calls.

Alternative would be to start some tests in single synchronizer (but this also means, such test would fail randomly if run on multi synchronizer localnet).

@jarekr-da jarekr-da changed the title All tests use multi-sync Removed default synchronizer Id May 18, 2026
@jarekr-da jarekr-da changed the title Removed default synchronizer Id Removed default synchronizer May 18, 2026
@jarekr-da jarekr-da force-pushed the jarekr/sdk_synchronizers branch from 97545e9 to 3ae7ca0 Compare May 20, 2026 13:51
@jarekr-da jarekr-da force-pushed the wiktor/multisync-example branch from 563df2d to 98dfc85 Compare May 20, 2026 17:18
@jarekr-da jarekr-da force-pushed the jarekr/sdk_synchronizers branch from 3ae7ca0 to a84acce Compare June 8, 2026 10:45
@jarekr-da jarekr-da self-assigned this Jun 9, 2026
@jarekr-da jarekr-da force-pushed the jarekr/sdk_synchronizers branch from a84acce to fa21b86 Compare June 9, 2026 13:12
@jarekr-da jarekr-da changed the title Removed default synchronizer refactor(wallet-sdk): remove default synchronizer auto-selection Jun 9, 2026
@jarekr-da jarekr-da force-pushed the jarekr/sdk_synchronizers branch 2 times, most recently from 7c58d39 to 452af4a Compare June 10, 2026 10:28
@jarekr-da

Copy link
Copy Markdown
Contributor Author

Check - where syncId is really needed by canton.

@jarekr-da jarekr-da force-pushed the jarekr/sdk_synchronizers branch 2 times, most recently from 0256183 to 51c5d16 Compare June 15, 2026 15:54
@jarekr-da jarekr-da marked this pull request as ready for review June 16, 2026 07:15
@jarekr-da jarekr-da requested a review from a team as a code owner June 16, 2026 07:15
@jarekr-da jarekr-da force-pushed the wiktor/multisync-example branch from 93653ae to 1bee65e Compare June 17, 2026 07:54
…vide synchronizerId

Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…examples and snippets

Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
… for multi-sync

Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…Id to DAR uploads in upload-dars

Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…Id to DAR uploads and external party creation

The wallet SDK no longer auto-selects a synchronizer. DAR upload and external party creation now require an explicit synchronizerId, which fails on multi-sync participants otherwise. Resolve the global synchronizer via getGlobalSynchronizerId and pass it to dar.upload and party.external.create across the affected example scripts.

Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>
…arty creation in scripts 08, 09, 12 and stress 01

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>
@jarekr-da jarekr-da force-pushed the jarekr/sdk_synchronizers branch from 5bf4f06 to f937203 Compare June 17, 2026 14:12
Signed-off-by: jarekr-da <jaroslaw.ratajski@digitalasset.com>

@mateuszpiatkowski-da mateuszpiatkowski-da left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code itself looks fine, but I don't understand why can't we simply make the default synchronizer id an optional parameter when instantiating sdk. This way the user would still have the ability to point to the right resource (as described in this comment) while keeping the interface as simple as possible :)

options?.confirmingParticipantEndpoints ?? []
),
options?.synchronizerId || this.resolveSynchronizerId(),
options?.synchronizerId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed here, as this is not async

]) =>
this.ctx.ledgerProvider.request<Ops.PostV2PartiesExternalGenerateTopology>(
]) => {
if (!synchronizerId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simply pass options.synchronizerId

this.ctx.defaultSynchronizerId
const synchronizerId = this.createPartyOptions?.synchronizerId
if (!synchronizerId)
throw new Error(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sdk.ctx.error.throw

const migrationId = params.migrationId ?? 0
const synchronizerId = params.synchronizerId
if (!synchronizerId)
throw new Error(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sdk.ctx.error.throw

this.sdkContext.commonCtx.defaultSynchronizerId
const synchronizerId = params?.synchronizerId
if (!synchronizerId)
throw new Error(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sdk.ctx.error.throw

const provider = parties?.provider ?? this.ctx.validatorParty
const synchronizerId =
args.synchronizerId ?? this.ctx.commonCtx.defaultSynchronizerId
const synchronizerId = args.synchronizerId

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: is this const needed? I think we can just write args.synchronizerId


// ========= Resolve the synchronizer parties are hosted on =========
const { connectedSynchronizers } = await sdk.ledger.connectedSynchronizers(
{}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commented on this in the target branch's PR - I think that the argument can be optional, as {} doesn't say much to the reader

PATH_TO_DAR_IN_LOCALNET
)

// Resolve the global synchronizer explicitly: the SDK no longer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: the comment refers to the prior status of SDK capabilities, but once this PR is merged this will no longer be valid as the changes will be overwritten. I suggest shortening this to:

Suggested change
// Resolve the global synchronizer explicitly: the SDK no longer
// Resolve the global synchronizer explicitly as the DAR upload cannot be autodetected when the
// participant is connected to multiple synchronizers.

if (!this.sdk) throw new Error('SDK not initialized')

const { connectedSynchronizers } =
await this.sdk.ledger.connectedSynchronizers({})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: same comment as in #1740 (comment)

* The wallet SDK no longer auto-selects a synchronizer, so client code (these
* examples) resolves it explicitly and passes it to SDK calls that require one.
*/
export async function getGlobalSynchronizerId(sdk: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I don't understand - why can't wallet-sdk itself have the default behavior like described here to implement? I think it would be substantially easier for the end user to just let sdk do their own thing by default and have the possibility to optionally overwrite that behavior by passing either:

  1. end value
  2. callback incorporating appropriate business logic
  3. value that would be used in sdk-fixed function

Is it possible for the global synchronizer id to change during the lifecycle of the sdk instance? Can the global synchronizer id even change? Intutively this should be a constant publically accessible, so in this case synchronizerAlias should always be equal to global which in turn should simplify both the logic and the user interface of sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants