Skip to content

Commit

Permalink
Remove SGX-related message fields (#229)
Browse files Browse the repository at this point in the history
* util: remove sgx-related message fields

* tests: remove tests to sgx message fields and encoded output

* proto: remove sgx fields from the main message object

* endpoint: remove checks for sgx results
  • Loading branch information
csegarragonz authored Feb 16, 2022
1 parent 318fd7e commit 14daa9c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 94 deletions.
8 changes: 1 addition & 7 deletions src/endpoint/FaabricEndpointHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,7 @@ std::pair<int, std::string> FaabricEndpointHandler::executeFunction(
sch.getFunctionResult(msg.id(), conf.globalMessageTimeout);
SPDLOG_DEBUG("Worker thread {} result {}", tid, funcStr);

if (result.sgxresult().empty()) {
return std::make_pair(result.returnvalue(),
result.outputdata() + "\n");
}

return std::make_pair(result.returnvalue(),
faabric::util::getJsonOutput(result));
return std::make_pair(result.returnvalue(), result.outputdata() + "\n");
} catch (faabric::redis::RedisNoResponseException& ex) {
return std::make_pair(1, "No response from function\n");
}
Expand Down
19 changes: 5 additions & 14 deletions src/proto/faabric.proto
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,16 @@ message Message {

string cmdline = 34;

// SGX
bool isSgx = 35;

string sgxSid = 36;
string sgxNonce = 37;
string sgxTag = 38;
bytes sgxPolicy = 39;
bytes sgxResult = 40;

// Exec-graph utils
bool recordExecGraph = 41;
map<string, int32> intExecGraphDetails = 42;
map<string, string> execGraphDetails = 43;
bool recordExecGraph = 35;
map<string, int32> intExecGraphDetails = 36;
map<string, string> execGraphDetails = 37;

// Function migration
int32 migrationCheckPeriod = 44;
int32 migrationCheckPeriod = 38;

// Scheduling
string topologyHint = 45;
string topologyHint = 39;
}

// ---------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions src/util/func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ std::string funcToString(const faabric::Message& msg, bool includeId)
str += ":" + std::to_string(msg.id());
}

if (msg.issgx()) {
str += ":sgx";
}

return str;
}

Expand Down
43 changes: 0 additions & 43 deletions src/util/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,40 +151,6 @@ std::string messageToJson(const faabric::Message& msg)
a);
}

if (msg.issgx()) {
d.AddMember("sgx", msg.issgx(), a);
}

if (!msg.sgxsid().empty()) {
d.AddMember(
"sgxsid", Value(msg.sgxsid().c_str(), msg.sgxsid().size()).Move(), a);
}

if (!msg.sgxnonce().empty()) {
d.AddMember("sgxnonce",
Value(msg.sgxnonce().c_str(), msg.sgxnonce().size()).Move(),
a);
}

if (!msg.sgxtag().empty()) {
d.AddMember(
"sgxtag", Value(msg.sgxtag().c_str(), msg.sgxtag().size()).Move(), a);
}

if (!msg.sgxpolicy().empty()) {
d.AddMember(
"sgxpolicy",
Value(msg.sgxpolicy().c_str(), msg.sgxpolicy().size()).Move(),
a);
}

if (!msg.sgxresult().empty()) {
d.AddMember(
"sgxresult",
Value(msg.sgxresult().c_str(), msg.sgxresult().size()).Move(),
a);
}

if (msg.recordexecgraph()) {
d.AddMember("record_exec_graph", msg.recordexecgraph(), a);

Expand Down Expand Up @@ -251,8 +217,6 @@ std::string getJsonOutput(const faabric::Message& msg)
Document d;
d.SetObject();
Document::AllocatorType& a = d.GetAllocator();
std::string result_ = cppcodec::base64_rfc4648::encode(msg.sgxresult());
d.AddMember("result", Value(result_.c_str(), result_.size(), a).Move(), a);
d.AddMember(
"output_data",
Value(msg.outputdata().c_str(), msg.outputdata().size(), a).Move(),
Expand Down Expand Up @@ -421,13 +385,6 @@ faabric::Message jsonToMessage(const std::string& jsonIn)

msg.set_cmdline(getStringFromJson(d, "cmdline", ""));

msg.set_issgx(getBoolFromJson(d, "sgx", false));
msg.set_sgxsid(getStringFromJson(d, "sgxsid", ""));
msg.set_sgxnonce(getStringFromJson(d, "sgxnonce", ""));
msg.set_sgxtag(getStringFromJson(d, "sgxtag", ""));
msg.set_sgxpolicy(getStringFromJson(d, "sgxpolicy", ""));
msg.set_sgxresult(getStringFromJson(d, "sgxresult", ""));

msg.set_recordexecgraph(getBoolFromJson(d, "record_exec_graph", false));

// By default, clear the map
Expand Down
19 changes: 0 additions & 19 deletions tests/test/util/test_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ TEST_CASE("Test message to JSON round trip", "[util]")

msg.set_cmdline("some cmdline");

msg.set_issgx(true);
msg.set_sgxsid("test sid string");
msg.set_sgxnonce("test nonce string");
msg.set_sgxtag("test tag string");
msg.set_sgxpolicy("test policy string");
msg.set_sgxresult("test result string");

msg.set_recordexecgraph(true);
auto& map = *msg.mutable_execgraphdetails();
map["foo"] = "bar";
Expand Down Expand Up @@ -93,16 +86,4 @@ TEST_CASE("Test with raw string literals", "[util]")
REQUIRE(msg.user() == "foo");
REQUIRE(msg.function() == "bar");
}

TEST_CASE("Test base64-encoded result", "[util]")
{
faabric::Message msg;
msg.set_sgxresult("test tag string");
msg.set_outputdata("test output string");
std::string encodedOutput = getJsonOutput(msg);
REQUIRE(getValueFromJsonString("result", encodedOutput) ==
"dGVzdCB0YWcgc3RyaW5n");
REQUIRE(getValueFromJsonString("output_data", encodedOutput) ==
"test output string");
}
}
7 changes: 0 additions & 7 deletions tests/utils/message_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ void checkMessageEquality(const faabric::Message& msgA,

REQUIRE(msgA.cmdline() == msgB.cmdline());

REQUIRE(msgA.issgx() == msgB.issgx());
REQUIRE(msgA.sgxsid() == msgB.sgxsid());
REQUIRE(msgA.sgxnonce() == msgB.sgxnonce());
REQUIRE(msgA.sgxtag() == msgB.sgxtag());
REQUIRE(msgA.sgxpolicy() == msgB.sgxpolicy());
REQUIRE(msgA.sgxresult() == msgB.sgxresult());

REQUIRE(msgA.recordexecgraph() == msgB.recordexecgraph());
checkMessageMapEquality(msgA.execgraphdetails(), msgB.execgraphdetails());
checkMessageMapEquality(msgA.intexecgraphdetails(),
Expand Down

0 comments on commit 14daa9c

Please sign in to comment.