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: recording circuit inputs + oracles #12148

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

benesjan
Copy link
Contributor

@benesjan benesjan commented Feb 20, 2025

Fixes #11855

This is an example of a (shortened) recoding:

{
  "circuitName": "AMM",
  "functionName": "add_liquidity",
  "bytecodeMd5Hash": "b46c640ed38f20eac5f61a5e41d8dd1e",
  "timestamp": 1740691464360,
  "inputs": {
    "0": "0x1e89de1f0ad5204263733b7ddf65bec45b8f44714a4da85a46474dad677679ef",
    "1": "0x00f4d59c0ff773427bb0fed5b422557ca4dc5655abe53d31fa9408cb3c5a672f",
    "5": "0x000000000000000000000000000000000000000000000000000000000000000f"
  },
  "oracleCalls": [
    {
      "name": "loadCapsule",
      "inputs": [
        [
          "0x102422483bad6abd385948435667e144ac4c272576e325e7563608876cd446fd"
        ],
        [
          "0x000000000000000000000000000000000000000000000000000000000000004d"
        ],
        [
          "0x0000000000000000000000000000000000000000000000000000000000000001"
        ]
      ],
      "outputs": [
        "0x0000000000000000000000000000000000000000000000000000000000000000",
        [
          "0x0000000000000000000000000000000000000000000000000000000000000000"
        ]
      ]
    },
    {
      "name": "syncNotes",
      "inputs": []
    }
  ]
}

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@benesjan benesjan force-pushed the 02-20-feat_recording_circuit_inputs_oracles branch 4 times, most recently from 7066df6 to 9704d8c Compare February 27, 2025 19:22
@benesjan benesjan marked this pull request as ready for review February 27, 2025 19:23
@benesjan benesjan marked this pull request as draft February 27, 2025 19:54
@benesjan benesjan marked this pull request as ready for review February 27, 2025 19:55
@benesjan benesjan force-pushed the 02-20-feat_recording_circuit_inputs_oracles branch from 8ff3a09 to d4d63fe Compare February 27, 2025 21:52
getClientCircuitArtifactByName(artifact: ClientProtocolArtifact): Promise<NoirCompiledCircuit> {
return Promise.resolve(ClientCircuitArtifacts[artifact]);
getClientCircuitArtifactByName(artifact: ClientProtocolArtifact): Promise<NoirCompiledCircuitWithName> {
return Promise.resolve({ ...ClientCircuitArtifacts[artifact], name: artifact.replace('Artifact', '') });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I introduced NoirCompiledCircuitWithName which as the name implies is just NoirCompiledCircuit type with the name. This was necessary as I needed the name in the circuit recorder.

@@ -98,7 +98,7 @@ function generateVkImportFunction() {
const main = async () => {
const content = `
/* eslint-disable camelcase */
// GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:client-artifacts-helper\`
// GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` in the noir-protocol-circuits-types package to update.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yarn generate:client-artifacts-helper no longer exists so I updated it.

@@ -54,12 +54,12 @@ function generateCircuitArtifactImportFunction() {
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
return `case '${artifactName}': {
const { default: compiledCircuit } = await import(\"../artifacts/${artifactName}.json\");
return compiledCircuit as NoirCompiledCircuit;
return { ...(compiledCircuit as NoirCompiledCircuit), name: '${artifactName}' };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code generates client_artifacts_helper.ts which looks like this after the changes:
image

@@ -75,7 +75,7 @@ export interface NoirCompiledContract {
}

/**
* The compilation result of an Aztec.nr contract.
* The compilation result of a protocol (non-contract) circuit.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was incorrect as it doesn't seem to ever be used with contracts. There is a lot of tech debt around.

dependencies:
"@noir-lang/acvm_js": "npm:1.0.0-beta.3"
"@noir-lang/noirc_abi": "npm:1.0.0-beta.3"
"@noir-lang/types": "npm:1.0.0-beta.3"
checksum: 10/4e756f69e5c8fcfe4f1243f026e37d68584852ad18887414ccc74de928ff2c019ea785ae06e48c523744676ccff2993b4d3ed8b971d6478e431af38574b4e924
checksum: 10/e544b07c369f63eb6513f11b3e4f203a2c4fd8cfca4965cecd576affc06ceee8c4ec817d220dcd24f8e31c896fc86eb3343f2a49744082c81808336567ac4882
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why this change got triggered here - I just bootstrapped and it happened

@benesjan benesjan marked this pull request as draft February 28, 2025 12:51
@benesjan benesjan force-pushed the 02-20-feat_recording_circuit_inputs_oracles branch 3 times, most recently from cd417dc to e328450 Compare February 28, 2025 14:26
@benesjan benesjan added the ci-full Run all master checks. label Feb 28, 2025
@benesjan benesjan marked this pull request as ready for review February 28, 2025 14:27
*
* @param aztecNode - The AztecNode instance to be used by the server.
* @param config - The PXE Service Config to use
* @param options - (Optional) Optional information for creating an PXEService.
* @param proofCreator - An optional proof creator to use in place of any other configuration
* @returns A Promise that resolves to the started PXEService instance.
*/
export async function createPXEService(
export function createPXEService(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split this function into 2 so that I can pass in the SimulationProviderRecorderWrapper into the PXE in tests.

*/
export async function setupPXEService(
aztecNode: AztecNode,
opts: Partial<PXEServiceConfig> = {},
logger = getLogger(),
useLogSuffix = false,
proofCreator?: BBNativePrivateKernelProver,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This param was never used so I nuked it.

aztecNode: AztecNode,
config: PXEServiceConfig,
useLogSuffix: string | boolean | undefined = undefined,
proofCreator?: PrivateKernelProver,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This param was never used so I nuked it.

@benesjan benesjan force-pushed the 02-20-feat_recording_circuit_inputs_oracles branch from 34b9dbf to b236395 Compare February 28, 2025 15:45
@benesjan benesjan force-pushed the 02-20-feat_recording_circuit_inputs_oracles branch from b236395 to 1457278 Compare February 28, 2025 18:39
@benesjan benesjan requested a review from nventuro February 28, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-full Run all master checks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Record circuit inputs and oracle calls
1 participant