From 3820426d0049dee48f0c38a27da6b701d56b7cf9 Mon Sep 17 00:00:00 2001 From: LeviBarnes Date: Mon, 28 Jan 2019 16:16:37 -0800 Subject: [PATCH 1/3] Allow calls to runRaw to specify the timestamp. This is useful when, for example, running a recorded .json file for cases that rely on a specific time between transactions. If no timestamp is passed as part of the tx argument to runRaw, behavior does not change. --- package.json | 4 ++++ remix-lib/src/execution/txRunner.js | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d448b61977..f845d92b86 100644 --- a/package.json +++ b/package.json @@ -11,5 +11,9 @@ "publish": "lerna publish", "release": "lerna bootstrap; lerna publish;", "tag": "gulp; gulp publishTag;" + }, + "dependencies": { + "remix-ide": "^0.7.5-local", + "remixd": "^0.1.8-alpha.6" } } diff --git a/remix-lib/src/execution/txRunner.js b/remix-lib/src/execution/txRunner.js index dad77bdc6a..b1b54a5b9d 100644 --- a/remix-lib/src/execution/txRunner.js +++ b/remix-lib/src/execution/txRunner.js @@ -22,7 +22,11 @@ class TxRunner { } rawRun (args, confirmationCb, gasEstimationForceSend, promptCb, cb) { - run(this, args, Date.now(), confirmationCb, gasEstimationForceSend, promptCb, cb) + var timestamp = Date.now() + if (args.timestamp) { + timestamp = args.timestamp + } + run(this, args, timestamp, confirmationCb, gasEstimationForceSend, promptCb, cb) } _executeTx (tx, gasPrice, api, promptCb, callback) { @@ -81,20 +85,21 @@ class TxRunner { self.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, confirmationCb, gasEstimationForceSend, promptCb, callback) } else { try { - self.runInVm(args.from, args.to, data, args.value, args.gasLimit, args.useCall, callback) + self.runInVm(args.from, args.to, data, args.value, args.gasLimit, args.useCall, args.timestamp, callback) } catch (e) { callback(e, null) } } } - runInVm (from, to, data, value, gasLimit, useCall, callback) { + runInVm (from, to, data, value, gasLimit, useCall, timestamp, callback) { const self = this var account = self.vmaccounts[from] if (!account) { return callback('Invalid account selected') } var tx = new EthJSTX({ + timestamp: timestamp, nonce: new BN(account.nonce++), gasPrice: new BN(1), gasLimit: new BN(gasLimit, 10), @@ -108,7 +113,7 @@ class TxRunner { const difficulties = [ new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10) ] var block = new EthJSBlock({ header: { - timestamp: new Date().getTime() / 1000 | 0, + timestamp: timestamp || (new Date().getTime() / 1000 | 0), number: self.blockNumber, coinbase: coinbases[self.blockNumber % coinbases.length], difficulty: difficulties[self.blockNumber % difficulties.length], From 956ff3b26b671406373f6abe8bfbad0dd1cb9223 Mon Sep 17 00:00:00 2001 From: LeviBarnes Date: Tue, 29 Jan 2019 08:25:28 -0800 Subject: [PATCH 2/3] Reverting changes to package.json --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index f845d92b86..d448b61977 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,5 @@ "publish": "lerna publish", "release": "lerna bootstrap; lerna publish;", "tag": "gulp; gulp publishTag;" - }, - "dependencies": { - "remix-ide": "^0.7.5-local", - "remixd": "^0.1.8-alpha.6" } } From 989b6b048a0473c2b4a07ff37fea615e5abf34fd Mon Sep 17 00:00:00 2001 From: LeviBarnes Date: Wed, 30 Jan 2019 19:33:58 -0800 Subject: [PATCH 3/3] Fix indent error in txRunner --- remix-lib/src/execution/txRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-lib/src/execution/txRunner.js b/remix-lib/src/execution/txRunner.js index b1b54a5b9d..3d23ec7eda 100644 --- a/remix-lib/src/execution/txRunner.js +++ b/remix-lib/src/execution/txRunner.js @@ -24,7 +24,7 @@ class TxRunner { rawRun (args, confirmationCb, gasEstimationForceSend, promptCb, cb) { var timestamp = Date.now() if (args.timestamp) { - timestamp = args.timestamp + timestamp = args.timestamp } run(this, args, timestamp, confirmationCb, gasEstimationForceSend, promptCb, cb) }