From c31dacbee2025c5994de5276d75a7c6163221efe Mon Sep 17 00:00:00 2001 From: ivanshumkov Date: Wed, 27 Nov 2024 16:47:33 +0700 Subject: [PATCH] revert: core setup for local network --- .../setup/local/configureCoreTaskFactory.js | 213 +++++++++++++++--- 1 file changed, 180 insertions(+), 33 deletions(-) diff --git a/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js b/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js index 920038d8779..d059e9c8606 100644 --- a/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js @@ -93,40 +93,9 @@ export default function configureCoreTaskFactory( }, }, { - title: 'Create wallet', - task: async () => { - const disablePrivateKeys = false; - const createBlankWallet = false; - const walletPassphrase = ''; - const avoidReuse = false; - const loadOnStartup = true; - const descriptors = false; - - await ctx.coreService.getRpcClient().createWallet( - 'main', - disablePrivateKeys, - createBlankWallet, - walletPassphrase, - avoidReuse, - descriptors, - loadOnStartup, - ); - }, - }, - { - title: 'Generating funds to use as a collateral for masternodes', - task: () => { - const amount = HPMN_COLLATERAL_AMOUNT * configGroup.length; - return generateToAddressTask( - configGroup.find((c) => c.getName() === 'local_seed'), - amount, - ); - }, - }, - { - title: 'Activating forks', + title: 'Activating DIP3', task: () => new Observable(async (observer) => { - const dip3ActivationHeight = 901; + const dip3ActivationHeight = 1000; const blocksToGenerateInOneStep = 10; let blocksGenerated = 0; @@ -157,6 +126,37 @@ export default function configureCoreTaskFactory( return this; }), }, + { + title: 'Create wallet', + task: async () => { + const disablePrivateKeys = false; + const createBlankWallet = false; + const walletPassphrase = ''; + const avoidReuse = false; + const loadOnStartup = true; + const descriptors = false; + + await ctx.coreService.getRpcClient().createWallet( + 'main', + disablePrivateKeys, + createBlankWallet, + walletPassphrase, + avoidReuse, + descriptors, + loadOnStartup, + ); + }, + }, + { + title: 'Generating funds to use as a collateral for masternodes', + task: () => { + const amount = HPMN_COLLATERAL_AMOUNT * configGroup.length; + return generateToAddressTask( + configGroup.find((c) => c.getName() === 'local_seed'), + amount, + ); + }, + }, { title: 'Register masternodes', task: async () => { @@ -276,6 +276,51 @@ export default function configureCoreTaskFactory( ); }, }, + { + title: 'Wait for nodes to have the same sporks', + task: () => waitForNodesToHaveTheSameSporks(ctx.coreServices), + }, + { + title: 'Activating DIP8 to enable ChainLocks', + task: () => new Observable(async (observer) => { + let isDip8Activated = false; + let blockchainInfo; + + let blocksGenerated = 0; + + const blocksToGenerateInOneStep = 10; + + do { + ({ + result: blockchainInfo, + } = await ctx.seedCoreService.getRpcClient().getBlockchainInfo()); + + isDip8Activated = blockchainInfo.softforks.dip0008.active; + + if (isDip8Activated) { + break; + } + + await generateBlocks( + ctx.seedCoreService, + blocksToGenerateInOneStep, + NETWORK_LOCAL, + // eslint-disable-next-line no-loop-func + (blocks) => { + blocksGenerated += blocks; + + observer.next(`${blocksGenerated} blocks generated`); + }, + ); + } while (!isDip8Activated); + + observer.next(`DIP8 has been activated at height ${blockchainInfo.softforks.dip0008.height}`); + + observer.complete(); + + return this; + }), + }, { title: 'Wait for nodes to have the same height', task: () => waitForNodesToHaveTheSameHeight( @@ -302,6 +347,108 @@ export default function configureCoreTaskFactory( title: 'Wait for quorums to be enabled', task: () => enableCoreQuorumsTask(), }, + { + title: 'Activating V20 fork', + task: () => new Observable(async (observer) => { + let isV20Activated = false; + let blockchainInfo; + + let blocksGenerated = 0; + + const blocksToGenerateInOneStep = 10; + + do { + ({ + result: blockchainInfo, + } = await ctx.seedCoreService.getRpcClient().getBlockchainInfo()); + + isV20Activated = blockchainInfo.softforks && blockchainInfo.softforks.v20 + && blockchainInfo.softforks.v20.active; + if (isV20Activated) { + break; + } + + await generateBlocks( + ctx.seedCoreService, + blocksToGenerateInOneStep, + NETWORK_LOCAL, + // eslint-disable-next-line no-loop-func + (blocks) => { + blocksGenerated += blocks; + + observer.next(`${blocksGenerated} blocks generated`); + }, + ); + } while (!isV20Activated); + + observer.next(`V20 fork has been activated at height ${blockchainInfo.softforks.v20.height}`); + + observer.complete(); + + return this; + }), + }, + { + title: 'Wait for nodes to have the same height', + task: () => waitForNodesToHaveTheSameHeight( + ctx.rpcClients, + WAIT_FOR_NODES_TIMEOUT, + ), + }, + { + title: 'Enable EHF spork', + task: async () => new Observable(async (observer) => { + const seedRpcClient = ctx.seedCoreService.getRpcClient(); + const { + result: initialCoreChainLockedHeight, + } = await seedRpcClient.getBlockCount(); + + await activateCoreSpork( + seedRpcClient, + 'SPORK_24_TEST_EHF', + initialCoreChainLockedHeight, + ); + + let isEhfActivated = false; + let blockchainInfo; + + let blocksGenerated = 0; + + const blocksToGenerateInOneStep = 48; + + do { + ({ + result: blockchainInfo, + } = await ctx.seedCoreService.getRpcClient().getBlockchainInfo()); + + isEhfActivated = blockchainInfo.softforks && blockchainInfo.softforks.mn_rr + && blockchainInfo.softforks.mn_rr.active; + if (isEhfActivated) { + break; + } + + await ctx.bumpMockTime(blocksToGenerateInOneStep); + + await generateBlocks( + ctx.seedCoreService, + blocksToGenerateInOneStep, + NETWORK_LOCAL, + // eslint-disable-next-line no-loop-func + (blocks) => { + blocksGenerated += blocks; + + observer.next(`${blocksGenerated} blocks generated`); + }, + ); + } while (!isEhfActivated); + + observer.next(`EHF has been activated at height ${blockchainInfo.softforks.mn_rr.height}`); + + observer.complete(); + + return this; + }), + }, { title: 'Wait for nodes to have the same height', task: () => waitForNodesToHaveTheSameHeight(