Skip to content

Commit

Permalink
chore: nuking redundant oracle (#11368)
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored Jan 20, 2025
1 parent 38fbd5c commit b32d9a1
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 45 deletions.
10 changes: 5 additions & 5 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl PrivateContext {
args: [Field; ARGS_COUNT],
) -> ReturnsHash {
let args_hash = hash_args_array(args);
execution_cache::store_array(args);
execution_cache::store(args);
self.call_private_function_with_args_hash(
contract_address,
function_selector,
Expand All @@ -356,7 +356,7 @@ impl PrivateContext {
args: [Field; ARGS_COUNT],
) -> ReturnsHash {
let args_hash = hash_args_array(args);
execution_cache::store_array(args);
execution_cache::store(args);
self.call_private_function_with_args_hash(
contract_address,
function_selector,
Expand Down Expand Up @@ -443,7 +443,7 @@ impl PrivateContext {
args: [Field; ARGS_COUNT],
) {
let args_hash = hash_args_array(args);
execution_cache::store_array(args);
execution_cache::store(args);
self.call_public_function_with_args_hash(
contract_address,
function_selector,
Expand All @@ -459,7 +459,7 @@ impl PrivateContext {
args: [Field; ARGS_COUNT],
) {
let args_hash = hash_args_array(args);
execution_cache::store_array(args);
execution_cache::store(args);
self.call_public_function_with_args_hash(
contract_address,
function_selector,
Expand Down Expand Up @@ -531,7 +531,7 @@ impl PrivateContext {
args: [Field; ARGS_COUNT],
) {
let args_hash = hash_args_array(args);
execution_cache::store_array(args);
execution_cache::store(args);
self.set_public_teardown_function_with_args_hash(
contract_address,
function_selector,
Expand Down
14 changes: 0 additions & 14 deletions noir-projects/aztec-nr/aztec/src/oracle/execution_cache.nr
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,16 @@ pub fn store(values: [Field]) {
unsafe { store_in_execution_cache_oracle_wrapper(values) };
}

/// Stores values represented as array in execution cache to be later obtained by its hash.
pub fn store_array<let N: u32>(values: [Field; N]) {
/// Safety: This oracle call returns nothing: we only call it for its side effects. It is therefore always safe
/// to call. When loading the values, however, the caller must check that the values are indeed the preimage.
unsafe { store_array_in_execution_cache_oracle_wrapper(values) };
}

pub unconstrained fn store_in_execution_cache_oracle_wrapper(values: [Field]) {
let _ = store_in_execution_cache_oracle(values);
}

pub unconstrained fn store_array_in_execution_cache_oracle_wrapper<let N: u32>(values: [Field; N]) {
let _ = store_array_in_execution_cache_oracle(values);
}

pub unconstrained fn load<let N: u32>(hash: Field) -> [Field; N] {
load_from_execution_cache_oracle(hash)
}

#[oracle(storeInExecutionCache)]
unconstrained fn store_in_execution_cache_oracle(_values: [Field]) -> Field {}

#[oracle(storeArrayInExecutionCache)]
unconstrained fn store_array_in_execution_cache_oracle<let N: u32>(_args: [Field; N]) -> Field {}

#[oracle(loadFromExecutionCache)]
unconstrained fn load_from_execution_cache_oracle<let N: u32>(_hash: Field) -> [Field; N] {}
5 changes: 0 additions & 5 deletions yarn-project/simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ export class Oracle {
return toACVMField(val);
}

async storeArrayInExecutionCache(values: ACVMField[]): Promise<ACVMField> {
const hash = await this.typedOracle.storeArrayInExecutionCache(values.map(fromACVMField));
return toACVMField(hash);
}

// Since the argument is a slice, noir automatically adds a length field to oracle call.
async storeInExecutionCache(_length: ACVMField[], values: ACVMField[]): Promise<ACVMField> {
const hash = await this.typedOracle.storeInExecutionCache(values.map(fromACVMField));
Expand Down
4 changes: 0 additions & 4 deletions yarn-project/simulator/src/acvm/oracle/typed_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export abstract class TypedOracle {
return Fr.random();
}

storeArrayInExecutionCache(_args: Fr[]): Promise<Fr> {
throw new OracleMethodNotAvailableError('storeArrayInExecutionCache');
}

storeInExecutionCache(_values: Fr[]): Promise<Fr> {
throw new OracleMethodNotAvailableError('storeInExecutionCache');
}
Expand Down
8 changes: 0 additions & 8 deletions yarn-project/simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,6 @@ export class ClientExecutionContext extends ViewDataOracle {
return this.publicTeardownFunctionCall;
}

/**
* Store values in the execution cache.
* @param values - Values to store.
*/
public override storeArrayInExecutionCache(args: Fr[]): Promise<Fr> {
return Promise.resolve(this.executionCache.store(args));
}

/**
* Store values in the execution cache.
* @param values - Values to store.
Expand Down
4 changes: 0 additions & 4 deletions yarn-project/txe/src/oracle/txe_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,6 @@ export class TXE implements TypedOracle {
return Fr.random();
}

storeArrayInExecutionCache(values: Fr[]) {
return Promise.resolve(this.executionCache.store(values));
}

storeInExecutionCache(values: Fr[]) {
return Promise.resolve(this.executionCache.store(values));
}
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/txe/src/txe_service/txe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,6 @@ export class TXEService {
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
}

async storeArrayInExecutionCache(args: ForeignCallArray) {
const hash = await this.typedOracle.storeArrayInExecutionCache(fromArray(args));
return toForeignCallResult([toSingle(hash)]);
}

// Since the argument is a slice, noir automatically adds a length field to oracle call.
async storeInExecutionCache(_length: ForeignCallSingle, values: ForeignCallArray) {
const returnsHash = await this.typedOracle.storeInExecutionCache(fromArray(values));
Expand Down

0 comments on commit b32d9a1

Please sign in to comment.