Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
21db667
extract getContractInstance from PXEOracleInterface
mverzilli Dec 16, 2025
077c625
Merge branch 'next' into martin/refactor-pxe-oracle-interface-away
mverzilli Dec 16, 2025
511fb18
extract getFunctionArtifact from PXEOracleInterface
mverzilli Dec 16, 2025
3510ad5
extract getDebugFunctionName from PXEOracleInterface
mverzilli Dec 16, 2025
cec0289
extract getNotes from PXEOracleInterface
mverzilli Dec 17, 2025
cef673b
merge
mverzilli Dec 17, 2025
2ebef27
extract getKeyValidationRequest from PXEOracleInterface
mverzilli Dec 17, 2025
61dec41
extract getCompleteAddress from PXEOracleInterface
mverzilli Dec 17, 2025
d1beaca
calculateDirectionalAppTaggingSecret
mverzilli Dec 17, 2025
13118f9
getSharedSecret
mverzilli Dec 17, 2025
cad9544
getL1ToL2MembershipWitness
mverzilli Dec 17, 2025
37ea1da
fix regression
mverzilli Dec 17, 2025
aabc3a0
getMembershipWitness
mverzilli Dec 17, 2025
8e79091
getLowNullifierMembershipWitness
mverzilli Dec 17, 2025
6b9cd95
fix some regressions
mverzilli Dec 17, 2025
6844a44
fix regression
mverzilli Dec 17, 2025
31b5cea
getBlock
mverzilli Dec 17, 2025
b8f8de3
getNulliferMembershipWitness and getNullifierMembershipWitnessAtLates…
mverzilli Dec 17, 2025
7514360
getPublicDataWitness
mverzilli Dec 17, 2025
19c6fd7
getPublicStorageAt
mverzilli Dec 17, 2025
95918da
fix regressions
mverzilli Dec 18, 2025
245af9a
assertCompatibleOracleVersion
mverzilli Dec 18, 2025
cd0313d
remove getSenders
mverzilli Dec 18, 2025
3bf3ac2
storeCapsule
mverzilli Dec 18, 2025
a022b02
rest of capsule delegates
mverzilli Dec 18, 2025
a94eb8e
getStats
mverzilli Dec 18, 2025
ee24653
almost the rest of the frigging owl
mverzilli Dec 18, 2025
c99cdf6
getNullifierIndex
mverzilli Dec 18, 2025
86db9f5
remove aztec node getter from PXEOracleInterface
mverzilli Dec 18, 2025
ba6c7ed
note and event validation
mverzilli Dec 18, 2025
2b60f30
good bye PXEOracleInterface
mverzilli Dec 18, 2025
46c5d3c
move getContractInstance to utility execution oracle
mverzilli Dec 18, 2025
74fdb15
move getNotes to UtilityExecutionOracle
mverzilli Dec 18, 2025
f4c1c6b
bring some more stuff inside oracles
mverzilli Dec 18, 2025
2a3c9de
getMembershipWitness
mverzilli Dec 18, 2025
8ae2fb2
more
mverzilli Dec 18, 2025
79d4fda
common => utility_execution_oracle 1/
mverzilli Dec 18, 2025
71d42be
common => utility_execution_oracle 2/
mverzilli Dec 18, 2025
7b6e829
common => utility_execution_oracle 3/
mverzilli Dec 18, 2025
9074c82
common => utility_execution_oracle 4/
mverzilli Dec 18, 2025
fb87a5a
common => utility_execution_oracle 5/
mverzilli Dec 18, 2025
014fca7
common => utility_execution_oracle 6/
mverzilli Dec 18, 2025
b2cfbfb
common => utility_execution_oracle 7/
mverzilli Dec 18, 2025
5b7d6cd
common => utility_execution_oracle 8/
mverzilli Dec 18, 2025
78c8966
common => utility_execution_oracle 9/
mverzilli Dec 18, 2025
750862b
common => utility_execution_oracle 10/
mverzilli Dec 19, 2025
57362d2
introduce NoteSynchronizer
mverzilli Dec 19, 2025
66c7836
deliverNote
mverzilli Dec 19, 2025
eec0dd3
rename NoteSynchronizer => NoteService
mverzilli Dec 19, 2025
375364b
EventService
mverzilli Dec 19, 2025
6ac2b9c
refactor validateEnqueuedNotesAndEvents
mverzilli Dec 19, 2025
4a0d9d4
getFunctionArtifactWithDebugMetadata
mverzilli Dec 19, 2025
88e3f33
good bye common
mverzilli Dec 19, 2025
9a6bcbd
simplify readCurrentClassId
mverzilli Dec 19, 2025
455db79
help shaking trees
mverzilli Dec 19, 2025
80708ce
fix weird lint issue
mverzilli Dec 19, 2025
2fe98d5
LogService
mverzilli Dec 19, 2025
0b97781
bulkRetrieveLogs
mverzilli Dec 19, 2025
343adc2
MembershipWitnessService
mverzilli Dec 19, 2025
3e4cca4
more MembershipWitnessService
mverzilli Dec 19, 2025
20b47ff
getBlock
mverzilli Dec 19, 2025
5f9a2e9
getNotes
mverzilli Dec 19, 2025
dbc48fc
TreeMembershipService
mverzilli Dec 19, 2025
9fd681e
PublicStorageService
mverzilli Dec 19, 2025
719255e
port docs
mverzilli Dec 19, 2025
ba5c24b
good bye ExecutionDataProvider
mverzilli Dec 19, 2025
268c6dd
wanted
mverzilli Dec 19, 2025
bb4422b
merge
mverzilli Dec 19, 2025
5b0a17e
reduce barrel imports
mverzilli Dec 19, 2025
e03955a
POC: optimize playground build
mverzilli Dec 22, 2025
bd84fe7
remove report
mverzilli Dec 22, 2025
2567d4c
Revert "remove report"
mverzilli Dec 22, 2025
fb2c21e
Revert "POC: optimize playground build"
mverzilli Dec 22, 2025
328a86b
hunt down barrel imports
mverzilli Dec 22, 2025
c3d269b
went too far in the shaking
mverzilli Dec 22, 2025
ef40d3b
sync from PXE instead of from contracts
mverzilli Dec 22, 2025
91241dd
make it bootstrap
mverzilli Dec 22, 2025
b33eb0f
Merge branch 'next' into martin/f-162-explicit-contract-sync
mverzilli Dec 22, 2025
9cfbcc1
guard against external sync_private_state invocations
mverzilli Dec 23, 2025
864a62c
more guards
mverzilli Dec 23, 2025
ee980bf
decomplect sync in txe
mverzilli Dec 23, 2025
33a4acd
refactor to unify where sync happens
mverzilli Dec 23, 2025
43101f3
wip
mverzilli Dec 23, 2025
b28b007
fix getPrivateEvents
mverzilli Dec 23, 2025
814ea1d
Sync private state before simulating utility in TXE
mverzilli Jan 2, 2026
88979d2
Merge branch 'next' into martin/f-162-explicit-contract-sync
mverzilli Jan 2, 2026
a79eec1
Fix PXE unit test
mverzilli Jan 2, 2026
beb5666
Call syncPrivateState on txePrivateCallNewFlow
mverzilli Jan 2, 2026
dd934b7
Sync notes when entering private state in TXE
mverzilli Jan 2, 2026
4ac3539
fix circuit recorder tests
mverzilli Jan 2, 2026
9ef873e
fix multiple blobs test
mverzilli Jan 2, 2026
d52fee0
first part of PXE db integrity through staged writes
mverzilli Jan 2, 2026
16556e8
adapt providers to use staging phase
mverzilli Jan 2, 2026
560aeaf
integrate with PXE main code
mverzilli Jan 2, 2026
17934e4
final pieces of integration
mverzilli Jan 2, 2026
2f4cc9c
remove context from block synchronizer
mverzilli Jan 2, 2026
c814836
fix lint issues
mverzilli Jan 2, 2026
bdb30a1
fix for IndexedDB serialization
mverzilli Jan 2, 2026
39ce555
tidy up
mverzilli Jan 5, 2026
1861653
fix dep cycle
mverzilli Jan 5, 2026
63a0854
Merge branch 'martin/f-162-explicit-contract-sync' into martin/pxe-db…
mverzilli Jan 5, 2026
3d74dc9
rename
mverzilli Jan 5, 2026
a603749
handle store transaction at commitJob level
mverzilli Jan 5, 2026
b11c1c0
less granularity on commit blast
mverzilli Jan 5, 2026
fde4d08
rename provider => store
mverzilli Jan 5, 2026
52aa605
refactor PrivateEventDataProvider to use in-memory data
mverzilli Jan 5, 2026
e6da298
make e2e changes more minimal
mverzilli Jan 5, 2026
766b859
remove outdated comment
mverzilli Jan 5, 2026
014c614
tweak e2e test
mverzilli Jan 5, 2026
1c6fa2a
Merge branch 'next' into martin/f-162-explicit-contract-sync
mverzilli Jan 5, 2026
397b0d5
Merge branch 'martin/f-162-explicit-contract-sync' into martin/pxe-db…
mverzilli Jan 5, 2026
da7e500
fix RecipientTaggingDataProvider
mverzilli Jan 5, 2026
bfe2d1d
merge
mverzilli Jan 6, 2026
ea2a7f5
more renames
mverzilli Jan 6, 2026
027cfe1
make anchor block store work in memory
mverzilli Jan 6, 2026
7592652
rename commitStaged => commit
mverzilli Jan 6, 2026
89eca7c
make sender tagging store committable
mverzilli Jan 6, 2026
bb241d4
another pass at note store
mverzilli Jan 6, 2026
42c3ac4
polish job_coordinator
mverzilli Jan 6, 2026
ca369a6
little refactors to JobCoordinator
mverzilli Jan 6, 2026
768b61f
make getNotes support staged writes
mverzilli Jan 6, 2026
c70fbe3
remove recover feature
mverzilli Jan 6, 2026
a2c786b
use contexts for capsule store operations
mverzilli Jan 7, 2026
d6688b3
simplify jobcontext objects
mverzilli Jan 7, 2026
0d525ad
do not rely on prefixes for staging operations
mverzilli Jan 7, 2026
166264b
remove JobContext, use simple jobId strings
mverzilli Jan 7, 2026
b9eafe1
make sure note store uses staged writes
mverzilli Jan 7, 2026
a85cf6e
thread jobIds through event store calls
mverzilli Jan 7, 2026
b319c1f
make sure we use jobIds with tagging store ops
mverzilli Jan 7, 2026
fad3030
make jobid mandatory
mverzilli Jan 7, 2026
4bd9334
make job_id mandatory for oracles
mverzilli Jan 7, 2026
d510ef0
remove comment
mverzilli Jan 7, 2026
010f373
polish job coordinator
mverzilli Jan 7, 2026
db043a6
use constant
mverzilli Jan 7, 2026
eaf4139
better comments for anchor_block_store
mverzilli Jan 7, 2026
f7bff61
reduce verbosity
mverzilli Jan 7, 2026
84f3ed6
significantly refactor capsule_store_test
mverzilli Jan 7, 2026
0c799f7
fix potential deadlock on capsule store commit
mverzilli Jan 7, 2026
e21468d
significant refactor of getNotes
mverzilli Jan 7, 2026
f9e17c0
significant refactor of note store
mverzilli Jan 7, 2026
7221d37
leverage promise.all where low-hanging
mverzilli Jan 7, 2026
5d0e5c9
remove spurious comment
mverzilli Jan 7, 2026
05a69ba
remove redundant comments
mverzilli Jan 7, 2026
80fbc72
remove unnecessary comments
mverzilli Jan 7, 2026
fdd3b13
update comments
mverzilli Jan 7, 2026
b9600ab
update comments
mverzilli Jan 7, 2026
ae2fa9d
remove old comment
mverzilli Jan 7, 2026
0e4852b
fix bug in nullifier found during e2e testing
mverzilli Jan 7, 2026
2504963
rollback bad fix
mverzilli Jan 8, 2026
7306b2c
basic logging for debugging
mverzilli Jan 8, 2026
c58f1b7
Merge branch 'next' into martin/pxe-db-integrity
mverzilli Jan 8, 2026
3a9e138
more touches to private_event_store tests
mverzilli Jan 8, 2026
53b3753
fix nullifier commit bugs and sync tagging race
mverzilli Jan 8, 2026
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
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_multiple_blobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('e2e_multiple_blobs', () => {
await aztecNodeAdmin.setConfig({ minTxsPerBlock: TX_COUNT });

const provenTxs = [
// 1 contract deployment tx.
// 1 contract deployment tx (publishes public_dispatch bytecode: ~1,931 fields).
await publishContractClass(wallet, AvmTestContract.artifact),
// 2 private function broadcast txs. We pick [2] because it has large bytecode (~1,807 fields),
// which combined with the contract class publication exceeds FIELDS_PER_BLOB (4,096).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class ContractFunctionSimulator {
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
* the `privateGetSenderForTags` oracle.
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
* @param jobId - The job ID for staged writes.
* @returns The result of the execution.
*/
public async run(
Expand All @@ -131,13 +132,14 @@ export class ContractFunctionSimulator {
selector: FunctionSelector,
msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
anchorBlockHeader: BlockHeader,
senderForTags?: AztecAddress,
scopes?: AztecAddress[],
senderForTags: AztecAddress | undefined,
scopes: AztecAddress[] | undefined,
jobId: string,
): Promise<PrivateExecutionResult> {
const simulatorSetupTimer = new Timer();

await this.contractStore.syncPrivateState(contractAddress, selector, privateSyncCall =>
this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes),
this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes, jobId),
);

await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
Expand Down Expand Up @@ -174,7 +176,7 @@ export class ContractFunctionSimulator {
callContext,
anchorBlockHeader,
async call => {
await this.runUtility(call, [], anchorBlockHeader, scopes);
await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
},
request.authWitnesses,
request.capsules,
Expand All @@ -192,6 +194,7 @@ export class ContractFunctionSimulator {
this.senderAddressBookStore,
this.capsuleStore,
this.privateEventStore,
jobId,
0, // totalPublicArgsCount
startSideEffectCounter,
undefined, // log
Expand Down Expand Up @@ -255,13 +258,15 @@ export class ContractFunctionSimulator {
* @param anchorBlockHeader - The block header to use as base state for this run.
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
* accounts if not specified.
* @param jobId - The job ID for staged writes.
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
*/
public async runUtility(
call: FunctionCall,
authwits: AuthWitness[],
anchorBlockHeader: BlockHeader,
scopes?: AztecAddress[],
scopes: AztecAddress[] | undefined,
jobId: string,
): Promise<Fr[]> {
await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);

Expand All @@ -286,6 +291,7 @@ export class ContractFunctionSimulator {
this.senderAddressBookStore,
this.capsuleStore,
this.privateEventStore,
jobId,
undefined,
scopes,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,16 @@ describe('Oracle Version Check test suite', () => {
// Call the private function with arbitrary message sender and sender for tags
const msgSender = await AztecAddress.random();
const senderForTags = await AztecAddress.random();
await acirSimulator.run(txRequest, contractAddress, selector, msgSender, anchorBlockHeader, senderForTags);
await acirSimulator.run(
txRequest,
contractAddress,
selector,
msgSender,
anchorBlockHeader,
senderForTags,
undefined,
'test',
);

expect(utilityAssertCompatibleOracleVersionSpy).toHaveBeenCalledTimes(1);
}, 30_000);
Expand Down Expand Up @@ -169,7 +178,7 @@ describe('Oracle Version Check test suite', () => {
};

// Call the utility function
await acirSimulator.runUtility(execRequest, [], anchorBlockHeader, []);
await acirSimulator.runUtility(execRequest, [], anchorBlockHeader, [], 'test');

expect(utilityAssertCompatibleOracleVersionSpy).toHaveBeenCalledTimes(1);
}, 30_000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,16 @@ describe('Private Execution test suite', () => {
salt: Fr.random(),
});

return acirSimulator.run(txRequest, contractAddress, selector, msgSender, anchorBlockHeader, senderForTags);
return acirSimulator.run(
txRequest,
contractAddress,
selector,
msgSender,
anchorBlockHeader,
senderForTags,
undefined,
'test',
);
};

const insertLeaves = async (leaves: Fr[], name = 'noteHash') => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
senderAddressBookStore: SenderAddressBookStore,
capsuleStore: CapsuleStore,
privateEventStore: PrivateEventStore,
jobId: string,
private totalPublicCalldataCount: number = 0,
protected sideEffectCounter: number = 0,
log = createLogger('simulator:client_execution_context'),
Expand All @@ -126,6 +127,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
senderAddressBookStore,
capsuleStore,
privateEventStore,
jobId,
log,
scopes,
);
Expand Down Expand Up @@ -281,9 +283,9 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
// This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
// are up to date. We do this here because this store is not synced as part of the global sync because
// that'd be wasteful as most tagging secrets are not used in each tx.
await syncSenderTaggingIndexes(secret, this.contractAddress, this.aztecNode, this.senderTaggingStore);
await syncSenderTaggingIndexes(secret, this.contractAddress, this.aztecNode, this.senderTaggingStore, this.jobId);

const lastUsedIndex = await this.senderTaggingStore.getLastUsedIndex(secret);
const lastUsedIndex = await this.senderTaggingStore.getLastUsedIndex(secret, this.jobId);
// If lastUsedIndex is undefined, we've never used this secret, so start from 0
// Otherwise, the next index to use is one past the last used index
return lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
Expand Down Expand Up @@ -372,7 +374,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP

const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);

const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore, this.jobId);
const dbNotes = await noteService.getNotes(
this.callContext.contractAddress,
owner,
Expand Down Expand Up @@ -586,6 +588,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
this.senderAddressBookStore,
this.capsuleStore,
this.privateEventStore,
this.jobId,
this.totalPublicCalldataCount,
sideEffectCounter,
this.log,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('Utility Execution test suite', () => {
returnTypes: artifact.returnTypes,
};

const result = await acirSimulator.runUtility(execRequest, [], anchorBlockHeader, []);
const result = await acirSimulator.runUtility(execRequest, [], anchorBlockHeader, [], 'test');

expect(result).toEqual([new Fr(9)]);
}, 30_000);
Expand Down Expand Up @@ -222,6 +222,7 @@ describe('Utility Execution test suite', () => {
senderAddressBookStore,
capsuleStore,
privateEventStore,
'test',
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
protected readonly senderAddressBookStore: SenderAddressBookStore,
protected readonly capsuleStore: CapsuleStore,
protected readonly privateEventStore: PrivateEventStore,
protected readonly jobId: string,
protected log = createLogger('simulator:client_view_context'),
protected readonly scopes?: AztecAddress[],
) {}
Expand Down Expand Up @@ -256,7 +257,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
offset: number,
status: NoteStatus,
): Promise<NoteData[]> {
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore, this.jobId);

const dbNotes = await noteService.getNotes(this.contractAddress, owner, storageSlot, status, this.scopes);
return pickNotes<NoteData>(dbNotes, {
Expand Down Expand Up @@ -353,11 +354,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
this.recipientTaggingStore,
this.senderAddressBookStore,
this.addressStore,
this.jobId,
);

await logService.syncTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);

const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore, this.jobId);
await noteService.syncNoteNullifiers(this.contractAddress);
}

Expand All @@ -384,14 +386,26 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
// We read all note and event validation requests and process them all concurrently. This makes the process much
// faster as we don't need to wait for the network round-trip.
const noteValidationRequests = (
await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot)
await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, this.jobId)
).map(NoteValidationRequest.fromFields);

