Skip to content

Commit

Permalink
Merge pull request #1267 from nomiclabs/fix-hardhat-network-bugs
Browse files Browse the repository at this point in the history
Fix Hardhat Network bugs
  • Loading branch information
fvictorio authored Feb 23, 2021
2 parents b646360 + c6f8cdb commit ddbb37b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {

export class JsonRpcClient {
private _cache: Map<string, any> = new Map();
private _scopedForkCacheFolderCreated?: boolean;

constructor(
private _httpProvider: HttpProvider,
Expand Down Expand Up @@ -429,11 +428,7 @@ export class JsonRpcClient {
) {
const requestPath = this._getDiskCachePathForKey(forkCachePath, cacheKey);

if (this._scopedForkCacheFolderCreated !== true) {
this._scopedForkCacheFolderCreated = true;
await fsExtra.ensureDir(path.dirname(requestPath));
}

await fsExtra.ensureDir(path.dirname(requestPath));
await fsExtra.writeJSON(requestPath, rawResult, {
encoding: "utf8",
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import VM from "@nomiclabs/ethereumjs-vm";
import Bloom from "@nomiclabs/ethereumjs-vm/dist/bloom";
import { EVMResult, ExecResult } from "@nomiclabs/ethereumjs-vm/dist/evm/evm";
import { ERROR } from "@nomiclabs/ethereumjs-vm/dist/exceptions";
import { ERROR, VmError } from "@nomiclabs/ethereumjs-vm/dist/exceptions";
import { RunBlockResult } from "@nomiclabs/ethereumjs-vm/dist/runBlock";
import { StateManager } from "@nomiclabs/ethereumjs-vm/dist/state";
import chalk from "chalk";
Expand Down Expand Up @@ -931,6 +931,13 @@ export class HardhatNode extends EventEmitter {

const error = vmResult.exceptionError;

// If this is an internal VM error, or a different kind of error was
// thrown, we just rethrow. An example of a non-VmError being thrown here
// is an HTTP error coming from the ForkedStateManager.
if (!(error instanceof VmError) || error.error === ERROR.INTERNAL_ERROR) {
throw error;
}

if (error.error === ERROR.OUT_OF_GAS) {
if (this._isContractTooLargeStackTrace(stackTrace)) {
return encodeSolidityStackTrace(
Expand Down

0 comments on commit ddbb37b

Please sign in to comment.