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(dashmate): single node local network [WIP] #2392

Open
wants to merge 11 commits into
base: v1.8-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
24 changes: 12 additions & 12 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/fsevents-patch-19706e7e35-10.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bench-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": ""
},
"dependencies": {
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "github:dashpay/dashcore-lib#feat/add-quourm-111",
"@dashevo/dpns-contract": "workspace:*",
"@dashevo/wallet-lib": "workspace:*",
"@dashevo/wasm-dpp": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/dapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@dashevo/bls": "~1.2.9",
"@dashevo/dapi-grpc": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "github:dashpay/dashcore-lib#feat/add-quourm-111",
"@dashevo/dashd-rpc": "^19.0.0",
"@dashevo/grpc-common": "workspace:*",
"@dashevo/wasm-dpp": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/dash-spv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@dashevo/dark-gravity-wave": "^1.1.1",
"@dashevo/dash-util": "^2.0.3",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "github:dashpay/dashcore-lib#feat/add-quourm-111",
"levelup": "^4.4.0",
"memdown": "^5.1.0",
"wasm-x11-hash": "~0.0.2"
Expand Down
4 changes: 2 additions & 2 deletions 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:22',
image: 'dashpay/dashd:22.1.0-devpr6437.f0e7eb57',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review usage of development Docker image.

Using a development PR version (22.1.0-devpr6437.f0e7eb57) of the Core image in base configuration could introduce instability.

Consider:

  1. Using a stable release version
  2. If dev features are required, document the specific features needed from this PR

commandArgs: [],
},
p2p: {
Expand Down Expand Up @@ -310,7 +310,7 @@ export default function getBaseConfigFactory() {
tenderdash: {
mode: 'full',
docker: {
image: 'dashpay/tenderdash:1',
image: 'dashpay/tenderdash:feat-support-quorum-111',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid using feature branch Docker image in production.

Using a feature branch (feat-support-quorum-111) for the Tenderdash image is not recommended for production environments as it:

  1. May contain unstable code
  2. Could be rebased or deleted
  3. Makes deployments non-reproducible

Consider using a stable, tagged release version instead.

},
p2p: {
host: '0.0.0.0',
Expand Down
6 changes: 3 additions & 3 deletions packages/dashmate/configs/defaults/getLocalConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ export default function getLocalConfigFactory(getBaseConfig) {
epochTime: 1200,
validatorSet: {
quorum: {
llmqType: 106,
llmqType: 111,
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace magic number with constant from constants.js

The hardcoded value 111 should use the QUORUM_TYPES.LLMQ_TYPE_1 constant for better maintainability and type safety.

-                llmqType: 111,
+                llmqType: QUORUM_TYPES.LLMQ_TYPE_1,

Also applies to: 79-79, 87-87

dkgInterval: 24,
activeSigners: 2,
rotation: false,
},
},
chainLock: {
quorum: {
llmqType: 100,
llmqType: 111,
dkgInterval: 24,
activeSigners: 2,
rotation: false,
},
},
instantLock: {
quorum: {
llmqType: 104,
llmqType: 111,
dkgInterval: 24,
activeSigners: 2,
rotation: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"dependencies": {
"@dashevo/bls": "~1.2.9",
"@dashevo/dapi-client": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "github:dashpay/dashcore-lib#feat/add-quourm-111",
"@dashevo/dashd-rpc": "^19.0.0",
"@dashevo/docker-compose": "^0.24.4",
"@dashevo/wallet-lib": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/dashmate/src/commands/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default class SetupCommand extends BaseCommand {
dockerCompose,
defaultConfigs,
) {
if (nodeCount !== null && (nodeCount < 3)) {
throw new Error('node-count flag should be not less than 3');
if (nodeCount !== null && (nodeCount < 1)) {
throw new Error('node-count flag should be not less than 1');
}

const tasks = new Listr(
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/config/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default {
properties: {
llmqType: {
type: 'integer',
enum: [1, 2, 3, 4, 5, 6, 100, 101, 102, 103, 104, 105, 106, 107],
enum: [1, 2, 3, 4, 5, 6, 100, 101, 102, 103, 104, 105, 106, 107, 111],
},
dkgInterval: {
type: 'integer',
Expand Down
1 change: 1 addition & 0 deletions packages/dashmate/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const NODE_TYPE_FULLNODE = 'fullnode';

export const LLMQ_TYPE_TEST = 'llmq_test';
export const LLMQ_TYPE_TEST_PLATFORM = 'llmq_test_platform';
export const LLMQ_TYPE_1 = 'llmq_1_100';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add mapping for LLMQ_TYPE_1 in QUORUM_TYPES object

The new constant LLMQ_TYPE_1 is added but not mapped in the QUORUM_TYPES object, unlike other LLMQ types. This seems inconsistent with the value 111 used in the local config factory.

Add the mapping to maintain consistency:

 export const QUORUM_TYPES = {
   LLMQ_TYPE_TEST: 100,
   LLMQ_TYPE_TEST_PLATFORM: 106,
+  LLMQ_TYPE_1: 111,
 };

Committable suggestion skipped: line range outside the PR's diff.


export const QUORUM_TYPES = {
LLMQ_TYPE_TEST: 100,
Expand Down
6 changes: 4 additions & 2 deletions packages/dashmate/src/createDIContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ import configureCoreTaskFactory from './listr/tasks/setup/local/configureCoreTas
import configureTenderdashTaskFactory from './listr/tasks/setup/local/configureTenderdashTaskFactory.js';
import obtainSelfSignedCertificateTaskFactory from './listr/tasks/ssl/selfSigned/obtainSelfSignedCertificateTaskFactory.js';
import waitForNodeToBeReadyTaskFactory from './listr/tasks/platform/waitForNodeToBeReadyTaskFactory.js';
import enableCoreQuorumsTaskFactory from './listr/tasks/setup/local/enableCoreQuorumsTaskFactory.js';
import enableMultiCoreQuorumsTaskFactory from './listr/tasks/setup/local/enableMultiCoreQuorumsTaskFactory.js';
import enableSingleCoreQuorumTaskFactory from './listr/tasks/setup/local/enableSingleCoreQuorumTaskFactory.js';
import startGroupNodesTaskFactory from './listr/tasks/startGroupNodesTaskFactory.js';
import buildServicesTaskFactory from './listr/tasks/buildServicesTaskFactory.js';
import reindexNodeTaskFactory from './listr/tasks/reindexNodeTaskFactory.js';
Expand Down Expand Up @@ -300,7 +301,8 @@ export default async function createDIContainer(options = {}) {
configureCoreTask: asFunction(configureCoreTaskFactory).singleton(),
configureTenderdashTask: asFunction(configureTenderdashTaskFactory).singleton(),
waitForNodeToBeReadyTask: asFunction(waitForNodeToBeReadyTaskFactory).singleton(),
enableCoreQuorumsTask: asFunction(enableCoreQuorumsTaskFactory).singleton(),
enableMultiCoreQuorumsTask: asFunction(enableMultiCoreQuorumsTaskFactory).singleton(),
enableSingleCoreQuorumTask: asFunction(enableSingleCoreQuorumTaskFactory).singleton(),
registerMasternodeGuideTask: asFunction(registerMasternodeGuideTaskFactory).singleton(),
obtainZeroSSLCertificateTask: asFunction(obtainZeroSSLCertificateTaskFactory).singleton(),
cleanupZeroSSLCertificatesTask: asFunction(cleanupZeroSSLCertificatesTaskFactory).singleton(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const { PrivateKey } = DashCoreLib;
* @param {generateToAddressTask} generateToAddressTask
* @param {registerMasternodeTask} registerMasternodeTask
* @param {generateBlsKeys} generateBlsKeys
* @param {enableCoreQuorumsTask} enableCoreQuorumsTask
* @param {enableMultiCoreQuorumsTask} enableMultiCoreQuorumsTask
* @param {enableSingleCoreQuorumTask} enableSingleCoreQuorumTask
* @param {waitForMasternodesSync} waitForMasternodesSync
* @param {ConfigFile} configFile
* @return {configureCoreTask}
Expand All @@ -30,7 +31,8 @@ export default function configureCoreTaskFactory(
generateToAddressTask,
registerMasternodeTask,
generateBlsKeys,
enableCoreQuorumsTask,
enableMultiCoreQuorumsTask,
enableSingleCoreQuorumTask,
waitForMasternodesSync,
configFile,
) {
Expand Down Expand Up @@ -115,7 +117,8 @@ export default function configureCoreTaskFactory(
{
title: 'Generating funds to use as a collateral for masternodes',
task: () => {
const amount = HPMN_COLLATERAL_AMOUNT * configGroup.length;
// Generate for evnodes (- a seed node) + some cash for fees
const amount = HPMN_COLLATERAL_AMOUNT * (configGroup.length - 1) + 100;
return generateToAddressTask(
configGroup.find((c) => c.getName() === 'local_seed'),
amount,
Expand All @@ -125,7 +128,7 @@ export default function configureCoreTaskFactory(
{
title: 'Activating v19 and v20',
task: () => new Observable(async (observer) => {
const dip3ActivationHeight = 901;
const activationHeight = 901;
const blocksToGenerateInOneStep = 10;

let blocksGenerated = 0;
Expand All @@ -149,7 +152,7 @@ export default function configureCoreTaskFactory(
observer.next(`${blocksGenerated} blocks generated`);
},
);
} while (dip3ActivationHeight > currentBlockHeight);
} while (activationHeight > currentBlockHeight);

observer.complete();

Expand Down Expand Up @@ -235,6 +238,7 @@ export default function configureCoreTaskFactory(
{
title: 'Set initial mock time',
task: async () => {
// TODO: We want to get rid of mock time
// Set initial mock time from the last block
const { result: bestBlockHash } = await ctx.seedRpcClient.getBestBlockHash();
const { result: bestBlock } = await ctx.seedRpcClient.getBlock(bestBlockHash);
Expand Down Expand Up @@ -297,9 +301,15 @@ export default function configureCoreTaskFactory(
}
},
},
{
title: 'Wait for quorum to be enabled',
enabled: configGroup.length - 1 === 1,
task: () => enableSingleCoreQuorumTask(),
},
{
title: 'Wait for quorums to be enabled',
task: () => enableCoreQuorumsTask(),
enabled: configGroup.length - 1 > 1,
task: () => enableMultiCoreQuorumsTask(),
},
{
title: 'Wait for nodes to have the same height',
Expand All @@ -311,7 +321,10 @@ export default function configureCoreTaskFactory(
{
title: 'Activating v21 fork',
task: () => new Observable(async (observer) => {
const dip3ActivationHeight = 1001;
// Drive expect all quorums available when we activate mn_rr (activation of
// Evolution)
// We activate v21 at block 1000 when we expect all quorums already formed
const activationHeight = 1001;
const blocksToGenerateInOneStep = 10;

let blocksGenerated = 0;
Expand All @@ -335,7 +348,7 @@ export default function configureCoreTaskFactory(
observer.next(`${blocksGenerated} blocks generated`);
},
);
} while (dip3ActivationHeight > currentBlockHeight);
} while (activationHeight > currentBlockHeight);

observer.complete();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ import waitForMasternodeProbes from '../../../../core/quorum/waitForMasternodePr
* @param {generateBlocks} generateBlocks
* @return {enableCoreQuorumsTask}
*/
export default function enableCoreQuorumsTaskFactory(generateBlocks) {
export default function enableMultiCoreQuorumsTaskFactory(generateBlocks) {
/**
* @typedef {enableCoreQuorumsTask}
* @return {Listr}
*/
function enableCoreQuorumsTask() {
function enableMultiCoreQuorumsTask() {
const WAIT_FOR_NODES_TIMEOUT = 60 * 5 * 1000;

return new Listr([
{
task: (ctx) => {
// Those are default values for the quorum size 3 with all nodes
// behaving correctly with "llmq_test" quorum
ctx.expectedMembers = 3;
ctx.expectedCommitments = 3;
ctx.expectedConnections = 2;

ctx.expectedContributions = 3;
ctx.expectedJustifications = 0;
ctx.expectedComplaints = 0;

ctx.masternodeCoreServices = ctx.coreServices
.filter((coreService) => coreService.getConfig().getName() !== 'local_seed');

ctx.masternodeRpcClients = ctx.masternodeCoreServices
.map((coreService) => coreService.getRpcClient());

// Those are default values for the quorum size 3 with all nodes
// behaving correctly with "llmq_test" quorum
ctx.expectedMembers = Math.min(ctx.masternodeCoreServices.length, 3);
ctx.expectedCommitments = Math.min(ctx.masternodeCoreServices.length, 3);
ctx.expectedConnections = Math.min(ctx.masternodeCoreServices.length, 3) - 1;

ctx.expectedContributions = Math.min(ctx.masternodeCoreServices.length, 3);
ctx.expectedJustifications = 0;
ctx.expectedComplaints = 0;
},
},
{
Expand Down Expand Up @@ -292,5 +292,5 @@ export default function enableCoreQuorumsTaskFactory(generateBlocks) {
]);
}

return enableCoreQuorumsTask;
return enableMultiCoreQuorumsTask;
}
Loading
Loading