Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically rejoins session when reconnecting to server #5563

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

hughy
Copy link
Contributor

@hughy hughy commented Oct 17, 2024

Summary

if a client disconnects from the multisig broker server unexpectedly then the server will remove the client and its identity from the session

client automatically rejoins the session after automatically reconnecting so that the server adds it and its identity back into the session

nests sessionId and passphrase properties into a single 'session' property along with the identity. sessionId, passphrase, and identity must all be non-null or all null, and grouping them into an object reflects this

Testing Plan

apply the diff below (git diff apply) to make the server drop a client's connection on ~50% of 'dkg.get_status' messages:

diff --git a/ironfish-cli/src/multisigBroker/server.ts b/ironfish-cli/src/multisigBroker/server.ts
index adf297087..88d841165 100644
--- a/ironfish-cli/src/multisigBroker/server.ts
+++ b/ironfish-cli/src/multisigBroker/server.ts
@@ -2,6 +2,7 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 import { ErrorUtils, Logger, YupUtils } from '@ironfish/sdk'
+import { randomInt } from 'crypto'
 import net from 'net'
 import { IMultisigBrokerAdapter } from './adapters'
 import { ClientMessageMalformedError, MultisigBrokerErrorCodes } from './errors'
@@ -201,6 +202,13 @@ export class MultisigServer {
       this.logger.debug(`Client ${client.id} sent ${message.method} message`)
       this.send(client.socket, 'ack', message.sessionId, { messageId: message.id })
 
+      if (message.method === 'dkg.get_status' && randomInt(10) < 5) {
+        this.removeClientFromSession(client)
+        client.close()
+        this.clients.delete(client.id)
+        return
+      }
+
       if (message.method === 'dkg.start_session') {
         await this.handleDkgStartSessionMessage(client, message)
         return

run wallet:multisig:dkg:create with two participants, and the process should still complete (eventually) with clients reconnecting

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes

if a client disconnects from the multisig broker server unexpectedly then the
server will remove the client and its identity from the session

client automatically rejoins the session after automatically reconnecting so
that the server adds it and its identity back into the session
@hughy hughy requested a review from a team as a code owner October 17, 2024 23:12
@hughy hughy merged commit e9bec69 into staging Oct 18, 2024
10 checks passed
@hughy hughy deleted the feat/hughy/reconnect-rejoin branch October 18, 2024 17:55
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