-
Notifications
You must be signed in to change notification settings - Fork 56
fix(dashmate): local nodes missing envs after group reset #839
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c8aa7a5
fix(dashmate): generate contract keys after group reset
pshenmic 46ef622
Merge remote-tracking branch 'origin/v0.24-dev' into fix/dashmate-gro…
pshenmic 9413ccf
chore(dashmate): lint and bug fixes
pshenmic 95160bc
chore(dashmate): code review fixes
pshenmic 4e4080f
fix(dashmate): leave contract keys on group reset
pshenmic 9bea33d
fix(dashmate): print system contracts private keys
pshenmic 1cfac2e
fix(dashmate): revert generateSystemDataContractKeysTask
pshenmic 6c8f23e
chore(dashmate): revert script
pshenmic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
packages/dashmate/src/listr/tasks/setup/local/configureContractsPrivateKeysTaskFactory.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| const { Listr } = require('listr2'); | ||
|
|
||
| /** | ||
| * @param {generateHDPrivateKeys} generateHDPrivateKeys | ||
| * @return {configureTenderdashTask} | ||
| */ | ||
| function configureContractsPrivateKeysTaskFactory(generateHDPrivateKeys) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generateSystemDataContractKeysTask |
||
| /** | ||
| * @typedef {configureTenderdashTask} | ||
| * @return {Listr} | ||
| * @param config | ||
| * @param network | ||
| */ | ||
| function configureContractsPrivateKeysTask(config, network) { | ||
| return new Listr([ | ||
| { | ||
| task: async (ctx, task) => { | ||
| const { | ||
| hdPrivateKey: dpnsPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| dpnsDerivedMasterPrivateKey, | ||
| dpnsDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| const { | ||
| hdPrivateKey: featureFlagsPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| featureFlagsDerivedMasterPrivateKey, | ||
| featureFlagsDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| const { | ||
| hdPrivateKey: dashpayPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| dashpayDerivedMasterPrivateKey, | ||
| dashpayDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| const { | ||
| hdPrivateKey: masternodeRewardSharesPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| masternodeRewardSharesDerivedMasterPrivateKey, | ||
| masternodeRewardSharesDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| config.set('platform.dpns.masterPublicKey', dpnsDerivedMasterPrivateKey.privateKey.toPublicKey().toString()); | ||
| config.set('platform.dpns.secondPublicKey', dpnsDerivedSecondPrivateKey.privateKey.toPublicKey().toString()); | ||
|
|
||
| config.set('platform.featureFlags.masterPublicKey', featureFlagsDerivedMasterPrivateKey.privateKey.toPublicKey().toString()); | ||
| config.set('platform.featureFlags.secondPublicKey', featureFlagsDerivedSecondPrivateKey.privateKey.toPublicKey().toString()); | ||
|
|
||
| config.set('platform.dashpay.masterPublicKey', dashpayDerivedMasterPrivateKey.privateKey.toPublicKey().toString()); | ||
| config.set('platform.dashpay.secondPublicKey', dashpayDerivedSecondPrivateKey.privateKey.toPublicKey().toString()); | ||
|
|
||
| config.set('platform.masternodeRewardShares.masterPublicKey', | ||
| masternodeRewardSharesDerivedMasterPrivateKey.privateKey | ||
| .toPublicKey().toString()); | ||
| config.set('platform.masternodeRewardShares.secondPublicKey', | ||
| masternodeRewardSharesDerivedSecondPrivateKey.privateKey | ||
| .toPublicKey().toString()); | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `DPNS Private Key: ${dpnsPrivateKey.toString()}`; | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `Feature Flags Private Key: ${featureFlagsPrivateKey.toString()}`; | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `Dashpay Private Key: ${dashpayPrivateKey.toString()}`; | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `Masternode Reward Shares Private Key: ${masternodeRewardSharesPrivateKey.toString()}`; | ||
| }, | ||
| }, | ||
| ]); | ||
| } | ||
|
|
||
| return configureContractsPrivateKeysTask; | ||
| } | ||
|
|
||
| module.exports = configureContractsPrivateKeysTaskFactory; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ const { | |
| * @param {resolveDockerHostIp} resolveDockerHostIp | ||
| * @param {configFileRepository} configFileRepository | ||
| * @param {generateHDPrivateKeys} generateHDPrivateKeys | ||
| * @param {configureContractsPrivateKeysTask} configureContractsPrivateKeysTask | ||
| */ | ||
| function setupLocalPresetTaskFactory( | ||
| configFile, | ||
|
|
@@ -22,6 +23,7 @@ function setupLocalPresetTaskFactory( | |
| resolveDockerHostIp, | ||
| configFileRepository, | ||
| generateHDPrivateKeys, | ||
| configureContractsPrivateKeysTask, | ||
| ) { | ||
| /** | ||
| * @typedef {setupLocalPresetTask} | ||
|
|
@@ -82,7 +84,7 @@ function setupLocalPresetTaskFactory( | |
| }, | ||
| { | ||
| title: 'Create local group configs', | ||
| task: async (ctx, task) => { | ||
| task: async (ctx) => { | ||
| ctx.configGroup = new Array(ctx.nodeCount) | ||
| .fill(undefined) | ||
| .map((value, i) => `local_${i + 1}`) | ||
|
|
@@ -98,53 +100,10 @@ function setupLocalPresetTaskFactory( | |
|
|
||
| const network = ctx.configGroup[0].get('network'); | ||
|
|
||
| const { | ||
| hdPrivateKey: dpnsPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| dpnsDerivedMasterPrivateKey, | ||
| dpnsDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| const { | ||
| hdPrivateKey: featureFlagsPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| featureFlagsDerivedMasterPrivateKey, | ||
| featureFlagsDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| const { | ||
| hdPrivateKey: dashpayPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| dashpayDerivedMasterPrivateKey, | ||
| dashpayDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| const { | ||
| hdPrivateKey: masternodeRewardSharesPrivateKey, | ||
| derivedPrivateKeys: [ | ||
| masternodeRewardSharesDerivedMasterPrivateKey, | ||
| masternodeRewardSharesDerivedSecondPrivateKey, | ||
| ], | ||
| } = await generateHDPrivateKeys(network, [0, 1]); | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `DPNS Private Key: ${dpnsPrivateKey.toString()}`; | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `Feature Flags Private Key: ${featureFlagsPrivateKey.toString()}`; | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `Dashpay Private Key: ${dashpayPrivateKey.toString()}`; | ||
|
|
||
| // eslint-disable-next-line no-param-reassign | ||
| task.output = `Masternode Reward Shares Private Key: ${masternodeRewardSharesPrivateKey.toString()}`; | ||
|
|
||
| const subTasks = ctx.configGroup.map((config, i) => ( | ||
| { | ||
| title: `Create ${config.getName()} config`, | ||
| // eslint-disable-next-line consistent-return | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad idea |
||
| task: () => { | ||
| const nodeIndex = i + 1; | ||
|
|
||
|
|
@@ -203,24 +162,7 @@ function setupLocalPresetTaskFactory( | |
| config.set('platform.drive.abci.log.jsonFile.path', driveJsonLogFile); | ||
| } | ||
|
|
||
| config.set('platform.dpns.masterPublicKey', dpnsDerivedMasterPrivateKey.privateKey.toPublicKey().toString()); | ||
| config.set('platform.dpns.secondPublicKey', dpnsDerivedSecondPrivateKey.privateKey.toPublicKey().toString()); | ||
|
|
||
| config.set('platform.featureFlags.masterPublicKey', featureFlagsDerivedMasterPrivateKey.privateKey.toPublicKey().toString()); | ||
| config.set('platform.featureFlags.secondPublicKey', featureFlagsDerivedSecondPrivateKey.privateKey.toPublicKey().toString()); | ||
|
|
||
| config.set('platform.dashpay.masterPublicKey', dashpayDerivedMasterPrivateKey.privateKey.toPublicKey().toString()); | ||
| config.set('platform.dashpay.secondPublicKey', dashpayDerivedSecondPrivateKey.privateKey.toPublicKey().toString()); | ||
|
|
||
| config.set( | ||
| 'platform.masternodeRewardShares.masterPublicKey', | ||
| masternodeRewardSharesDerivedMasterPrivateKey.privateKey | ||
| .toPublicKey().toString(), | ||
| ); config.set( | ||
| 'platform.masternodeRewardShares.secondPublicKey', | ||
| masternodeRewardSharesDerivedSecondPrivateKey.privateKey | ||
| .toPublicKey().toString(), | ||
| ); | ||
| return configureContractsPrivateKeysTask(config, network); | ||
| } | ||
| }, | ||
| options: { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why so?