Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions yarn-project/txe/src/oracle/txe_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
CallContext,
type ContractInstance,
type ContractInstanceWithAddress,
DEPLOYER_CONTRACT_ADDRESS,
Gas,
GasFees,
GlobalVariables,
Expand Down Expand Up @@ -888,36 +887,16 @@ 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());
globalVariables.version = new Fr(await this.node.getVersion());
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,
);

Expand Down Expand Up @@ -954,7 +933,6 @@ export class TXE implements TypedOracle {
),
);

await tempFork.close();
return Promise.resolve(result);
}

Expand Down
8 changes: 7 additions & 1 deletion yarn-project/txe/src/txe_service/txe_service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
import { MerkleTreeId, SimulationError } from '@aztec/circuit-types';
import {
DEPLOYER_CONTRACT_ADDRESS,
Fr,
FunctionSelector,
PublicDataWrite,
PublicKeys,
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';
Expand Down Expand Up @@ -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);
Expand Down