Skip to content

Commit ce92165

Browse files
authored
handles errors from full dkg sessions (#5580)
upgrades '@ironfish/multisig-broker' catches error messages with the 'DKG_SESSION_FULL' error code and throws an appropriate error in 'waitForJoinedSession' changes 'dkg:create' to ask the user if they want to retry joining the session. gives the user an opportunity to wait before immediately trying to rejoin a full session defines error types that were removed from '@ironfish/multisig-broker'
1 parent 3289f76 commit ce92165

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

ironfish-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"oclif:version": "oclif readme && git add README.md"
6161
},
6262
"dependencies": {
63-
"@ironfish/multisig-broker": "0.1.1",
63+
"@ironfish/multisig-broker": "0.3.0",
6464
"@ironfish/rust-nodejs": "2.7.0",
6565
"@ironfish/sdk": "2.8.1",
6666
"@ledgerhq/errors": "6.19.1",

ironfish-cli/src/commands/wallet/multisig/dkg/create.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,18 @@ export class DkgCreateCommand extends IronfishCommand {
116116
logger: this.logger,
117117
})
118118

119-
const { totalParticipants, minSigners } = await ui.retryStep(async () => {
120-
return sessionManager.startSession({
121-
totalParticipants: flags.totalParticipants,
122-
minSigners: flags.minSigners,
123-
ledger: flags.ledger,
124-
identity,
125-
})
126-
}, this.logger)
119+
const { totalParticipants, minSigners } = await ui.retryStep(
120+
async () => {
121+
return sessionManager.startSession({
122+
totalParticipants: flags.totalParticipants,
123+
minSigners: flags.minSigners,
124+
ledger: flags.ledger,
125+
identity,
126+
})
127+
},
128+
this.logger,
129+
true,
130+
)
127131

128132
const { round1 } = await ui.retryStep(
129133
async () => {

ironfish-cli/src/utils/multisig/sessionManagers/sessionManager.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44
import {
5-
IdentityNotAllowedError,
6-
InvalidSessionError,
75
MultisigBrokerErrorCodes,
86
MultisigBrokerUtils,
97
MultisigClient,
@@ -113,6 +111,8 @@ export abstract class MultisigClientSessionManager extends MultisigSessionManage
113111
this.client.onMultisigBrokerError.on((errorMessage) => {
114112
if (errorMessage.error.code === MultisigBrokerErrorCodes.SESSION_ID_NOT_FOUND) {
115113
clientError = new InvalidSessionError(errorMessage.error.message)
114+
} else if (errorMessage.error.code === MultisigBrokerErrorCodes.DKG_SESSION_FULL) {
115+
clientError = new DkgSessionFullError(errorMessage.error.message)
116116
} else if (errorMessage.error.code === MultisigBrokerErrorCodes.IDENTITY_NOT_ALLOWED) {
117117
// Throws error immediately instead of deferring to loop, below
118118
throw new IdentityNotAllowedError(errorMessage.error.message)
@@ -143,3 +143,11 @@ export abstract class MultisigClientSessionManager extends MultisigSessionManage
143143

144144
abstract getSessionConfig(): Promise<object>
145145
}
146+
147+
export class MultisigSessionError extends Error {
148+
name = this.constructor.name
149+
}
150+
151+
export class DkgSessionFullError extends MultisigSessionError {}
152+
export class InvalidSessionError extends MultisigSessionError {}
153+
export class IdentityNotAllowedError extends MultisigSessionError {}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,10 +1115,10 @@
11151115
dependencies:
11161116
mute-stream "^1.0.0"
11171117

1118-
"@ironfish/multisig-broker@0.1.1":
1119-
version "0.1.1"
1120-
resolved "https://registry.yarnpkg.com/@ironfish/multisig-broker/-/multisig-broker-0.1.1.tgz#9c4abfbe09f8199fb13fb672d0e1714203ed9a60"
1121-
integrity sha512-v7KaSvmsx3ihlVRi6er8YyLf7zRHB46uP6Rc2/zVvZqSoEeASViN1bpdDYM4YzuVeqTNQBF6Em79eT4tI40IpA==
1118+
"@ironfish/multisig-broker@0.3.0":
1119+
version "0.3.0"
1120+
resolved "https://registry.yarnpkg.com/@ironfish/multisig-broker/-/multisig-broker-0.3.0.tgz#6779c9fdae428cd59e46d7e300c82a1bb97d1f1a"
1121+
integrity sha512-D2hW7GV7SutnFAb0B1DVM9VV3+BWB31AdsCtQLuMeD9z4MHJJYTzzGFjsQ77sFI4lauVSCfPoPmpVQYd/KdxLA==
11221122
dependencies:
11231123
"@ironfish/rust-nodejs" "^2.7.0"
11241124
"@ironfish/sdk" "^2.8.1"

0 commit comments

Comments
 (0)