From c710ce19eaa3fbcf7c83957e7341a6ca10677ef1 Mon Sep 17 00:00:00 2001 From: guipublic <47281315+guipublic@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:23:32 +0100 Subject: [PATCH] chore: codegen acir opcodes after renaming arithmetic to assertzero (#3896) Please provide a paragraph or two giving a summary of the change, including relevant motivation and context. Arithmetic ACIR opcode has been renamed to AssetZero, but it was not 'codegened' in BB. This PR takes care of this. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- .../acir_format/acir_to_constraint_buf.hpp | 4 ++-- .../dsl/acir_format/serde/acir.hpp | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index 02193ef7b71..db26416f744 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -61,7 +61,7 @@ poly_triple serialize_arithmetic_gate(Circuit::Expression const& arg) return pt; } -void handle_arithmetic(Circuit::Opcode::Arithmetic const& arg, acir_format& af) +void handle_arithmetic(Circuit::Opcode::AssertZero const& arg, acir_format& af) { af.constraints.push_back(serialize_arithmetic_gate(arg.value)); } @@ -269,7 +269,7 @@ acir_format circuit_buf_to_acir_format(std::vector const& buf) std::visit( [&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { handle_arithmetic(arg, af); } else if constexpr (std::is_same_v) { handle_blackbox_func_call(arg, af); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index e9a9b17d864..82e57cad6c6 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -805,12 +805,12 @@ struct MemOp { struct Opcode { - struct Arithmetic { + struct AssertZero { Circuit::Expression value; - friend bool operator==(const Arithmetic&, const Arithmetic&); + friend bool operator==(const AssertZero&, const AssertZero&); std::vector bincodeSerialize() const; - static Arithmetic bincodeDeserialize(std::vector); + static AssertZero bincodeDeserialize(std::vector); }; struct BlackBoxFuncCall { @@ -856,7 +856,7 @@ struct Opcode { static MemoryInit bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; friend bool operator==(const Opcode&, const Opcode&); std::vector bincodeSerialize() const; @@ -5109,7 +5109,7 @@ Circuit::Opcode serde::Deserializable::deserialize(Deserializer namespace Circuit { -inline bool operator==(const Opcode::Arithmetic& lhs, const Opcode::Arithmetic& rhs) +inline bool operator==(const Opcode::AssertZero& lhs, const Opcode::AssertZero& rhs) { if (!(lhs.value == rhs.value)) { return false; @@ -5117,17 +5117,17 @@ inline bool operator==(const Opcode::Arithmetic& lhs, const Opcode::Arithmetic& return true; } -inline std::vector Opcode::Arithmetic::bincodeSerialize() const +inline std::vector Opcode::AssertZero::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline Opcode::Arithmetic Opcode::Arithmetic::bincodeDeserialize(std::vector input) +inline Opcode::AssertZero Opcode::AssertZero::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -5138,7 +5138,7 @@ inline Opcode::Arithmetic Opcode::Arithmetic::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Circuit::Opcode::Arithmetic& obj, +void serde::Serializable::serialize(const Circuit::Opcode::AssertZero& obj, Serializer& serializer) { serde::Serializable::serialize(obj.value, serializer); @@ -5146,9 +5146,9 @@ void serde::Serializable::serialize(const Circuit:: template <> template -Circuit::Opcode::Arithmetic serde::Deserializable::deserialize(Deserializer& deserializer) +Circuit::Opcode::AssertZero serde::Deserializable::deserialize(Deserializer& deserializer) { - Circuit::Opcode::Arithmetic obj; + Circuit::Opcode::AssertZero obj; obj.value = serde::Deserializable::deserialize(deserializer); return obj; }