From 3881a513e13e3566ca301abc85c7299a6a0d7f25 Mon Sep 17 00:00:00 2001 From: Daniel Kronovet Date: Thu, 10 Feb 2022 11:25:33 -0800 Subject: [PATCH] TEMP --- packages/reputation-miner/ReputationMiner.js | 4 ++-- packages/reputation-miner/ReputationMinerClient.js | 4 ++++ packages/reputation-miner/bin/index.js | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/reputation-miner/ReputationMiner.js b/packages/reputation-miner/ReputationMiner.js index aa4904b5dd..c9e3eed5d9 100644 --- a/packages/reputation-miner/ReputationMiner.js +++ b/packages/reputation-miner/ReputationMiner.js @@ -1356,7 +1356,7 @@ class ReputationMiner { filter.fromBlock = blockNumber; const events = await this.realProvider.getLogs(filter); let localHash = await this.reputationTree.getRootHash(); - let applyLogs = false; + let applyLogs = true; console.log(`Beginning sync from block ${blockNumber} with ${events.length} cycles`) @@ -1512,7 +1512,7 @@ class ReputationMiner { } const currentStateHash = await this.reputationTree.getRootHash(); if (currentStateHash !== reputationRootHash) { - console.log("WARNING: The supplied state failed to be recreated successfully. Are you sure it was saved?"); + console.log(`WARNING: The supplied state ${reputationRootHash} failed to be recreated successfully. Are you sure it was saved?`); } else { console.log(`Reputation state ${reputationRootHash} was loaded successfully.`); } diff --git a/packages/reputation-miner/ReputationMinerClient.js b/packages/reputation-miner/ReputationMinerClient.js index 6d926b2480..d290d673ed 100644 --- a/packages/reputation-miner/ReputationMinerClient.js +++ b/packages/reputation-miner/ReputationMinerClient.js @@ -272,9 +272,13 @@ class ReputationMinerClient { // Get latest state from database if available, otherwise sync to current state on-chain await this._miner.createDB(); + this._adapter.log(`Attempting to load latest on-chain state ${latestConfirmedReputationHash}`); await this._miner.loadState(latestConfirmedReputationHash); if (this._miner.nReputations.eq(0)) { this._adapter.log("Latest state not found - need to sync"); + if (startingHash !== undefined) { + await this._miner.loadState(startingHash); + } await this._miner.sync(startingBlock, true); } diff --git a/packages/reputation-miner/bin/index.js b/packages/reputation-miner/bin/index.js index 9635bf94cb..90d593b5bc 100644 --- a/packages/reputation-miner/bin/index.js +++ b/packages/reputation-miner/bin/index.js @@ -45,7 +45,7 @@ class RetryProvider extends ethers.providers.StaticJsonRpcProvider { static attemptCheck(err, attemptNumber){ console.log("Retrying RPC request #", attemptNumber); - if (attemptNumber === 5){ + if (attemptNumber === 1000){ return false; } return true; @@ -59,7 +59,7 @@ class RetryProvider extends ethers.providers.StaticJsonRpcProvider { // method is the method name (e.g. getBalance) and params is an // object with normalized values passed in, depending on the method perform(method, params) { - return backoff(() => super.perform(method, params), {retry: RetryProvider.attemptCheck, startingDelay: 1000}); + return backoff(() => super.perform(method, params), {retry: RetryProvider.attemptCheck, startingDelay: 1000, numOfAttempts: 1000, timeMultiple: 1}); } }