const eventValidationRequests = (
await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot)
await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId)
).map(EventValidationRequest.fromFields);

const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
this.log.verbose('utilityValidateEnqueuedNotesAndEvents', {
contract: contractAddress.toString(),
noteValidationRequestCount: noteValidationRequests.length,
eventValidationRequestCount: eventValidationRequests.length,
notes: noteValidationRequests.map(r => ({
owner: r.owner.toString(),
recipient: r.recipient.toString(),
storageSlot: r.storageSlot.toString(),
noteHash: r.noteHash.toString(),
})),
});

const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore, this.jobId);
const noteDeliveries = noteValidationRequests.map(request =>
noteService.deliverNote(
request.contractAddress,
Expand All @@ -407,7 +421,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
),
);

const eventService = new EventService(this.anchorBlockStore, this.aztecNode, this.privateEventStore);
const eventService = new EventService(this.anchorBlockStore, this.aztecNode, this.privateEventStore, this.jobId);
const eventDeliveries = eventValidationRequests.map(request =>
eventService.deliverEvent(
request.contractAddress,
Expand All @@ -422,8 +436,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
await Promise.all([...noteDeliveries, ...eventDeliveries]);

// Requests are cleared once we're done.
await this.capsuleStore.setCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, []);
await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, []);
await this.capsuleStore.setCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, [], this.jobId);
await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
}

public async utilityBulkRetrieveLogs(
Expand All @@ -439,7 +453,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
// We read all log retrieval requests and process them all concurrently. This makes the process much faster as we
// don't need to wait for the network round-trip.
const logRetrievalRequests = (
await this.capsuleStore.readCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot)
await this.capsuleStore.readCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, this.jobId)
).map(LogRetrievalRequest.fromFields);

const logService = new LogService(
Expand All @@ -450,18 +464,20 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
this.recipientTaggingStore,
this.senderAddressBookStore,
this.addressStore,
this.jobId,
);

const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);

// Requests are cleared once we're done.
await this.capsuleStore.setCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, []);
await this.capsuleStore.setCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, [], this.jobId);

// The responses are stored as Option<LogRetrievalResponse> in a second CapsuleArray.
await this.capsuleStore.setCapsuleArray(
contractAddress,
logRetrievalResponsesArrayBaseSlot,
maybeLogRetrievalResponses.map(LogRetrievalResponse.toSerializedOption),
this.jobId,
);
}

Expand All @@ -470,7 +486,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
}
return this.capsuleStore.storeCapsule(this.contractAddress, slot, capsule);
this.capsuleStore.storeCapsule(this.contractAddress, slot, capsule, this.jobId);
return Promise.resolve();
}

