Merge pull request #1141 from ethereum/constantinople

constantinople support (JSVM)
pull/5370/head
yann300 6 years ago committed by GitHub
commit 9a0f81e36d
  1. 2
      remix-debug/package.json
  2. 10
      remix-debug/test/decoder/vmCall.js
  3. 10
      remix-debug/test/vmCall.js
  4. 2
      remix-lib/package.json
  5. 32
      remix-lib/src/execution/execution-context.js
  6. 2
      remix-lib/src/execution/txRunner.js
  7. 9
      remix-lib/src/web3Provider/web3VmProvider.js
  8. 1
      remix-simulator/package.json
  9. 2
      remix-solidity/package.json

@ -20,7 +20,7 @@
"dependencies": {
"commander": "^2.19.0",
"ethereumjs-util": "^4.5.0",
"ethereumjs-vm": "2.4.0",
"ethereumjs-vm": "github:yann300/ethereumjs-vm#48db4cb8f884234428682803c2ea5301f5141e96",
"fast-async": "^6.1.2",
"remix-lib": "0.4.1"
},

@ -42,7 +42,15 @@ function initVM (st, privateKey) {
enableHomestead: true,
activatePrecompiles: true
})
vm.stateManager.putAccountBalance(address, 'f00000000000000001', function cb () {})
vm.stateManager.getAccount(address, (error, account) => {
if (error) return console.log(error)
account.balance = '0xf00000000000000001'
vm.stateManager.putAccount(address, account, function cb (error) {
if (error) console.log(error)
})
})
var web3Providers = new Web3Providers()
web3Providers.addVM('VM', vm)
web3Providers.get('VM', function (error, obj) {

@ -42,7 +42,15 @@ function initVM (st, privateKey) {
enableHomestead: true,
activatePrecompiles: true
})
vm.stateManager.putAccountBalance(address, 'f00000000000000001', function cb () {})
vm.stateManager.getAccount(address, (error, account) => {
if (error) return console.log(error)
account.balance = '0xf00000000000000001'
vm.stateManager.putAccount(address, account, function cb (error) {
if (error) console.log(error)
})
})
var web3Providers = new Web3Providers()
web3Providers.addVM('VM', vm)
web3Providers.get('VM', function (error, obj) {

@ -18,7 +18,7 @@
"ethereumjs-block": "^1.6.0",
"ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.2",
"ethereumjs-vm": "2.4.0",
"ethereumjs-vm": "github:yann300/ethereumjs-vm#48db4cb8f884234428682803c2ea5301f5141e96",
"ethers": "^3.0.15",
"fast-async": "^6.1.2",
"solc": "^0.5.0",

@ -57,20 +57,24 @@ class StateManagerCommonStorageDump extends StateManager {
}
}
function createVm (hardfork) {
var stateManager = new StateManagerCommonStorageDump({})
stateManager.checkpoint(() => {})
var vm = new EthJSVM({
enableHomestead: true,
activatePrecompiles: true
activatePrecompiles: true,
blockchain: stateManager.blockchain,
stateManager: stateManager,
hardfork: hardfork
})
var web3vm = new Web3VMProvider()
web3vm.setVM(vm)
return { vm, web3vm, stateManager }
}
// FIXME: move state manager in EthJSVM ctr
vm.stateManager = stateManager
vm.blockchain = stateManager.blockchain
vm.trie = stateManager.trie
vm.stateManager.checkpoint(() => {})
var web3VM = new Web3VMProvider()
web3VM.setVM(vm)
var vms = {
byzantium: createVm('byzantium'),
constantinople: createVm('constantinople')
}
var mainNetGenesisHash = '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3'
@ -104,7 +108,7 @@ function ExecutionContext () {
}
this.web3 = function () {
return this.isVM() ? web3VM : web3
return this.isVM() ? vms.constantinople.web3vm : web3
}
this.detectNetwork = function (callback) {
@ -158,7 +162,7 @@ function ExecutionContext () {
}
this.vm = function () {
return vm
return vms.constantinople.vm
}
this.setContext = function (context, endPointUrl, confirmCb, infoCb) {
@ -171,8 +175,8 @@ function ExecutionContext () {
if (context === 'vm') {
executionContext = context
vm.stateManager.revert(function () {
vm.stateManager.checkpoint()
vms.constantinople.stateManager.revert(() => {
vms.constantinople.stateManager.checkpoint(() => {})
})
self.event.trigger('contextChanged', ['vm'])
return cb()

@ -125,7 +125,7 @@ class TxRunner {
if (!useCall) {
++self.blockNumber
} else {
executionContext.vm().stateManager.checkpoint()
executionContext.vm().stateManager.checkpoint(() => {})
}
executionContext.vm().runTx({block: block, tx: tx, skipBalance: true, skipNonce: true}, function (err, result) {

@ -88,7 +88,8 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
self.txsReceipt[self.processingHash] = tx
self.storageCache[self.processingHash] = {}
if (tx.to) {
self.vm.stateManager.dumpStorage(tx.to, function (storage) {
const account = ethutil.toBuffer(tx.to)
self.vm.stateManager.dumpStorage(account, function (storage) {
self.storageCache[self.processingHash][tx.to] = storage
})
}
@ -172,7 +173,8 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
} else {
this.processingAddress = uiutil.normalizeHexAddress(step.stack[step.stack.length - 2])
if (!self.storageCache[self.processingHash][this.processingAddress]) {
self.vm.stateManager.dumpStorage(this.processingAddress, function (storage) {
const account = ethutil.toBuffer(this.processingAddress)
self.vm.stateManager.dumpStorage(account, function (storage) {
self.storageCache[self.processingHash][self.processingAddress] = storage
})
}
@ -191,7 +193,8 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
}
web3VmProvider.prototype.getCode = function (address, cb) {
this.vm.stateManager.getContractCode(address, function (error, result) {
const account = ethutil.toBuffer(address)
this.vm.stateManager.getContractCode(account, function (error, result) {
cb(error, util.hexConvert(result))
})
}

@ -23,6 +23,7 @@
"fast-async": "^6.3.7",
"merge": "^1.2.0",
"remix-lib": "0.4.1",
"standard": "^10.0.3",
"time-stamp": "^2.0.0",
"web3": "1.0.0-beta.27"
},

@ -15,7 +15,7 @@
"main": "./index.js",
"dependencies": {
"ethereumjs-util": "^4.5.0",
"ethereumjs-vm": "2.4.0",
"ethereumjs-vm": "github:yann300/ethereumjs-vm#48db4cb8f884234428682803c2ea5301f5141e96",
"fast-async": "^6.1.2",
"remix-lib": "0.4.1",
"solc": "^0.5.0",

Loading…
Cancel
Save