Merge branch 'master' into fix-test-reporter

pull/5370/head
yann300 5 years ago committed by GitHub
commit f1ad1f3a2d
  1. 2
      package.json
  2. 4
      remix-analyzer/package.json
  3. 4
      remix-astwalker/package.json
  4. 4
      remix-debug/package.json
  5. 2
      remix-lib/package.json
  6. 32
      remix-lib/src/execution/execution-context.js
  7. 25
      remix-lib/src/execution/txRunner.js
  8. 4
      remix-lib/src/universalDapp.js
  9. 14
      remix-lib/src/util.js
  10. 5
      remix-simulator/package.json
  11. 2
      remix-simulator/src/genesis.js
  12. 19
      remix-simulator/src/methods/accounts.js
  13. 12
      remix-simulator/src/methods/transactions.js
  14. 8
      remix-simulator/src/provider.js
  15. 7
      remix-simulator/src/server.js
  16. 4
      remix-solidity/package.json
  17. 8
      remix-tests/package.json
  18. 10
      remix-tests/src/runTestSources.ts
  19. 3
      remix-tests/tests/testRunner.ts

@ -1,5 +1,5 @@
{ {
"version": "0.1.16", "version": "0.1.19",
"devDependencies": { "devDependencies": {
"gulp": "^3.9.1", "gulp": "^3.9.1",
"lerna": "^2.10.2" "lerna": "^2.10.2"

@ -1,6 +1,6 @@
{ {
"name": "remix-analyzer", "name": "remix-analyzer",
"version": "0.3.10", "version": "0.3.13",
"description": "Remix Analyzer", "description": "Remix Analyzer",
"main": "./index.js", "main": "./index.js",
"contributors": [ "contributors": [
@ -18,7 +18,7 @@
} }
], ],
"dependencies": { "dependencies": {
"remix-lib": "0.4.9" "remix-lib": "0.4.12"
}, },
"scripts": { "scripts": {
"lint": "standard", "lint": "standard",

@ -1,6 +1,6 @@
{ {
"name": "remix-astwalker", "name": "remix-astwalker",
"version": "0.0.6", "version": "0.0.9",
"description": "Remix sub-module for walking through AST", "description": "Remix sub-module for walking through AST",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
@ -34,7 +34,7 @@
"dependencies": { "dependencies": {
"@types/tape": "^4.2.33", "@types/tape": "^4.2.33",
"nyc": "^13.3.0", "nyc": "^13.3.0",
"remix-lib": "0.4.9", "remix-lib": "0.4.12",
"tape": "^4.10.1", "tape": "^4.10.1",
"ts-node": "^8.0.3", "ts-node": "^8.0.3",
"typescript": "^3.4.3" "typescript": "^3.4.3"

@ -1,6 +1,6 @@
{ {
"name": "remix-debug", "name": "remix-debug",
"version": "0.3.11", "version": "0.3.14",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
@ -22,7 +22,7 @@
"ethereumjs-util": "^4.5.0", "ethereumjs-util": "^4.5.0",
"ethereumjs-vm": "3.0.0", "ethereumjs-vm": "3.0.0",
"fast-async": "^6.1.2", "fast-async": "^6.1.2",
"remix-lib": "0.4.9", "remix-lib": "0.4.12",
"web3": "0.20.6" "web3": "0.20.6"
}, },
"devDependencies": { "devDependencies": {

@ -1,6 +1,6 @@
{ {
"name": "remix-lib", "name": "remix-lib",
"version": "0.4.9", "version": "0.4.12",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {

@ -56,6 +56,24 @@ class StateManagerCommonStorageDump extends StateManager {
}) })
}) })
} }
getStateRoot (cb) {
let checkpoint = this._checkpointCount
this._checkpointCount = 0
super.getStateRoot((err, stateRoot) => {
this._checkpointCount = checkpoint
cb(err, stateRoot)
})
}
setStateRoot (stateRoot, cb) {
let checkpoint = this._checkpointCount
this._checkpointCount = 0
super.setStateRoot(stateRoot, (err) => {
this._checkpointCount = checkpoint
cb(err)
})
}
} }
function createVm (hardfork) { function createVm (hardfork) {
@ -220,20 +238,6 @@ function ExecutionContext () {
} }
} }
this.checkpointAndCommit = function (cb, checkpointCount) {
// due to issue https://github.com/ethereumjs/ethereumjs-vm/issues/567
if (this.vm().stateManager._checkpointCount > (checkpointCount || 0)) {
return this.vm().stateManager.commit(() => {
cb()
})
}
this.vm().stateManager.checkpoint(() => {
this.vm().stateManager.commit(() => {
cb()
})
})
}
this.currentblockGasLimit = function () { this.currentblockGasLimit = function () {
return this.blockGasLimit return this.blockGasLimit
} }

@ -101,9 +101,13 @@ class TxRunner {
return callback('Invalid account selected') return callback('Invalid account selected')
} }
executionContext.vm().stateManager.getAccount(Buffer.from(from.replace('0x', ''), 'hex'), (err, res) => {
if (err) {
callback('Account not found')
} else {
var tx = new EthJSTX({ var tx = new EthJSTX({
timestamp: timestamp, timestamp: timestamp,
nonce: new BN(account.nonce++), nonce: new BN(res.nonce),
gasPrice: new BN(1), gasPrice: new BN(1),
gasLimit: gasLimit, gasLimit: gasLimit,
to: to, to: to,
@ -127,20 +131,28 @@ class TxRunner {
}) })
if (!useCall) { if (!useCall) {
++self.blockNumber ++self.blockNumber
this.runBlockInVm(tx, block, callback)
} else { } else {
executionContext.vm().stateManager.checkpoint(() => { }) executionContext.vm().stateManager.checkpoint(() => {
this.runBlockInVm(tx, block, (err, result) => {
executionContext.vm().stateManager.revert(() => {
callback(err, result)
})
})
})
}
}
})
} }
executionContext.checkpointAndCommit(() => { runBlockInVm (tx, block, callback) {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function (err, results) { executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function (err, results) {
err = err ? err.message : err err = err ? err.message : err
if (err) { if (err) {
return callback(err) return callback(err)
} }
let result = results.results[0] let result = results.results[0]
if (useCall) {
executionContext.vm().stateManager.revert(function () { })
}
if (result) { if (result) {
result.status = '0x' + result.vm.exception.toString(16) result.status = '0x' + result.vm.exception.toString(16)
} }
@ -153,7 +165,6 @@ class TxRunner {
transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash())) transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash()))
}) })
}) })
}, 1)
} }
runInNode (from, to, data, value, gasLimit, useCall, confirmCb, gasEstimationForceSend, promptCb, callback) { runInNode (from, to, data, value, gasLimit, useCall, confirmCb, gasEstimationForceSend, promptCb, callback) {

@ -1,5 +1,5 @@
const async = require('async') const async = require('async')
const { BN, privateToAddress, isValidPrivate, stripHexPrefix } = require('ethereumjs-util') const { BN, privateToAddress, isValidPrivate, stripHexPrefix, toChecksumAddress } = require('ethereumjs-util')
const crypto = require('crypto') const crypto = require('crypto')
const { EventEmitter } = require('events') const { EventEmitter } = require('events')
@ -121,7 +121,7 @@ module.exports = class UniversalDApp {
}) })
}) })
this.accounts['0x' + address.toString('hex')] = { privateKey, nonce: 0 } this.accounts[toChecksumAddress('0x' + address.toString('hex'))] = { privateKey, nonce: 0 }
} }
} }

@ -180,13 +180,23 @@ module.exports = {
* *
* @return {RegEx} * @return {RegEx}
*/ */
swarmHashExtractionPOC3: function () { swarmHashExtractionPOC31: function () {
return /a265627a7a72315820([0-9a-f]{64})64736f6c6343([0-9a-f]{6})0032$/ return /a265627a7a72315820([0-9a-f]{64})64736f6c6343([0-9a-f]{6})0032$/
}, },
/**
* return a regex which extract the swarmhash from the bytecode, from POC 0.3
*
* @return {RegEx}
*/
swarmHashExtractionPOC32: function () {
return /a265627a7a72305820([0-9a-f]{64})64736f6c6343([0-9a-f]{6})0032$/
},
extractSwarmHash: function (value) { extractSwarmHash: function (value) {
value = value.replace(this.swarmHashExtraction(), '') value = value.replace(this.swarmHashExtraction(), '')
value = value.replace(this.swarmHashExtractionPOC3(), '') value = value.replace(this.swarmHashExtractionPOC31(), '')
value = value.replace(this.swarmHashExtractionPOC32(), '')
return value return value
}, },

@ -1,6 +1,6 @@
{ {
"name": "remix-simulator", "name": "remix-simulator",
"version": "0.1.9-alpha.2", "version": "0.1.9-alpha.5",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
@ -18,13 +18,14 @@
"body-parser": "^1.18.2", "body-parser": "^1.18.2",
"color-support": "^1.1.3", "color-support": "^1.1.3",
"commander": "^2.19.0", "commander": "^2.19.0",
"cors": "^2.8.5",
"ethereumjs-util": "^5.1.2", "ethereumjs-util": "^5.1.2",
"ethereumjs-vm": "3.0.0", "ethereumjs-vm": "3.0.0",
"express": "^4.16.3", "express": "^4.16.3",
"express-ws": "^4.0.0", "express-ws": "^4.0.0",
"fast-async": "^6.3.7", "fast-async": "^6.3.7",
"merge": "^1.2.0", "merge": "^1.2.0",
"remix-lib": "0.4.9", "remix-lib": "0.4.12",
"standard": "^10.0.3", "standard": "^10.0.3",
"time-stamp": "^2.0.0", "time-stamp": "^2.0.0",
"web3": "1.0.0-beta.27" "web3": "1.0.0-beta.27"

@ -17,11 +17,9 @@ function generateBlock () {
uncleHeaders: [] uncleHeaders: []
}) })
executionContext.checkpointAndCommit(() => {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function () { executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function () {
executionContext.addBlock(block) executionContext.addBlock(block)
}) })
})
} }
module.exports = generateBlock module.exports = generateBlock

