|
|
|
@ -57,20 +57,24 @@ class StateManagerCommonStorageDump extends StateManager { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var stateManager = new StateManagerCommonStorageDump({}) |
|
|
|
|
var vm = new EthJSVM({ |
|
|
|
|
enableHomestead: true, |
|
|
|
|
activatePrecompiles: true |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// FIXME: move state manager in EthJSVM ctr
|
|
|
|
|
vm.stateManager = stateManager |
|
|
|
|
vm.blockchain = stateManager.blockchain |
|
|
|
|
vm.trie = stateManager.trie |
|
|
|
|
vm.stateManager.checkpoint(() => {}) |
|
|
|
|
function createVm (hardfork) { |
|
|
|
|
var stateManager = new StateManagerCommonStorageDump({}) |
|
|
|
|
stateManager.checkpoint(() => {}) |
|
|
|
|
var vm = new EthJSVM({ |
|
|
|
|
activatePrecompiles: true, |
|
|
|
|
blockchain: stateManager.blockchain, |
|
|
|
|
stateManager: stateManager, |
|
|
|
|
hardfork: hardfork |
|
|
|
|
}) |
|
|
|
|
var web3vm = new Web3VMProvider() |
|
|
|
|
web3vm.setVM(vm) |
|
|
|
|
return { vm, web3vm, stateManager } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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() |
|
|
|
|