New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@liskhq/lisk-bft

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liskhq/lisk-bft - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

LICENSE

18

dist-node/bft.js

@@ -10,2 +10,3 @@ "use strict";

const types_1 = require("./types");
const constant_1 = require("./constant");
exports.EVENT_BFT_BLOCK_FINALIZED = 'EVENT_BFT_BLOCK_FINALIZED';

@@ -85,14 +86,19 @@ exports.BFTFinalizedHeightCodecSchema = {

assert(blockHeader, 'No block was provided to be verified');
const roundsThreshold = 3;
const validators = await lisk_chain_1.getValidators(stateStore);
const numberOfVotingValidators = validators.filter(validator => validator.isConsensusParticipant).length;
const heightThreshold = numberOfVotingValidators * roundsThreshold;
const heightThreshold = numberOfVotingValidators * constant_1.BFT_ROUND_THRESHOLD;
if (blockHeader.asset.maxHeightPreviouslyForged === 0) {
return true;
}
if (blockHeader.height <= blockHeader.asset.maxHeightPreviouslyForged) {
return false;
}
if (blockHeader.height - blockHeader.asset.maxHeightPreviouslyForged > heightThreshold) {
return true;
}
const maxHeightPreviouslyForgedBlock = stateStore.chain.lastBlockHeaders.find(bftHeader => bftHeader.height === blockHeader.asset.maxHeightPreviouslyForged);
if (!maxHeightPreviouslyForgedBlock ||
blockHeader.asset.maxHeightPreviouslyForged >= blockHeader.height ||
(blockHeader.height - blockHeader.asset.maxHeightPreviouslyForged <= heightThreshold &&
!blockHeader.generatorPublicKey.equals(maxHeightPreviouslyForgedBlock.generatorPublicKey))) {
if (!maxHeightPreviouslyForgedBlock) {
throw new Error(`Block at height ${blockHeader.asset.maxHeightPreviouslyForged} must be in the lastBlockHeaders.`);
}
if (!blockHeader.generatorPublicKey.equals(maxHeightPreviouslyForgedBlock.generatorPublicKey)) {
return false;

@@ -99,0 +105,0 @@ }

{
"name": "@liskhq/lisk-bft",
"version": "0.2.0",
"version": "0.2.1",
"description": "Byzantine fault tolerance implementation according to the Lisk protocol",

@@ -72,3 +72,4 @@ "author": "Lisk Foundation <admin@lisk.io>, lightcurve GmbH <admin@lightcurve.io>",

"typescript": "3.8.3"
}
},
"gitHead": "4db44a150d38c5cf1e428f78922073b3d314b29f"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc