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

feat: convert to or modify multisig account added #307

Merged
merged 6 commits into from
Oct 31, 2021

Conversation

yilmazbahadir
Copy link
Collaborator

@yilmazbahadir yilmazbahadir commented Oct 30, 2021

symbol-bootstrap modifyMultisig command is added. It's useful to convert main account into a multisig account or to modify the multisig account structure. Takes the following parameters, the user will be prompted for the unset parameters.

-A, --addressAdditions=addressAdditions              Cosignatory accounts addresses to be added (separated by a
                                                       comma).

  -D, --addressDeletions=addressDeletions              Cosignatory accounts addresses to be removed (separated by a
                                                       comma).

  -a, --minApprovalDelta=minApprovalDelta              Number of signatures needed to approve a transaction. If the
                                                       account is already multisig, enter the number of cosignatories to
                                                       add or remove.

  -r, --minRemovalDelta=minRemovalDelta                Number of signatures needed to remove a cosignatory. If the
                                                       account is already multisig, enter the number of cosignatories to
                                                       add or remove.

@yilmazbahadir yilmazbahadir force-pushed the feature/multisig-account-modification branch from 2972581 to 009d108 Compare October 30, 2021 20:50
ready,
nodeAccount.name,
);
if (transactions[0] instanceof MultisigAccountModificationTransaction) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be better to use the transactionType instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why do you think so?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean you can use instanceof, but the SDK has already got a transactionType enum. could that be neat using the type?

ready,
nodeAccount.name,
);
}
} else {
await this.announceAggregateComplete(
Copy link
Collaborator

Choose a reason for hiding this comment

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

does the modifyMultisig tx needs to be announced as a bonded transaction? Using transactions.length might not always be safe. What if modifyMultisig is part of the transactions array? what about using array.filter?

target: BootstrapUtils.defaultTargetFolder,
useKnownRestGateways: false,
ready: false,
url: 'http://localhost:3000',
Copy link
Collaborator

Choose a reason for hiding this comment

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

default to hardcoded http?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes and default to localhost :)
Copied from: https://github.com/symbol/symbol-bootstrap/blob/56239efa3100116ea294c570ddab317160e0e00b/src/service/LinkService.ts#L77
I think it's fine for this PR, the node list loading logic will be changed after @fboucquez 's (soon to be raised) PR.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, it's fine, default url is when you are running the link/modify command on the same box that you have launched the node. Most people would either provide an --url or use --useKnownRestGateways

Copy link
Owner

@fboucquez fboucquez left a comment

Choose a reason for hiding this comment

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

Please also run npm run style:fix to update the index.ts and docs

I have done the following testing:

Multisig M, cosigners A,B,C , ServiceOperatorAccount S. It looks really nice:

  1. Convert to multisig M using M private key. It creates a bonded where All A,B,C need to cosign.
  2. Modify mutlisg M using A cosigner private key. It creates a bonded where some of B,C to cosign
  3. Convert to multisig M using S private key. It creates a bonded where all M, A, B, C need to cosign (wallet warning shown as expected)
  4. Modify multisig M using S private key. It creates a bonded where some A, B, C need to cosign (wallet warning shown as expected)

Could the command ask (optionally) for cosigners private keys. Use case, I'm a regular user that wants to convert my main account to multisig for security reasons. I could provide my cosigners private keys on the spot without bonded, using full aggregate complete. This could be an improvement though, the service providers should never know any cosigner private key.

char: 'a',
}),
addressAdditions: flags.string({
description: 'Cosignatory accounts addresses to be added (separated by a comma).',
Copy link
Owner

Choose a reason for hiding this comment

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

have you tried multiple: true, cli handles lists of strings. Does it work nicely?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, tried multiple addresses separated by comma, works fine 👍

Copy link
Owner

@fboucquez fboucquez Oct 31, 2021

Choose a reason for hiding this comment

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

I mean, oclif multiple: true field in the flags.string. It uses cli style multiple values

Copy link
Owner

@fboucquez fboucquez Oct 31, 2021

Choose a reason for hiding this comment

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

ignore, --addressAdditions A,B,C is easier than --addressAdditions A --addressAdditions B --addressAdditions C

does --addressAdditions (empty) work? empty list no prompt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so

ignore, --addressAdditions A,B,C is easier than --addressAdditions A --addressAdditions B --addressAdditions C

No it doesn't, it gives => No Error: Flag --addressAdditions expects a value

does --addressAdditions (empty) work? empty list no prompt.

If we need to support no-prompt command as well, I think we have 2 options here:

  1. Remove all the prompts, use only the flag values
  2. Add the following flags --no-addressAdditions, --no-addressDeletions
    and the command will look like
    symbol-bootstrap modifyMultisig --no-addressAdditions --no-addressDeletions --minApprovalDelta=1 --minRemovalDelta=0
    I'd probably vote for 2.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the code as it will not prompt for the following.
--addressAdditions='' --addressDeletions=''

target: BootstrapUtils.defaultTargetFolder,
useKnownRestGateways: false,
ready: false,
url: 'http://localhost:3000',
Copy link
Owner

Choose a reason for hiding this comment

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

Yes, it's fine, default url is when you are running the link/modify command on the same box that you have launched the node. Most people would either provide an --url or use --useKnownRestGateways

@yilmazbahadir
Copy link
Collaborator Author

Please also run npm run style:fix to update the index.ts and docs

I have done the following testing:

Multisig M, cosigners A,B,C , ServiceOperatorAccount S. It looks really nice:

  1. Convert to multisig M using M private key. It creates a bonded where All A,B,C need to cosign.
  2. Modify mutlisg M using A cosigner private key. It creates a bonded where some of B,C to cosign
  3. Convert to multisig M using S private key. It creates a bonded where all M, A, B, C need to cosign (wallet warning shown as expected)
  4. Modify multisig M using S private key. It creates a bonded where some A, B, C need to cosign (wallet warning shown as expected)

Could the command ask (optionally) for cosigners private keys. Use case, I'm a regular user that wants to convert my main account to multisig for security reasons. I could provide my cosigners private keys on the spot without bonded, using full aggregate complete. This could be an improvement though, the service providers should never know any cosigner private key.

Great! Will run the style:fix script. Let's implement this improvement with a different PR, created https://github.com/symbol/symbol-bootstrap/issues/308.
Currently writing some unit tests and also adding some parameter sanity checks, will be updating the PR shortly.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@fboucquez fboucquez merged commit 67287bc into dev Oct 31, 2021
@fboucquez fboucquez deleted the feature/multisig-account-modification branch October 31, 2021 21:24
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.

3 participants