Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change tee to sworker and upgrade version file #235

Merged
merged 3 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Please refer to [Crust sWorker docker mode](docs/Docker.md)
In /opt/crust/crust-sworker/etc/Config.json file you can configure your sworker application.
```
{
"base_path" : "/opt/crust/crust-sworker/0.5.1/tee_base_path", # sWorker key information location, must be absolute path
"base_path" : "/opt/crust/crust-sworker/0.6.0/sworker_base_path", # sWorker key information location, must be absolute path
"base_url": "http://127.0.0.1:12222/api/v0", # your sWorker node api address
"srd_paths" : ["/data1", "/data2"], # If this item is not set, base_path will be used
"srd_init_capacity" : 4, # srd initial disk storage in Gb
Expand All @@ -72,7 +72,7 @@ In /opt/crust/crust-sworker/etc/Config.json file you can configure your sworker

### Run
```
/opt/crust/crust-sworker/0.5.1/bin/crust-sworker -c /opt/crust/crust-sworker/0.5.1/etc/Config.json
/opt/crust/crust-sworker/0.6.0/bin/crust-sworker -c /opt/crust/crust-sworker/0.6.0/etc/Config.json
```

### Crust sWorker executable file
Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.5.1
TEE=0.5.1
0.6.0
SWORKER=0.6.0
6 changes: 3 additions & 3 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Output:
},
"srd" : {
"detail" : {
"/opt/crust/crust-sworker/0.5.1/tee_base_path/test1" : { "assigned" : 57, "available" : 0, "total" : 457 }
"/opt/crust/crust-sworker/0.6.0/sworker_base_path/test1" : { "assigned" : 57, "available" : 0, "total" : 457 }
},
"disk_reserved" : 50,
"remaining_task" : 1,
Expand Down Expand Up @@ -56,8 +56,8 @@ Output:
{
"mrenclave" : "aad180124c8670b397a838f552a9136e7e3e7eba2f1c9c49ba16bf53c015b195",
"pub_key" : "ad288767765f9402ed9a15ecba7fc56a5e39167f94eefe39c05f5f43862686c0b21328d489d3c7d0c4e19445d49a63c1cedbfad9e027166261ae04eb34868514",
"version" : "0.5.1",
"tee_version" : "0.5.1"
"version" : "0.6.0",
"sworker_version" : "0.6.0"
}
```

Expand Down
4 changes: 2 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
function checkOldCrustTee()
function checkOldCrustSworker()
{
verbose INFO "Checking old crust sworker..." h
local ret=0
Expand Down Expand Up @@ -217,7 +217,7 @@ verbose INFO "Version -----------------$newversion-------------------"
disown -r

# check previous crust-sworker
checkOldCrustTee
checkOldCrustSworker

# Install Dependencies
if [ "$DOCKERMODLE" == "0" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trap "success_exit" EXIT

# Write version
getVERSION > $instdir/VERSION
echo "TEE=$(getTEEVERSION)" >> $instdir/VERSION
echo "SWORKER=$(getSWORKERVERSION)" >> $instdir/VERSION

newversion=$(cat $instdir/VERSION | head -n 1)
verbose INFO "Start packaging sworker, version is $newversion..."
Expand Down
6 changes: 3 additions & 3 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ function getVERSION()
}

# Be careful about this function
function getTEEVERSION()
function getSWORKERVERSION()
{
local basedir=$(cd `dirname $0`;pwd)
local srcdir=$(cd $basedir/../src;pwd)
local tee_para="$srcdir/enclave/include/Parameter.h"
echo $(cat $tee_para | grep "#define TEE_VERSION" | awk '{print $3}' | sed 's/"//g' 2>/dev/null)
local sworker_para="$srcdir/enclave/include/Parameter.h"
echo $(cat $sworker_para | grep "#define SWORKER_VERSION" | awk '{print $3}' | sed 's/"//g' 2>/dev/null)
}

# color
Expand Down
4 changes: 2 additions & 2 deletions src/Config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"base_path" : "/opt/crust/crust-sworker/<VERSION>/tee_base_path",
"base_path" : "/opt/crust/crust-sworker/<VERSION>/sworker_base_path",
"base_url": "http://0.0.0.0:12222/api/v0",
"srd_paths" : ["/opt/crust/crust-sworker/<VERSION>/tee_base_path/test1", "/opt/crust/crust-sworker/<VERSION>/tee_base_path/test2"],
"srd_paths" : ["/opt/crust/crust-sworker/<VERSION>/sworker_base_path/test1", "/opt/crust/crust-sworker/<VERSION>/sworker_base_path/test2"],
"srd_init_capacity" : 4,

"karst_url": "ws://0.0.0.0:17000/api/v0/node/data",
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ define setMaxThreadNum
sed -i "/^#define ENC_MAX_THREAD_NUM/c #define ENC_MAX_THREAD_NUM $$max_thread_num" app/ecalls/ECalls.h; \
sed -i "/^#define ENC_MAX_THREAD_NUM/c #define ENC_MAX_THREAD_NUM $$max_thread_num" $$enclave_para; \
cat $$app_para | grep "#define VERSION" | awk '{print $$3}' | sed 's/"//g' > ../VERSION; \
tee_version=$$(cat $$enclave_para | grep "#define TEE_VERSION" | awk '{print $$3}' | sed 's/"//g'); \
echo "TEE=$$tee_version" >> ../VERSION
sworker_version=$$(cat $$enclave_para | grep "#define SWORKER_VERSION" | awk '{print $$3}' | sed 's/"//g'); \
echo "SWORKER=$$sworker_version" >> ../VERSION
endef

ifneq ($(TFLAG), 1)
Expand Down
2 changes: 1 addition & 1 deletion src/app/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int SGX_CDECL main(int argc, char *argv[])
else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{
printf("Release version: %s\
\nTEE version: %s\n", VERSION, TEE_VERSION);
\nSWorker version: %s\n", VERSION, SWORKER_VERSION);
return 0;
}
else if (strcmp(argv[i], "--offline") == 0)
Expand Down
16 changes: 8 additions & 8 deletions src/app/chain/Chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ bool Chain::wait_for_running(void)
}

