|
|
@ -101,59 +101,70 @@ class TxRunner { |
|
|
|
return callback('Invalid account selected') |
|
|
|
return callback('Invalid account selected') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var tx = new EthJSTX({ |
|
|
|
executionContext.vm().stateManager.getAccount(Buffer.from(from.replace('0x', ''), 'hex'), (err, res) => { |
|
|
|
timestamp: timestamp, |
|
|
|
if (err) { |
|
|
|
nonce: new BN(account.nonce++), |
|
|
|
callback('Account not found') |
|
|
|
gasPrice: new BN(1), |
|
|
|
} else { |
|
|
|
gasLimit: gasLimit, |
|
|
|
var tx = new EthJSTX({ |
|
|
|
to: to, |
|
|
|
timestamp: timestamp, |
|
|
|
value: new BN(value, 10), |
|
|
|
nonce: new BN(res.nonce), |
|
|
|
data: Buffer.from(data.slice(2), 'hex') |
|
|
|
gasPrice: new BN(1), |
|
|
|
}) |
|
|
|
gasLimit: gasLimit, |
|
|
|
tx.sign(account.privateKey) |
|
|
|
to: to, |
|
|
|
|
|
|
|
value: new BN(value, 10), |
|
|
|
|
|
|
|
data: Buffer.from(data.slice(2), 'hex') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
tx.sign(account.privateKey) |
|
|
|
|
|
|
|
|
|
|
|
const coinbases = ['0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a', '0x8945a1288dc78a6d8952a92c77aee6730b414778', '0x94d76e24f818426ae84aa404140e8d5f60e10e7e'] |
|
|
|
const coinbases = ['0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a', '0x8945a1288dc78a6d8952a92c77aee6730b414778', '0x94d76e24f818426ae84aa404140e8d5f60e10e7e'] |
|
|
|
const difficulties = [new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10)] |
|
|
|
const difficulties = [new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10)] |
|
|
|
var block = new EthJSBlock({ |
|
|
|
var block = new EthJSBlock({ |
|
|
|
header: { |
|
|
|
header: { |
|
|
|
timestamp: timestamp || (new Date().getTime() / 1000 | 0), |
|
|
|
timestamp: timestamp || (new Date().getTime() / 1000 | 0), |
|
|
|
number: self.blockNumber, |
|
|
|
number: self.blockNumber, |
|
|
|
coinbase: coinbases[self.blockNumber % coinbases.length], |
|
|
|
coinbase: coinbases[self.blockNumber % coinbases.length], |
|
|
|
difficulty: difficulties[self.blockNumber % difficulties.length], |
|
|
|
difficulty: difficulties[self.blockNumber % difficulties.length], |
|
|
|
gasLimit: new BN(gasLimit, 10).imuln(2) |
|
|
|
gasLimit: new BN(gasLimit, 10).imuln(2) |
|
|
|
}, |
|
|
|
}, |
|
|
|
transactions: [tx], |
|
|
|
transactions: [tx], |
|
|
|
uncleHeaders: [] |
|
|
|
uncleHeaders: [] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
if (!useCall) { |
|
|
|
|
|
|
|
++self.blockNumber |
|
|
|
|
|
|
|
this.runBlockInVm(tx, block, callback) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
executionContext.vm().stateManager.checkpoint(() => { |
|
|
|
|
|
|
|
this.runBlockInVm(tx, block, (err, result) => { |
|
|
|
|
|
|
|
executionContext.vm().stateManager.revert(() => { |
|
|
|
|
|
|
|
callback(err, result) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (!useCall) { |
|
|
|
} |
|
|
|
++self.blockNumber |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
executionContext.vm().stateManager.checkpoint(() => { }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
|
result.status = '0x' + result.vm.exception.toString(16) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
executionContext.addBlock(block) |
|
|
|
if (result) { |
|
|
|
executionContext.trackTx('0x' + tx.hash().toString('hex'), block) |
|
|
|
result.status = '0x' + result.vm.exception.toString(16) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callback(err, { |
|
|
|
executionContext.addBlock(block) |
|
|
|
result: result, |
|
|
|
executionContext.trackTx('0x' + tx.hash().toString('hex'), block) |
|
|
|
transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash())) |
|
|
|
|
|
|
|
}) |
|
|
|
callback(err, { |
|
|
|
|
|
|
|
result: result, |
|
|
|
|
|
|
|
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) { |
|
|
|