diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index cdd706c457a..3b1740e07fa 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -22,7 +22,6 @@ import { CallContext, type ContractInstance, type ContractInstanceWithAddress, - DEPLOYER_CONTRACT_ADDRESS, Gas, GasFees, GlobalVariables, @@ -888,7 +887,6 @@ export class TXE implements TypedOracle { const executionRequest = new PublicExecutionRequest(callContext, args); const db = this.baseFork; - const worldStateDb = new TXEWorldStateDB(db, new TXEPublicContractDataSource(this), this); const globalVariables = GlobalVariables.empty(); globalVariables.chainId = new Fr(await this.node.getChainId()); @@ -896,28 +894,9 @@ export class TXE implements TypedOracle { globalVariables.blockNumber = new Fr(this.blockNumber); globalVariables.gasFees = new GasFees(1, 1); - const tempFork = await this.nativeWorldStateService.fork(); - // Apply current public data writes - await tempFork.sequentialInsert( - MerkleTreeId.PUBLIC_DATA_TREE, - this.publicDataWrites.map(p => p.toBuffer()), - ); - - // If the contract instance exists in the TXE's world state, make sure its nullifier is present in the tree - // so its nullifier check passes. - if ((await worldStateDb.getContractInstance(callContext.contractAddress)) !== undefined) { - const contractAddressNullifier = await siloNullifier( - AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), - callContext.contractAddress.toField(), - ); - if ((await worldStateDb.getNullifierIndex(contractAddressNullifier)) === undefined) { - await tempFork.batchInsert(MerkleTreeId.NULLIFIER_TREE, [contractAddressNullifier.toBuffer()], 0); - } - } - const simulator = new PublicTxSimulator( - tempFork, - new TXEWorldStateDB(tempFork, new TXEPublicContractDataSource(this), this), + db, + new TXEWorldStateDB(db, new TXEPublicContractDataSource(this), this), globalVariables, ); @@ -954,7 +933,6 @@ export class TXE implements TypedOracle { ), ); - await tempFork.close(); return Promise.resolve(result); } diff --git a/yarn-project/txe/src/txe_service/txe_service.ts b/yarn-project/txe/src/txe_service/txe_service.ts index 245bb7e7b5d..2dfe839d3e7 100644 --- a/yarn-project/txe/src/txe_service/txe_service.ts +++ b/yarn-project/txe/src/txe_service/txe_service.ts @@ -1,6 +1,7 @@ import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr'; import { MerkleTreeId, SimulationError } from '@aztec/circuit-types'; import { + DEPLOYER_CONTRACT_ADDRESS, Fr, FunctionSelector, PublicDataWrite, @@ -8,7 +9,7 @@ import { computePartialAddress, getContractInstanceFromDeployParams, } from '@aztec/circuits.js'; -import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/hash'; +import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/circuits.js/hash'; import { type ContractArtifact, NoteSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { type Logger } from '@aztec/foundation/log'; @@ -115,6 +116,11 @@ export class TXEService { deployer: AztecAddress.ZERO, }); + // Emit deployment nullifier + (this.typedOracle as TXE).addSiloedNullifiersFromPublic([ + await siloNullifier(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), instance.address.toField()), + ]); + this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`); await (this.typedOracle as TXE).addContractInstance(instance); await (this.typedOracle as TXE).addContractArtifact(artifact);