Skip to content

Commit c31dacb

Browse files
committed
revert: core setup for local network
1 parent 6a13415 commit c31dacb

File tree

1 file changed

+180
-33
lines changed

1 file changed

+180
-33
lines changed

packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js

Lines changed: 180 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -93,40 +93,9 @@ export default function configureCoreTaskFactory(
9393
},
9494
},
9595
{
96-
title: 'Create wallet',
97-
task: async () => {
98-
const disablePrivateKeys = false;
99-
const createBlankWallet = false;
100-
const walletPassphrase = '';
101-
const avoidReuse = false;
102-
const loadOnStartup = true;
103-
const descriptors = false;
104-
105-
await ctx.coreService.getRpcClient().createWallet(
106-
'main',
107-
disablePrivateKeys,
108-
createBlankWallet,
109-
walletPassphrase,
110-
avoidReuse,
111-
descriptors,
112-
loadOnStartup,
113-
);
114-
},
115-
},
116-
{
117-
title: 'Generating funds to use as a collateral for masternodes',
118-
task: () => {
119-
const amount = HPMN_COLLATERAL_AMOUNT * configGroup.length;
120-
return generateToAddressTask(
121-
configGroup.find((c) => c.getName() === 'local_seed'),
122-
amount,
123-
);
124-
},
125-
},
126-
{
127-
title: 'Activating forks',
96+
title: 'Activating DIP3',
12897
task: () => new Observable(async (observer) => {
129-
const dip3ActivationHeight = 901;
98+
const dip3ActivationHeight = 1000;
13099
const blocksToGenerateInOneStep = 10;
131100

132101
let blocksGenerated = 0;
@@ -157,6 +126,37 @@ export default function configureCoreTaskFactory(
157126
return this;
158127
}),
159128
},
129+
{
130+
title: 'Create wallet',
131+
task: async () => {
132+
const disablePrivateKeys = false;
133+
const createBlankWallet = false;
134+
const walletPassphrase = '';
135+
const avoidReuse = false;
136+
const loadOnStartup = true;
137+
const descriptors = false;
138+
139+
await ctx.coreService.getRpcClient().createWallet(
140+
'main',
141+
disablePrivateKeys,
142+
createBlankWallet,
143+
walletPassphrase,
144+
avoidReuse,
145+
descriptors,
146+
loadOnStartup,
147+
);
148+
},
149+
},
150+
{
151+
title: 'Generating funds to use as a collateral for masternodes',
152+
task: () => {
153+
const amount = HPMN_COLLATERAL_AMOUNT * configGroup.length;
154+
return generateToAddressTask(
155+
configGroup.find((c) => c.getName() === 'local_seed'),
156+
amount,
157+
);
158+
},
159+
},
160160
{
161161
title: 'Register masternodes',
162162
task: async () => {
@@ -276,6 +276,51 @@ export default function configureCoreTaskFactory(
276276
);
277277
},
278278
},
279+
{
280+
title: 'Wait for nodes to have the same sporks',
281+
task: () => waitForNodesToHaveTheSameSporks(ctx.coreServices),
282+
},
283+
{
284+
title: 'Activating DIP8 to enable ChainLocks',
285+
task: () => new Observable(async (observer) => {
286+
let isDip8Activated = false;
287+
let blockchainInfo;
288+
289+
let blocksGenerated = 0;
290+
291+
const blocksToGenerateInOneStep = 10;
292+
293+
do {
294+
({
295+
result: blockchainInfo,
296+
} = await ctx.seedCoreService.getRpcClient().getBlockchainInfo());
297+
298+
isDip8Activated = blockchainInfo.softforks.dip0008.active;
299+
300+
if (isDip8Activated) {
301+
break;
302+
}
303+
304+
await generateBlocks(
305+
ctx.seedCoreService,
306+
blocksToGenerateInOneStep,
307+
NETWORK_LOCAL,
308+
// eslint-disable-next-line no-loop-func
309+
(blocks) => {
310+
blocksGenerated += blocks;
311+
312+
observer.next(`${blocksGenerated} blocks generated`);
313+
},
314+
);
315+
} while (!isDip8Activated);
316+
317+
observer.next(`DIP8 has been activated at height ${blockchainInfo.softforks.dip0008.height}`);
318+
319+
observer.complete();
320+
321+
return this;
322+
}),
323+
},
279324
{
280325
title: 'Wait for nodes to have the same height',
281326
task: () => waitForNodesToHaveTheSameHeight(
@@ -302,6 +347,108 @@ export default function configureCoreTaskFactory(
302347
title: 'Wait for quorums to be enabled',
303348
task: () => enableCoreQuorumsTask(),
304349
},
350+
{
351+
title: 'Activating V20 fork',
352+
task: () => new Observable(async (observer) => {
353+
let isV20Activated = false;
354+
let blockchainInfo;
355+
356+
let blocksGenerated = 0;
357+
358+
const blocksToGenerateInOneStep = 10;
359+
360+
do {
361+
({
362+
result: blockchainInfo,
363+
} = await ctx.seedCoreService.getRpcClient().getBlockchainInfo());
364+
365+
isV20Activated = blockchainInfo.softforks && blockchainInfo.softforks.v20
366+
&& blockchainInfo.softforks.v20.active;
367+
if (isV20Activated) {
368+
break;
369+
}
370+
371+
await generateBlocks(
372+
ctx.seedCoreService,
373+
blocksToGenerateInOneStep,
374+
NETWORK_LOCAL,
375+
// eslint-disable-next-line no-loop-func
376+
(blocks) => {
377+
blocksGenerated += blocks;
378+
379+
observer.next(`${blocksGenerated} blocks generated`);
380+
},
381+
);
382+
} while (!isV20Activated);
383+
384+
observer.next(`V20 fork has been activated at height ${blockchainInfo.softforks.v20.height}`);
385+
386+
observer.complete();
387+
388+
return this;
389+
}),
390+
},
391+
{
392+
title: 'Wait for nodes to have the same height',
393+
task: () => waitForNodesToHaveTheSameHeight(
394+
ctx.rpcClients,
395+
WAIT_FOR_NODES_TIMEOUT,
396+
),
397+
},
398+
{
399+
title: 'Enable EHF spork',
400+
task: async () => new Observable(async (observer) => {
401+
const seedRpcClient = ctx.seedCoreService.getRpcClient();
402+
const {
403+
result: initialCoreChainLockedHeight,
404+
} = await seedRpcClient.getBlockCount();
405+
406+
await activateCoreSpork(
407+
seedRpcClient,
408+
'SPORK_24_TEST_EHF',
409+
initialCoreChainLockedHeight,
410+
);
411+
412+
let isEhfActivated = false;
413+
let blockchainInfo;
414+
415+
let blocksGenerated = 0;
416+
417+
const blocksToGenerateInOneStep = 48;
418+
419+
do {
420+
({
421+
result: blockchainInfo,
422+
} = await ctx.seedCoreService.getRpcClient().getBlockchainInfo());
423+
424+
isEhfActivated = blockchainInfo.softforks && blockchainInfo.softforks.mn_rr
425+
&& blockchainInfo.softforks.mn_rr.active;
426+
if (isEhfActivated) {
427+
break;
428+
}
429+
430+
await ctx.bumpMockTime(blocksToGenerateInOneStep);
431+
432+
await generateBlocks(
433+
ctx.seedCoreService,
434+
blocksToGenerateInOneStep,
435+
NETWORK_LOCAL,
436+
// eslint-disable-next-line no-loop-func
437+
(blocks) => {
438+
blocksGenerated += blocks;
439+
440+
observer.next(`${blocksGenerated} blocks generated`);
441+
},
442+
);
443+
} while (!isEhfActivated);
444+
445+
observer.next(`EHF has been activated at height ${blockchainInfo.softforks.mn_rr.height}`);
446+
447+
observer.complete();
448+
449+
return this;
450+
}),
451+
},
305452
{
306453
title: 'Wait for nodes to have the same height',
307454
task: () => waitForNodesToHaveTheSameHeight(

0 commit comments

Comments
 (0)