diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c4c5462ae9..2692fde7e2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,7 +98,11 @@ jobs: # prepare images locally, tagged by commit hash - name: "Build E2E Image" timeout-minutes: 40 - run: earthly-ci ./yarn-project+export-e2e-test-images + run: | + earthly-ci \ + --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ + --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ + ./yarn-project+export-e2e-test-images # We base our e2e list used in e2e-x86 off the targets in ./yarn-project/end-to-end # (Note ARM uses just 2 tests as a smoketest) - name: Create list of non-bench end-to-end jobs @@ -377,7 +381,11 @@ jobs: - name: "Format noir-projects" working-directory: ./noir-projects/ timeout-minutes: 40 - run: earthly-ci --no-output ./+format + run: | + earthly-ci --no-output \ + --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ + --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ + ./+format noir-test: needs: [setup, changes] @@ -430,7 +438,11 @@ jobs: concurrency_key: noir-projects-x86 - name: "Noir Projects" timeout-minutes: 40 - run: earthly-ci --no-output ./noir-projects/+test + run: | + earthly-ci --no-output \ + --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ + --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ + ./noir-projects/+test avm-format: needs: [setup, changes] @@ -515,7 +527,14 @@ jobs: - name: "Docs Preview" if: github.event.number timeout-minutes: 40 - run: earthly-ci --no-output ./docs/+deploy-preview --ENV=staging --PR=${{ github.event.number }} --AZTEC_BOT_COMMENTER_GITHUB_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} --NETLIFY_AUTH_TOKEN=${{ secrets.NETLIFY_AUTH_TOKEN }} --NETLIFY_SITE_ID=${{ secrets.NETLIFY_SITE_ID }} + run: | + earthly-ci --no-output \ + --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ + --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ + ./docs/+deploy-preview --ENV=staging --PR=${{ github.event.number }} \ + --AZTEC_BOT_COMMENTER_GITHUB_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} \ + --NETLIFY_AUTH_TOKEN=${{ secrets.NETLIFY_AUTH_TOKEN }} \ + --NETLIFY_SITE_ID=${{ secrets.NETLIFY_SITE_ID }} bb-bench: runs-on: ubuntu-20.04 @@ -617,7 +636,10 @@ jobs: working-directory: ./noir-projects/ timeout-minutes: 40 run: | - earthly-ci --artifact +gates-report/gates_report.json + earthly-ci \ + --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ + --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ + --artifact +gates-report/gates_report.json mv gates_report.json ../protocol_circuits_report.json - name: Compare gates reports diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index 13046308571..4ef4bc84302 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -45,17 +45,25 @@ contract Rollup is IRollup { // See https://github.com/AztecProtocol/aztec-packages/issues/1614 uint256 public lastWarpedBlockTs; + bytes32 public vkTreeRoot; + using EnumerableSet for EnumerableSet.AddressSet; EnumerableSet.AddressSet private sequencers; - constructor(IRegistry _registry, IAvailabilityOracle _availabilityOracle, IERC20 _gasToken) { + constructor( + IRegistry _registry, + IAvailabilityOracle _availabilityOracle, + IERC20 _gasToken, + bytes32 _vkTreeRoot + ) { verifier = new MockVerifier(); REGISTRY = _registry; AVAILABILITY_ORACLE = _availabilityOracle; GAS_TOKEN = _gasToken; INBOX = new Inbox(address(this), Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT); OUTBOX = new Outbox(address(this)); + vkTreeRoot = _vkTreeRoot; VERSION = 1; } @@ -85,6 +93,10 @@ contract Rollup is IRollup { verifier = IVerifier(_verifier); } + function setVkTreeRoot(bytes32 _vkTreeRoot) external { + vkTreeRoot = _vkTreeRoot; + } + /** * @notice Process an incoming L2 block and progress the state * @param _header - The L2 block header @@ -113,7 +125,7 @@ contract Rollup is IRollup { } bytes32[] memory publicInputs = - new bytes32[](2 + Constants.HEADER_LENGTH + Constants.AGGREGATION_OBJECT_LENGTH); + new bytes32[](3 + Constants.HEADER_LENGTH + Constants.AGGREGATION_OBJECT_LENGTH); // the archive tree root publicInputs[0] = _archive; // this is the _next_ available leaf in the archive tree @@ -121,9 +133,11 @@ contract Rollup is IRollup { // but in yarn-project/merkle-tree/src/new_tree.ts we prefill the tree so that block N is in leaf N publicInputs[1] = bytes32(header.globalVariables.blockNumber + 1); + publicInputs[2] = vkTreeRoot; + bytes32[] memory headerFields = HeaderLib.toFields(header); for (uint256 i = 0; i < headerFields.length; i++) { - publicInputs[i + 2] = headerFields[i]; + publicInputs[i + 3] = headerFields[i]; } // the block proof is recursive, which means it comes with an aggregation object @@ -135,7 +149,7 @@ contract Rollup is IRollup { assembly { part := calldataload(add(_aggregationObject.offset, mul(i, 32))) } - publicInputs[i + 2 + Constants.HEADER_LENGTH] = part; + publicInputs[i + 3 + Constants.HEADER_LENGTH] = part; } if (!verifier.verify(_proof, publicInputs)) { diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 527ae5c969b..68a8d265207 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -49,13 +49,12 @@ library Constants { uint256 internal constant MAX_UNENCRYPTED_LOGS_PER_TX = 8; uint256 internal constant MAX_PUBLIC_DATA_HINTS = 128; uint256 internal constant NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; - uint256 internal constant VK_TREE_HEIGHT = 3; + uint256 internal constant VK_TREE_HEIGHT = 5; uint256 internal constant FUNCTION_TREE_HEIGHT = 5; uint256 internal constant NOTE_HASH_TREE_HEIGHT = 32; uint256 internal constant PUBLIC_DATA_TREE_HEIGHT = 40; uint256 internal constant NULLIFIER_TREE_HEIGHT = 20; uint256 internal constant L1_TO_L2_MSG_TREE_HEIGHT = 16; - uint256 internal constant ROLLUP_VK_TREE_HEIGHT = 8; uint256 internal constant ARTIFACT_FUNCTION_TREE_MAX_HEIGHT = 5; uint256 internal constant NULLIFIER_TREE_ID = 0; uint256 internal constant NOTE_HASH_TREE_ID = 1; @@ -71,6 +70,25 @@ library Constants { uint256 internal constant PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH = 34; uint256 internal constant L1_TO_L2_MSG_SUBTREE_HEIGHT = 4; uint256 internal constant L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12; + uint256 internal constant PRIVATE_KERNEL_INIT_INDEX = 0; + uint256 internal constant PRIVATE_KERNEL_INNER_INDEX = 1; + uint256 internal constant PRIVATE_KERNEL_RESET_FULL_INDEX = 2; + uint256 internal constant PRIVATE_KERNEL_RESET_BIG_INDEX = 3; + uint256 internal constant PRIVATE_KERNEL_RESET_MEDIUM_INDEX = 4; + uint256 internal constant PRIVATE_KERNEL_RESET_SMALL_INDEX = 5; + uint256 internal constant PRIVATE_KERNEL_TAIL_INDEX = 10; + uint256 internal constant PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX = 11; + uint256 internal constant EMPTY_NESTED_INDEX = 12; + uint256 internal constant PRIVATE_KERNEL_EMPTY_INDEX = 13; + uint256 internal constant PUBLIC_KERNEL_SETUP_INDEX = 14; + uint256 internal constant PUBLIC_KERNEL_APP_LOGIC_INDEX = 15; + uint256 internal constant PUBLIC_KERNEL_TEARDOWN_INDEX = 16; + uint256 internal constant PUBLIC_KERNEL_TAIL_INDEX = 17; + uint256 internal constant BASE_PARITY_INDEX = 18; + uint256 internal constant ROOT_PARITY_INDEX = 19; + uint256 internal constant BASE_ROLLUP_INDEX = 20; + uint256 internal constant MERGE_ROLLUP_INDEX = 21; + uint256 internal constant ROOT_ROLLUP_INDEX = 22; uint256 internal constant FUNCTION_SELECTOR_NUM_BYTES = 4; uint256 internal constant ARGS_HASH_CHUNK_LENGTH = 16; uint256 internal constant ARGS_HASH_CHUNK_COUNT = 16; @@ -164,16 +182,16 @@ library Constants { uint256 internal constant VALIDATION_REQUESTS_LENGTH = 1026; uint256 internal constant PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; uint256 internal constant COMBINED_ACCUMULATED_DATA_LENGTH = 333; - uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 40; + uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 41; uint256 internal constant PUBLIC_CALL_STACK_ITEM_COMPRESSED_LENGTH = 16; uint256 internal constant CALL_REQUEST_LENGTH = 7; uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1168; - uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2243; + uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2244; uint256 internal constant PUBLIC_ACCUMULATED_DATA_LENGTH = 983; - uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3258; - uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 383; - uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 14; - uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 31; + uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3259; + uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 384; + uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 11; + uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 28; uint256 internal constant ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_LENGTH = 9; uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674; uint256 internal constant NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 2048; diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index 97f6080fb04..50f7d7f66d7 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -40,7 +40,7 @@ contract RollupTest is DecoderBase { registry = new Registry(); availabilityOracle = new AvailabilityOracle(); portalERC20 = new PortalERC20(); - rollup = new Rollup(registry, availabilityOracle, IERC20(address(portalERC20))); + rollup = new Rollup(registry, availabilityOracle, IERC20(address(portalERC20)), bytes32(0)); inbox = Inbox(address(rollup.INBOX())); outbox = Outbox(address(rollup.OUTBOX())); diff --git a/l1-contracts/test/portals/TokenPortal.t.sol b/l1-contracts/test/portals/TokenPortal.t.sol index e51f4c0dccb..ad48731f4ef 100644 --- a/l1-contracts/test/portals/TokenPortal.t.sol +++ b/l1-contracts/test/portals/TokenPortal.t.sol @@ -59,7 +59,8 @@ contract TokenPortalTest is Test { function setUp() public { registry = new Registry(); portalERC20 = new PortalERC20(); - rollup = new Rollup(registry, new AvailabilityOracle(), IERC20(address(portalERC20))); + rollup = + new Rollup(registry, new AvailabilityOracle(), IERC20(address(portalERC20)), bytes32(0)); inbox = rollup.INBOX(); outbox = rollup.OUTBOX(); diff --git a/l1-contracts/test/portals/UniswapPortal.t.sol b/l1-contracts/test/portals/UniswapPortal.t.sol index bd4e566ddf4..df5fcf2e0cd 100644 --- a/l1-contracts/test/portals/UniswapPortal.t.sol +++ b/l1-contracts/test/portals/UniswapPortal.t.sol @@ -52,7 +52,8 @@ contract UniswapPortalTest is Test { registry = new Registry(); PortalERC20 portalERC20 = new PortalERC20(); - rollup = new Rollup(registry, new AvailabilityOracle(), IERC20(address(portalERC20))); + rollup = + new Rollup(registry, new AvailabilityOracle(), IERC20(address(portalERC20)), bytes32(0)); registry.upgrade(address(rollup), address(rollup.INBOX()), address(rollup.OUTBOX())); portalERC20.mint(address(rollup), 1000000); diff --git a/noir-projects/Earthfile b/noir-projects/Earthfile index 625397f75b4..e7ee3d3eeaa 100644 --- a/noir-projects/Earthfile +++ b/noir-projects/Earthfile @@ -5,6 +5,8 @@ source: # Install nargo COPY ../noir/+nargo/nargo /usr/bin/nargo + # Install bb + COPY ../barretenberg/cpp/+preset-release/bin/bb /usr/src/barretenberg/cpp/build/bin/bb WORKDIR /usr/src/noir-projects @@ -25,6 +27,8 @@ build-contracts: build-protocol-circuits: FROM +source + RUN --secret AWS_ACCESS_KEY_ID --secret AWS_SECRET_ACCESS_KEY mkdir -p ~/.aws && \ + bash -c 'echo -e "[default]\naws_access_key_id=$AWS_ACCESS_KEY_ID\naws_secret_access_key=$AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials' RUN cd noir-protocol-circuits && NARGO=nargo ./bootstrap.sh SAVE ARTIFACT noir-protocol-circuits diff --git a/noir-projects/noir-protocol-circuits/bootstrap.sh b/noir-projects/noir-protocol-circuits/bootstrap.sh index 874fe97e3e2..5755a31bb16 100755 --- a/noir-projects/noir-protocol-circuits/bootstrap.sh +++ b/noir-projects/noir-protocol-circuits/bootstrap.sh @@ -16,8 +16,46 @@ if [ -n "$CMD" ]; then fi yarn -node ./index.js +node ./generate_variants.js echo "Compiling protocol circuits..." NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo} -$NARGO compile --silence-warnings --use-legacy \ No newline at end of file +$NARGO compile --silence-warnings --use-legacy + +mkdir -p "./target/keys" + +AVAILABLE_MEMORY=0 + +case "$(uname)" in + Linux*) + # Check available memory on Linux + AVAILABLE_MEMORY=$(awk '/MemTotal/ { printf $2 }' /proc/meminfo) + ;; + *) + echo "Parallel vk generation not supported on this operating system" + ;; +esac +# This value may be too low. +# If vk generation fail with an amount of free memory greater than this value then it should be increased. +MIN_PARALLEL_VK_GENERATION_MEMORY=500000000 + +if [[ AVAILABLE_MEMORY -lt MIN_PARALLEL_VK_GENERATION_MEMORY ]]; then + echo "System does not have enough memory for parallel vk generation, falling back to sequential" + + for pathname in "./target"/*.json; do + node ./scripts/generate_vk_json.js "$pathname" "./target/keys" + done + +else + + echo "Generating vks in parallel..." + for pathname in "./target"/*.json; do + node ./scripts/generate_vk_json.js "$pathname" "./target/keys" & + done + + for job in $(jobs -p); do + wait $job || exit 1 + done + +fi + diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr index 71a9bcd52f4..b7758df3d98 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/base/base_parity_inputs.nr @@ -3,6 +3,7 @@ use dep::types::{constants::NUM_MSGS_PER_BASE_PARITY, merkle_tree::MerkleTree, u struct BaseParityInputs { msgs: [Field; NUM_MSGS_PER_BASE_PARITY], + vk_tree_root: Field, } impl BaseParityInputs { @@ -10,7 +11,11 @@ impl BaseParityInputs { let sha_tree = Sha256MerkleTree::new(self.msgs); let pedersen_tree = MerkleTree::new(self.msgs); - ParityPublicInputs { sha_root: sha_tree.get_root(), converted_root: pedersen_tree.get_root() } + ParityPublicInputs { + sha_root: sha_tree.get_root(), + converted_root: pedersen_tree.get_root(), + vk_tree_root: self.vk_tree_root + } } } @@ -24,7 +29,7 @@ fn test_sha_root_matches_frontier_tree() { 0x2806c860af67e9cd50000378411b8c4c4db172ceb2daa862b259b689ccbdc1 ]; - let base_parity_inputs = BaseParityInputs { msgs }; + let base_parity_inputs = BaseParityInputs { msgs, vk_tree_root: 42 }; let public_inputs = base_parity_inputs.base_parity_circuit(); // 31 byte truncated root hash diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr index 7ad2f4647c6..d34f0587b14 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr @@ -2,7 +2,8 @@ use dep::types::{traits::{Empty, Serialize, Deserialize}}; struct ParityPublicInputs { sha_root: Field, - converted_root: Field, + converted_root: Field, + vk_tree_root: Field, } impl Empty for ParityPublicInputs { @@ -10,24 +11,27 @@ impl Empty for ParityPublicInputs { ParityPublicInputs { sha_root: 0, converted_root: 0, + vk_tree_root: 0, } } } -impl Serialize<2> for ParityPublicInputs { - fn serialize(self) -> [Field; 2] { - let mut fields = [0; 2]; +impl Serialize<3> for ParityPublicInputs { + fn serialize(self) -> [Field; 3] { + let mut fields = [0; 3]; fields[0] = self.sha_root; fields[1] = self.converted_root; + fields[2] = self.vk_tree_root; fields } } -impl Deserialize<2> for ParityPublicInputs { - fn deserialize(fields: [Field; 2]) -> Self { +impl Deserialize<3> for ParityPublicInputs { + fn deserialize(fields: [Field; 3]) -> Self { ParityPublicInputs { sha_root: fields[0], converted_root: fields[1], + vk_tree_root: fields[2], } } } diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr index f1536fb0ab4..fdb685ab6f7 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr @@ -1,12 +1,14 @@ use dep::types::{ traits::Empty, - recursion::{verification_key::VerificationKey, proof::RecursiveProof, traits::Verifiable} + recursion::{verification_key::VerificationKey, proof::RecursiveProof, traits::Verifiable}, + constants::{BASE_PARITY_INDEX, VK_TREE_HEIGHT}, merkle_tree::membership::assert_check_membership }; use crate::parity_public_inputs::ParityPublicInputs; struct RootParityInput { proof: RecursiveProof, verification_key: VerificationKey, + vk_path: [Field; VK_TREE_HEIGHT], public_inputs: ParityPublicInputs, } @@ -15,6 +17,7 @@ impl Empty for RootParityInput { RootParityInput { proof: RecursiveProof::empty(), verification_key: VerificationKey::empty(), + vk_path: [0; VK_TREE_HEIGHT], public_inputs: ParityPublicInputs::empty(), } } @@ -31,3 +34,14 @@ impl Verifiable for RootParityInput { ); } } + +impl RootParityInput { + fn validate_in_vk_tree(self) { + assert_check_membership( + self.verification_key.hash, + BASE_PARITY_INDEX as Field, + self.vk_path, + self.public_inputs.vk_tree_root + ); + } +} diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr index e94b0e5f6e4..134421e483f 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr @@ -17,6 +17,12 @@ struct RootParityInputs { impl RootParityInputs { pub fn root_parity_circuit(self) -> ParityPublicInputs { self.verify_child_proofs(); + let vk_tree_root = self.children[0].public_inputs.vk_tree_root; + for i in 0..NUM_BASE_PARITY_PER_ROOT_PARITY { + assert( + self.children[i].public_inputs.vk_tree_root == vk_tree_root, "Inconsistent vk tree roots across base parity circuits" + ); + } let mut sha_roots = [0; NUM_BASE_PARITY_PER_ROOT_PARITY]; let mut converted_roots = [0; NUM_BASE_PARITY_PER_ROOT_PARITY]; @@ -28,19 +34,21 @@ impl RootParityInputs { let sha_tree = Sha256MerkleTree::new(sha_roots); let pedersen_tree = MerkleTree::new(converted_roots); - ParityPublicInputs { sha_root: sha_tree.get_root(), converted_root: pedersen_tree.get_root() } + ParityPublicInputs { sha_root: sha_tree.get_root(), converted_root: pedersen_tree.get_root(), vk_tree_root } } fn verify_child_proofs(self) { - //TODO(@PhilWindle): Validate all keys against the actual BASE_PARITY_CIRCUIT_VK_HASH - //assert(self.children[0].verification_key.hash == BASE_PARITY_CIRCUIT_VK_HASH); for i in 0..NUM_BASE_PARITY_PER_ROOT_PARITY { assert( self.children[i].verification_key.hash == self.children[0].verification_key.hash, "Inconsistent vk hashes across base parity circuits" ); + assert( + self.children[i].vk_path == self.children[0].vk_path, "Inconsistent vk paths across base parity circuits" + ); //TODO: Do we need to validate this following hash //assert(hash(self.children[i].verification_key) == self.children[i].verification_key.hash); self.children[i].verify(); + self.children[i].validate_in_vk_tree(); } } } @@ -51,6 +59,8 @@ mod tests { root::{root_parity_input::RootParityInput, root_parity_inputs::RootParityInputs} }; use dep::types::recursion::{verification_key::VerificationKey, proof::RecursiveProof}; + use dep::types::tests::fixtures; + use dep::types::constants::BASE_PARITY_INDEX; fn test_setup() -> [RootParityInput; 4] { // 31 byte test SHA roots @@ -61,29 +71,39 @@ mod tests { 0x53042d820859d80c474d4694e03778f8dc0ac88fc1c3a97b4369c1096e904a ]; + let vk_tree = fixtures::vk_tree::get_vk_merkle_tree(); + + let vk_hash = vk_tree.leaves[BASE_PARITY_INDEX]; + let vk_path = vk_tree.get_sibling_path(BASE_PARITY_INDEX); + let vk_tree_root = vk_tree.get_root(); + let mut vk1 = VerificationKey::empty(); - vk1.hash = 0x43f78e0ebc9633ce336a8c086064d898c32fb5d7d6011f5427459c0b8d14e9; + vk1.hash = vk_hash; let children = [ RootParityInput { proof: RecursiveProof::empty(), verification_key: vk1, - public_inputs: ParityPublicInputs { sha_root: children_sha_roots[0], converted_root: 0 } + vk_path, + public_inputs: ParityPublicInputs { sha_root: children_sha_roots[0], converted_root: 0, vk_tree_root } }, RootParityInput { proof: RecursiveProof::empty(), verification_key: vk1, - public_inputs: ParityPublicInputs { sha_root: children_sha_roots[1], converted_root: 0 } + vk_path, + public_inputs: ParityPublicInputs { sha_root: children_sha_roots[1], converted_root: 0, vk_tree_root } }, RootParityInput { proof: RecursiveProof::empty(), verification_key: vk1, - public_inputs: ParityPublicInputs { sha_root: children_sha_roots[2], converted_root: 0 } + vk_path, + public_inputs: ParityPublicInputs { sha_root: children_sha_roots[2], converted_root: 0, vk_tree_root } }, RootParityInput { proof: RecursiveProof::empty(), verification_key: vk1, - public_inputs: ParityPublicInputs { sha_root: children_sha_roots[3], converted_root: 0 } + vk_path, + public_inputs: ParityPublicInputs { sha_root: children_sha_roots[3], converted_root: 0, vk_tree_root } } ]; children diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr index 4646d6837db..b8ce076e479 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr @@ -1,12 +1,14 @@ use dep::types::{ traits::Empty, - recursion::{verification_key::VerificationKey, proof::NestedRecursiveProof, traits::Verifiable} + recursion::{verification_key::VerificationKey, proof::NestedRecursiveProof, traits::Verifiable}, + constants::{ROOT_PARITY_INDEX, VK_TREE_HEIGHT}, merkle_tree::membership::assert_check_membership }; use crate::parity_public_inputs::ParityPublicInputs; struct RootRollupParityInput { proof: NestedRecursiveProof, verification_key: VerificationKey, + vk_path: [Field; VK_TREE_HEIGHT], public_inputs: ParityPublicInputs, } @@ -15,6 +17,7 @@ impl Empty for RootRollupParityInput { RootRollupParityInput { proof: NestedRecursiveProof::empty(), verification_key: VerificationKey::empty(), + vk_path: [0; VK_TREE_HEIGHT], public_inputs: ParityPublicInputs::empty(), } } @@ -31,3 +34,14 @@ impl Verifiable for RootRollupParityInput { ); } } + +impl RootRollupParityInput { + fn validate_in_vk_tree(self) { + assert_check_membership( + self.verification_key.hash, + ROOT_PARITY_INDEX as Field, + self.vk_path, + self.public_inputs.vk_tree_root + ); + } +} diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr index 692ae21defd..0fdc92830d9 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr @@ -119,9 +119,15 @@ impl PrivateKernelCircuitOutputValidator { private_call_array_lengths: PrivateCircuitPublicInputsArrayLengths, contract_address: AztecAddress, public_call_requests: [CallRequest; PUBLIC_CALL_REQUESTS_LEN], - public_teardown_call_request: CallRequest + public_teardown_call_request: CallRequest, + vk_tree_root: Field ) { - self.validate_initial_values(tx_request, private_call, public_teardown_call_request); + self.validate_initial_values( + tx_request, + private_call, + public_teardown_call_request, + vk_tree_root + ); let mut offsets = PrivateKernelCircuitPublicInputsArrayLengths::empty(); offsets.nullifiers = 1; // The first nullifier is not propagated from the private call. self.validate_propagated_from_private_call( @@ -160,7 +166,8 @@ impl PrivateKernelCircuitOutputValidator { self, tx_request: TxRequest, private_call: PrivateCircuitPublicInputs, - public_teardown_call_request: CallRequest + public_teardown_call_request: CallRequest, + vk_tree_root: Field ) { // Constants. assert_eq(self.output.constants.tx_context, tx_request.tx_context, "mismatch tx_context"); @@ -168,6 +175,7 @@ impl PrivateKernelCircuitOutputValidator { self.output.constants.historical_header, private_call.historical_header, "mismatch historical_header" ); assert(is_empty(self.output.constants.global_variables), "constants.global_variables must be empty"); + assert_eq(self.output.constants.vk_tree_root, vk_tree_root); // First nullifier. let first_nullifier = create_first_nullifier(tx_request); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr index 0c52b1cf755..b89b318dc73 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr @@ -35,12 +35,17 @@ struct PrivateKernelCircuitPublicInputsComposer { } impl PrivateKernelCircuitPublicInputsComposer { - pub fn new_from_tx_request(tx_request: TxRequest, private_call_public_inputs: PrivateCircuitPublicInputs) -> Self { + pub fn new_from_tx_request( + tx_request: TxRequest, + private_call_public_inputs: PrivateCircuitPublicInputs, + vk_tree_root: Field + ) -> Self { let mut public_inputs = PrivateKernelCircuitPublicInputsBuilder::empty(); public_inputs.constants = CombinedConstantData::private( private_call_public_inputs.historical_header, tx_request.tx_context, + vk_tree_root, ); // Since it's the first iteration, we need to push the tx hash nullifier into the `nullifiers` array diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr index 3a81cd1c774..d3b7ff7a315 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr @@ -33,6 +33,7 @@ struct PrivateKernelEmptyPrivateInputs { historical_header: Header, chain_id: Field, version: Field, + vk_tree_root: Field, } impl PrivateKernelEmptyPrivateInputs { @@ -43,6 +44,7 @@ impl PrivateKernelEmptyPrivateInputs { public_inputs.constants.historical_header = self.historical_header; public_inputs.constants.tx_context.chain_id = self.chain_id; public_inputs.constants.tx_context.version = self.version; + public_inputs.constants.vk_tree_root = self.vk_tree_root; public_inputs } @@ -55,6 +57,7 @@ impl Empty for PrivateKernelEmptyPrivateInputs { historical_header: Header::empty(), chain_id: 0, version: 0, + vk_tree_root: 0 } } } @@ -69,10 +72,12 @@ mod tests { empty_nested: EmptyNestedCircuitPublicInputs::empty(), historical_header: Header::empty(), chain_id: 1, - version: 2 + version: 2, + vk_tree_root: 3 }; let public_inputs = private_inputs.execute(); assert_eq(public_inputs.constants.tx_context.chain_id, 1); assert_eq(public_inputs.constants.tx_context.version, 2); + assert_eq(public_inputs.constants.vk_tree_root, 3); } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr index 739cbcc332b..f016a8ada88 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr @@ -16,13 +16,14 @@ use dep::types::{ // Initialization struct for private inputs to the private kernel struct PrivateKernelInitCircuitPrivateInputs { tx_request: TxRequest, + vk_tree_root: Field, private_call: PrivateCallData, } impl PrivateKernelInitCircuitPrivateInputs { unconstrained fn generate_output(self) -> PrivateKernelCircuitPublicInputs { let private_call_public_inputs = self.private_call.call_stack_item.public_inputs; - PrivateKernelCircuitPublicInputsComposer::new_from_tx_request(self.tx_request, private_call_public_inputs).with_private_call( + PrivateKernelCircuitPublicInputsComposer::new_from_tx_request(self.tx_request, private_call_public_inputs, self.vk_tree_root).with_private_call( private_call_public_inputs, self.private_call.call_stack_item.contract_address, self.private_call.public_call_stack, @@ -52,7 +53,8 @@ impl PrivateKernelInitCircuitPrivateInputs { private_call_data_validator.array_lengths, self.private_call.call_stack_item.contract_address, self.private_call.public_call_stack, - self.private_call.public_teardown_call_request + self.private_call.public_teardown_call_request, + self.vk_tree_root ); } output @@ -63,7 +65,7 @@ mod tests { use crate::private_kernel_init::PrivateKernelInitCircuitPrivateInputs; use dep::types::{ abis::{kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs}, - tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, + tests::{fixture_builder::FixtureBuilder, fixtures, utils::assert_array_eq}, transaction::tx_request::TxRequest }; @@ -81,7 +83,7 @@ mod tests { pub fn execute(self) -> PrivateKernelCircuitPublicInputs { let private_call = self.private_call.to_private_call_data(); - PrivateKernelInitCircuitPrivateInputs { tx_request: self.tx_request, private_call }.execute() + PrivateKernelInitCircuitPrivateInputs { tx_request: self.tx_request, private_call, vk_tree_root: FixtureBuilder::vk_tree_root() }.execute() } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr index 512d318e18e..a98a4a5c6b6 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr @@ -9,9 +9,22 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::{PrivateKernelCircuitPublicInputs, PrivateKernelCircuitPublicInputsArrayLengths}, private_kernel_data::PrivateKernelData, private_kernel::private_call_data::PrivateCallData +}, + constants::{ + PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, PRIVATE_KERNEL_RESET_MEDIUM_INDEX, PRIVATE_KERNEL_RESET_SMALL_INDEX } }; +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_INIT_INDEX, + PRIVATE_KERNEL_INNER_INDEX, + PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, + PRIVATE_KERNEL_RESET_MEDIUM_INDEX, + PRIVATE_KERNEL_RESET_SMALL_INDEX, +]; + struct PrivateKernelInnerCircuitPrivateInputs { previous_kernel: PrivateKernelData, private_call: PrivateCallData, @@ -44,6 +57,7 @@ impl PrivateKernelInnerCircuitPrivateInputs { self.private_call.verify(); // verify/aggregate the previous kernel self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); } // Validate output. @@ -63,9 +77,10 @@ impl PrivateKernelInnerCircuitPrivateInputs { } mod tests { - use crate::private_kernel_inner::PrivateKernelInnerCircuitPrivateInputs; + use crate::private_kernel_inner::{PrivateKernelInnerCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}; use dep::types::{ abis::{kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs}, + constants::{PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, BASE_ROLLUP_INDEX}, tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq} }; @@ -76,7 +91,7 @@ mod tests { impl PrivateKernelInnerInputsBuilder { pub fn new() -> Self { - let mut previous_kernel = FixtureBuilder::new_from_counter(15).as_parent_contract(); + let mut previous_kernel = FixtureBuilder::new_from_counter(15).in_vk_tree(PRIVATE_KERNEL_INIT_INDEX).as_parent_contract(); let private_call = FixtureBuilder::new_from_counter(200); // 0th nullifier must be non-zero. @@ -125,4 +140,23 @@ mod tests { [prev_encrypted_log_hashes[0], prev_encrypted_log_hashes[1], curr_encrypted_log_hashes[0]] ); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PrivateKernelInnerInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PrivateKernelInnerInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr index 02af30ae549..2affa858a41 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr @@ -5,9 +5,15 @@ use dep::reset_kernel_lib::{ }; use dep::types::{ abis::private_kernel_data::PrivateKernelData, - constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX}, PrivateKernelCircuitPublicInputs + constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX}, + PrivateKernelCircuitPublicInputs }; +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_INIT_INDEX, + PRIVATE_KERNEL_INNER_INDEX, +]; + struct PrivateKernelResetHints { transient_nullifier_indexes_for_note_hashes: [u32; MAX_NOTE_HASHES_PER_TX], transient_note_hash_indexes_for_nullifiers: [u32; MAX_NULLIFIERS_PER_TX], @@ -38,6 +44,7 @@ impl Self { - let mut previous_kernel = FixtureBuilder::new(); + let mut previous_kernel = FixtureBuilder::new().in_vk_tree(PRIVATE_KERNEL_INNER_INDEX); previous_kernel.append_nullifiers(1); PrivateKernelResetInputsBuilder { @@ -427,4 +435,23 @@ mod tests { let public_inputs = builder.execute(); assert_eq(public_inputs.fee_payer, AztecAddress::empty()); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PrivateKernelResetInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PrivateKernelResetInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr index 496be7841d0..cd703071d96 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr @@ -2,7 +2,22 @@ use crate::components::{ previous_kernel_validator::PreviousKernelValidator, tail_output_composer::TailOutputComposer, tail_output_validator::TailOutputValidator }; -use dep::types::{abis::{private_kernel_data::PrivateKernelData, kernel_circuit_public_inputs::KernelCircuitPublicInputs}}; +use dep::types::{ + abis::{private_kernel_data::PrivateKernelData, kernel_circuit_public_inputs::KernelCircuitPublicInputs}, + constants::{ + PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, PRIVATE_KERNEL_RESET_MEDIUM_INDEX, PRIVATE_KERNEL_RESET_SMALL_INDEX +} +}; + +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_INIT_INDEX, + PRIVATE_KERNEL_INNER_INDEX, + PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, + PRIVATE_KERNEL_RESET_MEDIUM_INDEX, + PRIVATE_KERNEL_RESET_SMALL_INDEX, +]; struct PrivateKernelTailCircuitPrivateInputs { previous_kernel: PrivateKernelData, @@ -22,6 +37,7 @@ impl PrivateKernelTailCircuitPrivateInputs { if !std::runtime::is_unconstrained() { // verify/aggregate the previous kernel self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); } // Validate output. @@ -34,10 +50,11 @@ impl PrivateKernelTailCircuitPrivateInputs { } mod tests { - use crate::private_kernel_tail::PrivateKernelTailCircuitPrivateInputs; + use crate::private_kernel_tail::{PrivateKernelTailCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}; use dep::types::constants::{ MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, - GENERATOR_INDEX__IVSK_M, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NULLIFIER, L2_GAS_PER_NOTE_HASH + GENERATOR_INDEX__IVSK_M, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NULLIFIER, L2_GAS_PER_NOTE_HASH, + PRIVATE_KERNEL_INNER_INDEX, BASE_ROLLUP_INDEX }; use dep::types::{ abis::{ @@ -60,7 +77,7 @@ mod tests { impl PrivateKernelTailInputsBuilder { pub fn new() -> Self { - let mut previous_kernel = FixtureBuilder::new(); + let mut previous_kernel = FixtureBuilder::new().in_vk_tree(PRIVATE_KERNEL_INNER_INDEX); previous_kernel.tx_context.gas_settings.gas_limits = Gas::new(1_000_000, 1_000_000); previous_kernel.set_first_nullifier(); @@ -398,4 +415,23 @@ mod tests { let public_inputs = builder.execute(); assert_eq(public_inputs.fee_payer, AztecAddress::empty()); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PrivateKernelTailInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PrivateKernelTailInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr index fe914554ef0..13bc6c233d7 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr @@ -3,7 +3,22 @@ use crate::components::{ tail_to_public_output_composer::TailToPublicOutputComposer, tail_to_public_output_validator::TailToPublicOutputValidator }; -use dep::types::{abis::{private_kernel_data::PrivateKernelData, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs}}; +use dep::types::{ + abis::{private_kernel_data::PrivateKernelData, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs}, + constants::{ + PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, PRIVATE_KERNEL_RESET_MEDIUM_INDEX, PRIVATE_KERNEL_RESET_SMALL_INDEX +} +}; + +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_INIT_INDEX, + PRIVATE_KERNEL_INNER_INDEX, + PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, + PRIVATE_KERNEL_RESET_MEDIUM_INDEX, + PRIVATE_KERNEL_RESET_SMALL_INDEX, +]; struct PrivateKernelTailToPublicCircuitPrivateInputs { previous_kernel: PrivateKernelData, @@ -23,6 +38,7 @@ impl PrivateKernelTailToPublicCircuitPrivateInputs { if !std::runtime::is_unconstrained() { // verify/aggregate the previous kernel self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); } // Validate output. @@ -35,7 +51,7 @@ impl PrivateKernelTailToPublicCircuitPrivateInputs { } mod tests { - use crate::private_kernel_tail_to_public::PrivateKernelTailToPublicCircuitPrivateInputs; + use crate::private_kernel_tail_to_public::{PrivateKernelTailToPublicCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}; use dep::types::constants::{ DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, GENERATOR_INDEX__TSK_M, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, FIXED_AVM_STARTUP_L2_GAS @@ -47,7 +63,8 @@ mod tests { log_hash::{LogHash, NoteLogHash} }, address::{AztecAddress, EthAddress}, hash::{silo_note_hash, silo_nullifier}, - tests::fixture_builder::FixtureBuilder, utils::{arrays::array_eq}, grumpkin_point::GrumpkinPoint + tests::fixture_builder::FixtureBuilder, utils::{arrays::array_eq}, + grumpkin_point::GrumpkinPoint, constants::{BASE_ROLLUP_INDEX, PRIVATE_KERNEL_INNER_INDEX} }; // TODO: Reduce the duplicated code/tests for PrivateKernelTailToPublicInputs and PrivateKernelTailInputs. @@ -57,7 +74,7 @@ mod tests { impl PrivateKernelTailToPublicInputsBuilder { pub fn new() -> Self { - let mut previous_kernel = FixtureBuilder::new(); + let mut previous_kernel = FixtureBuilder::new().in_vk_tree(PRIVATE_KERNEL_INNER_INDEX); previous_kernel.tx_context.gas_settings.gas_limits = Gas::new(1_000_000, 1_000_000); previous_kernel.set_first_nullifier(); previous_kernel.push_public_call_request(1, false); @@ -408,4 +425,23 @@ mod tests { let public_inputs = builder.execute(); assert_eq(public_inputs.fee_payer, AztecAddress::empty()); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PrivateKernelTailToPublicInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PrivateKernelTailToPublicInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr index a58f1a8d033..9eda032c422 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr @@ -15,7 +15,8 @@ use dep::types::{ kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputsArrayLengths, private_circuit_public_inputs::PrivateCircuitPublicInputsArrayLengths }, - tests::{fixture_builder::FixtureBuilder}, transaction::tx_request::TxRequest + tests::{fixture_builder::FixtureBuilder}, transaction::tx_request::TxRequest, + constants::PRIVATE_KERNEL_INIT_INDEX }; struct PrivateKernelCircuitOutputValidatorBuilder { @@ -34,9 +35,15 @@ impl PrivateKernelCircuitOutputValidatorBuilder { let first_nullifier = create_first_nullifier(tx_request); output.nullifiers.push(first_nullifier); previous_kernel.nullifiers.push(first_nullifier); + previous_kernel = previous_kernel.in_vk_tree(PRIVATE_KERNEL_INIT_INDEX); + PrivateKernelCircuitOutputValidatorBuilder { previous_kernel, private_call, output, tx_request } } + pub fn with_previous_kernel_vk_index(&mut self, vk_index: u32) { + self.previous_kernel = self.previous_kernel.in_vk_tree(vk_index); + } + pub fn offset_values(&mut self, num_prepended_items: Field) { // Add an offset to the mock values so that the data in the private call won't be the same as those in the previous kernel. self.private_call.value_offset = 9999; @@ -55,7 +62,8 @@ impl PrivateKernelCircuitOutputValidatorBuilder { array_lengths, private_call.call_stack_item.contract_address, private_call.public_call_stack, - private_call.public_teardown_call_request + private_call.public_teardown_call_request, + FixtureBuilder::vk_tree_root() ); } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr index 86403b3c94c..699b6991032 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr @@ -31,7 +31,7 @@ impl PrivateKernelCircuitPublicInputsComposerBuilder { pub fn new_from_tx_request(self) -> PrivateKernelCircuitPublicInputsComposer { let private_call = self.private_call.to_private_circuit_public_inputs(); - PrivateKernelCircuitPublicInputsComposer::new_from_tx_request(self.tx_request, private_call) + PrivateKernelCircuitPublicInputsComposer::new_from_tx_request(self.tx_request, private_call, FixtureBuilder::vk_tree_root()) } pub fn new_from_previous_kernel(self) -> PrivateKernelCircuitPublicInputsComposer { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr index 2cb9d9f733a..3e978ac9afe 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_app_logic.nr @@ -3,8 +3,15 @@ use dep::types::abis::public_kernel_data::PublicKernelData; use dep::types::PublicKernelCircuitPublicInputs; use dep::types::abis::kernel_circuit_public_inputs::PublicKernelCircuitPublicInputsBuilder; use dep::types::utils::arrays::array_to_bounded_vec; +use dep::types::constants::{PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX}; use crate::common; +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, +]; + struct PublicKernelAppLogicCircuitPrivateInputs { previous_kernel: PublicKernelData, public_call: PublicCallData, @@ -39,9 +46,11 @@ impl PublicKernelAppLogicCircuitPrivateInputs { } fn public_kernel_app_logic(self) -> PublicKernelCircuitPublicInputs { - // verify the previous kernel proof - self.previous_kernel.verify(); - + if !dep::std::runtime::is_unconstrained() { + // verify the previous kernel proof + self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + } // construct the circuit outputs let mut public_inputs = PublicKernelCircuitPublicInputsBuilder::empty(); @@ -93,7 +102,7 @@ impl PublicKernelAppLogicCircuitPrivateInputs { mod tests { use crate::{ - public_kernel_app_logic::PublicKernelAppLogicCircuitPrivateInputs, + public_kernel_app_logic::{PublicKernelAppLogicCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}, utils::{ assert_eq_call_requests, assert_eq_public_data_reads, assert_eq_public_data_update_requests, compute_public_data_reads, compute_public_data_update_requests @@ -115,7 +124,10 @@ mod tests { tests::{fixture_builder::FixtureBuilder, public_call_data_builder::PublicCallDataBuilder}, utils::arrays::{array_eq, array_length}, traits::is_empty }; - use dep::types::constants::{MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL}; + use dep::types::constants::{ + MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, BASE_ROLLUP_INDEX + }; struct PublicKernelAppLogicCircuitPrivateInputsBuilder { previous_kernel: FixtureBuilder, @@ -124,7 +136,7 @@ mod tests { impl PublicKernelAppLogicCircuitPrivateInputsBuilder { pub fn new() -> Self { - let previous_kernel = FixtureBuilder::new().as_parent_contract(); + let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX); let public_call = PublicCallDataBuilder::new(); PublicKernelAppLogicCircuitPrivateInputsBuilder { previous_kernel, public_call } @@ -193,7 +205,7 @@ mod tests { #[test(should_fail_with="Cannot run unnecessary app logic circuit")] fn public_previous_kernel_private_previous_kernel_should_fail() { let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); - builder.previous_kernel = FixtureBuilder::new(); + builder.previous_kernel = FixtureBuilder::new().in_vk_tree(PUBLIC_KERNEL_APP_LOGIC_INDEX); let public_call = builder.public_call.finish(); // the key difference in this test versus those that use builder.execute() @@ -614,4 +626,23 @@ mod tests { assert_eq(array_length(public_inputs.end.public_call_stack), 0); assert_eq(array_length(public_inputs.public_teardown_call_stack), 2); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PublicKernelAppLogicCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr index a434a3ecc3e..46f0d711000 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_setup.nr @@ -4,6 +4,12 @@ use dep::types::abis::{ public_kernel_data::PublicKernelData, public_call_data::PublicCallData }; use dep::types::utils::arrays::array_to_bounded_vec; +use dep::types::constants::{PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PUBLIC_KERNEL_SETUP_INDEX}; + +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, +]; struct PublicKernelSetupCircuitPrivateInputs { // Note: One might think that our previous_kernel ought to be @@ -39,9 +45,11 @@ impl PublicKernelSetupCircuitPrivateInputs { } fn public_kernel_setup(self) -> PublicKernelCircuitPublicInputs { - // verify the previous kernel proof - self.previous_kernel.verify(); - + if !dep::std::runtime::is_unconstrained() { + // verify the previous kernel proof + self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + } // construct the circuit outputs let mut public_inputs = PublicKernelCircuitPublicInputsBuilder::empty(); self.initialize_revert_code(&mut public_inputs); @@ -76,7 +84,7 @@ impl PublicKernelSetupCircuitPrivateInputs { mod tests { use crate::{ - public_kernel_setup::PublicKernelSetupCircuitPrivateInputs, + public_kernel_setup::{PublicKernelSetupCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS}, utils::{ assert_eq_call_requests, assert_eq_public_data_reads, assert_eq_public_data_update_requests, compute_public_data_reads, compute_public_data_update_requests @@ -96,7 +104,7 @@ mod tests { }; use dep::types::constants::{ MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, BASE_ROLLUP_INDEX }; struct PublicKernelSetupCircuitPrivateInputsBuilder { @@ -107,7 +115,7 @@ mod tests { impl PublicKernelSetupCircuitPrivateInputsBuilder { pub fn new() -> Self { - let previous_kernel = FixtureBuilder::new().as_parent_contract(); + let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX); let previous_revertible = FixtureBuilder::new(); let public_call = PublicCallDataBuilder::new(); @@ -156,6 +164,7 @@ mod tests { let setup_call = self.public_call.finish(); self.push_public_call(setup_call); let mut previous_kernel = self.previous_kernel.to_public_kernel_data(false); + previous_kernel.public_inputs.end = self.previous_revertible.to_public_accumulated_data(); // Run the kernel on the setup call @@ -607,4 +616,23 @@ mod tests { assert_eq(array_length(public_inputs.end_non_revertible.public_call_stack), 1); assert_eq(array_length(public_inputs.public_teardown_call_stack), 2); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PublicKernelSetupCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr index bcb64d69486..72061159abb 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr @@ -9,12 +9,22 @@ use dep::types::{ kernel_circuit_public_inputs::KernelCircuitPublicInputs, public_kernel_data::PublicKernelData, public_data_update_request::PublicDataUpdateRequest, side_effect::Ordered }, - constants::{MAX_PUBLIC_DATA_HINTS, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX}, + constants::{ + MAX_NOTE_HASHES_PER_TX, MAX_PUBLIC_DATA_HINTS, MAX_NULLIFIER_READ_REQUESTS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, + PUBLIC_KERNEL_TEARDOWN_INDEX +}, data::public_data_hint::PublicDataHint, merkle_tree::{conditionally_assert_check_membership, MembershipWitness}, partial_state_reference::PartialStateReference, utils::{arrays::array_length}, address::AztecAddress }; +global ALLOWED_PREVIOUS_CIRCUITS = [ + PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, + PUBLIC_KERNEL_TEARDOWN_INDEX, +]; + struct PublicKernelTailCircuitPrivateInputs { previous_kernel: PublicKernelData, nullifier_read_request_hints: NullifierReadRequestHints, @@ -56,9 +66,11 @@ impl PublicKernelTailCircuitPrivateInputs { } pub fn public_kernel_tail(self) -> KernelCircuitPublicInputs { - // verify the previous kernel proof - self.previous_kernel.verify(); - + if !dep::std::runtime::is_unconstrained() { + // verify the previous kernel proof + self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + } self.validate_inputs(); self.validate_public_data_hints(); @@ -88,7 +100,7 @@ impl PublicKernelTailCircuitPrivateInputs { } mod tests { - use crate::public_kernel_tail::PublicKernelTailCircuitPrivateInputs; + use crate::public_kernel_tail::{ALLOWED_PREVIOUS_CIRCUITS, PublicKernelTailCircuitPrivateInputs}; use dep::reset_kernel_lib::{ tests::{ nullifier_non_existent_read_request_hints_builder::NullifierNonExistentReadRequestHintsBuilder, @@ -110,7 +122,9 @@ mod tests { MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_TREE_HEIGHT, MAX_ENCRYPTED_LOGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + MAX_UNENCRYPTED_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, BASE_ROLLUP_INDEX, PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_TEARDOWN_INDEX }, hash::{compute_siloed_nullifier, sha256_to_field}, public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, @@ -163,7 +177,7 @@ mod tests { impl PublicKernelTailCircuitPrivateInputsBuilder { pub fn new() -> Self { - let previous_kernel = FixtureBuilder::new(); + let previous_kernel = FixtureBuilder::new().in_vk_tree(PUBLIC_KERNEL_APP_LOGIC_INDEX); let previous_revertible = FixtureBuilder::new(); let nullifier_non_existent_read_request_hints_builder = NullifierNonExistentReadRequestHintsBuilder::new(); @@ -591,4 +605,37 @@ mod tests { let public_inputs = builder.execute(); assert_eq(public_inputs.fee_payer, AztecAddress::empty()); } + + #[test] + fn valid_previous_kernel_setup() { + let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(PUBLIC_KERNEL_SETUP_INDEX); + + let _res = builder.execute(); + } + + #[test] + fn valid_previous_kernel_app_logic() { + let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(PUBLIC_KERNEL_APP_LOGIC_INDEX); + + let _res = builder.execute(); + } + + #[test] + fn valid_previous_kernel_teardown() { + let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(PUBLIC_KERNEL_TEARDOWN_INDEX); + + let _res = builder.execute(); + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr index e748e57c856..8069c45fc43 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_teardown.nr @@ -4,12 +4,23 @@ use dep::types::abis::{ public_kernel_data::PublicKernelData, public_call_data::PublicCallData, gas_fees::GasFees }; use dep::types::utils::arrays::array_to_bounded_vec; +use dep::types::constants::{ + PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, PUBLIC_KERNEL_TEARDOWN_INDEX, + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX +}; struct PublicKernelTeardownCircuitPrivateInputs { previous_kernel: PublicKernelData, public_call: PublicCallData, } +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, + PUBLIC_KERNEL_TEARDOWN_INDEX, +]; + impl PublicKernelTeardownCircuitPrivateInputs { fn initialize_revert_code(self, circuit_outputs: &mut PublicKernelCircuitPublicInputsBuilder) { // See https://docs.aztec.network/protocol-specs/gas-and-fees/kernel-tracking#handling-reverts @@ -94,8 +105,11 @@ impl PublicKernelTeardownCircuitPrivateInputs { } fn public_kernel_teardown(self) -> PublicKernelCircuitPublicInputs { - // verify the previous kernel proof - self.previous_kernel.verify(); + if !dep::std::runtime::is_unconstrained() { + // verify the previous kernel proof + self.previous_kernel.verify(); + self.previous_kernel.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + } // construct the circuit outputs let mut public_inputs = PublicKernelCircuitPublicInputsBuilder::empty(); @@ -141,7 +155,7 @@ impl PublicKernelTeardownCircuitPrivateInputs { mod tests { use crate::{ - public_kernel_teardown::PublicKernelTeardownCircuitPrivateInputs, + public_kernel_teardown::{ALLOWED_PREVIOUS_CIRCUITS, PublicKernelTeardownCircuitPrivateInputs}, utils::{ assert_eq_call_requests, assert_eq_public_data_reads, assert_eq_public_data_update_requests, compute_public_data_reads, compute_public_data_update_requests @@ -160,7 +174,7 @@ mod tests { }; use dep::types::constants::{ MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, BASE_ROLLUP_INDEX }; struct PublicKernelTeardownCircuitPrivateInputsBuilder { @@ -171,7 +185,7 @@ mod tests { impl PublicKernelTeardownCircuitPrivateInputsBuilder { pub fn new() -> Self { - let previous_kernel = FixtureBuilder::new().as_parent_contract(); + let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX); let previous_revertible = FixtureBuilder::new(); let public_call = PublicCallDataBuilder::new(); @@ -582,4 +596,23 @@ mod tests { let public_inputs = builder.execute(); assert_eq(public_inputs.revert_code, 3); } + + #[test] + fn valid_previous_kernel() { + for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + builder.previous_kernel = builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]); + + let _res = builder.execute(); + } + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = PublicKernelTeardownCircuitPrivateInputsBuilder::new(); + + builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr index ef4065bb9ee..8aa79f5b0dd 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr @@ -8,12 +8,7 @@ struct ConstantRollupData { // Archive tree snapshot at the very beginning of the entire rollup. last_archive : AppendOnlyTreeSnapshot, - // TODO(Sean): Some members of this struct tbd - private_kernel_vk_tree_root : Field, - public_kernel_vk_tree_root : Field, - - base_rollup_vk_hash : Field, - merge_rollup_vk_hash : Field, + vk_tree_root : Field, global_variables : GlobalVariables, } @@ -22,10 +17,7 @@ impl Eq for ConstantRollupData { fn eq(self, other : ConstantRollupData) -> bool { self.last_archive.eq(other.last_archive) & self.global_variables.eq(other.global_variables) & - (self.private_kernel_vk_tree_root == other.private_kernel_vk_tree_root) & - (self.public_kernel_vk_tree_root == other.public_kernel_vk_tree_root) & - (self.base_rollup_vk_hash == other.base_rollup_vk_hash) & - (self.merge_rollup_vk_hash == other.merge_rollup_vk_hash) + (self.vk_tree_root == other.vk_tree_root) } } @@ -33,10 +25,7 @@ impl Empty for ConstantRollupData { fn empty() -> Self { ConstantRollupData { last_archive: AppendOnlyTreeSnapshot::zero(), - private_kernel_vk_tree_root: 0, - public_kernel_vk_tree_root: 0, - base_rollup_vk_hash: 0, - merge_rollup_vk_hash: 0, + vk_tree_root: 0, global_variables: GlobalVariables::empty(), } } @@ -47,10 +36,7 @@ impl Serialize for ConstantRollupData { let mut fields: BoundedVec = BoundedVec::new(); fields.extend_from_array(self.last_archive.serialize()); - fields.push(self.private_kernel_vk_tree_root as Field); - fields.push(self.public_kernel_vk_tree_root as Field); - fields.push(self.base_rollup_vk_hash as Field); - fields.push(self.merge_rollup_vk_hash as Field); + fields.push(self.vk_tree_root as Field); fields.extend_from_array(self.global_variables.serialize()); assert_eq(fields.len(), CONSTANT_ROLLUP_DATA_LENGTH); @@ -64,10 +50,7 @@ impl Deserialize for ConstantRollupData { let mut reader = Reader::new(fields); let item = Self { last_archive: reader.read_struct(AppendOnlyTreeSnapshot::deserialize), - private_kernel_vk_tree_root: reader.read(), - public_kernel_vk_tree_root: reader.read(), - base_rollup_vk_hash: reader.read(), - merge_rollup_vk_hash: reader.read(), + vk_tree_root: reader.read(), global_variables: reader.read_struct(GlobalVariables::deserialize), }; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr index a0faee5bfea..8727470a1d6 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr @@ -1,16 +1,16 @@ use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs; use dep::types::{ - constants::ROLLUP_VK_TREE_HEIGHT, + constants::VK_TREE_HEIGHT, recursion::{proof::NestedRecursiveProof, verification_key::VerificationKey, traits::Verifiable}, - traits::Empty, merkle_tree::MembershipWitness + traits::Empty, merkle_tree::MembershipWitness, merkle_tree::membership::assert_check_membership, + utils::arrays::find_index_hint }; struct PreviousRollupData{ base_or_merge_rollup_public_inputs : BaseOrMergeRollupPublicInputs, proof : NestedRecursiveProof, vk : VerificationKey, - vk_index : u32, - vk_sibling_path : MembershipWitness, + vk_witness : MembershipWitness, } impl Verifiable for PreviousRollupData { @@ -31,8 +31,21 @@ impl Empty for PreviousRollupData { base_or_merge_rollup_public_inputs: BaseOrMergeRollupPublicInputs::empty(), proof : NestedRecursiveProof::empty(), vk : VerificationKey::empty(), - vk_index : 0 as u32, - vk_sibling_path : MembershipWitness::empty(), + vk_witness : MembershipWitness::empty(), } } } + +impl PreviousRollupData { + fn validate_in_vk_tree(self, allowed_indices: [u32; N]) { + let index_hint = find_index_hint(allowed_indices, self.vk_witness.leaf_index as u32); + assert_eq(allowed_indices[index_hint], self.vk_witness.leaf_index as u32, "Invalid vk index"); + + assert_check_membership( + self.vk.hash, + self.vk_witness.leaf_index, + self.vk_witness.sibling_path, + self.base_or_merge_rollup_public_inputs.constants.vk_tree_root + ); + } +} diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr index f85e50c1749..52a87dda50c 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -25,7 +25,8 @@ use dep::types::{ MAX_L2_TO_L1_MSGS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_SUBTREE_HEIGHT, PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, ARCHIVE_HEIGHT, GAS_TOKEN_ADDRESS, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PUBLIC_KERNEL_TAIL_INDEX, PRIVATE_KERNEL_EMPTY_INDEX, + PRIVATE_KERNEL_TAIL_INDEX }, merkle_tree::{ append_only_tree, assert_check_membership, calculate_empty_tree_root, calculate_subtree_root, @@ -36,6 +37,12 @@ use dep::types::{ utils::{field::{full_field_less_than, full_field_greater_than}, uint256::U256} }; +global ALLOWED_PREVIOUS_CIRCUITS = [ + PRIVATE_KERNEL_EMPTY_INDEX, + PRIVATE_KERNEL_TAIL_INDEX, + PUBLIC_KERNEL_TAIL_INDEX, +]; + struct BaseRollupInputs { kernel_data: KernelData, start: PartialStateReference, @@ -57,9 +64,11 @@ struct BaseRollupInputs { impl BaseRollupInputs { pub fn base_rollup_circuit(self) -> BaseOrMergeRollupPublicInputs { - // Verify the kernel circuit proof - self.kernel_data.verify(); - + if !dep::std::runtime::is_unconstrained() { + // Verify the kernel circuit proof + self.kernel_data.verify(); + self.kernel_data.validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + } // Verify the kernel chain_id and versions assert( self.kernel_data.public_inputs.constants.tx_context.chain_id @@ -69,6 +78,9 @@ impl BaseRollupInputs { self.kernel_data.public_inputs.constants.tx_context.version == self.constants.global_variables.version, "kernel version does not match the rollup version" ); + assert( + self.kernel_data.public_inputs.constants.vk_tree_root == self.constants.vk_tree_root, "kernel vk_tree_root does not match the rollup vk_tree_root" + ); // Verify the kernel global variables if set, note these can be empty if this is a request coming directly from the private kernel tail. // TODO(@spalladino) How can we check that this is a request coming from the private kernel tail? @@ -440,7 +452,7 @@ mod tests { }, base::{ state_diff_hints::StateDiffHints, - base_rollup_inputs::{BaseRollupInputs, compute_fee_payer_gas_token_balance_leaf_slot} + base_rollup_inputs::{BaseRollupInputs, compute_fee_payer_gas_token_balance_leaf_slot, ALLOWED_PREVIOUS_CIRCUITS} }, components::{TX_EFFECTS_HASH_INPUT_FIELDS, compute_kernel_out_hash} }; @@ -459,7 +471,9 @@ mod tests { NOTE_HASH_TREE_HEIGHT, NOTE_HASH_SUBTREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, MAX_L2_TO_L1_MSGS_PER_TX, - PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + BASE_ROLLUP_INDEX, PRIVATE_KERNEL_EMPTY_INDEX, PRIVATE_KERNEL_TAIL_INDEX, + PUBLIC_KERNEL_TAIL_INDEX }, contract_class_id::ContractClassId, partial_state_reference::PartialStateReference, public_data_tree_leaf::PublicDataTreeLeaf, @@ -596,9 +610,10 @@ mod tests { impl BaseRollupInputsBuilder { fn new() -> Self { let mut inputs = BaseRollupInputsBuilder::empty(); - inputs.kernel_data = FixtureBuilder::new(); + inputs.kernel_data = FixtureBuilder::new().in_vk_tree(PRIVATE_KERNEL_TAIL_INDEX); inputs.constants.global_variables.chain_id = fixtures::CHAIN_ID; inputs.constants.global_variables.version = fixtures::VERSION; + inputs.constants.vk_tree_root = inputs.kernel_data.vk_tree_root; inputs.pre_existing_blocks[0] = inputs.kernel_data.historical_header.hash(); @@ -1408,4 +1423,37 @@ mod tests { builder.fails(); } + + #[test] + fn valid_previous_kernel_empty() { + let mut builder = BaseRollupInputsBuilder::new(); + builder.kernel_data = builder.kernel_data.in_vk_tree(PRIVATE_KERNEL_EMPTY_INDEX); + + let _res = builder.execute(); + } + + #[test] + fn valid_previous_kernel_tail() { + let mut builder = BaseRollupInputsBuilder::new(); + builder.kernel_data = builder.kernel_data.in_vk_tree(PRIVATE_KERNEL_TAIL_INDEX); + + let _res = builder.execute(); + } + + #[test] + fn valid_previous_kernel_public_tail() { + let mut builder = BaseRollupInputsBuilder::new(); + builder.kernel_data = builder.kernel_data.in_vk_tree(PUBLIC_KERNEL_TAIL_INDEX); + + let _res = builder.execute(); + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_kernel() { + let mut builder = BaseRollupInputsBuilder::new(); + + builder.kernel_data = builder.kernel_data.in_vk_tree(BASE_ROLLUP_INDEX); + + let _res = builder.execute(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index 78a138dd4f3..2d817320c42 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -129,7 +129,6 @@ pub fn compute_txs_effects_hash(previous_rollup_data: [PreviousRollupData; 2]) - global TX_EFFECTS_HASH_INPUT_FIELDS = 1 + 1 + MAX_NOTE_HASHES_PER_TX + MAX_NULLIFIERS_PER_TX + MAX_L2_TO_L1_MSGS_PER_TX + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 + 3 + 3; // Computes the tx effects hash for a base rollup (a single transaction) -// TODO(Alvaro): This is too slow for brillig without the array optimization pub fn compute_tx_effects_hash( combined: CombinedAccumulatedData, revert_code: u8, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr index 0fbdc3d22d4..cd04084aec0 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr @@ -1,8 +1,13 @@ -use dep::types::traits::Empty; +use dep::types::{traits::Empty, constants::{BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX}}; use crate::abis::previous_rollup_data::PreviousRollupData; use crate::abis::base_or_merge_rollup_public_inputs::{BaseOrMergeRollupPublicInputs, MERGE_ROLLUP_TYPE}; use crate::components; +global ALLOWED_PREVIOUS_CIRCUITS = [ + BASE_ROLLUP_INDEX, + MERGE_ROLLUP_INDEX, +]; + struct MergeRollupInputs { // TODO(Kev): Why is this 2? previous_rollup_data : [PreviousRollupData; 2] @@ -22,8 +27,13 @@ impl MergeRollupInputs { // we don't have a set of permitted kernel vks yet. // Verify the previous rollup proofs - self.previous_rollup_data[0].verify(); - self.previous_rollup_data[1].verify(); + if !dep::std::runtime::is_unconstrained() { + self.previous_rollup_data[0].verify(); + self.previous_rollup_data[0].validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + + self.previous_rollup_data[1].verify(); + self.previous_rollup_data[1].validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + } let left = self.previous_rollup_data[0].base_or_merge_rollup_public_inputs; let right = self.previous_rollup_data[1].base_or_merge_rollup_public_inputs; @@ -59,6 +69,7 @@ mod tests { tests::merge_rollup_inputs::default_merge_rollup_inputs }; use dep::types::hash::accumulate_sha256; + use dep::types::constants::{ROOT_PARITY_INDEX, MERGE_ROLLUP_INDEX, BASE_ROLLUP_INDEX}; #[test(should_fail_with="The rollup should be filled greedily from L to R, but received a L base and R merge")] fn different_rollup_type_fails() { @@ -71,8 +82,8 @@ mod tests { #[test(should_fail_with="input proofs have different constants")] fn constants_different_fails() { let mut inputs = default_merge_rollup_inputs(); - inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.constants.public_kernel_vk_tree_root = 1; - inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants.public_kernel_vk_tree_root = 0; + inputs.previous_rollup_data[0].base_or_merge_rollup_public_inputs.constants.global_variables.chain_id = 1; + inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants.global_variables.chain_id = 0; let _output = inputs.merge_rollup_circuit(); } @@ -175,4 +186,43 @@ mod tests { inputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants.eq(outputs.constants) ); } + + #[test] + fn valid_previous_circuit_base() { + let mut inputs = default_merge_rollup_inputs(); + + let vk_tree = dep::types::tests::fixtures::vk_tree::get_vk_merkle_tree(); + + inputs.previous_rollup_data[0].vk.hash = vk_tree.leaves[BASE_ROLLUP_INDEX]; + inputs.previous_rollup_data[0].vk_witness.leaf_index = BASE_ROLLUP_INDEX as Field; + inputs.previous_rollup_data[0].vk_witness.sibling_path = vk_tree.get_sibling_path(BASE_ROLLUP_INDEX); + + let _outputs = inputs.merge_rollup_circuit(); + } + + #[test] + fn valid_previous_circuit_merge() { + let mut inputs = default_merge_rollup_inputs(); + + let vk_tree = dep::types::tests::fixtures::vk_tree::get_vk_merkle_tree(); + + inputs.previous_rollup_data[0].vk.hash = vk_tree.leaves[MERGE_ROLLUP_INDEX]; + inputs.previous_rollup_data[0].vk_witness.leaf_index = MERGE_ROLLUP_INDEX as Field; + inputs.previous_rollup_data[0].vk_witness.sibling_path = vk_tree.get_sibling_path(MERGE_ROLLUP_INDEX); + + let _outputs = inputs.merge_rollup_circuit(); + } + + #[test(should_fail_with="Invalid vk index")] + fn invalid_previous_circuit() { + let mut inputs = default_merge_rollup_inputs(); + + let vk_tree = dep::types::tests::fixtures::vk_tree::get_vk_merkle_tree(); + + inputs.previous_rollup_data[0].vk.hash = vk_tree.leaves[ROOT_PARITY_INDEX]; + inputs.previous_rollup_data[0].vk_witness.leaf_index = ROOT_PARITY_INDEX as Field; + inputs.previous_rollup_data[0].vk_witness.sibling_path = vk_tree.get_sibling_path(ROOT_PARITY_INDEX); + + let _outputs = inputs.merge_rollup_circuit(); + } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr index 365d288359c..68c62d126c7 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr @@ -7,13 +7,18 @@ use types::{ abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot, nullifier_leaf_preimage::NullifierLeafPreimage}, constants::{ NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, L1_TO_L2_MSG_SUBTREE_HEIGHT, - L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, ARCHIVE_HEIGHT + L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, ARCHIVE_HEIGHT, BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX }, header::Header, content_commitment::ContentCommitment, merkle_tree::{append_only_tree, calculate_subtree_root, calculate_empty_tree_root}, state_reference::StateReference, traits::Empty }; +global ALLOWED_PREVIOUS_CIRCUITS = [ + BASE_ROLLUP_INDEX, + MERGE_ROLLUP_INDEX, +]; + struct RootRollupInputs { // All below are shared between the base and merge rollups previous_rollup_data : [PreviousRollupData; 2], @@ -34,11 +39,17 @@ struct RootRollupInputs { impl RootRollupInputs { pub fn root_rollup_circuit(self) -> RootRollupPublicInputs { // Verify the previous rollup proofs - self.previous_rollup_data[0].verify(); - self.previous_rollup_data[1].verify(); + if !dep::std::runtime::is_unconstrained() { + self.previous_rollup_data[0].verify(); + self.previous_rollup_data[0].validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); + + self.previous_rollup_data[1].verify(); + self.previous_rollup_data[1].validate_in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS); - // verify the root parity - self.l1_to_l2_roots.verify(); + // verify the root parity + self.l1_to_l2_roots.verify(); + self.l1_to_l2_roots.validate_in_vk_tree(); + } let left = self.previous_rollup_data[0].base_or_merge_rollup_public_inputs; let right = self.previous_rollup_data[1].base_or_merge_rollup_public_inputs; @@ -70,6 +81,8 @@ impl RootRollupInputs { let total_fees = components::accumulate_fees(left, right); + let vk_tree_root = left.constants.vk_tree_root; + let header = Header { last_archive: left.constants.last_archive, content_commitment, @@ -90,7 +103,7 @@ impl RootRollupInputs { 0 ); - RootRollupPublicInputs { archive, header } + RootRollupPublicInputs { archive, header, vk_tree_root } } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr index 301f4b2cd42..40b352a3ff6 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr @@ -4,6 +4,9 @@ struct RootRollupPublicInputs { // Snapshot of archive tree after this block/rollup been processed archive: AppendOnlyTreeSnapshot, + // Root of the protocol circuits VK tree + vk_tree_root: Field, + // New block header header: Header, } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr new file mode 100644 index 00000000000..c15acb6695e --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr @@ -0,0 +1,19 @@ +use dep::types::constants::ROOT_PARITY_INDEX; +use dep::types::tests::fixtures; +use dep::parity_lib::{root::root_rollup_parity_input::RootRollupParityInput, ParityPublicInputs}; + +pub fn default_root_rollup_parity_input() -> RootRollupParityInput { + let mut input = RootRollupParityInput::empty(); + + let vk_index = ROOT_PARITY_INDEX; + let vk_tree = fixtures::vk_tree::get_vk_merkle_tree(); + let vk_hash = vk_tree.leaves[vk_index]; + let vk_path = vk_tree.get_sibling_path(vk_index); + let vk_tree_root = vk_tree.get_root(); + + input.verification_key.hash = vk_hash; + input.vk_path = vk_path; + input.public_inputs.vk_tree_root = vk_tree_root; + + input +} diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/mod.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/mod.nr index 37faca7f824..6008fb5f449 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/mod.nr @@ -1,3 +1,4 @@ mod merge_rollup_inputs; mod root_rollup_inputs; mod previous_rollup_data; +mod l1_to_l2_roots; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr index 52edabc33e6..f41b33dca84 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr @@ -1,10 +1,34 @@ use crate::abis::base_or_merge_rollup_public_inputs::BASE_ROLLUP_TYPE; use crate::abis::previous_rollup_data::PreviousRollupData; +use dep::types::constants::BASE_ROLLUP_INDEX; +use dep::types::tests::fixtures; use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; +use dep::types::merkle_tree::MembershipWitness; pub fn default_previous_rollup_data() -> [PreviousRollupData; 2] { let mut previous_rollup_data = [PreviousRollupData::empty(); 2]; + let vk_index = BASE_ROLLUP_INDEX; + let vk_tree = fixtures::vk_tree::get_vk_merkle_tree(); + let vk_hash = vk_tree.leaves[vk_index]; + let vk_path = vk_tree.get_sibling_path(vk_index); + let vk_tree_root = vk_tree.get_root(); + + previous_rollup_data[0].base_or_merge_rollup_public_inputs.constants.vk_tree_root = vk_tree_root; + previous_rollup_data[1].base_or_merge_rollup_public_inputs.constants.vk_tree_root = vk_tree_root; + + previous_rollup_data[0].vk.hash = vk_hash; + previous_rollup_data[1].vk.hash = vk_hash; + + previous_rollup_data[0].vk_witness = MembershipWitness { + leaf_index: vk_index as Field, + sibling_path: vk_path + }; + previous_rollup_data[1].vk_witness = MembershipWitness { + leaf_index: vk_index as Field, + sibling_path: vk_path + }; + previous_rollup_data[0].base_or_merge_rollup_public_inputs.start.note_hash_tree = AppendOnlyTreeSnapshot { root: 0, next_available_leaf_index: 0 diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/root_rollup_inputs.nr index fec7e28ec22..cdc41a9a1f9 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/root_rollup_inputs.nr @@ -8,6 +8,7 @@ use dep::types::{ tests::merkle_tree_utils::compute_zero_hashes }; use crate::tests::previous_rollup_data::default_previous_rollup_data; +use crate::tests::l1_to_l2_roots::default_root_rollup_parity_input; pub fn compute_l1_l2_empty_snapshot() -> (AppendOnlyTreeSnapshot, [Field; L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH]) { let zero_hashes = compute_zero_hashes([0; L1_TO_L2_MSG_TREE_HEIGHT]); @@ -36,6 +37,9 @@ pub fn compute_archive_snapshot() -> (AppendOnlyTreeSnapshot, [Field; ARCHIVE_HE pub fn default_root_rollup_inputs() -> RootRollupInputs { let mut inputs = RootRollupInputs::empty(); + + inputs.l1_to_l2_roots = default_root_rollup_parity_input(); + let (l1_l2_empty_snapshot, l1_l2_empty_sibling_path) = compute_l1_l2_empty_snapshot(); inputs.l1_to_l2_message_subtree_sibling_path = l1_l2_empty_sibling_path; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr index 7f4496af650..bf4620385c0 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr @@ -13,12 +13,19 @@ struct CombinedConstantData { // protocol to execute and prove the transaction. tx_context: TxContext, + vk_tree_root: Field, + + // Must be empty in private, will be filled in by the public kernel global_variables: GlobalVariables, } impl CombinedConstantData { - pub fn private(historical_header: Header, tx_context: TxContext) -> CombinedConstantData { - CombinedConstantData { historical_header, tx_context, global_variables: GlobalVariables::empty() } + pub fn private( + historical_header: Header, + tx_context: TxContext, + vk_tree_root: Field + ) -> CombinedConstantData { + CombinedConstantData { historical_header, tx_context, vk_tree_root, global_variables: GlobalVariables::empty() } } } @@ -27,6 +34,7 @@ impl Empty for CombinedConstantData { CombinedConstantData { historical_header: Header::empty(), tx_context: TxContext::empty(), + vk_tree_root: 0, global_variables: GlobalVariables::empty() } } @@ -38,6 +46,7 @@ impl Serialize for CombinedConstantData { fields.extend_from_array(self.historical_header.serialize()); fields.extend_from_array(self.tx_context.serialize()); + fields.push(self.vk_tree_root); fields.extend_from_array(self.global_variables.serialize()); assert_eq(fields.len(), COMBINED_CONSTANT_DATA_LENGTH); @@ -53,6 +62,7 @@ impl Deserialize for CombinedConstantData { let item = CombinedConstantData { historical_header: reader.read_struct(Header::deserialize), tx_context: reader.read_struct(TxContext::deserialize), + vk_tree_root: reader.read(), global_variables: reader.read_struct(GlobalVariables::deserialize), }; reader.finish(); @@ -64,6 +74,7 @@ impl Eq for CombinedConstantData { fn eq(self, other: Self) -> bool { (self.historical_header.eq(other.historical_header)) & (self.tx_context.eq(other.tx_context)) & + (self.vk_tree_root.eq(other.vk_tree_root)) & (self.global_variables.eq(other.global_variables)) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr index 5ec42ae4b06..30b4241e89a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr @@ -1,6 +1,8 @@ use crate::constants::VK_TREE_HEIGHT; use crate::abis::kernel_circuit_public_inputs::KernelCircuitPublicInputs; use crate::recursion::{proof::NestedRecursiveProof, verification_key::VerificationKey, traits::Verifiable}; +use crate::merkle_tree::membership::assert_check_membership; +use crate::utils::arrays::find_index_hint; struct KernelData { public_inputs: KernelCircuitPublicInputs, @@ -21,3 +23,17 @@ impl Verifiable for KernelData { ); } } + +impl KernelData { + fn validate_in_vk_tree(self, allowed_indices: [u32; N]) { + let index_hint = find_index_hint(allowed_indices, self.vk_index); + assert_eq(allowed_indices[index_hint], self.vk_index, "Invalid vk index"); + + assert_check_membership( + self.vk.hash, + self.vk_index as Field, + self.vk_path, + self.public_inputs.constants.vk_tree_root + ); + } +} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr index 2493aaba90a..0439e09afc5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr @@ -1,6 +1,8 @@ use crate::recursion::{verification_key::VerificationKey, proof::NestedRecursiveProof, traits::Verifiable}; use crate::constants::VK_TREE_HEIGHT; use crate::abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs; +use crate::merkle_tree::membership::assert_check_membership; +use crate::utils::arrays::find_index_hint; struct PrivateKernelData { // TODO(David): Left a note asking if we need this due to it @@ -17,7 +19,7 @@ struct PrivateKernelData { proof: NestedRecursiveProof, vk: VerificationKey, - // TODO(Mike): left a note saying : this index and path are meant to be those of a leaf within the tree of _kernel circuit_ vks; not the tree + // This index and path are meant to be those of a leaf within the tree of protocol circuits vks; not the tree // of functions within the contract tree. vk_index: u32, vk_path: [Field; VK_TREE_HEIGHT], @@ -34,3 +36,17 @@ impl Verifiable for PrivateKernelData { ); } } + +impl PrivateKernelData { + fn validate_in_vk_tree(self, allowed_indices: [u32; N]) { + let index_hint = find_index_hint(allowed_indices, self.vk_index); + assert_eq(allowed_indices[index_hint], self.vk_index, "Invalid vk index"); + + assert_check_membership( + self.vk.hash, + self.vk_index as Field, + self.vk_path, + self.public_inputs.constants.vk_tree_root + ); + } +} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr index fc6246a321d..1c434a5a7a6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr @@ -1,6 +1,8 @@ use crate::constants::VK_TREE_HEIGHT; use crate::abis::kernel_circuit_public_inputs::{PublicKernelCircuitPublicInputs, KernelCircuitPublicInputs}; use crate::recursion::{proof::NestedRecursiveProof, verification_key::VerificationKey, traits::Verifiable}; +use crate::merkle_tree::membership::assert_check_membership; +use crate::utils::arrays::find_index_hint; struct PublicKernelData { public_inputs: PublicKernelCircuitPublicInputs, @@ -21,3 +23,18 @@ impl Verifiable for PublicKernelData { ); } } + +impl PublicKernelData { + fn validate_in_vk_tree(self, allowed_indices: [u32; N]) { + let index_hint = find_index_hint(allowed_indices, self.vk_index); + assert_eq(allowed_indices[index_hint], self.vk_index, "Invalid vk index"); + + assert_check_membership( + self.vk.hash, + self.vk_index as Field, + self.vk_path, + self.public_inputs.constants.vk_tree_root + ); + } +} + diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index eca27679e02..3216596fb01 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -73,13 +73,12 @@ global MAX_PUBLIC_DATA_HINTS: u32 = 128; global NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP: u32 = 16; // TREES RELATED CONSTANTS -global VK_TREE_HEIGHT: u32 = 3; +global VK_TREE_HEIGHT: u32 = 5; global FUNCTION_TREE_HEIGHT: u32 = 5; global NOTE_HASH_TREE_HEIGHT: u32 = 32; global PUBLIC_DATA_TREE_HEIGHT: u32 = 40; global NULLIFIER_TREE_HEIGHT: u32 = 20; global L1_TO_L2_MSG_TREE_HEIGHT: u32 = 16; -global ROLLUP_VK_TREE_HEIGHT: u32 = 8; global ARTIFACT_FUNCTION_TREE_MAX_HEIGHT = 5; global NULLIFIER_TREE_ID = 0; global NOTE_HASH_TREE_ID = 1; @@ -98,6 +97,27 @@ global PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH: u32 = 34; global L1_TO_L2_MSG_SUBTREE_HEIGHT: u32 = 4; global L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH: u32 = 12; +// VK TREE CONSTANTS +global PRIVATE_KERNEL_INIT_INDEX: u32 = 0; +global PRIVATE_KERNEL_INNER_INDEX: u32 = 1; +global PRIVATE_KERNEL_RESET_FULL_INDEX: u32 = 2; +global PRIVATE_KERNEL_RESET_BIG_INDEX: u32 = 3; +global PRIVATE_KERNEL_RESET_MEDIUM_INDEX: u32 = 4; +global PRIVATE_KERNEL_RESET_SMALL_INDEX: u32 = 5; +global PRIVATE_KERNEL_TAIL_INDEX: u32 = 10; +global PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX: u32 = 11; +global EMPTY_NESTED_INDEX: u32 = 12; +global PRIVATE_KERNEL_EMPTY_INDEX: u32 = 13; +global PUBLIC_KERNEL_SETUP_INDEX: u32 = 14; +global PUBLIC_KERNEL_APP_LOGIC_INDEX: u32 = 15; +global PUBLIC_KERNEL_TEARDOWN_INDEX: u32 = 16; +global PUBLIC_KERNEL_TAIL_INDEX: u32 = 17; +global BASE_PARITY_INDEX: u32 = 18; +global ROOT_PARITY_INDEX: u32 = 19; +global BASE_ROLLUP_INDEX: u32 = 20; +global MERGE_ROLLUP_INDEX: u32 = 21; +global ROOT_ROLLUP_INDEX: u32 = 22; + // MISC CONSTANTS global FUNCTION_SELECTOR_NUM_BYTES: Field = 4; global ARGS_HASH_CHUNK_LENGTH: u32 = 16; @@ -218,7 +238,7 @@ global VALIDATION_REQUESTS_LENGTH = ROLLUP_VALIDATION_REQUESTS_LENGTH + (SCOPED_ global PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; global COMBINED_ACCUMULATED_DATA_LENGTH = MAX_NOTE_HASHES_PER_TX + MAX_NULLIFIERS_PER_TX + MAX_L2_TO_L1_MSGS_PER_TX + 6 + (MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * PUBLIC_DATA_UPDATE_REQUEST_LENGTH) + GAS_LENGTH; -global COMBINED_CONSTANT_DATA_LENGTH = HEADER_LENGTH + TX_CONTEXT_LENGTH + GLOBAL_VARIABLES_LENGTH; +global COMBINED_CONSTANT_DATA_LENGTH = HEADER_LENGTH + TX_CONTEXT_LENGTH + GLOBAL_VARIABLES_LENGTH + 1; global PUBLIC_CALL_STACK_ITEM_COMPRESSED_LENGTH = AZTEC_ADDRESS_LENGTH + CALL_CONTEXT_LENGTH + FUNCTION_DATA_LENGTH + 3 + 2 * GAS_LENGTH; global CALL_REQUEST_LENGTH = 1 + AZTEC_ADDRESS_LENGTH + CALLER_CONTEXT_LENGTH + 2; @@ -230,7 +250,7 @@ global PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = VALIDATION_REQUESTS_LENGTH + global KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = ROLLUP_VALIDATION_REQUESTS_LENGTH + COMBINED_ACCUMULATED_DATA_LENGTH + COMBINED_CONSTANT_DATA_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH + 1 + AZTEC_ADDRESS_LENGTH; -global CONSTANT_ROLLUP_DATA_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 4 + GLOBAL_VARIABLES_LENGTH; +global CONSTANT_ROLLUP_DATA_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 1 + GLOBAL_VARIABLES_LENGTH; // + 5 for rollup_type, height_in_block_tree, txs_effects_hash, out_hash, accumulated_fees global BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = CONSTANT_ROLLUP_DATA_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH + 5; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr index 88e497089a0..43a03fa5af6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr @@ -1,4 +1,5 @@ use crate::traits::Empty; +use crate::merkle_tree::membership::assert_check_membership; struct MerkleTree { leaves: [Field; N], @@ -38,5 +39,36 @@ impl MerkleTree { fn get_root(self) -> Field { self.nodes[N - 2] } + + pub fn sibling_index(index: u32) -> u32 { + if index % 2 == 0 { index + 1 } else { index - 1 } + } + + fn get_sibling_path(self, leaf_index: u32) -> [Field; K] { + assert_eq(2.pow_32(K as Field), N as Field, "Invalid path length"); + + let mut path = [0; K]; + let mut current_index = leaf_index; + let mut subtree_width = N; + + let mut sibling_index = MerkleTree::sibling_index(current_index); + + path[0] = self.leaves[sibling_index]; + + let mut subtree_offset: u32 = 0; + + for i in 1..K { + current_index = current_index / 2; + subtree_width = subtree_width / 2; + + sibling_index = MerkleTree::sibling_index(current_index); + + path[i] = self.nodes[subtree_offset + sibling_index]; + + subtree_offset += subtree_width; + } + + path + } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index fa3397e73b4..0d77ccc15f0 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -127,6 +127,7 @@ struct FixtureBuilder { vk: VerificationKey, vk_index: u32, vk_path: [Field; VK_TREE_HEIGHT], + vk_tree_root: Field, // Counters. min_revertible_side_effect_counter: u32, @@ -176,6 +177,20 @@ impl FixtureBuilder { *self } + pub fn in_vk_tree(&mut self, vk_index: u32) -> Self { + self.vk_index = vk_index; + let vk_tree = fixtures::vk_tree::get_vk_merkle_tree(); + + let vk_hash = vk_tree.leaves[vk_index]; + self.vk.hash = vk_hash; + + self.vk_path = vk_tree.get_sibling_path(vk_index); + + self.vk_tree_root = vk_tree.get_root(); + + *self + } + pub fn is_delegate_call(&mut self) -> Self { self.is_delegate_call = true; self.storage_contract_address = fixtures::contracts::parent_contract.address; @@ -192,6 +207,7 @@ impl FixtureBuilder { CombinedConstantData { historical_header: self.historical_header, tx_context: self.tx_context, + vk_tree_root: self.vk_tree_root, global_variables: self.global_variables } } @@ -438,13 +454,7 @@ impl FixtureBuilder { pub fn to_public_kernel_data(self, revertible: bool) -> PublicKernelData { let public_inputs = self.to_public_kernel_circuit_public_inputs(revertible); - PublicKernelData { - public_inputs, - proof: NestedRecursiveProof::empty(), - vk: VerificationKey::empty(), - vk_index: self.vk_index, - vk_path: self.vk_path - } + PublicKernelData { public_inputs, proof: self.proof, vk: self.vk, vk_index: self.vk_index, vk_path: self.vk_path } } pub fn to_kernel_circuit_public_inputs(self) -> KernelCircuitPublicInputs { @@ -467,7 +477,7 @@ impl FixtureBuilder { KernelData { public_inputs, proof: NestedRecursiveProof::empty(), - vk: VerificationKey::empty(), + vk: self.vk, vk_index: self.vk_index, vk_path: self.vk_path } @@ -1020,6 +1030,10 @@ impl FixtureBuilder { self.counter += 1; counter } + + fn vk_tree_root() -> Field { + fixtures::vk_tree::get_vk_merkle_tree().get_root() + } } impl Empty for FixtureBuilder { @@ -1069,6 +1083,7 @@ impl Empty for FixtureBuilder { vk: VerificationKey::empty(), vk_index: 0, vk_path: [0; VK_TREE_HEIGHT], + vk_tree_root: FixtureBuilder::vk_tree_root(), revert_code: 0, min_revertible_side_effect_counter: 0, counter_start: 0, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr index d30e18d7056..38cb5b48129 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures.nr @@ -1,5 +1,6 @@ mod contract_functions; mod contracts; +mod vk_tree; use crate::{address::AztecAddress, grumpkin_point::GrumpkinPoint}; @@ -10,3 +11,4 @@ global PUBLIC_KEY = GrumpkinPoint { x: 123456789, y: 123456789 }; global CHAIN_ID = 1; global VERSION = 3; + diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr new file mode 100644 index 00000000000..c26f9b12554 --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr @@ -0,0 +1,43 @@ +use crate::constants::{ + VK_TREE_HEIGHT, PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, + PRIVATE_KERNEL_RESET_FULL_INDEX, PRIVATE_KERNEL_RESET_BIG_INDEX, PRIVATE_KERNEL_RESET_MEDIUM_INDEX, + PRIVATE_KERNEL_RESET_SMALL_INDEX, PRIVATE_KERNEL_TAIL_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + EMPTY_NESTED_INDEX, PRIVATE_KERNEL_EMPTY_INDEX, PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, PUBLIC_KERNEL_TEARDOWN_INDEX, PUBLIC_KERNEL_TAIL_INDEX, + BASE_PARITY_INDEX, ROOT_PARITY_INDEX, BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX, ROOT_ROLLUP_INDEX +}; +use crate::merkle_tree::merkle_tree::MerkleTree; + +global VK_TREE_WIDTH = 32; + +#[test] +fn check_vk_tree_width() { + assert_eq(2.pow_32(VK_TREE_HEIGHT as Field), VK_TREE_WIDTH as Field, "Incorrect VK tree width"); +} + +pub fn get_vk_merkle_tree() -> MerkleTree { + let mut leaves = [0; VK_TREE_WIDTH]; + + // Fake VK hashes for testing purposes + leaves[PRIVATE_KERNEL_INIT_INDEX] = 0; + leaves[PRIVATE_KERNEL_INNER_INDEX] = 1; + leaves[PRIVATE_KERNEL_RESET_FULL_INDEX] = 2; + leaves[PRIVATE_KERNEL_RESET_BIG_INDEX] = 3; + leaves[PRIVATE_KERNEL_RESET_MEDIUM_INDEX] = 4; + leaves[PRIVATE_KERNEL_RESET_SMALL_INDEX] = 5; + leaves[PRIVATE_KERNEL_TAIL_INDEX] = 10; + leaves[PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX] = 11; + leaves[EMPTY_NESTED_INDEX] = 12; + leaves[PRIVATE_KERNEL_EMPTY_INDEX] = 13; + leaves[PUBLIC_KERNEL_SETUP_INDEX] = 14; + leaves[PUBLIC_KERNEL_APP_LOGIC_INDEX] = 15; + leaves[PUBLIC_KERNEL_TEARDOWN_INDEX] = 16; + leaves[PUBLIC_KERNEL_TAIL_INDEX] = 17; + leaves[BASE_PARITY_INDEX] = 18; + leaves[ROOT_PARITY_INDEX] = 19; + leaves[BASE_ROLLUP_INDEX] = 20; + leaves[MERGE_ROLLUP_INDEX] = 21; + leaves[ROOT_ROLLUP_INDEX] = 22; + + MerkleTree::new(leaves) +} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr index 5818fb22ace..19a2073001d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr @@ -42,10 +42,6 @@ impl MerkleTree { current_width = current_width / 2; } } - - pub fn sibling_index(index: u32) -> u32 { - if index % 2 == 0 { index + 1 } else { index - 1 } - } } #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr index 179d1f893f3..e3f5439b22c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr @@ -55,6 +55,16 @@ pub fn filter_array_to_bounded_vec(arr: [T; N], should_propagate: [bool; N vec_hint } +unconstrained pub fn find_index_hint(array: [T; N], find: T) -> u32 where T: Eq { + let mut index = 0; + for i in 0..array.len() { + if array[i] == find { + index = i; + } + } + index +} + // Routine which validates that all zero values of an array form a contiguous region at the end, i.e., // of the form: [*,*,*...,0,0,0,0] where any * is non-zero. Note that a full array of non-zero values is // valid. diff --git a/noir-projects/noir-protocol-circuits/index.js b/noir-projects/noir-protocol-circuits/generate_variants.js similarity index 100% rename from noir-projects/noir-protocol-circuits/index.js rename to noir-projects/noir-protocol-circuits/generate_variants.js diff --git a/noir-projects/noir-protocol-circuits/package.json b/noir-projects/noir-protocol-circuits/package.json index 5e0598e8ce7..7edc5e20f5d 100644 --- a/noir-projects/noir-protocol-circuits/package.json +++ b/noir-projects/noir-protocol-circuits/package.json @@ -3,6 +3,8 @@ "version": "0.0.0", "main": "index.js", "dependencies": { + "@aws-sdk/client-s3": "^3.609.0", + "@aws-sdk/credential-providers": "^3.609.0", "@iarna/toml": "^2.2.5" } -} \ No newline at end of file +} diff --git a/noir-projects/noir-protocol-circuits/scripts/generate_vk_json.js b/noir-projects/noir-protocol-circuits/scripts/generate_vk_json.js new file mode 100644 index 00000000000..ee92ebbfd87 --- /dev/null +++ b/noir-projects/noir-protocol-circuits/scripts/generate_vk_json.js @@ -0,0 +1,206 @@ +const path = require("path"); +const fs = require("fs/promises"); +const fs_stream = require("fs"); +const child_process = require("child_process"); + +const { fromIni } = require("@aws-sdk/credential-providers"); +const { S3 } = require("@aws-sdk/client-s3"); + +const crypto = require("crypto"); + +const BB_BIN_PATH = process.env.BB_BIN || "../../barretenberg/cpp/build/bin/bb"; +const BUCKET_NAME = "aztec-ci-artifacts"; +const PREFIX = "protocol"; + +function vkBinaryFileNameForArtifactName(outputFolder, artifactName) { + return path.join(outputFolder, `${artifactName}.vk`); +} + +function vkJsonFileNameForArtifactName(outputFolder, artifactName) { + return path.join(outputFolder, `${artifactName}.vk.json`); +} + +function vkDataFileNameForArtifactName(outputFolder, artifactName) { + return path.join(outputFolder, `${artifactName}.vk.data.json`); +} + +async function getBytecodeHash(artifactPath) { + const { bytecode } = JSON.parse(await fs.readFile(artifactPath)); + return crypto.createHash("md5").update(bytecode).digest("hex"); +} + +function getBarretenbergHash() { + return new Promise((res, rej) => { + const hash = crypto.createHash("md5"); + + const rStream = fs_stream.createReadStream(BB_BIN_PATH); + rStream.on("data", (data) => { + hash.update(data); + }); + rStream.on("end", () => { + res(hash.digest("hex")); + }); + rStream.on("error", (err) => { + rej(err); + }); + }); +} + +async function getNewArtifactHash(artifactPath, outputFolder, artifactName) { + const bytecodeHash = await getBytecodeHash(artifactPath); + const barretenbergHash = await getBarretenbergHash(); + const artifactHash = `${barretenbergHash}-${bytecodeHash}`; + + const vkDataPath = vkDataFileNameForArtifactName(outputFolder, artifactName); + try { + const { artifactHash: previousArtifactHash } = JSON.parse( + await fs.readFile(vkDataPath, "utf8") + ); + if (previousArtifactHash === artifactHash) { + return null; + } else { + console.log( + `Circuit ${artifactName} has changed, old hash ${previousArtifactHash}, new hash ${artifactHash}` + ); + } + } catch (ignored) { + console.log("No on disk vk found for", artifactName); + } + return artifactHash; +} + +async function processArtifact(artifactPath, outputFolder) { + const artifactName = path.basename(artifactPath, ".json"); + + const artifactHash = await getNewArtifactHash( + artifactPath, + outputFolder, + artifactName + ); + if (!artifactHash) { + console.log("Reusing on disk vk for", artifactName); + return; + } + + let vkData = await readVKFromS3(artifactName, artifactHash); + + if (!vkData) { + vkData = await generateVKData( + artifactName, + outputFolder, + artifactPath, + artifactHash + ); + await writeVKToS3(artifactName, artifactHash, JSON.stringify(vkData)); + } else { + console.log("Using VK from remote cache for", artifactName); + } + + await fs.writeFile( + vkDataFileNameForArtifactName(outputFolder, artifactName), + JSON.stringify(vkData, null, 2) + ); +} + +async function generateVKData( + artifactName, + outputFolder, + artifactPath, + artifactHash +) { + console.log("Generating new vk for", artifactName); + + const binaryVkPath = vkBinaryFileNameForArtifactName( + outputFolder, + artifactName + ); + const jsonVkPath = vkJsonFileNameForArtifactName(outputFolder, artifactName); + + const writeVkCommand = `${BB_BIN_PATH} write_vk -b "${artifactPath}" -o "${binaryVkPath}"`; + + const vkAsFieldsCommand = `${BB_BIN_PATH} vk_as_fields -k "${binaryVkPath}" -o "${jsonVkPath}"`; + + await new Promise((resolve, reject) => { + child_process.exec(`${writeVkCommand} && ${vkAsFieldsCommand}`, (err) => { + if (err) { + reject(err); + } else { + resolve(); + } + }); + }); + const binaryVk = await fs.readFile(binaryVkPath); + const jsonVk = JSON.parse(await fs.readFile(jsonVkPath, "utf8")); + await fs.unlink(jsonVkPath); + await fs.unlink(binaryVkPath); + + const vkData = { + keyAsBytes: binaryVk.toString("hex"), + keyAsFields: jsonVk, + artifactHash, + }; + console.log("Generated vk for", artifactName); + + return vkData; +} + +async function main() { + let [artifactPath, outputFolder] = process.argv.slice(2); + if (!artifactPath || !outputFolder) { + console.log( + "Usage: node generate_vk_json.js " + ); + return; + } + processArtifact(artifactPath, outputFolder); +} + +function generateS3Client() { + return new S3({ + credentials: fromIni({ + profile: "default", + }), + region: "us-east-2", + }); +} + +async function writeVKToS3(artifactName, artifactHash, body) { + if (process.env.DISABLE_VK_S3_CACHE) { + return; + } + try { + const s3 = generateS3Client(); + await s3.putObject({ + Bucket: BUCKET_NAME, + Key: `${PREFIX}/${artifactName}-${artifactHash}.json`, + Body: body, + }); + } catch (err) { + console.warn("Could not write to S3 VK remote cache", err.message); + } +} + +async function readVKFromS3(artifactName, artifactHash) { + if (process.env.DISABLE_VK_S3_CACHE) { + return; + } + + try { + const s3 = generateS3Client(); + const { Body: response } = await s3.getObject({ + Bucket: BUCKET_NAME, + Key: `${PREFIX}/${artifactName}-${artifactHash}.json`, + }); + + const result = JSON.parse(await response.transformToString()); + return result; + } catch (err) { + console.warn("Could not read VK from remote cache", err.message); + return undefined; + } +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/noir-projects/noir-protocol-circuits/yarn.lock b/noir-projects/noir-protocol-circuits/yarn.lock index f411a21e2d6..cd744e32635 100644 --- a/noir-projects/noir-protocol-circuits/yarn.lock +++ b/noir-projects/noir-protocol-circuits/yarn.lock @@ -2,7 +2,1193 @@ # yarn lockfile v1 +"@aws-crypto/crc32@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/crc32/-/crc32-5.2.0.tgz#cfcc22570949c98c6689cfcbd2d693d36cdae2e1" + integrity sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg== + dependencies: + "@aws-crypto/util" "^5.2.0" + "@aws-sdk/types" "^3.222.0" + tslib "^2.6.2" + +"@aws-crypto/crc32c@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/crc32c/-/crc32c-5.2.0.tgz#4e34aab7f419307821509a98b9b08e84e0c1917e" + integrity sha512-+iWb8qaHLYKrNvGRbiYRHSdKRWhto5XlZUEBwDjYNf+ly5SVYG6zEoYIdxvf5R3zyeP16w4PLBn3rH1xc74Rag== + dependencies: + "@aws-crypto/util" "^5.2.0" + "@aws-sdk/types" "^3.222.0" + tslib "^2.6.2" + +"@aws-crypto/sha1-browser@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/sha1-browser/-/sha1-browser-5.2.0.tgz#b0ee2d2821d3861f017e965ef3b4cb38e3b6a0f4" + integrity sha512-OH6lveCFfcDjX4dbAvCFSYUjJZjDr/3XJ3xHtjn3Oj5b9RjojQo8npoLeA/bNwkOkrSQ0wgrHzXk4tDRxGKJeg== + dependencies: + "@aws-crypto/supports-web-crypto" "^5.2.0" + "@aws-crypto/util" "^5.2.0" + "@aws-sdk/types" "^3.222.0" + "@aws-sdk/util-locate-window" "^3.0.0" + "@smithy/util-utf8" "^2.0.0" + tslib "^2.6.2" + +"@aws-crypto/sha256-browser@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/sha256-browser/-/sha256-browser-5.2.0.tgz#153895ef1dba6f9fce38af550e0ef58988eb649e" + integrity sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw== + dependencies: + "@aws-crypto/sha256-js" "^5.2.0" + "@aws-crypto/supports-web-crypto" "^5.2.0" + "@aws-crypto/util" "^5.2.0" + "@aws-sdk/types" "^3.222.0" + "@aws-sdk/util-locate-window" "^3.0.0" + "@smithy/util-utf8" "^2.0.0" + tslib "^2.6.2" + +"@aws-crypto/sha256-js@5.2.0", "@aws-crypto/sha256-js@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz#c4fdb773fdbed9a664fc1a95724e206cf3860042" + integrity sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA== + dependencies: + "@aws-crypto/util" "^5.2.0" + "@aws-sdk/types" "^3.222.0" + tslib "^2.6.2" + +"@aws-crypto/supports-web-crypto@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/supports-web-crypto/-/supports-web-crypto-5.2.0.tgz#a1e399af29269be08e695109aa15da0a07b5b5fb" + integrity sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg== + dependencies: + tslib "^2.6.2" + +"@aws-crypto/util@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@aws-crypto/util/-/util-5.2.0.tgz#71284c9cffe7927ddadac793c14f14886d3876da" + integrity sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ== + dependencies: + "@aws-sdk/types" "^3.222.0" + "@smithy/util-utf8" "^2.0.0" + tslib "^2.6.2" + +"@aws-sdk/client-cognito-identity@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.609.0.tgz#839796c9ada529bf1fdbac4153e4191df55fefcc" + integrity sha512-3kDTpia1iN/accayoH3MbZRbDvX2tzrKrBTU7wNNoazVrh+gOMS8KCOWrOB72F0V299l4FsfQhnl9BDMVrc1iw== + dependencies: + "@aws-crypto/sha256-browser" "5.2.0" + "@aws-crypto/sha256-js" "5.2.0" + "@aws-sdk/client-sso-oidc" "3.609.0" + "@aws-sdk/client-sts" "3.609.0" + "@aws-sdk/core" "3.609.0" + "@aws-sdk/credential-provider-node" "3.609.0" + "@aws-sdk/middleware-host-header" "3.609.0" + "@aws-sdk/middleware-logger" "3.609.0" + "@aws-sdk/middleware-recursion-detection" "3.609.0" + "@aws-sdk/middleware-user-agent" "3.609.0" + "@aws-sdk/region-config-resolver" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-endpoints" "3.609.0" + "@aws-sdk/util-user-agent-browser" "3.609.0" + "@aws-sdk/util-user-agent-node" "3.609.0" + "@smithy/config-resolver" "^3.0.4" + "@smithy/core" "^2.2.4" + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/hash-node" "^3.0.3" + "@smithy/invalid-dependency" "^3.0.3" + "@smithy/middleware-content-length" "^3.0.3" + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-retry" "^3.0.7" + "@smithy/middleware-serde" "^3.0.3" + "@smithy/middleware-stack" "^3.0.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + "@smithy/util-base64" "^3.0.0" + "@smithy/util-body-length-browser" "^3.0.0" + "@smithy/util-body-length-node" "^3.0.0" + "@smithy/util-defaults-mode-browser" "^3.0.7" + "@smithy/util-defaults-mode-node" "^3.0.7" + "@smithy/util-endpoints" "^2.0.4" + "@smithy/util-middleware" "^3.0.3" + "@smithy/util-retry" "^3.0.3" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/client-s3@^3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/client-s3/-/client-s3-3.609.0.tgz#bf1b9ea83f2e648452273e8739d833ff936341cf" + integrity sha512-lh8NxL9qm8eSphEcsTGjNMArYRlga4yTZCr3d7UPCRFiV1oz3e0EIA5EnxSriYi9P5Houi5d9GSWtPOel2mAow== + dependencies: + "@aws-crypto/sha1-browser" "5.2.0" + "@aws-crypto/sha256-browser" "5.2.0" + "@aws-crypto/sha256-js" "5.2.0" + "@aws-sdk/client-sso-oidc" "3.609.0" + "@aws-sdk/client-sts" "3.609.0" + "@aws-sdk/core" "3.609.0" + "@aws-sdk/credential-provider-node" "3.609.0" + "@aws-sdk/middleware-bucket-endpoint" "3.609.0" + "@aws-sdk/middleware-expect-continue" "3.609.0" + "@aws-sdk/middleware-flexible-checksums" "3.609.0" + "@aws-sdk/middleware-host-header" "3.609.0" + "@aws-sdk/middleware-location-constraint" "3.609.0" + "@aws-sdk/middleware-logger" "3.609.0" + "@aws-sdk/middleware-recursion-detection" "3.609.0" + "@aws-sdk/middleware-sdk-s3" "3.609.0" + "@aws-sdk/middleware-signing" "3.609.0" + "@aws-sdk/middleware-ssec" "3.609.0" + "@aws-sdk/middleware-user-agent" "3.609.0" + "@aws-sdk/region-config-resolver" "3.609.0" + "@aws-sdk/signature-v4-multi-region" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-endpoints" "3.609.0" + "@aws-sdk/util-user-agent-browser" "3.609.0" + "@aws-sdk/util-user-agent-node" "3.609.0" + "@aws-sdk/xml-builder" "3.609.0" + "@smithy/config-resolver" "^3.0.4" + "@smithy/core" "^2.2.4" + "@smithy/eventstream-serde-browser" "^3.0.4" + "@smithy/eventstream-serde-config-resolver" "^3.0.3" + "@smithy/eventstream-serde-node" "^3.0.4" + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/hash-blob-browser" "^3.1.2" + "@smithy/hash-node" "^3.0.3" + "@smithy/hash-stream-node" "^3.1.2" + "@smithy/invalid-dependency" "^3.0.3" + "@smithy/md5-js" "^3.0.3" + "@smithy/middleware-content-length" "^3.0.3" + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-retry" "^3.0.7" + "@smithy/middleware-serde" "^3.0.3" + "@smithy/middleware-stack" "^3.0.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + "@smithy/util-base64" "^3.0.0" + "@smithy/util-body-length-browser" "^3.0.0" + "@smithy/util-body-length-node" "^3.0.0" + "@smithy/util-defaults-mode-browser" "^3.0.7" + "@smithy/util-defaults-mode-node" "^3.0.7" + "@smithy/util-endpoints" "^2.0.4" + "@smithy/util-retry" "^3.0.3" + "@smithy/util-stream" "^3.0.5" + "@smithy/util-utf8" "^3.0.0" + "@smithy/util-waiter" "^3.1.2" + tslib "^2.6.2" + +"@aws-sdk/client-sso-oidc@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.609.0.tgz#66b3cdf6c1ede12423046ea0d0b5889655565e1a" + integrity sha512-0bNPAyPdkWkS9EGB2A9BZDkBNrnVCBzk5lYRezoT4K3/gi9w1DTYH5tuRdwaTZdxW19U1mq7CV0YJJARKO1L9Q== + dependencies: + "@aws-crypto/sha256-browser" "5.2.0" + "@aws-crypto/sha256-js" "5.2.0" + "@aws-sdk/core" "3.609.0" + "@aws-sdk/credential-provider-node" "3.609.0" + "@aws-sdk/middleware-host-header" "3.609.0" + "@aws-sdk/middleware-logger" "3.609.0" + "@aws-sdk/middleware-recursion-detection" "3.609.0" + "@aws-sdk/middleware-user-agent" "3.609.0" + "@aws-sdk/region-config-resolver" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-endpoints" "3.609.0" + "@aws-sdk/util-user-agent-browser" "3.609.0" + "@aws-sdk/util-user-agent-node" "3.609.0" + "@smithy/config-resolver" "^3.0.4" + "@smithy/core" "^2.2.4" + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/hash-node" "^3.0.3" + "@smithy/invalid-dependency" "^3.0.3" + "@smithy/middleware-content-length" "^3.0.3" + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-retry" "^3.0.7" + "@smithy/middleware-serde" "^3.0.3" + "@smithy/middleware-stack" "^3.0.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + "@smithy/util-base64" "^3.0.0" + "@smithy/util-body-length-browser" "^3.0.0" + "@smithy/util-body-length-node" "^3.0.0" + "@smithy/util-defaults-mode-browser" "^3.0.7" + "@smithy/util-defaults-mode-node" "^3.0.7" + "@smithy/util-endpoints" "^2.0.4" + "@smithy/util-middleware" "^3.0.3" + "@smithy/util-retry" "^3.0.3" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/client-sso@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/client-sso/-/client-sso-3.609.0.tgz#2a99166694b64947ba5b7453f057772bd3bba5b8" + integrity sha512-gqXGFDkIpKHCKAbeJK4aIDt3tiwJ26Rf5Tqw9JS6BYXsdMeOB8FTzqD9R+Yc1epHd8s5L94sdqXT5PapgxFZrg== + dependencies: + "@aws-crypto/sha256-browser" "5.2.0" + "@aws-crypto/sha256-js" "5.2.0" + "@aws-sdk/core" "3.609.0" + "@aws-sdk/middleware-host-header" "3.609.0" + "@aws-sdk/middleware-logger" "3.609.0" + "@aws-sdk/middleware-recursion-detection" "3.609.0" + "@aws-sdk/middleware-user-agent" "3.609.0" + "@aws-sdk/region-config-resolver" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-endpoints" "3.609.0" + "@aws-sdk/util-user-agent-browser" "3.609.0" + "@aws-sdk/util-user-agent-node" "3.609.0" + "@smithy/config-resolver" "^3.0.4" + "@smithy/core" "^2.2.4" + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/hash-node" "^3.0.3" + "@smithy/invalid-dependency" "^3.0.3" + "@smithy/middleware-content-length" "^3.0.3" + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-retry" "^3.0.7" + "@smithy/middleware-serde" "^3.0.3" + "@smithy/middleware-stack" "^3.0.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + "@smithy/util-base64" "^3.0.0" + "@smithy/util-body-length-browser" "^3.0.0" + "@smithy/util-body-length-node" "^3.0.0" + "@smithy/util-defaults-mode-browser" "^3.0.7" + "@smithy/util-defaults-mode-node" "^3.0.7" + "@smithy/util-endpoints" "^2.0.4" + "@smithy/util-middleware" "^3.0.3" + "@smithy/util-retry" "^3.0.3" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/client-sts@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/client-sts/-/client-sts-3.609.0.tgz#ac373baf1d4c02adcf6162f0a6f099607046a44c" + integrity sha512-A0B3sDKFoFlGo8RYRjDBWHXpbgirer2bZBkCIzhSPHc1vOFHt/m2NcUoE2xnBKXJFrptL1xDkvo1P+XYp/BfcQ== + dependencies: + "@aws-crypto/sha256-browser" "5.2.0" + "@aws-crypto/sha256-js" "5.2.0" + "@aws-sdk/client-sso-oidc" "3.609.0" + "@aws-sdk/core" "3.609.0" + "@aws-sdk/credential-provider-node" "3.609.0" + "@aws-sdk/middleware-host-header" "3.609.0" + "@aws-sdk/middleware-logger" "3.609.0" + "@aws-sdk/middleware-recursion-detection" "3.609.0" + "@aws-sdk/middleware-user-agent" "3.609.0" + "@aws-sdk/region-config-resolver" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-endpoints" "3.609.0" + "@aws-sdk/util-user-agent-browser" "3.609.0" + "@aws-sdk/util-user-agent-node" "3.609.0" + "@smithy/config-resolver" "^3.0.4" + "@smithy/core" "^2.2.4" + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/hash-node" "^3.0.3" + "@smithy/invalid-dependency" "^3.0.3" + "@smithy/middleware-content-length" "^3.0.3" + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-retry" "^3.0.7" + "@smithy/middleware-serde" "^3.0.3" + "@smithy/middleware-stack" "^3.0.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + "@smithy/util-base64" "^3.0.0" + "@smithy/util-body-length-browser" "^3.0.0" + "@smithy/util-body-length-node" "^3.0.0" + "@smithy/util-defaults-mode-browser" "^3.0.7" + "@smithy/util-defaults-mode-node" "^3.0.7" + "@smithy/util-endpoints" "^2.0.4" + "@smithy/util-middleware" "^3.0.3" + "@smithy/util-retry" "^3.0.3" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/core@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/core/-/core-3.609.0.tgz#4c3994cd341452d1ef1a8b5e81a16442a7422287" + integrity sha512-ptqw+DTxLr01+pKjDUuo53SEDzI+7nFM3WfQaEo0yhDg8vWw8PER4sWj1Ysx67ksctnZesPUjqxd5SHbtdBxiA== + dependencies: + "@smithy/core" "^2.2.4" + "@smithy/protocol-http" "^4.0.3" + "@smithy/signature-v4" "^3.1.2" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + fast-xml-parser "4.2.5" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-cognito-identity@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.609.0.tgz#15cb5af87dd3c98b49112e7315643c871b9cb964" + integrity sha512-BqrpAXRr64dQ/uZsRB2wViGKTkVRlfp8Q+Zd7Bc8Ikk+YXjPtl+IyWXKtdKQ3LBO255KwAcPmra5oFC+2R1GOQ== + dependencies: + "@aws-sdk/client-cognito-identity" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-env@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-env/-/credential-provider-env-3.609.0.tgz#b3f32e5a8ff8b541e151eadadfb60283aa3d835e" + integrity sha512-v69ZCWcec2iuV9vLVJMa6fAb5xwkzN4jYIT8yjo2c4Ia/j976Q+TPf35Pnz5My48Xr94EFcaBazrWedF+kwfuQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-http@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-http/-/credential-provider-http-3.609.0.tgz#836c042a012bf1b9ff9df9ae9e3d876bb492c82e" + integrity sha512-GQQfB9Mk4XUZwaPsk4V3w8MqleS6ApkZKVQn3vTLAKa8Y7B2Imcpe5zWbKYjDd8MPpMWjHcBGFTVlDRFP4zwSQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/property-provider" "^3.1.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/util-stream" "^3.0.5" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-ini@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.609.0.tgz#5b569a7fb8cddd0fecb1dd6444ae0599fb27121e" + integrity sha512-hwaBfXuBTv6/eAdEsDfGcteYUW6Km7lvvubbxEdxIuJNF3vswR7RMGIXaEC37hhPkTTgd3H0TONammhwZIfkog== + dependencies: + "@aws-sdk/credential-provider-env" "3.609.0" + "@aws-sdk/credential-provider-http" "3.609.0" + "@aws-sdk/credential-provider-process" "3.609.0" + "@aws-sdk/credential-provider-sso" "3.609.0" + "@aws-sdk/credential-provider-web-identity" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@smithy/credential-provider-imds" "^3.1.3" + "@smithy/property-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-node@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-node/-/credential-provider-node-3.609.0.tgz#9abcf6c9104310cc4fba70d95f0b9029ba54dea9" + integrity sha512-4J8/JRuqfxJDGD9jTHVCBxCvYt7/Vgj2Stlhj930mrjFPO/yRw8ilAAZxBWe0JHPX3QwepCmh4ErZe53F5ysxQ== + dependencies: + "@aws-sdk/credential-provider-env" "3.609.0" + "@aws-sdk/credential-provider-http" "3.609.0" + "@aws-sdk/credential-provider-ini" "3.609.0" + "@aws-sdk/credential-provider-process" "3.609.0" + "@aws-sdk/credential-provider-sso" "3.609.0" + "@aws-sdk/credential-provider-web-identity" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@smithy/credential-provider-imds" "^3.1.3" + "@smithy/property-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-process@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-process/-/credential-provider-process-3.609.0.tgz#2bfa160eec4be8532a45061810466ee3462ce240" + integrity sha512-Ux35nGOSJKZWUIM3Ny0ROZ8cqPRUEkh+tR3X2o9ydEbFiLq3eMMyEnHJqx4EeUjLRchidlm4CCid9GxMe5/gdw== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-sso@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.609.0.tgz#94da403a000060700a34ee62fcf119fd4cacf167" + integrity sha512-oQPGDKMMIxjvTcm86g07RPYeC7mCNk+29dPpY15ZAPRpAF7F0tircsC3wT9fHzNaKShEyK5LuI5Kg/uxsdy+Iw== + dependencies: + "@aws-sdk/client-sso" "3.609.0" + "@aws-sdk/token-providers" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-provider-web-identity@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.609.0.tgz#d29222d6894347ee89c781ea090d388656df1d2a" + integrity sha512-U+PG8NhlYYF45zbr1km3ROtBMYqyyj/oK8NRp++UHHeuavgrP+4wJ4wQnlEaKvJBjevfo3+dlIBcaeQ7NYejWg== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/credential-providers@^3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/credential-providers/-/credential-providers-3.609.0.tgz#e35489f21f99b9908a229ba59925c3386a08f67c" + integrity sha512-bJKMY4QwRVderh8R2s9kukoZhuNZew/xzwPa9DRRFVOIsznsS0faAdmAAFrKb8e06YyQq6DiZP0BfFyVHAXE2A== + dependencies: + "@aws-sdk/client-cognito-identity" "3.609.0" + "@aws-sdk/client-sso" "3.609.0" + "@aws-sdk/client-sts" "3.609.0" + "@aws-sdk/credential-provider-cognito-identity" "3.609.0" + "@aws-sdk/credential-provider-env" "3.609.0" + "@aws-sdk/credential-provider-http" "3.609.0" + "@aws-sdk/credential-provider-ini" "3.609.0" + "@aws-sdk/credential-provider-node" "3.609.0" + "@aws-sdk/credential-provider-process" "3.609.0" + "@aws-sdk/credential-provider-sso" "3.609.0" + "@aws-sdk/credential-provider-web-identity" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@smithy/credential-provider-imds" "^3.1.3" + "@smithy/property-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-bucket-endpoint@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-bucket-endpoint/-/middleware-bucket-endpoint-3.609.0.tgz#f6f1e366c1816292d6e78866653c6e7122b7932f" + integrity sha512-QhHRfr4e7FqaMUAnOAFdQVOR3yDLw40i1IZPo+TeiKyev9LEyYEX2l6DbdaIwAztofOpAxfFNj/IJ0V/efzz/w== + dependencies: + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-arn-parser" "3.568.0" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + "@smithy/util-config-provider" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-expect-continue@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-expect-continue/-/middleware-expect-continue-3.609.0.tgz#89af76f115aa5fadd5a82fe4e95a64cb15150517" + integrity sha512-+zeg//mSer4JZRxOB/4mUOMUJyuYPwATnIC5moBB8P8Xe+mJaVRFy8qlCtzYNj2TycnlsBPzTK0j7P1yvDh97w== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-flexible-checksums@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-flexible-checksums/-/middleware-flexible-checksums-3.609.0.tgz#3bcd54d64e65808f2053d5a38053625cacb5464a" + integrity sha512-TJ4WE+ehT+qcrhr7/yJCzmJJPmUoPPWIbCnFzqGxauH/dpVBCslmd1vZg3h2VnfRiaDkc6f68dqYVc29CaurhQ== + dependencies: + "@aws-crypto/crc32" "5.2.0" + "@aws-crypto/crc32c" "5.2.0" + "@aws-sdk/types" "3.609.0" + "@smithy/is-array-buffer" "^3.0.0" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-host-header@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-host-header/-/middleware-host-header-3.609.0.tgz#844302cb905e4d09b9a1ea4bfa96729833068913" + integrity sha512-iTKfo158lc4jLDfYeZmYMIBHsn8m6zX+XB6birCSNZ/rrlzAkPbGE43CNdKfvjyWdqgLMRXF+B+OcZRvqhMXPQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-location-constraint@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-location-constraint/-/middleware-location-constraint-3.609.0.tgz#7ed82d71e5ddcd50683ef2bbde10d1cc2492057e" + integrity sha512-xzsdoTkszGVqGVPjUmgoP7TORiByLueMHieI1fhQL888WPdqctwAx3ES6d/bA9Q/i8jnc6hs+Fjhy8UvBTkE9A== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-logger@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-logger/-/middleware-logger-3.609.0.tgz#ed44d201f091b8bac908cbf14724c7a4d492553f" + integrity sha512-S62U2dy4jMDhDFDK5gZ4VxFdWzCtLzwbYyFZx2uvPYTECkepLUfzLic2BHg2Qvtu4QjX+oGE3P/7fwaGIsGNuQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-recursion-detection@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.609.0.tgz#b7b869aaeac021a43dbea1435eaea81e5d2460b1" + integrity sha512-6sewsYB7/o/nbUfA99Aa/LokM+a/u4Wpm/X2o0RxOsDtSB795ObebLJe2BxY5UssbGaWkn7LswyfvrdZNXNj1w== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-sdk-s3@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.609.0.tgz#a743bd63adf786c7c6d4b9102946b67a5032d1f4" + integrity sha512-kvwjL6OJFhAGWoYaIWR7HmILjiVk6xVj6QEU6qZMA7FtGgvlKi4pLfs8Of+hQqo+2TEhUoxG/5t6WqwB8uxjsw== + dependencies: + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-arn-parser" "3.568.0" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/signature-v4" "^3.1.2" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/util-config-provider" "^3.0.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-signing@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-signing/-/middleware-signing-3.609.0.tgz#7e5c4e70302bf87a7aa3dfde83ec1b387bf819f0" + integrity sha512-2w3dBLjQVKIajYzokO4hduq8/0hSMUYHHmIo1Kdl+MSY8uwRBt12bLL6pyreobTcRMxizvn2ph/CQ9I1ST/WGQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/signature-v4" "^3.1.2" + "@smithy/types" "^3.3.0" + "@smithy/util-middleware" "^3.0.3" + tslib "^2.6.2" + +"@aws-sdk/middleware-ssec@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-ssec/-/middleware-ssec-3.609.0.tgz#b87a8bc6133f3f6bdc6801183d0f9dad3f93cf9f" + integrity sha512-GZSD1s7+JswWOTamVap79QiDaIV7byJFssBW68GYjyRS5EBjNfwA/8s+6uE6g39R3ojyTbYOmvcANoZEhSULXg== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/middleware-user-agent@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.609.0.tgz#eb3b7c604817be42f7ecd97988dda69a22e6011b" + integrity sha512-nbq7MXRmeXm4IDqh+sJRAxGPAq0OfGmGIwKvJcw66hLoG8CmhhVMZmIAEBDFr57S+YajGwnLLRt+eMI05MMeVA== + dependencies: + "@aws-sdk/types" "3.609.0" + "@aws-sdk/util-endpoints" "3.609.0" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/region-config-resolver@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/region-config-resolver/-/region-config-resolver-3.609.0.tgz#68fe568d1c69f35f7fa3d66f718bd5751b1debda" + integrity sha512-lMHBG8zg9GWYBc9/XVPKyuAUd7iKqfPP7z04zGta2kGNOKbUTeqmAdc1gJGku75p4kglIPlGBorOxti8DhRmKw== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + "@smithy/util-config-provider" "^3.0.0" + "@smithy/util-middleware" "^3.0.3" + tslib "^2.6.2" + +"@aws-sdk/signature-v4-multi-region@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.609.0.tgz#c88c4a25713bd50b7b253d611e3d2473258087eb" + integrity sha512-FJs0BxVMyYOKNu7nzFI1kehfgWoYmdto5B8BSS29geUACF7jlOoeCfNZWVrnMjvAxVlSQ5O7Mr575932BnsycA== + dependencies: + "@aws-sdk/middleware-sdk-s3" "3.609.0" + "@aws-sdk/types" "3.609.0" + "@smithy/protocol-http" "^4.0.3" + "@smithy/signature-v4" "^3.1.2" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/token-providers@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/token-providers/-/token-providers-3.609.0.tgz#cfa9cdc84fefe71277c7d44b08b09f42c16c1d66" + integrity sha512-WvhW/7XSf+H7YmtiIigQxfDVZVZI7mbKikQ09YpzN7FeN3TmYib1+0tB+EE9TbICkwssjiFc71FEBEh4K9grKQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/property-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/types@3.609.0", "@aws-sdk/types@^3.222.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.609.0.tgz#06b39d799c9f197a7b43670243e8e78a3bf7d6a5" + integrity sha512-+Tqnh9w0h2LcrUsdXyT1F8mNhXz+tVYBtP19LpeEGntmvHwa2XzvLUCWpoIAIVsHp5+HdB2X9Sn0KAtmbFXc2Q== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/util-arn-parser@3.568.0": + version "3.568.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/util-arn-parser/-/util-arn-parser-3.568.0.tgz#6a19a8c6bbaa520b6be1c278b2b8c17875b91527" + integrity sha512-XUKJWWo+KOB7fbnPP0+g/o5Ulku/X53t7i/h+sPHr5xxYTJJ9CYnbToo95mzxe7xWvkLrsNtJ8L+MnNn9INs2w== + dependencies: + tslib "^2.6.2" + +"@aws-sdk/util-endpoints@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/util-endpoints/-/util-endpoints-3.609.0.tgz#e02d3fce2f999d750828dacf9f37289a1a48f6c9" + integrity sha512-Rh+3V8dOvEeE1aQmUy904DYWtLUEJ7Vf5XBPlQ6At3pBhp+zpXbsnpZzVL33c8lW1xfj6YPwtO6gOeEsl1juCQ== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/types" "^3.3.0" + "@smithy/util-endpoints" "^2.0.4" + tslib "^2.6.2" + +"@aws-sdk/util-locate-window@^3.0.0": + version "3.568.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/util-locate-window/-/util-locate-window-3.568.0.tgz#2acc4b2236af0d7494f7e517401ba6b3c4af11ff" + integrity sha512-3nh4TINkXYr+H41QaPelCceEB2FXP3fxp93YZXB/kqJvX0U9j0N0Uk45gvsjmEPzG8XxkPEeLIfT2I1M7A6Lig== + dependencies: + tslib "^2.6.2" + +"@aws-sdk/util-user-agent-browser@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.609.0.tgz#aa15421b2e32ae8bc589dac2bd6e8969832ce588" + integrity sha512-fojPU+mNahzQ0YHYBsx0ZIhmMA96H+ZIZ665ObU9tl+SGdbLneVZVikGve+NmHTQwHzwkFsZYYnVKAkreJLAtA== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/types" "^3.3.0" + bowser "^2.11.0" + tslib "^2.6.2" + +"@aws-sdk/util-user-agent-node@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.609.0.tgz#f8270517b2961cbf627e4e8fb6338ad153db44bb" + integrity sha512-DlZBwQ/HkZyf3pOWc7+wjJRk5R7x9YxHhs2szHwtv1IW30KMabjjjX0GMlGJ9LLkBHkbaaEY/w9Tkj12XRLhRg== + dependencies: + "@aws-sdk/types" "3.609.0" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@aws-sdk/xml-builder@3.609.0": + version "3.609.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/xml-builder/-/xml-builder-3.609.0.tgz#eeb3d5cde000a23cfeeefe0354b6193440dc7d87" + integrity sha512-l9XxNcA4HX98rwCC2/KoiWcmEiRfZe4G+mYwDbCFT87JIMj6GBhLDkAzr/W8KAaA2IDr8Vc6J8fZPgVulxxfMA== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + "@iarna/toml@^2.2.5": version "2.2.5" resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== + +"@smithy/abort-controller@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@smithy/abort-controller/-/abort-controller-3.1.1.tgz#291210611ff6afecfc198d0ca72d5771d8461d16" + integrity sha512-MBJBiidoe+0cTFhyxT8g+9g7CeVccLM0IOKKUMCNQ1CNMJ/eIfoo0RTfVrXOONEI1UCN1W+zkiHSbzUNE9dZtQ== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/chunked-blob-reader-native@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/chunked-blob-reader-native/-/chunked-blob-reader-native-3.0.0.tgz#f1104b30030f76f9aadcbd3cdca4377bd1ba2695" + integrity sha512-VDkpCYW+peSuM4zJip5WDfqvg2Mo/e8yxOv3VF1m11y7B8KKMKVFtmZWDe36Fvk8rGuWrPZHHXZ7rR7uM5yWyg== + dependencies: + "@smithy/util-base64" "^3.0.0" + tslib "^2.6.2" + +"@smithy/chunked-blob-reader@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/chunked-blob-reader/-/chunked-blob-reader-3.0.0.tgz#e5d3b04e9b273ba8b7ede47461e2aa96c8aa49e0" + integrity sha512-sbnURCwjF0gSToGlsBiAmd1lRCmSn72nu9axfJu5lIx6RUEgHu6GwTMbqCdhQSi0Pumcm5vFxsi9XWXb2mTaoA== + dependencies: + tslib "^2.6.2" + +"@smithy/config-resolver@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@smithy/config-resolver/-/config-resolver-3.0.4.tgz#85fffa86cee4562f867b0a70a374057a48525d1b" + integrity sha512-VwiOk7TwXoE7NlNguV/aPq1hFH72tqkHCw8eWXbr2xHspRyyv9DLpLXhq+Ieje+NwoqXrY0xyQjPXdOE6cGcHA== + dependencies: + "@smithy/node-config-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + "@smithy/util-config-provider" "^3.0.0" + "@smithy/util-middleware" "^3.0.3" + tslib "^2.6.2" + +"@smithy/core@^2.2.4": + version "2.2.4" + resolved "https://registry.yarnpkg.com/@smithy/core/-/core-2.2.4.tgz#a83d62fc685ff95ad3133d55d7e365a51526a436" + integrity sha512-qdY3LpMOUyLM/gfjjMQZui+UTNS7kBRDWlvyIhVOql5dn2J3isk9qUTBtQ1CbDH8MTugHis1zu3h4rH+Qmmh4g== + dependencies: + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-retry" "^3.0.7" + "@smithy/middleware-serde" "^3.0.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/util-middleware" "^3.0.3" + tslib "^2.6.2" + +"@smithy/credential-provider-imds@^3.1.3": + version "3.1.3" + resolved "https://registry.yarnpkg.com/@smithy/credential-provider-imds/-/credential-provider-imds-3.1.3.tgz#43e6c2d1e3df6bb6bb28bfae6b99c5a4d93bda09" + integrity sha512-U1Yrv6hx/mRK6k8AncuI6jLUx9rn0VVSd9NPEX6pyYFBfkSkChOc/n4zUb8alHUVg83TbI4OdZVo1X0Zfj3ijA== + dependencies: + "@smithy/node-config-provider" "^3.1.3" + "@smithy/property-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + tslib "^2.6.2" + +"@smithy/eventstream-codec@^3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@smithy/eventstream-codec/-/eventstream-codec-3.1.2.tgz#4a1c72b34400631b829241151984a1ad8c4f963c" + integrity sha512-0mBcu49JWt4MXhrhRAlxASNy0IjDRFU+aWNDRal9OtUJvJNiwDuyKMUONSOjLjSCeGwZaE0wOErdqULer8r7yw== + dependencies: + "@aws-crypto/crc32" "5.2.0" + "@smithy/types" "^3.3.0" + "@smithy/util-hex-encoding" "^3.0.0" + tslib "^2.6.2" + +"@smithy/eventstream-serde-browser@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@smithy/eventstream-serde-browser/-/eventstream-serde-browser-3.0.4.tgz#98d6e7ae60d297e37ee7775af2a7a8bbe574579d" + integrity sha512-Eo4anLZX6ltGJTZ5yJMc80gZPYYwBn44g0h7oFq6et+TYr5dUsTpIcDbz2evsOKIZhZ7zBoFWHtBXQ4QQeb5xA== + dependencies: + "@smithy/eventstream-serde-universal" "^3.0.4" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/eventstream-serde-config-resolver@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/eventstream-serde-config-resolver/-/eventstream-serde-config-resolver-3.0.3.tgz#f852e096d0ad112363b4685e1d441088d1fce67a" + integrity sha512-NVTYjOuYpGfrN/VbRQgn31x73KDLfCXCsFdad8DiIc3IcdxL+dYA9zEQPyOP7Fy2QL8CPy2WE4WCUD+ZsLNfaQ== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/eventstream-serde-node@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@smithy/eventstream-serde-node/-/eventstream-serde-node-3.0.4.tgz#6301752ca51b3ebabcd2dec112f1dacd990de4c1" + integrity sha512-mjlG0OzGAYuUpdUpflfb9zyLrBGgmQmrobNT8b42ZTsGv/J03+t24uhhtVEKG/b2jFtPIHF74Bq+VUtbzEKOKg== + dependencies: + "@smithy/eventstream-serde-universal" "^3.0.4" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/eventstream-serde-universal@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@smithy/eventstream-serde-universal/-/eventstream-serde-universal-3.0.4.tgz#6754de5b94bdc286d8ef1d6bcf22d80f6ab68f30" + integrity sha512-Od9dv8zh3PgOD7Vj4T3HSuox16n0VG8jJIM2gvKASL6aCtcS8CfHZDWe1Ik3ZXW6xBouU+45Q5wgoliWDZiJ0A== + dependencies: + "@smithy/eventstream-codec" "^3.1.2" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/fetch-http-handler@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@smithy/fetch-http-handler/-/fetch-http-handler-3.2.0.tgz#425ce7686bf20176b38f8013ed7fb28302a88929" + integrity sha512-vFvDxMrc6sO5Atec8PaISckMcAwsCrRhYxwUylg97bRT2KZoumOF7qk5+6EVUtuM1IG9AJV5aqXnHln9ZdXHpg== + dependencies: + "@smithy/protocol-http" "^4.0.3" + "@smithy/querystring-builder" "^3.0.3" + "@smithy/types" "^3.3.0" + "@smithy/util-base64" "^3.0.0" + tslib "^2.6.2" + +"@smithy/hash-blob-browser@^3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@smithy/hash-blob-browser/-/hash-blob-browser-3.1.2.tgz#90281c1f183d93686fb4f26107f1819644d68829" + integrity sha512-hAbfqN2UbISltakCC2TP0kx4LqXBttEv2MqSPE98gVuDFMf05lU+TpC41QtqGP3Ff5A3GwZMPfKnEy0VmEUpmg== + dependencies: + "@smithy/chunked-blob-reader" "^3.0.0" + "@smithy/chunked-blob-reader-native" "^3.0.0" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/hash-node@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/hash-node/-/hash-node-3.0.3.tgz#82c5cb7b0f1a29ee7319081853d2d158c07dff24" + integrity sha512-2ctBXpPMG+B3BtWSGNnKELJ7SH9e4TNefJS0cd2eSkOOROeBnnVBnAy9LtJ8tY4vUEoe55N4CNPxzbWvR39iBw== + dependencies: + "@smithy/types" "^3.3.0" + "@smithy/util-buffer-from" "^3.0.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@smithy/hash-stream-node@^3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@smithy/hash-stream-node/-/hash-stream-node-3.1.2.tgz#89f0290ae44b113863878e75b10c484ff48af71c" + integrity sha512-PBgDMeEdDzi6JxKwbfBtwQG9eT9cVwsf0dZzLXoJF4sHKHs5HEo/3lJWpn6jibfJwT34I1EBXpBnZE8AxAft6g== + dependencies: + "@smithy/types" "^3.3.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@smithy/invalid-dependency@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/invalid-dependency/-/invalid-dependency-3.0.3.tgz#8d9fd70e3a94b565a4eba4ffbdc95238e1930528" + integrity sha512-ID1eL/zpDULmHJbflb864k72/SNOZCADRc9i7Exq3RUNJw6raWUSlFEQ+3PX3EYs++bTxZB2dE9mEHTQLv61tw== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/is-array-buffer@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz#f84f0d9f9a36601a9ca9381688bd1b726fd39111" + integrity sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA== + dependencies: + tslib "^2.6.2" + +"@smithy/is-array-buffer@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/is-array-buffer/-/is-array-buffer-3.0.0.tgz#9a95c2d46b8768946a9eec7f935feaddcffa5e7a" + integrity sha512-+Fsu6Q6C4RSJiy81Y8eApjEB5gVtM+oFKTffg+jSuwtvomJJrhUJBu2zS8wjXSgH/g1MKEWrzyChTBe6clb5FQ== + dependencies: + tslib "^2.6.2" + +"@smithy/md5-js@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/md5-js/-/md5-js-3.0.3.tgz#55ee40aa24075b096c39f7910590c18ff7660c98" + integrity sha512-O/SAkGVwpWmelpj/8yDtsaVe6sINHLB1q8YE/+ZQbDxIw3SRLbTZuRaI10K12sVoENdnHqzPp5i3/H+BcZ3m3Q== + dependencies: + "@smithy/types" "^3.3.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@smithy/middleware-content-length@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/middleware-content-length/-/middleware-content-length-3.0.3.tgz#426a7f907cc3c0a5d81deb84e16d38303e5a9ad8" + integrity sha512-Dbz2bzexReYIQDWMr+gZhpwBetNXzbhnEMhYKA6urqmojO14CsXjnsoPYO8UL/xxcawn8ZsuVU61ElkLSltIUQ== + dependencies: + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/middleware-endpoint@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@smithy/middleware-endpoint/-/middleware-endpoint-3.0.4.tgz#c18518b21c80887c16fb595b156c7c009b0b64ca" + integrity sha512-whUJMEPwl3ANIbXjBXZVdJNgfV2ZU8ayln7xUM47rXL2txuenI7jQ/VFFwCzy5lCmXScjp6zYtptW5Evud8e9g== + dependencies: + "@smithy/middleware-serde" "^3.0.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + "@smithy/url-parser" "^3.0.3" + "@smithy/util-middleware" "^3.0.3" + tslib "^2.6.2" + +"@smithy/middleware-retry@^3.0.7": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@smithy/middleware-retry/-/middleware-retry-3.0.7.tgz#b42d90b3ecc392fdfeda1eff9dc7a023ba11d34b" + integrity sha512-f5q7Y09G+2h5ivkSx5CHvlAT4qRR3jBFEsfXyQ9nFNiWQlr8c48blnu5cmbTQ+p1xmIO14UXzKoF8d7Tm0Gsjw== + dependencies: + "@smithy/node-config-provider" "^3.1.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/service-error-classification" "^3.0.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + "@smithy/util-middleware" "^3.0.3" + "@smithy/util-retry" "^3.0.3" + tslib "^2.6.2" + uuid "^9.0.1" + +"@smithy/middleware-serde@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/middleware-serde/-/middleware-serde-3.0.3.tgz#74d974460f74d99f38c861e6862984543a880a66" + integrity sha512-puUbyJQBcg9eSErFXjKNiGILJGtiqmuuNKEYNYfUD57fUl4i9+mfmThtQhvFXU0hCVG0iEJhvQUipUf+/SsFdA== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/middleware-stack@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/middleware-stack/-/middleware-stack-3.0.3.tgz#91845c7e61e6f137fa912b623b6def719a4f6ce7" + integrity sha512-r4klY9nFudB0r9UdSMaGSyjyQK5adUyPnQN/ZM6M75phTxOdnc/AhpvGD1fQUvgmqjQEBGCwpnPbDm8pH5PapA== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/node-config-provider@^3.1.3": + version "3.1.3" + resolved "https://registry.yarnpkg.com/@smithy/node-config-provider/-/node-config-provider-3.1.3.tgz#e8e69d0df5be9d6ed3f3a84f51fd2176f09c7ab8" + integrity sha512-rxdpAZczzholz6CYZxtqDu/aKTxATD5DAUDVj7HoEulq+pDSQVWzbg0btZDlxeFfa6bb2b5tUvgdX5+k8jUqcg== + dependencies: + "@smithy/property-provider" "^3.1.3" + "@smithy/shared-ini-file-loader" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/node-http-handler@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@smithy/node-http-handler/-/node-http-handler-3.1.1.tgz#9213d9b5139c9f9c5a1928e1574de767a979bf94" + integrity sha512-L71NLyPeP450r2J/mfu1jMc//Z1YnqJt2eSNw7uhiItaONnBLDA68J5jgxq8+MBDsYnFwNAIc7dBG1ImiWBiwg== + dependencies: + "@smithy/abort-controller" "^3.1.1" + "@smithy/protocol-http" "^4.0.3" + "@smithy/querystring-builder" "^3.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/property-provider@^3.1.3": + version "3.1.3" + resolved "https://registry.yarnpkg.com/@smithy/property-provider/-/property-provider-3.1.3.tgz#afd57ea82a3f6c79fbda95e3cb85c0ee0a79f39a" + integrity sha512-zahyOVR9Q4PEoguJ/NrFP4O7SMAfYO1HLhB18M+q+Z4KFd4V2obiMnlVoUFzFLSPeVt1POyNWneHHrZaTMoc/g== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/protocol-http@^4.0.3": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@smithy/protocol-http/-/protocol-http-4.0.3.tgz#acf16058504e3cce2dbe8abf94f7b544cd09d3f4" + integrity sha512-x5jmrCWwQlx+Zv4jAtc33ijJ+vqqYN+c/ZkrnpvEe/uDas7AT7A/4Rc2CdfxgWv4WFGmEqODIrrUToPN6DDkGw== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/querystring-builder@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/querystring-builder/-/querystring-builder-3.0.3.tgz#6b0e566f885bb84938d077c69e8f8555f686af13" + integrity sha512-vyWckeUeesFKzCDaRwWLUA1Xym9McaA6XpFfAK5qI9DKJ4M33ooQGqvM4J+LalH4u/Dq9nFiC8U6Qn1qi0+9zw== + dependencies: + "@smithy/types" "^3.3.0" + "@smithy/util-uri-escape" "^3.0.0" + tslib "^2.6.2" + +"@smithy/querystring-parser@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/querystring-parser/-/querystring-parser-3.0.3.tgz#272a6b83f88dfcbbec8283d72a6bde850cc00091" + integrity sha512-zahM1lQv2YjmznnfQsWbYojFe55l0SLG/988brlLv1i8z3dubloLF+75ATRsqPBboUXsW6I9CPGE5rQgLfY0vQ== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/service-error-classification@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/service-error-classification/-/service-error-classification-3.0.3.tgz#73484255060a094aa9372f6cd972dcaf97e3ce80" + integrity sha512-Jn39sSl8cim/VlkLsUhRFq/dKDnRUFlfRkvhOJaUbLBXUsLRLNf9WaxDv/z9BjuQ3A6k/qE8af1lsqcwm7+DaQ== + dependencies: + "@smithy/types" "^3.3.0" + +"@smithy/shared-ini-file-loader@^3.1.3": + version "3.1.3" + resolved "https://registry.yarnpkg.com/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-3.1.3.tgz#49a5e0e8cd98d219e7e56860586710b146d52ade" + integrity sha512-Z8Y3+08vgoDgl4HENqNnnzSISAaGrF2RoKupoC47u2wiMp+Z8P/8mDh1CL8+8ujfi2U5naNvopSBmP/BUj8b5w== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/signature-v4@^3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@smithy/signature-v4/-/signature-v4-3.1.2.tgz#63fc0d4f9a955e902138fb0a57fafc96b9d4e8bb" + integrity sha512-3BcPylEsYtD0esM4Hoyml/+s7WP2LFhcM3J2AGdcL2vx9O60TtfpDOL72gjb4lU8NeRPeKAwR77YNyyGvMbuEA== + dependencies: + "@smithy/is-array-buffer" "^3.0.0" + "@smithy/types" "^3.3.0" + "@smithy/util-hex-encoding" "^3.0.0" + "@smithy/util-middleware" "^3.0.3" + "@smithy/util-uri-escape" "^3.0.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@smithy/smithy-client@^3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@smithy/smithy-client/-/smithy-client-3.1.5.tgz#3956f0b511c3a51f859c45eb11bfd70ae00c5fec" + integrity sha512-x9bL9Mx2CT2P1OiUlHM+ZNpbVU6TgT32f9CmTRzqIHA7M4vYrROCWEoC3o4xHNJASoGd4Opos3cXYPgh+/m4Ww== + dependencies: + "@smithy/middleware-endpoint" "^3.0.4" + "@smithy/middleware-stack" "^3.0.3" + "@smithy/protocol-http" "^4.0.3" + "@smithy/types" "^3.3.0" + "@smithy/util-stream" "^3.0.5" + tslib "^2.6.2" + +"@smithy/types@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@smithy/types/-/types-3.3.0.tgz#fae037c733d09bc758946a01a3de0ef6e210b16b" + integrity sha512-IxvBBCTFDHbVoK7zIxqA1ZOdc4QfM5HM7rGleCuHi7L1wnKv5Pn69xXJQ9hgxH60ZVygH9/JG0jRgtUncE3QUA== + dependencies: + tslib "^2.6.2" + +"@smithy/url-parser@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/url-parser/-/url-parser-3.0.3.tgz#e8a060d9810b24b1870385fc2b02485b8a6c5955" + integrity sha512-pw3VtZtX2rg+s6HMs6/+u9+hu6oY6U7IohGhVNnjbgKy86wcIsSZwgHrFR+t67Uyxvp4Xz3p3kGXXIpTNisq8A== + dependencies: + "@smithy/querystring-parser" "^3.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/util-base64@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-base64/-/util-base64-3.0.0.tgz#f7a9a82adf34e27a72d0719395713edf0e493017" + integrity sha512-Kxvoh5Qtt0CDsfajiZOCpJxgtPHXOKwmM+Zy4waD43UoEMA+qPxxa98aE/7ZhdnBFZFXMOiBR5xbcaMhLtznQQ== + dependencies: + "@smithy/util-buffer-from" "^3.0.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@smithy/util-body-length-browser@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-body-length-browser/-/util-body-length-browser-3.0.0.tgz#86ec2f6256310b4845a2f064e2f571c1ca164ded" + integrity sha512-cbjJs2A1mLYmqmyVl80uoLTJhAcfzMOyPgjwAYusWKMdLeNtzmMz9YxNl3/jRLoxSS3wkqkf0jwNdtXWtyEBaQ== + dependencies: + tslib "^2.6.2" + +"@smithy/util-body-length-node@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-body-length-node/-/util-body-length-node-3.0.0.tgz#99a291bae40d8932166907fe981d6a1f54298a6d" + integrity sha512-Tj7pZ4bUloNUP6PzwhN7K386tmSmEET9QtQg0TgdNOnxhZvCssHji+oZTUIuzxECRfG8rdm2PMw2WCFs6eIYkA== + dependencies: + tslib "^2.6.2" + +"@smithy/util-buffer-from@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz#6fc88585165ec73f8681d426d96de5d402021e4b" + integrity sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA== + dependencies: + "@smithy/is-array-buffer" "^2.2.0" + tslib "^2.6.2" + +"@smithy/util-buffer-from@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-buffer-from/-/util-buffer-from-3.0.0.tgz#559fc1c86138a89b2edaefc1e6677780c24594e3" + integrity sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA== + dependencies: + "@smithy/is-array-buffer" "^3.0.0" + tslib "^2.6.2" + +"@smithy/util-config-provider@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-config-provider/-/util-config-provider-3.0.0.tgz#62c6b73b22a430e84888a8f8da4b6029dd5b8efe" + integrity sha512-pbjk4s0fwq3Di/ANL+rCvJMKM5bzAQdE5S/6RL5NXgMExFAi6UgQMPOm5yPaIWPpr+EOXKXRonJ3FoxKf4mCJQ== + dependencies: + tslib "^2.6.2" + +"@smithy/util-defaults-mode-browser@^3.0.7": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-3.0.7.tgz#5868ae56c9ae4a3532c175f9c0ee281a41065215" + integrity sha512-Q2txLyvQyGfmjsaDbVV7Sg8psefpFcrnlGapDzXGFRPFKRBeEg6OvFK8FljqjeHSaCZ6/UuzQExUPqBR/2qlDA== + dependencies: + "@smithy/property-provider" "^3.1.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + bowser "^2.11.0" + tslib "^2.6.2" + +"@smithy/util-defaults-mode-node@^3.0.7": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-3.0.7.tgz#e802ca57df6b8543dc288524d3894a6c357b51fc" + integrity sha512-F4Qcj1fG6MGi2BSWCslfsMSwllws/WzYONBGtLybyY+halAcXdWhcew+mej8M5SKd5hqPYp4f7b+ABQEaeytgg== + dependencies: + "@smithy/config-resolver" "^3.0.4" + "@smithy/credential-provider-imds" "^3.1.3" + "@smithy/node-config-provider" "^3.1.3" + "@smithy/property-provider" "^3.1.3" + "@smithy/smithy-client" "^3.1.5" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/util-endpoints@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@smithy/util-endpoints/-/util-endpoints-2.0.4.tgz#0cfb01deb42ec5cd819b54e85acb2c32e4ba4385" + integrity sha512-ZAtNf+vXAsgzgRutDDiklU09ZzZiiV/nATyqde4Um4priTmasDH+eLpp3tspL0hS2dEootyFMhu1Y6Y+tzpWBQ== + dependencies: + "@smithy/node-config-provider" "^3.1.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/util-hex-encoding@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-hex-encoding/-/util-hex-encoding-3.0.0.tgz#32938b33d5bf2a15796cd3f178a55b4155c535e6" + integrity sha512-eFndh1WEK5YMUYvy3lPlVmYY/fZcQE1D8oSf41Id2vCeIkKJXPcYDCZD+4+xViI6b1XSd7tE+s5AmXzz5ilabQ== + dependencies: + tslib "^2.6.2" + +"@smithy/util-middleware@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/util-middleware/-/util-middleware-3.0.3.tgz#07bf9602682f5a6c55bc2f0384303f85fc68c87e" + integrity sha512-l+StyYYK/eO3DlVPbU+4Bi06Jjal+PFLSMmlWM1BEwyLxZ3aKkf1ROnoIakfaA7mC6uw3ny7JBkau4Yc+5zfWw== + dependencies: + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/util-retry@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@smithy/util-retry/-/util-retry-3.0.3.tgz#9b2ac0dbb1c81f69812a8affa4d772bebfc0e049" + integrity sha512-AFw+hjpbtVApzpNDhbjNG5NA3kyoMs7vx0gsgmlJF4s+yz1Zlepde7J58zpIRIsdjc+emhpAITxA88qLkPF26w== + dependencies: + "@smithy/service-error-classification" "^3.0.3" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +"@smithy/util-stream@^3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@smithy/util-stream/-/util-stream-3.0.5.tgz#8ca98441e1deedfc4ec8d3fee9aa4342fdbc484f" + integrity sha512-xC3L5PKMAT/Bh8fmHNXP9sdQ4+4aKVUU3EEJ2CF/lLk7R+wtMJM+v/1B4en7jO++Wa5spGzFDBCl0QxgbUc5Ug== + dependencies: + "@smithy/fetch-http-handler" "^3.2.0" + "@smithy/node-http-handler" "^3.1.1" + "@smithy/types" "^3.3.0" + "@smithy/util-base64" "^3.0.0" + "@smithy/util-buffer-from" "^3.0.0" + "@smithy/util-hex-encoding" "^3.0.0" + "@smithy/util-utf8" "^3.0.0" + tslib "^2.6.2" + +"@smithy/util-uri-escape@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-uri-escape/-/util-uri-escape-3.0.0.tgz#e43358a78bf45d50bb736770077f0f09195b6f54" + integrity sha512-LqR7qYLgZTD7nWLBecUi4aqolw8Mhza9ArpNEQ881MJJIU2sE5iHCK6TdyqqzcDLy0OPe10IY4T8ctVdtynubg== + dependencies: + tslib "^2.6.2" + +"@smithy/util-utf8@^2.0.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@smithy/util-utf8/-/util-utf8-2.3.0.tgz#dd96d7640363259924a214313c3cf16e7dd329c5" + integrity sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A== + dependencies: + "@smithy/util-buffer-from" "^2.2.0" + tslib "^2.6.2" + +"@smithy/util-utf8@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@smithy/util-utf8/-/util-utf8-3.0.0.tgz#1a6a823d47cbec1fd6933e5fc87df975286d9d6a" + integrity sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA== + dependencies: + "@smithy/util-buffer-from" "^3.0.0" + tslib "^2.6.2" + +"@smithy/util-waiter@^3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@smithy/util-waiter/-/util-waiter-3.1.2.tgz#2d40c3312f3537feee763459a19acafab4c75cf3" + integrity sha512-4pP0EV3iTsexDx+8PPGAKCQpd/6hsQBaQhqWzU4hqKPHN5epPsxKbvUTIiYIHTxaKt6/kEaqPBpu/ufvfbrRzw== + dependencies: + "@smithy/abort-controller" "^3.1.1" + "@smithy/types" "^3.3.0" + tslib "^2.6.2" + +bowser@^2.11.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/bowser/-/bowser-2.11.0.tgz#5ca3c35757a7aa5771500c70a73a9f91ef420a8f" + integrity sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA== + +fast-xml-parser@4.2.5: + version "4.2.5" + resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz#a6747a09296a6cb34f2ae634019bf1738f3b421f" + integrity sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g== + dependencies: + strnum "^1.0.5" + +strnum@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db" + integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA== + +tslib@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== + +uuid@^9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" + integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index a4fcecef5f7..7a2e8a8ba04 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -182,7 +182,6 @@ export class AztecNodeService implements AztecNode { ? undefined : await TxProver.new( config, - await proofVerifier.getVerificationKeys(), worldStateSynchronizer, telemetry, await archiver @@ -795,10 +794,6 @@ export class AztecNodeService implements AztecNode { new MetadataTxValidator(this.chainId), new TxProofValidator(proofVerifier), ); - - await this.prover?.updateProverConfig({ - vks: await proofVerifier.getVerificationKeys(), - }); } this.config = newConfig; diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 785493afda2..5d7413523ac 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -1,7 +1,7 @@ import { type Tx, type TxExecutionRequest, type TxHash, type TxReceipt } from '@aztec/circuit-types'; import { AztecAddress, CompleteAddress, EthAddress } from '@aztec/circuits.js'; import { type L1ContractAddresses } from '@aztec/ethereum'; -import { ABIParameterVisibility, type ContractArtifact, type DecodedReturn, FunctionType } from '@aztec/foundation/abi'; +import { type ContractArtifact, type DecodedReturn, FunctionType } from '@aztec/foundation/abi'; import { type NodeInfo } from '@aztec/types/interfaces'; import { type MockProxy, mock } from 'jest-mock-extended'; @@ -60,14 +60,14 @@ describe('Contract Class', () => { type: { kind: 'field', }, - visibility: ABIParameterVisibility.PUBLIC, + visibility: 'public', }, { name: 'value', type: { kind: 'field', }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -96,13 +96,13 @@ describe('Contract Class', () => { type: { kind: 'field', }, - visibility: ABIParameterVisibility.PUBLIC, + visibility: 'public', }, ], returnTypes: [ { kind: 'integer', - sign: '', + sign: 'unsigned', width: 32, }, ], diff --git a/yarn-project/aztec/package.json b/yarn-project/aztec/package.json index 66705456835..2178b55ebea 100644 --- a/yarn-project/aztec/package.json +++ b/yarn-project/aztec/package.json @@ -41,6 +41,7 @@ "@aztec/kv-store": "workspace:^", "@aztec/l1-artifacts": "workspace:^", "@aztec/noir-contracts.js": "workspace:^", + "@aztec/noir-protocol-circuits-types": "workspace:^", "@aztec/p2p": "workspace:^", "@aztec/p2p-bootstrap": "workspace:^", "@aztec/protocol-contracts": "workspace:^", diff --git a/yarn-project/aztec/src/sandbox.ts b/yarn-project/aztec/src/sandbox.ts index 79d6e6e3218..437dbb99baa 100644 --- a/yarn-project/aztec/src/sandbox.ts +++ b/yarn-project/aztec/src/sandbox.ts @@ -32,6 +32,7 @@ import { } from '@aztec/l1-artifacts'; import { AuthRegistryContract, KeyRegistryContract } from '@aztec/noir-contracts.js'; import { GasTokenContract } from '@aztec/noir-contracts.js/GasToken'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry'; import { GasTokenAddress, getCanonicalGasToken } from '@aztec/protocol-contracts/gas-token'; import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry'; @@ -126,6 +127,7 @@ export async function deployContractsToL1( const l1Contracts = await waitThenDeploy(aztecNodeConfig, () => deployL1Contracts(aztecNodeConfig.rpcUrl, hdAccount, localAnvil, contractDeployLogger, l1Artifacts, { l2GasTokenAddress: GasTokenAddress, + vkTreeRoot: getVKTreeRoot(), }), ); diff --git a/yarn-project/aztec/tsconfig.json b/yarn-project/aztec/tsconfig.json index 557c0080199..61805f56d7a 100644 --- a/yarn-project/aztec/tsconfig.json +++ b/yarn-project/aztec/tsconfig.json @@ -48,6 +48,9 @@ { "path": "../noir-contracts.js" }, + { + "path": "../noir-protocol-circuits-types" + }, { "path": "../p2p" }, diff --git a/yarn-project/bb-prover/src/prover/bb_native_proof_creator.ts b/yarn-project/bb-prover/src/prover/bb_native_proof_creator.ts index ecfad7d8ed1..31686b6f2a6 100644 --- a/yarn-project/bb-prover/src/prover/bb_native_proof_creator.ts +++ b/yarn-project/bb-prover/src/prover/bb_native_proof_creator.ts @@ -25,6 +25,7 @@ import { ClientCircuitArtifacts, type ClientProtocolArtifact, PrivateResetTagToArtifactName, + ProtocolCircuitVks, convertPrivateKernelInitInputsToWitnessMap, convertPrivateKernelInitOutputsFromWitnessMap, convertPrivateKernelInnerInputsToWitnessMap, @@ -44,14 +45,7 @@ import { type WitnessMap } from '@noir-lang/types'; import * as fs from 'fs/promises'; import { join } from 'path'; -import { - BB_RESULT, - PROOF_FIELDS_FILENAME, - PROOF_FILENAME, - generateKeyForNoirCircuit, - generateProof, - verifyProof, -} from '../bb/execute.js'; +import { BB_RESULT, PROOF_FIELDS_FILENAME, PROOF_FILENAME, generateProof, verifyProof } from '../bb/execute.js'; import { mapProtocolArtifactNameToCircuitName } from '../stats.js'; import { extractVkData } from '../verification_key/verification_key_data.js'; @@ -159,7 +153,7 @@ export class BBNativeProofCreator implements ProofCreator { * @param proof - The proof to be verified */ public async verifyProofForProtocolCircuit(circuitType: ClientProtocolArtifact, proof: Proof) { - const verificationKey = await this.getVerificationKeyDataForCircuit(circuitType); + const verificationKey = ProtocolCircuitVks[circuitType]; this.log.debug(`Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`); @@ -193,32 +187,6 @@ export class BBNativeProofCreator implements ProofCreator { return await runInDirectory(this.bbWorkingDirectory, operation); } - /** - * Returns the verification key data for a circuit, will generate and cache it if not cached internally - * @param circuitType - The type of circuit for which the verification key is required - * @returns The verification key data - */ - private async getVerificationKeyDataForCircuit(circuitType: ClientProtocolArtifact): Promise { - let promise = this.verificationKeys.get(circuitType); - if (!promise) { - promise = generateKeyForNoirCircuit( - this.bbBinaryPath, - this.bbWorkingDirectory, - circuitType, - ClientCircuitArtifacts[circuitType], - 'vk', - this.log.debug, - ).then(result => { - if (result.status === BB_RESULT.FAILURE) { - throw new Error(`Failed to generate verification key for ${circuitType}, ${result.reason}`); - } - return extractVkData(result.vkPath!); - }); - this.verificationKeys.set(circuitType, promise); - } - return await promise; - } - /** * Ensures our verification key cache includes the key data located at the specified directory * @param filePath - The directory containing the verification key data files diff --git a/yarn-project/bb-prover/src/prover/bb_prover.ts b/yarn-project/bb-prover/src/prover/bb_prover.ts index 00c9d0e8b8a..419469cf2f6 100644 --- a/yarn-project/bb-prover/src/prover/bb_prover.ts +++ b/yarn-project/bb-prover/src/prover/bb_prover.ts @@ -38,7 +38,7 @@ import { runInDirectory } from '@aztec/foundation/fs'; import { createDebugLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; import { - EmptyNestedArtifact, + ProtocolCircuitVkIndexes, ServerCircuitArtifacts, type ServerProtocolArtifact, convertBaseParityInputsToWitnessMap, @@ -55,6 +55,7 @@ import { convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, + getVKSiblingPath, } from '@aztec/noir-protocol-circuits-types'; import { NativeACVMSimulator } from '@aztec/simulator'; import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-client'; @@ -145,7 +146,12 @@ export class BBNativeRollupProver implements ServerCircuitProver { await this.verifyProof('BaseParityArtifact', proof.binaryProof); - return new RootParityInput(proof, verificationKey.keyAsFields, circuitOutput); + return new RootParityInput( + proof, + verificationKey.keyAsFields, + getVKSiblingPath(ProtocolCircuitVkIndexes.BaseParityArtifact), + circuitOutput, + ); } /** @@ -169,7 +175,12 @@ export class BBNativeRollupProver implements ServerCircuitProver { await this.verifyProof('RootParityArtifact', proof.binaryProof); - return new RootParityInput(proof, verificationKey.keyAsFields, circuitOutput); + return new RootParityInput( + proof, + verificationKey.keyAsFields, + getVKSiblingPath(ProtocolCircuitVkIndexes.RootParityArtifact), + circuitOutput, + ); } /** @@ -351,7 +362,7 @@ export class BBNativeRollupProver implements ServerCircuitProver { inputs, 'EmptyNestedArtifact', RECURSIVE_PROOF_LENGTH, - (nothing: any) => abiEncode(EmptyNestedArtifact.abi as Abi, { _inputs: nothing as any }), + (nothing: any) => abiEncode(ServerCircuitArtifacts.EmptyNestedArtifact.abi as Abi, { _inputs: nothing as any }), () => new EmptyNestedCircuitInputs(), ); diff --git a/yarn-project/bb-prover/src/test/test_circuit_prover.ts b/yarn-project/bb-prover/src/test/test_circuit_prover.ts index 85ce58a9580..be9c0be794c 100644 --- a/yarn-project/bb-prover/src/test/test_circuit_prover.ts +++ b/yarn-project/bb-prover/src/test/test_circuit_prover.ts @@ -24,7 +24,6 @@ import { type RootParityInputs, type RootRollupInputs, type RootRollupPublicInputs, - VerificationKeyAsFields, VerificationKeyData, makeEmptyProof, makeEmptyRecursiveProof, @@ -33,28 +32,25 @@ import { import { createDebugLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; import { - BaseParityArtifact, - MergeRollupArtifact, - PrivateKernelEmptyArtifact, - RootParityArtifact, - RootRollupArtifact, + ProtocolCircuitVkIndexes, + ProtocolCircuitVks, type ServerProtocolArtifact, - SimulatedBaseRollupArtifact, SimulatedServerCircuitArtifacts, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertPrivateKernelEmptyInputsToWitnessMap, - convertPrivateKernelEmptyOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSimulatedBaseRollupInputsToWitnessMap, convertSimulatedBaseRollupOutputsFromWitnessMap, + convertSimulatedPrivateKernelEmptyOutputsFromWitnessMap, convertSimulatedPublicTailInputsToWitnessMap, convertSimulatedPublicTailOutputFromWitnessMap, + getVKSiblingPath, } from '@aztec/noir-protocol-circuits-types'; import { type SimulationProvider, WASMSimulator, emitCircuitSimulationStats } from '@aztec/simulator'; import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client'; @@ -63,20 +59,6 @@ import { ProverInstrumentation } from '../instrumentation.js'; import { SimulatedPublicKernelArtifactMapping } from '../mappings/mappings.js'; import { mapPublicKernelToCircuitName } from '../stats.js'; -const VERIFICATION_KEYS: Record = { - BaseParityArtifact: VerificationKeyAsFields.makeFake(), - RootParityArtifact: VerificationKeyAsFields.makeFake(), - PublicKernelAppLogicArtifact: VerificationKeyAsFields.makeFake(), - PublicKernelSetupArtifact: VerificationKeyAsFields.makeFake(), - PublicKernelTailArtifact: VerificationKeyAsFields.makeFake(), - PublicKernelTeardownArtifact: VerificationKeyAsFields.makeFake(), - BaseRollupArtifact: VerificationKeyAsFields.makeFake(), - MergeRollupArtifact: VerificationKeyAsFields.makeFake(), - RootRollupArtifact: VerificationKeyAsFields.makeFake(), - PrivateKernelEmptyArtifact: VerificationKeyAsFields.makeFake(), - EmptyNestedArtifact: VerificationKeyAsFields.makeFake(), -}; - /** * A class for use in testing situations (e2e, unit test etc) * Simulates circuits using the most efficient method and performs no proving @@ -102,17 +84,26 @@ export class TestCircuitProver implements ServerCircuitProver { ): Promise> { const emptyNested = new EmptyNestedData( makeRecursiveProof(RECURSIVE_PROOF_LENGTH), - VERIFICATION_KEYS['EmptyNestedArtifact'], + ProtocolCircuitVks['EmptyNestedArtifact'].keyAsFields, + ); + const kernelInputs = new PrivateKernelEmptyInputs( + emptyNested, + inputs.header, + inputs.chainId, + inputs.version, + inputs.vkTreeRoot, ); - const kernelInputs = new PrivateKernelEmptyInputs(emptyNested, inputs.header, inputs.chainId, inputs.version); const witnessMap = convertPrivateKernelEmptyInputsToWitnessMap(kernelInputs); - const witness = await this.wasmSimulator.simulateCircuit(witnessMap, PrivateKernelEmptyArtifact); - const result = convertPrivateKernelEmptyOutputsFromWitnessMap(witness); + const witness = await this.wasmSimulator.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.PrivateKernelEmptyArtifact, + ); + const result = convertSimulatedPrivateKernelEmptyOutputsFromWitnessMap(witness); return makePublicInputsAndRecursiveProof( result, makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VerificationKeyData.makeFake(), + ProtocolCircuitVks['PrivateKernelEmptyArtifact'], ); } @@ -127,12 +118,16 @@ export class TestCircuitProver implements ServerCircuitProver { const witnessMap = convertBaseParityInputsToWitnessMap(inputs); // use WASM here as it is faster for small circuits - const witness = await this.wasmSimulator.simulateCircuit(witnessMap, BaseParityArtifact); + const witness = await this.wasmSimulator.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.BaseParityArtifact, + ); const result = convertBaseParityOutputsFromWitnessMap(witness); const rootParityInput = new RootParityInput( makeRecursiveProof(RECURSIVE_PROOF_LENGTH), - VERIFICATION_KEYS['BaseParityArtifact'], + ProtocolCircuitVks['BaseParityArtifact'].keyAsFields, + getVKSiblingPath(ProtocolCircuitVkIndexes['BaseParityArtifact']), result, ); @@ -162,13 +157,17 @@ export class TestCircuitProver implements ServerCircuitProver { const witnessMap = convertRootParityInputsToWitnessMap(inputs); // use WASM here as it is faster for small circuits - const witness = await this.wasmSimulator.simulateCircuit(witnessMap, RootParityArtifact); + const witness = await this.wasmSimulator.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.RootParityArtifact, + ); const result = convertRootParityOutputsFromWitnessMap(witness); const rootParityInput = new RootParityInput( makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VERIFICATION_KEYS['RootParityArtifact'], + ProtocolCircuitVks['RootParityArtifact'].keyAsFields, + getVKSiblingPath(ProtocolCircuitVkIndexes['RootParityArtifact']), result, ); @@ -197,7 +196,10 @@ export class TestCircuitProver implements ServerCircuitProver { const witnessMap = convertSimulatedBaseRollupInputsToWitnessMap(input); const simulationProvider = this.simulationProvider ?? this.wasmSimulator; - const witness = await simulationProvider.simulateCircuit(witnessMap, SimulatedBaseRollupArtifact); + const witness = await simulationProvider.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.BaseRollupArtifact, + ); const result = convertSimulatedBaseRollupOutputsFromWitnessMap(witness); @@ -212,7 +214,7 @@ export class TestCircuitProver implements ServerCircuitProver { return makePublicInputsAndRecursiveProof( result, makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VerificationKeyData.makeFake(), + ProtocolCircuitVks['BaseRollupArtifact'], ); } /** @@ -228,7 +230,10 @@ export class TestCircuitProver implements ServerCircuitProver { const witnessMap = convertMergeRollupInputsToWitnessMap(input); // use WASM here as it is faster for small circuits - const witness = await this.wasmSimulator.simulateCircuit(witnessMap, MergeRollupArtifact); + const witness = await this.wasmSimulator.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.MergeRollupArtifact, + ); const result = convertMergeRollupOutputsFromWitnessMap(witness); @@ -243,7 +248,7 @@ export class TestCircuitProver implements ServerCircuitProver { return makePublicInputsAndRecursiveProof( result, makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VerificationKeyData.makeFake(), + ProtocolCircuitVks['MergeRollupArtifact'], ); } @@ -260,7 +265,10 @@ export class TestCircuitProver implements ServerCircuitProver { const witnessMap = convertRootRollupInputsToWitnessMap(input); // use WASM here as it is faster for small circuits - const witness = await this.wasmSimulator.simulateCircuit(witnessMap, RootRollupArtifact); + const witness = await this.wasmSimulator.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.RootRollupArtifact, + ); const result = convertRootRollupOutputsFromWitnessMap(witness); @@ -275,7 +283,7 @@ export class TestCircuitProver implements ServerCircuitProver { return makePublicInputsAndRecursiveProof( result, makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VerificationKeyData.makeFake(), + ProtocolCircuitVks['RootRollupArtifact'], ); } @@ -309,7 +317,7 @@ export class TestCircuitProver implements ServerCircuitProver { return makePublicInputsAndRecursiveProof( result, makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VerificationKeyData.makeFake(), + ProtocolCircuitVks[kernelOps.artifact], ); } @@ -338,7 +346,7 @@ export class TestCircuitProver implements ServerCircuitProver { return makePublicInputsAndRecursiveProof( result, makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - VerificationKeyData.makeFake(), + ProtocolCircuitVks['PublicKernelTailArtifact'], ); } diff --git a/yarn-project/bb-prover/src/test/test_verifier.ts b/yarn-project/bb-prover/src/test/test_verifier.ts index 03ca11cd277..f6c7a72e88f 100644 --- a/yarn-project/bb-prover/src/test/test_verifier.ts +++ b/yarn-project/bb-prover/src/test/test_verifier.ts @@ -1,12 +1,7 @@ import { type ClientProtocolCircuitVerifier, type Tx } from '@aztec/circuit-types'; -import { type VerificationKeys, getMockVerificationKeys } from '@aztec/circuits.js'; export class TestCircuitVerifier implements ClientProtocolCircuitVerifier { verifyProof(_tx: Tx): Promise { return Promise.resolve(true); } - - getVerificationKeys(): Promise { - return Promise.resolve(getMockVerificationKeys()); - } } diff --git a/yarn-project/bb-prover/src/verifier/bb_verifier.ts b/yarn-project/bb-prover/src/verifier/bb_verifier.ts index e5c12ce088e..0c34e7bccec 100644 --- a/yarn-project/bb-prover/src/verifier/bb_verifier.ts +++ b/yarn-project/bb-prover/src/verifier/bb_verifier.ts @@ -1,5 +1,5 @@ import { type ClientProtocolCircuitVerifier, Tx } from '@aztec/circuit-types'; -import { type Proof, type VerificationKeyData, type VerificationKeys } from '@aztec/circuits.js'; +import { type Proof, type VerificationKeyData } from '@aztec/circuits.js'; import { runInDirectory } from '@aztec/foundation/fs'; import { type DebugLogger, type LogFn, createDebugLogger } from '@aztec/foundation/log'; import { @@ -142,16 +142,4 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier { return false; } } - - async getVerificationKeys(): Promise { - const [privateKernelCircuit, privateKernelToPublicCircuit] = await Promise.all([ - this.getVerificationKeyData('PrivateKernelTailArtifact'), - this.getVerificationKeyData('PrivateKernelTailToPublicArtifact'), - ]); - - return { - privateKernelCircuit, - privateKernelToPublicCircuit, - }; - } } diff --git a/yarn-project/circuit-types/src/interfaces/prover-client.ts b/yarn-project/circuit-types/src/interfaces/prover-client.ts index 800a923e9ca..f8e390c0297 100644 --- a/yarn-project/circuit-types/src/interfaces/prover-client.ts +++ b/yarn-project/circuit-types/src/interfaces/prover-client.ts @@ -1,5 +1,4 @@ import { type TxHash } from '@aztec/circuit-types'; -import { type VerificationKeys } from '@aztec/circuits.js'; import { type BlockProver } from './block-prover.js'; import { type ProvingJobSource } from './proving-job.js'; @@ -35,7 +34,7 @@ export interface ProverClient extends BlockProver { getProvingJobSource(): ProvingJobSource; - updateProverConfig(config: Partial): Promise; + updateProverConfig(config: Partial): Promise; } export class BlockProofError extends Error { diff --git a/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts b/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts index 6d198b5ba9c..0bf3e3a7932 100644 --- a/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts +++ b/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts @@ -20,7 +20,6 @@ import { type RootParityInputs, type RootRollupInputs, type RootRollupPublicInputs, - type VerificationKeys, } from '@aztec/circuits.js'; /** @@ -112,9 +111,4 @@ export interface ClientProtocolCircuitVerifier { * @returns True if the proof is valid, false otherwise */ verifyProof(tx: Tx): Promise; - - /** - * Returns the verification keys used to verify tx proofs. - */ - getVerificationKeys(): Promise; } diff --git a/yarn-project/circuit-types/src/tx/processed_tx.ts b/yarn-project/circuit-types/src/tx/processed_tx.ts index bb96b7f5615..edf5228603c 100644 --- a/yarn-project/circuit-types/src/tx/processed_tx.ts +++ b/yarn-project/circuit-types/src/tx/processed_tx.ts @@ -207,11 +207,12 @@ export function makePaddingProcessedTx( * Makes an empty tx from an empty kernel circuit public inputs. * @returns A processed empty tx. */ -export function makeEmptyProcessedTx(header: Header, chainId: Fr, version: Fr): ProcessedTx { +export function makeEmptyProcessedTx(header: Header, chainId: Fr, version: Fr, vkTreeRoot: Fr): ProcessedTx { const emptyKernelOutput = KernelCircuitPublicInputs.empty(); emptyKernelOutput.constants.historicalHeader = header; emptyKernelOutput.constants.txContext.chainId = chainId; emptyKernelOutput.constants.txContext.version = version; + emptyKernelOutput.constants.vkTreeRoot = vkTreeRoot; const emptyProof = makeEmptyProof(); const hash = new TxHash(Fr.ZERO.toBuffer()); diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index bc4a5a91d2f..91e6484dffc 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -35,13 +35,12 @@ export const MAX_ENCRYPTED_LOGS_PER_TX = 8; export const MAX_UNENCRYPTED_LOGS_PER_TX = 8; export const MAX_PUBLIC_DATA_HINTS = 128; export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; -export const VK_TREE_HEIGHT = 3; +export const VK_TREE_HEIGHT = 5; export const FUNCTION_TREE_HEIGHT = 5; export const NOTE_HASH_TREE_HEIGHT = 32; export const PUBLIC_DATA_TREE_HEIGHT = 40; export const NULLIFIER_TREE_HEIGHT = 20; export const L1_TO_L2_MSG_TREE_HEIGHT = 16; -export const ROLLUP_VK_TREE_HEIGHT = 8; export const ARTIFACT_FUNCTION_TREE_MAX_HEIGHT = 5; export const NULLIFIER_TREE_ID = 0; export const NOTE_HASH_TREE_ID = 1; @@ -57,6 +56,25 @@ export const NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 14; export const PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH = 34; export const L1_TO_L2_MSG_SUBTREE_HEIGHT = 4; export const L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12; +export const PRIVATE_KERNEL_INIT_INDEX = 0; +export const PRIVATE_KERNEL_INNER_INDEX = 1; +export const PRIVATE_KERNEL_RESET_FULL_INDEX = 2; +export const PRIVATE_KERNEL_RESET_BIG_INDEX = 3; +export const PRIVATE_KERNEL_RESET_MEDIUM_INDEX = 4; +export const PRIVATE_KERNEL_RESET_SMALL_INDEX = 5; +export const PRIVATE_KERNEL_TAIL_INDEX = 10; +export const PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX = 11; +export const EMPTY_NESTED_INDEX = 12; +export const PRIVATE_KERNEL_EMPTY_INDEX = 13; +export const PUBLIC_KERNEL_SETUP_INDEX = 14; +export const PUBLIC_KERNEL_APP_LOGIC_INDEX = 15; +export const PUBLIC_KERNEL_TEARDOWN_INDEX = 16; +export const PUBLIC_KERNEL_TAIL_INDEX = 17; +export const BASE_PARITY_INDEX = 18; +export const ROOT_PARITY_INDEX = 19; +export const BASE_ROLLUP_INDEX = 20; +export const MERGE_ROLLUP_INDEX = 21; +export const ROOT_ROLLUP_INDEX = 22; export const FUNCTION_SELECTOR_NUM_BYTES = 4; export const ARGS_HASH_CHUNK_LENGTH = 16; export const ARGS_HASH_CHUNK_COUNT = 16; @@ -148,16 +166,16 @@ export const PUBLIC_DATA_READ_LENGTH = 2; export const VALIDATION_REQUESTS_LENGTH = 1026; export const PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; export const COMBINED_ACCUMULATED_DATA_LENGTH = 333; -export const COMBINED_CONSTANT_DATA_LENGTH = 40; +export const COMBINED_CONSTANT_DATA_LENGTH = 41; export const PUBLIC_CALL_STACK_ITEM_COMPRESSED_LENGTH = 16; export const CALL_REQUEST_LENGTH = 7; export const PRIVATE_ACCUMULATED_DATA_LENGTH = 1168; -export const PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2243; +export const PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2244; export const PUBLIC_ACCUMULATED_DATA_LENGTH = 983; -export const PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3258; -export const KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 383; -export const CONSTANT_ROLLUP_DATA_LENGTH = 14; -export const BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 31; +export const PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3259; +export const KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 384; +export const CONSTANT_ROLLUP_DATA_LENGTH = 11; +export const BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 28; export const ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_LENGTH = 9; export const GET_NOTES_ORACLE_RETURN_LENGTH = 674; export const NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 2048; diff --git a/yarn-project/circuits.js/src/contract/contract_address.test.ts b/yarn-project/circuits.js/src/contract/contract_address.test.ts index 9f424a3d665..ac6eca06396 100644 --- a/yarn-project/circuits.js/src/contract/contract_address.test.ts +++ b/yarn-project/circuits.js/src/contract/contract_address.test.ts @@ -1,4 +1,4 @@ -import { ABIParameterVisibility, type FunctionAbi, FunctionType } from '@aztec/foundation/abi'; +import { type FunctionAbi, FunctionType } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing'; @@ -38,7 +38,7 @@ describe('ContractAddress', () => { isInternal: false, isStatic: false, name: 'fun', - parameters: [{ name: 'param1', type: { kind: 'boolean' }, visibility: ABIParameterVisibility.SECRET }], + parameters: [{ name: 'param1', type: { kind: 'boolean' }, visibility: 'private' }], returnTypes: [], }; const mockArgs: any[] = [true]; diff --git a/yarn-project/circuits.js/src/index.ts b/yarn-project/circuits.js/src/index.ts index 875f51fe952..3b7dba0dfef 100644 --- a/yarn-project/circuits.js/src/index.ts +++ b/yarn-project/circuits.js/src/index.ts @@ -6,3 +6,4 @@ export * from './keys/index.js'; export * from './structs/index.js'; export * from './types/index.js'; export * from './utils/index.js'; +export * from './merkle/index.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts index de03065d49f..a1c58d78678 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts @@ -1,4 +1,4 @@ -import { type Fr } from '@aztec/foundation/fields'; +import { Fr } from '@aztec/foundation/fields'; import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -22,21 +22,30 @@ export class CombinedConstantData { * protocol to execute and prove the transaction. */ public txContext: TxContext, + /** + * Root of the vk tree for the protocol circuits. + */ + public vkTreeRoot: Fr, /** Present when output by a public kernel, empty otherwise. */ public globalVariables: GlobalVariables, ) {} toBuffer() { - return serializeToBuffer(this.historicalHeader, this.txContext, this.globalVariables); + return serializeToBuffer(this.historicalHeader, this.txContext, this.vkTreeRoot, this.globalVariables); } getSize() { return this.historicalHeader.getSize() + this.txContext.getSize() + this.globalVariables.getSize(); } - static from({ historicalHeader, txContext, globalVariables }: FieldsOf): CombinedConstantData { - return new CombinedConstantData(historicalHeader, txContext, globalVariables); + static from({ + historicalHeader, + txContext, + vkTreeRoot, + globalVariables, + }: FieldsOf): CombinedConstantData { + return new CombinedConstantData(historicalHeader, txContext, vkTreeRoot, globalVariables); } /** @@ -49,6 +58,7 @@ export class CombinedConstantData { return new CombinedConstantData( reader.readObject(Header), reader.readObject(TxContext), + Fr.fromBuffer(reader), reader.readObject(GlobalVariables), ); } @@ -58,11 +68,12 @@ export class CombinedConstantData { return new CombinedConstantData( reader.readObject(Header), reader.readObject(TxContext), + reader.readField(), reader.readObject(GlobalVariables), ); } static empty() { - return new CombinedConstantData(Header.empty(), TxContext.empty(), GlobalVariables.empty()); + return new CombinedConstantData(Header.empty(), TxContext.empty(), Fr.ZERO, GlobalVariables.empty()); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.test.ts b/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.test.ts index e5ab98a82c1..e6997878696 100644 --- a/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.test.ts +++ b/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.test.ts @@ -38,6 +38,7 @@ describe('KernelCircuitPublicInputs', () => { inclusionFee: new Fr(42), }), ), + new Fr(0), GlobalVariables.empty(), ), PartialStateReference.empty(), diff --git a/yarn-project/circuits.js/src/structs/kernel/private_kernel_empty_inputs.ts b/yarn-project/circuits.js/src/structs/kernel/private_kernel_empty_inputs.ts index b4ee34c1a6e..01ea1fb6113 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_kernel_empty_inputs.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_kernel_empty_inputs.ts @@ -15,14 +15,21 @@ export class PrivateKernelEmptyInputs { public readonly header: Header, public readonly chainId: Fr, public readonly version: Fr, + public readonly vkTreeRoot: Fr, ) {} toBuffer(): Buffer { - return serializeToBuffer(this.emptyNested, this.header, this.chainId, this.version); + return serializeToBuffer(this.emptyNested, this.header, this.chainId, this.version, this.vkTreeRoot); } static from(fields: FieldsOf) { - return new PrivateKernelEmptyInputs(fields.emptyNested, fields.header, fields.chainId, fields.version); + return new PrivateKernelEmptyInputs( + fields.emptyNested, + fields.header, + fields.chainId, + fields.version, + fields.vkTreeRoot, + ); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/private_kernel_init_circuit_private_inputs.ts b/yarn-project/circuits.js/src/structs/kernel/private_kernel_init_circuit_private_inputs.ts index 9cb9adbd836..e6cc1f4f3ce 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_kernel_init_circuit_private_inputs.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_kernel_init_circuit_private_inputs.ts @@ -1,3 +1,4 @@ +import { Fr } from '@aztec/foundation/fields'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { TxRequest } from '../tx_request.js'; @@ -12,6 +13,10 @@ export class PrivateKernelInitCircuitPrivateInputs { * The transaction request which led to the creation of these inputs. */ public txRequest: TxRequest, + /** + * The root of the vk tree. + */ + public vkTreeRoot: Fr, /** * Private calldata corresponding to this iteration of the kernel. */ @@ -23,7 +28,7 @@ export class PrivateKernelInitCircuitPrivateInputs { * @returns The buffer. */ toBuffer() { - return serializeToBuffer(this.txRequest, this.privateCall); + return serializeToBuffer(this.txRequest, this.vkTreeRoot, this.privateCall); } /** @@ -33,6 +38,10 @@ export class PrivateKernelInitCircuitPrivateInputs { */ static fromBuffer(buffer: Buffer | BufferReader): PrivateKernelInitCircuitPrivateInputs { const reader = BufferReader.asReader(buffer); - return new PrivateKernelInitCircuitPrivateInputs(reader.readObject(TxRequest), reader.readObject(PrivateCallData)); + return new PrivateKernelInitCircuitPrivateInputs( + reader.readObject(TxRequest), + Fr.fromBuffer(reader), + reader.readObject(PrivateCallData), + ); } } diff --git a/yarn-project/circuits.js/src/structs/parity/base_parity_inputs.ts b/yarn-project/circuits.js/src/structs/parity/base_parity_inputs.ts index c1458fe5fd6..292432538cc 100644 --- a/yarn-project/circuits.js/src/structs/parity/base_parity_inputs.ts +++ b/yarn-project/circuits.js/src/structs/parity/base_parity_inputs.ts @@ -7,21 +7,24 @@ export class BaseParityInputs { constructor( /** Aggregated proof of all the parity circuit iterations. */ public readonly msgs: Tuple, + /** Root of the VK tree */ + public readonly vkTreeRoot: Fr, ) {} public static fromSlice( array: Tuple, index: number, + vkTreeRoot: Fr, ): BaseParityInputs { const start = index * NUM_MSGS_PER_BASE_PARITY; const end = start + NUM_MSGS_PER_BASE_PARITY; const msgs = array.slice(start, end); - return new BaseParityInputs(msgs as Tuple); + return new BaseParityInputs(msgs as Tuple, vkTreeRoot); } /** Serializes the inputs to a buffer. */ toBuffer() { - return serializeToBuffer(this.msgs); + return serializeToBuffer(this.msgs, this.vkTreeRoot); } /** Serializes the inputs to a hex string. */ @@ -35,7 +38,7 @@ export class BaseParityInputs { */ static fromBuffer(buffer: Buffer | BufferReader) { const reader = BufferReader.asReader(buffer); - return new BaseParityInputs(reader.readArray(NUM_MSGS_PER_BASE_PARITY, Fr)); + return new BaseParityInputs(reader.readArray(NUM_MSGS_PER_BASE_PARITY, Fr), Fr.fromBuffer(reader)); } /** diff --git a/yarn-project/circuits.js/src/structs/parity/parity_public_inputs.ts b/yarn-project/circuits.js/src/structs/parity/parity_public_inputs.ts index f160be71bf5..2d909fe4a88 100644 --- a/yarn-project/circuits.js/src/structs/parity/parity_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/parity/parity_public_inputs.ts @@ -8,6 +8,8 @@ export class ParityPublicInputs { public shaRoot: Fr, /** Root of the converted tree. */ public convertedRoot: Fr, + /** Root of the VK tree */ + public vkTreeRoot: Fr, ) { if (shaRoot.toBuffer()[0] != 0) { throw new Error(`shaRoot buffer must be 31 bytes. Got 32 bytes`); @@ -45,7 +47,7 @@ export class ParityPublicInputs { * @returns The instance fields. */ static getFields(fields: FieldsOf) { - return [fields.shaRoot, fields.convertedRoot] as const; + return [fields.shaRoot, fields.convertedRoot, fields.vkTreeRoot] as const; } /** @@ -55,7 +57,7 @@ export class ParityPublicInputs { */ static fromBuffer(buffer: Buffer | BufferReader) { const reader = BufferReader.asReader(buffer); - return new ParityPublicInputs(reader.readObject(Fr), reader.readObject(Fr)); + return new ParityPublicInputs(reader.readObject(Fr), reader.readObject(Fr), Fr.fromBuffer(reader)); } /** diff --git a/yarn-project/circuits.js/src/structs/parity/root_parity_input.ts b/yarn-project/circuits.js/src/structs/parity/root_parity_input.ts index 1496d19b179..87e1f7b3609 100644 --- a/yarn-project/circuits.js/src/structs/parity/root_parity_input.ts +++ b/yarn-project/circuits.js/src/structs/parity/root_parity_input.ts @@ -1,6 +1,8 @@ -import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { Fr } from '@aztec/foundation/fields'; +import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; +import { VK_TREE_HEIGHT } from '../../constants.gen.js'; import { RecursiveProof } from '../recursive_proof.js'; import { VerificationKeyAsFields } from '../verification_key.js'; import { ParityPublicInputs } from './parity_public_inputs.js'; @@ -11,6 +13,8 @@ export class RootParityInput { public readonly proof: RecursiveProof, /** The circuit's verification key */ public readonly verificationKey: VerificationKeyAsFields, + /** The vk path in the vk tree*/ + public readonly vkPath: Tuple, /** The public inputs of the parity circuit. */ public readonly publicInputs: ParityPublicInputs, ) {} @@ -30,7 +34,7 @@ export class RootParityInput { } static getFields(fields: FieldsOf>) { - return [fields.proof, fields.verificationKey, fields.publicInputs] as const; + return [fields.proof, fields.verificationKey, fields.vkPath, fields.publicInputs] as const; } static fromBuffer( @@ -41,6 +45,7 @@ export class RootParityInput { return new RootParityInput( RecursiveProof.fromBuffer(reader, expectedSize), reader.readObject(VerificationKeyAsFields), + reader.readArray(VK_TREE_HEIGHT, Fr), reader.readObject(ParityPublicInputs), ); } diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 96603d92254..fbe008cc036 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -27,21 +27,9 @@ export class ConstantRollupData { public lastArchive: AppendOnlyTreeSnapshot, /** - * Root of the private kernel verification key tree. + * Root of the verification key tree. */ - public privateKernelVkTreeRoot: Fr, - /** - * Root of the public kernel circuit verification key tree. - */ - public publicKernelVkTreeRoot: Fr, - /** - * Hash of the base rollup circuit verification key. - */ - public baseRollupVkHash: Fr, - /** - * Hash of the merge rollup circuit verification key. - */ - public mergeRollupVkHash: Fr, + public vkTreeRoot: Fr, /** * Global variables for the block */ @@ -57,33 +45,16 @@ export class ConstantRollupData { return new ConstantRollupData( reader.readObject(AppendOnlyTreeSnapshot), Fr.fromBuffer(reader), - Fr.fromBuffer(reader), - Fr.fromBuffer(reader), - Fr.fromBuffer(reader), reader.readObject(GlobalVariables), ); } static getFields(fields: FieldsOf) { - return [ - fields.lastArchive, - fields.privateKernelVkTreeRoot, - fields.publicKernelVkTreeRoot, - fields.baseRollupVkHash, - fields.mergeRollupVkHash, - fields.globalVariables, - ] as const; + return [fields.lastArchive, fields.vkTreeRoot, fields.globalVariables] as const; } static empty() { - return new ConstantRollupData( - AppendOnlyTreeSnapshot.zero(), - Fr.ZERO, - Fr.ZERO, - Fr.ZERO, - Fr.ZERO, - GlobalVariables.empty(), - ); + return new ConstantRollupData(AppendOnlyTreeSnapshot.zero(), Fr.ZERO, GlobalVariables.empty()); } toBuffer() { diff --git a/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts b/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts index f516fc34854..85d495186be 100644 --- a/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts +++ b/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts @@ -1,9 +1,8 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { NESTED_RECURSIVE_PROOF_LENGTH, ROLLUP_VK_TREE_HEIGHT } from '../../constants.gen.js'; +import { NESTED_RECURSIVE_PROOF_LENGTH, VK_TREE_HEIGHT } from '../../constants.gen.js'; import { MembershipWitness } from '../membership_witness.js'; import { RecursiveProof } from '../recursive_proof.js'; -import { type UInt32 } from '../shared.js'; import { VerificationKeyAsFields } from '../verification_key.js'; import { BaseOrMergeRollupPublicInputs } from './base_or_merge_rollup_public_inputs.js'; @@ -24,14 +23,10 @@ export class PreviousRollupData { * The verification key of the base or merge rollup circuit. */ public vk: VerificationKeyAsFields, - /** - * The index of the rollup circuit's vk in a big tree of rollup circuit vks. - */ - public vkIndex: UInt32, /** * Sibling path of the rollup circuit's vk in a big tree of rollup circuit vks. */ - public vkSiblingPath: MembershipWitness, + public vkWitness: MembershipWitness, ) {} /** @@ -39,7 +34,7 @@ export class PreviousRollupData { * @returns The buffer of the serialized previous rollup data. */ public toBuffer(): Buffer { - return serializeToBuffer(this.baseOrMergeRollupPublicInputs, this.proof, this.vk, this.vkIndex, this.vkSiblingPath); + return serializeToBuffer(this.baseOrMergeRollupPublicInputs, this.proof, this.vk, this.vkWitness); } /** @@ -53,8 +48,7 @@ export class PreviousRollupData { reader.readObject(BaseOrMergeRollupPublicInputs), RecursiveProof.fromBuffer(reader, NESTED_RECURSIVE_PROOF_LENGTH), reader.readObject(VerificationKeyAsFields), - reader.readNumber(), - MembershipWitness.fromBuffer(reader, ROLLUP_VK_TREE_HEIGHT), + MembershipWitness.fromBuffer(reader, VK_TREE_HEIGHT), ); } } diff --git a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts index 10a82972ba5..dc1e47ef5a5 100644 --- a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts @@ -129,12 +129,14 @@ export class RootRollupPublicInputs { constructor( /** Snapshot of archive tree after this block/rollup been processed */ public archive: AppendOnlyTreeSnapshot, + /** The root for the protocol circuits vk tree */ + public vkTreeRoot: Fr, /** A header of an L2 block. */ public header: Header, ) {} static getFields(fields: FieldsOf) { - return [fields.archive, fields.header] as const; + return [fields.archive, fields.vkTreeRoot, fields.header] as const; } toBuffer() { @@ -156,7 +158,11 @@ export class RootRollupPublicInputs { */ public static fromBuffer(buffer: Buffer | BufferReader): RootRollupPublicInputs { const reader = BufferReader.asReader(buffer); - return new RootRollupPublicInputs(reader.readObject(AppendOnlyTreeSnapshot), reader.readObject(Header)); + return new RootRollupPublicInputs( + reader.readObject(AppendOnlyTreeSnapshot), + Fr.fromBuffer(reader), + reader.readObject(Header), + ); } toString() { diff --git a/yarn-project/circuits.js/src/structs/verification_key.ts b/yarn-project/circuits.js/src/structs/verification_key.ts index 2b3745e7143..4e66c1e5a82 100644 --- a/yarn-project/circuits.js/src/structs/verification_key.ts +++ b/yarn-project/circuits.js/src/structs/verification_key.ts @@ -256,28 +256,3 @@ export class VerificationKeyData { return VerificationKeyData.fromBuffer(this.toBuffer()); } } - -/** - * Well-known verification keys. - */ -export interface VerificationKeys { - /** - * Verification key for the default private kernel tail circuit. - */ - privateKernelCircuit: VerificationKeyData; - /** - * Verification key for the default private kernel circuit. - */ - privateKernelToPublicCircuit: VerificationKeyData; -} - -/** - * Returns mock verification keys for each well known circuit. - * @returns A VerificationKeys object with fake values. - */ -export function getMockVerificationKeys(): VerificationKeys { - return { - privateKernelCircuit: VerificationKeyData.makeFake(), - privateKernelToPublicCircuit: VerificationKeyData.makeFake(), - }; -} diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index dc15c1de700..cef3587cd07 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -119,7 +119,6 @@ import { PublicKernelData, PublicKernelTailCircuitPrivateInputs, RECURSIVE_PROOF_LENGTH, - ROLLUP_VK_TREE_HEIGHT, ReadRequest, RevertCode, RollupTypes, @@ -195,7 +194,12 @@ export function makeTxContext(seed: number = 1): TxContext { * @returns A constant data object. */ export function makeConstantData(seed = 1): CombinedConstantData { - return new CombinedConstantData(makeHeader(seed, undefined), makeTxContext(seed + 4), makeGlobalVariables(seed + 5)); + return new CombinedConstantData( + makeHeader(seed, undefined), + makeTxContext(seed + 4), + new Fr(seed + 1), + makeGlobalVariables(seed + 5), + ); } /** @@ -320,7 +324,12 @@ export function makeRollupValidationRequests(seed = 1) { } export function makeCombinedConstantData(seed = 1): CombinedConstantData { - return new CombinedConstantData(makeHeader(seed), makeTxContext(seed + 0x100), makeGlobalVariables(seed + 0x200)); + return new CombinedConstantData( + makeHeader(seed), + makeTxContext(seed + 0x100), + new Fr(seed + 0x200), + makeGlobalVariables(seed + 0x300), + ); } /** @@ -865,11 +874,8 @@ export function makeConstantBaseRollupData( ): ConstantRollupData { return ConstantRollupData.from({ lastArchive: makeAppendOnlyTreeSnapshot(seed + 0x300), - privateKernelVkTreeRoot: fr(seed + 0x401), - publicKernelVkTreeRoot: fr(seed + 0x402), - baseRollupVkHash: fr(seed + 0x403), - mergeRollupVkHash: fr(seed + 0x404), - globalVariables: globalVariables ?? makeGlobalVariables(seed + 0x405), + vkTreeRoot: fr(seed + 0x401), + globalVariables: globalVariables ?? makeGlobalVariables(seed + 0x402), }); } @@ -955,8 +961,7 @@ export function makePreviousRollupData( makeBaseOrMergeRollupPublicInputs(seed, globalVariables), makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH, seed + 0x50), VerificationKeyAsFields.makeFake(), - seed + 0x110, - makeMembershipWitness(ROLLUP_VK_TREE_HEIGHT, seed + 0x120), + makeMembershipWitness(VK_TREE_HEIGHT, seed + 0x120), ); } @@ -985,16 +990,21 @@ export function makeRootParityInput( return new RootParityInput( makeRecursiveProof(proofSize, seed), VerificationKeyAsFields.makeFake(seed + 0x100), - makeParityPublicInputs(seed + 0x200), + makeTuple(VK_TREE_HEIGHT, fr, 0x200), + makeParityPublicInputs(seed + 0x300), ); } export function makeParityPublicInputs(seed = 0): ParityPublicInputs { - return new ParityPublicInputs(new Fr(BigInt(seed + 0x200)), new Fr(BigInt(seed + 0x300))); + return new ParityPublicInputs( + new Fr(BigInt(seed + 0x200)), + new Fr(BigInt(seed + 0x300)), + new Fr(BigInt(seed + 0x400)), + ); } export function makeBaseParityInputs(seed = 0): BaseParityInputs { - return new BaseParityInputs(makeTuple(NUM_MSGS_PER_BASE_PARITY, fr, seed + 0x3000)); + return new BaseParityInputs(makeTuple(NUM_MSGS_PER_BASE_PARITY, fr, seed + 0x3000), new Fr(seed + 0x4000)); } export function makeRootParityInputs(seed = 0): RootParityInputs { @@ -1020,6 +1030,7 @@ export function makeRootRollupPublicInputs( return RootRollupPublicInputs.from({ archive: makeAppendOnlyTreeSnapshot(seed + 0x100), header: makeHeader(seed + 0x200, blockNumber), + vkTreeRoot: fr(seed + 0x300), }); } diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index 303d4d9c336..34b2c2a91b9 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -67,6 +67,7 @@ "@aztec/foundation": "workspace:^", "@aztec/l1-artifacts": "workspace:^", "@aztec/noir-contracts.js": "workspace:^", + "@aztec/noir-protocol-circuits-types": "workspace:^", "@aztec/protocol-contracts": "workspace:^", "@aztec/simulator": "workspace:^", "@aztec/types": "workspace:^", diff --git a/yarn-project/cli/src/utils.ts b/yarn-project/cli/src/utils.ts index 2d731424666..0d8d714d533 100644 --- a/yarn-project/cli/src/utils.ts +++ b/yarn-project/cli/src/utils.ts @@ -12,6 +12,7 @@ import { PortalERC20Abi, PortalERC20Bytecode, } from '@aztec/l1-artifacts'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token'; import TOML from '@iarna/toml'; @@ -104,6 +105,7 @@ export async function deployAztecContracts( }; return await deployL1Contracts(chain.rpcUrl, account, chain.chainInfo, debugLogger, l1Artifacts, { l2GasTokenAddress: GasTokenAddress, + vkTreeRoot: getVKTreeRoot(), }); } diff --git a/yarn-project/cli/tsconfig.json b/yarn-project/cli/tsconfig.json index 80b20c28830..0627dbf0496 100644 --- a/yarn-project/cli/tsconfig.json +++ b/yarn-project/cli/tsconfig.json @@ -33,6 +33,9 @@ { "path": "../noir-contracts.js" }, + { + "path": "../noir-protocol-circuits-types" + }, { "path": "../protocol-contracts" }, diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 6444cf51694..fe4762ed479 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -34,6 +34,7 @@ "@aztec/l1-artifacts": "workspace:^", "@aztec/merkle-tree": "workspace:^", "@aztec/noir-contracts.js": "workspace:^", + "@aztec/noir-protocol-circuits-types": "workspace:^", "@aztec/p2p": "workspace:^", "@aztec/protocol-contracts": "workspace:^", "@aztec/prover-client": "workspace:^", diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index 628bfaf8db3..c797483e372 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -29,7 +29,6 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, type Proof, PublicDataUpdateRequest, - getMockVerificationKeys, makeEmptyProof, } from '@aztec/circuits.js'; import { fr, makeProof } from '@aztec/circuits.js/testing'; @@ -38,6 +37,7 @@ import { makeTuple, range } from '@aztec/foundation/array'; import { openTmpStore } from '@aztec/kv-store/utils'; import { AvailabilityOracleAbi, InboxAbi, OutboxAbi, RollupAbi } from '@aztec/l1-artifacts'; import { SHA256Trunc, StandardTree } from '@aztec/merkle-tree'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { TxProver } from '@aztec/prover-client'; import { type L1Publisher, getL1Publisher } from '@aztec/sequencer-client'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; @@ -146,7 +146,7 @@ describe('L1Publisher integration', () => { }; const worldStateSynchronizer = new ServerWorldStateSynchronizer(tmpStore, builderDb, blockSource, worldStateConfig); await worldStateSynchronizer.start(); - builder = await TxProver.new(config, getMockVerificationKeys(), worldStateSynchronizer, new NoopTelemetryClient()); + builder = await TxProver.new(config, worldStateSynchronizer, new NoopTelemetryClient()); l2Proof = makeEmptyProof(); publisher = getL1Publisher({ @@ -165,7 +165,12 @@ describe('L1Publisher integration', () => { }); const makeEmptyProcessedTx = () => { - const tx = makeEmptyProcessedTxFromHistoricalTreeRoots(prevHeader, new Fr(chainId), new Fr(config.version)); + const tx = makeEmptyProcessedTxFromHistoricalTreeRoots( + prevHeader, + new Fr(chainId), + new Fr(config.version), + getVKTreeRoot(), + ); return tx; }; @@ -174,6 +179,7 @@ describe('L1Publisher integration', () => { const kernelOutput = KernelCircuitPublicInputs.empty(); kernelOutput.constants.txContext.chainId = fr(chainId); kernelOutput.constants.txContext.version = fr(config.version); + kernelOutput.constants.vkTreeRoot = getVKTreeRoot(); kernelOutput.constants.historicalHeader = prevHeader; kernelOutput.end.publicDataUpdateRequests = makeTuple( MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, diff --git a/yarn-project/end-to-end/src/fixtures/dumps/block_result.json b/yarn-project/end-to-end/src/fixtures/dumps/block_result.json index 3002f03ab91..8243c7cfef2 100644 --- a/yarn-project/end-to-end/src/fixtures/dumps/block_result.json +++ b/yarn-project/end-to-end/src/fixtures/dumps/block_result.json @@ -1 +1 @@ -{"block":"02b1d92c03a900077142be58e050a4851b5ddd96de8d5be19a2883a1c1092ab6000000080000000000000000000000000000000000000000000000000000000000000001005bdc3f48834bbbaa08489f73194da5da4557159e2617ccb5a2b6f98d86f9f800089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f80000000800864cd058d35f391fe0af0fc7afab73141bd52d68a0cb5e9c891aae026ed35d4000004002b30d43b02736c4596954b375b80b5e89fb06b51412fa6853cf3d9096cdfa33b000004800684192208ee5f4c87ffe2eea98d55c8f52a4860e4ff8edb3499a52f37bbb84e000002400000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000664e8d5e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000bf113f813c80273df0c9727a8ad0d4c73edba9071a8fbc8469486c79f49b90e79dcb682000000090000000200000000000000000000000000000000000000000000000000000000000bf113f800011450ec40acf6dc5c5f2438d935ba79c9170f67dd3d2fd67200742b0d1572c6ee000206415339676e7d61706dc747fa9943430da5c9bb48735f2e90426ff3ce5928c50000000000000000000000000000000000000000000000000000000000001388249eb7a7cfbd40fbf5c928c6875d9ee3afba5069a1184e8e958d427cd4cc53b70000000000000000000000000000000000000000000000000000000000001388000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000040000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000002118f9f85f477b211579f2d8f6cf19559ae8cc749a8f6f6ee04882320e5b87ace2d11e4310b21ed24d5df6a1347d249a12ff1251049bc68f369ba1cdcfb41708e0225f50389f2d607ab1dd7dba47739ed71595b68bef6556b4afdc06c2f3045ca7d1b9d5f3e1f6886b34a519a8fade967ed20d1893963dc6908eab0d1279add9a490000000000000000000000000000000000000000000000000000000000000000048800000000000000000000000000000000000000000000000000000000000000000000048c00000488000002400000000000000000000000000000000000000000000000000000000000000021000000000000000000000000000000000000000000000000000000000000002126c82b15717f9760f038b474d5e98064e3e364d9a21094cc0a541cbb1bdee628234e5b9f02fe9a39a85888057745ffaa6bef381e4f12e3e0d4b93e4ddd6214e257025cc37c776f03fc1231f9a642b420b051371f6a6f1868b35dae60f9d618a10d266088a97901f4cc2df40a93f581d0adef0a4d15509ebb140bbdf7ffa64d9a94114e5014ee84fe194cbefe030e945962e5442f9c74d1082e1c48c236a35a15236148efe47ac4babefcfe8f751ce25107650a14c487a8d6f9053b2b8df003227e52e9b2bc9ca917738112ea17c306030ca0dbce80d317be7dd81dcdd08afae7ab468db0188fa95b50e325fdbb3864e9e9ea6b57d80a6c92ce8bb5f1f1c411b69c91002f319b77def9f9806d5e93033b2f2db6d61eea61b2cdc41b8a35b45886e9b971243010e788935bd0f26120bce128500381228c6d08b731e87fba69b32cbd3c605728363650d26f0bcf386587875932581e8473f915e96a1bfce34026cc9f2c0c15b9cc35b6eb5ec44afe8581ff0e607a74e12b4c84154a11ee87c20436947e921f06cf6f631052ec880f5d482a3901a045043e74b3d5b723ca9bb4ce30cefded1a5879b11bb8bdc94d8087bdb1ed4aa0f98d25ffaffa861c4e45b65af2f793c3bba6ffd618b78f8d7ef1875d61d2df0129cb842b2dfa65c0b11ba9ad38e792a214188d835720b076678b011adf91ab932845a041ac3d290d0b8ee2db5800000240000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000212b234cd92b2aacd26698861a4e799d9334988e4c2d2f02899b59d82460401c24091f8c12503ceea9d78e204d49cde61edc20eb9a4fe47d9491df06e34fdd3981add82df4836beb1009d534be5972786548ff70490d4b690d30fd8b1326ddec7b4f065f8c692e2612364f4636d7b4d65aa6a10009ac61dabb9f660fd4bfe8a8606837d2995560851c0f318d156071ea2ba1132b8fae2174d74a97fc5b923dd595961df649df446e8cced8dae0ea78a67f0c13f8c2b2ff4ec0fee86bdd3003e4871da3a5dfe9e278918ccda5ffb156266d48b7582d49b7be47f34c4a98f112291373b473281aba42422c116d3e3b6efcb23e3040e697cc08253f84bba2df19aa3c3c751b22c6b4c4166b96f920ee31a5621355881147ba1502b13c44ed866198f711356602f7316df474ce682cfaa77763137e55afd7bdf4a0e5bc48c5dda65022a8e5cd790ddeab34197129a783bb29e39e27dd1d0fefbcccc172480993dc0f46ac21edf7eb60106e0695df288a7b515efb75ab6fff2d4ed3ae569ce305be97566bbed06bd5b3770f1957f7777c2f837586255caa89ee36c72850a5b6e75baebf7aedcaec041fc721a31b824d7de8f24abdc6d5cd2a5d2d8e1c6c5a0f8e6efcdd07ffcd11f9edca5dab35a1c7becc3d5953256601880d0d499c73fc0d6218303b2a4126780a63e7196c74cd55300dd5a92c299e70d85bcbd4e170fb6ba99e72e800000004000000000000000400000000","proof":"00000d8013c80273df0c9727a8ad0d4c73edba9071a8fbc8469486c79f49b90e79dcb682000000000000000000000000000000000000000000000000000000000000000902b1d92c03a900077142be58e050a4851b5ddd96de8d5be19a2883a1c1092ab600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001005bdc3f48834bbbaa08489f73194da5da4557159e2617ccb5a2b6f98d86f9f800089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f8000000000000000000000000000000000000000000000000000000000000000800864cd058d35f391fe0af0fc7afab73141bd52d68a0cb5e9c891aae026ed35d400000000000000000000000000000000000000000000000000000000000004002b30d43b02736c4596954b375b80b5e89fb06b51412fa6853cf3d9096cdfa33b00000000000000000000000000000000000000000000000000000000000004800684192208ee5f4c87ffe2eea98d55c8f52a4860e4ff8edb3499a52f37bbb84e00000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000664e8d5e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000bf113f8000000000000000000000000000000000000000000000002ad1fd114e0a85a8a0000000000000000000000000000000000000000000000094f51514caac5a5be000000000000000000000000000000000000000000000006a86137d3af51d90e0000000000000000000000000000000000000000000000000002de73e2d41a2100000000000000000000000000000000000000000000000379ab4590c5e7052e00000000000000000000000000000000000000000000000d4b7fff8fec02d79a0000000000000000000000000000000000000000000000025e1dcddd8dbdeee80000000000000000000000000000000000000000000000000002d5601e122d1300000000000000000000000000000000000000000000000c53242e73f075453500000000000000000000000000000000000000000000000ecf3715d2bc030f4c00000000000000000000000000000000000000000000000079c6bb4ea1a16f4d00000000000000000000000000000000000000000000000000013c4d0181356c000000000000000000000000000000000000000000000006638bf11bf90232c70000000000000000000000000000000000000000000000074caf7a3bd6c75ac700000000000000000000000000000000000000000000000497840051abc1b1b40000000000000000000000000000000000000000000000000002555c8d188eb0013f6b1408fe596ab4492b56f69d9eac4a669c896e301c9eae287b59c1f3bbe4244a154995cfc71784ca7b79fd66f8869ee17762ecb41f879eed7e16c98694ca0851810a125874fefc198248a79cd808701960716b114565c799707e12307b12130dfb53571cdd4ea09440ba85cab20456c88e727fa3466eabf4cf0e93b8dc182ae56fce0c8f268c443dac3edcb3d9c7de8e54110f763cdac249befe1408dcd525eef89fe8cd2cc860c6194057fcab666bdfa73160ae0a054913a076411432030a9b11dee41bf6a27824f0d87b227f6dddb2d59652181b991becf0540d07d6721c57f7d2a12598edac785c2d7eec5105e12bfc81a58657cb6120ab715305f238207c2cbcc443a9ad3c97df95ffd73807063e50d6d69c45fe4a881db97838f6882ab0c91eabeef9de382d69e26bdc93d04de77d25e9cb76b089aaf321e216530b153c664070900cedf926b4af2492d864ebaf4eec8b5c8c5e37c2a11e9f46b0f42be15477dbdc724da5f83e4908b3af4e69e41f63c0acf612a03ed70304c7cc9605548b41d3c8eae741c05220fa23b9973cb3c9bbd1d44817a76fee92842e232d2a4f404d9fdf3681657b58c17de12c91d788f99a7f22c9f0918e7eb84faadb541810564bc49466cddfa12a1fe8d54a7afdcfed078addcba6aa07bf0b3734203f241dc385ee5c312b3569ec846dd754add2d51605f729c1d813e989b37f7484c32fdd9f338a7ebc38d79215401f69a2d4c8174ee7666e1fbc4fa814f2a4e8e93a1d38ffd418a475da9f15af70dc60523a316df6320063932f56593cc9d6517dd823597488d16d2d0f0a8f8af172431cbadddc0a5afa3b84874bc861fed9b6a596177ec37833d53adae3e2989a4c34c742bcf86a09d1d7d1c4169f2f024064a51916a9bd1c6b86356423b65fbd61165a55b3db385391e7674695cfa0c2b67406271458bac64868dccd480c66ec94cf9b2e93dbf6c2487ca923c484db0a96f5bff40cc903861817778d31da9e698d88ef1da3d6d3310048d8ce41dbe10e4f7c64930841d10bea3a7fd2b7809bef8c9cd148d5a3a0b3edf33cf162ac6711bd25cfa427293eee2cf9412030572f171b544af5fb65c7b2d2f0b9bac75356fb4dd620d22b4d1bf22247b1bea4badc68e3648e519c27882373d33ed6bdb41d6805adf5f62cd25893677862e54dd1bb719e6cafc4ae03fe11d1e809edb5382e979a3c9b2c0a41feff83ee0b70b55eac1dd167c713740c7f9c1ecbf0d0150d53557ead18c62536b99ab8babd9898a8dcbb929bac8908e5b25c4135319a05762fa025b5ade70e4f4fbd3d9ff8a864886d2ec4595296de5d1b6efeca0c3e0968ce142a23e8000724a75ed70e6db551204483f473cebcde47b9e770aeda211fbe8e8122e69e9917113573bc318b14a4724fa44cb1d330bae00504804950c4963a8b8a277f48541522a05a6fb87607cd569af66ef2ed3e0c11e8bda980a37de4691fb09f9a283d1fa2cca913919f4a68d6739ef73d410d2ff1012371574e534da1007a103cc4fa05e372425360126f4837d5cbcd8f7fbd6ddbba1dab3b6eac16359753c1055b7d0a8d30756c6549e9eb977d53279359cd9a42e68e4ee00e8e140decd1521774be2e2c1c34b23edb6b3f7aaceb4babd72d491cf3a93b3911b1835b5120ef39ebf71797a483b76c94ecf940a697f7f93c80fb80c63e9672b3b9387e73a41c5284fa018495451b8e879467e3bf1eee7627ba761115fc868762c9149c1c7cf494faf407a7d5ac7008bb375ac57f3ae6456ae844512892f531ff2fd577caf9d259ae2711e1ba8be98de1af9d1b1c873473256a2b4ed716cae72587eda2eae0c49b85b32a1113caedc44e0a63e9b8ff827ab39da0196311f5f4ecce888c3d6e72940a8f037cf1093f500904920a42fdfbc06528ae60780d808deeaff14b7fd6e81a44391b09ffdefaa69ce164b649743158e31062621e73f96c96ceafdc5c04704c98740c7b54fd8a9dc021e6cb1710cf285e714a8996d17324c10ddd9040fb66ab05cb12817448211186ecc361b5927adf14bda29cc05496ec2ddd6c497fa98c5b925b0738532b291d0725368eecbd5ad8e1909f01813dba182fe78cb09fabef4d515a133b756089ced374f17f7acc67c955dd1f75496eb6e06a1b1b8f0da0585bea1b2d5f329c27625b36b3c6e4d32fa2dd208a781fccf8d00178591f53ffba4fbae1292642d8429b64471b10931a841400bda5e32493c9fdbe3822dcb75cee152a5c0e11da41129a746c65ec1601e4c01499268e5a258271d0fc02c4e25e166eaa7618ce99c369cabc7cd867c8b44d1aea72b350fd92234eae70398379a98f40b6f7292ccf238e0fcafd52cf45fd43e89408272c22623577601f72a0c973f0c714660a7066c7b537b7f6367e3817832e8cb26247c4ba811e039ba168efaeda02251c1224350532f4ef053c248cb5c33e06fd498d4d33760a46a408ffc7d31dfad221221953774d7db534e2890b47bccc80c20a092d79b2c879dbe3618844f309f4a913eb8e1111d959faec030a9403dd6e0e422ac4135ce940866ffb5d3ecb43fb9726218b0c70a223e455b972398a4f3f779d044091099109294fed1eda777a4bb91153c67aa19a0571482d4592dc4e78d138ec672fd7c861256fbad73ae76686d01c6da7fef34438115f6ecf7750f3346473b291c5b65dbd84409bcdf68807ec2d2d9286a5e6985a245bddc63a68a1d3dc9703a942f96e89dd90ccf7ad75eb1fe1151535bd33d92063015039c37717c583cb59599e594042ae5146f28fddab9ad41474b4fdb7d3e131e14d848068ac902094e6400c48fb0ccfa224ec10e145295b0de41e8b0d15886016b11706b31be49d6703972eb032a6e8727290c935546d1d248439d01d7f90e39d9b53e4b5768843a6cdc57dcce29cb2170bc7c4a7a29cab0cd712c7224980ea0deced915e24d30d1ca197ecf3a061a6af8e68a7e8175c351eafc04409c9d4671278e2314d29ead4f9c31356abae69d01076e37136781a3d00000029","aggregationObject":["0x000000000000000000000000000000000000000000000002ad1fd114e0a85a8a","0x0000000000000000000000000000000000000000000000094f51514caac5a5be","0x000000000000000000000000000000000000000000000006a86137d3af51d90e","0x0000000000000000000000000000000000000000000000000002de73e2d41a21","0x00000000000000000000000000000000000000000000000379ab4590c5e7052e","0x00000000000000000000000000000000000000000000000d4b7fff8fec02d79a","0x0000000000000000000000000000000000000000000000025e1dcddd8dbdeee8","0x0000000000000000000000000000000000000000000000000002d5601e122d13","0x00000000000000000000000000000000000000000000000c53242e73f0754535","0x00000000000000000000000000000000000000000000000ecf3715d2bc030f4c","0x00000000000000000000000000000000000000000000000079c6bb4ea1a16f4d","0x00000000000000000000000000000000000000000000000000013c4d0181356c","0x000000000000000000000000000000000000000000000006638bf11bf90232c7","0x0000000000000000000000000000000000000000000000074caf7a3bd6c75ac7","0x00000000000000000000000000000000000000000000000497840051abc1b1b4","0x0000000000000000000000000000000000000000000000000002555c8d188eb0"]} \ No newline at end of file +{"block":"06a48c149b9f07a40484e8ee3f4dc4bddfef61b72cb406c004c2e78409a4195000000009000000000000000000000000000000000000000000000000000000000000000200d4a6b1654c63744d273f4cb9c8cd2e9028912b3c980133873a7d26f9c98efd00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f80000000901cdfa98dc0dcee5ce093e93988a6288fbcada0b334e5687bd452b8e35a76c4f800000480015cfc7c3c062b1ebad0d4222886a8a2e39983ec113de881c4b858269b6f6c8e000005002353fa6fc72e1c9b59cc203024bcdf2f61090ae8ff71ef1c7f9d426aaa31fb3d000005000000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000066879d7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000017d862421cd30d89eda9aec991cbed0e0815bbf9ab46cef6b0f99d2c2c2254a543287c9c0000000a0000000200000000000000000000000000000000000000000000000000000000000bec56b002019c23681b804d9612e0f41081b746a3647b3c4d8074c5d9c5a661c9bd02f48d1f1d4ca452d4f6f8e74f48f02088b7a916a8b3a0548e13c301a6271df0db48aa022ba8f0ef06ee82d116708a3587cb5b01f70cee9b3eb80d07be5fae008226f13f2bb71c545b12dc3f635740f896dc3bda87e9f4c944f74734e99515490eb4026000000000000000000000000000000000000000000000000000000000000000000488000000000000000000000000000000000000000000000000000000000000024400000000000000000000000000000000000000000000000000000000000000000000048c00000488000002400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018b9f587da4ef3fcf590c8ac5acc12610f4b4667b24ed14682f3ae7bc8d7eb2c2db533ef73c5205a40e838722f0cd595a9c10296baea5b707aa82456902e8918cd58639f1409dba7d1351c0bbf3848add8bf2fb24562b0f4426086629c5d16399ba064d36462f25fbd4d9b9b52087cba20bfe599210c6ebe49d6644408ef8ce5c2d0a1ca96b340379a89ca294850401282ce8a7aee5df23f93e1c9383a317bd7ce8c6e2049eae65c850eb43ef4c2f53013ec3fde59903094b231a1289f21c800ffdef142b1f8a14392f22d4ebaa3c599d259662dbcfe0b693a4be216b94345f2e9505ab9b24d30aa04b0b4865e008ceb42a47339f06157a88b3a0b1eb835a287f2a09c1119af2062f4e3f0cc92bfda0cdd82cc8e8c22e7c22d973a93e2866123ac74f5c390868bfd6a79acc92e7dd9a973e191986b3cc62cacb95859a3c0b513a55cbe462fedac523df639c546a5db7eadb24ed8219e0653e209438b8cc08ee455493cfb0bb0fefa3011ff8e731939fe2cab4388923e89d1ed932f2e064814bf00343c3a3b88eb874ad97336a50d511c5f155228bea1b71493492a100a51a53da8f8a22284801dc9fbd36ca19b7c9593399726288b250d8b7d082cde2633da4624cea927a618e18b7e42fd47c8266963edbb428d8cd5fd4f93916db1559eb2b9347f2661696dff0b9b52b76ce32c3f696077d82c8430ad248cabc27bb44d52eb0000024000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083e4a1bebea81168dafad6f2bdacfd40372f7cfc05e70bdf0c92ff2f747471900a2689abc0d110423a66df61236b315d408226743794d09794a29a241abbeb3ac55db0434f6cae603c7fe0c54124454cc861194edac1103313247cd1751aa68b6a5ef176e99741e409f86a37acb1723959ec30138ed02d89c225308a5e68cacec067e6eee13e8d7cf4d7997088c2d63aa7189db1ee5d3fb99883e39dedbe57e0a7c5bc24391063ed8d31b792b12a686467fe5879601c30c553e514b9d16ebebbcce13e92fcc3ccd1445f9db1a68175ee962620c33e379ca37b3e2ea6ca779b74aa0e11bf13211632d7a76fdae54b6cc05ada9960126d89d7b1f5f1ebd5b7236ff3571930ebdd0676d32b4743fbd11d12de06c07af8a90436cc54754f8f4cb70830302b5084eab0c14f479dfbc474f856a2c1965abdf571a218185487fca384e76535ecd0f612dea66fdc71008e9bf314874f93cf5b68bfacf4ddbce9a58b5b626bcefac5c65aab79609bbc60a242da8ad318580a8cac02f697e6b6397cc73063bab35779d1dfc476fca8c73cc3f99275d7f2397d0e1c0ae46b62b3ed239e6cc3a449e197f03d0930242f92ac90076d4f4e22f84ae7e0b5fa47c65569522c52ed8ef75341667ede3802c2308b79eae9c594dc8d40d79d5f448aec20611f76954c534e2d8d653b38a614731a6ba0dd4d1cf3e66efce3b855b209fce80dbcc8b59000002680000026400000260066eff2be6545b71613ee324b4f7644bd07f479ff27f1427c6d2036b094b753f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000091fa823c9d4dad62d349aedc826c1f76d266583a684b2507963c46f06253de1fb741366cb341eb5b6fb18f435dde9b016d2745b4e670b736da74ab04619d105b47a9d0a900ca3e6b9a495200d360e5f56c062979e3dfc01a88d31b8288f18843b10b69dfb1ec05fd47eabafc3247ea5f86b747611d6dbc4e78468fd6b1495cb8ac0e4e16e671432e3034ad004e91bdae4e6f6af41927d94662b02cfc8e489a080edb2f22ca1adbb11618dce8698662de3fb8eb1db97f4a25762d8f23641aedca6bbd1697f104e9a9e7e9110dab84316461573a64f2f9bf67644f378327a3343591585b9080e7db0a329aa1f9372d1ecb1df51c7b43deb155e18f90e5ea05688f7502e7fa30e8ccbfe91ffbfb2ac7000599c4569f909e3e1c64468fd476db3ed58de5cec7b6967a787ee0f28520e6b2ec5cb19764c284315f04f57e946a376b843193ab4ec31c5faf18119a8ffdaea3048c7a2b47b9ddf05102ed1e43ad10d557a652cbe6b0fe7d2feb082f62cb549538d3ec955919d5a382ec815c4a5876a4ed6cd271ccdf9242d9f7a3265c7b2856c1a78aa429667a687f0652bc451f2df88f0845b7e8226edef077685bd47b157f3fc2e84c308faaf5b9c18c13d1bbc06b01b43db5d68d0eb18611505abd4d9ab7b0ad47b1635bb2c831e53e3db2642ca291de395097a8c19edade1938ffec82b7b74c04f0744d163d73e62ca1b6f6cc04000000040000000000000000000000000000000000000000000000000000000000000000000bec0b9200012cd62e91677d9cba2fee4932c0ac07f9bda9f4c0222114798a062fcbe00384e200021c771b1eec4a4b2be897e26cb9331e02654645ea883d6c4e6f4e664f4e2bd14500000000000000000000000000000000000000000000000000000000000013881d6a2422e2bd4b148e058c92a0ae0247efd5164686bc35d166ea6b653ff8cdc5000000000000000000000000000000000000000000000000000000000000138800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000400000000000000080000000000000000","proof":"00000da01cd30d89eda9aec991cbed0e0815bbf9ab46cef6b0f99d2c2c2254a543287c9c000000000000000000000000000000000000000000000000000000000000000a27baa73f715e0ecd7832b9f655a8543cef524f772a37cdbbb1f64b0eb31e922606a48c149b9f07a40484e8ee3f4dc4bddfef61b72cb406c004c2e78409a419500000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000200d4a6b1654c63744d273f4cb9c8cd2e9028912b3c980133873a7d26f9c98efd00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f8000000000000000000000000000000000000000000000000000000000000000901cdfa98dc0dcee5ce093e93988a6288fbcada0b334e5687bd452b8e35a76c4f80000000000000000000000000000000000000000000000000000000000000480015cfc7c3c062b1ebad0d4222886a8a2e39983ec113de881c4b858269b6f6c8e00000000000000000000000000000000000000000000000000000000000005002353fa6fc72e1c9b59cc203024bcdf2f61090ae8ff71ef1c7f9d426aaa31fb3d00000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000066879d7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000017d8624200000000000000000000000000000000000000000000000411700d6c4cf14ec00000000000000000000000000000000000000000000000092a9c3224b018d49d0000000000000000000000000000000000000000000000072d1022a88f16c52b0000000000000000000000000000000000000000000000000001b36811921c81000000000000000000000000000000000000000000000007f0819be5758c25f20000000000000000000000000000000000000000000000007fc055b30fc5cf6400000000000000000000000000000000000000000000000316c9c3b0385c17680000000000000000000000000000000000000000000000000001cd75bd2f36640000000000000000000000000000000000000000000000032f5395931eb1209800000000000000000000000000000000000000000000000f9a88d0be49ab9d4b00000000000000000000000000000000000000000000000d077fab6d15e7029f00000000000000000000000000000000000000000000000000018a72eb3d3bf500000000000000000000000000000000000000000000000446902910332b16570000000000000000000000000000000000000000000000046419b3737fd0a12000000000000000000000000000000000000000000000000c8b87236ac632c8e3000000000000000000000000000000000000000000000000000056b92ff0f1fa0e2d5505193cae745bc5092945b9a60d066ac943b8a21bb7b03cafe1adc3a81326bf7788363144636bd31e3ff842b0a0b925d4b95a5dc9f1210062210e64c85221e2504c667027cd92a45f3cabad887878c49f2ec8faa976a87e185eeac3e44529fa5d26b91c3cd82e5c9c9b14cf51e6515bbdb1d161a2049cdce317dbf5f45b1b120471e41662fc0d4554af553b40a6af62221fc076fdbe8d369b3b997a7d7c26cc2fa11b4a73b65698af048ee23ec107c23b2b2fca160b8590b5e9964f1609047e8037729cd2a3395b53c7ad5530b60a385308d5d0562e535192cfe0f3dee016f14f0193371e7a9a0908e91728d46479e74e6bc12da1444181a1115c2557a5035d1775ad4e31b5b2385a154395d57c1bdf95ba209d525e1f77f6f3fd6749b227b66a096eb901513ac2df36a01d0b2b61616a3a300b85b281a8339571cc133c0a067e38200b49fb3dc8a571102fac8bb1f479ddfac959f9cdacf099ae17690002eb36b1043bc31379ef93bb1cfd27b1d29e80bf08a9c9786efbfd63b52fe8e31dfc8205fb56d490a669a177d0aef3312c5eb05e944ac5eb8b0b50c82bbbf7122bec29e61578e5b4c075ed7cade1fe328c1d9f4c23eff59db2b2edf335216d770d75b68ccea64ecf3cef78b5324242bfbb54a76ccae1dbeb7a624bfede327cb314516b283acf07ecf6be4ac2bef91e5b22ad0f247a664787cb724ae3d79823e106de91200c3e92c83693c7e6414954a14a3dc35afa9d5b45807ed6fa7ae4102b0129fc50bb8e6f77ffb4d5dca652851dbb5d23411fb850f5fbddb3ea211354170f9f9c2e5e8fd54a6c6ccfc213418b6530eb19a932f86425bff044ad32c9b2d0304fed62357f5030b417b3e9e76dead3e66adbf3b1e211f49dda0cabc48d154d0ccc9acaf558ffeba06af0dc1ee6250ad9dc0d9ed8312c3f4ec53d161e338c5f2a448e2add29ebab3ebb8c4591debfb6cec707b05858b2e6ab7143adb15c7c461496ab69f2caf2183869fa5fab4dc6b29a4d5a50d5b82e4efb2f7f9e0380fa0c2473d9e1841b30f99c6745914bee99336bc088e7c6472ced3f1bb25b72c3f77c208fa4ceb955c724657c9acced1375e687d05db1173a8146524b1742e51d32512385322a7a81de13f746a35f0baa26557e587ed5fa076ff78eee942c1f88830f065e47fdb4299a74c53da88ff464f6f253cd53b577d16613b4a39c4f3025245e27460bc3f12606c463528fcc9d9726af32c37d6a5a34b76eecbf6338a6ed446a23f78856d66bf869df8a4f8025686379fdbeb4f4ced6dad072724077370c3a242cf331a3c5f0b1b5cefa491079f6a35b07810356fdecafc90ff2a589bc8816c921c4f77f4ae4af1ddd7f956dbb76aa3bed103948363fbd07ff8b5dce5705c2fd151b8e7f353f3c13cfaae537337b0614da5aaaa15a78088deee5fa8aeba9a0241c1d69145fabdf57d423b64c30faeb7c53bfe606a645baedbc3744704d34e9ce05043fe94f5bbd2eb6e62f4d9489886f83cb9e148f84f290c4af27e72f7b7227106ec3a43ba875f8baaa564bf6ddf14698c9fed648dd068d59ca1e2e1b4f11a91d4a70ae8ecb1efca06212cd9f1a40eb3129650e5ea75119576075449aa890250772b1d8c93aade60080813d124a6b40eb863653ad2cc9a255dbf12adcae984b137448b0473b3600af40a464cae3fddda2b1f208f2c71892bee6892cac7251bf150c25a3325c17faa3ca7b695f331d7815d45cb748fcf440e1670ded9224ccc412cf6358db1109fcb48a5365aec60f83d7d312de326a47d2f62bdf50b420b71a0cbd3784b5203622a2d1a63c883b46d25951407e69911605a78bee23d4c233650179d25e63bc5ada8bd4f17caf1f2b3f526f3b516ec384cb03554b90ead4f1d6111f8031a4f4e763e3ee95112a81553441b3a4033a5da8387876180b38f7555b20d511ce4f33591c3d42075acd495ba62329aeb2060946d9fb53c4dae4f3e9c9073952c4c4a245392f308db379cd56f98cba838d396fc475c900e1bea96e8ae004005be1b59c833be1302c8399e12cda0747b59f287f7777d9e601df7112175a15a2fce62a1e43faaaa03df8163c27aafa675053d618b75366c72460d5f4a61523530dacd57684ec5c31bb63ca2efb5747438c482343a601f660d4f077dd06221db045d47a19b484e375f71317401c1ab96bfd8612799eb9883e0c4dc8294a3526e0f3465cbdc5c37d8be48b9df7e4ba02ca5b435e9d01a8acf344a00b759f0d12197b0a0bb19857762dbac1708a31772bb82ba8adc61a608a971ad7d5a74d880154d930e320618d39639ee341747abbd5508e9eb2b063ccd688b3f4b6e80dce2a8b9216a0ae38a90dcfe52effe789ee3500a2887ddb763ff1d48e48abebb6d32c7aa47d2b16e079ee3fa0d5435036875a6f88fe489060bbc4151b7671b1468f23552f614c78ffaa65942f5052f43d75adf499eedfa30915b8b8c82638134c5707b54757110744d89ccef92a43de0fa32d856e46352e57456f6e89ffee1074f701e5df46eb2b01c5beef8b3914526c057ef9873f357c3012305a3905bbd5037a286a7328d181da93ef085f81267c0f06fa45b8bc0e5f829f869956aeba201e2e21c65d131c30cc048becd93ba38f04bf6bb19aeb8dde081286441dbb5fdf364625c407db9d2ae61d08e4ccfc18ef9d1fcdf07ba1b416e4377eebea37a94d417a1736dace8ac0239bc23b1fbf3ddfe110376a4f01057e86f4a3a2e45dd3ac319401fa82aec40fd865fbc390f7bfc2fd77b97ffef00baab3a92d7654b8d790782a2e8072801bb9eaff2344f5fc5bb0e79260021448d445eefb1bd50ba2d0328ed9177605fc3af5c836b06018e67e213f35d8df27913b3aa20f3667a9db14eca25e255f9fd38c5a1a40e1b89f306091330873ce312919fffc589bce4c826c58ece3229b471a1d8780c4f81390bd8275eccdc5cae9515a1d821213d02a2cbddf9af12a6f84e7fae74f3ff9637b143fc8d425cccbdfb6945005c400206f4cc5c8e2720000002a","aggregationObject":["0x00000000000000000000000000000000000000000000000411700d6c4cf14ec0","0x0000000000000000000000000000000000000000000000092a9c3224b018d49d","0x0000000000000000000000000000000000000000000000072d1022a88f16c52b","0x0000000000000000000000000000000000000000000000000001b36811921c81","0x000000000000000000000000000000000000000000000007f0819be5758c25f2","0x0000000000000000000000000000000000000000000000007fc055b30fc5cf64","0x00000000000000000000000000000000000000000000000316c9c3b0385c1768","0x0000000000000000000000000000000000000000000000000001cd75bd2f3664","0x0000000000000000000000000000000000000000000000032f5395931eb12098","0x00000000000000000000000000000000000000000000000f9a88d0be49ab9d4b","0x00000000000000000000000000000000000000000000000d077fab6d15e7029f","0x00000000000000000000000000000000000000000000000000018a72eb3d3bf5","0x00000000000000000000000000000000000000000000000446902910332b1657","0x0000000000000000000000000000000000000000000000046419b3737fd0a120","0x00000000000000000000000000000000000000000000000c8b87236ac632c8e3","0x000000000000000000000000000000000000000000000000000056b92ff0f1fa"]} \ No newline at end of file diff --git a/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts b/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts index 62e6d9d78cb..c50097d639c 100644 --- a/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts +++ b/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts @@ -15,6 +15,7 @@ import { RollupAbi, RollupBytecode, } from '@aztec/l1-artifacts'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token'; import { type HDAccount, type PrivateKeyAccount } from 'viem'; @@ -60,6 +61,7 @@ export const setupL1Contracts = async ( const l1Data = await deployL1Contracts(l1RpcUrl, account, foundry, logger, l1Artifacts, { l2GasTokenAddress: GasTokenAddress, + vkTreeRoot: getVKTreeRoot(), }); return l1Data; diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 05ef01cafa7..93d3e0bd3be 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -57,6 +57,7 @@ import { } from '@aztec/l1-artifacts'; import { AuthRegistryContract, KeyRegistryContract } from '@aztec/noir-contracts.js'; import { GasTokenContract } from '@aztec/noir-contracts.js/GasToken'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry'; import { GasTokenAddress, getCanonicalGasToken } from '@aztec/protocol-contracts/gas-token'; import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry'; @@ -139,6 +140,7 @@ export const setupL1Contracts = async ( const l1Data = await deployL1Contracts(l1RpcUrl, account, foundry, logger, l1Artifacts, { l2GasTokenAddress: GasTokenAddress, + vkTreeRoot: getVKTreeRoot(), }); return l1Data; diff --git a/yarn-project/end-to-end/tsconfig.json b/yarn-project/end-to-end/tsconfig.json index 28bde215732..caad50a6304 100644 --- a/yarn-project/end-to-end/tsconfig.json +++ b/yarn-project/end-to-end/tsconfig.json @@ -48,6 +48,9 @@ { "path": "../noir-contracts.js" }, + { + "path": "../noir-protocol-circuits-types" + }, { "path": "../p2p" }, diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index c6feb14af17..f9fc6df299a 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -1,5 +1,6 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; +import { type Fr } from '@aztec/foundation/fields'; import { type DebugLogger } from '@aztec/foundation/log'; import type { Abi, Narrow } from 'abitype'; @@ -131,7 +132,7 @@ export const deployL1Contracts = async ( chain: Chain, logger: DebugLogger, contractsToDeploy: L1ContractArtifactsForDeployment, - args: { l2GasTokenAddress: AztecAddress }, + args: { l2GasTokenAddress: AztecAddress; vkTreeRoot: Fr }, ): Promise => { logger.debug('Deploying contracts...'); @@ -179,6 +180,7 @@ export const deployL1Contracts = async ( getAddress(registryAddress.toString()), getAddress(availabilityOracleAddress.toString()), getAddress(gasTokenAddress.toString()), + args.vkTreeRoot.toString(), ], ); logger.info(`Deployed Rollup at ${rollupAddress}`); diff --git a/yarn-project/foundation/src/abi/abi.ts b/yarn-project/foundation/src/abi/abi.ts index 9e996fc4249..ee5352cf4d1 100644 --- a/yarn-project/foundation/src/abi/abi.ts +++ b/yarn-project/foundation/src/abi/abi.ts @@ -59,10 +59,7 @@ export interface ABIVariable { /** * Indicates whether a parameter is public or secret/private. */ -export enum ABIParameterVisibility { - PUBLIC = 'public', - SECRET = 'secret', -} +export type ABIParameterVisibility = 'public' | 'private' | 'databus'; /** * A function parameter. @@ -89,6 +86,8 @@ export interface BasicType { */ export type AbiType = BasicType<'field'> | BasicType<'boolean'> | IntegerType | ArrayType | StringType | StructType; +type Sign = 'unsigned' | 'signed'; + /** * An integer type. */ @@ -96,7 +95,7 @@ export interface IntegerType extends BasicType<'integer'> { /** * The sign of the integer. */ - sign: string; + sign: Sign; /** * The width of the integer in bits. */ diff --git a/yarn-project/foundation/src/abi/encoder.test.ts b/yarn-project/foundation/src/abi/encoder.test.ts index b9a54c993fa..1053db02af0 100644 --- a/yarn-project/foundation/src/abi/encoder.test.ts +++ b/yarn-project/foundation/src/abi/encoder.test.ts @@ -1,7 +1,7 @@ import { AztecAddress } from '../aztec-address/index.js'; import { Fr } from '../fields/fields.js'; import { Point } from '../fields/point.js'; -import { ABIParameterVisibility, type FunctionAbi, FunctionType } from './abi.js'; +import { type FunctionAbi, FunctionType } from './abi.js'; import { encodeArguments } from './encoder.js'; describe('abi/encoder', () => { @@ -18,7 +18,7 @@ describe('abi/encoder', () => { type: { kind: 'field', }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -43,7 +43,7 @@ describe('abi/encoder', () => { length: 2, type: { kind: 'field' }, }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -67,7 +67,7 @@ describe('abi/encoder', () => { kind: 'string', length: 4, }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -99,7 +99,7 @@ describe('abi/encoder', () => { }, ], }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -135,7 +135,7 @@ describe('abi/encoder', () => { }, ], }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -160,7 +160,7 @@ describe('abi/encoder', () => { type: { kind: 'field', }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -181,11 +181,11 @@ describe('abi/encoder', () => { { name: 'isOwner', type: { - sign: 'value', + sign: 'signed', width: 5, kind: 'integer', }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], @@ -207,7 +207,7 @@ describe('abi/encoder', () => { type: { kind: 'field', }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], returnTypes: [], diff --git a/yarn-project/noir-protocol-circuits-types/package.json b/yarn-project/noir-protocol-circuits-types/package.json index 4f1b5e1fd38..85546842b68 100644 --- a/yarn-project/noir-protocol-circuits-types/package.json +++ b/yarn-project/noir-protocol-circuits-types/package.json @@ -17,7 +17,7 @@ "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "formatting:fix:types": "NODE_OPTIONS='--max-old-space-size=8096' run -T eslint --fix ./src/types && run -T prettier -w ./src/types", "generate": "yarn generate:noir-circuits", - "generate:noir-circuits": "mkdir -p ./artifacts && cp ../../noir-projects/noir-protocol-circuits/target/* ./artifacts && node --no-warnings --loader ts-node/esm src/scripts/generate_declaration_files.ts && node --no-warnings --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && run -T prettier -w ./src/types", + "generate:noir-circuits": "mkdir -p ./artifacts && cp -r ../../noir-projects/noir-protocol-circuits/target/* ./artifacts && node --no-warnings --loader ts-node/esm src/scripts/generate_declaration_files.ts && node --no-warnings --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && run -T prettier -w ./src/types", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests", "codegen": "yarn noir-codegen", "build:dev": "tsc -b --watch" @@ -67,7 +67,6 @@ "tslib": "^2.4.0" }, "devDependencies": { - "@aztec/circuit-types": "workspace:^", "@aztec/kv-store": "workspace:^", "@aztec/merkle-tree": "workspace:^", "@jest/globals": "^29.5.0", diff --git a/yarn-project/noir-protocol-circuits-types/src/artifacts.ts b/yarn-project/noir-protocol-circuits-types/src/artifacts.ts new file mode 100644 index 00000000000..97ce2df7a70 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/artifacts.ts @@ -0,0 +1,131 @@ +import { type PrivateKernelResetTags } from '@aztec/circuits.js'; +import { type NoirCompiledCircuit } from '@aztec/types/noir'; + +import EmptyNestedJson from '../artifacts/empty_nested.json' assert { type: 'json' }; +import EmptyNestedSimulatedJson from '../artifacts/empty_nested_simulated.json' assert { type: 'json' }; +import BaseParityJson from '../artifacts/parity_base.json' assert { type: 'json' }; +import RootParityJson from '../artifacts/parity_root.json' assert { type: 'json' }; +import PrivateKernelEmptyJson from '../artifacts/private_kernel_empty.json' assert { type: 'json' }; +import PrivateKernelEmptySimulatedJson from '../artifacts/private_kernel_empty_simulated.json' assert { type: 'json' }; +import PrivateKernelInitJson from '../artifacts/private_kernel_init.json' assert { type: 'json' }; +import PrivateKernelInitSimulatedJson from '../artifacts/private_kernel_init_simulated.json' assert { type: 'json' }; +import PrivateKernelInnerJson from '../artifacts/private_kernel_inner.json' assert { type: 'json' }; +import PrivateKernelInnerSimulatedJson from '../artifacts/private_kernel_inner_simulated.json' assert { type: 'json' }; +import PrivateKernelResetJson from '../artifacts/private_kernel_reset.json' assert { type: 'json' }; +import PrivateKernelResetBigJson from '../artifacts/private_kernel_reset_big.json' assert { type: 'json' }; +import PrivateKernelResetMediumJson from '../artifacts/private_kernel_reset_medium.json' assert { type: 'json' }; +import PrivateKernelResetSimulatedJson from '../artifacts/private_kernel_reset_simulated.json' assert { type: 'json' }; +import PrivateKernelResetBigSimulatedJson from '../artifacts/private_kernel_reset_simulated_big.json' assert { type: 'json' }; +import PrivateKernelResetMediumSimulatedJson from '../artifacts/private_kernel_reset_simulated_medium.json' assert { type: 'json' }; +import PrivateKernelResetSmallSimulatedJson from '../artifacts/private_kernel_reset_simulated_small.json' assert { type: 'json' }; +import PrivateKernelResetSmallJson from '../artifacts/private_kernel_reset_small.json' assert { type: 'json' }; +import PrivateKernelTailJson from '../artifacts/private_kernel_tail.json' assert { type: 'json' }; +import PrivateKernelTailSimulatedJson from '../artifacts/private_kernel_tail_simulated.json' assert { type: 'json' }; +import PrivateKernelTailToPublicJson from '../artifacts/private_kernel_tail_to_public.json' assert { type: 'json' }; +import PrivateKernelTailToPublicSimulatedJson from '../artifacts/private_kernel_tail_to_public_simulated.json' assert { type: 'json' }; +import PublicKernelAppLogicJson from '../artifacts/public_kernel_app_logic.json' assert { type: 'json' }; +import PublicKernelAppLogicSimulatedJson from '../artifacts/public_kernel_app_logic_simulated.json' assert { type: 'json' }; +import PublicKernelSetupJson from '../artifacts/public_kernel_setup.json' assert { type: 'json' }; +import PublicKernelSetupSimulatedJson from '../artifacts/public_kernel_setup_simulated.json' assert { type: 'json' }; +import PublicKernelTailJson from '../artifacts/public_kernel_tail.json' assert { type: 'json' }; +import PublicKernelTailSimulatedJson from '../artifacts/public_kernel_tail_simulated.json' assert { type: 'json' }; +import PublicKernelTeardownJson from '../artifacts/public_kernel_teardown.json' assert { type: 'json' }; +import PublicKernelTeardownSimulatedJson from '../artifacts/public_kernel_teardown_simulated.json' assert { type: 'json' }; +import BaseRollupJson from '../artifacts/rollup_base.json' assert { type: 'json' }; +import BaseRollupSimulatedJson from '../artifacts/rollup_base_simulated.json' assert { type: 'json' }; +import MergeRollupJson from '../artifacts/rollup_merge.json' assert { type: 'json' }; +import RootRollupJson from '../artifacts/rollup_root.json' assert { type: 'json' }; + +export type PrivateResetArtifacts = + | 'PrivateKernelResetFullArtifact' + | 'PrivateKernelResetBigArtifact' + | 'PrivateKernelResetMediumArtifact' + | 'PrivateKernelResetSmallArtifact'; + +export const PrivateResetTagToArtifactName: Record = { + full: 'PrivateKernelResetFullArtifact', + big: 'PrivateKernelResetBigArtifact', + medium: 'PrivateKernelResetMediumArtifact', + small: 'PrivateKernelResetSmallArtifact', +}; + +export type ServerProtocolArtifact = + | 'EmptyNestedArtifact' + | 'PrivateKernelEmptyArtifact' + | 'PublicKernelSetupArtifact' + | 'PublicKernelAppLogicArtifact' + | 'PublicKernelTeardownArtifact' + | 'PublicKernelTailArtifact' + | 'BaseParityArtifact' + | 'RootParityArtifact' + | 'BaseRollupArtifact' + | 'MergeRollupArtifact' + | 'RootRollupArtifact'; + +export type ClientProtocolArtifact = + | 'PrivateKernelInitArtifact' + | 'PrivateKernelInnerArtifact' + | 'PrivateKernelTailArtifact' + | 'PrivateKernelTailToPublicArtifact' + | PrivateResetArtifacts; + +export type ProtocolArtifact = ServerProtocolArtifact | ClientProtocolArtifact; + +export const ServerCircuitArtifacts: Record = { + EmptyNestedArtifact: EmptyNestedJson as NoirCompiledCircuit, + PrivateKernelEmptyArtifact: PrivateKernelEmptyJson as NoirCompiledCircuit, + PublicKernelSetupArtifact: PublicKernelSetupJson as NoirCompiledCircuit, + PublicKernelAppLogicArtifact: PublicKernelAppLogicJson as NoirCompiledCircuit, + PublicKernelTeardownArtifact: PublicKernelTeardownJson as NoirCompiledCircuit, + PublicKernelTailArtifact: PublicKernelTailJson as NoirCompiledCircuit, + BaseParityArtifact: BaseParityJson as NoirCompiledCircuit, + RootParityArtifact: RootParityJson as NoirCompiledCircuit, + BaseRollupArtifact: BaseRollupJson as NoirCompiledCircuit, + MergeRollupArtifact: MergeRollupJson as NoirCompiledCircuit, + RootRollupArtifact: RootRollupJson as NoirCompiledCircuit, +}; + +export const SimulatedServerCircuitArtifacts: Record = { + EmptyNestedArtifact: EmptyNestedSimulatedJson as NoirCompiledCircuit, + PrivateKernelEmptyArtifact: PrivateKernelEmptySimulatedJson as NoirCompiledCircuit, + PublicKernelSetupArtifact: PublicKernelSetupSimulatedJson as NoirCompiledCircuit, + PublicKernelAppLogicArtifact: PublicKernelAppLogicSimulatedJson as NoirCompiledCircuit, + PublicKernelTeardownArtifact: PublicKernelTeardownSimulatedJson as NoirCompiledCircuit, + PublicKernelTailArtifact: PublicKernelTailSimulatedJson as NoirCompiledCircuit, + BaseParityArtifact: BaseParityJson as NoirCompiledCircuit, + RootParityArtifact: RootParityJson as NoirCompiledCircuit, + BaseRollupArtifact: BaseRollupSimulatedJson as NoirCompiledCircuit, + MergeRollupArtifact: MergeRollupJson as NoirCompiledCircuit, + RootRollupArtifact: RootRollupJson as NoirCompiledCircuit, +}; + +export const ResetSimulatedArtifacts: Record = { + PrivateKernelResetFullArtifact: PrivateKernelResetSimulatedJson as NoirCompiledCircuit, + PrivateKernelResetBigArtifact: PrivateKernelResetBigSimulatedJson as NoirCompiledCircuit, + PrivateKernelResetMediumArtifact: PrivateKernelResetMediumSimulatedJson as NoirCompiledCircuit, + PrivateKernelResetSmallArtifact: PrivateKernelResetSmallSimulatedJson as NoirCompiledCircuit, +}; + +export const ClientCircuitArtifacts: Record = { + PrivateKernelInitArtifact: PrivateKernelInitJson as NoirCompiledCircuit, + PrivateKernelInnerArtifact: PrivateKernelInnerJson as NoirCompiledCircuit, + PrivateKernelResetFullArtifact: PrivateKernelResetJson as NoirCompiledCircuit, + PrivateKernelResetBigArtifact: PrivateKernelResetBigJson as NoirCompiledCircuit, + PrivateKernelResetMediumArtifact: PrivateKernelResetMediumJson as NoirCompiledCircuit, + PrivateKernelResetSmallArtifact: PrivateKernelResetSmallJson as NoirCompiledCircuit, + PrivateKernelTailArtifact: PrivateKernelTailJson as NoirCompiledCircuit, + PrivateKernelTailToPublicArtifact: PrivateKernelTailToPublicJson as NoirCompiledCircuit, +}; + +export const SimulatedClientCircuitArtifacts: Record = { + PrivateKernelInitArtifact: PrivateKernelInitSimulatedJson as NoirCompiledCircuit, + PrivateKernelInnerArtifact: PrivateKernelInnerSimulatedJson as NoirCompiledCircuit, + PrivateKernelTailArtifact: PrivateKernelTailSimulatedJson as NoirCompiledCircuit, + PrivateKernelTailToPublicArtifact: PrivateKernelTailToPublicSimulatedJson as NoirCompiledCircuit, + ...ResetSimulatedArtifacts, +}; + +export const ProtocolCircuitArtifacts: Record = { + ...ClientCircuitArtifacts, + ...ServerCircuitArtifacts, +}; diff --git a/yarn-project/noir-protocol-circuits-types/src/index.ts b/yarn-project/noir-protocol-circuits-types/src/index.ts index 789ff0f92f7..6fdeb0945c6 100644 --- a/yarn-project/noir-protocol-circuits-types/src/index.ts +++ b/yarn-project/noir-protocol-circuits-types/src/index.ts @@ -22,7 +22,6 @@ import { type RootRollupPublicInputs, } from '@aztec/circuits.js'; import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log'; -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'; @@ -30,40 +29,14 @@ import { type Abi, abiDecode, abiEncode } from '@noir-lang/noirc_abi'; import { type WitnessMap } from '@noir-lang/types'; import { strict as assert } from 'assert'; -import EmptyNestedJson from '../artifacts/empty_nested.json' assert { type: 'json' }; -import EmptyNestedSimulatedJson from '../artifacts/empty_nested_simulated.json' assert { type: 'json' }; -import BaseParityJson from '../artifacts/parity_base.json' assert { type: 'json' }; -import RootParityJson from '../artifacts/parity_root.json' assert { type: 'json' }; -import PrivateKernelEmptyJson from '../artifacts/private_kernel_empty.json' assert { type: 'json' }; -import PrivateKernelEmptySimulatedJson from '../artifacts/private_kernel_empty_simulated.json' assert { type: 'json' }; -import PrivateKernelInitJson from '../artifacts/private_kernel_init.json' assert { type: 'json' }; -import PrivateKernelInitSimulatedJson from '../artifacts/private_kernel_init_simulated.json' assert { type: 'json' }; -import PrivateKernelInnerJson from '../artifacts/private_kernel_inner.json' assert { type: 'json' }; -import PrivateKernelInnerSimulatedJson from '../artifacts/private_kernel_inner_simulated.json' assert { type: 'json' }; -import PrivateKernelResetJson from '../artifacts/private_kernel_reset.json' assert { type: 'json' }; -import PrivateKernelResetBigJson from '../artifacts/private_kernel_reset_big.json' assert { type: 'json' }; -import PrivateKernelResetMediumJson from '../artifacts/private_kernel_reset_medium.json' assert { type: 'json' }; -import PrivateKernelResetSimulatedJson from '../artifacts/private_kernel_reset_simulated.json' assert { type: 'json' }; -import PrivateKernelResetBigSimulatedJson from '../artifacts/private_kernel_reset_simulated_big.json' assert { type: 'json' }; -import PrivateKernelResetMediumSimulatedJson from '../artifacts/private_kernel_reset_simulated_medium.json' assert { type: 'json' }; -import PrivateKernelResetSmallSimulatedJson from '../artifacts/private_kernel_reset_simulated_small.json' assert { type: 'json' }; -import PrivateKernelResetSmallJson from '../artifacts/private_kernel_reset_small.json' assert { type: 'json' }; -import PrivateKernelTailJson from '../artifacts/private_kernel_tail.json' assert { type: 'json' }; -import PrivateKernelTailSimulatedJson from '../artifacts/private_kernel_tail_simulated.json' assert { type: 'json' }; -import PrivateKernelTailToPublicJson from '../artifacts/private_kernel_tail_to_public.json' assert { type: 'json' }; -import PrivateKernelTailToPublicSimulatedJson from '../artifacts/private_kernel_tail_to_public_simulated.json' assert { type: 'json' }; -import PublicKernelAppLogicJson from '../artifacts/public_kernel_app_logic.json' assert { type: 'json' }; -import PublicKernelAppLogicSimulatedJson from '../artifacts/public_kernel_app_logic_simulated.json' assert { type: 'json' }; -import PublicKernelSetupJson from '../artifacts/public_kernel_setup.json' assert { type: 'json' }; -import PublicKernelSetupSimulatedJson from '../artifacts/public_kernel_setup_simulated.json' assert { type: 'json' }; -import PublicKernelTailJson from '../artifacts/public_kernel_tail.json' assert { type: 'json' }; -import PublicKernelTailSimulatedJson from '../artifacts/public_kernel_tail_simulated.json' assert { type: 'json' }; -import PublicKernelTeardownJson from '../artifacts/public_kernel_teardown.json' assert { type: 'json' }; -import PublicKernelTeardownSimulatedJson from '../artifacts/public_kernel_teardown_simulated.json' assert { type: 'json' }; -import BaseRollupJson from '../artifacts/rollup_base.json' assert { type: 'json' }; -import BaseRollupSimulatedJson from '../artifacts/rollup_base_simulated.json' assert { type: 'json' }; -import MergeRollupJson from '../artifacts/rollup_merge.json' assert { type: 'json' }; -import RootRollupJson from '../artifacts/rollup_root.json' assert { type: 'json' }; +import { + ClientCircuitArtifacts, + PrivateResetTagToArtifactName, + ResetSimulatedArtifacts, + ServerCircuitArtifacts, + SimulatedClientCircuitArtifacts, + SimulatedServerCircuitArtifacts, +} from './artifacts.js'; import { mapBaseOrMergeRollupPublicInputsFromNoir, mapBaseParityInputsToNoir, @@ -106,6 +79,9 @@ import { PrivateKernelTail as executePrivateKernelTailWithACVM, } from './types/index.js'; +export * from './artifacts.js'; +export * from './vks.js'; + // TODO(Tom): This should be exported from noirc_abi /** * The decoded inputs from the circuit. @@ -121,131 +97,6 @@ export type DecodedInputs = { return_value: any; }; -export const PrivateKernelInitArtifact = PrivateKernelInitJson as NoirCompiledCircuit; - -export const PrivateKernelInnerArtifact = PrivateKernelInnerJson as NoirCompiledCircuit; - -export const PrivateKernelResetArtifact = PrivateKernelResetJson as NoirCompiledCircuit; - -export const PrivateKernelTailArtifact = PrivateKernelTailJson as NoirCompiledCircuit; - -export const PrivateKernelTailToPublicArtifact = PrivateKernelTailToPublicJson as NoirCompiledCircuit; - -export const PrivateKernelEmptyArtifact = PrivateKernelEmptyJson as NoirCompiledCircuit; - -export const EmptyNestedArtifact = EmptyNestedJson as NoirCompiledCircuit; - -export const SimulatedPublicKernelSetupArtifact = PublicKernelSetupSimulatedJson as NoirCompiledCircuit; - -export const SimulatedPublicKernelAppLogicArtifact = PublicKernelAppLogicSimulatedJson as NoirCompiledCircuit; - -export const SimulatedPublicKernelTeardownArtifact = PublicKernelTeardownSimulatedJson as NoirCompiledCircuit; - -export const SimulatedPublicKernelTailArtifact = PublicKernelTailSimulatedJson as NoirCompiledCircuit; - -export const SimulatedPrivateKernelEmptyArtifact = PrivateKernelEmptySimulatedJson as NoirCompiledCircuit; - -export const SimulatedEmptyNestedArtifact = EmptyNestedSimulatedJson as NoirCompiledCircuit; - -export const PublicKernelSetupArtifact = PublicKernelSetupJson as NoirCompiledCircuit; - -export const PublicKernelAppLogicArtifact = PublicKernelAppLogicJson as NoirCompiledCircuit; - -export const PublicKernelTeardownArtifact = PublicKernelTeardownJson as NoirCompiledCircuit; - -export const PublicKernelTailArtifact = PublicKernelTailJson as NoirCompiledCircuit; - -export const BaseParityArtifact = BaseParityJson as NoirCompiledCircuit; - -export const RootParityArtifact = RootParityJson as NoirCompiledCircuit; - -export const SimulatedBaseRollupArtifact = BaseRollupSimulatedJson as NoirCompiledCircuit; - -export const BaseRollupArtifact = BaseRollupJson as NoirCompiledCircuit; - -export const MergeRollupArtifact = MergeRollupJson as NoirCompiledCircuit; - -export const RootRollupArtifact = RootRollupJson as NoirCompiledCircuit; - -export type PrivateResetArtifacts = - | 'PrivateKernelResetFullArtifact' - | 'PrivateKernelResetBigArtifact' - | 'PrivateKernelResetMediumArtifact' - | 'PrivateKernelResetSmallArtifact'; - -export const PrivateResetTagToArtifactName: Record = { - full: 'PrivateKernelResetFullArtifact', - big: 'PrivateKernelResetBigArtifact', - medium: 'PrivateKernelResetMediumArtifact', - small: 'PrivateKernelResetSmallArtifact', -}; - -export type ServerProtocolArtifact = - | 'EmptyNestedArtifact' - | 'PrivateKernelEmptyArtifact' - | 'PublicKernelSetupArtifact' - | 'PublicKernelAppLogicArtifact' - | 'PublicKernelTeardownArtifact' - | 'PublicKernelTailArtifact' - | 'BaseParityArtifact' - | 'RootParityArtifact' - | 'BaseRollupArtifact' - | 'MergeRollupArtifact' - | 'RootRollupArtifact'; - -export type ClientProtocolArtifact = - | 'PrivateKernelInitArtifact' - | 'PrivateKernelInnerArtifact' - | 'PrivateKernelTailArtifact' - | 'PrivateKernelTailToPublicArtifact' - | PrivateResetArtifacts; - -export type ProtocolArtifact = ServerProtocolArtifact | ClientProtocolArtifact; - -export const ServerCircuitArtifacts: Record = { - EmptyNestedArtifact: EmptyNestedArtifact, - PrivateKernelEmptyArtifact: PrivateKernelEmptyArtifact, - PublicKernelSetupArtifact: PublicKernelSetupArtifact, - PublicKernelAppLogicArtifact: PublicKernelAppLogicArtifact, - PublicKernelTeardownArtifact: PublicKernelTeardownArtifact, - PublicKernelTailArtifact: PublicKernelTailArtifact, - BaseParityArtifact: BaseParityArtifact, - RootParityArtifact: RootParityArtifact, - BaseRollupArtifact: BaseRollupArtifact, - MergeRollupArtifact: MergeRollupArtifact, - RootRollupArtifact: RootRollupArtifact, -}; - -export const SimulatedServerCircuitArtifacts: Record = { - EmptyNestedArtifact: SimulatedEmptyNestedArtifact, - PrivateKernelEmptyArtifact: SimulatedPrivateKernelEmptyArtifact, - PublicKernelSetupArtifact: SimulatedPublicKernelSetupArtifact, - PublicKernelAppLogicArtifact: SimulatedPublicKernelAppLogicArtifact, - PublicKernelTeardownArtifact: SimulatedPublicKernelTeardownArtifact, - PublicKernelTailArtifact: SimulatedPublicKernelTailArtifact, - BaseParityArtifact: BaseParityArtifact, - RootParityArtifact: RootParityArtifact, - BaseRollupArtifact: SimulatedBaseRollupArtifact, - MergeRollupArtifact: MergeRollupArtifact, - RootRollupArtifact: RootRollupArtifact, -}; - -export const ClientCircuitArtifacts: Record = { - PrivateKernelInitArtifact: PrivateKernelInitArtifact, - PrivateKernelInnerArtifact: PrivateKernelInnerArtifact, - PrivateKernelResetFullArtifact: PrivateKernelResetArtifact, - PrivateKernelResetBigArtifact: PrivateKernelResetBigJson as NoirCompiledCircuit, - PrivateKernelResetMediumArtifact: PrivateKernelResetMediumJson as NoirCompiledCircuit, - PrivateKernelResetSmallArtifact: PrivateKernelResetSmallJson as NoirCompiledCircuit, - PrivateKernelTailArtifact: PrivateKernelTailArtifact, - PrivateKernelTailToPublicArtifact: PrivateKernelTailToPublicArtifact, -}; - -export const ProtocolCircuitArtifacts: Record = { - ...ClientCircuitArtifacts, - ...ServerCircuitArtifacts, -}; - /** * Executes the init private kernel. * @param privateKernelInitCircuitPrivateInputs - The private inputs to the initial private kernel. @@ -256,7 +107,7 @@ export async function executeInit( ): Promise { const returnType = await executePrivateKernelInitWithACVM( mapPrivateKernelInitCircuitPrivateInputsToNoir(privateKernelInitCircuitPrivateInputs), - PrivateKernelInitSimulatedJson as CompiledCircuit, + SimulatedClientCircuitArtifacts.PrivateKernelInitArtifact as CompiledCircuit, foreignCallHandler, ); @@ -273,20 +124,13 @@ export async function executeInner( ): Promise { const returnType = await executePrivateKernelInnerWithACVM( mapPrivateKernelInnerCircuitPrivateInputsToNoir(privateKernelInnerCircuitPrivateInputs), - PrivateKernelInnerSimulatedJson as CompiledCircuit, + SimulatedClientCircuitArtifacts.PrivateKernelInnerArtifact as CompiledCircuit, foreignCallHandler, ); return mapPrivateKernelCircuitPublicInputsFromNoir(returnType); } -const ResetSimulatedArtifacts: Record = { - PrivateKernelResetFullArtifact: PrivateKernelResetSimulatedJson as CompiledCircuit, - PrivateKernelResetBigArtifact: PrivateKernelResetBigSimulatedJson as CompiledCircuit, - PrivateKernelResetMediumArtifact: PrivateKernelResetMediumSimulatedJson as CompiledCircuit, - PrivateKernelResetSmallArtifact: PrivateKernelResetSmallSimulatedJson as CompiledCircuit, -}; - /** * Executes the inner private kernel. * @param privateKernelResetCircuitPrivateInputs - The private inputs to the reset private kernel. @@ -297,7 +141,7 @@ export async function executeReset( ): Promise { const artifact = ResetSimulatedArtifacts[PrivateResetTagToArtifactName[privateKernelResetCircuitPrivateInputs.sizeTag]]; - const program = new Noir(artifact); + const program = new Noir(artifact as CompiledCircuit); const args: InputMap = { input: mapPrivateKernelResetCircuitPrivateInputsToNoir(privateKernelResetCircuitPrivateInputs as any), }; @@ -315,7 +159,7 @@ export async function executeTail( ): Promise { const returnType = await executePrivateKernelTailWithACVM( mapPrivateKernelTailCircuitPrivateInputsToNoir(privateInputs), - PrivateKernelTailSimulatedJson as CompiledCircuit, + SimulatedClientCircuitArtifacts.PrivateKernelTailArtifact as CompiledCircuit, foreignCallHandler, ); @@ -332,7 +176,7 @@ export async function executeTailForPublic( ): Promise { const returnType = await executePrivateKernelTailToPublicWithACVM( mapPrivateKernelTailToPublicCircuitPrivateInputsToNoir(privateInputs), - PrivateKernelTailToPublicSimulatedJson as CompiledCircuit, + SimulatedClientCircuitArtifacts.PrivateKernelTailToPublicArtifact as CompiledCircuit, foreignCallHandler, ); @@ -348,7 +192,9 @@ export function convertPrivateKernelInitInputsToWitnessMap( privateKernelInitCircuitPrivateInputs: PrivateKernelInitCircuitPrivateInputs, ): WitnessMap { const mapped = mapPrivateKernelInitCircuitPrivateInputsToNoir(privateKernelInitCircuitPrivateInputs); - const initialWitnessMap = abiEncode(PrivateKernelInitArtifact.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ClientCircuitArtifacts.PrivateKernelInitArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -361,7 +207,7 @@ export function convertPrivateKernelInnerInputsToWitnessMap( privateKernelInnerCircuitPrivateInputs: PrivateKernelInnerCircuitPrivateInputs, ): WitnessMap { const mapped = mapPrivateKernelInnerCircuitPrivateInputsToNoir(privateKernelInnerCircuitPrivateInputs); - const initialWitnessMap = abiEncode(PrivateKernelInnerArtifact.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ClientCircuitArtifacts.PrivateKernelInnerArtifact.abi, { input: mapped as any }); return initialWitnessMap; } @@ -389,7 +235,7 @@ export function convertPrivateKernelTailInputsToWitnessMap( privateKernelTailCircuitPrivateInputs: PrivateKernelTailCircuitPrivateInputs, ): WitnessMap { const mapped = mapPrivateKernelTailCircuitPrivateInputsToNoir(privateKernelTailCircuitPrivateInputs); - const initialWitnessMap = abiEncode(PrivateKernelTailArtifact.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ClientCircuitArtifacts.PrivateKernelTailArtifact.abi, { input: mapped as any }); return initialWitnessMap; } @@ -402,7 +248,9 @@ export function convertPrivateKernelTailToPublicInputsToWitnessMap( privateKernelTailToPublicCircuitPrivateInputs: PrivateKernelTailCircuitPrivateInputs, ): WitnessMap { const mapped = mapPrivateKernelTailToPublicCircuitPrivateInputsToNoir(privateKernelTailToPublicCircuitPrivateInputs); - const initialWitnessMap = abiEncode(PrivateKernelTailToPublicArtifact.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ClientCircuitArtifacts.PrivateKernelTailToPublicArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -413,7 +261,7 @@ export function convertPrivateKernelTailToPublicInputsToWitnessMap( */ export function convertPrivateKernelInitOutputsFromWitnessMap(outputs: WitnessMap): PrivateKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PrivateKernelInitArtifact.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ClientCircuitArtifacts.PrivateKernelInitArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as InitReturnType; @@ -428,7 +276,7 @@ export function convertPrivateKernelInitOutputsFromWitnessMap(outputs: WitnessMa */ export function convertPrivateKernelInnerOutputsFromWitnessMap(outputs: WitnessMap): PrivateKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PrivateKernelInnerArtifact.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ClientCircuitArtifacts.PrivateKernelInnerArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as InnerReturnType; @@ -464,7 +312,7 @@ export function convertPrivateKernelTailOutputsFromWitnessMap( outputs: WitnessMap, ): PrivateKernelTailCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PrivateKernelTailArtifact.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ClientCircuitArtifacts.PrivateKernelTailArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as TailReturnType; @@ -481,7 +329,7 @@ export function convertPrivateKernelTailForPublicOutputsFromWitnessMap( outputs: WitnessMap, ): PrivateKernelTailCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PrivateKernelTailToPublicArtifact.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ClientCircuitArtifacts.PrivateKernelTailToPublicArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicPublicPreviousReturnType; @@ -496,7 +344,7 @@ export function convertPrivateKernelTailForPublicOutputsFromWitnessMap( */ export function convertBaseParityInputsToWitnessMap(inputs: BaseParityInputs): WitnessMap { const mapped = mapBaseParityInputsToNoir(inputs); - const initialWitnessMap = abiEncode(BaseParityJson.abi as Abi, { inputs: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.BaseParityArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } @@ -507,7 +355,7 @@ export function convertBaseParityInputsToWitnessMap(inputs: BaseParityInputs): W */ export function convertRootParityInputsToWitnessMap(inputs: RootParityInputs): WitnessMap { const mapped = mapRootParityInputsToNoir(inputs); - const initialWitnessMap = abiEncode(RootParityJson.abi as Abi, { inputs: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.RootParityArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } @@ -518,13 +366,13 @@ export function convertRootParityInputsToWitnessMap(inputs: RootParityInputs): W */ export function convertBaseRollupInputsToWitnessMap(inputs: BaseRollupInputs): WitnessMap { const mapped = mapBaseRollupInputsToNoir(inputs); - const initialWitnessMap = abiEncode(BaseRollupJson.abi as Abi, { inputs: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.BaseRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } export function convertPrivateKernelEmptyInputsToWitnessMap(inputs: PrivateKernelEmptyInputs): WitnessMap { const mapped = mapEmptyKernelInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PrivateKernelEmptyJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.PrivateKernelEmptyArtifact.abi, { input: mapped as any }); return initialWitnessMap; } @@ -535,7 +383,9 @@ export function convertPrivateKernelEmptyInputsToWitnessMap(inputs: PrivateKerne */ export function convertSimulatedBaseRollupInputsToWitnessMap(inputs: BaseRollupInputs): WitnessMap { const mapped = mapBaseRollupInputsToNoir(inputs); - const initialWitnessMap = abiEncode(BaseRollupSimulatedJson.abi as Abi, { inputs: mapped as any }); + const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.BaseRollupArtifact.abi, { + inputs: mapped as any, + }); return initialWitnessMap; } @@ -546,7 +396,7 @@ export function convertSimulatedBaseRollupInputsToWitnessMap(inputs: BaseRollupI */ export function convertMergeRollupInputsToWitnessMap(inputs: MergeRollupInputs): WitnessMap { const mapped = mapMergeRollupInputsToNoir(inputs); - const initialWitnessMap = abiEncode(MergeRollupJson.abi as Abi, { inputs: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.MergeRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } @@ -557,7 +407,7 @@ export function convertMergeRollupInputsToWitnessMap(inputs: MergeRollupInputs): */ export function convertRootRollupInputsToWitnessMap(inputs: RootRollupInputs): WitnessMap { const mapped = mapRootRollupInputsToNoir(inputs); - const initialWitnessMap = abiEncode(RootRollupJson.abi as Abi, { inputs: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.RootRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } /** @@ -567,7 +417,9 @@ export function convertRootRollupInputsToWitnessMap(inputs: RootRollupInputs): W */ export function convertSimulatedPublicSetupInputsToWitnessMap(inputs: PublicKernelCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelSetupSimulatedJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.PublicKernelSetupArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -578,7 +430,9 @@ export function convertSimulatedPublicSetupInputsToWitnessMap(inputs: PublicKern */ export function convertSimulatedPublicInnerInputsToWitnessMap(inputs: PublicKernelCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelAppLogicSimulatedJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.PublicKernelAppLogicArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -589,7 +443,9 @@ export function convertSimulatedPublicInnerInputsToWitnessMap(inputs: PublicKern */ export function convertSimulatedPublicTeardownInputsToWitnessMap(inputs: PublicKernelCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelTeardownSimulatedJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.PublicKernelTeardownArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -600,7 +456,9 @@ export function convertSimulatedPublicTeardownInputsToWitnessMap(inputs: PublicK */ export function convertSimulatedPublicTailInputsToWitnessMap(inputs: PublicKernelTailCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelTailCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelTailSimulatedJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.PublicKernelTailArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -611,7 +469,7 @@ export function convertSimulatedPublicTailInputsToWitnessMap(inputs: PublicKerne */ export function convertPublicSetupInputsToWitnessMap(inputs: PublicKernelCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelSetupJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.PublicKernelSetupArtifact.abi, { input: mapped as any }); return initialWitnessMap; } @@ -622,7 +480,9 @@ export function convertPublicSetupInputsToWitnessMap(inputs: PublicKernelCircuit */ export function convertPublicInnerInputsToWitnessMap(inputs: PublicKernelCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelAppLogicJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.PublicKernelAppLogicArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -633,7 +493,9 @@ export function convertPublicInnerInputsToWitnessMap(inputs: PublicKernelCircuit */ export function convertPublicTeardownInputsToWitnessMap(inputs: PublicKernelCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelTeardownJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.PublicKernelTeardownArtifact.abi, { + input: mapped as any, + }); return initialWitnessMap; } @@ -644,13 +506,24 @@ export function convertPublicTeardownInputsToWitnessMap(inputs: PublicKernelCirc */ export function convertPublicTailInputsToWitnessMap(inputs: PublicKernelTailCircuitPrivateInputs): WitnessMap { const mapped = mapPublicKernelTailCircuitPrivateInputsToNoir(inputs); - const initialWitnessMap = abiEncode(PublicKernelTailJson.abi as Abi, { input: mapped as any }); + const initialWitnessMap = abiEncode(ServerCircuitArtifacts.PublicKernelTailArtifact.abi, { input: mapped as any }); return initialWitnessMap; } export function convertPrivateKernelEmptyOutputsFromWitnessMap(outputs: WitnessMap): KernelCircuitPublicInputs { - const decodedInputs: DecodedInputs = abiDecode(PrivateKernelEmptyJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.PrivateKernelEmptyArtifact.abi, outputs); + const returnType = decodedInputs.return_value as PrivateKernelEmptyReturnType; + + return mapKernelCircuitPublicInputsFromNoir(returnType); +} +export function convertSimulatedPrivateKernelEmptyOutputsFromWitnessMap( + outputs: WitnessMap, +): KernelCircuitPublicInputs { + const decodedInputs: DecodedInputs = abiDecode( + SimulatedServerCircuitArtifacts.PrivateKernelEmptyArtifact.abi, + outputs, + ); const returnType = decodedInputs.return_value as PrivateKernelEmptyReturnType; return mapKernelCircuitPublicInputsFromNoir(returnType); @@ -663,7 +536,7 @@ export function convertPrivateKernelEmptyOutputsFromWitnessMap(outputs: WitnessM */ export function convertSimulatedBaseRollupOutputsFromWitnessMap(outputs: WitnessMap): BaseOrMergeRollupPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(BaseRollupSimulatedJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(SimulatedServerCircuitArtifacts.BaseRollupArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as BaseRollupReturnType; @@ -678,7 +551,7 @@ export function convertSimulatedBaseRollupOutputsFromWitnessMap(outputs: Witness */ export function convertBaseRollupOutputsFromWitnessMap(outputs: WitnessMap): BaseOrMergeRollupPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(BaseRollupJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.BaseRollupArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as BaseRollupReturnType; @@ -693,7 +566,7 @@ export function convertBaseRollupOutputsFromWitnessMap(outputs: WitnessMap): Bas */ export function convertMergeRollupOutputsFromWitnessMap(outputs: WitnessMap): BaseOrMergeRollupPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(MergeRollupJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.MergeRollupArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as MergeRollupReturnType; @@ -708,7 +581,7 @@ export function convertMergeRollupOutputsFromWitnessMap(outputs: WitnessMap): Ba */ export function convertRootRollupOutputsFromWitnessMap(outputs: WitnessMap): RootRollupPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(RootRollupJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.RootRollupArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as RootRollupReturnType; @@ -723,7 +596,7 @@ export function convertRootRollupOutputsFromWitnessMap(outputs: WitnessMap): Roo */ export function convertBaseParityOutputsFromWitnessMap(outputs: WitnessMap): ParityPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(BaseParityJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.BaseParityArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as BaseParityReturnType; @@ -738,7 +611,7 @@ export function convertBaseParityOutputsFromWitnessMap(outputs: WitnessMap): Par */ export function convertRootParityOutputsFromWitnessMap(outputs: WitnessMap): ParityPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(RootParityJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.RootParityArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as RootParityReturnType; @@ -753,7 +626,10 @@ export function convertRootParityOutputsFromWitnessMap(outputs: WitnessMap): Par */ export function convertSimulatedPublicSetupOutputFromWitnessMap(outputs: WitnessMap): PublicKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelSetupSimulatedJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode( + SimulatedServerCircuitArtifacts.PublicKernelSetupArtifact.abi, + outputs, + ); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicSetupReturnType; @@ -768,7 +644,10 @@ export function convertSimulatedPublicSetupOutputFromWitnessMap(outputs: Witness */ export function convertSimulatedPublicInnerOutputFromWitnessMap(outputs: WitnessMap): PublicKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelAppLogicSimulatedJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode( + SimulatedServerCircuitArtifacts.PublicKernelAppLogicArtifact.abi, + outputs, + ); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicPublicPreviousReturnType; @@ -785,7 +664,10 @@ export function convertSimulatedPublicTeardownOutputFromWitnessMap( outputs: WitnessMap, ): PublicKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelTeardownSimulatedJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode( + SimulatedServerCircuitArtifacts.PublicKernelTeardownArtifact.abi, + outputs, + ); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicPublicPreviousReturnType; @@ -800,7 +682,7 @@ export function convertSimulatedPublicTeardownOutputFromWitnessMap( */ export function convertSimulatedPublicTailOutputFromWitnessMap(outputs: WitnessMap): KernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelTailSimulatedJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(SimulatedServerCircuitArtifacts.PublicKernelTailArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as TailReturnType; @@ -815,7 +697,7 @@ export function convertSimulatedPublicTailOutputFromWitnessMap(outputs: WitnessM */ export function convertPublicSetupOutputFromWitnessMap(outputs: WitnessMap): PublicKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelSetupJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.PublicKernelSetupArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicSetupReturnType; @@ -830,7 +712,7 @@ export function convertPublicSetupOutputFromWitnessMap(outputs: WitnessMap): Pub */ export function convertPublicInnerOutputFromWitnessMap(outputs: WitnessMap): PublicKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelAppLogicJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.PublicKernelAppLogicArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicPublicPreviousReturnType; @@ -845,7 +727,7 @@ export function convertPublicInnerOutputFromWitnessMap(outputs: WitnessMap): Pub */ export function convertPublicTeardownOutputFromWitnessMap(outputs: WitnessMap): PublicKernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelTeardownJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.PublicKernelTeardownArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as PublicPublicPreviousReturnType; @@ -860,7 +742,7 @@ export function convertPublicTeardownOutputFromWitnessMap(outputs: WitnessMap): */ export function convertPublicTailOutputFromWitnessMap(outputs: WitnessMap): KernelCircuitPublicInputs { // Decode the witness map into two fields, the return values and the inputs - const decodedInputs: DecodedInputs = abiDecode(PublicKernelTailJson.abi as Abi, outputs); + const decodedInputs: DecodedInputs = abiDecode(ServerCircuitArtifacts.PublicKernelTailArtifact.abi, outputs); // Cast the inputs as the return type const returnType = decodedInputs.return_value as TailReturnType; diff --git a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts index 32e454308cb..6f69ce635c1 100644 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts @@ -1433,6 +1433,7 @@ export function mapCombinedConstantDataFromNoir(combinedConstantData: CombinedCo return new CombinedConstantData( mapHeaderFromNoir(combinedConstantData.historical_header), mapTxContextFromNoir(combinedConstantData.tx_context), + mapFieldFromNoir(combinedConstantData.vk_tree_root), mapGlobalVariablesFromNoir(combinedConstantData.global_variables), ); } @@ -1446,6 +1447,7 @@ export function mapCombinedConstantDataToNoir(combinedConstantData: CombinedCons return { historical_header: mapHeaderToNoir(combinedConstantData.historicalHeader), tx_context: mapTxContextToNoir(combinedConstantData.txContext), + vk_tree_root: mapFieldToNoir(combinedConstantData.vkTreeRoot), global_variables: mapGlobalVariablesToNoir(combinedConstantData.globalVariables), }; } @@ -1598,6 +1600,7 @@ export function mapPrivateKernelInitCircuitPrivateInputsToNoir( return { tx_request: mapTxRequestToNoir(inputs.txRequest), private_call: mapPrivateCallDataToNoir(inputs.privateCall), + vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), }; } @@ -1828,10 +1831,7 @@ export function mapGasFeesFromNoir(gasFees: GasFeesNoir): GasFees { export function mapConstantRollupDataToNoir(constantRollupData: ConstantRollupData): ConstantRollupDataNoir { return { last_archive: mapAppendOnlyTreeSnapshotToNoir(constantRollupData.lastArchive), - private_kernel_vk_tree_root: mapFieldToNoir(constantRollupData.privateKernelVkTreeRoot), - public_kernel_vk_tree_root: mapFieldToNoir(constantRollupData.publicKernelVkTreeRoot), - base_rollup_vk_hash: mapFieldToNoir(constantRollupData.baseRollupVkHash), - merge_rollup_vk_hash: mapFieldToNoir(constantRollupData.mergeRollupVkHash), + vk_tree_root: mapFieldToNoir(constantRollupData.vkTreeRoot), global_variables: mapGlobalVariablesToNoir(constantRollupData.globalVariables), }; } @@ -1881,10 +1881,7 @@ export function mapPublicCircuitPublicInputsToNoir( export function mapConstantRollupDataFromNoir(constantRollupData: ConstantRollupDataNoir): ConstantRollupData { return new ConstantRollupData( mapAppendOnlyTreeSnapshotFromNoir(constantRollupData.last_archive), - mapFieldFromNoir(constantRollupData.private_kernel_vk_tree_root), - mapFieldFromNoir(constantRollupData.public_kernel_vk_tree_root), - mapFieldFromNoir(constantRollupData.base_rollup_vk_hash), - mapFieldFromNoir(constantRollupData.merge_rollup_vk_hash), + mapFieldFromNoir(constantRollupData.vk_tree_root), mapGlobalVariablesFromNoir(constantRollupData.global_variables), ); } @@ -1968,10 +1965,9 @@ export function mapPreviousRollupDataToNoir(previousRollupData: PreviousRollupDa ), proof: mapRecursiveProofToNoir(previousRollupData.proof), vk: mapVerificationKeyToNoir(previousRollupData.vk), - vk_index: mapFieldToNoir(new Fr(previousRollupData.vkIndex)), - vk_sibling_path: { - leaf_index: mapFieldToNoir(new Fr(previousRollupData.vkSiblingPath.leafIndex)), - sibling_path: mapTuple(previousRollupData.vkSiblingPath.siblingPath, mapFieldToNoir), + vk_witness: { + leaf_index: mapFieldToNoir(new Fr(previousRollupData.vkWitness.leafIndex)), + sibling_path: mapTuple(previousRollupData.vkWitness.siblingPath, mapFieldToNoir), }, }; } @@ -2006,6 +2002,7 @@ export function mapRootRollupParityInputToNoir( return { proof: mapRecursiveProofToNoir(rootParityInput.proof), verification_key: mapVerificationKeyToNoir(rootParityInput.verificationKey), + vk_path: mapTuple(rootParityInput.vkPath, mapFieldToNoir), public_inputs: mapParityPublicInputsToNoir(rootParityInput.publicInputs), }; } @@ -2044,6 +2041,7 @@ export function mapRootParityInputToNoir( return { proof: mapRecursiveProofToNoir(rootParityInput.proof), verification_key: mapVerificationKeyToNoir(rootParityInput.verificationKey), + vk_path: mapTuple(rootParityInput.vkPath, mapFieldToNoir), public_inputs: mapParityPublicInputsToNoir(rootParityInput.publicInputs), }; } @@ -2052,6 +2050,7 @@ export function mapParityPublicInputsToNoir(parityPublicInputs: ParityPublicInpu return { sha_root: mapFieldToNoir(parityPublicInputs.shaRoot), converted_root: mapFieldToNoir(parityPublicInputs.convertedRoot), + vk_tree_root: mapFieldToNoir(parityPublicInputs.vkTreeRoot), }; } @@ -2065,6 +2064,7 @@ export function mapRootRollupPublicInputsFromNoir( ): RootRollupPublicInputs { return new RootRollupPublicInputs( mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.archive), + mapFieldFromNoir(rootRollupPublicInputs.vk_tree_root), mapHeaderFromNoir(rootRollupPublicInputs.header), ); } @@ -2078,6 +2078,7 @@ export function mapParityPublicInputsFromNoir(parityPublicInputs: ParityPublicIn return new ParityPublicInputs( mapFieldFromNoir(parityPublicInputs.sha_root), mapFieldFromNoir(parityPublicInputs.converted_root), + mapFieldFromNoir(parityPublicInputs.vk_tree_root), ); } @@ -2281,6 +2282,7 @@ export function mapStateDiffHintsToNoir(hints: StateDiffHints): StateDiffHintsNo export function mapBaseParityInputsToNoir(inputs: BaseParityInputs): BaseParityInputsNoir { return { msgs: mapTuple(inputs.msgs, mapFieldToNoir), + vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), }; } @@ -2329,6 +2331,7 @@ export function mapEmptyKernelInputsToNoir(inputs: PrivateKernelEmptyInputs): Pr historical_header: mapHeaderToNoir(inputs.header), chain_id: mapFieldToNoir(inputs.chainId), version: mapFieldToNoir(inputs.version), + vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), }; } diff --git a/yarn-project/noir-protocol-circuits-types/src/vks.ts b/yarn-project/noir-protocol-circuits-types/src/vks.ts new file mode 100644 index 00000000000..2d56ff679a9 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/vks.ts @@ -0,0 +1,172 @@ +import { + BASE_PARITY_INDEX, + BASE_ROLLUP_INDEX, + EMPTY_NESTED_INDEX, + Fr, + MERGE_ROLLUP_INDEX, + type MerkleTree, + MerkleTreeCalculator, + PRIVATE_KERNEL_EMPTY_INDEX, + PRIVATE_KERNEL_INIT_INDEX, + PRIVATE_KERNEL_INNER_INDEX, + PRIVATE_KERNEL_RESET_BIG_INDEX, + PRIVATE_KERNEL_RESET_FULL_INDEX, + PRIVATE_KERNEL_RESET_MEDIUM_INDEX, + PRIVATE_KERNEL_RESET_SMALL_INDEX, + PRIVATE_KERNEL_TAIL_INDEX, + PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PUBLIC_KERNEL_APP_LOGIC_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, + PUBLIC_KERNEL_TAIL_INDEX, + PUBLIC_KERNEL_TEARDOWN_INDEX, + ROOT_PARITY_INDEX, + ROOT_ROLLUP_INDEX, + VERIFICATION_KEY_LENGTH_IN_FIELDS, + VK_TREE_HEIGHT, + VerificationKeyAsFields, + VerificationKeyData, +} from '@aztec/circuits.js'; +import { assertLength } from '@aztec/foundation/serialize'; + +import EmptyNestedVkJson from '../artifacts/keys/empty_nested.vk.data.json' assert { type: 'json' }; +import BaseParityVkJson from '../artifacts/keys/parity_base.vk.data.json' assert { type: 'json' }; +import RootParityVkJson from '../artifacts/keys/parity_root.vk.data.json' assert { type: 'json' }; +import PrivateKernelEmptyVkJson from '../artifacts/keys/private_kernel_empty.vk.data.json' assert { type: 'json' }; +import PrivateKernelInitVkJson from '../artifacts/keys/private_kernel_init.vk.data.json' assert { type: 'json' }; +import PrivateKernelInnerVkJson from '../artifacts/keys/private_kernel_inner.vk.data.json' assert { type: 'json' }; +import PrivateKernelResetFullVkJson from '../artifacts/keys/private_kernel_reset.vk.data.json' assert { type: 'json' }; +import PrivateKernelResetBigVkJson from '../artifacts/keys/private_kernel_reset_big.vk.data.json' assert { type: 'json' }; +import PrivateKernelResetMediumVkJson from '../artifacts/keys/private_kernel_reset_medium.vk.data.json' assert { type: 'json' }; +import PrivateKernelResetSmallVkJson from '../artifacts/keys/private_kernel_reset_small.vk.data.json' assert { type: 'json' }; +import PrivateKernelTailVkJson from '../artifacts/keys/private_kernel_tail.vk.data.json' assert { type: 'json' }; +import PrivateKernelTailToPublicVkJson from '../artifacts/keys/private_kernel_tail_to_public.vk.data.json' assert { type: 'json' }; +import PublicKernelAppLogicVkJson from '../artifacts/keys/public_kernel_app_logic.vk.data.json' assert { type: 'json' }; +import PublicKernelSetupVkJson from '../artifacts/keys/public_kernel_setup.vk.data.json' assert { type: 'json' }; +import PublicKernelTailVkJson from '../artifacts/keys/public_kernel_tail.vk.data.json' assert { type: 'json' }; +import PublicKernelTeardownVkJson from '../artifacts/keys/public_kernel_teardown.vk.data.json' assert { type: 'json' }; +import BaseRollupVkJson from '../artifacts/keys/rollup_base.vk.data.json' assert { type: 'json' }; +import MergeRollupVkJson from '../artifacts/keys/rollup_merge.vk.data.json' assert { type: 'json' }; +import RootRollupVkJson from '../artifacts/keys/rollup_root.vk.data.json' assert { type: 'json' }; +import { type ClientProtocolArtifact, type ProtocolArtifact, type ServerProtocolArtifact } from './artifacts.js'; + +interface VkJson { + keyAsBytes: string; + keyAsFields: string[]; +} + +function keyJsonToVKData(json: VkJson): VerificationKeyData { + const { keyAsBytes, keyAsFields } = json; + return new VerificationKeyData( + new VerificationKeyAsFields( + assertLength( + keyAsFields.slice(1).map((str: string) => new Fr(Buffer.from(str.slice(2), 'hex'))), + VERIFICATION_KEY_LENGTH_IN_FIELDS, + ), + new Fr(Buffer.from(keyAsFields[0].slice(2), 'hex')), + ), + Buffer.from(keyAsBytes, 'hex'), + ); +} + +const ServerCircuitVks: Record = { + EmptyNestedArtifact: keyJsonToVKData(EmptyNestedVkJson), + PrivateKernelEmptyArtifact: keyJsonToVKData(PrivateKernelEmptyVkJson), + PublicKernelSetupArtifact: keyJsonToVKData(PublicKernelSetupVkJson), + PublicKernelAppLogicArtifact: keyJsonToVKData(PublicKernelAppLogicVkJson), + PublicKernelTeardownArtifact: keyJsonToVKData(PublicKernelTeardownVkJson), + PublicKernelTailArtifact: keyJsonToVKData(PublicKernelTailVkJson), + BaseParityArtifact: keyJsonToVKData(BaseParityVkJson), + RootParityArtifact: keyJsonToVKData(RootParityVkJson), + BaseRollupArtifact: keyJsonToVKData(BaseRollupVkJson), + MergeRollupArtifact: keyJsonToVKData(MergeRollupVkJson), + RootRollupArtifact: keyJsonToVKData(RootRollupVkJson), +}; + +const ClientCircuitVks: Record = { + PrivateKernelInitArtifact: keyJsonToVKData(PrivateKernelInitVkJson), + PrivateKernelInnerArtifact: keyJsonToVKData(PrivateKernelInnerVkJson), + PrivateKernelResetFullArtifact: keyJsonToVKData(PrivateKernelResetFullVkJson), + PrivateKernelResetBigArtifact: keyJsonToVKData(PrivateKernelResetBigVkJson), + PrivateKernelResetMediumArtifact: keyJsonToVKData(PrivateKernelResetMediumVkJson), + PrivateKernelResetSmallArtifact: keyJsonToVKData(PrivateKernelResetSmallVkJson), + PrivateKernelTailArtifact: keyJsonToVKData(PrivateKernelTailVkJson), + PrivateKernelTailToPublicArtifact: keyJsonToVKData(PrivateKernelTailToPublicVkJson), +}; + +export const ProtocolCircuitVks: Record = { + ...ClientCircuitVks, + ...ServerCircuitVks, +}; + +export const ProtocolCircuitVkIndexes: Record = { + EmptyNestedArtifact: EMPTY_NESTED_INDEX, + PrivateKernelEmptyArtifact: PRIVATE_KERNEL_EMPTY_INDEX, + PrivateKernelInitArtifact: PRIVATE_KERNEL_INIT_INDEX, + PrivateKernelInnerArtifact: PRIVATE_KERNEL_INNER_INDEX, + PrivateKernelResetFullArtifact: PRIVATE_KERNEL_RESET_FULL_INDEX, + PrivateKernelResetBigArtifact: PRIVATE_KERNEL_RESET_BIG_INDEX, + PrivateKernelResetMediumArtifact: PRIVATE_KERNEL_RESET_MEDIUM_INDEX, + PrivateKernelResetSmallArtifact: PRIVATE_KERNEL_RESET_SMALL_INDEX, + PrivateKernelTailArtifact: PRIVATE_KERNEL_TAIL_INDEX, + PrivateKernelTailToPublicArtifact: PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, + PublicKernelSetupArtifact: PUBLIC_KERNEL_SETUP_INDEX, + PublicKernelAppLogicArtifact: PUBLIC_KERNEL_APP_LOGIC_INDEX, + PublicKernelTeardownArtifact: PUBLIC_KERNEL_TEARDOWN_INDEX, + PublicKernelTailArtifact: PUBLIC_KERNEL_TAIL_INDEX, + BaseParityArtifact: BASE_PARITY_INDEX, + RootParityArtifact: ROOT_PARITY_INDEX, + BaseRollupArtifact: BASE_ROLLUP_INDEX, + MergeRollupArtifact: MERGE_ROLLUP_INDEX, + RootRollupArtifact: ROOT_ROLLUP_INDEX, +}; + +function buildVKTree() { + const calculator = new MerkleTreeCalculator(VK_TREE_HEIGHT); + const vkHashes = new Array(2 ** VK_TREE_HEIGHT).fill(Buffer.alloc(32)); + + for (const [key, value] of Object.entries(ProtocolCircuitVks)) { + const index = ProtocolCircuitVkIndexes[key as ProtocolArtifact]; + vkHashes[index] = value.keyAsFields.hash.toBuffer(); + } + + return calculator.computeTree(vkHashes); +} + +let vkTree: MerkleTree | undefined; + +export function getVKTree() { + if (!vkTree) { + vkTree = buildVKTree(); + } + return vkTree; +} + +export function getVKTreeRoot() { + return Fr.fromBuffer(getVKTree().root); +} + +export function getVKIndex(vk: VerificationKeyData | VerificationKeyAsFields | Fr) { + let hash; + if (vk instanceof VerificationKeyData) { + hash = vk.keyAsFields.hash; + } else if (vk instanceof VerificationKeyAsFields) { + hash = vk.hash; + } else { + hash = vk; + } + + const index = getVKTree().getIndex(hash.toBuffer()); + if (index < 0) { + throw new Error(`VK index for ${hash.toString()} not found in VK tree`); + } + return index; +} + +export function getVKSiblingPath(vkIndex: number) { + return assertLength( + getVKTree() + .getSiblingPath(vkIndex) + .map(buf => new Fr(buf)), + VK_TREE_HEIGHT, + ); +} diff --git a/yarn-project/noir-protocol-circuits-types/tsconfig.json b/yarn-project/noir-protocol-circuits-types/tsconfig.json index 390735ab54c..ddf8367e766 100644 --- a/yarn-project/noir-protocol-circuits-types/tsconfig.json +++ b/yarn-project/noir-protocol-circuits-types/tsconfig.json @@ -19,9 +19,6 @@ { "path": "../types" }, - { - "path": "../circuit-types" - }, { "path": "../kv-store" }, diff --git a/yarn-project/prover-client/src/mocks/fixtures.ts b/yarn-project/prover-client/src/mocks/fixtures.ts index 09934382c59..c10f9d42140 100644 --- a/yarn-project/prover-client/src/mocks/fixtures.ts +++ b/yarn-project/prover-client/src/mocks/fixtures.ts @@ -27,6 +27,7 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { randomBytes } from '@aztec/foundation/crypto'; import { type DebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { NativeACVMSimulator, type SimulationProvider, WASMSimulator } from '@aztec/simulator'; import { type MerkleTreeOperations } from '@aztec/world-state'; @@ -99,6 +100,7 @@ export const makeBloatedProcessedTx = async (builderDb: MerkleTreeOperations, se seed *= MAX_NULLIFIERS_PER_TX; // Ensure no clashing given incremental seeds const tx = mockTx(seed); const kernelOutput = KernelCircuitPublicInputs.empty(); + kernelOutput.constants.vkTreeRoot = getVKTreeRoot(); kernelOutput.constants.historicalHeader = await builderDb.buildInitialHeader(); kernelOutput.end.publicDataUpdateRequests = makeTuple( MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, @@ -128,7 +130,7 @@ export const makeBloatedProcessedTx = async (builderDb: MerkleTreeOperations, se export const makeEmptyProcessedTx = async (builderDb: MerkleTreeOperations, chainId: Fr, version: Fr) => { const header = await builderDb.buildInitialHeader(); - return makeEmptyProcessedTxFromHistoricalTreeRoots(header, chainId, version); + return makeEmptyProcessedTxFromHistoricalTreeRoots(header, chainId, version, getVKTreeRoot()); }; // Updates the expectedDb trees based on the new note hashes, contracts, and nullifiers from these txs diff --git a/yarn-project/prover-client/src/mocks/test_context.ts b/yarn-project/prover-client/src/mocks/test_context.ts index 1573ba7f68d..91d6c9bac98 100644 --- a/yarn-project/prover-client/src/mocks/test_context.ts +++ b/yarn-project/prover-client/src/mocks/test_context.ts @@ -8,14 +8,7 @@ import { type Tx, type TxValidator, } from '@aztec/circuit-types'; -import { - type Gas, - GlobalVariables, - Header, - type Nullifier, - type TxContext, - getMockVerificationKeys, -} from '@aztec/circuits.js'; +import { type Gas, GlobalVariables, Header, type Nullifier, type TxContext } from '@aztec/circuits.js'; import { type Fr } from '@aztec/foundation/fields'; import { type DebugLogger } from '@aztec/foundation/log'; import { openTmpStore } from '@aztec/kv-store/utils'; @@ -44,9 +37,9 @@ import { ProverAgent } from '../prover-agent/prover-agent.js'; import { getEnvironmentConfig, getSimulationProvider, makeGlobals } from './fixtures.js'; class DummyProverClient implements BlockProver { - constructor(private orchestrator: ProvingOrchestrator, private verificationKeys = getMockVerificationKeys()) {} + constructor(private orchestrator: ProvingOrchestrator) {} startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise { - return this.orchestrator.startNewBlock(numTxs, globalVariables, l1ToL2Messages, this.verificationKeys); + return this.orchestrator.startNewBlock(numTxs, globalVariables, l1ToL2Messages); } addNewTx(tx: ProcessedTx): Promise { return this.orchestrator.addNewTx(tx); diff --git a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts index 64e68f7a271..fd1c2e82746 100644 --- a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts +++ b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts @@ -30,7 +30,6 @@ import { PublicDataTreeLeaf, type PublicDataTreeLeafPreimage, PublicDataUpdateRequest, - ROLLUP_VK_TREE_HEIGHT, type RecursiveProof, type RootParityInput, RootRollupInputs, @@ -45,16 +44,10 @@ import { import { assertPermutation, makeTuple } from '@aztec/foundation/array'; import { padArrayEnd } from '@aztec/foundation/collection'; import { type Tuple, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize'; +import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { HintsBuilder, computeFeePayerBalanceLeafSlot } from '@aztec/simulator'; import { type MerkleTreeOperations } from '@aztec/world-state'; -// Denotes fields that are not used now, but will be in the future -const FUTURE_FR = new Fr(0n); -const FUTURE_NUM = 0; - -// Denotes fields that should be deleted -const DELETE_FR = new Fr(0n); - /** * Type representing the names of the trees for the base rollup. */ @@ -267,18 +260,13 @@ export function getPreviousRollupDataFromPublicInputs( rollupProof: RecursiveProof, vk: VerificationKeyAsFields, ) { + const leafIndex = getVKIndex(vk); + return new PreviousRollupData( rollupOutput, rollupProof, vk, - - // MembershipWitness for a VK tree to be implemented in the future - FUTURE_NUM, - new MembershipWitness( - ROLLUP_VK_TREE_HEIGHT, - BigInt(FUTURE_NUM), - makeTuple(ROLLUP_VK_TREE_HEIGHT, () => FUTURE_FR), - ), + new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)), ); } @@ -287,10 +275,7 @@ export async function getConstantRollupData( db: MerkleTreeOperations, ): Promise { return ConstantRollupData.from({ - baseRollupVkHash: DELETE_FR, - mergeRollupVkHash: DELETE_FR, - privateKernelVkTreeRoot: FUTURE_FR, - publicKernelVkTreeRoot: FUTURE_FR, + vkTreeRoot: getVKTreeRoot(), lastArchive: await getTreeSnapshot(MerkleTreeId.ARCHIVE, db), globalVariables, }); @@ -303,6 +288,8 @@ export async function getTreeSnapshot(id: MerkleTreeId, db: MerkleTreeOperations export function getKernelDataFor(tx: ProcessedTx, vk: VerificationKeyData): KernelData { const recursiveProof = makeRecursiveProofFromBinary(tx.proof, NESTED_RECURSIVE_PROOF_LENGTH); + const leafIndex = getVKIndex(vk); + return new KernelData( tx.data, recursiveProof, @@ -310,9 +297,8 @@ export function getKernelDataFor(tx: ProcessedTx, vk: VerificationKeyData): Kern // VK for the kernel circuit vk, - // MembershipWitness for a VK tree to be implemented in the future - FUTURE_NUM, - assertLength(Array(VK_TREE_HEIGHT).fill(FUTURE_FR), VK_TREE_HEIGHT), + leafIndex, + getVKSiblingPath(leafIndex), ); } diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator.ts b/yarn-project/prover-client/src/orchestrator/orchestrator.ts index 1f68ce4c4ef..5673297f60a 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator.ts @@ -45,7 +45,6 @@ import { RootParityInputs, type VerificationKeyAsFields, VerificationKeyData, - type VerificationKeys, makeEmptyProof, } from '@aztec/circuits.js'; import { makeTuple } from '@aztec/foundation/array'; @@ -55,6 +54,7 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { promiseWithResolvers } from '@aztec/foundation/promise'; import { BufferReader, type Tuple } from '@aztec/foundation/serialize'; import { pushTestData } from '@aztec/foundation/testing'; +import { ProtocolCircuitVks, getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { Attributes, type TelemetryClient, type Tracer, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client'; import { type MerkleTreeOperations } from '@aztec/world-state'; @@ -128,7 +128,6 @@ export class ProvingOrchestrator { numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[], - verificationKeys: VerificationKeys, ): Promise { // Create initial header if not done so yet if (!this.initialHeader) { @@ -150,7 +149,7 @@ export class ProvingOrchestrator { throw new Error('Too many L1 to L2 messages'); } baseParityInputs = Array.from({ length: NUM_BASE_PARITY_PER_ROOT_PARITY }, (_, i) => - BaseParityInputs.fromSlice(l1ToL2MessagesPadded, i), + BaseParityInputs.fromSlice(l1ToL2MessagesPadded, i, getVKTreeRoot()), ); const messageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.db); @@ -188,7 +187,6 @@ export class ProvingOrchestrator { baseParityInputs.length, messageTreeSnapshot, newL1ToL2MessageTreeRootSiblingPath, - verificationKeys, ); for (let i = 0; i < baseParityInputs.length; i++) { @@ -271,6 +269,7 @@ export class ProvingOrchestrator { this.initialHeader ?? (await this.db.buildInitialHeader()), this.provingState.globalVariables.chainId, this.provingState.globalVariables.version, + getVKTreeRoot(), ); const txInputs: Array<{ inputs: BaseRollupInputs; snapshot: TreeSnapshots }> = []; for (let i = 0; i < paddingTxCount; i++) { @@ -318,6 +317,7 @@ export class ProvingOrchestrator { chainId: unprovenPaddingTx.data.constants.txContext.chainId, version: unprovenPaddingTx.data.constants.txContext.version, header: unprovenPaddingTx.data.constants.historicalHeader, + vkTreeRoot: getVKTreeRoot(), }, signal, ), @@ -346,6 +346,9 @@ export class ProvingOrchestrator { for (let i = 0; i < txInputs.length; i++) { txInputs[i].inputs.kernelData.vk = paddingTx.verificationKey; txInputs[i].inputs.kernelData.proof = paddingTx.recursiveProof; + + txInputs[i].inputs.kernelData.vkIndex = getVKIndex(paddingTx.verificationKey); + txInputs[i].inputs.kernelData.vkPath = getVKSiblingPath(txInputs[i].inputs.kernelData.vkIndex); this.enqueueFirstProof(txInputs[i].inputs, txInputs[i].snapshot, paddingTx, provingState); } } @@ -448,7 +451,7 @@ export class ProvingOrchestrator { private async prepareTransaction(tx: ProcessedTx, provingState: ProvingState) { // Pass the private kernel tail vk here as the previous one. // If there are public functions then this key will be overwritten once the public tail has been proven - const previousKernelVerificationKey = provingState.privateKernelVerificationKeys.privateKernelCircuit; + const previousKernelVerificationKey = ProtocolCircuitVks.PrivateKernelTailArtifact; const txInputs = await this.prepareBaseRollupInputs(provingState, tx, previousKernelVerificationKey); if (!txInputs) { @@ -468,7 +471,7 @@ export class ProvingOrchestrator { tx, inputs, treeSnapshots, - provingState.privateKernelVerificationKeys.privateKernelToPublicCircuit, + ProtocolCircuitVks.PrivateKernelTailToPublicArtifact, ); const txIndex = provingState.addNewTx(txProvingState); const numPublicKernels = txProvingState.getNumPublicKernels(); @@ -982,6 +985,11 @@ export class ProvingOrchestrator { // Take the final public tail proof and verification key and pass them to the base rollup txProvingState.baseRollupInputs.kernelData.proof = result.proof; txProvingState.baseRollupInputs.kernelData.vk = result.verificationKey; + txProvingState.baseRollupInputs.kernelData.vkIndex = getVKIndex(result.verificationKey); + txProvingState.baseRollupInputs.kernelData.vkPath = getVKSiblingPath( + txProvingState.baseRollupInputs.kernelData.vkIndex, + ); + this.enqueueBaseRollup(provingState, BigInt(txIndex), txProvingState); return; } diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts index e4ae1e55a4a..ade0c83053e 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts @@ -1,5 +1,5 @@ import { PROVING_STATUS } from '@aztec/circuit-types'; -import { Fr, getMockVerificationKeys } from '@aztec/circuits.js'; +import { Fr } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { makeBloatedProcessedTx, makeEmptyProcessedTestTx } from '../mocks/fixtures.js'; @@ -29,13 +29,7 @@ describe('prover/orchestrator/errors', () => { makeBloatedProcessedTx(context.actualDb, 4), ]); - const blockTicket = await context.orchestrator.startNewBlock( - txs.length, - context.globalVariables, - [], - - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(txs.length, context.globalVariables, []); for (const tx of txs) { await context.orchestrator.addNewTx(tx); @@ -71,7 +65,7 @@ describe('prover/orchestrator/errors', () => { }); it('throws if setting an incomplete block completed', async () => { - await context.orchestrator.startNewBlock(3, context.globalVariables, [], getMockVerificationKeys()); + await context.orchestrator.startNewBlock(3, context.globalVariables, []); await expect(async () => await context.orchestrator.setBlockCompleted()).rejects.toThrow( `Block not ready for completion: expecting ${3} more transactions.`, ); @@ -83,12 +77,7 @@ describe('prover/orchestrator/errors', () => { makeEmptyProcessedTestTx(context.actualDb), ]); - const blockTicket = await context.orchestrator.startNewBlock( - txs.length, - context.globalVariables, - [], - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(txs.length, context.globalVariables, []); await context.orchestrator.setBlockCompleted(); @@ -100,13 +89,7 @@ describe('prover/orchestrator/errors', () => { }); it('throws if adding to a cancelled block', async () => { - await context.orchestrator.startNewBlock( - 2, - context.globalVariables, - [], - - getMockVerificationKeys(), - ); + await context.orchestrator.startNewBlock(2, context.globalVariables, []); context.orchestrator.cancelBlock(); @@ -119,14 +102,7 @@ describe('prover/orchestrator/errors', () => { 'fails to start a block with %i transactions', async (blockSize: number) => { await expect( - async () => - await context.orchestrator.startNewBlock( - blockSize, - context.globalVariables, - [], - - getMockVerificationKeys(), - ), + async () => await context.orchestrator.startNewBlock(blockSize, context.globalVariables, []), ).rejects.toThrow(`Length of txs for the block should be at least two (got ${blockSize})`); }, ); @@ -135,14 +111,7 @@ describe('prover/orchestrator/errors', () => { // Assemble a fake transaction const l1ToL2Messages = new Array(100).fill(new Fr(0n)); await expect( - async () => - await context.orchestrator.startNewBlock( - 2, - context.globalVariables, - l1ToL2Messages, - - getMockVerificationKeys(), - ), + async () => await context.orchestrator.startNewBlock(2, context.globalVariables, l1ToL2Messages), ).rejects.toThrow('Too many L1 to L2 messages'); }); }); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts index 6e31aebd688..18797c30105 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts @@ -1,5 +1,4 @@ import { PROVING_STATUS, type ServerCircuitProver } from '@aztec/circuit-types'; -import { getMockVerificationKeys } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { WASMSimulator } from '@aztec/simulator'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; @@ -72,13 +71,7 @@ describe('prover/orchestrator/failures', () => { makeBloatedProcessedTx(context.actualDb, 3), ]); - const blockTicket = await orchestrator.startNewBlock( - txs.length, - context.globalVariables, - [], - - getMockVerificationKeys(), - ); + const blockTicket = await orchestrator.startNewBlock(txs.length, context.globalVariables, []); for (const tx of txs) { await orchestrator.addNewTx(tx); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_lifecycle.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_lifecycle.test.ts index 5814ae93b20..20fb077ebf8 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_lifecycle.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_lifecycle.test.ts @@ -3,7 +3,6 @@ import { type GlobalVariables, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_BASE_PARITY_PER_ROOT_PARITY, - getMockVerificationKeys, } from '@aztec/circuits.js'; import { fr, makeGlobalVariables } from '@aztec/circuits.js/testing'; import { range } from '@aztec/foundation/array'; @@ -49,13 +48,7 @@ describe('prover/orchestrator/lifecycle', () => { const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); - const blockTicket1 = await context.orchestrator.startNewBlock( - 2, - globals1, - l1ToL2Messages, - - getMockVerificationKeys(), - ); + const blockTicket1 = await context.orchestrator.startNewBlock(2, globals1, l1ToL2Messages); await context.orchestrator.addNewTx(txs1[0]); await context.orchestrator.addNewTx(txs1[1]); @@ -73,13 +66,7 @@ describe('prover/orchestrator/lifecycle', () => { await context.actualDb.rollback(); - const blockTicket2 = await context.orchestrator.startNewBlock( - 2, - globals2, - l1ToL2Messages, - - getMockVerificationKeys(), - ); + const blockTicket2 = await context.orchestrator.startNewBlock(2, globals2, l1ToL2Messages); await context.orchestrator.addNewTx(txs2[0]); await context.orchestrator.addNewTx(txs2[1]); @@ -107,25 +94,13 @@ describe('prover/orchestrator/lifecycle', () => { const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); - const blockTicket1 = await context.orchestrator.startNewBlock( - 2, - globals1, - l1ToL2Messages, - - getMockVerificationKeys(), - ); + const blockTicket1 = await context.orchestrator.startNewBlock(2, globals1, l1ToL2Messages); await context.orchestrator.addNewTx(txs1[0]); await context.actualDb.rollback(); - const blockTicket2 = await context.orchestrator.startNewBlock( - 2, - globals2, - l1ToL2Messages, - - getMockVerificationKeys(), - ); + const blockTicket2 = await context.orchestrator.startNewBlock(2, globals2, l1ToL2Messages); await context.orchestrator.addNewTx(txs2[0]); await context.orchestrator.addNewTx(txs2[1]); @@ -152,13 +127,7 @@ describe('prover/orchestrator/lifecycle', () => { deferredPromises.push(deferred); return deferred.promise; }); - await orchestrator.startNewBlock( - 2, - makeGlobalVariables(1), - [], - - getMockVerificationKeys(), - ); + await orchestrator.startNewBlock(2, makeGlobalVariables(1), []); await sleep(1); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts index 5c686a472a5..cf7ecd749bd 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts @@ -1,5 +1,5 @@ import { PROVING_STATUS } from '@aztec/circuit-types'; -import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, getMockVerificationKeys } from '@aztec/circuits.js'; +import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js'; import { fr } from '@aztec/circuits.js/testing'; import { range } from '@aztec/foundation/array'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -30,13 +30,7 @@ describe('prover/orchestrator/mixed-blocks', () => { const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); - const blockTicket = await context.orchestrator.startNewBlock( - 3, - context.globalVariables, - l1ToL2Messages, - - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(3, context.globalVariables, l1ToL2Messages); for (const tx of txs) { await context.orchestrator.addNewTx(tx); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks_2.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks_2.test.ts index 3000e349085..48d429a1e38 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks_2.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks_2.test.ts @@ -1,5 +1,5 @@ import { MerkleTreeId, PROVING_STATUS } from '@aztec/circuit-types'; -import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, getMockVerificationKeys } from '@aztec/circuits.js'; +import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js'; import { fr } from '@aztec/circuits.js/testing'; import { range } from '@aztec/foundation/array'; import { times } from '@aztec/foundation/collection'; @@ -33,13 +33,7 @@ describe('prover/orchestrator/mixed-blocks', () => { const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); - const blockTicket = await context.orchestrator.startNewBlock( - txs.length, - context.globalVariables, - l1ToL2Messages, - - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(txs.length, context.globalVariables, l1ToL2Messages); for (const tx of txs) { await context.orchestrator.addNewTx(tx); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_multi_public_functions.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_multi_public_functions.test.ts index 21e5f5f502b..b87f0a1fe2f 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_multi_public_functions.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_multi_public_functions.test.ts @@ -1,7 +1,7 @@ import { PROVING_STATUS, mockTx } from '@aztec/circuit-types'; -import { getMockVerificationKeys } from '@aztec/circuits.js'; import { times } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { TestContext } from '../mocks/test_context.js'; @@ -35,15 +35,10 @@ describe('prover/orchestrator/public-functions', () => { ); for (const tx of txs) { tx.data.constants.historicalHeader = await context.actualDb.buildInitialHeader(); + tx.data.constants.vkTreeRoot = getVKTreeRoot(); } - const blockTicket = await context.orchestrator.startNewBlock( - numTransactions, - context.globalVariables, - [], - - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(numTransactions, context.globalVariables, []); const [processed, failed] = await context.processPublicFunctions(txs, numTransactions, context.blockProver); expect(processed.length).toBe(numTransactions); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_multiple_blocks.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_multiple_blocks.test.ts index ac6bfe63d97..193cd667dc4 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_multiple_blocks.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_multiple_blocks.test.ts @@ -1,6 +1,6 @@ import { PROVING_STATUS } from '@aztec/circuit-types'; -import { getMockVerificationKeys } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { makeBloatedProcessedTx, makeGlobals } from '../mocks/fixtures.js'; import { TestContext } from '../mocks/test_context.js'; @@ -26,13 +26,14 @@ describe('prover/orchestrator/multi-block', () => { for (let i = 0; i < numBlocks; i++) { const tx = await makeBloatedProcessedTx(context.actualDb, i + 1); tx.data.constants.historicalHeader = header; + tx.data.constants.vkTreeRoot = getVKTreeRoot(); const blockNum = i + 1000; const globals = makeGlobals(blockNum); // This will need to be a 2 tx block - const blockTicket = await context.orchestrator.startNewBlock(2, globals, [], getMockVerificationKeys()); + const blockTicket = await context.orchestrator.startNewBlock(2, globals, []); await context.orchestrator.addNewTx(tx); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_public_functions.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_public_functions.test.ts index 2cf9b38146b..73365e3c3e6 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_public_functions.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_public_functions.test.ts @@ -1,6 +1,6 @@ import { PROVING_STATUS, mockTx } from '@aztec/circuit-types'; -import { getMockVerificationKeys } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { TestContext } from '../mocks/test_context.js'; @@ -35,16 +35,12 @@ describe('prover/orchestrator/public-functions', () => { numberOfRevertiblePublicCallRequests, }); tx.data.constants.historicalHeader = await context.actualDb.buildInitialHeader(); + tx.data.constants.vkTreeRoot = getVKTreeRoot(); const [processed, _] = await context.processPublicFunctions([tx], 1, undefined); // This will need to be a 2 tx block - const blockTicket = await context.orchestrator.startNewBlock( - 2, - context.globalVariables, - [], - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(2, context.globalVariables, []); for (const processedTx of processed) { await context.orchestrator.addNewTx(processedTx); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts index 635d1dec429..b2dca6f6bb2 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts @@ -1,5 +1,5 @@ import { PROVING_STATUS } from '@aztec/circuit-types'; -import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, getMockVerificationKeys } from '@aztec/circuits.js'; +import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js'; import { fr } from '@aztec/circuits.js/testing'; import { range } from '@aztec/foundation/array'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -27,12 +27,7 @@ describe('prover/orchestrator/blocks', () => { describe('blocks', () => { it('builds an empty L2 block', async () => { - const blockTicket = await context.orchestrator.startNewBlock( - 2, - context.globalVariables, - [], - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(2, context.globalVariables, []); await context.orchestrator.setBlockCompleted(); @@ -49,12 +44,7 @@ describe('prover/orchestrator/blocks', () => { await updateExpectedTreesFromTxs(expectsDb, txs); // This will need to be a 2 tx block - const blockTicket = await context.orchestrator.startNewBlock( - 2, - context.globalVariables, - [], - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(2, context.globalVariables, []); for (const tx of txs) { await context.orchestrator.addNewTx(tx); @@ -80,12 +70,7 @@ describe('prover/orchestrator/blocks', () => { const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); - const blockTicket = await context.orchestrator.startNewBlock( - txs.length, - context.globalVariables, - l1ToL2Messages, - getMockVerificationKeys(), - ); + const blockTicket = await context.orchestrator.startNewBlock(txs.length, context.globalVariables, l1ToL2Messages); for (const tx of txs) { await context.orchestrator.addNewTx(tx); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts index e139b16d18f..3c34ff32dda 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts @@ -5,7 +5,6 @@ import { NUM_BASE_PARITY_PER_ROOT_PARITY, RECURSIVE_PROOF_LENGTH, type RootParityInput, - getMockVerificationKeys, } from '@aztec/circuits.js'; import { makeGlobalVariables, makeRootParityInput } from '@aztec/circuits.js/testing'; import { promiseWithResolvers } from '@aztec/foundation/promise'; @@ -47,7 +46,7 @@ describe('prover/orchestrator', () => { } }); - await orchestrator.startNewBlock(2, makeGlobalVariables(1), [message], getMockVerificationKeys()); + await orchestrator.startNewBlock(2, makeGlobalVariables(1), [message]); await sleep(10); expect(mockProver.getBaseParityProof).toHaveBeenCalledTimes(NUM_BASE_PARITY_PER_ROOT_PARITY); diff --git a/yarn-project/prover-client/src/orchestrator/proving-state.ts b/yarn-project/prover-client/src/orchestrator/proving-state.ts index 51004578237..e247b6f0d20 100644 --- a/yarn-project/prover-client/src/orchestrator/proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/proving-state.ts @@ -13,7 +13,6 @@ import { type RootParityInput, type RootRollupPublicInputs, type VerificationKeyAsFields, - type VerificationKeys, } from '@aztec/circuits.js'; import { type Tuple } from '@aztec/foundation/serialize'; @@ -61,7 +60,6 @@ export class ProvingState { numRootParityInputs: number, public readonly messageTreeSnapshot: AppendOnlyTreeSnapshot, public readonly messageTreeRootSiblingPath: Tuple, - public readonly privateKernelVerificationKeys: VerificationKeys, ) { this.rootParityInputs = Array.from({ length: numRootParityInputs }).map(_ => undefined); } diff --git a/yarn-project/prover-client/src/prover-agent/memory-proving-queue.test.ts b/yarn-project/prover-client/src/prover-agent/memory-proving-queue.test.ts index 1aed172cc54..cde99db00b5 100644 --- a/yarn-project/prover-client/src/prover-agent/memory-proving-queue.test.ts +++ b/yarn-project/prover-client/src/prover-agent/memory-proving-queue.test.ts @@ -1,11 +1,14 @@ import { ProvingRequestType } from '@aztec/circuit-types'; import { + Fr, RECURSIVE_PROOF_LENGTH, RootParityInput, + VK_TREE_HEIGHT, VerificationKeyAsFields, makeRecursiveProof, } from '@aztec/circuits.js'; import { makeBaseParityInputs, makeBaseRollupInputs, makeParityPublicInputs } from '@aztec/circuits.js/testing'; +import { makeTuple } from '@aztec/foundation/array'; import { AbortError } from '@aztec/foundation/error'; import { sleep } from '@aztec/foundation/sleep'; @@ -52,8 +55,9 @@ describe('MemoryProvingQueue', () => { const publicInputs = makeParityPublicInputs(); const proof = makeRecursiveProof(RECURSIVE_PROOF_LENGTH); const vk = VerificationKeyAsFields.makeFake(); - await queue.resolveProvingJob(job!.id, new RootParityInput(proof, vk, publicInputs)); - await expect(promise).resolves.toEqual(new RootParityInput(proof, vk, publicInputs)); + const vkPath = makeTuple(VK_TREE_HEIGHT, Fr.zero); + await queue.resolveProvingJob(job!.id, new RootParityInput(proof, vk, vkPath, publicInputs)); + await expect(promise).resolves.toEqual(new RootParityInput(proof, vk, vkPath, publicInputs)); }); it('retries failed jobs', async () => { @@ -109,6 +113,7 @@ describe('MemoryProvingQueue', () => { const output = new RootParityInput( makeRecursiveProof(RECURSIVE_PROOF_LENGTH), VerificationKeyAsFields.makeFake(), + makeTuple(VK_TREE_HEIGHT, Fr.zero), makeParityPublicInputs(), ); await queue.resolveProvingJob(job!.id, output); diff --git a/yarn-project/prover-client/src/prover-agent/prover-agent.test.ts b/yarn-project/prover-client/src/prover-agent/prover-agent.test.ts index 3c52df01acc..8ebbabe34df 100644 --- a/yarn-project/prover-client/src/prover-agent/prover-agent.test.ts +++ b/yarn-project/prover-client/src/prover-agent/prover-agent.test.ts @@ -1,11 +1,14 @@ import { type ServerCircuitProver } from '@aztec/circuit-types'; import { + Fr, RECURSIVE_PROOF_LENGTH, RootParityInput, + VK_TREE_HEIGHT, VerificationKeyAsFields, makeRecursiveProof, } from '@aztec/circuits.js'; import { makeBaseParityInputs, makeParityPublicInputs } from '@aztec/circuits.js/testing'; +import { makeTuple } from '@aztec/foundation/array'; import { type MockProxy, mock } from 'jest-mock-extended'; @@ -38,13 +41,15 @@ describe('ProverAgent', () => { const proof = makeRecursiveProof(RECURSIVE_PROOF_LENGTH); const vk = VerificationKeyAsFields.makeFake(); prover.getBaseParityProof.mockResolvedValue( - new RootParityInput(proof, vk, publicInputs), + new RootParityInput(proof, vk, makeTuple(VK_TREE_HEIGHT, Fr.zero), publicInputs), ); const inputs = makeBaseParityInputs(); const promise = queue.getBaseParityProof(inputs); - await expect(promise).resolves.toEqual(new RootParityInput(proof, vk, publicInputs)); + await expect(promise).resolves.toEqual( + new RootParityInput(proof, vk, makeTuple(VK_TREE_HEIGHT, Fr.zero), publicInputs), + ); expect(prover.getBaseParityProof).toHaveBeenCalledWith(inputs); }); @@ -65,21 +70,21 @@ describe('ProverAgent', () => { const proof = makeRecursiveProof(RECURSIVE_PROOF_LENGTH); const vk = VerificationKeyAsFields.makeFake(); prover.getBaseParityProof.mockResolvedValue( - new RootParityInput(proof, vk, publicInputs), + new RootParityInput(proof, vk, makeTuple(VK_TREE_HEIGHT, Fr.zero), publicInputs), ); const inputs = makeBaseParityInputs(); const promise1 = queue.getBaseParityProof(inputs); await expect(promise1).resolves.toEqual( - new RootParityInput(proof, vk, publicInputs), + new RootParityInput(proof, vk, makeTuple(VK_TREE_HEIGHT, Fr.zero), publicInputs), ); const inputs2 = makeBaseParityInputs(); const promise2 = queue.getBaseParityProof(inputs2); await expect(promise2).resolves.toEqual( - new RootParityInput(proof, vk, publicInputs), + new RootParityInput(proof, vk, makeTuple(VK_TREE_HEIGHT, Fr.zero), publicInputs), ); expect(prover.getBaseParityProof).toHaveBeenCalledTimes(2); diff --git a/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts b/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts index 2bc202a947b..51f54b60c5a 100644 --- a/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts +++ b/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts @@ -1,6 +1,7 @@ import { BBNativeRollupProver, type BBProverConfig } from '@aztec/bb-prover'; import { makePaddingProcessedTx } from '@aztec/circuit-types'; import { createDebugLogger } from '@aztec/foundation/log'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; import { TestContext } from '../mocks/test_context.js'; @@ -28,11 +29,13 @@ describe('prover/bb_prover/base-rollup', () => { const header = await context.actualDb.buildInitialHeader(); const chainId = context.globalVariables.chainId; const version = context.globalVariables.version; + const vkTreeRoot = getVKTreeRoot(); const inputs = { header, chainId, version, + vkTreeRoot, }; const paddingTxPublicInputsAndProof = await context.prover.getEmptyPrivateKernelProof(inputs); diff --git a/yarn-project/prover-client/src/test/bb_prover_full_rollup.test.ts b/yarn-project/prover-client/src/test/bb_prover_full_rollup.test.ts index 5b6791a1e58..266bf7fd4e9 100644 --- a/yarn-project/prover-client/src/test/bb_prover_full_rollup.test.ts +++ b/yarn-project/prover-client/src/test/bb_prover_full_rollup.test.ts @@ -1,9 +1,10 @@ import { BBNativeRollupProver, type BBProverConfig } from '@aztec/bb-prover'; import { PROVING_STATUS, mockTx } from '@aztec/circuit-types'; -import { Fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, getMockVerificationKeys } from '@aztec/circuits.js'; +import { Fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js'; import { makeTuple } from '@aztec/foundation/array'; import { times } from '@aztec/foundation/collection'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; import { TestContext } from '../mocks/test_context.js'; @@ -38,6 +39,7 @@ describe('prover/bb_prover/full-rollup', () => { numberOfRevertiblePublicCallRequests: 0, }); tx.data.constants.historicalHeader = initialHeader; + tx.data.constants.vkTreeRoot = getVKTreeRoot(); return tx; }); @@ -47,12 +49,7 @@ describe('prover/bb_prover/full-rollup', () => { ); logger.info(`Starting new block`); - const provingTicket = await context.orchestrator.startNewBlock( - totalTxs, - context.globalVariables, - l1ToL2Messages, - getMockVerificationKeys(), - ); + const provingTicket = await context.orchestrator.startNewBlock(totalTxs, context.globalVariables, l1ToL2Messages); logger.info(`Processing public functions`); const [processed, failed] = await context.processPublicFunctions(txs, nonEmptyTxs, context.blockProver); @@ -94,7 +91,6 @@ describe('prover/bb_prover/full-rollup', () => { numTransactions, context.globalVariables, l1ToL2Messages, - getMockVerificationKeys(), ); const [processed, failed] = await context.processPublicFunctions(txs, numTransactions, context.blockProver); diff --git a/yarn-project/prover-client/src/test/bb_prover_parity.test.ts b/yarn-project/prover-client/src/test/bb_prover_parity.test.ts index b43f1c8aafd..9272d74a78b 100644 --- a/yarn-project/prover-client/src/test/bb_prover_parity.test.ts +++ b/yarn-project/prover-client/src/test/bb_prover_parity.test.ts @@ -15,6 +15,7 @@ import { makeTuple } from '@aztec/foundation/array'; import { randomBytes } from '@aztec/foundation/crypto'; import { createDebugLogger } from '@aztec/foundation/log'; import { type Tuple } from '@aztec/foundation/serialize'; +import { ProtocolCircuitVkIndexes, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; import { TestContext } from '../mocks/test_context.js'; @@ -44,7 +45,7 @@ describe('prover/bb_prover/parity', () => { Fr.random, ); const baseParityInputs = Array.from({ length: NUM_BASE_PARITY_PER_ROOT_PARITY }, (_, i) => - BaseParityInputs.fromSlice(l1ToL2Messages, i), + BaseParityInputs.fromSlice(l1ToL2Messages, i, getVKTreeRoot()), ); // Generate the base parity proofs @@ -73,12 +74,14 @@ describe('prover/bb_prover/parity', () => { // In each case either the proof should fail to generate or verify const validVk = rootParityInputs.children[0].verificationKey; + const baseParityVkPath = getVKSiblingPath(ProtocolCircuitVkIndexes.BaseParityArtifact); const validPublicInputs = rootParityInputs.children[0].publicInputs; const validProof = rootParityInputs.children[0].proof; const defectiveProofInput = new RootParityInput( makeRecursiveProof(RECURSIVE_PROOF_LENGTH, 0x500), validVk, + baseParityVkPath, validPublicInputs, ); @@ -88,12 +91,14 @@ describe('prover/bb_prover/parity', () => { const defectivePublicInputs = new RootParityInput( validProof, validVk, - new ParityPublicInputs(Fr.fromBuffer(shaRoot), Fr.random()), + baseParityVkPath, + new ParityPublicInputs(Fr.fromBuffer(shaRoot), Fr.random(), getVKTreeRoot()), ); const defectiveVerificationKey = new RootParityInput( validProof, VerificationKeyAsFields.makeFake(), + baseParityVkPath, validPublicInputs, ); diff --git a/yarn-project/prover-client/src/tx-prover/tx-prover.ts b/yarn-project/prover-client/src/tx-prover/tx-prover.ts index 09392412912..41cda4da56f 100644 --- a/yarn-project/prover-client/src/tx-prover/tx-prover.ts +++ b/yarn-project/prover-client/src/tx-prover/tx-prover.ts @@ -7,7 +7,7 @@ import { type ProvingTicket, type ServerCircuitProver, } from '@aztec/circuit-types/interfaces'; -import { type Fr, type GlobalVariables, type Header, type VerificationKeys } from '@aztec/circuits.js'; +import { type Fr, type GlobalVariables, type Header } from '@aztec/circuits.js'; import { NativeACVMSimulator } from '@aztec/simulator'; import { type TelemetryClient } from '@aztec/telemetry-client'; import { type WorldStateSynchronizer } from '@aztec/world-state'; @@ -28,7 +28,6 @@ export class TxProver implements ProverClient { private constructor( private config: ProverClientConfig, private worldStateSynchronizer: WorldStateSynchronizer, - private vks: VerificationKeys, private telemetry: TelemetryClient, private agent?: ProverAgent, initialHeader?: Header, @@ -42,13 +41,9 @@ export class TxProver implements ProverClient { ); } - async updateProverConfig(config: Partial): Promise { + async updateProverConfig(config: Partial): Promise { const newConfig = { ...this.config, ...config }; - if (config.vks) { - this.vks = config.vks; - } - if (newConfig.realProofs !== this.config.realProofs && this.agent) { const circuitProver = await TxProver.buildCircuitProver(newConfig, this.telemetry); this.agent.setCircuitProver(circuitProver); @@ -100,7 +95,6 @@ export class TxProver implements ProverClient { */ public static async new( config: ProverClientConfig, - vks: VerificationKeys, worldStateSynchronizer: WorldStateSynchronizer, telemetry: TelemetryClient, initialHeader?: Header, @@ -113,7 +107,7 @@ export class TxProver implements ProverClient { ) : undefined; - const prover = new TxProver(config, worldStateSynchronizer, vks, telemetry, agent, initialHeader); + const prover = new TxProver(config, worldStateSynchronizer, telemetry, agent, initialHeader); await prover.start(); return prover; } @@ -146,7 +140,7 @@ export class TxProver implements ProverClient { ): Promise { const previousBlockNumber = globalVariables.blockNumber.toNumber() - 1; await this.worldStateSynchronizer.syncImmediate(previousBlockNumber); - return this.orchestrator.startNewBlock(numTxs, globalVariables, newL1ToL2Messages, this.vks); + return this.orchestrator.startNewBlock(numTxs, globalVariables, newL1ToL2Messages); } /** diff --git a/yarn-project/pxe/src/contract_data_oracle/index.ts b/yarn-project/pxe/src/contract_data_oracle/index.ts index 5b8d6fe9f5c..ed2217589f7 100644 --- a/yarn-project/pxe/src/contract_data_oracle/index.ts +++ b/yarn-project/pxe/src/contract_data_oracle/index.ts @@ -1,4 +1,4 @@ -import { type AztecAddress, MembershipWitness, VK_TREE_HEIGHT } from '@aztec/circuits.js'; +import { type AztecAddress } from '@aztec/circuits.js'; import { type ContractArtifact, type FunctionArtifact, @@ -131,20 +131,6 @@ export class ContractDataOracle { return tree.getFunctionMembershipWitness(selector); } - /** - * Retrieve the membership witness corresponding to a verification key. - * This function currently returns a random membership witness of the specified height, - * which is a placeholder implementation until a concrete membership witness calculation - * is implemented. - * - * @param vk - The VerificationKey for which the membership witness is needed. - * @returns A Promise that resolves to the MembershipWitness instance. - */ - public async getVkMembershipWitness() { - // TODO - return await Promise.resolve(MembershipWitness.random(VK_TREE_HEIGHT)); - } - public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) { const tree = await this.getTreeForAddress(contractAddress); const { name: contractName } = tree.getArtifact(); diff --git a/yarn-project/pxe/src/kernel_oracle/index.ts b/yarn-project/pxe/src/kernel_oracle/index.ts index 4d8e99567c5..c7f55240771 100644 --- a/yarn-project/pxe/src/kernel_oracle/index.ts +++ b/yarn-project/pxe/src/kernel_oracle/index.ts @@ -7,12 +7,15 @@ import { MembershipWitness, type NOTE_HASH_TREE_HEIGHT, type Point, + VK_TREE_HEIGHT, + type VerificationKeyAsFields, computeContractClassIdPreimage, computeSaltedInitializationHash, } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { type Tuple } from '@aztec/foundation/serialize'; import { type KeyStore } from '@aztec/key-store'; +import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types'; import { type ContractDataOracle } from '../contract_data_oracle/index.js'; import { type ProvingDataOracle } from './../kernel_prover/proving_data_oracle.js'; @@ -47,8 +50,9 @@ export class KernelOracle implements ProvingDataOracle { return await this.contractDataOracle.getFunctionMembershipWitness(contractAddress, selector); } - public async getVkMembershipWitness() { - return await this.contractDataOracle.getVkMembershipWitness(); + public getVkMembershipWitness(vk: VerificationKeyAsFields) { + const leafIndex = getVKIndex(vk); + return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex))); } async getNoteHashMembershipWitness(leafIndex: bigint): Promise> { diff --git a/yarn-project/pxe/src/kernel_prover/kernel_prover.ts b/yarn-project/pxe/src/kernel_prover/kernel_prover.ts index e1799cb653f..5a219fce08a 100644 --- a/yarn-project/pxe/src/kernel_prover/kernel_prover.ts +++ b/yarn-project/pxe/src/kernel_prover/kernel_prover.ts @@ -29,6 +29,7 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; import { assertLength } from '@aztec/foundation/serialize'; import { pushTestData } from '@aztec/foundation/testing'; +import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { type ExecutionResult, collectNoteHashLeafIndexMap, collectNullifiedNoteHashCounters } from '@aztec/simulator'; import { buildPrivateKernelResetInputs } from './private_inputs_builders/index.js'; @@ -103,7 +104,7 @@ export class KernelProver { ); if (firstIteration) { - const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, privateCallData); + const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, getVKTreeRoot(), privateCallData); pushTestData('private-kernel-inputs-init', proofInput); output = await this.proofCreator.createProofInit(proofInput); } else { diff --git a/yarn-project/pxe/src/kernel_prover/test/test_circuit_prover.ts b/yarn-project/pxe/src/kernel_prover/test/test_circuit_prover.ts index b08dcdaeaac..b9bf1ae03e5 100644 --- a/yarn-project/pxe/src/kernel_prover/test/test_circuit_prover.ts +++ b/yarn-project/pxe/src/kernel_prover/test/test_circuit_prover.ts @@ -17,6 +17,8 @@ import { siloNoteHash } from '@aztec/circuits.js/hash'; import { createDebugLogger } from '@aztec/foundation/log'; import { elapsed } from '@aztec/foundation/timer'; import { + type ProtocolArtifact, + ProtocolCircuitVks, executeInit, executeInner, executeReset, @@ -47,7 +49,7 @@ export class TestProofCreator implements ProofCreator { inputSize: privateInputs.toBuffer().length, outputSize: result.toBuffer().length, } satisfies CircuitSimulationStats); - return this.makeEmptyKernelProofOutput(result); + return this.makeEmptyKernelProofOutput(result, 'PrivateKernelInitArtifact'); } public async createProofInner( @@ -61,7 +63,7 @@ export class TestProofCreator implements ProofCreator { inputSize: privateInputs.toBuffer().length, outputSize: result.toBuffer().length, } satisfies CircuitSimulationStats); - return this.makeEmptyKernelProofOutput(result); + return this.makeEmptyKernelProofOutput(result, 'PrivateKernelInnerArtifact'); } public async createProofReset( @@ -75,7 +77,7 @@ export class TestProofCreator implements ProofCreator { inputSize: privateInputs.toBuffer().length, outputSize: result.toBuffer().length, } satisfies CircuitSimulationStats); - return this.makeEmptyKernelProofOutput(result); + return this.makeEmptyKernelProofOutput(result, 'PrivateKernelResetFullArtifact'); } public async createProofTail( @@ -92,7 +94,10 @@ export class TestProofCreator implements ProofCreator { inputSize: privateInputs.toBuffer().length, outputSize: result.toBuffer().length, } satisfies CircuitSimulationStats); - return this.makeEmptyKernelProofOutput(result); + return this.makeEmptyKernelProofOutput( + result, + isForPublic ? 'PrivateKernelTailToPublicArtifact' : 'PrivateKernelTailArtifact', + ); } createAppCircuitProof(_1: Map, _2: Buffer): Promise { @@ -103,11 +108,11 @@ export class TestProofCreator implements ProofCreator { return Promise.resolve(appCircuitProofOutput); } - private makeEmptyKernelProofOutput(publicInputs: PublicInputsType) { + private makeEmptyKernelProofOutput(publicInputs: PublicInputsType, circuitType: ProtocolArtifact) { const kernelProofOutput: KernelProofOutput = { publicInputs, proof: makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH), - verificationKey: VerificationKeyAsFields.makeEmpty(), + verificationKey: ProtocolCircuitVks[circuitType].keyAsFields, }; return kernelProofOutput; } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index 8fc0be58c6d..2e301e40e3d 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -59,7 +59,13 @@ describe('L1Publisher', () => { const result = await publisher.processL2Block(l2Block, [], makeEmptyProof()); expect(result).toEqual(true); - expect(txSender.sendProcessTx).toHaveBeenCalledWith({ header, archive, body, aggregationObject, proof }); + expect(txSender.sendProcessTx).toHaveBeenCalledWith({ + header, + archive, + body, + aggregationObject, + proof, + }); expect(txSender.getTransactionReceipt).toHaveBeenCalledWith(processTxHash); }); diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index 824cd1def7a..a761bb4df8f 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -6,7 +6,7 @@ import { computeUniqueNoteHash, siloNoteHash, } from '@aztec/circuits.js/hash'; -import { ABIParameterVisibility, type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi'; +import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { poseidon2Hash } from '@aztec/foundation/crypto'; import { Fr, type Point } from '@aztec/foundation/fields'; @@ -129,7 +129,7 @@ describe('Simulator', () => { kind: 'field', }, }, - visibility: ABIParameterVisibility.SECRET, + visibility: 'private', }, ], }; diff --git a/yarn-project/simulator/src/public/abstract_phase_manager.ts b/yarn-project/simulator/src/public/abstract_phase_manager.ts index 3a056339b67..3428158116c 100644 --- a/yarn-project/simulator/src/public/abstract_phase_manager.ts +++ b/yarn-project/simulator/src/public/abstract_phase_manager.ts @@ -35,7 +35,6 @@ import { MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_UNENCRYPTED_LOGS_PER_CALL, - MembershipWitness, NESTED_RECURSIVE_PROOF_LENGTH, NoteHash, Nullifier, @@ -48,14 +47,19 @@ import { PublicKernelData, ReadRequest, RevertCode, - VK_TREE_HEIGHT, - VerificationKeyData, makeEmptyProof, makeEmptyRecursiveProof, } from '@aztec/circuits.js'; import { computeVarArgsHash } from '@aztec/circuits.js/hash'; import { padArrayEnd } from '@aztec/foundation/collection'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; +import { + type ProtocolArtifact, + ProtocolCircuitVkIndexes, + ProtocolCircuitVks, + getVKIndex, + getVKSiblingPath, +} from '@aztec/noir-protocol-circuits-types'; import { type PublicExecutionRequest, type PublicExecutionResult, @@ -106,6 +110,8 @@ export type TxPublicCallsResult = { publicProvingInformation: PublicProvingInformation[]; /** The public kernel output at the end of the Tx */ kernelOutput: PublicKernelCircuitPublicInputs; + /** The last circuit ran by this phase */ + lastKernelArtifact: ProtocolArtifact; /** Unencrypted logs generated during the execution of this Tx */ newUnencryptedLogs: UnencryptedFunctionL2Logs[]; /** Revert reason, if any */ @@ -121,6 +127,8 @@ export type PhaseResult = { publicProvingRequests: PublicProvingRequest[]; /** The output of the public kernel circuit simulation for this phase */ publicKernelOutput: PublicKernelCircuitPublicInputs; + /** The last circuit ran by this phase */ + lastKernelArtifact: ProtocolArtifact; /** The final output of the public kernel circuit for this phase */ finalKernelOutput?: KernelCircuitPublicInputs; /** Revert reason, if any */ @@ -150,7 +158,11 @@ export abstract class AbstractPhaseManager { * @param tx - the tx to be processed * @param publicKernelPublicInputs - the output of the public kernel circuit for the previous phase */ - abstract handle(tx: Tx, publicKernelPublicInputs: PublicKernelCircuitPublicInputs): Promise; + abstract handle( + tx: Tx, + publicKernelPublicInputs: PublicKernelCircuitPublicInputs, + previousKernelArtifact: ProtocolArtifact, + ): Promise; public static extractEnqueuedPublicCallsByPhase(tx: Tx): Record { const data = tx.data.forPublic; @@ -230,6 +242,7 @@ export abstract class AbstractPhaseManager { protected async processEnqueuedPublicCalls( tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs, + previousKernelArtifact: ProtocolArtifact, ): Promise { const enqueuedCalls = this.extractEnqueuedPublicCalls(tx); @@ -237,6 +250,7 @@ export abstract class AbstractPhaseManager { return { publicProvingInformation: [], kernelOutput: previousPublicKernelOutput, + lastKernelArtifact: previousKernelArtifact, newUnencryptedLogs: [], returnValues: [], gasUsed: Gas.empty(), @@ -253,6 +267,7 @@ export abstract class AbstractPhaseManager { const transactionFee = this.getTransactionFee(tx, previousPublicKernelOutput); let gasUsed = Gas.empty(); let kernelPublicOutput: PublicKernelCircuitPublicInputs = previousPublicKernelOutput; + const enqueuedCallResults = []; for (const enqueuedCall of enqueuedCalls) { @@ -313,8 +328,13 @@ export abstract class AbstractPhaseManager { })`, ); const callData = await this.getPublicCallData(result, isExecutionRequest); - const [privateInputs, publicInputs] = await this.runKernelCircuit(kernelPublicOutput, callData); + const [privateInputs, publicInputs, artifact] = await this.runKernelCircuit( + kernelPublicOutput, + previousKernelArtifact, + callData, + ); kernelPublicOutput = publicInputs; + previousKernelArtifact = artifact; // Capture the inputs for later proving in the AVM and kernel. const publicProvingInformation: PublicProvingInformation = { @@ -349,6 +369,7 @@ export abstract class AbstractPhaseManager { return { publicProvingInformation: [], kernelOutput: kernelPublicOutput, + lastKernelArtifact: previousKernelArtifact, newUnencryptedLogs: [], revertReason: result.revertReason, returnValues: [], @@ -367,6 +388,7 @@ export abstract class AbstractPhaseManager { return { publicProvingInformation: provingInformationList, kernelOutput: kernelPublicOutput, + lastKernelArtifact: previousKernelArtifact, newUnencryptedLogs: newUnencryptedFunctionLogs, returnValues: enqueuedCallResults, gasUsed, @@ -391,31 +413,46 @@ export abstract class AbstractPhaseManager { private async runKernelCircuit( previousOutput: PublicKernelCircuitPublicInputs, + previousCircuit: ProtocolArtifact, callData: PublicCallData, - ): Promise<[PublicKernelCircuitPrivateInputs, PublicKernelCircuitPublicInputs]> { - const previousKernel = this.getPreviousKernelData(previousOutput); + ): Promise<[PublicKernelCircuitPrivateInputs, PublicKernelCircuitPublicInputs, ProtocolArtifact]> { + const previousKernel = this.getPreviousKernelData(previousOutput, previousCircuit); // We take a deep copy (clone) of these inputs to be passed to the prover const inputs = new PublicKernelCircuitPrivateInputs(previousKernel, callData); switch (this.phase) { case PublicKernelType.SETUP: - return [inputs.clone(), await this.publicKernel.publicKernelCircuitSetup(inputs)]; + return [inputs.clone(), await this.publicKernel.publicKernelCircuitSetup(inputs), 'PublicKernelSetupArtifact']; case PublicKernelType.APP_LOGIC: - return [inputs.clone(), await this.publicKernel.publicKernelCircuitAppLogic(inputs)]; + return [ + inputs.clone(), + await this.publicKernel.publicKernelCircuitAppLogic(inputs), + 'PublicKernelAppLogicArtifact', + ]; case PublicKernelType.TEARDOWN: - return [inputs.clone(), await this.publicKernel.publicKernelCircuitTeardown(inputs)]; + return [ + inputs.clone(), + await this.publicKernel.publicKernelCircuitTeardown(inputs), + 'PublicKernelTeardownArtifact', + ]; default: throw new Error(`No public kernel circuit for inputs`); } } - protected getPreviousKernelData(previousOutput: PublicKernelCircuitPublicInputs): PublicKernelData { - // The proof and verification key are not used in simulation - const vk = VerificationKeyData.makeFake(); + protected getPreviousKernelData( + previousOutput: PublicKernelCircuitPublicInputs, + previousCircuit: ProtocolArtifact, + ): PublicKernelData { + // The proof is not used in simulation const proof = makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH); - const vkIndex = 0; - const vkSiblingPath = MembershipWitness.random(VK_TREE_HEIGHT).siblingPath; - return new PublicKernelData(previousOutput, proof, vk, vkIndex, vkSiblingPath); + + const vk = ProtocolCircuitVks[previousCircuit]; + const vkIndex = ProtocolCircuitVkIndexes[previousCircuit]; + + const leafIndex = getVKIndex(vk); + + return new PublicKernelData(previousOutput, proof, vk, vkIndex, getVKSiblingPath(leafIndex)); } protected async getPublicCallStackItem(result: PublicExecutionResult, isExecutionRequest = false) { diff --git a/yarn-project/simulator/src/public/app_logic_phase_manager.ts b/yarn-project/simulator/src/public/app_logic_phase_manager.ts index de2628b6bea..9809e4cb226 100644 --- a/yarn-project/simulator/src/public/app_logic_phase_manager.ts +++ b/yarn-project/simulator/src/public/app_logic_phase_manager.ts @@ -1,5 +1,6 @@ import { PublicKernelType, type PublicProvingRequest, type Tx } from '@aztec/circuit-types'; import { type GlobalVariables, type Header, type PublicKernelCircuitPublicInputs } from '@aztec/circuits.js'; +import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types'; import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator'; import { type MerkleTreeOperations } from '@aztec/world-state'; @@ -24,7 +25,11 @@ export class AppLogicPhaseManager extends AbstractPhaseManager { super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase); } - override async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs) { + override async handle( + tx: Tx, + previousPublicKernelOutput: PublicKernelCircuitPublicInputs, + previousCircuit: ProtocolArtifact, + ) { this.log.verbose(`Processing tx ${tx.getTxHash()}`); // add new contracts to the contracts db so that their functions may be found and called // TODO(#4073): This is catching only private deployments, when we add public ones, we'll @@ -33,14 +38,21 @@ export class AppLogicPhaseManager extends AbstractPhaseManager { // TODO(#6464): Should we allow emitting contracts in the private setup phase? // if so, this should only add contracts that were deployed during private app logic. await this.publicContractsDB.addNewContracts(tx); - const { publicProvingInformation, kernelOutput, newUnencryptedLogs, revertReason, returnValues, gasUsed } = - await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput).catch( - // if we throw for any reason other than simulation, we need to rollback and drop the TX - async err => { - await this.publicStateDB.rollbackToCommit(); - throw err; - }, - ); + const { + publicProvingInformation, + kernelOutput, + lastKernelArtifact, + newUnencryptedLogs, + revertReason, + returnValues, + gasUsed, + } = await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput, previousCircuit).catch( + // if we throw for any reason other than simulation, we need to rollback and drop the TX + async err => { + await this.publicStateDB.rollbackToCommit(); + throw err; + }, + ); if (revertReason) { // TODO(#6464): Should we allow emitting contracts in the private setup phase? @@ -57,6 +69,13 @@ export class AppLogicPhaseManager extends AbstractPhaseManager { const publicProvingRequests: PublicProvingRequest[] = publicProvingInformation.map(info => { return makeAvmProvingRequest(info, PublicKernelType.APP_LOGIC); }); - return { publicProvingRequests, publicKernelOutput: kernelOutput, revertReason, returnValues, gasUsed }; + return { + publicProvingRequests, + publicKernelOutput: kernelOutput, + lastKernelArtifact, + revertReason, + returnValues, + gasUsed, + }; } } diff --git a/yarn-project/simulator/src/public/public_kernel.ts b/yarn-project/simulator/src/public/public_kernel.ts index 6910123b54e..e7490c85ada 100644 --- a/yarn-project/simulator/src/public/public_kernel.ts +++ b/yarn-project/simulator/src/public/public_kernel.ts @@ -8,10 +8,7 @@ import { import { createDebugLogger } from '@aztec/foundation/log'; import { elapsed } from '@aztec/foundation/timer'; import { - SimulatedPublicKernelAppLogicArtifact, - SimulatedPublicKernelSetupArtifact, - SimulatedPublicKernelTailArtifact, - SimulatedPublicKernelTeardownArtifact, + SimulatedServerCircuitArtifacts, convertSimulatedPublicInnerInputsToWitnessMap, convertSimulatedPublicInnerOutputFromWitnessMap, convertSimulatedPublicSetupInputsToWitnessMap, @@ -50,7 +47,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu } const inputWitness = convertSimulatedPublicSetupInputsToWitnessMap(input); const [duration, witness] = await elapsed(() => - this.wasmSimulator.simulateCircuit(inputWitness, SimulatedPublicKernelSetupArtifact), + this.wasmSimulator.simulateCircuit(inputWitness, SimulatedServerCircuitArtifacts.PublicKernelSetupArtifact), ); const result = convertSimulatedPublicSetupOutputFromWitnessMap(witness); this.log.debug(`Simulated public kernel setup circuit`, { @@ -76,7 +73,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu } const inputWitness = convertSimulatedPublicInnerInputsToWitnessMap(input); const [duration, witness] = await elapsed(() => - this.wasmSimulator.simulateCircuit(inputWitness, SimulatedPublicKernelAppLogicArtifact), + this.wasmSimulator.simulateCircuit(inputWitness, SimulatedServerCircuitArtifacts.PublicKernelAppLogicArtifact), ); const result = convertSimulatedPublicInnerOutputFromWitnessMap(witness); this.log.debug(`Simulated public kernel app logic circuit`, { @@ -102,7 +99,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu } const inputWitness = convertSimulatedPublicTeardownInputsToWitnessMap(input); const [duration, witness] = await elapsed(() => - this.wasmSimulator.simulateCircuit(inputWitness, SimulatedPublicKernelTeardownArtifact), + this.wasmSimulator.simulateCircuit(inputWitness, SimulatedServerCircuitArtifacts.PublicKernelTeardownArtifact), ); const result = convertSimulatedPublicTeardownOutputFromWitnessMap(witness); this.log.debug(`Simulated public kernel teardown circuit`, { @@ -125,7 +122,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu ): Promise { const inputWitness = convertSimulatedPublicTailInputsToWitnessMap(input); const [duration, witness] = await elapsed(() => - this.wasmSimulator.simulateCircuit(inputWitness, SimulatedPublicKernelTailArtifact), + this.wasmSimulator.simulateCircuit(inputWitness, SimulatedServerCircuitArtifacts.PublicKernelTailArtifact), ); const result = convertSimulatedPublicTailOutputFromWitnessMap(witness); this.log.debug(`Simulated public kernel tail circuit`, { diff --git a/yarn-project/simulator/src/public/public_processor.ts b/yarn-project/simulator/src/public/public_processor.ts index fa15414db15..86b9ed3ad27 100644 --- a/yarn-project/simulator/src/public/public_processor.ts +++ b/yarn-project/simulator/src/public/public_processor.ts @@ -23,6 +23,7 @@ import { } from '@aztec/circuits.js'; import { times } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; +import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types'; import { PublicExecutor, type PublicStateDB, @@ -232,17 +233,19 @@ export class PublicProcessor { ); this.log.debug(`Beginning processing in phase ${phase?.phase} for tx ${tx.getTxHash()}`); let publicKernelPublicInput = tx.data.toPublicKernelCircuitPublicInputs(); + let lastKernelArtifact: ProtocolArtifact = 'PrivateKernelTailToPublicArtifact'; // All txs with public calls must carry tail to public proofs let finalKernelOutput: KernelCircuitPublicInputs | undefined; let revertReason: SimulationError | undefined; const gasUsed: ProcessedTx['gasUsed'] = {}; while (phase) { - const output = await phase.handle(tx, publicKernelPublicInput); + const output = await phase.handle(tx, publicKernelPublicInput, lastKernelArtifact); gasUsed[phase.phase] = output.gasUsed; if (phase.phase === PublicKernelType.APP_LOGIC) { returnValues = output.returnValues; } publicProvingRequests.push(...output.publicProvingRequests); publicKernelPublicInput = output.publicKernelOutput; + lastKernelArtifact = output.lastKernelArtifact; finalKernelOutput = output.finalKernelOutput; revertReason ??= output.revertReason; phase = PhaseManagerFactory.phaseFromOutput( diff --git a/yarn-project/simulator/src/public/setup_phase_manager.ts b/yarn-project/simulator/src/public/setup_phase_manager.ts index ee75f637ac7..2e40f0ffeb0 100644 --- a/yarn-project/simulator/src/public/setup_phase_manager.ts +++ b/yarn-project/simulator/src/public/setup_phase_manager.ts @@ -1,5 +1,6 @@ import { PublicKernelType, type PublicProvingRequest, type Tx } from '@aztec/circuit-types'; import { type GlobalVariables, type Header, type PublicKernelCircuitPublicInputs } from '@aztec/circuits.js'; +import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types'; import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator'; import { type MerkleTreeOperations } from '@aztec/world-state'; @@ -24,13 +25,17 @@ export class SetupPhaseManager extends AbstractPhaseManager { super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase); } - override async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs) { + override async handle( + tx: Tx, + previousPublicKernelOutput: PublicKernelCircuitPublicInputs, + previousCircuit: ProtocolArtifact, + ) { this.log.verbose(`Processing tx ${tx.getTxHash()}`); // TODO(#6464): Should we allow emitting contracts in the private setup phase? // if so, this should only add contracts that were deployed during private app logic. await this.publicContractsDB.addNewContracts(tx); - const { publicProvingInformation, kernelOutput, newUnencryptedLogs, revertReason, gasUsed } = - await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput).catch( + const { publicProvingInformation, kernelOutput, lastKernelArtifact, newUnencryptedLogs, revertReason, gasUsed } = + await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput, previousCircuit).catch( // the abstract phase manager throws if simulation gives error in a non-revertible phase async err => { await this.publicStateDB.rollbackToCommit(); @@ -44,6 +49,13 @@ export class SetupPhaseManager extends AbstractPhaseManager { const publicProvingRequests: PublicProvingRequest[] = publicProvingInformation.map(info => { return makeAvmProvingRequest(info, PublicKernelType.SETUP); }); - return { publicProvingRequests, publicKernelOutput: kernelOutput, revertReason, returnValues: [], gasUsed }; + return { + publicProvingRequests, + publicKernelOutput: kernelOutput, + lastKernelArtifact, + revertReason, + returnValues: [], + gasUsed, + }; } } diff --git a/yarn-project/simulator/src/public/tail_phase_manager.ts b/yarn-project/simulator/src/public/tail_phase_manager.ts index 940c6621870..d33b0826c88 100644 --- a/yarn-project/simulator/src/public/tail_phase_manager.ts +++ b/yarn-project/simulator/src/public/tail_phase_manager.ts @@ -10,6 +10,7 @@ import { PublicKernelTailCircuitPrivateInputs, mergeAccumulatedData, } from '@aztec/circuits.js'; +import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types'; import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator'; import { type MerkleTreeOperations } from '@aztec/world-state'; @@ -31,9 +32,13 @@ export class TailPhaseManager extends AbstractPhaseManager { super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase); } - override async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs) { + override async handle( + tx: Tx, + previousPublicKernelOutput: PublicKernelCircuitPublicInputs, + previousKernelArtifact: ProtocolArtifact, + ) { this.log.verbose(`Processing tx ${tx.getTxHash()}`); - const [inputs, finalKernelOutput] = await this.simulate(previousPublicKernelOutput).catch( + const [inputs, finalKernelOutput] = await this.simulate(previousPublicKernelOutput, previousKernelArtifact).catch( // the abstract phase manager throws if simulation gives error in non-revertible phase async err => { await this.publicStateDB.rollbackToCommit(); @@ -50,6 +55,7 @@ export class TailPhaseManager extends AbstractPhaseManager { return { publicProvingRequests: [kernelRequest], publicKernelOutput: previousPublicKernelOutput, + lastKernelArtifact: 'PublicKernelTailArtifact' as ProtocolArtifact, finalKernelOutput, returnValues: [], }; @@ -57,14 +63,18 @@ export class TailPhaseManager extends AbstractPhaseManager { private async simulate( previousOutput: PublicKernelCircuitPublicInputs, + previousKernelArtifact: ProtocolArtifact, ): Promise<[PublicKernelTailCircuitPrivateInputs, KernelCircuitPublicInputs]> { - const inputs = await this.buildPrivateInputs(previousOutput); + const inputs = await this.buildPrivateInputs(previousOutput, previousKernelArtifact); // We take a deep copy (clone) of these to pass to the prover return [inputs.clone(), await this.publicKernel.publicKernelCircuitTail(inputs)]; } - private async buildPrivateInputs(previousOutput: PublicKernelCircuitPublicInputs) { - const previousKernel = this.getPreviousKernelData(previousOutput); + private async buildPrivateInputs( + previousOutput: PublicKernelCircuitPublicInputs, + previousKernelArtifact: ProtocolArtifact, + ) { + const previousKernel = this.getPreviousKernelData(previousOutput, previousKernelArtifact); const { validationRequests, endNonRevertibleData: nonRevertibleData, end: revertibleData } = previousOutput; diff --git a/yarn-project/simulator/src/public/teardown_phase_manager.ts b/yarn-project/simulator/src/public/teardown_phase_manager.ts index 14eb475746a..03401e33dbb 100644 --- a/yarn-project/simulator/src/public/teardown_phase_manager.ts +++ b/yarn-project/simulator/src/public/teardown_phase_manager.ts @@ -6,6 +6,7 @@ import { type Header, type PublicKernelCircuitPublicInputs, } from '@aztec/circuits.js'; +import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types'; import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator'; import { type MerkleTreeOperations } from '@aztec/world-state'; @@ -32,10 +33,14 @@ export class TeardownPhaseManager extends AbstractPhaseManager { super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase); } - override async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs) { + override async handle( + tx: Tx, + previousPublicKernelOutput: PublicKernelCircuitPublicInputs, + previousKernelArtifact: ProtocolArtifact, + ) { this.log.verbose(`Processing tx ${tx.getTxHash()}`); - const { publicProvingInformation, kernelOutput, newUnencryptedLogs, revertReason, gasUsed } = - await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput).catch( + const { publicProvingInformation, kernelOutput, lastKernelArtifact, newUnencryptedLogs, revertReason, gasUsed } = + await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput, previousKernelArtifact).catch( // the abstract phase manager throws if simulation gives error in a non-revertible phase async err => { await this.publicStateDB.rollbackToCommit(); @@ -55,7 +60,14 @@ export class TeardownPhaseManager extends AbstractPhaseManager { const publicProvingRequests: PublicProvingRequest[] = publicProvingInformation.map(info => { return makeAvmProvingRequest(info, PublicKernelType.TEARDOWN); }); - return { publicProvingRequests, publicKernelOutput: kernelOutput, revertReason, returnValues: [], gasUsed }; + return { + publicProvingRequests, + publicKernelOutput: kernelOutput, + lastKernelArtifact, + revertReason, + returnValues: [], + gasUsed, + }; } protected override getTransactionFee(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs): Fr { diff --git a/yarn-project/simulator/src/rollup/rollup.ts b/yarn-project/simulator/src/rollup/rollup.ts index 58c72653d8f..4c9511c218b 100644 --- a/yarn-project/simulator/src/rollup/rollup.ts +++ b/yarn-project/simulator/src/rollup/rollup.ts @@ -12,11 +12,7 @@ import { import { createDebugLogger } from '@aztec/foundation/log'; import { elapsed } from '@aztec/foundation/timer'; import { - BaseParityArtifact, - MergeRollupArtifact, - RootParityArtifact, - RootRollupArtifact, - SimulatedBaseRollupArtifact, + SimulatedServerCircuitArtifacts, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, @@ -87,7 +83,10 @@ export class RealRollupCircuitSimulator implements RollupSimulator { public async baseParityCircuit(inputs: BaseParityInputs): Promise { const witnessMap = convertBaseParityInputsToWitnessMap(inputs); - const witness = await this.simulationProvider.simulateCircuit(witnessMap, BaseParityArtifact); + const witness = await this.simulationProvider.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.BaseParityArtifact, + ); const result = convertBaseParityOutputsFromWitnessMap(witness); @@ -102,7 +101,10 @@ export class RealRollupCircuitSimulator implements RollupSimulator { public async rootParityCircuit(inputs: RootParityInputs): Promise { const witnessMap = convertRootParityInputsToWitnessMap(inputs); - const witness = await this.simulationProvider.simulateCircuit(witnessMap, RootParityArtifact); + const witness = await this.simulationProvider.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.RootParityArtifact, + ); const result = convertRootParityOutputsFromWitnessMap(witness); @@ -117,7 +119,10 @@ export class RealRollupCircuitSimulator implements RollupSimulator { public async baseRollupCircuit(input: BaseRollupInputs): Promise { const witnessMap = convertSimulatedBaseRollupInputsToWitnessMap(input); - const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedBaseRollupArtifact); + const witness = await this.simulationProvider.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.BaseRollupArtifact, + ); const result = convertSimulatedBaseRollupOutputsFromWitnessMap(witness); @@ -131,7 +136,10 @@ export class RealRollupCircuitSimulator implements RollupSimulator { public async mergeRollupCircuit(input: MergeRollupInputs): Promise { const witnessMap = convertMergeRollupInputsToWitnessMap(input); - const witness = await this.wasmSimulator.simulateCircuit(witnessMap, MergeRollupArtifact); + const witness = await this.wasmSimulator.simulateCircuit( + witnessMap, + SimulatedServerCircuitArtifacts.MergeRollupArtifact, + ); const result = convertMergeRollupOutputsFromWitnessMap(witness); @@ -146,7 +154,9 @@ export class RealRollupCircuitSimulator implements RollupSimulator { public async rootRollupCircuit(input: RootRollupInputs): Promise { const witnessMap = convertRootRollupInputsToWitnessMap(input); - const [duration, witness] = await elapsed(() => this.wasmSimulator.simulateCircuit(witnessMap, RootRollupArtifact)); + const [duration, witness] = await elapsed(() => + this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.RootRollupArtifact), + ); const result = convertRootRollupOutputsFromWitnessMap(witness); diff --git a/yarn-project/types/src/noir/index.ts b/yarn-project/types/src/noir/index.ts index 41b860a3719..b56d32762a0 100644 --- a/yarn-project/types/src/noir/index.ts +++ b/yarn-project/types/src/noir/index.ts @@ -14,12 +14,21 @@ export const AZTEC_INTERNAL_ATTRIBUTE = 'aztec(internal)'; export const AZTEC_INITIALIZER_ATTRIBUTE = 'aztec(initializer)'; export const AZTEC_VIEW_ATTRIBUTE = 'aztec(view)'; +/** + * An error could be a custom error of any regular type or a formatted string error. + */ +export type AbiErrorType = + | { + error_kind: 'fmtstring'; + length: number; + item_types: AbiType[]; + } + | ({ error_kind: 'custom' } & AbiType); + /** The ABI of an Aztec.nr function. */ export interface NoirFunctionAbi { /** The parameters of the function. */ parameters: ABIParameter[]; - /** TODO */ - error_types: Record; /** The return type of the function. */ return_type: { /** @@ -31,6 +40,8 @@ export interface NoirFunctionAbi { */ visibility: ABIParameterVisibility; }; + /** Mapping of error selector => error type */ + error_types: Record; } /** diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 4d4c0a11fb8..27fee5d58f3 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -203,6 +203,7 @@ __metadata: "@aztec/kv-store": "workspace:^" "@aztec/l1-artifacts": "workspace:^" "@aztec/noir-contracts.js": "workspace:^" + "@aztec/noir-protocol-circuits-types": "workspace:^" "@aztec/p2p": "workspace:^" "@aztec/p2p-bootstrap": "workspace:^" "@aztec/protocol-contracts": "workspace:^" @@ -363,6 +364,7 @@ __metadata: "@aztec/foundation": "workspace:^" "@aztec/l1-artifacts": "workspace:^" "@aztec/noir-contracts.js": "workspace:^" + "@aztec/noir-protocol-circuits-types": "workspace:^" "@aztec/protocol-contracts": "workspace:^" "@aztec/simulator": "workspace:^" "@aztec/types": "workspace:^" @@ -420,6 +422,7 @@ __metadata: "@aztec/l1-artifacts": "workspace:^" "@aztec/merkle-tree": "workspace:^" "@aztec/noir-contracts.js": "workspace:^" + "@aztec/noir-protocol-circuits-types": "workspace:^" "@aztec/p2p": "workspace:^" "@aztec/protocol-contracts": "workspace:^" "@aztec/prover-client": "workspace:^" @@ -658,7 +661,6 @@ __metadata: resolution: "@aztec/noir-protocol-circuits-types@workspace:noir-protocol-circuits-types" dependencies: "@aztec/builder": "workspace:^" - "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/kv-store": "workspace:^"