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
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
this.recipientTaggingStore,
this.senderAddressBookStore,
this.addressStore,
this.jobId,
);

await logService.syncTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
Expand Down Expand Up @@ -385,11 +386,11 @@ 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);
Expand Down Expand Up @@ -424,8 +425,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 @@ -441,7 +442,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 @@ -452,18 +453,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 @@ -472,7 +475,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 @@ -483,7 +487,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 @@ -492,7 +496,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 @@ -505,7 +510,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
1 change: 1 addition & 0 deletions yarn-project/pxe/src/logs/log_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('LogService', () => {
recipientTaggingStore,
senderAddressBookStore,
addressStore,
'test',
);

aztecNode.getPrivateLogsByTags.mockReset();
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/pxe/src/logs/log_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class LogService {
private readonly recipientTaggingStore: RecipientTaggingStore,
private readonly senderAddressBookStore: SenderAddressBookStore,
private readonly addressStore: AddressStore,
private readonly jobId: string,
) {}

public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
Expand Down Expand Up @@ -186,7 +187,7 @@ export class LogService {
});

// TODO: This looks like it could belong more at the oracle interface level
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
}

async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
Expand Down
1 change: 1 addition & 0 deletions yarn-project/pxe/src/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class PXE {
);

const jobCoordinator = new JobCoordinator(store);
jobCoordinator.registerStores([capsuleStore]);

const debugUtils = new PXEDebugUtils(contractStore, noteStore);

Expand Down
Loading
Loading