Skip to content

Commit

Permalink
Merge pull request #1643 from ArkEcosystem/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
faustbrian authored Dec 5, 2018
2 parents 6c1dc3e + fe0f93b commit aee3d00
Show file tree
Hide file tree
Showing 59 changed files with 393 additions and 400 deletions.
34 changes: 5 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,40 +72,17 @@ jobs:
./node_modules/.bin/cross-env ARK_ENV=test ./node_modules/.bin/jest
./packages/core-vote-report/ ./packages/core-transaction-pool/
./packages/core-snapshots-cli/ ./packages/core-logger-winston/
./packages/core-api/ ./packages/core-event-emitter/
./packages/core-http-utils/ ./packages/core-event-emitter/
./packages/core-elasticsearch/ ./packages/core-database-postgres/
./packages/core-config/ ./packages/core-http-utils/
--detectOpenHandles --runInBand --forceExit --ci --coverage | tee
test_output.txt
./packages/core-config/ ./packages/core/ --detectOpenHandles
--runInBand --forceExit --ci --coverage | tee test_output.txt
- run:
name: Last 1000 lines of test output
when: on_fail
command: tail -n 1000 test_output.txt
- run:
name: Codecov
command: ./node_modules/.bin/codecov
depcheck-lint:
working_directory: ~/ark-core
docker:
- image: 'circleci/node:10'
steps:
- checkout
- run:
name: Generate cache key
command: >-
find ./packages/ -name package.json -print0 | sort -z | xargs -r0
echo ./package.json | xargs md5sum | md5sum - > checksum.txt
- restore_cache:
key: 'core-node10-{{ checksum "checksum.txt" }}-1'
- run:
name: Install packages
command: yarn
- run:
name: Lint
command: yarn lint
- run:
name: Depcheck
command: yarn depcheck
test-node10-1:
working_directory: ~/ark-core
docker:
Expand Down Expand Up @@ -180,7 +157,7 @@ jobs:
./packages/core-test-utils/ ./packages/core-p2p/
./packages/core-json-rpc/ ./packages/core-forger/
./packages/core-error-tracker-bugsnag/ ./packages/core-debugger-cli/
./packages/core-container/ ./packages/core/ --detectOpenHandles
./packages/core-container/ ./packages/core-api/ --detectOpenHandles
--runInBand --forceExit --ci --coverage | tee test_output.txt
- run:
name: Last 1000 lines of test output
Expand Down Expand Up @@ -275,9 +252,8 @@ jobs:
command: ./node_modules/.bin/codecov
workflows:
version: 2
test_depcheck_lint:
build_and_test:
jobs:
- depcheck-lint
- test-node10-0
- test-node10-1
- test-node10-2
44 changes: 2 additions & 42 deletions .circleci/configTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,52 +79,12 @@
}
}
]
},
"depcheck-lint": {
"working_directory": "~/ark-core",
"docker": [
{
"image": "circleci/node:10"
}
],
"steps": [
"checkout",
{
"run": {
"name": "Generate cache key",
"command": "find ./packages/ -name package.json -print0 | sort -z | xargs -r0 echo ./package.json | xargs md5sum | md5sum - > checksum.txt"
}
},
{
"restore_cache": {
"key": "core-node10-{{ checksum \"checksum.txt\" }}-1"
}
},
{
"run": {
"name": "Install packages",
"command": "yarn"
}
},
{
"run": {
"name": "Lint",
"command": "yarn lint"
}
},
{
"run": {
"name": "Depcheck",
"command": "yarn depcheck"
}
}
]
}
},
"workflows": {
"version": 2,
"test_depcheck_lint": {
"jobs": ["depcheck-lint"]
"build_and_test": {
"jobs": []
}
}
}
2 changes: 1 addition & 1 deletion .circleci/generateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function genYaml(options) {
)

config.jobs[`test-node10-${index}`] = job
config.workflows.test_depcheck_lint.jobs.push(`test-node10-${index}`)
config.workflows.build_and_test.jobs.push(`test-node10-${index}`)
})

fs.writeFile('.circleci/config.yml', yaml.safeDump(config), 'utf8', err => {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<img src="./banner.png" />
</p>

[![Greenkeeper badge](https://badges.greenkeeper.io/ArkEcosystem/core.svg)](https://greenkeeper.io/)
[![Build Status](https://badgen.now.sh/circleci/github/ArkEcosystem/core)](https://circleci.com/gh/ArkEcosystem/core)
[![Codecov](https://badgen.now.sh/codecov/c/github/arkecosystem/core)](https://codecov.io/gh/arkecosystem/core)
[![License: MIT](https://badgen.now.sh/badge/license/MIT/green)](https://opensource.org/licenses/MIT)
Expand Down
39 changes: 39 additions & 0 deletions greenkeeper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"groups": {
"default": {
"packages": [
"package.json",
"packages/core-api/package.json",
"packages/core-blockchain/package.json",
"packages/core-config/package.json",
"packages/core-container/package.json",
"packages/core-database-postgres/package.json",
"packages/core-database/package.json",
"packages/core-debugger-cli/package.json",
"packages/core-deployer/package.json",
"packages/core-elasticsearch/package.json",
"packages/core-error-tracker-bugsnag/package.json",
"packages/core-error-tracker-sentry/package.json",
"packages/core-event-emitter/package.json",
"packages/core-forger/package.json",
"packages/core-graphql/package.json",
"packages/core-http-utils/package.json",
"packages/core-json-rpc/package.json",
"packages/core-logger-winston/package.json",
"packages/core-logger/package.json",
"packages/core-p2p/package.json",
"packages/core-snapshots-cli/package.json",
"packages/core-snapshots/package.json",
"packages/core-test-utils/package.json",
"packages/core-tester-cli/package.json",
"packages/core-transaction-pool-mem/package.json",
"packages/core-transaction-pool/package.json",
"packages/core-utils/package.json",
"packages/core-vote-report/package.json",
"packages/core-webhooks/package.json",
"packages/core/package.json",
"packages/crypto/package.json"
]
}
}
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"clean": "lerna clean",
"commit": "git-cz",
"lint": "lerna run lint",
"depcheck": "lerna run depcheck",
"prepare": "lerna run prepare",
"test": "cross-env ARK_ENV=test jest --runInBand --detectOpenHandles",
"test:force-exit": "cross-env ARK_ENV=test jest --runInBand --forceExit",
Expand All @@ -22,7 +21,6 @@
"body-parser": "^1.18.3",
"codecov": "^3.1.0",
"cross-env": "^5.2.0",
"depcheck": "^0.6.11",
"docdash": "^1.0.0",
"eslint": "^5.9.0",
"eslint-config-airbnb-base": "^13.1.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/core-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

## 0.2.11 - 2018-12-05

### Fixed

- Take milestones into account for supply calculations

## 0.2.1 - 2018-12-04

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ describe('API 2.0 - Transactions', () => {

const transaction = response.data.data[0]
utils.expectTransaction(transaction)
expect(transaction.id).toBe(transactionId)
expect(transaction.recipient).toBe(recipientAddress)
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core-api/lib/repositories/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BlocksRepository extends Repository {
.from(this.query)
.where(this.query.id.equals(value))

if (Number.isSafeInteger(value)) {
if (Number.isSafeInteger(+value)) {
query.or(this.query.height.equals(value))
}

Expand Down
18 changes: 3 additions & 15 deletions packages/core-api/lib/versions/1/handlers/blocks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const app = require('@arkecosystem/core-container')
const { bignumify } = require('@arkecosystem/core-utils')
const { supplyCalculator } = require('@arkecosystem/core-utils')

const config = app.resolvePlugin('config')
const blockchain = app.resolvePlugin('blockchain')
Expand Down Expand Up @@ -184,15 +184,8 @@ exports.supply = {
*/
handler(request, h) {
const lastBlock = blockchain.getLastBlock()
const constants = config.getConstants(lastBlock.data.height)
const rewards = bignumify(constants.reward).times(
lastBlock.data.height - constants.height,
)

return utils.respondWith({
supply: +bignumify(config.genesisBlock.totalAmount)
.plus(rewards)
.toFixed(),
supply: supplyCalculator.calculate(lastBlock.data.height),
})
},
}
Expand All @@ -209,9 +202,6 @@ exports.status = {
handler(request, h) {
const lastBlock = blockchain.getLastBlock()
const constants = config.getConstants(lastBlock.data.height)
const rewards = bignumify(constants.reward).times(
lastBlock.data.height - constants.height,
)

return utils.respondWith({
epoch: constants.epoch,
Expand All @@ -220,9 +210,7 @@ exports.status = {
milestone: Math.floor(lastBlock.data.height / 3000000),
nethash: config.network.nethash,
reward: constants.reward,
supply: +bignumify(config.genesisBlock.totalAmount)
.plus(rewards)
.toFixed(),
supply: supplyCalculator.calculate(lastBlock.data.height),
})
},
}
11 changes: 2 additions & 9 deletions packages/core-api/lib/versions/2/handlers/blockchain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const app = require('@arkecosystem/core-container')
const { bignumify } = require('@arkecosystem/core-utils')
const { bignumify, supplyCalculator } = require('@arkecosystem/core-utils')

const config = app.resolvePlugin('config')
const blockchain = app.resolvePlugin('blockchain')
Expand All @@ -16,20 +16,13 @@ exports.index = {
handler(request, h) {
const lastBlock = blockchain.getLastBlock()

const constants = config.getConstants(lastBlock.data.height)
const rewards = bignumify(constants.reward).times(
lastBlock.data.height - constants.height,
)

return {
data: {
block: {
height: lastBlock.data.height,
id: lastBlock.data.id,
},
supply: +bignumify(config.genesisBlock.totalAmount)
.plus(rewards)
.toFixed(),
supply: supplyCalculator.calculate(lastBlock.data.height),
},
}
},
Expand Down
5 changes: 2 additions & 3 deletions packages/core-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@arkecosystem/core-api",
"description": "Public API for Ark Core",
"version": "0.2.1",
"version": "0.2.11",
"contributors": [
"Kristjan Košič <kristjan@ark.io>",
"Brian Faust <brian@ark.io>"
Expand All @@ -14,8 +14,7 @@
"test:debug": "cross-env ARK_ENV=test node --inspect-brk ../../node_modules/.bin/jest --runInBand",
"test:watch": "cross-env ARK_ENV=test jest --runInBand --watch",
"test:watch:all": "cross-env ARK_ENV=test jest --runInBand --watchAll",
"lint": "eslint ./ --fix",
"depcheck": "depcheck ./ --ignores=lodash,lodash.*"
"lint": "eslint ./ --fix"
},
"dependencies": {
"@arkecosystem/core-container": "~0.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/core-blockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"test:debug": "cross-env ARK_ENV=test node --inspect-brk ../../node_modules/.bin/jest --runInBand",
"test:watch": "cross-env ARK_ENV=test jest --runInBand --watch",
"test:watch:all": "cross-env ARK_ENV=test jest --runInBand --watchAll",
"lint": "eslint ./ --fix",
"depcheck": "depcheck ./"
"lint": "eslint ./ --fix"
},
"dependencies": {
"@arkecosystem/core-container": "~0.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/core-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"test:debug": "cross-env ARK_ENV=test node --inspect-brk ../../node_modules/.bin/jest --runInBand",
"test:watch": "cross-env ARK_ENV=test jest --runInBand --watch",
"test:watch:all": "cross-env ARK_ENV=test jest --runInBand --watchAll",
"lint": "eslint ./ --fix",
"depcheck": "depcheck ./"
"lint": "eslint ./ --fix"
},
"dependencies": {
"@arkecosystem/crypto": "~0.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/core-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"test:debug": "cross-env ARK_ENV=test node --inspect-brk ../../node_modules/.bin/jest --runInBand",
"test:watch": "cross-env ARK_ENV=test jest --runInBand --watch",
"test:watch:all": "cross-env ARK_ENV=test jest --runInBand --watchAll",
"lint": "eslint ./ --fix",
"depcheck": "depcheck ./ --ignores=lodash,lodash.*"
"lint": "eslint ./ --fix"
},
"dependencies": {
"@arkecosystem/crypto": "~0.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/core-database-postgres/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

## 0.2.1 - 2018-12-05

### Added

- `sender_public_key`, `recipient_id` and `timestamp` indices on the `transactions` table
- `generator_public_key` index on the `blocks` table

## 0.2.0 - 2018-12-03

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP INDEX "blocks_unique";
CREATE INDEX IF NOT EXISTS "blocks_generator_public_key" ON ${schema~}.blocks ("generator_public_key");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX IF NOT EXISTS "transactions_timestamp" ON ${schema~}.transactions ("timestamp");
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE INDEX IF NOT EXISTS "transactions_sender_public_key" ON ${schema~}.transactions ("sender_public_key");
CREATE INDEX IF NOT EXISTS "transactions_recipient_id" ON ${schema~}.transactions ("recipient_id");
3 changes: 3 additions & 0 deletions packages/core-database-postgres/lib/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ module.exports = [
loadQueryFile(__dirname, './20180305300000-create-blocks-table.sql'),
loadQueryFile(__dirname, './20180305400000-create-transactions-table.sql'),
loadQueryFile(__dirname, './20181129400000-add-block_id-index-to-transactions-table.sql'),
loadQueryFile(__dirname, './20181204100000-blocks-generator_public_key-index.sql'),
loadQueryFile(__dirname, './20181204200000-transactions-timestamp-index.sql'),
loadQueryFile(__dirname, './20181204300000-transactions-sender-and-receiver-indexes.sql'),
]
5 changes: 2 additions & 3 deletions packages/core-database-postgres/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@arkecosystem/core-database-postgres",
"description": "PostgreSQL integration for Ark Core",
"version": "0.2.0",
"version": "0.2.1",
"contributors": [
"Brian Faust <brian@ark.io>"
],
Expand All @@ -13,8 +13,7 @@
"test:debug": "cross-env ARK_ENV=test node --inspect-brk ../../node_modules/.bin/jest --runInBand",
"test:watch": "cross-env ARK_ENV=test jest --runInBand --watch",
"test:watch:all": "cross-env ARK_ENV=test jest --runInBand --watchAll",
"lint": "eslint ./ --fix",
"depcheck": "depcheck ./ --ignores=lodash,lodash.*"
"lint": "eslint ./ --fix"
},
"dependencies": {
"@arkecosystem/core-container": "~0.2",
Expand Down
Loading

0 comments on commit aee3d00

Please sign in to comment.