You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by ms...@apache.org on 2020/03/23 00:10:52 UTC

[incubator-teaclave] branch develop updated (770b9b2 -> 4275ace)

This is an automated email from the ASF dual-hosted git repository.

mssun pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git.


    from 770b9b2  [types] Common types refactoring
     new adf9a4e  [rustfmt] Set use_field_init_shorthand to true
     new 9a4de97  [types] Use FunctionArguments in other proto definitions
     new 4275ace  Add Apache License in header

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .rustfmt.toml                                      |  3 +-
 attestation/src/attestation.rs                     | 17 ++++++
 attestation/src/platform.rs                        | 17 ++++++
 binder/src/ipc/mod.rs                              | 17 ++++++
 common/rusty_leveldb_sgx/src/block.rs              |  2 +-
 common/rusty_leveldb_sgx/src/block_builder.rs      |  2 +-
 common/rusty_leveldb_sgx/src/blockhandle.rs        |  5 +-
 common/rusty_leveldb_sgx/src/db_impl.rs            |  6 +-
 common/rusty_leveldb_sgx/src/db_iter.rs            |  8 +--
 common/rusty_leveldb_sgx/src/error.rs              |  5 +-
 common/rusty_leveldb_sgx/src/filter.rs             |  5 +-
 common/rusty_leveldb_sgx/src/key_types.rs          |  2 +-
 common/rusty_leveldb_sgx/src/log.rs                |  4 +-
 common/rusty_leveldb_sgx/src/merging_iter.rs       |  4 +-
 common/rusty_leveldb_sgx/src/skipmap.rs            |  4 +-
 common/rusty_leveldb_sgx/src/snapshot.rs           |  2 +-
 common/rusty_leveldb_sgx/src/table_builder.rs      |  4 +-
 common/rusty_leveldb_sgx/src/table_reader.rs       | 10 ++--
 common/rusty_leveldb_sgx/src/version.rs            |  6 +-
 common/rusty_leveldb_sgx/src/version_edit.rs       | 16 +++---
 common/rusty_leveldb_sgx/src/version_set.rs        |  6 +-
 config/build.rs                                    | 17 ++++++
 config/config_gen/main.rs                          | 17 ++++++
 config/src/build.rs                                | 17 ++++++
 config/src/lib.rs                                  | 17 ++++++
 config/src/runtime.rs                              | 17 ++++++
 dcap/src/main.rs                                   | 17 ++++++
 rpc/proc_macro/src/lib.rs                          | 17 ++++++
 rpc/src/channel.rs                                 | 17 ++++++
 rpc/src/config.rs                                  | 17 ++++++
 rpc/src/endpoint.rs                                | 17 ++++++
 rpc/src/lib.rs                                     | 17 ++++++
 rpc/src/protocol.rs                                | 17 ++++++
 rpc/src/request.rs                                 | 17 ++++++
 rpc/src/server.rs                                  | 17 ++++++
 rpc/src/transport.rs                               | 17 ++++++
 rpc/src/utils.rs                                   | 17 ++++++
 services/access_control/enclave/src/acs.rs         | 17 ++++++
 services/access_control/enclave/src/service.rs     | 17 ++++++
 services/authentication/enclave/src/api_service.rs | 17 ++++++
 .../authentication/enclave/src/internal_service.rs | 17 ++++++
 services/execution/enclave/src/service.rs          | 28 +++++-----
 services/frontend/enclave/src/service.rs           | 17 ++++++
 services/management/enclave/src/service.rs         | 29 ++++++++--
 services/management/enclave/src/task.rs            |  6 +-
 .../src/proto/teaclave_frontend_service.proto      |  9 +--
 .../proto/src/teaclave_access_control_service.rs   | 17 ++++++
 .../proto/src/teaclave_authentication_service.rs   | 17 ++++++
 services/proto/src/teaclave_common.rs              | 17 ++++++
 services/proto/src/teaclave_frontend_service.rs    | 60 ++++++++++----------
 services/proto/src/teaclave_management_service.rs  | 17 ++++++
 services/proto/src/teaclave_scheduler_service.rs   | 17 ++++++
 services/proto/src/teaclave_storage_service.rs     | 17 ++++++
 services/storage/enclave/src/proxy.rs              | 17 ++++++
 services/storage/enclave/src/service.rs            | 17 ++++++
 .../enclave/src/teaclave_access_control_service.rs | 17 ++++++
 .../enclave/src/teaclave_authentication_service.rs | 17 ++++++
 .../enclave/src/teaclave_frontend_service.rs       | 47 ++++++++++------
 .../enclave/src/teaclave_management_service.rs     | 30 ++++++++--
 .../enclave/src/teaclave_scheduler_service.rs      | 17 ++++++
 .../enclave/src/teaclave_storage_service.rs        | 17 ++++++
 tests/integration/app/src/teaclave_config_tests.rs | 17 ++++++
 tests/integration/enclave/src/rusty_leveldb_sgx.rs | 17 ++++++
 tests/integration/enclave/src/teaclave_rpc.rs      | 17 ++++++
 tests/integration/enclave/src/teaclave_worker.rs   | 23 +++++++-
 tests/utils/src/lib.rs                             | 17 ++++++
 types/src/crypto.rs                                | 17 ++++++
 types/src/file_agent.rs                            | 17 ++++++
 types/src/lib.rs                                   | 17 ++++++
 types/src/macros.rs                                | 19 ++++++-
 types/src/staged_file.rs                           | 17 ++++++
 types/src/staged_function.rs                       | 65 ++++++++++++++++++----
 types/src/staged_task.rs                           | 17 ++++++
 types/src/storage.rs                               | 17 ++++++
 types/src/task.rs                                  | 17 ++++++
 types/src/worker.rs                                | 17 ++++++
 utils/service_app_utils/src/lib.rs                 | 17 ++++++
 utils/service_enclave_utils/proc_macro/src/lib.rs  | 17 ++++++
 utils/service_enclave_utils/src/lib.rs             | 17 ++++++
 worker/src/function/context.rs                     | 17 ++++++
 worker/src/function/echo.rs                        |  2 +-
 worker/src/function/gbdt_training.rs               |  2 +-
 worker/src/function/mesapy.rs                      | 12 ++--
 worker/src/worker.rs                               | 11 ++--
 84 files changed, 1155 insertions(+), 166 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 02/03: [types] Use FunctionArguments in other proto definitions

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 9a4de971c74ea909807993163bc975825ddc2b13
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Sun Mar 22 15:54:07 2020 -0700

    [types] Use FunctionArguments in other proto definitions
---
 services/execution/enclave/src/service.rs          | 28 ++++++-------
 services/management/enclave/src/service.rs         | 12 +++---
 services/management/enclave/src/task.rs            |  6 +--
 .../src/proto/teaclave_frontend_service.proto      |  9 +---
 services/proto/src/teaclave_frontend_service.rs    | 43 ++++++-------------
 .../enclave/src/teaclave_frontend_service.rs       | 30 ++++++--------
 .../enclave/src/teaclave_management_service.rs     | 13 +++---
 tests/integration/enclave/src/teaclave_worker.rs   |  6 +--
 types/src/macros.rs                                |  2 +-
 types/src/staged_function.rs                       | 48 ++++++++++++++++------
 worker/src/function/echo.rs                        |  2 +-
 worker/src/function/gbdt_training.rs               |  2 +-
 worker/src/function/mesapy.rs                      | 12 +++---
 worker/src/worker.rs                               | 11 ++---
 14 files changed, 110 insertions(+), 114 deletions(-)

