Skip to content

Commit

Permalink
Merge branch 'master' into 2.7-merge-master
Browse files Browse the repository at this point in the history
  • Loading branch information
air1one committed Sep 9, 2020
2 parents 3b12c70 + c1f7c7a commit b8afdb4
Show file tree
Hide file tree
Showing 9 changed files with 1,098 additions and 71 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.6.54] - 2020-09-09

### Changed

- Verify peer claimed state (24a8b044, @air1one)

### Fixed

- Use head from utils (da13465e, @air1one)

## [2.6.52] - 2020-08-11

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/core-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@arkecosystem/core-transactions": "^2.7.0-next.0",
"@arkecosystem/core-utils": "^2.7.0-next.0",
"@arkecosystem/crypto": "^2.7.0-next.0",
"@arkecosystem/utils": "^1.1",
"@arkecosystem/utils": "^1.2",
"@hapi/boom": "^8.0.0",
"@hapi/joi": "^15.1.0",
"ajv": "^6.10.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-database-postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@arkecosystem/core-transactions": "^2.7.0-next.0",
"@arkecosystem/core-utils": "^2.7.0-next.0",
"@arkecosystem/crypto": "^2.7.0-next.0",
"@arkecosystem/utils": "^1.1",
"@arkecosystem/utils": "^1.2",
"bluebird": "^3.5.5",
"cpy-cli": "^2.0.0",
"dayjs": "^1.8.15",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@arkecosystem/core-transactions": "^2.7.0-next.0",
"@arkecosystem/core-utils": "^2.7.0-next.0",
"@arkecosystem/crypto": "^2.7.0-next.0",
"@arkecosystem/utils": "^1.1",
"@arkecosystem/utils": "^1.2",
"dottie": "^2.0.1",
"lodash.clonedeep": "^4.5.0",
"lodash.compact": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-jest-matchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@arkecosystem/core-container": "^2.7.0-next.0",
"@arkecosystem/crypto": "^2.7.0-next.0",
"@arkecosystem/utils": "^1.1",
"@arkecosystem/utils": "^1.2",
"bip39": "^3.0.2",
"got": "^9.6.0",
"jest-extended": "^0.11.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/core-p2p/src/peer-communicator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app } from "@arkecosystem/core-container";
import { EventEmitter, Logger, P2P } from "@arkecosystem/core-interfaces";
import { httpie } from "@arkecosystem/core-utils";
import { Blocks, Interfaces, Transactions, Validation } from "@arkecosystem/crypto";
import { http } from "@arkecosystem/utils";
import dayjs from "dayjs";
import delay from "delay";
import { SCClientSocket } from "socketcluster-client";
Expand Down Expand Up @@ -101,9 +101,9 @@ export class PeerCommunicator implements P2P.IPeerCommunicator {
Object.entries(peer.plugins).map(async ([name, plugin]) => {
peer.ports[name] = -1;
try {
const { status } = await httpie.head(`http://${peer.ip}:${plugin.port}/`);
const { statusCode } = await http.head(`http://${peer.ip}:${plugin.port}/`);

if (status === 200) {
if (statusCode === 200) {
peer.ports[name] = plugin.port;
}
} catch {
Expand Down
9 changes: 5 additions & 4 deletions packages/core-p2p/src/peer-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class PeerVerifier {
claimedState: P2P.IPeerState,
deadline: number,
): Promise<PeerVerificationResult | undefined> {
if (!this.checkStateHeader(claimedState)) {
if (!(await this.checkStateHeader(claimedState))) {
return undefined;
}

Expand All @@ -102,7 +102,7 @@ export class PeerVerifier {
return new PeerVerificationResult(ourHeight, claimedHeight, highestCommonBlockHeight);
}

private checkStateHeader(claimedState: P2P.IPeerState): boolean {
private async checkStateHeader(claimedState: P2P.IPeerState): Promise<boolean> {
const blockHeader: Interfaces.IBlockData = claimedState.header as Interfaces.IBlockData;
const claimedHeight: number = Number(blockHeader.height);
if (claimedHeight !== claimedState.height) {
Expand All @@ -126,8 +126,9 @@ export class PeerVerifier {
return true;
}

const claimedBlock: Interfaces.IBlock = Blocks.BlockFactory.fromData(blockHeader);
if (claimedBlock.verifySignature()) {
const roundInfo = roundCalculator.calculateRound(claimedHeight);
const delegates = await this.getDelegatesByRound(roundInfo);
if (await this.verifyPeerBlock(blockHeader, claimedHeight, delegates)) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"prepublishOnly": "yarn build:rollup"
},
"dependencies": {
"@arkecosystem/utils": "^1.1",
"@arkecosystem/utils": "^1.2",
"@types/bytebuffer": "^5.0.40",
"ajv": "^6.10.2",
"ajv-keywords": "^3.4.1",
Expand Down
Loading

0 comments on commit b8afdb4

Please sign in to comment.