Merge pull request #432 from ethereum/fixUsageOfRemixSimulator

Fix usage of remix simulator provider
pull/478/head
yann300 4 years ago committed by GitHub
commit a012a0496e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/remix-ide-e2e/src/tests/ballot.test.ts
  2. 4
      apps/remix-ide-e2e/src/tests/runAndDeploy.ts
  3. 8
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  4. 43
      apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
  5. 4
      apps/remix-ide-e2e/src/tests/txListener.test.ts
  6. 5
      apps/remix-ide/src/blockchain/blockchain.js
  7. 2
      libs/remix-lib/src/execution/execution-context.js
  8. 10
      libs/remix-lib/src/web3Provider/web3VmProvider.js
  9. 33
      libs/remix-simulator/src/methods/debug.js
  10. 3
      libs/remix-simulator/src/methods/transactions.js
  11. 2
      libs/remix-simulator/src/provider.js

@ -30,7 +30,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}) .clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', .testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', 'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } 'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
}) })
@ -62,7 +62,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}) .clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803', .testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
{ {
status: '0x0 Transaction mined but execution failed', status: 'false Transaction mined but execution failed',
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803', 'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } 'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
}) })

@ -48,7 +48,7 @@ module.exports = {
.click('*[data-id="Deploy - transact (not payable)"]') .click('*[data-id="Deploy - transact (not payable)"]')
.pause(5000) .pause(5000)
.testFunction('0xc39ee005c1e1368c84f02e458de4b41dbb966631a8714d15ef8362dada249ede', { .testFunction('0xc39ee005c1e1368c84f02e458de4b41dbb966631a8714d15ef8362dada249ede', {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0xc39ee005c1e1368c84f02e458de4b41dbb966631a8714d15ef8362dada249ede' 'transaction hash': '0xc39ee005c1e1368c84f02e458de4b41dbb966631a8714d15ef8362dada249ede'
}) })
}, },
@ -61,7 +61,7 @@ module.exports = {
.click('*[data-id="pluginManagerSettingsDeployAndRunLLTxSendTransaction"]') .click('*[data-id="pluginManagerSettingsDeployAndRunLLTxSendTransaction"]')
.pause(5000) .pause(5000)
.testFunction('0xfe718871ee0b4d03cdcac0e12e5b164efaf7e23ba952c07db76e62692867019b', { .testFunction('0xfe718871ee0b4d03cdcac0e12e5b164efaf7e23ba952c07db76e62692867019b', {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0xfe718871ee0b4d03cdcac0e12e5b164efaf7e23ba952c07db76e62692867019b' 'transaction hash': '0xfe718871ee0b4d03cdcac0e12e5b164efaf7e23ba952c07db76e62692867019b'
}) })
}, },

@ -59,7 +59,13 @@ module.exports = {
.pause(5000) .pause(5000)
.executeScript(`remix.execute('browser/asyncAwaitWithFileManagerAccess.js')`) .executeScript(`remix.execute('browser/asyncAwaitWithFileManagerAccess.js')`)
.pause(6000) .pause(6000)
.journalLastChildIncludes('contract Ballot {') .journalLastChildIncludes('contract Ballot {')
},
'Call web3.eth.getAccounts() using JavaScript VM': function (browser: NightwatchBrowser) {
browser
.executeScript(`web3.eth.getAccounts()`)
.journalLastChildIncludes(`[ "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4", "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2", "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db", "0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB", "0x617F2E2fD72FD9D5503197092aC168c91465E7f2", "0x17F6AD8Ef982297579C203069C1DbfFE4348c372", "0x5c6B0f7Bf3E7ce046039Bd8FABdfD3f9F5021678", "0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7", "0x1aE0EA34a72D944a8C7603FfB3eC30a6669E454C", "0x0A098Eda01Ce92ff4A4CCb7A4fFFb5A43EBC70DC", "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c", "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C", "0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB", "0x583031D1113aD414F02576BD6afaBfb302140225", "0xdD870fA1b7C4700F2BD7f44238821C26f7392148" ]`)
.end() .end()
}, },

