diff --git a/remix-lib/src/execution/execution-context.js b/remix-lib/src/execution/execution-context.js index 9aa3d34efa..08b9b2ce06 100644 --- a/remix-lib/src/execution/execution-context.js +++ b/remix-lib/src/execution/execution-context.js @@ -220,6 +220,19 @@ function ExecutionContext () { } } + this.checkpointAndCommit = function (cb, checkpointCount) { + 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 () { return this.blockGasLimit } diff --git a/remix-lib/src/execution/txRunner.js b/remix-lib/src/execution/txRunner.js index 3f274d4e75..7ad38fb02c 100644 --- a/remix-lib/src/execution/txRunner.js +++ b/remix-lib/src/execution/txRunner.js @@ -135,7 +135,7 @@ class TxRunner { executionContext.vm().stateManager.checkpoint(() => { }) } - this.checkpointAndCommit(() => { + executionContext.checkpointAndCommit(() => { executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function (err, results) { err = err ? err.message : err if (err) { @@ -157,20 +157,7 @@ class TxRunner { transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash())) }) }) - }) - } - - checkpointAndCommit (cb) { - if (executionContext.vm().stateManager._checkpointCount > 1) { - return executionContext.vm().stateManager.commit(() => { - cb() - }) - } - executionContext.vm().stateManager.checkpoint(() => { - executionContext.vm().stateManager.commit(() => { - cb() - }) - }) + }, 1) } runInNode (from, to, data, value, gasLimit, useCall, confirmCb, gasEstimationForceSend, promptCb, callback) { diff --git a/remix-simulator/src/genesis.js b/remix-simulator/src/genesis.js index 542930a2a8..295cb935f4 100644 --- a/remix-simulator/src/genesis.js +++ b/remix-simulator/src/genesis.js @@ -4,19 +4,6 @@ var executionContext = RemixLib.execution.executionContext var ethJSUtil = require('ethereumjs-util') var BN = ethJSUtil.BN -function checkpointAndCommit (cb) { - if (executionContext.vm().stateManager._checkpointCount > 0) { - return executionContext.vm().stateManager.commit(() => { - cb() - }) - } - executionContext.vm().stateManager.checkpoint(() => { - executionContext.vm().stateManager.commit(() => { - cb() - }) - }) -} - function generateBlock () { var block = new EthJSBlock({ header: { @@ -30,7 +17,7 @@ function generateBlock () { uncleHeaders: [] }) - checkpointAndCommit(() => { + executionContext.checkpointAndCommit(() => { executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function () { executionContext.addBlock(block) })