Skip to content
Closed
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
12 changes: 10 additions & 2 deletions yarn-project/pxe/src/storage/capsule_store/capsule_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ import type { CapsuleStore } from './capsule_store.js';
export class CapsuleService {
constructor(
private readonly capsuleStore: CapsuleStore,
private readonly allowedScopes: AztecAddress[],
private readonly allowedScopes: AztecAddress[] | 'unrestricted',
) {}

/** Creates a CapsuleService that allows all scopes without restriction. Intended for test environments (TXE). */
static unrestricted(capsuleStore: CapsuleStore): CapsuleService {
return new CapsuleService(capsuleStore, 'unrestricted');
}

setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress) {
assertAllowedScope(scope, this.allowedScopes);
this.capsuleStore.setCapsule(contractAddress, slot, capsule, jobId, scope);
Expand Down Expand Up @@ -78,7 +83,10 @@ export class CapsuleService {
}
}

function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[]) {
function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[] | 'unrestricted') {
if (allowedScopes === 'unrestricted') {
return;
}
if (scope.equals(AztecAddress.ZERO)) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/txe/src/oracle/txe_oracle_top_level_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
senderTaggingStore: this.senderTaggingStore,
recipientTaggingStore: this.recipientTaggingStore,
senderAddressBookStore: this.senderAddressBookStore,
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
capsuleService: CapsuleService.unrestricted(this.capsuleStore),
privateEventStore: this.privateEventStore,
contractSyncService: this.stateMachine.contractSyncService,
jobId,
Expand Down Expand Up @@ -748,7 +748,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
aztecNode: this.stateMachine.node,
recipientTaggingStore: this.recipientTaggingStore,
senderAddressBookStore: this.senderAddressBookStore,
capsuleService: new CapsuleService(this.capsuleStore, scopes),
capsuleService: CapsuleService.unrestricted(this.capsuleStore),
privateEventStore: this.privateEventStore,
messageContextService: this.stateMachine.messageContextService,
contractSyncService: this.contractSyncService,
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/txe/src/txe_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export class TXESession implements TXESessionStateHandler {
senderTaggingStore: this.senderTaggingStore,
recipientTaggingStore: this.recipientTaggingStore,
senderAddressBookStore: this.senderAddressBookStore,
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
capsuleService: CapsuleService.unrestricted(this.capsuleStore),
privateEventStore: this.privateEventStore,
contractSyncService: this.stateMachine.contractSyncService,
jobId: this.currentJobId,
Expand Down Expand Up @@ -444,7 +444,7 @@ export class TXESession implements TXESessionStateHandler {
aztecNode: this.stateMachine.node,
recipientTaggingStore: this.recipientTaggingStore,
senderAddressBookStore: this.senderAddressBookStore,
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
capsuleService: CapsuleService.unrestricted(this.capsuleStore),
privateEventStore: this.privateEventStore,
messageContextService: this.stateMachine.messageContextService,
contractSyncService: this.contractSyncService,
Expand Down Expand Up @@ -537,7 +537,7 @@ export class TXESession implements TXESessionStateHandler {
aztecNode: this.stateMachine.node,
recipientTaggingStore: this.recipientTaggingStore,
senderAddressBookStore: this.senderAddressBookStore,
capsuleService: new CapsuleService(this.capsuleStore, scopes),
capsuleService: CapsuleService.unrestricted(this.capsuleStore),
privateEventStore: this.privateEventStore,
messageContextService: this.stateMachine.messageContextService,
contractSyncService: this.contractSyncService,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@ __metadata:
"@aztec/noir-noirc_abi": "npm:1.0.0-beta.19"
"@aztec/noir-types": "npm:1.0.0-beta.19"
pako: "npm:^2.1.0"
checksum: 10/8e144df7c33c34852a2e26dfff1efeb6d28b7d55e121f4047f53beee09fc73d5b3ba610e1abd108eb55911e084f346e0d101beb8830d916a79883bc6a78d0b6e
languageName: node
linkType: hard

Expand Down
Loading