/**
* @description: post tee identity to chain chain
* @param identity -> tee identity
* @description: post sworker identity to chain chain
* @param identity -> sworker identity
* @return: success or fail
*/
bool Chain::post_tee_identity(std::string identity)
bool Chain::post_sworker_identity(std::string identity)
{
for(int i = 0; i < 3; i++)
{
std::string path = this->url + "/tee/identity";
std::string path = this->url + "/swork/identity";
ApiHeaders headers = {{"password", this->password}, {"Content-Type", "application/json"}};

json::JSON obj = json::JSON::Load(identity);
Expand Down Expand Up @@ -238,15 +238,15 @@ bool Chain::post_tee_identity(std::string identity)
}

/**
* @description: post tee work report to chain
* @param work_report -> tee work report
* @description: post sworker work report to chain
* @param work_report -> sworker work report
* @return: success or fail
*/
bool Chain::post_tee_work_report(std::string work_report)
bool Chain::post_sworker_work_report(std::string work_report)
{
for(int i = 0; i < 3; i++)
{
std::string path = this->url + "/tee/workreport";
std::string path = this->url + "/swork/workreport";
ApiHeaders headers = {{"password", this->password}, {"Content-Type", "application/json"}};

json::JSON obj = json::JSON::Load(work_report);
Expand Down
4 changes: 2 additions & 2 deletions src/app/chain/Chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Chain
static Chain *get_instance();
BlockHeader *get_block_header(void);
std::string get_block_hash(size_t block_number);
bool post_tee_identity(std::string identity);
bool post_tee_work_report(std::string work_report);
bool post_sworker_identity(std::string identity);
bool post_sworker_work_report(std::string work_report);
bool is_online(void);
bool is_syncing(void);
bool wait_for_running(void);
Expand Down
2 changes: 1 addition & 1 deletion src/app/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Config::show(void)
printf(" 'srd path %d' : '%s',\n", i + 1, this->srd_paths[i].ToString().c_str());
}
printf(" 'srd init capacity' : %lu,\n", this->srd_capacity);
printf(" 'tee base url' : '%s',\n", this->base_url.c_str());
printf(" 'base url' : '%s',\n", this->base_url.c_str());
printf(" 'karst url' : '%s',\n", this->karst_url.c_str());

printf(" 'chain config' : {\n");
Expand Down
2 changes: 1 addition & 1 deletion src/app/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Config
{
public:
// base information
std::string base_path; /* TEE base path */
std::string base_path; /* sworker base path */
json::JSON srd_paths; /* Srd paths */
std::string srd_path; /* srd validation files base path */
std::string db_path; /* DB path */
Expand Down
2 changes: 1 addition & 1 deletion src/app/http/ApiHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void ApiHandler::http_handler(beast::string_view /*doc_root*/,
Ecall_id_get_info(global_eid);
json::JSON id_json = json::JSON::Load(get_g_enclave_id_info());
id_json["version"] = VERSION;
id_json["tee_version"] = TEE_VERSION;
id_json["sworker_version"] = SWORKER_VERSION;
res.body() = id_json.dump();
goto getcleanup;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/include/Resource.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define VERSION "0.5.1"
#define VERSION "0.6.0"

#define CRUST_INST_DIR "/opt/crust/crust-sworker/" VERSION
#define ENCLAVE_FILE_PATH CRUST_INST_DIR "/etc/enclave.signed.so"
Expand Down
4 changes: 2 additions & 2 deletions src/app/ocalls/OCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,12 @@ void ocall_srd_change(long change)
}

/**
* @description: Store tee identity
* @description: Store sworker identity
* @param id -> Pointer to identity
*/
void ocall_store_identity(const char *id)
{
set_g_tee_identity(id);
set_g_sworker_identity(id);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/app/process/Data.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Data.h"

// Store TEE identity
std::string g_tee_identity = "";
// Store sworker identity
std::string g_sworker_identity = "";
// Store order report
std::string g_order_report = "";
// Store enclave identity information
Expand All @@ -13,14 +13,14 @@ std::string g_enclave_workreport = "";
// New karst url
std::string g_new_karst_url = "";

std::string get_g_tee_identity()
std::string get_g_sworker_identity()
{
return g_tee_identity;
return g_sworker_identity;
}

void set_g_tee_identity(std::string identity)
void set_g_sworker_identity(std::string identity)
{
g_tee_identity = identity;
g_sworker_identity = identity;
}

std::string get_g_order_report()
Expand Down
4 changes: 2 additions & 2 deletions src/app/process/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ extern "C"
{
#endif

std::string get_g_tee_identity();
void set_g_tee_identity(std::string identity);
std::string get_g_sworker_identity();
void set_g_sworker_identity(std::string identity);
std::string get_g_order_report();
void set_g_order_report(std::string order_report);
std::string get_g_enclave_id_info();
Expand Down
12 changes: 6 additions & 6 deletions src/app/process/EntryNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ crust::Log *p_log = crust::Log::get_instance();
/**
* @description: Entry network off-chain node sends quote to onchain node to verify identity
* @param p_config -> configurations
* @param tee_identity_out -> tee identity result
* @param sworker_identity_out -> sworker identity result
* @return: Success or failure
*/
bool entry_network(Config *p_config, std::string &tee_identity_out)
bool entry_network(Config *p_config, std::string &sworker_identity_out)
{
sgx_quote_sign_type_t linkable = SGX_UNLINKABLE_SIGNATURE;
sgx_status_t status, sgxrv;
Expand Down Expand Up @@ -246,16 +246,16 @@ bool entry_network(Config *p_config, std::string &tee_identity_out)

// Verify IAS report in enclave
crust_status_t crust_status;
// Ecall_verify_iasreport will store tee identity to g_tee_identity by ocall
// You can get this identity by accessing g_tee_identity
// Ecall_verify_iasreport will store sworker identity to g_sworker_identity by ocall
// You can get this identity by accessing g_sworker_identity
sgx_status_t status_ret = Ecall_verify_iasreport(global_eid, &crust_status, const_cast<char**>(ias_report.data()), ias_report.size());
if (SGX_SUCCESS == status_ret)
{
if (CRUST_SUCCESS == crust_status)
{
json::JSON tmp_json = json::JSON::Load(get_g_tee_identity());
json::JSON tmp_json = json::JSON::Load(get_g_sworker_identity());
tmp_json["account_id"] = p_config->chain_address;
tee_identity_out = tmp_json.dump();
sworker_identity_out = tmp_json.dump();
entry_status = true;
p_log->info("Verify IAS report in enclave successfully!\n");
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/process/EntryNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
#define OPT_LINK 0x04
#define OPT_PUBKEY 0x08

bool entry_network(Config *p_config, std::string &tee_identity_out);
bool entry_network(Config *p_config, std::string &sworker_identity_out);

#endif /* !_CRUST_ENTRY_NETWORK_H_ */
8 changes: 4 additions & 4 deletions src/app/process/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int process_run()
pid_t worker_pid = getpid();
sgx_status_t sgx_status = SGX_SUCCESS;
crust_status_t crust_status = CRUST_SUCCESS;
std::string tee_identity_result = "";
std::string sworker_identity_result = "";
int return_status = 1;
p_log->info("WorkerPID = %d\n", worker_pid);

Expand Down Expand Up @@ -219,12 +219,12 @@ int process_run()
{
// Entry network
p_log->info("Entrying network...\n");
if (!entry_network(p_config, tee_identity_result))
if (!entry_network(p_config, sworker_identity_result))
{
goto cleanup;
return_status = -1;
}
p_log->info("Entry network application successfully! TEE identity: %s\n", tee_identity_result.c_str());
p_log->info("Entry network application successfully! Identity: %s\n", sworker_identity_result.c_str());

// Send identity to crust chain
if (!crust::Chain::get_instance()->wait_for_running())
Expand All @@ -233,7 +233,7 @@ int process_run()
goto cleanup;
}

if (!crust::Chain::get_instance()->post_tee_identity(tee_identity_result))
if (!crust::Chain::get_instance()->post_sworker_identity(sworker_identity_result))
{
p_log->err("Send identity to crust chain failed!\n");
return_status = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/app/process/Srd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ void set_reserved_space(size_t reserved)
}

/**
* @description: Get old TEE's reserved space from url
* @param url -> Indicates old TEE url
* @return: Old TEE srd reserved space
* @description: Get old sworker's reserved space from url
* @param url -> Indicates old sworker url
* @return: Old sworker srd reserved space
*/
long get_old_reserved_space(std::string url)
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/process/WorkReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void work_report_loop(void)
remove_char(work_str, '\\');
remove_char(work_str, '\n');
remove_char(work_str, ' ');
if (!p_chain->post_tee_work_report(work_str))
if (!p_chain->post_sworker_work_report(work_str))
{
p_log->err("Send work report to crust chain failed!\n");
}
Expand Down
Loading