Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7df3235
feat(dashmate): expose drive port
pshenmic Jan 5, 2023
7babd7b
Merge remote-tracking branch 'origin/v0.24-dev' into feat/dashmate-te…
pshenmic Jan 10, 2023
ba5728d
chore(dashmate): flip hard reset condition
pshenmic Jan 10, 2023
c88cba2
chore(dashmate): add silent error example
pshenmic Jan 10, 2023
e46bbe5
chore(dashmate): add silent error example
pshenmic Jan 10, 2023
e4de496
chore(dashmate): cleanup
pshenmic Jan 10, 2023
5c659ff
chore(dashmate): switch to return
pshenmic Jan 10, 2023
05d1154
chore(dashmate): return back switch and reset for devnets
pshenmic Jan 11, 2023
47e2b0a
chore(dashmate): fix
pshenmic Jan 11, 2023
8eaca6c
chore(dashmate): change comparison
pshenmic Jan 11, 2023
dfd93df
chore(dashmate): change back
pshenmic Jan 11, 2023
f046d67
chore(dashmate): debug
pshenmic Jan 11, 2023
569c51b
chore(dashmate): change back to constant
pshenmic Jan 11, 2023
b6f6c7e
chore(dashmate): silent error
pshenmic Jan 11, 2023
874df84
chore(dashmate): revert silent errors
pshenmic Jan 11, 2023
efa1f9a
chore(dashmate): revert some things
pshenmic Jan 17, 2023
22ea8f3
chore(dashmate): implement drive status with echo
pshenmic Jan 17, 2023
094b3ba
chore(dashmate): disable with arrow function
pshenmic Jan 18, 2023
2bb53e0
chore(dashmate): use locally built image of dashmate helper
pshenmic Jan 19, 2023
2bb5d53
chore(dashmate): use prebuilt docker image
pshenmic Jan 19, 2023
febeb98
feat(dashmate): add few more fields to the status platform
pshenmic Jan 20, 2023
e365dcb
fix(dashmate): add missing spaces
pshenmic Jan 20, 2023
9dc4ff7
fix(dashmate): forgot to remove
pshenmic Jan 20, 2023
aa9b9c7
fix(dashmate): add parseInt for peers
pshenmic Jan 20, 2023
8bbe4a8
fix(dashmate): lint fixes
pshenmic Jan 20, 2023
da54eb2
fix(dashmate): add getConnectionHost for the rest of the commands
pshenmic Jan 20, 2023
0a9b603
fix(dashmate): revert image for dashmate_helper
pshenmic Jan 20, 2023
c5f440b
feat(dashmate): disable initialize tenderdash in regular preset task
pshenmic Jan 20, 2023
95e0c07
chore(dashmate): cleanup
pshenmic Jan 23, 2023
9d78278
test(dashmate): fix platform scope spec
pshenmic Jan 23, 2023
4804da9
chore(dashmate): fix lint
pshenmic Jan 24, 2023
2b685c1
chore(js-drive): fix lint
pshenmic Jan 24, 2023
a514f5b
feat(dashmate): code review fixes
pshenmic Jan 24, 2023
cd50199
feat(dashmate): get back tenderdash iit
pshenmic Jan 24, 2023
cd39888
Merge branch 'v0.24-dev' into feat/dashmate-working-branch
pshenmic Jan 24, 2023
45e27f7
chore(dashmate): fix lint
pshenmic Jan 24, 2023
0a0b80d
test(dashmate): fix tests
pshenmic Jan 24, 2023
0f7e04d
chore(dashmate): add default null for moniker
pshenmic Jan 24, 2023
6f4e6ca
chore(dashmate): code review fixes
pshenmic Jan 24, 2023
d361b2a
chore(dashmate): fix migrations
pshenmic Jan 24, 2023
09f6fa0
chore(dashmate): fix linting stuff
pshenmic Jan 24, 2023
dc25c07
Merge remote-tracking branch 'origin/v0.24-dev' into feat/dashmate-wo…
pshenmic Jan 25, 2023
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
3 changes: 2 additions & 1 deletion packages/dashmate/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ FROM node:16-alpine3.16

ARG NODE_ENV=production
ENV NODE_ENV ${NODE_ENV}
ENV DASHMATE_HELPER=1

RUN apk update && \
apk --no-cache upgrade && \
apk add --no-cache docker-cli
apk add --no-cache docker-cli docker-cli-compose

