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

feat(nargo): Mock oracle resolver #6070

Closed
wants to merge 2 commits into from

Conversation

spalladino
Copy link
Collaborator

Adds a --mock-oracle-resolver option to nargo, that responds to all oracle requests with a single zero-value field. Useful for allowing noop oracle calls, such as debug-log, when running circuits in aztec-packages, without breaking tests run via nargo test.

Adds a `--mock-oracle-resolver` option to nargo, that responds to all oracle requests with a single zero-value field. Useful for allowing noop oracle calls, such as debug-log, when running circuits in aztec-packages, without breaking tests run via `nargo test`.

Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
@spalladino spalladino force-pushed the palla/mock-oracle-resolver branch from ca3fb2f to c34f073 Compare April 29, 2024 12:25
@AztecBot
Copy link
Collaborator

AztecBot commented Apr 29, 2024

Benchmark results

No metrics with a significant change found.

Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 772 772 772
l1_rollup_calldata_gas 6,820 6,832 6,796
l1_rollup_execution_gas 587,301 587,313 587,277
l2_block_processing_time_in_ms 1,581 (+7%) 5,315 (-4%) 10,651 (+2%)
l2_block_building_time_in_ms 19,736 (+1%) 76,860 152,733
l2_block_rollup_simulation_time_in_ms 19,521 (+1%) 76,100 151,235
l2_block_public_tx_process_time_in_ms 8,969 (+1%) 35,197 70,249

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 16,873 (-1%) 31,352
node_database_size_in_bytes 20,738,128 37,412,944
pxe_database_size_in_bytes 29,868 59,425

Circuits stats

Stats on running time and I/O sizes collected for every circuit run across all benchmarks.

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 164 47,763 32,254
private-kernel-inner 190 (+2%) 81,070 32,254
private-kernel-ordering 175 (+1%) 58,008 49,589
base-parity 9.27 128 64.0
root-parity 105 (+1%) 27,064 64.0
base-rollup 11,937 (-2%) 111,202 957
root-rollup 61.0 (+1%) 11,518 821
public-kernel-app-logic 1,657 (+3%) 62,569 26,341
public-kernel-tail 4,499 (+1%) 168,842 3,953
merge-rollup 3,184 2,760 957
public-kernel-teardown 132 (-2%) 62,569 34,895
public-kernel-setup 140 (-1%) 62,569 34,895

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 11.0 (+1%) 17.9 (+1%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.7 31.8 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.639 (+1%) 0.550 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 52.2 80.5 (+1%) 261 504 (+1%) 981 1,948 (+1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.533 0.497 0.475 0.470 (+1%) 0.465 (-1%) 0.466 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 60.8 121 (+1%) 376 (-1%) 745 (+1%) 1,464 (-1%) 2,915 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 105 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.534 0.542 0.511 (-1%) 0.512 (+1%) 0.506 (-1%) 0.508 (-1%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 67.1 (+1%)
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 108
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.589

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 51,687 537,196

Transaction size based on fee payment method

Metric native fee payment method fpc_public fee payment method fpc_private fee payment method
tx_with_fee_size_in_bytes 897 1,145 1,345

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 1,288 (-1%) 936 (+1%) 3,545 (-1%)
Metric 1 public data writes 2 public data writes 3 public data writes 4 public data writes 5 public data writes 8 public data writes
tx_sequencer_processing_time_ms 890 (+1%) 789 (-1%) 1,431 (-1%) 929 (-1%) 2,198 (-1%) 1,114 (-1%)

@Savio-Sou
Copy link
Member

Feel free to document the feature as a part of / following the PR on the Oracles doc page.

A nice-to-have if it's useful for Aztec devs; not strictly necessary (as Oracles is considered an experimental feature that without complete documentation for general Noir devs).

@spalladino
Copy link
Collaborator Author

@Savio-Sou done here

}
}

pub fn none() -> Self {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this to a Default impl?

impl JsonRpcExternalResolver {
fn new(resolver_url: &str) -> Self {
let mut transport_builder =
Builder::new().url(resolver_url).expect("Invalid oracle resolver URL");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be a CliError?

@@ -29,3 +29,5 @@ unconstrained fn get_number_sequence(_size: Field) -> [Field] {}
```

The timeout for when using an external RPC oracle resolver can be set with the `NARGO_FOREIGN_CALL_TIMEOUT` environment variable. This timeout is in units of milliseconds.

Alternatively, a Noir program can be run with a mock oracle set up, which will default to answering every oracle call with a single zero-value `Field`. Note that this will work only for oracle calls that expect a return value of a single field element.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which will default to answering every oracle call -> which answers every oracle call
single field element -> single Field element

perhaps note that the specific argument can be found by running nargo --help?

let encoded_params: Vec<_> = call.inputs.iter().map(build_json_rpc_arg).collect();
let request = self.client.build_request(call.function.as_str(), &encoded_params);
let response = self.client.send_request(request).expect("Failed to send request");
response.result().expect("Failed to parse response")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change these expect's back to the errors with ?/Try's?

the error type will probably need to be added to ExternalResolver

@TomAFrench
Copy link
Member

Spoke on this topic in slack. Conclusion is that:

  • oracle calls don't need to return a dummy field in order to not be removed.
  • nargo will ignore any custom oracle calls which don't return values to the circuit if no oracle resolver is set
    • no need for an extra flag
  • nargo test and nargo execute will both have this behaviour.
  • PR is going to be moved to the main noir repo as it rely on any aztec-packages code.

@spalladino
Copy link
Collaborator Author

Superseded by noir-lang/noir#4959

@spalladino spalladino closed this May 2, 2024
@ludamad ludamad deleted the palla/mock-oracle-resolver branch August 22, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants