From 6f03f4fee9f21df54a9b92f28741d3fb774a0011 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 10 Oct 2023 19:47:13 +0100 Subject: [PATCH] chore: update ACIR serialisation format --- .../dsl/acir_format/serde/acir.hpp | 235 +----------------- 1 file changed, 1 insertion(+), 234 deletions(-) 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 6867fefbcae..e59f786ce66 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -712,43 +712,9 @@ struct BrilligOutputs { static BrilligOutputs bincodeDeserialize(std::vector); }; -struct ForeignCallParam { - - struct Single { - Circuit::Value value; - - friend bool operator==(const Single&, const Single&); - std::vector bincodeSerialize() const; - static Single bincodeDeserialize(std::vector); - }; - - struct Array { - std::vector value; - - friend bool operator==(const Array&, const Array&); - std::vector bincodeSerialize() const; - static Array bincodeDeserialize(std::vector); - }; - - std::variant value; - - friend bool operator==(const ForeignCallParam&, const ForeignCallParam&); - std::vector bincodeSerialize() const; - static ForeignCallParam bincodeDeserialize(std::vector); -}; - -struct ForeignCallResult { - std::vector values; - - friend bool operator==(const ForeignCallResult&, const ForeignCallResult&); - std::vector bincodeSerialize() const; - static ForeignCallResult bincodeDeserialize(std::vector); -}; - struct Brillig { std::vector inputs; std::vector outputs; - std::vector foreign_call_results; std::vector bytecode; std::optional predicate; @@ -3253,9 +3219,6 @@ inline bool operator==(const Brillig& lhs, const Brillig& rhs) if (!(lhs.outputs == rhs.outputs)) { return false; } - if (!(lhs.foreign_call_results == rhs.foreign_call_results)) { - return false; - } if (!(lhs.bytecode == rhs.bytecode)) { return false; } @@ -3291,7 +3254,6 @@ void serde::Serializable::serialize(const Circuit::Brillig& ob serializer.increase_container_depth(); serde::Serializable::serialize(obj.inputs, serializer); serde::Serializable::serialize(obj.outputs, serializer); - serde::Serializable::serialize(obj.foreign_call_results, serializer); serde::Serializable::serialize(obj.bytecode, serializer); serde::Serializable::serialize(obj.predicate, serializer); serializer.decrease_container_depth(); @@ -3305,7 +3267,6 @@ Circuit::Brillig serde::Deserializable::deserialize(Deserializ Circuit::Brillig obj; obj.inputs = serde::Deserializable::deserialize(deserializer); obj.outputs = serde::Deserializable::deserialize(deserializer); - obj.foreign_call_results = serde::Deserializable::deserialize(deserializer); obj.bytecode = serde::Deserializable::deserialize(deserializer); obj.predicate = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); @@ -4758,200 +4719,6 @@ Circuit::Expression serde::Deserializable::deserialize(Dese namespace Circuit { -inline bool operator==(const ForeignCallParam& lhs, const ForeignCallParam& rhs) -{ - if (!(lhs.value == rhs.value)) { - return false; - } - return true; -} - -inline std::vector ForeignCallParam::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline ForeignCallParam ForeignCallParam::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::ForeignCallParam& obj, - Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); -} - -template <> -template -Circuit::ForeignCallParam serde::Deserializable::deserialize(Deserializer& deserializer) -{ - deserializer.increase_container_depth(); - Circuit::ForeignCallParam obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); - return obj; -} - -namespace Circuit { - -inline bool operator==(const ForeignCallParam::Single& lhs, const ForeignCallParam::Single& rhs) -{ - if (!(lhs.value == rhs.value)) { - return false; - } - return true; -} - -inline std::vector ForeignCallParam::Single::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline ForeignCallParam::Single ForeignCallParam::Single::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::ForeignCallParam::Single& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::ForeignCallParam::Single serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::ForeignCallParam::Single obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const ForeignCallParam::Array& lhs, const ForeignCallParam::Array& rhs) -{ - if (!(lhs.value == rhs.value)) { - return false; - } - return true; -} - -inline std::vector ForeignCallParam::Array::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline ForeignCallParam::Array ForeignCallParam::Array::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::ForeignCallParam::Array& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.value, serializer); -} - -template <> -template -Circuit::ForeignCallParam::Array serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::ForeignCallParam::Array obj; - obj.value = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const ForeignCallResult& lhs, const ForeignCallResult& rhs) -{ - if (!(lhs.values == rhs.values)) { - return false; - } - return true; -} - -inline std::vector ForeignCallResult::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline ForeignCallResult ForeignCallResult::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::ForeignCallResult& obj, - Serializer& serializer) -{ - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.values, serializer); - serializer.decrease_container_depth(); -} - -template <> -template -Circuit::ForeignCallResult serde::Deserializable::deserialize(Deserializer& deserializer) -{ - deserializer.increase_container_depth(); - Circuit::ForeignCallResult obj; - obj.values = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); - return obj; -} - -namespace Circuit { - inline bool operator==(const FunctionInput& lhs, const FunctionInput& rhs) { if (!(lhs.witness == rhs.witness)) { @@ -6115,4 +5882,4 @@ Circuit::Witness serde::Deserializable::deserialize(Deserializ obj.value = serde::Deserializable::deserialize(deserializer); deserializer.decrease_container_depth(); return obj; -} \ No newline at end of file +}