Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: nuking redundant oracle #11368

Merged
merged 1 commit into from
Jan 20, 2025
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
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
Loading