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: Do not import big jsons #6972

Closed
wants to merge 4 commits into from
Closed
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: 8 additions & 2 deletions yarn-project/accounts/src/ecdsa/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
import { fileURLToPath } from '@aztec/foundation/url';

import EcdsaAccountContractJson from '../artifacts/EcdsaAccount.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

export const EcdsaAccountContractArtifact = loadContractArtifact(EcdsaAccountContractJson as NoirCompiledContract);
const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/EcdsaAccount.json');

export const EcdsaAccountContractArtifact = loadContractArtifact(
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
10 changes: 8 additions & 2 deletions yarn-project/accounts/src/schnorr/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
import { fileURLToPath } from '@aztec/foundation/url';

import SchnorrAccountContractJson from '../artifacts/SchnorrAccount.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract);
const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/SchnorrAccount.json');

export const SchnorrAccountContractArtifact = loadContractArtifact(
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
8 changes: 6 additions & 2 deletions yarn-project/accounts/src/single_key/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
import { fileURLToPath } from '@aztec/foundation/url';

import SchnorrSingleKeyAccountContractJson from '../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/SchnorrSingleKeyAccount.json');

export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact(
SchnorrSingleKeyAccountContractJson as NoirCompiledContract,
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/src/aztec-node/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type ArchiverConfig, getConfigEnvVars as getArchiverVars } from '@aztec/archiver';
import { fileURLToPath } from '@aztec/foundation/url';
import { type P2PConfig, getP2PConfigEnvVars } from '@aztec/p2p';
import { type ProverClientConfig, getProverEnvVars } from '@aztec/prover-client';
import { type SequencerClientConfig, getConfigEnvVars as getSequencerVars } from '@aztec/sequencer-client';
import { getConfigEnvVars as getWorldStateVars } from '@aztec/world-state';

import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

/**
* The configuration the aztec node.
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/builder/src/contract-interface-gen/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ function generateArtifactGetter(name: string) {
*/
function generateAbiStatement(name: string, artifactImportPath: string) {
const stmts = [
`import ${name}ContractArtifactJson from '${artifactImportPath}' assert { type: 'json' };`,
`export const ${name}ContractArtifact = loadContractArtifact(${name}ContractArtifactJson as NoirCompiledContract);`,
`const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '${artifactImportPath}')`,
`export const ${name}ContractArtifact = loadContractArtifact(JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract);`,
];
return stmts.join('\n');
}
Expand Down Expand Up @@ -259,6 +259,9 @@ export function generateTypescriptContractInterface(input: ContractArtifact, art
/* Autogenerated file, do not edit! */

/* eslint-disable */
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

import {
AztecAddress,
AztecAddressLike,
Expand All @@ -275,6 +278,7 @@ import {
EthAddress,
EthAddressLike,
FieldLike,
fileURLToPath,
Fr,
FunctionSelectorLike,
loadContractArtifact,
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/circuits.js/src/scripts/constants.in.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fileURLToPath } from '@aztec/foundation/url';

import * as fs from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

const NOIR_CONSTANTS_FILE = '../../../../noir-projects/noir-protocol-circuits/crates/types/src/constants.nr';
const TS_CONSTANTS_FILE = '../constants.gen.ts';
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/tests/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type ContractArtifact } from '@aztec/foundation/abi';
import { fileURLToPath } from '@aztec/foundation/url';
import { loadContractArtifact } from '@aztec/types/abi';
import { type NoirCompiledContract } from '@aztec/types/noir';

import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

// Copied from the build output for the contract `Benchmarking` in noir-contracts
export function getBenchmarkContractArtifact(): ContractArtifact {
Expand Down
78 changes: 44 additions & 34 deletions yarn-project/noir-protocol-circuits-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,17 @@ import {
type RootRollupPublicInputs,
} from '@aztec/circuits.js';
import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log';
import { fileURLToPath } from '@aztec/foundation/url';
import { type NoirCompiledCircuit } from '@aztec/types/noir';

import { type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js';
import { type CompiledCircuit, type InputMap, Noir } from '@noir-lang/noir_js';
import { type Abi, abiDecode, abiEncode } from '@noir-lang/noirc_abi';
import { type WitnessMap } from '@noir-lang/types';
import { strict as assert } from 'assert';
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

import EmptyNestedJson from './target/empty_nested.json' assert { type: 'json' };
import EmptyNestedSimulatedJson from './target/empty_nested_simulated.json' assert { type: 'json' };
import BaseParityJson from './target/parity_base.json' assert { type: 'json' };
import RootParityJson from './target/parity_root.json' assert { type: 'json' };
import PrivateKernelEmptyJson from './target/private_kernel_empty.json' assert { type: 'json' };
import PrivateKernelEmptySimulatedJson from './target/private_kernel_empty_simulated.json' assert { type: 'json' };
import PrivateKernelInitJson from './target/private_kernel_init.json' assert { type: 'json' };
import PrivateKernelInitSimulatedJson from './target/private_kernel_init_simulated.json' assert { type: 'json' };
import PrivateKernelInnerJson from './target/private_kernel_inner.json' assert { type: 'json' };
import PrivateKernelInnerSimulatedJson from './target/private_kernel_inner_simulated.json' assert { type: 'json' };
import PrivateKernelResetJson from './target/private_kernel_reset.json' assert { type: 'json' };
import PrivateKernelResetBigJson from './target/private_kernel_reset_big.json' assert { type: 'json' };
import PrivateKernelResetMediumJson from './target/private_kernel_reset_medium.json' assert { type: 'json' };
import PrivateKernelResetSimulatedJson from './target/private_kernel_reset_simulated.json' assert { type: 'json' };
import PrivateKernelResetBigSimulatedJson from './target/private_kernel_reset_simulated_big.json' assert { type: 'json' };
import PrivateKernelResetMediumSimulatedJson from './target/private_kernel_reset_simulated_medium.json' assert { type: 'json' };
import PrivateKernelResetSmallSimulatedJson from './target/private_kernel_reset_simulated_small.json' assert { type: 'json' };
import PrivateKernelResetSmallJson from './target/private_kernel_reset_small.json' assert { type: 'json' };
import PrivateKernelTailJson from './target/private_kernel_tail.json' assert { type: 'json' };
import PrivateKernelTailSimulatedJson from './target/private_kernel_tail_simulated.json' assert { type: 'json' };
import PrivateKernelTailToPublicJson from './target/private_kernel_tail_to_public.json' assert { type: 'json' };
import PrivateKernelTailToPublicSimulatedJson from './target/private_kernel_tail_to_public_simulated.json' assert { type: 'json' };
import PublicKernelAppLogicJson from './target/public_kernel_app_logic.json' assert { type: 'json' };
import PublicKernelAppLogicSimulatedJson from './target/public_kernel_app_logic_simulated.json' assert { type: 'json' };
import PublicKernelSetupJson from './target/public_kernel_setup.json' assert { type: 'json' };
import PublicKernelSetupSimulatedJson from './target/public_kernel_setup_simulated.json' assert { type: 'json' };
import PublicKernelTailJson from './target/public_kernel_tail.json' assert { type: 'json' };
import PublicKernelTailSimulatedJson from './target/public_kernel_tail_simulated.json' assert { type: 'json' };
import PublicKernelTeardownJson from './target/public_kernel_teardown.json' assert { type: 'json' };
import PublicKernelTeardownSimulatedJson from './target/public_kernel_teardown_simulated.json' assert { type: 'json' };
import BaseRollupJson from './target/rollup_base.json' assert { type: 'json' };
import BaseRollupSimulatedJson from './target/rollup_base_simulated.json' assert { type: 'json' };
import MergeRollupJson from './target/rollup_merge.json' assert { type: 'json' };
import RootRollupJson from './target/rollup_root.json' assert { type: 'json' };
import {
mapBaseOrMergeRollupPublicInputsFromNoir,
mapBaseParityInputsToNoir,
Expand Down Expand Up @@ -106,6 +75,47 @@ import {
PrivateKernelTail as executePrivateKernelTailWithACVM,
} from './types/index.js';

const __dirname = dirname(fileURLToPath(import.meta.url));
function loadCircuit(name: string) {
const path = resolve(__dirname, `./target/${name}.json`);
return JSON.parse(readFileSync(path).toString());
}

const EmptyNestedJson = loadCircuit('empty_nested');
const EmptyNestedSimulatedJson = loadCircuit('empty_nested_simulated');
const BaseParityJson = loadCircuit('parity_base');
const RootParityJson = loadCircuit('parity_root');
const PrivateKernelEmptyJson = loadCircuit('private_kernel_empty');
const PrivateKernelEmptySimulatedJson = loadCircuit('private_kernel_empty_simulated');
const PrivateKernelInitJson = loadCircuit('private_kernel_init');
const PrivateKernelInitSimulatedJson = loadCircuit('private_kernel_init_simulated');
const PrivateKernelInnerJson = loadCircuit('private_kernel_inner');
const PrivateKernelInnerSimulatedJson = loadCircuit('private_kernel_inner_simulated');
const PrivateKernelResetJson = loadCircuit('private_kernel_reset');
const PrivateKernelResetBigJson = loadCircuit('private_kernel_reset_big');
const PrivateKernelResetMediumJson = loadCircuit('private_kernel_reset_medium');
const PrivateKernelResetSimulatedJson = loadCircuit('private_kernel_reset_simulated');
const PrivateKernelResetBigSimulatedJson = loadCircuit('private_kernel_reset_simulated_big');
const PrivateKernelResetMediumSimulatedJson = loadCircuit('private_kernel_reset_simulated_medium');
const PrivateKernelResetSmallSimulatedJson = loadCircuit('private_kernel_reset_simulated_small');
const PrivateKernelResetSmallJson = loadCircuit('private_kernel_reset_small');
const PrivateKernelTailJson = loadCircuit('private_kernel_tail');
const PrivateKernelTailSimulatedJson = loadCircuit('private_kernel_tail_simulated');
const PrivateKernelTailToPublicJson = loadCircuit('private_kernel_tail_to_public');
const PrivateKernelTailToPublicSimulatedJson = loadCircuit('private_kernel_tail_to_public_simulated');
const PublicKernelAppLogicJson = loadCircuit('public_kernel_app_logic');
const PublicKernelAppLogicSimulatedJson = loadCircuit('public_kernel_app_logic_simulated');
const PublicKernelSetupJson = loadCircuit('public_kernel_setup');
const PublicKernelSetupSimulatedJson = loadCircuit('public_kernel_setup_simulated');
const PublicKernelTailJson = loadCircuit('public_kernel_tail');
const PublicKernelTailSimulatedJson = loadCircuit('public_kernel_tail_simulated');
const PublicKernelTeardownJson = loadCircuit('public_kernel_teardown');
const PublicKernelTeardownSimulatedJson = loadCircuit('public_kernel_teardown_simulated');
const BaseRollupJson = loadCircuit('rollup_base');
const BaseRollupSimulatedJson = loadCircuit('rollup_base_simulated');
const MergeRollupJson = loadCircuit('rollup_merge');
const RootRollupJson = loadCircuit('rollup_root');

// TODO(Tom): This should be exported from noirc_abi
/**
* The decoded inputs from the circuit.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { fileURLToPath } from '@aztec/foundation/url';
import { loadContractArtifact } from '@aztec/types/abi';
import { type NoirCompiledContract } from '@aztec/types/noir';

import ContractClassRegistererJson from '../artifacts/ContractClassRegisterer.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/ContractClassRegisterer.json');

export const ContractClassRegistererArtifact = loadContractArtifact(
ContractClassRegistererJson as NoirCompiledContract,
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
10 changes: 8 additions & 2 deletions yarn-project/protocol-contracts/src/gas-token/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { fileURLToPath } from '@aztec/foundation/url';
import { loadContractArtifact } from '@aztec/types/abi';
import { type NoirCompiledContract } from '@aztec/types/noir';

import GasTokenJson from '../artifacts/GasToken.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

export const GasTokenArtifact = loadContractArtifact(GasTokenJson as NoirCompiledContract);
const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/GasToken.json');

export const GasTokenArtifact = loadContractArtifact(
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { fileURLToPath } from '@aztec/foundation/url';
import { loadContractArtifact } from '@aztec/types/abi';
import { type NoirCompiledContract } from '@aztec/types/noir';

import ContractInstanceDeployerJson from '../artifacts/ContractInstanceDeployer.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/ContractInstanceDeployer.json');

export const ContractInstanceDeployerArtifact = loadContractArtifact(
ContractInstanceDeployerJson as NoirCompiledContract,
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
10 changes: 8 additions & 2 deletions yarn-project/protocol-contracts/src/key-registry/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { fileURLToPath } from '@aztec/foundation/url';
import { loadContractArtifact } from '@aztec/types/abi';
import { type NoirCompiledContract } from '@aztec/types/noir';

import KeyRegistryJson from '../artifacts/KeyRegistry.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

export const KeyRegistryArtifact = loadContractArtifact(KeyRegistryJson as NoirCompiledContract);
const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/KeyRegistry.json');

export const KeyRegistryArtifact = loadContractArtifact(
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { fileURLToPath } from '@aztec/foundation/url';
import { loadContractArtifact } from '@aztec/types/abi';
import { type NoirCompiledContract } from '@aztec/types/noir';

import MultiCallEntrypoint from '../artifacts/MultiCallEntrypoint.json' assert { type: 'json' };
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';

export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypoint as NoirCompiledContract);
const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/MultiCallEntrypoint.json');

export const MultiCallEntrypointArtifact = loadContractArtifact(
JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract,
);
2 changes: 1 addition & 1 deletion yarn-project/pxe/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
import { fileURLToPath } from '@aztec/foundation/url';

import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

/**
* Temporary configuration until WASM can be used instead of native
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/types/src/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type ContractArtifact } from '@aztec/foundation/abi';

import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { fileURLToPath } from '@aztec/foundation/url';

import { loadContractArtifact } from '../abi/contract_artifact.js';
import { type NoirCompiledContract } from '../noir/index.js';
Expand Down
Loading