Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Txlistener reads on the last compilation per file and not only the last one #2898

Merged
merged 6 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,096 changes: 1,167 additions & 929 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
"npm-merge-driver": "^2.3.5",
"npm-run-all": "^4.0.2",
"onchange": "^3.2.1",
"remix-analyzer": "0.5.2",
"remix-debug": "0.4.4",
"remix-lib": "0.4.29",
"remix-simulator": "0.1.9-beta.5",
"remix-solidity": "0.3.30",
"remix-analyzer": "0.5.3",
"remix-debug": "0.4.5",
"remix-lib": "0.4.30",
"remix-simulator": "0.1.9-beta.6",
"remix-solidity": "0.3.31",
"remix-tabs": "1.0.48",
"remix-tests": "0.1.33",
"remix-tests": "0.1.34",
"remixd": "0.1.8-alpha.16",
"request": "^2.83.0",
"rimraf": "^2.6.1",
Expand Down Expand Up @@ -186,6 +186,7 @@
"nightwatch_local_debugger": "nightwatch ./test-browser/tests/debugger.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_editor": "nightwatch ./test-browser/tests/editor.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_compiler": "nightwatch ./test-browser/tests/compiler_api.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_txListener": "nightwatch ./test-browser/tests/txListener.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_runAndDeploy": "nightwatch ./test-browser/tests/runAndDeploy.js --config nightwatch.js --env chrome-runAndDeploy ",
"onchange": "onchange build/app.js -- npm-run-all lint",
"prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build",
Expand Down
24 changes: 24 additions & 0 deletions src/app/compiler/compiler-artefacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,52 @@ module.exports = class CompilerArtefacts extends Plugin {
constructor () {
super(profile)
this.compilersArtefacts = {}
this.compilersArtefactsPerFile = {}
}

clear () {
this.compilersArtefacts = {}
this.compilersArtefactsPerFile = {}
}

onActivation () {
const saveCompilationPerFileResult = (file, source, languageVersion, data) => {
this.compilersArtefactsPerFile[file] = new CompilerAbstract(languageVersion, data, source)
}

this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})

this.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})

this.on('lexon', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})

this.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts['__last'] = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})
}

getAllContractDatas () {
const contractsData = {}
Object.keys(this.compilersArtefactsPerFile).map((targetFile) => {
const contracts = this.compilersArtefactsPerFile[targetFile].getContracts()
Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] })
})
// making sure we shave last compilation result in there
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

if (this.compilersArtefacts['__last']) {
const contracts = this.compilersArtefacts['__last'].getContracts()
Object.keys(contracts).map((file) => { contractsData[file] = contracts[file] })
}
return contractsData
}

addResolvedContract (address, compilerData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class FetchAndCompile extends Plugin {
name === 'main' ? 'mainnet' : name // source-verifier api expect "mainnet" and not "main"
let data
try {
data = await this.call('source-verification', 'fetchByNetwork', contractAddress, name.toLowerCase())
data = await this.call('sourcify', 'fetchByNetwork', contractAddress, name.toLowerCase())
Copy link
Collaborator

@LianaHus LianaHus Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you do this in this PR please also change it on homepage UI and loading page code

} catch (e) {
setTimeout(_ => this.emit('notFound', contractAddress), 0) // plugin framework returns a time out error although it actually didn't find the source...
this.unresolvedAddresses.push(contractAddress)
Expand Down
2 changes: 1 addition & 1 deletion src/app/tabs/debugger-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DebuggerTab extends ViewPlugin {
}
)

this.call('manager', 'activatePlugin', 'source-verification')
this.call('manager', 'activatePlugin', 'sourcify')
// this.call('manager', 'activatePlugin', 'udapp')

return this.el
Expand Down
2 changes: 1 addition & 1 deletion src/app/udapp/make-udapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) {
const txlistener = blockchain.getTxListener({
api: {
contracts: function () {
if (compilersArtefacts['__last']) return compilersArtefacts['__last'].getContracts()
if (compilersArtefacts['__last']) return compilersArtefacts.getAllContractDatas()
return null
},
resolveReceipt: function (tx, cb) {
Expand Down
4 changes: 2 additions & 2 deletions test-browser/tests/debugger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ module.exports = {
.assert.containsText('*[data-id="stepdetail"]', 'execution step: 0')
.click('*[data-id="buttonNavigatorJumpNextBreakpoint"]')
.pause(2000)
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 140')
.assert.containsText('*[data-id="stepdetail"]', 'execution step: 140')
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step: 184')
.assert.containsText('*[data-id="stepdetail"]', 'execution step: 184')
.end()
},

Expand Down
2 changes: 1 addition & 1 deletion test-browser/tests/runAndDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports = {
* - Source Verifier service for fetching the contract code
* - Ropsten node for retrieving the trace and storage
*
*/
*/
'Should debug Ropsten transaction with source highlighting using the source verifier service and MetaMask': function (browser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
Expand Down
6 changes: 6 additions & 0 deletions test-browser/tests/specialFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ var sauce = require('./sauce')

module.exports = {
before: function (browser, done) {
// this test suite also contribute testing https://github.com/ethereum/remix/pull/1497 and https://github.com/ethereum/remix-ide/pull/2898
// quick explanation:
// the goal of https://github.com/ethereum/remix-ide/pull/2898 is to keep track of all the compiled contracts an not only the last one.
// this introduce an issue: if 2 compiled contracts have the same name, the second one override the first which is not wanted.
// fix's delivered by https://github.com/ethereum/remix/pull/1497: instead of getting contract by name,
// which result in name clashing we process the whole contract object (which contain bytecode, deployedbytecode, ...)
init(browser, done)
},
'@sources': function () {
Expand Down
2 changes: 1 addition & 1 deletion test-browser/tests/staticAnalysis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function runTests (browser) {
.waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () {
listSelectorContains(['Use of tx.origin',
'Fallback function of contract TooMuchGas requires too much gas',
'TooMuchGas.() : Variables have very similar names test and test1.'],
'TooMuchGas.() : Variables have very similar names "test" and "test1".'],
'#staticanalysisresult .warning',
browser, function () {
browser.end()
Expand Down
52 changes: 52 additions & 0 deletions test-browser/tests/txListener.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict'
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')

var sources = [
{'browser/Untitled.sol': {content: examples.ballot.content}},
{'browser/Untitled1.sol': {content: `contract test {}`}}
]

module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@sources': function () {
return sources
},
'The sequence: Compiling / Deploying / Compiling another contract / calling the first contract - should display in the log the transaction with all the decoded information': function (browser) {
// https://github.com/ethereum/remix-ide/issues/2864
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('*[data-id="Deploy - transact (not payable)"]')
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]')
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
{
status: '0x1 Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
.clickLaunchIcon('solidity')
.testContracts('Untitled1.sol', sources[1]['browser/Untitled1.sol'], ['test'])
.clickLaunchIcon('udapp')
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: ''})
.pause(5000)
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
{
status: '0x0 Transaction mined but execution failed',
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
.end()
},

tearDown: sauce
}