LABEL maintainer="Dash Developers <dev@dash.org>"
LABEL description="Dashmate Helper Node.JS"
Expand Down
14 changes: 14 additions & 0 deletions packages/dashmate/configs/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,18 @@ module.exports = {

return configFile;
},
'0.24.0-dev.13': (configFile) => {
Object.entries(configFile.configs)
.forEach(([, config]) => {
if (config.platform) {
if (config.group === 'local') {
config.platform.drive.tenderdash.moniker = config.name;
} else {
config.platform.drive.tenderdash.moniker = null;
}
}
});

return configFile;
},
};
6 changes: 5 additions & 1 deletion packages/dashmate/configs/schema/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,18 @@ module.exports = {
nodeKey: {
type: 'object',
},
moniker: {
type: ['string', 'null'],
},
genesis: {
type: 'object',
},
nodeId: {
type: ['string', 'null'],
},
},
required: ['docker', 'p2p', 'rpc', 'consensus', 'nodeKey', 'genesis', 'nodeId'],
required: ['docker', 'p2p', 'rpc', 'consensus',
'nodeKey', 'moniker', 'genesis', 'nodeId'],
additionalProperties: false,
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/dashmate/configs/system/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ module.exports = {

},
nodeId: null,
moniker: null,
},
},
dpns: {
Expand Down
97 changes: 55 additions & 42 deletions packages/dashmate/src/commands/status/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,51 +43,64 @@ class PlatformStatusCommand extends ConfigBaseCommand {
throw new Error('Platform status is not available until core sync is complete!');
}

const {
httpService,
httpPort,
httpPortState,
gRPCService,
gRPCPort,
gRPCPortState,
p2pService,
p2pPort,
p2pPortState,
rpcService,
tenderdash,
} = scope;

const plain = {
'HTTP service': httpService,
'HTTP port': `${httpPort} ${colors.portState(httpPortState)(httpPortState)}`,
'GRPC service': gRPCService,
'GRPC port': `${gRPCPort} ${colors.portState(gRPCPortState)(gRPCPortState)}`,
'P2P service': p2pService,
'P2P port': `${p2pPort} ${colors.portState(p2pPortState)(p2pPortState)}`,
'RPC service': rpcService,
};

if (tenderdash.version) {
if (flags.format === OUTPUT_FORMATS.PLAIN) {
const {
dockerStatus,
serviceStatus,
version: tenderdashVersion,
lastBlockHeight: platformBlockHeight,
latestAppHash: platformLatestAppHash,
peers: platformPeers,
network: tenderdashNetwork,
} = tenderdash;

plain['Docker Status'] = dockerStatus;
plain['Service Status'] = colors.status(serviceStatus)(serviceStatus);
plain['Network'] = tenderdashNetwork;
plain['Tenderdash Version'] = tenderdashVersion;
plain['Block height'] = platformBlockHeight;
plain['Peer count'] = platformPeers;
plain['App hash'] = platformLatestAppHash;
httpService,
httpPort,
httpPortState,
gRPCService,
gRPCPort,
gRPCPortState,
p2pService,
p2pPort,
p2pPortState,
rpcService,
tenderdash,
drive,
} = scope;

const plain = {
'HTTP service': httpService,
'HTTP port': `${httpPort} ${colors.portState(httpPortState)(httpPortState)}`,
'GRPC service': gRPCService,
'GRPC port': `${gRPCPort} ${colors.portState(gRPCPortState)(gRPCPortState)}`,
'P2P service': p2pService,
'P2P port': `${p2pPort} ${colors.portState(p2pPortState)(p2pPortState)}`,
'RPC service': rpcService,
};

const { dockerStatus: tenderdashDockerStatus } = tenderdash;
const { serviceStatus: tenderdashServiceStatus } = tenderdash;

const { dockerStatus: driveDockerStatus } = drive;
const { serviceStatus: driveServiceStatus } = drive;

plain['Tenderdash Docker Status'] = colors.docker(tenderdashDockerStatus)(tenderdashDockerStatus);
plain['Tenderdash Service Status'] = colors.status(tenderdashServiceStatus)(tenderdashServiceStatus);

plain['Drive Docker Status'] = colors.docker(driveDockerStatus)(driveDockerStatus);
plain['Drive Service Status'] = colors.status(driveServiceStatus)(driveServiceStatus);

if (tenderdash.version) {
const {
version: tenderdashVersion,
lastBlockHeight: platformBlockHeight,
latestAppHash: platformLatestAppHash,
peers: platformPeers,
network: tenderdashNetwork,
} = tenderdash;

plain['Network'] = tenderdashNetwork;
plain['Tenderdash Version'] = tenderdashVersion;
plain['Block height'] = platformBlockHeight;
plain['Peer count'] = platformPeers;
plain['App hash'] = platformLatestAppHash;
}

return printObject(plain, flags.format);
}

return printObject(plain, flags.format);
return printObject(scope, flags.format);
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/dashmate/src/core/startCoreFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ const CoreService = require('./CoreService');
* @param {waitForCoreStart} waitForCoreStart
* @param {waitForCoreSync} waitForCoreSync
* @param {DockerCompose} dockerCompose
* @param {getConnectionHost} getConnectionHost
* @return {startCore}
*/
function startCoreFactory(
createRpcClient,
waitForCoreStart,
waitForCoreSync,
dockerCompose,
getConnectionHost,
) {
/**
* @typedef startCore
Expand Down Expand Up @@ -70,6 +72,7 @@ function startCoreFactory(
port: config.get('core.rpc.port'),
user: config.get('core.rpc.user'),
pass: config.get('core.rpc.password'),
host: await getConnectionHost(config, 'core'),
},
);

Expand Down
3 changes: 3 additions & 0 deletions packages/dashmate/src/createDIContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
const Docker = require('dockerode');

const ensureHomeDirFactory = require('./ensureHomeDirFactory');
const getConnectionHostFactory = require('./getConnectionHostFactory');
const ConfigFileJsonRepository = require('./config/configFile/ConfigFileJsonRepository');
const createSystemConfigsFactory = require('./config/systemConfigs/createSystemConfigsFactory');
const isSystemConfigFactory = require('./config/systemConfigs/isSystemConfigFactory');
Expand Down Expand Up @@ -106,6 +107,8 @@ async function createDIContainer() {
createSystemConfigs: asFunction(createSystemConfigsFactory).singleton(),
isSystemConfig: asFunction(isSystemConfigFactory).singleton(),
migrateConfigFile: asValue(migrateConfigFile),
isHelper: asValue(process.env.DASHMATE_HELPER === '1'),
getConnectionHost: asClass(getConnectionHostFactory).singleton(),
// `configFile` and `config` are registering on command init
});

Expand Down
16 changes: 16 additions & 0 deletions packages/dashmate/src/docker/DockerCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,22 @@ class DockerCompose {
env,
};
}

/**
* Resolve container internal IP
*
* @param {Object} envs
* @param {string} serviceName
* @return {Promise<string>}
*/
async getContainerIp(envs, serviceName) {
const containerInfo = await this.inspectService(envs, serviceName);

const [firstNetwork] = Object.keys(containerInfo.NetworkSettings.Networks);
const { IPAddress: containerIP } = containerInfo.NetworkSettings.Networks[firstNetwork];

return containerIP;
}
}

DockerCompose.DOCKER_COMPOSE_MIN_VERSION = '2.0.0';
Expand Down
19 changes: 19 additions & 0 deletions packages/dashmate/src/getConnectionHostFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function getConnectionHostFactory(dockerCompose, isHelper) {
/**
* Get proper service endpoint url
* @param config
* @param serviceName
* @return {Promise<string>}
*/
async function getConnectionHost(config, serviceName) {
if (isHelper) {
return dockerCompose.getContainerIp(config.toEnvs(), serviceName);
}

return '127.0.0.1';
}

return getConnectionHost;
}

module.exports = getConnectionHostFactory;
3 changes: 3 additions & 0 deletions packages/dashmate/src/listr/tasks/reindexNodeTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const CoreService = require('../../core/CoreService');
* @param {writeServiceConfigs} writeServiceConfigs
* @param {configFileRepository} configFileRepository
* @param {configFile} configFile
* @param {getConnectionHost} getConnectionHost
* @return {reindexNodeTask}
*/
function reindexNodeTaskFactory(
Expand All @@ -26,6 +27,7 @@ function reindexNodeTaskFactory(
writeServiceConfigs,
configFileRepository,
configFile,
getConnectionHost,
) {
/**
* @typedef {reindexNodeTask}
Expand Down Expand Up @@ -94,6 +96,7 @@ function reindexNodeTaskFactory(
port: config.get('core.rpc.port'),
user: config.get('core.rpc.user'),
pass: config.get('core.rpc.password'),
host: await getConnectionHost(config, 'core'),
},
),
docker.getContainer(containerId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function setupLocalPresetTaskFactory(
config.set('platform.dapi.envoy.grpc.port', 3010 + (i * 100));
config.set('platform.drive.tenderdash.p2p.port', 26656 + (i * 100));
config.set('platform.drive.tenderdash.rpc.port', 26657 + (i * 100));
config.set('platform.drive.tenderdash.moniker', config.name);

// Setup logs
if (ctx.debugLogs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ function setupRegularPresetTaskFactory(
},
options: { persistentOutput: true },
},
{
title: 'Initialize Tenderdash',
enabled: (ctx) => ctx.preset !== PRESET_MAINNET,
task: (ctx) => tenderdashInitTask(ctx.config),
},
{
title: 'Set default config',
task: (ctx, task) => {
Expand Down Expand Up @@ -245,6 +240,11 @@ function setupRegularPresetTaskFactory(
return saveCertificateTask(ctx.config);
},
},
{
title: 'Initialize Tenderdash',
enabled: (ctx) => ctx.preset !== PRESET_MAINNET,
task: (ctx) => tenderdashInitTask(ctx.config),
},
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { NETWORK_LOCAL } = require('../../constants');
* @param {startNodeTask} startNodeTask
* @param {waitForNodeToBeReadyTask} waitForNodeToBeReadyTask
* @param {buildServicesTask} buildServicesTask
* @param {getConnectionHost} getConnectionHost
* @return {startGroupNodesTask}
*/
function startGroupNodesTaskFactory(
Expand All @@ -24,6 +25,7 @@ function startGroupNodesTaskFactory(
startNodeTask,
waitForNodeToBeReadyTask,
buildServicesTask,
getConnectionHost,
) {
/**
* @typedef {startGroupNodesTask}
Expand Down Expand Up @@ -68,6 +70,7 @@ function startGroupNodesTaskFactory(
port: config.get('core.rpc.port'),
user: config.get('core.rpc.user'),
pass: config.get('core.rpc.password'),
host: await getConnectionHost(config, 'core'),
});

await waitForCorePeersConnected(rpcClient);
Expand Down
3 changes: 3 additions & 0 deletions packages/dashmate/src/listr/tasks/startNodeTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { NETWORK_LOCAL } = require('../../constants');
* @param {waitForMasternodesSync} waitForMasternodesSync
* @param {createRpcClient} createRpcClient
* @param {buildServicesTask} buildServicesTask
* @param getConnectionHost {getConnectionHost}
* @return {startNodeTask}
*/
function startNodeTaskFactory(
Expand All @@ -21,6 +22,7 @@ function startNodeTaskFactory(
waitForMasternodesSync,
createRpcClient,
buildServicesTask,
getConnectionHost,
) {
/**
* @typedef {startNodeTask}
Expand Down Expand Up @@ -106,6 +108,7 @@ function startNodeTaskFactory(
port: config.get('core.rpc.port'),
user: config.get('core.rpc.user'),
pass: config.get('core.rpc.password'),
host: await getConnectionHost(config, 'core'),
});

return new Observable(async (observer) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ const { Listr } = require('listr2');
/**
* @param {DockerCompose} dockerCompose
* @param {createRpcClient} createRpcClient
* @param {getConnectionHost} getConnectionHost
* @return {stopNodeTask}
*/
function stopNodeTaskFactory(
dockerCompose,
createRpcClient,
getConnectionHost,
) {
/**
* Stop node
Expand Down Expand Up @@ -36,6 +38,7 @@ function stopNodeTaskFactory(
port: config.get('core.rpc.port'),
user: config.get('core.rpc.user'),
pass: config.get('core.rpc.password'),
host: await getConnectionHost(config, 'core'),
});

const { result: { mediantime } } = await rpcClient.getBlockchainInfo();
Expand Down
9 changes: 9 additions & 0 deletions packages/dashmate/src/status/colors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const chalk = require('chalk');
const PortStateEnum = require('../enums/portState');
const ServiceStatusEnum = require('../enums/serviceStatus');
const DockerStatusEnum = require('../enums/dockerStatus');

module.exports = {

Expand All @@ -14,6 +15,14 @@ module.exports = {
}
return chalk.red;
},
docker: (status) => {
switch (status) {
case DockerStatusEnum.running:
return chalk.green;
default:
return chalk.red;
}
},
status: (status) => {
switch (status) {
case ServiceStatusEnum.up:
Expand Down
Loading