Skip to content

Commit

Permalink
feat(dashmate): remove sentinel service (#1354)
Browse files Browse the repository at this point in the history
Co-authored-by: pshenmic <[email protected]>
  • Loading branch information
strophy and pshenmic authored Sep 4, 2023
1 parent c284f76 commit 8b9e35a
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 197 deletions.
5 changes: 0 additions & 5 deletions packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ function getBaseConfigFactory(homeDir) {
mediantime: null,
address: null,
},
sentinel: {
docker: {
image: 'dashpay/sentinel:1.7.3',
},
},
devnet: {
name: null,
minimumDifficultyBlocks: 0,
Expand Down
7 changes: 7 additions & 0 deletions packages/dashmate/configs/getConfigFileMigrationsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ function getConfigFileMigrationsFactory(homeDir, defaultConfigs) {
});
return configFile;
},
'0.25.0-dev.18': (configFile) => {
Object.entries(configFile.configs)
.forEach(([, options]) => {
delete options.core.sentinel;
});
return configFile;
},
};
}

Expand Down
20 changes: 0 additions & 20 deletions packages/dashmate/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,6 @@ services:
- WSL2_FIX=${WSL2_FIX:-0}
profiles:
- core
- masternode

sentinel:
image: ${CORE_SENTINEL_DOCKER_IMAGE:?err}
labels:
org.dashmate.service.title: "Sentinel"
restart: unless-stopped
depends_on:
- core
environment:
- DEBUG=false
- RPCUSER=${CORE_RPC_USER:?err}
- RPCPASSWORD=${CORE_RPC_PASSWORD:?err}
- RPCHOST=core
- RPCPORT=${CORE_RPC_PORT:?err}
- NETWORK=${NETWORK?:err}
- SENTINEL_ARGS=-b
stop_grace_period: 10s
profiles:
- masternode

drive_abci:
image: ${PLATFORM_DRIVE_ABCI_DOCKER_IMAGE:?err}
Expand Down
7 changes: 0 additions & 7 deletions packages/dashmate/src/commands/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class StatusCommand extends ConfigBaseCommand {
'Last paid time': 'n/a',
'Payment queue position': 'n/a',
'Next payment time': 'n/a',
'Sentinel Version': 'n/a',
'Sentinel Status': 'n/a',
'Platform Enabled': 'n/a',
'Platform Status': 'n/a',
'Platform Version': 'n/a',
Expand Down Expand Up @@ -92,11 +90,6 @@ class StatusCommand extends ConfigBaseCommand {
plain['Payment queue position'] = paymentQueuePosition || 'n/a';
plain['Next payment time'] = nextPaymentTime || 'n/a';
}

if (masternode.sentinel.version) {
plain['Sentinel Version'] = masternode.sentinel.version || 'n/a';
plain['Sentinel Status'] = colors.sentinel(masternode.sentinel.state)(masternode.sentinel.state) || 'n/a';
}
}

