Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

feat: masternode registration scripts #30

Merged
merged 27 commits into from
Apr 29, 2020
Merged

feat: masternode registration scripts #30

merged 27 commits into from
Apr 29, 2020

Conversation

shuplenkov
Copy link
Member

No description provided.

bin/run Outdated
@@ -0,0 +1,6 @@
#!/usr/bin/env node
Copy link
Member

Choose a reason for hiding this comment

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

bin/mn?

const path = require('path');
const RpcClient = require('@dashevo/dashd-rpc/promise');
const compose = require('docker-compose');
const waitForCoreStart = require('../util/waitForCoreStart');
Copy link
Member

Choose a reason for hiding this comment

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

These things doesn’t looks like utils, more like business logic. Let’s put core stuff to lib/core/?

package.json Outdated
@@ -0,0 +1,82 @@
{
"name": "mn-bootstrap",
Copy link
Member

Choose a reason for hiding this comment

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

@dashevo/mn-bootstrap

options: [
'evonet',
'local',
'testnet',
Copy link
Member

@shumkov shumkov Apr 22, 2020

Choose a reason for hiding this comment

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

Will it work?

const { Command, flags: flagTypes } = require('@oclif/command');
const getNewAddress = require('../../../lib/commands/getNewAddress');

class GetNewAddressCommand extends Command {
Copy link
Member

Choose a reason for hiding this comment

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

mn core generate-to-address <amount> --address . Create a new wallet if address omitted

@@ -0,0 +1,91 @@
const path = require('path');
Copy link
Member

Choose a reason for hiding this comment

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

src/core/wallet

if (preset !== 'local') {
console.info('You need to wait at least 100 block before registering masternode');
}
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't use console in business logic. we need to handle errors in commands. use oclif error handling

@@ -0,0 +1,160 @@
const path = require('path');
Copy link
Member

Choose a reason for hiding this comment

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

src/core/mn/

addresses: [fundSourceAddress],
});

console.info(`Fund balance is ${balance / SATOSHI_MULTIPLIER}`);
Copy link
Member

Choose a reason for hiding this comment

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

factory should accept logger

console.info(`Fund balance is ${balance / SATOSHI_MULTIPLIER}`);

if (balance / SATOSHI_MULTIPLIER < MASTERNODE_DASH_AMOUNT) {
console.error('Needs wallet with more than 1000 dash');
Copy link
Member

Choose a reason for hiding this comment

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

throw exception


console.info(`Masternode registered with tx ${protx}`);
console.info(`Add this bls private key to your config: ${operator.privateKey}`);
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

remove

} finally {
// close dash core
await compose.stopOne('core', composeOptions);
await compose.rm(composeOptions);
Copy link
Member

Choose a reason for hiding this comment

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

why not flag rm?

@@ -0,0 +1,19 @@
version: '3.7'
Copy link
Member

Choose a reason for hiding this comment

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

let's existing one with options

@@ -0,0 +1,20 @@
const { PrivateKey } = require('@dashevo/dashcore-lib');
Copy link
Member

Choose a reason for hiding this comment

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

src/core/

@@ -0,0 +1,30 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

src/core/wallet/

@@ -0,0 +1,32 @@
const wait = require('./wait');
Copy link
Member

Choose a reason for hiding this comment

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

/src/core/

@@ -0,0 +1,34 @@
const wait = require('./wait');
Copy link
Member

Choose a reason for hiding this comment

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

src/core/

do {
try {
// just any random request
await coreClient.getBlockchainInfo();
Copy link
Member

Choose a reason for hiding this comment

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

ping?

@@ -0,0 +1,21 @@
const wait = require('./wait');
Copy link
Member

@shumkov shumkov Apr 22, 2020

Choose a reason for hiding this comment

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

src/core/

package.json Outdated
@@ -0,0 +1,82 @@
{
"name": "mn-bootstrap",
"version": "0.12.0-dev.1",
Copy link
Member

Choose a reason for hiding this comment

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

0.13.0-dev.1

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a tool for 0.12.x though?

Copy link
Member

@shumkov shumkov Apr 23, 2020

Choose a reason for hiding this comment

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

0.12 is released and considering as stable (master branch) so just fixes should go there but new untested features should go to dev branch.

package.json Outdated
{
"name": "mn-bootstrap",
"version": "0.12.0-dev.1",
"description": "Dash masternode bootstrap",
Copy link
Member

Choose a reason for hiding this comment

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

Distribution package for Dash Masternode installation


try {
// start dash core
await compose.upOne('core', composeOptions);
Copy link
Member

Choose a reason for hiding this comment

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

Should we use run?


if (preset === 'local') {
// generate some blocks to unlock dash
await generateLocalBlocks(coreClient, 100);
Copy link
Member

Choose a reason for hiding this comment

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

let's try to use coreClient.generate(100)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this only for use on private devnets? Because it is almost certain to fail on Evonet (it may be possible to generate a few blocks, but not 100 all at once).

Copy link
Member

Choose a reason for hiding this comment

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

It's only for the local preset, i.e. regtest

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep 🙈 😄

enabled: () => preset !== PRESETS.LOCAL,
task: async (ctx) => (
new Observable(async (observer) => {
await waitForConfirmations(
Copy link
Member

Choose a reason for hiding this comment

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

Could we reuse waitForBlocks here?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, because your transaction could be included 5 blocks later, for example

task: async (ctx) => {
ctx.coreService = await startCore(preset, { wallet: true });

process.on('SIGINT', async () => {
Copy link
Member

@shumkov shumkov Apr 28, 2020

Choose a reason for hiding this comment

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

It would be nice to do that on the exit event, not just Ctrl+C

@shumkov shumkov self-requested a review April 29, 2020 12:38
Copy link
Member

@shumkov shumkov left a comment

Choose a reason for hiding this comment

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

Awesome! Great work! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants