From 24ecc37cdbe7a3f82f55bf2da770f1959ba5cba3 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 7 May 2020 17:43:15 +0200 Subject: [PATCH 01/14] using baseURL from single source --- src/app/tabs/compileTab/compilerContainer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tabs/compileTab/compilerContainer.js b/src/app/tabs/compileTab/compilerContainer.js index 5c51fd8ce9..46e4967926 100644 --- a/src/app/tabs/compileTab/compilerContainer.js +++ b/src/app/tabs/compileTab/compilerContainer.js @@ -6,7 +6,7 @@ const addTooltip = require('../../ui/tooltip') const semver = require('semver') const modalDialogCustom = require('../../ui/modal-dialog-custom') const css = require('../styles/compile-tab-styles') -import { canUseWorker } from '../../compiler/compiler-utils' +import { canUseWorker, baseUrl } from '../../compiler/compiler-utils' class CompilerContainer { @@ -25,7 +25,7 @@ class CompilerContainer { allversions: null, selectedVersion: null, defaultVersion: 'soljson-v0.6.6+commit.6c089d02.js', // this default version is defined: in makeMockCompiler (for browser test) and in package.json (downloadsolc_root) for the builtin compiler - baseurl: 'https://solc-bin.ethereum.org/bin' + baseurl: baseUrl } } From 018549a3e04750acbca87301d85da875a901db02 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 7 May 2020 20:04:49 +0200 Subject: [PATCH 02/14] load wasm builds --- src/app/compiler/compiler-utils.js | 4 ++-- src/app/tabs/compileTab/compilerContainer.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/compiler/compiler-utils.js b/src/app/compiler/compiler-utils.js index f7afcf9307..a1020bd9ef 100644 --- a/src/app/compiler/compiler-utils.js +++ b/src/app/compiler/compiler-utils.js @@ -1,7 +1,7 @@ const semver = require('semver') /* global Worker */ -export const baseUrl = 'https://solc-bin.ethereum.org/bin' +export const baseUrl = 'https://solc-bin.ethereum.org/wasm' export function urlFromVersion (version) { return `${baseUrl}/soljson-v${version}.js` @@ -30,7 +30,7 @@ export function canUseWorker (selectedVersion) { default : isFromWhiteList = true } - return browserSupportWorker() && (!isChrome || (isChrome && isFromWhiteList)) + return browserSupportWorker()// && (!isChrome || (isChrome && isFromWhiteList)) } function browserSupportWorker () { diff --git a/src/app/tabs/compileTab/compilerContainer.js b/src/app/tabs/compileTab/compilerContainer.js index 46e4967926..960f5c8d16 100644 --- a/src/app/tabs/compileTab/compilerContainer.js +++ b/src/app/tabs/compileTab/compilerContainer.js @@ -389,7 +389,7 @@ class CompilerContainer { // Workers cannot load js on "file:"-URLs and we get a // "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium, // resort to non-worker version in that case. - if (canUseWorker(this.data.selectedVersion)) { + if (this.data.selectedVersion !== 'builtin' && canUseWorker(this.data.selectedVersion)) { this.compileTabLogic.compiler.loadVersion(true, url) this.setVersionText('(loading using worker)') } else { From ffab90543df71376760fff89582825c99caf140d Mon Sep 17 00:00:00 2001 From: LianaHus Date: Mon, 11 May 2020 12:49:48 +0200 Subject: [PATCH 03/14] trying to test wasm versions --- src/app/compiler/compiler-utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/compiler/compiler-utils.js b/src/app/compiler/compiler-utils.js index a1020bd9ef..25e6425f10 100644 --- a/src/app/compiler/compiler-utils.js +++ b/src/app/compiler/compiler-utils.js @@ -1,4 +1,4 @@ -const semver = require('semver') +// const semver = require('semver') /* global Worker */ export const baseUrl = 'https://solc-bin.ethereum.org/wasm' @@ -13,7 +13,7 @@ export function urlFromVersion (version) { export function canUseWorker (selectedVersion) { // Following restrictions should be deleted when Solidity will release fixed versions of compilers. // See https://github.com/ethereum/remix-ide/issues/2461 - const isChrome = !!window.chrome + /* const isChrome = !!window.chrome const os = retrieveOS() // define a whitelist for Linux const linuxWL = ['0.4.26', '0.5.3', '0.5.4', '0.5.5'] @@ -29,7 +29,7 @@ export function canUseWorker (selectedVersion) { break default : isFromWhiteList = true - } + } */ return browserSupportWorker()// && (!isChrome || (isChrome && isFromWhiteList)) } @@ -37,7 +37,7 @@ function browserSupportWorker () { return document.location.protocol !== 'file:' && Worker !== undefined } -function retrieveOS () { +/* function retrieveOS () { let osName = 'Unknown OS' if (navigator.platform.indexOf('Win') !== -1) { osName = 'Windows' @@ -45,4 +45,4 @@ function retrieveOS () { osName = 'Linux' } return osName -} +} */ From c8238c3fbe11d57968b0427ceb41103282cdcf0a Mon Sep 17 00:00:00 2001 From: LianaHus Date: Mon, 11 May 2020 18:40:54 +0200 Subject: [PATCH 04/14] adjusted the test --- test-browser/tests/solidityUnittests.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-browser/tests/solidityUnittests.test.js b/test-browser/tests/solidityUnittests.test.js index 3a4882ad51..cdb99c4e03 100644 --- a/test-browser/tests/solidityUnittests.test.js +++ b/test-browser/tests/solidityUnittests.test.js @@ -86,7 +86,7 @@ module.exports = { .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .pause(5000) .click('*[data-id="testTabRunTestsTabStopAction"]') - .pause(2000) + .pause(1000) .assert.containsText('*[data-id="testTabRunTestsTabStopAction"]', 'Stopping') .waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutputheader"]', 40000) .assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/ks2b_test.sol') From 18dde6ec1bc7caa0e6fe2735e2f33388949ae37e Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 19 May 2020 23:00:32 +0200 Subject: [PATCH 05/14] adding pathToURL --- src/app/compiler/compiler-helpers.js | 4 +- ...compiler-sourceVerifier-fetchAndCompile.js | 2 - src/app/compiler/compiler-utils.js | 19 +++++-- src/app/tabs/compileTab/compilerContainer.js | 51 ++++++++++++++++--- src/app/tabs/test-tab.js | 6 +-- src/lib/helper.js | 1 - 6 files changed, 63 insertions(+), 20 deletions(-) diff --git a/src/app/compiler/compiler-helpers.js b/src/app/compiler/compiler-helpers.js index a20ffa13b1..820e5c298f 100644 --- a/src/app/compiler/compiler-helpers.js +++ b/src/app/compiler/compiler-helpers.js @@ -1,5 +1,5 @@ 'use strict' -import { canUseWorker } from './compiler-utils' +import { canUseWorker, urlFromVersion } from './compiler-utils' import { Compiler } from 'remix-solidity' import CompilerAbstract from './compiler-abstract' @@ -9,7 +9,7 @@ export const compile = async (compilationTargets, settings) => { const compiler = new Compiler(() => {}) compiler.set('evmVersion', settings.evmVersion) compiler.set('optimize', settings.optimize) - compiler.loadVersion(canUseWorker(settings.version), settings.compilerUrl) + compiler.loadVersion(canUseWorker(settings.version), urlFromVersion(settings.version)) compiler.event.register('compilationFinished', (success, compilationData, source) => { if (!success) return reject(compilationData) resolve(new CompilerAbstract(settings.version, compilationData, source)) diff --git a/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js b/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js index 04956b5ac7..8da3dd9bb1 100644 --- a/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js +++ b/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js @@ -1,7 +1,6 @@ const ethutil = require('ethereumjs-util') import * as packageJson from '../../../package.json' import { Plugin } from '@remixproject/engine' -import { urlFromVersion } from './compiler-utils' import { compile } from './compiler-helpers' import globalRegistry from '../../global/registry' @@ -109,7 +108,6 @@ export default class FetchAndCompile extends Plugin { languageName: data.metadata.language, evmVersion: data.metadata.settings.evmVersion, optimize: data.metadata.settings.optimizer.enabled, - compilerUrl: urlFromVersion(data.metadata.compiler.version) } try { setTimeout(_ => this.emit('compiling', settings), 0) diff --git a/src/app/compiler/compiler-utils.js b/src/app/compiler/compiler-utils.js index 25e6425f10..a36e25a83c 100644 --- a/src/app/compiler/compiler-utils.js +++ b/src/app/compiler/compiler-utils.js @@ -1,11 +1,15 @@ -// const semver = require('semver') + const semver = require('semver') /* global Worker */ -export const baseUrl = 'https://solc-bin.ethereum.org/wasm' +export const baseURLBin = 'https://solc-bin.ethereum.org/bin' +export const baseURLWasm = 'https://solc-bin.ethereum.org/wasm' + +export const pathToURL = [] export function urlFromVersion (version) { - return `${baseUrl}/soljson-v${version}.js` + return `${pathToURL[version]}/${version}` } + /** * Checks if the worker can be used to load a compiler. * checks a compiler whitelist, browser support and OS. @@ -30,7 +34,14 @@ export function canUseWorker (selectedVersion) { default : isFromWhiteList = true } */ - return browserSupportWorker()// && (!isChrome || (isChrome && isFromWhiteList)) + const version = semver.coerce(selectedVersion) + const isNightly = selectedVersion.includes('nightly') + return browserSupportWorker() && + ( + semver.gt(version, '0.6.3') || + semver.gt(version, '0.3.5') && !isNightly + ) + // && (!isChrome || (isChrome && isFromWhiteList)) } function browserSupportWorker () { diff --git a/src/app/tabs/compileTab/compilerContainer.js b/src/app/tabs/compileTab/compilerContainer.js index 960f5c8d16..e7ef28696d 100644 --- a/src/app/tabs/compileTab/compilerContainer.js +++ b/src/app/tabs/compileTab/compilerContainer.js @@ -6,7 +6,7 @@ const addTooltip = require('../../ui/tooltip') const semver = require('semver') const modalDialogCustom = require('../../ui/modal-dialog-custom') const css = require('../styles/compile-tab-styles') -import { canUseWorker, baseUrl } from '../../compiler/compiler-utils' +import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL } from '../../compiler/compiler-utils' class CompilerContainer { @@ -25,7 +25,8 @@ class CompilerContainer { allversions: null, selectedVersion: null, defaultVersion: 'soljson-v0.6.6+commit.6c089d02.js', // this default version is defined: in makeMockCompiler (for browser test) and in package.json (downloadsolc_root) for the builtin compiler - baseurl: baseUrl + baseURLWasm: baseURLWasm, + baseURLBin: baseURLBin } } @@ -383,7 +384,7 @@ class CompilerContainer { if (this.data.selectedVersion.indexOf('soljson') !== 0 || helper.checkSpecialChars(this.data.selectedVersion)) { return console.log('loading ' + this.data.selectedVersion + ' not allowed') } - url = `${this.data.baseurl}/${this.data.selectedVersion}` + url = `${urlFromVersion(this.data.selectedVersion)}` } // Workers cannot load js on "file:"-URLs and we get a @@ -413,25 +414,59 @@ class CompilerContainer { if (this._view.version) this._view.version.innerText = text } + // fetching both normal and wasm builds and creating an array [version, baseUrl] fetchAllVersion (callback) { - minixhr(`${this.data.baseurl}/list.json`, (json, event) => { + let allVersions, selectedVersion, allVersionsWasm, urls + // fetch normal builds + minixhr(`${this.data.baseURLBin}/list.json`, (json, event) => { // @TODO: optimise and cache results to improve app loading times #2461 - var allversions, selectedVersion if (event.type !== 'error') { try { const data = JSON.parse(json) - allversions = data.builds.slice().reverse() + allVersions = data.builds.slice().reverse() selectedVersion = this.data.defaultVersion if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version + // no fetching wasm builds + minixhr(`${this.data.baseURLWasm}/list.json`, (json, event) => { + // @TODO: optimise and cache results to improve app loading times #2461 + if (event.type !== 'error') { + try { + const data = JSON.parse(json) + allVersionsWasm = data.builds.slice().reverse() + //selectedVersion = this.data.defaultVersion + if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version + // rewriting all versions in allVersions which exist in allVersionsWasm + if (allVersionsWasm && allVersions) + allVersions.forEach((compiler, index) => { + const rewritten = allVersionsWasm.findIndex(oldCompiler => { return oldCompiler.longVersion === compiler.longVersion }) + if (-1 !== rewritten) { + allVersions[index] = allVersionsWasm[rewritten] + pathToURL[compiler.path] = baseURLWasm + } else { + pathToURL[compiler.path] = baseURLBin + } + }) + callback(allVersions, selectedVersion) + } catch (e) { + addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.') + } + } else { + allVersionsWasm = [{ path: 'builtin', longVersion: 'latest local version' }] + selectedVersion = 'builtin' + } + //callback(allVersions, selectedVersion) + }) } catch (e) { addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.') } } else { - allversions = [{ path: 'builtin', longVersion: 'latest local version' }] + allVersions = [{ path: 'builtin', longVersion: 'latest local version' }] selectedVersion = 'builtin' } - callback(allversions, selectedVersion) + //callback(allVersions, selectedVersion) }) + + } scheduleCompilation () { diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 2dfb270a9f..abc9986a1d 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -4,7 +4,7 @@ var tooltip = require('../ui/tooltip') var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') import { ViewPlugin } from '@remixproject/engine' -import { canUseWorker, baseUrl } from '../compiler/compiler-utils' +import { canUseWorker, urlFromVersion } from '../compiler/compiler-utils' const TestTabLogic = require('./testTab/testTab') @@ -301,7 +301,7 @@ module.exports = class TestTab extends ViewPlugin { let runningTest = {} runningTest[path] = { content } const {currentVersion, evmVersion, optimize} = this.compileTab.getCurrentCompilerConfig() - const currentCompilerUrl = baseUrl + '/' + currentVersion + const currentCompilerUrl = urlFromVersion(currentVersion) const compilerConfig = { currentCompilerUrl, evmVersion, @@ -327,7 +327,7 @@ module.exports = class TestTab extends ViewPlugin { const runningTest = {} runningTest[testFilePath] = { content } const {currentVersion, evmVersion, optimize} = this.compileTab.getCurrentCompilerConfig() - const currentCompilerUrl = baseUrl + '/' + currentVersion + const currentCompilerUrl = urlFromVersion(currentVersion) const compilerConfig = { currentCompilerUrl, evmVersion, diff --git a/src/lib/helper.js b/src/lib/helper.js index cda3bfe519..15f692fcc1 100644 --- a/src/lib/helper.js +++ b/src/lib/helper.js @@ -84,4 +84,3 @@ function find (args, query) { }) return isMatch } - From 9ad5e3dfa5a5f4ed80b1fcfa42d7bc848cc85e5f Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 20 May 2020 17:30:37 +0200 Subject: [PATCH 06/14] Promise for minixhr: --- ...compiler-sourceVerifier-fetchAndCompile.js | 2 +- src/app/compiler/compiler-utils.js | 52 ++++------- src/app/tabs/compileTab/compilerContainer.js | 88 +++++++------------ 3 files changed, 51 insertions(+), 91 deletions(-) diff --git a/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js b/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js index 8da3dd9bb1..5df4e66390 100644 --- a/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js +++ b/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js @@ -107,7 +107,7 @@ export default class FetchAndCompile extends Plugin { version: data.metadata.compiler.version, languageName: data.metadata.language, evmVersion: data.metadata.settings.evmVersion, - optimize: data.metadata.settings.optimizer.enabled, + optimize: data.metadata.settings.optimizer.enabled } try { setTimeout(_ => this.emit('compiling', settings), 0) diff --git a/src/app/compiler/compiler-utils.js b/src/app/compiler/compiler-utils.js index a36e25a83c..2edf06f1ed 100644 --- a/src/app/compiler/compiler-utils.js +++ b/src/app/compiler/compiler-utils.js @@ -1,11 +1,13 @@ - const semver = require('semver') +const semver = require('semver') +const minixhr = require('minixhr') /* global Worker */ export const baseURLBin = 'https://solc-bin.ethereum.org/bin' export const baseURLWasm = 'https://solc-bin.ethereum.org/wasm' -export const pathToURL = [] +export const pathToURL = {} +// retrieves the URL of the given compiler version export function urlFromVersion (version) { return `${pathToURL[version]}/${version}` } @@ -15,45 +17,23 @@ export function urlFromVersion (version) { * checks a compiler whitelist, browser support and OS. */ export function canUseWorker (selectedVersion) { - // Following restrictions should be deleted when Solidity will release fixed versions of compilers. - // See https://github.com/ethereum/remix-ide/issues/2461 - /* const isChrome = !!window.chrome - const os = retrieveOS() - // define a whitelist for Linux - const linuxWL = ['0.4.26', '0.5.3', '0.5.4', '0.5.5'] - const version = semver.coerce(selectedVersion) - // defining whitelist for chrome - let isFromWhiteList = false - switch (os) { - case 'Windows': - isFromWhiteList = semver.gt(version, '0.5.2') || version === '0.4.26' - break - case 'Linux': - isFromWhiteList = semver.gt(version, '0.5.13') || linuxWL.includes(version) - break - default : - isFromWhiteList = true - } */ const version = semver.coerce(selectedVersion) const isNightly = selectedVersion.includes('nightly') - return browserSupportWorker() && - ( - semver.gt(version, '0.6.3') || - semver.gt(version, '0.3.5') && !isNightly - ) - // && (!isChrome || (isChrome && isFromWhiteList)) + return browserSupportWorker() && ( + semver.gt(version, '0.6.3') || + semver.gt(version, '0.3.6') && !isNightly + ) } function browserSupportWorker () { return document.location.protocol !== 'file:' && Worker !== undefined } -/* function retrieveOS () { - let osName = 'Unknown OS' - if (navigator.platform.indexOf('Win') !== -1) { - osName = 'Windows' - } else if (navigator.platform.indexOf('Linux') !== -1) { - osName = 'Linux' - } - return osName -} */ +// returns a promice for minixhr +export function promisedMiniXhr (url) { + return new Promise((resolve, reject) => { + minixhr(url, (json, event) => { + resolve({ json, event }) + }) + }) +} diff --git a/src/app/tabs/compileTab/compilerContainer.js b/src/app/tabs/compileTab/compilerContainer.js index e7ef28696d..9163b52f6c 100644 --- a/src/app/tabs/compileTab/compilerContainer.js +++ b/src/app/tabs/compileTab/compilerContainer.js @@ -1,12 +1,11 @@ const yo = require('yo-yo') -const minixhr = require('minixhr') const helper = require('../../../lib/helper') const addTooltip = require('../../ui/tooltip') const semver = require('semver') const modalDialogCustom = require('../../ui/modal-dialog-custom') const css = require('../styles/compile-tab-styles') -import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL } from '../../compiler/compiler-utils' +import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '../../compiler/compiler-utils' class CompilerContainer { @@ -414,61 +413,42 @@ class CompilerContainer { if (this._view.version) this._view.version.innerText = text } - // fetching both normal and wasm builds and creating an array [version, baseUrl] - fetchAllVersion (callback) { - let allVersions, selectedVersion, allVersionsWasm, urls + // fetching both normal and wasm builds and creating a [version, baseUrl] map + async fetchAllVersion (callback) { + let allVersions, selectedVersion, allVersionsWasm // fetch normal builds - minixhr(`${this.data.baseURLBin}/list.json`, (json, event) => { - // @TODO: optimise and cache results to improve app loading times #2461 - if (event.type !== 'error') { - try { - const data = JSON.parse(json) - allVersions = data.builds.slice().reverse() - selectedVersion = this.data.defaultVersion - if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version - // no fetching wasm builds - minixhr(`${this.data.baseURLWasm}/list.json`, (json, event) => { - // @TODO: optimise and cache results to improve app loading times #2461 - if (event.type !== 'error') { - try { - const data = JSON.parse(json) - allVersionsWasm = data.builds.slice().reverse() - //selectedVersion = this.data.defaultVersion - if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version - // rewriting all versions in allVersions which exist in allVersionsWasm - if (allVersionsWasm && allVersions) - allVersions.forEach((compiler, index) => { - const rewritten = allVersionsWasm.findIndex(oldCompiler => { return oldCompiler.longVersion === compiler.longVersion }) - if (-1 !== rewritten) { - allVersions[index] = allVersionsWasm[rewritten] - pathToURL[compiler.path] = baseURLWasm - } else { - pathToURL[compiler.path] = baseURLBin - } - }) - callback(allVersions, selectedVersion) - } catch (e) { - addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.') - } - } else { - allVersionsWasm = [{ path: 'builtin', longVersion: 'latest local version' }] - selectedVersion = 'builtin' - } - //callback(allVersions, selectedVersion) - }) - } catch (e) { - addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload.') - } - } else { - allVersions = [{ path: 'builtin', longVersion: 'latest local version' }] - selectedVersion = 'builtin' + const binRes = await promisedMiniXhr(`${this.data.baseURLBin}/list.json`) + // fetch wasm builds + const wasmRes = await promisedMiniXhr(`${this.data.baseURLWasm}/list.json`) + if (binRes.event.type === 'error' && wasmRes.event.type === 'error') { + allVersions = [{ path: 'builtin', longVersion: 'latest local version' }] + selectedVersion = 'builtin' + callback(allVersions, selectedVersion) + } + try { + allVersions = JSON.parse(binRes.json).builds.slice().reverse() + selectedVersion = this.data.defaultVersion + if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version + if (wasmRes.event.type !== 'error') { + allVersionsWasm = JSON.parse(wasmRes.json).builds.slice().reverse() } - //callback(allVersions, selectedVersion) - }) - - + } catch (e) { + addTooltip('Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload. Error: ' + e) + } + // replace in allVersions those compiler builds which exist in allVersionsWasm with new once + if (allVersionsWasm && allVersions) { + allVersions.forEach((compiler, index) => { + const wasmIndex = allVersionsWasm.findIndex(wasmCompiler => { return wasmCompiler.longVersion === compiler.longVersion }) + if (wasmIndex !== -1) { + allVersions[index] = allVersionsWasm[wasmIndex] + pathToURL[compiler.path] = baseURLWasm + } else { + pathToURL[compiler.path] = baseURLBin + } + }) + } + callback(allVersions, selectedVersion) } - scheduleCompilation () { if (!this.config.get('autoCompile')) return if (this.data.compileTimeout) window.clearTimeout(this.data.compileTimeout) From 687b2b8297fa4f79e2403e6e53951a738c8a9c70 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 26 May 2020 14:26:47 +0200 Subject: [PATCH 07/14] removed URL's from data --- src/app/tabs/compileTab/compilerContainer.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/tabs/compileTab/compilerContainer.js b/src/app/tabs/compileTab/compilerContainer.js index 9163b52f6c..b91f933bf3 100644 --- a/src/app/tabs/compileTab/compilerContainer.js +++ b/src/app/tabs/compileTab/compilerContainer.js @@ -23,9 +23,7 @@ class CompilerContainer { timeout: 300, allversions: null, selectedVersion: null, - defaultVersion: 'soljson-v0.6.6+commit.6c089d02.js', // this default version is defined: in makeMockCompiler (for browser test) and in package.json (downloadsolc_root) for the builtin compiler - baseURLWasm: baseURLWasm, - baseURLBin: baseURLBin + defaultVersion: 'soljson-v0.6.6+commit.6c089d02.js' // this default version is defined: in makeMockCompiler (for browser test) and in package.json (downloadsolc_root) for the builtin compiler } } @@ -417,9 +415,9 @@ class CompilerContainer { async fetchAllVersion (callback) { let allVersions, selectedVersion, allVersionsWasm // fetch normal builds - const binRes = await promisedMiniXhr(`${this.data.baseURLBin}/list.json`) + const binRes = await promisedMiniXhr(`${baseURLBin}/list.json`) // fetch wasm builds - const wasmRes = await promisedMiniXhr(`${this.data.baseURLWasm}/list.json`) + const wasmRes = await promisedMiniXhr(`${baseURLWasm}/list.json`) if (binRes.event.type === 'error' && wasmRes.event.type === 'error') { allVersions = [{ path: 'builtin', longVersion: 'latest local version' }] selectedVersion = 'builtin' From 874cc2c6ee1bc77e9234f2aa30a6f1732e0e665f Mon Sep 17 00:00:00 2001 From: LianaHus Date: Fri, 29 May 2020 16:43:14 +0200 Subject: [PATCH 08/14] adding usingWebWorker test --- package-lock.json | 5 ++++ package.json | 2 ++ src/app/editor/example-contracts.js | 13 +++++++++- src/app/tabs/compile-tab.js | 2 +- test-browser/tests/usingWebWorker.test.js | 29 +++++++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 test-browser/tests/usingWebWorker.test.js diff --git a/package-lock.json b/package-lock.json index f571dd4b3f..0bcbd9da49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16145,6 +16145,11 @@ } } }, + "selenium": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/selenium/-/selenium-2.20.0.tgz", + "integrity": "sha1-9RWxoWLek8LM7y/AyjPztVQ+OMg=" + }, "selenium-standalone": { "version": "6.17.0", "resolved": "https://registry.npmjs.org/selenium-standalone/-/selenium-standalone-6.17.0.tgz", diff --git a/package.json b/package.json index 16d78d20e4..d06f4fe39d 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "dependencies": { "@remixproject/engine": "^0.2.3", "http-server": "^0.11.1", + "selenium": "^2.20.0", "standard": "^8.5.0" }, "repository": { @@ -165,6 +166,7 @@ "nightwatch_local_firefox": "nightwatch --config nightwatch.js --env firefox", "nightwatch_local_chrome": "nightwatch --config nightwatch.js --env chrome", "nightwatch_local_ballot": "nightwatch ./test-browser/tests/ballot.test.js --config nightwatch.js --env chrome ", + "nightwatch_local_usingWorker": "nightwatch ./test-browser/tests/usingWebWorker.test.js --config nightwatch.js --env chrome ", "nightwatch_local_libraryDeployment": "nightwatch ./test-browser/tests/libraryDeployment.test.js --config nightwatch.js --env chrome ", "nightwatch_local_solidityImport": "nightwatch ./test-browser/tests/solidityImport.test.js --config nightwatch.js --env chrome ", "nightwatch_local_recorder": "nightwatch ./test-browser/tests/recorder.test.js --config nightwatch.js --env chrome ", diff --git a/src/app/editor/example-contracts.js b/src/app/editor/example-contracts.js index 945abe0349..34c6ea9a64 100644 --- a/src/app/editor/example-contracts.js +++ b/src/app/editor/example-contracts.js @@ -1,5 +1,15 @@ 'use strict' +const basic = `pragma solidity >=0.2.0 <0.7.0; + +/** + * @title Basic contract + */ +contract Basic { + uint someVar; + constructor() public {} +}` + const storage = `pragma solidity >=0.4.22 <0.7.0; /** @@ -245,5 +255,6 @@ module.exports = { storage: { name: '1_Storage.sol', content: storage }, owner: { name: '2_Owner.sol', content: owner }, ballot: { name: '3_Ballot.sol', content: ballot }, - ballot_test: { name: '4_Ballot_test.sol', content: ballotTest } + ballot_test: { name: '4_Ballot_test.sol', content: ballotTest }, + basic: { name: 'basic.sol', content: basic } } diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index a5d8e4de10..42147694c6 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -411,7 +411,7 @@ class CompileTab extends ViewPlugin { render () { if (this._view.el) return this._view.el this.onActivationInternal() - this._view.errorContainer = yo`
` + this._view.errorContainer = yo`
` this._view.contractSelection = this.contractSelection() this._view.compilerContainer = this.compilerContainer.render() this.compilerContainer.activate() diff --git a/test-browser/tests/usingWebWorker.test.js b/test-browser/tests/usingWebWorker.test.js new file mode 100644 index 0000000000..b6918fad47 --- /dev/null +++ b/test-browser/tests/usingWebWorker.test.js @@ -0,0 +1,29 @@ +'use strict' +var examples = require('../../src/app/editor/example-contracts') +var init = require('../helpers/init') +var sauce = require('./sauce') + +var sources = [ + {'browser/basic.sol': {content: examples.basic.content}} +] + +module.exports = { + before: function (browser, done) { + init(browser, done) + }, + '@sources': function () { + return sources + }, + 'Using Web Worker': function (browser) { + browser + .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) + .addFile('basic.sol', sources[0]['browser/basic.sol']) + .noWorkerErrorFor('soljson-v0.3.4+commit.7dab890.js') + .noWorkerErrorFor('soljson-v0.6.5+commit.f956cc89.js') + .noWorkerErrorFor('soljson-v0.6.8-nightly.2020.5.14+commit.a6d0067b.js') + .noWorkerErrorFor('soljson-v0.6.0-nightly.2019.12.17+commit.d13438ee.js') + .noWorkerErrorFor('soljson-v0.4.26+commit.4563c3fc.js') + }, + + tearDown: sauce +} From 689b91d3cd286c638e5689c481e2f086a0dc7c95 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Fri, 29 May 2020 18:03:06 +0200 Subject: [PATCH 09/14] added command --- package.json | 1 - test-browser/commands/noWorkerErrorFor.js | 28 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test-browser/commands/noWorkerErrorFor.js diff --git a/package.json b/package.json index d06f4fe39d..afacc50006 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,6 @@ "dependencies": { "@remixproject/engine": "^0.2.3", "http-server": "^0.11.1", - "selenium": "^2.20.0", "standard": "^8.5.0" }, "repository": { diff --git a/test-browser/commands/noWorkerErrorFor.js b/test-browser/commands/noWorkerErrorFor.js new file mode 100644 index 0000000000..c3c0f854d6 --- /dev/null +++ b/test-browser/commands/noWorkerErrorFor.js @@ -0,0 +1,28 @@ +const EventEmitter = require('events') + +class NoWorkerErrorFor extends EventEmitter { + command (version, content) { + this.api.perform((done) => { + noWorkerErrorFor(this.api, version, content, () => { + done() + this.emit('complete') + }) + }) + return this + } +} + +function noWorkerErrorFor (browser, version, done) { + browser + .clickLaunchIcon('solidity') + .setSolidityCompilerVersion(version) + .waitForElementPresent('*[data-id="compiledErrors"]') + .notContainsText('*[data-id="compiledErrors"]', 'worker error:undefined') + .notContainsText('*[data-id="compiledErrors"]', 'Uncaught RangeError: Maximum call stack size exceeded') + .notContainsText('*[data-id="compiledErrors"]', 'RangeError: Maximum call stack size exceeded') + .perform(function (done) { + done() + }) +} + +module.exports = NoWorkerErrorFor From eb585cc0964733a7e7af795274bee4205a6cff09 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 2 Jun 2020 10:07:22 +0200 Subject: [PATCH 10/14] test improved --- test-browser/commands/noWorkerErrorFor.js | 12 ++++++------ test-browser/tests/usingWebWorker.test.js | 10 +++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test-browser/commands/noWorkerErrorFor.js b/test-browser/commands/noWorkerErrorFor.js index c3c0f854d6..1fcb30dafc 100644 --- a/test-browser/commands/noWorkerErrorFor.js +++ b/test-browser/commands/noWorkerErrorFor.js @@ -1,9 +1,9 @@ const EventEmitter = require('events') class NoWorkerErrorFor extends EventEmitter { - command (version, content) { + command (version) { this.api.perform((done) => { - noWorkerErrorFor(this.api, version, content, () => { + noWorkerErrorFor(this.api, version, () => { done() this.emit('complete') }) @@ -12,16 +12,16 @@ class NoWorkerErrorFor extends EventEmitter { } } -function noWorkerErrorFor (browser, version, done) { +function noWorkerErrorFor (browser, version, callback) { browser - .clickLaunchIcon('solidity') .setSolidityCompilerVersion(version) + .pause(2000) .waitForElementPresent('*[data-id="compiledErrors"]') .notContainsText('*[data-id="compiledErrors"]', 'worker error:undefined') .notContainsText('*[data-id="compiledErrors"]', 'Uncaught RangeError: Maximum call stack size exceeded') .notContainsText('*[data-id="compiledErrors"]', 'RangeError: Maximum call stack size exceeded') - .perform(function (done) { - done() + .perform(() => { + callback() }) } diff --git a/test-browser/tests/usingWebWorker.test.js b/test-browser/tests/usingWebWorker.test.js index b6918fad47..c59da319d3 100644 --- a/test-browser/tests/usingWebWorker.test.js +++ b/test-browser/tests/usingWebWorker.test.js @@ -17,12 +17,20 @@ module.exports = { 'Using Web Worker': function (browser) { browser .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) - .addFile('basic.sol', sources[0]['browser/basic.sol']) + .clickLaunchIcon('fileExplorers') + .openFile('browser/basic.sol') + .clickLaunchIcon('solidity') + .execute(() => { + document.getElementById('nightlies').checked = true + }) .noWorkerErrorFor('soljson-v0.3.4+commit.7dab890.js') .noWorkerErrorFor('soljson-v0.6.5+commit.f956cc89.js') .noWorkerErrorFor('soljson-v0.6.8-nightly.2020.5.14+commit.a6d0067b.js') .noWorkerErrorFor('soljson-v0.6.0-nightly.2019.12.17+commit.d13438ee.js') .noWorkerErrorFor('soljson-v0.4.26+commit.4563c3fc.js') + .execute(() => { + document.getElementById('nightlies').checked = false + }) }, tearDown: sauce From 6dd2b3e7165e9f3270e5056ca108b2c761f9bcc6 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 2 Jun 2020 12:28:12 +0200 Subject: [PATCH 11/14] added result indicator for compilation with compiler version --- src/app/tabs/compile-tab.js | 1 + test-browser/commands/noWorkerErrorFor.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 42147694c6..52de47dd7e 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -116,6 +116,7 @@ class CompileTab extends ViewPlugin { this.fileManager.events.on('noFileSelected', this.data.eventHandlers.onNoFileSelected) this.data.eventHandlers.onCompilationFinished = (success, data, source) => { + this._view.errorContainer.appendChild(yo``) if (success) { // forwarding the event to the appManager infra this.emit('compilationFinished', source.target, source, 'soljson', data) diff --git a/test-browser/commands/noWorkerErrorFor.js b/test-browser/commands/noWorkerErrorFor.js index 1fcb30dafc..614e710c14 100644 --- a/test-browser/commands/noWorkerErrorFor.js +++ b/test-browser/commands/noWorkerErrorFor.js @@ -15,8 +15,8 @@ class NoWorkerErrorFor extends EventEmitter { function noWorkerErrorFor (browser, version, callback) { browser .setSolidityCompilerVersion(version) - .pause(2000) - .waitForElementPresent('*[data-id="compiledErrors"]') + .click('*[data-id="compilerContainerCompileBtn"]') + .waitForElementPresent('*[data-id="compilationFinishedWith_' + version + '"]', 10000) .notContainsText('*[data-id="compiledErrors"]', 'worker error:undefined') .notContainsText('*[data-id="compiledErrors"]', 'Uncaught RangeError: Maximum call stack size exceeded') .notContainsText('*[data-id="compiledErrors"]', 'RangeError: Maximum call stack size exceeded') From 2b72c6c95889b157574ed869fb1b0f7bcdac403a Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 2 Jun 2020 18:11:19 +0200 Subject: [PATCH 12/14] fixing test --- package-lock.json | 5 ----- src/app/compiler/compiler-utils.js | 13 ++++++++++--- test-browser/tests/runAndDeploy.js | 7 +++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bcbd9da49..f571dd4b3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16145,11 +16145,6 @@ } } }, - "selenium": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/selenium/-/selenium-2.20.0.tgz", - "integrity": "sha1-9RWxoWLek8LM7y/AyjPztVQ+OMg=" - }, "selenium-standalone": { "version": "6.17.0", "resolved": "https://registry.npmjs.org/selenium-standalone/-/selenium-standalone-6.17.0.tgz", diff --git a/src/app/compiler/compiler-utils.js b/src/app/compiler/compiler-utils.js index 2edf06f1ed..5a5e44cdb4 100644 --- a/src/app/compiler/compiler-utils.js +++ b/src/app/compiler/compiler-utils.js @@ -7,8 +7,15 @@ export const baseURLWasm = 'https://solc-bin.ethereum.org/wasm' export const pathToURL = {} -// retrieves the URL of the given compiler version -export function urlFromVersion (version) { +/** + * Retrieves the URL of the given compiler version + * @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix + */ +export function urlFromVersion (version) { // 0x959371506b8f6223d71c709ac2eb2d0158104dca2d76ca949f1662712cf0e6db + console.log("1. orig_________= " + version + " path =", pathToURL, " version =", version, " and url is = ", pathToURL[version]) + if (version.substr(0, 9) !== 'soljson-v') version = 'soljson-v' + version + if (version.substr(version.length - 3, version.length) !== '.js') version = version + '.js;' + console.log("2. orig_________= " + version + " path =", pathToURL, " version =", version, " and url is = ", pathToURL[version]) return `${pathToURL[version]}/${version}` } @@ -29,7 +36,7 @@ function browserSupportWorker () { return document.location.protocol !== 'file:' && Worker !== undefined } -// returns a promice for minixhr +// returns a promise for minixhr export function promisedMiniXhr (url) { return new Promise((resolve, reject) => { minixhr(url, (json, event) => { diff --git a/test-browser/tests/runAndDeploy.js b/test-browser/tests/runAndDeploy.js index 7f705171b3..1fddeedb54 100644 --- a/test-browser/tests/runAndDeploy.js +++ b/test-browser/tests/runAndDeploy.js @@ -31,8 +31,7 @@ module.exports = { .assert.elementNotPresent('*[data-id="settingsRemixRunSignMsgHash"]') .assert.elementNotPresent('*[data-id="settingsRemixRunSignMsgSignature"]') .modalFooterOKClick() - .pause(2000) - .waitForElementPresent('*[data-id="modalDialogContainer"]') + .waitForElementPresent('*[data-id="modalDialogContainer"]', 12000) .assert.elementPresent('*[data-id="settingsRemixRunSignMsgHash"]') .assert.elementPresent('*[data-id="settingsRemixRunSignMsgSignature"]') .modalFooterOKClick() @@ -145,8 +144,8 @@ module.exports = { .clickLaunchIcon('udapp') .waitForElementPresent('*[data-id="Deploy - transact (not payable)"]') .click('*[data-id="Deploy - transact (not payable)"]') - .pause(2000) - .waitForElementPresent('*[data-id="modalDialogContainer"]') + .waitForElementPresent('*[data-id="modalDialogContainer"]', 15000) + .pause(10000) .assert.containsText('*[data-id="modalDialogModalBody"]', 'You are creating a transaction on the main network. Click confirm if you are sure to continue.') .modalFooterCancelClick() }, From efce5cfad514495557a9f8eacbde18fde9984222 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 4 Jun 2020 11:01:52 +0200 Subject: [PATCH 13/14] use endsWith and startsWith --- src/app/compiler/compiler-utils.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/compiler/compiler-utils.js b/src/app/compiler/compiler-utils.js index 5a5e44cdb4..f7222f582d 100644 --- a/src/app/compiler/compiler-utils.js +++ b/src/app/compiler/compiler-utils.js @@ -11,11 +11,9 @@ export const pathToURL = {} * Retrieves the URL of the given compiler version * @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix */ -export function urlFromVersion (version) { // 0x959371506b8f6223d71c709ac2eb2d0158104dca2d76ca949f1662712cf0e6db - console.log("1. orig_________= " + version + " path =", pathToURL, " version =", version, " and url is = ", pathToURL[version]) - if (version.substr(0, 9) !== 'soljson-v') version = 'soljson-v' + version - if (version.substr(version.length - 3, version.length) !== '.js') version = version + '.js;' - console.log("2. orig_________= " + version + " path =", pathToURL, " version =", version, " and url is = ", pathToURL[version]) +export function urlFromVersion (version) { + if (!version.startsWith('soljson-v')) version = 'soljson-v' + version + if (!version.endsWith('.js')) version = version + '.js' return `${pathToURL[version]}/${version}` } From 9630deca25559a77eeafb488b2c0c78256068bdf Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 4 Jun 2020 11:02:15 +0200 Subject: [PATCH 14/14] fix set content --- src/app/files/fileProvider.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/files/fileProvider.js b/src/app/files/fileProvider.js index 116f42b368..1fa54ab11c 100644 --- a/src/app/files/fileProvider.js +++ b/src/app/files/fileProvider.js @@ -93,7 +93,10 @@ class FileProvider { cb = cb || function () {} var unprefixedpath = this.removePrefix(path) var exists = window.remixFileSystem.existsSync(unprefixedpath) - if (exists && window.remixFileSystem.readFileSync(unprefixedpath, 'utf8') === content) return true + if (exists && window.remixFileSystem.readFileSync(unprefixedpath, 'utf8') === content) { + cb() + return true + } if (!exists && unprefixedpath.indexOf('/') !== -1) { this.createDir(path) }