Skip to content

Commit

Permalink
chore: Switch to using test_data_ssa_refactor for acir_tests (#AztecP…
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad committed Jul 26, 2023
1 parent 3b803c9 commit ed74b21
Show file tree
Hide file tree
Showing 12 changed files with 520 additions and 333 deletions.
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,3 @@
[submodule "l1-contracts/lib/forge-std"]
path = l1-contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "circuits/cpp/barretenberg/sol/lib/forge-std"]
path = circuits/cpp/barretenberg/sol/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "circuits/cpp/barretenberg/sol/lib/solidity-stringutils"]
path = circuits/cpp/barretenberg/sol/lib/solidity-stringutils
url = https://github.com/Arachnid/solidity-stringutils
[submodule "circuits/cpp/barretenberg/sol/lib/openzeppelin-contracts"]
path = circuits/cpp/barretenberg/sol/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{".":"0.3.3","ts":"0.3.3"}
{".":"0.3.4","ts":"0.3.4"}
9 changes: 9 additions & 0 deletions circuits/cpp/barretenberg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [0.3.4](https://github.com/AztecProtocol/barretenberg/compare/barretenberg-v0.3.3...barretenberg-v0.3.4) (2023-07-25)


### Features

* Add Goblin Ultra Circuit builder ([#587](https://github.com/AztecProtocol/barretenberg/issues/587)) ([2d38c25](https://github.com/AztecProtocol/barretenberg/commit/2d38c252de8b867955da661181e51f1a5f28cbc6))
* Modify bb.js to be compatible with next.js ([#544](https://github.com/AztecProtocol/barretenberg/issues/544)) ([d384089](https://github.com/AztecProtocol/barretenberg/commit/d384089f60d1a6d5baeb0d3459556a310b790366))
* Support public inputs in Ultra Honk ([#581](https://github.com/AztecProtocol/barretenberg/issues/581)) ([9cd0a06](https://github.com/AztecProtocol/barretenberg/commit/9cd0a064b8258bf4f72dd9e1c5e8f85b074d1bbc))

## [0.3.3](https://github.com/AztecProtocol/barretenberg/compare/barretenberg-v0.3.2...barretenberg-v0.3.3) (2023-07-17)


Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.3 x-release-please-version
v0.3.4 x-release-please-version
4 changes: 2 additions & 2 deletions circuits/cpp/barretenberg/acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ if [ ! -d acir_tests ]; then
git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git
cd noir
git sparse-checkout init --cone
git sparse-checkout set crates/nargo_cli/tests/test_data
git sparse-checkout set crates/nargo_cli/tests/test_data_ssa_refactor
git checkout
cd ..
mv noir/crates/nargo_cli/tests/test_data acir_tests
mv noir/crates/nargo_cli/tests/test_data_ssa_refactor acir_tests
rm -rf noir
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/barretenberg-wasm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ in
stdenv.mkDerivation
{
pname = "barretenberg.wasm";
version = "0.3.3"; # x-release-please-version
version = "0.3.4"; # x-release-please-version

src = ./cpp;

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/barretenberg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in
buildEnv.mkDerivation
{
pname = "libbarretenberg";
version = "0.3.3"; # x-release-please-version
version = "0.3.4"; # x-release-please-version

src = ./cpp;

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24)
project(
Barretenberg
DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover"
VERSION 0.3.3 # x-release-please-version
VERSION 0.3.4 # x-release-please-version
LANGUAGES CXX C
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "acir_format.hpp"
#include "barretenberg/common/container.hpp"
#include "barretenberg/common/throw_or_abort.hpp"
#include "barretenberg/dsl/acir_format/blake2s_constraint.hpp"
#include "barretenberg/dsl/acir_format/block_constraint.hpp"
#include "barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp"
Expand Down Expand Up @@ -233,6 +234,44 @@ void handle_memory(Circuit::MemoryBlock const& mem_block, bool is_ram, acir_form
af.block_constraints.push_back(BlockConstraint{ .init = init, .trace = trace, .type = (BlockType)is_ram });
}

BlockConstraint handle_memory_init(Circuit::Opcode::MemoryInit const& mem_init)
{
BlockConstraint block{ .init = {}, .trace = {}, .type = BlockType::ROM };
std::vector<poly_triple> init;
std::vector<MemOp> trace;

auto len = mem_init.init.size();
for (size_t i = 0; i < len; ++i) {
block.init.push_back(poly_triple{
.a = mem_init.init[i].value,
.b = 0,
.c = 0,
.q_m = 0,
.q_l = 1,
.q_r = 0,
.q_o = 0,
.q_c = 0,
});
}
return block;
}

void handle_memory_op(Circuit::Opcode::MemoryOp const& mem_op, BlockConstraint& block)
{
uint8_t access_type = 1;
if (mem_op.op.is_rom()) {
access_type = 0;
}
if (block.type == BlockType::ROM && access_type == 1) {
block.type = BlockType::RAM;
}

MemOp acir_mem_op = MemOp{ .access_type = access_type,
.index = serialize_arithmetic_gate(mem_op.op.index),
.value = serialize_arithmetic_gate(mem_op.op.value) };
block.trace.push_back(acir_mem_op);
}

acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
{
auto circuit = Circuit::Circuit::bincodeDeserialize(buf);
Expand All @@ -241,7 +280,7 @@ acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
af.varnum = circuit.current_witness_index + 1;
af.public_inputs = join({ map(circuit.public_parameters.value, [](auto e) { return e.value; }),
map(circuit.return_values.value, [](auto e) { return e.value; }) });

std::map<uint32_t, BlockConstraint> block_id_to_block_constraint;
for (auto gate : circuit.opcodes) {
std::visit(
[&](auto&& arg) {
Expand All @@ -254,10 +293,25 @@ acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
handle_memory(arg.value, true, af);
} else if constexpr (std::is_same_v<T, Circuit::Opcode::ROM>) {
handle_memory(arg.value, false, af);
} else if constexpr (std::is_same_v<T, Circuit::Opcode::MemoryInit>) {
auto block = handle_memory_init(arg);
uint32_t block_id = arg.block_id.value;
block_id_to_block_constraint[block_id] = block;
} else if constexpr (std::is_same_v<T, Circuit::Opcode::MemoryOp>) {
auto block = block_id_to_block_constraint.find(arg.block_id.value);
if (block == block_id_to_block_constraint.end()) {
throw_or_abort("unitialized MemoryOp");
}
handle_memory_op(arg, block->second);
}
},
gate.value);
}
for (const auto& [block_id, block] : block_id_to_block_constraint) {
if (!block.trace.empty()) {
af.block_constraints.push_back(block);
}
}
return af;
}

Expand Down
Loading

0 comments on commit ed74b21

Please sign in to comment.