public async utilityLoadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
Expand All @@ -481,7 +498,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
return (
// TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
this.capsules.find(c => c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot))?.data ??
(await this.capsuleStore.loadCapsule(this.contractAddress, slot))
(await this.capsuleStore.loadCapsule(this.contractAddress, slot, this.jobId))
);
}

Expand All @@ -490,7 +507,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
}
return this.capsuleStore.deleteCapsule(this.contractAddress, slot);
this.capsuleStore.deleteCapsule(this.contractAddress, slot, this.jobId);
return Promise.resolve();
}

public utilityCopyCapsule(
Expand All @@ -503,7 +521,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
}
return this.capsuleStore.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries);
return this.capsuleStore.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries, this.jobId);
}

// TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
Expand Down
19 changes: 12 additions & 7 deletions yarn-project/pxe/src/events/event_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('deliverEvent', () => {
let aztecNode: ReturnType<typeof mock<AztecNode>>;

let eventService: EventService;
const TEST_JOB_ID = 'test-job-id';

const setSyncedBlockNumber = (blockNumber: BlockNumber) => {
return anchorBlockStore.setHeader(
Expand Down Expand Up @@ -89,7 +90,7 @@ describe('deliverEvent', () => {
]),
);

eventService = new EventService(anchorBlockStore, aztecNode, privateEventStore);
eventService = new EventService(anchorBlockStore, aztecNode, privateEventStore, TEST_JOB_ID);
});

function runDeliverEvent(
Expand Down Expand Up @@ -138,12 +139,16 @@ describe('deliverEvent', () => {
await runDeliverEvent();

// I should be able to retrieve the private event I just saved using getPrivateEvents
const result = await privateEventStore.getPrivateEvents(eventSelector, {
contractAddress,
fromBlock: blockNumber,
toBlock: blockNumber + 1,
scopes: [recipient],
});
const result = await privateEventStore.getPrivateEvents(
eventSelector,
{
contractAddress,
fromBlock: blockNumber,
toBlock: blockNumber + 1,
scopes: [recipient],
},
TEST_JOB_ID,
);

expect(result.length).toEqual(1);
expect(result[0].packedEvent).toEqual(eventContent);
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/pxe/src/events/event_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class EventService {
private readonly anchorBlockStore: AnchorBlockStore,
private readonly aztecNode: AztecNode,
private readonly privateEventStore: PrivateEventStore,
private readonly jobId: string,
) {}

public async deliverEvent(
Expand Down Expand Up @@ -72,6 +73,7 @@ export class EventService {
l2BlockNumber: nullifierIndex.l2BlockNumber, // Block number in which the event was emitted
l2BlockHash: nullifierIndex.l2BlockHash, // Block hash in which the event was emitted
},
this.jobId,
);
}
}
1 change: 1 addition & 0 deletions yarn-project/pxe/src/job_coordinator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { JobCoordinator, type StagedStore } from './job_coordinator.js';
Loading
Loading