@@ -88,7 +88,7 @@ export class AztecNodeService implements AztecNode {
88
88
const p2pClient = await createP2PClient ( config , new InMemoryTxPool ( ) , archiver ) ;
89
89
90
90
// now create the merkle trees and the world state syncher
91
- const merkleTreeDB = await MerkleTrees . new ( levelup ( createMemDown ( ) ) , await CircuitsWasm . get ( ) ) ;
91
+ const merkleTreeDB = await AztecNodeService . createMerkleTreeDB ( ) ;
92
92
const worldStateConfig : WorldStateConfig = getWorldStateConfig ( ) ;
93
93
const worldStateSynchroniser = new ServerWorldStateSynchroniser ( merkleTreeDB , archiver , worldStateConfig ) ;
94
94
@@ -119,6 +119,10 @@ export class AztecNodeService implements AztecNode {
119
119
) ;
120
120
}
121
121
122
+ static async createMerkleTreeDB ( ) {
123
+ return MerkleTrees . new ( levelup ( createMemDown ( ) ) , await CircuitsWasm . get ( ) ) ;
124
+ }
125
+
122
126
/**
123
127
* Method to determine if the node is ready to accept transactions.
124
128
* @returns - Flag indicating the readiness for tx submission.
@@ -382,16 +386,17 @@ export class AztecNodeService implements AztecNode {
382
386
**/
383
387
public async simulatePublicPart ( tx : Tx ) {
384
388
this . log . info ( `Simulating tx ${ await tx . getTxHash ( ) } ` ) ;
389
+ // Instantiate merkle tree db so uncommited updates by this simulation are local to it.
390
+ const merkleTreeDb = await AztecNodeService . createMerkleTreeDB ( ) ;
385
391
386
392
const publicProcessorFactory = new PublicProcessorFactory (
387
- this . worldStateSynchroniser . getLatest ( ) ,
393
+ merkleTreeDb . asLatest ( ) ,
388
394
this . contractDataSource ,
389
395
this . l1ToL2MessageSource ,
390
396
) ;
391
397
const blockNumber = ( await this . blockSource . getBlockNumber ( ) ) + 1 ;
392
398
const newGlobalVariables = await this . globalVariableBuilder . buildGlobalVariables ( new Fr ( blockNumber ) ) ;
393
399
const prevGlobalVariables = ( await this . blockSource . getL2Block ( - 1 ) ) ?. globalVariables ?? GlobalVariables . empty ( ) ;
394
-
395
400
const processor = await publicProcessorFactory . create ( prevGlobalVariables , newGlobalVariables ) ;
396
401
const [ , failedTxs ] = await processor . process ( [ tx ] ) ;
397
402
if ( failedTxs . length ) {
0 commit comments