plain['Platform Enabled'] = platform.enabled || 'n/a';
Expand Down
7 changes: 0 additions & 7 deletions packages/dashmate/src/commands/status/masternode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class MasternodeStatusCommand extends ConfigBaseCommand {
getMasternodeScope,
) {
const plain = {
'Sentinel Version': 'n/a',
'Sentinel Status': 'n/a',
'Masternode State': 'n/a',
'Masternode Sync Status': 'n/a',
'ProTx Hash': 'n/a',
Expand All @@ -51,11 +49,6 @@ class MasternodeStatusCommand extends ConfigBaseCommand {
const scope = await getMasternodeScope(config);

if (flags.format === OUTPUT_FORMATS.PLAIN) {
if (scope.sentinel.version) {
plain['Sentinel Version'] = scope.sentinel.version || 'n/a';
plain['Sentinel Status'] = colors.sentinel(scope.sentinel.state)(scope.sentinel.state) || 'n/a';
}

if (scope.syncAsset === MasternodeSyncAssetEnum.MASTERNODE_SYNC_FINISHED) {
plain['Masternode State'] = (scope.state === MasternodeStateEnum.READY
? chalk.green : chalk.red)(scope.state) || 'n/a';
Expand Down
14 changes: 2 additions & 12 deletions packages/dashmate/src/config/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,6 @@ module.exports = {
required: ['enable', 'interval', 'mediantime', 'address'],
additionalProperties: false,
},
sentinel: {
type: 'object',
properties: {
docker: {
$ref: '#/definitions/docker',
},
},
required: ['docker'],
additionalProperties: false,
},
devnet: {
type: 'object',
properties: {
Expand Down Expand Up @@ -308,8 +298,8 @@ module.exports = {
type: 'boolean',
},
},
required: ['docker', 'p2p', 'rpc', 'spork', 'masternode', 'miner', 'sentinel', 'devnet',
'log', 'logIps', 'indexes'],
required: ['docker', 'p2p', 'rpc', 'spork', 'masternode', 'miner', 'devnet', 'log',
'logIps', 'indexes'],
additionalProperties: false,
},
platform: {
Expand Down
4 changes: 0 additions & 4 deletions packages/dashmate/src/config/getConfigProfilesFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ function getConfigProfilesFactory() {

profiles.push('core');

if (config.get('core.masternode.enable')) {
profiles.push('masternode');
}

if (config.get('platform.enable')) {
profiles.push('platform');
}
Expand Down
6 changes: 0 additions & 6 deletions packages/dashmate/src/status/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,4 @@ module.exports = {
}
return chalk.red;
},
sentinel: (state) => {
if (state === 'ok') {
return chalk.green;
}
return chalk.red;
},
};
45 changes: 5 additions & 40 deletions packages/dashmate/src/status/scopes/masternode.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ function getMasternodeScopeFactory(dockerCompose, createRpcClient, getConnection
return info;
}

async function getSentinelInfo(config) {
// cannot be put in Promise.all, because sentinel will cause exit 1 with simultaneous requests
const sentinelStateResponse = await dockerCompose
.execCommand(config, 'sentinel', 'python bin/sentinel.py');
const sentinelVersionResponse = await dockerCompose
.execCommand(config, 'sentinel', 'python bin/sentinel.py -v');

const [state] = sentinelStateResponse.out.split(/\r?\n/);

return {
state: state === '' ? 'ok' : state,
version: sentinelVersionResponse.out
.replace(/Dash Sentinel v/, '').trim(),
};
}

/**
* Get masternode status scope
*
Expand All @@ -110,10 +94,6 @@ function getMasternodeScopeFactory(dockerCompose, createRpcClient, getConnection
async function getMasternodeScope(config) {
const scope = {
syncAsset: null,
sentinel: {
state: null,
version: null,
},
proTxHash: null,
state: MasternodeStateEnum.UNKNOWN,
status: null,
Expand All @@ -127,30 +107,15 @@ function getMasternodeScopeFactory(dockerCompose, createRpcClient, getConnection
},
};

const basicResult = await Promise.allSettled([
getSyncAsset(config),
getSentinelInfo(config),
]);

if (process.env.DEBUG) {
for (const error of basicResult.filter((e) => e.status === 'rejected')) {
try {
scope.syncAsset = await getSyncAsset(config);
} catch (error) {
if (process.env.DEBUG) {
// eslint-disable-next-line no-console
console.error(error.reason);
console.error(error);
}
}

const [syncAsset, sentinelInfo] = basicResult
.map((result) => (result.status === 'fulfilled' ? result.value : null));

if (syncAsset) {
scope.syncAsset = syncAsset;
}

if (sentinelInfo) {
scope.sentinel.state = sentinelInfo.state;
scope.sentinel.version = sentinelInfo.version;
}

if (scope.syncAsset === MasternodeSyncAssetEnum.MASTERNODE_SYNC_FINISHED) {
try {
const masternodeInfo = await getMasternodeInfo(config);
Expand Down
7 changes: 1 addition & 6 deletions packages/dashmate/src/status/scopes/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ function getOverviewScopeFactory(getCoreScope,
proTxHash: null,
nodeState: null,
state: null,
sentinel: {
version: null,
state: null,
},
};

const platform = {
Expand All @@ -50,12 +46,11 @@ function getOverviewScopeFactory(getCoreScope,

if (masternodeEnabled) {
const {
state, proTxHash, sentinel, nodeState,
state, proTxHash, nodeState,
} = await getMasternodeScope(config);

masternode.state = state;
masternode.proTxHash = proTxHash;
masternode.sentinel = sentinel;
masternode.nodeState = nodeState;
}

Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/src/test/constants/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const services = {
dapi_envoy: 'DAPI Envoy',
dapi_api: 'DAPI API',
drive_tenderdash: 'Drive Tenderdash',
sentinel: 'Sentinel',
drive_abci: 'Drive ABCI',
dapi_tx_filter_stream: 'DAPI Transactions Filter Stream',
core: 'Core',
Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/src/test/constants/statusOutput.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const preSyncedStatus = {
testChain: 'test',
testnet: 'testnet',
sentinel_statusNotSynced: 'dashd not synced with network! Awaiting full sync before running Sentinel.',
masternode_status: 'Waiting for ProTx to appear on-chain',
platform_status: 'Waiting for core sync',
};
Expand Down
1 change: 1 addition & 0 deletions packages/dashmate/templates/core/dash.conf.dot
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ server=1
rpcuser={{=it.core.rpc.user}}
rpcpassword={{=it.core.rpc.password}}
rpcwallet=main
deprecatedrpc=hpmn

{{~it.core.rpc.allowIps :host}}
rpcallowip={{=host}}{{~}}
Expand Down
10 changes: 0 additions & 10 deletions packages/dashmate/test/unit/status/colors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,4 @@ describe('colors.js', () => {
expect(colors.poSePenalty(20, 2)).to.be.equal(chalk.red);
});
});

describe('#sentinel', () => {
it('should color green', async () => {
expect(colors.sentinel('ok')).to.be.equal(chalk.green);
});

it('should color red', async () => {
expect(colors.sentinel('fake')).to.be.equal(chalk.red);
});
});
});
75 changes: 1 addition & 74 deletions packages/dashmate/test/unit/status/scopes/masternode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ describe('getMasternodeScopeFactory', () => {
AssetName: MasternodeSyncAssetEnum.MASTERNODE_SYNC_FINISHED,
},
});
mockDockerCompose.execCommand
.withArgs(config, 'sentinel', 'python bin/sentinel.py')
.returns({ out: '' });
mockDockerCompose.execCommand
.withArgs(config, 'sentinel', 'python bin/sentinel.py -v')
.returns({ out: 'Dash Sentinel v1.7.3' });

const mockProTxHash = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef';
const mockDmnState = {
Expand All @@ -67,10 +61,6 @@ describe('getMasternodeScopeFactory', () => {

const expectedScope = {
syncAsset: MasternodeSyncAssetEnum.MASTERNODE_SYNC_FINISHED,
sentinel: {
state: 'ok',
version: '1.7.3',
},
proTxHash: mockProTxHash,
state: MasternodeStateEnum.READY,
status: 'Ready',
Expand All @@ -93,39 +83,7 @@ describe('getMasternodeScopeFactory', () => {
// simulate failed request to dashcore
mockRpcClient.mnsync.throws(new Error());

// and lets say sentinel is working
mockDockerCompose.execCommand
.withArgs(config, 'sentinel', 'python bin/sentinel.py')
.returns({ out: 'Waiting for dash core sync' });
mockDockerCompose.execCommand
.withArgs(config, 'sentinel', 'python bin/sentinel.py -v')
.returns({ out: 'Dash Sentinel v1.7.3' });

const scope = await getMasternodeScope(config);

// should return scope with no info, but sentinel is in there
const expectedScope = {
syncAsset: null,
sentinel: {
state: 'Waiting for dash core sync',
version: '1.7.3',
},
proTxHash: null,
state: MasternodeStateEnum.UNKNOWN,
status: null,
nodeState: {
dmnState: null,
poSePenalty: null,
lastPaidHeight: null,
lastPaidTime: null,
paymentQueuePosition: null,
nextPaymentTime: null,
},
};

expect(scope).to.deep.equal(expectedScope);

// and also should not be trying to obtain masternode info
// it should not be trying to obtain masternode info
expect(mockRpcClient.getBlockchainInfo.notCalled).to.be.true();
});

Expand All @@ -136,37 +94,6 @@ describe('getMasternodeScopeFactory', () => {
},
});

mockDockerCompose.execCommand
.withArgs(config, 'sentinel', 'python bin/sentinel.py')
.returns({ out: 'Waiting for dash core sync' });

mockDockerCompose.execCommand
.withArgs(config, 'sentinel', 'python bin/sentinel.py -v')
.returns({ out: 'Dash Sentinel v1.7.3' });

const scope = await getMasternodeScope(config);

const expectedScope = {
syncAsset: MasternodeSyncAssetEnum.MASTERNODE_SYNC_BLOCKCHAIN,
sentinel: {
state: 'Waiting for dash core sync',
version: '1.7.3',
},
proTxHash: null,
state: MasternodeStateEnum.UNKNOWN,
status: null,
nodeState: {
dmnState: null,
poSePenalty: null,
lastPaidHeight: null,
lastPaidTime: null,
paymentQueuePosition: null,
nextPaymentTime: null,
},
};

expect(scope).to.deep.equal(expectedScope);

expect(mockRpcClient.getBlockchainInfo.notCalled).to.be.true();
expect(mockRpcClient.masternode.notCalled).to.be.true();
});
Expand Down
4 changes: 0 additions & 4 deletions packages/dashmate/test/unit/status/scopes/overview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ describe('getOverviewScopeFactory', () => {
lastPaidTime: '23 days ago',
paymentQueuePosition: null,
nextPaymentTime: 'in 1 day',
sentinelState: '',
sentinelVersion: 'v1.2',
};

const mockPlatformScope = {
Expand Down Expand Up @@ -94,8 +92,6 @@ describe('getOverviewScopeFactory', () => {
expect(mockGetMasternodeScope.notCalled).to.be.true();
expect(scope.masternode.state).to.be.equal(null);
expect(scope.masternode.proTxHash).to.be.equal(null);
expect(scope.masternode.sentinel.version).to.be.equal(null);
expect(scope.masternode.sentinel.state).to.be.equal(null);
expect(scope.masternode.nodeState).to.be.equal(null);

expect(mockGetPlatformScope.notCalled).to.be.true();
Expand Down

0 comments on commit 8b9e35a

Please sign in to comment.