Skip to content

Commit

Permalink
fix(compiler): increases deserialization limit for values
Browse files Browse the repository at this point in the history
  • Loading branch information
aPere3 committed Apr 18, 2024
1 parent f66deda commit ba1d049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#ifndef CONCRETELANG_BINDINGS_PYTHON_COMPILER_API_MODULE_H
#define CONCRETELANG_BINDINGS_PYTHON_COMPILER_API_MODULE_H

#include <capnp/message.h>
#include <pybind11/pybind11.h>

namespace mlir {
namespace concretelang {
namespace python {

inline constexpr capnp::ReaderOptions DESER_OPTIONS = {7000000000, 64};

void populateCompilerAPISubmodule(pybind11::module &m);

} // namespace python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ concretelang::clientlib::EvaluationKeys
evaluationKeysUnserialize(const std::string &buffer) {
auto serverKeysetProto = Message<concreteprotocol::ServerKeyset>();
auto maybeError = serverKeysetProto.readBinaryFromString(
buffer, capnp::ReaderOptions{7000000000, 64});
buffer, mlir::concretelang::python::DESER_OPTIONS);
if (maybeError.has_failure()) {
throw std::runtime_error("Failed to deserialize server keyset." +
maybeError.as_failure().error().mesg);
Expand All @@ -329,7 +329,7 @@ std::unique_ptr<concretelang::clientlib::KeySet>
keySetUnserialize(const std::string &buffer) {
auto keysetProto = Message<concreteprotocol::Keyset>();
auto maybeError = keysetProto.readBinaryFromString(
buffer, capnp::ReaderOptions{7000000000, 64});
buffer, mlir::concretelang::python::DESER_OPTIONS);
if (maybeError.has_failure()) {
throw std::runtime_error("Failed to deserialize keyset." +
maybeError.as_failure().error().mesg);
Expand All @@ -351,7 +351,10 @@ std::string keySetSerialize(concretelang::clientlib::KeySet &keySet) {
concretelang::clientlib::SharedScalarOrTensorData
valueUnserialize(const std::string &buffer) {
auto inner = TransportValue();
if (inner.readBinaryFromString(buffer).has_failure()) {
if (inner
.readBinaryFromString(buffer,
mlir::concretelang::python::DESER_OPTIONS)
.has_failure()) {
throw std::runtime_error("Failed to deserialize Value");
}
return {inner};
Expand Down

0 comments on commit ba1d049

Please sign in to comment.