Skip to content

Commit d736c32

Browse files
change script
Signed-off-by: rukmini-basu-da <[email protected]>
1 parent 0fa0fb8 commit d736c32

File tree

2 files changed

+101
-82
lines changed

2 files changed

+101
-82
lines changed

canton/mainnet/bootstrap.sc

Lines changed: 100 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,25 @@ participant1.ledger_api.users.create(id = "operator", actAs = Set(operatorParty)
121121

122122
logger.info(s"WALLET-KERNEL-BOOTSTRAP: created operator user and party")
123123

124+
val parId = participant1.id.toLengthLimitedString
125+
126+
logger.info(s"WALLET-KERNEL-BOOTSTRAP ParticipantId is: $parId")
127+
128+
129+
participant1.ledger_api.identity_provider_config.create("mock-oauth2", isDeactivated = false, jwksUrl = "http://127.0.0.1:8889/jwks", issuer = "http://127.0.0.1:8889", audience = None)
130+
131+
participant1.ledger_api.users
132+
.create(
133+
id = "mock-oauth2-user",
134+
primaryParty = Some(operatorParty),
135+
actAs = Set(),
136+
readAs = Set(),
137+
participantAdmin = true,
138+
isDeactivated = false,
139+
identityProviderAdmin = true,
140+
identityProviderId = "mock-oauth2",
141+
annotations = Map()
142+
)
124143

125144

126145
def initializeSequencer(
@@ -139,91 +158,91 @@ def initializeSequencer(
139158
}
140159

141160
def migrateNode(
142-
migratedNode: InstanceReference with ConsoleCommandGroup,
143-
newStaticSynchronizerParameters: StaticSynchronizerParameters,
144-
synchronizerId: SynchronizerId,
145-
newSequencers: Seq[SequencerReference],
146-
dars: Seq[String],
147-
sequencerTrustThreshold: PositiveInt = PositiveInt.one,
148-
exportDirectory: File,
149-
): Unit = {
150-
val files = UpgradeDataFiles.from(migratedNode.name, exportDirectory)
151-
152-
files.keys.foreach { case (keys, name) =>
153-
migratedNode.keys.secret.upload(keys, name)
154-
}
155-
migratedNode.topology.init_id_from_uid(files.uid)
156-
migratedNode.health.wait_for_ready_for_node_topology()
157-
migratedNode.topology.transactions
158-
.import_topology_snapshot(files.authorizedStore, TopologyStoreId.Authorized)
159-
160-
migratedNode match {
161-
case newSequencer: SequencerReference =>
162-
initializeSequencer(newSequencer, files.genesisState, newStaticSynchronizerParameters)
163-
164-
case newMediator: MediatorReference =>
165-
newMediator.setup.assign(
166-
synchronizerId,
167-
SequencerConnections.tryMany(
168-
newSequencers
169-
.map(s => s.sequencerConnection.withAlias(SequencerAlias.tryCreate(s.name))),
170-
sequencerTrustThreshold,
171-
SubmissionRequestAmplification.NoAmplification,
172-
),
173-
)
174-
175-
case newParticipant: ParticipantReference =>
176-
val node = newParticipant
177-
// user-manual-entry-begin: WaitForParticipantInitialization
178-
node.health.wait_for_initialized()
179-
// user-manual-entry-end: WaitForParticipantInitialization
180-
dars.foreach(dar => newParticipant.dars.upload(dar))
181-
182-
case _ =>
183-
throw new IllegalStateException(
184-
s"Unsupported migration from $files to $migratedNode"
185-
)
161+
migratedNode: InstanceReference with ConsoleCommandGroup,
162+
newStaticSynchronizerParameters: StaticSynchronizerParameters,
163+
synchronizerId: SynchronizerId,
164+
newSequencers: Seq[SequencerReference],
165+
dars: Seq[String],
166+
sequencerTrustThreshold: PositiveInt = PositiveInt.one,
167+
exportDirectory: File,
168+
): Unit = {
169+
val files = UpgradeDataFiles.from(migratedNode.name, exportDirectory)
170+
171+
files.keys.foreach { case (keys, name) =>
172+
migratedNode.keys.secret.upload(keys, name)
173+
}
174+
migratedNode.topology.init_id_from_uid(files.uid)
175+
migratedNode.health.wait_for_ready_for_node_topology()
176+
migratedNode.topology.transactions
177+
.import_topology_snapshot(files.authorizedStore, TopologyStoreId.Authorized)
178+
179+
migratedNode match {
180+
case newSequencer: SequencerReference =>
181+
initializeSequencer(newSequencer, files.genesisState, newStaticSynchronizerParameters)
182+
183+
case newMediator: MediatorReference =>
184+
newMediator.setup.assign(
185+
synchronizerId,
186+
SequencerConnections.tryMany(
187+
newSequencers
188+
.map(s => s.sequencerConnection.withAlias(SequencerAlias.tryCreate(s.name))),
189+
sequencerTrustThreshold,
190+
SubmissionRequestAmplification.NoAmplification,
191+
),
192+
)
193+
194+
case newParticipant: ParticipantReference =>
195+
val node = newParticipant
196+
// user-manual-entry-begin: WaitForParticipantInitialization
197+
node.health.wait_for_initialized()
198+
// user-manual-entry-end: WaitForParticipantInitialization
199+
dars.foreach(dar => newParticipant.dars.upload(dar))
200+
201+
case _ =>
202+
throw new IllegalStateException(
203+
s"Unsupported migration from $files to $migratedNode"
204+
)
205+
}
186206
}
187-
}
188207

189208
final case class UpgradeDataFiles(
190-
uidFile: File,
191-
keyFiles: Seq[File],
192-
authorizedStoreFile: File,
193-
acsSnapshotFile: File,
194-
genesisStateFile: File,
195-
) {
196-
def uid: UniqueIdentifier =
197-
UniqueIdentifier.tryFromProtoPrimitive(
198-
uidFile.contentAsString
199-
)
200-
201-
def keys: Seq[(ByteString, Option[String])] =
202-
keyFiles.map { file =>
203-
val key = BinaryFileUtil.tryReadByteStringFromFile(file.canonicalPath)
204-
val name = file.name.stripSuffix(".keys")
205-
key -> Option(name)
206-
}
209+
uidFile: File,
210+
keyFiles: Seq[File],
211+
authorizedStoreFile: File,
212+
acsSnapshotFile: File,
213+
genesisStateFile: File,
214+
) {
215+
def uid: UniqueIdentifier =
216+
UniqueIdentifier.tryFromProtoPrimitive(
217+
uidFile.contentAsString
218+
)
207219

208-
def authorizedStore: ByteString =
209-
BinaryFileUtil.tryReadByteStringFromFile(authorizedStoreFile.canonicalPath)
220+
def keys: Seq[(ByteString, Option[String])] =
221+
keyFiles.map { file =>
222+
val key = BinaryFileUtil.tryReadByteStringFromFile(file.canonicalPath)
223+
val name = file.name.stripSuffix(".keys")
224+
key -> Option(name)
225+
}
210226

211-
def genesisState: ByteString =
212-
BinaryFileUtil.tryReadByteStringFromFile(genesisStateFile.canonicalPath)
213-
}
227+
def authorizedStore: ByteString =
228+
BinaryFileUtil.tryReadByteStringFromFile(authorizedStoreFile.canonicalPath)
214229

215-
object UpgradeDataFiles {
216-
def from(nodeName: String, baseDirectory: File): UpgradeDataFiles = {
217-
val keys =
218-
baseDirectory.list
219-
.filter(file => file.name.startsWith(nodeName) && file.name.endsWith(".keys"))
220-
.toList
221-
UpgradeDataFiles(
222-
uidFile = baseDirectory / s"$nodeName-uid",
223-
keyFiles = keys,
224-
authorizedStoreFile = baseDirectory / s"$nodeName-authorized-store",
225-
acsSnapshotFile = baseDirectory / s"$nodeName-acs-snapshot",
226-
genesisStateFile = baseDirectory / s"$nodeName-genesis-state",
227-
)
230+
def genesisState: ByteString =
231+
BinaryFileUtil.tryReadByteStringFromFile(genesisStateFile.canonicalPath)
228232
}
229-
}
233+
234+
object UpgradeDataFiles {
235+
def from(nodeName: String, baseDirectory: File): UpgradeDataFiles = {
236+
val keys =
237+
baseDirectory.list
238+
.filter(file => file.name.startsWith(nodeName) && file.name.endsWith(".keys"))
239+
.toList
240+
UpgradeDataFiles(
241+
uidFile = baseDirectory / s"$nodeName-uid",
242+
keyFiles = keys,
243+
authorizedStoreFile = baseDirectory / s"$nodeName-authorized-store",
244+
acsSnapshotFile = baseDirectory / s"$nodeName-acs-snapshot",
245+
genesisStateFile = baseDirectory / s"$nodeName-genesis-state",
246+
)
247+
}
248+
}

canton/mainnet/canton.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ canton {
4444
}]
4545
}
4646
}
47-
}
47+
}

0 commit comments

Comments
 (0)