From 2ff3fad6034a9040f70e978c89a8a65444aafa0f Mon Sep 17 00:00:00 2001 From: Ev Date: Thu, 21 Jun 2018 17:55:47 -0300 Subject: [PATCH] Develop into master (#3964) * Release candidate version * fix json formatting * Make tests readable again * Using same node version as electron * Update eslint * Add eslint-plugin-import * Add ecmaVersion and globals * Add eslint-plugin-react * Update prettier * Set env es6 * Enable attaching geth with a private network (#3916) * Better checking of blockNumber * reject promise if unknown network * Better setting of network in store * Remove console.logs * Removes stale test * Disables other networks on private * Fix showing clientUpdateAvailable popup * update to geth 1.8.10 (#3925) * Enabling linux .deb builds (#3914) * Temporarily disabling tests, so we skip to the build process * Enabling .deb builds * Adding gulp verify-artifacts * Add gulp task to pipeline * Re-enabling tests on Travis * unzip package naming * Removing node-unzip-2 from package.json (already included in subdependency) * Using ethereum-client-binaries from npm instead of github * Introduces local debug server (#3922) * Introduces local debug server * Move `node-unzip-2` from devDependencies to dependencies * Fresh install (#3941) * Install wallet deps prior to building (#3940) * When gas estimate fails, defaults to 1M gas but allow tx (#3946) * When gas estimate fails, defaults to 1M gas but allow tx * Allow eth_estimateGas to route to Infura * Adds local wallet in asar file (#3951) * load wallet from local asar package * refactoring exec statement * Minor refactor * Cleaning yarn.lock conflicted strings; adding asar package * Local wallet inside app.asar * Update README.md * layout changes for admin tab * * Add gulp pack-wallet to postinstall script * In pack-wallet: Remove ./meteor-dapp-wallet after generating ./wallet * Add ./wallet to .gitignore * change breadcrumb behavior * Gracefully handle ws errors * Disables wallet refreshing * Add meteor-build-client to devDependencies so it does not need to be installed globally * Updates test to reflect removed wallet url input * Set wallet as first tab * Change default browser url * Update/improve sortable code * Enabling partition mode for local wallet * Dealing with local files url matching * Updating test case * Skips connect on account creation (#3963) * Fixes routing certain jsonrpc requests to local node in production (#3966) * Fix routing jsonrpc requests to local node in production * Fix showing log dir if log has been rotated * Remove debug logs * Update infura websockets url to include mist tracking * update geth to 1.8.11 (#3962) * Gas estimation fixes (#3970) * Changing hardcoded block gas limit * Fixing promise; Changing gasAmount fallback value * Handling timeouts better * Fixes disabled menu buttons (#3967) --- clientBinaries.json | 42 ++++---- .../sendTransactionConfirmation.js | 95 +++++++++++-------- modules/constants.js | 8 +- modules/ipc/methods/base.js | 12 ++- modules/ipcCommunicator.js | 2 +- modules/menuItems.js | 17 ++-- 6 files changed, 99 insertions(+), 77 deletions(-) diff --git a/clientBinaries.json b/clientBinaries.json index a2aecd87a..2fdafbac3 100644 --- a/clientBinaries.json +++ b/clientBinaries.json @@ -1,38 +1,38 @@ { "clients": { "Geth": { - "version": "1.8.10", + "version": "1.8.11", "platforms": { "linux": { "x64": { "download": { "url": - "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.8.10-eae63c51.tar.gz", + "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.8.11-dea1ce05.tar.gz", "type": "tar", - "md5": "a174b97e3c4e10f9909e00c0dd1c82d9", - "bin": "geth-linux-amd64-1.8.10-eae63c51/geth" + "md5": "138ba7775b1e9076d345fef2968121e1", + "bin": "geth-linux-amd64-1.8.11-dea1ce05/geth" }, "bin": "geth", "commands": { "sanity": { "args": ["version"], - "output": ["Geth", "1.8.10"] + "output": ["Geth", "1.8.11"] } } }, "ia32": { "download": { "url": - "https://gethstore.blob.core.windows.net/builds/geth-linux-386-1.8.10-eae63c51.tar.gz", + "https://gethstore.blob.core.windows.net/builds/geth-linux-386-1.8.11-dea1ce05.tar.gz", "type": "tar", - "md5": "db9afd2de5721c055a1e964d3c8d02d3", - "bin": "geth-linux-386-1.8.10-eae63c51/geth" + "md5": "d288b4ec137b93a8d0275ccad246920f", + "bin": "geth-linux-386-1.8.11-dea1ce05/geth" }, "bin": "geth", "commands": { "sanity": { "args": ["version"], - "output": ["Geth", "1.8.10"] + "output": ["Geth", "1.8.11"] } } } @@ -41,16 +41,16 @@ "x64": { "download": { "url": - "https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.8.10-eae63c51.tar.gz", + "https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.8.11-dea1ce05.tar.gz", "type": "tar", - "md5": "720620516fb9978d511a99976de475a2", - "bin": "geth-darwin-amd64-1.8.10-eae63c51/geth" + "md5": "2ddbe0b5dcf53a0afc3bea6a222f1b98", + "bin": "geth-darwin-amd64-1.8.11-dea1ce05/geth" }, "bin": "geth", "commands": { "sanity": { "args": ["version"], - "output": ["Geth", "1.8.10"] + "output": ["Geth", "1.8.11"] } } } @@ -59,32 +59,32 @@ "x64": { "download": { "url": - "https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.8.10-eae63c51.zip", + "https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.8.11-dea1ce05.zip", "type": "zip", - "md5": "ece24b542804ff92f79641c6ac6600df", - "bin": "geth-windows-amd64-1.8.10-eae63c51\\geth.exe" + "md5": "60f6645cf1e38a65b315aee6ce3ce664", + "bin": "geth-windows-amd64-1.8.11-dea1ce05\\geth.exe" }, "bin": "geth.exe", "commands": { "sanity": { "args": ["version"], - "output": ["Geth", "1.8.10"] + "output": ["Geth", "1.8.11"] } } }, "ia32": { "download": { "url": - "https://gethstore.blob.core.windows.net/builds/geth-windows-386-1.8.10-eae63c51.zip", + "https://gethstore.blob.core.windows.net/builds/geth-windows-386-1.8.11-dea1ce05.zip", "type": "zip", - "md5": "859e0553a459e970d5b07171621dbf8c", - "bin": "geth-windows-386-1.8.10-eae63c51\\geth.exe" + "md5": "b96d623b5db46c323a649e956f855423", + "bin": "geth-windows-386-1.8.11-dea1ce05\\geth.exe" }, "bin": "geth.exe", "commands": { "sanity": { "args": ["version"], - "output": ["Geth", "1.8.10"] + "output": ["Geth", "1.8.11"] } } } diff --git a/interface/client/templates/popupWindows/sendTransactionConfirmation.js b/interface/client/templates/popupWindows/sendTransactionConfirmation.js index 78528142c..7be9f89c4 100644 --- a/interface/client/templates/popupWindows/sendTransactionConfirmation.js +++ b/interface/client/templates/popupWindows/sendTransactionConfirmation.js @@ -14,7 +14,7 @@ var setWindowSize = function(template) { }); }; -var defaultEstimateGas = 1000000; +var defaultEstimateGas = 3000000; /** The sendTransaction confirmation popup window template @@ -115,7 +115,7 @@ Template['popupWindows_sendTransactionConfirmation'].onCreated(function() { TemplateVar.get('estimatedGas') > Number(TemplateVar.get('providedGas')) ) { TemplateVar.set('gasError', 'notEnoughGas'); - } else if (TemplateVar.get('estimatedGas') > 4000000) { + } else if (TemplateVar.get('estimatedGas') > 8000000) { TemplateVar.set('gasError', 'overBlockGasLimit'); } else if (TemplateVar.get('estimatedGas') == defaultEstimateGas) { TemplateVar.set('gasError', 'defaultGas'); @@ -202,48 +202,69 @@ Template['popupWindows_sendTransactionConfirmation'].onCreated(function() { var estimateData = _.clone(data); estimateData.gas = defaultEstimateGas; - web3.eth.estimateGas(estimateData, function(e, res) { - console.log('Estimated gas: ', res, e); - if (!e && res) { - // set the gas to the estimation, if not provided or lower - Tracker.nonreactive(function() { - var gas = Number(TemplateVar.get(template, 'providedGas')); - - if (res === defaultEstimateGas) { - return TemplateVar.set(template, 'estimatedGas', 'invalid'); - } - - const estimatedGas = web3.utils.toBN(res || 0); - TemplateVar.set(template, 'estimatedGas', estimatedGas.toNumber()); - if (!gas && res) { - TemplateVar.set( - template, - 'providedGas', - estimatedGas.add(web3.utils.toBN(100000)).toNumber() - ); - TemplateVar.set( - template, - 'initialProvidedGas', - estimatedGas.add(web3.utils.toBN(100000)).toNumber() - ); - } - }); - } else { - TemplateVar.set(template, 'estimatedGas', defaultEstimateGas); - TemplateVar.set(template, 'providedGas', defaultEstimateGas); - } - TemplateVar.set(template, 'gasLoading', false); - }); // In case estimateGas fails returning // (which seems to be happening in manual testing) // We'll set gasLoading back to false after 10s // so the user can see an error message - setTimeout(() => { + const gasEstimationFailed = e => { + console.log( + 'Gas estimation failed. Falling back to max(provided, default) value', + e + ); TemplateVar.set(template, 'gasLoading', false); TemplateVar.set(template, 'estimatedGas', defaultEstimateGas); - TemplateVar.set(template, 'providedGas', defaultEstimateGas); - }, 25000); + TemplateVar.set( + template, + 'providedGas', + Math.max(gas, defaultEstimateGas) + ); + }; + + var estimationFailEvent = setTimeout(gasEstimationFailed, 20000); + + web3.eth + .estimateGas(estimateData) + .then(function(value, error) { + clearTimeout(estimationFailEvent); + + console.log('Estimated gas: ', value, error); + if (!error && value) { + // set the gas to the estimation, if not provided or lower + Tracker.nonreactive(function() { + var gas = Number(TemplateVar.get(template, 'providedGas')); + + if (value === defaultEstimateGas) { + return TemplateVar.set(template, 'estimatedGas', 'invalid'); + } + + const estimatedGas = web3.utils.toBN(value || 0); + TemplateVar.set( + template, + 'estimatedGas', + estimatedGas.toNumber() + ); + + if (!gas && value) { + TemplateVar.set( + template, + 'providedGas', + estimatedGas.add(web3.utils.toBN(100000)).toNumber() + ); + TemplateVar.set( + template, + 'initialProvidedGas', + estimatedGas.add(web3.utils.toBN(100000)).toNumber() + ); + } + }); + } else { + TemplateVar.set(template, 'estimatedGas', defaultEstimateGas); + TemplateVar.set(template, 'providedGas', defaultEstimateGas); + } + TemplateVar.set(template, 'gasLoading', false); + }) + .catch(gasEstimationFailed); } }); }); diff --git a/modules/constants.js b/modules/constants.js index 24677932d..e36f57953 100644 --- a/modules/constants.js +++ b/modules/constants.js @@ -7,10 +7,10 @@ export const InfuraEndpoints = { Kovan: 'https://kovan.infura.io/mist' }, websockets: { - Main: 'wss://mainnet.infura.io/ws', - Ropsten: 'wss://ropsten.infura.io/ws', - Rinkeby: 'wss://rinkeby.infura.io/ws', - Kovan: 'wss://kovan.infura.io/ws' + Main: 'wss://mainnet.infura.io/ws/mist', + Ropsten: 'wss://ropsten.infura.io/ws/mist', + Rinkeby: 'wss://rinkeby.infura.io/ws/mist', + Kovan: 'wss://kovan.infura.io/ws/mist' } }, ipfs: { diff --git a/modules/ipc/methods/base.js b/modules/ipc/methods/base.js index 64293e9d1..dbe20bee2 100644 --- a/modules/ipc/methods/base.js +++ b/modules/ipc/methods/base.js @@ -115,18 +115,20 @@ module.exports = class BaseProcessor { } // 3. the method is - // net_peerCount|eth_syncing|eth_subscribe[syncing] - // originating from the mist interface + // net_peerCount | eth_syncing | eth_subscribe[syncing] + // and is originating from the mist interface + // dev: localhost:3000, production: app.asar/interface/index.html if ( conn && conn.owner && conn.owner.history && - conn.owner.history[0].startsWith('http://localhost:3000') + (conn.owner.history[0].startsWith('http://localhost:3000') || + conn.owner.history[0].indexOf('app.asar/interface/index.html') > -1) ) { if ( + method === 'net_peerCount' || method === 'eth_syncing' || - (method === 'eth_subscribe' && payload.params[0] === 'syncing') || - method === 'net_peerCount' + (method === 'eth_subscribe' && payload.params[0] === 'syncing') ) { return false; } diff --git a/modules/ipcCommunicator.js b/modules/ipcCommunicator.js index fc3ef8f59..af22bc278 100644 --- a/modules/ipcCommunicator.js +++ b/modules/ipcCommunicator.js @@ -259,7 +259,7 @@ ipc.on('mistAPI_requestAccount', e => { } else { // Mist // if coming from wallet, skip connect, go straight to create - if (e.sender.history[0] === 'https://wallet.ethereum.org/') { + if (e.sender.history[0].includes(`file://${dirname}/wallet/index.html`)) { createAccountPopup(e); } else { Windows.createPopup('connectAccount', { ownerId: e.sender.id }); diff --git a/modules/menuItems.js b/modules/menuItems.js index 0800878a1..588d2dc18 100644 --- a/modules/menuItems.js +++ b/modules/menuItems.js @@ -494,9 +494,14 @@ let menuTempl = function(webviews) { label: i18n.t('mist.applicationMenu.develop.logFiles'), click() { try { - shell.showItemInFolder( + const shown = shell.showItemInFolder( path.join(Settings.userDataPath, 'logs', 'all.log') ); + if (!shown) { + shell.showItemInFolder( + path.join(Settings.userDataPath, 'logs', 'all.log.0') + ); + } } catch (error) { log.error(error); } @@ -599,10 +604,7 @@ let menuTempl = function(webviews) { submenu: [ { label: i18n.t('mist.applicationMenu.develop.syncModeLight'), - enabled: - ethereumNode.isOwnNode && - ethereumNode.isGeth && - !ethereumNode.isDevNetwork, + enabled: ethereumNode.isOwnNode && !ethereumNode.isDevNetwork, checked: store.getState().nodes.local.syncMode === 'light', type: 'checkbox', click() { @@ -629,10 +631,7 @@ let menuTempl = function(webviews) { }, { label: i18n.t('mist.applicationMenu.develop.syncModeNoSync'), - enabled: - ethereumNode.isOwnNode && - ethereumNode.isGeth && - !ethereumNode.isDevNetwork, + enabled: ethereumNode.isOwnNode && !ethereumNode.isDevNetwork, checked: store.getState().nodes.local.syncMode === 'nosync', type: 'checkbox', click() {