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

chore(dashmate)!: update Core to version 22 #2384

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function getBaseConfigFactory() {
port: 3001,
},
docker: {
image: 'dashpay/dashd:21',
image: 'dashpay/dashd:22',
commandArgs: [],
},
p2p: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
'1.7.0': (configFile) => {
Object.entries(configFile.configs)
.forEach(([, options]) => {
options.core.docker.image = 'dashpay/dashd:22';
options.platform.drive.tenderdash.docker.image = 'dashpay/tenderdash:1';
});
return configFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Listr } from 'listr2';
import { Observable } from 'rxjs';
import DashCoreLib from '@dashevo/dashcore-lib';
import waitForNodesToHaveTheSameHeight from '../../../../core/waitForNodesToHaveTheSameHeight.js';
import waitForNodesToHaveTheSameSporks from '../../../../core/waitForNodesToHaveTheSameSporks.js';

import { NETWORK_LOCAL, HPMN_COLLATERAL_AMOUNT } from '../../../../constants.js';

Expand Down Expand Up @@ -93,9 +92,40 @@ export default function configureCoreTaskFactory(
},
},
{
title: 'Activating DIP3',
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 v19 and v20',
task: () => new Observable(async (observer) => {
const dip3ActivationHeight = 1000;
const dip3ActivationHeight = 901;
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 13, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the search results, I can now provide a final response as we have clear evidence about the activation heights in the code.

The activation heights in the code are incorrect

The code shows two different activation heights:

  • DIP3 activation height is set to 901 for v19/v20 activation
  • DIP3 activation height is set to 1001 for v21 fork activation

This appears to be inconsistent as it sets two different DIP3 activation heights. Additionally, from the configuration template found earlier (packages/dashmate/templates/core/dash.conf.dot), we see that the testnet activation height for mn_rr is set to 1000, which suggests these values need to be aligned.

🔗 Analysis chain

Verify activation heights for Core v22

Please verify that the activation heights (901 for DIP3 and 1001 for v21) are correct for Core v22. These values seem to have changed from previous versions.

Also applies to: 314-314


Let me analyze the search results. I notice that the code in configureCoreTaskFactory.js shows different activation heights than what's in the review comment. Let me verify this further by searching for more specific context around these values.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for activation height references in Core v22 codebase
# Expected: Find references to activation heights in Core v22 configuration or documentation

# Search for activation height references
rg -A 2 "activation.*height|height.*activation" 

# Search for DIP3 and v21 specific configurations
rg -A 2 "DIP0003|v21.*fork"

Length of output: 9401


Script:

#!/bin/bash
# Search for specific context around activation heights in configureCoreTaskFactory.js
rg -A 5 -B 5 "dip3ActivationHeight|v21.*fork" packages/dashmate/src/listr/tasks/setup/local/configureCoreTaskFactory.js

# Also search for any configuration or documentation files that might contain these values
fd -e md -e txt -e conf -e yaml -e json | xargs rg "DIP3.*height|v21.*height|activation.*height"

Length of output: 1689

Copy link
Member Author

Choose a reason for hiding this comment

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

This code will be changed soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

@shumkov, understood. Thank you for the update.

const blocksToGenerateInOneStep = 10;

let blocksGenerated = 0;
Expand Down Expand Up @@ -126,37 +156,6 @@ 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 () => {
Expand Down Expand Up @@ -276,51 +275,6 @@ 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(
Expand All @@ -347,47 +301,6 @@ 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(
Expand All @@ -396,41 +309,23 @@ export default function configureCoreTaskFactory(
),
},
{
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;
title: 'Activating v21 fork',
task: () => new Observable(async (observer) => {
const dip3ActivationHeight = 1001;
const blocksToGenerateInOneStep = 10;

let blocksGenerated = 0;

const blocksToGenerateInOneStep = 48;
let {
result: currentBlockHeight,
} = await ctx.coreService.getRpcClient().getBlockCount();

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);
result: currentBlockHeight,
} = await ctx.coreService.getRpcClient().getBlockCount());

await generateBlocks(
ctx.seedCoreService,
ctx.coreService,
blocksToGenerateInOneStep,
NETWORK_LOCAL,
// eslint-disable-next-line no-loop-func
Expand All @@ -440,9 +335,7 @@ export default function configureCoreTaskFactory(
observer.next(`${blocksGenerated} blocks generated`);
},
);
} while (!isEhfActivated);

observer.next(`EHF has been activated at height ${blockchainInfo.softforks.mn_rr.height}`);
} while (dip3ActivationHeight > currentBlockHeight);

observer.complete();

Expand Down
7 changes: 1 addition & 6 deletions packages/dashmate/src/status/scopes/platform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import prettyMs from 'pretty-ms';
import { PortStateEnum } from '../enums/portState.js';
import DockerComposeError from '../../docker/errors/DockerComposeError.js';
import providers from '../providers.js';
Expand Down Expand Up @@ -314,11 +313,7 @@ export default function getPlatformScopeFactory(
if (mnRRSoftFork.active) {
scope.platformActivation = `Activated (at height ${mnRRSoftFork.height})`;
} else {
const startTime = mnRRSoftFork.bip9.start_time;

const diff = (new Date().getTime() - startTime) / 1000;

scope.platformActivation = `Waiting for activation (approximately in ${prettyMs(diff, { compact: true })})`;
scope.platformActivation = `Waiting for activation on height ${mnRRSoftFork.height}`;
}

const [tenderdash, drive] = await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/templates/core/dash.conf.dot
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ debuglogfile=/var/log/dash/debug.log
# JSON RPC
server=1
rpcwallet=main
deprecatedrpc=hpmn
rpcworkqueue=64
rpcthreads=16
rpcwhitelistdefault=0
Expand Down Expand Up @@ -93,6 +92,7 @@ fallbackfee=0.00001
{{?? it.network === 'local'}}
regtest=1
[regtest]
testactivationheight=mn_rr@1000
{{? it.core.spork.address}}sporkaddr={{=it.core.spork.address}}{{?}}
{{? it.core.spork.privateKey}}sporkkey={{=it.core.spork.privateKey}}{{?}}
{{? it.core.miner.mediantime}}mocktime={{=it.core.miner.mediantime}}{{?}}
Expand Down
Loading