Skip to content

Commit 50ea237

Browse files
authored
Merge pull request #92 from ainblockchain/develop
Release v0.2.3 ready
2 parents 0388221 + ca942f9 commit 50ea237

File tree

15 files changed

+192
-251
lines changed

15 files changed

+192
-251
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ sh setup_ubuntu.sh
3939
```
4040
- Copy files to a sharable folder & install npm packages
4141
```
42-
sh setup_tracker_gcp.sh
42+
source setup_tracker_gcp.sh
4343
```
4444
- Start tracker server job
4545
```
@@ -131,7 +131,7 @@ sh setup_ubuntu.sh
131131
```
132132
- Copy files to a sharable folder & install npm packages
133133
```
134-
sh setup_node_gcp.sh
134+
source setup_node_gcp.sh
135135
```
136136
- Start Node server job
137137
```

blockchain/block-file-patterns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class BlockFilePatterns {
99
* @return {String} A RegEx statement matching the block corresponding to the hash in the given chainPath directory.
1010
*/
1111
static getBlockFilenameByHash(chainPath, hash) {
12-
return `${chainPath}/*-*-*${hash}*.${FILE_NAME_SUFFIX}`;
12+
return `${chainPath}/[0-9]*-*${hash}.${FILE_NAME_SUFFIX}`;
1313
}
1414
/**
1515
* Returns a RegEx query expression for querying all block files in a given chainPath directory.

consensus/block-pool.js

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const get = require('lodash/get');
22
const logger = require('../logger');
33
const { ConsensusConsts } = require('./constants');
4-
const { DEBUG, WriteDbOperations } = require('../constants');
4+
const { WriteDbOperations } = require('../constants');
55
const ChainUtil = require('../chain-util');
66
const LOG_PREFIX = 'BLOCKPOOL';
77

@@ -69,9 +69,7 @@ class BlockPool {
6969
return;
7070
}
7171
const longestChains = this.getLongestNotarizedChainList();
72-
if (DEBUG) {
73-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] longestChains: ${JSON.stringify(longestChains, null, 2)}`);
74-
}
72+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] longestChains: ${JSON.stringify(longestChains, null, 2)}`);
7573
this.longestNotarizedChainTips = longestChains.reduce((a, b) => { a.push(b[b.length - 1].hash); return a; }, []);
7674
}
7775

@@ -87,9 +85,7 @@ class BlockPool {
8785
chain.unshift(withInfo ? currBlockWithInfo : currBlockWithInfo.block);
8886
currBlockWithInfo = this.hashToBlockInfo[currBlockWithInfo.block.last_hash];
8987
}
90-
if (DEBUG) {
91-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] currBlockWithInfo: ${JSON.stringify(currBlockWithInfo, null, 2)}\nfinalizedBlock: ${JSON.stringify(finalizedBlock, null, 2)}`);
92-
}
88+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] currBlockWithInfo: ${JSON.stringify(currBlockWithInfo, null, 2)}\nfinalizedBlock: ${JSON.stringify(finalizedBlock, null, 2)}`);
9389
if (!currBlockWithInfo || !currBlockWithInfo.block) {
9490
logger.error(`[${LOG_PREFIX}:${LOG_SUFFIX}] Block info is missing`);
9591
return [];
@@ -107,9 +103,7 @@ class BlockPool {
107103
const lastFinalized = fromBlock ? fromBlock
108104
: lastBlockNumber < 1 ? { block: this.node.bc.lastBlock(), notarized: true }
109105
: this.hashToBlockInfo[this.node.bc.lastBlock().hash];
110-
if (DEBUG) {
111-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] lastFinalized: ${JSON.stringify(lastFinalized, null, 2)}`);
112-
}
106+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] lastFinalized: ${JSON.stringify(lastFinalized, null, 2)}`);
113107
const chainList = [];
114108
this.dfsLongest(lastFinalized, [], chainList, withInfo);
115109
return chainList;
@@ -130,16 +124,12 @@ class BlockPool {
130124
withInfo ? chainList[0][chainList[0].length - 1].block.number
131125
: chainList[0][chainList[0].length - 1].number : 0;
132126
if (blockNumber > longestNumber) {
133-
if (DEBUG) {
134-
logger.debug(`[blockPool:dfsLongest] New longest chain found: ${JSON.stringify(currentChain, null, 2)}, longestNumber: ${blockNumber}`);
135-
}
127+
logger.debug(`[blockPool:dfsLongest] New longest chain found: ${JSON.stringify(currentChain, null, 2)}, longestNumber: ${blockNumber}`);
136128
chainList.length = 0;
137129
chainList.push([...currentChain]);
138130
longestNumber = blockNumber;
139131
} else if (blockNumber === longestNumber) {
140-
if (DEBUG) {
141-
logger.debug(`[blockPool:dfsLongest] Another longest chain found: ${JSON.stringify(currentChain, null, 2)}, longestNumber: ${blockNumber}`);
142-
}
132+
logger.debug(`[blockPool:dfsLongest] Another longest chain found: ${JSON.stringify(currentChain, null, 2)}, longestNumber: ${blockNumber}`);
143133
chainList.push([...currentChain]);
144134
}
145135
if (!nextBlockSet || !nextBlockSet.size) {
@@ -151,9 +141,7 @@ class BlockPool {
151141
this.dfsLongest(this.hashToBlockInfo[val], currentChain, chainList, withInfo);
152142
}
153143
currentChain.pop();
154-
if (DEBUG) {
155-
logger.debug(`[blockPool:dfsLongest] returning.. currentChain: ${JSON.stringify(currentChain, null, 2)}`);
156-
}
144+
logger.debug(`[blockPool:dfsLongest] returning.. currentChain: ${JSON.stringify(currentChain, null, 2)}`);
157145
}
158146

159147
// A finalizable chain (extension of current finalized chain):
@@ -174,16 +162,12 @@ class BlockPool {
174162
const nextBlockSet = this.hashToNextBlockSet[currentNode.block.hash];
175163
if (!nextBlockSet || !nextBlockSet.size) {
176164
if (BlockPool.endsWithThreeConsecutiveEpochs(currentChain)) {
177-
if (DEBUG) {
178-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No next blocks but found a finalizable chain`);
179-
}
165+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No next blocks but found a finalizable chain`);
180166
const chainCopy = [...currentChain];
181167
currentChain.pop();
182168
return chainCopy;
183169
}
184-
if (DEBUG) {
185-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No next blocks.. returning empty array`);
186-
}
170+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No next blocks.. returning empty array`);
187171
currentChain.pop();
188172
return [...currentChain];
189173
}
@@ -217,9 +201,7 @@ class BlockPool {
217201
getNotarizedBlockByHash(hash) {
218202
const LOG_SUFFIX = 'getNotarizedBlockByHash';
219203
const blockInfo = this.hashToBlockInfo[hash];
220-
if (DEBUG) {
221-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] blockInfo: ${JSON.stringify(blockInfo, null, 2)}`);
222-
}
204+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] blockInfo: ${JSON.stringify(blockInfo, null, 2)}`);
223205
return blockInfo && blockInfo.block && blockInfo.notarized ? blockInfo.block : null;
224206
}
225207

@@ -292,9 +274,7 @@ class BlockPool {
292274
const LOG_SUFFIX = 'addSeenVote';
293275
const blockHash = get(voteTx, 'operation.value.block_hash');
294276
const stake = get(voteTx, 'operation.value.stake');
295-
if (DEBUG) {
296-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] voteTx: ${JSON.stringify(voteTx, null, 2)}, blockHash: ${blockHash}, stake: ${stake}`);
297-
}
277+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] voteTx: ${JSON.stringify(voteTx, null, 2)}, blockHash: ${blockHash}, stake: ${stake}`);
298278
if (!this.hashToBlockInfo[blockHash]) {
299279
this.hashToBlockInfo[blockHash] = {};
300280
}
@@ -317,10 +297,8 @@ class BlockPool {
317297
// FIXME
318298
}
319299
const voter = voteTx.address;
320-
if (DEBUG) {
321-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] voted block: ${JSON.stringify(block, null, 2)}`);
322-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] ${block && block.validators[voter] === stake}`);
323-
}
300+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] voted block: ${JSON.stringify(block, null, 2)}`);
301+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] ${block && block.validators[voter] === stake}`);
324302
if (stake > 0 && block && block.validators[voter] === stake) {
325303
this.hashToBlockInfo[blockHash].tallied += stake;
326304
this.tryUpdateNotarized(blockHash);

consensus/index.js

Lines changed: 24 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const Transaction = require('../tx-pool/transaction');
1111
const PushId = require('../db/push-id');
1212
const ChainUtil = require('../chain-util');
1313
const {
14-
DEBUG,
1514
WriteDbOperations,
1615
ReadDbOperations,
1716
PredefinedDbPaths,
@@ -124,9 +123,7 @@ class Consensus {
124123
// adjust time
125124
try {
126125
const iNTPData = await ntpsync.ntpLocalClockDeltaPromise();
127-
if (DEBUG) {
128-
logger.debug(`(Local Time - NTP Time) Delta = ${iNTPData.minimalNTPLatencyDelta} ms`);
129-
}
126+
logger.debug(`(Local Time - NTP Time) Delta = ${iNTPData.minimalNTPLatencyDelta} ms`);
130127
this.timeAdjustment = iNTPData.minimalNTPLatencyDelta;
131128
} catch (e) {
132129
logger.error(`ntpsync error: ${e}`);
@@ -135,17 +132,11 @@ class Consensus {
135132
currentTime -= this.timeAdjustment;
136133
const absEpoch = Math.floor((currentTime - this.startingTime) / ConsensusConsts.EPOCH_MS);
137134
if (this.state.epoch + 1 < absEpoch) {
138-
if (DEBUG) {
139-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Epoch is too low: ${this.state.epoch} / ${absEpoch}`);
140-
}
135+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Epoch is too low: ${this.state.epoch} / ${absEpoch}`);
141136
} else if (this.state.epoch + 1 > absEpoch) {
142-
if (DEBUG) {
143-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Epoch is too high: ${this.state.epoch} / ${absEpoch}`);
144-
}
145-
}
146-
if (DEBUG) {
147-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Updating epoch at ${currentTime}: ${this.state.epoch} => ${absEpoch}`);
137+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Epoch is too high: ${this.state.epoch} / ${absEpoch}`);
148138
}
139+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Updating epoch at ${currentTime}: ${this.state.epoch} => ${absEpoch}`);
149140
// re-adjust and update epoch
150141
this.state.epoch = absEpoch;
151142
if (this.state.epoch > 1) {
@@ -186,9 +177,7 @@ class Consensus {
186177
const LOG_SUFFIX = 'handleConsensusMessage';
187178

188179
if (this.status !== ConsensusStatus.RUNNING) {
189-
if (DEBUG) {
190-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Consensus status (${this.status}) is not RUNNING (${ConsensusStatus.RUNNING})`);
191-
}
180+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Consensus status (${this.status}) is not RUNNING (${ConsensusStatus.RUNNING})`);
192181
return;
193182
}
194183
if (msg.type !== ConsensusMessageTypes.PROPOSE && msg.type !== ConsensusMessageTypes.VOTE) {
@@ -200,20 +189,16 @@ class Consensus {
200189
return;
201190
}
202191
logger.info(`[${LOG_PREFIX}:${LOG_SUFFIX}] Consensus state - finalized number: ${this.node.bc.lastBlockNumber()} / epoch: ${this.state.epoch}`);
203-
if (DEBUG) {
204-
logger.debug(`Message: ${JSON.stringify(msg.value, null, 2)}`);
205-
}
192+
logger.debug(`Message: ${JSON.stringify(msg.value, null, 2)}`);
206193
if (msg.type === ConsensusMessageTypes.PROPOSE) {
207194
const lastNotarizedBlock = this.getLastNotarizedBlock();
208-
const { proposalBlock, proposalTx } = msg.value;
195+
const { proposalBlock, proposalTx } = msg.value;
209196
if (!proposalBlock || !proposalTx) {
210197
logger.error(`[${LOG_PREFIX}:${LOG_SUFFIX}] Proposal is missing required fields: ${msg.value}`);
211198
return;
212199
}
213200
if (this.node.tp.transactionTracker[proposalTx.hash]) {
214-
if (DEBUG) {
215-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Already have the proposal in my tx tracker`);
216-
}
201+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Already have the proposal in my tx tracker`);
217202
return;
218203
}
219204
if (proposalBlock.number > lastNotarizedBlock.number + 1) {
@@ -234,9 +219,7 @@ class Consensus {
234219
}
235220
} else {
236221
if (this.node.tp.transactionTracker[msg.value.hash]) {
237-
if (DEBUG) {
238-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Already have the vote in my tx tracker`);
239-
}
222+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Already have the vote in my tx tracker`);
240223
return;
241224
}
242225
if (Consensus.isValidConsensusTx(msg.value) && this.checkVote(msg.value)) {
@@ -264,13 +247,9 @@ class Consensus {
264247
this.node.bc.backupDb : this.blockPool.hashToState.get(lastBlock.hash);
265248
const tempState = new DB(null, lastBlock.number - 1);
266249
tempState.setDbToSnapshot(prevState);
267-
if (DEBUG) {
268-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Created a temp state for tx checks`);
269-
}
250+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Created a temp state for tx checks`);
270251
const lastBlockInfo = this.blockPool.hashToBlockInfo[lastBlock.hash];
271-
if (DEBUG) {
272-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] lastBlockInfo: ${JSON.stringify(lastBlockInfo, null, 2)}`);
273-
}
252+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] lastBlockInfo: ${JSON.stringify(lastBlockInfo, null, 2)}`);
274253
// FIXME(minsu or lia): When I am behind and a newly coming node is ahead of me, then I cannot
275254
// get lastBlockInfo from the block-pool. So that, it is not able to create a proper block
276255
// proposal and also cannot pass checkProposal() where checking prevBlockInfo.notarized.
@@ -287,9 +266,7 @@ class Consensus {
287266
})
288267

289268
transactions.forEach(tx => {
290-
if (DEBUG) {
291-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Checking tx ${JSON.stringify(tx, null, 2)}`);
292-
}
269+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Checking tx ${JSON.stringify(tx, null, 2)}`);
293270
if (!ChainUtil.transactionFailed(tempState.executeTransaction(tx))) {
294271
logger.info(`[${LOG_PREFIX}:${LOG_SUFFIX}] tx result: success!`);
295272
validTransactions.push(tx);
@@ -373,13 +350,9 @@ class Consensus {
373350
const { proposer, number, epoch, last_hash } = proposalBlock;
374351
if (number <= this.node.bc.lastBlockNumber()) {
375352
logger.info(`[${LOG_PREFIX}:${LOG_SUFFIX}] There already is a finalized block of the number`);
376-
if (DEBUG) {
377-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] corresponding block info: ${JSON.stringify(this.blockPool.hashToBlockInfo[proposalBlock.hash], null, 2)}`);
378-
}
353+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] corresponding block info: ${JSON.stringify(this.blockPool.hashToBlockInfo[proposalBlock.hash], null, 2)}`);
379354
if (!this.blockPool.hasSeenBlock(proposalBlock)) {
380-
if (DEBUG) {
381-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Adding the proposal to the blockPool for later use`);
382-
}
355+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Adding the proposal to the blockPool for later use`);
383356
this.blockPool.addSeenBlock(proposalBlock, proposalTx);
384357
}
385358
return false;
@@ -388,13 +361,9 @@ class Consensus {
388361
// those can notarize the prevBlock (verify, execute and add the missing votes)
389362
let prevBlockInfo = number === 1 ? this.node.bc.getBlockByNumber(0) : this.blockPool.hashToBlockInfo[last_hash];
390363
const prevBlock = number > 1 ? prevBlockInfo.block : prevBlockInfo;
391-
if (DEBUG) {
392-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] prevBlockInfo: ${JSON.stringify(prevBlockInfo, null, 2)}`);
393-
}
364+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] prevBlockInfo: ${JSON.stringify(prevBlockInfo, null, 2)}`);
394365
if (number !== 1 && (!prevBlockInfo || !prevBlockInfo.block)) {
395-
if (DEBUG) {
396-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No notarized block at number ${number - 1} with hash ${last_hash}`);
397-
}
366+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No notarized block at number ${number - 1} with hash ${last_hash}`);
398367
return;
399368
}
400369
const validators = prevBlock.validators;
@@ -431,9 +400,7 @@ class Consensus {
431400
// TODO(lia): do more checks on the prevBlockProposal
432401
this.blockPool.addSeenBlock(prevBlockInfo.block, prevBlockProposal);
433402
} else {
434-
if (DEBUG) {
435-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Prev block is missing its proposal`);
436-
}
403+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Prev block is missing its proposal`);
437404
return false;
438405
}
439406
}
@@ -607,13 +574,9 @@ class Consensus {
607574
tryFinalize() {
608575
const LOG_SUFFIX = 'tryFinalize';
609576
let finalizableChain = this.blockPool.getFinalizableChain();
610-
if (DEBUG) {
611-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] finalizableChain: ${JSON.stringify(finalizableChain, null, 2)}`);
612-
}
577+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] finalizableChain: ${JSON.stringify(finalizableChain, null, 2)}`);
613578
if (!finalizableChain || !finalizableChain.length) {
614-
if (DEBUG) {
615-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No notarized chain with 3 consecutive epochs yet`);
616-
}
579+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] No notarized chain with 3 consecutive epochs yet`);
617580
return;
618581
}
619582
// Discard the last block (but save it for a future finalization)
@@ -639,9 +602,7 @@ class Consensus {
639602
if (!blockList || !blockList.length) return;
640603
let lastVerifiedBlock;
641604
blockList.forEach(blockInfo => {
642-
if (DEBUG) {
643-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Adding notarized chain's block: ${JSON.stringify(blockInfo, null, 2)}`);
644-
}
605+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] Adding notarized chain's block: ${JSON.stringify(blockInfo, null, 2)}`);
645606
let lastNotarizedBlock = this.getLastNotarizedBlock();
646607
logger.info(`[${LOG_PREFIX}:${LOG_SUFFIX}] Current lastNotarizedBlock: ${lastNotarizedBlock.number} / ${lastNotarizedBlock.epoch}`);
647608
if (!blockInfo.block || !blockInfo.proposal || blockInfo.block.number < lastNotarizedBlock.number) {
@@ -676,9 +637,7 @@ class Consensus {
676637
getLastNotarizedBlock() {
677638
const LOG_SUFFIX = 'getLastNotarizedBlock';
678639
let candidate = this.node.bc.lastBlock();
679-
if (DEBUG) {
680-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] longestNotarizedChainTips: ${JSON.stringify(this.blockPool.longestNotarizedChainTips, null, 2)}`);
681-
}
640+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] longestNotarizedChainTips: ${JSON.stringify(this.blockPool.longestNotarizedChainTips, null, 2)}`);
682641
this.blockPool.longestNotarizedChainTips.forEach(chainTip => {
683642
const block = _.get(this.blockPool.hashToBlockInfo[chainTip], 'block');
684643
if (!block) return;
@@ -724,9 +683,7 @@ class Consensus {
724683
while (chain.length) {
725684
// apply last_votes and transactions
726685
const block = chain.shift();
727-
if (DEBUG) {
728-
logger.debug(`[[${LOG_PREFIX}:${LOG_SUFFIX}] applying block ${JSON.stringify(block)}`);
729-
}
686+
logger.debug(`[[${LOG_PREFIX}:${LOG_SUFFIX}] applying block ${JSON.stringify(block)}`);
730687
snapshot.executeTransactionList(block.last_votes);
731688
snapshot.executeTransactionList(block.transactions);
732689
snapshot.blockNumberSnapshot = block.number;
@@ -742,9 +699,7 @@ class Consensus {
742699
logger.error(`[${LOG_PREFIX}:${LOG_SUFFIX}] No validators voted`);
743700
throw Error('No validators voted');
744701
}
745-
if (DEBUG) {
746-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] current epoch: ${this.state.epoch}\nblock hash: ${blockHash}\nvotes: ${JSON.stringify(blockInfo.votes, null, 2)}`);
747-
}
702+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] current epoch: ${this.state.epoch}\nblock hash: ${blockHash}\nvotes: ${JSON.stringify(blockInfo.votes, null, 2)}`);
748703
const validators = {};
749704
blockInfo.votes.forEach(vote => {
750705
validators[vote.address] = _.get(vote, 'operation.value.stake');
@@ -958,9 +913,7 @@ class Consensus {
958913

959914
static selectProposer(seed, validators) {
960915
const LOG_SUFFIX = 'selectProposer';
961-
if (DEBUG) {
962-
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] seed: ${seed}, validators: ${JSON.stringify(validators)}`);
963-
}
916+
logger.debug(`[${LOG_PREFIX}:${LOG_SUFFIX}] seed: ${seed}, validators: ${JSON.stringify(validators)}`);
964917
const alphabeticallyOrderedValidators = Object.keys(validators).sort();
965918
const totalAtStake = Object.values(validators).reduce((a, b) => { return a + b; }, 0);
966919
const randomNumGenerator = seedrandom(seed);

0 commit comments

Comments
 (0)