Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Beddows committed Feb 21, 2017
2 parents 8db20c4 + 8da902e commit 6a0056f
Show file tree
Hide file tree
Showing 48 changed files with 1,666 additions and 277 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ release
ssl/
stacktrace*
tmp
sftp-config.json
52 changes: 52 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dist: 'trusty'
language: node_js
node_js:
- '6.9.4'
cache:
yarn: true
directories:
- test/lisk-js
services:
- postgresql
addons:
postgresql: '9.6'
install:
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update && sudo apt-get install yarn
- yarn
before_script:
- createdb lisk_test
- psql -d lisk_test -c "alter user "$USER" with password 'password';"
- wget https://downloads.lisk.io/lisk-node/lisk-node-Linux-x86_64.tar.gz
- tar -zxvf lisk-node-Linux-x86_64.tar.gz
- cd test/lisk-js/; yarn; cd ../..
- cp test/config.json test/genesisBlock.json .
- node app.js &> .app.log &
env:
matrix:
- TEST=test/api/peer.transactions.stress.js
- TEST=test/api/peer.transactions.votes.js
- TEST=test/api/delegates.js
- TEST=test/api/accounts.js
- TEST=test/api/blocks.js
- TEST=test/api/dapps.js
- TEST=test/api/loader.js
- TEST=test/api/multisignatures.js
- TEST=test/api/peer.js
- TEST=test/api/peer.dapp.js
- TEST=test/api/peer.blocks.js
- TEST=test/api/peer.signatures.js
- TEST=test/api/peer.transactions.collision.js
- TEST=test/api/peer.transactions.delegates.js
- TEST=test/api/peer.transactions.main.js
- TEST=test/api/peer.transactions.signatures.js
- TEST=test/api/peers.js
- TEST=test/api/signatures.js
- TEST=test/api/transactions.js

