From e53f5480bd785f2927f1f6096a1062269f323393 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 20 Jan 2025 19:23:44 +0000 Subject: [PATCH] chore: nuking redundant oracle --- .../aztec-nr/aztec/src/context/private_context.nr | 10 +++++----- .../aztec-nr/aztec/src/oracle/execution_cache.nr | 14 -------------- yarn-project/simulator/src/acvm/oracle/oracle.ts | 5 ----- .../simulator/src/acvm/oracle/typed_oracle.ts | 4 ---- .../src/client/client_execution_context.ts | 8 -------- yarn-project/txe/src/oracle/txe_oracle.ts | 4 ---- yarn-project/txe/src/txe_service/txe_service.ts | 5 ----- 7 files changed, 5 insertions(+), 45 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 2e4958b73ff..d5b4de035df 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/noir-projects/aztec-nr/aztec/src/oracle/execution_cache.nr b/noir-projects/aztec-nr/aztec/src/oracle/execution_cache.nr index 3da3faca655..f85ca12e9ec 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/execution_cache.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/execution_cache.nr @@ -5,21 +5,10 @@ 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(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(values: [Field; N]) { - let _ = store_array_in_execution_cache_oracle(values); -} - pub unconstrained fn load(hash: Field) -> [Field; N] { load_from_execution_cache_oracle(hash) } @@ -27,8 +16,5 @@ pub unconstrained fn load(hash: Field) -> [Field; N] { #[oracle(storeInExecutionCache)] unconstrained fn store_in_execution_cache_oracle(_values: [Field]) -> Field {} -#[oracle(storeArrayInExecutionCache)] -unconstrained fn store_array_in_execution_cache_oracle(_args: [Field; N]) -> Field {} - #[oracle(loadFromExecutionCache)] unconstrained fn load_from_execution_cache_oracle(_hash: Field) -> [Field; N] {} diff --git a/yarn-project/simulator/src/acvm/oracle/oracle.ts b/yarn-project/simulator/src/acvm/oracle/oracle.ts index 5351def9eb4..3d2501a3a2e 100644 --- a/yarn-project/simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/oracle.ts @@ -19,11 +19,6 @@ export class Oracle { return toACVMField(val); } - async storeArrayInExecutionCache(values: ACVMField[]): Promise { - 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 { const hash = await this.typedOracle.storeInExecutionCache(values.map(fromACVMField)); diff --git a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts index e9fbf9d5dc7..6eac05947f3 100644 --- a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts @@ -56,10 +56,6 @@ export abstract class TypedOracle { return Fr.random(); } - storeArrayInExecutionCache(_args: Fr[]): Promise { - throw new OracleMethodNotAvailableError('storeArrayInExecutionCache'); - } - storeInExecutionCache(_values: Fr[]): Promise { throw new OracleMethodNotAvailableError('storeInExecutionCache'); } diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index 3b816ed4bd9..15bbfa66efd 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -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 { - return Promise.resolve(this.executionCache.store(args)); - } - /** * Store values in the execution cache. * @param values - Values to store. diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index 99293a325c2..b10bae922ad 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -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)); } diff --git a/yarn-project/txe/src/txe_service/txe_service.ts b/yarn-project/txe/src/txe_service/txe_service.ts index e2ce5828222..f3ea96ee1c7 100644 --- a/yarn-project/txe/src/txe_service/txe_service.ts +++ b/yarn-project/txe/src/txe_service/txe_service.ts @@ -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));