|
|
@ -15,6 +15,7 @@ export class TxRunnerVM { |
|
|
|
blocks |
|
|
|
blocks |
|
|
|
logsManager |
|
|
|
logsManager |
|
|
|
commonContext |
|
|
|
commonContext |
|
|
|
|
|
|
|
nextNonceForCall: number |
|
|
|
getVMObject: () => any |
|
|
|
getVMObject: () => any |
|
|
|
|
|
|
|
|
|
|
|
constructor (vmaccounts, api, getVMObject) { |
|
|
|
constructor (vmaccounts, api, getVMObject) { |
|
|
@ -31,6 +32,13 @@ export class TxRunnerVM { |
|
|
|
this.vmaccounts = vmaccounts |
|
|
|
this.vmaccounts = vmaccounts |
|
|
|
this.queusTxs = [] |
|
|
|
this.queusTxs = [] |
|
|
|
this.blocks = [] |
|
|
|
this.blocks = [] |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
txHash is generated using the nonce, |
|
|
|
|
|
|
|
in order to have unique transaction hash, we need to keep using different nonce (in case of a call) |
|
|
|
|
|
|
|
so we increment this value after each call. |
|
|
|
|
|
|
|
For this to function we also need to skip nonce validation, in the vm: `{ skipNonce: true }` |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
this.nextNonceForCall = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
execute (args, confirmationCb, gasEstimationForceSend, promptCb, callback) { |
|
|
|
execute (args, confirmationCb, gasEstimationForceSend, promptCb, callback) { |
|
|
@ -75,7 +83,7 @@ export class TxRunnerVM { |
|
|
|
let tx |
|
|
|
let tx |
|
|
|
if (!EIP1559) { |
|
|
|
if (!EIP1559) { |
|
|
|
tx = Transaction.fromTxData({ |
|
|
|
tx = Transaction.fromTxData({ |
|
|
|
nonce: new BN(res.nonce), |
|
|
|
nonce: useCall ? this.nextNonceForCall : new BN(res.nonce), |
|
|
|
gasPrice: '0x1', |
|
|
|
gasPrice: '0x1', |
|
|
|
gasLimit: gasLimit, |
|
|
|
gasLimit: gasLimit, |
|
|
|
to: to, |
|
|
|
to: to, |
|
|
@ -84,7 +92,7 @@ export class TxRunnerVM { |
|
|
|
}, { common: this.commonContext }).sign(account.privateKey) |
|
|
|
}, { common: this.commonContext }).sign(account.privateKey) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tx = FeeMarketEIP1559Transaction.fromTxData({ |
|
|
|
tx = FeeMarketEIP1559Transaction.fromTxData({ |
|
|
|
nonce: new BN(res.nonce), |
|
|
|
nonce: useCall ? this.nextNonceForCall : new BN(res.nonce), |
|
|
|
maxPriorityFeePerGas: '0x01', |
|
|
|
maxPriorityFeePerGas: '0x01', |
|
|
|
maxFeePerGas: '0x1', |
|
|
|
maxFeePerGas: '0x1', |
|
|
|
gasLimit: gasLimit, |
|
|
|
gasLimit: gasLimit, |
|
|
@ -93,6 +101,7 @@ export class TxRunnerVM { |
|
|
|
data: Buffer.from(data.slice(2), 'hex') |
|
|
|
data: Buffer.from(data.slice(2), 'hex') |
|
|
|
}).sign(account.privateKey) |
|
|
|
}).sign(account.privateKey) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (useCall) this.nextNonceForCall++ |
|
|
|
|
|
|
|
|
|
|
|
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)] |
|
|
@ -127,7 +136,7 @@ export class TxRunnerVM { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
runBlockInVm (tx, block, callback) { |
|
|
|
runBlockInVm (tx, block, callback) { |
|
|
|
this.getVMObject().vm.runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }).then((results) => { |
|
|
|
this.getVMObject().vm.runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false, skipNonce: true }).then((results) => { |
|
|
|
const result = results.results[0] |
|
|
|
const result = results.results[0] |
|
|
|
if (result) { |
|
|
|
if (result) { |
|
|
|
const status = result.execResult.exceptionError ? 0 : 1 |
|
|
|
const status = result.execResult.exceptionError ? 0 : 1 |
|
|
|