Skip to content

Commit

Permalink
chore: update ACIR serialisation format
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Oct 10, 2023
1 parent 9d10326 commit 6f03f4f
Showing 1 changed file with 1 addition and 234 deletions.
235 changes: 1 addition & 234 deletions barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,43 +712,9 @@ struct BrilligOutputs {
static BrilligOutputs bincodeDeserialize(std::vector<uint8_t>);
};

struct ForeignCallParam {

struct Single {
Circuit::Value value;

friend bool operator==(const Single&, const Single&);
std::vector<uint8_t> bincodeSerialize() const;
static Single bincodeDeserialize(std::vector<uint8_t>);
};

struct Array {
std::vector<Circuit::Value> value;

friend bool operator==(const Array&, const Array&);
std::vector<uint8_t> bincodeSerialize() const;
static Array bincodeDeserialize(std::vector<uint8_t>);
};

std::variant<Single, Array> value;

friend bool operator==(const ForeignCallParam&, const ForeignCallParam&);
std::vector<uint8_t> bincodeSerialize() const;
static ForeignCallParam bincodeDeserialize(std::vector<uint8_t>);
};

struct ForeignCallResult {
std::vector<Circuit::ForeignCallParam> values;

friend bool operator==(const ForeignCallResult&, const ForeignCallResult&);
std::vector<uint8_t> bincodeSerialize() const;
static ForeignCallResult bincodeDeserialize(std::vector<uint8_t>);
};

struct Brillig {
std::vector<Circuit::BrilligInputs> inputs;
std::vector<Circuit::BrilligOutputs> outputs;
std::vector<Circuit::ForeignCallResult> foreign_call_results;
std::vector<Circuit::BrilligOpcode> bytecode;
std::optional<Circuit::Expression> predicate;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -3291,7 +3254,6 @@ void serde::Serializable<Circuit::Brillig>::serialize(const Circuit::Brillig& ob
serializer.increase_container_depth();
serde::Serializable<decltype(obj.inputs)>::serialize(obj.inputs, serializer);
serde::Serializable<decltype(obj.outputs)>::serialize(obj.outputs, serializer);
serde::Serializable<decltype(obj.foreign_call_results)>::serialize(obj.foreign_call_results, serializer);
serde::Serializable<decltype(obj.bytecode)>::serialize(obj.bytecode, serializer);
serde::Serializable<decltype(obj.predicate)>::serialize(obj.predicate, serializer);
serializer.decrease_container_depth();
Expand All @@ -3305,7 +3267,6 @@ Circuit::Brillig serde::Deserializable<Circuit::Brillig>::deserialize(Deserializ
Circuit::Brillig obj;
obj.inputs = serde::Deserializable<decltype(obj.inputs)>::deserialize(deserializer);
obj.outputs = serde::Deserializable<decltype(obj.outputs)>::deserialize(deserializer);
obj.foreign_call_results = serde::Deserializable<decltype(obj.foreign_call_results)>::deserialize(deserializer);
obj.bytecode = serde::Deserializable<decltype(obj.bytecode)>::deserialize(deserializer);
obj.predicate = serde::Deserializable<decltype(obj.predicate)>::deserialize(deserializer);
deserializer.decrease_container_depth();
Expand Down Expand Up @@ -4758,200 +4719,6 @@ Circuit::Expression serde::Deserializable<Circuit::Expression>::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<uint8_t> ForeignCallParam::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<ForeignCallParam>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline ForeignCallParam ForeignCallParam::bincodeDeserialize(std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<ForeignCallParam>::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 <typename Serializer>
void serde::Serializable<Circuit::ForeignCallParam>::serialize(const Circuit::ForeignCallParam& obj,
Serializer& serializer)
{
serializer.increase_container_depth();
serde::Serializable<decltype(obj.value)>::serialize(obj.value, serializer);
serializer.decrease_container_depth();
}

template <>
template <typename Deserializer>
Circuit::ForeignCallParam serde::Deserializable<Circuit::ForeignCallParam>::deserialize(Deserializer& deserializer)
{
deserializer.increase_container_depth();
Circuit::ForeignCallParam obj;
obj.value = serde::Deserializable<decltype(obj.value)>::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<uint8_t> ForeignCallParam::Single::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<ForeignCallParam::Single>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline ForeignCallParam::Single ForeignCallParam::Single::bincodeDeserialize(std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<ForeignCallParam::Single>::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 <typename Serializer>
void serde::Serializable<Circuit::ForeignCallParam::Single>::serialize(const Circuit::ForeignCallParam::Single& obj,
Serializer& serializer)
{
serde::Serializable<decltype(obj.value)>::serialize(obj.value, serializer);
}

template <>
template <typename Deserializer>
Circuit::ForeignCallParam::Single serde::Deserializable<Circuit::ForeignCallParam::Single>::deserialize(
Deserializer& deserializer)
{
Circuit::ForeignCallParam::Single obj;
obj.value = serde::Deserializable<decltype(obj.value)>::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<uint8_t> ForeignCallParam::Array::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<ForeignCallParam::Array>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline ForeignCallParam::Array ForeignCallParam::Array::bincodeDeserialize(std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<ForeignCallParam::Array>::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 <typename Serializer>
void serde::Serializable<Circuit::ForeignCallParam::Array>::serialize(const Circuit::ForeignCallParam::Array& obj,
Serializer& serializer)
{
serde::Serializable<decltype(obj.value)>::serialize(obj.value, serializer);
}

template <>
template <typename Deserializer>
Circuit::ForeignCallParam::Array serde::Deserializable<Circuit::ForeignCallParam::Array>::deserialize(
Deserializer& deserializer)
{
Circuit::ForeignCallParam::Array obj;
obj.value = serde::Deserializable<decltype(obj.value)>::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<uint8_t> ForeignCallResult::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<ForeignCallResult>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline ForeignCallResult ForeignCallResult::bincodeDeserialize(std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<ForeignCallResult>::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 <typename Serializer>
void serde::Serializable<Circuit::ForeignCallResult>::serialize(const Circuit::ForeignCallResult& obj,
Serializer& serializer)
{
serializer.increase_container_depth();
serde::Serializable<decltype(obj.values)>::serialize(obj.values, serializer);
serializer.decrease_container_depth();
}

template <>
template <typename Deserializer>
Circuit::ForeignCallResult serde::Deserializable<Circuit::ForeignCallResult>::deserialize(Deserializer& deserializer)
{
deserializer.increase_container_depth();
Circuit::ForeignCallResult obj;
obj.values = serde::Deserializable<decltype(obj.values)>::deserialize(deserializer);
deserializer.decrease_container_depth();
return obj;
}

namespace Circuit {

inline bool operator==(const FunctionInput& lhs, const FunctionInput& rhs)
{
if (!(lhs.witness == rhs.witness)) {
Expand Down Expand Up @@ -6115,4 +5882,4 @@ Circuit::Witness serde::Deserializable<Circuit::Witness>::deserialize(Deserializ
obj.value = serde::Deserializable<decltype(obj.value)>::deserialize(deserializer);
deserializer.decrease_container_depth();
return obj;
}
}

0 comments on commit 6f03f4f

Please sign in to comment.