- TEST=test/unit/helpers
- TEST=test/unit/logic
script: 'npm run travis'
after_failure:
- cat .app.log
12 changes: 12 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports = function (grunt) {
var release_dir = __dirname + '/release/',
version_dir = release_dir + config.version;

var maxBufferSize = require('buffer').kMaxLength - 1;

grunt.initConfig({
obfuscator: {
files: files,
Expand Down Expand Up @@ -68,6 +70,14 @@ module.exports = function (grunt) {
},
build: {
command: 'cd ' + version_dir + '/ && touch build && echo "v' + today + '" > build'
},
coverage: {
command: 'node_modules/.bin/istanbul cover --dir test/.coverage ./node_modules/.bin/mocha',
maxBuffer: maxBufferSize
},
coverageSingle: {
command: 'node_modules/.bin/istanbul cover --dir test/.$TEST_coverage ./node_modules/.bin/mocha $TEST',
maxBuffer: maxBufferSize
}
},

Expand Down Expand Up @@ -126,4 +136,6 @@ module.exports = function (grunt) {

grunt.registerTask('default', ['release']);
grunt.registerTask('release', ['exec:folder', 'obfuscator', 'exec:package', 'exec:build', 'compress']);
grunt.registerTask('travis', ['jshint', 'exec:coverageSingle']);
grunt.registerTask('test', ['jshint', 'exec:coverage']);
};
101 changes: 64 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,57 @@
Lisk is a next generation crypto-currency and decentralized application platform, written entirely in JavaScript. For more information please refer to our website: https://lisk.io/.

[![Join the chat at https://gitter.im/LiskHQ/lisk](https://badges.gitter.im/LiskHQ/lisk.svg)](https://gitter.im/LiskHQ/lisk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/LiskHQ/lisk.svg?branch=development)](https://travis-ci.org/LiskHQ/lisk)

## Installation
**NOTE:** The following information is applicable to: **Ubuntu 14.04 (LTS) - x86_64**.

**NOTE:** The following is applicable to: **Ubuntu 14.04 (LTS) - x86_64**.
## Prerequisites - In order

Install essentials:
- Tool chain components -- Used for compiling dependencies

```
sudo apt-get update
sudo apt-get install -y autoconf automake build-essential curl git libtool python
```
`sudo apt-get install -y python build-essential curl automake autoconf libtool`

- Git (<https://github.com/git/git>) -- Used for cloning and updating Lisk

Install PostgreSQL (version 9.5.2):
`sudo apt-get install -y git`

```
curl -sL "https://downloads.lisk.io/scripts/setup_postgresql.Linux" | bash -
sudo -u postgres createuser --createdb $USER
createdb lisk_test
sudo -u postgres psql -d lisk_test -c "alter user "$USER" with password 'password';"
```
- Nodejs v0.12.17 (<https://nodejs.org/>) -- Nodejs serves as the underlying engine for code execution.

Install Node.js (version 0.12.x) + npm:
```
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
nvm install v0.12.17
```

- Install PostgreSQL (version 9.6.1):

```
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
```
```
curl -sL "https://downloads.lisk.io/scripts/setup_postgresql.Linux" | bash -
sudo -u postgres createuser --createdb $USER
createdb lisk_test
createdb lisk_main
sudo -u postgres psql -d lisk_test -c "alter user "$USER" with password 'password';"
sudo -u postgres psql -d lisk_main -c "alter user "$USER" with password 'password';"
```

- Bower (<http://bower.io/>) -- Bower helps to install required JavaScript dependencies.

Install grunt-cli (globally):
`npm install -g bower`

```
sudo npm install grunt-cli -g
```
- Grunt.js (<http://gruntjs.com/>) -- Grunt is used to compile the frontend code and serves other functions.

Install bower (globally):
`npm install -g grunt`

- Forever (<https://github.com/foreverjs/forever>) -- Forever manages the node process for Lisk (Optional)

```
sudo npm install bower -g
```
`npm install -g forever`

Install node modules:
## Installation Steps

Clone the Lisk repository using Git and initialize the modules.

```
git clone https://github.com/LiskHQ/lisk.git
cd lisk
npm install
```

Expand Down Expand Up @@ -74,37 +82,56 @@ bower install
grunt release
```

## Launch
## Managing Lisk

To launch Lisk:
To test that Lisk is built and configured correctly, run the following command:

```
node app.js
```
`node app.js`

In a browser navigate to: <http://localhost:7000>. If Lisk is running on a remote system, switch `localhost` for the external IP Address of the machine.

Once the process is verified as running correctly, `CTRL+C` and start the process with `forever`. This will fork the process into the background and automatically recover the process if it fails.

`forever start app.js`

After the process is started its runtime status and log location can be found by issuing this statement:

`forever list`

To stop Lisk after it has been started with `forever`, issue the following command:

`forever stop app.js`

**NOTE:** The **port**, **address** and **config-path** can be overridden by providing the relevant command switch:

```
node app.js -p [port] -a [address] -c [config-path]
forever start app.js -p [port] -a [address] -c [config-path]
```

## Tests

Before running any tests, please ensure Lisk is configured to run on the same testnet as used by the test-suite.
Before running any tests, please ensure Lisk is configured to run on the same testnet that is used by the test-suite.

Replace **config.json** and **genesisBlock.json** with the corresponding files under the **test** directory:

```
cp test/config.json test/genesisBlock.json .
```

**NOTE:** If the node was started with a different genesis block previous, trauncate the database before running tests.

```
dropdb lisk_test
createdb lisk_test
```

**NOTE:** The master passphrase for this genesis block is as follows:

```
wagon stock borrow episode laundry kitten salute link globe zero feed marble
```

Launch lisk (runs on port 4000):
Launch Lisk (runs on port 4000):

```
node app.js
Expand Down Expand Up @@ -134,7 +161,7 @@ npm test -- test/lib/transactions.js

The MIT License (MIT)

Copyright (c) 2016 Lisk
Copyright (c) 2016-2017 Lisk
Copyright (c) 2014-2015 Crypti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
36 changes: 36 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var checkIpInList = require('./helpers/checkIpInList.js');
var extend = require('extend');
var fs = require('fs');
var genesisblock = require('./genesisBlock.json');
var git = require('./helpers/git.js');
var https = require('https');
var Logger = require('./logger.js');
var packageJson = require('./package.json');
Expand All @@ -17,6 +18,15 @@ var z_schema = require('./helpers/z_schema.js');
process.stdin.resume();

var versionBuild = fs.readFileSync(path.join(__dirname, 'build'), 'utf8');
/**
* Hash of last git commit
*
* @private
* @property lastCommit
* @type {String}
* @default ''
*/
var lastCommit = '';

if (typeof gc !== 'undefined') {
setInterval(function () {
Expand Down Expand Up @@ -94,6 +104,13 @@ var config = {

var logger = new Logger({ echo: appConfig.consoleLogLevel, errorLevel: appConfig.fileLogLevel, filename: appConfig.logFileName });

// Trying to get last git commit
try {
lastCommit = git.getLastCommit();
} catch (err) {
logger.debug('Cannot get last git commit', err.message);
}

var d = require('domain').create();

d.on('error', function (err) {
Expand Down Expand Up @@ -140,6 +157,20 @@ d.run(function () {
build: function (cb) {
cb(null, versionBuild);
},
/**
* Returns hash of last git commit
*
* @property lastCommit
* @type {Function}
* @async
* @param {Function} cb Callback function
* @return {Function} cb Callback function from params
* @return {Object} cb.err Always return `null` here
* @return {String} cb.lastCommit Hash of last git commit
*/
lastCommit: function (cb) {
cb(null, lastCommit);
},

genesisblock: function (cb) {
cb(null, {
Expand Down Expand Up @@ -246,6 +277,11 @@ d.run(function () {
return value;
}

// Ignore conditional fields for transactions list
if (/^.+?:(blockId|recipientId|senderId)$/.test(name)) {
return value;
}

/*jslint eqeq: true*/
if (isNaN(value) || parseInt(value) != value || isNaN(parseInt(value, radix))) {
return value;
Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"port": 8000,
"address": "0.0.0.0",
"version": "0.5.2",
"minVersion": "~0.5.0",
"version": "0.6.0",
"minVersion": ">=0.5.0",
"fileLogLevel": "info",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "info",
Expand Down
5 changes: 3 additions & 2 deletions helpers/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ function Migrator (pgp, db) {
};

this.applyRuntimeQueryFile = function (waterCb) {
var sql = new pgp.QueryFile(path.join('sql', 'runtime.sql'), {minify: true});
var dirname = path.basename(__dirname) === 'helpers' ? path.join(__dirname, '..') : __dirname;
var sql = new pgp.QueryFile(path.join(dirname, 'sql', 'runtime.sql'), {minify: true});

db.query(sql).then(function () {
return waterCb();
Expand All @@ -123,7 +124,7 @@ module.exports.connect = function (config, logger, cb) {
monitor.attach(pgOptions, config.logEvents);
monitor.setTheme('matrix');

monitor.log = function(msg, info){
monitor.log = function (msg, info){
logger.log(info.event, info.text);
info.display = false;
};
Expand Down
6 changes: 4 additions & 2 deletions helpers/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ module.exports = {
signatures: [
'5676385569187187158', // 868797
'5384302058030309746', // 869890
'9352922026980330230', // 925165
'9352922026980330230' // 925165
],
multisignatures: [
'14122550998639658526' // 1189962
],
multisignatures: [],
votes: [
'5524930565698900323', // 20407
'11613486949732674475', // 123300
Expand Down
31 changes: 31 additions & 0 deletions helpers/git.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';
/**
* Helper module for parsing git commit information
*
* @class git.js
*/

var childProcess = require('child_process');

/**
* Return hash of last git commit if available
*
* @method getLastCommit
* @public
* @return {String} Hash of last git commit
* @throws {Error} Throws error if cannot get last git commit
*/
function getLastCommit () {
var spawn = childProcess.spawnSync('git', ['rev-parse', 'HEAD']);
var err = spawn.stderr.toString().trim();

if (err) {
throw new Error(err);
} else {
return spawn.stdout.toString().trim();
}
}

module.exports = {
getLastCommit: getLastCommit
};
Loading

0 comments on commit 6a0056f

Please sign in to comment.