@ -12,19 +12,28 @@ var Accounts = function () {
this.accountsKeys = {} this.accountsKeys = {}
executionContext.init({get: () => { return true }}) executionContext.init({get: () => { return true }})
}
for (let _account of this.accountsList) { Accounts.prototype.init = async function () {
this.accountsKeys[_account.address.toLowerCase()] = _account.privateKey let setBalance = (account) => {
this.accounts[_account.address.toLowerCase()] = { privateKey: Buffer.from(_account.privateKey.replace('0x', ''), 'hex'), nonce: 0 } return new Promise((resolve, reject) => {
this.accountsKeys[ethJSUtil.toChecksumAddress(account.address)] = account.privateKey
this.accounts[ethJSUtil.toChecksumAddress(account.address)] = { privateKey: Buffer.from(account.privateKey.replace('0x', ''), 'hex'), nonce: 0 }
executionContext.vm().stateManager.getAccount(Buffer.from(_account.address.toLowerCase().replace('0x', ''), 'hex'), (err, account) => { executionContext.vm().stateManager.getAccount(Buffer.from(account.address.toLowerCase().replace('0x', ''), 'hex'), (err, account) => {
if (err) { if (err) {
throw new Error(err) throw new Error(err)
} }
var balance = '0x56BC75E2D63100000' var balance = '0x56BC75E2D63100000'
account.balance = balance || '0xf00000000000000001' account.balance = balance || '0xf00000000000000001'
resolve()
})
}) })
} }
for (let _account of this.accountsList) {
await setBalance(_account)
}
} }
Accounts.prototype.methods = function () { Accounts.prototype.methods = function () {
@ -36,7 +45,7 @@ Accounts.prototype.methods = function () {
} }
Accounts.prototype.eth_accounts = function (payload, cb) { Accounts.prototype.eth_accounts = function (payload, cb) {
return cb(null, this.accountsList.map((x) => x.address)) return cb(null, this.accountsList.map((x) => ethJSUtil.toChecksumAddress(x.address)))
} }
Accounts.prototype.eth_getBalance = function (payload, cb) { Accounts.prototype.eth_getBalance = function (payload, cb) {

@ -5,7 +5,9 @@ var ethJSUtil = require('ethereumjs-util')
var processTx = require('./txProcess.js') var processTx = require('./txProcess.js')
var BN = ethJSUtil.BN var BN = ethJSUtil.BN
var Transactions = function (accounts) { var Transactions = function () {}
Transactions.prototype.init = function (accounts) {
this.accounts = accounts this.accounts = accounts
} }
@ -24,6 +26,10 @@ Transactions.prototype.methods = function () {
} }
Transactions.prototype.eth_sendTransaction = function (payload, cb) { Transactions.prototype.eth_sendTransaction = function (payload, cb) {
// from might be lowercased address (web3)
if (payload.params && payload.params.length > 0 && payload.params[0].from) {
payload.params[0].from = ethJSUtil.toChecksumAddress(payload.params[0].from)
}
processTx(this.accounts, payload, false, cb) processTx(this.accounts, payload, false, cb)
} }
@ -68,6 +74,10 @@ Transactions.prototype.eth_getCode = function (payload, cb) {
} }
Transactions.prototype.eth_call = function (payload, cb) { Transactions.prototype.eth_call = function (payload, cb) {
// from might be lowercased address (web3)
if (payload.params && payload.params.length > 0 && payload.params[0].from) {
payload.params[0].from = ethJSUtil.toChecksumAddress(payload.params[0].from)
}
processTx(this.accounts, payload, true, cb) processTx(this.accounts, payload, true, cb)
} }

@ -12,18 +12,24 @@ const generateBlock = require('./genesis.js')
var Provider = function (options) { var Provider = function (options) {
this.Accounts = new Accounts() this.Accounts = new Accounts()
this.Transactions = new Transactions()
this.methods = {} this.methods = {}
this.methods = merge(this.methods, this.Accounts.methods()) this.methods = merge(this.methods, this.Accounts.methods())
this.methods = merge(this.methods, (new Blocks(options)).methods()) this.methods = merge(this.methods, (new Blocks(options)).methods())
this.methods = merge(this.methods, (new Misc()).methods()) this.methods = merge(this.methods, (new Misc()).methods())
this.methods = merge(this.methods, (new Net()).methods()) this.methods = merge(this.methods, (new Net()).methods())
this.methods = merge(this.methods, (new Transactions(this.Accounts.accounts)).methods()) this.methods = merge(this.methods, (this.Transactions.methods()))
this.methods = merge(this.methods, (new Whisper()).methods()) this.methods = merge(this.methods, (new Whisper()).methods())
generateBlock() generateBlock()
} }
Provider.prototype.init = async function () {
await this.Accounts.init()
this.Transactions.init(this.Accounts.accounts)
}
Provider.prototype.sendAsync = function (payload, callback) { Provider.prototype.sendAsync = function (payload, callback) {
log.info('payload method is ', payload.method) log.info('payload method is ', payload.method)

@ -1,4 +1,5 @@
const express = require('express') const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser') const bodyParser = require('body-parser')
const app = express() const app = express()
const expressWs = require('express-ws') const expressWs = require('express-ws')
@ -8,11 +9,17 @@ const log = require('./utils/logs.js')
class Server { class Server {
constructor (options) { constructor (options) {
this.provider = new Provider(options) this.provider = new Provider(options)
this.provider.init().then(() => {
log('Provider initiated')
}).catch((error) => {
log(error)
})
} }
start (host, port) { start (host, port) {
expressWs(app) expressWs(app)
app.use(cors())
app.use(bodyParser.urlencoded({extended: true})) app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json()) app.use(bodyParser.json())

@ -1,6 +1,6 @@
{ {
"name": "remix-solidity", "name": "remix-solidity",
"version": "0.3.12", "version": "0.3.15",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
@ -17,7 +17,7 @@
"ethereumjs-util": "^4.5.0", "ethereumjs-util": "^4.5.0",
"ethereumjs-vm": "3.0.0", "ethereumjs-vm": "3.0.0",
"fast-async": "^6.1.2", "fast-async": "^6.1.2",
"remix-lib": "0.4.9", "remix-lib": "0.4.12",
"solc": "^0.5.0", "solc": "^0.5.0",
"webworkify": "^1.2.1" "webworkify": "^1.2.1"
}, },

@ -1,6 +1,6 @@
{ {
"name": "remix-tests", "name": "remix-tests",
"version": "0.1.15", "version": "0.1.18",
"description": "Tests for the Ethereum tool suite Remix", "description": "Tests for the Ethereum tool suite Remix",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -42,9 +42,9 @@
"change-case": "^3.0.1", "change-case": "^3.0.1",
"colors": "^1.1.2", "colors": "^1.1.2",
"commander": "^2.13.0", "commander": "^2.13.0",
"remix-lib": "0.4.9", "remix-lib": "0.4.12",
"remix-simulator": "0.1.9-alpha.2", "remix-simulator": "0.1.9-alpha.5",
"remix-solidity": "0.3.12", "remix-solidity": "0.3.15",
"web3": "1.0.0-beta.36", "web3": "1.0.0-beta.36",
"winston": "^3.0.0" "winston": "^3.0.0"
}, },

@ -10,15 +10,17 @@ import Web3 = require('web3')
import { Provider } from 'remix-simulator' import { Provider } from 'remix-simulator'
import { FinalResult } from './types' import { FinalResult } from './types'
const createWeb3Provider = function () { const createWeb3Provider = async function () {
let web3 = new Web3() let web3 = new Web3()
web3.setProvider(new Provider()) let provider = new Provider()
await provider.init()
web3.setProvider(provider)
return web3 return web3
} }
export function runTestSources(contractSources, testCallback, resultCallback, finalCallback, importFileCb, opts) { export async function runTestSources(contractSources, testCallback, resultCallback, finalCallback, importFileCb, opts) {
opts = opts || {} opts = opts || {}
let web3 = opts.web3 || createWeb3Provider() let web3 = opts.web3 || await createWeb3Provider()
let accounts = opts.accounts || null let accounts = opts.accounts || null
async.waterfall([ async.waterfall([
function getAccountList (next) { function getAccountList (next) {

@ -44,8 +44,9 @@ function deepEqualExcluding(a: any, b: any, excludedKeys: string[]) {
let accounts: string[] let accounts: string[]
let provider = new Provider() let provider = new Provider()
function compileAndDeploy(filename: string, callback: Function) { async function compileAndDeploy(filename: string, callback: Function) {
let web3: Web3 = new Web3() let web3: Web3 = new Web3()
await provider.init()
web3.setProvider(provider) web3.setProvider(provider)
let compilationData: object let compilationData: object
async.waterfall([ async.waterfall([

Loading…
Cancel
Save