diff --git a/services/execution/enclave/src/service.rs b/services/execution/enclave/src/service.rs
index 50bf2e8..11ea963 100644
--- a/services/execution/enclave/src/service.rs
+++ b/services/execution/enclave/src/service.rs
@@ -260,17 +260,17 @@ pub mod tests {
 
     pub fn test_invoke_gbdt_training() {
         let task_id = Uuid::new_v4();
-        let arg_map = hashmap!(
-            "feature_size".to_string()                => "4".to_string(),
-            "max_depth".to_string()                   => "4".to_string(),
-            "iterations".to_string()                  => "100".to_string(),
-            "shrinkage".to_string()                   => "0.1".to_string(),
-            "feature_sample_ratio".to_string()        => "1.0".to_string(),
-            "data_sample_ratio".to_string()           => "1.0".to_string(),
-            "min_leaf_size".to_string()               => "1".to_string(),
-            "loss".to_string()                        => "LAD".to_string(),
-            "training_optimization_level".to_string() => "2".to_string(),
-        );
+        let function_arguments = FunctionArguments::new(hashmap!(
+            "feature_size"                => "4",
+            "max_depth"                   => "4",
+            "iterations"                  => "100",
+            "shrinkage"                   => "0.1",
+            "feature_sample_ratio"        => "1.0",
+            "data_sample_ratio"           => "1.0",
+            "min_leaf_size"               => "1",
+            "loss"                        => "LAD",
+            "training_optimization_level" => "2",
+        ));
         let fixture_dir = format!(
             "file:///{}/fixtures/functions/gbdt_training",
             env!("TEACLAVE_TEST_INSTALL_DIR")
@@ -288,13 +288,13 @@ pub mod tests {
         let training_input_data = FunctionInputFile::new(input_url, "", crypto_info);
         let model_output_data = FunctionOutputFile::new(output_url, crypto_info);
 
-        let input_data = hashmap!("training_data".to_string() => training_input_data);
-        let output_data = hashmap!("trained_model".to_string() => model_output_data);
+        let input_data = hashmap!("training_data" => training_input_data);
+        let output_data = hashmap!("trained_model" => model_output_data);
 
         let staged_task = StagedTask::new()
             .task_id(task_id)
             .function_name("gbdt_training")
-            .function_arguments(arg_map.into())
+            .function_arguments(function_arguments)
             .input_data(input_data)
             .output_data(output_data);
 
diff --git a/services/management/enclave/src/service.rs b/services/management/enclave/src/service.rs
index d48ce2f..3c527f1 100644
--- a/services/management/enclave/src/service.rs
+++ b/services/management/enclave/src/service.rs
@@ -315,7 +315,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
         let task = crate::task::create_task(
             function,
             user_id,
-            request.arg_list,
+            request.function_arguments,
             request.input_data_owner_list,
             request.output_data_owner_list,
         )
@@ -352,7 +352,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
             creator: task.creator,
             function_id: task.function_id,
             function_owner: task.function_owner,
-            arg_list: task.function_arguments.into(),
+            function_arguments: task.function_arguments,
             input_data_owner_list: task.input_data_owner_list,
             output_data_owner_list: task.output_data_owner_list,
             participants: task.participants,
@@ -663,7 +663,8 @@ pub mod tests {
     use super::*;
     use std::collections::{HashMap, HashSet};
     use teaclave_types::{
-        FunctionInput, FunctionOutput, TeaclaveFileCryptoInfo, TeaclaveFileRootKey128,
+        hashmap, FunctionArguments, FunctionInput, FunctionOutput, TeaclaveFileCryptoInfo,
+        TeaclaveFileRootKey128,
     };
     use url::Url;
 
@@ -730,13 +731,12 @@ pub mod tests {
             owner: "mock_user".to_string(),
             is_native: false,
         };
-        let mut arg_list = HashMap::new();
-        arg_list.insert("arg".to_string(), "data".to_string());
+        let function_arguments = FunctionArguments::new(hashmap!("arg" => "data"));
 
         let task = crate::task::create_task(
             function,
             "mock_user".to_string(),
-            arg_list,
+            function_arguments,
             HashMap::new(),
             HashMap::new(),
         )
diff --git a/services/management/enclave/src/task.rs b/services/management/enclave/src/task.rs
index c5b804f..5d0b6be 100644
--- a/services/management/enclave/src/task.rs
+++ b/services/management/enclave/src/task.rs
@@ -20,14 +20,15 @@ use std::collections::HashSet;
 use std::prelude::v1::*;
 use teaclave_types::Function;
 use teaclave_types::{
-    DataOwnerList, Storable, Task, TaskStatus, TeaclaveInputFile, TeaclaveOutputFile,
+    DataOwnerList, FunctionArguments, Storable, Task, TaskStatus, TeaclaveInputFile,
+    TeaclaveOutputFile,
 };
 use uuid::Uuid;
 
 pub(crate) fn create_task(
     function: Function,
     creator: String,
-    arg_list: HashMap<String, String>,
+    function_arguments: FunctionArguments,
     input_data_owner_list: HashMap<String, DataOwnerList>,
     output_data_owner_list: HashMap<String, DataOwnerList>,
 ) -> Result<Task> {
@@ -47,7 +48,6 @@ pub(crate) fn create_task(
             participants.insert(user_id.clone());
         }
     }
-    let function_arguments = arg_list.into();
     let task = Task {
         task_id,
         creator,
diff --git a/services/proto/src/proto/teaclave_frontend_service.proto b/services/proto/src/proto/teaclave_frontend_service.proto
index b2434f4..0ecbce2 100644
--- a/services/proto/src/proto/teaclave_frontend_service.proto
+++ b/services/proto/src/proto/teaclave_frontend_service.proto
@@ -106,14 +106,9 @@ message DataMap {
   string data_id = 2;
 }
 
-message Argument {
-  string arg_name = 1;
-  string arg_value = 2;
-}
-
 message CreateTaskRequest {
   string function_id = 1;
-  repeated Argument arg_list = 2;
+  map<string, string> function_arguments = 2;
   repeated DataOwnerList input_data_owner_list = 3;
   repeated DataOwnerList output_data_owner_list = 4;
 }
@@ -131,7 +126,7 @@ message GetTaskResponse {
   string creator = 2;
   string function_id = 3;
   string function_owner = 4;
-  repeated Argument arg_list = 5;
+  map<string, string> function_arguments = 5;
   repeated DataOwnerList input_data_owner_list = 6;
   repeated DataOwnerList output_data_owner_list = 7;
   repeated string participants = 8;
diff --git a/services/proto/src/teaclave_frontend_service.rs b/services/proto/src/teaclave_frontend_service.rs
index 123371d..8878eb6 100644
--- a/services/proto/src/teaclave_frontend_service.rs
+++ b/services/proto/src/teaclave_frontend_service.rs
@@ -10,7 +10,8 @@ use std::collections::{HashMap, HashSet};
 use std::prelude::v1::*;
 use teaclave_rpc::into_request;
 use teaclave_types::{
-    DataOwnerList, FunctionInput, FunctionOutput, TaskStatus, TeaclaveFileCryptoInfo,
+    DataOwnerList, FunctionArguments, FunctionInput, FunctionOutput, TaskStatus,
+    TeaclaveFileCryptoInfo,
 };
 use url::Url;
 
@@ -264,7 +265,7 @@ pub struct GetFunctionResponse {
 #[derive(Debug)]
 pub struct CreateTaskRequest {
     pub function_id: String,
-    pub arg_list: HashMap<String, String>,
+    pub function_arguments: FunctionArguments,
     pub input_data_owner_list: HashMap<String, DataOwnerList>,
     pub output_data_owner_list: HashMap<String, DataOwnerList>,
 }
@@ -305,7 +306,7 @@ pub struct GetTaskResponse {
     pub creator: String,
     pub function_id: String,
     pub function_owner: String,
-    pub arg_list: HashMap<String, String>,
+    pub function_arguments: FunctionArguments,
     pub input_data_owner_list: HashMap<String, DataOwnerList>,
     pub output_data_owner_list: HashMap<String, DataOwnerList>,
     pub participants: HashSet<String>,
@@ -845,36 +846,16 @@ pub fn data_owner_list_to_proto<S: std::hash::BuildHasher>(
     ret
 }
 
-fn arg_list_from_proto(vector: Vec<proto::Argument>) -> Result<HashMap<String, String>> {
-    let mut ret = HashMap::with_capacity(vector.len());
-    for item in vector.into_iter() {
-        ret.insert(item.arg_name, item.arg_value);
-    }
-    Ok(ret)
-}
-
-fn arg_list_to_proto(map: HashMap<String, String>) -> Vec<proto::Argument> {
-    let mut ret = Vec::with_capacity(map.len());
-    for (arg_name, arg_value) in map.into_iter() {
-        let argument = proto::Argument {
-            arg_name,
-            arg_value,
-        };
-        ret.push(argument);
-    }
-    ret
-}
-
 impl std::convert::TryFrom<proto::CreateTaskRequest> for CreateTaskRequest {
     type Error = Error;
 
     fn try_from(proto: proto::CreateTaskRequest) -> Result<Self> {
-        let arg_list = arg_list_from_proto(proto.arg_list)?;
+        let function_arguments = proto.function_arguments.into();
         let input_data_owner_list = data_owner_list_from_proto(proto.input_data_owner_list)?;
         let output_data_owner_list = data_owner_list_from_proto(proto.output_data_owner_list)?;
         let ret = Self {
             function_id: proto.function_id,
-            arg_list,
+            function_arguments,
             input_data_owner_list,
             output_data_owner_list,
         };
@@ -884,13 +865,13 @@ impl std::convert::TryFrom<proto::CreateTaskRequest> for CreateTaskRequest {
 
 impl From<CreateTaskRequest> for proto::CreateTaskRequest {
     fn from(request: CreateTaskRequest) -> Self {
-        let arg_list = arg_list_to_proto(request.arg_list);
+        let function_arguments = request.function_arguments.into();
         let input_data_owner_list = data_owner_list_to_proto(request.input_data_owner_list);
         let output_data_owner_list = data_owner_list_to_proto(request.output_data_owner_list);
 
         Self {
             function_id: request.function_id,
-            arg_list,
+            function_arguments,
             input_data_owner_list,
             output_data_owner_list,
         }
@@ -958,7 +939,7 @@ impl std::convert::TryFrom<proto::GetTaskResponse> for GetTaskResponse {
     type Error = Error;
 
     fn try_from(proto: proto::GetTaskResponse) -> Result<Self> {
-        let arg_list = arg_list_from_proto(proto.arg_list)?;
+        let function_arguments = proto.function_arguments.into();
         let input_data_owner_list = data_owner_list_from_proto(proto.input_data_owner_list)?;
         let output_data_owner_list = data_owner_list_from_proto(proto.output_data_owner_list)?;
         let input_map = data_map_from_proto(proto.input_map)?;
@@ -970,7 +951,7 @@ impl std::convert::TryFrom<proto::GetTaskResponse> for GetTaskResponse {
             creator: proto.creator,
             function_id: proto.function_id,
             function_owner: proto.function_owner,
-            arg_list,
+            function_arguments,
             input_data_owner_list,
             output_data_owner_list,
             participants: proto.participants.into_iter().collect(),
@@ -986,7 +967,7 @@ impl std::convert::TryFrom<proto::GetTaskResponse> for GetTaskResponse {
 
 impl From<GetTaskResponse> for proto::GetTaskResponse {
     fn from(response: GetTaskResponse) -> Self {
-        let arg_list = arg_list_to_proto(response.arg_list);
+        let function_arguments = response.function_arguments.into();
         let input_data_owner_list = data_owner_list_to_proto(response.input_data_owner_list);
         let output_data_owner_list = data_owner_list_to_proto(response.output_data_owner_list);
         let input_map = data_map_to_proto(response.input_map);
@@ -997,7 +978,7 @@ impl From<GetTaskResponse> for proto::GetTaskResponse {
             creator: response.creator,
             function_id: response.function_id,
             function_owner: response.function_owner,
-            arg_list,
+            function_arguments,
             input_data_owner_list,
             output_data_owner_list,
             participants: response.participants.into_iter().collect(),
diff --git a/tests/functional/enclave/src/teaclave_frontend_service.rs b/tests/functional/enclave/src/teaclave_frontend_service.rs
index b670133..5982981 100644
--- a/tests/functional/enclave/src/teaclave_frontend_service.rs
+++ b/tests/functional/enclave/src/teaclave_frontend_service.rs
@@ -276,11 +276,10 @@ fn test_create_task() {
     let function_id = "function-00000000-0000-0000-0000-000000000002";
     let mut output_data_owner_list = HashMap::new();
     output_data_owner_list.insert("output".to_string(), data_owner_id_list);
+    let function_arguments = FunctionArguments::new(hashmap!("arg1" => "data1"));
     let request = CreateTaskRequest {
         function_id: function_id.to_string(),
-        arg_list: vec![("arg1".to_string(), "data1".to_string())]
-            .into_iter()
-            .collect(),
+        function_arguments,
         input_data_owner_list: HashMap::new(),
         output_data_owner_list: output_data_owner_list.clone(),
     };
@@ -288,11 +287,10 @@ fn test_create_task() {
     assert!(response.is_ok());
     assert!(!response.unwrap().task_id.is_empty());
 
+    let function_arguments = FunctionArguments::new(hashmap!("arg1" => "data1"));
     let request = CreateTaskRequest {
         function_id: function_id.to_string(),
-        arg_list: vec![("arg1".to_string(), "data1".to_string())]
-            .into_iter()
-            .collect(),
+        function_arguments,
         input_data_owner_list: HashMap::new(),
         output_data_owner_list,
     };
@@ -313,11 +311,10 @@ fn test_get_task() {
     };
     let mut output_data_owner_list = HashMap::new();
     output_data_owner_list.insert("output".to_string(), data_owner_id_list);
+    let function_arguments = FunctionArguments::new(hashmap!("arg1" => "data1"));
     let request = CreateTaskRequest {
         function_id: "function-00000000-0000-0000-0000-000000000002".to_string(),
-        arg_list: vec![("arg1".to_string(), "data1".to_string())]
-            .into_iter()
-            .collect(),
+        function_arguments,
         input_data_owner_list: HashMap::new(),
         output_data_owner_list,
     };
@@ -345,11 +342,10 @@ fn test_assign_data() {
     };
     let mut output_data_owner_list = HashMap::new();
     output_data_owner_list.insert("output".to_string(), data_owner_id_list);
+    let function_arguments = FunctionArguments::new(hashmap!("arg1" => "data1"));
     let request = CreateTaskRequest {
         function_id: "function-00000000-0000-0000-0000-000000000002".to_string(),
-        arg_list: vec![("arg1".to_string(), "data1".to_string())]
-            .into_iter()
-            .collect(),
+        function_arguments,
         input_data_owner_list: HashMap::new(),
         output_data_owner_list,
     };
@@ -399,11 +395,10 @@ fn test_approve_task() {
     };
     let mut output_data_owner_list = HashMap::new();
     output_data_owner_list.insert("output".to_string(), data_owner_id_list);
+    let function_arguments = FunctionArguments::new(hashmap!("arg1" => "data1"));
     let request = CreateTaskRequest {
         function_id: "function-00000000-0000-0000-0000-000000000002".to_string(),
-        arg_list: vec![("arg1".to_string(), "data1".to_string())]
-            .into_iter()
-            .collect(),
+        function_arguments,
         input_data_owner_list: HashMap::new(),
         output_data_owner_list,
     };
@@ -450,11 +445,10 @@ fn test_invoke_task() {
     };
     let mut output_data_owner_list = HashMap::new();
     output_data_owner_list.insert("output".to_string(), data_owner_id_list);
+    let function_arguments = FunctionArguments::new(hashmap!("arg1" => "data1"));
     let request = CreateTaskRequest {
         function_id: "function-00000000-0000-0000-0000-000000000002".to_string(),
-        arg_list: vec![("arg1".to_string(), "data1".to_string())]
-            .into_iter()
-            .collect(),
+        function_arguments,
         input_data_owner_list: HashMap::new(),
         output_data_owner_list,
     };
diff --git a/tests/functional/enclave/src/teaclave_management_service.rs b/tests/functional/enclave/src/teaclave_management_service.rs
index d802df1..c97fc75 100644
--- a/tests/functional/enclave/src/teaclave_management_service.rs
+++ b/tests/functional/enclave/src/teaclave_management_service.rs
@@ -220,9 +220,10 @@ fn test_get_function() {
 }
 
 fn get_correct_create_task() -> CreateTaskRequest {
-    let mut arg_list = HashMap::new();
-    arg_list.insert("arg1".to_string(), "data1".to_string());
-    arg_list.insert("arg2".to_string(), "data2".to_string());
+    let function_arguments = FunctionArguments::new(hashmap!(
+        "arg1" => "data1",
+        "arg2" => "data2",
+    ));
     let data_owner_id_list = DataOwnerList {
         user_id_list: vec!["mock_user1".to_string()].into_iter().collect(),
     };
@@ -240,7 +241,7 @@ fn get_correct_create_task() -> CreateTaskRequest {
 
     CreateTaskRequest {
         function_id: "function-00000000-0000-0000-0000-000000000001".to_string(),
-        arg_list,
+        function_arguments,
         input_data_owner_list,
         output_data_owner_list,
     }
@@ -249,7 +250,7 @@ fn get_correct_create_task() -> CreateTaskRequest {
 fn test_create_task() {
     let request = CreateTaskRequest {
         function_id: "invalid_function".to_string(),
-        arg_list: HashMap::new(),
+        function_arguments: HashMap::new().into(),
         input_data_owner_list: HashMap::new(),
         output_data_owner_list: HashMap::new(),
     };
@@ -262,7 +263,7 @@ fn test_create_task() {
     assert!(response.is_ok());
 
     let mut request = get_correct_create_task();
-    request.arg_list.remove("arg1");
+    request.function_arguments.inner_mut().remove("arg1");
     let response = client.create_task(request);
     assert!(response.is_err());
 
diff --git a/tests/integration/enclave/src/teaclave_worker.rs b/tests/integration/enclave/src/teaclave_worker.rs
index 7d2feb4..9956587 100644
--- a/tests/integration/enclave/src/teaclave_worker.rs
+++ b/tests/integration/enclave/src/teaclave_worker.rs
@@ -7,7 +7,7 @@ use teaclave_types::{
 use teaclave_worker::Worker;
 
 fn test_start_worker() {
-    let arguments = FunctionArguments::from_map(&hashmap!(
+    let arguments = FunctionArguments::new(hashmap!(
         "feature_size"  => "4",
         "max_depth"     => "4",
         "iterations"    => "100",
@@ -26,12 +26,12 @@ fn test_start_worker() {
     let input_info = StagedInputFile::create_with_plaintext_file(plain_input).unwrap();
 
     let input_files = StagedFiles::new(hashmap!(
-        "training_data".to_string() => input_info));
+        "training_data" => input_info));
 
     let output_info = StagedOutputFile::new(enc_output, TeaclaveFileRootKey128::random());
 
     let output_files = StagedFiles::new(hashmap!(
-        "trained_model".to_string() => output_info.clone()));
+        "trained_model" => output_info.clone()));
 
     let staged_function = StagedFunction::new()
         .name("gbdt_training")
diff --git a/types/src/macros.rs b/types/src/macros.rs
index 34e0ab0..db59a38 100644
--- a/types/src/macros.rs
+++ b/types/src/macros.rs
@@ -3,7 +3,7 @@ macro_rules! hashmap {
     ($( $key: expr => $value: expr,)+) => { hashmap!($($key => $value),+) };
     ($( $key: expr => $value: expr ),*) => {{
         let mut map = ::std::collections::HashMap::new();
-        $( map.insert($key, $value); )*
+        $( map.insert($key.into(), $value.into()); )*
             map
     }}
 }
diff --git a/types/src/staged_function.rs b/types/src/staged_function.rs
index cff442c..8048e14 100644
--- a/types/src/staged_function.rs
+++ b/types/src/staged_function.rs
@@ -12,6 +12,30 @@ pub struct ArgumentValue {
     inner: String,
 }
 
+impl From<String> for ArgumentValue {
+    fn from(value: String) -> Self {
+        ArgumentValue::new(value)
+    }
+}
+
+impl From<&str> for ArgumentValue {
+    fn from(value: &str) -> Self {
+        ArgumentValue::new(value.into())
+    }
+}
+
+impl From<&String> for ArgumentValue {
+    fn from(value: &String) -> Self {
+        ArgumentValue::new(value.into())
+    }
+}
+
+impl From<ArgumentValue> for String {
+    fn from(value: ArgumentValue) -> Self {
+        value.as_str().to_owned()
+    }
+}
+
 impl ArgumentValue {
     pub fn new(value: String) -> Self {
         Self { inner: value }
@@ -72,28 +96,28 @@ impl<S: core::default::Default + std::hash::BuildHasher> From<FunctionArguments>
 
 impl From<HashMap<String, String>> for FunctionArguments {
     fn from(map: HashMap<String, String>) -> Self {
-        FunctionArguments::from_map(&map)
-    }
-}
-
-impl FunctionArguments {
-    pub fn from_map<K, V>(input: &HashMap<K, V>) -> Self
-    where
-        K: std::string::ToString,
-        V: std::string::ToString,
-    {
-        let inner = input.iter().fold(HashMap::new(), |mut acc, (k, v)| {
-            acc.insert(k.to_string(), ArgumentValue::new(v.to_string()));
+        let inner = map.iter().fold(HashMap::new(), |mut acc, (k, v)| {
+            acc.insert(k.into(), v.into());
             acc
         });
 
         Self { inner }
     }
+}
+
+impl FunctionArguments {
+    pub fn new(map: HashMap<String, ArgumentValue>) -> Self {
+        Self { inner: map }
+    }
 
     pub fn inner(&self) -> &HashMap<String, ArgumentValue> {
         &self.inner
     }
 
+    pub fn inner_mut(&mut self) -> &mut HashMap<String, ArgumentValue> {
+        &mut self.inner
+    }
+
     pub fn get(&self, key: &str) -> anyhow::Result<&ArgumentValue> {
         self.inner
             .get(key)
diff --git a/worker/src/function/echo.rs b/worker/src/function/echo.rs
index a98ee16..5d46bb2 100644
--- a/worker/src/function/echo.rs
+++ b/worker/src/function/echo.rs
@@ -54,7 +54,7 @@ pub mod tests {
     }
 
     fn test_echo() {
-        let func_args = FunctionArguments::from_map(&hashmap!(
+        let func_args = FunctionArguments::new(hashmap!(
             "message"  => "Hello Teaclave!"
         ));
 
diff --git a/worker/src/function/gbdt_training.rs b/worker/src/function/gbdt_training.rs
index df45c6f..5287435 100644
--- a/worker/src/function/gbdt_training.rs
+++ b/worker/src/function/gbdt_training.rs
@@ -150,7 +150,7 @@ pub mod tests {
     }
 
     fn test_gbdt_training() {
-        let func_arguments = FunctionArguments::from_map(&hashmap!(
+        let func_arguments = FunctionArguments::new(hashmap!(
             "feature_size"  => "4",
             "max_depth"     => "4",
             "iterations"    => "100",
diff --git a/worker/src/function/mesapy.rs b/worker/src/function/mesapy.rs
index b1d4828..2ba6a1a 100644
--- a/worker/src/function/mesapy.rs
+++ b/worker/src/function/mesapy.rs
@@ -119,7 +119,7 @@ pub mod tests {
     }
 
     fn test_mesapy() {
-        let py_args = FunctionArguments::from_map(&hashmap!("--name" => "Teaclave"));
+        let py_args = FunctionArguments::new(hashmap!("--name" => "Teaclave"));
         let py_payload = r#"
 def entrypoint(argv):
     in_file_id = "in_f1"
@@ -157,8 +157,8 @@ def entrypoint(argv):
         teaclave_open("invalid_key", "wb")
     except RuntimeError as e:
         assert e.message == "fileio_init: teaclave_ffi_error"
-    
-    # open invalid option    
+
+    # open invalid option
     try:
         teaclave_open(out_file_id, "w")
     except RuntimeError as e:
@@ -181,9 +181,9 @@ def entrypoint(argv):
         };
         let runtime = Box::new(RawIoRuntime::new(input_files, output_files));
 
-        let func_args = FunctionArguments::from_map(&hashmap!(
-                "py_payload".to_string() => py_payload.to_string(),
-                "py_args".to_string() => serde_json::to_string(&py_args).unwrap()
+        let func_args = FunctionArguments::new(hashmap!(
+                "py_payload" => py_payload.to_string(),
+                "py_args" => serde_json::to_string(&py_args).unwrap()
         ));
 
         let function = Mesapy;
diff --git a/worker/src/worker.rs b/worker/src/worker.rs
index bbcdf68..6166778 100644
--- a/worker/src/worker.rs
+++ b/worker/src/worker.rs
@@ -25,7 +25,7 @@ use anyhow;
 use serde_json;
 
 use teaclave_types::{
-    ExecutorType, FunctionArguments, StagedFiles, StagedFunction, StagedInputFile,
+    hashmap, ExecutorType, FunctionArguments, StagedFiles, StagedFunction, StagedInputFile,
     StagedOutputFile, WorkerCapability,
 };
 
@@ -162,11 +162,12 @@ fn prepare_arguments(
                 !function_payload.is_empty(),
                 "Python function payload must not be empty!"
             );
-            let mut wrap_args = HashMap::new();
             let req_args = serde_json::to_string(&function_arguments)?;
-            wrap_args.insert("py_payload".to_string(), function_payload);
-            wrap_args.insert("py_args".to_string(), req_args);
-            FunctionArguments::from_map(&wrap_args)
+            let wrap_args = hashmap!(
+                "py_payload" => function_payload,
+                "py_args" => req_args,
+            );
+            FunctionArguments::new(wrap_args)
         }
     };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 03/03: Add Apache License in header

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 4275aceaabb47f54b8caa3e4ddaa6b8958d6333a
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Sun Mar 22 16:39:57 2020 -0700

    Add Apache License in header
---
 attestation/src/attestation.rs                          | 17 +++++++++++++++++
 attestation/src/platform.rs                             | 17 +++++++++++++++++
 binder/src/ipc/mod.rs                                   | 17 +++++++++++++++++
 config/build.rs                                         | 17 +++++++++++++++++
 config/config_gen/main.rs                               | 17 +++++++++++++++++
 config/src/build.rs                                     | 17 +++++++++++++++++
 config/src/lib.rs                                       | 17 +++++++++++++++++
 config/src/runtime.rs                                   | 17 +++++++++++++++++
 dcap/src/main.rs                                        | 17 +++++++++++++++++
 rpc/proc_macro/src/lib.rs                               | 17 +++++++++++++++++
 rpc/src/channel.rs                                      | 17 +++++++++++++++++
 rpc/src/config.rs                                       | 17 +++++++++++++++++
 rpc/src/endpoint.rs                                     | 17 +++++++++++++++++
 rpc/src/lib.rs                                          | 17 +++++++++++++++++
 rpc/src/protocol.rs                                     | 17 +++++++++++++++++
 rpc/src/request.rs                                      | 17 +++++++++++++++++
 rpc/src/server.rs                                       | 17 +++++++++++++++++
 rpc/src/transport.rs                                    | 17 +++++++++++++++++
 rpc/src/utils.rs                                        | 17 +++++++++++++++++
 services/access_control/enclave/src/acs.rs              | 17 +++++++++++++++++
 services/access_control/enclave/src/service.rs          | 17 +++++++++++++++++
 services/authentication/enclave/src/api_service.rs      | 17 +++++++++++++++++
 services/authentication/enclave/src/internal_service.rs | 17 +++++++++++++++++
 services/frontend/enclave/src/service.rs                | 17 +++++++++++++++++
 services/management/enclave/src/service.rs              | 17 +++++++++++++++++
 services/proto/src/teaclave_access_control_service.rs   | 17 +++++++++++++++++
 services/proto/src/teaclave_authentication_service.rs   | 17 +++++++++++++++++
 services/proto/src/teaclave_common.rs                   | 17 +++++++++++++++++
 services/proto/src/teaclave_frontend_service.rs         | 17 +++++++++++++++++
 services/proto/src/teaclave_management_service.rs       | 17 +++++++++++++++++
 services/proto/src/teaclave_scheduler_service.rs        | 17 +++++++++++++++++
 services/proto/src/teaclave_storage_service.rs          | 17 +++++++++++++++++
 services/storage/enclave/src/proxy.rs                   | 17 +++++++++++++++++
 services/storage/enclave/src/service.rs                 | 17 +++++++++++++++++
 .../enclave/src/teaclave_access_control_service.rs      | 17 +++++++++++++++++
 .../enclave/src/teaclave_authentication_service.rs      | 17 +++++++++++++++++
 .../functional/enclave/src/teaclave_frontend_service.rs | 17 +++++++++++++++++
 .../enclave/src/teaclave_management_service.rs          | 17 +++++++++++++++++
 .../enclave/src/teaclave_scheduler_service.rs           | 17 +++++++++++++++++
 .../functional/enclave/src/teaclave_storage_service.rs  | 17 +++++++++++++++++
 tests/integration/app/src/teaclave_config_tests.rs      | 17 +++++++++++++++++
 tests/integration/enclave/src/rusty_leveldb_sgx.rs      | 17 +++++++++++++++++
 tests/integration/enclave/src/teaclave_rpc.rs           | 17 +++++++++++++++++
 tests/integration/enclave/src/teaclave_worker.rs        | 17 +++++++++++++++++
 tests/utils/src/lib.rs                                  | 17 +++++++++++++++++
 types/src/crypto.rs                                     | 17 +++++++++++++++++
 types/src/file_agent.rs                                 | 17 +++++++++++++++++
 types/src/lib.rs                                        | 17 +++++++++++++++++
 types/src/macros.rs                                     | 17 +++++++++++++++++
 types/src/staged_file.rs                                | 17 +++++++++++++++++
 types/src/staged_function.rs                            | 17 +++++++++++++++++
 types/src/staged_task.rs                                | 17 +++++++++++++++++
 types/src/storage.rs                                    | 17 +++++++++++++++++
 types/src/task.rs                                       | 17 +++++++++++++++++
 types/src/worker.rs                                     | 17 +++++++++++++++++
 utils/service_app_utils/src/lib.rs                      | 17 +++++++++++++++++
 utils/service_enclave_utils/proc_macro/src/lib.rs       | 17 +++++++++++++++++
 utils/service_enclave_utils/src/lib.rs                  | 17 +++++++++++++++++
 worker/src/function/context.rs                          | 17 +++++++++++++++++
 59 files changed, 1003 insertions(+)

diff --git a/attestation/src/attestation.rs b/attestation/src/attestation.rs
index 881c7ab..9805f0c 100644
--- a/attestation/src/attestation.rs
+++ b/attestation/src/attestation.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::key;
 use crate::AttestationConfig;
 use crate::AttestedTlsConfig;
diff --git a/attestation/src/platform.rs b/attestation/src/platform.rs
index 2bac1ec..5357916 100644
--- a/attestation/src/platform.rs
+++ b/attestation/src/platform.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::AttestationError;
 use anyhow::{ensure, Result};
 use log::debug;
diff --git a/binder/src/ipc/mod.rs b/binder/src/ipc/mod.rs
index 2669acc..1662216 100644
--- a/binder/src/ipc/mod.rs
+++ b/binder/src/ipc/mod.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use serde::{Deserialize, Serialize};
 use std::prelude::v1::*;
 
diff --git a/config/build.rs b/config/build.rs
index a7c30c7..31ed439 100644
--- a/config/build.rs
+++ b/config/build.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::env;
 use std::path::Path;
 use std::process::Command;
diff --git a/config/config_gen/main.rs b/config/config_gen/main.rs
index 35b024b..69c359e 100644
--- a/config/config_gen/main.rs
+++ b/config/config_gen/main.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use askama;
 use askama::Template;
 use serde::{Deserialize, Serialize};
diff --git a/config/src/build.rs b/config/src/build.rs
index 517b0af..5866042 100644
--- a/config/src/build.rs
+++ b/config/src/build.rs
@@ -1,2 +1,19 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![allow(clippy::all)]
 include!(concat!(env!("OUT_DIR"), "/build_config.rs"));
diff --git a/config/src/lib.rs b/config/src/lib.rs
index 4acca84..1ca24e2 100644
--- a/config/src/lib.rs
+++ b/config/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![cfg_attr(feature = "mesalock_sgx", no_std)]
 #[cfg(feature = "mesalock_sgx")]
 #[macro_use]
diff --git a/config/src/runtime.rs b/config/src/runtime.rs
index d03f44d..1b6a960 100644
--- a/config/src/runtime.rs
+++ b/config/src/runtime.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::ConfigSource;
 #[cfg(not(feature = "mesalock_sgx"))]
 use std::fs;
diff --git a/dcap/src/main.rs b/dcap/src/main.rs
index 4293e56..ad58686 100644
--- a/dcap/src/main.rs
+++ b/dcap/src/main.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![feature(proc_macro_hygiene, decl_macro)]
 
 #[macro_use]
diff --git a/rpc/proc_macro/src/lib.rs b/rpc/proc_macro/src/lib.rs
index 5afd210..ef2522b 100644
--- a/rpc/proc_macro/src/lib.rs
+++ b/rpc/proc_macro/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 extern crate proc_macro;
 use proc_macro2::{Ident, Span};
 use quote::quote;
diff --git a/rpc/src/channel.rs b/rpc/src/channel.rs
index ffce1c5..63a18ef 100644
--- a/rpc/src/channel.rs
+++ b/rpc/src/channel.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::config::SgxTrustedTlsClientConfig;
 use crate::transport::{ClientTransport, SgxTrustedTlsTransport};
 use crate::Request;
diff --git a/rpc/src/config.rs b/rpc/src/config.rs
index cfdb4fb..55b0d50 100644
--- a/rpc/src/config.rs
+++ b/rpc/src/config.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::{anyhow, bail, Result};
 use log::debug;
 use rustls;
diff --git a/rpc/src/endpoint.rs b/rpc/src/endpoint.rs
index a24d40c..85f839f 100644
--- a/rpc/src/endpoint.rs
+++ b/rpc/src/endpoint.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::channel::SgxTrustedTlsChannel;
 use crate::config::SgxTrustedTlsClientConfig;
 use anyhow::Result;
diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs
index 7a403c5..c1fc0c5 100644
--- a/rpc/src/lib.rs
+++ b/rpc/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![cfg_attr(feature = "mesalock_sgx", no_std)]
 #[cfg(feature = "mesalock_sgx")]
 #[macro_use]
diff --git a/rpc/src/protocol.rs b/rpc/src/protocol.rs
index eb1018c..f0a35d5 100644
--- a/rpc/src/protocol.rs
+++ b/rpc/src/protocol.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use log::debug;
 use serde::{Deserialize, Serialize};
 use serde_json;
diff --git a/rpc/src/request.rs b/rpc/src/request.rs
index 3b71c32..242b8f3 100644
--- a/rpc/src/request.rs
+++ b/rpc/src/request.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use serde::{Deserialize, Serialize};
 use std::collections::HashMap;
 use std::prelude::v1::*;
diff --git a/rpc/src/server.rs b/rpc/src/server.rs
index 01eb835..0e863d9 100644
--- a/rpc/src/server.rs
+++ b/rpc/src/server.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::config::SgxTrustedTlsServerConfig;
 use crate::transport::{ServerTransport, SgxTrustedTlsTransport};
 use crate::utils;
diff --git a/rpc/src/transport.rs b/rpc/src/transport.rs
index cb88534..a7ca98a 100644
--- a/rpc/src/transport.rs
+++ b/rpc/src/transport.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::protocol;
 use crate::Request;
 use crate::TeaclaveService;
diff --git a/rpc/src/utils.rs b/rpc/src/utils.rs
index 5ea1822..e9fa6ef 100644
--- a/rpc/src/utils.rs
+++ b/rpc/src/utils.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 pub(crate) fn get_tcs_num() -> usize {
     if sgx_trts::enclave::rsgx_is_supported_EDMM() {
         sgx_trts::enclave::SgxGlobalData::new().get_dyn_tcs_num() as usize
diff --git a/services/access_control/enclave/src/acs.rs b/services/access_control/enclave/src/acs.rs
index 7f8f753..cbcdc95 100644
--- a/services/access_control/enclave/src/acs.rs
+++ b/services/access_control/enclave/src/acs.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::{anyhow, Result};
 use cfg_if::cfg_if;
 use std::collections::HashSet;
diff --git a/services/access_control/enclave/src/service.rs b/services/access_control/enclave/src/service.rs
index 72e4f6e..8f27532 100644
--- a/services/access_control/enclave/src/service.rs
+++ b/services/access_control/enclave/src/service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::acs::{AccessControlModule, EnforceRequest};
 use std::prelude::v1::*;
 use teaclave_proto::teaclave_access_control_service::{
diff --git a/services/authentication/enclave/src/api_service.rs b/services/authentication/enclave/src/api_service.rs
index bd0bd2a..3dd8cfb 100644
--- a/services/authentication/enclave/src/api_service.rs
+++ b/services/authentication/enclave/src/api_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::user_db::{DbClient, DbError};
 use crate::user_info::UserInfo;
 use std::prelude::v1::*;
diff --git a/services/authentication/enclave/src/internal_service.rs b/services/authentication/enclave/src/internal_service.rs
index c95589d..ef10949 100644
--- a/services/authentication/enclave/src/internal_service.rs
+++ b/services/authentication/enclave/src/internal_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::user_db::DbClient;
 use crate::user_info::UserInfo;
 use std::prelude::v1::*;
diff --git a/services/frontend/enclave/src/service.rs b/services/frontend/enclave/src/service.rs
index dea5f81..f31d817 100644
--- a/services/frontend/enclave/src/service.rs
+++ b/services/frontend/enclave/src/service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::Result;
 use std::prelude::v1::*;
 use std::sync::{Arc, SgxMutex as Mutex};
diff --git a/services/management/enclave/src/service.rs b/services/management/enclave/src/service.rs
index 3c527f1..ee490a0 100644
--- a/services/management/enclave/src/service.rs
+++ b/services/management/enclave/src/service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::task::{
     assign_input_to_task, assign_output_to_task, try_update_task_to_approved_status,
     try_update_task_to_ready_status,
diff --git a/services/proto/src/teaclave_access_control_service.rs b/services/proto/src/teaclave_access_control_service.rs
index 95b9b1e..5a5cc2e 100644
--- a/services/proto/src/teaclave_access_control_service.rs
+++ b/services/proto/src/teaclave_access_control_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::teaclave_access_control_service_proto as proto;
 use anyhow::{Error, Result};
 use std::prelude::v1::*;
diff --git a/services/proto/src/teaclave_authentication_service.rs b/services/proto/src/teaclave_authentication_service.rs
index 5ec220a..c843f22 100644
--- a/services/proto/src/teaclave_authentication_service.rs
+++ b/services/proto/src/teaclave_authentication_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::anyhow;
 use anyhow::{Error, Result};
 use core::convert::TryInto;
diff --git a/services/proto/src/teaclave_common.rs b/services/proto/src/teaclave_common.rs
index 4126579..7686ccb 100644
--- a/services/proto/src/teaclave_common.rs
+++ b/services/proto/src/teaclave_common.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #[cfg(feature = "mesalock_sgx")]
 use std::prelude::v1::*;
 
diff --git a/services/proto/src/teaclave_frontend_service.rs b/services/proto/src/teaclave_frontend_service.rs
index 8878eb6..1aaf245 100644
--- a/services/proto/src/teaclave_frontend_service.rs
+++ b/services/proto/src/teaclave_frontend_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::teaclave_common::{i32_from_task_status, i32_to_task_status};
 use crate::teaclave_frontend_service_proto as proto;
 use crate::teaclave_management_service::TeaclaveManagementRequest;
diff --git a/services/proto/src/teaclave_management_service.rs b/services/proto/src/teaclave_management_service.rs
index 55edd23..67908ed 100644
--- a/services/proto/src/teaclave_management_service.rs
+++ b/services/proto/src/teaclave_management_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::teaclave_management_service_proto as proto;
 
 pub use proto::TeaclaveManagement;
diff --git a/services/proto/src/teaclave_scheduler_service.rs b/services/proto/src/teaclave_scheduler_service.rs
index f298444..a2f42d5 100644
--- a/services/proto/src/teaclave_scheduler_service.rs
+++ b/services/proto/src/teaclave_scheduler_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![allow(unused_imports)]
 #![allow(unused_variables)]
 
diff --git a/services/proto/src/teaclave_storage_service.rs b/services/proto/src/teaclave_storage_service.rs
index ebcbb72..c89ef85 100644
--- a/services/proto/src/teaclave_storage_service.rs
+++ b/services/proto/src/teaclave_storage_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::{Error, Result};
 use std::prelude::v1::*;
 
diff --git a/services/storage/enclave/src/proxy.rs b/services/storage/enclave/src/proxy.rs
index 085327f..2466d42 100644
--- a/services/storage/enclave/src/proxy.rs
+++ b/services/storage/enclave/src/proxy.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::service::TeaclaveStorageError;
 use std::prelude::v1::*;
 use std::sync::mpsc::{channel, Sender};
diff --git a/services/storage/enclave/src/service.rs b/services/storage/enclave/src/service.rs
index 1a95ff5..7227339 100644
--- a/services/storage/enclave/src/service.rs
+++ b/services/storage/enclave/src/service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::proxy::ProxyRequest;
 use rusty_leveldb::DB;
 use std::cell::RefCell;
diff --git a/tests/functional/enclave/src/teaclave_access_control_service.rs b/tests/functional/enclave/src/teaclave_access_control_service.rs
index 67bf78d..23888c4 100644
--- a/tests/functional/enclave/src/teaclave_access_control_service.rs
+++ b/tests/functional/enclave/src/teaclave_access_control_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::prelude::v1::*;
 use teaclave_attestation::verifier;
 use teaclave_config::RuntimeConfig;
diff --git a/tests/functional/enclave/src/teaclave_authentication_service.rs b/tests/functional/enclave/src/teaclave_authentication_service.rs
index 53a72a1..2f5d27c 100644
--- a/tests/functional/enclave/src/teaclave_authentication_service.rs
+++ b/tests/functional/enclave/src/teaclave_authentication_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::prelude::v1::*;
 use teaclave_attestation::verifier;
 use teaclave_config::RuntimeConfig;
diff --git a/tests/functional/enclave/src/teaclave_frontend_service.rs b/tests/functional/enclave/src/teaclave_frontend_service.rs
index 5982981..c270e12 100644
--- a/tests/functional/enclave/src/teaclave_frontend_service.rs
+++ b/tests/functional/enclave/src/teaclave_frontend_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::collections::HashMap;
 use std::prelude::v1::*;
 use teaclave_attestation::verifier;
diff --git a/tests/functional/enclave/src/teaclave_management_service.rs b/tests/functional/enclave/src/teaclave_management_service.rs
index c97fc75..c3aec68 100644
--- a/tests/functional/enclave/src/teaclave_management_service.rs
+++ b/tests/functional/enclave/src/teaclave_management_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::collections::HashMap;
 use std::prelude::v1::*;
 use teaclave_attestation::verifier;
diff --git a/tests/functional/enclave/src/teaclave_scheduler_service.rs b/tests/functional/enclave/src/teaclave_scheduler_service.rs
index 7a6caa1..099fb1a 100644
--- a/tests/functional/enclave/src/teaclave_scheduler_service.rs
+++ b/tests/functional/enclave/src/teaclave_scheduler_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::collections::HashMap;
 use std::prelude::v1::*;
 use teaclave_attestation::verifier;
diff --git a/tests/functional/enclave/src/teaclave_storage_service.rs b/tests/functional/enclave/src/teaclave_storage_service.rs
index e8b39b2..6a7aa85 100644
--- a/tests/functional/enclave/src/teaclave_storage_service.rs
+++ b/tests/functional/enclave/src/teaclave_storage_service.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::prelude::v1::*;
 use teaclave_config::RuntimeConfig;
 use teaclave_proto::teaclave_storage_service::*;
diff --git a/tests/integration/app/src/teaclave_config_tests.rs b/tests/integration/app/src/teaclave_config_tests.rs
index deb175d..a7b5051 100644
--- a/tests/integration/app/src/teaclave_config_tests.rs
+++ b/tests/integration/app/src/teaclave_config_tests.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::env;
 use teaclave_config;
 
diff --git a/tests/integration/enclave/src/rusty_leveldb_sgx.rs b/tests/integration/enclave/src/rusty_leveldb_sgx.rs
index d407550..edcf237 100644
--- a/tests/integration/enclave/src/rusty_leveldb_sgx.rs
+++ b/tests/integration/enclave/src/rusty_leveldb_sgx.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use rand::distributions::Alphanumeric;
 use rand::Rng;
 use std::iter;
diff --git a/tests/integration/enclave/src/teaclave_rpc.rs b/tests/integration/enclave/src/teaclave_rpc.rs
index fea8637..609e65c 100644
--- a/tests/integration/enclave/src/teaclave_rpc.rs
+++ b/tests/integration/enclave/src/teaclave_rpc.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::Result;
 use rustls::internal::pemfile;
 use serde::{Deserialize, Serialize};
diff --git a/tests/integration/enclave/src/teaclave_worker.rs b/tests/integration/enclave/src/teaclave_worker.rs
index 9956587..4b1229e 100644
--- a/tests/integration/enclave/src/teaclave_worker.rs
+++ b/tests/integration/enclave/src/teaclave_worker.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::prelude::v1::*;
 
 use teaclave_types::{
diff --git a/tests/utils/src/lib.rs b/tests/utils/src/lib.rs
index c5ce8ee..1d4741e 100644
--- a/tests/utils/src/lib.rs
+++ b/tests/utils/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![cfg_attr(feature = "mesalock_sgx", no_std)]
 #[cfg(feature = "mesalock_sgx")]
 #[macro_use]
diff --git a/types/src/crypto.rs b/types/src/crypto.rs
index 04c2da1..b37c0cd 100644
--- a/types/src/crypto.rs
+++ b/types/src/crypto.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #[cfg(feature = "mesalock_sgx")]
 use std::prelude::v1::*;
 
diff --git a/types/src/file_agent.rs b/types/src/file_agent.rs
index 042fbcd..c2252da 100644
--- a/types/src/file_agent.rs
+++ b/types/src/file_agent.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use serde::{Deserialize, Serialize};
 use std::path::PathBuf;
 use std::prelude::v1::*;
diff --git a/types/src/lib.rs b/types/src/lib.rs
index 13ecacf..701bd6e 100644
--- a/types/src/lib.rs
+++ b/types/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![cfg_attr(feature = "mesalock_sgx", no_std)]
 #[cfg(feature = "mesalock_sgx")]
 #[macro_use]
diff --git a/types/src/macros.rs b/types/src/macros.rs
index db59a38..26c38e8 100644
--- a/types/src/macros.rs
+++ b/types/src/macros.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #[macro_export]
 macro_rules! hashmap {
     ($( $key: expr => $value: expr,)+) => { hashmap!($($key => $value),+) };
diff --git a/types/src/staged_file.rs b/types/src/staged_file.rs
index b591b64..887a94d 100644
--- a/types/src/staged_file.rs
+++ b/types/src/staged_file.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::{TeaclaveFileCryptoInfo, TeaclaveFileRootKey128};
 
 use std::collections::HashMap;
diff --git a/types/src/staged_function.rs b/types/src/staged_function.rs
index 8048e14..40d0605 100644
--- a/types/src/staged_function.rs
+++ b/types/src/staged_function.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::{ExecutorType, StagedFiles, StagedInputFile, StagedOutputFile};
 
 use serde::{Deserialize, Serialize};
diff --git a/types/src/staged_task.rs b/types/src/staged_task.rs
index f3636a8..1c03895 100644
--- a/types/src/staged_task.rs
+++ b/types/src/staged_task.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::collections::HashMap;
 use std::prelude::v1::*;
 
diff --git a/types/src/storage.rs b/types/src/storage.rs
index 778681e..71f8e1c 100644
--- a/types/src/storage.rs
+++ b/types/src/storage.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow;
 use serde::{Deserialize, Serialize};
 use serde_json;
diff --git a/types/src/task.rs b/types/src/task.rs
index 8d08a4d..a16a5e2 100644
--- a/types/src/task.rs
+++ b/types/src/task.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use crate::FunctionArguments;
 use crate::Storable;
 use serde::{Deserialize, Serialize};
diff --git a/types/src/worker.rs b/types/src/worker.rs
index ddcc952..b498bfd 100644
--- a/types/src/worker.rs
+++ b/types/src/worker.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use std::collections::HashMap;
 use std::collections::HashSet;
 use std::prelude::v1::*;
diff --git a/utils/service_app_utils/src/lib.rs b/utils/service_app_utils/src/lib.rs
index 1202dd1..b9024b8 100644
--- a/utils/service_app_utils/src/lib.rs
+++ b/utils/service_app_utils/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 use anyhow::Result;
 use log::{error, info};
 use std::sync::Arc;
diff --git a/utils/service_enclave_utils/proc_macro/src/lib.rs b/utils/service_enclave_utils/proc_macro/src/lib.rs
index 1eb8fbe..2467c89 100644
--- a/utils/service_enclave_utils/proc_macro/src/lib.rs
+++ b/utils/service_enclave_utils/proc_macro/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 extern crate proc_macro;
 use proc_macro2::{Ident, Span};
 use quote::quote;
diff --git a/utils/service_enclave_utils/src/lib.rs b/utils/service_enclave_utils/src/lib.rs
index eb2bcd9..6413474 100644
--- a/utils/service_enclave_utils/src/lib.rs
+++ b/utils/service_enclave_utils/src/lib.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #![cfg_attr(feature = "mesalock_sgx", no_std)]
 #[cfg(feature = "mesalock_sgx")]
 #[macro_use]
diff --git a/worker/src/function/context.rs b/worker/src/function/context.rs
index 7510858..b30ab01 100644
--- a/worker/src/function/context.rs
+++ b/worker/src/function/context.rs
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
 #[cfg(feature = "mesalock_sgx")]
 use std::prelude::v1::*;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 01/03: [rustfmt] Set use_field_init_shorthand to true

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit adf9a4e4cdabbfb671cce1e1d272a533f6c1de36
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Sun Mar 22 13:26:51 2020 -0700

    [rustfmt] Set use_field_init_shorthand to true
---
 .rustfmt.toml                                 |  3 ++-
 common/rusty_leveldb_sgx/src/block.rs         |  2 +-
 common/rusty_leveldb_sgx/src/block_builder.rs |  2 +-
 common/rusty_leveldb_sgx/src/blockhandle.rs   |  5 +----
 common/rusty_leveldb_sgx/src/db_impl.rs       |  6 +++---
 common/rusty_leveldb_sgx/src/db_iter.rs       |  8 ++++----
 common/rusty_leveldb_sgx/src/error.rs         |  5 +----
 common/rusty_leveldb_sgx/src/filter.rs        |  5 +----
 common/rusty_leveldb_sgx/src/key_types.rs     |  2 +-
 common/rusty_leveldb_sgx/src/log.rs           |  4 ++--
 common/rusty_leveldb_sgx/src/merging_iter.rs  |  4 ++--
 common/rusty_leveldb_sgx/src/skipmap.rs       |  4 ++--
 common/rusty_leveldb_sgx/src/snapshot.rs      |  2 +-
 common/rusty_leveldb_sgx/src/table_builder.rs |  4 ++--
 common/rusty_leveldb_sgx/src/table_reader.rs  | 10 +++++-----
 common/rusty_leveldb_sgx/src/version.rs       |  6 +++---
 common/rusty_leveldb_sgx/src/version_edit.rs  | 16 +++++++---------
 common/rusty_leveldb_sgx/src/version_set.rs   |  6 +++---
 18 files changed, 42 insertions(+), 52 deletions(-)

diff --git a/.rustfmt.toml b/.rustfmt.toml
index c51666e..80eeb40 100644
--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -1 +1,2 @@
-edition = "2018"
\ No newline at end of file
+edition = "2018"
+use_field_init_shorthand = true
diff --git a/common/rusty_leveldb_sgx/src/block.rs b/common/rusty_leveldb_sgx/src/block.rs
index 487cb60..0eca3a9 100644
--- a/common/rusty_leveldb_sgx/src/block.rs
+++ b/common/rusty_leveldb_sgx/src/block.rs
@@ -69,7 +69,7 @@ impl Block {
         assert!(contents.len() > 4);
         Block {
             block: Rc::new(contents),
-            opt: opt,
+            opt,
         }
     }
 }
diff --git a/common/rusty_leveldb_sgx/src/block_builder.rs b/common/rusty_leveldb_sgx/src/block_builder.rs
index ce0c686..cd00aee 100644
--- a/common/rusty_leveldb_sgx/src/block_builder.rs
+++ b/common/rusty_leveldb_sgx/src/block_builder.rs
@@ -28,7 +28,7 @@ impl BlockBuilder {
         BlockBuilder {
             buffer: Vec::with_capacity(o.block_size),
             opt: o,
-            restarts: restarts,
+            restarts,
             last_key: Vec::new(),
             restart_counter: 0,
             counter: 0,
diff --git a/common/rusty_leveldb_sgx/src/blockhandle.rs b/common/rusty_leveldb_sgx/src/blockhandle.rs
index 36fee2b..10b0152 100644
--- a/common/rusty_leveldb_sgx/src/blockhandle.rs
+++ b/common/rusty_leveldb_sgx/src/blockhandle.rs
@@ -27,10 +27,7 @@ impl BlockHandle {
     }
 
     pub fn new(offset: usize, size: usize) -> BlockHandle {
-        BlockHandle {
-            offset: offset,
-            size: size,
-        }
+        BlockHandle { offset, size }
     }
 
     pub fn offset(&self) -> usize {
diff --git a/common/rusty_leveldb_sgx/src/db_impl.rs b/common/rusty_leveldb_sgx/src/db_impl.rs
index 50ccc92..7a56758 100644
--- a/common/rusty_leveldb_sgx/src/db_impl.rs
+++ b/common/rusty_leveldb_sgx/src/db_impl.rs
@@ -84,7 +84,7 @@ impl DB {
 
         DB {
             name: name.to_owned(),
-            path: path,
+            path,
             lock: None,
             internal_cmp: Rc::new(Box::new(InternalKeyCmp(opt.cmp.clone()))),
             fpol: InternalFilterPolicy::new(opt.filter_policy.clone()),
@@ -92,11 +92,11 @@ impl DB {
             mem: MemTable::new(opt.cmp.clone()),
             imm: None,
 
-            opt: opt,
+            opt,
 
             log: None,
             log_num: None,
-            cache: cache,
+            cache,
             vset: share(vset),
             snaps: SnapshotList::new(),
 
diff --git a/common/rusty_leveldb_sgx/src/db_iter.rs b/common/rusty_leveldb_sgx/src/db_iter.rs
index ff5b9ff..392a93b 100644
--- a/common/rusty_leveldb_sgx/src/db_iter.rs
+++ b/common/rusty_leveldb_sgx/src/db_iter.rs
@@ -45,10 +45,10 @@ impl DBIterator {
         ss: Snapshot,
     ) -> DBIterator {
         DBIterator {
-            cmp: cmp,
-            vset: vset,
-            iter: iter,
-            ss: ss,
+            cmp,
+            vset,
+            iter,
+            ss,
             dir: Direction::Forward,
             byte_count: random_period(),
 
diff --git a/common/rusty_leveldb_sgx/src/error.rs b/common/rusty_leveldb_sgx/src/error.rs
index 6a6fbb5..3f55bf9 100644
--- a/common/rusty_leveldb_sgx/src/error.rs
+++ b/common/rusty_leveldb_sgx/src/error.rs
@@ -68,10 +68,7 @@ impl Status {
         } else {
             err = format!("{:?}: {}", code, msg);
         }
-        return Status {
-            code: code,
-            err: err,
-        };
+        return Status { code, err };
     }
 }
 
diff --git a/common/rusty_leveldb_sgx/src/filter.rs b/common/rusty_leveldb_sgx/src/filter.rs
index a7c5371..1e276a2 100644
--- a/common/rusty_leveldb_sgx/src/filter.rs
+++ b/common/rusty_leveldb_sgx/src/filter.rs
@@ -82,10 +82,7 @@ impl BloomPolicy {
             k = 30;
         }
 
-        BloomPolicy {
-            bits_per_key: bits_per_key,
-            k: k,
-        }
+        BloomPolicy { bits_per_key, k }
     }
 
     fn bloom_hash(&self, data: &[u8]) -> u32 {
diff --git a/common/rusty_leveldb_sgx/src/key_types.rs b/common/rusty_leveldb_sgx/src/key_types.rs
index 00219f8..3e6481f 100644
--- a/common/rusty_leveldb_sgx/src/key_types.rs
+++ b/common/rusty_leveldb_sgx/src/key_types.rs
@@ -68,7 +68,7 @@ impl LookupKey {
         }
 
         LookupKey {
-            key: key,
+            key,
             key_offset: internal_keylen.required_space(),
         }
     }
diff --git a/common/rusty_leveldb_sgx/src/log.rs b/common/rusty_leveldb_sgx/src/log.rs
index 75eb554..9c5faa2 100644
--- a/common/rusty_leveldb_sgx/src/log.rs
+++ b/common/rusty_leveldb_sgx/src/log.rs
@@ -39,7 +39,7 @@ impl<W: Write> LogWriter<W> {
             dst: writer,
             current_block_offset: 0,
             block_size: BLOCK_SIZE,
-            digest: digest,
+            digest,
         }
     }
 
@@ -131,7 +131,7 @@ pub struct LogReader<R: Read> {
 impl<R: Read> LogReader<R> {
     pub fn new(src: R, chksum: bool) -> LogReader<R> {
         LogReader {
-            src: src,
+            src,
             blk_off: 0,
             blocksize: BLOCK_SIZE,
             checksums: chksum,
diff --git a/common/rusty_leveldb_sgx/src/merging_iter.rs b/common/rusty_leveldb_sgx/src/merging_iter.rs
index af90393..6c20ba3 100644
--- a/common/rusty_leveldb_sgx/src/merging_iter.rs
+++ b/common/rusty_leveldb_sgx/src/merging_iter.rs
@@ -30,10 +30,10 @@ impl MergingIter {
     /// Construct a new merging iterator.
     pub fn new(cmp: Rc<Box<dyn Cmp>>, iters: Vec<Box<dyn LdbIterator>>) -> MergingIter {
         let mi = MergingIter {
-            iters: iters,
+            iters,
             current: None,
             direction: Direction::Forward,
-            cmp: cmp,
+            cmp,
         };
         mi
     }
diff --git a/common/rusty_leveldb_sgx/src/skipmap.rs b/common/rusty_leveldb_sgx/src/skipmap.rs
index 34bc704..9976bd9 100644
--- a/common/rusty_leveldb_sgx/src/skipmap.rs
+++ b/common/rusty_leveldb_sgx/src/skipmap.rs
@@ -62,7 +62,7 @@ impl SkipMap {
                 rand: StdRng::seed_from_u64(0xdeadbeef),
                 len: 0,
                 approx_mem: size_of::<Self>() + MAX_HEIGHT * size_of::<Option<*mut Node>>(),
-                cmp: cmp,
+                cmp,
             })),
         }
     }
@@ -241,7 +241,7 @@ impl InnerSkipMap {
         let mut new = Box::new(Node {
             skips: new_skips,
             next: None,
-            key: key,
+            key,
             value: val,
         });
         let newp = new.as_mut() as *mut Node;
diff --git a/common/rusty_leveldb_sgx/src/snapshot.rs b/common/rusty_leveldb_sgx/src/snapshot.rs
index 1577d57..395f714 100644
--- a/common/rusty_leveldb_sgx/src/snapshot.rs
+++ b/common/rusty_leveldb_sgx/src/snapshot.rs
@@ -69,7 +69,7 @@ impl SnapshotList {
         Snapshot {
             inner: Rc::new(InnerSnapshot {
                 id: sl.newest,
-                seq: seq,
+                seq,
                 sl: inner,
             }),
         }
diff --git a/common/rusty_leveldb_sgx/src/table_builder.rs b/common/rusty_leveldb_sgx/src/table_builder.rs
index 4313757..ebaf515 100644
--- a/common/rusty_leveldb_sgx/src/table_builder.rs
+++ b/common/rusty_leveldb_sgx/src/table_builder.rs
@@ -44,7 +44,7 @@ impl Footer {
     pub fn new(metaix: BlockHandle, index: BlockHandle) -> Footer {
         Footer {
             meta_index: metaix,
-            index: index,
+            index,
         }
     }
 
@@ -120,7 +120,7 @@ impl<Dst: Write> TableBuilder<Dst> {
     pub fn new_raw(opt: Options, dst: Dst) -> TableBuilder<Dst> {
         TableBuilder {
             opt: opt.clone(),
-            dst: dst,
+            dst,
             offset: 0,
             prev_block_last_key: vec![],
             num_entries: 0,
diff --git a/common/rusty_leveldb_sgx/src/table_reader.rs b/common/rusty_leveldb_sgx/src/table_reader.rs
index 0e61819..cd87d87 100644
--- a/common/rusty_leveldb_sgx/src/table_reader.rs
+++ b/common/rusty_leveldb_sgx/src/table_reader.rs
@@ -54,13 +54,13 @@ impl Table {
         let cache_id = opt.block_cache.borrow_mut().new_cache_id();
 
         Ok(Table {
-            file: file,
+            file,
             file_size: size,
-            cache_id: cache_id,
-            opt: opt,
-            footer: footer,
+            cache_id,
+            opt,
+            footer,
             filters: filter_block_reader,
-            indexblock: indexblock,
+            indexblock,
         })
     }
 
diff --git a/common/rusty_leveldb_sgx/src/version.rs b/common/rusty_leveldb_sgx/src/version.rs
index 0564373..171890e 100644
--- a/common/rusty_leveldb_sgx/src/version.rs
+++ b/common/rusty_leveldb_sgx/src/version.rs
@@ -392,8 +392,8 @@ pub fn new_version_iter(
     ucmp: Rc<Box<dyn Cmp>>,
 ) -> VersionIter {
     VersionIter {
-        files: files,
-        cache: cache,
+        files,
+        cache,
         cmp: InternalKeyCmp(ucmp),
         current: None,
         current_ix: 0,
@@ -596,7 +596,7 @@ pub mod testutil {
         share(FileMetaData {
             allowed_seeks: 10,
             size: 163840,
-            num: num,
+            num,
             smallest: LookupKey::new(smallest, smallestix).internal_key().to_vec(),
             largest: LookupKey::new(largest, largestix).internal_key().to_vec(),
         })
diff --git a/common/rusty_leveldb_sgx/src/version_edit.rs b/common/rusty_leveldb_sgx/src/version_edit.rs
index fd6f159..860b2dc 100644
--- a/common/rusty_leveldb_sgx/src/version_edit.rs
+++ b/common/rusty_leveldb_sgx/src/version_edit.rs
@@ -121,7 +121,7 @@ impl VersionEdit {
 
     pub fn set_compact_pointer(&mut self, level: usize, key: InternalKey) {
         self.compaction_ptrs.push(CompactionPointer {
-            level: level,
+            level,
             key: Vec::from(key),
         })
     }
@@ -239,10 +239,8 @@ impl VersionEdit {
                         if let Ok(lvl) = reader.read_varint() {
                             let key = read_length_prefixed(&mut reader)?;
 
-                            ve.compaction_ptrs.push(CompactionPointer {
-                                level: lvl,
-                                key: key,
-                            });
+                            ve.compaction_ptrs
+                                .push(CompactionPointer { level: lvl, key });
                         } else {
                             return err(StatusCode::IOError, "Couldn't read level");
                         }
@@ -269,10 +267,10 @@ impl VersionEdit {
                                     ve.new_files.push((
                                         lvl,
                                         FileMetaData {
-                                            num: num,
-                                            size: size,
-                                            smallest: smallest,
-                                            largest: largest,
+                                            num,
+                                            size,
+                                            smallest,
+                                            largest,
                                             allowed_seeks: 0,
                                         },
                                     ))
diff --git a/common/rusty_leveldb_sgx/src/version_set.rs b/common/rusty_leveldb_sgx/src/version_set.rs
index 6d61297..21976e0 100644
--- a/common/rusty_leveldb_sgx/src/version_set.rs
+++ b/common/rusty_leveldb_sgx/src/version_set.rs
@@ -47,7 +47,7 @@ impl Compaction {
     // Note: opt.cmp should be the user-supplied or default comparator (not an InternalKeyCmp).
     pub fn new(opt: &Options, level: usize, input: Option<Shared<Version>>) -> Compaction {
         Compaction {
-            level: level,
+            level,
             max_file_size: opt.max_file_size,
             input_version: input,
             level_ixs: Default::default(),
@@ -195,8 +195,8 @@ impl VersionSet {
         VersionSet {
             dbname: db.as_ref().to_owned(),
             cmp: InternalKeyCmp(opt.cmp.clone()),
-            opt: opt,
-            cache: cache,
+            opt,
+            cache,
 
             next_file_num: 2,
             manifest_num: 0,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org