diff --git a/tee-worker/Cargo.lock b/tee-worker/Cargo.lock index a2ba0495f2..42209161ac 100644 --- a/tee-worker/Cargo.lock +++ b/tee-worker/Cargo.lock @@ -1018,6 +1018,16 @@ dependencies = [ "thiserror 1.0.44", ] +[[package]] +name = "cargo_toml" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3f9629bc6c4388ea699781dc988c2b99766d7679b151c81990b4fa1208fafd3" +dependencies = [ + "serde 1.0.175", + "toml 0.8.0", +] + [[package]] name = "cc" version = "1.0.79" @@ -1368,7 +1378,7 @@ dependencies = [ "rust-ini", "serde 1.0.175", "serde_json 1.0.103", - "toml", + "toml 0.5.11", "yaml-rust 0.4.5", ] @@ -6844,6 +6854,14 @@ dependencies = [ "thiserror 1.0.44", ] +[[package]] +name = "litentry-macros" +version = "0.1.0" +dependencies = [ + "cargo_toml", + "quote", +] + [[package]] name = "litentry-primitives" version = "0.1.0" @@ -11050,7 +11068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell 1.18.0", - "toml_edit", + "toml_edit 0.19.14", ] [[package]] @@ -11292,9 +11310,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -13633,6 +13651,15 @@ dependencies = [ "serde 1.0.175", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde 1.0.175", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -15145,7 +15172,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum 0.24.1", "tempfile", - "toml", + "toml 0.5.11", "walkdir", "wasm-opt", ] @@ -15622,11 +15649,26 @@ dependencies = [ "serde 1.0.175", ] +[[package]] +name = "toml" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +dependencies = [ + "serde 1.0.175", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.0", +] + [[package]] name = "toml_datetime" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde 1.0.175", +] [[package]] name = "toml_edit" @@ -15639,6 +15681,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +dependencies = [ + "indexmap 2.0.0", + "serde 1.0.175", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -16569,7 +16624,7 @@ dependencies = [ "rustix 0.36.15", "serde 1.0.175", "sha2 0.10.7", - "toml", + "toml 0.5.11", "windows-sys 0.42.0", "zstd", ] diff --git a/tee-worker/Cargo.toml b/tee-worker/Cargo.toml index a6c3157862..dc3e2bc90b 100644 --- a/tee-worker/Cargo.toml +++ b/tee-worker/Cargo.toml @@ -69,6 +69,7 @@ members = [ "sidechain/state", "sidechain/validateer-fetch", "litentry/primitives", + "litentry/macros", "litentry/pallets/identity-management", "litentry/core/stf-task/sender", "litentry/core/stf-task/receiver", diff --git a/tee-worker/enclave-runtime/Cargo.lock b/tee-worker/enclave-runtime/Cargo.lock index 0f9ccbeda0..fab908ec52 100644 --- a/tee-worker/enclave-runtime/Cargo.lock +++ b/tee-worker/enclave-runtime/Cargo.lock @@ -189,7 +189,7 @@ checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -437,6 +437,16 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[package]] +name = "cargo_toml" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3f9629bc6c4388ea699781dc988c2b99766d7679b151c81990b4fa1208fafd3" +dependencies = [ + "serde 1.0.175", + "toml", +] + [[package]] name = "cc" version = "1.0.79" @@ -621,7 +631,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -633,7 +643,7 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "rustc_version", "syn 1.0.109", ] @@ -736,11 +746,13 @@ dependencies = [ "itc-direct-rpc-server", "itc-offchain-worker-executor", "itc-parentchain", + "itc-parentchain-indirect-calls-executor", "itc-parentchain-test", "itc-tls-websocket-server", "itp-attestation-handler", "itp-component-container", "itp-extrinsics-factory", + "itp-hashing", "itp-import-queue", "itp-node-api", "itp-node-api-metadata", @@ -751,6 +763,7 @@ dependencies = [ "itp-settings", "itp-sgx-crypto", "itp-sgx-externalities", + "itp-sgx-io", "itp-sgx-temp-dir", "itp-stf-executor", "itp-stf-interface", @@ -758,6 +771,7 @@ dependencies = [ "itp-stf-state-handler", "itp-stf-state-observer", "itp-storage", + "itp-teerex-storage", "itp-test", "itp-time-utils", "itp-top-pool", @@ -772,6 +786,8 @@ dependencies = [ "lc-data-providers", "lc-scheduled-enclave", "lc-stf-task-receiver", + "lc-stf-task-sender", + "litentry-macros", "litentry-primitives", "log", "multibase", @@ -780,6 +796,8 @@ dependencies = [ "primitive-types", "rust-base58 0.0.4 (git+https://github.com/mesalock-linux/rust-base58-sgx?rev=sgx_1.1.3)", "rustls 0.19.0 (git+https://github.com/mesalock-linux/rustls?rev=sgx_1.1.3)", + "serde 1.0.118 (git+https://github.com/mesalock-linux/serde-sgx?tag=sgx_1.1.3)", + "serde_derive 1.0.118", "serde_json 1.0.60 (git+https://github.com/mesalock-linux/serde-json-sgx?tag=sgx_1.1.3)", "sgx_rand", "sgx_serialize", @@ -794,6 +812,7 @@ dependencies = [ "sgx_types", "sp-core", "sp-runtime", + "sp-std", "webpki", ] @@ -1082,7 +1101,7 @@ dependencies = [ "frame-support-procedural-tools", "itertools 0.10.5", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -1094,7 +1113,7 @@ dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -1104,7 +1123,7 @@ version = "3.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -1226,7 +1245,7 @@ source = "git+https://github.com/mesalock-linux/futures-rs-sgx#d54882f24ddf7d613 dependencies = [ "proc-macro-hack", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -1512,7 +1531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -2757,6 +2776,14 @@ dependencies = [ "sgx_tstd", ] +[[package]] +name = "litentry-macros" +version = "0.1.0" +dependencies = [ + "cargo_toml", + "quote 1.0.33", +] + [[package]] name = "litentry-primitives" version = "0.1.0" @@ -2948,7 +2975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3172,7 +3199,7 @@ checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" dependencies = [ "proc-macro-crate", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3252,7 +3279,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell 1.18.0", - "toml_edit", + "toml_edit 0.19.14", ] [[package]] @@ -3263,7 +3290,7 @@ checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", "version_check", ] @@ -3275,7 +3302,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "version_check", ] @@ -3316,7 +3343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3342,9 +3369,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -3434,7 +3461,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 2.0.27", ] @@ -3560,7 +3587,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a169f6bc5a81033e86ed39d0f4150e2608160b73d2b93c6e8e6a3efa873f14" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3582,7 +3609,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3692,7 +3719,7 @@ checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3809,7 +3836,7 @@ version = "1.0.118" source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -3820,7 +3847,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23f7ade6f110613c0d63858ddb8b94c1041f550eab58a16b371bdf2c9c80ab4" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 2.0.27", ] @@ -3858,6 +3885,15 @@ dependencies = [ "serde 1.0.175", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde 1.0.175", +] + [[package]] name = "sgx_alloc" version = "1.1.6" @@ -4173,7 +4209,7 @@ dependencies = [ "blake2", "proc-macro-crate", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -4263,7 +4299,7 @@ version = "5.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "sp-core-hashing", "syn 1.0.109", ] @@ -4274,7 +4310,7 @@ version = "5.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -4375,7 +4411,7 @@ dependencies = [ "Inflector", "proc-macro-crate", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -4464,7 +4500,7 @@ source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3 dependencies = [ "parity-scale-codec", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -4506,7 +4542,7 @@ checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" dependencies = [ "Inflector", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "serde 1.0.175", "serde_json 1.0.103", "unicode-xid 0.2.4", @@ -4532,7 +4568,7 @@ checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "rustversion", "syn 2.0.27", ] @@ -4591,7 +4627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "unicode-ident", ] @@ -4602,7 +4638,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "unicode-ident", ] @@ -4644,7 +4680,7 @@ version = "1.0.9" source = "git+https://github.com/mesalock-linux/thiserror-sgx?tag=sgx_1.1.3#c2f806b88616e06aab0af770366a76885d974fdc" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -4674,11 +4710,26 @@ dependencies = [ "crunchy", ] +[[package]] +name = "toml" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +dependencies = [ + "serde 1.0.175", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.0", +] + [[package]] name = "toml_datetime" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde 1.0.175", +] [[package]] name = "toml_edit" @@ -4691,6 +4742,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +dependencies = [ + "indexmap 2.0.0", + "serde 1.0.175", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" version = "0.1.37" @@ -4906,7 +4970,7 @@ dependencies = [ "log", "once_cell 1.18.0", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 2.0.27", "wasm-bindgen-shared", ] @@ -4917,7 +4981,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ - "quote 1.0.32", + "quote 1.0.33", "wasm-bindgen-macro-support", ] @@ -4928,7 +4992,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 2.0.27", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -5093,6 +5157,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 2.0.27", ] diff --git a/tee-worker/enclave-runtime/Cargo.toml b/tee-worker/enclave-runtime/Cargo.toml index 75272672ea..50653733d2 100644 --- a/tee-worker/enclave-runtime/Cargo.toml +++ b/tee-worker/enclave-runtime/Cargo.toml @@ -79,6 +79,8 @@ log = { git = "https://github.com/integritee-network/log-sgx" } # Todo #1313: use the `once_cell` included in rusts core library once we use rust v1.70.0 once_cell = { git = "https://github.com/mesalock-linux/once_cell-sgx" } rustls = { rev = "sgx_1.1.3", features = ["dangerous_configuration"], git = "https://github.com/mesalock-linux/rustls" } +serde = { tag = "sgx_1.1.3", git = "https://github.com/mesalock-linux/serde-sgx", features = ["alloc", "mesalock_sgx"] } +serde_derive = { git = "https://github.com/mesalock-linux/serde-sgx" } serde_json = { tag = "sgx_1.1.3", git = "https://github.com/mesalock-linux/serde-json-sgx" } webpki = { git = "https://github.com/mesalock-linux/webpki", branch = "mesalock_sgx" } @@ -100,6 +102,7 @@ itc-tls-websocket-server = { path = "../core/tls-websocket-server", default-feat itp-attestation-handler = { path = "../core-primitives/attestation-handler", default-features = false, features = ["sgx"] } itp-component-container = { path = "../core-primitives/component-container", default-features = false, features = ["sgx"] } itp-extrinsics-factory = { path = "../core-primitives/extrinsics-factory", default-features = false, features = ["sgx"] } +itp-hashing = { path = "../core-primitives/hashing", default-features = false } itp-import-queue = { path = "../core-primitives/import-queue", default-features = false, features = ["sgx"] } itp-node-api = { path = "../core-primitives/node-api", default-features = false, features = ["sgx"] } itp-node-api-metadata = { path = "../core-primitives/node-api/metadata", default-features = false } @@ -110,12 +113,14 @@ itp-rpc = { path = "../core-primitives/rpc", default-features = false, features itp-settings = { path = "../core-primitives/settings" } itp-sgx-crypto = { path = "../core-primitives/sgx/crypto", default-features = false, features = ["sgx"] } itp-sgx-externalities = { path = "../core-primitives/substrate-sgx/externalities", default-features = false, features = ["sgx"] } +itp-sgx-io = { path = "../core-primitives/sgx/io", default-features = false, features = ["sgx"] } itp-stf-executor = { path = "../core-primitives/stf-executor", default-features = false, features = ["sgx"] } itp-stf-interface = { path = "../core-primitives/stf-interface", default-features = false } itp-stf-primitives = { path = "../core-primitives/stf-primitives", default-features = false } itp-stf-state-handler = { path = "../core-primitives/stf-state-handler", default-features = false, features = ["sgx"] } itp-stf-state-observer = { path = "../core-primitives/stf-state-observer", default-features = false, features = ["sgx"] } itp-storage = { path = "../core-primitives/storage", default-features = false, features = ["sgx"] } +itp-teerex-storage = { path = "../core-primitives/teerex-storage", default-features = false } itp-test = { path = "../core-primitives/test", default-features = false, optional = true } itp-time-utils = { path = "../core-primitives/time-utils", default-features = false, features = ["sgx"] } itp-top-pool = { path = "../core-primitives/top-pool", default-features = false, features = ["sgx"] } @@ -127,9 +132,12 @@ its-primitives = { path = "../sidechain/primitives", default-features = false } its-sidechain = { path = "../sidechain/sidechain-crate", default-features = false, features = ["sgx"] } # litentry +itc-parentchain-indirect-calls-executor = { path = "../core/parentchain/indirect-calls-executor", default-features = false } lc-data-providers = { path = "../litentry/core/data-providers", default-features = false, features = ["sgx"] } lc-scheduled-enclave = { path = "../litentry/core/scheduled-enclave", default-features = false, features = ["sgx"] } lc-stf-task-receiver = { path = "../litentry/core/stf-task/receiver", default-features = false, features = ["sgx"] } +lc-stf-task-sender = { path = "../litentry/core/stf-task/sender", default-features = false, features = ["sgx"] } +litentry-macros = { path = "../litentry/macros" } litentry-primitives = { path = "../litentry/primitives", default-features = false, features = ["sgx"] } # substrate deps @@ -137,6 +145,7 @@ frame-support = { default-features = false, git = "https://github.com/paritytech frame-system = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" } sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" } # test-deps itp-sgx-temp-dir = { version = "0.1", default-features = false, optional = true, path = "../core-primitives/sgx/temp-dir" } diff --git a/tee-worker/enclave-runtime/src/lib.rs b/tee-worker/enclave-runtime/src/lib.rs index c74c468c40..8cf5e5c830 100644 --- a/tee-worker/enclave-runtime/src/lib.rs +++ b/tee-worker/enclave-runtime/src/lib.rs @@ -127,7 +127,19 @@ pub unsafe extern "C" fn init( ) -> sgx_status_t { // Initialize the logging environment in the enclave. if_production_or!( - env_logger::Builder::new().filter(None, LevelFilter::Info).init(), + { + let module_names = litentry_macros::local_modules!(); + println!( + "Initializing logger to filter only following local modules: {:?}", + module_names + ); + let mut builder = env_logger::Builder::new(); + builder.filter(None, LevelFilter::Off); + module_names.into_iter().for_each(|module| { + builder.filter(Some(module), LevelFilter::Info); + }); + builder.init(); + }, env_logger::init() ); diff --git a/tee-worker/litentry/macros/Cargo.toml b/tee-worker/litentry/macros/Cargo.toml new file mode 100644 index 0000000000..c3039927e1 --- /dev/null +++ b/tee-worker/litentry/macros/Cargo.toml @@ -0,0 +1,12 @@ +[package] +authors = ["Trust Computing GmbH "] +name = "litentry-macros" +version = "0.1.0" +edition = "2021" + +[dependencies] +cargo_toml = "0.16.3" +quote = "1.0.33" + +[lib] +proc-macro = true diff --git a/tee-worker/litentry/macros/src/lib.rs b/tee-worker/litentry/macros/src/lib.rs new file mode 100644 index 0000000000..b57ac19473 --- /dev/null +++ b/tee-worker/litentry/macros/src/lib.rs @@ -0,0 +1,59 @@ +// Copyright 2020-2023 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +use cargo_toml::{Dependency, Manifest}; +use proc_macro::TokenStream; +use quote::quote; +use std::fs; + +#[proc_macro] +pub fn local_modules(_item: TokenStream) -> TokenStream { + let mut deps: Vec = vec![]; + read_module_names("", ".", &mut deps); + let output = quote! { + { + let deps: Vec<&str> = vec![ + #(#deps),* + ]; + deps + } + }; + output.into() +} + +fn read_module_names(path: &str, relative_to: &str, module_names: &mut Vec) { + let current_path = relative_to.to_string() + "/" + path; + let cargo_file = current_path.to_string() + "/Cargo.toml"; + let contents = fs::read_to_string(&cargo_file) + .unwrap_or_else(|_| panic!("Should have been able to read the file: {}", cargo_file)); + let manifest = Manifest::from_str(&contents) + .unwrap_or_else(|_| panic!("Could not parse manifest file locate at {}", cargo_file)); + if let Some(package) = manifest.package { + let module_name = package.name.replace('-', "_"); + // skip package if it is unnamed or it was already visited + if !package.name.is_empty() && !module_names.contains(&module_name) { + module_names.push(module_name); + // go through all dependencies and visit the ones that has `path`, which means they are local + manifest.dependencies.values().for_each(|dep| { + if let Dependency::Detailed(details) = dep { + if let Some(path) = &details.path { + read_module_names(path, ¤t_path, module_names) + } + } + }); + } + } +}