File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
yarn-project/simulator/src/public/avm Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type { PublicPersistableStateManager } from '../state_manager/state_manag
5
5
import type { AvmExecutionEnvironment } from './avm_execution_environment.js' ;
6
6
import { type Gas , gasToGasLeft } from './avm_gas.js' ;
7
7
import { AvmMachineState } from './avm_machine_state.js' ;
8
- import type { AvmSimulator } from './avm_simulator .js' ;
8
+ import type { AvmSimulatorInterface } from './avm_simulator_interface .js' ;
9
9
10
10
/**
11
11
* An execution context includes the information necessary to initiate AVM
@@ -27,7 +27,7 @@ export class AvmContext {
27
27
28
28
// This is needed to break a dependency cycle created by the CALL opcode,
29
29
// which needs to create a new simulator but cannot depend directly on AvmSimulator.
30
- public provideSimulator ?: ( ctx : this ) => Promise < AvmSimulator > ;
30
+ public provideSimulator ?: ( context : AvmContext ) => Promise < AvmSimulatorInterface > ;
31
31
32
32
/**
33
33
* Prepare a new AVM context that will be ready for an external/nested call
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { AvmContractCallResult } from './avm_contract_call_result.js';
13
13
import { AvmExecutionEnvironment } from './avm_execution_environment.js' ;
14
14
import type { Gas } from './avm_gas.js' ;
15
15
import { AvmMachineState } from './avm_machine_state.js' ;
16
+ import type { AvmSimulatorInterface } from './avm_simulator_interface.js' ;
16
17
import {
17
18
AvmExecutionError ,
18
19
AvmRevertReason ,
@@ -32,7 +33,7 @@ type OpcodeTally = {
32
33
gas : Gas ;
33
34
} ;
34
35
35
- export class AvmSimulator {
36
+ export class AvmSimulator implements AvmSimulatorInterface {
36
37
private log : Logger ;
37
38
private bytecode : Buffer | undefined ;
38
39
private opcodeTallies : Map < string , OpcodeTally > = new Map ( ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Interface for AvmSimulator to break the circular dependency between avm_context.ts and avm_simulator.ts
3
+ */
4
+ export interface AvmSimulatorInterface {
5
+ execute ( ) : Promise < any > ; // Using any here to avoid importing AvmContractCallResult
6
+ executeBytecode ( bytecode : Buffer ) : Promise < any > ;
7
+ getBytecode ( ) : Buffer | undefined ;
8
+ }
You can’t perform that action at this time.
0 commit comments