@ -23,7 +23,7 @@ module.exports = {
.clickFunction('f - transact (not payable)') .clickFunction('f - transact (not payable)')
.testFunction('0x38bb944fa4709ed9e163d6c670259f97284b4defd916d512a2fcc3f35bb53e03', .testFunction('0x38bb944fa4709ed9e163d6c670259f97284b4defd916d512a2fcc3f35bb53e03',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0x38bb944fa4709ed9e163d6c670259f97284b4defd916d512a2fcc3f35bb53e03', 'transaction hash': '0x38bb944fa4709ed9e163d6c670259f97284b4defd916d512a2fcc3f35bb53e03',
'decoded output': { '0': 'uint256: 8' } 'decoded output': { '0': 'uint256: 8' }
}) })
@ -32,7 +32,7 @@ module.exports = {
.clickFunction('g - transact (not payable)') .clickFunction('g - transact (not payable)')
.testFunction('0xab4f794ca0b531f27fc6eace623666b440facbf20e77615a057d728c67b500f0', .testFunction('0xab4f794ca0b531f27fc6eace623666b440facbf20e77615a057d728c67b500f0',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0xab4f794ca0b531f27fc6eace623666b440facbf20e77615a057d728c67b500f0', 'transaction hash': '0xab4f794ca0b531f27fc6eace623666b440facbf20e77615a057d728c67b500f0',
'decoded output': { 'decoded output': {
'0': 'uint256: 345', '0': 'uint256: 345',
@ -53,7 +53,7 @@ module.exports = {
.clickFunction('retunValues1 - transact (not payable)') .clickFunction('retunValues1 - transact (not payable)')
.testFunction('0x09c6716a67f0f8c7a0ca2b3ddf59c25982da856a95aefd640b767f9b9feee39d', .testFunction('0x09c6716a67f0f8c7a0ca2b3ddf59c25982da856a95aefd640b767f9b9feee39d',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0x09c6716a67f0f8c7a0ca2b3ddf59c25982da856a95aefd640b767f9b9feee39d', 'transaction hash': '0x09c6716a67f0f8c7a0ca2b3ddf59c25982da856a95aefd640b767f9b9feee39d',
'decoded output': { 'decoded output': {
'0': 'bool: _b true', '0': 'bool: _b true',
@ -65,7 +65,7 @@ module.exports = {
.clickFunction('retunValues2 - transact (not payable)') .clickFunction('retunValues2 - transact (not payable)')
.testFunction('0xe884953e0695399d60914af3e1ea2dad59fe41f3c0c20665c130fa40dd0fb6bf', .testFunction('0xe884953e0695399d60914af3e1ea2dad59fe41f3c0c20665c130fa40dd0fb6bf',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0xe884953e0695399d60914af3e1ea2dad59fe41f3c0c20665c130fa40dd0fb6bf', 'transaction hash': '0xe884953e0695399d60914af3e1ea2dad59fe41f3c0c20665c130fa40dd0fb6bf',
'decoded output': { 'decoded output': {
'0': 'bytes1: _b 0x12', '0': 'bytes1: _b 0x12',
@ -83,7 +83,7 @@ module.exports = {
.clickFunction('retunValues3 - transact (not payable)') .clickFunction('retunValues3 - transact (not payable)')
.testFunction('0xb4108649d5e65a4a0776d6ac98c2c356540a7e99d641705a82352a845d467eb5', .testFunction('0xb4108649d5e65a4a0776d6ac98c2c356540a7e99d641705a82352a845d467eb5',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0xb4108649d5e65a4a0776d6ac98c2c356540a7e99d641705a82352a845d467eb5', 'transaction hash': '0xb4108649d5e65a4a0776d6ac98c2c356540a7e99d641705a82352a845d467eb5',
'decoded output': { 'decoded output': {
'0': 'uint8: _en 2', '0': 'uint8: _en 2',
@ -101,7 +101,7 @@ module.exports = {
.clickFunction('inputValue1 - transact (not payable)', {types: 'uint256 _u, int256 _i, string _str', values: '"2343242", "-4324324", "string _ string _ string _ string _ string _ string _ string _ string _ string _ string _"'}) .clickFunction('inputValue1 - transact (not payable)', {types: 'uint256 _u, int256 _i, string _str', values: '"2343242", "-4324324", "string _ string _ string _ string _ string _ string _ string _ string _ string _ string _"'})
.testFunction('0xe9678b5486674a0425301a1d7e925c22cfb9f7f7ec6242697d742009f7ef5b97', .testFunction('0xe9678b5486674a0425301a1d7e925c22cfb9f7f7ec6242697d742009f7ef5b97',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0xe9678b5486674a0425301a1d7e925c22cfb9f7f7ec6242697d742009f7ef5b97', 'transaction hash': '0xe9678b5486674a0425301a1d7e925c22cfb9f7f7ec6242697d742009f7ef5b97',
'decoded output': { 'decoded output': {
'0': 'uint256: _uret 2343242', '0': 'uint256: _uret 2343242',
@ -112,26 +112,29 @@ module.exports = {
.pause(500) .pause(500)
.clickFunction('inputValue2 - transact (not payable)', {types: 'uint256[3] _n, bytes8[4] _b8', values: '[1,2,3], ["0x1234000000000000", "0x1234000000000000","0x1234000000000000","0x1234000000000000"]'}) .clickFunction('inputValue2 - transact (not payable)', {types: 'uint256[3] _n, bytes8[4] _b8', values: '[1,2,3], ["0x1234000000000000", "0x1234000000000000","0x1234000000000000","0x1234000000000000"]'})
.testFunction('0x21724b08c3699bda8375803f8dc842194aea370f2aac284e55144b452dca321f', { .testFunction('0x21724b08c3699bda8375803f8dc842194aea370f2aac284e55144b452dca321f', {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0x21724b08c3699bda8375803f8dc842194aea370f2aac284e55144b452dca321f', 'transaction hash': '0x21724b08c3699bda8375803f8dc842194aea370f2aac284e55144b452dca321f',
'decoded output': { 'decoded output': {
'0': 'uint256[3]: _nret 1,2,3', '0': 'uint256[3]: _nret 1,2,3',
'1': 'bytes8[4]: _b8ret 0x1234000000000000,0x1234000000000000,0x1234000000000000,0x1234000000000000' '1': 'bytes8[4]: _b8ret 0x1234000000000000,0x1234000000000000,0x1234000000000000,0x1234000000000000'
}, },
logs: [ logs: [
{"from":"0x8c1ed7e19abaa9f23c476da86dc1577f1ef401f5", {
"topic":"0xd30981760edbf605bda8689e945f622877f230c9a77cbfbd448aa4b7d8ac6e7f", 'from': '0x8c1eD7e19abAa9f23c476dA86Dc1577F1Ef401f5',
"event":"event1", 'topic': '0xd30981760edbf605bda8689e945f622877f230c9a77cbfbd448aa4b7d8ac6e7f',
"args":{ 'event': 'event1',
"0":"-123", 'args': {
"1":"123", '0': '-123',
"2":{ '1': '123',
"_isIndexed":true, '2': {
"hash":"0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658" "_isIndexed":true,
}, 'hash': '0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658'
"3":"0x12340000", },
"4":"test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test "} '3': '0x12340000',
}] '4': 'test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test '
}
}
]
}) })
.click('*[data-id="deployAndRunClearInstances"]') .click('*[data-id="deployAndRunClearInstances"]')
}, },

@ -31,7 +31,7 @@ module.exports = {
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}) .clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', .testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
{ {
status: '0x1 Transaction mined and execution succeed', status: 'true Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', 'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } 'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
}) })
@ -42,7 +42,7 @@ module.exports = {
.pause(5000) .pause(5000)
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803', .testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
{ {
status: '0x0 Transaction mined but execution failed', status: 'false Transaction mined but execution failed',
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803', 'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } 'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
}) })

@ -228,6 +228,11 @@ class Blockchain {
} }
web3 () { web3 () {
// @todo(https://github.com/ethereum/remix-project/issues/431)
const isVM = this.getProvider() === 'vm'
if (isVM) {
return this.providers.vm.web3
}
return this.executionContext.web3() return this.executionContext.web3()
} }

@ -91,10 +91,12 @@ function createVm (hardfork) {
} }
const vms = { const vms = {
/*
byzantium: createVm('byzantium'), byzantium: createVm('byzantium'),
constantinople: createVm('constantinople'), constantinople: createVm('constantinople'),
petersburg: createVm('petersburg'), petersburg: createVm('petersburg'),
istanbul: createVm('istanbul'), istanbul: createVm('istanbul'),
*/
muirGlacier: createVm('muirGlacier') muirGlacier: createVm('muirGlacier')
} }

@ -72,9 +72,9 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
} }
let tx = {} let tx = {}
tx.hash = self.processingHash tx.hash = self.processingHash
tx.from = util.hexConvert(data.getSenderAddress()) tx.from = ethutil.toChecksumAddress(util.hexConvert(data.getSenderAddress()))
if (data.to && data.to.length) { if (data.to && data.to.length) {
tx.to = util.hexConvert(data.to) tx.to = ethutil.toChecksumAddress(util.hexConvert(data.to))
} }
this.processingAddress = tx.to this.processingAddress = tx.to
tx.data = util.hexConvert(data.data) tx.data = util.hexConvert(data.data)
@ -128,8 +128,8 @@ web3VmProvider.prototype.txProcessed = function (self, data) {
if (data.createdAddress) { if (data.createdAddress) {
const address = util.hexConvert(data.createdAddress) const address = util.hexConvert(data.createdAddress)
self.vmTraces[self.processingHash].return = address self.vmTraces[self.processingHash].return = ethutil.toChecksumAddress(address)
self.txsReceipt[self.processingHash].contractAddress = address self.txsReceipt[self.processingHash].contractAddress = ethutil.toChecksumAddress(address)
} else if (data.execResult.returnValue) { } else if (data.execResult.returnValue) {
self.vmTraces[self.processingHash].return = util.hexConvert(data.execResult.returnValue) self.vmTraces[self.processingHash].return = util.hexConvert(data.execResult.returnValue)
} else { } else {
@ -196,6 +196,7 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
} }
web3VmProvider.prototype.getCode = function (address, cb) { web3VmProvider.prototype.getCode = function (address, cb) {
address = ethutil.toChecksumAddress(address)
const account = ethutil.toBuffer(address) const account = ethutil.toBuffer(address)
this.vm.stateManager.getContractCode(account, (error, result) => { this.vm.stateManager.getContractCode(account, (error, result) => {
cb(error, util.hexConvert(result)) cb(error, util.hexConvert(result))
@ -219,6 +220,7 @@ web3VmProvider.prototype.traceTransaction = function (txHash, options, cb) {
web3VmProvider.prototype.storageRangeAt = function (blockNumber, txIndex, address, start, maxLength, cb) { // txIndex is the hash in the case of the VM web3VmProvider.prototype.storageRangeAt = function (blockNumber, txIndex, address, start, maxLength, cb) { // txIndex is the hash in the case of the VM
// we don't use the range params here // we don't use the range params here
address = ethutil.toChecksumAddress(address)
if (txIndex === 'latest') { if (txIndex === 'latest') {
txIndex = this.lastProcessedStorageTxHash[address] txIndex = this.lastProcessedStorageTxHash[address]

@ -0,0 +1,33 @@
class Debug {
constructor (executionContext) {
this.executionContext = executionContext
}
methods () {
return {
debug_traceTransaction: this.debug_traceTransaction.bind(this),
debug_preimage: this.debug_preimage.bind(this),
debug_storageRangeAt: this.debug_storageRangeAt.bind(this),
}
}
debug_traceTransaction (payload, cb) {
this.executionContext.web3().debug.traceTransaction(payload.params[0], {}, cb)
}
debug_preimage (payload, cb) {
this.executionContext.web3().debug.preimage(payload.params[0], cb)
}
debug_storageRangeAt (payload, cb) {
this.executionContext.web3().debug.storageRangeAt(
payload.params[0],
payload.params[1],
payload.params[2],
payload.params[3],
payload.params[4],
cb)
}
}
module.exports = Debug

@ -52,7 +52,8 @@ class Transactions{
'cumulativeGasUsed': Web3.utils.toHex(receipt.gas), 'cumulativeGasUsed': Web3.utils.toHex(receipt.gas),
'contractAddress': receipt.contractAddress, 'contractAddress': receipt.contractAddress,
'logs': receipt.logs, 'logs': receipt.logs,
'status': receipt.status 'status': receipt.status,
'to': receipt.to
} }
if (r.blockNumber === '0x') { if (r.blockNumber === '0x') {

@ -10,6 +10,7 @@ const Filters = require('./methods/filters.js')
const Misc = require('./methods/misc.js') const Misc = require('./methods/misc.js')
const Net = require('./methods/net.js') const Net = require('./methods/net.js')
const Transactions = require('./methods/transactions.js') const Transactions = require('./methods/transactions.js')
const Debug = require('./methods/debug.js')
const generateBlock = require('./genesis.js') const generateBlock = require('./genesis.js')
@ -28,6 +29,7 @@ class Provider {
this.methods = merge(this.methods, (new Filters(this.executionContext)).methods()) this.methods = merge(this.methods, (new Filters(this.executionContext)).methods())
this.methods = merge(this.methods, (new Net()).methods()) this.methods = merge(this.methods, (new Net()).methods())
this.methods = merge(this.methods, this.Transactions.methods()) this.methods = merge(this.methods, this.Transactions.methods())
this.methods = merge(this.methods, (new Debug(this.executionContext)).methods())
generateBlock(this.executionContext) generateBlock(this.executionContext)
this.init() this.init()

Loading…
Cancel
Save