Skip to content

Commit

Permalink
Merge pull request #49 from input-output-hk/release/0.1.0
Browse files Browse the repository at this point in the history
Release/0.1.0
  • Loading branch information
lgobbi-atix committed Dec 10, 2019
2 parents ea1cd78 + bd73751 commit 52977a6
Show file tree
Hide file tree
Showing 91 changed files with 5,199 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# stakepool-management-tools
# Stake Pool Management Tools

The purpose of these tools is to provide stake pool operators an easy way to install, configure, test and deploy their stake pools.

## SPM CLI

### Summary

Command line interface that returns read only items to query transactions, rewards and fragments to insure reliable delegation for ADA holders.

<hr>

## SPM Desktop

### Summary

An Electron + React app that enables the ability to provide the same info as the CLI in a running desktop app that can be pointed to the localhost on a specific port for stake pool testing.
69 changes: 69 additions & 0 deletions cli-node/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"extends": [ "airbnb", "plugin:prettier/recommended"],
"env": {
"browser": true,
"mocha": true,
"node": true
},
"rules": {
"func-names": "error",
"new-cap": "off",
"arrow-parens": "off",
"consistent-return": "off",
"comma-dangle": "off",
"generator-star-spacing": "off",
"import/no-unresolved": "error",
"import/no-extraneous-dependencies": "off",
"import/no-dynamic-require": "off",
"import/prefer-default-export": "off",
"no-use-before-define": "off",
"promise/param-names": "error",
"promise/always-return": "error",
"promise/catch-or-return": "error",
"promise/no-native": "off",
"react/jsx-no-bind": "off",
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }],
"react/jsx-closing-bracket-location": "warn",
"react/jsx-one-expression-per-line": "off",
"react/prefer-stateless-function": "warn",
"react/no-unused-prop-types": "error",
"react/prop-types": "warn",
"react/sort-comp": "error",
"jsx-a11y/label-has-associated-control": "off",
"class-methods-use-this": "off",
"no-duplicate-imports": "error",
"no-param-reassign": "error",
"no-plusplus": "off",
"no-bitwise": "off",
"no-underscore-dangle": "off",
"no-console": "off",
"no-mixed-operators": "off",
"prefer-template": "warn",
"no-unused-vars": "warn",
"no-trailing-spaces": "warn",
"padded-blocks": "warn",
"no-undef": "warn",
"arrow-body-style": "warn",
"key-spacing": "warn",
"no-empty-function": "warn",
"max-len": "warn",
"no-useless-escape": "warn",
"prefer-const": "warn",
"object-curly-spacing": "warn",
"spaced-comment": "warn",
"quotes": ["error", "single"],
"import/imports-first": "warn",
"no-multi-spaces": "warn",
"no-multiple-empty-lines": "warn",
"react/jsx-indent": "warn",
"flowtype/define-flow-type": "warn",
"flowtype/use-flow-type": "warn",
"global-require": "off"
},
"plugins": [
"import",
"promise",
"react",
"flowtype"
]
}
6 changes: 6 additions & 0 deletions cli-node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/

**-lock.json
**.lock

**.tgz
1 change: 1 addition & 0 deletions cli-node/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.16.3
3 changes: 3 additions & 0 deletions cli-node/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
45 changes: 45 additions & 0 deletions cli-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPM CLI

### Install Dependencies

In project folder run:
```console
yarn install
```

### Usage/Run

In project folder run:
```console
yarn start [ARGS]
```

or `yarn link` and run with `spm [ARGS]`

ARGS:
* `settings -p <node-rest-port>` establish a connection with the local node
* `<node-rest-port>` node REST listening port (e.g, 3100)
* `--info <topic-number>` displays info on how to set up a stake pool
* `<topic-number>` displays info related to the chosen topic
* `--help` displays help usage

Once connection is established, you can run these commands:
* `chain-info` displays Blockchain information: block0 hash, started on, consensus version
* `node-info` displays Node information: up since time, blocks received, last block, date, length
* `tx` displays Transaction information: tx received, txs, outputs, fees
* `stake-state` displays Stake state Information: total value, total stake
* `leader-schedules` displays Leader schedules logs: schedule, started at, finished at
* `fragment-logs <fragment-id>` displays fragment logs: fragment, received, uploaded, status
* `<fragment-id>` well formed fragment id
* `help` displays this help message
* `exit` exits the CLI

### Building package and Installation

* Install production dependencies: `yarn install --prod`

* Create distribution package (spm-v0.1.0.tgz): `yarn pack`

> **NOTE**: you can also omit these two previous steps by using the `build` script located in the `package.json` file by running `yarn run build`.
* Install spm globally: `npm install -g spm-v0.1.0.tgz`
66 changes: 66 additions & 0 deletions cli-node/content/configureNode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 3. Configure Node

**1\. Download the config.yaml file**

**Download** the `config.yaml` file (https://hydra.iohk.io/job/Cardano/jormungandr/jormungandrConfigs.itn_balance_check/latest) and save it to the same location that jormungandr and jcli.
The `config.yaml` file has the list of trusted peers. From this list the node is going to download its copy of the blockchain.

**2\. Download the genesis-hash.txt file**

From the same location you can also download the genesis-hash.txt file.
The genesis-hash contains the initial configuration of the testnet.

`curl -sLOJ https://hydra.iohk.io/job/Cardano/jormungandr/jormungandrConfigs.itn_balance_check/latest/download/2/genesis-hash.txt`

**3\. Edit config.yaml file**

By default the config file comes setup for passive node, but since we want to creat a stake pool we need to edit the file.

Use a plain text editor to open the config.yaml and add

* Public ip address
* Listen address
* Blocks and messages update priority

```
"p2p": {
listen_address: '/ip4/0.0.0.0/tcp/3000',
  public_address: '/ip4/0.0.0.0/tcp/3000', # Replace 0.0.0.0 with your public IP
  topics_of_interest: {
   blocks: 'high',
   messages: 'high'
  }
}
```

**4\. Start the node**

**Start the node** by executing the below command in the same location where all 3 files were saved.

`./jormungandr --genesis-block-hash $(cat genesis-hash.txt) --config config.yaml`

**5\. Check that the node syncing**

Execute the following command in your command-line interface to check if your node is syncing.

`./jcli rest v0 node stats get --host "http://127.0.0.1:3100/api"`

It will output something like this:

blockRecvCnt: 351
lastBlockDate: "220.1821"
lastBlockFees: 0
lastBlockHash: 13966f0025b46667f2a0ce8c13409025d10237e21b5d3f7083d3d795a9b39f2d
lastBlockHeight: "28663"
lastBlockSum: 0
lastBlockTime: "2019-09-30T08:54:17+00:00"
lastBlockTx: 0
txRecvCnt: 0
uptime: 1057

Your node is synced with the blockchain when it receives all the blocks that are created in the network/blockchain in real-time.

You can check that by following the below 2 rules:

1\. Execute the `node stats` command from above multiple times and check that the value of the `lastBlockHash` field is updated (with the actual blockchain values, there should bea new block created every 2-5 minutes);
2\. Compare the value of the `lastBlockTime` field (that is in UTC) with the local time of the node. If the difference if more than 10 minutes, the node might not be synced even the node received blocks in the past `(blockRecvCnt > 0);`
55 changes: 55 additions & 0 deletions cli-node/content/createCertificate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 4. Create and Send Certificate

## Linux/macOS

**1\. Download the `createStakePool.sh` and `send-certificate.sh` scripts and save them to the directory where you stored the rest of the files (jcli, jormungandr, config.yaml, etc):**

`curl -sLOJ https://raw.githubusercontent.com/input-output-hk/jormungandr-qa/master/scripts/createStakePool.sh`

`curl - sLOJ https://raw.githubusercontent.com/input-output-hk/jormungandr-qa/master/scripts/send-certificate.sh`

- Check that the scripts were downloaded into the current location by executing `ls` command into the terminal
- Change the scripts permissions in order to be able to execute them
`chmod +x createStakePool.sh`
`chmod +x send-certificate.sh`
- Check the parameters required by the script
`./createStakePool.sh --help`
- Output:

```
usage: `./createStakePool.sh <REST-LISTEN-PORT>`
<ACCOUNT_SK>
<REST-PORT> The REST Listen Port set in node-config.yaml file (EX: 3101)
<SOURCE-SK> The Secret key of the Source address`
```

**2\. Execute the `createStakePool.sh` script**

- For the `--host` parameter, use the same value you used in node configuration (config.yaml) for the **rest/listen** parameter.
- For the second parameter use the **Private Key** of your recently funded stake pool account address.
`./createStakePool.sh 3100 ed25519e_sk1nqh6fk0dm9p3tgvqcgt9had3ajn5pcmme04qp256p3g7tahxd9q9j4wgn2n250huxc5t38u0yjd9rtalrzae9t7xcwzhcz98jf4hamsgfmydk`

- Check the results
- If everything is fine and you did not receive any error, the last line of the script output is your **Stake Pool ID**. Now you can check if your stake pool id appears in the list of available stake pools by executing the below command.
`./jcli rest v0 stake-pools get --host "http://127.0.0.1:3100/api"`
- Now you can start the node as a **leader candidate**, using the `--secret node-config.yaml` parameter. The `node-config.yaml` file was automatically created in the same location as `createStakePool.sh`.

**3\. Send your Stake Pool certificate**

- Check the parameters required by the script
`$ ./send-certificate.sh --help`
- Output

```
usage: send-certificate.sh <CERTIFICATE-PATH> <REST-LISTEN-PORT> <ACCOUNT-SOURCE-SK>
<CERT-PATH> Path to a readable certificate file
<REST-PORT> The REST Listen Port set in node-config.yaml file (EX: 3101)
<SOURCE-SK> The Secret key of the Source address
```

**4\. Execute the `send-certificate.sh` script**

- Make sure that the signed certificate **(stake_pool.signcert)** is in the **same location** of the `send-certificate.sh` script
- For the `REST-PORT` parameter, use the same value you used in node configuration (config.yaml) for the rest/listen parameter
- For the `SOURCE-SK` parameter, use the **private key** of your stake pool account address.
`./send-certificate.sh stake_pool.signcert 3100 ed25519e_sk1nqh6fk0dm9p3tgvqcgt9had3ajn5pcmme04qp256p3g7tahxd9q9j4wgn2n250huxc5t38u0yjd9rtalrzae9t7xcwzhcz98jf4hamsgfmydk`
33 changes: 33 additions & 0 deletions cli-node/content/installNode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 2. Install Node and Command Line Tool (CLI)

## Linux/macOS
**1\. Download Jormungandr (https://github.com/input-output-hk/jormungandr/releases/) latest version**

* Linux
See the Assest Section in Github
`jormungandr-v[the latest version number]-x86_64-unknown-linux-gnu.tar.gz`

* macOS
See the Assets Section in GitHub
`jormungandr-v[the latest version number]-x86_64-apple-darwin.tar.gz`

**2\. Extract the files, either use Terminal or Finder**

* Terminal
Using the command line navigate to the directory where you downloaded the archive and execute:
`tar -xvzf jormungandr-vx.x.x-x86_64-unknown-linux-gnu.tar.gz`

OR

* Finder
Navigate to the folder where you saved the archive and double click it to extract it (the default is the Downloads folder).

**3\. Verify the files were installed correctly**

* In Terminal just type:
`./jcli -V`

* It should return something like:
`jcli 0.7.2`

> **Note:** If you have any issues while installing Jormungandr and JCLI, please refer to our support portal macOS/Linux instructions (https://iohk.zendesk.com/hc/en-us/articles/360036898153) to make sure you are following the most up to date procedure.
5 changes: 5 additions & 0 deletions cli-node/content/testStake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 5. Check that your stake pool is visible

Check that your Stake Pool appears in the list of available stake pools.

`$ jcli rest v0 stake get --host "http://127.0.0.1:3100/api"`
18 changes: 18 additions & 0 deletions cli-node/content/understandRequirements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 1. Understand Stake Pool Minimum Requirements

**Hardware**
* 4 GB of RAM
* Processor speed is not a significant factor

**Network**
* 1 GB/hour
* A public ip4 address

**Operating System**
* Linux (2.6.18 or later)
* BSD (NetBSD 8.x and FreeBSD 12.x)
* macOS (10.7 Lion or later)
* Windows 10

**Cardano**
* Install RUST version called Jormungandr (https://github.com/input-output-hk/jormungandr/releases)
58 changes: 58 additions & 0 deletions cli-node/lib/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const fetch = require('node-fetch');

const getBlockchainInfo = async node => {
const response = await makeGetRequest(`${node}/api/v0/settings`);
return response;
};

const getNodeInfo = async node => {
const response = await makeGetRequest(`${node}/api/v0/node/stats`);
return response;
};

const getLeaderSchedules = async node => {
const response = await makeGetRequest(`${node}/api/v0/leaders/logs`);
return response;
};

const getStakeInfo = async node => {
const response = await makeGetRequest(`${node}/api/v0/stake`);
return response && response.stake ? response : undefined;
};

const getFragmentLogs = async node => {
const response = await makeGetRequest(`${node}/api/v0/fragment/logs`);
return response;
};

const checkConnection = async node => {
try {
await fetch(node, {
method: 'GET'
});
} catch (error) {
return false;
}
return true;
};

const makeGetRequest = async url => {
try {
const response = await fetch(url, {
method: 'GET'
});
const json = await response.json();
return json;
} catch (error) {
console.log('ERROR: ', error);
}
};

module.exports = {
getBlockchainInfo,
getNodeInfo,
getLeaderSchedules,
getStakeInfo,
getFragmentLogs,
checkConnection
};
Loading

0 comments on commit 52977a6

Please sign in to comment.