diff --git a/src/chains/ethereum/ethereum/src/api.ts b/src/chains/ethereum/ethereum/src/api.ts index 59b91880aa..58ae4cda06 100644 --- a/src/chains/ethereum/ethereum/src/api.ts +++ b/src/chains/ethereum/ethereum/src/api.ts @@ -592,9 +592,14 @@ export default class EthereumApi implements Api { @assertArgLength(0, 1) async miner_start(threads: number = 1) { if (this.#options.miner.legacyInstamine === true) { - const { transactions } = await this.#blockchain.resume(threads); - if (transactions != null && this.#options.chain.vmErrorsOnRPCResponse) { - assertExceptionalTransactions(transactions); + const resumption = await this.#blockchain.resume(threads); + // resumption can be undefined if the blockchain isn't currently paused + if ( + resumption && + resumption.transactions != null && + this.#options.chain.vmErrorsOnRPCResponse + ) { + assertExceptionalTransactions(resumption.transactions); } } else { this.#blockchain.resume(threads); diff --git a/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts b/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts index f72caf104d..2f274ff128 100644 --- a/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/miner/miner.test.ts @@ -67,6 +67,14 @@ describe("api", () => { const provider = await getProvider({ miner: { blockTime: 1 } }); await testStopStartMining(provider); }).timeout(4000); + + it("should not throw an error when miner was already started when calling miner_start", async () => { + const provider = await getProvider({ + miner: { blockTime: 1, legacyInstamine: true } + }); + await assert.doesNotReject(provider.send("miner_start")); + await assert.doesNotReject(provider.send("miner_start")); + }).timeout(4000); }); describe("miner_setEtherbase", () => {