Skip to content

Commit

Permalink
VM: unify interpreter and evm DEBUG property
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau committed May 19, 2022
1 parent 723638f commit 3a0edf9
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/vm/src/evm/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export default class Interpreter {
_common: Common
_evm: EVM

protected readonly DEBUG: boolean = false

// Opcode debuggers (e.g. { 'push': [debug Object], 'sstore': [debug Object], ...})
private opDebuggers: { [key: string]: (debug: string) => void } = {}

Expand All @@ -92,11 +90,6 @@ export default class Interpreter {
eei: this._eei,
shouldDoJumpAnalysis: true,
}

// Safeguard if "process" is not available (browser)
if (process !== undefined && process.env.DEBUG) {
this.DEBUG = true
}
}

async run(code: Buffer, opts: InterpreterOpts = {}): Promise<InterpreterResult> {
Expand Down Expand Up @@ -197,7 +190,7 @@ export default class Interpreter {
gas = await dynamicGasHandler(this._runState, gas, this._common)
}

if (this._evm.listenerCount('step') > 0 || this.DEBUG) {
if (this._evm.listenerCount('step') > 0 || this._evm.DEBUG) {
// Only run this stepHook function if there is an event listener (e.g. test runner)
// or if the vm is running in debug mode (to display opcode debug logs)
await this._runStepHook(gas, gasLimitClone)
Expand Down Expand Up @@ -261,7 +254,7 @@ export default class Interpreter {
codeAddress: this._eei._env.codeAddress,
}

if (this.DEBUG) {
if (this._evm.DEBUG) {
// Create opTrace for debug functionality
let hexStack = []
hexStack = eventObj.stack.map((item: any) => {
Expand Down

0 comments on commit 3a0edf9

Please sign in to comment.