Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add initial integration of databus #8710

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ AcirFormat circuit_serde_to_acir_format(Program::Circuit const& circuit, bool ho
}
for (const auto& [block_id, block] : block_id_to_block_constraint) {
// Note: the trace will always be empty for ReturnData since it cannot be explicitly read from in noir
if (!block.first.trace.empty() || block.first.type == BlockType::ReturnData) {
if (!block.first.trace.empty() || block.first.type == BlockType::ReturnData ||
block.first.type == BlockType::CallData) {
af.block_constraints.push_back(block.first);
af.original_opcode_indices.block_constraints.push_back(block.second);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ template <typename FF_> class MegaArith {
this->elliptic = 80000;
this->aux = 100000;
this->lookup = 200000;
this->busread = 10;
this->busread = 100;
this->poseidon2_external = 30000;
this->poseidon2_internal = 150000;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use dep::mock_types::{AppPublicInputs, MAX_COMMITMENTS_PER_CALL};

// Mock app for testing that creates the commitments the user commands.
// Note: A zero is a null commitment.
fn main(commitments_to_create: [Field; MAX_COMMITMENTS_PER_CALL]) -> pub AppPublicInputs {
fn main(commitments_to_create: [Field; MAX_COMMITMENTS_PER_CALL]) -> return_data AppPublicInputs {
let mut result = AppPublicInputs::default();
result.commitments = commitments_to_create;
result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use dep::mock_types::{AppPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_CALL};

// Mock app for testing that reads the commitments (generates read requests) the user commands.
// Note: A zero read is a null read.
fn main(commitments_to_read: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_CALL]) -> pub AppPublicInputs {
fn main(commitments_to_read: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_CALL]) -> return_data AppPublicInputs {
let mut result = AppPublicInputs::default();
result.read_requests = commitments_to_read;
result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use dep::mock_types::{TxRequest, PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, AppPublicInputs};

fn main(tx: TxRequest, app_inputs: AppPublicInputs) -> pub PrivateKernelPublicInputs {
fn main(
tx: TxRequest,
app_inputs: call_data(1) AppPublicInputs
) -> return_data PrivateKernelPublicInputs {
let mut private_kernel_inputs = PrivateKernelPublicInputsBuilder::from_tx(tx);
private_kernel_inputs.ingest_app_inputs(app_inputs);
private_kernel_inputs.finish()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use dep::mock_types::{PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, AppPublicInputs};

fn main(
prev_kernel_public_inputs: PrivateKernelPublicInputs,
app_inputs: AppPublicInputs
) -> pub PrivateKernelPublicInputs {
prev_kernel_public_inputs: call_data(0) PrivateKernelPublicInputs,
app_inputs: call_data(1) AppPublicInputs
) -> return_data PrivateKernelPublicInputs {
let mut private_kernel_inputs = PrivateKernelPublicInputsBuilder::from_previous_kernel(prev_kernel_public_inputs);
private_kernel_inputs.ingest_app_inputs(app_inputs);
private_kernel_inputs.finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use dep::mock_types::{PrivateKernelPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PE
// Mock reset kernel that reset read requests.
// It needs hints to locate the commitment that matches the read requests.
fn main(
mut prev_kernel_public_inputs: PrivateKernelPublicInputs,
mut prev_kernel_public_inputs: call_data(0) PrivateKernelPublicInputs,
commitment_read_hints: [u32; MAX_COMMITMENT_READ_REQUESTS_PER_TX]
) -> pub PrivateKernelPublicInputs {
) -> return_data PrivateKernelPublicInputs {
for i in 0..MAX_COMMITMENT_READ_REQUESTS_PER_TX {
if commitment_read_hints[i] != MAX_COMMITMENTS_PER_TX {
assert_eq(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::mock_types::{PrivateKernelPublicInputs, KernelPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_TX};

// The tail kernel finishes the client IVC chain exposing the final public inputs with no remaining calls or unfulfilled read requests.
fn main(prev_kernel_public_inputs: PrivateKernelPublicInputs) -> pub KernelPublicInputs {
fn main(prev_kernel_public_inputs: call_data(0) PrivateKernelPublicInputs) -> return_data KernelPublicInputs {
assert_eq(prev_kernel_public_inputs.remaining_calls, 0);
for i in 0..MAX_COMMITMENT_READ_REQUESTS_PER_TX {
assert_eq(prev_kernel_public_inputs.read_requests[i], 0);
Expand Down
39 changes: 18 additions & 21 deletions yarn-project/ivc-integration/src/client_ivc_integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ import path from 'path';
import { fileURLToPath } from 'url';

import {
MOCK_MAX_COMMITMENTS_PER_TX,
MockAppCreatorCircuit,
MockAppReaderCircuit,
MockPrivateKernelInitCircuit,
MockPrivateKernelInnerCircuit,
MockPrivateKernelResetCircuit,
MockPrivateKernelTailCircuit,
witnessGenCreatorAppMockCircuit,
witnessGenMockPrivateKernelInitCircuit,
witnessGenMockPrivateKernelInnerCircuit,
witnessGenMockPrivateKernelResetCircuit,
witnessGenMockPrivateKernelTailCircuit,
witnessGenReaderAppMockCircuit,
} from './index.js';

Expand Down Expand Up @@ -127,36 +122,38 @@ describe('Client IVC Integration', () => {
app_inputs: readerAppWitnessGenResult.publicInputs,
});

const resetWitnessGenResult = await witnessGenMockPrivateKernelResetCircuit({
prev_kernel_public_inputs: innerWitnessGenResult.publicInputs,
commitment_read_hints: [
'0x1', // Reader reads commitment 0x2, which is at index 1 of the created commitments
MOCK_MAX_COMMITMENTS_PER_TX.toString(), // Pad with no-ops
MOCK_MAX_COMMITMENTS_PER_TX.toString(),
MOCK_MAX_COMMITMENTS_PER_TX.toString(),
],
});
// TODO: https://github.com/AztecProtocol/barretenberg/issues/1111 - Add back reset and tail when this is fixed.

const tailWitnessGenResult = await witnessGenMockPrivateKernelTailCircuit({
prev_kernel_public_inputs: resetWitnessGenResult.publicInputs,
});
// const resetWitnessGenResult = await witnessGenMockPrivateKernelResetCircuit({
// prev_kernel_public_inputs: innerWitnessGenResult.publicInputs,
// commitment_read_hints: [
// '0x1', // Reader reads commitment 0x2, which is at index 1 of the created commitments
// MOCK_MAX_COMMITMENTS_PER_TX.toString(), // Pad with no-ops
// MOCK_MAX_COMMITMENTS_PER_TX.toString(),
// MOCK_MAX_COMMITMENTS_PER_TX.toString(),
// ],
// });

// const tailWitnessGenResult = await witnessGenMockPrivateKernelTailCircuit({
// prev_kernel_public_inputs: resetWitnessGenResult.publicInputs,
// });

// Create client IVC proof
const bytecodes = [
MockAppCreatorCircuit.bytecode,
MockPrivateKernelInitCircuit.bytecode,
MockAppReaderCircuit.bytecode,
MockPrivateKernelInnerCircuit.bytecode,
MockPrivateKernelResetCircuit.bytecode,
MockPrivateKernelTailCircuit.bytecode,
// MockPrivateKernelResetCircuit.bytecode,
// MockPrivateKernelTailCircuit.bytecode,
];
const witnessStack = [
creatorAppWitnessGenResult.witness,
initWitnessGenResult.witness,
readerAppWitnessGenResult.witness,
innerWitnessGenResult.witness,
resetWitnessGenResult.witness,
tailWitnessGenResult.witness,
// resetWitnessGenResult.witness,
// tailWitnessGenResult.witness,
];

const proof = await createClientIvcProof(witnessStack, bytecodes);
Expand Down
Loading