Skip to content

Commit

Permalink
fix: Core-SV-009 and Core-SV-010 (#2042)
Browse files Browse the repository at this point in the history
  • Loading branch information
spkjp authored and faustbrian committed Jan 31, 2019
1 parent 078a653 commit 8a62f55
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
30 changes: 14 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
- ./packages/core-vote-report/node_modules
- ./packages/core-webhooks/node_modules
- ./packages/crypto/node_modules
- ./packages/utils/node_modules
- ./node_modules
- run:
name: Create .ark/database directory
Expand All @@ -78,8 +77,8 @@ jobs:
./packages/core-json-rpc/ ./packages/core-http-utils/
./packages/core-event-emitter/ ./packages/core-elasticsearch/
./packages/core-database-postgres/ ./packages/core-config/
./packages/core-interfaces/ --detectOpenHandles --runInBand
--forceExit --ci --coverage | tee test_output.txt
./packages/core/ --detectOpenHandles --runInBand --forceExit --ci
--coverage | tee test_output.txt
- run:
name: Last 1000 lines of test output
when: on_fail
Expand Down Expand Up @@ -151,7 +150,6 @@ jobs:
- ./packages/core-vote-report/node_modules
- ./packages/core-webhooks/node_modules
- ./packages/crypto/node_modules
- ./packages/utils/node_modules
- ./node_modules
- run:
name: Create .ark/database directory
Expand All @@ -162,10 +160,11 @@ jobs:
./node_modules/.bin/cross-env ARK_ENV=test ./node_modules/.bin/jest
./packages/crypto/ ./packages/core-utils/
./packages/core-tester-cli/ ./packages/core-snapshots/
./packages/core-logger/ ./packages/core-api/ ./packages/core-forger/
./packages/core-error-tracker-bugsnag/ ./packages/core-debugger-cli/
./packages/core-container/ ./packages/core/ --detectOpenHandles
--runInBand --forceExit --ci --coverage | tee test_output.txt
./packages/core-logger/ ./packages/core-interfaces/
./packages/core-forger/ ./packages/core-error-tracker-bugsnag/
./packages/core-debugger-cli/ ./packages/core-container/
./packages/core-api/ --detectOpenHandles --runInBand --forceExit
--ci --coverage | tee test_output.txt
- run:
name: Last 1000 lines of test output
when: on_fail
Expand Down Expand Up @@ -237,7 +236,6 @@ jobs:
- ./packages/core-vote-report/node_modules
- ./packages/core-webhooks/node_modules
- ./packages/crypto/node_modules
- ./packages/utils/node_modules
- ./node_modules
- run:
name: Create .ark/database directory
Expand All @@ -246,13 +244,13 @@ jobs:
name: Test
command: >
./node_modules/.bin/cross-env ARK_ENV=test ./node_modules/.bin/jest
./packages/utils/ ./packages/core-vote-report/
./packages/core-transaction-pool/ ./packages/core-snapshots-cli/
./packages/core-logger-winston/ ./packages/core-jest-matchers/
./packages/core-graphql/ ./packages/core-error-tracker-sentry/
./packages/core-deployer/ ./packages/core-database/
./packages/core-blockchain/ --detectOpenHandles --runInBand
--forceExit --ci --coverage | tee test_output.txt
./packages/core-vote-report/ ./packages/core-transaction-pool/
./packages/core-snapshots-cli/ ./packages/core-logger-winston/
./packages/core-jest-matchers/ ./packages/core-graphql/
./packages/core-error-tracker-sentry/ ./packages/core-deployer/
./packages/core-database/ ./packages/core-blockchain/
--detectOpenHandles --runInBand --forceExit --ci --coverage | tee
test_output.txt
- run:
name: Last 1000 lines of test output
when: on_fail
Expand Down
4 changes: 4 additions & 0 deletions packages/core-blockchain/lib/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ module.exports = class Blockchain {
logger.debug(
`Block ${block.data.height.toLocaleString()} just received :chains:`,
)
} else if (block.data.timestamp < lastBlock.data.timestamp) {
logger.debug(
`Block ${block.data.height.toLocaleString()} disregarded because it has a lower timestamp than the last block :bangbang:`
)
} else {
const isValid = await this.database.validateForkedBlock(block)

Expand Down
4 changes: 4 additions & 0 deletions packages/core-p2p/__tests__/utils/is-myself.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ describe('isMyself', () => {
expect(isMyself('192.167.22.1')).toBeFalse()
})

it('should be ok for non-quad-dotted localhost addresses', () => {
expect(isMyself('2130706433')).toBeTrue()
})

it('should be ok for LAN addresses', () => {
const interfaces = os.networkInterfaces()
const addresses = []
Expand Down
7 changes: 7 additions & 0 deletions packages/core-p2p/lib/utils/is-myself.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint max-len: "off" */

const os = require('os')
const ip = require("ipaddr.js")

/**
* Checks if IP belongs to local computer (all network interfaces are checked)
Expand All @@ -10,6 +11,12 @@ const os = require('os')
module.exports = ipAddress => {
const interfaces = os.networkInterfaces()

try {
ipAddress = ip.parse(ipAddress).toString();
} catch (error) {
return true;
}

return (
ipAddress.startsWith('127.') ||
ipAddress.startsWith('0.') ||
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@arkecosystem/core",
"description": "Core of the Ark Blockchain",
"version": "2.0.18",
"version": "2.0.19",
"contributors": [
"François-Xavier Thoorens <[email protected]>",
"Kristjan Košič <[email protected]>",
Expand Down

0 comments on commit 8a62f55

Please sign in to comment.